From: Yafang Shao <laoar.shao@gmail.com>
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 <laoar.shao@gmail.com>
Subject: [PATCH v2 net-next 2/2] net: sock: undefine SOCK_DEBUGGING
Date: Sun, 17 Feb 2019 00:28:57 +0800 [thread overview]
Message-ID: <1550334537-380-3-git-send-email-laoar.shao@gmail.com> (raw)
In-Reply-To: <1550334537-380-1-git-send-email-laoar.shao@gmail.com>
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 <laoar.shao@gmail.com>
Suggested-by: Joe Perches <joe@perches.com>
---
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..d41e8f4 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)) \
+ pr_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
--
1.8.3.1
next prev parent reply other threads:[~2019-02-16 16:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-16 16:28 [PATCH v2 net-next 0/2] clean up SOCK_DEBUG() Yafang Shao
2019-02-16 16:28 ` [PATCH v2 net-next 1/2] tcp: " Yafang Shao
2019-02-16 16:28 ` Yafang Shao [this message]
2019-02-17 11:58 ` [PATCH v2 net-next 2/2] net: sock: undefine SOCK_DEBUGGING Joe Perches
2019-02-17 14:07 ` Yafang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1550334537-380-3-git-send-email-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
--cc=shaoyafang@didiglobal.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox