netlabel_mgmt.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. struct netlbl_audit audit_info;
  83. if (!info->attrs[NLBL_MGMT_A_DOMAIN] ||
  84. !info->attrs[NLBL_MGMT_A_PROTOCOL])
  85. goto add_failure;
  86. netlbl_netlink_auditinfo(skb, &audit_info);
  87. entry = kzalloc(sizeof(*entry), GFP_KERNEL);
  88. if (entry == NULL) {
  89. ret_val = -ENOMEM;
  90. goto add_failure;
  91. }
  92. tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
  93. entry->domain = kmalloc(tmp_size, GFP_KERNEL);
  94. if (entry->domain == NULL) {
  95. ret_val = -ENOMEM;
  96. goto add_failure;
  97. }
  98. entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
  99. nla_strlcpy(entry->domain, info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
  100. switch (entry->type) {
  101. case NETLBL_NLTYPE_UNLABELED:
  102. ret_val = netlbl_domhsh_add(entry, &audit_info);
  103. break;
  104. case NETLBL_NLTYPE_CIPSOV4:
  105. if (!info->attrs[NLBL_MGMT_A_CV4DOI])
  106. goto add_failure;
  107. tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
  108. /* We should be holding a rcu_read_lock() here while we hold
  109. * the result but since the entry will always be deleted when
  110. * the CIPSO DOI is deleted we aren't going to keep the
  111. * lock. */
  112. rcu_read_lock();
  113. entry->type_def.cipsov4 = cipso_v4_doi_getdef(tmp_val);
  114. if (entry->type_def.cipsov4 == NULL) {
  115. rcu_read_unlock();
  116. goto add_failure;
  117. }
  118. ret_val = netlbl_domhsh_add(entry, &audit_info);
  119. rcu_read_unlock();
  120. break;
  121. default:
  122. goto add_failure;
  123. }
  124. if (ret_val != 0)
  125. goto add_failure;
  126. return 0;
  127. add_failure:
  128. if (entry)
  129. kfree(entry->domain);
  130. kfree(entry);
  131. return ret_val;
  132. }
  133. /**
  134. * netlbl_mgmt_remove - Handle a REMOVE message
  135. * @skb: the NETLINK buffer
  136. * @info: the Generic NETLINK info block
  137. *
  138. * Description:
  139. * Process a user generated REMOVE message and remove the specified domain
  140. * mappings. Returns zero on success, negative values on failure.
  141. *
  142. */
  143. static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info)
  144. {
  145. char *domain;
  146. struct netlbl_audit audit_info;
  147. if (!info->attrs[NLBL_MGMT_A_DOMAIN])
  148. return -EINVAL;
  149. netlbl_netlink_auditinfo(skb, &audit_info);
  150. domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]);
  151. return netlbl_domhsh_remove(domain, &audit_info);
  152. }
  153. /**
  154. * netlbl_mgmt_listall_cb - netlbl_domhsh_walk() callback for LISTALL
  155. * @entry: the domain mapping hash table entry
  156. * @arg: the netlbl_domhsh_walk_arg structure
  157. *
  158. * Description:
  159. * This function is designed to be used as a callback to the
  160. * netlbl_domhsh_walk() function for use in generating a response for a LISTALL
  161. * message. Returns the size of the message on success, negative values on
  162. * failure.
  163. *
  164. */
  165. static int netlbl_mgmt_listall_cb(struct netlbl_dom_map *entry, void *arg)
  166. {
  167. int ret_val = -ENOMEM;
  168. struct netlbl_domhsh_walk_arg *cb_arg = arg;
  169. void *data;
  170. data = netlbl_netlink_hdr_put(cb_arg->skb,
  171. NETLINK_CB(cb_arg->nl_cb->skb).pid,
  172. cb_arg->seq,
  173. netlbl_mgmt_gnl_family.id,
  174. NLM_F_MULTI,
  175. NLBL_MGMT_C_LISTALL);
  176. if (data == NULL)
  177. goto listall_cb_failure;
  178. ret_val = nla_put_string(cb_arg->skb,
  179. NLBL_MGMT_A_DOMAIN,
  180. entry->domain);
  181. if (ret_val != 0)
  182. goto listall_cb_failure;
  183. ret_val = nla_put_u32(cb_arg->skb, NLBL_MGMT_A_PROTOCOL, entry->type);
  184. if (ret_val != 0)
  185. goto listall_cb_failure;
  186. switch (entry->type) {
  187. case NETLBL_NLTYPE_CIPSOV4:
  188. ret_val = nla_put_u32(cb_arg->skb,
  189. NLBL_MGMT_A_CV4DOI,
  190. entry->type_def.cipsov4->doi);
  191. if (ret_val != 0)
  192. goto listall_cb_failure;
  193. break;
  194. }
  195. cb_arg->seq++;
  196. return genlmsg_end(cb_arg->skb, data);
  197. listall_cb_failure:
  198. genlmsg_cancel(cb_arg->skb, data);
  199. return ret_val;
  200. }
  201. /**
  202. * netlbl_mgmt_listall - Handle a LISTALL message
  203. * @skb: the NETLINK buffer
  204. * @cb: the NETLINK callback
  205. *
  206. * Description:
  207. * Process a user generated LISTALL message and dumps the domain hash table in
  208. * a form suitable for use in a kernel generated LISTALL message. Returns zero
  209. * on success, negative values on failure.
  210. *
  211. */
  212. static int netlbl_mgmt_listall(struct sk_buff *skb,
  213. struct netlink_callback *cb)
  214. {
  215. struct netlbl_domhsh_walk_arg cb_arg;
  216. u32 skip_bkt = cb->args[0];
  217. u32 skip_chain = cb->args[1];
  218. cb_arg.nl_cb = cb;
  219. cb_arg.skb = skb;
  220. cb_arg.seq = cb->nlh->nlmsg_seq;
  221. netlbl_domhsh_walk(&skip_bkt,
  222. &skip_chain,
  223. netlbl_mgmt_listall_cb,
  224. &cb_arg);
  225. cb->args[0] = skip_bkt;
  226. cb->args[1] = skip_chain;
  227. return skb->len;
  228. }
  229. /**
  230. * netlbl_mgmt_adddef - Handle an ADDDEF message
  231. * @skb: the NETLINK buffer
  232. * @info: the Generic NETLINK info block
  233. *
  234. * Description:
  235. * Process a user generated ADDDEF message and respond accordingly. Returns
  236. * zero on success, negative values on failure.
  237. *
  238. */
  239. static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
  240. {
  241. int ret_val = -EINVAL;
  242. struct netlbl_dom_map *entry = NULL;
  243. u32 tmp_val;
  244. struct netlbl_audit audit_info;
  245. if (!info->attrs[NLBL_MGMT_A_PROTOCOL])
  246. goto adddef_failure;
  247. netlbl_netlink_auditinfo(skb, &audit_info);
  248. entry = kzalloc(sizeof(*entry), GFP_KERNEL);
  249. if (entry == NULL) {
  250. ret_val = -ENOMEM;
  251. goto adddef_failure;
  252. }
  253. entry->type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
  254. switch (entry->type) {
  255. case NETLBL_NLTYPE_UNLABELED:
  256. ret_val = netlbl_domhsh_add_default(entry, &audit_info);
  257. break;
  258. case NETLBL_NLTYPE_CIPSOV4:
  259. if (!info->attrs[NLBL_MGMT_A_CV4DOI])
  260. goto adddef_failure;
  261. tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
  262. /* We should be holding a rcu_read_lock() here while we hold
  263. * the result but since the entry will always be deleted when
  264. * the CIPSO DOI is deleted we aren't going to keep the
  265. * lock. */
  266. rcu_read_lock();
  267. entry->type_def.cipsov4 = cipso_v4_doi_getdef(tmp_val);
  268. if (entry->type_def.cipsov4 == NULL) {
  269. rcu_read_unlock();
  270. goto adddef_failure;
  271. }
  272. ret_val = netlbl_domhsh_add_default(entry, &audit_info);
  273. rcu_read_unlock();
  274. break;
  275. default:
  276. goto adddef_failure;
  277. }
  278. if (ret_val != 0)
  279. goto adddef_failure;
  280. return 0;
  281. adddef_failure:
  282. kfree(entry);
  283. return ret_val;
  284. }
  285. /**
  286. * netlbl_mgmt_removedef - Handle a REMOVEDEF message
  287. * @skb: the NETLINK buffer
  288. * @info: the Generic NETLINK info block
  289. *
  290. * Description:
  291. * Process a user generated REMOVEDEF message and remove the default domain
  292. * mapping. Returns zero on success, negative values on failure.
  293. *
  294. */
  295. static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
  296. {
  297. struct netlbl_audit audit_info;
  298. netlbl_netlink_auditinfo(skb, &audit_info);
  299. return netlbl_domhsh_remove_default(&audit_info);
  300. }
  301. /**
  302. * netlbl_mgmt_listdef - Handle a LISTDEF message
  303. * @skb: the NETLINK buffer
  304. * @info: the Generic NETLINK info block
  305. *
  306. * Description:
  307. * Process a user generated LISTDEF message and dumps the default domain
  308. * mapping in a form suitable for use in a kernel generated LISTDEF message.
  309. * Returns zero on success, negative values on failure.
  310. *
  311. */
  312. static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
  313. {
  314. int ret_val = -ENOMEM;
  315. struct sk_buff *ans_skb = NULL;
  316. void *data;
  317. struct netlbl_dom_map *entry;
  318. ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  319. if (ans_skb == NULL)
  320. return -ENOMEM;
  321. data = netlbl_netlink_hdr_put(ans_skb,
  322. info->snd_pid,
  323. info->snd_seq,
  324. netlbl_mgmt_gnl_family.id,
  325. 0,
  326. NLBL_MGMT_C_LISTDEF);
  327. if (data == NULL)
  328. goto listdef_failure;
  329. rcu_read_lock();
  330. entry = netlbl_domhsh_getentry(NULL);
  331. if (entry == NULL) {
  332. ret_val = -ENOENT;
  333. goto listdef_failure_lock;
  334. }
  335. ret_val = nla_put_u32(ans_skb, NLBL_MGMT_A_PROTOCOL, entry->type);
  336. if (ret_val != 0)
  337. goto listdef_failure_lock;
  338. switch (entry->type) {
  339. case NETLBL_NLTYPE_CIPSOV4:
  340. ret_val = nla_put_u32(ans_skb,
  341. NLBL_MGMT_A_CV4DOI,
  342. entry->type_def.cipsov4->doi);
  343. if (ret_val != 0)
  344. goto listdef_failure_lock;
  345. break;
  346. }
  347. rcu_read_unlock();
  348. genlmsg_end(ans_skb, data);
  349. ret_val = genlmsg_unicast(ans_skb, info->snd_pid);
  350. if (ret_val != 0)
  351. goto listdef_failure;
  352. return 0;
  353. listdef_failure_lock:
  354. rcu_read_unlock();
  355. listdef_failure:
  356. kfree_skb(ans_skb);
  357. return ret_val;
  358. }
  359. /**
  360. * netlbl_mgmt_protocols_cb - Write an individual PROTOCOL message response
  361. * @skb: the skb to write to
  362. * @seq: the NETLINK sequence number
  363. * @cb: the NETLINK callback
  364. * @protocol: the NetLabel protocol to use in the message
  365. *
  366. * Description:
  367. * This function is to be used in conjunction with netlbl_mgmt_protocols() to
  368. * answer a application's PROTOCOLS message. Returns the size of the message
  369. * on success, negative values on failure.
  370. *
  371. */
  372. static int netlbl_mgmt_protocols_cb(struct sk_buff *skb,
  373. struct netlink_callback *cb,
  374. u32 protocol)
  375. {
  376. int ret_val = -ENOMEM;
  377. void *data;
  378. data = netlbl_netlink_hdr_put(skb,
  379. NETLINK_CB(cb->skb).pid,
  380. cb->nlh->nlmsg_seq,
  381. netlbl_mgmt_gnl_family.id,
  382. NLM_F_MULTI,
  383. NLBL_MGMT_C_PROTOCOLS);
  384. if (data == NULL)
  385. goto protocols_cb_failure;
  386. ret_val = nla_put_u32(skb, NLBL_MGMT_A_PROTOCOL, protocol);
  387. if (ret_val != 0)
  388. goto protocols_cb_failure;
  389. return genlmsg_end(skb, data);
  390. protocols_cb_failure:
  391. genlmsg_cancel(skb, data);
  392. return ret_val;
  393. }
  394. /**
  395. * netlbl_mgmt_protocols - Handle a PROTOCOLS message
  396. * @skb: the NETLINK buffer
  397. * @cb: the NETLINK callback
  398. *
  399. * Description:
  400. * Process a user generated PROTOCOLS message and respond accordingly.
  401. *
  402. */
  403. static int netlbl_mgmt_protocols(struct sk_buff *skb,
  404. struct netlink_callback *cb)
  405. {
  406. u32 protos_sent = cb->args[0];
  407. if (protos_sent == 0) {
  408. if (netlbl_mgmt_protocols_cb(skb,
  409. cb,
  410. NETLBL_NLTYPE_UNLABELED) < 0)
  411. goto protocols_return;
  412. protos_sent++;
  413. }
  414. if (protos_sent == 1) {
  415. if (netlbl_mgmt_protocols_cb(skb,
  416. cb,
  417. NETLBL_NLTYPE_CIPSOV4) < 0)
  418. goto protocols_return;
  419. protos_sent++;
  420. }
  421. protocols_return:
  422. cb->args[0] = protos_sent;
  423. return skb->len;
  424. }
  425. /**
  426. * netlbl_mgmt_version - Handle a VERSION message
  427. * @skb: the NETLINK buffer
  428. * @info: the Generic NETLINK info block
  429. *
  430. * Description:
  431. * Process a user generated VERSION message and respond accordingly. Returns
  432. * zero on success, negative values on failure.
  433. *
  434. */
  435. static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
  436. {
  437. int ret_val = -ENOMEM;
  438. struct sk_buff *ans_skb = NULL;
  439. void *data;
  440. ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
  441. if (ans_skb == NULL)
  442. return -ENOMEM;
  443. data = netlbl_netlink_hdr_put(ans_skb,
  444. info->snd_pid,
  445. info->snd_seq,
  446. netlbl_mgmt_gnl_family.id,
  447. 0,
  448. NLBL_MGMT_C_VERSION);
  449. if (data == NULL)
  450. goto version_failure;
  451. ret_val = nla_put_u32(ans_skb,
  452. NLBL_MGMT_A_VERSION,
  453. NETLBL_PROTO_VERSION);
  454. if (ret_val != 0)
  455. goto version_failure;
  456. genlmsg_end(ans_skb, data);
  457. ret_val = genlmsg_unicast(ans_skb, info->snd_pid);
  458. if (ret_val != 0)
  459. goto version_failure;
  460. return 0;
  461. version_failure:
  462. kfree_skb(ans_skb);
  463. return ret_val;
  464. }
  465. /*
  466. * NetLabel Generic NETLINK Command Definitions
  467. */
  468. static struct genl_ops netlbl_mgmt_genl_c_add = {
  469. .cmd = NLBL_MGMT_C_ADD,
  470. .flags = GENL_ADMIN_PERM,
  471. .policy = netlbl_mgmt_genl_policy,
  472. .doit = netlbl_mgmt_add,
  473. .dumpit = NULL,
  474. };
  475. static struct genl_ops netlbl_mgmt_genl_c_remove = {
  476. .cmd = NLBL_MGMT_C_REMOVE,
  477. .flags = GENL_ADMIN_PERM,
  478. .policy = netlbl_mgmt_genl_policy,
  479. .doit = netlbl_mgmt_remove,
  480. .dumpit = NULL,
  481. };
  482. static struct genl_ops netlbl_mgmt_genl_c_listall = {
  483. .cmd = NLBL_MGMT_C_LISTALL,
  484. .flags = 0,
  485. .policy = netlbl_mgmt_genl_policy,
  486. .doit = NULL,
  487. .dumpit = netlbl_mgmt_listall,
  488. };
  489. static struct genl_ops netlbl_mgmt_genl_c_adddef = {
  490. .cmd = NLBL_MGMT_C_ADDDEF,
  491. .flags = GENL_ADMIN_PERM,
  492. .policy = netlbl_mgmt_genl_policy,
  493. .doit = netlbl_mgmt_adddef,
  494. .dumpit = NULL,
  495. };
  496. static struct genl_ops netlbl_mgmt_genl_c_removedef = {
  497. .cmd = NLBL_MGMT_C_REMOVEDEF,
  498. .flags = GENL_ADMIN_PERM,
  499. .policy = netlbl_mgmt_genl_policy,
  500. .doit = netlbl_mgmt_removedef,
  501. .dumpit = NULL,
  502. };
  503. static struct genl_ops netlbl_mgmt_genl_c_listdef = {
  504. .cmd = NLBL_MGMT_C_LISTDEF,
  505. .flags = 0,
  506. .policy = netlbl_mgmt_genl_policy,
  507. .doit = netlbl_mgmt_listdef,
  508. .dumpit = NULL,
  509. };
  510. static struct genl_ops netlbl_mgmt_genl_c_protocols = {
  511. .cmd = NLBL_MGMT_C_PROTOCOLS,
  512. .flags = 0,
  513. .policy = netlbl_mgmt_genl_policy,
  514. .doit = NULL,
  515. .dumpit = netlbl_mgmt_protocols,
  516. };
  517. static struct genl_ops netlbl_mgmt_genl_c_version = {
  518. .cmd = NLBL_MGMT_C_VERSION,
  519. .flags = 0,
  520. .policy = netlbl_mgmt_genl_policy,
  521. .doit = netlbl_mgmt_version,
  522. .dumpit = NULL,
  523. };
  524. /*
  525. * NetLabel Generic NETLINK Protocol Functions
  526. */
  527. /**
  528. * netlbl_mgmt_genl_init - Register the NetLabel management component
  529. *
  530. * Description:
  531. * Register the NetLabel management component with the Generic NETLINK
  532. * mechanism. Returns zero on success, negative values on failure.
  533. *
  534. */
  535. int netlbl_mgmt_genl_init(void)
  536. {
  537. int ret_val;
  538. ret_val = genl_register_family(&netlbl_mgmt_gnl_family);
  539. if (ret_val != 0)
  540. return ret_val;
  541. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  542. &netlbl_mgmt_genl_c_add);
  543. if (ret_val != 0)
  544. return ret_val;
  545. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  546. &netlbl_mgmt_genl_c_remove);
  547. if (ret_val != 0)
  548. return ret_val;
  549. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  550. &netlbl_mgmt_genl_c_listall);
  551. if (ret_val != 0)
  552. return ret_val;
  553. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  554. &netlbl_mgmt_genl_c_adddef);
  555. if (ret_val != 0)
  556. return ret_val;
  557. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  558. &netlbl_mgmt_genl_c_removedef);
  559. if (ret_val != 0)
  560. return ret_val;
  561. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  562. &netlbl_mgmt_genl_c_listdef);
  563. if (ret_val != 0)
  564. return ret_val;
  565. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  566. &netlbl_mgmt_genl_c_protocols);
  567. if (ret_val != 0)
  568. return ret_val;
  569. ret_val = genl_register_ops(&netlbl_mgmt_gnl_family,
  570. &netlbl_mgmt_genl_c_version);
  571. if (ret_val != 0)
  572. return ret_val;
  573. return 0;
  574. }