netlabel_mgmt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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);
  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);
  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);
  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. break;
  252. case NETLBL_NLTYPE_CIPSOV4:
  253. if (!info->attrs[NLBL_MGMT_A_CV4DOI])
  254. goto adddef_failure;
  255. tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
  256. /* We should be holding a rcu_read_lock() here while we hold
  257. * the result but since the entry will always be deleted when
  258. * the CIPSO DOI is deleted we aren't going to keep the
  259. * lock. */
  260. rcu_read_lock();
  261. entry->type_def.cipsov4 = cipso_v4_doi_getdef(tmp_val);
  262. if (entry->type_def.cipsov4 == NULL) {
  263. rcu_read_unlock();
  264. goto adddef_failure;
  265. }
  266. ret_val = netlbl_domhsh_add_default(entry);
  267. rcu_read_unlock();
  268. break;
  269. default:
  270. goto adddef_failure;
  271. }
  272. if (ret_val != 0)
  273. goto adddef_failure;
  274. return 0;
  275. adddef_failure:
  276. kfree(entry);
  277. return ret_val;
  278. }
  279. /**
  280. * netlbl_mgmt_removedef - Handle a REMOVEDEF message
  281. * @skb: the NETLINK buffer
  282. * @info: the Generic NETLINK info block
  283. *
  284. * Description:
  285. * Process a user generated REMOVEDEF message and remove the default domain
  286. * mapping. Returns zero on success, negative values on failure.
  287. *
  288. */
  289. static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
  290. {
  291. return netlbl_domhsh_remove_default();
  292. }
  293. /**
  294. * netlbl_mgmt_listdef - Handle a LISTDEF message
  295. * @skb: the NETLINK buffer
  296. * @info: the Generic NETLINK info block
  297. *
  298. * Description:
  299. * Process a user generated LISTDEF message and dumps the default domain
  300. * mapping in a form suitable for use in a kernel generated LISTDEF message.
  301. * Returns zero on success, negative values on failure.
  302. *
  303. */
  304. static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
  305. {
  306. int ret_val = -ENOMEM;
  307. struct sk_buff *ans_skb = NULL;
  308. void *data;
  309. struct netlbl_dom_map *entry;
  310. ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  311. if (ans_skb == NULL)
  312. return -ENOMEM;
  313. data = netlbl_netlink_hdr_put(ans_skb,
  314. info->snd_pid,
  315. info->snd_seq,
  316. netlbl_mgmt_gnl_family.id,
  317. 0,
  318. NLBL_MGMT_C_LISTDEF);
  319. if (data == NULL)
  320. goto listdef_failure;
  321. rcu_read_lock();
  322. entry = netlbl_domhsh_getentry(NULL);
  323. if (entry == NULL) {
  324. ret_val = -ENOENT;
  325. goto listdef_failure_lock;
  326. }
  327. ret_val = nla_put_u32(ans_skb, NLBL_MGMT_A_PROTOCOL, entry->type);
  328. if (ret_val != 0)
  329. goto listdef_failure_lock;
  330. switch (entry->type) {
  331. case NETLBL_NLTYPE_CIPSOV4:
  332. ret_val = nla_put_u32(ans_skb,
  333. NLBL_MGMT_A_CV4DOI,
  334. entry->type_def.cipsov4->doi);
  335. if (ret_val != 0)
  336. goto listdef_failure_lock;
  337. break;
  338. }
  339. rcu_read_unlock();
  340. genlmsg_end(ans_skb, data);
  341. ret_val = genlmsg_unicast(ans_skb, info->snd_pid);
  342. if (ret_val != 0)
  343. goto listdef_failure;
  344. return 0;
  345. listdef_failure_lock:
  346. rcu_read_unlock();
  347. listdef_failure:
  348. kfree_skb(ans_skb);
  349. return ret_val;
  350. }
  351. /**
  352. * netlbl_mgmt_protocols_cb - Write an individual PROTOCOL message response
  353. * @skb: the skb to write to
  354. * @seq: the NETLINK sequence number
  355. * @cb: the NETLINK callback
  356. * @protocol: the NetLabel protocol to use in the message
  357. *
  358. * Description:
  359. * This function is to be used in conjunction with netlbl_mgmt_protocols() to
  360. * answer a application's PROTOCOLS message. Returns the size of the message
  361. * on success, negative values on failure.
  362. *
  363. */
  364. static int netlbl_mgmt_protocols_cb(struct sk_buff *skb,
  365. struct netlink_callback *cb,
  366. u32 protocol)
  367. {
  368. int ret_val = -ENOMEM;
  369. void *data;
  370. data = netlbl_netlink_hdr_put(skb,
  371. NETLINK_CB(cb->skb).pid,
  372. cb->nlh->nlmsg_seq,
  373. netlbl_mgmt_gnl_family.id,
  374. NLM_F_MULTI,
  375. NLBL_MGMT_C_PROTOCOLS);
  376. if (data == NULL)
  377. goto protocols_cb_failure;
  378. ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, protocol);
  379. if (ret_val != 0)
  380. goto protocols_cb_failure;
  381. return genlmsg_end(skb, data);
  382. protocols_cb_failure:
  383. genlmsg_cancel(skb, data);
  384. return ret_val;
  385. }
  386. /**
  387. * netlbl_mgmt_protocols - Handle a PROTOCOLS message
  388. * @skb: the NETLINK buffer
  389. * @cb: the NETLINK callback
  390. *
  391. * Description:
  392. * Process a user generated PROTOCOLS message and respond accordingly.
  393. *
  394. */
  395. static int netlbl_mgmt_protocols(struct sk_buff *skb,
  396. struct netlink_callback *cb)
  397. {
  398. u32 protos_sent = cb->args[0];
  399. if (protos_sent == 0) {
  400. if (netlbl_mgmt_protocols_cb(skb,
  401. cb,
  402. NETLBL_NLTYPE_UNLABELED) < 0)
  403. goto protocols_return;
  404. protos_sent++;
  405. }
  406. if (protos_sent == 1) {
  407. if (netlbl_mgmt_protocols_cb(skb,
  408. cb,
  409. NETLBL_NLTYPE_CIPSOV4) < 0)
  410. goto protocols_return;
  411. protos_sent++;
  412. }
  413. protocols_return:
  414. cb->args[0] = protos_sent;
  415. return skb->len;
  416. }
  417. /**
  418. * netlbl_mgmt_version - Handle a VERSION message
  419. * @skb: the NETLINK buffer
  420. * @info: the Generic NETLINK info block
  421. *
  422. * Description:
  423. * Process a user generated VERSION message and respond accordingly. Returns
  424. * zero on success, negative values on failure.
  425. *
  426. */
  427. static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
  428. {
  429. int ret_val = -ENOMEM;
  430. struct sk_buff *ans_skb = NULL;
  431. void *data;
  432. ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  433. if (ans_skb == NULL)
  434. return -ENOMEM;
  435. data = netlbl_netlink_hdr_put(ans_skb,
  436. info->snd_pid,
  437. info->snd_seq,
  438. netlbl_mgmt_gnl_family.id,
  439. 0,
  440. NLBL_MGMT_C_VERSION);
  441. if (data == NULL)
  442. goto version_failure;
  443. ret_val = nla_put_u32(ans_skb,
  444. NLBL_MGMT_A_VERSION,
  445. NETLBL_PROTO_VERSION);
  446. if (ret_val != 0)
  447. goto version_failure;
  448. genlmsg_end(ans_skb, data);
  449. ret_val = genlmsg_unicast(ans_skb, info->snd_pid);
  450. if (ret_val != 0)
  451. goto version_failure;
  452. return 0;
  453. version_failure:
  454. kfree_skb(ans_skb);
  455. return ret_val;
  456. }
  457. /*
  458. * NetLabel Generic NETLINK Command Definitions
  459. */
  460. static struct genl_ops netlbl_mgmt_genl_c_add = {
  461. .cmd = NLBL_MGMT_C_ADD,
  462. .flags = GENL_ADMIN_PERM,
  463. .policy = netlbl_mgmt_genl_policy,
  464. .doit = netlbl_mgmt_add,
  465. .dumpit = NULL,
  466. };
  467. static struct genl_ops netlbl_mgmt_genl_c_remove = {
  468. .cmd = NLBL_MGMT_C_REMOVE,
  469. .flags = GENL_ADMIN_PERM,
  470. .policy = netlbl_mgmt_genl_policy,
  471. .doit = netlbl_mgmt_remove,
  472. .dumpit = NULL,
  473. };
  474. static struct genl_ops netlbl_mgmt_genl_c_listall = {
  475. .cmd = NLBL_MGMT_C_LISTALL,
  476. .flags = 0,
  477. .policy = netlbl_mgmt_genl_policy,
  478. .doit = NULL,
  479. .dumpit = netlbl_mgmt_listall,
  480. };
  481. static struct genl_ops netlbl_mgmt_genl_c_adddef = {
  482. .cmd = NLBL_MGMT_C_ADDDEF,
  483. .flags = GENL_ADMIN_PERM,
  484. .policy = netlbl_mgmt_genl_policy,
  485. .doit = netlbl_mgmt_adddef,
  486. .dumpit = NULL,
  487. };
  488. static struct genl_ops netlbl_mgmt_genl_c_removedef = {
  489. .cmd = NLBL_MGMT_C_REMOVEDEF,
  490. .flags = GENL_ADMIN_PERM,
  491. .policy = netlbl_mgmt_genl_policy,
  492. .doit = netlbl_mgmt_removedef,
  493. .dumpit = NULL,
  494. };
  495. static struct genl_ops netlbl_mgmt_genl_c_listdef = {
  496. .cmd = NLBL_MGMT_C_LISTDEF,
  497. .flags = 0,
  498. .policy = netlbl_mgmt_genl_policy,
  499. .doit = netlbl_mgmt_listdef,
  500. .dumpit = NULL,
  501. };
  502. static struct genl_ops netlbl_mgmt_genl_c_protocols = {
  503. .cmd = NLBL_MGMT_C_PROTOCOLS,
  504. .flags = 0,
  505. .policy = netlbl_mgmt_genl_policy,
  506. .doit = NULL,
  507. .dumpit = netlbl_mgmt_protocols,
  508. };
  509. static struct genl_ops netlbl_mgmt_genl_c_version = {
  510. .cmd = NLBL_MGMT_C_VERSION,
  511. .flags = 0,
  512. .policy = netlbl_mgmt_genl_policy,
  513. .doit = netlbl_mgmt_version,
  514. .dumpit = NULL,
  515. };
  516. /*
  517. * NetLabel Generic NETLINK Protocol Functions
  518. */
  519. /**
  520. * netlbl_mgmt_genl_init - Register the NetLabel management component
  521. *
  522. * Description:
  523. * Register the NetLabel management component with the Generic NETLINK
  524. * mechanism. Returns zero on success, negative values on failure.
  525. *
  526. */
  527. int netlbl_mgmt_genl_init(void)
  528. {
  529. int ret_val;
  530. ret_val = genl_register_family(&netlbl_mgmt_gnl_family);
  531. if (ret_val != 0)
  532. return ret_val;
  533. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  534. &netlbl_mgmt_genl_c_add);
  535. if (ret_val != 0)
  536. return ret_val;
  537. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  538. &netlbl_mgmt_genl_c_remove);
  539. if (ret_val != 0)
  540. return ret_val;
  541. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  542. &netlbl_mgmt_genl_c_listall);
  543. if (ret_val != 0)
  544. return ret_val;
  545. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  546. &netlbl_mgmt_genl_c_adddef);
  547. if (ret_val != 0)
  548. return ret_val;
  549. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  550. &netlbl_mgmt_genl_c_removedef);
  551. if (ret_val != 0)
  552. return ret_val;
  553. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  554. &netlbl_mgmt_genl_c_listdef);
  555. if (ret_val != 0)
  556. return ret_val;
  557. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  558. &netlbl_mgmt_genl_c_protocols);
  559. if (ret_val != 0)
  560. return ret_val;
  561. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  562. &netlbl_mgmt_genl_c_version);
  563. if (ret_val != 0)
  564. return ret_val;
  565. return 0;
  566. }