Received: by 10.192.165.148 with SMTP id m20csp728897imm; Wed, 9 May 2018 22:47:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp85dZgTVBvidi9MmmNfWiZTevgpWpBTuiaEysB1neJLO9bz1z9fGwbTJEfEAJoPcwy1zWc X-Received: by 2002:a62:b03:: with SMTP id t3-v6mr65439pfi.32.1525931246596; Wed, 09 May 2018 22:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525931246; cv=none; d=google.com; s=arc-20160816; b=SbU4PQMgYvHQQlGxuWMMr+skral6QRCbmVBlz9beJsvWllJdf21nnoTh8yryomW0Iz B0q2eqRi++9P6501kkZWXGmiCR64OzZJFYyhMt6vzij9mRoKL467ngkZTp61O1iE1HSS y3jNZWcdRYhk4KT/224ynsrqcJnzGv9al1FsnapZFT4vly8UkUCkfApy7ZQjohYOheRt yTEmDPC596nlGXFGOYKBygSnMXwitXMlZBX+JXb5agMliqTtzil6cGDdZBSFA4DR+10F Tl6Li89pCh0e+Noq5W4BfI4+ByahFgSbFfxZfW/oFCfOLeBYZboTU59Sp+4nDF2EslWc N+JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=zWj9cp/gywcOKU4FkTVzwiOZoD7JG3Kh59ah/XH9VZw=; b=FvygmAUDB+s1cJUS7jyh5ayn6ZR4hT0r9g7kLlW+s4OkkhqlnLhnkQ3+SgU+z/ZR6X M/30jKhpi7pryWcjnEYf8LyQUwWPaGqkTj4EyHjT/SG2+mhS8ag8BsmbC+s2s8AuiQv3 ofjNhJRAfaWXf9TGSXX827V63dIiAIHugNA4KJscqBcxBSOck1PLMd/kRZyAafU8oOIv pxvH6iumt7+vXYZREdJpRd5zH8+xk5TXODD/z2VcNL6NNuueX8Yc2kfjxcTsh+3yVANg 5WYksi/HhXw/uybFtUhrzkTtXTeFhBNU3Wa5zVWl9pX5NLEq0UYmaSVUPnxRKGVNSy9j Y7/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eBVQynfI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8-v6si11758pgn.269.2018.05.09.22.47.10; Wed, 09 May 2018 22:47:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eBVQynfI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756571AbeEJFpV (ORCPT + 99 others); Thu, 10 May 2018 01:45:21 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:36845 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753696AbeEJFpT (ORCPT ); Thu, 10 May 2018 01:45:19 -0400 Received: by mail-pg0-f44.google.com with SMTP id z70-v6so469278pgz.3; Wed, 09 May 2018 22:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zWj9cp/gywcOKU4FkTVzwiOZoD7JG3Kh59ah/XH9VZw=; b=eBVQynfIQluoxvzUXpnttVY1B/tUXIbLK+3aM7WWgxRGurkI2Q5xn3fpyhZAmWREfP otK0XGQXC7Nhpe5X0+m7CxNnm20OW3UlA0RNZo33n6XznOSiuyGGvImJB1heFJymbPyi oJQyFYD/sfPW8bZ2Z9HOTq33Og3kJ9OGWtRYfNVRlAj+QacpXDZ0gPGDDbHr4aKe7OMP jaKu4k6XJCI3Im7daa8yXAjhsXs8m1ALZzm8M4r/IkKSYGqw+3PqQ0NuwMj5IK33pRsn 0Xwkt6OK38i/Vnfr4KaClh+hWHEtNcUHDNFjDT7nOgzV70UNDN55ZRkHWHpsO6SEsmvj lueQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zWj9cp/gywcOKU4FkTVzwiOZoD7JG3Kh59ah/XH9VZw=; b=mPJzExq+3d2KOl6GU3Rkl533IHiu7Nms45VccolyyxxwFxGyhkXgVaCPhmSo9nNKB2 HGDVVJFvtdQP3C5+snd+sUXGGe+UV9h2JbN+/bgCAAXEoZqC/imd2yyRBASZdwso374c YiHt+UcREz+yBwHaFr9q5v2eWr8xYSfYuYz3mJG2LOP1RhTfXH5bdP2+v5lnqY8UPtgg FnWHrcjFZONnjwxZvDfPB8ZKphXZfKlhy/5xaHfn8UNukldRVKAtWTRHtS5gH2T7Zu31 gOq5iWEeQSOrmsLja3Sy8+drYoTiUmRabmj6MH/zk4FXXl7tJvyvxHlF2B9b2duR2Sn7 TsTA== X-Gm-Message-State: ALKqPwfRSxDw/C87TPja8g3aU23XIuBopqDR6b1oOXboH0P5MaillqHR 3dnzzOK1vcPHVzAX7z4lLbE= X-Received: by 2002:a65:4601:: with SMTP id v1-v6mr19846pgq.237.1525931119255; Wed, 09 May 2018 22:45:19 -0700 (PDT) Received: from [192.168.86.235] (c-67-180-167-114.hsd1.ca.comcast.net. [67.180.167.114]) by smtp.gmail.com with ESMTPSA id b6-v6sm138465pgr.52.2018.05.09.22.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 May 2018 22:45:17 -0700 (PDT) Subject: Re: [PATCH net-next v1] tcp: Add mark for TIMEWAIT sockets To: Jon Maxwell , davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jmaxwell@redhat.com References: <20180510052111.17886-1-jmaxwell37@gmail.com> From: Eric Dumazet Message-ID: Date: Wed, 9 May 2018 22:45:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180510052111.17886-1-jmaxwell37@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/2018 10:21 PM, Jon Maxwell wrote: ... > if (th->rst) > @@ -723,11 +724,17 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb) > arg.tos = ip_hdr(skb)->tos; > arg.uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL); > local_bh_disable(); > - ip_send_unicast_reply(*this_cpu_ptr(net->ipv4.tcp_sk), > + ctl_sk = *this_cpu_ptr(net->ipv4.tcp_sk); > + if (sk && sk->sk_state == TCP_TIME_WAIT) > + ctl_sk->sk_mark = inet_twsk(sk)->tw_mark; > + else if (sk && sk_fullsock(sk)) I do not believe we could have a non fullsock here ? A request socket (SYN_RECV state) at this point is not expected. So you can factorize : if (sk) ctl_sk->sk_mark = (sk->sk_state == TCP_TIME_WAIT) ? inet_twsk(sk)->tw_mark : sk->sk_mark; (same remark for IPv6) > + ctl_sk->sk_mark = sk->sk_mark; > + ip_send_unicast_reply(ctl_sk, > skb, &TCP_SKB_CB(skb)->header.h4.opt, > ip_hdr(skb)->saddr, ip_hdr(skb)->daddr, > &arg, arg.iov[0].iov_len);