337-v4.16-netfilter-nf_tables-get-rid-of-pernet-families.patch 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. From: Pablo Neira Ayuso <pablo@netfilter.org>
  2. Date: Tue, 9 Jan 2018 02:42:11 +0100
  3. Subject: [PATCH] netfilter: nf_tables: get rid of pernet families
  4. Now that we have a single table list for each netns, we can get rid of
  5. one pointer per family and the global afinfo list, thus, shrinking
  6. struct netns for nftables that now becomes 64 bytes smaller.
  7. And call __nft_release_afinfo() from __net_exit path accordingly to
  8. release netnamespace objects on removal.
  9. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  10. ---
  11. --- a/include/net/netfilter/nf_tables.h
  12. +++ b/include/net/netfilter/nf_tables.h
  13. @@ -977,8 +977,8 @@ struct nft_af_info {
  14. struct module *owner;
  15. };
  16. -int nft_register_afinfo(struct net *, struct nft_af_info *);
  17. -void nft_unregister_afinfo(struct net *, struct nft_af_info *);
  18. +int nft_register_afinfo(struct nft_af_info *);
  19. +void nft_unregister_afinfo(struct nft_af_info *);
  20. int nft_register_chain_type(const struct nf_chain_type *);
  21. void nft_unregister_chain_type(const struct nf_chain_type *);
  22. --- a/include/net/netns/nftables.h
  23. +++ b/include/net/netns/nftables.h
  24. @@ -7,15 +7,8 @@
  25. struct nft_af_info;
  26. struct netns_nftables {
  27. - struct list_head af_info;
  28. struct list_head tables;
  29. struct list_head commit_list;
  30. - struct nft_af_info *ipv4;
  31. - struct nft_af_info *ipv6;
  32. - struct nft_af_info *inet;
  33. - struct nft_af_info *arp;
  34. - struct nft_af_info *bridge;
  35. - struct nft_af_info *netdev;
  36. unsigned int base_seq;
  37. u8 gencursor;
  38. };
  39. --- a/net/bridge/netfilter/nf_tables_bridge.c
  40. +++ b/net/bridge/netfilter/nf_tables_bridge.c
  41. @@ -47,34 +47,6 @@ static struct nft_af_info nft_af_bridge
  42. .owner = THIS_MODULE,
  43. };
  44. -static int nf_tables_bridge_init_net(struct net *net)
  45. -{
  46. - net->nft.bridge = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
  47. - if (net->nft.bridge == NULL)
  48. - return -ENOMEM;
  49. -
  50. - memcpy(net->nft.bridge, &nft_af_bridge, sizeof(nft_af_bridge));
  51. -
  52. - if (nft_register_afinfo(net, net->nft.bridge) < 0)
  53. - goto err;
  54. -
  55. - return 0;
  56. -err:
  57. - kfree(net->nft.bridge);
  58. - return -ENOMEM;
  59. -}
  60. -
  61. -static void nf_tables_bridge_exit_net(struct net *net)
  62. -{
  63. - nft_unregister_afinfo(net, net->nft.bridge);
  64. - kfree(net->nft.bridge);
  65. -}
  66. -
  67. -static struct pernet_operations nf_tables_bridge_net_ops = {
  68. - .init = nf_tables_bridge_init_net,
  69. - .exit = nf_tables_bridge_exit_net,
  70. -};
  71. -
  72. static const struct nf_chain_type filter_bridge = {
  73. .name = "filter",
  74. .type = NFT_CHAIN_T_DEFAULT,
  75. @@ -98,17 +70,17 @@ static int __init nf_tables_bridge_init(
  76. {
  77. int ret;
  78. - ret = nft_register_chain_type(&filter_bridge);
  79. + ret = nft_register_afinfo(&nft_af_bridge);
  80. if (ret < 0)
  81. return ret;
  82. - ret = register_pernet_subsys(&nf_tables_bridge_net_ops);
  83. + ret = nft_register_chain_type(&filter_bridge);
  84. if (ret < 0)
  85. - goto err_register_subsys;
  86. + goto err_register_chain;
  87. return ret;
  88. -err_register_subsys:
  89. +err_register_chain:
  90. nft_unregister_chain_type(&filter_bridge);
  91. return ret;
  92. @@ -116,8 +88,8 @@ err_register_subsys:
  93. static void __exit nf_tables_bridge_exit(void)
  94. {
  95. - unregister_pernet_subsys(&nf_tables_bridge_net_ops);
  96. nft_unregister_chain_type(&filter_bridge);
  97. + nft_unregister_afinfo(&nft_af_bridge);
  98. }
  99. module_init(nf_tables_bridge_init);
  100. --- a/net/ipv4/netfilter/nf_tables_arp.c
  101. +++ b/net/ipv4/netfilter/nf_tables_arp.c
  102. @@ -32,34 +32,6 @@ static struct nft_af_info nft_af_arp __r
  103. .owner = THIS_MODULE,
  104. };
  105. -static int nf_tables_arp_init_net(struct net *net)
  106. -{
  107. - net->nft.arp = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
  108. - if (net->nft.arp== NULL)
  109. - return -ENOMEM;
  110. -
  111. - memcpy(net->nft.arp, &nft_af_arp, sizeof(nft_af_arp));
  112. -
  113. - if (nft_register_afinfo(net, net->nft.arp) < 0)
  114. - goto err;
  115. -
  116. - return 0;
  117. -err:
  118. - kfree(net->nft.arp);
  119. - return -ENOMEM;
  120. -}
  121. -
  122. -static void nf_tables_arp_exit_net(struct net *net)
  123. -{
  124. - nft_unregister_afinfo(net, net->nft.arp);
  125. - kfree(net->nft.arp);
  126. -}
  127. -
  128. -static struct pernet_operations nf_tables_arp_net_ops = {
  129. - .init = nf_tables_arp_init_net,
  130. - .exit = nf_tables_arp_exit_net,
  131. -};
  132. -
  133. static const struct nf_chain_type filter_arp = {
  134. .name = "filter",
  135. .type = NFT_CHAIN_T_DEFAULT,
  136. @@ -77,21 +49,26 @@ static int __init nf_tables_arp_init(voi
  137. {
  138. int ret;
  139. - ret = nft_register_chain_type(&filter_arp);
  140. + ret = nft_register_afinfo(&nft_af_arp);
  141. if (ret < 0)
  142. return ret;
  143. - ret = register_pernet_subsys(&nf_tables_arp_net_ops);
  144. + ret = nft_register_chain_type(&filter_arp);
  145. if (ret < 0)
  146. - nft_unregister_chain_type(&filter_arp);
  147. + goto err_register_chain;
  148. +
  149. + return 0;
  150. +
  151. +err_register_chain:
  152. + nft_unregister_chain_type(&filter_arp);
  153. return ret;
  154. }
  155. static void __exit nf_tables_arp_exit(void)
  156. {
  157. - unregister_pernet_subsys(&nf_tables_arp_net_ops);
  158. nft_unregister_chain_type(&filter_arp);
  159. + nft_unregister_afinfo(&nft_af_arp);
  160. }
  161. module_init(nf_tables_arp_init);
  162. --- a/net/ipv4/netfilter/nf_tables_ipv4.c
  163. +++ b/net/ipv4/netfilter/nf_tables_ipv4.c
  164. @@ -35,34 +35,6 @@ static struct nft_af_info nft_af_ipv4 __
  165. .owner = THIS_MODULE,
  166. };
  167. -static int nf_tables_ipv4_init_net(struct net *net)
  168. -{
  169. - net->nft.ipv4 = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
  170. - if (net->nft.ipv4 == NULL)
  171. - return -ENOMEM;
  172. -
  173. - memcpy(net->nft.ipv4, &nft_af_ipv4, sizeof(nft_af_ipv4));
  174. -
  175. - if (nft_register_afinfo(net, net->nft.ipv4) < 0)
  176. - goto err;
  177. -
  178. - return 0;
  179. -err:
  180. - kfree(net->nft.ipv4);
  181. - return -ENOMEM;
  182. -}
  183. -
  184. -static void nf_tables_ipv4_exit_net(struct net *net)
  185. -{
  186. - nft_unregister_afinfo(net, net->nft.ipv4);
  187. - kfree(net->nft.ipv4);
  188. -}
  189. -
  190. -static struct pernet_operations nf_tables_ipv4_net_ops = {
  191. - .init = nf_tables_ipv4_init_net,
  192. - .exit = nf_tables_ipv4_exit_net,
  193. -};
  194. -
  195. static const struct nf_chain_type filter_ipv4 = {
  196. .name = "filter",
  197. .type = NFT_CHAIN_T_DEFAULT,
  198. @@ -86,21 +58,25 @@ static int __init nf_tables_ipv4_init(vo
  199. {
  200. int ret;
  201. - ret = nft_register_chain_type(&filter_ipv4);
  202. + ret = nft_register_afinfo(&nft_af_ipv4);
  203. if (ret < 0)
  204. return ret;
  205. - ret = register_pernet_subsys(&nf_tables_ipv4_net_ops);
  206. + ret = nft_register_chain_type(&filter_ipv4);
  207. if (ret < 0)
  208. - nft_unregister_chain_type(&filter_ipv4);
  209. + goto err_register_chain;
  210. +
  211. + return 0;
  212. +err_register_chain:
  213. + nft_unregister_afinfo(&nft_af_ipv4);
  214. return ret;
  215. }
  216. static void __exit nf_tables_ipv4_exit(void)
  217. {
  218. - unregister_pernet_subsys(&nf_tables_ipv4_net_ops);
  219. nft_unregister_chain_type(&filter_ipv4);
  220. + nft_unregister_afinfo(&nft_af_ipv4);
  221. }
  222. module_init(nf_tables_ipv4_init);
  223. --- a/net/ipv6/netfilter/nf_tables_ipv6.c
  224. +++ b/net/ipv6/netfilter/nf_tables_ipv6.c
  225. @@ -33,34 +33,6 @@ static struct nft_af_info nft_af_ipv6 __
  226. .owner = THIS_MODULE,
  227. };
  228. -static int nf_tables_ipv6_init_net(struct net *net)
  229. -{
  230. - net->nft.ipv6 = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
  231. - if (net->nft.ipv6 == NULL)
  232. - return -ENOMEM;
  233. -
  234. - memcpy(net->nft.ipv6, &nft_af_ipv6, sizeof(nft_af_ipv6));
  235. -
  236. - if (nft_register_afinfo(net, net->nft.ipv6) < 0)
  237. - goto err;
  238. -
  239. - return 0;
  240. -err:
  241. - kfree(net->nft.ipv6);
  242. - return -ENOMEM;
  243. -}
  244. -
  245. -static void nf_tables_ipv6_exit_net(struct net *net)
  246. -{
  247. - nft_unregister_afinfo(net, net->nft.ipv6);
  248. - kfree(net->nft.ipv6);
  249. -}
  250. -
  251. -static struct pernet_operations nf_tables_ipv6_net_ops = {
  252. - .init = nf_tables_ipv6_init_net,
  253. - .exit = nf_tables_ipv6_exit_net,
  254. -};
  255. -
  256. static const struct nf_chain_type filter_ipv6 = {
  257. .name = "filter",
  258. .type = NFT_CHAIN_T_DEFAULT,
  259. @@ -84,20 +56,24 @@ static int __init nf_tables_ipv6_init(vo
  260. {
  261. int ret;
  262. - ret = nft_register_chain_type(&filter_ipv6);
  263. + ret = nft_register_afinfo(&nft_af_ipv6);
  264. if (ret < 0)
  265. return ret;
  266. - ret = register_pernet_subsys(&nf_tables_ipv6_net_ops);
  267. + ret = nft_register_chain_type(&filter_ipv6);
  268. if (ret < 0)
  269. - nft_unregister_chain_type(&filter_ipv6);
  270. + goto err_register_chain;
  271. +
  272. + return 0;
  273. +err_register_chain:
  274. + nft_unregister_afinfo(&nft_af_ipv6);
  275. return ret;
  276. }
  277. static void __exit nf_tables_ipv6_exit(void)
  278. {
  279. - unregister_pernet_subsys(&nf_tables_ipv6_net_ops);
  280. + nft_unregister_afinfo(&nft_af_ipv6);
  281. nft_unregister_chain_type(&filter_ipv6);
  282. }
  283. --- a/net/netfilter/nf_tables_api.c
  284. +++ b/net/netfilter/nf_tables_api.c
  285. @@ -26,6 +26,7 @@
  286. static LIST_HEAD(nf_tables_expressions);
  287. static LIST_HEAD(nf_tables_objects);
  288. static LIST_HEAD(nf_tables_flowtables);
  289. +static LIST_HEAD(nf_tables_af_info);
  290. /**
  291. * nft_register_afinfo - register nf_tables address family info
  292. @@ -35,17 +36,15 @@ static LIST_HEAD(nf_tables_flowtables);
  293. * Register the address family for use with nf_tables. Returns zero on
  294. * success or a negative errno code otherwise.
  295. */
  296. -int nft_register_afinfo(struct net *net, struct nft_af_info *afi)
  297. +int nft_register_afinfo(struct nft_af_info *afi)
  298. {
  299. nfnl_lock(NFNL_SUBSYS_NFTABLES);
  300. - list_add_tail_rcu(&afi->list, &net->nft.af_info);
  301. + list_add_tail_rcu(&afi->list, &nf_tables_af_info);
  302. nfnl_unlock(NFNL_SUBSYS_NFTABLES);
  303. return 0;
  304. }
  305. EXPORT_SYMBOL_GPL(nft_register_afinfo);
  306. -static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi);
  307. -
  308. /**
  309. * nft_unregister_afinfo - unregister nf_tables address family info
  310. *
  311. @@ -53,10 +52,9 @@ static void __nft_release_afinfo(struct
  312. *
  313. * Unregister the address family for use with nf_tables.
  314. */
  315. -void nft_unregister_afinfo(struct net *net, struct nft_af_info *afi)
  316. +void nft_unregister_afinfo(struct nft_af_info *afi)
  317. {
  318. nfnl_lock(NFNL_SUBSYS_NFTABLES);
  319. - __nft_release_afinfo(net, afi);
  320. list_del_rcu(&afi->list);
  321. nfnl_unlock(NFNL_SUBSYS_NFTABLES);
  322. }
  323. @@ -66,7 +64,7 @@ static struct nft_af_info *nft_afinfo_lo
  324. {
  325. struct nft_af_info *afi;
  326. - list_for_each_entry(afi, &net->nft.af_info, list) {
  327. + list_for_each_entry(afi, &nf_tables_af_info, list) {
  328. if (afi->family == family)
  329. return afi;
  330. }
  331. @@ -5064,15 +5062,12 @@ void nft_flow_table_iterate(struct net *
  332. void *data)
  333. {
  334. struct nft_flowtable *flowtable;
  335. - const struct nft_af_info *afi;
  336. const struct nft_table *table;
  337. rcu_read_lock();
  338. - list_for_each_entry_rcu(afi, &net->nft.af_info, list) {
  339. - list_for_each_entry_rcu(table, &net->nft.tables, list) {
  340. - list_for_each_entry_rcu(flowtable, &table->flowtables, list) {
  341. - iter(&flowtable->data, data);
  342. - }
  343. + list_for_each_entry_rcu(table, &net->nft.tables, list) {
  344. + list_for_each_entry_rcu(flowtable, &table->flowtables, list) {
  345. + iter(&flowtable->data, data);
  346. }
  347. }
  348. rcu_read_unlock();
  349. @@ -6564,21 +6559,6 @@ int nft_data_dump(struct sk_buff *skb, i
  350. }
  351. EXPORT_SYMBOL_GPL(nft_data_dump);
  352. -static int __net_init nf_tables_init_net(struct net *net)
  353. -{
  354. - INIT_LIST_HEAD(&net->nft.af_info);
  355. - INIT_LIST_HEAD(&net->nft.tables);
  356. - INIT_LIST_HEAD(&net->nft.commit_list);
  357. - net->nft.base_seq = 1;
  358. - return 0;
  359. -}
  360. -
  361. -static void __net_exit nf_tables_exit_net(struct net *net)
  362. -{
  363. - WARN_ON_ONCE(!list_empty(&net->nft.af_info));
  364. - WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
  365. -}
  366. -
  367. int __nft_release_basechain(struct nft_ctx *ctx)
  368. {
  369. struct nft_rule *rule, *nr;
  370. @@ -6599,8 +6579,7 @@ int __nft_release_basechain(struct nft_c
  371. }
  372. EXPORT_SYMBOL_GPL(__nft_release_basechain);
  373. -/* Called by nft_unregister_afinfo() from __net_exit path, nfnl_lock is held. */
  374. -static void __nft_release_afinfo(struct net *net, struct nft_af_info *afi)
  375. +static void __nft_release_afinfo(struct net *net)
  376. {
  377. struct nft_flowtable *flowtable, *nf;
  378. struct nft_table *table, *nt;
  379. @@ -6610,10 +6589,11 @@ static void __nft_release_afinfo(struct
  380. struct nft_set *set, *ns;
  381. struct nft_ctx ctx = {
  382. .net = net,
  383. - .family = afi->family,
  384. };
  385. list_for_each_entry_safe(table, nt, &net->nft.tables, list) {
  386. + ctx.family = table->afi->family;
  387. +
  388. list_for_each_entry(chain, &table->chains, list)
  389. nf_tables_unregister_hook(net, table, chain);
  390. list_for_each_entry(flowtable, &table->flowtables, list)
  391. @@ -6654,6 +6634,21 @@ static void __nft_release_afinfo(struct
  392. }
  393. }
  394. +static int __net_init nf_tables_init_net(struct net *net)
  395. +{
  396. + INIT_LIST_HEAD(&net->nft.tables);
  397. + INIT_LIST_HEAD(&net->nft.commit_list);
  398. + net->nft.base_seq = 1;
  399. + return 0;
  400. +}
  401. +
  402. +static void __net_exit nf_tables_exit_net(struct net *net)
  403. +{
  404. + __nft_release_afinfo(net);
  405. + WARN_ON_ONCE(!list_empty(&net->nft.tables));
  406. + WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
  407. +}
  408. +
  409. static struct pernet_operations nf_tables_net_ops = {
  410. .init = nf_tables_init_net,
  411. .exit = nf_tables_exit_net,
  412. --- a/net/netfilter/nf_tables_inet.c
  413. +++ b/net/netfilter/nf_tables_inet.c
  414. @@ -43,34 +43,6 @@ static struct nft_af_info nft_af_inet __
  415. .owner = THIS_MODULE,
  416. };
  417. -static int __net_init nf_tables_inet_init_net(struct net *net)
  418. -{
  419. - net->nft.inet = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
  420. - if (net->nft.inet == NULL)
  421. - return -ENOMEM;
  422. - memcpy(net->nft.inet, &nft_af_inet, sizeof(nft_af_inet));
  423. -
  424. - if (nft_register_afinfo(net, net->nft.inet) < 0)
  425. - goto err;
  426. -
  427. - return 0;
  428. -
  429. -err:
  430. - kfree(net->nft.inet);
  431. - return -ENOMEM;
  432. -}
  433. -
  434. -static void __net_exit nf_tables_inet_exit_net(struct net *net)
  435. -{
  436. - nft_unregister_afinfo(net, net->nft.inet);
  437. - kfree(net->nft.inet);
  438. -}
  439. -
  440. -static struct pernet_operations nf_tables_inet_net_ops = {
  441. - .init = nf_tables_inet_init_net,
  442. - .exit = nf_tables_inet_exit_net,
  443. -};
  444. -
  445. static const struct nf_chain_type filter_inet = {
  446. .name = "filter",
  447. .type = NFT_CHAIN_T_DEFAULT,
  448. @@ -94,21 +66,24 @@ static int __init nf_tables_inet_init(vo
  449. {
  450. int ret;
  451. - ret = nft_register_chain_type(&filter_inet);
  452. - if (ret < 0)
  453. + if (nft_register_afinfo(&nft_af_inet) < 0)
  454. return ret;
  455. - ret = register_pernet_subsys(&nf_tables_inet_net_ops);
  456. + ret = nft_register_chain_type(&filter_inet);
  457. if (ret < 0)
  458. - nft_unregister_chain_type(&filter_inet);
  459. + goto err_register_chain;
  460. +
  461. + return ret;
  462. +err_register_chain:
  463. + nft_unregister_afinfo(&nft_af_inet);
  464. return ret;
  465. }
  466. static void __exit nf_tables_inet_exit(void)
  467. {
  468. - unregister_pernet_subsys(&nf_tables_inet_net_ops);
  469. nft_unregister_chain_type(&filter_inet);
  470. + nft_unregister_afinfo(&nft_af_inet);
  471. }
  472. module_init(nf_tables_inet_init);
  473. --- a/net/netfilter/nf_tables_netdev.c
  474. +++ b/net/netfilter/nf_tables_netdev.c
  475. @@ -43,34 +43,6 @@ static struct nft_af_info nft_af_netdev
  476. .owner = THIS_MODULE,
  477. };
  478. -static int nf_tables_netdev_init_net(struct net *net)
  479. -{
  480. - net->nft.netdev = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
  481. - if (net->nft.netdev == NULL)
  482. - return -ENOMEM;
  483. -
  484. - memcpy(net->nft.netdev, &nft_af_netdev, sizeof(nft_af_netdev));
  485. -
  486. - if (nft_register_afinfo(net, net->nft.netdev) < 0)
  487. - goto err;
  488. -
  489. - return 0;
  490. -err:
  491. - kfree(net->nft.netdev);
  492. - return -ENOMEM;
  493. -}
  494. -
  495. -static void nf_tables_netdev_exit_net(struct net *net)
  496. -{
  497. - nft_unregister_afinfo(net, net->nft.netdev);
  498. - kfree(net->nft.netdev);
  499. -}
  500. -
  501. -static struct pernet_operations nf_tables_netdev_net_ops = {
  502. - .init = nf_tables_netdev_init_net,
  503. - .exit = nf_tables_netdev_exit_net,
  504. -};
  505. -
  506. static const struct nf_chain_type nft_filter_chain_netdev = {
  507. .name = "filter",
  508. .type = NFT_CHAIN_T_DEFAULT,
  509. @@ -145,32 +117,32 @@ static int __init nf_tables_netdev_init(
  510. {
  511. int ret;
  512. - ret = nft_register_chain_type(&nft_filter_chain_netdev);
  513. - if (ret)
  514. + if (nft_register_afinfo(&nft_af_netdev) < 0)
  515. return ret;
  516. - ret = register_pernet_subsys(&nf_tables_netdev_net_ops);
  517. + ret = nft_register_chain_type(&nft_filter_chain_netdev);
  518. if (ret)
  519. - goto err1;
  520. + goto err_register_chain_type;
  521. ret = register_netdevice_notifier(&nf_tables_netdev_notifier);
  522. if (ret)
  523. - goto err2;
  524. + goto err_register_netdevice_notifier;
  525. return 0;
  526. -err2:
  527. - unregister_pernet_subsys(&nf_tables_netdev_net_ops);
  528. -err1:
  529. +err_register_netdevice_notifier:
  530. nft_unregister_chain_type(&nft_filter_chain_netdev);
  531. +err_register_chain_type:
  532. + nft_unregister_afinfo(&nft_af_netdev);
  533. +
  534. return ret;
  535. }
  536. static void __exit nf_tables_netdev_exit(void)
  537. {
  538. unregister_netdevice_notifier(&nf_tables_netdev_notifier);
  539. - unregister_pernet_subsys(&nf_tables_netdev_net_ops);
  540. nft_unregister_chain_type(&nft_filter_chain_netdev);
  541. + nft_unregister_afinfo(&nft_af_netdev);
  542. }
  543. module_init(nf_tables_netdev_init);