MFIB; CLI improvements 57/16357/2
authorNeale Ranns <nranns@cisco.com>
Wed, 5 Dec 2018 16:39:45 +0000 (16:39 +0000)
committerNeale Ranns <nranns@cisco.com>
Thu, 6 Dec 2018 13:49:59 +0000 (13:49 +0000)
Change-Id: I7cf3ae8c10dd584e8bc234a3253bea3c5a2d105a
Signed-off-by: Neale Ranns <nranns@cisco.com>
src/vnet/ip/lookup.c
src/vnet/mfib/mfib_types.c

index 9986a70..2a9b3fe 100644 (file)
@@ -814,6 +814,7 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
   mfib_entry_flags_t eflags = 0;
   u32 gcount, scount, ss, gg, incr;
   f64 timet[2];
+  u32 rpf_id = MFIB_RPF_ID_NONE;
 
   gcount = scount = 1;
   vnm = vnet_get_main ();
@@ -835,6 +836,8 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
        is_del = 1;
       else if (unformat (line_input, "add"))
        is_del = 0;
+      else if (unformat (line_input, "rpf-id %d", &rpf_id))
+       ;
       else if (unformat (line_input, "scount %d", &scount))
        ;
       else if (unformat (line_input, "gcount %d", &gcount))
@@ -883,6 +886,30 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
          pfx.fp_proto = FIB_PROTOCOL_IP6;
          pfx.fp_len = 128;
        }
+      else if (unformat (line_input, "via %U %U %U",
+                        unformat_ip4_address, &rpath.frp_addr.ip4,
+                        unformat_vnet_sw_interface, vnm,
+                        &rpath.frp_sw_if_index,
+                        unformat_mfib_itf_flags, &iflags))
+       {
+         rpath.frp_weight = 1;
+       }
+      else if (unformat (line_input, "via %U %U %U",
+                        unformat_ip6_address, &rpath.frp_addr.ip6,
+                        unformat_vnet_sw_interface, vnm,
+                        &rpath.frp_sw_if_index,
+                        unformat_mfib_itf_flags, &iflags))
+       {
+         rpath.frp_weight = 1;
+       }
+      else if (unformat (line_input, "via %U %U",
+                        unformat_vnet_sw_interface, vnm,
+                        &rpath.frp_sw_if_index,
+                        unformat_mfib_itf_flags, &iflags))
+       {
+         clib_memset (&rpath.frp_addr, 0, sizeof (rpath.frp_addr));
+         rpath.frp_weight = 1;
+       }
       else if (unformat (line_input, "via %U %U",
                         unformat_ip4_address, &rpath.frp_addr.ip4,
                         unformat_vnet_sw_interface, vnm,
@@ -904,7 +931,7 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
          clib_memset (&rpath.frp_addr, 0, sizeof (rpath.frp_addr));
          rpath.frp_weight = 1;
        }
-      else if (unformat (line_input, "via local"))
+      else if (unformat (line_input, "via local Forward"))
        {
          clib_memset (&rpath.frp_addr, 0, sizeof (rpath.frp_addr));
          rpath.frp_sw_if_index = ~0;
@@ -914,9 +941,8 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
           * set the path proto appropriately for the prefix
           */
          rpath.frp_proto = fib_proto_to_dpo (pfx.fp_proto);
+         iflags = MFIB_ITF_FLAG_FORWARD;
        }
-      else if (unformat (line_input, "%U", unformat_mfib_itf_flags, &iflags))
-       ;
       else if (unformat (line_input, "%U",
                         unformat_mfib_entry_flags, &eflags))
        ;
@@ -965,10 +991,10 @@ vnet_ip_mroute_cmd (vlib_main_t * vm,
              /* no path provided => route delete */
              mfib_table_entry_delete (fib_index, &pfx, MFIB_SOURCE_CLI);
            }
-         else if (eflags)
+         else if (eflags || (MFIB_RPF_ID_NONE != rpf_id))
            {
              mfib_table_entry_update (fib_index, &pfx, MFIB_SOURCE_CLI,
-                                      MFIB_RPF_ID_NONE, eflags);
+                                      rpf_id, eflags);
            }
          else
            {
@@ -1053,7 +1079,7 @@ done:
 VLIB_CLI_COMMAND (ip_mroute_command, static) =
 {
   .path = "ip mroute",
-  .short_help = "ip mroute [add|del] <dst-ip-addr>/<width> [table <table-id>] [via <next-hop-ip-addr> [<interface>],",
+  .short_help = "ip mroute [add|del] <dst-ip-addr>/<width> [table <table-id>] [rpf-id <ID>] [via <next-hop-ip-addr> [<interface>],",
   .function = vnet_ip_mroute_cmd,
   .is_mp_safe = 1,
 };
index 8452d86..a3ed46a 100644 (file)
@@ -93,7 +93,7 @@ format_mfib_entry_flags (u8 * s, va_list * args)
         s = format(s, " flags:");
         FOR_EACH_MFIB_ATTRIBUTE(attr) {
             if ((1<<attr) & flags) {
-                s = format (s, "%s,", mfib_flag_names[attr]);
+                s = format (s, "%s,", mfib_flag_names_long[attr]);
             }
         }
     }
@@ -146,6 +146,10 @@ unformat_mfib_entry_flags (unformat_input_t * input,
     mfib_entry_attribute_t attr;
 
     old = *eflags;
+    FOR_EACH_MFIB_ATTRIBUTE(attr) {
+        if (unformat (input, mfib_flag_names_long[attr]))
+            *eflags |= (1 << attr);
+    }
     FOR_EACH_MFIB_ATTRIBUTE(attr) {
         if (unformat (input, mfib_flag_names[attr]))
             *eflags |= (1 << attr);