vti/tunnel: Unify ikey/okey printing
For vti6 tunnel we print [io]key in dotted-quad notation (ipv4 address) while in vti we do that in hex format. For vti tunnel we print [io]key only if value is not zero while for vti6 we miss such check. Unify vti and vti6 tunnel [io]key output. While here enlarge s2 buffer to the same size as in rest of tunnel support code (64 bytes) and check return from inet_ntop(). Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
2a8d0f6e9c
commit
34a8c54d6d
|
|
@ -167,8 +167,7 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||||
{
|
{
|
||||||
const char *local = "any";
|
const char *local = "any";
|
||||||
const char *remote = "any";
|
const char *remote = "any";
|
||||||
__u32 key;
|
char s2[64];
|
||||||
char s2[IFNAMSIZ];
|
|
||||||
|
|
||||||
if (!tb)
|
if (!tb)
|
||||||
return;
|
return;
|
||||||
|
|
@ -200,14 +199,21 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[IFLA_VTI_IKEY] &&
|
if (tb[IFLA_VTI_IKEY]) {
|
||||||
(key = rta_getattr_u32(tb[IFLA_VTI_IKEY])))
|
struct rtattr *rta = tb[IFLA_VTI_IKEY];
|
||||||
print_0xhex(PRINT_ANY, "ikey", "ikey %#x ", ntohl(key));
|
__u32 key = rta_getattr_u32(rta);
|
||||||
|
|
||||||
|
if (key && inet_ntop(AF_INET, RTA_DATA(rta), s2, sizeof(s2)))
|
||||||
|
print_string(PRINT_ANY, "ikey", "ikey %s ", s2);
|
||||||
|
}
|
||||||
|
|
||||||
if (tb[IFLA_VTI_OKEY] &&
|
if (tb[IFLA_VTI_OKEY]) {
|
||||||
(key = rta_getattr_u32(tb[IFLA_VTI_OKEY])))
|
struct rtattr *rta = tb[IFLA_VTI_OKEY];
|
||||||
print_0xhex(PRINT_ANY, "okey", "okey %#x ", ntohl(key));
|
__u32 key = rta_getattr_u32(rta);
|
||||||
|
|
||||||
|
if (key && inet_ntop(AF_INET, RTA_DATA(rta), s2, sizeof(s2)))
|
||||||
|
print_string(PRINT_ANY, "okey", "okey %s ", s2);
|
||||||
|
}
|
||||||
|
|
||||||
if (tb[IFLA_VTI_FWMARK]) {
|
if (tb[IFLA_VTI_FWMARK]) {
|
||||||
__u32 fwmark = rta_getattr_u32(tb[IFLA_VTI_FWMARK]);
|
__u32 fwmark = rta_getattr_u32(tb[IFLA_VTI_FWMARK]);
|
||||||
|
|
|
||||||
|
|
@ -199,13 +199,19 @@ static void vti6_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[IFLA_VTI_IKEY]) {
|
if (tb[IFLA_VTI_IKEY]) {
|
||||||
inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2, sizeof(s2));
|
struct rtattr *rta = tb[IFLA_VTI_IKEY];
|
||||||
print_string(PRINT_ANY, "ikey", "ikey %s ", s2);
|
__u32 key = rta_getattr_u32(rta);
|
||||||
|
|
||||||
|
if (key && inet_ntop(AF_INET, RTA_DATA(rta), s2, sizeof(s2)))
|
||||||
|
print_string(PRINT_ANY, "ikey", "ikey %s ", s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[IFLA_VTI_OKEY]) {
|
if (tb[IFLA_VTI_OKEY]) {
|
||||||
inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2, sizeof(s2));
|
struct rtattr *rta = tb[IFLA_VTI_OKEY];
|
||||||
print_string(PRINT_ANY, "okey", "okey %s ", s2);
|
__u32 key = rta_getattr_u32(rta);
|
||||||
|
|
||||||
|
if (key && inet_ntop(AF_INET, RTA_DATA(rta), s2, sizeof(s2)))
|
||||||
|
print_string(PRINT_ANY, "okey", "okey %s ", s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tb[IFLA_VTI_FWMARK]) {
|
if (tb[IFLA_VTI_FWMARK]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue