From f0905d2f1507c8678eab0197f21396376c3e0f51 Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Wed, 22 May 2024 19:54:22 +0200 Subject: [PATCH] netfilter: propagate net to nf_bridge_get_physindev This is a preparation patch for replacing physindev with physinif on nf_bridge_info structure. We will use dev_get_by_index_rcu to resolve device, when needed, and it requires net to be available. Signed-off-by: Pavel Tikhomirov Reviewed-by: Simon Horman Signed-off-by: Pablo Neira Ayuso Signed-off-by: Jozsef Kadlecsik --- .../net/netfilter/ipset/ip_set_hash_netiface.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/net/netfilter/ipset/ip_set_hash_netiface.c b/kernel/net/netfilter/ipset/ip_set_hash_netiface.c index 5baa852e..293d0951 100644 --- a/kernel/net/netfilter/ipset/ip_set_hash_netiface.c +++ b/kernel/net/netfilter/ipset/ip_set_hash_netiface.c @@ -139,10 +139,15 @@ hash_netiface4_data_next(struct hash_netiface4_elem *next, #include "ip_set_hash_gen.h" #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) +#ifdef HAVE_NF_BRIDGE_GET_PYSINDEV_NET +static const char *get_physindev_name(const struct sk_buff *skb, struct net *net) +{ + struct net_device *dev = nf_bridge_get_physindev(skb, net); +#else static const char *get_physindev_name(const struct sk_buff *skb) { struct net_device *dev = nf_bridge_get_physindev(skb); - +#endif return dev ? dev->name : NULL; } @@ -178,8 +183,13 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb, if (opt->cmdflags & IPSET_FLAG_PHYSDEV) { #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) +#ifdef HAVE_NF_BRIDGE_GET_PYSINDEV_NET + const char *eiface = SRCDIR ? get_physindev_name(skb, xt_net(par)) : + get_physoutdev_name(skb); +#else const char *eiface = SRCDIR ? get_physindev_name(skb) : get_physoutdev_name(skb); +#endif if (!eiface) return -EINVAL; @@ -396,8 +406,13 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb, if (opt->cmdflags & IPSET_FLAG_PHYSDEV) { #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) +#ifdef HAVE_NF_BRIDGE_GET_PYSINDEV_NET + const char *eiface = SRCDIR ? get_physindev_name(skb, xt_net(par)) : + get_physoutdev_name(skb); +#else const char *eiface = SRCDIR ? get_physindev_name(skb) : get_physoutdev_name(skb); +#endif if (!eiface) return -EINVAL; -- 2.47.3