Update of free text tag patch for BD 24/8424/4
authorJerome Tollet <jtollet@cisco.com>
Thu, 14 Sep 2017 11:53:56 +0000 (12:53 +0100)
committerJohn Lo <loj@cisco.com>
Fri, 15 Sep 2017 10:46:31 +0000 (10:46 +0000)
Change-Id: Ia886ff2bfa2cf33ffbaa35ec89494d4300ec2769
Signed-off-by: Jerome Tollet <jtollet@cisco.com>
src/vat/api_format.c
src/vnet/l2/l2.api
src/vnet/l2/l2_bd.c
src/vnet/l2/l2_bd.h
src/vpp/api/custom_dump.c

index 43d1eb3..ff3354c 100644 (file)
@@ -6356,6 +6356,7 @@ api_bridge_domain_add_del (vat_main_t * vam)
   u32 bd_id = ~0;
   u8 is_add = 1;
   u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
+  u8 *bd_tag = NULL;
   u32 mac_age = 0;
   int ret;
 
@@ -6376,6 +6377,8 @@ api_bridge_domain_add_del (vat_main_t * vam)
        ;
       else if (unformat (i, "mac-age %d", &mac_age))
        ;
+      else if (unformat (i, "bd-tag %s", &bd_tag))
+       ;
       else if (unformat (i, "del"))
        {
          is_add = 0;
@@ -6388,13 +6391,22 @@ api_bridge_domain_add_del (vat_main_t * vam)
   if (bd_id == ~0)
     {
       errmsg ("missing bridge domain");
-      return -99;
+      ret = -99;
+      goto done;
     }
 
   if (mac_age > 255)
     {
       errmsg ("mac age must be less than 256 ");
-      return -99;
+      ret = -99;
+      goto done;
+    }
+
+  if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
+    {
+      errmsg ("bd-tag cannot be longer than 63");
+      ret = -99;
+      goto done;
     }
 
   M (BRIDGE_DOMAIN_ADD_DEL, mp);
@@ -6407,9 +6419,14 @@ api_bridge_domain_add_del (vat_main_t * vam)
   mp->arp_term = arp_term;
   mp->is_add = is_add;
   mp->mac_age = (u8) mac_age;
+  if (bd_tag)
+    strcpy ((char *) mp->bd_tag, (char *) bd_tag);
 
   S (mp);
   W (ret);
+
+done:
+  vec_free (bd_tag);
   return ret;
 }
 
@@ -20152,7 +20169,7 @@ _(sw_interface_set_l2_bridge,                                           \
   "enable | disable")                                                   \
 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255")  \
 _(bridge_domain_add_del,                                                \
-  "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [del]\n") \
+  "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [bd-tag <tag>] [del]\n") \
 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n")                   \
 _(l2fib_add_del,                                                        \
   "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
index baf830f..ac923de 100644 (file)
@@ -285,6 +285,7 @@ typeonly manual_print manual_endian define bridge_domain_sw_if
     @param learn - learning state on all interfaces in the bd
     @param arp_term - arp termination state on all interfaces in the bd
     @param mac_age - mac aging time in min, 0 for disabled
+    @param bd_tag - optional textual tag for the bridge domain
     @param n_sw_ifs - number of sw_if_index's in the domain
 */
 manual_print manual_endian define bridge_domain_details
index 3670a4f..b1abb4c 100644 (file)
@@ -291,8 +291,11 @@ bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age)
                             L2_MAC_AGE_PROCESS_EVENT_STOP, 0);
 }
 
+/**
+    Set the tag for the bridge domain.
+*/
 
-void
+static void
 bd_set_bd_tag (vlib_main_t * vm, u32 bd_index, u8 * bd_tag)
 {
   u8 *old;
@@ -1191,8 +1194,8 @@ bd_add_del (l2_bridge_domain_add_del_args_t * a)
 /**
    Create or delete bridge-domain.
    The CLI format:
-   create bridge-domain <bd_index> [learn <0|1>] [forward <0|1>] [uu-flood <0|1>]
-                                   [flood <0|1>] [arp-term <0|1>] [mac-age <nn>] [del]
+   create bridge-domain <bd_index> [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>]
+                                       [arp-term <0|1>] [mac-age <nn>] [bd-tag <tag>] [del]
 */
 
 static clib_error_t *
index e60f1ab..fd34ae6 100644 (file)
@@ -134,7 +134,6 @@ u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index);
 
 u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable);
 void bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age);
-void bd_set_bd_tag (vlib_main_t * vm, u32 bd_index, u8 * bd_tag);
 int bd_add_del (l2_bridge_domain_add_del_args_t * args);
 
 /**
index be74b83..2e1f980 100644 (file)
@@ -279,6 +279,8 @@ static void *vl_api_bridge_domain_add_del_t_print
 
   if (mp->is_add)
     {
+      if (mp->bd_tag[0])
+       s = format (s, "bd_tag %s ", mp->bd_tag);
       s = format (s, "flood %d uu-flood %d ", mp->flood, mp->uu_flood);
       s = format (s, "forward %d learn %d ", mp->forward, mp->learn);
       s = format (s, "arp-term %d mac-age %d", mp->arp_term, mp->mac_age);