]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
netfilter: Support iif matches in POSTROUTING
authorPhil Sutter <phil@nwl.cc>
Tue, 12 Nov 2019 16:14:37 +0000 (17:14 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 15 Nov 2019 22:44:48 +0000 (23:44 +0100)
Instead of generally passing NULL to NF_HOOK_COND() for input device,
pass skb->dev which contains input device for routed skbs.

Note that iptables (both legacy and nft) reject rules with input
interface match from being added to POSTROUTING chains, but nftables
allows this.

Cc: Eric Garver <eric@garver.life>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/ip_output.c
net/ipv4/xfrm4_output.c
net/ipv6/ip6_output.c
net/ipv6/xfrm6_output.c

index 3d8baaaf7086dba0c8fde178891734b2da7d7ec7..9d83cb320dcb77d803554b950adce0d655c043ae 100644 (file)
@@ -422,7 +422,7 @@ int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 
 int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       struct net_device *dev = skb_dst(skb)->dev;
+       struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev;
 
        IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
 
@@ -430,7 +430,7 @@ int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
        skb->protocol = htons(ETH_P_IP);
 
        return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
-                           net, sk, skb, NULL, dev,
+                           net, sk, skb, indev, dev,
                            ip_finish_output,
                            !(IPCB(skb)->flags & IPSKB_REROUTED));
 }
index ecff3fce9807365123a07f78322ae3d28340514a..89ba7c87de5df35d8a3807f360fd9d3845fcfa20 100644 (file)
@@ -92,7 +92,7 @@ static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
-                           net, sk, skb, NULL, skb_dst(skb)->dev,
+                           net, sk, skb, skb->dev, skb_dst(skb)->dev,
                            __xfrm4_output,
                            !(IPCB(skb)->flags & IPSKB_REROUTED));
 }
index 71827b56c0063b56bcfbef4bd8910ddcec035824..945508a7cb0f1135d9ab5754124206db13ce0046 100644 (file)
@@ -160,7 +160,7 @@ static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
 
 int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-       struct net_device *dev = skb_dst(skb)->dev;
+       struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev;
        struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
 
        skb->protocol = htons(ETH_P_IPV6);
@@ -173,7 +173,7 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
        }
 
        return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
-                           net, sk, skb, NULL, dev,
+                           net, sk, skb, indev, dev,
                            ip6_finish_output,
                            !(IP6CB(skb)->flags & IP6SKB_REROUTED));
 }
index eecac1b7148e5f7a9faa34b84b00e08574fec62d..fbe51d40bd7e9f8b50bc3ba1c1d41710a162e29d 100644 (file)
@@ -187,7 +187,7 @@ skip_frag:
 int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
        return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
-                           net, sk, skb,  NULL, skb_dst(skb)->dev,
+                           net, sk, skb,  skb->dev, skb_dst(skb)->dev,
                            __xfrm6_output,
                            !(IP6CB(skb)->flags & IP6SKB_REROUTED));
 }