aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_output.c
diff options
context:
space:
mode:
authorStephen Suryaputra <ssuryaextr@gmail.com>2019-06-26 02:21:16 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-26 15:40:10 -0400
commit5b18f1289808fee5d04a7e6ecf200189f41a4db6 (patch)
treec4f8ffda52e1fa30489d1eae8c7f4066c0fc2df6 /net/ipv4/ip_output.c
parentee4297420d56a0033a8593e80b33fcc93fda8509 (diff)
ipv4: reset rt_iif for recirculated mcast/bcast out pkts
Multicast or broadcast egress packets have rt_iif set to the oif. These packets might be recirculated back as input and lookup to the raw sockets may fail because they are bound to the incoming interface (skb_iif). If rt_iif is not zero, during the lookup, inet_iif() function returns rt_iif instead of skb_iif. Hence, the lookup fails. v2: Make it non vrf specific (David Ahern). Reword the changelog to reflect it. Signed-off-by: Stephen Suryaputra <ssuryaextr@gmail.com> Reviewed-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_output.c')
-rw-r--r--net/ipv4/ip_output.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 16f9159234a2..8c2ec35b6512 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -318,6 +318,7 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
318static int ip_mc_finish_output(struct net *net, struct sock *sk, 318static int ip_mc_finish_output(struct net *net, struct sock *sk,
319 struct sk_buff *skb) 319 struct sk_buff *skb)
320{ 320{
321 struct rtable *new_rt;
321 int ret; 322 int ret;
322 323
323 ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb); 324 ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb);
@@ -326,6 +327,17 @@ static int ip_mc_finish_output(struct net *net, struct sock *sk,
326 return ret; 327 return ret;
327 } 328 }
328 329
330 /* Reset rt_iif so that inet_iif() will return skb->skb_iif. Setting
331 * this to non-zero causes ipi_ifindex in in_pktinfo to be overwritten,
332 * see ipv4_pktinfo_prepare().
333 */
334 new_rt = rt_dst_clone(net->loopback_dev, skb_rtable(skb));
335 if (new_rt) {
336 new_rt->rt_iif = 0;
337 skb_dst_drop(skb);
338 skb_dst_set(skb, &new_rt->dst);
339 }
340
329 return dev_loopback_xmit(net, sk, skb); 341 return dev_loopback_xmit(net, sk, skb);
330} 342}
331 343