Skip to contentSkip to conversation

l2tp: ensure sk->dst is still valid

PATCH Applied Florian Westphal 3 participants 3 messages Nov 25, 2011 – Nov 26, 2011

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

PATCH 1/1 l2tp: ensure sk->dst is still valid

When using l2tp over ipsec, the tunnel will hang when rekeying occurs. Reason is that the transformer bundle attached to the dst entry is now in STATE_DEAD and thus xfrm_output_one() drops all packets (XfrmOutStateExpired increases).

Fix this by calling __sk_dst_check (which drops the stale dst if xfrm dst->check callback finds that the bundle is no longer valid).

---
 net/l2tp/l2tp_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/l2tp/l2tp_core.c +1 -1
index cf0f308..89ff8c6 100644
@@ -1072,7 +1072,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
 
 	/* Get routing info from the tunnel socket */
 	skb_dst_drop(skb);
-	skb_dst_set(skb, dst_clone(__sk_dst_get(sk)));
+	skb_dst_set(skb, dst_clone(__sk_dst_check(sk, 0)));
 
 	inet = inet_sk(sk);
 	fl = &inet->cork.fl;
Signature · 1 line
1.7.3.4
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Florian Westphal

When using l2tp over ipsec, the tunnel will hang when rekeying occurs. Reason is that the transformer bundle attached to the dst entry is now in STATE_DEAD and thus xfrm_output_one() drops all packets (XfrmOutStateExpired increases).

Fix this by calling __sk_dst_check (which drops the stale dst if xfrm dst->check callback finds that the bundle is no longer valid).

---
 net/l2tp/l2tp_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/l2tp/l2tp_core.c +0 -0
index cf0f308..89ff8c6 100644

net/l2tp/l2tp_core.c int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len · line 1078

Quoted 8 lines
net/l2tp/l2tp_core.c +1 -1
@@ -1072,7 +1072,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
 
 	/* Get routing info from the tunnel socket */
 	skb_dst_drop(skb);
-	skb_dst_set(skb, dst_clone(__sk_dst_get(sk)));
+	skb_dst_set(skb, dst_clone(__sk_dst_check(sk, 0)));
 
 	inet = inet_sk(sk);
 	fl = &inet->cork.fl;

Seems good to me, although we could use RCU and skb_dst_set_noref() to avoid dirtying dst refcount. I'll send a patch for net-next later.

maintainer Applied
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Sat, 26 Nov 2011 05:30:01 +0100

Quoted 26 lines · Florian Westphal
Quoted 25 lines

When using l2tp over ipsec, the tunnel will hang when rekeying occurs. Reason is that the transformer bundle attached to the dst entry is now in STATE_DEAD and thus xfrm_output_one() drops all packets (XfrmOutStateExpired increases).

Fix this by calling __sk_dst_check (which drops the stale dst if xfrm dst->check callback finds that the bundle is no longer valid).

---
 net/l2tp/l2tp_core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/l2tp/l2tp_core.c +1 -1
index cf0f308..89ff8c6 100644
@@ -1072,7 +1072,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
 
 	/* Get routing info from the tunnel socket */
 	skb_dst_drop(skb);
-	skb_dst_set(skb, dst_clone(__sk_dst_get(sk)));
+	skb_dst_set(skb, dst_clone(__sk_dst_check(sk, 0)));
 
Quoted 7 lines

net/l2tp/l2tp_core.c int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len · line 1078

Quoted 2 lines
net/l2tp/l2tp_core.c +0 -0
 	inet = inet_sk(sk);
 	fl = &inet->cork.fl;

Seems good to me, although we could use RCU and skb_dst_set_noref() to avoid dirtying dst refcount. I'll send a patch for net-next later.

Applied, thanks everyone.