* [iproute PATCH 05/18] ss: introduce proc_ctx_print()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
This consolidates identical code in three places. While the function
name is not quite perfect as there is different proc_ctx printing code
in netlink_show_one() as well, I sadly didn't find a more suitable one.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 49 ++++++++++++++-----------------------------------
1 file changed, 14 insertions(+), 35 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index e6053467aaf82..b3475cc96ae7b 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1719,14 +1719,9 @@ void *parse_markmask(const char *markmask)
return res;
}
-static void inet_stats_print(struct sockstat *s)
+static void proc_ctx_print(struct sockstat *s)
{
- char *buf = NULL;
-
- sock_state_print(s);
-
- inet_addr_print(&s->local, s->lport, s->iface);
- inet_addr_print(&s->remote, s->rport, 0);
+ char *buf;
if (show_proc_ctx || show_sock_ctx) {
if (find_entry(s->ino, &buf,
@@ -1743,6 +1738,16 @@ static void inet_stats_print(struct sockstat *s)
}
}
+static void inet_stats_print(struct sockstat *s)
+{
+ sock_state_print(s);
+
+ inet_addr_print(&s->local, s->lport, s->iface);
+ inet_addr_print(&s->remote, s->rport, 0);
+
+ proc_ctx_print(s);
+}
+
static int proc_parse_inet_addr(char *loc, char *rem, int family, struct
sockstat * s)
{
@@ -2814,7 +2819,6 @@ static void unix_stats_print(struct sockstat *list, struct filter *f)
{
struct sockstat *s;
char *peer;
- char *ctx_buf = NULL;
bool use_proc = unix_use_proc();
char port_name[30] = {};
@@ -2863,19 +2867,7 @@ static void unix_stats_print(struct sockstat *list, struct filter *f)
sock_addr_print(peer, " ", int_to_str(s->rport, port_name),
NULL);
- if (show_proc_ctx || show_sock_ctx) {
- if (find_entry(s->ino, &ctx_buf,
- (show_proc_ctx & show_sock_ctx) ?
- PROC_SOCK_CTX : PROC_CTX) > 0) {
- printf(" users:(%s)", ctx_buf);
- free(ctx_buf);
- }
- } else if (show_users) {
- if (find_entry(s->ino, &ctx_buf, USERS) > 0) {
- printf(" users:(%s)", ctx_buf);
- free(ctx_buf);
- }
- }
+ proc_ctx_print(s);
printf("\n");
}
}
@@ -3071,7 +3063,6 @@ static int unix_show(struct filter *f)
static int packet_stats_print(struct sockstat *s, const struct filter *f)
{
- char *buf = NULL;
const char *addr, *port;
char ll_name[16];
@@ -3098,19 +3089,7 @@ static int packet_stats_print(struct sockstat *s, const struct filter *f)
sock_addr_print(addr, ":", port, NULL);
sock_addr_print("", "*", "", NULL);
- if (show_proc_ctx || show_sock_ctx) {
- if (find_entry(s->ino, &buf,
- (show_proc_ctx & show_sock_ctx) ?
- PROC_SOCK_CTX : PROC_CTX) > 0) {
- printf(" users:(%s)", buf);
- free(buf);
- }
- } else if (show_users) {
- if (find_entry(s->ino, &buf, USERS) > 0) {
- printf(" users:(%s)", buf);
- free(buf);
- }
- }
+ proc_ctx_print(s);
if (show_details)
sock_details_print(s);
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 12/18] ss: Make slabstat_ids local to get_slabstat()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index d546a00eb2c24..c3a5148e05013 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -580,21 +580,19 @@ struct slabstat {
static struct slabstat slabstat;
-static const char *slabstat_ids[] = {
-
- "sock",
- "tcp_bind_bucket",
- "tcp_tw_bucket",
- "tcp_open_request",
- "skbuff_head_cache",
-};
-
static int get_slabstat(struct slabstat *s)
{
char buf[256];
FILE *fp;
int cnt;
static int slabstat_valid;
+ static const char * const slabstat_ids[] = {
+ "sock",
+ "tcp_bind_bucket",
+ "tcp_tw_bucket",
+ "tcp_open_request",
+ "skbuff_head_cache",
+ };
if (slabstat_valid)
return 0;
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 16/18] ss: Make sstate_name local to sock_state_print()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index cf4187310816e..14492da256c61 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -634,21 +634,6 @@ static unsigned long long cookie_sk_get(const uint32_t *cookie)
return (((unsigned long long)cookie[1] << 31) << 1) | cookie[0];
}
-static const char *sstate_name[] = {
- "UNKNOWN",
- [SS_ESTABLISHED] = "ESTAB",
- [SS_SYN_SENT] = "SYN-SENT",
- [SS_SYN_RECV] = "SYN-RECV",
- [SS_FIN_WAIT1] = "FIN-WAIT-1",
- [SS_FIN_WAIT2] = "FIN-WAIT-2",
- [SS_TIME_WAIT] = "TIME-WAIT",
- [SS_CLOSE] = "UNCONN",
- [SS_CLOSE_WAIT] = "CLOSE-WAIT",
- [SS_LAST_ACK] = "LAST-ACK",
- [SS_LISTEN] = "LISTEN",
- [SS_CLOSING] = "CLOSING",
-};
-
static const char *sstate_namel[] = {
"UNKNOWN",
[SS_ESTABLISHED] = "established",
@@ -769,6 +754,20 @@ static char *proto_name(int protocol)
static void sock_state_print(struct sockstat *s)
{
const char *sock_name;
+ static const char * const sstate_name[] = {
+ "UNKNOWN",
+ [SS_ESTABLISHED] = "ESTAB",
+ [SS_SYN_SENT] = "SYN-SENT",
+ [SS_SYN_RECV] = "SYN-RECV",
+ [SS_FIN_WAIT1] = "FIN-WAIT-1",
+ [SS_FIN_WAIT2] = "FIN-WAIT-2",
+ [SS_TIME_WAIT] = "TIME-WAIT",
+ [SS_CLOSE] = "UNCONN",
+ [SS_CLOSE_WAIT] = "CLOSE-WAIT",
+ [SS_LAST_ACK] = "LAST-ACK",
+ [SS_LISTEN] = "LISTEN",
+ [SS_CLOSING] = "CLOSING",
+ };
switch (s->local.family) {
case AF_UNIX:
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 15/18] ss: Make unix_state_map local to unix_show()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Also make it const, since there won't be any write access happening.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 85fc6096a986f..cf4187310816e 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2727,9 +2727,6 @@ outerr:
} while (0);
}
-int unix_state_map[] = { SS_CLOSE, SS_SYN_SENT,
- SS_ESTABLISHED, SS_CLOSING };
-
#define MAX_UNIX_REMEMBER (1024*1024/sizeof(struct sockstat))
static void unix_list_drop_first(struct sockstat **list)
@@ -2869,6 +2866,8 @@ static int unix_show(struct filter *f)
int newformat = 0;
int cnt;
struct sockstat *list = NULL;
+ const int unix_state_map[] = { SS_CLOSE, SS_SYN_SENT,
+ SS_ESTABLISHED, SS_CLOSING };
if (!filter_af_get(f, AF_UNIX))
return 0;
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 08/18] ss: Turn generic_proc_open() wrappers into macros
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 89 ++++++++++++++-------------------------------------------------
1 file changed, 19 insertions(+), 70 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 8e021731cf71c..e9fecd39a8493 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -306,76 +306,25 @@ static FILE *generic_proc_open(const char *env, const char *name)
return fopen(p, "r");
}
-
-static FILE *net_tcp_open(void)
-{
- return generic_proc_open("PROC_NET_TCP", "net/tcp");
-}
-
-static FILE *net_tcp6_open(void)
-{
- return generic_proc_open("PROC_NET_TCP6", "net/tcp6");
-}
-
-static FILE *net_udp_open(void)
-{
- return generic_proc_open("PROC_NET_UDP", "net/udp");
-}
-
-static FILE *net_udp6_open(void)
-{
- return generic_proc_open("PROC_NET_UDP6", "net/udp6");
-}
-
-static FILE *net_raw_open(void)
-{
- return generic_proc_open("PROC_NET_RAW", "net/raw");
-}
-
-static FILE *net_raw6_open(void)
-{
- return generic_proc_open("PROC_NET_RAW6", "net/raw6");
-}
-
-static FILE *net_unix_open(void)
-{
- return generic_proc_open("PROC_NET_UNIX", "net/unix");
-}
-
-static FILE *net_packet_open(void)
-{
- return generic_proc_open("PROC_NET_PACKET", "net/packet");
-}
-
-static FILE *net_netlink_open(void)
-{
- return generic_proc_open("PROC_NET_NETLINK", "net/netlink");
-}
-
-static FILE *slabinfo_open(void)
-{
- return generic_proc_open("PROC_SLABINFO", "slabinfo");
-}
-
-static FILE *net_sockstat_open(void)
-{
- return generic_proc_open("PROC_NET_SOCKSTAT", "net/sockstat");
-}
-
-static FILE *net_sockstat6_open(void)
-{
- return generic_proc_open("PROC_NET_SOCKSTAT6", "net/sockstat6");
-}
-
-static FILE *net_snmp_open(void)
-{
- return generic_proc_open("PROC_NET_SNMP", "net/snmp");
-}
-
-static FILE *ephemeral_ports_open(void)
-{
- return generic_proc_open("PROC_IP_LOCAL_PORT_RANGE", "sys/net/ipv4/ip_local_port_range");
-}
+#define net_tcp_open() generic_proc_open("PROC_NET_TCP", "net/tcp")
+#define net_tcp6_open() generic_proc_open("PROC_NET_TCP6", "net/tcp6")
+#define net_udp_open() generic_proc_open("PROC_NET_UDP", "net/udp")
+#define net_udp6_open() generic_proc_open("PROC_NET_UDP6", "net/udp6")
+#define net_raw_open() generic_proc_open("PROC_NET_RAW", "net/raw")
+#define net_raw6_open() generic_proc_open("PROC_NET_RAW6", "net/raw6")
+#define net_unix_open() generic_proc_open("PROC_NET_UNIX", "net/unix")
+#define net_packet_open() generic_proc_open("PROC_NET_PACKET", \
+ "net/packet")
+#define net_netlink_open() generic_proc_open("PROC_NET_NETLINK", \
+ "net/netlink")
+#define slabinfo_open() generic_proc_open("PROC_SLABINFO", "slabinfo")
+#define net_sockstat_open() generic_proc_open("PROC_NET_SOCKSTAT", \
+ "net/sockstat")
+#define net_sockstat6_open() generic_proc_open("PROC_NET_SOCKSTAT6", \
+ "net/sockstat6")
+#define net_snmp_open() generic_proc_open("PROC_NET_SNMP", "net/snmp")
+#define ephemeral_ports_open() generic_proc_open("PROC_IP_LOCAL_PORT_RANGE", \
+ "sys/net/ipv4/ip_local_port_range")
struct user_ent {
struct user_ent *next;
--
2.10.0
^ permalink raw reply related
* Re: Long delays creating a netns after deleting one (possibly RCU related)
From: Rolf Neugebauer @ 2016-11-11 13:11 UTC (permalink / raw)
To: paulmck
Cc: Cong Wang, LKML, Linux Kernel Network Developers, Justin Cormack,
Ian Campbell
In-Reply-To: <20161110212404.GB4127@linux.vnet.ibm.com>
On Thu, Nov 10, 2016 at 9:24 PM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
> On Thu, Nov 10, 2016 at 09:37:47AM -0800, Cong Wang wrote:
>> (Cc'ing Paul)
>>
>> On Wed, Nov 9, 2016 at 7:42 AM, Rolf Neugebauer
>> <rolf.neugebauer@docker.com> wrote:
>> > Hi
>> >
>> > We noticed some long delays starting docker containers on some newer
>> > kernels (starting with 4.5.x and still present in 4.9-rc4, 4.4.x is
>> > fine). We narrowed this down to the creation of a network namespace
>> > being delayed directly after removing another one (details and
>> > reproduction below). We have seen delays of up to 60s on some systems.
>> >
>> > - The delay is proportional to the number of CPUs (online or offline).
>> > We first discovered it with a Hyper-V Linux VM. Hyper-V advertises up
>> > to 240 offline vCPUs even if one configures the VM with only, say 2
>> > vCPUs. We see linear increase in delay when we change NR_CPUS in the
>> > kernel config.
>> >
>> > - The delay is also dependent on some tunnel network interfaces being
>> > present (which we had compiled in in one of our kernel configs).
>> >
>> > - We can reproduce this issue with stock kernels from
>> > http://kernel.ubuntu.com/~kernel-ppa/mainline/running in Hyper-V VMs
>> > as well as other hypervisors like qemu and hyperkit where we have good
>> > control over the number of CPUs.
>> >
>> > A simple test is:
>> > modprobe ipip
>> > moprobe ip_gre
>> > modprobe ip_vti
>> > echo -n "add netns foo ===> "; /usr/bin/time -f "%E" ip netns add foo
>> > echo -n "del netns foo ===> "; /usr/bin/time -f "%E" ip netns delete foo
>> > echo -n "add netns bar ===> "; /usr/bin/time -f "%E" ip netns add bar
>> > echo -n "del netns bar ===> "; /usr/bin/time -f "%E" ip netns delete bar
>> >
>> > with an output like:
>> > add netns foo ===> 0:00.00
>> > del netns foo ===> 0:00.01
>> > add netns bar ===> 0:08.53
>> > del netns bar ===> 0:00.01
>> >
>> > This is on a 4.9-rc4 kernel from the above URL configured with
>> > NR_CPUS=256 running in a Hyper-V VM (kernel config attached).
>> >
>> > Below is a dump of the work queues while the second 'ip add netns' is
>> > hanging. The state of the work queues does not seem to change while
>> > the command is delayed and the pattern shown is consistent across
>> > different kernel versions.
>> >
>> > Is this a known issue and/or is someone working on a fix?
>>
>> Not to me.
>>
>>
>> >
>> > [ 610.356272] sysrq: SysRq : Show Blocked State
>> > [ 610.356742] task PC stack pid father
>> > [ 610.357252] kworker/u480:1 D 0 1994 2 0x00000000
>> > [ 610.357752] Workqueue: netns cleanup_net
>> > [ 610.358239] ffff9892f1065800 0000000000000000 ffff9892ee1e1e00
>> > ffff9892f8e59340
>> > [ 610.358705] ffff9892f4526900 ffffbf0104b5ba88 ffffffffbe486df3
>> > ffffbf0104b5ba60
>> > [ 610.359168] 00ffffffbdcbe663 ffff9892f8e59340 0000000100012e70
>> > ffff9892ee1e1e00
>> > [ 610.359677] Call Trace:
>> > [ 610.360169] [<ffffffffbe486df3>] ? __schedule+0x233/0x6e0
>> > [ 610.360723] [<ffffffffbe4872d6>] schedule+0x36/0x80
>> > [ 610.361194] [<ffffffffbe48a9ca>] schedule_timeout+0x22a/0x3f0
>> > [ 610.361789] [<ffffffffbe486dfb>] ? __schedule+0x23b/0x6e0
>> > [ 610.362260] [<ffffffffbe487d24>] wait_for_completion+0xb4/0x140
>> > [ 610.362736] [<ffffffffbdcb05a0>] ? wake_up_q+0x80/0x80
>> > [ 610.363306] [<ffffffffbdceb528>] __wait_rcu_gp+0xc8/0xf0
>> > [ 610.363782] [<ffffffffbdceea5c>] synchronize_sched+0x5c/0x80
>> > [ 610.364137] [<ffffffffbdcf0010>] ? call_rcu_bh+0x20/0x20
>> > [ 610.364742] [<ffffffffbdceb440>] ?
>> > trace_raw_output_rcu_utilization+0x60/0x60
>> > [ 610.365337] [<ffffffffbe3696bc>] synchronize_net+0x1c/0x30
>>
>> This is a worker which holds the net_mutex and is waiting for
>> a RCU grace period to elapse.
>>
>>
>> > [ 610.365846] [<ffffffffbe369803>] netif_napi_del+0x23/0x80
>> > [ 610.367494] [<ffffffffc057f6f8>] ip_tunnel_dev_free+0x68/0xf0 [ip_tunnel]
>> > [ 610.368007] [<ffffffffbe372c10>] netdev_run_todo+0x230/0x330
>> > [ 610.368454] [<ffffffffbe37eb4e>] rtnl_unlock+0xe/0x10
>> > [ 610.369001] [<ffffffffc057f4df>] ip_tunnel_delete_net+0xdf/0x120 [ip_tunnel]
>> > [ 610.369500] [<ffffffffc058b92c>] ipip_exit_net+0x2c/0x30 [ipip]
>> > [ 610.369997] [<ffffffffbe362688>] ops_exit_list.isra.4+0x38/0x60
>> > [ 610.370636] [<ffffffffbe363674>] cleanup_net+0x1c4/0x2b0
>> > [ 610.371130] [<ffffffffbdc9e4ac>] process_one_work+0x1fc/0x4b0
>> > [ 610.371812] [<ffffffffbdc9e7ab>] worker_thread+0x4b/0x500
>> > [ 610.373074] [<ffffffffbdc9e760>] ? process_one_work+0x4b0/0x4b0
>> > [ 610.373622] [<ffffffffbdc9e760>] ? process_one_work+0x4b0/0x4b0
>> > [ 610.374100] [<ffffffffbdca4b09>] kthread+0xd9/0xf0
>> > [ 610.374574] [<ffffffffbdca4a30>] ? kthread_park+0x60/0x60
>> > [ 610.375198] [<ffffffffbe48c2b5>] ret_from_fork+0x25/0x30
>> > [ 610.375678] ip D 0 2149 2148 0x00000000
>> > [ 610.376185] ffff9892f0a99000 0000000000000000 ffff9892f0a66900
>> > [ 610.376185] ffff9892f8e59340
>> > [ 610.376185] ffff9892f4526900 ffffbf0101173db8 ffffffffbe486df3
>> > [ 610.376753] 00000005fecffd76
>> > [ 610.376762] 00ff9892f11d9820 ffff9892f8e59340 ffff989200000000
>> > ffff9892f0a66900
>> > [ 610.377274] Call Trace:
>> > [ 610.377789] [<ffffffffbe486df3>] ? __schedule+0x233/0x6e0
>> > [ 610.378306] [<ffffffffbe4872d6>] schedule+0x36/0x80
>> > [ 610.378992] [<ffffffffbe48756e>] schedule_preempt_disabled+0xe/0x10
>> > [ 610.379514] [<ffffffffbe489199>] __mutex_lock_slowpath+0xb9/0x130
>> > [ 610.380031] [<ffffffffbde0fce2>] ? __kmalloc+0x162/0x1e0
>> > [ 610.380556] [<ffffffffbe48922f>] mutex_lock+0x1f/0x30
>> > [ 610.381135] [<ffffffffbe3637ff>] copy_net_ns+0x9f/0x170
>> > [ 610.381647] [<ffffffffbdca5e6b>] create_new_namespaces+0x11b/0x200
>> > [ 610.382249] [<ffffffffbdca60fa>] unshare_nsproxy_namespaces+0x5a/0xb0
>> > [ 610.382818] [<ffffffffbdc82dcd>] SyS_unshare+0x1cd/0x360
>> > [ 610.383319] [<ffffffffbe48c03b>] entry_SYSCALL_64_fastpath+0x1e/0xad
>>
>> This process is apparently waiting for the net_mutex held by the previous one.
>>
>> Either RCU implementation is broken or something else is missing.
>> Do you have more stack traces of related processes? For example,
>> rcu_tasks_kthread. And if anything you can help to narrow down the problem,
>> it would be great.
>
> Did you set the rcu_normal boot parameter? Doing so would have this effect.
>
> (It is intended for real-time users who don't like expedited grace periods.)
rcu_normal is not set on the kernel command line and
/sys/kernel/rcu_normal and /sys/kernel/rcu_expedited both show 0.
>
> Thanx, Paul
>
^ permalink raw reply
* [iproute PATCH 03/18] ss: Add missing tab when printing UNIX details
From: Phil Sutter @ 2016-11-11 13:09 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
When dumping UNIX sockets and show_details is active but not show_mem
(ss -xne), the socket details are printed without being prefixed by tab.
Fix this by printing the tab character when either one of '-e' or '-m'
has been specified.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 4698683c4e84a..d0b4f879c4d9f 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2907,10 +2907,10 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,
unix_stats_print(&stat, f);
- if (show_mem) {
+ if (show_mem || show_details)
printf("\t");
+ if (show_mem)
print_skmeminfo(tb, UNIX_DIAG_MEMINFO);
- }
if (show_details) {
if (tb[UNIX_DIAG_SHUTDOWN]) {
unsigned char mask;
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 00/18] ss: Minor code review
From: Phil Sutter @ 2016-11-11 13:09 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
This is a series of misc changes to ss code which happened as fall-out
when working on a unified output formatter (still unfinished).
Phil Sutter (18):
ss: Mark fall through in arg parsing switch()
ss: Drop empty lines in UDP output
ss: Add missing tab when printing UNIX details
ss: Use sockstat->type in all socket types
ss: introduce proc_ctx_print()
ss: Drop list traversal from unix_stats_print()
ss: Eliminate unix_use_proc()
ss: Turn generic_proc_open() wrappers into macros
ss: Make tmr_name local to tcp_timer_print()
ss: Make user_ent_hash_build_init local to user_ent_hash_build()
ss: Make some variables function-local
ss: Make slabstat_ids local to get_slabstat()
ss: Get rid of useless goto in handle_follow_request()
ss: Get rid of single-fielded struct snmpstat
ss: Make unix_state_map local to unix_show()
ss: Make sstate_name local to sock_state_print()
ss: Make sstate_namel local to scan_state()
ss: unix_show: No need to initialize members of calloc'ed structs
misc/ss.c | 524 ++++++++++++++++++++++++++------------------------------------
1 file changed, 220 insertions(+), 304 deletions(-)
--
2.10.0
^ permalink raw reply
* [iproute PATCH 06/18] ss: Drop list traversal from unix_stats_print()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Although this complicates the dedicated procfs-based code path in
unix_show() a bit, it's the only sane way to get rid of unix_show_sock()
output diverging from other socket types in that it prints all socket
details in a new line.
As a side effect, it allows to eliminate all procfs specific code in
the same function.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 137 +++++++++++++++++++++++++++++---------------------------------
1 file changed, 64 insertions(+), 73 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index b3475cc96ae7b..36b18ff2ce3cb 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2788,15 +2788,13 @@ int unix_state_map[] = { SS_CLOSE, SS_SYN_SENT,
#define MAX_UNIX_REMEMBER (1024*1024/sizeof(struct sockstat))
-static void unix_list_free(struct sockstat *list)
+static void unix_list_drop_first(struct sockstat **list)
{
- while (list) {
- struct sockstat *s = list;
+ struct sockstat *s = *list;
- list = list->next;
- free(s->name);
- free(s);
- }
+ (*list) = (*list)->next;
+ free(s->name);
+ free(s);
}
static bool unix_type_skip(struct sockstat *s, struct filter *f)
@@ -2815,61 +2813,18 @@ static bool unix_use_proc(void)
return getenv("PROC_NET_UNIX") || getenv("PROC_ROOT");
}
-static void unix_stats_print(struct sockstat *list, struct filter *f)
+static void unix_stats_print(struct sockstat *s, struct filter *f)
{
- struct sockstat *s;
- char *peer;
- bool use_proc = unix_use_proc();
char port_name[30] = {};
- for (s = list; s; s = s->next) {
- if (!(f->states & (1 << s->state)))
- continue;
- if (unix_type_skip(s, f))
- continue;
-
- peer = "*";
- if (s->peer_name)
- peer = s->peer_name;
-
- if (s->rport && use_proc) {
- struct sockstat *p;
-
- for (p = list; p; p = p->next) {
- if (s->rport == p->lport)
- break;
- }
-
- if (!p) {
- peer = "?";
- } else {
- peer = p->name ? : "*";
- }
- }
-
- if (use_proc && f->f) {
- struct sockstat st = {
- .local.family = AF_UNIX,
- .remote.family = AF_UNIX,
- };
-
- memcpy(st.local.data, &s->name, sizeof(s->name));
- if (strcmp(peer, "*"))
- memcpy(st.remote.data, &peer, sizeof(peer));
- if (run_ssfilter(f->f, &st) == 0)
- continue;
- }
-
- sock_state_print(s);
+ sock_state_print(s);
- sock_addr_print(s->name ?: "*", " ",
- int_to_str(s->lport, port_name), NULL);
- sock_addr_print(peer, " ", int_to_str(s->rport, port_name),
- NULL);
+ sock_addr_print(s->name ?: "*", " ",
+ int_to_str(s->lport, port_name), NULL);
+ sock_addr_print(s->peer_name ?: "*", " ",
+ int_to_str(s->rport, port_name), NULL);
- proc_ctx_print(s);
- printf("\n");
- }
+ proc_ctx_print(s);
}
static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,
@@ -2916,8 +2871,6 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,
unix_stats_print(&stat, f);
- if (show_mem || show_details)
- printf("\t");
if (show_mem)
print_skmeminfo(tb, UNIX_DIAG_MEMINFO);
if (show_details) {
@@ -2928,8 +2881,7 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,
printf(" %c-%c", mask & 1 ? '-' : '<', mask & 2 ? '-' : '>');
}
}
- if (show_mem || show_details)
- printf("\n");
+ printf("\n");
return 0;
}
@@ -3020,6 +2972,11 @@ static int unix_show(struct filter *f)
if (u->type == SOCK_DGRAM && u->state == SS_CLOSE && u->rport)
u->state = SS_ESTABLISHED;
}
+ if (unix_type_skip(u, f) ||
+ !(f->states & (1 << u->state))) {
+ free(u);
+ continue;
+ }
if (!newformat) {
u->rport = 0;
@@ -3027,6 +2984,42 @@ static int unix_show(struct filter *f)
u->wq = 0;
}
+ if (name[0]) {
+ u->name = strdup(name);
+ if (!u->name)
+ break;
+ }
+
+ if (u->rport) {
+ struct sockstat *p;
+
+ for (p = list; p; p = p->next) {
+ if (u->rport == p->lport)
+ break;
+ }
+ if (!p)
+ u->peer_name = "?";
+ else
+ u->peer_name = p->name ? : "*";
+ }
+
+ if (f->f) {
+ struct sockstat st = {
+ .local.family = AF_UNIX,
+ .remote.family = AF_UNIX,
+ };
+
+ memcpy(st.local.data, &u->name, sizeof(u->name));
+ if (strcmp(u->peer_name, "*"))
+ memcpy(st.remote.data, &u->peer_name,
+ sizeof(u->peer_name));
+ if (run_ssfilter(f->f, &st) == 0) {
+ free(u->name);
+ free(u);
+ continue;
+ }
+ }
+
insp = &list;
while (*insp) {
if (u->type < (*insp)->type ||
@@ -3038,24 +3031,22 @@ static int unix_show(struct filter *f)
u->next = *insp;
*insp = u;
- if (name[0]) {
- if ((u->name = malloc(strlen(name)+1)) == NULL)
- break;
- strcpy(u->name, name);
- }
if (++cnt > MAX_UNIX_REMEMBER) {
- unix_stats_print(list, f);
- unix_list_free(list);
- list = NULL;
+ while (list) {
+ unix_stats_print(list, f);
+ printf("\n");
+
+ unix_list_drop_first(&list);
+ }
cnt = 0;
}
}
fclose(fp);
- if (list) {
+ while (list) {
unix_stats_print(list, f);
- unix_list_free(list);
- list = NULL;
- cnt = 0;
+ printf("\n");
+
+ unix_list_drop_first(&list);
}
return 0;
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 18/18] ss: unix_show: No need to initialize members of calloc'ed structs
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 6e669f7b0593c..1e3ccf28c4e84 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2877,8 +2877,6 @@ static int unix_show(struct filter *f)
if (!(u = calloc(1, sizeof(*u))))
break;
- u->name = NULL;
- u->peer_name = NULL;
if (sscanf(buf, "%x: %x %x %x %x %x %d %s",
&u->rport, &u->rq, &u->wq, &flags, &u->type,
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 14/18] ss: Get rid of single-fielded struct snmpstat
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
A struct with only a single field does not make much sense. Besides
that, it was used by print_summary() only.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index b06b9e6fa9884..85fc6096a986f 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -3472,10 +3472,6 @@ static int handle_follow_request(struct filter *f)
return ret;
}
-struct snmpstat {
- int tcp_estab;
-};
-
static int get_snmp_int(char *proto, char *key, int *result)
{
char buf[1024];
@@ -3596,11 +3592,11 @@ static int get_sockstat(struct ssummary *s)
static int print_summary(void)
{
struct ssummary s;
- struct snmpstat sn;
+ int tcp_estab;
if (get_sockstat(&s) < 0)
perror("ss: get_sockstat");
- if (get_snmp_int("Tcp:", "CurrEstab", &sn.tcp_estab) < 0)
+ if (get_snmp_int("Tcp:", "CurrEstab", &tcp_estab) < 0)
perror("ss: get_snmpstat");
get_slabstat(&slabstat);
@@ -3609,7 +3605,7 @@ static int print_summary(void)
printf("TCP: %d (estab %d, closed %d, orphaned %d, synrecv %d, timewait %d/%d), ports %d\n",
s.tcp_total + slabstat.tcp_syns + s.tcp_tws,
- sn.tcp_estab,
+ tcp_estab,
s.tcp_total - (s.tcp4_hashed+s.tcp6_hashed-s.tcp_tws),
s.tcp_orphans,
slabstat.tcp_syns,
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 01/18] ss: Mark fall through in arg parsing switch()
From: Phil Sutter @ 2016-11-11 13:09 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
As there is a certain chance of overlooking this, better add a comment
to draw readers' attention.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/misc/ss.c b/misc/ss.c
index dd77b8153b6da..c20bfbdb01c62 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -4025,6 +4025,7 @@ int main(int argc, char *argv[])
exit(0);
case 'z':
show_sock_ctx++;
+ /* fall through */
case 'Z':
if (is_selinux_enabled() <= 0) {
fprintf(stderr, "ss: SELinux is not enabled.\n");
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 11/18] ss: Make some variables function-local
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
addrp_width and screen_width are used in main() only, so no need to have
them globally available.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 3e5c93bb7c6f9..d546a00eb2c24 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -103,10 +103,8 @@ int follow_events;
int netid_width;
int state_width;
-int addrp_width;
int addr_width;
int serv_width;
-int screen_width;
static const char *TCP_PROTO = "tcp";
static const char *UDP_PROTO = "udp";
@@ -3784,6 +3782,7 @@ int main(int argc, char *argv[])
FILE *filter_fp = NULL;
int ch;
int state_filter = 0;
+ int addrp_width, screen_width = 80;
while ((ch = getopt_long(argc, argv, "dhaletuwxnro460spbEf:miA:D:F:vVzZN:KH",
long_opts, NULL)) != EOF) {
@@ -4067,7 +4066,6 @@ int main(int argc, char *argv[])
if (current_filter.states&(current_filter.states-1))
state_width = 10;
- screen_width = 80;
if (isatty(STDOUT_FILENO)) {
struct winsize w;
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 09/18] ss: Make tmr_name local to tcp_timer_print()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
It's used only there, so no need to have it globally defined.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index e9fecd39a8493..477910a842726 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -830,15 +830,6 @@ static void sock_addr_print(const char *addr, char *delim, const char *port,
sock_addr_print_width(addr_width, addr, delim, serv_width, port, ifname);
}
-static const char *tmr_name[] = {
- "off",
- "on",
- "keepalive",
- "timewait",
- "persist",
- "unknown"
-};
-
static const char *print_ms_timer(int timeout)
{
static char buf[64];
@@ -1879,6 +1870,15 @@ static void tcp_stats_print(struct tcpstat *s)
static void tcp_timer_print(struct tcpstat *s)
{
+ static const char * const tmr_name[] = {
+ "off",
+ "on",
+ "keepalive",
+ "timewait",
+ "persist",
+ "unknown"
+ };
+
if (s->timer) {
if (s->timer > 4)
s->timer = 5;
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 07/18] ss: Eliminate unix_use_proc()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
This function is used only at a single place anymore, so replace the
call to it by it's content, which makes that specific part of
unix_show() consistent with e.g. tcp_show().
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 36b18ff2ce3cb..8e021731cf71c 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2808,11 +2808,6 @@ static bool unix_type_skip(struct sockstat *s, struct filter *f)
return false;
}
-static bool unix_use_proc(void)
-{
- return getenv("PROC_NET_UNIX") || getenv("PROC_ROOT");
-}
-
static void unix_stats_print(struct sockstat *s, struct filter *f)
{
char port_name[30] = {};
@@ -2934,7 +2929,8 @@ static int unix_show(struct filter *f)
if (!filter_af_get(f, AF_UNIX))
return 0;
- if (!unix_use_proc() && unix_show_netlink(f) == 0)
+ if (!getenv("PROC_NET_UNIX") && !getenv("PROC_ROOT")
+ && unix_show_netlink(f) == 0)
return 0;
if ((fp = net_unix_open()) == NULL)
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 10/18] ss: Make user_ent_hash_build_init local to user_ent_hash_build()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
By having it statically defined, there is no need for it to be global.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 477910a842726..3e5c93bb7c6f9 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -99,8 +99,6 @@ int show_bpf;
int show_proc_ctx;
int show_sock_ctx;
int show_header = 1;
-/* If show_users & show_proc_ctx only do user_ent_hash_build() once */
-int user_ent_hash_build_init;
int follow_events;
int netid_width;
@@ -400,6 +398,7 @@ static void user_ent_hash_build(void)
char *pid_context;
char *sock_context;
const char *no_ctx = "unavailable";
+ static int user_ent_hash_build_init;
/* If show_users & show_proc_ctx set only do this once */
if (user_ent_hash_build_init != 0)
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 13/18] ss: Get rid of useless goto in handle_follow_request()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index c3a5148e05013..b06b9e6fa9884 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -3443,7 +3443,7 @@ static int generic_show_sock(const struct sockaddr_nl *addr,
static int handle_follow_request(struct filter *f)
{
- int ret = -1;
+ int ret = 0;
int groups = 0;
struct rtnl_handle rth;
@@ -3466,10 +3466,8 @@ static int handle_follow_request(struct filter *f)
rth.local.nl_pid = 0;
if (rtnl_dump_filter(&rth, generic_show_sock, f))
- goto Exit;
+ ret = -1;
- ret = 0;
-Exit:
rtnl_close(&rth);
return ret;
}
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 17/18] ss: Make sstate_namel local to scan_state()
From: Phil Sutter @ 2016-11-11 13:10 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 14492da256c61..6e669f7b0593c 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -634,21 +634,6 @@ static unsigned long long cookie_sk_get(const uint32_t *cookie)
return (((unsigned long long)cookie[1] << 31) << 1) | cookie[0];
}
-static const char *sstate_namel[] = {
- "UNKNOWN",
- [SS_ESTABLISHED] = "established",
- [SS_SYN_SENT] = "syn-sent",
- [SS_SYN_RECV] = "syn-recv",
- [SS_FIN_WAIT1] = "fin-wait-1",
- [SS_FIN_WAIT2] = "fin-wait-2",
- [SS_TIME_WAIT] = "time-wait",
- [SS_CLOSE] = "unconnected",
- [SS_CLOSE_WAIT] = "close-wait",
- [SS_LAST_ACK] = "last-ack",
- [SS_LISTEN] = "listening",
- [SS_CLOSING] = "closing",
-};
-
struct sockstat {
struct sockstat *next;
unsigned int type;
@@ -3698,6 +3683,20 @@ static void usage(void)
static int scan_state(const char *state)
{
+ static const char * const sstate_namel[] = {
+ "UNKNOWN",
+ [SS_ESTABLISHED] = "established",
+ [SS_SYN_SENT] = "syn-sent",
+ [SS_SYN_RECV] = "syn-recv",
+ [SS_FIN_WAIT1] = "fin-wait-1",
+ [SS_FIN_WAIT2] = "fin-wait-2",
+ [SS_TIME_WAIT] = "time-wait",
+ [SS_CLOSE] = "unconnected",
+ [SS_CLOSE_WAIT] = "close-wait",
+ [SS_LAST_ACK] = "last-ack",
+ [SS_LISTEN] = "listening",
+ [SS_CLOSING] = "closing",
+ };
int i;
if (strcasecmp(state, "close") == 0 ||
--
2.10.0
^ permalink raw reply related
* [iproute PATCH 02/18] ss: Drop empty lines in UDP output
From: Phil Sutter @ 2016-11-11 13:09 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20161111131014.21865-1-phil@nwl.cc>
When dumping UDP sockets and show_tcpinfo (-i) is active but not
show_mem (-m), print_tcpinfo() does not output anything leading to an
empty line being printed after every socket. Fix this by skipping the
call to print_tcpinfo() and the previous newline printing in that case.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc/ss.c b/misc/ss.c
index c20bfbdb01c62..4698683c4e84a 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2240,7 +2240,7 @@ static int inet_show_sock(struct nlmsghdr *nlh,
}
}
- if (show_mem || show_tcpinfo) {
+ if (show_mem || (show_tcpinfo && protocol != IPPROTO_UDP)) {
printf("\n\t");
tcp_show_info(nlh, r, tb);
}
--
2.10.0
^ permalink raw reply related
* Re: [patch net 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity
From: Jiri Pirko @ 2016-11-11 13:13 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <20161111125405.x56ipwlaoln4b4fe@splinter>
Fri, Nov 11, 2016 at 01:54:05PM CET, idosch@idosch.org wrote:
>On Fri, Nov 11, 2016 at 11:20:42AM +0100, Jiri Pirko wrote:
>> From: Arkadi Sharshevsky <arkadis@mellanox.com>
>>
>> During neighbour activity check the device's table is dumped by multiple
>> query requests. The query session should end when the response carries
>> less records than requested or when a given record is not full. Current
>> code only stops the dumping process if the number of returned records is
>> zero, which can result in infinite loop in case of activity.
>>
>> Fix this by stopping the dumping process according to the above logic.
>>
>> Fixes: c723c735fa6b ("mlxsw: spectrum_router: Periodically update the kernel's neigh table")
>> Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
>> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>> .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 22 +++++++++++++++++++++-
>> 1 file changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
>> index 040737e..d437457 100644
>> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
>> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
>> @@ -800,6 +800,26 @@ static void mlxsw_sp_router_neigh_rec_process(struct mlxsw_sp *mlxsw_sp,
>> }
>> }
>>
>> +static bool mlxsw_sp_router_rauhtd_is_full(char *rauhtd_pl)
>> +{
>> + u8 num_rec, last_rec_index, num_entries;
>> +
>> + num_rec = mlxsw_reg_rauhtd_num_rec_get(rauhtd_pl);
>> + last_rec_index = num_rec - 1;
>> +
>> + if (num_rec < MLXSW_REG_RAUHTD_REC_MAX_NUM)
>> + return false;
>> + if (mlxsw_reg_rauhtd_rec_type_get(rauhtd_pl, last_rec_index) ==
>> + MLXSW_REG_RAUHTD_TYPE_IPV6)
>> + return true;
>> +
>> + num_entries = mlxsw_reg_rauhtd_ipv4_rec_num_entries_get(rauhtd_pl,
>> + last_rec_index);
>> + if (++num_entries == MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC)
>
>Jiri, I just noticed we have an extra space after the '=='. Can you
>please remove it in v2? Sorry for not spotting this earlier.
Will do.
^ permalink raw reply
* Re: [patch net 1/2] mlxsw: spectrum: Fix refcount bug on span entries
From: Jiri Pirko @ 2016-11-11 13:15 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <20161111124928.dbxqswx6akatsjrt@splinter>
Fri, Nov 11, 2016 at 01:49:28PM CET, idosch@idosch.org wrote:
>On Fri, Nov 11, 2016 at 11:20:41AM +0100, Jiri Pirko wrote:
>> From: Yotam Gigi <yotamg@mellanox.com>
>>
>> When binding port to a newly created span entry, its refcount is set 0
>> even though it has a bound port. That leeds to unexpected behaviour when
>
>s/leeds/leads/
>
>> the user tries to delete that port from the span entry.
>>
>> Change the binding process to increase the refcount of the bound entry
>> even if the entry is newly created, and add warning on the process of
>> removing bound port from entry when its refcount is 0.
>>
>> Fixes: 763b4b70afcd3 ("mlxsw: spectrum: Add support in matchall mirror TC offloading")
>
>You only need the first 12 characters.
>
>> Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>> drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
>> index 1ec0a4c..d75c1ff 100644
>> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
>> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
>> @@ -269,17 +269,18 @@ static struct mlxsw_sp_span_entry
>> struct mlxsw_sp_span_entry *span_entry;
>>
>> span_entry = mlxsw_sp_span_entry_find(port);
>> - if (span_entry) {
>> - span_entry->ref_count++;
>> - return span_entry;
>> - }
>> + if (!span_entry)
>> + span_entry = mlxsw_sp_span_entry_create(port);
>>
>> - return mlxsw_sp_span_entry_create(port);
>> + span_entry->ref_count++;
>
>mlxsw_sp_span_entry_create() can return NULL. You can look at
>mlxsw_sp_fib_entry_get() for reference.
Right, missed that. Will fix. Thanks.
^ permalink raw reply
* [PATCH] vhost/vsock: Remove unused but set variable
From: Tobias Klauser @ 2016-11-11 13:26 UTC (permalink / raw)
To: Stefan Hajnoczi, Michael S. Tsirkin, Jason Wang
Cc: kvm, virtualization, netdev
Remove the unused but set variable vq in vhost_transport_send_pkt() to
fix the following GCC warning when building with 'W=1':
drivers/vhost/vsock.c:198:26: warning: variable ‘vq’ set but not used
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
drivers/vhost/vsock.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index e3b30ea9ece5..9c3c68b9a49e 100644
--- a/drivers/vhost/vsock.c
+++ b/drivers/vhost/vsock.c
@@ -195,7 +195,6 @@ static int
vhost_transport_send_pkt(struct virtio_vsock_pkt *pkt)
{
struct vhost_vsock *vsock;
- struct vhost_virtqueue *vq;
int len = pkt->len;
/* Find the vhost_vsock according to guest context id */
@@ -205,8 +204,6 @@ vhost_transport_send_pkt(struct virtio_vsock_pkt *pkt)
return -ENODEV;
}
- vq = &vsock->vqs[VSOCK_VQ_RX];
-
if (pkt->reply)
atomic_inc(&vsock->queued_replies);
--
2.11.0.rc0.7.gbe5a750
^ permalink raw reply related
* [PATCH] vhost/scsi: Remove unused but set variable
From: Tobias Klauser @ 2016-11-11 13:27 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang; +Cc: kvm, virtualization, netdev
Remove the unused but set variable se_tpg in vhost_scsi_nexus_cb() to
fix the following GCC warning when building with 'W=1':
drivers/vhost/scsi.c:1752:26: warning: variable ‘se_tpg’ set but not used
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
drivers/vhost/scsi.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 6e29d053843d..e2be447752c2 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1749,7 +1749,6 @@ static int vhost_scsi_nexus_cb(struct se_portal_group *se_tpg,
static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
const char *name)
{
- struct se_portal_group *se_tpg;
struct vhost_scsi_nexus *tv_nexus;
mutex_lock(&tpg->tv_tpg_mutex);
@@ -1758,7 +1757,6 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
pr_debug("tpg->tpg_nexus already exists\n");
return -EEXIST;
}
- se_tpg = &tpg->se_tpg;
tv_nexus = kzalloc(sizeof(struct vhost_scsi_nexus), GFP_KERNEL);
if (!tv_nexus) {
--
2.11.0.rc0.7.gbe5a750
^ permalink raw reply related
* Hopefully
From: Rita Micheal @ 2016-11-11 13:27 UTC (permalink / raw)
Hi friend I am a banker in ADB BANK. I want to transfer an abandoned
$25.5Million to your Bank account. 40/percent will be your share.
No risks involved but keep it as secret. Contact me for more details
And also acknowledge receipt of this message in acceptance of my
mutual business Endeavour by furnishing me with the following:
1. Your Full Names and Address.
2. Direct Telephone and Fax numbers
Please reply in my private email address (michealrita70@yahoo.fr) for
security and confidential reasons.
Yours
Miss Rita Micheal
^ permalink raw reply
* [PATCH v2] net: ethernet: ti: davinci_cpdma: fix fixed prio cpdma ctlr configuration
From: Ivan Khoronzhuk @ 2016-11-11 13:45 UTC (permalink / raw)
To: mugunthanvnm, grygorii.strashko, netdev
Cc: linux-omap, linux-kernel, Ivan Khoronzhuk
The dma ctlr is reseted to 0 while cpdma soft reset, thus cpdma ctlr
cannot be configured after cpdma is stopped. So restoring content
of cpdma ctlr while off/on procedure is needed. The cpdma ctlr off/on
procedure is present while interface down/up and while changing number
of channels with ethtool. In order to not restore content in many
places, move it to cpdma_ctlr_start().
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
Based on net-next/master
Since v1:
- don't use redundant parameters for cpdma, make prio fixed to be constant
drivers/net/ethernet/ti/cpsw.c | 4 --
drivers/net/ethernet/ti/davinci_cpdma.c | 102 +++++++++++++++++---------------
2 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index b1ddf89..39d06e8 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1376,10 +1376,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0);
if (!cpsw_common_res_usage_state(cpsw)) {
- /* setup tx dma to fixed prio and zero offset */
- cpdma_control_set(cpsw->dma, CPDMA_TX_PRIO_FIXED, 1);
- cpdma_control_set(cpsw->dma, CPDMA_RX_BUFFER_OFFSET, 0);
-
/* disable priority elevation */
__raw_writel(0, &cpsw->regs->ptype);
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index c3f35f1..c2fb1b6 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -124,6 +124,29 @@ struct cpdma_chan {
int int_set, int_clear, td;
};
+struct cpdma_control_info {
+ u32 reg;
+ u32 shift, mask;
+ int access;
+#define ACCESS_RO BIT(0)
+#define ACCESS_WO BIT(1)
+#define ACCESS_RW (ACCESS_RO | ACCESS_WO)
+};
+
+static struct cpdma_control_info controls[] = {
+ [CPDMA_CMD_IDLE] = {CPDMA_DMACONTROL, 3, 1, ACCESS_WO},
+ [CPDMA_COPY_ERROR_FRAMES] = {CPDMA_DMACONTROL, 4, 1, ACCESS_RW},
+ [CPDMA_RX_OFF_LEN_UPDATE] = {CPDMA_DMACONTROL, 2, 1, ACCESS_RW},
+ [CPDMA_RX_OWNERSHIP_FLIP] = {CPDMA_DMACONTROL, 1, 1, ACCESS_RW},
+ [CPDMA_TX_PRIO_FIXED] = {CPDMA_DMACONTROL, 0, 1, ACCESS_RW},
+ [CPDMA_STAT_IDLE] = {CPDMA_DMASTATUS, 31, 1, ACCESS_RO},
+ [CPDMA_STAT_TX_ERR_CODE] = {CPDMA_DMASTATUS, 20, 0xf, ACCESS_RW},
+ [CPDMA_STAT_TX_ERR_CHAN] = {CPDMA_DMASTATUS, 16, 0x7, ACCESS_RW},
+ [CPDMA_STAT_RX_ERR_CODE] = {CPDMA_DMASTATUS, 12, 0xf, ACCESS_RW},
+ [CPDMA_STAT_RX_ERR_CHAN] = {CPDMA_DMASTATUS, 8, 0x7, ACCESS_RW},
+ [CPDMA_RX_BUFFER_OFFSET] = {CPDMA_RXBUFFOFS, 0, 0xffff, ACCESS_RW},
+};
+
#define tx_chan_num(chan) (chan)
#define rx_chan_num(chan) ((chan) + CPDMA_MAX_CHANNELS)
#define is_rx_chan(chan) ((chan)->chan_num >= CPDMA_MAX_CHANNELS)
@@ -253,6 +276,31 @@ static void cpdma_desc_free(struct cpdma_desc_pool *pool,
gen_pool_free(pool->gen_pool, (unsigned long)desc, pool->desc_size);
}
+static int _cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value)
+{
+ struct cpdma_control_info *info = &controls[control];
+ u32 val;
+
+ if (!ctlr->params.has_ext_regs)
+ return -ENOTSUPP;
+
+ if (ctlr->state != CPDMA_STATE_ACTIVE)
+ return -EINVAL;
+
+ if (control < 0 || control >= ARRAY_SIZE(controls))
+ return -ENOENT;
+
+ if ((info->access & ACCESS_WO) != ACCESS_WO)
+ return -EPERM;
+
+ val = dma_reg_read(ctlr, info->reg);
+ val &= ~(info->mask << info->shift);
+ val |= (value & info->mask) << info->shift;
+ dma_reg_write(ctlr, info->reg, val);
+
+ return 0;
+}
+
struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
{
struct cpdma_ctlr *ctlr;
@@ -324,6 +372,10 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr)
if (ctlr->channels[i])
cpdma_chan_start(ctlr->channels[i]);
}
+
+ _cpdma_control_set(ctlr, CPDMA_TX_PRIO_FIXED, 1);
+ _cpdma_control_set(ctlr, CPDMA_RX_BUFFER_OFFSET, 0);
+
spin_unlock_irqrestore(&ctlr->lock, flags);
return 0;
}
@@ -874,29 +926,6 @@ int cpdma_chan_int_ctrl(struct cpdma_chan *chan, bool enable)
return 0;
}
-struct cpdma_control_info {
- u32 reg;
- u32 shift, mask;
- int access;
-#define ACCESS_RO BIT(0)
-#define ACCESS_WO BIT(1)
-#define ACCESS_RW (ACCESS_RO | ACCESS_WO)
-};
-
-static struct cpdma_control_info controls[] = {
- [CPDMA_CMD_IDLE] = {CPDMA_DMACONTROL, 3, 1, ACCESS_WO},
- [CPDMA_COPY_ERROR_FRAMES] = {CPDMA_DMACONTROL, 4, 1, ACCESS_RW},
- [CPDMA_RX_OFF_LEN_UPDATE] = {CPDMA_DMACONTROL, 2, 1, ACCESS_RW},
- [CPDMA_RX_OWNERSHIP_FLIP] = {CPDMA_DMACONTROL, 1, 1, ACCESS_RW},
- [CPDMA_TX_PRIO_FIXED] = {CPDMA_DMACONTROL, 0, 1, ACCESS_RW},
- [CPDMA_STAT_IDLE] = {CPDMA_DMASTATUS, 31, 1, ACCESS_RO},
- [CPDMA_STAT_TX_ERR_CODE] = {CPDMA_DMASTATUS, 20, 0xf, ACCESS_RW},
- [CPDMA_STAT_TX_ERR_CHAN] = {CPDMA_DMASTATUS, 16, 0x7, ACCESS_RW},
- [CPDMA_STAT_RX_ERR_CODE] = {CPDMA_DMASTATUS, 12, 0xf, ACCESS_RW},
- [CPDMA_STAT_RX_ERR_CHAN] = {CPDMA_DMASTATUS, 8, 0x7, ACCESS_RW},
- [CPDMA_RX_BUFFER_OFFSET] = {CPDMA_RXBUFFOFS, 0, 0xffff, ACCESS_RW},
-};
-
int cpdma_control_get(struct cpdma_ctlr *ctlr, int control)
{
unsigned long flags;
@@ -931,35 +960,10 @@ int cpdma_control_get(struct cpdma_ctlr *ctlr, int control)
int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value)
{
unsigned long flags;
- struct cpdma_control_info *info = &controls[control];
int ret;
- u32 val;
spin_lock_irqsave(&ctlr->lock, flags);
-
- ret = -ENOTSUPP;
- if (!ctlr->params.has_ext_regs)
- goto unlock_ret;
-
- ret = -EINVAL;
- if (ctlr->state != CPDMA_STATE_ACTIVE)
- goto unlock_ret;
-
- ret = -ENOENT;
- if (control < 0 || control >= ARRAY_SIZE(controls))
- goto unlock_ret;
-
- ret = -EPERM;
- if ((info->access & ACCESS_WO) != ACCESS_WO)
- goto unlock_ret;
-
- val = dma_reg_read(ctlr, info->reg);
- val &= ~(info->mask << info->shift);
- val |= (value & info->mask) << info->shift;
- dma_reg_write(ctlr, info->reg, val);
- ret = 0;
-
-unlock_ret:
+ ret = _cpdma_control_set(ctlr, control, value);
spin_unlock_irqrestore(&ctlr->lock, flags);
return ret;
}
--
1.9.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox