summaryrefslogtreecommitdiffstats
path: root/src/plugins/gbp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gbp')
-rw-r--r--src/plugins/gbp/gbp.api15
-rw-r--r--src/plugins/gbp/gbp_api.c35
-rw-r--r--src/plugins/gbp/gbp_api_print.h24
-rw-r--r--src/plugins/gbp/gbp_ext_itf.c66
-rw-r--r--src/plugins/gbp/gbp_ext_itf.h16
5 files changed, 49 insertions, 107 deletions
diff --git a/src/plugins/gbp/gbp.api b/src/plugins/gbp/gbp.api
index cf0564ccc9a..99be9c4f777 100644
--- a/src/plugins/gbp/gbp.api
+++ b/src/plugins/gbp/gbp.api
@@ -393,11 +393,18 @@ define gbp_vxlan_tunnel_details
vl_api_gbp_vxlan_tunnel_t tunnel;
};
+enum gbp_ext_itf_flags
+{
+ GBP_API_EXT_ITF_F_NONE = 0,
+ GBP_API_EXT_ITF_F_ANON = 1,
+};
+
typeonly define gbp_ext_itf
{
u32 sw_if_index;
u32 bd_id;
u32 rd_id;
+ vl_api_gbp_ext_itf_flags_t flags;
};
manual_print autoreply define gbp_ext_itf_add_del
@@ -420,14 +427,6 @@ define gbp_ext_itf_details
vl_api_gbp_ext_itf_t ext_itf;
};
-manual_print autoreply define gbp_ext_itf_anon_add_del
-{
- u32 client_index;
- u32 context;
- u8 is_add;
- vl_api_gbp_ext_itf_t ext_itf;
-};
-
/*
* Local Variables:
* eval: (c-set-style "gnu")
diff --git a/src/plugins/gbp/gbp_api.c b/src/plugins/gbp/gbp_api.c
index 3a3ce32c68d..fca85a79ce6 100644
--- a/src/plugins/gbp/gbp_api.c
+++ b/src/plugins/gbp/gbp_api.c
@@ -82,8 +82,7 @@
_(GBP_CONTRACT_DUMP, gbp_contract_dump) \
_(GBP_VXLAN_TUNNEL_ADD, gbp_vxlan_tunnel_add) \
_(GBP_VXLAN_TUNNEL_DEL, gbp_vxlan_tunnel_del) \
- _(GBP_VXLAN_TUNNEL_DUMP, gbp_vxlan_tunnel_dump) \
- _(GBP_EXT_ITF_ANON_ADD_DEL, gbp_ext_itf_anon_add_del)
+ _(GBP_VXLAN_TUNNEL_DUMP, gbp_vxlan_tunnel_dump)
gbp_main_t gbp_main;
@@ -733,7 +732,8 @@ vl_api_gbp_ext_itf_add_del_t_handler (vl_api_gbp_ext_itf_add_del_t * mp)
if (mp->is_add)
rv = gbp_ext_itf_add (sw_if_index,
- ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id));
+ ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id),
+ ntohl (ext_itf->flags));
else
rv = gbp_ext_itf_delete (sw_if_index);
@@ -757,6 +757,7 @@ gbp_ext_itf_send_details (gbp_ext_itf_t * gx, void *args)
mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE);
mp->context = ctx->context;
+ mp->ext_itf.flags = ntohl (gx->gx_flags);
mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd));
mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd));
mp->ext_itf.sw_if_index = ntohl (gx->gx_itf);
@@ -1153,34 +1154,6 @@ vl_api_gbp_vxlan_tunnel_dump_t_handler (vl_api_gbp_vxlan_tunnel_dump_t * mp)
gbp_vxlan_walk (gbp_vxlan_tunnel_send_details, &ctx);
}
-static void
-vl_api_gbp_ext_itf_anon_add_del_t_handler (vl_api_gbp_ext_itf_anon_add_del_t *
- mp)
-{
- vl_api_gbp_ext_itf_anon_add_del_reply_t *rmp;
- u32 sw_if_index = ~0;
- vl_api_gbp_ext_itf_t *ext_itf;
- int rv = 0;
-
- ext_itf = &mp->ext_itf;
- if (ext_itf)
- sw_if_index = ntohl (ext_itf->sw_if_index);
-
- if (!vnet_sw_if_index_is_api_valid (sw_if_index))
- goto bad_sw_if_index;
-
- if (mp->is_add)
- rv = gbp_ext_itf_anon_add (sw_if_index,
- ntohl (ext_itf->bd_id),
- ntohl (ext_itf->rd_id));
- else
- rv = gbp_ext_itf_anon_delete (sw_if_index);
-
- BAD_SW_IF_INDEX_LABEL;
-
- REPLY_MACRO (VL_API_GBP_EXT_ITF_ANON_ADD_DEL_REPLY + GBP_MSG_BASE);
-}
-
/*
* gbp_api_hookup
* Add vpe's API message handlers to the table.
diff --git a/src/plugins/gbp/gbp_api_print.h b/src/plugins/gbp/gbp_api_print.h
index b3afc94dc4b..39c25b6e476 100644
--- a/src/plugins/gbp/gbp_api_print.h
+++ b/src/plugins/gbp/gbp_api_print.h
@@ -332,29 +332,7 @@ vl_api_gbp_ext_itf_add_del_t_print (vl_api_gbp_ext_itf_add_del_t * a,
s = format (s, "sw_if_index %d ", ntohl (a->ext_itf.sw_if_index));
s = format (s, "bd_id %d ", ntohl (a->ext_itf.bd_id));
s = format (s, "rd_id %d ", ntohl (a->ext_itf.rd_id));
-
- s = format (s, "\n");
-
- PRINT_S;
-
- return handle;
-}
-
-static inline void *
-vl_api_gbp_ext_itf_anon_add_del_t_print (vl_api_gbp_ext_itf_anon_add_del_t *
- a, void *handle)
-{
- u8 *s = 0;
-
- s = format (s, "SCRIPT: gbp_ext_itf_anon_add_del ");
- if (a->is_add)
- s = format (s, "add ");
- else
- s = format (s, "del ");
-
- s = format (s, "sw_if_index %d ", ntohl (a->ext_itf.sw_if_index));
- s = format (s, "bd_id %d ", ntohl (a->ext_itf.bd_id));
- s = format (s, "rd_id %d ", ntohl (a->ext_itf.rd_id));
+ s = format (s, "flags %x ", ntohl (a->ext_itf.flags));
s = format (s, "\n");
diff --git a/src/plugins/gbp/gbp_ext_itf.c b/src/plugins/gbp/gbp_ext_itf.c
index 89bcb3da49e..6462eca9eaf 100644
--- a/src/plugins/gbp/gbp_ext_itf.c
+++ b/src/plugins/gbp/gbp_ext_itf.c
@@ -43,13 +43,14 @@ format_gbp_ext_itf (u8 * s, va_list * args)
{
gbp_ext_itf_t *gx = va_arg (*args, gbp_ext_itf_t *);
- return (format (s, "%U in %U",
+ return (format (s, "%U%s in %U",
format_gbp_itf, gx->gx_itf,
+ (gx->gx_flags & GBP_EXT_ITF_F_ANON) ? " [anon]" : "",
format_gbp_bridge_domain, gx->gx_bd));
}
int
-gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id)
+gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id, u32 flags)
{
gbp_ext_itf_t *gx;
index_t gxi;
@@ -92,6 +93,20 @@ gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id)
gr->grd_fib_index[fib_proto_to_dpo (fproto)];
}
+ if (flags & GBP_EXT_ITF_F_ANON)
+ {
+ /* add interface to the BD */
+ index_t itf = gbp_itf_add_and_lock (sw_if_index, bd_id);
+ /* setup GBP L2 features on this interface */
+ gbp_itf_set_l2_input_feature (itf, 0,
+ L2INPUT_FEAT_GBP_LPM_ANON_CLASSIFY |
+ L2INPUT_FEAT_LEARN);
+ gbp_itf_set_l2_output_feature (itf, 0,
+ L2OUTPUT_FEAT_GBP_POLICY_LPM);
+ }
+
+ gx->gx_flags = flags;
+
gbp_ext_itf_db[sw_if_index] = gxi;
GBP_EXT_ITF_DBG ("add: %U", format_gbp_ext_itf, gx);
@@ -119,6 +134,9 @@ gbp_ext_itf_delete (u32 sw_if_index)
GBP_EXT_ITF_DBG ("del: %U", format_gbp_ext_itf, gx);
+ if (gx->gx_flags & GBP_EXT_ITF_F_ANON)
+ gbp_itf_unlock (gx->gx_itf);
+
gbp_route_domain_unlock (gx->gx_rd);
gbp_bridge_domain_unlock (gx->gx_bd);
@@ -130,39 +148,13 @@ gbp_ext_itf_delete (u32 sw_if_index)
return (VNET_API_ERROR_NO_SUCH_ENTRY);
}
-int
-gbp_ext_itf_anon_add (u32 sw_if_index, u32 bd_id, u32 rd_id)
-{
- int rv = gbp_ext_itf_add (sw_if_index, bd_id, rd_id);
- if (rv)
- return rv;
- /* add interface to the BD */
- index_t itf = gbp_itf_add_and_lock (sw_if_index, bd_id);
- /* setup GBP L2 features on this interface */
- gbp_itf_set_l2_input_feature (itf, 0,
- L2INPUT_FEAT_GBP_LPM_ANON_CLASSIFY |
- L2INPUT_FEAT_LEARN);
- gbp_itf_set_l2_output_feature (itf, 0, L2OUTPUT_FEAT_GBP_POLICY_LPM);
- return 0;
-}
-
-int
-gbp_ext_itf_anon_delete (u32 sw_if_index)
-{
- int rv = gbp_ext_itf_delete (sw_if_index);
- if (rv)
- return rv;
- gbp_itf_unlock (sw_if_index);
- return 0;
-}
-
static clib_error_t *
gbp_ext_itf_add_del_cli (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
- u32 sw_if_index = ~0, bd_id = ~0, rd_id = ~0;
- int add = 1, anon = 0;
+ u32 sw_if_index = ~0, bd_id = ~0, rd_id = ~0, flags = 0;
+ int add = 1;
int rv;
/* Get a line of input. */
@@ -183,7 +175,7 @@ gbp_ext_itf_add_del_cli (vlib_main_t * vm,
else if (unformat (line_input, "rd %d", &rd_id))
;
else if (unformat (line_input, "anon-l3-out"))
- anon = 1;
+ flags |= GBP_EXT_ITF_F_ANON;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
@@ -199,18 +191,10 @@ gbp_ext_itf_add_del_cli (vlib_main_t * vm,
return clib_error_return (0, "BD-ID must be specified");
if (~0 == rd_id)
return clib_error_return (0, "RD-ID must be specified");
- if (anon)
- rv = gbp_ext_itf_anon_add (sw_if_index, bd_id, rd_id);
- else
- rv = gbp_ext_itf_add (sw_if_index, bd_id, rd_id);
+ rv = gbp_ext_itf_add (sw_if_index, bd_id, rd_id, flags);
}
else
- {
- if (anon)
- rv = gbp_ext_itf_anon_delete (sw_if_index);
- else
- rv = gbp_ext_itf_delete (sw_if_index);
- }
+ rv = gbp_ext_itf_delete (sw_if_index);
switch (rv)
{
diff --git a/src/plugins/gbp/gbp_ext_itf.h b/src/plugins/gbp/gbp_ext_itf.h
index d1b0f983447..f3829ca13b0 100644
--- a/src/plugins/gbp/gbp_ext_itf.h
+++ b/src/plugins/gbp/gbp_ext_itf.h
@@ -18,6 +18,12 @@
#include <gbp/gbp.h>
+enum
+{
+ GBP_EXT_ITF_F_NONE = 0,
+ GBP_EXT_ITF_F_ANON = 1 << 0,
+};
+
/**
* An external interface maps directly to an oflex L3ExternalInterface.
* The special characteristics of an external interface is the way the source
@@ -46,15 +52,17 @@ typedef struct gpb_ext_itf_t_
*/
u32 gx_fib_index[DPO_PROTO_NUM];
+ /**
+ * The associated flags
+ */
+ u32 gx_flags;
+
} gbp_ext_itf_t;
-extern int gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id);
+extern int gbp_ext_itf_add (u32 sw_if_index, u32 bd_id, u32 rd_id, u32 flags);
extern int gbp_ext_itf_delete (u32 sw_if_index);
-extern int gbp_ext_itf_anon_add (u32 sw_if_index, u32 bd_id, u32 rd_id);
-extern int gbp_ext_itf_anon_delete (u32 sw_if_index);
-
extern u8 *format_gbp_ext_itf (u8 * s, va_list * args);
typedef walk_rc_t (*gbp_ext_itf_cb_t) (gbp_ext_itf_t * gbpe, void *ctx);