Skip to content

Commit 1ecc9ad

Browse files
Julian Anastasovdavem330
authored andcommitted
xfrm: provide correct dst in xfrm_neigh_lookup
Fix xfrm_neigh_lookup to provide dst->path to the neigh_lookup dst_ops method. When skb is provided, the IP address in packet should already match the dst->path address family. But for the non-skb case, we should consider the last tunnel address as nexthop address. Fixes: f894cbf ("net: Add optional SKB arg to dst_ops->neigh_lookup().") Signed-off-by: Julian Anastasov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c4d2603 commit 1ecc9ad

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,14 +2836,8 @@ static unsigned int xfrm_mtu(const struct dst_entry *dst)
28362836
return mtu ? : dst_mtu(dst->path);
28372837
}
28382838

2839-
static struct neighbour *xfrm_neigh_lookup(const struct dst_entry *dst,
2840-
struct sk_buff *skb,
2841-
const void *daddr)
2842-
{
2843-
return dst->path->ops->neigh_lookup(dst, skb, daddr);
2844-
}
2845-
2846-
static void xfrm_confirm_neigh(const struct dst_entry *dst, const void *daddr)
2839+
static const void *xfrm_get_dst_nexthop(const struct dst_entry *dst,
2840+
const void *daddr)
28472841
{
28482842
const struct dst_entry *path = dst->path;
28492843

@@ -2857,6 +2851,25 @@ static void xfrm_confirm_neigh(const struct dst_entry *dst, const void *daddr)
28572851
else if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR))
28582852
daddr = &xfrm->id.daddr;
28592853
}
2854+
return daddr;
2855+
}
2856+
2857+
static struct neighbour *xfrm_neigh_lookup(const struct dst_entry *dst,
2858+
struct sk_buff *skb,
2859+
const void *daddr)
2860+
{
2861+
const struct dst_entry *path = dst->path;
2862+
2863+
if (!skb)
2864+
daddr = xfrm_get_dst_nexthop(dst, daddr);
2865+
return path->ops->neigh_lookup(path, skb, daddr);
2866+
}
2867+
2868+
static void xfrm_confirm_neigh(const struct dst_entry *dst, const void *daddr)
2869+
{
2870+
const struct dst_entry *path = dst->path;
2871+
2872+
daddr = xfrm_get_dst_nexthop(dst, daddr);
28602873
path->ops->confirm_neigh(path, daddr);
28612874
}
28622875

0 commit comments

Comments
 (0)