ping: fix ipv6 ping socket flow labels
PATCH 1/1 ping: fix ipv6 ping socket flow labels
Ping sockets don't appear to make any attempt to preserve flow labels created and set by userspace. Instead they are always clobbered by autolabels (if enabled) or zero.
This grabs the flowlabel out of the msghdr similar to how rawv6_sendmsg does it and moves the memset up so we don't zero it.
--- net/ipv6/ping.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv6/ping.c +5 -1
@@ -64,6 +64,8 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (err)return err; +memset (&fl6,0 ,sizeof (fl6)); +if (msg->msg_name) { DECLARE_SOCKADDR(struct sockaddr_in6 *, u, msg->msg_name);if (msg->msg_namelen <sizeof (*u))
@@ -72,12 +74,15 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)return -EAFNOSUPPORT ; } daddr = &(u->sin6_addr); +if (np->sndflow) + fl6.flowlabel = u->sin6_flowinfo &IPV6_FLOWINFO_MASK ;if (__ipv6_addr_needs_scope_id (ipv6_addr_type (daddr))) oif = u->sin6_scope_id; }else {if (sk->sk_state !=TCP_ESTABLISHED )return -EDESTADDRREQ ; daddr = &sk->sk_v6_daddr; + fl6.flowlabel = np->flow_label; }if (!oif)
@@ -101,7 +106,6 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) ipc6.sockc.tsflags = sk->sk_tsflags; ipc6.sockc.mark = sk->sk_mark; -memset (&fl6,0 ,sizeof (fl6)); fl6.flowi6_oif = oif;if (msg->msg_controllen) {
Signature · 6 lines
2.36.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Alan Brady
Sent: Monday, June 27, 2022 10:23 PM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH net-next] ping: fix ipv6 ping socket flow labelsPing sockets don't appear to make any attempt to preserve flow labels created and set by userspace. Instead they are always clobbered by autolabels (if enabled) or zero.
Quoted 8 lines
This grabs the flowlabel out of the msghdr similar to how
rawv6_sendmsgdoes it and moves the memset up so we don't zero it.Signed-off-by Alan Brady <[email protected]>--- net/ipv6/ping.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan