Skip to contentSkip to conversation

xfrm: provide correct dst in xfrm_neigh_lookup

PATCH In review Julian Anastasov 3 participants 3 messages Feb 25, 2017 – Feb 27, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 f894cbf847c9 ("net: Add optional SKB arg to dst_ops->neigh_lookup().")
---
 net/xfrm/xfrm_policy.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)
net/xfrm/xfrm_policy.c +21 -8
index 5f3e878..0806dcc 100644
@@ -2836,14 +2836,8 @@ static unsigned int xfrm_mtu(const struct dst_entry *dst)
 	return mtu ? : dst_mtu(dst->path);
 }
 
-static struct neighbour *xfrm_neigh_lookup(const struct dst_entry *dst,
-					   struct sk_buff *skb,
-					   const void *daddr)
-{
-	return dst->path->ops->neigh_lookup(dst, skb, daddr);
-}
-
-static void xfrm_confirm_neigh(const struct dst_entry *dst, const void *daddr)
+static const void *xfrm_get_dst_nexthop(const struct dst_entry *dst,
+					const void *daddr)
 {
 	const struct dst_entry *path = dst->path;
 
@@ -2857,6 +2851,25 @@ static void xfrm_confirm_neigh(const struct dst_entry *dst, const void *daddr)
 		else if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR))
 			daddr = &xfrm->id.daddr;
 	}
+	return daddr;
+}
+
+static struct neighbour *xfrm_neigh_lookup(const struct dst_entry *dst,
+					   struct sk_buff *skb,
+					   const void *daddr)
+{
+	const struct dst_entry *path = dst->path;
+
+	if (!skb)
+		daddr = xfrm_get_dst_nexthop(dst, daddr);
+	return path->ops->neigh_lookup(path, skb, daddr);
+}
+
+static void xfrm_confirm_neigh(const struct dst_entry *dst, const void *daddr)
+{
+	const struct dst_entry *path = dst->path;
+
+	daddr = xfrm_get_dst_nexthop(dst, daddr);
 	path->ops->confirm_neigh(path, daddr);
 }
 
Signature · 1 line
1.9.3
maintainer
#1 lore raw

From: Julian Anastasov <[email protected]>
Date: Sat, 25 Feb 2017 17:57:43 +0200

Quoted 9 lines

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 f894cbf847c9 ("net: Add optional SKB arg to dst_ops->neigh_lookup().")

This looks good to me.

Steffen, I applied this directly to my tree, I hope you don't mind.

maintainer
#2 lore raw
Quoted 10 lines · David Miller

From: Julian Anastasov <[email protected]>
Date: Sat, 25 Feb 2017 17:57:43 +0200

Quoted 7 lines

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.

Quoted 6 lines
Quoted 2 lines
Fixes f894cbf847c9 ("net: Add optional SKB arg to dst_ops->neigh_lookup().")

This looks good to me.

Steffen, I applied this directly to my tree, I hope you don't mind.

That's ok, no problem.