Skip to content

Commit

Permalink
xfrm: add route lookup to xfrm4_rcv_encap
Browse files Browse the repository at this point in the history
At this point, with TCP encapsulation, the dst may be gone, but
xfrm_input needs one.

Signed-off-by: Sabrina Dubroca <[email protected]>
Acked-by: David S. Miller <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
  • Loading branch information
qsn authored and klassert committed Dec 9, 2019
1 parent 7b38019 commit cac3c71
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/ipv4/xfrm4_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,22 @@ int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,
if (!head)
goto out;

if (!skb_dst(skb)) {
const struct iphdr *iph = ip_hdr(skb);

if (ip_route_input_noref(skb, iph->daddr, iph->saddr,
iph->tos, skb->dev))
goto drop;
}

for_each_protocol_rcu(*head, handler)
if ((ret = handler->input_handler(skb, nexthdr, spi, encap_type)) != -EINVAL)
return ret;

out:
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);

drop:
kfree_skb(skb);
return 0;
}
Expand Down

0 comments on commit cac3c71

Please sign in to comment.