From: Justin Iurman <justin.iurman@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, andrea.mayer@uniroma2.it,
justin.iurman@gmail.com
Subject: [PATCH net 1/2] ioam6: drop the packet if no outer source address is available
Date: Sun, 15 Nov 2026 01:00:46 +0100 [thread overview]
Message-ID: <20261115000047.14669-2-justin.iurman@gmail.com> (raw)
In-Reply-To: <20261115000047.14669-1-justin.iurman@gmail.com>
When no tunnel source is configured, ioam6_do_encap() ignores the
return value of ipv6_dev_get_saddr(). On failure, the outer header
keeps the source address copied from the inner header, so the packet
is sent with an address that may not belong to this node.
Drop the packet instead.
Fixes: 8cb3bf8bff3c ("ipv6: ioam: Add support for the ip6ip6 encapsulation")
Signed-off-by: Justin Iurman <justin.iurman@gmail.com>
---
net/ipv6/ioam6_iptunnel.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
index cfb2c41634a0..4990ae1ee78c 100644
--- a/net/ipv6/ioam6_iptunnel.c
+++ b/net/ipv6/ioam6_iptunnel.c
@@ -324,11 +324,14 @@ static int ioam6_do_encap(struct net *net, struct sk_buff *skb,
hdr->payload_len = cpu_to_be16(skb->len - sizeof(*hdr));
hdr->daddr = *tundst;
- if (has_tunsrc)
+ if (has_tunsrc) {
memcpy(&hdr->saddr, tunsrc, sizeof(*tunsrc));
- else
- ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr,
- IPV6_PREFER_SRC_PUBLIC, &hdr->saddr);
+ } else {
+ err = ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr,
+ IPV6_PREFER_SRC_PUBLIC, &hdr->saddr);
+ if (unlikely(err))
+ return err;
+ }
skb_postpush_rcsum(skb, hdr, len);
--
2.34.1
next prev parent reply other threads:[~2026-11-15 0:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 0:00 [PATCH net 0/2] ipv6: drop encapsulated packets when no source address is available Justin Iurman
2026-11-15 0:00 ` Justin Iurman [this message]
2026-11-15 0:00 ` [PATCH net 2/2] seg6: drop the packet if no outer " Justin Iurman
2026-11-15 20:08 ` [PATCH net 0/2] ipv6: drop encapsulated packets when no " netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261115000047.14669-2-justin.iurman@gmail.com \
--to=justin.iurman@gmail.com \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox