aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorEyal Bari <ebari@cisco.com>2017-04-04 04:46:32 +0300
committerJohn Lo <loj@cisco.com>2017-04-04 19:00:37 +0000
commitfead670ae0a8323d8cd14e2cfad1fb8c25a48a99 (patch)
tree7e541e98aeee7dee5c7dbd36550ea54896c8a1f6 /src/vnet
parenta8ed6bd9ded4cbfff01f49571272e59def9f4010 (diff)
BD/API:add bridge_domain_set_mac_age api
Change-Id: Ic2d33b31ba88f6d9602a22439865637d98cf4a33 Signed-off-by: Eyal Bari <ebari@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/l2/l2.api24
-rw-r--r--src/vnet/l2/l2_api.c33
-rw-r--r--src/vnet/l2/l2_bd.c3
-rw-r--r--src/vnet/l2/l2_input.h5
4 files changed, 55 insertions, 10 deletions
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index 061990c0265..81b75858bce 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -146,6 +146,30 @@ define l2_flags_reply
u32 resulting_feature_bitmap;
};
+/** \brief L2 bridge domain set mac age
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param bd_id - the bridge domain to create
+ @param mac_age - mac aging time in min, 0 for disabled
+*/
+define bridge_domain_set_mac_age
+{
+ u32 client_index;
+ u32 context;
+ u32 bd_id;
+ u8 mac_age;
+};
+
+/** \brief Set bridge domain response
+ @param context - sender context, to match reply w/ request
+ @param retval - return code for the set l2 bits request
+*/
+define bridge_domain_set_mac_age_reply
+{
+ u32 context;
+ i32 retval;
+};
+
/** \brief L2 bridge domain add or delete request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index a985852cec8..ffcc790134e 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -54,7 +54,8 @@ _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
_(BRIDGE_FLAGS, bridge_flags) \
_(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
-_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)
+_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
+_(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age)
static void
send_l2_xconnect_details (unix_shared_memory_queue_t * q, u32 context,
@@ -244,17 +245,13 @@ vl_api_l2_flags_t_handler (vl_api_l2_flags_t * mp)
{
vl_api_l2_flags_reply_t *rmp;
int rv = 0;
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 flags = ntohl (mp->feature_bitmap);
u32 rbm = 0;
VALIDATE_SW_IF_INDEX (mp);
-#define _(a,b) \
- if (flags & L2INPUT_FEAT_ ## a) \
- rbm = l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_ ## a, mp->is_set);
- foreach_l2input_feat;
-#undef _
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 flags = ntohl (mp->feature_bitmap) & L2INPUT_VALID_MASK;
+ rbm = l2input_intf_bitmap_enable (sw_if_index, flags, mp->is_set);
BAD_SW_IF_INDEX_LABEL;
@@ -267,6 +264,26 @@ vl_api_l2_flags_t_handler (vl_api_l2_flags_t * mp)
}
static void
+vl_api_bridge_domain_set_mac_age_t_handler (vl_api_bridge_domain_set_mac_age_t
+ * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ bd_main_t *bdm = &bd_main;
+ vl_api_bridge_domain_set_mac_age_reply_t *rmp;
+ int rv = 0;
+ u32 bd_id = ntohl (mp->bd_id);
+ uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
+ if (p == 0)
+ {
+ rv = VNET_API_ERROR_NO_SUCH_ENTRY;
+ goto out;
+ }
+ bd_set_mac_age (vm, *p, mp->mac_age);
+out:
+ REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
+}
+
+static void
vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
diff --git a/src/vnet/l2/l2_bd.c b/src/vnet/l2/l2_bd.c
index 0375998c990..a222fec9b81 100644
--- a/src/vnet/l2/l2_bd.c
+++ b/src/vnet/l2/l2_bd.c
@@ -284,8 +284,7 @@ bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age)
/* check if there is at least one bd with mac aging enabled */
vec_foreach (bd_config, l2input_main.bd_configs)
- if (bd_config->bd_id != ~0 && bd_config->mac_age != 0)
- enable = 1;
+ enable |= bd_config->bd_id != ~0 && bd_config->mac_age != 0;
vlib_process_signal_event (vm, l2fib_mac_age_scanner_process_node.index,
enable ? L2_MAC_AGE_PROCESS_EVENT_START :
diff --git a/src/vnet/l2/l2_input.h b/src/vnet/l2/l2_input.h
index 262f75c7e64..a2ade8d8e1e 100644
--- a/src/vnet/l2/l2_input.h
+++ b/src/vnet/l2/l2_input.h
@@ -117,6 +117,11 @@ typedef enum
foreach_l2input_feat
#undef _
L2INPUT_N_FEAT,
+ L2INPUT_VALID_MASK =
+#define _(sym,str) L2INPUT_FEAT_##sym##_BIT |
+ foreach_l2input_feat
+#undef _
+ 0,
} l2input_feat_t;
/* Feature bit masks */