ipip: populate mode in tunnel details 39/39239/1
authorMatthew Smith <mgsmith@netgate.com>
Fri, 14 Jul 2023 16:05:39 +0000 (16:05 +0000)
committerMatthew Smith <mgsmith@netgate.com>
Fri, 14 Jul 2023 17:42:26 +0000 (17:42 +0000)
Type: improvement

There is a mode field in ipip_tunnel_details. The handler for the dump
API does not do anything to populate it so it always contains 0
(TUNNEL_API_MODE_P2P). This is correct for p2p tunnels but is wrong for
multipoint tunnels.

Populate the field with the correct mode.

Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Change-Id: I6c1288a0d3929db0f67100748b5760c36b594f97

src/vnet/ipip/ipip_api.c

index 50b6731..59ff282 100644 (file)
@@ -105,6 +105,22 @@ vl_api_ipip_del_tunnel_t_handler (vl_api_ipip_del_tunnel_t * mp)
   REPLY_MACRO (VL_API_IPIP_DEL_TUNNEL_REPLY);
 }
 
+static vl_api_tunnel_mode_t
+ipip_tunnel_mode_encode (ipip_mode_t mode)
+{
+  switch (mode)
+    {
+    case IPIP_MODE_P2P:
+      return TUNNEL_API_MODE_P2P;
+    case IPIP_MODE_P2MP:
+      return TUNNEL_API_MODE_MP;
+    case IPIP_MODE_6RD:
+      return TUNNEL_API_MODE_P2P;
+    default:
+      return TUNNEL_API_MODE_P2P;
+    }
+}
+
 static void
 send_ipip_tunnel_details (ipip_tunnel_t * t, vl_api_ipip_tunnel_dump_t * mp)
 {
@@ -113,8 +129,8 @@ send_ipip_tunnel_details (ipip_tunnel_t * t, vl_api_ipip_tunnel_dump_t * mp)
   bool is_ipv6 = t->transport == IPIP_TRANSPORT_IP6 ? true : false;
   fib_table_t *ft;
 
-  ft = fib_table_get (t->fib_index, (is_ipv6 ? FIB_PROTOCOL_IP6 :
-                                    FIB_PROTOCOL_IP4));
+  ft = fib_table_get (t->fib_index,
+                     (is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4));
 
   /* *INDENT-OFF* */
   REPLY_MACRO_DETAILS2(VL_API_IPIP_TUNNEL_DETAILS,
@@ -126,6 +142,7 @@ send_ipip_tunnel_details (ipip_tunnel_t * t, vl_api_ipip_tunnel_dump_t * mp)
     rmp->tunnel.sw_if_index = htonl (t->sw_if_index);
     rmp->tunnel.dscp = ip_dscp_encode(t->dscp);
     rmp->tunnel.flags = tunnel_encap_decap_flags_encode(t->flags);
+    rmp->tunnel.mode = ipip_tunnel_mode_encode (t->mode);
   }));
     /* *INDENT-ON* */
 }