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