338-v4.16-netfilter-nf_tables-get-rid-of-struct-nft_af_info-ab.patch 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. From: Pablo Neira Ayuso <pablo@netfilter.org>
  2. Date: Tue, 9 Jan 2018 02:48:47 +0100
  3. Subject: [PATCH] netfilter: nf_tables: get rid of struct nft_af_info
  4. abstraction
  5. Remove the infrastructure to register/unregister nft_af_info structure,
  6. this structure stores no useful information anymore.
  7. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  8. ---
  9. --- a/include/net/netfilter/nf_tables.h
  10. +++ b/include/net/netfilter/nf_tables.h
  11. @@ -958,28 +958,12 @@ struct nft_table {
  12. struct list_head flowtables;
  13. u64 hgenerator;
  14. u32 use;
  15. - u16 flags:14,
  16. + u16 family:6,
  17. + flags:8,
  18. genmask:2;
  19. - struct nft_af_info *afi;
  20. char *name;
  21. };
  22. -/**
  23. - * struct nft_af_info - nf_tables address family info
  24. - *
  25. - * @list: used internally
  26. - * @family: address family
  27. - * @owner: module owner
  28. - */
  29. -struct nft_af_info {
  30. - struct list_head list;
  31. - int family;
  32. - struct module *owner;
  33. -};
  34. -
  35. -int nft_register_afinfo(struct nft_af_info *);
  36. -void nft_unregister_afinfo(struct nft_af_info *);
  37. -
  38. int nft_register_chain_type(const struct nf_chain_type *);
  39. void nft_unregister_chain_type(const struct nf_chain_type *);
  40. @@ -1147,9 +1131,6 @@ void nft_trace_notify(struct nft_tracein
  41. #define nft_dereference(p) \
  42. nfnl_dereference(p, NFNL_SUBSYS_NFTABLES)
  43. -#define MODULE_ALIAS_NFT_FAMILY(family) \
  44. - MODULE_ALIAS("nft-afinfo-" __stringify(family))
  45. -
  46. #define MODULE_ALIAS_NFT_CHAIN(family, name) \
  47. MODULE_ALIAS("nft-chain-" __stringify(family) "-" name)
  48. --- a/net/bridge/netfilter/nf_tables_bridge.c
  49. +++ b/net/bridge/netfilter/nf_tables_bridge.c
  50. @@ -42,11 +42,6 @@ nft_do_chain_bridge(void *priv,
  51. return nft_do_chain(&pkt, priv);
  52. }
  53. -static struct nft_af_info nft_af_bridge __read_mostly = {
  54. - .family = NFPROTO_BRIDGE,
  55. - .owner = THIS_MODULE,
  56. -};
  57. -
  58. static const struct nf_chain_type filter_bridge = {
  59. .name = "filter",
  60. .type = NFT_CHAIN_T_DEFAULT,
  61. @@ -68,28 +63,12 @@ static const struct nf_chain_type filter
  62. static int __init nf_tables_bridge_init(void)
  63. {
  64. - int ret;
  65. -
  66. - ret = nft_register_afinfo(&nft_af_bridge);
  67. - if (ret < 0)
  68. - return ret;
  69. -
  70. - ret = nft_register_chain_type(&filter_bridge);
  71. - if (ret < 0)
  72. - goto err_register_chain;
  73. -
  74. - return ret;
  75. -
  76. -err_register_chain:
  77. - nft_unregister_chain_type(&filter_bridge);
  78. -
  79. - return ret;
  80. + return nft_register_chain_type(&filter_bridge);
  81. }
  82. static void __exit nf_tables_bridge_exit(void)
  83. {
  84. nft_unregister_chain_type(&filter_bridge);
  85. - nft_unregister_afinfo(&nft_af_bridge);
  86. }
  87. module_init(nf_tables_bridge_init);
  88. @@ -97,4 +76,4 @@ module_exit(nf_tables_bridge_exit);
  89. MODULE_LICENSE("GPL");
  90. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  91. -MODULE_ALIAS_NFT_FAMILY(AF_BRIDGE);
  92. +MODULE_ALIAS_NFT_CHAIN(AF_BRIDGE, "filter");
  93. --- a/net/ipv4/netfilter/nf_tables_arp.c
  94. +++ b/net/ipv4/netfilter/nf_tables_arp.c
  95. @@ -27,11 +27,6 @@ nft_do_chain_arp(void *priv,
  96. return nft_do_chain(&pkt, priv);
  97. }
  98. -static struct nft_af_info nft_af_arp __read_mostly = {
  99. - .family = NFPROTO_ARP,
  100. - .owner = THIS_MODULE,
  101. -};
  102. -
  103. static const struct nf_chain_type filter_arp = {
  104. .name = "filter",
  105. .type = NFT_CHAIN_T_DEFAULT,
  106. @@ -47,28 +42,12 @@ static const struct nf_chain_type filter
  107. static int __init nf_tables_arp_init(void)
  108. {
  109. - int ret;
  110. -
  111. - ret = nft_register_afinfo(&nft_af_arp);
  112. - if (ret < 0)
  113. - return ret;
  114. -
  115. - ret = nft_register_chain_type(&filter_arp);
  116. - if (ret < 0)
  117. - goto err_register_chain;
  118. -
  119. - return 0;
  120. -
  121. -err_register_chain:
  122. - nft_unregister_chain_type(&filter_arp);
  123. -
  124. - return ret;
  125. + return nft_register_chain_type(&filter_arp);
  126. }
  127. static void __exit nf_tables_arp_exit(void)
  128. {
  129. nft_unregister_chain_type(&filter_arp);
  130. - nft_unregister_afinfo(&nft_af_arp);
  131. }
  132. module_init(nf_tables_arp_init);
  133. @@ -76,4 +55,4 @@ module_exit(nf_tables_arp_exit);
  134. MODULE_LICENSE("GPL");
  135. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  136. -MODULE_ALIAS_NFT_FAMILY(3); /* NFPROTO_ARP */
  137. +MODULE_ALIAS_NFT_CHAIN(3, "filter"); /* NFPROTO_ARP */
  138. --- a/net/ipv4/netfilter/nf_tables_ipv4.c
  139. +++ b/net/ipv4/netfilter/nf_tables_ipv4.c
  140. @@ -30,11 +30,6 @@ static unsigned int nft_do_chain_ipv4(vo
  141. return nft_do_chain(&pkt, priv);
  142. }
  143. -static struct nft_af_info nft_af_ipv4 __read_mostly = {
  144. - .family = NFPROTO_IPV4,
  145. - .owner = THIS_MODULE,
  146. -};
  147. -
  148. static const struct nf_chain_type filter_ipv4 = {
  149. .name = "filter",
  150. .type = NFT_CHAIN_T_DEFAULT,
  151. @@ -56,27 +51,12 @@ static const struct nf_chain_type filter
  152. static int __init nf_tables_ipv4_init(void)
  153. {
  154. - int ret;
  155. -
  156. - ret = nft_register_afinfo(&nft_af_ipv4);
  157. - if (ret < 0)
  158. - return ret;
  159. -
  160. - ret = nft_register_chain_type(&filter_ipv4);
  161. - if (ret < 0)
  162. - goto err_register_chain;
  163. -
  164. - return 0;
  165. -
  166. -err_register_chain:
  167. - nft_unregister_afinfo(&nft_af_ipv4);
  168. - return ret;
  169. + return nft_register_chain_type(&filter_ipv4);
  170. }
  171. static void __exit nf_tables_ipv4_exit(void)
  172. {
  173. nft_unregister_chain_type(&filter_ipv4);
  174. - nft_unregister_afinfo(&nft_af_ipv4);
  175. }
  176. module_init(nf_tables_ipv4_init);
  177. @@ -84,4 +64,4 @@ module_exit(nf_tables_ipv4_exit);
  178. MODULE_LICENSE("GPL");
  179. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  180. -MODULE_ALIAS_NFT_FAMILY(AF_INET);
  181. +MODULE_ALIAS_NFT_CHAIN(AF_INET, "filter");
  182. --- a/net/ipv6/netfilter/nf_tables_ipv6.c
  183. +++ b/net/ipv6/netfilter/nf_tables_ipv6.c
  184. @@ -28,11 +28,6 @@ static unsigned int nft_do_chain_ipv6(vo
  185. return nft_do_chain(&pkt, priv);
  186. }
  187. -static struct nft_af_info nft_af_ipv6 __read_mostly = {
  188. - .family = NFPROTO_IPV6,
  189. - .owner = THIS_MODULE,
  190. -};
  191. -
  192. static const struct nf_chain_type filter_ipv6 = {
  193. .name = "filter",
  194. .type = NFT_CHAIN_T_DEFAULT,
  195. @@ -54,26 +49,11 @@ static const struct nf_chain_type filter
  196. static int __init nf_tables_ipv6_init(void)
  197. {
  198. - int ret;
  199. -
  200. - ret = nft_register_afinfo(&nft_af_ipv6);
  201. - if (ret < 0)
  202. - return ret;
  203. -
  204. - ret = nft_register_chain_type(&filter_ipv6);
  205. - if (ret < 0)
  206. - goto err_register_chain;
  207. -
  208. - return 0;
  209. -
  210. -err_register_chain:
  211. - nft_unregister_afinfo(&nft_af_ipv6);
  212. - return ret;
  213. + return nft_register_chain_type(&filter_ipv6);
  214. }
  215. static void __exit nf_tables_ipv6_exit(void)
  216. {
  217. - nft_unregister_afinfo(&nft_af_ipv6);
  218. nft_unregister_chain_type(&filter_ipv6);
  219. }
  220. @@ -82,4 +62,4 @@ module_exit(nf_tables_ipv6_exit);
  221. MODULE_LICENSE("GPL");
  222. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  223. -MODULE_ALIAS_NFT_FAMILY(AF_INET6);
  224. +MODULE_ALIAS_NFT_CHAIN(AF_INET6, "filter");
  225. --- a/net/netfilter/nf_tables_api.c
  226. +++ b/net/netfilter/nf_tables_api.c
  227. @@ -26,71 +26,6 @@
  228. static LIST_HEAD(nf_tables_expressions);
  229. static LIST_HEAD(nf_tables_objects);
  230. static LIST_HEAD(nf_tables_flowtables);
  231. -static LIST_HEAD(nf_tables_af_info);
  232. -
  233. -/**
  234. - * nft_register_afinfo - register nf_tables address family info
  235. - *
  236. - * @afi: address family info to register
  237. - *
  238. - * Register the address family for use with nf_tables. Returns zero on
  239. - * success or a negative errno code otherwise.
  240. - */
  241. -int nft_register_afinfo(struct nft_af_info *afi)
  242. -{
  243. - nfnl_lock(NFNL_SUBSYS_NFTABLES);
  244. - list_add_tail_rcu(&afi->list, &nf_tables_af_info);
  245. - nfnl_unlock(NFNL_SUBSYS_NFTABLES);
  246. - return 0;
  247. -}
  248. -EXPORT_SYMBOL_GPL(nft_register_afinfo);
  249. -
  250. -/**
  251. - * nft_unregister_afinfo - unregister nf_tables address family info
  252. - *
  253. - * @afi: address family info to unregister
  254. - *
  255. - * Unregister the address family for use with nf_tables.
  256. - */
  257. -void nft_unregister_afinfo(struct nft_af_info *afi)
  258. -{
  259. - nfnl_lock(NFNL_SUBSYS_NFTABLES);
  260. - list_del_rcu(&afi->list);
  261. - nfnl_unlock(NFNL_SUBSYS_NFTABLES);
  262. -}
  263. -EXPORT_SYMBOL_GPL(nft_unregister_afinfo);
  264. -
  265. -static struct nft_af_info *nft_afinfo_lookup(struct net *net, int family)
  266. -{
  267. - struct nft_af_info *afi;
  268. -
  269. - list_for_each_entry(afi, &nf_tables_af_info, list) {
  270. - if (afi->family == family)
  271. - return afi;
  272. - }
  273. - return NULL;
  274. -}
  275. -
  276. -static struct nft_af_info *
  277. -nf_tables_afinfo_lookup(struct net *net, int family, bool autoload)
  278. -{
  279. - struct nft_af_info *afi;
  280. -
  281. - afi = nft_afinfo_lookup(net, family);
  282. - if (afi != NULL)
  283. - return afi;
  284. -#ifdef CONFIG_MODULES
  285. - if (autoload) {
  286. - nfnl_unlock(NFNL_SUBSYS_NFTABLES);
  287. - request_module("nft-afinfo-%u", family);
  288. - nfnl_lock(NFNL_SUBSYS_NFTABLES);
  289. - afi = nft_afinfo_lookup(net, family);
  290. - if (afi != NULL)
  291. - return ERR_PTR(-EAGAIN);
  292. - }
  293. -#endif
  294. - return ERR_PTR(-EAFNOSUPPORT);
  295. -}
  296. static void nft_ctx_init(struct nft_ctx *ctx,
  297. struct net *net,
  298. @@ -434,7 +369,7 @@ static struct nft_table *nft_table_looku
  299. list_for_each_entry(table, &net->nft.tables, list) {
  300. if (!nla_strcmp(nla, table->name) &&
  301. - table->afi->family == family &&
  302. + table->family == family &&
  303. nft_active_genmask(table, genmask))
  304. return table;
  305. }
  306. @@ -575,7 +510,7 @@ static int nf_tables_dump_tables(struct
  307. cb->seq = net->nft.base_seq;
  308. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  309. - if (family != NFPROTO_UNSPEC && family != table->afi->family)
  310. + if (family != NFPROTO_UNSPEC && family != table->family)
  311. continue;
  312. if (idx < s_idx)
  313. @@ -589,7 +524,7 @@ static int nf_tables_dump_tables(struct
  314. NETLINK_CB(cb->skb).portid,
  315. cb->nlh->nlmsg_seq,
  316. NFT_MSG_NEWTABLE, NLM_F_MULTI,
  317. - table->afi->family, table) < 0)
  318. + table->family, table) < 0)
  319. goto done;
  320. nl_dump_check_consistent(cb, nlmsg_hdr(skb));
  321. @@ -609,7 +544,6 @@ static int nf_tables_gettable(struct net
  322. {
  323. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  324. u8 genmask = nft_genmask_cur(net);
  325. - const struct nft_af_info *afi;
  326. const struct nft_table *table;
  327. struct sk_buff *skb2;
  328. int family = nfmsg->nfgen_family;
  329. @@ -622,11 +556,7 @@ static int nf_tables_gettable(struct net
  330. return netlink_dump_start(nlsk, skb, nlh, &c);
  331. }
  332. - afi = nf_tables_afinfo_lookup(net, family, false);
  333. - if (IS_ERR(afi))
  334. - return PTR_ERR(afi);
  335. -
  336. - table = nf_tables_table_lookup(net, nla[NFTA_TABLE_NAME], afi->family,
  337. + table = nf_tables_table_lookup(net, nla[NFTA_TABLE_NAME], family,
  338. genmask);
  339. if (IS_ERR(table))
  340. return PTR_ERR(table);
  341. @@ -746,19 +676,14 @@ static int nf_tables_newtable(struct net
  342. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  343. u8 genmask = nft_genmask_next(net);
  344. const struct nlattr *name;
  345. - struct nft_af_info *afi;
  346. struct nft_table *table;
  347. int family = nfmsg->nfgen_family;
  348. u32 flags = 0;
  349. struct nft_ctx ctx;
  350. int err;
  351. - afi = nf_tables_afinfo_lookup(net, family, true);
  352. - if (IS_ERR(afi))
  353. - return PTR_ERR(afi);
  354. -
  355. name = nla[NFTA_TABLE_NAME];
  356. - table = nf_tables_table_lookup(net, name, afi->family, genmask);
  357. + table = nf_tables_table_lookup(net, name, family, genmask);
  358. if (IS_ERR(table)) {
  359. if (PTR_ERR(table) != -ENOENT)
  360. return PTR_ERR(table);
  361. @@ -768,7 +693,7 @@ static int nf_tables_newtable(struct net
  362. if (nlh->nlmsg_flags & NLM_F_REPLACE)
  363. return -EOPNOTSUPP;
  364. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  365. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  366. return nf_tables_updtable(&ctx);
  367. }
  368. @@ -778,40 +703,34 @@ static int nf_tables_newtable(struct net
  369. return -EINVAL;
  370. }
  371. - err = -EAFNOSUPPORT;
  372. - if (!try_module_get(afi->owner))
  373. - goto err1;
  374. -
  375. err = -ENOMEM;
  376. table = kzalloc(sizeof(*table), GFP_KERNEL);
  377. if (table == NULL)
  378. - goto err2;
  379. + goto err_kzalloc;
  380. table->name = nla_strdup(name, GFP_KERNEL);
  381. if (table->name == NULL)
  382. - goto err3;
  383. + goto err_strdup;
  384. INIT_LIST_HEAD(&table->chains);
  385. INIT_LIST_HEAD(&table->sets);
  386. INIT_LIST_HEAD(&table->objects);
  387. INIT_LIST_HEAD(&table->flowtables);
  388. - table->afi = afi;
  389. + table->family = family;
  390. table->flags = flags;
  391. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  392. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  393. err = nft_trans_table_add(&ctx, NFT_MSG_NEWTABLE);
  394. if (err < 0)
  395. - goto err4;
  396. + goto err_trans;
  397. list_add_tail_rcu(&table->list, &net->nft.tables);
  398. return 0;
  399. -err4:
  400. +err_trans:
  401. kfree(table->name);
  402. -err3:
  403. +err_strdup:
  404. kfree(table);
  405. -err2:
  406. - module_put(afi->owner);
  407. -err1:
  408. +err_kzalloc:
  409. return err;
  410. }
  411. @@ -882,10 +801,10 @@ static int nft_flush(struct nft_ctx *ctx
  412. int err = 0;
  413. list_for_each_entry_safe(table, nt, &ctx->net->nft.tables, list) {
  414. - if (family != AF_UNSPEC && table->afi->family != family)
  415. + if (family != AF_UNSPEC && table->family != family)
  416. continue;
  417. - ctx->family = table->afi->family;
  418. + ctx->family = table->family;
  419. if (!nft_is_active_next(ctx->net, table))
  420. continue;
  421. @@ -911,7 +830,6 @@ static int nf_tables_deltable(struct net
  422. {
  423. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  424. u8 genmask = nft_genmask_next(net);
  425. - struct nft_af_info *afi;
  426. struct nft_table *table;
  427. int family = nfmsg->nfgen_family;
  428. struct nft_ctx ctx;
  429. @@ -920,11 +838,7 @@ static int nf_tables_deltable(struct net
  430. if (family == AF_UNSPEC || nla[NFTA_TABLE_NAME] == NULL)
  431. return nft_flush(&ctx, family);
  432. - afi = nf_tables_afinfo_lookup(net, family, false);
  433. - if (IS_ERR(afi))
  434. - return PTR_ERR(afi);
  435. -
  436. - table = nf_tables_table_lookup(net, nla[NFTA_TABLE_NAME], afi->family,
  437. + table = nf_tables_table_lookup(net, nla[NFTA_TABLE_NAME], family,
  438. genmask);
  439. if (IS_ERR(table))
  440. return PTR_ERR(table);
  441. @@ -933,7 +847,7 @@ static int nf_tables_deltable(struct net
  442. table->use > 0)
  443. return -EBUSY;
  444. - ctx.family = afi->family;
  445. + ctx.family = family;
  446. ctx.table = table;
  447. return nft_flush_table(&ctx);
  448. @@ -945,7 +859,6 @@ static void nf_tables_table_destroy(stru
  449. kfree(ctx->table->name);
  450. kfree(ctx->table);
  451. - module_put(ctx->table->afi->owner);
  452. }
  453. int nft_register_chain_type(const struct nf_chain_type *ctype)
  454. @@ -1174,7 +1087,7 @@ static int nf_tables_dump_chains(struct
  455. cb->seq = net->nft.base_seq;
  456. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  457. - if (family != NFPROTO_UNSPEC && family != table->afi->family)
  458. + if (family != NFPROTO_UNSPEC && family != table->family)
  459. continue;
  460. list_for_each_entry_rcu(chain, &table->chains, list) {
  461. @@ -1190,7 +1103,7 @@ static int nf_tables_dump_chains(struct
  462. cb->nlh->nlmsg_seq,
  463. NFT_MSG_NEWCHAIN,
  464. NLM_F_MULTI,
  465. - table->afi->family, table,
  466. + table->family, table,
  467. chain) < 0)
  468. goto done;
  469. @@ -1212,7 +1125,6 @@ static int nf_tables_getchain(struct net
  470. {
  471. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  472. u8 genmask = nft_genmask_cur(net);
  473. - const struct nft_af_info *afi;
  474. const struct nft_table *table;
  475. const struct nft_chain *chain;
  476. struct sk_buff *skb2;
  477. @@ -1226,11 +1138,7 @@ static int nf_tables_getchain(struct net
  478. return netlink_dump_start(nlsk, skb, nlh, &c);
  479. }
  480. - afi = nf_tables_afinfo_lookup(net, family, false);
  481. - if (IS_ERR(afi))
  482. - return PTR_ERR(afi);
  483. -
  484. - table = nf_tables_table_lookup(net, nla[NFTA_CHAIN_TABLE], afi->family,
  485. + table = nf_tables_table_lookup(net, nla[NFTA_CHAIN_TABLE], family,
  486. genmask);
  487. if (IS_ERR(table))
  488. return PTR_ERR(table);
  489. @@ -1612,7 +1520,6 @@ static int nf_tables_newchain(struct net
  490. const struct nlattr * uninitialized_var(name);
  491. u8 genmask = nft_genmask_next(net);
  492. int family = nfmsg->nfgen_family;
  493. - struct nft_af_info *afi;
  494. struct nft_table *table;
  495. struct nft_chain *chain;
  496. u8 policy = NF_ACCEPT;
  497. @@ -1622,11 +1529,7 @@ static int nf_tables_newchain(struct net
  498. create = nlh->nlmsg_flags & NLM_F_CREATE ? true : false;
  499. - afi = nf_tables_afinfo_lookup(net, family, true);
  500. - if (IS_ERR(afi))
  501. - return PTR_ERR(afi);
  502. -
  503. - table = nf_tables_table_lookup(net, nla[NFTA_CHAIN_TABLE], afi->family,
  504. + table = nf_tables_table_lookup(net, nla[NFTA_CHAIN_TABLE], family,
  505. genmask);
  506. if (IS_ERR(table))
  507. return PTR_ERR(table);
  508. @@ -1667,7 +1570,7 @@ static int nf_tables_newchain(struct net
  509. }
  510. }
  511. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, chain, nla);
  512. + nft_ctx_init(&ctx, net, skb, nlh, family, table, chain, nla);
  513. if (chain != NULL) {
  514. if (nlh->nlmsg_flags & NLM_F_EXCL)
  515. @@ -1688,7 +1591,6 @@ static int nf_tables_delchain(struct net
  516. {
  517. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  518. u8 genmask = nft_genmask_next(net);
  519. - struct nft_af_info *afi;
  520. struct nft_table *table;
  521. struct nft_chain *chain;
  522. struct nft_rule *rule;
  523. @@ -1697,11 +1599,7 @@ static int nf_tables_delchain(struct net
  524. u32 use;
  525. int err;
  526. - afi = nf_tables_afinfo_lookup(net, family, false);
  527. - if (IS_ERR(afi))
  528. - return PTR_ERR(afi);
  529. -
  530. - table = nf_tables_table_lookup(net, nla[NFTA_CHAIN_TABLE], afi->family,
  531. + table = nf_tables_table_lookup(net, nla[NFTA_CHAIN_TABLE], family,
  532. genmask);
  533. if (IS_ERR(table))
  534. return PTR_ERR(table);
  535. @@ -1714,7 +1612,7 @@ static int nf_tables_delchain(struct net
  536. chain->use > 0)
  537. return -EBUSY;
  538. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, chain, nla);
  539. + nft_ctx_init(&ctx, net, skb, nlh, family, table, chain, nla);
  540. use = chain->use;
  541. list_for_each_entry(rule, &chain->rules, list) {
  542. @@ -2145,7 +2043,7 @@ static int nf_tables_dump_rules(struct s
  543. cb->seq = net->nft.base_seq;
  544. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  545. - if (family != NFPROTO_UNSPEC && family != table->afi->family)
  546. + if (family != NFPROTO_UNSPEC && family != table->family)
  547. continue;
  548. if (ctx && ctx->table && strcmp(ctx->table, table->name) != 0)
  549. @@ -2168,7 +2066,7 @@ static int nf_tables_dump_rules(struct s
  550. cb->nlh->nlmsg_seq,
  551. NFT_MSG_NEWRULE,
  552. NLM_F_MULTI | NLM_F_APPEND,
  553. - table->afi->family,
  554. + table->family,
  555. table, chain, rule) < 0)
  556. goto done;
  557. @@ -2204,7 +2102,6 @@ static int nf_tables_getrule(struct net
  558. {
  559. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  560. u8 genmask = nft_genmask_cur(net);
  561. - const struct nft_af_info *afi;
  562. const struct nft_table *table;
  563. const struct nft_chain *chain;
  564. const struct nft_rule *rule;
  565. @@ -2248,11 +2145,7 @@ static int nf_tables_getrule(struct net
  566. return netlink_dump_start(nlsk, skb, nlh, &c);
  567. }
  568. - afi = nf_tables_afinfo_lookup(net, family, false);
  569. - if (IS_ERR(afi))
  570. - return PTR_ERR(afi);
  571. -
  572. - table = nf_tables_table_lookup(net, nla[NFTA_RULE_TABLE], afi->family,
  573. + table = nf_tables_table_lookup(net, nla[NFTA_RULE_TABLE], family,
  574. genmask);
  575. if (IS_ERR(table))
  576. return PTR_ERR(table);
  577. @@ -2318,7 +2211,7 @@ static int nf_tables_newrule(struct net
  578. {
  579. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  580. u8 genmask = nft_genmask_next(net);
  581. - struct nft_af_info *afi;
  582. + int family = nfmsg->nfgen_family;
  583. struct nft_table *table;
  584. struct nft_chain *chain;
  585. struct nft_rule *rule, *old_rule = NULL;
  586. @@ -2334,11 +2227,7 @@ static int nf_tables_newrule(struct net
  587. create = nlh->nlmsg_flags & NLM_F_CREATE ? true : false;
  588. - afi = nf_tables_afinfo_lookup(net, nfmsg->nfgen_family, create);
  589. - if (IS_ERR(afi))
  590. - return PTR_ERR(afi);
  591. -
  592. - table = nf_tables_table_lookup(net, nla[NFTA_RULE_TABLE], afi->family,
  593. + table = nf_tables_table_lookup(net, nla[NFTA_RULE_TABLE], family,
  594. genmask);
  595. if (IS_ERR(table))
  596. return PTR_ERR(table);
  597. @@ -2378,7 +2267,7 @@ static int nf_tables_newrule(struct net
  598. return PTR_ERR(old_rule);
  599. }
  600. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, chain, nla);
  601. + nft_ctx_init(&ctx, net, skb, nlh, family, table, chain, nla);
  602. n = 0;
  603. size = 0;
  604. @@ -2500,18 +2389,13 @@ static int nf_tables_delrule(struct net
  605. {
  606. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  607. u8 genmask = nft_genmask_next(net);
  608. - struct nft_af_info *afi;
  609. struct nft_table *table;
  610. struct nft_chain *chain = NULL;
  611. struct nft_rule *rule;
  612. int family = nfmsg->nfgen_family, err = 0;
  613. struct nft_ctx ctx;
  614. - afi = nf_tables_afinfo_lookup(net, family, false);
  615. - if (IS_ERR(afi))
  616. - return PTR_ERR(afi);
  617. -
  618. - table = nf_tables_table_lookup(net, nla[NFTA_RULE_TABLE], afi->family,
  619. + table = nf_tables_table_lookup(net, nla[NFTA_RULE_TABLE], family,
  620. genmask);
  621. if (IS_ERR(table))
  622. return PTR_ERR(table);
  623. @@ -2523,7 +2407,7 @@ static int nf_tables_delrule(struct net
  624. return PTR_ERR(chain);
  625. }
  626. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, chain, nla);
  627. + nft_ctx_init(&ctx, net, skb, nlh, family, table, chain, nla);
  628. if (chain) {
  629. if (nla[NFTA_RULE_HANDLE]) {
  630. @@ -2708,26 +2592,17 @@ static int nft_ctx_init_from_setattr(str
  631. u8 genmask)
  632. {
  633. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  634. - struct nft_af_info *afi = NULL;
  635. + int family = nfmsg->nfgen_family;
  636. struct nft_table *table = NULL;
  637. - if (nfmsg->nfgen_family != NFPROTO_UNSPEC) {
  638. - afi = nf_tables_afinfo_lookup(net, nfmsg->nfgen_family, false);
  639. - if (IS_ERR(afi))
  640. - return PTR_ERR(afi);
  641. - }
  642. -
  643. if (nla[NFTA_SET_TABLE] != NULL) {
  644. - if (afi == NULL)
  645. - return -EAFNOSUPPORT;
  646. -
  647. table = nf_tables_table_lookup(net, nla[NFTA_SET_TABLE],
  648. - afi->family, genmask);
  649. + family, genmask);
  650. if (IS_ERR(table))
  651. return PTR_ERR(table);
  652. }
  653. - nft_ctx_init(ctx, net, skb, nlh, afi->family, table, NULL, nla);
  654. + nft_ctx_init(ctx, net, skb, nlh, family, table, NULL, nla);
  655. return 0;
  656. }
  657. @@ -2960,7 +2835,7 @@ static int nf_tables_dump_sets(struct sk
  658. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  659. if (ctx->family != NFPROTO_UNSPEC &&
  660. - ctx->family != table->afi->family)
  661. + ctx->family != table->family)
  662. continue;
  663. if (ctx->table && ctx->table != table)
  664. @@ -2981,7 +2856,7 @@ static int nf_tables_dump_sets(struct sk
  665. ctx_set = *ctx;
  666. ctx_set.table = table;
  667. - ctx_set.family = table->afi->family;
  668. + ctx_set.family = table->family;
  669. if (nf_tables_fill_set(skb, &ctx_set, set,
  670. NFT_MSG_NEWSET,
  671. @@ -3093,8 +2968,8 @@ static int nf_tables_newset(struct net *
  672. {
  673. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  674. u8 genmask = nft_genmask_next(net);
  675. + int family = nfmsg->nfgen_family;
  676. const struct nft_set_ops *ops;
  677. - struct nft_af_info *afi;
  678. struct nft_table *table;
  679. struct nft_set *set;
  680. struct nft_ctx ctx;
  681. @@ -3204,16 +3079,12 @@ static int nf_tables_newset(struct net *
  682. create = nlh->nlmsg_flags & NLM_F_CREATE ? true : false;
  683. - afi = nf_tables_afinfo_lookup(net, nfmsg->nfgen_family, create);
  684. - if (IS_ERR(afi))
  685. - return PTR_ERR(afi);
  686. -
  687. - table = nf_tables_table_lookup(net, nla[NFTA_SET_TABLE], afi->family,
  688. + table = nf_tables_table_lookup(net, nla[NFTA_SET_TABLE], family,
  689. genmask);
  690. if (IS_ERR(table))
  691. return PTR_ERR(table);
  692. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  693. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  694. set = nf_tables_set_lookup(table, nla[NFTA_SET_NAME], genmask);
  695. if (IS_ERR(set)) {
  696. @@ -3475,19 +3346,15 @@ static int nft_ctx_init_from_elemattr(st
  697. u8 genmask)
  698. {
  699. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  700. - struct nft_af_info *afi;
  701. + int family = nfmsg->nfgen_family;
  702. struct nft_table *table;
  703. - afi = nf_tables_afinfo_lookup(net, nfmsg->nfgen_family, false);
  704. - if (IS_ERR(afi))
  705. - return PTR_ERR(afi);
  706. -
  707. table = nf_tables_table_lookup(net, nla[NFTA_SET_ELEM_LIST_TABLE],
  708. - afi->family, genmask);
  709. + family, genmask);
  710. if (IS_ERR(table))
  711. return PTR_ERR(table);
  712. - nft_ctx_init(ctx, net, skb, nlh, afi->family, table, NULL, nla);
  713. + nft_ctx_init(ctx, net, skb, nlh, family, table, NULL, nla);
  714. return 0;
  715. }
  716. @@ -3605,7 +3472,7 @@ static int nf_tables_dump_set(struct sk_
  717. rcu_read_lock();
  718. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  719. if (dump_ctx->ctx.family != NFPROTO_UNSPEC &&
  720. - dump_ctx->ctx.family != table->afi->family)
  721. + dump_ctx->ctx.family != table->family)
  722. continue;
  723. if (table != dump_ctx->ctx.table)
  724. @@ -3635,7 +3502,7 @@ static int nf_tables_dump_set(struct sk_
  725. goto nla_put_failure;
  726. nfmsg = nlmsg_data(nlh);
  727. - nfmsg->nfgen_family = table->afi->family;
  728. + nfmsg->nfgen_family = table->family;
  729. nfmsg->version = NFNETLINK_V0;
  730. nfmsg->res_id = htons(net->nft.base_seq & 0xffff);
  731. @@ -4523,7 +4390,6 @@ static int nf_tables_newobj(struct net *
  732. const struct nft_object_type *type;
  733. u8 genmask = nft_genmask_next(net);
  734. int family = nfmsg->nfgen_family;
  735. - struct nft_af_info *afi;
  736. struct nft_table *table;
  737. struct nft_object *obj;
  738. struct nft_ctx ctx;
  739. @@ -4535,11 +4401,7 @@ static int nf_tables_newobj(struct net *
  740. !nla[NFTA_OBJ_DATA])
  741. return -EINVAL;
  742. - afi = nf_tables_afinfo_lookup(net, family, true);
  743. - if (IS_ERR(afi))
  744. - return PTR_ERR(afi);
  745. -
  746. - table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], afi->family,
  747. + table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], family,
  748. genmask);
  749. if (IS_ERR(table))
  750. return PTR_ERR(table);
  751. @@ -4558,7 +4420,7 @@ static int nf_tables_newobj(struct net *
  752. return 0;
  753. }
  754. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  755. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  756. type = nft_obj_type_get(objtype);
  757. if (IS_ERR(type))
  758. @@ -4650,7 +4512,7 @@ static int nf_tables_dump_obj(struct sk_
  759. cb->seq = net->nft.base_seq;
  760. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  761. - if (family != NFPROTO_UNSPEC && family != table->afi->family)
  762. + if (family != NFPROTO_UNSPEC && family != table->family)
  763. continue;
  764. list_for_each_entry_rcu(obj, &table->objects, list) {
  765. @@ -4673,7 +4535,7 @@ static int nf_tables_dump_obj(struct sk_
  766. cb->nlh->nlmsg_seq,
  767. NFT_MSG_NEWOBJ,
  768. NLM_F_MULTI | NLM_F_APPEND,
  769. - table->afi->family, table,
  770. + table->family, table,
  771. obj, reset) < 0)
  772. goto done;
  773. @@ -4731,7 +4593,6 @@ static int nf_tables_getobj(struct net *
  774. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  775. u8 genmask = nft_genmask_cur(net);
  776. int family = nfmsg->nfgen_family;
  777. - const struct nft_af_info *afi;
  778. const struct nft_table *table;
  779. struct nft_object *obj;
  780. struct sk_buff *skb2;
  781. @@ -4762,11 +4623,7 @@ static int nf_tables_getobj(struct net *
  782. !nla[NFTA_OBJ_TYPE])
  783. return -EINVAL;
  784. - afi = nf_tables_afinfo_lookup(net, family, false);
  785. - if (IS_ERR(afi))
  786. - return PTR_ERR(afi);
  787. -
  788. - table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], afi->family,
  789. + table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], family,
  790. genmask);
  791. if (IS_ERR(table))
  792. return PTR_ERR(table);
  793. @@ -4813,7 +4670,6 @@ static int nf_tables_delobj(struct net *
  794. const struct nfgenmsg *nfmsg = nlmsg_data(nlh);
  795. u8 genmask = nft_genmask_next(net);
  796. int family = nfmsg->nfgen_family;
  797. - struct nft_af_info *afi;
  798. struct nft_table *table;
  799. struct nft_object *obj;
  800. struct nft_ctx ctx;
  801. @@ -4823,11 +4679,7 @@ static int nf_tables_delobj(struct net *
  802. !nla[NFTA_OBJ_NAME])
  803. return -EINVAL;
  804. - afi = nf_tables_afinfo_lookup(net, family, true);
  805. - if (IS_ERR(afi))
  806. - return PTR_ERR(afi);
  807. -
  808. - table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], afi->family,
  809. + table = nf_tables_table_lookup(net, nla[NFTA_OBJ_TABLE], family,
  810. genmask);
  811. if (IS_ERR(table))
  812. return PTR_ERR(table);
  813. @@ -4839,7 +4691,7 @@ static int nf_tables_delobj(struct net *
  814. if (obj->use > 0)
  815. return -EBUSY;
  816. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  817. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  818. return nft_delobj(&ctx, obj);
  819. }
  820. @@ -5024,33 +4876,31 @@ err1:
  821. return err;
  822. }
  823. -static const struct nf_flowtable_type *
  824. -__nft_flowtable_type_get(const struct nft_af_info *afi)
  825. +static const struct nf_flowtable_type *__nft_flowtable_type_get(u8 family)
  826. {
  827. const struct nf_flowtable_type *type;
  828. list_for_each_entry(type, &nf_tables_flowtables, list) {
  829. - if (afi->family == type->family)
  830. + if (family == type->family)
  831. return type;
  832. }
  833. return NULL;
  834. }
  835. -static const struct nf_flowtable_type *
  836. -nft_flowtable_type_get(const struct nft_af_info *afi)
  837. +static const struct nf_flowtable_type *nft_flowtable_type_get(u8 family)
  838. {
  839. const struct nf_flowtable_type *type;
  840. - type = __nft_flowtable_type_get(afi);
  841. + type = __nft_flowtable_type_get(family);
  842. if (type != NULL && try_module_get(type->owner))
  843. return type;
  844. #ifdef CONFIG_MODULES
  845. if (type == NULL) {
  846. nfnl_unlock(NFNL_SUBSYS_NFTABLES);
  847. - request_module("nf-flowtable-%u", afi->family);
  848. + request_module("nf-flowtable-%u", family);
  849. nfnl_lock(NFNL_SUBSYS_NFTABLES);
  850. - if (__nft_flowtable_type_get(afi))
  851. + if (__nft_flowtable_type_get(family))
  852. return ERR_PTR(-EAGAIN);
  853. }
  854. #endif
  855. @@ -5098,7 +4948,6 @@ static int nf_tables_newflowtable(struct
  856. u8 genmask = nft_genmask_next(net);
  857. int family = nfmsg->nfgen_family;
  858. struct nft_flowtable *flowtable;
  859. - struct nft_af_info *afi;
  860. struct nft_table *table;
  861. struct nft_ctx ctx;
  862. int err, i, k;
  863. @@ -5108,12 +4957,8 @@ static int nf_tables_newflowtable(struct
  864. !nla[NFTA_FLOWTABLE_HOOK])
  865. return -EINVAL;
  866. - afi = nf_tables_afinfo_lookup(net, family, true);
  867. - if (IS_ERR(afi))
  868. - return PTR_ERR(afi);
  869. -
  870. table = nf_tables_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE],
  871. - afi->family, genmask);
  872. + family, genmask);
  873. if (IS_ERR(table))
  874. return PTR_ERR(table);
  875. @@ -5130,7 +4975,7 @@ static int nf_tables_newflowtable(struct
  876. return 0;
  877. }
  878. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  879. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  880. flowtable = kzalloc(sizeof(*flowtable), GFP_KERNEL);
  881. if (!flowtable)
  882. @@ -5143,7 +4988,7 @@ static int nf_tables_newflowtable(struct
  883. goto err1;
  884. }
  885. - type = nft_flowtable_type_get(afi);
  886. + type = nft_flowtable_type_get(family);
  887. if (IS_ERR(type)) {
  888. err = PTR_ERR(type);
  889. goto err2;
  890. @@ -5203,16 +5048,11 @@ static int nf_tables_delflowtable(struct
  891. u8 genmask = nft_genmask_next(net);
  892. int family = nfmsg->nfgen_family;
  893. struct nft_flowtable *flowtable;
  894. - struct nft_af_info *afi;
  895. struct nft_table *table;
  896. struct nft_ctx ctx;
  897. - afi = nf_tables_afinfo_lookup(net, family, true);
  898. - if (IS_ERR(afi))
  899. - return PTR_ERR(afi);
  900. -
  901. table = nf_tables_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE],
  902. - afi->family, genmask);
  903. + family, genmask);
  904. if (IS_ERR(table))
  905. return PTR_ERR(table);
  906. @@ -5223,7 +5063,7 @@ static int nf_tables_delflowtable(struct
  907. if (flowtable->use > 0)
  908. return -EBUSY;
  909. - nft_ctx_init(&ctx, net, skb, nlh, afi->family, table, NULL, nla);
  910. + nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
  911. return nft_delflowtable(&ctx, flowtable);
  912. }
  913. @@ -5298,7 +5138,7 @@ static int nf_tables_dump_flowtable(stru
  914. cb->seq = net->nft.base_seq;
  915. list_for_each_entry_rcu(table, &net->nft.tables, list) {
  916. - if (family != NFPROTO_UNSPEC && family != table->afi->family)
  917. + if (family != NFPROTO_UNSPEC && family != table->family)
  918. continue;
  919. list_for_each_entry_rcu(flowtable, &table->flowtables, list) {
  920. @@ -5317,7 +5157,7 @@ static int nf_tables_dump_flowtable(stru
  921. cb->nlh->nlmsg_seq,
  922. NFT_MSG_NEWFLOWTABLE,
  923. NLM_F_MULTI | NLM_F_APPEND,
  924. - table->afi->family, flowtable) < 0)
  925. + table->family, flowtable) < 0)
  926. goto done;
  927. nl_dump_check_consistent(cb, nlmsg_hdr(skb));
  928. @@ -5377,7 +5217,6 @@ static int nf_tables_getflowtable(struct
  929. u8 genmask = nft_genmask_cur(net);
  930. int family = nfmsg->nfgen_family;
  931. struct nft_flowtable *flowtable;
  932. - const struct nft_af_info *afi;
  933. const struct nft_table *table;
  934. struct sk_buff *skb2;
  935. int err;
  936. @@ -5403,12 +5242,8 @@ static int nf_tables_getflowtable(struct
  937. if (!nla[NFTA_FLOWTABLE_NAME])
  938. return -EINVAL;
  939. - afi = nf_tables_afinfo_lookup(net, family, false);
  940. - if (IS_ERR(afi))
  941. - return PTR_ERR(afi);
  942. -
  943. table = nf_tables_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE],
  944. - afi->family, genmask);
  945. + family, genmask);
  946. if (IS_ERR(table))
  947. return PTR_ERR(table);
  948. @@ -6579,7 +6414,7 @@ int __nft_release_basechain(struct nft_c
  949. }
  950. EXPORT_SYMBOL_GPL(__nft_release_basechain);
  951. -static void __nft_release_afinfo(struct net *net)
  952. +static void __nft_release_tables(struct net *net)
  953. {
  954. struct nft_flowtable *flowtable, *nf;
  955. struct nft_table *table, *nt;
  956. @@ -6592,7 +6427,7 @@ static void __nft_release_afinfo(struct
  957. };
  958. list_for_each_entry_safe(table, nt, &net->nft.tables, list) {
  959. - ctx.family = table->afi->family;
  960. + ctx.family = table->family;
  961. list_for_each_entry(chain, &table->chains, list)
  962. nf_tables_unregister_hook(net, table, chain);
  963. @@ -6644,7 +6479,7 @@ static int __net_init nf_tables_init_net
  964. static void __net_exit nf_tables_exit_net(struct net *net)
  965. {
  966. - __nft_release_afinfo(net);
  967. + __nft_release_tables(net);
  968. WARN_ON_ONCE(!list_empty(&net->nft.tables));
  969. WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
  970. }
  971. --- a/net/netfilter/nf_tables_inet.c
  972. +++ b/net/netfilter/nf_tables_inet.c
  973. @@ -38,11 +38,6 @@ static unsigned int nft_do_chain_inet(vo
  974. return nft_do_chain(&pkt, priv);
  975. }
  976. -static struct nft_af_info nft_af_inet __read_mostly = {
  977. - .family = NFPROTO_INET,
  978. - .owner = THIS_MODULE,
  979. -};
  980. -
  981. static const struct nf_chain_type filter_inet = {
  982. .name = "filter",
  983. .type = NFT_CHAIN_T_DEFAULT,
  984. @@ -64,26 +59,12 @@ static const struct nf_chain_type filter
  985. static int __init nf_tables_inet_init(void)
  986. {
  987. - int ret;
  988. -
  989. - if (nft_register_afinfo(&nft_af_inet) < 0)
  990. - return ret;
  991. -
  992. - ret = nft_register_chain_type(&filter_inet);
  993. - if (ret < 0)
  994. - goto err_register_chain;
  995. -
  996. - return ret;
  997. -
  998. -err_register_chain:
  999. - nft_unregister_afinfo(&nft_af_inet);
  1000. - return ret;
  1001. + return nft_register_chain_type(&filter_inet);
  1002. }
  1003. static void __exit nf_tables_inet_exit(void)
  1004. {
  1005. nft_unregister_chain_type(&filter_inet);
  1006. - nft_unregister_afinfo(&nft_af_inet);
  1007. }
  1008. module_init(nf_tables_inet_init);
  1009. @@ -91,4 +72,4 @@ module_exit(nf_tables_inet_exit);
  1010. MODULE_LICENSE("GPL");
  1011. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  1012. -MODULE_ALIAS_NFT_FAMILY(1);
  1013. +MODULE_ALIAS_NFT_CHAIN(1, "filter");
  1014. --- a/net/netfilter/nf_tables_netdev.c
  1015. +++ b/net/netfilter/nf_tables_netdev.c
  1016. @@ -38,11 +38,6 @@ nft_do_chain_netdev(void *priv, struct s
  1017. return nft_do_chain(&pkt, priv);
  1018. }
  1019. -static struct nft_af_info nft_af_netdev __read_mostly = {
  1020. - .family = NFPROTO_NETDEV,
  1021. - .owner = THIS_MODULE,
  1022. -};
  1023. -
  1024. static const struct nf_chain_type nft_filter_chain_netdev = {
  1025. .name = "filter",
  1026. .type = NFT_CHAIN_T_DEFAULT,
  1027. @@ -91,10 +86,10 @@ static int nf_tables_netdev_event(struct
  1028. nfnl_lock(NFNL_SUBSYS_NFTABLES);
  1029. list_for_each_entry(table, &ctx.net->nft.tables, list) {
  1030. - if (table->afi->family != NFPROTO_NETDEV)
  1031. + if (table->family != NFPROTO_NETDEV)
  1032. continue;
  1033. - ctx.family = table->afi->family;
  1034. + ctx.family = table->family;
  1035. ctx.table = table;
  1036. list_for_each_entry_safe(chain, nr, &table->chains, list) {
  1037. if (!nft_is_base_chain(chain))
  1038. @@ -117,12 +112,9 @@ static int __init nf_tables_netdev_init(
  1039. {
  1040. int ret;
  1041. - if (nft_register_afinfo(&nft_af_netdev) < 0)
  1042. - return ret;
  1043. -
  1044. ret = nft_register_chain_type(&nft_filter_chain_netdev);
  1045. if (ret)
  1046. - goto err_register_chain_type;
  1047. + return ret;
  1048. ret = register_netdevice_notifier(&nf_tables_netdev_notifier);
  1049. if (ret)
  1050. @@ -132,8 +124,6 @@ static int __init nf_tables_netdev_init(
  1051. err_register_netdevice_notifier:
  1052. nft_unregister_chain_type(&nft_filter_chain_netdev);
  1053. -err_register_chain_type:
  1054. - nft_unregister_afinfo(&nft_af_netdev);
  1055. return ret;
  1056. }
  1057. @@ -142,7 +132,6 @@ static void __exit nf_tables_netdev_exit
  1058. {
  1059. unregister_netdevice_notifier(&nf_tables_netdev_notifier);
  1060. nft_unregister_chain_type(&nft_filter_chain_netdev);
  1061. - nft_unregister_afinfo(&nft_af_netdev);
  1062. }
  1063. module_init(nf_tables_netdev_init);
  1064. @@ -150,4 +139,4 @@ module_exit(nf_tables_netdev_exit);
  1065. MODULE_LICENSE("GPL");
  1066. MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
  1067. -MODULE_ALIAS_NFT_FAMILY(5); /* NFPROTO_NETDEV */
  1068. +MODULE_ALIAS_NFT_CHAIN(5, "filter"); /* NFPROTO_NETDEV */