aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorPaul Moore <paul.moore@hp.com>2006-09-25 18:56:09 -0400
committerDavid S. Miller <davem@davemloft.net>2006-09-25 18:56:09 -0400
commitfcd48280643e92ec6cb29a04e9079dd7b6b5bfef (patch)
treec594e16a021262e97f8b41493529c95bd616529e /include/net
parent4fe5d5c07ab615a52fd1b0ceba5aeed7c612821a (diff)
[NetLabel]: rework the Netlink attribute handling (part 1)
At the suggestion of Thomas Graf, rewrite NetLabel's use of Netlink attributes to better follow the common Netlink attribute usage. Signed-off-by: Paul Moore <paul.moore@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/cipso_ipv4.h16
-rw-r--r--include/net/netlabel.h49
2 files changed, 9 insertions, 56 deletions
diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index 6718452a5cd0..2d72496c2029 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -130,8 +130,9 @@ extern int cipso_v4_rbm_strictvalid;
130int cipso_v4_doi_add(struct cipso_v4_doi *doi_def); 130int cipso_v4_doi_add(struct cipso_v4_doi *doi_def);
131int cipso_v4_doi_remove(u32 doi, void (*callback) (struct rcu_head * head)); 131int cipso_v4_doi_remove(u32 doi, void (*callback) (struct rcu_head * head));
132struct cipso_v4_doi *cipso_v4_doi_getdef(u32 doi); 132struct cipso_v4_doi *cipso_v4_doi_getdef(u32 doi);
133struct sk_buff *cipso_v4_doi_dump_all(size_t headroom); 133int cipso_v4_doi_walk(u32 *skip_cnt,
134struct sk_buff *cipso_v4_doi_dump(u32 doi, size_t headroom); 134 int (*callback) (struct cipso_v4_doi *doi_def, void *arg),
135 void *cb_arg);
135int cipso_v4_doi_domhsh_add(struct cipso_v4_doi *doi_def, const char *domain); 136int cipso_v4_doi_domhsh_add(struct cipso_v4_doi *doi_def, const char *domain);
136int cipso_v4_doi_domhsh_remove(struct cipso_v4_doi *doi_def, 137int cipso_v4_doi_domhsh_remove(struct cipso_v4_doi *doi_def,
137 const char *domain); 138 const char *domain);
@@ -152,14 +153,11 @@ static inline struct cipso_v4_doi *cipso_v4_doi_getdef(u32 doi)
152 return NULL; 153 return NULL;
153} 154}
154 155
155static inline struct sk_buff *cipso_v4_doi_dump_all(size_t headroom) 156static inline int cipso_v4_doi_walk(u32 *skip_cnt,
157 int (*callback) (struct cipso_v4_doi *doi_def, void *arg),
158 void *cb_arg)
156{ 159{
157 return NULL; 160 return 0;
158}
159
160static inline struct sk_buff *cipso_v4_doi_dump(u32 doi, size_t headroom)
161{
162 return NULL;
163} 161}
164 162
165static inline int cipso_v4_doi_domhsh_add(struct cipso_v4_doi *doi_def, 163static inline int cipso_v4_doi_domhsh_add(struct cipso_v4_doi *doi_def,
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index bf7b564e3540..6692430063fd 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -57,9 +57,8 @@
57 * The payload is dependent on the subsystem specified in the 57 * The payload is dependent on the subsystem specified in the
58 * 'nlmsghdr->nlmsg_type' and should be defined below, supporting functions 58 * 'nlmsghdr->nlmsg_type' and should be defined below, supporting functions
59 * should be defined in the corresponding net/netlabel/netlabel_<subsys>.h|c 59 * should be defined in the corresponding net/netlabel/netlabel_<subsys>.h|c
60 * file. All of the fields in the NetLabel payload are NETLINK attributes, the 60 * file. All of the fields in the NetLabel payload are NETLINK attributes, see
61 * length of each field is the length of the NETLINK attribute payload, see 61 * the include/net/netlink.h file for more information on NETLINK attributes.
62 * include/net/netlink.h for more information on NETLINK attributes.
63 * 62 *
64 */ 63 */
65 64
@@ -82,50 +81,6 @@
82#define NETLBL_NLTYPE_UNLABELED 5 81#define NETLBL_NLTYPE_UNLABELED 5
83#define NETLBL_NLTYPE_UNLABELED_NAME "NLBL_UNLBL" 82#define NETLBL_NLTYPE_UNLABELED_NAME "NLBL_UNLBL"
84 83
85/* NetLabel return codes */
86#define NETLBL_E_OK 0
87
88/*
89 * Helper functions
90 */
91
92#define NETLBL_LEN_U8 nla_total_size(sizeof(u8))
93#define NETLBL_LEN_U16 nla_total_size(sizeof(u16))
94#define NETLBL_LEN_U32 nla_total_size(sizeof(u32))
95
96/**
97 * netlbl_netlink_alloc_skb - Allocate a NETLINK message buffer
98 * @head: the amount of headroom in bytes
99 * @body: the desired size (minus headroom) in bytes
100 * @gfp_flags: the alloc flags to pass to alloc_skb()
101 *
102 * Description:
103 * Allocate a NETLINK message buffer based on the sizes given in @head and
104 * @body. If @head is greater than zero skb_reserve() is called to reserve
105 * @head bytes at the start of the buffer. Returns a valid sk_buff pointer on
106 * success, NULL on failure.
107 *
108 */
109static inline struct sk_buff *netlbl_netlink_alloc_skb(size_t head,
110 size_t body,
111 gfp_t gfp_flags)
112{
113 struct sk_buff *skb;
114
115 skb = alloc_skb(NLMSG_ALIGN(head + body), gfp_flags);
116 if (skb == NULL)
117 return NULL;
118 if (head > 0) {
119 skb_reserve(skb, head);
120 if (skb_tailroom(skb) < body) {
121 kfree_skb(skb);
122 return NULL;
123 }
124 }
125
126 return skb;
127}
128
129/* 84/*
130 * NetLabel - Kernel API for accessing the network packet label mappings. 85 * NetLabel - Kernel API for accessing the network packet label mappings.
131 * 86 *