Thread (4 messages) flat view 4 messages, 2 authors, 2021-02-05

Re: [PATCH iproute2-next] ss: always prefer family as part of host condition to default family

From: David Ahern <hidden>
Date: 2021-02-02 03:05:01

On 1/31/21 1:17 AM, Thayne McCombs wrote:
quoted hunk ↗ jump to hunk
diff --git a/misc/ss.c b/misc/ss.c
index 0593627b..2a5e056a 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2119,24 +2119,39 @@ void *parse_hostcond(char *addr, bool is_port)
 	int fam = preferred_family;
 	struct filter *f = &current_filter;
 
-	if (fam == AF_UNIX || strncmp(addr, "unix:", 5) == 0) {
+    if (strncmp(addr, "unix:", 5) == 0) {
+        fam = AF_UNIX;
+        addr += 5;
+    } else if (strncmp(addr, "link:", 5) == 0) {
+        fam = AF_PACKET;
+        addr += 5;
+    } else if (strncmp(addr, "netlink:", 8) == 0) {
+        fam = AF_NETLINK;
+        addr += 8;
+    } else if (strncmp(addr, "vsock:", 6) == 0) {
+        fam = AF_VSOCK;
+        addr += 6;
+    } else if (strncmp(addr, "inet:", 5) == 0) {
+        fam = AF_INET;
+        addr += 5;
+    } else if (strncmp(addr, "inet6:", 6) == 0) {
+        fam = AF_INET6;
+        addr += 6;
+    }
+
+	if (fam == AF_UNIX) {
 		char *p;
 
Looks fine to me, but you need to fix the coding style -- tabs, not spaces.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help