Netdev List
 help / color / mirror / Atom feed
* [PATCH v2 net-next 3/4] net: tracepoint: using sock_set_state tracepoint to trace DCCP state transition
From: Yafang Shao @ 2017-12-15 17:01 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao
In-Reply-To: <1513357314-8402-1-git-send-email-laoar.shao@gmail.com>

With changes in inet_ files, DCCP state transitions are traced with
sock_set_state tracepoint.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/dccp/proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 9d43c1f..2874faf 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -110,7 +110,7 @@ void dccp_set_state(struct sock *sk, const int state)
 	/* Change state AFTER socket is unhashed to avoid closed
 	 * socket sitting in hash tables.
 	 */
-	sk->sk_state = state;
+	sk_set_state(sk, state);
 }

 EXPORT_SYMBOL_GPL(dccp_set_state);
--
1.8.3.1

^ permalink raw reply related

* [PATCH v2 net-next 4/4] net: tracepoint: using sock_set_state tracepoint to trace SCTP state transition
From: Yafang Shao @ 2017-12-15 17:01 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao
In-Reply-To: <1513357314-8402-1-git-send-email-laoar.shao@gmail.com>

With changes in inet_ files, SCTP state transitions are traced with
sockt_set_state tracepoint.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/sctp/endpointola.c   |  2 +-
 net/sctp/sm_sideeffect.c |  4 ++--
 net/sctp/socket.c        | 12 ++++++------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index ee1e601..5e129df 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -232,7 +232,7 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)
 {
 	ep->base.dead = true;

-	ep->base.sk->sk_state = SCTP_SS_CLOSED;
+	 sk_set_state(ep->base.sk, SCTP_SS_CLOSED);

 	/* Unlink this endpoint, so we can't find it again! */
 	sctp_unhash_endpoint(ep);
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 8adde71..22ab3b4 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -878,12 +878,12 @@ static void sctp_cmd_new_state(struct sctp_cmd_seq *cmds,
 		 * successfully completed a connect() call.
 		 */
 		if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED))
-			sk->sk_state = SCTP_SS_ESTABLISHED;
+			sk_set_state(sk, SCTP_SS_ESTABLISHED);

 		/* Set the RCV_SHUTDOWN flag when a SHUTDOWN is received. */
 		if (sctp_state(asoc, SHUTDOWN_RECEIVED) &&
 		    sctp_sstate(sk, ESTABLISHED)) {
-			sk->sk_state = SCTP_SS_CLOSING;
+			sk_set_state(sk, SCTP_SS_CLOSING);
 			sk->sk_shutdown |= RCV_SHUTDOWN;
 		}
 	}
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7eec0a0..ecb532c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1544,7 +1544,7 @@ static void sctp_close(struct sock *sk, long timeout)

 	lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
 	sk->sk_shutdown = SHUTDOWN_MASK;
-	sk->sk_state = SCTP_SS_CLOSING;
+	sk_set_state(sk, SCTP_SS_CLOSING);

 	ep = sctp_sk(sk)->ep;

@@ -4653,7 +4653,7 @@ static void sctp_shutdown(struct sock *sk, int how)
 	if (how & SEND_SHUTDOWN && !list_empty(&ep->asocs)) {
 		struct sctp_association *asoc;

-		sk->sk_state = SCTP_SS_CLOSING;
+		sk_set_state(sk, SCTP_SS_CLOSING);
 		asoc = list_entry(ep->asocs.next,
 				  struct sctp_association, asocs);
 		sctp_primitive_SHUTDOWN(net, asoc, NULL);
@@ -7509,13 +7509,13 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 	 * sockets.
 	 *
 	 */
-	sk->sk_state = SCTP_SS_LISTENING;
+	sk_set_state(sk, SCTP_SS_LISTENING);
 	if (!ep->base.bind_addr.port) {
 		if (sctp_autobind(sk))
 			return -EAGAIN;
 	} else {
 		if (sctp_get_port(sk, inet_sk(sk)->inet_num)) {
-			sk->sk_state = SCTP_SS_CLOSED;
+			sk_set_state(sk, SCTP_SS_CLOSED);
 			return -EADDRINUSE;
 		}
 	}
@@ -8538,10 +8538,10 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
 	 * is called, set RCV_SHUTDOWN flag.
 	 */
 	if (sctp_state(assoc, CLOSED) && sctp_style(newsk, TCP)) {
-		newsk->sk_state = SCTP_SS_CLOSED;
+		sk_set_state(newsk, SCTP_SS_CLOSED);
 		newsk->sk_shutdown |= RCV_SHUTDOWN;
 	} else {
-		newsk->sk_state = SCTP_SS_ESTABLISHED;
+		sk_set_state(newsk, SCTP_SS_ESTABLISHED);
 	}

 	release_sock(newsk);
--
1.8.3.1

^ permalink raw reply related

* [PATCH v2 net-next 0/4]  replace tcp_set_state tracepoint with
From: Yafang Shao @ 2017-12-15 17:01 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao

Hi,

According to the discussion in the mail thread
https://patchwork.kernel.org/patch/10099243/,
tcp_set_state tracepoint is renamed to sock_set_state tracepoint and is moved
to include/trace/events/sock.h.

Using this new tracepoint to trace TCP/DCCP/SCTP state transition.

v1-v2: Steven's patch is included in this series.

Steven Rostedt:
  tcp: Export to userspace the TCP state names for the trace events

Yafang Shao (3):
  net: tracepoint: using sock_set_state tracepoint to trace SCTP state
    transition
  net: tracepoint: replace tcp_set_state tracepoint with sock_set_state
    tracepoint
  net: tracepoint: using sock_set_state tracepoint to trace DCCP state
    transition

 include/net/sock.h              |  15 +-----
 include/trace/events/sock.h     | 106 ++++++++++++++++++++++++++++++++++++++++
 include/trace/events/tcp.h      |  76 ----------------------------
 net/core/sock.c                 |  13 +++++
 net/dccp/proto.c                |   2 +-
 net/ipv4/inet_connection_sock.c |   4 +-
 net/ipv4/inet_hashtables.c      |   2 +-
 net/ipv4/tcp.c                  |   4 --
 net/sctp/endpointola.c          |   2 +-
 net/sctp/sm_sideeffect.c        |   4 +-
 net/sctp/socket.c               |  12 ++---
 11 files changed, 134 insertions(+), 106 deletions(-)

-- 
1.8.3.1

^ permalink raw reply

* [PATCH v2 net-next 2/4] net: tracepoint: replace tcp_set_state tracepoint with sock_set_state tracepoint
From: Yafang Shao @ 2017-12-15 17:01 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao
In-Reply-To: <1513357314-8402-1-git-send-email-laoar.shao@gmail.com>

As sk_state is a common field for struct sock, so the state
transition should not be a TCP specific feature.
So I rename tcp_set_state tracepoint to sock_set_state tracepoint with
some minor changes and move it into file trace/events/sock.h.

Two helpers are introduced to trace sk_state transition
    - void sk_state_store(struct sock *sk, int state);
    - void sk_set_state(struct sock *sk, int state);
As trace header should not be included in other header files,
so they are defined in sock.c.

The protocol such as SCTP maybe compiled as a ko, hence export
sk_set_state().

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 include/net/sock.h              |  15 +-----
 include/trace/events/sock.h     | 106 ++++++++++++++++++++++++++++++++++++++++
 include/trace/events/tcp.h      |  91 ----------------------------------
 net/core/sock.c                 |  13 +++++
 net/ipv4/inet_connection_sock.c |   4 +-
 net/ipv4/inet_hashtables.c      |   2 +-
 net/ipv4/tcp.c                  |   4 --
 7 files changed, 124 insertions(+), 111 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 9a90472..988ce82 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2344,19 +2344,8 @@ static inline int sk_state_load(const struct sock *sk)
 	return smp_load_acquire(&sk->sk_state);
 }

-/**
- * sk_state_store - update sk->sk_state
- * @sk: socket pointer
- * @newstate: new state
- *
- * Paired with sk_state_load(). Should be used in contexts where
- * state change might impact lockless readers.
- */
-static inline void sk_state_store(struct sock *sk, int newstate)
-{
-	smp_store_release(&sk->sk_state, newstate);
-}
-
+void sk_state_store(struct sock *sk, int newstate);
+void sk_set_state(struct sock *sk, int state);
 void sock_enable_timestamp(struct sock *sk, int flag);
 int sock_get_timestamp(struct sock *, struct timeval __user *);
 int sock_get_timestampns(struct sock *, struct timespec __user *);
diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h
index ec4dade..61977e5 100644
--- a/include/trace/events/sock.h
+++ b/include/trace/events/sock.h
@@ -6,7 +6,49 @@
 #define _TRACE_SOCK_H

 #include <net/sock.h>
+#include <net/ipv6.h>
 #include <linux/tracepoint.h>
+#include <linux/ipv6.h>
+#include <linux/tcp.h>
+
+#define inet_protocol_names		\
+		EM(IPPROTO_TCP)			\
+		EM(IPPROTO_DCCP)		\
+		EMe(IPPROTO_SCTP)
+
+#define tcp_state_names			\
+		EM(TCP_ESTABLISHED)		\
+		EM(TCP_SYN_SENT)		\
+		EM(TCP_SYN_RECV)		\
+		EM(TCP_FIN_WAIT1)	   \
+		EM(TCP_FIN_WAIT2)	   \
+		EM(TCP_TIME_WAIT)	   \
+		EM(TCP_CLOSE)		   \
+		EM(TCP_CLOSE_WAIT)	  \
+		EM(TCP_LAST_ACK)		\
+		EM(TCP_LISTEN)		  \
+		EM(TCP_CLOSING)		 \
+		EMe(TCP_NEW_SYN_RECV)
+
+/* enums need to be exported to user space */
+#undef EM
+#undef EMe
+#define EM(a)       TRACE_DEFINE_ENUM(a);
+#define EMe(a)      TRACE_DEFINE_ENUM(a);
+
+inet_protocol_names
+tcp_state_names
+
+#undef EM
+#undef EMe
+#define EM(a)       { a, #a },
+#define EMe(a)      { a, #a }
+
+#define show_inet_protocol_name(val)	\
+	__print_symbolic(val, inet_protocol_names)
+
+#define show_tcp_state_name(val)		\
+	__print_symbolic(val, tcp_state_names)

 TRACE_EVENT(sock_rcvqueue_full,

@@ -63,6 +105,70 @@
 		__entry->rmem_alloc)
 );

+TRACE_EVENT(sock_set_state,
+
+	TP_PROTO(const struct sock *sk, const int oldstate, const int newstate),
+
+	TP_ARGS(sk, oldstate, newstate),
+
+	TP_STRUCT__entry(
+		__field(const void *, skaddr)
+		__field(int, oldstate)
+		__field(int, newstate)
+		__field(__u16, sport)
+		__field(__u16, dport)
+		__field(__u8, protocol)
+		__array(__u8, saddr, 4)
+		__array(__u8, daddr, 4)
+		__array(__u8, saddr_v6, 16)
+		__array(__u8, daddr_v6, 16)
+	),
+
+	TP_fast_assign(
+		struct inet_sock *inet = inet_sk(sk);
+		struct in6_addr *pin6;
+		__be32 *p32;
+
+		__entry->skaddr = sk;
+		__entry->oldstate = oldstate;
+		__entry->newstate = newstate;
+
+		__entry->protocol = sk->sk_protocol;
+		__entry->sport = ntohs(inet->inet_sport);
+		__entry->dport = ntohs(inet->inet_dport);
+
+		p32 = (__be32 *) __entry->saddr;
+		*p32 = inet->inet_saddr;
+
+		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_printk("protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4"
+			"saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
+			show_inet_protocol_name(__entry->protocol),
+			__entry->sport, __entry->dport,
+			__entry->saddr, __entry->daddr,
+			__entry->saddr_v6, __entry->daddr_v6,
+			show_tcp_state_name(__entry->oldstate),
+			show_tcp_state_name(__entry->newstate))
+);
+
 #endif /* _TRACE_SOCK_H */

 /* This part must be outside protection */
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 40240ac..7399399 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -9,37 +9,6 @@
 #include <linux/tracepoint.h>
 #include <net/ipv6.h>

-#define tcp_state_names			\
-		EM(TCP_ESTABLISHED)		\
-		EM(TCP_SYN_SENT)		\
-		EM(TCP_SYN_RECV)		\
-		EM(TCP_FIN_WAIT1)		\
-		EM(TCP_FIN_WAIT2)		\
-		EM(TCP_TIME_WAIT)		\
-		EM(TCP_CLOSE)			\
-		EM(TCP_CLOSE_WAIT)		\
-		EM(TCP_LAST_ACK)		\
-		EM(TCP_LISTEN)			\
-		EM(TCP_CLOSING)			\
-		EMe(TCP_NEW_SYN_RECV)	\
-
-/* enums need to be exported to user space */
-#undef EM
-#undef EMe
-#define EM(a)         TRACE_DEFINE_ENUM(a);
-#define EMe(a)        TRACE_DEFINE_ENUM(a);
-
-tcp_state_names
-
-#undef EM
-#undef EMe
-#define EM(a)         tcp_state_name(a),
-#define EMe(a)        tcp_state_name(a)
-
-#define tcp_state_name(state)	{ state, #state }
-#define show_tcp_state_name(val)			\
-	__print_symbolic(val, tcp_state_names)
-
 /*
  * tcp event with arguments sk and skb
  *
@@ -192,66 +161,6 @@
 	TP_ARGS(sk)
 );

-TRACE_EVENT(tcp_set_state,
-
-	TP_PROTO(const struct sock *sk, const int oldstate, const int newstate),
-
-	TP_ARGS(sk, oldstate, newstate),
-
-	TP_STRUCT__entry(
-		__field(const void *, skaddr)
-		__field(int, oldstate)
-		__field(int, newstate)
-		__field(__u16, sport)
-		__field(__u16, dport)
-		__array(__u8, saddr, 4)
-		__array(__u8, daddr, 4)
-		__array(__u8, saddr_v6, 16)
-		__array(__u8, daddr_v6, 16)
-	),
-
-	TP_fast_assign(
-		struct inet_sock *inet = inet_sk(sk);
-		struct in6_addr *pin6;
-		__be32 *p32;
-
-		__entry->skaddr = sk;
-		__entry->oldstate = oldstate;
-		__entry->newstate = newstate;
-
-		__entry->sport = ntohs(inet->inet_sport);
-		__entry->dport = ntohs(inet->inet_dport);
-
-		p32 = (__be32 *) __entry->saddr;
-		*p32 = inet->inet_saddr;
-
-		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_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
-		  __entry->sport, __entry->dport,
-		  __entry->saddr, __entry->daddr,
-		  __entry->saddr_v6, __entry->daddr_v6,
-		  show_tcp_state_name(__entry->oldstate),
-		  show_tcp_state_name(__entry->newstate))
-);
-
 TRACE_EVENT(tcp_retransmit_synack,

 	TP_PROTO(const struct sock *sk, const struct request_sock *req),
diff --git a/net/core/sock.c b/net/core/sock.c
index c0b5b2f..717f7f6 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2859,6 +2859,19 @@ int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
 }
 EXPORT_SYMBOL(sock_get_timestampns);

+void sk_state_store(struct sock *sk, int state)
+{
+	trace_sock_set_state(sk, sk->sk_state, state);
+	smp_store_release(&sk->sk_state, state);
+}
+
+void sk_set_state(struct sock *sk, int state)
+{
+	trace_sock_set_state(sk, sk->sk_state, state);
+	 sk->sk_state = state;
+}
+EXPORT_SYMBOL(sk_set_state);
+
 void sock_enable_timestamp(struct sock *sk, int flag)
 {
 	if (!sock_flag(sk, flag)) {
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 4ca46dc..001f7b0 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -783,7 +783,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
 	if (newsk) {
 		struct inet_connection_sock *newicsk = inet_csk(newsk);

-		newsk->sk_state = TCP_SYN_RECV;
+		sk_set_state(newsk, TCP_SYN_RECV);
 		newicsk->icsk_bind_hash = NULL;

 		inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port;
@@ -888,7 +888,7 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
 			return 0;
 	}

-	sk->sk_state = TCP_CLOSE;
+	sk_set_state(sk, TCP_CLOSE);
 	return err;
 }
 EXPORT_SYMBOL_GPL(inet_csk_listen_start);
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index f6f5810..5973693 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -544,7 +544,7 @@ bool inet_ehash_nolisten(struct sock *sk, struct sock *osk)
 		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
 	} else {
 		percpu_counter_inc(sk->sk_prot->orphan_count);
-		sk->sk_state = TCP_CLOSE;
+		sk_set_state(sk, TCP_CLOSE);
 		sock_set_flag(sk, SOCK_DEAD);
 		inet_csk_destroy_sock(sk);
 	}
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c470fec..df6da92 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -283,8 +283,6 @@
 #include <asm/ioctls.h>
 #include <net/busy_poll.h>

-#include <trace/events/tcp.h>
-
 struct percpu_counter tcp_orphan_count;
 EXPORT_SYMBOL_GPL(tcp_orphan_count);

@@ -2040,8 +2038,6 @@ void tcp_set_state(struct sock *sk, int state)
 {
 	int oldstate = sk->sk_state;

-	trace_tcp_set_state(sk, oldstate, state);
-
 	switch (state) {
 	case TCP_ESTABLISHED:
 		if (oldstate != TCP_ESTABLISHED)

^ permalink raw reply related

* Re: [patch net-next v3 00/10] net: sched: allow qdiscs to share filter block instances
From: David Ahern @ 2017-12-15 17:08 UTC (permalink / raw)
  To: Jakub Kicinski, Jiri Pirko
  Cc: netdev, davem, jhs, xiyou.wangcong, mlxsw, andrew, vivien.didelot,
	f.fainelli, michael.chan, ganeshgr, saeedm, matanb, leonro,
	idosch, simon.horman, pieter.jansenvanvuuren, john.hurley,
	alexander.h.duyck, ogerlitz, john.fastabend, daniel
In-Reply-To: <20171213164652.5e5dfa2b@cakuba.netronome.com>

On 12/13/17 5:46 PM, Jakub Kicinski wrote:
> On Wed, 13 Dec 2017 19:42:41 +0100, Jiri Pirko wrote:
>>>>>> I plan to do it as a follow-up patch. But this is how things are done
>>>>>> now and have to continue to work.  
>>>>>
>>>>> Why is that? You are introducing the notion of a shared block with this
>>>>> patch set. What is the legacy "how things are done now" you are
>>>>> referring to?  
>>>>
>>>> Well, the filter add/del should just work no matter if the block behind is
>>>> shared or not.  
>>>
>>> My argument is that modifying a shared block instance via a dev should
>>> not be allowed. Those changes should only be allowed via the shared
>>> block. So if a user puts adds a shared block to the device and then
>>> attempts to add a filter via the device it should not be allowed.  
>>
>> I don't see why. The handle is the qdisc here.
> 
> If you look at it from Linux perspective that makes sense.  For people
> coming from switching world the fact that we use qdiscs as a handle for
> ACL blocks is an implementation detail..  is that the argument here?
> 

In a sense, yes. When configuring the filter, the primary command line
argument is the device. The qdisc is then derived from it and is an
implementation detail.

^ permalink raw reply

* Re: [patch net-next v3 00/10] net: sched: allow qdiscs to share filter block instances
From: Jiri Pirko @ 2017-12-15 17:10 UTC (permalink / raw)
  To: David Ahern
  Cc: Jakub Kicinski, netdev, davem, jhs, xiyou.wangcong, mlxsw, andrew,
	vivien.didelot, f.fainelli, michael.chan, ganeshgr, saeedm,
	matanb, leonro, idosch, simon.horman, pieter.jansenvanvuuren,
	john.hurley, alexander.h.duyck, ogerlitz, john.fastabend, daniel
In-Reply-To: <19ee8268-a93c-8c99-6005-b521a0ef346d@gmail.com>

Fri, Dec 15, 2017 at 06:08:13PM CET, dsahern@gmail.com wrote:
>On 12/13/17 5:46 PM, Jakub Kicinski wrote:
>> On Wed, 13 Dec 2017 19:42:41 +0100, Jiri Pirko wrote:
>>>>>>> I plan to do it as a follow-up patch. But this is how things are done
>>>>>>> now and have to continue to work.  
>>>>>>
>>>>>> Why is that? You are introducing the notion of a shared block with this
>>>>>> patch set. What is the legacy "how things are done now" you are
>>>>>> referring to?  
>>>>>
>>>>> Well, the filter add/del should just work no matter if the block behind is
>>>>> shared or not.  
>>>>
>>>> My argument is that modifying a shared block instance via a dev should
>>>> not be allowed. Those changes should only be allowed via the shared
>>>> block. So if a user puts adds a shared block to the device and then
>>>> attempts to add a filter via the device it should not be allowed.  
>>>
>>> I don't see why. The handle is the qdisc here.
>> 
>> If you look at it from Linux perspective that makes sense.  For people
>> coming from switching world the fact that we use qdiscs as a handle for
>> ACL blocks is an implementation detail..  is that the argument here?
>> 
>
>In a sense, yes. When configuring the filter, the primary command line
>argument is the device. The qdisc is then derived from it and is an
>implementation detail.

It is dev-handle tuple.

^ permalink raw reply

* Re: [patch net] mlxsw: spectrum: Disable MAC learning for ovs port
From: Jiri Pirko @ 2017-12-15 17:11 UTC (permalink / raw)
  To: netdev; +Cc: davem, yuvalm, idosch, mlxsw
In-Reply-To: <20171215132658.6553-1-jiri@resnulli.us>

Fri, Dec 15, 2017 at 02:26:58PM CET, jiri@resnulli.us wrote:
>From: Yuval Mintz <yuvalm@mellanox.com>
>
>Learning is currently enabled for ports which are OVS slaves -
>even though OVS doesn't need this indication.
>Since we're not associating a fid with the port, HW would continuously
>notify driver of learned [& aged] MACs which would be logged as errors.
>
>Fixes: 2b94e58df58c ("mlxsw: spectrum: Allow ports to work under OVS master")
>Signed-off-by: Yuval Mintz <yuvalm@mellanox.com>
>Reviewed-by: Ido Schimmel <idosch@mellanox.com>
>Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Oh, I sent this one twice. Sorry :)

^ permalink raw reply

* Re: [RFC v2 2/6] batman-adv: Rename batman-adv.h to batadv_genl.h
From: Sven Eckelmann @ 2017-12-15 17:18 UTC (permalink / raw)
  To: b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r
  Cc: Willem de Bruijn, Network Development, Eric Dumazet, LKML,
	Jiri Pirko, David S . Miller
In-Reply-To: <CAF=yD-JTfT-iOBG6KMhXv=KggoZ4tEP1fiJMiHMA_d0-wYncLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

On Freitag, 15. Dezember 2017 11:57:55 CET Willem de Bruijn wrote:
> > No, this is also bad because batman_adv.h is MIT license and packet.h is
> > GPL-2. So what other name would you suggest for packet.h? batman_adv_packet.h?
> 
> Sure, that sounds great. Thanks.

Really? Isn't include/uapi/linux/batman_adv_packet.h looking like an accident 
which never should have had happened?

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* [PATCH] net: arc_emac: fix arc_emac_rx() error paths
From: Alexander Kochetkov @ 2017-12-15 17:20 UTC (permalink / raw)
  To: netdev, linux-kernel, David S. Miller
  Cc: Florian Fainelli, Eric Dumazet, Alexander Kochetkov

arc_emac_rx() has some issues found by code review.

In case netdev_alloc_skb_ip_align() or dma_map_single() failure
rx fifo entry will not be returned to EMAC.

In case dma_map_single() failure previously allocated skb became
lost to driver. At the same time address of newly allocated skb
will not be provided to EMAC.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
---
 drivers/net/ethernet/arc/emac_main.c |   53 ++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index b2e0051..0ea57fe 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -212,39 +212,48 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
 			continue;
 		}
 
-		pktlen = info & LEN_MASK;
-		stats->rx_packets++;
-		stats->rx_bytes += pktlen;
-		skb = rx_buff->skb;
-		skb_put(skb, pktlen);
-		skb->dev = ndev;
-		skb->protocol = eth_type_trans(skb, ndev);
-
-		dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr),
-				 dma_unmap_len(rx_buff, len), DMA_FROM_DEVICE);
-
-		/* Prepare the BD for next cycle */
-		rx_buff->skb = netdev_alloc_skb_ip_align(ndev,
-							 EMAC_BUFFER_SIZE);
-		if (unlikely(!rx_buff->skb)) {
+		/* Prepare the BD for next cycle. netif_receive_skb()
+		 * only if new skb was allocated and mapped to avoid holes
+		 * in the RX fifo.
+		 */
+		skb = netdev_alloc_skb_ip_align(ndev, EMAC_BUFFER_SIZE);
+		if (unlikely(!skb)) {
+			if (net_ratelimit())
+				netdev_err(ndev, "cannot allocate skb\n");
+			/* Return ownership to EMAC */
+			rxbd->info = cpu_to_le32(FOR_EMAC | EMAC_BUFFER_SIZE);
 			stats->rx_errors++;
-			/* Because receive_skb is below, increment rx_dropped */
 			stats->rx_dropped++;
 			continue;
 		}
 
-		/* receive_skb only if new skb was allocated to avoid holes */
-		netif_receive_skb(skb);
-
-		addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data,
+		addr = dma_map_single(&ndev->dev, (void *)skb->data,
 				      EMAC_BUFFER_SIZE, DMA_FROM_DEVICE);
 		if (dma_mapping_error(&ndev->dev, addr)) {
 			if (net_ratelimit())
-				netdev_err(ndev, "cannot dma map\n");
-			dev_kfree_skb(rx_buff->skb);
+				netdev_err(ndev, "cannot map dma buffer\n");
+			dev_kfree_skb(skb);
+			/* Return ownership to EMAC */
+			rxbd->info = cpu_to_le32(FOR_EMAC | EMAC_BUFFER_SIZE);
 			stats->rx_errors++;
+			stats->rx_dropped++;
 			continue;
 		}
+
+		/* unmap previosly mapped skb */
+		dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr),
+				 dma_unmap_len(rx_buff, len), DMA_FROM_DEVICE);
+
+		pktlen = info & LEN_MASK;
+		stats->rx_packets++;
+		stats->rx_bytes += pktlen;
+		skb_put(rx_buff->skb, pktlen);
+		rx_buff->skb->dev = ndev;
+		rx_buff->skb->protocol = eth_type_trans(rx_buff->skb, ndev);
+
+		netif_receive_skb(rx_buff->skb);
+
+		rx_buff->skb = skb;
 		dma_unmap_addr_set(rx_buff, addr, addr);
 		dma_unmap_len_set(rx_buff, len, EMAC_BUFFER_SIZE);
 
-- 
1.7.9.5

^ permalink raw reply related

* Re: [PATCH v2 net-next 1/3] net: dsa: mediatek: add VLAN support for MT7530
From: kbuild test robot @ 2017-12-15 17:23 UTC (permalink / raw)
  To: sean.wang
  Cc: kbuild-all, davem, andrew, f.fainelli, vivien.didelot, netdev,
	linux-kernel, linux-mediatek, Sean Wang
In-Reply-To: <72a0a9f2748193bc02fed5e74c343aa5397348b7.1513136754.git.sean.wang@mediatek.com>

Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/add-VLAN-support-to-DSA-MT7530/20171215-214450
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


vim +1324 drivers/net/dsa/mt7530.c

  1305	
  1306	static const struct dsa_switch_ops mt7530_switch_ops = {
  1307		.get_tag_protocol	= mtk_get_tag_protocol,
  1308		.setup			= mt7530_setup,
  1309		.get_strings		= mt7530_get_strings,
  1310		.phy_read		= mt7530_phy_read,
  1311		.phy_write		= mt7530_phy_write,
  1312		.get_ethtool_stats	= mt7530_get_ethtool_stats,
  1313		.get_sset_count		= mt7530_get_sset_count,
  1314		.adjust_link		= mt7530_adjust_link,
  1315		.port_enable		= mt7530_port_enable,
  1316		.port_disable		= mt7530_port_disable,
  1317		.port_stp_state_set	= mt7530_stp_state_set,
  1318		.port_bridge_join	= mt7530_port_bridge_join,
  1319		.port_bridge_leave	= mt7530_port_bridge_leave,
  1320		.port_fdb_add		= mt7530_port_fdb_add,
  1321		.port_fdb_del		= mt7530_port_fdb_del,
  1322		.port_fdb_dump		= mt7530_port_fdb_dump,
  1323		.port_vlan_filtering	= mt7530_port_vlan_filtering,
> 1324		.port_vlan_prepare	= mt7530_port_vlan_prepare,
> 1325		.port_vlan_add		= mt7530_port_vlan_add,
  1326		.port_vlan_del		= mt7530_port_vlan_del,
  1327	};
  1328	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply

* Re: [B.A.T.M.A.N.] [RFC v2 2/6] batman-adv: Rename batman-adv.h to batadv_genl.h
From: Willem de Bruijn @ 2017-12-15 17:23 UTC (permalink / raw)
  To: Sven Eckelmann
  Cc: b.a.t.m.a.n, Eric Dumazet, Network Development, LKML, Jiri Pirko,
	David S . Miller
In-Reply-To: <1591888.FGtWPsc1tq@sven-edge>

On Fri, Dec 15, 2017 at 12:18 PM, Sven Eckelmann
<sven.eckelmann@openmesh.com> wrote:
> On Freitag, 15. Dezember 2017 11:57:55 CET Willem de Bruijn wrote:
>> > No, this is also bad because batman_adv.h is MIT license and packet.h is
>> > GPL-2. So what other name would you suggest for packet.h? batman_adv_packet.h?
>>
>> Sure, that sounds great. Thanks.
>
> Really? Isn't include/uapi/linux/batman_adv_packet.h looking like an accident
> which never should have had happened?

My only point was that renaming and modifying existing uapi files
can break userspace compilation.

As long as the existing files are not changed, I don't have a strong
opinion on naming for new files.

^ permalink raw reply

* Re: [PATCH net-next 0/2] nfp: ethtool flash updates
From: David Miller @ 2017-12-15 17:26 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: netdev, oss-drivers
In-Reply-To: <20171213224502.25407-1-jakub.kicinski@netronome.com>

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Wed, 13 Dec 2017 14:45:00 -0800

> Dirk says:
> 
> This series adds the ability to update the control FW with ethtool.
> 
> It should be noted that the locking scheme here is to release the RTNL
> lock before the flashing operation and to take it again afterwards to
> ensure consistent state from the core code point of view. In this time,
> we take a reference to the device to prevent the device being freed
> while its being flashed.
> 
> This provides protection for the device being flashed while at the same
> time not holding up any networking related functions which would
> otherwise be locked out due to RTNL being held.

Series applied, thanks.

^ permalink raw reply

* Re: [PATCH bpf 0/5] Couple of BPF JIT fixes
From: Alexei Starovoitov @ 2017-12-15 17:28 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: ast, holzheu, naveen.n.rao, davem, netdev
In-Reply-To: <20171214200727.22230-1-daniel@iogearbox.net>

On Thu, Dec 14, 2017 at 09:07:22PM +0100, Daniel Borkmann wrote:
> Two fixes that deal with buggy usage of bpf_helper_changes_pkt_data()
> in the sense that they also reload cached skb data when there's no
> skb context but xdp one, for example. A fix where skb meta data is
> reloaded out of the wrong register on helper call, rest is test cases
> and making sure on verifier side that there's always the guarantee
> that ctx sits in r1. Thanks!

Applied, thanks Daniel!

^ permalink raw reply

* RE: v4.15-rc2 on thinkpad x60: ethernet stopped working
From: Keller, Jacob E @ 2017-12-15 17:29 UTC (permalink / raw)
  To: Gabriel C, Pavel Machek, kernel list
  Cc: Kirsher, Jeffrey T, intel-wired-lan@lists.osuosl.org,
	netdev@vger.kernel.org
In-Reply-To: <d1ae924b-4d8f-a787-4c07-1f2db91482e5@gmail.com>

> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On Behalf Of Gabriel C
> Sent: Sunday, December 10, 2017 4:44 AM
> To: Pavel Machek <pavel@ucw.cz>; kernel list <linux-kernel@vger.kernel.org>
> Cc: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; intel-wired-
> lan@lists.osuosl.org; netdev@vger.kernel.org
> Subject: Re: v4.15-rc2 on thinkpad x60: ethernet stopped working
> 
> On 10.12.2017 09:39, Pavel Machek wrote:
> > Hi!
> 
> Hi,
> 
> > In v4.15-rc2+, network manager can not see my ethernet card, and
> > manual attempts to ifconfig it up did not really help, either.
> >
> > Card is:
> >
> > 02:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet
> > Controller
> >
> > Dmesg says:
> >
> >    dmesg | grep eth
> > [    0.648931] e1000e 0000:02:00.0 eth0: (PCI Express:2.5GT/s:Width
> > x1) 00:16:d3:25:19:04
> > [    0.648934] e1000e 0000:02:00.0 eth0: Intel(R) PRO/1000 Network
> > Connection
> > [    0.649012] e1000e 0000:02:00.0 eth0: MAC: 2, PHY: 2, PBA No:
> > 005302-003
> > [    0.706510] usbcore: registered new interface driver cdc_ether
> > [    6.557022] e1000e 0000:02:00.0 eth1: renamed from eth0
> > [    6.577554] systemd-udevd[2363]: renamed network interface eth0 to
> > eth1
> >
> > Any ideas ?
> 
> Yes , 19110cfbb34d4af0cdfe14cd243f3b09dc95b013 broke it.
> 
> See:
> https://bugzilla.kernel.org/show_bug.cgi?id=198047
> 
> Fix there :
> https://marc.info/?l=linux-kernel&m=151272209903675&w=2
> 
> Regards,
> 
> Gabriel C

Hi,

Digging into this, the problem is complicated. The original bug assumed behavior of the .check_for_link call, which is universally not implemented.

I think the correct fix is to revert 19110cfbb34d ("e1000e: Separate signaling for link check/link up", 2017-10-10) and find a more proper solution.

I don't think any other code which uses check_for_link expects the interface to return in the way this patch attempted.

Thanks,
Jake

^ permalink raw reply

* RE: v4.15-rc2 on thinkpad x60: ethernet stopped working
From: Keller, Jacob E @ 2017-12-15 17:30 UTC (permalink / raw)
  To: Keller, Jacob E, Gabriel C, Pavel Machek, kernel list
  Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org
In-Reply-To: <02874ECE860811409154E81DA85FBB5882B5FB2A@ORSMSX115.amr.corp.intel.com>

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On Behalf Of
> Keller, Jacob E
> Sent: Friday, December 15, 2017 9:29 AM
> To: Gabriel C <nix.or.die@gmail.com>; Pavel Machek <pavel@ucw.cz>; kernel list
> <linux-kernel@vger.kernel.org>
> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org
> Subject: Re: [Intel-wired-lan] v4.15-rc2 on thinkpad x60: ethernet stopped
> working
> 
> > -----Original Message-----
> > From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org]
> > On Behalf Of Gabriel C
> > Sent: Sunday, December 10, 2017 4:44 AM
> > To: Pavel Machek <pavel@ucw.cz>; kernel list <linux-kernel@vger.kernel.org>
> > Cc: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; intel-wired-
> > lan@lists.osuosl.org; netdev@vger.kernel.org
> > Subject: Re: v4.15-rc2 on thinkpad x60: ethernet stopped working
> >
> > On 10.12.2017 09:39, Pavel Machek wrote:
> > > Hi!
> >
> > Hi,
> >
> > > In v4.15-rc2+, network manager can not see my ethernet card, and
> > > manual attempts to ifconfig it up did not really help, either.
> > >
> > > Card is:
> > >
> > > 02:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet
> > > Controller
> > >
> > > Dmesg says:
> > >
> > >    dmesg | grep eth
> > > [    0.648931] e1000e 0000:02:00.0 eth0: (PCI Express:2.5GT/s:Width
> > > x1) 00:16:d3:25:19:04
> > > [    0.648934] e1000e 0000:02:00.0 eth0: Intel(R) PRO/1000 Network
> > > Connection
> > > [    0.649012] e1000e 0000:02:00.0 eth0: MAC: 2, PHY: 2, PBA No:
> > > 005302-003
> > > [    0.706510] usbcore: registered new interface driver cdc_ether
> > > [    6.557022] e1000e 0000:02:00.0 eth1: renamed from eth0
> > > [    6.577554] systemd-udevd[2363]: renamed network interface eth0 to
> > > eth1
> > >
> > > Any ideas ?
> >
> > Yes , 19110cfbb34d4af0cdfe14cd243f3b09dc95b013 broke it.
> >
> > See:
> > https://bugzilla.kernel.org/show_bug.cgi?id=198047
> >
> > Fix there :
> > https://marc.info/?l=linux-kernel&m=151272209903675&w=2
> >
> > Regards,
> >
> > Gabriel C
> 
> Hi,
> 
> Digging into this, the problem is complicated. The original bug assumed behavior
> of the .check_for_link call, which is universally not implemented.
> 
> I think the correct fix is to revert 19110cfbb34d ("e1000e: Separate signaling for
> link check/link up", 2017-10-10) and find a more proper solution.
> 
> I don't think any other code which uses check_for_link expects the interface to
> return in the way this patch attempted.
> 
> Thanks,
> Jake
> 

Alternatively, we can go a step farther and make sure every implementation of .check_for_link follows the modified interface.

Thanks,
Jake

^ permalink raw reply

* Re: [PATCH net-next 0/4] ERSPAN version 2 (type III) support
From: David Miller @ 2017-12-15 17:34 UTC (permalink / raw)
  To: u9012063; +Cc: netdev
In-Reply-To: <1513211938-8749-1-git-send-email-u9012063@gmail.com>

From: William Tu <u9012063@gmail.com>
Date: Wed, 13 Dec 2017 16:38:54 -0800

> ERSPAN has two versions, v1 (type II) and v2 (type III).  This patch
> series add support for erspan v2 based on existing erspan v1
> implementation.
 ...

Series applied, thanks William.

^ permalink raw reply

* Re: [PATCH v2 net-next 1/3] net: dsa: mediatek: add VLAN support for MT7530
From: kbuild test robot @ 2017-12-15 17:37 UTC (permalink / raw)
  To: sean.wang
  Cc: kbuild-all, davem, andrew, f.fainelli, vivien.didelot, netdev,
	linux-kernel, linux-mediatek, Sean Wang
In-Reply-To: <72a0a9f2748193bc02fed5e74c343aa5397348b7.1513136754.git.sean.wang@mediatek.com>

[-- Attachment #1: Type: text/plain, Size: 13966 bytes --]

Hi Sean,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/add-VLAN-support-to-DSA-MT7530/20171215-214450
config: x86_64-randconfig-g0-12151942 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/net/dsa/mt7530.c: In function 'mt7530_port_vlan_add':
   drivers/net/dsa/mt7530.c:1131:6: warning: unused variable 'ret' [-Wunused-variable]
     int ret;
         ^
   drivers/net/dsa/mt7530.c: At top level:
>> drivers/net/dsa/mt7530.c:1324:2: warning: initialization from incompatible pointer type
     .port_vlan_prepare = mt7530_port_vlan_prepare,
     ^
   drivers/net/dsa/mt7530.c:1324:2: warning: (near initialization for 'mt7530_switch_ops.port_vlan_prepare')
   drivers/net/dsa/mt7530.c:1325:2: warning: initialization from incompatible pointer type
     .port_vlan_add  = mt7530_port_vlan_add,
     ^
   drivers/net/dsa/mt7530.c:1325:2: warning: (near initialization for 'mt7530_switch_ops.port_vlan_add')
   Cyclomatic Complexity 3 include/linux/string.h:strncpy
   Cyclomatic Complexity 1 include/linux/err.h:ERR_PTR
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
   Cyclomatic Complexity 3 include/linux/ktime.h:ktime_compare
   Cyclomatic Complexity 1 include/linux/ktime.h:ktime_add_us
   Cyclomatic Complexity 1 include/linux/device.h:devm_kzalloc
   Cyclomatic Complexity 1 include/linux/device.h:dev_get_drvdata
   Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata
   Cyclomatic Complexity 5 include/linux/mii.h:mii_resolve_flowctrl_fdx
   Cyclomatic Complexity 1 include/linux/of.h:of_property_read_bool
   Cyclomatic Complexity 1 include/linux/phy.h:phy_is_pseudo_fixed_link
   Cyclomatic Complexity 1 include/linux/reset.h:reset_control_assert
   Cyclomatic Complexity 1 include/linux/reset.h:reset_control_deassert
   Cyclomatic Complexity 2 include/linux/reset.h:__devm_reset_control_get
   Cyclomatic Complexity 2 include/linux/reset.h:devm_reset_control_get_exclusive
   Cyclomatic Complexity 1 include/linux/reset.h:devm_reset_control_get
   Cyclomatic Complexity 1 include/net/dsa.h:dsa_to_port
   Cyclomatic Complexity 1 include/net/dsa.h:dsa_is_cpu_port
   Cyclomatic Complexity 1 include/net/dsa.h:dsa_is_user_port
   Cyclomatic Complexity 3 include/net/dsa.h:dsa_user_ports
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.h:mt7530_hw_vlan_entry_init
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.h:INIT_MT7530_DUMMY_POLL
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_get_strings
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_get_sset_count
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_port_vlan_prepare
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mdio_module_init
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_mii_read
   Cyclomatic Complexity 4 drivers/net/dsa/mt7530.c:mt7530_mii_write
   Cyclomatic Complexity 4 drivers/net/dsa/mt7530.c:core_read_mmd_indirect
   Cyclomatic Complexity 5 drivers/net/dsa/mt7530.c:core_write_mmd_indirect
   Cyclomatic Complexity 3 drivers/net/dsa/mt7530.c:mt7530_remove
   Cyclomatic Complexity 9 drivers/net/dsa/mt7530.c:mt7530_probe
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:_mt7530_read
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_read
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_fdb_read
   Cyclomatic Complexity 3 drivers/net/dsa/mt7530.c:mt7530_get_ethtool_stats
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_write
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_fdb_write
   Cyclomatic Complexity 3 drivers/net/dsa/mt7530.c:mt7530_hw_vlan_del
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_mib_reset
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_rmw
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_hw_vlan_add
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_port_set_vlan_aware
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_port_vlan_filtering
   Cyclomatic Complexity 5 drivers/net/dsa/mt7530.c:mt7530_stp_state_set
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_clear
   Cyclomatic Complexity 5 drivers/net/dsa/mt7530.c:mt7530_port_set_vlan_unaware
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_set
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7530_port_set_status
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_cpu_port_enable
   Cyclomatic Complexity 8 drivers/net/dsa/mt7530.c:mt7530_port_bridge_leave
   Cyclomatic Complexity 7 drivers/net/dsa/mt7530.c:mt7530_port_bridge_join
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_port_disable
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_port_enable
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:core_rmw
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:core_clear
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:core_set
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:core_write
   Cyclomatic Complexity 11 drivers/net/dsa/mt7530.c:mt7530_fdb_cmd
   Cyclomatic Complexity 8 drivers/net/dsa/mt7530.c:mt7530_port_fdb_dump
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_port_fdb_del
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_port_fdb_add
   Cyclomatic Complexity 9 drivers/net/dsa/mt7530.c:mt7530_vlan_cmd
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_hw_vlan_update
   Cyclomatic Complexity 4 drivers/net/dsa/mt7530.c:mt7530_port_vlan_del
   Cyclomatic Complexity 4 drivers/net/dsa/mt7530.c:mt7530_port_vlan_add
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7623_trgmii_read
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7623_trgmii_write
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7623_trgmii_rmw
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7623_trgmii_set
   Cyclomatic Complexity 7 drivers/net/dsa/mt7530.c:mt7530_pad_clk_setup
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7623_trgmii_clear
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mt7623_pad_clk_setup
   Cyclomatic Complexity 12 drivers/net/dsa/mt7530.c:mt7530_adjust_link
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_phy_write
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mt7530_phy_read
   Cyclomatic Complexity 16 drivers/net/dsa/mt7530.c:mt7530_setup
   Cyclomatic Complexity 2 drivers/net/dsa/mt7530.c:mtk_get_tag_protocol
   Cyclomatic Complexity 1 drivers/net/dsa/mt7530.c:mdio_module_exit

vim +1324 drivers/net/dsa/mt7530.c

  1121	
  1122	static void
  1123	mt7530_port_vlan_add(struct dsa_switch *ds, int port,
  1124			     const struct switchdev_obj_port_vlan *vlan,
  1125			     struct switchdev_trans *trans)
  1126	{
  1127		bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
  1128		bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
  1129		struct mt7530_hw_vlan_entry new_entry;
  1130		struct mt7530_priv *priv = ds->priv;
> 1131		int ret;
  1132		u16 vid;
  1133	
  1134		/* The port is kept as VLAN-unaware if bridge with vlan_filtering not
  1135		 * being set.
  1136		 */
  1137		if (!priv->ports[port].vlan_filtering)
  1138			return;
  1139	
  1140		mutex_lock(&priv->reg_mutex);
  1141	
  1142		for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
  1143			mt7530_hw_vlan_entry_init(&new_entry, port, untagged);
  1144			mt7530_hw_vlan_update(priv, vid, &new_entry,
  1145					      mt7530_hw_vlan_add);
  1146		}
  1147	
  1148		if (pvid) {
  1149			mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK,
  1150				   G0_PORT_VID(vlan->vid_end));
  1151			priv->ports[port].pvid = vlan->vid_end;
  1152		}
  1153	
  1154		mutex_unlock(&priv->reg_mutex);
  1155	}
  1156	
  1157	static int
  1158	mt7530_port_vlan_del(struct dsa_switch *ds, int port,
  1159			     const struct switchdev_obj_port_vlan *vlan)
  1160	{
  1161		struct mt7530_hw_vlan_entry target_entry;
  1162		struct mt7530_priv *priv = ds->priv;
  1163		u16 vid, pvid;
  1164	
  1165		/* The port is kept as VLAN-unaware if bridge with vlan_filtering not
  1166		 * being set.
  1167		 */
  1168		if (!priv->ports[port].vlan_filtering)
  1169			return 0;
  1170	
  1171		mutex_lock(&priv->reg_mutex);
  1172	
  1173		pvid = priv->ports[port].pvid;
  1174		for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
  1175			mt7530_hw_vlan_entry_init(&target_entry, port, 0);
  1176			mt7530_hw_vlan_update(priv, vid, &target_entry,
  1177					      mt7530_hw_vlan_del);
  1178	
  1179			/* PVID is being restored to the default whenever the PVID port
  1180			 * is being removed from the VLAN.
  1181			 */
  1182			if (pvid == vid)
  1183				pvid = G0_PORT_VID_DEF;
  1184		}
  1185	
  1186		mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, pvid);
  1187		priv->ports[port].pvid = pvid;
  1188	
  1189		mutex_unlock(&priv->reg_mutex);
  1190	
  1191		return 0;
  1192	}
  1193	
  1194	static enum dsa_tag_protocol
  1195	mtk_get_tag_protocol(struct dsa_switch *ds, int port)
  1196	{
  1197		struct mt7530_priv *priv = ds->priv;
  1198	
  1199		if (port != MT7530_CPU_PORT) {
  1200			dev_warn(priv->dev,
  1201				 "port not matched with tagging CPU port\n");
  1202			return DSA_TAG_PROTO_NONE;
  1203		} else {
  1204			return DSA_TAG_PROTO_MTK;
  1205		}
  1206	}
  1207	
  1208	static int
  1209	mt7530_setup(struct dsa_switch *ds)
  1210	{
  1211		struct mt7530_priv *priv = ds->priv;
  1212		int ret, i;
  1213		u32 id, val;
  1214		struct device_node *dn;
  1215		struct mt7530_dummy_poll p;
  1216	
  1217		/* The parent node of master netdev which holds the common system
  1218		 * controller also is the container for two GMACs nodes representing
  1219		 * as two netdev instances.
  1220		 */
  1221		dn = ds->ports[MT7530_CPU_PORT].master->dev.of_node->parent;
  1222		priv->ethernet = syscon_node_to_regmap(dn);
  1223		if (IS_ERR(priv->ethernet))
  1224			return PTR_ERR(priv->ethernet);
  1225	
  1226		regulator_set_voltage(priv->core_pwr, 1000000, 1000000);
  1227		ret = regulator_enable(priv->core_pwr);
  1228		if (ret < 0) {
  1229			dev_err(priv->dev,
  1230				"Failed to enable core power: %d\n", ret);
  1231			return ret;
  1232		}
  1233	
  1234		regulator_set_voltage(priv->io_pwr, 3300000, 3300000);
  1235		ret = regulator_enable(priv->io_pwr);
  1236		if (ret < 0) {
  1237			dev_err(priv->dev, "Failed to enable io pwr: %d\n",
  1238				ret);
  1239			return ret;
  1240		}
  1241	
  1242		/* Reset whole chip through gpio pin or memory-mapped registers for
  1243		 * different type of hardware
  1244		 */
  1245		if (priv->mcm) {
  1246			reset_control_assert(priv->rstc);
  1247			usleep_range(1000, 1100);
  1248			reset_control_deassert(priv->rstc);
  1249		} else {
  1250			gpiod_set_value_cansleep(priv->reset, 0);
  1251			usleep_range(1000, 1100);
  1252			gpiod_set_value_cansleep(priv->reset, 1);
  1253		}
  1254	
  1255		/* Waiting for MT7530 got to stable */
  1256		INIT_MT7530_DUMMY_POLL(&p, priv, MT7530_HWTRAP);
  1257		ret = readx_poll_timeout(_mt7530_read, &p, val, val != 0,
  1258					 20, 1000000);
  1259		if (ret < 0) {
  1260			dev_err(priv->dev, "reset timeout\n");
  1261			return ret;
  1262		}
  1263	
  1264		id = mt7530_read(priv, MT7530_CREV);
  1265		id >>= CHIP_NAME_SHIFT;
  1266		if (id != MT7530_ID) {
  1267			dev_err(priv->dev, "chip %x can't be supported\n", id);
  1268			return -ENODEV;
  1269		}
  1270	
  1271		/* Reset the switch through internal reset */
  1272		mt7530_write(priv, MT7530_SYS_CTRL,
  1273			     SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
  1274			     SYS_CTRL_REG_RST);
  1275	
  1276		/* Enable Port 6 only; P5 as GMAC5 which currently is not supported */
  1277		val = mt7530_read(priv, MT7530_MHWTRAP);
  1278		val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
  1279		val |= MHWTRAP_MANUAL;
  1280		mt7530_write(priv, MT7530_MHWTRAP, val);
  1281	
  1282		/* Enable and reset MIB counters */
  1283		mt7530_mib_reset(ds);
  1284	
  1285		mt7530_clear(priv, MT7530_MFC, UNU_FFP_MASK);
  1286	
  1287		for (i = 0; i < MT7530_NUM_PORTS; i++) {
  1288			/* Disable forwarding by default on all ports */
  1289			mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
  1290				   PCR_MATRIX_CLR);
  1291	
  1292			if (dsa_is_cpu_port(ds, i))
  1293				mt7530_cpu_port_enable(priv, i);
  1294			else
  1295				mt7530_port_disable(ds, i, NULL);
  1296		}
  1297	
  1298		/* Flush the FDB table */
  1299		ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, 0);
  1300		if (ret < 0)
  1301			return ret;
  1302	
  1303		return 0;
  1304	}
  1305	
  1306	static const struct dsa_switch_ops mt7530_switch_ops = {
  1307		.get_tag_protocol	= mtk_get_tag_protocol,
  1308		.setup			= mt7530_setup,
  1309		.get_strings		= mt7530_get_strings,
  1310		.phy_read		= mt7530_phy_read,
  1311		.phy_write		= mt7530_phy_write,
  1312		.get_ethtool_stats	= mt7530_get_ethtool_stats,
  1313		.get_sset_count		= mt7530_get_sset_count,
  1314		.adjust_link		= mt7530_adjust_link,
  1315		.port_enable		= mt7530_port_enable,
  1316		.port_disable		= mt7530_port_disable,
  1317		.port_stp_state_set	= mt7530_stp_state_set,
  1318		.port_bridge_join	= mt7530_port_bridge_join,
  1319		.port_bridge_leave	= mt7530_port_bridge_leave,
  1320		.port_fdb_add		= mt7530_port_fdb_add,
  1321		.port_fdb_del		= mt7530_port_fdb_del,
  1322		.port_fdb_dump		= mt7530_port_fdb_dump,
  1323		.port_vlan_filtering	= mt7530_port_vlan_filtering,
> 1324		.port_vlan_prepare	= mt7530_port_vlan_prepare,
  1325		.port_vlan_add		= mt7530_port_vlan_add,
  1326		.port_vlan_del		= mt7530_port_vlan_del,
  1327	};
  1328	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31760 bytes --]

^ permalink raw reply

* Re: [PATCH v2 net-next 0/4] replace tcp_set_state tracepoint with
From: David Miller @ 2017-12-15 17:43 UTC (permalink / raw)
  To: laoar.shao
  Cc: songliubraving, marcelo.leitner, rostedt, bgregg, netdev,
	linux-kernel
In-Reply-To: <1513357314-8402-1-git-send-email-laoar.shao@gmail.com>


Your Subject line here is incomplete, "replace tcp_set_state
tracepoint with" what?

^ permalink raw reply

* Re: [PATCH net v3 0/9] net: aquantia: Atlantic driver 12/2017 updates
From: David Miller @ 2017-12-15 17:47 UTC (permalink / raw)
  To: igor.russkikh
  Cc: netdev, darcari, pavel.belous, Nadezhda.Krupnina, simon.edelhaus
In-Reply-To: <cover.1513242414.git.igor.russkikh@aquantia.com>

From: Igor Russkikh <igor.russkikh@aquantia.com>
Date: Thu, 14 Dec 2017 12:34:39 +0300

> The patchset contains important hardware fix for machines with large MRRS
> and couple of improvement in stats and capabilities reporting
> 
> patch v3:
>  - Fixed patch #7 after Andrew's finding. NIC level stats actually
>    have to be cleaned only on hw struct creation (and this is done
>    in kzalloc). On each hwinit we only have to reset link state
>    to make sure hw stats update will not increment nic stats during init.
> 
> patch v2:
>  - split into more detailed commits
> 
> Comment from David on wrong defines case will be submitted separately later

Series applied, but don't make me regret letting you fix this define
issue "later".

^ permalink raw reply

* Re: [PATCH net-next 0/2] nfp: fix rtsym and XDP register handling in debug dump
From: David Miller @ 2017-12-15 17:49 UTC (permalink / raw)
  To: simon.horman; +Cc: jakub.kicinski, netdev, oss-drivers, carl.heymann
In-Reply-To: <20171215141828.3m7f66ziv4fn33c2@netronome.com>

From: Simon Horman <simon.horman@netronome.com>
Date: Fri, 15 Dec 2017 15:18:29 +0100

> On Thu, Dec 14, 2017 at 10:50:24AM +0100, Simon Horman wrote:
>> Hi,
>> 
>> this series resolves two problems in the recently added debug dump facility.
>> 
>> * Correctly handle reading absolute rtysms
>> * Correctly handle special-case PB register reads
>> 
>> These fixes are for code only present in net-next.
> 
> Hi Dave,
> 
> It seems that I made a thinko in the title of the cover letter.  s/XDP/XPB/
> These changes do not relate to XDP.

Series applied with this fixed, thanks.

^ permalink raw reply

* Re: [PATCH v2 net-next 0/4] replace tcp_set_state tracepoint with
From: Yafang Shao @ 2017-12-15 17:50 UTC (permalink / raw)
  To: David Miller
  Cc: Song Liu, Marcelo Ricardo Leitner, Steven Rostedt, Brendan Gregg,
	netdev, LKML
In-Reply-To: <20171215.124322.1720625792535447389.davem@davemloft.net>

2017-12-16 1:43 GMT+08:00 David Miller <davem@davemloft.net>:
>
> Your Subject line here is incomplete, "replace tcp_set_state
> tracepoint with" what?

Oh Sorry.

The subject should be

"replace tcp_set_state tracepoint with sock_set_state tracepoint"

Thanks
Yafang

^ permalink raw reply

* Re: [PATCH v2 net-next 0/4] replace tcp_set_state tracepoint with
From: David Miller @ 2017-12-15 17:51 UTC (permalink / raw)
  To: laoar.shao
  Cc: songliubraving, marcelo.leitner, rostedt, bgregg, netdev,
	linux-kernel
In-Reply-To: <CALOAHbB_T4A4mK6RW0Rw3KTjoDTwj-KZ048kS-qPUeFShBWU_g@mail.gmail.com>

From: Yafang Shao <laoar.shao@gmail.com>
Date: Sat, 16 Dec 2017 01:50:12 +0800

> 2017-12-16 1:43 GMT+08:00 David Miller <davem@davemloft.net>:
>>
>> Your Subject line here is incomplete, "replace tcp_set_state
>> tracepoint with" what?
> 
> Oh Sorry.
> 
> The subject should be
> 
> "replace tcp_set_state tracepoint with sock_set_state tracepoint"

Please resubmit with it fixed.

^ permalink raw reply

* [PATCH v2 net-next 1/4] tcp: Export to userspace the TCP state names for the trace events
From: Yafang Shao @ 2017-12-15 17:56 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao
In-Reply-To: <1513360611-11392-1-git-send-email-laoar.shao@gmail.com>

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The TCP trace events (specifically tcp_set_state), maps emums to symbol
names via __print_symbolic(). But this only works for reading trace events
from the tracefs trace files. If perf or trace-cmd were to record these
events, the event format file does not convert the enum names into numbers,
and you get something like:

__print_symbolic(REC->oldstate,
    { TCP_ESTABLISHED, "TCP_ESTABLISHED" },
    { TCP_SYN_SENT, "TCP_SYN_SENT" },
    { TCP_SYN_RECV, "TCP_SYN_RECV" },
    { TCP_FIN_WAIT1, "TCP_FIN_WAIT1" },
    { TCP_FIN_WAIT2, "TCP_FIN_WAIT2" },
    { TCP_TIME_WAIT, "TCP_TIME_WAIT" },
    { TCP_CLOSE, "TCP_CLOSE" },
    { TCP_CLOSE_WAIT, "TCP_CLOSE_WAIT" },
    { TCP_LAST_ACK, "TCP_LAST_ACK" },
    { TCP_LISTEN, "TCP_LISTEN" },
    { TCP_CLOSING, "TCP_CLOSING" },
    { TCP_NEW_SYN_RECV, "TCP_NEW_SYN_RECV" })

Where trace-cmd and perf do not know the values of those enums.

Use the TRACE_DEFINE_ENUM() macros that will have the trace events convert
the enum strings into their values at system boot. This will allow perf and
trace-cmd to see actual numbers and not enums:

__print_symbolic(REC->oldstate,
    { 1, "TCP_ESTABLISHED" },
    { 2, "TCP_SYN_SENT" },
    { 3, "TCP_SYN_RECV" },
    { 4, "TCP_FIN_WAIT1" },
    { 5, "TCP_FIN_WAIT2" },
    { 6, "TCP_TIME_WAIT" },
    { 7, "TCP_CLOSE" },
    { 8, "TCP_CLOSE_WAIT" },
    { 9, "TCP_LAST_ACK" },
    { 10, "TCP_LISTEN" },
    { 11, "TCP_CLOSING" },
    { 12, "TCP_NEW_SYN_RECV" })

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 include/trace/events/tcp.h | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 07cccca..40240ac 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -9,21 +9,36 @@
 #include <linux/tracepoint.h>
 #include <net/ipv6.h>

+#define tcp_state_names			\
+		EM(TCP_ESTABLISHED)		\
+		EM(TCP_SYN_SENT)		\
+		EM(TCP_SYN_RECV)		\
+		EM(TCP_FIN_WAIT1)		\
+		EM(TCP_FIN_WAIT2)		\
+		EM(TCP_TIME_WAIT)		\
+		EM(TCP_CLOSE)			\
+		EM(TCP_CLOSE_WAIT)		\
+		EM(TCP_LAST_ACK)		\
+		EM(TCP_LISTEN)			\
+		EM(TCP_CLOSING)			\
+		EMe(TCP_NEW_SYN_RECV)	\
+
+/* enums need to be exported to user space */
+#undef EM
+#undef EMe
+#define EM(a)         TRACE_DEFINE_ENUM(a);
+#define EMe(a)        TRACE_DEFINE_ENUM(a);
+
+tcp_state_names
+
+#undef EM
+#undef EMe
+#define EM(a)         tcp_state_name(a),
+#define EMe(a)        tcp_state_name(a)
+
 #define tcp_state_name(state)	{ state, #state }
 #define show_tcp_state_name(val)			\
-	__print_symbolic(val,				\
-		tcp_state_name(TCP_ESTABLISHED),	\
-		tcp_state_name(TCP_SYN_SENT),		\
-		tcp_state_name(TCP_SYN_RECV),		\
-		tcp_state_name(TCP_FIN_WAIT1),		\
-		tcp_state_name(TCP_FIN_WAIT2),		\
-		tcp_state_name(TCP_TIME_WAIT),		\
-		tcp_state_name(TCP_CLOSE),		\
-		tcp_state_name(TCP_CLOSE_WAIT),		\
-		tcp_state_name(TCP_LAST_ACK),		\
-		tcp_state_name(TCP_LISTEN),		\
-		tcp_state_name(TCP_CLOSING),		\
-		tcp_state_name(TCP_NEW_SYN_RECV))
+	__print_symbolic(val, tcp_state_names)

 /*
  * tcp event with arguments sk and skb
--
1.8.3.1

^ permalink raw reply related

* [PATCH v2 net-next 2/4] net: tracepoint: replace tcp_set_state tracepoint with sock_set_state tracepoint
From: Yafang Shao @ 2017-12-15 17:56 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao
In-Reply-To: <1513360611-11392-1-git-send-email-laoar.shao@gmail.com>

As sk_state is a common field for struct sock, so the state
transition should not be a TCP specific feature.
So I rename tcp_set_state tracepoint to sock_set_state tracepoint with
some minor changes and move it into file trace/events/sock.h.

Two helpers are introduced to trace sk_state transition
    - void sk_state_store(struct sock *sk, int state);
    - void sk_set_state(struct sock *sk, int state);
As trace header should not be included in other header files,
so they are defined in sock.c.

The protocol such as SCTP maybe compiled as a ko, hence export
sk_set_state().

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 include/net/sock.h              |  15 +-----
 include/trace/events/sock.h     | 106 ++++++++++++++++++++++++++++++++++++++++
 include/trace/events/tcp.h      |  91 ----------------------------------
 net/core/sock.c                 |  13 +++++
 net/ipv4/inet_connection_sock.c |   4 +-
 net/ipv4/inet_hashtables.c      |   2 +-
 net/ipv4/tcp.c                  |   4 --
 7 files changed, 124 insertions(+), 111 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 9a90472..988ce82 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2344,19 +2344,8 @@ static inline int sk_state_load(const struct sock *sk)
 	return smp_load_acquire(&sk->sk_state);
 }

-/**
- * sk_state_store - update sk->sk_state
- * @sk: socket pointer
- * @newstate: new state
- *
- * Paired with sk_state_load(). Should be used in contexts where
- * state change might impact lockless readers.
- */
-static inline void sk_state_store(struct sock *sk, int newstate)
-{
-	smp_store_release(&sk->sk_state, newstate);
-}
-
+void sk_state_store(struct sock *sk, int newstate);
+void sk_set_state(struct sock *sk, int state);
 void sock_enable_timestamp(struct sock *sk, int flag);
 int sock_get_timestamp(struct sock *, struct timeval __user *);
 int sock_get_timestampns(struct sock *, struct timespec __user *);
diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h
index ec4dade..61977e5 100644
--- a/include/trace/events/sock.h
+++ b/include/trace/events/sock.h
@@ -6,7 +6,49 @@
 #define _TRACE_SOCK_H

 #include <net/sock.h>
+#include <net/ipv6.h>
 #include <linux/tracepoint.h>
+#include <linux/ipv6.h>
+#include <linux/tcp.h>
+
+#define inet_protocol_names		\
+		EM(IPPROTO_TCP)			\
+		EM(IPPROTO_DCCP)		\
+		EMe(IPPROTO_SCTP)
+
+#define tcp_state_names			\
+		EM(TCP_ESTABLISHED)		\
+		EM(TCP_SYN_SENT)		\
+		EM(TCP_SYN_RECV)		\
+		EM(TCP_FIN_WAIT1)	   \
+		EM(TCP_FIN_WAIT2)	   \
+		EM(TCP_TIME_WAIT)	   \
+		EM(TCP_CLOSE)		   \
+		EM(TCP_CLOSE_WAIT)	  \
+		EM(TCP_LAST_ACK)		\
+		EM(TCP_LISTEN)		  \
+		EM(TCP_CLOSING)		 \
+		EMe(TCP_NEW_SYN_RECV)
+
+/* enums need to be exported to user space */
+#undef EM
+#undef EMe
+#define EM(a)       TRACE_DEFINE_ENUM(a);
+#define EMe(a)      TRACE_DEFINE_ENUM(a);
+
+inet_protocol_names
+tcp_state_names
+
+#undef EM
+#undef EMe
+#define EM(a)       { a, #a },
+#define EMe(a)      { a, #a }
+
+#define show_inet_protocol_name(val)	\
+	__print_symbolic(val, inet_protocol_names)
+
+#define show_tcp_state_name(val)		\
+	__print_symbolic(val, tcp_state_names)

 TRACE_EVENT(sock_rcvqueue_full,

@@ -63,6 +105,70 @@
 		__entry->rmem_alloc)
 );

+TRACE_EVENT(sock_set_state,
+
+	TP_PROTO(const struct sock *sk, const int oldstate, const int newstate),
+
+	TP_ARGS(sk, oldstate, newstate),
+
+	TP_STRUCT__entry(
+		__field(const void *, skaddr)
+		__field(int, oldstate)
+		__field(int, newstate)
+		__field(__u16, sport)
+		__field(__u16, dport)
+		__field(__u8, protocol)
+		__array(__u8, saddr, 4)
+		__array(__u8, daddr, 4)
+		__array(__u8, saddr_v6, 16)
+		__array(__u8, daddr_v6, 16)
+	),
+
+	TP_fast_assign(
+		struct inet_sock *inet = inet_sk(sk);
+		struct in6_addr *pin6;
+		__be32 *p32;
+
+		__entry->skaddr = sk;
+		__entry->oldstate = oldstate;
+		__entry->newstate = newstate;
+
+		__entry->protocol = sk->sk_protocol;
+		__entry->sport = ntohs(inet->inet_sport);
+		__entry->dport = ntohs(inet->inet_dport);
+
+		p32 = (__be32 *) __entry->saddr;
+		*p32 = inet->inet_saddr;
+
+		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_printk("protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4"
+			"saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
+			show_inet_protocol_name(__entry->protocol),
+			__entry->sport, __entry->dport,
+			__entry->saddr, __entry->daddr,
+			__entry->saddr_v6, __entry->daddr_v6,
+			show_tcp_state_name(__entry->oldstate),
+			show_tcp_state_name(__entry->newstate))
+);
+
 #endif /* _TRACE_SOCK_H */

 /* This part must be outside protection */
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 40240ac..7399399 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -9,37 +9,6 @@
 #include <linux/tracepoint.h>
 #include <net/ipv6.h>

-#define tcp_state_names			\
-		EM(TCP_ESTABLISHED)		\
-		EM(TCP_SYN_SENT)		\
-		EM(TCP_SYN_RECV)		\
-		EM(TCP_FIN_WAIT1)		\
-		EM(TCP_FIN_WAIT2)		\
-		EM(TCP_TIME_WAIT)		\
-		EM(TCP_CLOSE)			\
-		EM(TCP_CLOSE_WAIT)		\
-		EM(TCP_LAST_ACK)		\
-		EM(TCP_LISTEN)			\
-		EM(TCP_CLOSING)			\
-		EMe(TCP_NEW_SYN_RECV)	\
-
-/* enums need to be exported to user space */
-#undef EM
-#undef EMe
-#define EM(a)         TRACE_DEFINE_ENUM(a);
-#define EMe(a)        TRACE_DEFINE_ENUM(a);
-
-tcp_state_names
-
-#undef EM
-#undef EMe
-#define EM(a)         tcp_state_name(a),
-#define EMe(a)        tcp_state_name(a)
-
-#define tcp_state_name(state)	{ state, #state }
-#define show_tcp_state_name(val)			\
-	__print_symbolic(val, tcp_state_names)
-
 /*
  * tcp event with arguments sk and skb
  *
@@ -192,66 +161,6 @@
 	TP_ARGS(sk)
 );

-TRACE_EVENT(tcp_set_state,
-
-	TP_PROTO(const struct sock *sk, const int oldstate, const int newstate),
-
-	TP_ARGS(sk, oldstate, newstate),
-
-	TP_STRUCT__entry(
-		__field(const void *, skaddr)
-		__field(int, oldstate)
-		__field(int, newstate)
-		__field(__u16, sport)
-		__field(__u16, dport)
-		__array(__u8, saddr, 4)
-		__array(__u8, daddr, 4)
-		__array(__u8, saddr_v6, 16)
-		__array(__u8, daddr_v6, 16)
-	),
-
-	TP_fast_assign(
-		struct inet_sock *inet = inet_sk(sk);
-		struct in6_addr *pin6;
-		__be32 *p32;
-
-		__entry->skaddr = sk;
-		__entry->oldstate = oldstate;
-		__entry->newstate = newstate;
-
-		__entry->sport = ntohs(inet->inet_sport);
-		__entry->dport = ntohs(inet->inet_dport);
-
-		p32 = (__be32 *) __entry->saddr;
-		*p32 = inet->inet_saddr;
-
-		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_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
-		  __entry->sport, __entry->dport,
-		  __entry->saddr, __entry->daddr,
-		  __entry->saddr_v6, __entry->daddr_v6,
-		  show_tcp_state_name(__entry->oldstate),
-		  show_tcp_state_name(__entry->newstate))
-);
-
 TRACE_EVENT(tcp_retransmit_synack,

 	TP_PROTO(const struct sock *sk, const struct request_sock *req),
diff --git a/net/core/sock.c b/net/core/sock.c
index c0b5b2f..717f7f6 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2859,6 +2859,19 @@ int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
 }
 EXPORT_SYMBOL(sock_get_timestampns);

+void sk_state_store(struct sock *sk, int state)
+{
+	trace_sock_set_state(sk, sk->sk_state, state);
+	smp_store_release(&sk->sk_state, state);
+}
+
+void sk_set_state(struct sock *sk, int state)
+{
+	trace_sock_set_state(sk, sk->sk_state, state);
+	 sk->sk_state = state;
+}
+EXPORT_SYMBOL(sk_set_state);
+
 void sock_enable_timestamp(struct sock *sk, int flag)
 {
 	if (!sock_flag(sk, flag)) {
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 4ca46dc..001f7b0 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -783,7 +783,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
 	if (newsk) {
 		struct inet_connection_sock *newicsk = inet_csk(newsk);

-		newsk->sk_state = TCP_SYN_RECV;
+		sk_set_state(newsk, TCP_SYN_RECV);
 		newicsk->icsk_bind_hash = NULL;

 		inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port;
@@ -888,7 +888,7 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
 			return 0;
 	}

-	sk->sk_state = TCP_CLOSE;
+	sk_set_state(sk, TCP_CLOSE);
 	return err;
 }
 EXPORT_SYMBOL_GPL(inet_csk_listen_start);
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index f6f5810..5973693 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -544,7 +544,7 @@ bool inet_ehash_nolisten(struct sock *sk, struct sock *osk)
 		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
 	} else {
 		percpu_counter_inc(sk->sk_prot->orphan_count);
-		sk->sk_state = TCP_CLOSE;
+		sk_set_state(sk, TCP_CLOSE);
 		sock_set_flag(sk, SOCK_DEAD);
 		inet_csk_destroy_sock(sk);
 	}
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c470fec..df6da92 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -283,8 +283,6 @@
 #include <asm/ioctls.h>
 #include <net/busy_poll.h>

-#include <trace/events/tcp.h>
-
 struct percpu_counter tcp_orphan_count;
 EXPORT_SYMBOL_GPL(tcp_orphan_count);

@@ -2040,8 +2038,6 @@ void tcp_set_state(struct sock *sk, int state)
 {
 	int oldstate = sk->sk_state;

-	trace_tcp_set_state(sk, oldstate, state);
-
 	switch (state) {
 	case TCP_ESTABLISHED:
 		if (oldstate != TCP_ESTABLISHED)
--
1.8.3.1

^ permalink raw reply related

* [PATCH v2 net-next 3/4] net: tracepoint: using sock_set_state tracepoint to trace DCCP state transition
From: Yafang Shao @ 2017-12-15 17:56 UTC (permalink / raw)
  To: songliubraving, davem, marcelo.leitner, rostedt
  Cc: bgregg, netdev, linux-kernel, Yafang Shao
In-Reply-To: <1513360611-11392-1-git-send-email-laoar.shao@gmail.com>

With changes in inet_ files, DCCP state transitions are traced with
sock_set_state tracepoint.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/dccp/proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 9d43c1f..2874faf 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -110,7 +110,7 @@ void dccp_set_state(struct sock *sk, const int state)
 	/* Change state AFTER socket is unhashed to avoid closed
 	 * socket sitting in hash tables.
 	 */
-	sk->sk_state = state;
+	sk_set_state(sk, state);
 }

 EXPORT_SYMBOL_GPL(dccp_set_state);
--
1.8.3.1

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox