]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/tunnel.c
Merge branch 'master' into next
[mirror_iproute2.git] / ip / tunnel.c
index 20fe6d7d72f10f34a1368f80becbfa91773e7d04..88585cf3177b598dd11fd1bf2d712f004eb068af 100644 (file)
@@ -308,6 +308,51 @@ void tnl_print_endpoint(const char *name, const struct rtattr *rta, int family)
        }
 }
 
+void tnl_print_gre_flags(__u8 proto,
+                        __be16 i_flags, __be16 o_flags,
+                        __be32 i_key, __be32 o_key)
+{
+       if ((i_flags & GRE_KEY) && (o_flags & GRE_KEY) &&
+           o_key == i_key) {
+               print_uint(PRINT_ANY, "key", " key %u", ntohl(i_key));
+       } else {
+               if (i_flags & GRE_KEY)
+                       print_uint(PRINT_ANY, "ikey", " ikey %u", ntohl(i_key));
+               if (o_flags & GRE_KEY)
+                       print_uint(PRINT_ANY, "okey", " okey %u", ntohl(o_key));
+       }
+
+       if (proto != IPPROTO_GRE)
+               return;
+
+       open_json_array(PRINT_JSON, "flags");
+       if (i_flags & GRE_SEQ) {
+               if (is_json_context())
+                       print_string(PRINT_JSON, NULL, "%s", "rx_drop_ooseq");
+               else
+                       printf("%s  Drop packets out of sequence.", _SL_);
+       }
+       if (i_flags & GRE_CSUM) {
+               if (is_json_context())
+                       print_string(PRINT_JSON, NULL, "%s", "rx_csum");
+               else
+                       printf("%s  Checksum in received packet is required.", _SL_);
+       }
+       if (o_flags & GRE_SEQ) {
+               if (is_json_context())
+                       print_string(PRINT_JSON, NULL, "%s", "tx_seq");
+               else
+                       printf("%s  Sequence packets on output.", _SL_);
+       }
+       if (o_flags & GRE_CSUM) {
+               if (is_json_context())
+                       print_string(PRINT_JSON, NULL, "%s", "tx_csum");
+               else
+                       printf("%s  Checksum output packets.", _SL_);
+       }
+       close_json_array(PRINT_JSON, NULL);
+}
+
 static void tnl_print_stats(const struct rtnl_link_stats64 *s)
 {
        printf("%s", _SL_);
@@ -321,8 +366,7 @@ static void tnl_print_stats(const struct rtnl_link_stats64 *s)
               s->tx_carrier_errors, s->tx_dropped);
 }
 
-static int print_nlmsg_tunnel(const struct sockaddr_nl *who,
-                             struct nlmsghdr *n, void *arg)
+static int print_nlmsg_tunnel(struct nlmsghdr *n, void *arg)
 {
        struct tnl_print_nlmsg_info *info = arg;
        struct ifinfomsg *ifi = NLMSG_DATA(n);
@@ -392,6 +436,7 @@ static int print_nlmsg_tunnel(const struct sockaddr_nl *who,
 
 int do_tunnels_list(struct tnl_print_nlmsg_info *info)
 {
+       new_json_obj(json);
        if (rtnl_linkdump_req(&rth, preferred_family) < 0) {
                perror("Cannot send dump request\n");
                return -1;
@@ -401,6 +446,7 @@ int do_tunnels_list(struct tnl_print_nlmsg_info *info)
                fprintf(stderr, "Dump terminated\n");
                return -1;
        }
+       delete_json_obj();
 
        return 0;
 }