* [PATCH net-next 1/1] ping: fix ipv6 ping socket flow labels
@ 2022-07-12 16:56 Tony Nguyen
2022-07-13 19:49 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Tony Nguyen @ 2022-07-12 16:56 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet
Cc: Alan Brady, netdev, anthony.l.nguyen, yoshfuji, dsahern,
Gurucharan
From: Alan Brady <alan.brady@intel.com>
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.
Signed-off-by: Alan Brady <alan.brady@intel.com>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
net/ipv6/ping.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
index ecf3a553a0dc..b1179f62bd23 100644
--- a/net/ipv6/ping.c
+++ b/net/ipv6/ping.c
@@ -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) {
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next 1/1] ping: fix ipv6 ping socket flow labels
2022-07-12 16:56 [PATCH net-next 1/1] ping: fix ipv6 ping socket flow labels Tony Nguyen
@ 2022-07-13 19:49 ` Jakub Kicinski
2022-07-13 22:48 ` Alan Brady
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-07-13 19:49 UTC (permalink / raw)
To: Tony Nguyen
Cc: davem, pabeni, edumazet, Alan Brady, netdev, yoshfuji, dsahern,
Gurucharan
On Tue, 12 Jul 2022 09:56:08 -0700 Tony Nguyen wrote:
> From: Alan Brady <alan.brady@intel.com>
>
> 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.
>
> Signed-off-by: Alan Brady <alan.brady@intel.com>
> Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Thanks! Please add a selftest and s/fix/support/ in the subject
otherwise the stable ML bot will think this is a fix, and its more
of a missing feature.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 1/1] ping: fix ipv6 ping socket flow labels
2022-07-13 19:49 ` Jakub Kicinski
@ 2022-07-13 22:48 ` Alan Brady
0 siblings, 0 replies; 3+ messages in thread
From: Alan Brady @ 2022-07-13 22:48 UTC (permalink / raw)
To: Jakub Kicinski, Tony Nguyen
Cc: davem, pabeni, edumazet, netdev, yoshfuji, dsahern, Gurucharan
On 7/13/2022 12:49 PM, Jakub Kicinski wrote:
> On Tue, 12 Jul 2022 09:56:08 -0700 Tony Nguyen wrote:
>> From: Alan Brady <alan.brady@intel.com>
>>
>> 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.
>>
>> Signed-off-by: Alan Brady <alan.brady@intel.com>
>> Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
>> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
>
> Thanks! Please add a selftest and s/fix/support/ in the subject
> otherwise the stable ML bot will think this is a fix, and its more
> of a missing feature.
Gotcha, will do both, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-13 22:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-12 16:56 [PATCH net-next 1/1] ping: fix ipv6 ping socket flow labels Tony Nguyen
2022-07-13 19:49 ` Jakub Kicinski
2022-07-13 22:48 ` Alan Brady
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).