* [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args
@ 2017-12-21 18:29 Mat Martineau
2017-12-21 18:29 ` [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info Mat Martineau
2017-12-26 22:25 ` [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Mat Martineau @ 2017-12-21 18:29 UTC (permalink / raw)
To: netdev; +Cc: Mat Martineau, David Ahern
Using a preprocessor directive to check for CONFIG_IPV6 in the middle of
a DECLARE_EVENT_CLASS macro's arg list causes sparse to report a series
of errors:
./include/trace/events/tcp.h:68:1: error: directive in argument list
./include/trace/events/tcp.h:75:1: error: directive in argument list
./include/trace/events/tcp.h:144:1: error: directive in argument list
./include/trace/events/tcp.h:151:1: error: directive in argument list
./include/trace/events/tcp.h:216:1: error: directive in argument list
./include/trace/events/tcp.h:223:1: error: directive in argument list
./include/trace/events/tcp.h:274:1: error: directive in argument list
./include/trace/events/tcp.h:281:1: error: directive in argument list
Once sparse finds an error, it stops printing warnings for the file it
is checking. This masks any sparse warnings that would normally be
reported for the core TCP code.
Instead, handle the preprocessor conditionals in a couple of auxiliary
macros. This also has the benefit of reducing duplicate code.
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
include/trace/events/tcp.h | 97 ++++++++++++++++++----------------------------
1 file changed, 37 insertions(+), 60 deletions(-)
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 07cccca6cbf1..ab34c561f26b 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -25,6 +25,35 @@
tcp_state_name(TCP_CLOSING), \
tcp_state_name(TCP_NEW_SYN_RECV))
+#define TP_STORE_V4MAPPED(__entry, saddr, daddr) \
+ do { \
+ struct in6_addr *pin6; \
+ \
+ pin6 = (struct in6_addr *)__entry->saddr_v6; \
+ ipv6_addr_set_v4mapped(saddr, pin6); \
+ pin6 = (struct in6_addr *)__entry->daddr_v6; \
+ ipv6_addr_set_v4mapped(daddr, pin6); \
+ } while (0)
+
+#if IS_ENABLED(CONFIG_IPV6)
+#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
+ do { \
+ if (sk->sk_family == AF_INET6) { \
+ struct in6_addr *pin6; \
+ \
+ pin6 = (struct in6_addr *)__entry->saddr_v6; \
+ *pin6 = saddr6; \
+ pin6 = (struct in6_addr *)__entry->daddr_v6; \
+ *pin6 = daddr6; \
+ } else { \
+ TP_STORE_V4MAPPED(__entry, saddr, daddr); \
+ } \
+ } while (0)
+#else
+#define TP_STORE_ADDRS(__entry, saddr, daddr, saddr6, daddr6) \
+ TP_STORE_V4MAPPED(__entry, saddr, daddr)
+#endif
+
/*
* tcp event with arguments sk and skb
*
@@ -50,7 +79,6 @@ DECLARE_EVENT_CLASS(tcp_event_sk_skb,
TP_fast_assign(
struct inet_sock *inet = inet_sk(sk);
- struct in6_addr *pin6;
__be32 *p32;
__entry->skbaddr = skb;
@@ -65,20 +93,8 @@ DECLARE_EVENT_CLASS(tcp_event_sk_skb,
p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr;
-#if IS_ENABLED(CONFIG_IPV6)
- if (sk->sk_family == AF_INET6) {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- *pin6 = sk->sk_v6_rcv_saddr;
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- *pin6 = sk->sk_v6_daddr;
- } else
-#endif
- {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
- }
+ TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
+ sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
@@ -127,7 +143,6 @@ DECLARE_EVENT_CLASS(tcp_event_sk,
TP_fast_assign(
struct inet_sock *inet = inet_sk(sk);
- struct in6_addr *pin6;
__be32 *p32;
__entry->skaddr = sk;
@@ -141,20 +156,8 @@ DECLARE_EVENT_CLASS(tcp_event_sk,
p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr;
-#if IS_ENABLED(CONFIG_IPV6)
- if (sk->sk_family == AF_INET6) {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- *pin6 = sk->sk_v6_rcv_saddr;
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- *pin6 = sk->sk_v6_daddr;
- } else
-#endif
- {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
- }
+ TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
+ sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
@@ -197,7 +200,6 @@ TRACE_EVENT(tcp_set_state,
TP_fast_assign(
struct inet_sock *inet = inet_sk(sk);
- struct in6_addr *pin6;
__be32 *p32;
__entry->skaddr = sk;
@@ -213,20 +215,8 @@ TRACE_EVENT(tcp_set_state,
p32 = (__be32 *) __entry->daddr;
*p32 = inet->inet_daddr;
-#if IS_ENABLED(CONFIG_IPV6)
- if (sk->sk_family == AF_INET6) {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- *pin6 = sk->sk_v6_rcv_saddr;
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- *pin6 = sk->sk_v6_daddr;
- } else
-#endif
- {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
- }
+ TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr,
+ sk->sk_v6_rcv_saddr, sk->sk_v6_daddr);
),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
@@ -256,7 +246,6 @@ TRACE_EVENT(tcp_retransmit_synack,
TP_fast_assign(
struct inet_request_sock *ireq = inet_rsk(req);
- struct in6_addr *pin6;
__be32 *p32;
__entry->skaddr = sk;
@@ -271,20 +260,8 @@ TRACE_EVENT(tcp_retransmit_synack,
p32 = (__be32 *) __entry->daddr;
*p32 = ireq->ir_rmt_addr;
-#if IS_ENABLED(CONFIG_IPV6)
- if (sk->sk_family == AF_INET6) {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- *pin6 = ireq->ir_v6_loc_addr;
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- *pin6 = ireq->ir_v6_rmt_addr;
- } else
-#endif
- {
- pin6 = (struct in6_addr *)__entry->saddr_v6;
- ipv6_addr_set_v4mapped(ireq->ir_loc_addr, pin6);
- pin6 = (struct in6_addr *)__entry->daddr_v6;
- ipv6_addr_set_v4mapped(ireq->ir_rmt_addr, pin6);
- }
+ TP_STORE_ADDRS(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr,
+ ireq->ir_v6_loc_addr, ireq->ir_v6_rmt_addr);
),
TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info
2017-12-21 18:29 [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args Mat Martineau
@ 2017-12-21 18:29 ` Mat Martineau
2017-12-21 22:13 ` Christoph Paasch
2017-12-26 22:24 ` David Miller
2017-12-26 22:25 ` [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args David Miller
1 sibling, 2 replies; 5+ messages in thread
From: Mat Martineau @ 2017-12-21 18:29 UTC (permalink / raw)
To: netdev; +Cc: Mat Martineau
Dereference tp->md5sig_info in tcp_v4_destroy_sock() the same way it is
done in the adjacent call to tcp_clear_md5_list().
Resolves this sparse warning:
net/ipv4/tcp_ipv4.c:1914:17: warning: incorrect type in argument 1 (different address spaces)
net/ipv4/tcp_ipv4.c:1914:17: expected struct callback_head *head
net/ipv4/tcp_ipv4.c:1914:17: got struct callback_head [noderef] <asn:4>*<noident>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
net/ipv4/tcp_ipv4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index dd945b114215..5d203248123e 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1911,7 +1911,7 @@ void tcp_v4_destroy_sock(struct sock *sk)
/* Clean up the MD5 key list, if any */
if (tp->md5sig_info) {
tcp_clear_md5_list(sk);
- kfree_rcu(tp->md5sig_info, rcu);
+ kfree_rcu(rcu_dereference_protected(tp->md5sig_info, 1), rcu);
tp->md5sig_info = NULL;
}
#endif
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info
2017-12-21 18:29 ` [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info Mat Martineau
@ 2017-12-21 22:13 ` Christoph Paasch
2017-12-26 22:24 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: Christoph Paasch @ 2017-12-21 22:13 UTC (permalink / raw)
To: Mat Martineau; +Cc: netdev
On Thu, Dec 21, 2017 at 10:29 AM, Mat Martineau
<mathew.j.martineau@linux.intel.com> wrote:
> Dereference tp->md5sig_info in tcp_v4_destroy_sock() the same way it is
> done in the adjacent call to tcp_clear_md5_list().
>
> Resolves this sparse warning:
>
> net/ipv4/tcp_ipv4.c:1914:17: warning: incorrect type in argument 1 (different address spaces)
> net/ipv4/tcp_ipv4.c:1914:17: expected struct callback_head *head
> net/ipv4/tcp_ipv4.c:1914:17: got struct callback_head [noderef] <asn:4>*<noident>
>
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> ---
> net/ipv4/tcp_ipv4.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index dd945b114215..5d203248123e 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -1911,7 +1911,7 @@ void tcp_v4_destroy_sock(struct sock *sk)
> /* Clean up the MD5 key list, if any */
> if (tp->md5sig_info) {
> tcp_clear_md5_list(sk);
> - kfree_rcu(tp->md5sig_info, rcu);
> + kfree_rcu(rcu_dereference_protected(tp->md5sig_info, 1), rcu);
Acked-by: Christoph Paasch <cpaasch@apple.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info
2017-12-21 18:29 ` [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info Mat Martineau
2017-12-21 22:13 ` Christoph Paasch
@ 2017-12-26 22:24 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2017-12-26 22:24 UTC (permalink / raw)
To: mathew.j.martineau; +Cc: netdev
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
Date: Thu, 21 Dec 2017 10:29:10 -0800
> Dereference tp->md5sig_info in tcp_v4_destroy_sock() the same way it is
> done in the adjacent call to tcp_clear_md5_list().
>
> Resolves this sparse warning:
>
> net/ipv4/tcp_ipv4.c:1914:17: warning: incorrect type in argument 1 (different address spaces)
> net/ipv4/tcp_ipv4.c:1914:17: expected struct callback_head *head
> net/ipv4/tcp_ipv4.c:1914:17: got struct callback_head [noderef] <asn:4>*<noident>
>
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args
2017-12-21 18:29 [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args Mat Martineau
2017-12-21 18:29 ` [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info Mat Martineau
@ 2017-12-26 22:25 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2017-12-26 22:25 UTC (permalink / raw)
To: mathew.j.martineau; +Cc: netdev, dsahern
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
Date: Thu, 21 Dec 2017 10:29:09 -0800
> Using a preprocessor directive to check for CONFIG_IPV6 in the middle of
> a DECLARE_EVENT_CLASS macro's arg list causes sparse to report a series
> of errors:
>
> ./include/trace/events/tcp.h:68:1: error: directive in argument list
> ./include/trace/events/tcp.h:75:1: error: directive in argument list
> ./include/trace/events/tcp.h:144:1: error: directive in argument list
> ./include/trace/events/tcp.h:151:1: error: directive in argument list
> ./include/trace/events/tcp.h:216:1: error: directive in argument list
> ./include/trace/events/tcp.h:223:1: error: directive in argument list
> ./include/trace/events/tcp.h:274:1: error: directive in argument list
> ./include/trace/events/tcp.h:281:1: error: directive in argument list
>
> Once sparse finds an error, it stops printing warnings for the file it
> is checking. This masks any sparse warnings that would normally be
> reported for the core TCP code.
>
> Instead, handle the preprocessor conditionals in a couple of auxiliary
> macros. This also has the benefit of reducing duplicate code.
>
> Cc: David Ahern <dsahern@gmail.com>
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-12-26 22:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-21 18:29 [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args Mat Martineau
2017-12-21 18:29 ` [PATCH net-next] tcp: md5: Handle RCU dereference of md5sig_info Mat Martineau
2017-12-21 22:13 ` Christoph Paasch
2017-12-26 22:24 ` David Miller
2017-12-26 22:25 ` [PATCH net] tcp: Avoid preprocessor directives in tracepoint macro args David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox