netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Schroeter <mathieu@schroetersa.ch>
To: netdev@vger.kernel.org
Cc: Mathieu Schroeter <mathieu@schroetersa.ch>
Subject: [PATCH iproute2-next 3/4] ss: change aafilter port from int to long (inode support)
Date: Tue,  8 Aug 2023 23:42:57 +0200	[thread overview]
Message-ID: <20230808214258.975440-3-mathieu@schroetersa.ch> (raw)
In-Reply-To: <20230808214258.975440-1-mathieu@schroetersa.ch>

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 --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;
 
-- 
2.39.2


  parent reply	other threads:[~2023-08-08 21:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 21:42 [PATCH iproute2-next 1/4] Add get_long utility and adapt get_integer accordingly Mathieu Schroeter
2023-08-08 21:42 ` [PATCH iproute2-next 2/4] Add utility to convert an unsigned int to string Mathieu Schroeter
2023-08-08 21:42 ` Mathieu Schroeter [this message]
2023-08-08 21:42 ` [PATCH iproute2-next 4/4] ss: print unix socket "ports" as unsigned int (inode) Mathieu Schroeter
2023-08-13 16:30 ` [PATCH iproute2-next 1/4] Add get_long utility and adapt get_integer accordingly patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230808214258.975440-3-mathieu@schroetersa.ch \
    --to=mathieu@schroetersa.ch \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).