This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
This is the right solution but it might break someone parsing the output of ss
command. Will apply it anyway unless someone has an objection.
From: Phil Sutter <phil@nwl.cc> Date: 2017-07-31 10:30:12
On Sat, Jul 29, 2017 at 02:29:10PM +0200, Florian Lehner wrote:
quoted hunk
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
int port, unsigned int ifindex
ap = format_host(AF_INET, 4, a->data);
}
} else {
- ap = format_host(a->family, 16, a->data);
+ if (a->family == AF_INET6) {
+ sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+ } else {
+ ap = format_host(a->family, 16, a->data);
+ }
est_len = strlen(ap);
if (est_len <= addr_width)
est_len = addr_width;
Note that this will enclosed resolved hostnames in brackets as well, not
sure if that's intended. Looks like fixing that is not exactly trivial:
Hostname resolution is buried in format_host() which resides in
lib/utils.c so is shared code with ip, tc, etc. Hence, adding the
brackets in rt_addr_n2a_r() is not an option, either. Adding a 'bool *'
param to format_host() and format_host_r() indicating that name
resolution has happened might help here.
Cheers, Phil
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2017-07-31 16:27:58
On Mon, 31 Jul 2017 12:30:10 +0200
Phil Sutter [off-list ref] wrote:
On Sat, Jul 29, 2017 at 02:29:10PM +0200, Florian Lehner wrote:
quoted
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
int port, unsigned int ifindex
ap = format_host(AF_INET, 4, a->data);
}
} else {
- ap = format_host(a->family, 16, a->data);
+ if (a->family == AF_INET6) {
+ sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+ } else {
+ ap = format_host(a->family, 16, a->data);
+ }
est_len = strlen(ap);
if (est_len <= addr_width)
est_len = addr_width;
Note that this will enclosed resolved hostnames in brackets as well, not
sure if that's intended. Looks like fixing that is not exactly trivial:
Hostname resolution is buried in format_host() which resides in
lib/utils.c so is shared code with ip, tc, etc. Hence, adding the
brackets in rt_addr_n2a_r() is not an option, either. Adding a 'bool *'
param to format_host() and format_host_r() indicating that name
resolution has happened might help here.
Cheers, Phil
From: Phil Sutter <phil@nwl.cc> Date: 2017-07-31 16:43:30
On Mon, Jul 31, 2017 at 09:27:55AM -0700, Stephen Hemminger wrote:
On Mon, 31 Jul 2017 12:30:10 +0200
Phil Sutter [off-list ref] wrote:
quoted
On Sat, Jul 29, 2017 at 02:29:10PM +0200, Florian Lehner wrote:
quoted
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
int port, unsigned int ifindex
ap = format_host(AF_INET, 4, a->data);
}
} else {
- ap = format_host(a->family, 16, a->data);
+ if (a->family == AF_INET6) {
+ sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+ } else {
+ ap = format_host(a->family, 16, a->data);
+ }
est_len = strlen(ap);
if (est_len <= addr_width)
est_len = addr_width;
Note that this will enclosed resolved hostnames in brackets as well, not
sure if that's intended. Looks like fixing that is not exactly trivial:
Hostname resolution is buried in format_host() which resides in
lib/utils.c so is shared code with ip, tc, etc. Hence, adding the
brackets in rt_addr_n2a_r() is not an option, either. Adding a 'bool *'
param to format_host() and format_host_r() indicating that name
resolution has happened might help here.
Cheers, Phil
Also, this code should return "*" for IN6ADDR_ANY
Oh, really? It doesn't do that currently, and I always thought the IPv6
all-zero address was written '::' (or '[::]:1234' if a port is present).
Cheers, Phil
On Sat, Jul 29, 2017 at 02:29:10PM +0200, Florian Lehner wrote:
quoted
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
int port, unsigned int ifindex
ap = format_host(AF_INET, 4, a->data);
}
} else {
- ap = format_host(a->family, 16, a->data);
+ if (a->family == AF_INET6) {
+ sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+ } else {
+ ap = format_host(a->family, 16, a->data);
+ }
est_len = strlen(ap);
if (est_len <= addr_width)
est_len = addr_width;
Note that this will enclosed resolved hostnames in brackets as well, not
sure if that's intended. Looks like fixing that is not exactly trivial:
Hostname resolution is buried in format_host() which resides in
lib/utils.c so is shared code with ip, tc, etc. Hence, adding the
brackets in rt_addr_n2a_r() is not an option, either. Adding a 'bool *'
param to format_host() and format_host_r() indicating that name
resolution has happened might help here.
Cheers, Phil
By adding a check in the if statement on the global variable
$resolve_hosts the resolved hostnames will not enclosed with brackets.
This updated patch adds support for RFC2732 IPv6 address format with
brackets for the tool ss. Resolved hostnames will not be enclosed in
brackets, therefore the global variable resolve_hosts is initialized and
checked.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
From: Phil Sutter <phil@nwl.cc> Date: 2017-07-31 20:27:43
On Mon, Jul 31, 2017 at 09:50:04PM +0200, Florian Lehner wrote:
quoted hunk
This updated patch adds support for RFC2732 IPv6 address format with
brackets for the tool ss. Resolved hostnames will not be enclosed in
brackets, therefore the global variable resolve_hosts is initialized and
checked.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
This updated patch adds support for RFC2732 IPv6 address format with
brackets for the tool ss.
It implements the suggestion by Phil Sutter to use a further value,
whether an address was resolved to a hostname.
Signed-off-by: Lehner Florian <redacted>
---
include/utils.h | 10 +++++++---
lib/utils.c | 11 +++++++----
misc/ss.c | 20 +++++++++++++++-----
3 files changed, 29 insertions(+), 12 deletions(-)
int len, int af)
}
#endif
-const char *format_host_r(int af, int len, const void *addr,
- char *buf, int buflen)
+const char *format_host_rb(int af, int len, const void *addr,
+ char *buf, int buflen, bool *resolved)
{
#ifdef RESOLVE_HOSTNAMES
if (resolve_hosts) {
@@ -909,17 +909,20 @@ const char *format_host_r(int af, int len, const
From: David Laight <hidden> Date: 2017-08-01 11:11:09
From: Florian Lehner
quoted hunk
Sent: 29 July 2017 13:29
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
int port, unsigned int ifindex
ap = format_host(AF_INET, 4, a->data);
}
} else {
- ap = format_host(a->family, 16, a->data);
+ if (a->family == AF_INET6) {
+ sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+ } else {
+ ap = format_host(a->family, 16, a->data);
+ }
est_len = strlen(ap);
...
There are some strange things going on with global variables if this works at all.
The text form of the address is in buf[] in one path and *ap in the other.
One option might be to call format_host() then use strchr(ap, ':')
to add [] if the string contains any ':'.
David
int len, int af)
}
#endif
-const char *format_host_r(int af, int len, const void *addr,
- char *buf, int buflen)
+const char *format_host_rb(int af, int len, const void *addr,
+ char *buf, int buflen, bool *resolved)
{
#ifdef RESOLVE_HOSTNAMES
if (resolve_hosts) {
@@ -909,17 +909,20 @@ const char *format_host_r(int af, int len, const
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2017-08-01 14:41:50
On Tue, 1 Aug 2017 11:11:03 +0000
David Laight [off-list ref] wrote:
From: Florian Lehner
quoted
Sent: 29 July 2017 13:29
This patch adds support for RFC2732 IPv6 address format with brackets
for the tool ss. So output for ss changes from
2a00:1450:400a:804::200e:443 to [2a00:1450:400a:804::200e]:443 for IPv6
addresses with attached port number.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
int port, unsigned int ifindex
ap = format_host(AF_INET, 4, a->data);
}
} else {
- ap = format_host(a->family, 16, a->data);
+ if (a->family == AF_INET6) {
+ sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
+ } else {
+ ap = format_host(a->family, 16, a->data);
+ }
est_len = strlen(ap);
...
There are some strange things going on with global variables if this works at all.
The text form of the address is in buf[] in one path and *ap in the other.
One option might be to call format_host() then use strchr(ap, ':')
to add [] if the string contains any ':'.
David
That sounds like a better solution.
Also what about IN6ADDR_ANY
int len, int af)
}
#endif
-const char *format_host_r(int af, int len, const void *addr,
- char *buf, int buflen)
+const char *format_host_rb(int af, int len, const void *addr,
+ char *buf, int buflen, bool *resolved)
{
#ifdef RESOLVE_HOSTNAMES
if (resolve_hosts) {
@@ -909,17 +909,20 @@ const char *format_host_r(int af, int len, const
This updated patch adds support for RFC2732 IPv6 address format with
brackets for the tool ss.
Following the advice by David Laight I used strchr().
Also, IN6ADDR_ANY and INADDR_ANY will return "*".
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
This updated patch adds support for RFC2732 IPv6 address format with
brackets for the tool ss.
Now checking the complete IPv6 address if it is IN6ADDR_ANY.
Signed-off-by: Lehner Florian <redacted>
---
misc/ss.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Your email client is wrapping long lines which leads to malformed patch.
You didn't need buf2, and the code was more complex than it needed to be.
Rather than waiting for yet another version, I just merged in similar
code.
Your email client is wrapping long lines which leads to malformed patch.
You didn't need buf2, and the code was more complex than it needed to be.
Rather than waiting for yet another version, I just merged in similar
code.
Also, is this new format accepted for the filter ?
ss src [::1]:22
Your email client is wrapping long lines which leads to malformed patch.
You didn't need buf2, and the code was more complex than it needed to be.
Rather than waiting for yet another version, I just merged in similar
code.
Also, is this new format accepted for the filter ?
ss src [::1]:22
It looks like ss would always do that (from earliest git version).