Skip to contentSkip to conversation

ss: Dont show netlink and packet sockets by default

PATCH Superseded Vadim Kochan 2 participants 3 messages Dec 14, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ss: Dont show netlink and packet sockets by default

From: Vadim Kochan <[email protected]>

Checking by SS_CLOSE state was remowed in:

(45a4770bc0) ss: Remove checking SS_CLOSE state for packet and netlink

which is not really correct because now by default all sockets are seen when do 'ss'.

Here is most correct fix which considers specified family.

To see netlink sockets:
ss -A netlink

To see packet sockets:
ss -A packet

And ss by default will show only connected/established sockets as it was before all the time.

---
 misc/ss.c | 6 ++++++
 1 file changed, 6 insertions(+)
misc/ss.c +6 -0
index e9927a5..6050ab6 100644
@@ -2801,6 +2801,9 @@ static int packet_show(struct filter *f)
 	int ino;
 	unsigned long long sk;
 
+	if (preferred_family != AF_PACKET && !(f->states & (1<<SS_CLOSE)))
+		return 0;
+
 	if (packet_show_netlink(f, NULL) == 0)
 		return 0;
 
@@ -3028,6 +3031,9 @@ static int netlink_show(struct filter *f)
 	int rq, wq, rc;
 	unsigned long long sk, cb;
 
+	if (preferred_family != AF_NETLINK && !(f->states & (1<<SS_CLOSE)))
+		return 0;
+
 	if (!getenv("PROC_NET_NETLINK") && !getenv("PROC_ROOT") &&
 		netlink_show_netlink(f, NULL) == 0)
 		return 0;
Signature · 1 line
2.1.3
#1 lore raw

Hello.

Quoted 30 lines · Vadim Kochan

From: Vadim Kochan <[email protected]>

Checking by SS_CLOSE state was remowed in:

(45a4770bc0) ss: Remove checking SS_CLOSE state for packet and netlink

which is not really correct because now by default all sockets are seen when do 'ss'.

Here is most correct fix which considers specified family.

To see netlink sockets:
ss -A netlink

To see packet sockets:
ss -A packet

And ss by default will show only connected/established sockets as it was before all the time.

---
  misc/ss.c | 6 ++++++
  1 file changed, 6 insertions(+)
misc/ss.c +0 -0
index e9927a5..6050ab6 100644

misc/ss.c static int packet_show(struct filter *f) · line 2804

Quoted 4 lines
misc/ss.c +1 -0
@@ -2801,6 +2801,9 @@ static int packet_show(struct filter *f)
  	int ino;
  	unsigned long long sk;
 
+	if (preferred_family != AF_PACKET && !(f->states & (1<<SS_CLOSE)))

Please surround << with spaces, to be consistent with other operators and
general kernel coding style.

misc/ss.c static int netlink_show(struct filter *f) · line 3034

Quoted 10 lines
misc/ss.c +3 -0
+		return 0;
+
  	if (packet_show_netlink(f, NULL) == 0)
  		return 0;
 
@@ -3028,6 +3031,9 @@ static int netlink_show(struct filter *f)
  	int rq, wq, rc;
  	unsigned long long sk, cb;
 
+	if (preferred_family != AF_NETLINK && !(f->states & (1<<SS_CLOSE)))

Likewise.

misc/ss.c static int netlink_show(struct filter *f) · line 3036

Quoted 2 lines
misc/ss.c +2 -0
+		return 0;
+

[...]

WBR, Sergei

#2 lore raw
Quoted 55 lines · Sergei Shtylyov

Hello.

Quoted 30 lines · Vadim Kochan

From: Vadim Kochan <[email protected]>

Checking by SS_CLOSE state was remowed in:

(45a4770bc0) ss: Remove checking SS_CLOSE state for packet and netlink

which is not really correct because now by default all sockets are seen when do 'ss'.

Here is most correct fix which considers specified family.

To see netlink sockets:
ss -A netlink

To see packet sockets:
ss -A packet

And ss by default will show only connected/established sockets as it was before all the time.

---
 misc/ss.c | 6 ++++++
 1 file changed, 6 insertions(+)
misc/ss.c +0 -0
index e9927a5..6050ab6 100644

misc/ss.c static int packet_show(struct filter *f) · line 2804

Quoted 4 lines
misc/ss.c +1 -0
@@ -2801,6 +2801,9 @@ static int packet_show(struct filter *f)
 	int ino;
 	unsigned long long sk;
 
+	if (preferred_family != AF_PACKET && !(f->states & (1<<SS_CLOSE)))

Please surround << with spaces, to be consistent with other operators and
general kernel coding style.

misc/ss.c static int netlink_show(struct filter *f) · line 3034

Quoted 10 lines
misc/ss.c +3 -0
+		return 0;
+
 	if (packet_show_netlink(f, NULL) == 0)
 		return 0;
 
@@ -3028,6 +3031,9 @@ static int netlink_show(struct filter *f)
 	int rq, wq, rc;
 	unsigned long long sk, cb;
 
+	if (preferred_family != AF_NETLINK && !(f->states & (1<<SS_CLOSE)))

Likewise.

Quoted 6 lines

misc/ss.c static int netlink_show(struct filter *f) · line 3036

Quoted 2 lines
misc/ss.c +2 -0
+		return 0;
+

[...]

WBR, Sergei

OK, I just returned removed code, but I agree to correct it, thanks.