* [PATCH] ip/link_vti*.c: Fix output for ikey/okey
@ 2017-08-07 9:59 Christian Langrock
2017-08-07 22:38 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Christian Langrock @ 2017-08-07 9:59 UTC (permalink / raw)
To: netdev
[-- Attachment #1.1.1: Type: text/plain, Size: 2367 bytes --]
ikey and okey are normal u32 values. There's no reason to print them as
IPv4/IPv6 addresses.
Signed-off-by: Christian Langrock <christian.langrock@secunet.com>
---
ip/link_vti.c | 10 ++++------
ip/link_vti6.c | 10 ++++------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/ip/link_vti.c b/ip/link_vti.c
index d5242ac..a694ec4 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -244,14 +244,12 @@ static void vti_print_opt(struct link_util *lu,
FILE *f, struct rtattr *tb[])
fprintf(f, "dev %u ", link);
}
- if (tb[IFLA_VTI_IKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2,
sizeof(s2));
- fprintf(f, "ikey %s ", s2);
+ if (tb[IFLA_VTI_IKEY] && rta_getattr_u32(tb[IFLA_VTI_IKEY])) {
+ fprintf(f, "ikey %u ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_IKEY])));
}
- if (tb[IFLA_VTI_OKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2,
sizeof(s2));
- fprintf(f, "okey %s ", s2);
+ if (tb[IFLA_VTI_OKEY] && rta_getattr_u32(tb[IFLA_VTI_OKEY])) {
+ fprintf(f, "okey %u ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_OKEY])));
}
if (tb[IFLA_VTI_FWMARK] && rta_getattr_u32(tb[IFLA_VTI_FWMARK])) {
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index 220b7df..6ae87dd 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -247,14 +247,12 @@ static void vti6_print_opt(struct link_util *lu,
FILE *f, struct rtattr *tb[])
fprintf(f, "dev %u ", link);
}
- if (tb[IFLA_VTI_IKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2,
sizeof(s2));
- fprintf(f, "ikey %s ", s2);
+ if (tb[IFLA_VTI_IKEY] && rta_getattr_u32(tb[IFLA_VTI_IKEY])) {
+ fprintf(f, "ikey %u ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_IKEY])));
}
- if (tb[IFLA_VTI_OKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2,
sizeof(s2));
- fprintf(f, "okey %s ", s2);
+ if (tb[IFLA_VTI_OKEY] && rta_getattr_u32(tb[IFLA_VTI_OKEY])) {
+ fprintf(f, "okey %u ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_OKEY])));
}
if (tb[IFLA_VTI_FWMARK] && rta_getattr_u32(tb[IFLA_VTI_FWMARK])) {
--
2.7.4
[-- Attachment #1.1.2: 0x82EB6B5E.asc --]
[-- Type: application/pgp-keys, Size: 1758 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ip/link_vti*.c: Fix output for ikey/okey
2017-08-07 9:59 [PATCH] ip/link_vti*.c: Fix output for ikey/okey Christian Langrock
@ 2017-08-07 22:38 ` Stephen Hemminger
2017-08-08 6:24 ` Christian Langrock
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2017-08-07 22:38 UTC (permalink / raw)
To: Christian Langrock; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 565 bytes --]
On Mon, 7 Aug 2017 11:59:28 +0200
Christian Langrock <christian.langrock@secunet.com> wrote:
> ikey and okey are normal u32 values. There's no reason to print them as
> IPv4/IPv6 addresses.
>
> Signed-off-by: Christian Langrock <christian.langrock@secunet.com>
Changing output format breaks scripts that parse output.
But on the other hand, the VTI code breaks the assumption that ip command
output should be the same as input.
More likely the original output format was done to match Cisco output.
Why not print in hex like fwmark?
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ip/link_vti*.c: Fix output for ikey/okey
2017-08-07 22:38 ` Stephen Hemminger
@ 2017-08-08 6:24 ` Christian Langrock
0 siblings, 0 replies; 3+ messages in thread
From: Christian Langrock @ 2017-08-08 6:24 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
[-- Attachment #1.1: Type: text/plain, Size: 3189 bytes --]
Using hex values sounds reasonable.
BR,
Christian
Updated Patch:
Subject: [PATCH] ip/link_vti*.c: Fix output for ikey/okey
ikey and okey are normal u32 values. There's no reason to print them as
IPv4/IPv6 addresses. Instead print them as hex values.
Signed-off-by: Christian Langrock <christian.langrock@secunet.com>
---
ip/link_vti.c | 10 ++++------
ip/link_vti6.c | 10 ++++------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/ip/link_vti.c b/ip/link_vti.c
index d5242ac..f87623b 100644
--- a/ip/link_vti.c
+++ b/ip/link_vti.c
@@ -244,14 +244,12 @@ static void vti_print_opt(struct link_util *lu,
FILE *f, struct rtattr *tb[])
fprintf(f, "dev %u ", link);
}
- if (tb[IFLA_VTI_IKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2,
sizeof(s2));
- fprintf(f, "ikey %s ", s2);
+ if (tb[IFLA_VTI_IKEY] && rta_getattr_u32(tb[IFLA_VTI_IKEY])) {
+ fprintf(f, "ikey 0x%x ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_IKEY])));
}
- if (tb[IFLA_VTI_OKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2,
sizeof(s2));
- fprintf(f, "okey %s ", s2);
+ if (tb[IFLA_VTI_OKEY] && rta_getattr_u32(tb[IFLA_VTI_OKEY])) {
+ fprintf(f, "okey 0x%x ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_OKEY])));
}
if (tb[IFLA_VTI_FWMARK] && rta_getattr_u32(tb[IFLA_VTI_FWMARK])) {
diff --git a/ip/link_vti6.c b/ip/link_vti6.c
index 220b7df..6ae87dd 100644
--- a/ip/link_vti6.c
+++ b/ip/link_vti6.c
@@ -247,14 +247,12 @@ static void vti6_print_opt(struct link_util *lu,
FILE *f, struct rtattr *tb[])
fprintf(f, "dev %u ", link);
}
- if (tb[IFLA_VTI_IKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2,
sizeof(s2));
- fprintf(f, "ikey %s ", s2);
+ if (tb[IFLA_VTI_IKEY] && rta_getattr_u32(tb[IFLA_VTI_IKEY])) {
+ fprintf(f, "ikey %u ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_IKEY])));
}
- if (tb[IFLA_VTI_OKEY]) {
- inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2,
sizeof(s2));
- fprintf(f, "okey %s ", s2);
+ if (tb[IFLA_VTI_OKEY] && rta_getattr_u32(tb[IFLA_VTI_OKEY])) {
+ fprintf(f, "okey %u ",
ntohl(rta_getattr_u32(tb[IFLA_VTI_OKEY])));
}
if (tb[IFLA_VTI_FWMARK] && rta_getattr_u32(tb[IFLA_VTI_FWMARK])) {
--
2.7.4
Am 08.08.2017 um 00:38 schrieb Stephen Hemminger:
> On Mon, 7 Aug 2017 11:59:28 +0200
> Christian Langrock <christian.langrock@secunet.com> wrote:
>
>> ikey and okey are normal u32 values. There's no reason to print them as
>> IPv4/IPv6 addresses.
>>
>> Signed-off-by: Christian Langrock <christian.langrock@secunet.com>
> Changing output format breaks scripts that parse output.
> But on the other hand, the VTI code breaks the assumption that ip command
> output should be the same as input.
>
> More likely the original output format was done to match Cisco output.
>
>
> Why not print in hex like fwmark?
>
>
>
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-08 6:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-07 9:59 [PATCH] ip/link_vti*.c: Fix output for ikey/okey Christian Langrock
2017-08-07 22:38 ` Stephen Hemminger
2017-08-08 6:24 ` Christian Langrock
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).