* [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 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
* 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 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
* [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 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 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 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 04/18] ss: Use sockstat->type in all socket types
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>
Unix sockets used that field already to hold info about the socket type.
By replicating this approach in all other socket types, we can get rid
of protocol parameter in inet_stats_print() and have sock_state_print()
figure things out by itself.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
misc/ss.c | 124 +++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 70 insertions(+), 54 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index d0b4f879c4d9f..e6053467aaf82 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -793,8 +793,57 @@ struct tcpstat {
struct tcp_bbr_info *bbr_info;
};
-static void sock_state_print(struct sockstat *s, const char *sock_name)
+static const char *unix_netid_name(int type)
+{
+ switch (type) {
+ case SOCK_STREAM:
+ return "u_str";
+ case SOCK_SEQPACKET:
+ return "u_seq";
+ case SOCK_DGRAM:
+ default:
+ return "u_dgr";
+ }
+}
+
+static char *proto_name(int protocol)
{
+ switch (protocol) {
+ case 0:
+ return "raw";
+ case IPPROTO_UDP:
+ return "udp";
+ case IPPROTO_TCP:
+ return "tcp";
+ case IPPROTO_DCCP:
+ return "dccp";
+ }
+
+ return "???";
+}
+
+static void sock_state_print(struct sockstat *s)
+{
+ const char *sock_name;
+
+ switch (s->local.family) {
+ case AF_UNIX:
+ sock_name = unix_netid_name(s->type);
+ break;
+ case AF_INET:
+ case AF_INET6:
+ sock_name = proto_name(s->type);
+ break;
+ case AF_PACKET:
+ sock_name = s->type == SOCK_RAW ? "p_raw" : "p_dgr";
+ break;
+ case AF_NETLINK:
+ sock_name = "nl";
+ break;
+ default:
+ sock_name = "unknown";
+ }
+
if (netid_width)
printf("%-*s ", netid_width, sock_name);
if (state_width)
@@ -1670,27 +1719,11 @@ void *parse_markmask(const char *markmask)
return res;
}
-static char *proto_name(int protocol)
-{
- switch (protocol) {
- case 0:
- return "raw";
- case IPPROTO_UDP:
- return "udp";
- case IPPROTO_TCP:
- return "tcp";
- case IPPROTO_DCCP:
- return "dccp";
- }
-
- return "???";
-}
-
-static void inet_stats_print(struct sockstat *s, int protocol)
+static void inet_stats_print(struct sockstat *s)
{
char *buf = NULL;
- sock_state_print(s, proto_name(protocol));
+ sock_state_print(s);
inet_addr_print(&s->local, s->lport, s->iface);
inet_addr_print(&s->remote, s->rport, 0);
@@ -1948,8 +1981,9 @@ static int tcp_show_line(char *line, const struct filter *f, int family)
s.rto = (double)rto;
s.ssthresh = s.ssthresh == -1 ? 0 : s.ssthresh;
s.rto = s.rto != 3 * hz ? s.rto / hz : 0;
+ s.ss.type = IPPROTO_TCP;
- inet_stats_print(&s.ss, IPPROTO_TCP);
+ inet_stats_print(&s.ss);
if (show_options)
tcp_timer_print(&s);
@@ -2201,8 +2235,7 @@ static void parse_diag_msg(struct nlmsghdr *nlh, struct sockstat *s)
}
static int inet_show_sock(struct nlmsghdr *nlh,
- struct sockstat *s,
- int protocol)
+ struct sockstat *s)
{
struct rtattr *tb[INET_DIAG_MAX+1];
struct inet_diag_msg *r = NLMSG_DATA(nlh);
@@ -2211,9 +2244,9 @@ static int inet_show_sock(struct nlmsghdr *nlh,
nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
if (tb[INET_DIAG_PROTOCOL])
- protocol = *(__u8 *)RTA_DATA(tb[INET_DIAG_PROTOCOL]);
+ s->type = *(__u8 *)RTA_DATA(tb[INET_DIAG_PROTOCOL]);
- inet_stats_print(s, protocol);
+ inet_stats_print(s);
if (show_options) {
struct tcpstat t = {};
@@ -2240,7 +2273,7 @@ static int inet_show_sock(struct nlmsghdr *nlh,
}
}
- if (show_mem || (show_tcpinfo && protocol != IPPROTO_UDP)) {
+ if (show_mem || (show_tcpinfo && s->type != IPPROTO_UDP)) {
printf("\n\t");
tcp_show_info(nlh, r, tb);
}
@@ -2414,6 +2447,7 @@ static int show_one_inet_sock(const struct sockaddr_nl *addr,
return 0;
parse_diag_msg(h, &s);
+ s.type = diag_arg->protocol;
if (diag_arg->f->f && run_ssfilter(diag_arg->f->f, &s) == 0)
return 0;
@@ -2428,7 +2462,7 @@ static int show_one_inet_sock(const struct sockaddr_nl *addr,
}
}
- err = inet_show_sock(h, &s, diag_arg->protocol);
+ err = inet_show_sock(h, &s);
if (err < 0)
return err;
@@ -2534,11 +2568,12 @@ static int tcp_show_netlink_file(struct filter *f)
}
parse_diag_msg(h, &s);
+ s.type = IPPROTO_TCP;
if (f && f->f && run_ssfilter(f->f, &s) == 0)
continue;
- err = inet_show_sock(h, &s, IPPROTO_TCP);
+ err = inet_show_sock(h, &s);
if (err < 0)
return err;
}
@@ -2657,7 +2692,8 @@ static int dgram_show_line(char *line, const struct filter *f, int family)
if (n < 9)
opt[0] = 0;
- inet_stats_print(&s, dg_proto == UDP_PROTO ? IPPROTO_UDP : 0);
+ s.type = dg_proto == UDP_PROTO ? IPPROTO_UDP : 0;
+ inet_stats_print(&s);
if (show_details && opt[0])
printf(" opt:\"%s\"", opt);
@@ -2758,25 +2794,6 @@ static void unix_list_free(struct sockstat *list)
}
}
-static const char *unix_netid_name(int type)
-{
- const char *netid;
-
- switch (type) {
- case SOCK_STREAM:
- netid = "u_str";
- break;
- case SOCK_SEQPACKET:
- netid = "u_seq";
- break;
- case SOCK_DGRAM:
- default:
- netid = "u_dgr";
- break;
- }
- return netid;
-}
-
static bool unix_type_skip(struct sockstat *s, struct filter *f)
{
if (s->type == SOCK_STREAM && !(f->dbs&(1<<UNIX_ST_DB)))
@@ -2839,7 +2856,7 @@ static void unix_stats_print(struct sockstat *list, struct filter *f)
continue;
}
- sock_state_print(s, unix_netid_name(s->type));
+ sock_state_print(s);
sock_addr_print(s->name ?: "*", " ",
int_to_str(s->lport, port_name), NULL);
@@ -3058,15 +3075,15 @@ static int packet_stats_print(struct sockstat *s, const struct filter *f)
const char *addr, *port;
char ll_name[16];
+ s->local.family = s->remote.family = AF_PACKET;
+
if (f->f) {
- s->local.family = AF_PACKET;
- s->remote.family = AF_PACKET;
s->local.data[0] = s->prot;
if (run_ssfilter(f->f, s) == 0)
return 1;
}
- sock_state_print(s, s->type == SOCK_RAW ? "p_raw" : "p_dgr");
+ sock_state_print(s);
if (s->prot == 3)
addr = "*";
@@ -3316,10 +3333,9 @@ static int netlink_show_one(struct filter *f,
st.state = SS_CLOSE;
st.rq = rq;
st.wq = wq;
+ st.local.family = st.remote.family = AF_NETLINK;
if (f->f) {
- st.local.family = AF_NETLINK;
- st.remote.family = AF_NETLINK;
st.rport = -1;
st.lport = pid;
st.local.data[0] = prot;
@@ -3327,7 +3343,7 @@ static int netlink_show_one(struct filter *f,
return 1;
}
- sock_state_print(&st, "nl");
+ sock_state_print(&st);
if (resolve_services)
prot_name = nl_proto_n2a(prot, prot_buf, sizeof(prot_buf));
--
2.10.0
^ permalink raw reply related
* Re: BUG() can be hit in tcp_collapse()
From: Vladis Dronov @ 2016-11-11 13:08 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, stable, Marco Grassi
In-Reply-To: <1478808780.8455.23.camel@edumazet-glaptop3.roam.corp.google.com>
Hello, Eric,
> Another sk_filter() is used in tcp v6.
> So the correct patch would be :
Thank you much for your research. I'm happy my report
has resulted as the proposed patch.
Best regards,
Vladis Dronov | Red Hat, Inc. | Product Security Engineer
^ permalink raw reply
* Re: [patch net 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity
From: Ido Schimmel @ 2016-11-11 12:54 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <1478859642-2918-3-git-send-email-jiri@resnulli.us>
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.
> + return true;
> + return false;
> +}
> +
> static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
> {
> char *rauhtd_pl;
> @@ -826,7 +846,7 @@ static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
> for (i = 0; i < num_rec; i++)
> mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl,
> i);
> - } while (num_rec);
> + } while (mlxsw_sp_router_rauhtd_is_full(rauhtd_pl));
> rtnl_unlock();
>
> kfree(rauhtd_pl);
> --
> 2.7.4
>
^ permalink raw reply
* Re: [patch net 1/2] mlxsw: spectrum: Fix refcount bug on span entries
From: Ido Schimmel @ 2016-11-11 12:49 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <1478859642-2918-2-git-send-email-jiri@resnulli.us>
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.
> + return span_entry;
> }
>
> static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
> struct mlxsw_sp_span_entry *span_entry)
> {
> + WARN_ON(!span_entry->ref_count);
> +
> if (--span_entry->ref_count == 0)
> mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
> return 0;
> --
> 2.7.4
>
^ permalink raw reply
* Re: [patch net-next 5/8] Introduce sample tc action
From: Simon Horman @ 2016-11-11 12:43 UTC (permalink / raw)
To: Yotam Gigi
Cc: John Fastabend, Jiri Pirko, netdev@vger.kernel.org,
davem@davemloft.net, Ido Schimmel, Elad Raz, Nogah Frankel,
Or Gerlitz, jhs@mojatatu.com, geert+renesas@glider.be,
stephen@networkplumber.org, xiyou.wangcong@gmail.com,
linux@roeck-us.net, roopa@cumulusnetworks.com
In-Reply-To: <DB3PR05MB0764850867353EEB018FCA5FACBB0@DB3PR05MB0764.eurprd05.prod.outlook.com>
On Fri, Nov 11, 2016 at 08:28:50AM +0000, Yotam Gigi wrote:
...
> John, as a result of your question I realized that our hardware does do
> randomized sampling that I was not aware of. I will use the extensibility of
> the API and implement a random keyword, that will be offloaded in our
> hardware. Those changes will be sent on v2.
>
> Eventually, your question was very relevant :) Thanks!
Perhaps I am missing the point but why not just make random the default and
implement the inverse as an extension if it turns out to be needed in
future?
^ permalink raw reply
* [PATCH v2] net: ethernet: ti: davinci_cpdma: free memory while channel destroy
From: Ivan Khoronzhuk @ 2016-11-11 12:39 UTC (permalink / raw)
To: mugunthanvnm, grygorii.strashko, netdev
Cc: linux-omap, linux-kernel, Ivan Khoronzhuk
While create/destroy channel operation memory is not freed. It was
supposed that memory is freed while driver remove. But a channel
can be created and destroyed many times while changing number of
channels with ethtool.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
Based on net-next/master
drivers/net/ethernet/ti/davinci_cpdma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index 05afc05..07fc92d 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -586,7 +586,7 @@ int cpdma_chan_destroy(struct cpdma_chan *chan)
cpdma_chan_stop(chan);
ctlr->channels[chan->chan_num] = NULL;
ctlr->chan_num--;
-
+ devm_kfree(ctlr->dev, chan);
cpdma_chan_split_pool(ctlr);
spin_unlock_irqrestore(&ctlr->lock, flags);
--
1.9.1
^ permalink raw reply related
* [PATCH] netfilter: x_tables: simplify IS_ERR_OR_NULL to NULL test
From: Julia Lawall @ 2016-11-11 12:32 UTC (permalink / raw)
To: Florian Westphal, David S. Miller
Cc: kernel-janitors, linux-kernel, netdev, coreteam, netfilter-devel,
Hideaki YOSHIFUJI, James Morris, Alexey Kuznetsov,
Jozsef Kadlecsik, Patrick McHardy, Pablo Neira Ayuso,
christophe.jaillet
Since commit 7926dbfa4bc1 ("netfilter: don't use
mutex_lock_interruptible()"), the function xt_find_table_lock can only
return NULL on an error. Simplify the call sites and update the
comment before the function.
The semantic patch that change the code is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression t,e;
@@
t = \(xt_find_table_lock(...)\|
try_then_request_module(xt_find_table_lock(...),...)\)
... when != t=e
- ! IS_ERR_OR_NULL(t)
+ t
@@
expression t,e;
@@
t = \(xt_find_table_lock(...)\|
try_then_request_module(xt_find_table_lock(...),...)\)
... when != t=e
- IS_ERR_OR_NULL(t)
+ !t
@@
expression t,e,e1;
@@
t = \(xt_find_table_lock(...)\|
try_then_request_module(xt_find_table_lock(...),...)\)
... when != t=e
?- t ? PTR_ERR(t) : e1
+ e1
... when any
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
net/ipv4/netfilter/arp_tables.c | 20 ++++++++++----------
net/ipv4/netfilter/ip_tables.c | 20 ++++++++++----------
net/ipv6/netfilter/ip6_tables.c | 20 ++++++++++----------
net/netfilter/x_tables.c | 2 +-
4 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index e76ab23..39004da 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -805,7 +805,7 @@ static int get_info(struct net *net, void __user *user,
#endif
t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
"arptable_%s", name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
struct arpt_getinfo info;
const struct xt_table_info *private = t->private;
#ifdef CONFIG_COMPAT
@@ -834,7 +834,7 @@ static int get_info(struct net *net, void __user *user,
xt_table_unlock(t);
module_put(t->me);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
#ifdef CONFIG_COMPAT
if (compat)
xt_compat_unlock(NFPROTO_ARP);
@@ -859,7 +859,7 @@ static int get_entries(struct net *net, struct arpt_get_entries __user *uptr,
get.name[sizeof(get.name) - 1] = '\0';
t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
const struct xt_table_info *private = t->private;
if (get.size == private->size)
@@ -871,7 +871,7 @@ static int get_entries(struct net *net, struct arpt_get_entries __user *uptr,
module_put(t->me);
xt_table_unlock(t);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
return ret;
}
@@ -898,8 +898,8 @@ static int __do_replace(struct net *net, const char *name,
t = try_then_request_module(xt_find_table_lock(net, NFPROTO_ARP, name),
"arptable_%s", name);
- if (IS_ERR_OR_NULL(t)) {
- ret = t ? PTR_ERR(t) : -ENOENT;
+ if (!t) {
+ ret = -ENOENT;
goto free_newinfo_counters_untrans;
}
@@ -1014,8 +1014,8 @@ static int do_add_counters(struct net *net, const void __user *user,
return PTR_ERR(paddc);
t = xt_find_table_lock(net, NFPROTO_ARP, tmp.name);
- if (IS_ERR_OR_NULL(t)) {
- ret = t ? PTR_ERR(t) : -ENOENT;
+ if (!t) {
+ ret = -ENOENT;
goto free;
}
@@ -1404,7 +1404,7 @@ static int compat_get_entries(struct net *net,
xt_compat_lock(NFPROTO_ARP);
t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
const struct xt_table_info *private = t->private;
struct xt_table_info info;
@@ -1419,7 +1419,7 @@ static int compat_get_entries(struct net *net,
module_put(t->me);
xt_table_unlock(t);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
xt_compat_unlock(NFPROTO_ARP);
return ret;
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index de4fa03..46815c8 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -973,7 +973,7 @@ static int get_info(struct net *net, void __user *user,
#endif
t = try_then_request_module(xt_find_table_lock(net, AF_INET, name),
"iptable_%s", name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
struct ipt_getinfo info;
const struct xt_table_info *private = t->private;
#ifdef CONFIG_COMPAT
@@ -1003,7 +1003,7 @@ static int get_info(struct net *net, void __user *user,
xt_table_unlock(t);
module_put(t->me);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
#ifdef CONFIG_COMPAT
if (compat)
xt_compat_unlock(AF_INET);
@@ -1028,7 +1028,7 @@ static int get_info(struct net *net, void __user *user,
get.name[sizeof(get.name) - 1] = '\0';
t = xt_find_table_lock(net, AF_INET, get.name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
const struct xt_table_info *private = t->private;
if (get.size == private->size)
ret = copy_entries_to_user(private->size,
@@ -1039,7 +1039,7 @@ static int get_info(struct net *net, void __user *user,
module_put(t->me);
xt_table_unlock(t);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
return ret;
}
@@ -1064,8 +1064,8 @@ static int get_info(struct net *net, void __user *user,
t = try_then_request_module(xt_find_table_lock(net, AF_INET, name),
"iptable_%s", name);
- if (IS_ERR_OR_NULL(t)) {
- ret = t ? PTR_ERR(t) : -ENOENT;
+ if (!t) {
+ ret = -ENOENT;
goto free_newinfo_counters_untrans;
}
@@ -1180,8 +1180,8 @@ static int get_info(struct net *net, void __user *user,
return PTR_ERR(paddc);
t = xt_find_table_lock(net, AF_INET, tmp.name);
- if (IS_ERR_OR_NULL(t)) {
- ret = t ? PTR_ERR(t) : -ENOENT;
+ if (!t) {
+ ret = -ENOENT;
goto free;
}
@@ -1626,7 +1626,7 @@ struct compat_ipt_get_entries {
xt_compat_lock(AF_INET);
t = xt_find_table_lock(net, AF_INET, get.name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
const struct xt_table_info *private = t->private;
struct xt_table_info info;
ret = compat_table_info(private, &info);
@@ -1640,7 +1640,7 @@ struct compat_ipt_get_entries {
module_put(t->me);
xt_table_unlock(t);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
xt_compat_unlock(AF_INET);
return ret;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 7eac01d..6ff42b8 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1003,7 +1003,7 @@ static int get_info(struct net *net, void __user *user,
#endif
t = try_then_request_module(xt_find_table_lock(net, AF_INET6, name),
"ip6table_%s", name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
struct ip6t_getinfo info;
const struct xt_table_info *private = t->private;
#ifdef CONFIG_COMPAT
@@ -1033,7 +1033,7 @@ static int get_info(struct net *net, void __user *user,
xt_table_unlock(t);
module_put(t->me);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
#ifdef CONFIG_COMPAT
if (compat)
xt_compat_unlock(AF_INET6);
@@ -1059,7 +1059,7 @@ static int get_info(struct net *net, void __user *user,
get.name[sizeof(get.name) - 1] = '\0';
t = xt_find_table_lock(net, AF_INET6, get.name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
struct xt_table_info *private = t->private;
if (get.size == private->size)
ret = copy_entries_to_user(private->size,
@@ -1070,7 +1070,7 @@ static int get_info(struct net *net, void __user *user,
module_put(t->me);
xt_table_unlock(t);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
return ret;
}
@@ -1095,8 +1095,8 @@ static int get_info(struct net *net, void __user *user,
t = try_then_request_module(xt_find_table_lock(net, AF_INET6, name),
"ip6table_%s", name);
- if (IS_ERR_OR_NULL(t)) {
- ret = t ? PTR_ERR(t) : -ENOENT;
+ if (!t) {
+ ret = -ENOENT;
goto free_newinfo_counters_untrans;
}
@@ -1210,8 +1210,8 @@ static int get_info(struct net *net, void __user *user,
if (IS_ERR(paddc))
return PTR_ERR(paddc);
t = xt_find_table_lock(net, AF_INET6, tmp.name);
- if (IS_ERR_OR_NULL(t)) {
- ret = t ? PTR_ERR(t) : -ENOENT;
+ if (!t) {
+ ret = -ENOENT;
goto free;
}
@@ -1647,7 +1647,7 @@ struct compat_ip6t_get_entries {
xt_compat_lock(AF_INET6);
t = xt_find_table_lock(net, AF_INET6, get.name);
- if (!IS_ERR_OR_NULL(t)) {
+ if (t) {
const struct xt_table_info *private = t->private;
struct xt_table_info info;
ret = compat_table_info(private, &info);
@@ -1661,7 +1661,7 @@ struct compat_ip6t_get_entries {
module_put(t->me);
xt_table_unlock(t);
} else
- ret = t ? PTR_ERR(t) : -ENOENT;
+ ret = -ENOENT;
xt_compat_unlock(AF_INET6);
return ret;
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index fc49774..ad818e5 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -982,7 +982,7 @@ void xt_free_table_info(struct xt_table_info *info)
}
EXPORT_SYMBOL(xt_free_table_info);
-/* Find table by name, grabs mutex & ref. Returns ERR_PTR() on error. */
+/* Find table by name, grabs mutex & ref. Returns NULL on error. */
struct xt_table *xt_find_table_lock(struct net *net, u_int8_t af,
const char *name)
{
^ permalink raw reply related
* Re: [PATCH net 2/2] r8152: rx descriptor check
From: Francois Romieu @ 2016-11-11 12:13 UTC (permalink / raw)
To: Hayes Wang; +Cc: netdev, nic_swsd, linux-kernel, linux-usb, mlord
In-Reply-To: <1394712342-15778-228-Taiwan-albertk@realtek.com>
Hayes Wang <hayeswang@realtek.com> :
> For some platforms, the data in memory is not the same with the one
> from the device. That is, the data of memory is unbelievable. The
> check is used to find out this situation.
Invalid packet size corrupted receive descriptors in Realtek's device
reminds of CVE-2009-4537.
Is the silicium of both devices different enough to prevent the same
exploit to happen ?
--
Ueimor
^ permalink raw reply
* Re: question about xt_find_table_lock
From: Julia Lawall @ 2016-11-11 11:58 UTC (permalink / raw)
To: Florian Westphal
Cc: Julia Lawall, pablo, kaber, kadlec, davem, netfilter-devel,
coreteam, netdev, linux-kernel, christophe.jaillet
In-Reply-To: <20161111112307.GA7274@breakpoint.cc>
On Fri, 11 Nov 2016, Florian Westphal wrote:
> Julia Lawall <julia.lawall@lip6.fr> wrote:
> > The function xt_find_table_lock defined in net/netfilter/x_tables.c is
> > preceeded by a comment that says that it returns ERR_PTR() on error. But
> > looking at the definition, I only see occurrences of return NULL and
> > returns of pointers that have previously been dereferenced. Is it the
> > code or the documentation that is incorrect? The call sites seem to be
> > using IS_ERR_OR_NULL. Is there a plan to return ERR_PTR values in the
> > future?
>
> It used to return ERR_PTR, see:
>
> commit 7926dbfa4bc14e27f4e18a6184a031a1c1e077dc
> netfilter: don't use mutex_lock_interruptible()
>
> So the comment isn't correct anymore and callers could test vs NULL.
Thanks for the quick feedback.
julia
^ permalink raw reply
* Re: question about xt_find_table_lock
From: Florian Westphal @ 2016-11-11 11:23 UTC (permalink / raw)
To: Julia Lawall
Cc: pablo, kaber, kadlec, davem, netfilter-devel, coreteam, netdev,
linux-kernel, christophe.jaillet
In-Reply-To: <alpine.DEB.2.20.1611111141380.2074@hadrien>
Julia Lawall <julia.lawall@lip6.fr> wrote:
> The function xt_find_table_lock defined in net/netfilter/x_tables.c is
> preceeded by a comment that says that it returns ERR_PTR() on error. But
> looking at the definition, I only see occurrences of return NULL and
> returns of pointers that have previously been dereferenced. Is it the
> code or the documentation that is incorrect? The call sites seem to be
> using IS_ERR_OR_NULL. Is there a plan to return ERR_PTR values in the
> future?
It used to return ERR_PTR, see:
commit 7926dbfa4bc14e27f4e18a6184a031a1c1e077dc
netfilter: don't use mutex_lock_interruptible()
So the comment isn't correct anymore and callers could test vs NULL.
^ permalink raw reply
* Re: [PATCH net-next v2 2/7] vxlan: simplify exception handling
From: Jiri Benc @ 2016-11-11 11:14 UTC (permalink / raw)
To: Pravin Shelar; +Cc: Linux Kernel Network Developers
In-Reply-To: <CAOrHB_AGV4x4G4QYFAaWNYgckvkDAS-prp65CgXfTqB4KoxHTw@mail.gmail.com>
On Thu, 10 Nov 2016 11:21:19 -0800, Pravin Shelar wrote:
> One additional variable is not bad but look at what has happened in
> vxlan_xmit_one(). There are already more than 20 variables defined. It
> is hard to read code in this case.
I agree that the function is horrible.
What I was thinking about was separating the vxlan data and control
plane. The vxlan data plane would perform encapsulation and
decapsulation based on lwtunnel infrastructure and the rest of the
"classical" vxlan would be just one of the users of that. Basically
replacing vxlan_rdst by ip_tunnel_info, among other things.
That would make the vxlan code much much cleaner.
> anyways I can add another variable to the function. I do not feel that
> strongly about this.
Me neither, actually. I prefer another variable but I won't oppose the
patchset just based on that if you choose differently.
Thanks,
Jiri
^ permalink raw reply
* Re: [mm PATCH v3 12/23] arch/nios2: Add option to skip DMA sync as a part of map and unmap
From: Tobias Klauser @ 2016-11-11 10:58 UTC (permalink / raw)
To: Alexander Duyck; +Cc: linux-mm, akpm, Ley Foon Tan, linux-kernel, netdev
In-Reply-To: <20161110113518.76501.52225.stgit@ahduyck-blue-test.jf.intel.com>
On 2016-11-10 at 12:35:18 +0100, Alexander Duyck <alexander.h.duyck@intel.com> wrote:
> This change allows us to pass DMA_ATTR_SKIP_CPU_SYNC which allows us to
> avoid invoking cache line invalidation if the driver will just handle it
> via a sync_for_cpu or sync_for_device call.
>
> Cc: Ley Foon Tan <lftan@altera.com>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Reviewed-by: Tobias Klauser <tklauser@distanz.ch>
^ permalink raw reply
* question about xt_find_table_lock
From: Julia Lawall @ 2016-11-11 10:49 UTC (permalink / raw)
To: pablo, kaber, kadlec, davem
Cc: netfilter-devel, coreteam, netdev, linux-kernel,
christophe.jaillet
The function xt_find_table_lock defined in net/netfilter/x_tables.c is
preceeded by a comment that says that it returns ERR_PTR() on error. But
looking at the definition, I only see occurrences of return NULL and
returns of pointers that have previously been dereferenced. Is it the
code or the documentation that is incorrect? The call sites seem to be
using IS_ERR_OR_NULL. Is there a plan to return ERR_PTR values in the
future?
julia
^ permalink raw reply
* [patch net-next] mlxsw: reg: Fix pwm_frequency field size in MFCR register
From: Jiri Pirko @ 2016-11-11 10:22 UTC (permalink / raw)
To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
From: Jiri Pirko <jiri@mellanox.com>
The field is 7bit long. Fix it.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/reg.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 0936b4a..b5ab81a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -4424,7 +4424,7 @@ enum mlxsw_reg_mfcr_pwm_frequency {
* Controls the frequency of the PWM signal.
* Access: RW
*/
-MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 6);
+MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
#define MLXSW_MFCR_TACHOS_MAX 10
--
2.7.4
^ permalink raw reply related
* [patch net 2/2] mlxsw: spectrum_router: Correctly dump neighbour activity
From: Jiri Pirko @ 2016-11-11 10:20 UTC (permalink / raw)
To: netdev; +Cc: davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <1478859642-2918-1-git-send-email-jiri@resnulli.us>
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)
+ return true;
+ return false;
+}
+
static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
{
char *rauhtd_pl;
@@ -826,7 +846,7 @@ static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
for (i = 0; i < num_rec; i++)
mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl,
i);
- } while (num_rec);
+ } while (mlxsw_sp_router_rauhtd_is_full(rauhtd_pl));
rtnl_unlock();
kfree(rauhtd_pl);
--
2.7.4
^ permalink raw reply related
* [patch net 1/2] mlxsw: spectrum: Fix refcount bug on span entries
From: Jiri Pirko @ 2016-11-11 10:20 UTC (permalink / raw)
To: netdev; +Cc: davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
In-Reply-To: <1478859642-2918-1-git-send-email-jiri@resnulli.us>
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
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")
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++;
+ return span_entry;
}
static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_span_entry *span_entry)
{
+ WARN_ON(!span_entry->ref_count);
+
if (--span_entry->ref_count == 0)
mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
return 0;
--
2.7.4
^ permalink raw reply related
* [patch net 0/2] mlxsw: Couple of fixes
From: Jiri Pirko @ 2016-11-11 10:20 UTC (permalink / raw)
To: netdev; +Cc: davem, yotamg, arkadis, idosch, eladr, nogahf, ogerlitz
From: Jiri Pirko <jiri@mellanox.com>
Please, queue-up both for stable. Thanks!
Arkadi Sharshevsky (1):
mlxsw: spectrum_router: Correctly dump neighbour activity
Yotam Gigi (1):
mlxsw: spectrum: Fix refcount bug on span entries
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 ++++++-----
.../net/ethernet/mellanox/mlxsw/spectrum_router.c | 22 +++++++++++++++++++++-
2 files changed, 27 insertions(+), 6 deletions(-)
--
2.7.4
^ permalink raw reply
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