summaryrefslogtreecommitdiffstats
path: root/src/vnet/l2/l2_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/l2/l2_api.c')
-rw-r--r--src/vnet/l2/l2_api.c94
1 files changed, 75 insertions, 19 deletions
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 97b429d0498..85e9c31e2fb 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -58,7 +58,9 @@
_ (L2FIB_FLUSH_INT, l2fib_flush_int) \
_ (L2FIB_FLUSH_BD, l2fib_flush_bd) \
_ (L2FIB_ADD_DEL, l2fib_add_del) \
+ _ (L2FIB_SET_SCAN_DELAY, l2fib_set_scan_delay) \
_ (WANT_L2_MACS_EVENTS, want_l2_macs_events) \
+ _ (WANT_L2_MACS_EVENTS2, want_l2_macs_events2) \
_ (L2_FLAGS, l2_flags) \
_ (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
_ (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
@@ -262,22 +264,18 @@ vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp)
}
static void
-vl_api_want_l2_macs_events_t_handler (vl_api_want_l2_macs_events_t * mp)
+vl_api_want_l2_macs_events2_t_handler (vl_api_want_l2_macs_events2_t *mp)
{
int rv = 0;
- vl_api_want_l2_macs_events_reply_t *rmp;
+ vl_api_want_l2_macs_events2_reply_t *rmp;
l2learn_main_t *lm = &l2learn_main;
l2fib_main_t *fm = &l2fib_main;
u32 pid = ntohl (mp->pid);
- u32 learn_limit = ntohl (mp->learn_limit);
if (mp->enable_disable)
{
- if (lm->client_pid == 0)
+ if ((lm->client_pid == 0) || (lm->client_pid == pid))
{
- lm->client_pid = pid;
- lm->client_index = mp->client_index;
-
if (mp->max_macs_in_event)
fm->max_macs_in_event = mp->max_macs_in_event * 10;
else
@@ -286,23 +284,58 @@ vl_api_want_l2_macs_events_t_handler (vl_api_want_l2_macs_events_t * mp)
goto exit;
}
- if (mp->scan_delay)
- fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
- else
- {
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto exit;
- }
+ /* if scan_delay was not set before */
+ if (fm->event_scan_delay == 0.0)
+ fm->event_scan_delay = (f64) (10) * 10e-3;
- /* change learn limit and flush all learned MACs */
- if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
- lm->global_learn_limit = learn_limit;
- else
+ lm->client_pid = pid;
+ lm->client_index = mp->client_index;
+ l2fib_flush_all_mac (vlib_get_main ());
+ }
+ else if (lm->client_pid != pid)
+ {
+ rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
+ goto exit;
+ }
+ }
+ else if (lm->client_pid)
+ {
+ lm->client_pid = 0;
+ lm->client_index = 0;
+ }
+
+exit:
+ REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS2_REPLY);
+}
+
+static void
+vl_api_want_l2_macs_events_t_handler (vl_api_want_l2_macs_events_t *mp)
+{
+ int rv = 0;
+ vl_api_want_l2_macs_events_reply_t *rmp;
+ l2learn_main_t *lm = &l2learn_main;
+ l2fib_main_t *fm = &l2fib_main;
+ u32 pid = ntohl (mp->pid);
+ u32 learn_limit = ntohl (mp->learn_limit);
+
+ if (mp->enable_disable)
+ {
+ if ((lm->client_pid == 0) || (lm->client_pid == pid))
+ {
+ if ((mp->max_macs_in_event == 0) || (mp->scan_delay == 0) ||
+ (learn_limit == 0) || (learn_limit > L2LEARN_DEFAULT_LIMIT))
{
rv = VNET_API_ERROR_INVALID_VALUE;
goto exit;
}
+ lm->client_pid = pid;
+ lm->client_index = mp->client_index;
+ fm->max_macs_in_event = mp->max_macs_in_event * 10;
+ fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
+
+ /* change learn limit and flush all learned MACs */
+ lm->global_learn_limit = learn_limit;
l2fib_flush_all_mac (vlib_get_main ());
}
else if (lm->client_pid != pid)
@@ -315,7 +348,7 @@ vl_api_want_l2_macs_events_t_handler (vl_api_want_l2_macs_events_t * mp)
{
lm->client_pid = 0;
lm->client_index = 0;
- if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
+ if (learn_limit && (learn_limit <= L2LEARN_DEFAULT_LIMIT))
lm->global_learn_limit = learn_limit;
else
lm->global_learn_limit = L2LEARN_DEFAULT_LIMIT;
@@ -372,6 +405,29 @@ out:
}
static void
+vl_api_l2fib_set_scan_delay_t_handler (vl_api_l2fib_set_scan_delay_t *mp)
+{
+ int rv = 0;
+ l2fib_main_t *fm = &l2fib_main;
+ vl_api_l2fib_set_scan_delay_reply_t *rmp;
+ u16 scan_delay = ntohs (mp->scan_delay);
+
+ if (mp->scan_delay)
+ {
+ fm->event_scan_delay = (f64) (scan_delay) *10e-3;
+ l2fib_flush_all_mac (vlib_get_main ());
+ }
+ else
+ {
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto exit;
+ }
+
+exit:
+ REPLY_MACRO (VL_API_L2FIB_SET_SCAN_DELAY_REPLY);
+}
+
+static void
vl_api_l2_flags_t_handler (vl_api_l2_flags_t * mp)
{
vl_api_l2_flags_reply_t *rmp;