]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: change aafilter port from int to long (inode support)
authorMathieu Schroeter <mathieu@schroetersa.ch>
Tue, 8 Aug 2023 21:42:57 +0000 (23:42 +0200)
committerDavid Ahern <dsahern@kernel.org>
Sun, 13 Aug 2023 16:24:36 +0000 (10:24 -0600)
The aafilter struct considers the port as (usually) 32 bit signed
integer. In case of a unix socket, the port is used with an inode
number which is an unsigned int. In this case, the 'ss' command
fails because it assumes that the value does not look like a port
(<0).

Here an example of command call where the inode is passed and
is larger than a signed integer:

ss -H -A unix_stream src :2259952798

Signed-off-by: Mathieu Schroeter <mathieu@schroetersa.ch>
Signed-off-by: David Ahern <dsahern@kernel.org>
misc/ss.c

index e9d813596b91ac6475e494deb9412038034a4e32..baa835149588c0653a347824589cfbf5985fc507 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1733,7 +1733,7 @@ static void inet_addr_print(const inet_prefix *a, int port,
 
 struct aafilter {
        inet_prefix     addr;
-       int             port;
+       long            port;
        unsigned int    iface;
        __u32           mark;
        __u32           mask;
@@ -2256,7 +2256,7 @@ void *parse_hostcond(char *addr, bool is_port)
                port = find_port(addr, is_port);
                if (port) {
                        if (*port && strcmp(port, "*")) {
-                               if (get_integer(&a.port, port, 0)) {
+                               if (get_long(&a.port, port, 0)) {
                                        if ((a.port = xll_name_to_index(port)) <= 0)
                                                return NULL;
                                }
@@ -2279,7 +2279,7 @@ void *parse_hostcond(char *addr, bool is_port)
                port = find_port(addr, is_port);
                if (port) {
                        if (*port && strcmp(port, "*")) {
-                               if (get_integer(&a.port, port, 0)) {
+                               if (get_long(&a.port, port, 0)) {
                                        if (strcmp(port, "kernel") == 0)
                                                a.port = 0;
                                        else
@@ -2335,7 +2335,7 @@ void *parse_hostcond(char *addr, bool is_port)
                        *port++ = 0;
 
                if (*port && *port != '*') {
-                       if (get_integer(&a.port, port, 0)) {
+                       if (get_long(&a.port, port, 0)) {
                                struct servent *se1 = NULL;
                                struct servent *se2 = NULL;