diff mbox series

[iproute2-next,3/4] ss: change aafilter port from int to long (inode support)

Message ID 20230808214258.975440-3-mathieu@schroetersa.ch (mailing list archive)
State Accepted
Commit 012cb5152d05122299384c9159ea82d059c80873
Delegated to: David Ahern
Headers show
Series [iproute2-next,1/4] Add get_long utility and adapt get_integer accordingly | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Mathieu Schroeter Aug. 8, 2023, 9:42 p.m. UTC
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>
---
 misc/ss.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/misc/ss.c b/misc/ss.c
index e9d81359..baa83514 100644
--- 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;