Skip to content

Commit 28f8bfd

Browse files
Phil Sutterummakynes
authored andcommitted
netfilter: Support iif matches in POSTROUTING
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 <[email protected]> Signed-off-by: Phil Sutter <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 5c27d8d commit 28f8bfd

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

net/ipv4/ip_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb)
422422

423423
int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb)
424424
{
425-
struct net_device *dev = skb_dst(skb)->dev;
425+
struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev;
426426

427427
IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len);
428428

429429
skb->dev = dev;
430430
skb->protocol = htons(ETH_P_IP);
431431

432432
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
433-
net, sk, skb, NULL, dev,
433+
net, sk, skb, indev, dev,
434434
ip_finish_output,
435435
!(IPCB(skb)->flags & IPSKB_REROUTED));
436436
}

net/ipv4/xfrm4_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int __xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
9292
int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb)
9393
{
9494
return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
95-
net, sk, skb, NULL, skb_dst(skb)->dev,
95+
net, sk, skb, skb->dev, skb_dst(skb)->dev,
9696
__xfrm4_output,
9797
!(IPCB(skb)->flags & IPSKB_REROUTED));
9898
}

net/ipv6/ip6_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
160160

161161
int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
162162
{
163-
struct net_device *dev = skb_dst(skb)->dev;
163+
struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev;
164164
struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
165165

166166
skb->protocol = htons(ETH_P_IPV6);
@@ -173,7 +173,7 @@ int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
173173
}
174174

175175
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
176-
net, sk, skb, NULL, dev,
176+
net, sk, skb, indev, dev,
177177
ip6_finish_output,
178178
!(IP6CB(skb)->flags & IP6SKB_REROUTED));
179179
}

net/ipv6/xfrm6_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int __xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
187187
int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
188188
{
189189
return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
190-
net, sk, skb, NULL, skb_dst(skb)->dev,
190+
net, sk, skb, skb->dev, skb_dst(skb)->dev,
191191
__xfrm6_output,
192192
!(IP6CB(skb)->flags & IP6SKB_REROUTED));
193193
}

0 commit comments

Comments
 (0)