aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/linux-cp/lcp_interface.c46
-rw-r--r--src/plugins/linux-cp/lcp_interface.h10
2 files changed, 41 insertions, 15 deletions
diff --git a/src/plugins/linux-cp/lcp_interface.c b/src/plugins/linux-cp/lcp_interface.c
index e33c34b5f6a..5c4cd494232 100644
--- a/src/plugins/linux-cp/lcp_interface.c
+++ b/src/plugins/linux-cp/lcp_interface.c
@@ -60,6 +60,17 @@ static uword *lip_db_by_vif;
index_t *lip_db_by_phy;
u32 *lip_db_by_host;
+/**
+ * vector of virtual function table
+ */
+static lcp_itf_pair_vft_t *lcp_itf_vfts = NULL;
+
+void
+lcp_itf_pair_register_vft (lcp_itf_pair_vft_t *lcp_itf_vft)
+{
+ vec_add1 (lcp_itf_vfts, *lcp_itf_vft);
+}
+
#define LCP_ITF_PAIR_DBG(...) \
vlib_log_notice (lcp_itf_pair_logger, __VA_ARGS__);
@@ -216,12 +227,6 @@ lcp_itf_set_adjs (lcp_itf_pair_t *lip)
lip->lip_rewrite_len = adj->rewrite_header.data_bytes;
}
-int __clib_weak
-lcp_nl_drain_messages (void)
-{
- return 0;
-}
-
int
lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
u32 host_index, lip_host_type_t host_type, u8 *ns)
@@ -241,14 +246,6 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
return VNET_API_ERROR_VALUE_EXIST;
/*
- * Drain netlink messages before adding the new pair.
- * This avoids unnecessarily applying messages that were generated by
- * the creation of the tap/tun interface. By processing them before we
- * store the pair data, we will ensure that they are ignored.
- */
- lcp_nl_drain_messages ();
-
- /*
* Create a new pair.
*/
pool_get (lcp_itf_pair_pool, lip);
@@ -267,7 +264,6 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
lip->lip_host_type = host_type;
lip->lip_vif_index = host_index;
lip->lip_namespace = vec_dup (ns);
- lip->lip_create_ts = vlib_time_now (vlib_get_main ());
if (lip->lip_host_sw_if_index == ~0)
return 0;
@@ -323,6 +319,18 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
0);
}
+ /* invoke registered callbacks for pair addition */
+ lcp_itf_pair_vft_t *vft;
+
+ vec_foreach (vft, lcp_itf_vfts)
+ {
+ if (vft->pair_add_fn)
+ vft->pair_add_fn (lip);
+ }
+
+ /* set timestamp when pair entered service */
+ lip->lip_create_ts = vlib_time_now (vlib_get_main ());
+
return 0;
}
@@ -382,6 +390,7 @@ lcp_itf_pair_del (u32 phy_sw_if_index)
ip_address_family_t af;
lcp_itf_pair_t *lip;
u32 lipi;
+ lcp_itf_pair_vft_t *vft;
lipi = lcp_itf_pair_find_by_phy (phy_sw_if_index);
@@ -395,6 +404,13 @@ lcp_itf_pair_del (u32 phy_sw_if_index)
format_vnet_sw_if_index_name, vnet_get_main (),
lip->lip_host_sw_if_index, lip->lip_host_name);
+ /* invoke registered callbacks for pair deletion */
+ vec_foreach (vft, lcp_itf_vfts)
+ {
+ if (vft->pair_del_fn)
+ vft->pair_del_fn (lip);
+ }
+
FOR_EACH_IP_ADDRESS_FAMILY (af)
ip_feature_enable_disable (af, N_SAFI, IP_FEATURE_INPUT,
lcp_itf_l3_feat_names[lip->lip_host_type][af],
diff --git a/src/plugins/linux-cp/lcp_interface.h b/src/plugins/linux-cp/lcp_interface.h
index be566a07cb6..bed30248845 100644
--- a/src/plugins/linux-cp/lcp_interface.h
+++ b/src/plugins/linux-cp/lcp_interface.h
@@ -150,6 +150,16 @@ lcp_itf_pair_find_by_host (u32 host_sw_if_index)
void lcp_set_auto_intf (u8 is_auto);
int lcp_auto_intf (void);
+typedef void (*lcp_itf_pair_add_cb_t) (lcp_itf_pair_t *);
+typedef void (*lcp_itf_pair_del_cb_t) (lcp_itf_pair_t *);
+
+typedef struct lcp_itf_pair_vft
+{
+ lcp_itf_pair_add_cb_t pair_add_fn;
+ lcp_itf_pair_del_cb_t pair_del_fn;
+} lcp_itf_pair_vft_t;
+
+void lcp_itf_pair_register_vft (lcp_itf_pair_vft_t *lcp_itf_vft);
/*
* fd.io coding-style-patch-verification: ON
*