From patchwork Sun Feb 17 14:26:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 1043674 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kwyL87Fx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 442Tpm6VSBz9sDX for ; Mon, 18 Feb 2019 01:27:12 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbfBQO1E (ORCPT ); Sun, 17 Feb 2019 09:27:04 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33713 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbfBQO1E (ORCPT ); Sun, 17 Feb 2019 09:27:04 -0500 Received: by mail-pf1-f195.google.com with SMTP id c123so7233984pfb.0 for ; Sun, 17 Feb 2019 06:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6eqgbVzfbeostRs5zJ47WsuzZPvsQlrqs6sP0vIQU6o=; b=kwyL87FxFOfAnKS02sSrSd8Q2vS3Qp8Su2p7kJpDBGw+k0sB3fVu8ZuglaqXTnJod4 PwHekv+lLfxrIObF+tytXGHi1nkv3rWysgRkgzenidpXIBqF6vSO31+QFHnIYLuykj7T RLJWC2vf+Z4abl6ARTo7CuxPwkZn7CyQP+homL8v+Dh/1+bWowzXoUPqp6MPoCwB6ALk XGI2IA18O9DI5B9hIHF/xXGhvSWuSt8wetoTPzx/dxaeRBe4F9PAXOJCNWOAhdhIg/X4 I6SN83b+hgleMamGeG3ZXftD+eM4NAnhlWoUR7Q0Cha0rTE/onZammqvzQ2Yn/A1qzNt PkSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6eqgbVzfbeostRs5zJ47WsuzZPvsQlrqs6sP0vIQU6o=; b=Jc8p3f2uxa6XnAs3zIOunpMilQfpOaiDjBKezMotny0dC2HINkJikbPyJrUy6p0BkY utC/Epq6DlKibY7rVf00AqW7car4bCQNUnby+XU8+gQIfLMbua30PqknPdAHe23KHiU+ RXqe+G/arBR+YWIo7nt3BykJzu9ocFY+zIu4DOY3W6C95r+bURMyHRI5mawSD9aybuob /STAHAWF6rUeOHtC+zKIOiFAzZ8r8xf7zf1X8MF7/AuNmmgxswwweTTT1QlFzWSnS/sH MmQK5Kw5vrthnNFmLKIJGh3E8Mms6+vg8OPxv6iGHwd5GgTYzRFXc41zC0n6bdg1HJOK NbZQ== X-Gm-Message-State: AHQUAubyflaL3Qt8gHmVjdNhCIt/mvRLI1WYlR6/7wLG5Y0qNnpQNWqm 2YL9s2f3TTMdgdDPyxfmMgk8pVMCYdA= X-Google-Smtp-Source: AHgI3IYliSxN8u19DE/nO3SPn4kIPPRjY5MbS/OUy/38xNbwnfQxU/wTdyTuF9Rf/9TFB0ZZXGpTkw== X-Received: by 2002:a62:445a:: with SMTP id r87mr19225817pfa.13.1550413623541; Sun, 17 Feb 2019 06:27:03 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id t5sm14130325pgo.70.2019.02.17.06.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 06:27:02 -0800 (PST) From: Yafang Shao To: davem@davemloft.net Cc: daniel@iogearbox.net, edumazet@google.com, joe@perches.com, xiyou.wangcong@gmail.com, netdev@vger.kernel.org, shaoyafang@didiglobal.com, Yafang Shao Subject: [PATCH v3 net-next 1/2] tcp: clean up SOCK_DEBUG() Date: Sun, 17 Feb 2019 22:26:31 +0800 Message-Id: <1550413592-7877-2-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550413592-7877-1-git-send-email-laoar.shao@gmail.com> References: <1550413592-7877-1-git-send-email-laoar.shao@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Per discussion with Daniel[1] and Eric[2], these SOCK_DEBUG() calles in TCP are not needed now. We'd better clean up it. [1] https://patchwork.ozlabs.org/patch/1035573/ [2] https://patchwork.ozlabs.org/patch/1040533/ Signed-off-by: Yafang Shao --- net/ipv4/tcp_input.c | 19 +------------------ net/ipv6/tcp_ipv6.c | 2 -- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7a027dec..6d2750e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3595,7 +3595,7 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) * this segment (RFC793 Section 3.9). */ if (after(ack, tp->snd_nxt)) - goto invalid_ack; + return -1; if (after(ack, prior_snd_una)) { flag |= FLAG_SND_UNA_ADVANCED; @@ -3714,10 +3714,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_process_tlp_ack(sk, ack, flag); return 1; -invalid_ack: - SOCK_DEBUG(sk, "Ack %u after %u:%u\n", ack, tp->snd_una, tp->snd_nxt); - return -1; - old_ack: /* If data was SACKed, tag it and see if we should send more data. * If data was DSACKed, see if we can undo a cwnd reduction. @@ -3731,7 +3727,6 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) tcp_xmit_recovery(sk, rexmit); } - SOCK_DEBUG(sk, "Ack %u before %u:%u\n", ack, tp->snd_una, tp->snd_nxt); return 0; } @@ -4432,13 +4427,9 @@ static void tcp_ofo_queue(struct sock *sk) rb_erase(&skb->rbnode, &tp->out_of_order_queue); if (unlikely(!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))) { - SOCK_DEBUG(sk, "ofo packet was already received\n"); tcp_drop(sk, skb); continue; } - SOCK_DEBUG(sk, "ofo requeuing : rcv_next %X seq %X - %X\n", - tp->rcv_nxt, TCP_SKB_CB(skb)->seq, - TCP_SKB_CB(skb)->end_seq); tail = skb_peek_tail(&sk->sk_receive_queue); eaten = tail && tcp_try_coalesce(sk, tail, skb, &fragstolen); @@ -4502,8 +4493,6 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFOQUEUE); seq = TCP_SKB_CB(skb)->seq; end_seq = TCP_SKB_CB(skb)->end_seq; - SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n", - tp->rcv_nxt, seq, end_seq); p = &tp->out_of_order_queue.rb_node; if (RB_EMPTY_ROOT(&tp->out_of_order_queue)) { @@ -4779,10 +4768,6 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) if (before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { /* Partial packet, seq < rcv_next < end_seq */ - SOCK_DEBUG(sk, "partial packet: rcv_next %X seq %X - %X\n", - tp->rcv_nxt, TCP_SKB_CB(skb)->seq, - TCP_SKB_CB(skb)->end_seq); - tcp_dsack_set(sk, TCP_SKB_CB(skb)->seq, tp->rcv_nxt); /* If window is closed, drop tail of packet. But after @@ -5061,8 +5046,6 @@ static int tcp_prune_queue(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); - SOCK_DEBUG(sk, "prune_queue: c=%x\n", tp->copied_seq); - NET_INC_STATS(sock_net(sk), LINUX_MIB_PRUNECALLED); if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index e51cda7..57ef69a1 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -220,8 +220,6 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, u32 exthdrlen = icsk->icsk_ext_hdr_len; struct sockaddr_in sin; - SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); - if (__ipv6_only_sock(sk)) return -ENETUNREACH; From patchwork Sun Feb 17 14:26:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 1043675 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N8joPo/Z"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 442Tpn60g8z9s7h for ; Mon, 18 Feb 2019 01:27:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbfBQO1K (ORCPT ); Sun, 17 Feb 2019 09:27:10 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33824 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbfBQO1K (ORCPT ); Sun, 17 Feb 2019 09:27:10 -0500 Received: by mail-pf1-f193.google.com with SMTP id j18so7231081pfe.1 for ; Sun, 17 Feb 2019 06:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gIgAApXlOkB0VgkDFZmbv1Kzg9ZpFpPXRePfvNqhmeA=; b=N8joPo/ZgEDq1qyfwKPgCyrVaemoeI1UVHll2zNjacIvTAPeU8y87kIsDEer1stkj2 o74/fx/kgJVmO1FBAFy1MQMnFafR+tKR7J+z2OIiNhCd7fuljzy3piCkf1+EWj91y7tm frMRPXPIISyoFTfn66RmnmuyKHMURGst5OYCmLTxxC/4423JZTvNhD3sc+bINLF8Bhx1 G7rriPtwKfmEj7r6GkYAU0qOHHDUdblQH1LkC6A9yf+FspJtC26uM+4sx9Zvc09QZYE0 osVGH01wPxgVmsOT5lLdSwQM5tSG1kvfsGKNgrWuSvWbFybdNfc8G0efmpu+jMfy0jL7 JK8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gIgAApXlOkB0VgkDFZmbv1Kzg9ZpFpPXRePfvNqhmeA=; b=jzKeqDYXCGl1Vrz/YvgXzVheXLm5fE+9dO90XKTsSGduP24bk/Fsnip5Yl07mS6+ZW FBmW4WG56oQ1g6Aq+x6WTEw6zxB70RxLRLiypTDTWTSeDXIFG2uuHbhjtk88k8J4gsaB 7TDyR649ITmvEFMJQOb1ExUmHSPqrIPaNdrB73/D/vXzyqCpjL5GHuNak9A59RLrXEzV Oy2xLRLpqhR1z7IwmwLGj71Vm/I/idQxqYmIVpi2Ew387rOKwI+oexb3GZeE1mxnSvSI tisn83PLcwVGyea+uBDcBi3exbnpYqqVnHztuPUZzMYMSgLdePn9UggP7vA9ZbZPUG0w dNKg== X-Gm-Message-State: AHQUAuZKrx2dZeBOdmw9N121ky1xGIEJTDnErKiWopIQlOV+Xd5NDmxc syfV8zgHmejgMNPZgnpMNU0= X-Google-Smtp-Source: AHgI3IY9se7VQb3dHYbFIoavp9mFOrD5uz80l/YDzA+/xcS4yLCr7cqkP2Ke7MjnFgxr/ss+iokJww== X-Received: by 2002:a62:3990:: with SMTP id u16mr19463056pfj.80.1550413629226; Sun, 17 Feb 2019 06:27:09 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id t5sm14130325pgo.70.2019.02.17.06.27.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 06:27:08 -0800 (PST) From: Yafang Shao To: davem@davemloft.net Cc: daniel@iogearbox.net, edumazet@google.com, joe@perches.com, xiyou.wangcong@gmail.com, netdev@vger.kernel.org, shaoyafang@didiglobal.com, Yafang Shao Subject: [PATCH v3 net-next 2/2] net: sock: undefine SOCK_DEBUGGING Date: Sun, 17 Feb 2019 22:26:32 +0800 Message-Id: <1550413592-7877-3-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550413592-7877-1-git-send-email-laoar.shao@gmail.com> References: <1550413592-7877-1-git-send-email-laoar.shao@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org SOCK_DEBUG() is a old facility for debugging. If the user want to use it for debugging, the user must modify the application first, that doesn't seem like a good way. Now we have more powerful facilities, i.e. bpf or tracepoint, for this kind of debugging purpose. So we'd better disable it by default. The reason why I don't remove it comepletely is that someone may still would like to use it for debugging. Signed-off-by: Yafang Shao Suggested-by: Joe Perches --- include/net/sock.h | 13 ++++++++----- net/core/sock.c | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 6679f3c..444e92f 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -81,14 +81,17 @@ */ /* Define this to get the SOCK_DBG debugging facility. */ -#define SOCK_DEBUGGING +/* #define SOCK_DEBUGGING */ #ifdef SOCK_DEBUGGING -#define SOCK_DEBUG(sk, msg...) do { if ((sk) && sock_flag((sk), SOCK_DBG)) \ - printk(KERN_DEBUG msg); } while (0) +#define SOCK_DEBUG(sk, fmt, ...) \ +do { \ + if ((sk) && sock_flag((sk), SOCK_DBG)) \ + printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ +} while (0) #else /* Validate arguments and do nothing */ -static inline __printf(2, 3) -void SOCK_DEBUG(const struct sock *sk, const char *msg, ...) +__printf(2, 3) +static inline void SOCK_DEBUG(const struct sock *sk, const char *fmt, ...) { } #endif diff --git a/net/core/sock.c b/net/core/sock.c index 71ded4d..7c15835 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -753,6 +753,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, switch (optname) { case SO_DEBUG: + /* This option takes effect only when SOCK_DEBUGGING + * is defined. + */ if (val && !capable(CAP_NET_ADMIN)) ret = -EACCES; else