From: Guillaume Nault <gnault@redhat.com>
To: Emanuele Santini <emanuele.santini.88@gmail.com>
Cc: netdev@vger.kernel.org, yoshfuji@linux-ipv6.org,
friedrich@oslage.de, kuba@kernel.org, davem@davemloft.net,
pabeni@redhat.com, dsahern@kernel.org
Subject: Re: [PATCH] net: ipv6: fix the address length for net_device on a GRE tunnel
Date: Fri, 8 Nov 2024 13:08:46 +0100 [thread overview]
Message-ID: <Zy3/TmyK7imjT348@debian> (raw)
In-Reply-To: <20241108092555.5714-1-emanuele.santini.88@gmail.com>
On Fri, Nov 08, 2024 at 10:25:55AM +0100, Emanuele Santini wrote:
> While GRE tunneling does not require
> a hardware address, a random Ethernet address is still assigned to
> the 'net_device'.
That's really surprising and not what I can see on my system. Are you
really talking about ip6gre (and not ip6gretap)?
> Therefore, the correct 'addr_len' value should be
> the size of an Ethernet address (6 bytes), not the size of an IPv6
> address.
Ethernet address length only makes sense for ip6gretap. This doesn't
seem like a valid justification for ip6gre.
> This fix sets 'addr_len' to the appropriate value, ensuring
> consistency in the net_device setup for IPv6 GRE tunnels.
>
> Bug: Setting addr_len to the size of an IPv6 network address (16 bytes)
> can cause a packet socket with SOCK_DGRAM to fail on 'sendto' calls.
> This happens due to a check in 'packet_snd' for SOCK_DGRAM types,
> which validates the address length.
>
> This bug was introduced in kernel version 4.20.0 and is still present in the current version.
>
> Steps to reproduce:
>
> ip -6 tunnel add <dev_name> mode ip6gre remote <remote_addr> local <local_addr> ttl 255
> ip link set dev <dev_name> up
> busybox udhcpc -i <dev_name> -n -f
> -> It returns Invalid Argument.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=202147
> Reported-by: Friedrich Oslage <friedrich@oslage.de>
> Signed-off-by: Emanuele Santini <emanuele.santini.88@gmail.com>
> ---
> net/ipv6/ip6_gre.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
> index 235808cfec70..db7679b04a02 100644
> --- a/net/ipv6/ip6_gre.c
> +++ b/net/ipv6/ip6_gre.c
> @@ -1455,7 +1455,7 @@ static void ip6gre_tunnel_setup(struct net_device *dev)
> dev->type = ARPHRD_IP6GRE;
>
> dev->flags |= IFF_NOARP;
> - dev->addr_len = sizeof(struct in6_addr);
> + dev->addr_len = ETH_ALEN;
I guess it should be "dev->addr_len = 0" instead. We have no "hardware"
address.
> netif_keep_dst(dev);
> /* This perm addr will be used as interface identifier by IPv6 */
> dev->addr_assign_type = NET_ADDR_RANDOM;
> --
> 2.46.0
>
>
next prev parent reply other threads:[~2024-11-08 12:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 9:25 [PATCH] net: ipv6: fix the address length for net_device on a GRE tunnel Emanuele Santini
2024-11-08 12:08 ` Guillaume Nault [this message]
2024-11-08 14:24 ` Emanuele Santini
2024-11-08 16:17 ` Guillaume Nault
2024-12-18 10:52 ` Emanuele Santini
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=Zy3/TmyK7imjT348@debian \
--to=gnault@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=emanuele.santini.88@gmail.com \
--cc=friedrich@oslage.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yoshfuji@linux-ipv6.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.