aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/l2
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-09-05 09:13:57 -0700
committerJohn Lo <loj@cisco.com>2018-09-25 16:29:19 +0000
commitb474380f82b75d9640f9bf6ee78c891a6794dbfb (patch)
tree1deee7eda6675a9886ddebb4a38249110f67170d /src/vnet/l2
parent6a30b5f9182a44989e97bbc044f29adccdef09b2 (diff)
L2 BD: introduce a BD interface on which to send UU packets
Change-Id: I21ad6b04c19c8735d057174b1f260a59f2812241 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/l2')
-rw-r--r--src/vnet/l2/l2.api36
-rw-r--r--src/vnet/l2/l2_api.c66
-rw-r--r--src/vnet/l2/l2_bd.c41
-rw-r--r--src/vnet/l2/l2_bd.h38
-rw-r--r--src/vnet/l2/l2_flood.c6
-rw-r--r--src/vnet/l2/l2_fwd.c4
-rw-r--r--src/vnet/l2/l2_input.c68
-rw-r--r--src/vnet/l2/l2_input.h4
-rw-r--r--src/vnet/l2/l2_uu_fwd.c242
-rw-r--r--src/vnet/l2/l2_xcrw.c7
10 files changed, 451 insertions, 61 deletions
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index fdb7db7551d..2164ca74406 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -309,17 +309,27 @@ manual_print manual_endian define bridge_domain_details
u8 mac_age;
u8 bd_tag[64];
u32 bvi_sw_if_index;
+ u32 uu_fwd_sw_if_index;
u32 n_sw_ifs;
vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs];
};
-/** \brief Set bridge flags (such as L2_LEARN, L2_FWD, L2_FLOOD,
- L2_UU_FLOOD, or L2_ARP_TERM bits) request
+/** \brief Flags that can be changed on a bridge domain */
+enum bd_flags
+{
+ BRIDGE_API_FLAG_LEARN = 0x1,
+ BRIDGE_API_FLAG_FWD = 0x2,
+ BRIDGE_API_FLAG_FLOOD = 0x4,
+ BRIDGE_API_FLAG_UU_FLOOD = 0x8,
+ BRIDGE_API_FLAG_ARP_TERM = 0x10,
+};
+
+/** \brief Set bridge flags request
@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 set the flags for
@param is_set - if non-zero, set the flags, else clear them
- @param feature_bitmap - bits (as above) that are non-zero to set or clear
+ @param flags - flags that are non-zero to set or clear
*/
define bridge_flags
{
@@ -327,7 +337,7 @@ define bridge_flags
u32 context;
u32 bd_id;
u8 is_set;
- u32 feature_bitmap;
+ vl_api_bd_flags_t flags;
};
/** \brief Set bridge flags response
@@ -419,6 +429,21 @@ autoreply define sw_interface_set_l2_xconnect
u8 enable;
};
+/**
+ * @brief An enumeration of the type of ports that can be added
+ * to a bridge domain
+ */
+enum l2_port_type
+{
+ /* a 'normal' interface, i.e. not BVI or UU-Flood */
+ L2_API_PORT_TYPE_NORMAL = 0,
+ /* a BVI interface in the BD */
+ L2_API_PORT_TYPE_BVI = 1,
+ /* The interface on which to forward unknown unicast packets
+ * If this is not set for a BD then UU is flooded */
+ L2_API_PORT_TYPE_UU_FWD = 2,
+};
+
/** \brief Interface bridge mode request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -428,14 +453,15 @@ autoreply define sw_interface_set_l2_xconnect
@param shg - Split horizon group, for bridge mode only
@param enable - Enable beige mode if not 0, else set to L3 mode
*/
+
autoreply define sw_interface_set_l2_bridge
{
u32 client_index;
u32 context;
u32 rx_sw_if_index;
u32 bd_id;
+ vl_api_l2_port_type_t port_type;
u8 shg;
- u8 bvi;
u8 enable;
};
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index ab3a7c6fd64..3f27feb638a 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -26,6 +26,7 @@
#include <vnet/l2/l2_fib.h>
#include <vnet/l2/l2_vtr.h>
#include <vnet/l2/l2_learn.h>
+#include <vnet/l2/l2_bd.h>
#include <vnet/vnet_msg_enum.h>
@@ -464,6 +465,7 @@ send_bridge_domain_details (l2input_main_t * l2im,
mp->learn = bd_feature_learn (bd_config);
mp->arp_term = bd_feature_arp_term (bd_config);
mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
+ mp->uu_fwd_sw_if_index = ntohl (bd_config->uu_fwd_sw_if_index);
mp->mac_age = bd_config->mac_age;
if (bd_config->bd_tag)
{
@@ -527,6 +529,27 @@ vl_api_bridge_domain_dump_t_handler (vl_api_bridge_domain_dump_t * mp)
}
}
+static bd_flags_t
+bd_flags_decode (vl_api_bd_flags_t v)
+{
+ bd_flags_t f = L2_NONE;
+
+ v = ntohl (v);
+
+ if (v & BRIDGE_API_FLAG_LEARN)
+ f |= L2_LEARN;
+ if (v & BRIDGE_API_FLAG_FWD)
+ f |= L2_FWD;
+ if (v & BRIDGE_API_FLAG_FLOOD)
+ f |= L2_FLOOD;
+ if (v & BRIDGE_API_FLAG_UU_FLOOD)
+ f |= L2_UU_FLOOD;
+ if (v & BRIDGE_API_FLAG_ARP_TERM)
+ f |= L2_ARP_TERM;
+
+ return (f);
+}
+
static void
vl_api_bridge_flags_t_handler (vl_api_bridge_flags_t * mp)
{
@@ -535,7 +558,7 @@ vl_api_bridge_flags_t_handler (vl_api_bridge_flags_t * mp)
vl_api_bridge_flags_reply_t *rmp;
int rv = 0;
- u32 flags = ntohl (mp->feature_bitmap);
+ bd_flags_t flags = bd_flags_decode (mp->flags);
u32 bd_id = ntohl (mp->bd_id);
if (bd_id == 0)
{
@@ -656,11 +679,13 @@ static void
{
VALIDATE_TX_SW_IF_INDEX (mp);
rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
- rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
+ rx_sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, tx_sw_if_index);
}
else
{
- rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
+ rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, 0);
}
BAD_RX_SW_IF_INDEX_LABEL;
@@ -669,6 +694,27 @@ static void
REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
}
+static int
+l2_bd_port_type_decode (vl_api_l2_port_type_t v, l2_bd_port_type_t * l)
+{
+ v = clib_net_to_host_u32 (v);
+
+ switch (v)
+ {
+ case L2_API_PORT_TYPE_NORMAL:
+ *l = L2_BD_PORT_TYPE_NORMAL;
+ return 0;
+ case L2_API_PORT_TYPE_BVI:
+ *l = L2_BD_PORT_TYPE_BVI;
+ return 0;
+ case L2_API_PORT_TYPE_UU_FWD:
+ *l = L2_BD_PORT_TYPE_UU_FWD;
+ return 0;
+ }
+
+ return (VNET_API_ERROR_INVALID_VALUE);
+}
+
static void
vl_api_sw_interface_set_l2_bridge_t_handler
(vl_api_sw_interface_set_l2_bridge_t * mp)
@@ -678,29 +724,31 @@ static void
int rv = 0;
vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
+ l2_bd_port_type_t pt;
VALIDATE_RX_SW_IF_INDEX (mp);
u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
+ rv = l2_bd_port_type_decode (mp->port_type, &pt);
-
+ if (0 != rv)
+ goto out;
if (mp->enable)
{
VALIDATE_BD_ID (mp);
u32 bd_id = ntohl (mp->bd_id);
u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
- u32 bvi = mp->bvi;
- u8 shg = mp->shg;
+
rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
- rx_sw_if_index, bd_index, bvi, shg, 0);
+ rx_sw_if_index, bd_index, pt, mp->shg, 0);
}
else
{
- rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
+ rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, pt, 0, 0);
}
BAD_RX_SW_IF_INDEX_LABEL;
BAD_BD_ID_LABEL;
-
+out:
REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
}
diff --git a/src/vnet/l2/l2_bd.c b/src/vnet/l2/l2_bd.c
index 973beb71cd0..47bdce6af68 100644
--- a/src/vnet/l2/l2_bd.c
+++ b/src/vnet/l2/l2_bd.c
@@ -52,8 +52,9 @@ bd_validate (l2_bridge_domain_t * bd_config)
{
if (bd_is_valid (bd_config))
return;
- bd_config->feature_bitmap = ~L2INPUT_FEAT_ARP_TERM;
+ bd_config->feature_bitmap = ~(L2INPUT_FEAT_ARP_TERM | L2INPUT_FEAT_UU_FWD);
bd_config->bvi_sw_if_index = ~0;
+ bd_config->uu_fwd_sw_if_index = ~0;
bd_config->members = 0;
bd_config->flood_count = 0;
bd_config->tun_master_count = 0;
@@ -240,7 +241,7 @@ VLIB_INIT_FUNCTION (l2bd_init);
Return 0 if ok, non-zero if for an error.
*/
u32
-bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable)
+bd_set_flags (vlib_main_t * vm, u32 bd_index, bd_flags_t flags, u32 enable)
{
l2_bridge_domain_t *bd_config = l2input_bd_config (bd_index);
@@ -894,7 +895,7 @@ VLIB_CLI_COMMAND (bd_arp_entry_cli, static) = {
};
/* *INDENT-ON* */
-u8 *
+static u8 *
format_vtr (u8 * s, va_list * args)
{
u32 vtr_op = va_arg (*args, u32);
@@ -929,6 +930,20 @@ format_vtr (u8 * s, va_list * args)
}
}
+static u8 *
+format_uu_cfg (u8 * s, va_list * args)
+{
+ l2_bridge_domain_t *bd_config = va_arg (*args, l2_bridge_domain_t *);
+
+ if (bd_config->feature_bitmap & L2INPUT_FEAT_UU_FWD)
+ return (format (s, "%U", format_vnet_sw_if_index_name_with_NA,
+ vnet_get_main (), bd_config->uu_fwd_sw_if_index));
+ else if (bd_config->feature_bitmap & L2INPUT_FEAT_UU_FLOOD)
+ return (format (s, "flood"));
+ else
+ return (format (s, "drop"));
+}
+
/**
Show bridge-domain state.
The CLI format is:
@@ -1002,10 +1017,10 @@ bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
{
printed = 1;
vlib_cli_output (vm,
- "%=8s %=7s %=4s %=9s %=9s %=9s %=9s %=9s %=9s %=9s",
+ "%=8s %=7s %=4s %=9s %=9s %=9s %=11s %=9s %=9s %=11s",
"BD-ID", "Index", "BSN", "Age(min)",
- "Learning", "U-Forwrd", "UU-Flood", "Flooding",
- "ARP-Term", "BVI-Intf");
+ "Learning", "U-Forwrd", "UU-Flood",
+ "Flooding", "ARP-Term", "BVI-Intf");
}
if (bd_config->mac_age)
@@ -1013,14 +1028,13 @@ bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
else
as = format (as, "off");
vlib_cli_output (vm,
- "%=8d %=7d %=4d %=9v %=9s %=9s %=9s %=9s %=9s %=9U",
+ "%=8d %=7d %=4d %=9v %=9s %=9s %=11U %=9s %=9s %=11U",
bd_config->bd_id, bd_index, bd_config->seq_num, as,
bd_config->feature_bitmap & L2INPUT_FEAT_LEARN ?
"on" : "off",
bd_config->feature_bitmap & L2INPUT_FEAT_FWD ?
"on" : "off",
- bd_config->feature_bitmap & L2INPUT_FEAT_UU_FLOOD ?
- "on" : "off",
+ format_uu_cfg, bd_config,
bd_config->feature_bitmap & L2INPUT_FEAT_FLOOD ?
"on" : "off",
bd_config->feature_bitmap & L2INPUT_FEAT_ARP_TERM ?
@@ -1055,6 +1069,13 @@ bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
"-", i < bd_config->flood_count ? "*" : "-",
format_vtr, vtr_opr, dot1q, tag1, tag2);
}
+ if (~0 != bd_config->uu_fwd_sw_if_index)
+ vlib_cli_output (vm, "%=30U%=7d%=5d%=5d%=5s%=9s%=30s",
+ format_vnet_sw_if_index_name, vnm,
+ bd_config->uu_fwd_sw_if_index,
+ bd_config->uu_fwd_sw_if_index,
+ 0, 0, "uu", "-", "None");
+
}
if ((detail || arp) &&
@@ -1150,7 +1171,7 @@ bd_add_del (l2_bridge_domain_add_del_args_t * a)
return VNET_API_ERROR_BD_ID_EXCEED_MAX;
bd_index = bd_add_bd_index (bdm, a->bd_id);
- u32 enable_flags = 0, disable_flags = 0;
+ bd_flags_t enable_flags = 0, disable_flags = 0;
if (a->flood)
enable_flags |= L2_FLOOD;
else
diff --git a/src/vnet/l2/l2_bd.h b/src/vnet/l2/l2_bd.h
index ffc75339e97..226e30ecfd4 100644
--- a/src/vnet/l2/l2_bd.h
+++ b/src/vnet/l2/l2_bd.h
@@ -21,6 +21,13 @@
#include <vlib/vlib.h>
#include <vnet/vnet.h>
+typedef enum l2_bd_port_type_t_
+{
+ L2_BD_PORT_TYPE_NORMAL = 0,
+ L2_BD_PORT_TYPE_BVI = 1,
+ L2_BD_PORT_TYPE_UU_FWD = 2,
+} l2_bd_port_type_t;
+
typedef struct
{
/* hash bd_id -> bd_index */
@@ -53,16 +60,23 @@ typedef struct
typedef struct
{
- u32 feature_bitmap;
/*
* Contains bit enables for flooding, learning, and forwarding.
* All other feature bits should always be set.
- *
+ */
+ u32 feature_bitmap;
+ /*
* identity of the bridge-domain's BVI interface
* set to ~0 if there is no BVI
*/
u32 bvi_sw_if_index;
+ /*
+ * identity of the bridge-domain's UU flood interface
+ * set to ~0 if there is no such configuration
+ */
+ u32 uu_fwd_sw_if_index;
+
/* bridge domain id, not to be confused with bd_index */
u32 bd_id;
@@ -128,14 +142,18 @@ bd_add_member (l2_bridge_domain_t * bd_config, l2_flood_member_t * member);
u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index);
-
-#define L2_LEARN (1<<0)
-#define L2_FWD (1<<1)
-#define L2_FLOOD (1<<2)
-#define L2_UU_FLOOD (1<<3)
-#define L2_ARP_TERM (1<<4)
-
-u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable);
+typedef enum bd_flags_t_
+{
+ L2_NONE = 0,
+ L2_LEARN = (1 << 0),
+ L2_FWD = (1 << 1),
+ L2_FLOOD = (1 << 2),
+ L2_UU_FLOOD = (1 << 3),
+ L2_ARP_TERM = (1 << 4),
+} bd_flags_t;
+
+u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, bd_flags_t flags,
+ u32 enable);
void bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age);
int bd_add_del (l2_bridge_domain_add_del_args_t * args);
diff --git a/src/vnet/l2/l2_flood.c b/src/vnet/l2/l2_flood.c
index ee3d6d4621f..97a4ff59da7 100644
--- a/src/vnet/l2/l2_flood.c
+++ b/src/vnet/l2/l2_flood.c
@@ -372,10 +372,12 @@ VLIB_REGISTER_NODE (l2flood_node,static) = {
[L2FLOOD_NEXT_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
VLIB_NODE_FUNCTION_MULTIARCH (l2flood_node, l2flood_node_fn)
- clib_error_t *l2flood_init (vlib_main_t * vm)
+/* *INDENT-ON* */
+
+clib_error_t *
+l2flood_init (vlib_main_t * vm)
{
l2flood_main_t *mp = &l2flood_main;
diff --git a/src/vnet/l2/l2_fwd.c b/src/vnet/l2/l2_fwd.c
index 0fad124b89f..c647e3dbd06 100644
--- a/src/vnet/l2/l2_fwd.c
+++ b/src/vnet/l2/l2_fwd.c
@@ -211,7 +211,8 @@ l2fwd_process (vlib_main_t * vm,
* lookup miss, so flood which is typically the next feature
* unless some other feature is inserted before uu_flood
*/
- if (vnet_buffer (b0)->l2.feature_bitmap & L2INPUT_FEAT_UU_FLOOD)
+ if (vnet_buffer (b0)->l2.feature_bitmap &
+ (L2INPUT_FEAT_UU_FLOOD | L2INPUT_FEAT_UU_FWD))
{
*next0 = vnet_l2_feature_next (b0, msm->feat_next_node_index,
L2INPUT_FEAT_FWD);
@@ -223,7 +224,6 @@ l2fwd_process (vlib_main_t * vm,
*next0 = L2FWD_NEXT_DROP;
}
}
-
}
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index 1c9ddaac04a..f94ef668c41 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -573,7 +573,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
u32 mode, /* One of L2 modes or back to L3 mode */
u32 sw_if_index, /* sw interface index */
u32 bd_index, /* for bridged interface */
- u32 bvi, /* the bridged interface is the BVI */
+ l2_bd_port_type_t port_type, /* port_type */
u32 shg, /* the bridged interface split horizon group */
u32 xc_sw_if_index) /* peer interface for xconnect */
{
@@ -613,6 +613,11 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
si = vnet_get_sw_interface (vnm, sw_if_index);
si->flood_class = VNET_FLOOD_CLASS_NO_FLOOD;
}
+ if (bd_config->uu_fwd_sw_if_index == sw_if_index)
+ {
+ bd_config->uu_fwd_sw_if_index = ~0;
+ bd_config->feature_bitmap &= ~L2INPUT_FEAT_UU_FWD;
+ }
/* Clear MACs learned on the interface */
if ((config->feature_bitmap & L2INPUT_FEAT_LEARN) ||
@@ -657,6 +662,8 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
if (mode == MODE_L2_BRIDGE)
{
+ u8 member_flags;
+
/*
* Remove a check that the interface must be an Ethernet.
* Specifically so we can bridge to L3 tunnel interfaces.
@@ -676,8 +683,12 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
* Enable forwarding, flooding, learning and ARP termination by default
* (note that ARP term is disabled on BD feature bitmap by default)
*/
- config->feature_bitmap |= L2INPUT_FEAT_FWD | L2INPUT_FEAT_UU_FLOOD |
- L2INPUT_FEAT_FLOOD | L2INPUT_FEAT_LEARN | L2INPUT_FEAT_ARP_TERM;
+ config->feature_bitmap |= (L2INPUT_FEAT_FWD |
+ L2INPUT_FEAT_UU_FLOOD |
+ L2INPUT_FEAT_UU_FWD |
+ L2INPUT_FEAT_FLOOD |
+ L2INPUT_FEAT_LEARN |
+ L2INPUT_FEAT_ARP_TERM);
/* Make sure last-chance drop is configured */
config->feature_bitmap |= L2INPUT_FEAT_DROP;
@@ -692,7 +703,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
/* TODO: think: add l2fib entry even for non-bvi interface? */
/* Do BVI interface initializations */
- if (bvi)
+ if (L2_BD_PORT_TYPE_BVI == port_type)
{
vnet_sw_interface_t *si;
@@ -715,16 +726,29 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
/* since this is a BVI interface we want to flood to it */
si = vnet_get_sw_interface (vnm, sw_if_index);
si->flood_class = VNET_FLOOD_CLASS_BVI;
+ member_flags = L2_FLOOD_MEMBER_BVI;
+ }
+ else if (L2_BD_PORT_TYPE_UU_FWD == port_type)
+ {
+ bd_config->uu_fwd_sw_if_index = sw_if_index;
+ bd_config->feature_bitmap |= L2INPUT_FEAT_UU_FWD;
+ }
+ else
+ {
+ member_flags = L2_FLOOD_MEMBER_NORMAL;
}
- /* Add interface to bridge-domain flood vector */
- l2_flood_member_t member = {
- .sw_if_index = sw_if_index,
- .flags = bvi ? L2_FLOOD_MEMBER_BVI : L2_FLOOD_MEMBER_NORMAL,
- .shg = shg,
- };
- bd_add_member (bd_config, &member);
-
+ if (L2_BD_PORT_TYPE_NORMAL == port_type ||
+ L2_BD_PORT_TYPE_BVI == port_type)
+ {
+ /* Add interface to bridge-domain flood vector */
+ l2_flood_member_t member = {
+ .sw_if_index = sw_if_index,
+ .flags = member_flags,
+ .shg = shg,
+ };
+ bd_add_member (bd_config, &member);
+ }
}
else if (mode == MODE_L2_XC)
{
@@ -827,10 +851,10 @@ int_l2_bridge (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
+ l2_bd_port_type_t port_type;
clib_error_t *error = 0;
u32 bd_index, bd_id;
u32 sw_if_index;
- u32 bvi;
u32 rc;
u32 shg;
@@ -857,7 +881,11 @@ int_l2_bridge (vlib_main_t * vm,
bd_index = bd_find_or_add_bd_index (&bd_main, bd_id);
/* optional bvi */
- bvi = unformat (input, "bvi");
+ port_type = L2_BD_PORT_TYPE_NORMAL;
+ if (unformat (input, "bvi"))
+ port_type = L2_BD_PORT_TYPE_BVI;
+ if (unformat (input, "uu-fwd"))
+ port_type = L2_BD_PORT_TYPE_UU_FWD;
/* optional split horizon group */
shg = 0;
@@ -865,8 +893,8 @@ int_l2_bridge (vlib_main_t * vm,
/* set the interface mode */
if ((rc =
- set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE, sw_if_index, bd_index, bvi,
- shg, 0)))
+ set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE, sw_if_index, bd_index,
+ port_type, shg, 0)))
{
if (rc == MODE_ERROR_ETH)
{
@@ -920,7 +948,7 @@ done:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (int_l2_bridge_cli, static) = {
.path = "set interface l2 bridge",
- .short_help = "set interface l2 bridge <interface> <bridge-domain-id> [bvi] [shg]",
+ .short_help = "set interface l2 bridge <interface> <bridge-domain-id> [bvi|uu-fwd] [shg]",
.function = int_l2_bridge,
};
/* *INDENT-ON* */
@@ -956,7 +984,8 @@ int_l2_xc (vlib_main_t * vm,
/* set the interface mode */
if (set_int_l2_mode
- (vm, vnm, MODE_L2_XC, sw_if_index, 0, 0, 0, xc_sw_if_index))
+ (vm, vnm, MODE_L2_XC, sw_if_index, 0, L2_BD_PORT_TYPE_NORMAL,
+ 0, xc_sw_if_index))
{
error = clib_error_return (0, "invalid configuration for interface",
format_unformat_error, input);
@@ -1010,7 +1039,8 @@ int_l3 (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
}
/* set the interface mode */
- if (set_int_l2_mode (vm, vnm, MODE_L3, sw_if_index, 0, 0, 0, 0))
+ if (set_int_l2_mode (vm, vnm, MODE_L3, sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, 0))
{
error = clib_error_return (0, "invalid configuration for interface",
format_unformat_error, input);
diff --git a/src/vnet/l2/l2_input.h b/src/vnet/l2/l2_input.h
index fb601334f37..4d6f1a32177 100644
--- a/src/vnet/l2/l2_input.h
+++ b/src/vnet/l2/l2_input.h
@@ -104,6 +104,7 @@ l2input_bd_config (u32 bd_index)
_(FLOOD, "l2-flood") \
_(ARP_TERM, "arp-term-l2bd") \
_(UU_FLOOD, "l2-flood") \
+ _(UU_FWD, "l2-uu-fwd") \
_(GBP_FWD, "gbp-fwd") \
_(FWD, "l2-fwd") \
_(RW, "l2-rw") \
@@ -213,7 +214,8 @@ u32 set_int_l2_mode (vlib_main_t * vm,
vnet_main_t * vnet_main,
u32 mode,
u32 sw_if_index,
- u32 bd_index, u32 bvi, u32 shg, u32 xc_sw_if_index);
+ u32 bd_index, l2_bd_port_type_t port_type,
+ u32 shg, u32 xc_sw_if_index);
static inline void
vnet_update_l2_len (vlib_buffer_t * b)
diff --git a/src/vnet/l2/l2_uu_fwd.c b/src/vnet/l2/l2_uu_fwd.c
new file mode 100644
index 00000000000..fd79387bbe0
--- /dev/null
+++ b/src/vnet/l2/l2_uu_fwd.c
@@ -0,0 +1,242 @@
+/*
+ * l2_uu_fwd.c : Foward unknown unicast packets to BD's configured interface
+ *
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/l2/l2_bd.h>
+#include <vnet/l2/l2_input.h>
+
+#define foreach_l2_uu_fwd_error \
+_(L2_UU_FWD, "L2 UU fwd")
+
+typedef enum
+{
+#define _(sym,str) L2_UU_FWD_ERROR_##sym,
+ foreach_l2_uu_fwd_error
+#undef _
+ L2_UU_FWD_N_ERROR,
+} l2_uu_fwd_error_t;
+
+static char *l2_uu_fwd_error_strings[] = {
+#define _(sym,string) string,
+ foreach_l2_uu_fwd_error
+#undef _
+};
+
+typedef enum
+{
+ L2_UU_FWD_NEXT_DROP,
+ L2_UU_FWD_NEXT_L2_OUTPUT,
+ L2_UU_FWD_N_NEXT,
+} l2_uu_fwd_next_t;
+
+typedef struct
+{
+ u32 sw_if_index;
+} l2_uu_fwd_trace_t;
+
+/* packet trace format function */
+static u8 *
+format_l2_uu_fwd_trace (u8 * s, va_list * args)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ l2_uu_fwd_trace_t *t = va_arg (*args, l2_uu_fwd_trace_t *);
+
+ s = format (s, "l2-uu-fwd: sw_if_index %d", t->sw_if_index);
+ return s;
+}
+
+static uword
+l2_uu_fwd_node_fn (vlib_main_t * vm,
+ vlib_node_runtime_t * node, vlib_frame_t * frame)
+{
+ u32 n_left_from, *from, *to_next;
+ l2_uu_fwd_next_t next_index;
+
+ from = vlib_frame_vector_args (frame);
+ n_left_from = frame->n_vectors;
+ next_index = node->cached_next_index;
+
+ while (n_left_from > 0)
+ {
+ u32 n_left_to_next;
+
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+
+ while (n_left_from >= 8 && n_left_to_next >= 4)
+ {
+ const l2_bridge_domain_t *bdc0, *bdc1, *bdc2, *bdc3;
+ l2_uu_fwd_next_t next0, next1, next2, next3;
+ vlib_buffer_t *b0, *b1, *b2, *b3;
+ u32 bi0, bi1, bi2, bi3;
+
+ {
+ vlib_buffer_t *b4, *b5, *b6, *b7;
+
+ b4 = vlib_get_buffer (vm, from[4]);
+ b5 = vlib_get_buffer (vm, from[5]);
+ b6 = vlib_get_buffer (vm, from[6]);
+ b7 = vlib_get_buffer (vm, from[7]);
+
+ vlib_prefetch_buffer_header (b4, STORE);
+ vlib_prefetch_buffer_header (b5, STORE);
+ vlib_prefetch_buffer_header (b6, STORE);
+ vlib_prefetch_buffer_header (b7, STORE);
+ }
+ bi0 = to_next[0] = from[0];
+ bi1 = to_next[1] = from[1];
+ bi2 = to_next[2] = from[2];
+ bi3 = to_next[3] = from[3];
+
+ from += 4;
+ to_next += 4;
+ n_left_from -= 4;
+ n_left_to_next -= 4;
+
+ next3 = next2 = next1 = next0 = L2_UU_FWD_NEXT_L2_OUTPUT;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+ b2 = vlib_get_buffer (vm, bi2);
+ b3 = vlib_get_buffer (vm, bi3);
+
+ bdc0 = vec_elt_at_index (l2input_main.bd_configs,
+ vnet_buffer (b0)->l2.bd_index);
+ bdc1 = vec_elt_at_index (l2input_main.bd_configs,
+ vnet_buffer (b1)->l2.bd_index);
+ bdc2 = vec_elt_at_index (l2input_main.bd_configs,
+ vnet_buffer (b2)->l2.bd_index);
+ bdc3 = vec_elt_at_index (l2input_main.bd_configs,
+ vnet_buffer (b3)->l2.bd_index);
+
+ ASSERT (~0 != bdc0->uu_fwd_sw_if_index);
+
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = bdc0->uu_fwd_sw_if_index;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] = bdc1->uu_fwd_sw_if_index;
+ vnet_buffer (b2)->sw_if_index[VLIB_TX] = bdc2->uu_fwd_sw_if_index;
+ vnet_buffer (b3)->sw_if_index[VLIB_TX] = bdc3->uu_fwd_sw_if_index;
+
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ l2_uu_fwd_trace_t *t;
+
+ t = vlib_add_trace (vm, node, b0, sizeof (*t));
+ t->sw_if_index = bdc0->uu_fwd_sw_if_index;
+ }
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b1->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ l2_uu_fwd_trace_t *t;
+
+ t = vlib_add_trace (vm, node, b1, sizeof (*t));
+ t->sw_if_index = bdc1->uu_fwd_sw_if_index;
+ }
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b1->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ l2_uu_fwd_trace_t *t;
+
+ t = vlib_add_trace (vm, node, b2, sizeof (*t));
+ t->sw_if_index = bdc2->uu_fwd_sw_if_index;
+ }
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b1->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ l2_uu_fwd_trace_t *t;
+
+ t = vlib_add_trace (vm, node, b3, sizeof (*t));
+ t->sw_if_index = bdc3->uu_fwd_sw_if_index;
+ }
+ vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
+ to_next, n_left_to_next,
+ bi0, bi1, bi2, bi3,
+ next0, next1, next2, next3);
+ }
+
+ while (n_left_from > 0 && n_left_to_next > 0)
+ {
+ const l2_bridge_domain_t *bdc0;
+ l2_uu_fwd_next_t next0;
+ vlib_buffer_t *b0;
+ u32 bi0;
+
+ bi0 = from[0];
+ to_next[0] = bi0;
+ from += 1;
+ to_next += 1;
+ n_left_from -= 1;
+ n_left_to_next -= 1;
+ next0 = L2_UU_FWD_NEXT_L2_OUTPUT;
+ b0 = vlib_get_buffer (vm, bi0);
+
+ bdc0 = vec_elt_at_index (l2input_main.bd_configs,
+ vnet_buffer (b0)->l2.bd_index);
+ ASSERT (~0 != bdc0->uu_fwd_sw_if_index);
+
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = bdc0->uu_fwd_sw_if_index;
+
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ {
+ l2_uu_fwd_trace_t *t;
+
+ t = vlib_add_trace (vm, node, b0, sizeof (*t));
+ t->sw_if_index = bdc0->uu_fwd_sw_if_index;
+ }
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ bi0, next0);
+ }
+
+ vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+ }
+
+ vlib_node_increment_counter (vm, node->node_index,
+ L2_UU_FWD_ERROR_L2_UU_FWD, frame->n_vectors);
+
+ return frame->n_vectors;
+}
+
+/* *INDENT-OFF* */
+VLIB_REGISTER_NODE (l2_uu_fwd_node,static) = {
+ .function = l2_uu_fwd_node_fn,
+ .name = "l2-uu-fwd",
+ .vector_size = sizeof (u32),
+ .format_trace = format_l2_uu_fwd_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+
+ .n_errors = ARRAY_LEN(l2_uu_fwd_error_strings),
+ .error_strings = l2_uu_fwd_error_strings,
+
+ .n_next_nodes = L2_UU_FWD_N_NEXT,
+
+ .next_nodes = {
+ [L2_UU_FWD_NEXT_DROP] = "error-drop",
+ [L2_UU_FWD_NEXT_L2_OUTPUT] = "l2-output",
+ },
+};
+
+VLIB_NODE_FUNCTION_MULTIARCH (l2_uu_fwd_node, l2_uu_fwd_node_fn)
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/l2/l2_xcrw.c b/src/vnet/l2/l2_xcrw.c
index d08a5d8f8e8..334e8641455 100644
--- a/src/vnet/l2/l2_xcrw.c
+++ b/src/vnet/l2/l2_xcrw.c
@@ -366,8 +366,8 @@ vnet_configure_l2_xcrw (vlib_main_t * vm, vnet_main_t * vnm,
if (vec_len (rewrite))
vnet_rewrite_set_data (a[0], rewrite, vec_len (rewrite));
- set_int_l2_mode (vm, vnm, MODE_L2_XC, t->l2_sw_if_index, 0, 0, 0,
- t->tunnel_sw_if_index);
+ set_int_l2_mode (vm, vnm, MODE_L2_XC, t->l2_sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, t->tunnel_sw_if_index);
hash_set (xcm->tunnel_index_by_l2_sw_if_index,
t->l2_sw_if_index, t - xcm->tunnels);
return 0;
@@ -384,7 +384,8 @@ vnet_configure_l2_xcrw (vlib_main_t * vm, vnet_main_t * vnm,
/* Reset adj to drop traffic */
memset (a, 0, sizeof (*a));
- set_int_l2_mode (vm, vnm, MODE_L3, t->l2_sw_if_index, 0, 0, 0, 0);
+ set_int_l2_mode (vm, vnm, MODE_L3, t->l2_sw_if_index, 0,
+ L2_BD_PORT_TYPE_NORMAL, 0, 0);
vnet_sw_interface_set_flags (vnm, t->tunnel_sw_if_index, 0 /* down */ );