Skip to content

Commit 3e7a60b

Browse files
IurmanJPaolo Abeni
authored andcommitted
net: ipv6: ioam6: fix lwtunnel_output() loop
Fix the lwtunnel_output() reentry loop in ioam6_iptunnel when the destination is the same after transformation. Note that a check on the destination address was already performed, but it was not enough. This is the example of a lwtunnel user taking care of loops without relying only on the last resort detection offered by lwtunnel. Fixes: 8cb3bf8 ("ipv6: ioam: Add support for the ip6ip6 encapsulation") Signed-off-by: Justin Iurman <justin.iurman@uliege.be> Link: https://patch.msgid.link/20250314120048.12569-3-justin.iurman@uliege.be Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 986ffb3 commit 3e7a60b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/ipv6/ioam6_iptunnel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ static int ioam6_do_encap(struct net *net, struct sk_buff *skb,
337337
static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
338338
{
339339
struct dst_entry *dst = skb_dst(skb), *cache_dst = NULL;
340-
struct in6_addr orig_daddr;
341340
struct ioam6_lwt *ilwt;
342341
int err = -EINVAL;
343342
u32 pkt_cnt;
@@ -352,8 +351,6 @@ static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
352351
if (pkt_cnt % ilwt->freq.n >= ilwt->freq.k)
353352
goto out;
354353

355-
orig_daddr = ipv6_hdr(skb)->daddr;
356-
357354
local_bh_disable();
358355
cache_dst = dst_cache_get(&ilwt->cache);
359356
local_bh_enable();
@@ -422,7 +419,10 @@ static int ioam6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
422419
goto drop;
423420
}
424421

425-
if (!ipv6_addr_equal(&orig_daddr, &ipv6_hdr(skb)->daddr)) {
422+
/* avoid lwtunnel_output() reentry loop when destination is the same
423+
* after transformation (e.g., with the inline mode)
424+
*/
425+
if (dst->lwtstate != cache_dst->lwtstate) {
426426
skb_dst_drop(skb);
427427
skb_dst_set(skb, cache_dst);
428428
return dst_output(net, sk, skb);

0 commit comments

Comments
 (0)