hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/net/netfilter/nft_chain_filter.c
....@@ -2,6 +2,7 @@
22 #include <linux/kernel.h>
33 #include <linux/netdevice.h>
44 #include <net/net_namespace.h>
5
+#include <net/netns/generic.h>
56 #include <net/netfilter/nf_tables.h>
67 #include <linux/netfilter_ipv4.h>
78 #include <linux/netfilter_ipv6.h>
....@@ -9,6 +10,8 @@
910 #include <linux/netfilter_arp.h>
1011 #include <net/netfilter/nf_tables_ipv4.h>
1112 #include <net/netfilter/nf_tables_ipv6.h>
13
+
14
+extern unsigned int nf_tables_net_id;
1215
1316 #ifdef CONFIG_NF_TABLES_IPV4
1417 static unsigned int nft_do_chain_ipv4(void *priv,
....@@ -355,6 +358,7 @@
355358 unsigned long event, void *ptr)
356359 {
357360 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
361
+ struct nftables_pernet *nft_net;
358362 struct nft_table *table;
359363 struct nft_chain *chain, *nr;
360364 struct nft_ctx ctx = {
....@@ -365,8 +369,9 @@
365369 event != NETDEV_CHANGENAME)
366370 return NOTIFY_DONE;
367371
368
- mutex_lock(&ctx.net->nft.commit_mutex);
369
- list_for_each_entry(table, &ctx.net->nft.tables, list) {
372
+ nft_net = net_generic(ctx.net, nf_tables_net_id);
373
+ mutex_lock(&nft_net->commit_mutex);
374
+ list_for_each_entry(table, &nft_net->tables, list) {
370375 if (table->family != NFPROTO_NETDEV)
371376 continue;
372377
....@@ -380,7 +385,7 @@
380385 nft_netdev_event(event, dev, &ctx);
381386 }
382387 }
383
- mutex_unlock(&ctx.net->nft.commit_mutex);
388
+ mutex_unlock(&nft_net->commit_mutex);
384389
385390 return NOTIFY_DONE;
386391 }