From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH net V2] net: always reevalulate autoflowlabel setting for reset packet Date: Tue, 19 Dec 2017 14:33:30 -0800 Message-ID: <1513722810.64874.7.camel@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Kernel Team , Shaohua Li , Martin KaFai Lau To: Shaohua Li , netdev@vger.kernel.org, davem@davemloft.net Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:45648 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbdLSWde (ORCPT ); Tue, 19 Dec 2017 17:33:34 -0500 Received: by mail-wm0-f66.google.com with SMTP id 9so6526347wme.4 for ; Tue, 19 Dec 2017 14:33:33 -0800 (PST) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 2017-12-19 at 12:58 -0800, Shaohua Li wrote: > From: Shaohua Li > > ipv6_pinfo.autoflowlabel is set in sock creation. Later if we change > sysctl.ip6.auto_flowlabels, the ipv6_pinfo.autoflowlabel isn't changed, > so the sock will keep the old behavior in terms of auto flowlabel. Reset > packet is suffering from this problem, because reset packset is sent > from a special control socket, which is created at boot time. Since > sysctl.ipv6.auto_flowlabels is 2 by default, the control socket will > always have its ipv6_pinfo.autoflowlabel set, even after user set > sysctl.ipv6.auto_flowlabels to 1, so reset packset will always have > flowlabel. > > To fix this, we always reevaluate autoflowlabel setting for reset > packet. Normal sock has the same issue too, but since the > sysctl.ipv6.auto_flowlabels is usually set at host startup, this isn't a > big issue for normal sock. > > Cc: Martin KaFai Lau > Signed-off-by: Shaohua Li > --- > net/ipv6/tcp_ipv6.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c > index 7178476..5fba548 100644 > --- a/net/ipv6/tcp_ipv6.c > +++ b/net/ipv6/tcp_ipv6.c > @@ -787,9 +787,11 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 > struct net *net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev); > struct sock *ctl_sk = net->ipv6.tcp_sk; > unsigned int tot_len = sizeof(struct tcphdr); > + struct ipv6_pinfo *np = inet6_sk(ctl_sk); > struct dst_entry *dst; > __be32 *topt; > > + np->autoflowlabel = ip6_default_np_autolabel(net); This looks unsafe to set a bitfield on a shared socket (one ctl_sk per netns) Compiler could play strange things here.