clean up SOCK_DEBUG()
Subsystems (4)
v2 cover clean up SOCK_DEBUG()
Per discussion with Daniel[1] and Eric[2], these SOCK_DEBUG() calles in TCP are not needed now.
We'd better clean up it.
Plus undefine SOCK_DEBUGGING by default.
[1] https://patchwork.ozlabs.org/patch/1035573/
[2] https://patchwork.ozlabs.org/patch/1040533/
Yafang Shao (2):
tcp: clean up SOCK_DEBUG()
net: sock: undefine SOCK_DEBUGGING
include/net/sock.h | 13 ++++++++----- net/core/sock.c | 3 +++ net/ipv4/tcp_input.c | 19 +------------------ net/ipv6/tcp_ipv6.c | 2 -- 4 files changed, 12 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/2 tcp: clean up SOCK_DEBUG()
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/
--- net/ipv4/tcp_input.c | 19 +------------------ net/ipv6/tcp_ipv6.c | 2 -- 2 files changed, 1 insertion(+), 20 deletions(-)
net/ipv4/tcp_input.c +1 -18
@@ -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)
net/ipv6/tcp_ipv6.c +0 -2
@@ -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 ;
Signature · 1 line
1.8.3.1
PATCH v2 2/2 net: sock: undefine SOCK_DEBUGGING
In reply to Yafang ShaoSOCK_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.
--- include/net/sock.h | 13 ++++++++----- net/core/sock.c | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-)
include/net/sock.h +8 -5
@@ -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
net/core/sock.c +3 -0
@@ -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
Signature · 1 line
1.8.3.1
Re: [PATCH v2 net-next 2/2] net: sock: undefine SOCK_DEBUGGING
Quoted 23 lines · Yafang Shao
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 <[email protected]>Suggested-by Joe Perches <[email protected]>--- include/net/sock.h | 13 ++++++++----- net/core/sock.c | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-)include/net/sock.h +0
-0@@ -81,14 +81,17 @@*/
include/net/sock.h line 89
Quoted 10 lines
include/net/sock.h +5
-3/* 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__); \
trivia:
I would not suggest pr_debug here as it also requires either DEBUG to be defined or CONFIG_DYNAMIC_DEBUG to be set.
If you really set SOCK_DEBUGGING, then printk(KERN_DEBUG is probably right.
Re: [PATCH v2 net-next 2/2] net: sock: undefine SOCK_DEBUGGING
Quoted 38 lines · Joe Perches
Quoted 23 lines · Yafang Shao
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 <[email protected]>Suggested-by Joe Perches <[email protected]>--- include/net/sock.h | 13 ++++++++----- net/core/sock.c | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-)include/net/sock.h +0
-0@@ -81,14 +81,17 @@*/ include/net/sock.h line 89
Quoted 10 lines
include/net/sock.h +5
-3/* 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__); \trivia:
Quoted 7 lines
I would not suggest
pr_debughere as it also requires either DEBUG to be defined orCONFIG_DYNAMIC_DEBUGto be set.If you really set
SOCK_DEBUGGING, then printk(KERN_DEBUG is probably right.
Sure. Will change it.
Thanks
Yafang