]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
link_iptnl: Print tunnel mode
authorSerhey Popovych <serhe.popovych@gmail.com>
Tue, 2 Jan 2018 21:27:58 +0000 (23:27 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Sat, 6 Jan 2018 00:35:47 +0000 (16:35 -0800)
Tunnel mode does not appear in parameters print for iptnl
supported tunnels like ipip and sit, while printed for
ip6tnl.

Print tunnel mode as "proto" field name for JSON and
without any name when printing to cli to follow ip6tnl
behaviour.

For non JSON output we have:

   $ ip -d link show dev sit1

Before:
-------
17: sit1@NONE: <NOARP> mtu 1480 qdisc noop state DOWN ...
    link/sit X.X.X.X brd 0.0.0.0 promiscuity 0
    sit remote any local X.X.X.X ...
        ~~~

After:
------
17: sit1@NONE: <NOARP> mtu 1480 qdisc noop state DOWN ...
    link/sit X.X.X.X brd 0.0.0.0 promiscuity 0
    sit any remote any local X.X.X.X ...
        ^^^

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
ip/link_iptnl.c

index d4d935bbb5221824ccd51587ae9021aa903bc95c..b6ef95df2ec0f07d8d2f1e39297295ab75507a0f 100644 (file)
@@ -372,6 +372,23 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
        if (tb[IFLA_IPTUN_COLLECT_METADATA])
                print_bool(PRINT_ANY, "external", "external ", true);
 
+       if (tb[IFLA_IPTUN_PROTO]) {
+               switch (rta_getattr_u8(tb[IFLA_IPTUN_PROTO])) {
+               case IPPROTO_IPIP:
+                       print_string(PRINT_ANY, "proto", "%s ", "ipip");
+                       break;
+               case IPPROTO_IPV6:
+                       print_string(PRINT_ANY, "proto", "%s ", "ip6ip");
+                       break;
+               case IPPROTO_MPLS:
+                       print_string(PRINT_ANY, "proto", "%s ", "mplsip");
+                       break;
+               case 0:
+                       print_string(PRINT_ANY, "proto", "%s ", "any");
+                       break;
+               }
+       }
+
        if (tb[IFLA_IPTUN_REMOTE]) {
                unsigned int addr = rta_getattr_u32(tb[IFLA_IPTUN_REMOTE]);