netlabel_mgmt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * NetLabel Management Support
  3. *
  4. * This file defines the management functions for the NetLabel system. The
  5. * NetLabel system manages static and dynamic label mappings for network
  6. * protocols such as CIPSO and RIPSO.
  7. *
  8. * Author: Paul Moore <paul.moore@hp.com>
  9. *
  10. */
  11. /*
  12. * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  22. * the GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. *
  28. */
  29. #include <linux/types.h>
  30. #include <linux/socket.h>
  31. #include <linux/string.h>
  32. #include <linux/skbuff.h>
  33. #include <net/sock.h>
  34. #include <net/netlink.h>
  35. #include <net/genetlink.h>
  36. #include <net/netlabel.h>
  37. #include <net/cipso_ipv4.h>
  38. #include "netlabel_domainhash.h"
  39. #include "netlabel_user.h"
  40. #include "netlabel_mgmt.h"
  41. /* Argument struct for netlbl_domhsh_walk() */
  42. struct netlbl_domhsh_walk_arg {
  43. struct netlink_callback *nl_cb;
  44. struct sk_buff *skb;
  45. u32 seq;
  46. };
  47. /* NetLabel Generic NETLINK CIPSOv4 family */
  48. static struct genl_family netlbl_mgmt_gnl_family = {
  49. .id = GENL_ID_GENERATE,
  50. .hdrsize = 0,
  51. .name = NETLBL_NLTYPE_MGMT_NAME,
  52. .version = NETLBL_PROTO_VERSION,
  53. .maxattr = NLBL_MGMT_A_MAX,
  54. };
  55. /* NetLabel Netlink attribute policy */
  56. static struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = {
  57. [NLBL_MGMT_A_DOMAIN] = { .type = NLA_NUL_STRING },
  58. [NLBL_MGMT_A_PROTOCOL] = { .type = NLA_U32 },
  59. [NLBL_MGMT_A_VERSION] = { .type = NLA_U32 },
  60. [NLBL_MGMT_A_CV4DOI] = { .type = NLA_U32 },
  61. };
  62. /*
  63. * NetLabel Command Handlers
  64. */
  65. /**
  66. * netlbl_mgmt_add - Handle an ADD message
  67. * @skb: the NETLINK buffer
  68. * @info: the Generic NETLINK info block
  69. *
  70. * Description:
  71. * Process a user generated ADD message and add the domains from the message
  72. * to the hash table. See netlabel.h for a description of the message format.
  73. * Returns zero on success, negative values on failure.
  74. *
  75. */
  76. static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
  77. {
  78. int ret_val = -EINVAL;
  79. struct netlbl_dom_map *entry = NULL;
  80. size_t tmp_size;
  81. u32 tmp_val;
  82. if (!info->attrs[NLBL_MGMT_A_DOMAIN] ||
  83. !info->attrs[NLBL_MGMT_A_PROTOCOL])
  84. goto add_failure;
  85. entry = kzalloc(sizeof(*entry), GFP_KERNEL);
  86. if (entry == NULL) {
  87. ret_val = -ENOMEM;
  88. goto add_failure;
  89. }
  90. tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
  91. entry->domain = kmalloc(tmp_size, GFP_KERNEL);
  92. if (entry->domain == NULL) {
  93. ret_val = -ENOMEM;
  94. goto add_failure;
  95. }
  96. entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
  97. nla_strlcpy(entry->domain, info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
  98. switch (entry->type) {
  99. case NETLBL_NLTYPE_UNLABELED:
  100. ret_val = netlbl_domhsh_add(entry, NETLINK_CB(skb).sid);
  101. break;
  102. case NETLBL_NLTYPE_CIPSOV4:
  103. if (!info->attrs[NLBL_MGMT_A_CV4DOI])
  104. goto add_failure;
  105. tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
  106. /* We should be holding a rcu_read_lock() here while we hold
  107. * the result but since the entry will always be deleted when
  108. * the CIPSO DOI is deleted we aren't going to keep the
  109. * lock. */
  110. rcu_read_lock();
  111. entry->type_def.cipsov4 = cipso_v4_doi_getdef(tmp_val);
  112. if (entry->type_def.cipsov4 == NULL) {
  113. rcu_read_unlock();
  114. goto add_failure;
  115. }
  116. ret_val = netlbl_domhsh_add(entry, NETLINK_CB(skb).sid);
  117. rcu_read_unlock();
  118. break;
  119. default:
  120. goto add_failure;
  121. }
  122. if (ret_val != 0)
  123. goto add_failure;
  124. return 0;
  125. add_failure:
  126. if (entry)
  127. kfree(entry->domain);
  128. kfree(entry);
  129. return ret_val;
  130. }
  131. /**
  132. * netlbl_mgmt_remove - Handle a REMOVE message
  133. * @skb: the NETLINK buffer
  134. * @info: the Generic NETLINK info block
  135. *
  136. * Description:
  137. * Process a user generated REMOVE message and remove the specified domain
  138. * mappings. Returns zero on success, negative values on failure.
  139. *
  140. */
  141. static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info)
  142. {
  143. char *domain;
  144. if (!info->attrs[NLBL_MGMT_A_DOMAIN])
  145. return -EINVAL;
  146. domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]);
  147. return netlbl_domhsh_remove(domain, NETLINK_CB(skb).sid);
  148. }
  149. /**
  150. * netlbl_mgmt_listall_cb - netlbl_domhsh_walk() callback for LISTALL
  151. * @entry: the domain mapping hash table entry
  152. * @arg: the netlbl_domhsh_walk_arg structure
  153. *
  154. * Description:
  155. * This function is designed to be used as a callback to the
  156. * netlbl_domhsh_walk() function for use in generating a response for a LISTALL
  157. * message. Returns the size of the message on success, negative values on
  158. * failure.
  159. *
  160. */
  161. static int netlbl_mgmt_listall_cb(struct netlbl_dom_map *entry, void *arg)
  162. {
  163. int ret_val = -ENOMEM;
  164. struct netlbl_domhsh_walk_arg *cb_arg = arg;
  165. void *data;
  166. data = netlbl_netlink_hdr_put(cb_arg->skb,
  167. NETLINK_CB(cb_arg->nl_cb->skb).pid,
  168. cb_arg->seq,
  169. netlbl_mgmt_gnl_family.id,
  170. NLM_F_MULTI,
  171. NLBL_MGMT_C_LISTALL);
  172. if (data == NULL)
  173. goto listall_cb_failure;
  174. ret_val = nla_put_string(cb_arg->skb,
  175. NLBL_MGMT_A_DOMAIN,
  176. entry->domain);
  177. if (ret_val != 0)
  178. goto listall_cb_failure;
  179. ret_val = nla_put_u32(cb_arg->skb, NLBL_MGMT_A_PROTOCOL, entry->type);
  180. if (ret_val != 0)
  181. goto listall_cb_failure;
  182. switch (entry->type) {
  183. case NETLBL_NLTYPE_CIPSOV4:
  184. ret_val = nla_put_u32(cb_arg->skb,
  185. NLBL_MGMT_A_CV4DOI,
  186. entry->type_def.cipsov4->doi);
  187. if (ret_val != 0)
  188. goto listall_cb_failure;
  189. break;
  190. }
  191. cb_arg->seq++;
  192. return genlmsg_end(cb_arg->skb, data);
  193. listall_cb_failure:
  194. genlmsg_cancel(cb_arg->skb, data);
  195. return ret_val;
  196. }
  197. /**
  198. * netlbl_mgmt_listall - Handle a LISTALL message
  199. * @skb: the NETLINK buffer
  200. * @cb: the NETLINK callback
  201. *
  202. * Description:
  203. * Process a user generated LISTALL message and dumps the domain hash table in
  204. * a form suitable for use in a kernel generated LISTALL message. Returns zero
  205. * on success, negative values on failure.
  206. *
  207. */
  208. static int netlbl_mgmt_listall(struct sk_buff *skb,
  209. struct netlink_callback *cb)
  210. {
  211. struct netlbl_domhsh_walk_arg cb_arg;
  212. u32 skip_bkt = cb->args[0];
  213. u32 skip_chain = cb->args[1];
  214. cb_arg.nl_cb = cb;
  215. cb_arg.skb = skb;
  216. cb_arg.seq = cb->nlh->nlmsg_seq;
  217. netlbl_domhsh_walk(&skip_bkt,
  218. &skip_chain,
  219. netlbl_mgmt_listall_cb,
  220. &cb_arg);
  221. cb->args[0] = skip_bkt;
  222. cb->args[1] = skip_chain;
  223. return skb->len;
  224. }
  225. /**
  226. * netlbl_mgmt_adddef - Handle an ADDDEF message
  227. * @skb: the NETLINK buffer
  228. * @info: the Generic NETLINK info block
  229. *
  230. * Description:
  231. * Process a user generated ADDDEF message and respond accordingly. Returns
  232. * zero on success, negative values on failure.
  233. *
  234. */
  235. static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
  236. {
  237. int ret_val = -EINVAL;
  238. struct netlbl_dom_map *entry = NULL;
  239. u32 tmp_val;
  240. if (!info->attrs[NLBL_MGMT_A_PROTOCOL])
  241. goto adddef_failure;
  242. entry = kzalloc(sizeof(*entry), GFP_KERNEL);
  243. if (entry == NULL) {
  244. ret_val = -ENOMEM;
  245. goto adddef_failure;
  246. }
  247. entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
  248. switch (entry->type) {
  249. case NETLBL_NLTYPE_UNLABELED:
  250. ret_val = netlbl_domhsh_add_default(entry,
  251. NETLINK_CB(skb).sid);
  252. break;
  253. case NETLBL_NLTYPE_CIPSOV4:
  254. if (!info->attrs[NLBL_MGMT_A_CV4DOI])
  255. goto adddef_failure;
  256. tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
  257. /* We should be holding a rcu_read_lock() here while we hold
  258. * the result but since the entry will always be deleted when
  259. * the CIPSO DOI is deleted we aren't going to keep the
  260. * lock. */
  261. rcu_read_lock();
  262. entry->type_def.cipsov4 = cipso_v4_doi_getdef(tmp_val);
  263. if (entry->type_def.cipsov4 == NULL) {
  264. rcu_read_unlock();
  265. goto adddef_failure;
  266. }
  267. ret_val = netlbl_domhsh_add_default(entry,
  268. NETLINK_CB(skb).sid);
  269. rcu_read_unlock();
  270. break;
  271. default:
  272. goto adddef_failure;
  273. }
  274. if (ret_val != 0)
  275. goto adddef_failure;
  276. return 0;
  277. adddef_failure:
  278. kfree(entry);
  279. return ret_val;
  280. }
  281. /**
  282. * netlbl_mgmt_removedef - Handle a REMOVEDEF message
  283. * @skb: the NETLINK buffer
  284. * @info: the Generic NETLINK info block
  285. *
  286. * Description:
  287. * Process a user generated REMOVEDEF message and remove the default domain
  288. * mapping. Returns zero on success, negative values on failure.
  289. *
  290. */
  291. static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
  292. {
  293. return netlbl_domhsh_remove_default(NETLINK_CB(skb).sid);
  294. }
  295. /**
  296. * netlbl_mgmt_listdef - Handle a LISTDEF message
  297. * @skb: the NETLINK buffer
  298. * @info: the Generic NETLINK info block
  299. *
  300. * Description:
  301. * Process a user generated LISTDEF message and dumps the default domain
  302. * mapping in a form suitable for use in a kernel generated LISTDEF message.
  303. * Returns zero on success, negative values on failure.
  304. *
  305. */
  306. static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
  307. {
  308. int ret_val = -ENOMEM;
  309. struct sk_buff *ans_skb = NULL;
  310. void *data;
  311. struct netlbl_dom_map *entry;
  312. ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  313. if (ans_skb == NULL)
  314. return -ENOMEM;
  315. data = netlbl_netlink_hdr_put(ans_skb,
  316. info->snd_pid,
  317. info->snd_seq,
  318. netlbl_mgmt_gnl_family.id,
  319. 0,
  320. NLBL_MGMT_C_LISTDEF);
  321. if (data == NULL)
  322. goto listdef_failure;
  323. rcu_read_lock();
  324. entry = netlbl_domhsh_getentry(NULL);
  325. if (entry == NULL) {
  326. ret_val = -ENOENT;
  327. goto listdef_failure_lock;
  328. }
  329. ret_val = nla_put_u32(ans_skb, NLBL_MGMT_A_PROTOCOL, entry->type);
  330. if (ret_val != 0)
  331. goto listdef_failure_lock;
  332. switch (entry->type) {
  333. case NETLBL_NLTYPE_CIPSOV4:
  334. ret_val = nla_put_u32(ans_skb,
  335. NLBL_MGMT_A_CV4DOI,
  336. entry->type_def.cipsov4->doi);
  337. if (ret_val != 0)
  338. goto listdef_failure_lock;
  339. break;
  340. }
  341. rcu_read_unlock();
  342. genlmsg_end(ans_skb, data);
  343. ret_val = genlmsg_unicast(ans_skb, info->snd_pid);
  344. if (ret_val != 0)
  345. goto listdef_failure;
  346. return 0;
  347. listdef_failure_lock:
  348. rcu_read_unlock();
  349. listdef_failure:
  350. kfree_skb(ans_skb);
  351. return ret_val;
  352. }
  353. /**
  354. * netlbl_mgmt_protocols_cb - Write an individual PROTOCOL message response
  355. * @skb: the skb to write to
  356. * @seq: the NETLINK sequence number
  357. * @cb: the NETLINK callback
  358. * @protocol: the NetLabel protocol to use in the message
  359. *
  360. * Description:
  361. * This function is to be used in conjunction with netlbl_mgmt_protocols() to
  362. * answer a application's PROTOCOLS message. Returns the size of the message
  363. * on success, negative values on failure.
  364. *
  365. */
  366. static int netlbl_mgmt_protocols_cb(struct sk_buff *skb,
  367. struct netlink_callback *cb,
  368. u32 protocol)
  369. {
  370. int ret_val = -ENOMEM;
  371. void *data;
  372. data = netlbl_netlink_hdr_put(skb,
  373. NETLINK_CB(cb->skb).pid,
  374. cb->nlh->nlmsg_seq,
  375. netlbl_mgmt_gnl_family.id,
  376. NLM_F_MULTI,
  377. NLBL_MGMT_C_PROTOCOLS);
  378. if (data == NULL)
  379. goto protocols_cb_failure;
  380. ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, protocol);
  381. if (ret_val != 0)
  382. goto protocols_cb_failure;
  383. return genlmsg_end(skb, data);
  384. protocols_cb_failure:
  385. genlmsg_cancel(skb, data);
  386. return ret_val;
  387. }
  388. /**
  389. * netlbl_mgmt_protocols - Handle a PROTOCOLS message
  390. * @skb: the NETLINK buffer
  391. * @cb: the NETLINK callback
  392. *
  393. * Description:
  394. * Process a user generated PROTOCOLS message and respond accordingly.
  395. *
  396. */
  397. static int netlbl_mgmt_protocols(struct sk_buff *skb,
  398. struct netlink_callback *cb)
  399. {
  400. u32 protos_sent = cb->args[0];
  401. if (protos_sent == 0) {
  402. if (netlbl_mgmt_protocols_cb(skb,
  403. cb,
  404. NETLBL_NLTYPE_UNLABELED) < 0)
  405. goto protocols_return;
  406. protos_sent++;
  407. }
  408. if (protos_sent == 1) {
  409. if (netlbl_mgmt_protocols_cb(skb,
  410. cb,
  411. NETLBL_NLTYPE_CIPSOV4) < 0)
  412. goto protocols_return;
  413. protos_sent++;
  414. }
  415. protocols_return:
  416. cb->args[0] = protos_sent;
  417. return skb->len;
  418. }
  419. /**
  420. * netlbl_mgmt_version - Handle a VERSION message
  421. * @skb: the NETLINK buffer
  422. * @info: the Generic NETLINK info block
  423. *
  424. * Description:
  425. * Process a user generated VERSION message and respond accordingly. Returns
  426. * zero on success, negative values on failure.
  427. *
  428. */
  429. static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
  430. {
  431. int ret_val = -ENOMEM;
  432. struct sk_buff *ans_skb = NULL;
  433. void *data;
  434. ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  435. if (ans_skb == NULL)
  436. return -ENOMEM;
  437. data = netlbl_netlink_hdr_put(ans_skb,
  438. info->snd_pid,
  439. info->snd_seq,
  440. netlbl_mgmt_gnl_family.id,
  441. 0,
  442. NLBL_MGMT_C_VERSION);
  443. if (data == NULL)
  444. goto version_failure;
  445. ret_val = nla_put_u32(ans_skb,
  446. NLBL_MGMT_A_VERSION,
  447. NETLBL_PROTO_VERSION);
  448. if (ret_val != 0)
  449. goto version_failure;
  450. genlmsg_end(ans_skb, data);
  451. ret_val = genlmsg_unicast(ans_skb, info->snd_pid);
  452. if (ret_val != 0)
  453. goto version_failure;
  454. return 0;
  455. version_failure:
  456. kfree_skb(ans_skb);
  457. return ret_val;
  458. }
  459. /*
  460. * NetLabel Generic NETLINK Command Definitions
  461. */
  462. static struct genl_ops netlbl_mgmt_genl_c_add = {
  463. .cmd = NLBL_MGMT_C_ADD,
  464. .flags = GENL_ADMIN_PERM,
  465. .policy = netlbl_mgmt_genl_policy,
  466. .doit = netlbl_mgmt_add,
  467. .dumpit = NULL,
  468. };
  469. static struct genl_ops netlbl_mgmt_genl_c_remove = {
  470. .cmd = NLBL_MGMT_C_REMOVE,
  471. .flags = GENL_ADMIN_PERM,
  472. .policy = netlbl_mgmt_genl_policy,
  473. .doit = netlbl_mgmt_remove,
  474. .dumpit = NULL,
  475. };
  476. static struct genl_ops netlbl_mgmt_genl_c_listall = {
  477. .cmd = NLBL_MGMT_C_LISTALL,
  478. .flags = 0,
  479. .policy = netlbl_mgmt_genl_policy,
  480. .doit = NULL,
  481. .dumpit = netlbl_mgmt_listall,
  482. };
  483. static struct genl_ops netlbl_mgmt_genl_c_adddef = {
  484. .cmd = NLBL_MGMT_C_ADDDEF,
  485. .flags = GENL_ADMIN_PERM,
  486. .policy = netlbl_mgmt_genl_policy,
  487. .doit = netlbl_mgmt_adddef,
  488. .dumpit = NULL,
  489. };
  490. static struct genl_ops netlbl_mgmt_genl_c_removedef = {
  491. .cmd = NLBL_MGMT_C_REMOVEDEF,
  492. .flags = GENL_ADMIN_PERM,
  493. .policy = netlbl_mgmt_genl_policy,
  494. .doit = netlbl_mgmt_removedef,
  495. .dumpit = NULL,
  496. };
  497. static struct genl_ops netlbl_mgmt_genl_c_listdef = {
  498. .cmd = NLBL_MGMT_C_LISTDEF,
  499. .flags = 0,
  500. .policy = netlbl_mgmt_genl_policy,
  501. .doit = netlbl_mgmt_listdef,
  502. .dumpit = NULL,
  503. };
  504. static struct genl_ops netlbl_mgmt_genl_c_protocols = {
  505. .cmd = NLBL_MGMT_C_PROTOCOLS,
  506. .flags = 0,
  507. .policy = netlbl_mgmt_genl_policy,
  508. .doit = NULL,
  509. .dumpit = netlbl_mgmt_protocols,
  510. };
  511. static struct genl_ops netlbl_mgmt_genl_c_version = {
  512. .cmd = NLBL_MGMT_C_VERSION,
  513. .flags = 0,
  514. .policy = netlbl_mgmt_genl_policy,
  515. .doit = netlbl_mgmt_version,
  516. .dumpit = NULL,
  517. };
  518. /*
  519. * NetLabel Generic NETLINK Protocol Functions
  520. */
  521. /**
  522. * netlbl_mgmt_genl_init - Register the NetLabel management component
  523. *
  524. * Description:
  525. * Register the NetLabel management component with the Generic NETLINK
  526. * mechanism. Returns zero on success, negative values on failure.
  527. *
  528. */
  529. int netlbl_mgmt_genl_init(void)
  530. {
  531. int ret_val;
  532. ret_val = genl_register_family(&netlbl_mgmt_gnl_family);
  533. if (ret_val != 0)
  534. return ret_val;
  535. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  536. &netlbl_mgmt_genl_c_add);
  537. if (ret_val != 0)
  538. return ret_val;
  539. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  540. &netlbl_mgmt_genl_c_remove);
  541. if (ret_val != 0)
  542. return ret_val;
  543. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  544. &netlbl_mgmt_genl_c_listall);
  545. if (ret_val != 0)
  546. return ret_val;
  547. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  548. &netlbl_mgmt_genl_c_adddef);
  549. if (ret_val != 0)
  550. return ret_val;
  551. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  552. &netlbl_mgmt_genl_c_removedef);
  553. if (ret_val != 0)
  554. return ret_val;
  555. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  556. &netlbl_mgmt_genl_c_listdef);
  557. if (ret_val != 0)
  558. return ret_val;
  559. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  560. &netlbl_mgmt_genl_c_protocols);
  561. if (ret_val != 0)
  562. return ret_val;
  563. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  564. &netlbl_mgmt_genl_c_version);
  565. if (ret_val != 0)
  566. return ret_val;
  567. return 0;
  568. }