2 * NetLabel CIPSO/IPv4 Support
4 * This file defines the CIPSO/IPv4 functions for the NetLabel system. The
5 * NetLabel system manages static and dynamic label mappings for network
6 * protocols such as CIPSO and RIPSO.
8 * Author: Paul Moore <paul.moore@hp.com>
13 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
23 * the GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include <linux/types.h>
32 #include <linux/socket.h>
33 #include <linux/string.h>
34 #include <linux/skbuff.h>
35 #include <linux/audit.h>
37 #include <net/netlink.h>
38 #include <net/genetlink.h>
39 #include <net/netlabel.h>
40 #include <net/cipso_ipv4.h>
41 #include <asm/atomic.h>
43 #include "netlabel_user.h"
44 #include "netlabel_cipso_v4.h"
45 #include "netlabel_mgmt.h"
46 #include "netlabel_domainhash.h"
48 /* Argument struct for cipso_v4_doi_walk() */
49 struct netlbl_cipsov4_doiwalk_arg
{
50 struct netlink_callback
*nl_cb
;
55 /* Argument struct for netlbl_domhsh_walk() */
56 struct netlbl_domhsh_walk_arg
{
57 struct netlbl_audit
*audit_info
;
61 /* NetLabel Generic NETLINK CIPSOv4 family */
62 static struct genl_family netlbl_cipsov4_gnl_family
= {
63 .id
= GENL_ID_GENERATE
,
65 .name
= NETLBL_NLTYPE_CIPSOV4_NAME
,
66 .version
= NETLBL_PROTO_VERSION
,
67 .maxattr
= NLBL_CIPSOV4_A_MAX
,
70 /* NetLabel Netlink attribute policy */
71 static const struct nla_policy netlbl_cipsov4_genl_policy
[NLBL_CIPSOV4_A_MAX
+ 1] = {
72 [NLBL_CIPSOV4_A_DOI
] = { .type
= NLA_U32
},
73 [NLBL_CIPSOV4_A_MTYPE
] = { .type
= NLA_U32
},
74 [NLBL_CIPSOV4_A_TAG
] = { .type
= NLA_U8
},
75 [NLBL_CIPSOV4_A_TAGLST
] = { .type
= NLA_NESTED
},
76 [NLBL_CIPSOV4_A_MLSLVLLOC
] = { .type
= NLA_U32
},
77 [NLBL_CIPSOV4_A_MLSLVLREM
] = { .type
= NLA_U32
},
78 [NLBL_CIPSOV4_A_MLSLVL
] = { .type
= NLA_NESTED
},
79 [NLBL_CIPSOV4_A_MLSLVLLST
] = { .type
= NLA_NESTED
},
80 [NLBL_CIPSOV4_A_MLSCATLOC
] = { .type
= NLA_U32
},
81 [NLBL_CIPSOV4_A_MLSCATREM
] = { .type
= NLA_U32
},
82 [NLBL_CIPSOV4_A_MLSCAT
] = { .type
= NLA_NESTED
},
83 [NLBL_CIPSOV4_A_MLSCATLST
] = { .type
= NLA_NESTED
},
91 * netlbl_cipsov4_add_common - Parse the common sections of a ADD message
92 * @info: the Generic NETLINK info block
93 * @doi_def: the CIPSO V4 DOI definition
96 * Parse the common sections of a ADD message and fill in the related values
97 * in @doi_def. Returns zero on success, negative values on failure.
100 static int netlbl_cipsov4_add_common(struct genl_info
*info
,
101 struct cipso_v4_doi
*doi_def
)
107 doi_def
->doi
= nla_get_u32(info
->attrs
[NLBL_CIPSOV4_A_DOI
]);
109 if (nla_validate_nested(info
->attrs
[NLBL_CIPSOV4_A_TAGLST
],
111 netlbl_cipsov4_genl_policy
) != 0)
114 nla_for_each_nested(nla
, info
->attrs
[NLBL_CIPSOV4_A_TAGLST
], nla_rem
)
115 if (nla_type(nla
) == NLBL_CIPSOV4_A_TAG
) {
116 if (iter
>= CIPSO_V4_TAG_MAXCNT
)
118 doi_def
->tags
[iter
++] = nla_get_u8(nla
);
120 while (iter
< CIPSO_V4_TAG_MAXCNT
)
121 doi_def
->tags
[iter
++] = CIPSO_V4_TAG_INVALID
;
127 * NetLabel Command Handlers
131 * netlbl_cipsov4_add_std - Adds a CIPSO V4 DOI definition
132 * @info: the Generic NETLINK info block
133 * @audit_info: NetLabel audit information
136 * Create a new CIPSO_V4_MAP_TRANS DOI definition based on the given ADD
137 * message and add it to the CIPSO V4 engine. Return zero on success and
141 static int netlbl_cipsov4_add_std(struct genl_info
*info
,
142 struct netlbl_audit
*audit_info
)
144 int ret_val
= -EINVAL
;
145 struct cipso_v4_doi
*doi_def
= NULL
;
146 struct nlattr
*nla_a
;
147 struct nlattr
*nla_b
;
152 if (!info
->attrs
[NLBL_CIPSOV4_A_TAGLST
] ||
153 !info
->attrs
[NLBL_CIPSOV4_A_MLSLVLLST
])
156 if (nla_validate_nested(info
->attrs
[NLBL_CIPSOV4_A_MLSLVLLST
],
158 netlbl_cipsov4_genl_policy
) != 0)
161 doi_def
= kmalloc(sizeof(*doi_def
), GFP_KERNEL
);
164 doi_def
->map
.std
= kzalloc(sizeof(*doi_def
->map
.std
), GFP_KERNEL
);
165 if (doi_def
->map
.std
== NULL
) {
167 goto add_std_failure
;
169 doi_def
->type
= CIPSO_V4_MAP_TRANS
;
171 ret_val
= netlbl_cipsov4_add_common(info
, doi_def
);
173 goto add_std_failure
;
176 nla_for_each_nested(nla_a
,
177 info
->attrs
[NLBL_CIPSOV4_A_MLSLVLLST
],
179 if (nla_type(nla_a
) == NLBL_CIPSOV4_A_MLSLVL
) {
180 if (nla_validate_nested(nla_a
,
182 netlbl_cipsov4_genl_policy
) != 0)
183 goto add_std_failure
;
184 nla_for_each_nested(nla_b
, nla_a
, nla_b_rem
)
185 switch (nla_type(nla_b
)) {
186 case NLBL_CIPSOV4_A_MLSLVLLOC
:
187 if (nla_get_u32(nla_b
) >
188 CIPSO_V4_MAX_LOC_LVLS
)
189 goto add_std_failure
;
190 if (nla_get_u32(nla_b
) >=
191 doi_def
->map
.std
->lvl
.local_size
)
192 doi_def
->map
.std
->lvl
.local_size
=
193 nla_get_u32(nla_b
) + 1;
195 case NLBL_CIPSOV4_A_MLSLVLREM
:
196 if (nla_get_u32(nla_b
) >
197 CIPSO_V4_MAX_REM_LVLS
)
198 goto add_std_failure
;
199 if (nla_get_u32(nla_b
) >=
200 doi_def
->map
.std
->lvl
.cipso_size
)
201 doi_def
->map
.std
->lvl
.cipso_size
=
202 nla_get_u32(nla_b
) + 1;
206 doi_def
->map
.std
->lvl
.local
= kcalloc(doi_def
->map
.std
->lvl
.local_size
,
209 if (doi_def
->map
.std
->lvl
.local
== NULL
) {
211 goto add_std_failure
;
213 doi_def
->map
.std
->lvl
.cipso
= kcalloc(doi_def
->map
.std
->lvl
.cipso_size
,
216 if (doi_def
->map
.std
->lvl
.cipso
== NULL
) {
218 goto add_std_failure
;
220 for (iter
= 0; iter
< doi_def
->map
.std
->lvl
.local_size
; iter
++)
221 doi_def
->map
.std
->lvl
.local
[iter
] = CIPSO_V4_INV_LVL
;
222 for (iter
= 0; iter
< doi_def
->map
.std
->lvl
.cipso_size
; iter
++)
223 doi_def
->map
.std
->lvl
.cipso
[iter
] = CIPSO_V4_INV_LVL
;
224 nla_for_each_nested(nla_a
,
225 info
->attrs
[NLBL_CIPSOV4_A_MLSLVLLST
],
227 if (nla_type(nla_a
) == NLBL_CIPSOV4_A_MLSLVL
) {
228 struct nlattr
*lvl_loc
;
229 struct nlattr
*lvl_rem
;
231 lvl_loc
= nla_find_nested(nla_a
,
232 NLBL_CIPSOV4_A_MLSLVLLOC
);
233 lvl_rem
= nla_find_nested(nla_a
,
234 NLBL_CIPSOV4_A_MLSLVLREM
);
235 if (lvl_loc
== NULL
|| lvl_rem
== NULL
)
236 goto add_std_failure
;
237 doi_def
->map
.std
->lvl
.local
[nla_get_u32(lvl_loc
)] =
238 nla_get_u32(lvl_rem
);
239 doi_def
->map
.std
->lvl
.cipso
[nla_get_u32(lvl_rem
)] =
240 nla_get_u32(lvl_loc
);
243 if (info
->attrs
[NLBL_CIPSOV4_A_MLSCATLST
]) {
244 if (nla_validate_nested(info
->attrs
[NLBL_CIPSOV4_A_MLSCATLST
],
246 netlbl_cipsov4_genl_policy
) != 0)
247 goto add_std_failure
;
249 nla_for_each_nested(nla_a
,
250 info
->attrs
[NLBL_CIPSOV4_A_MLSCATLST
],
252 if (nla_type(nla_a
) == NLBL_CIPSOV4_A_MLSCAT
) {
253 if (nla_validate_nested(nla_a
,
255 netlbl_cipsov4_genl_policy
) != 0)
256 goto add_std_failure
;
257 nla_for_each_nested(nla_b
, nla_a
, nla_b_rem
)
258 switch (nla_type(nla_b
)) {
259 case NLBL_CIPSOV4_A_MLSCATLOC
:
260 if (nla_get_u32(nla_b
) >
261 CIPSO_V4_MAX_LOC_CATS
)
262 goto add_std_failure
;
263 if (nla_get_u32(nla_b
) >=
264 doi_def
->map
.std
->cat
.local_size
)
265 doi_def
->map
.std
->cat
.local_size
=
266 nla_get_u32(nla_b
) + 1;
268 case NLBL_CIPSOV4_A_MLSCATREM
:
269 if (nla_get_u32(nla_b
) >
270 CIPSO_V4_MAX_REM_CATS
)
271 goto add_std_failure
;
272 if (nla_get_u32(nla_b
) >=
273 doi_def
->map
.std
->cat
.cipso_size
)
274 doi_def
->map
.std
->cat
.cipso_size
=
275 nla_get_u32(nla_b
) + 1;
279 doi_def
->map
.std
->cat
.local
= kcalloc(
280 doi_def
->map
.std
->cat
.local_size
,
283 if (doi_def
->map
.std
->cat
.local
== NULL
) {
285 goto add_std_failure
;
287 doi_def
->map
.std
->cat
.cipso
= kcalloc(
288 doi_def
->map
.std
->cat
.cipso_size
,
291 if (doi_def
->map
.std
->cat
.cipso
== NULL
) {
293 goto add_std_failure
;
295 for (iter
= 0; iter
< doi_def
->map
.std
->cat
.local_size
; iter
++)
296 doi_def
->map
.std
->cat
.local
[iter
] = CIPSO_V4_INV_CAT
;
297 for (iter
= 0; iter
< doi_def
->map
.std
->cat
.cipso_size
; iter
++)
298 doi_def
->map
.std
->cat
.cipso
[iter
] = CIPSO_V4_INV_CAT
;
299 nla_for_each_nested(nla_a
,
300 info
->attrs
[NLBL_CIPSOV4_A_MLSCATLST
],
302 if (nla_type(nla_a
) == NLBL_CIPSOV4_A_MLSCAT
) {
303 struct nlattr
*cat_loc
;
304 struct nlattr
*cat_rem
;
306 cat_loc
= nla_find_nested(nla_a
,
307 NLBL_CIPSOV4_A_MLSCATLOC
);
308 cat_rem
= nla_find_nested(nla_a
,
309 NLBL_CIPSOV4_A_MLSCATREM
);
310 if (cat_loc
== NULL
|| cat_rem
== NULL
)
311 goto add_std_failure
;
312 doi_def
->map
.std
->cat
.local
[
313 nla_get_u32(cat_loc
)] =
314 nla_get_u32(cat_rem
);
315 doi_def
->map
.std
->cat
.cipso
[
316 nla_get_u32(cat_rem
)] =
317 nla_get_u32(cat_loc
);
321 ret_val
= cipso_v4_doi_add(doi_def
, audit_info
);
323 goto add_std_failure
;
328 cipso_v4_doi_free(doi_def
);
333 * netlbl_cipsov4_add_pass - Adds a CIPSO V4 DOI definition
334 * @info: the Generic NETLINK info block
335 * @audit_info: NetLabel audit information
338 * Create a new CIPSO_V4_MAP_PASS DOI definition based on the given ADD message
339 * and add it to the CIPSO V4 engine. Return zero on success and non-zero on
343 static int netlbl_cipsov4_add_pass(struct genl_info
*info
,
344 struct netlbl_audit
*audit_info
)
347 struct cipso_v4_doi
*doi_def
= NULL
;
349 if (!info
->attrs
[NLBL_CIPSOV4_A_TAGLST
])
352 doi_def
= kmalloc(sizeof(*doi_def
), GFP_KERNEL
);
355 doi_def
->type
= CIPSO_V4_MAP_PASS
;
357 ret_val
= netlbl_cipsov4_add_common(info
, doi_def
);
359 goto add_pass_failure
;
361 ret_val
= cipso_v4_doi_add(doi_def
, audit_info
);
363 goto add_pass_failure
;
367 cipso_v4_doi_free(doi_def
);
372 * netlbl_cipsov4_add_local - Adds a CIPSO V4 DOI definition
373 * @info: the Generic NETLINK info block
374 * @audit_info: NetLabel audit information
377 * Create a new CIPSO_V4_MAP_LOCAL DOI definition based on the given ADD
378 * message and add it to the CIPSO V4 engine. Return zero on success and
382 static int netlbl_cipsov4_add_local(struct genl_info
*info
,
383 struct netlbl_audit
*audit_info
)
386 struct cipso_v4_doi
*doi_def
= NULL
;
388 if (!info
->attrs
[NLBL_CIPSOV4_A_TAGLST
])
391 doi_def
= kmalloc(sizeof(*doi_def
), GFP_KERNEL
);
394 doi_def
->type
= CIPSO_V4_MAP_LOCAL
;
396 ret_val
= netlbl_cipsov4_add_common(info
, doi_def
);
398 goto add_local_failure
;
400 ret_val
= cipso_v4_doi_add(doi_def
, audit_info
);
402 goto add_local_failure
;
406 cipso_v4_doi_free(doi_def
);
411 * netlbl_cipsov4_add - Handle an ADD message
412 * @skb: the NETLINK buffer
413 * @info: the Generic NETLINK info block
416 * Create a new DOI definition based on the given ADD message and add it to the
417 * CIPSO V4 engine. Returns zero on success, negative values on failure.
420 static int netlbl_cipsov4_add(struct sk_buff
*skb
, struct genl_info
*info
)
423 int ret_val
= -EINVAL
;
424 const char *type_str
= "(unknown)";
425 struct netlbl_audit audit_info
;
427 if (!info
->attrs
[NLBL_CIPSOV4_A_DOI
] ||
428 !info
->attrs
[NLBL_CIPSOV4_A_MTYPE
])
431 netlbl_netlink_auditinfo(skb
, &audit_info
);
432 switch (nla_get_u32(info
->attrs
[NLBL_CIPSOV4_A_MTYPE
])) {
433 case CIPSO_V4_MAP_TRANS
:
435 ret_val
= netlbl_cipsov4_add_std(info
, &audit_info
);
437 case CIPSO_V4_MAP_PASS
:
439 ret_val
= netlbl_cipsov4_add_pass(info
, &audit_info
);
441 case CIPSO_V4_MAP_LOCAL
:
443 ret_val
= netlbl_cipsov4_add_local(info
, &audit_info
);
447 atomic_inc(&netlabel_mgmt_protocount
);
453 * netlbl_cipsov4_list - Handle a LIST message
454 * @skb: the NETLINK buffer
455 * @info: the Generic NETLINK info block
458 * Process a user generated LIST message and respond accordingly. While the
459 * response message generated by the kernel is straightforward, determining
460 * before hand the size of the buffer to allocate is not (we have to generate
461 * the message to know the size). In order to keep this function sane what we
462 * do is allocate a buffer of NLMSG_GOODSIZE and try to fit the response in
463 * that size, if we fail then we restart with a larger buffer and try again.
464 * We continue in this manner until we hit a limit of failed attempts then we
465 * give up and just send an error message. Returns zero on success and
466 * negative values on error.
469 static int netlbl_cipsov4_list(struct sk_buff
*skb
, struct genl_info
*info
)
472 struct sk_buff
*ans_skb
= NULL
;
476 struct nlattr
*nla_a
;
477 struct nlattr
*nla_b
;
478 struct cipso_v4_doi
*doi_def
;
481 if (!info
->attrs
[NLBL_CIPSOV4_A_DOI
]) {
487 ans_skb
= nlmsg_new(NLMSG_DEFAULT_SIZE
* nlsze_mult
, GFP_KERNEL
);
488 if (ans_skb
== NULL
) {
492 data
= genlmsg_put_reply(ans_skb
, info
, &netlbl_cipsov4_gnl_family
,
493 0, NLBL_CIPSOV4_C_LIST
);
499 doi
= nla_get_u32(info
->attrs
[NLBL_CIPSOV4_A_DOI
]);
502 doi_def
= cipso_v4_doi_getdef(doi
);
503 if (doi_def
== NULL
) {
505 goto list_failure_lock
;
508 ret_val
= nla_put_u32(ans_skb
, NLBL_CIPSOV4_A_MTYPE
, doi_def
->type
);
510 goto list_failure_lock
;
512 nla_a
= nla_nest_start(ans_skb
, NLBL_CIPSOV4_A_TAGLST
);
515 goto list_failure_lock
;
518 iter
< CIPSO_V4_TAG_MAXCNT
&&
519 doi_def
->tags
[iter
] != CIPSO_V4_TAG_INVALID
;
521 ret_val
= nla_put_u8(ans_skb
,
523 doi_def
->tags
[iter
]);
525 goto list_failure_lock
;
527 nla_nest_end(ans_skb
, nla_a
);
529 switch (doi_def
->type
) {
530 case CIPSO_V4_MAP_TRANS
:
531 nla_a
= nla_nest_start(ans_skb
, NLBL_CIPSOV4_A_MLSLVLLST
);
534 goto list_failure_lock
;
537 iter
< doi_def
->map
.std
->lvl
.local_size
;
539 if (doi_def
->map
.std
->lvl
.local
[iter
] ==
543 nla_b
= nla_nest_start(ans_skb
, NLBL_CIPSOV4_A_MLSLVL
);
548 ret_val
= nla_put_u32(ans_skb
,
549 NLBL_CIPSOV4_A_MLSLVLLOC
,
553 ret_val
= nla_put_u32(ans_skb
,
554 NLBL_CIPSOV4_A_MLSLVLREM
,
555 doi_def
->map
.std
->lvl
.local
[iter
]);
558 nla_nest_end(ans_skb
, nla_b
);
560 nla_nest_end(ans_skb
, nla_a
);
562 nla_a
= nla_nest_start(ans_skb
, NLBL_CIPSOV4_A_MLSCATLST
);
568 iter
< doi_def
->map
.std
->cat
.local_size
;
570 if (doi_def
->map
.std
->cat
.local
[iter
] ==
574 nla_b
= nla_nest_start(ans_skb
, NLBL_CIPSOV4_A_MLSCAT
);
579 ret_val
= nla_put_u32(ans_skb
,
580 NLBL_CIPSOV4_A_MLSCATLOC
,
584 ret_val
= nla_put_u32(ans_skb
,
585 NLBL_CIPSOV4_A_MLSCATREM
,
586 doi_def
->map
.std
->cat
.local
[iter
]);
589 nla_nest_end(ans_skb
, nla_b
);
591 nla_nest_end(ans_skb
, nla_a
);
597 genlmsg_end(ans_skb
, data
);
598 return genlmsg_reply(ans_skb
, info
);
601 /* XXX - this limit is a guesstimate */
602 if (nlsze_mult
< 4) {
616 * netlbl_cipsov4_listall_cb - cipso_v4_doi_walk() callback for LISTALL
617 * @doi_def: the CIPSOv4 DOI definition
618 * @arg: the netlbl_cipsov4_doiwalk_arg structure
621 * This function is designed to be used as a callback to the
622 * cipso_v4_doi_walk() function for use in generating a response for a LISTALL
623 * message. Returns the size of the message on success, negative values on
627 static int netlbl_cipsov4_listall_cb(struct cipso_v4_doi
*doi_def
, void *arg
)
629 int ret_val
= -ENOMEM
;
630 struct netlbl_cipsov4_doiwalk_arg
*cb_arg
= arg
;
633 data
= genlmsg_put(cb_arg
->skb
, NETLINK_CB(cb_arg
->nl_cb
->skb
).pid
,
634 cb_arg
->seq
, &netlbl_cipsov4_gnl_family
,
635 NLM_F_MULTI
, NLBL_CIPSOV4_C_LISTALL
);
637 goto listall_cb_failure
;
639 ret_val
= nla_put_u32(cb_arg
->skb
, NLBL_CIPSOV4_A_DOI
, doi_def
->doi
);
641 goto listall_cb_failure
;
642 ret_val
= nla_put_u32(cb_arg
->skb
,
643 NLBL_CIPSOV4_A_MTYPE
,
646 goto listall_cb_failure
;
648 return genlmsg_end(cb_arg
->skb
, data
);
651 genlmsg_cancel(cb_arg
->skb
, data
);
656 * netlbl_cipsov4_listall - Handle a LISTALL message
657 * @skb: the NETLINK buffer
658 * @cb: the NETLINK callback
661 * Process a user generated LISTALL message and respond accordingly. Returns
662 * zero on success and negative values on error.
665 static int netlbl_cipsov4_listall(struct sk_buff
*skb
,
666 struct netlink_callback
*cb
)
668 struct netlbl_cipsov4_doiwalk_arg cb_arg
;
669 u32 doi_skip
= cb
->args
[0];
673 cb_arg
.seq
= cb
->nlh
->nlmsg_seq
;
675 cipso_v4_doi_walk(&doi_skip
, netlbl_cipsov4_listall_cb
, &cb_arg
);
677 cb
->args
[0] = doi_skip
;
682 * netlbl_cipsov4_remove_cb - netlbl_cipsov4_remove() callback for REMOVE
683 * @entry: LSM domain mapping entry
684 * @arg: the netlbl_domhsh_walk_arg structure
687 * This function is intended for use by netlbl_cipsov4_remove() as the callback
688 * for the netlbl_domhsh_walk() function; it removes LSM domain map entries
689 * which are associated with the CIPSO DOI specified in @arg. Returns zero on
690 * success, negative values on failure.
693 static int netlbl_cipsov4_remove_cb(struct netlbl_dom_map
*entry
, void *arg
)
695 struct netlbl_domhsh_walk_arg
*cb_arg
= arg
;
697 if (entry
->type
== NETLBL_NLTYPE_CIPSOV4
&&
698 entry
->type_def
.cipsov4
->doi
== cb_arg
->doi
)
699 return netlbl_domhsh_remove_entry(entry
, cb_arg
->audit_info
);
705 * netlbl_cipsov4_remove - Handle a REMOVE message
706 * @skb: the NETLINK buffer
707 * @info: the Generic NETLINK info block
710 * Process a user generated REMOVE message and respond accordingly. Returns
711 * zero on success, negative values on failure.
714 static int netlbl_cipsov4_remove(struct sk_buff
*skb
, struct genl_info
*info
)
716 int ret_val
= -EINVAL
;
717 struct netlbl_domhsh_walk_arg cb_arg
;
718 struct netlbl_audit audit_info
;
722 if (!info
->attrs
[NLBL_CIPSOV4_A_DOI
])
725 netlbl_netlink_auditinfo(skb
, &audit_info
);
726 cb_arg
.doi
= nla_get_u32(info
->attrs
[NLBL_CIPSOV4_A_DOI
]);
727 cb_arg
.audit_info
= &audit_info
;
728 ret_val
= netlbl_domhsh_walk(&skip_bkt
, &skip_chain
,
729 netlbl_cipsov4_remove_cb
, &cb_arg
);
730 if (ret_val
== 0 || ret_val
== -ENOENT
) {
731 ret_val
= cipso_v4_doi_remove(cb_arg
.doi
, &audit_info
);
733 atomic_dec(&netlabel_mgmt_protocount
);
740 * NetLabel Generic NETLINK Command Definitions
743 static struct genl_ops netlbl_cipsov4_ops
[] = {
745 .cmd
= NLBL_CIPSOV4_C_ADD
,
746 .flags
= GENL_ADMIN_PERM
,
747 .policy
= netlbl_cipsov4_genl_policy
,
748 .doit
= netlbl_cipsov4_add
,
752 .cmd
= NLBL_CIPSOV4_C_REMOVE
,
753 .flags
= GENL_ADMIN_PERM
,
754 .policy
= netlbl_cipsov4_genl_policy
,
755 .doit
= netlbl_cipsov4_remove
,
759 .cmd
= NLBL_CIPSOV4_C_LIST
,
761 .policy
= netlbl_cipsov4_genl_policy
,
762 .doit
= netlbl_cipsov4_list
,
766 .cmd
= NLBL_CIPSOV4_C_LISTALL
,
768 .policy
= netlbl_cipsov4_genl_policy
,
770 .dumpit
= netlbl_cipsov4_listall
,
775 * NetLabel Generic NETLINK Protocol Functions
779 * netlbl_cipsov4_genl_init - Register the CIPSOv4 NetLabel component
782 * Register the CIPSOv4 packet NetLabel component with the Generic NETLINK
783 * mechanism. Returns zero on success, negative values on failure.
786 int __init
netlbl_cipsov4_genl_init(void)
790 ret_val
= genl_register_family(&netlbl_cipsov4_gnl_family
);
794 for (i
= 0; i
< ARRAY_SIZE(netlbl_cipsov4_ops
); i
++) {
795 ret_val
= genl_register_ops(&netlbl_cipsov4_gnl_family
,
796 &netlbl_cipsov4_ops
[i
]);