aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vat/api_format.c30
-rw-r--r--src/vnet/l2/l2.api6
-rw-r--r--src/vnet/l2/l2_api.c6
-rw-r--r--src/vnet/l2/l2_fib.c66
-rw-r--r--src/vnet/l2/l2_fib.h8
-rw-r--r--src/vnet/l2/l2_input.c7
-rw-r--r--src/vpp/api/custom_dump.c2
-rw-r--r--test/vpp_papi_provider.py2
8 files changed, 56 insertions, 71 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index de63bc394a9..ddc1f8cfaa4 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -718,14 +718,14 @@ increment_v6_address (ip6_address_t * a)
}
static void
-increment_mac_address (u64 * mac)
+increment_mac_address (u8 * mac)
{
- u64 tmp = *mac;
-
+ u64 tmp = *((u64 *) mac);
tmp = clib_net_to_host_u64 (tmp);
tmp += 1 << 16; /* skip unused (least significant) octets */
tmp = clib_host_to_net_u64 (tmp);
- *mac = tmp;
+
+ clib_memcpy (mac, &tmp, 6);
}
static void vl_api_create_loopback_reply_t_handler
@@ -7026,7 +7026,7 @@ api_l2fib_add_del (vat_main_t * vam)
unformat_input_t *i = vam->input;
vl_api_l2fib_add_del_t *mp;
f64 timeout;
- u64 mac = 0;
+ u8 mac[6] = { 0 };
u8 mac_set = 0;
u32 bd_id;
u8 bd_id_set = 0;
@@ -7043,7 +7043,7 @@ api_l2fib_add_del (vat_main_t * vam)
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
+ if (unformat (i, "mac %U", unformat_ethernet_address, mac))
mac_set = 1;
else if (unformat (i, "bd_id %d", &bd_id))
bd_id_set = 1;
@@ -7110,7 +7110,7 @@ api_l2fib_add_del (vat_main_t * vam)
{
M (L2FIB_ADD_DEL, mp);
- mp->mac = mac;
+ clib_memcpy (mp->mac, mac, 6);
mp->bd_id = ntohl (bd_id);
mp->is_add = is_add;
@@ -7121,7 +7121,7 @@ api_l2fib_add_del (vat_main_t * vam)
mp->filter_mac = filter_mac;
mp->bvi_mac = bvi_mac;
}
- increment_mac_address (&mac);
+ increment_mac_address (mac);
/* send it... */
S (mp);
}
@@ -13316,16 +13316,6 @@ api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
return ret;
}
-
-u8 *
-format_l2_fib_mac_address (u8 * s, va_list * args)
-{
- u8 *a = va_arg (*args, u8 *);
-
- return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
- a[2], a[3], a[4], a[5], a[6], a[7]);
-}
-
static void vl_api_l2_fib_table_details_t_handler
(vl_api_l2_fib_table_details_t * mp)
{
@@ -13333,7 +13323,7 @@ static void vl_api_l2_fib_table_details_t_handler
print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
" %d %d %d",
- ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
+ ntohl (mp->bd_id), format_ethernet_address, mp->mac,
ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
mp->bvi_mac);
}
@@ -13353,7 +13343,7 @@ static void vl_api_l2_fib_table_details_t_handler_json
vat_json_init_object (node);
vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
- vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
+ vat_json_object_add_bytes (node, "mac", mp->mac, 6);
vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
vat_json_object_add_uint (node, "static_mac", mp->static_mac);
vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index 18383652827..404a47888d8 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-vl_api_version 1.0.0
+vl_api_version 2.0.0
/** \brief Reply to l2_xconnect_dump
@param context - sender context which was passed in the request
@@ -50,7 +50,7 @@ define l2_fib_table_details
{
u32 context;
u32 bd_id;
- u64 mac;
+ u8 mac[6];
u32 sw_if_index;
u8 static_mac;
u8 filter_mac;
@@ -126,7 +126,7 @@ autoreply define l2fib_add_del
{
u32 client_index;
u32 context;
- u64 mac;
+ u8 mac[6];
u32 bd_id;
u32 sw_if_index;
u8 is_add;
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 20d6ab32fad..8fd94b0e40a 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -133,7 +133,7 @@ send_l2fib_table_entry (vpe_api_main_t * am,
mp->bd_id =
ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
- mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
+ clib_memcpy (mp->mac, l2fe_key->fields.mac, 6);
mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
mp->static_mac = l2fe_res->fields.static_mac;
mp->filter_mac = l2fe_res->fields.filter;
@@ -199,7 +199,9 @@ vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp)
}
u32 bd_index = p[0];
- u64 mac = mp->mac;
+ u8 mac[6];
+
+ clib_memcpy (mac, mp->mac, 6);
if (mp->is_add)
{
if (mp->filter_mac)
diff --git a/src/vnet/l2/l2_fib.c b/src/vnet/l2/l2_fib.c
index 0ad56f38fe0..9e095d236cf 100644
--- a/src/vnet/l2/l2_fib.c
+++ b/src/vnet/l2/l2_fib.c
@@ -54,6 +54,17 @@
l2fib_main_t l2fib_main;
+static void
+incr_mac_address (u8 * mac)
+{
+ u64 tmp = *((u64 *) mac);
+ tmp = clib_net_to_host_u64 (tmp);
+ tmp += 1 << 16; /* skip unused (least significant) octets */
+ tmp = clib_host_to_net_u64 (tmp);
+
+ clib_memcpy (mac, &tmp, 6);
+}
+
/** Format sw_if_index. If the value is ~0, use the text "N/A" */
u8 *
format_vnet_sw_if_index_name_with_NA (u8 * s, va_list * args)
@@ -342,7 +353,7 @@ l2fib_cur_seq_num (u32 bd_index, u32 sw_if_index)
* If the entry already exists then overwrite it
*/
void
-l2fib_add_entry (u64 mac, u32 bd_index,
+l2fib_add_entry (u8 * mac, u32 bd_index,
u32 sw_if_index, u8 static_mac, u8 filter_mac, u8 bvi_mac)
{
l2fib_entry_key_t key;
@@ -353,7 +364,7 @@ l2fib_add_entry (u64 mac, u32 bd_index,
BVT (clib_bihash_kv) kv;
/* set up key */
- key.raw = l2fib_make_key ((u8 *) & mac, bd_index);
+ key.raw = l2fib_make_key (mac, bd_index);
/* check if entry alread exist */
if (BV (clib_bihash_search) (&fm->mac_table, &kv, &kv))
@@ -392,7 +403,7 @@ l2fib_add (vlib_main_t * vm,
bd_main_t *bdm = &bd_main;
vnet_main_t *vnm = vnet_get_main ();
clib_error_t *error = 0;
- u64 mac;
+ u8 mac[6];
u32 bd_id;
u32 bd_index;
u32 sw_if_index = ~0;
@@ -401,7 +412,7 @@ l2fib_add (vlib_main_t * vm,
u32 bvi_mac = 0;
uword *p;
- if (!unformat_user (input, unformat_ethernet_address, &mac))
+ if (!unformat (input, "%U", unformat_ethernet_address, mac))
{
error = clib_error_return (0, "expected mac address `%U'",
format_unformat_error, input);
@@ -507,7 +518,7 @@ l2fib_test_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
{
clib_error_t *error = 0;
- u64 mac, save_mac;
+ u8 mac[6], save_mac[6];
u32 bd_index = 0;
u32 sw_if_index = 8;
u32 bvi_mac = 0;
@@ -520,7 +531,7 @@ l2fib_test_command_fn (vlib_main_t * vm,
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "mac %U", unformat_ethernet_address, &mac))
+ if (unformat (input, "mac %U", unformat_ethernet_address, mac))
mac_set = 1;
else if (unformat (input, "add"))
is_add = 1;
@@ -541,19 +552,14 @@ l2fib_test_command_fn (vlib_main_t * vm,
return clib_error_return (0,
"noop: pick at least one of (add,del,check)");
- save_mac = mac;
+ clib_memcpy (save_mac, mac, 6);
if (is_add)
{
for (i = 0; i < count; i++)
{
- u64 tmp;
- l2fib_add_fwd_entry (mac, bd_index, sw_if_index, mac, bvi_mac);
- tmp = clib_net_to_host_u64 (mac);
- tmp >>= 16;
- tmp++;
- tmp <<= 16;
- mac = clib_host_to_net_u64 (tmp);
+ l2fib_add_fwd_entry (mac, bd_index, sw_if_index, *mac, bvi_mac);
+ incr_mac_address (mac);
}
}
@@ -562,38 +568,28 @@ l2fib_test_command_fn (vlib_main_t * vm,
BVT (clib_bihash_kv) kv;
l2fib_main_t *mp = &l2fib_main;
- mac = save_mac;
+ clib_memcpy (mac, save_mac, 6);
for (i = 0; i < count; i++)
{
- u64 tmp;
- kv.key = l2fib_make_key ((u8 *) & mac, bd_index);
+ kv.key = l2fib_make_key (mac, bd_index);
if (BV (clib_bihash_search) (&mp->mac_table, &kv, &kv))
{
- clib_warning ("key %U AWOL", format_ethernet_address, &mac);
+ clib_warning ("key %U AWOL", format_ethernet_address, mac);
break;
}
- tmp = clib_net_to_host_u64 (mac);
- tmp >>= 16;
- tmp++;
- tmp <<= 16;
- mac = clib_host_to_net_u64 (tmp);
+ incr_mac_address (mac);
}
}
if (is_del)
{
+ clib_memcpy (mac, save_mac, 6);
+
for (i = 0; i < count; i++)
{
- u64 tmp;
-
l2fib_del_entry (mac, bd_index);
-
- tmp = clib_net_to_host_u64 (mac);
- tmp >>= 16;
- tmp++;
- tmp <<= 16;
- mac = clib_host_to_net_u64 (tmp);
+ incr_mac_address (mac);
}
}
@@ -680,9 +676,9 @@ l2fib_del_entry_by_key (u64 raw_key)
* Return 0 if the entry was deleted, or 1 if it was not found
*/
u32
-l2fib_del_entry (u64 mac, u32 bd_index)
+l2fib_del_entry (u8 * mac, u32 bd_index)
{
- return l2fib_del_entry_by_key (l2fib_make_key ((u8 *) & mac, bd_index));
+ return l2fib_del_entry_by_key (l2fib_make_key (mac, bd_index));
}
/**
@@ -696,12 +692,12 @@ l2fib_del (vlib_main_t * vm,
{
bd_main_t *bdm = &bd_main;
clib_error_t *error = 0;
- u64 mac;
+ u8 mac[6];
u32 bd_id;
u32 bd_index;
uword *p;
- if (!unformat_user (input, unformat_ethernet_address, &mac))
+ if (!unformat (input, "%U", unformat_ethernet_address, mac))
{
error = clib_error_return (0, "expected mac address `%U'",
format_unformat_error, input);
diff --git a/src/vnet/l2/l2_fib.h b/src/vnet/l2/l2_fib.h
index 7cc2dc5e15e..6346826ee99 100644
--- a/src/vnet/l2/l2_fib.h
+++ b/src/vnet/l2/l2_fib.h
@@ -371,24 +371,24 @@ l2fib_lookup_4 (BVT (clib_bihash) * mac_table,
void l2fib_clear_table (void);
void
-l2fib_add_entry (u64 mac,
+l2fib_add_entry (u8 * mac,
u32 bd_index,
u32 sw_if_index, u8 static_mac, u8 drop_mac, u8 bvi_mac);
static inline void
-l2fib_add_fwd_entry (u64 mac, u32 bd_index, u32 sw_if_index, u8 static_mac,
+l2fib_add_fwd_entry (u8 * mac, u32 bd_index, u32 sw_if_index, u8 static_mac,
u8 bvi_mac)
{
l2fib_add_entry (mac, bd_index, sw_if_index, static_mac, 0, bvi_mac);
}
static inline void
-l2fib_add_filter_entry (u64 mac, u32 bd_index)
+l2fib_add_filter_entry (u8 * mac, u32 bd_index)
{
l2fib_add_entry (mac, bd_index, ~0, 1, 1, 0);
}
-u32 l2fib_del_entry (u64 mac, u32 bd_index);
+u32 l2fib_del_entry (u8 * mac, u32 bd_index);
void l2fib_start_ager_scan (vlib_main_t * vm);
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index e556b141b3b..f60dd189e0a 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -550,7 +550,6 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
l2_output_config_t *out_config;
l2_input_config_t *config;
l2_bridge_domain_t *bd_config;
- u64 mac;
i32 l2_if_adjust = 0;
u32 slot;
@@ -572,8 +571,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
config->bvi = 0;
/* delete the l2fib entry for the bvi interface */
- mac = *((u64 *) hi->hw_address);
- l2fib_del_entry (mac, config->bd_index);
+ l2fib_del_entry (hi->hw_address, config->bd_index);
/* Make loop output node send packet back to ethernet-input node */
slot =
@@ -672,8 +670,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /* */
config->bvi = 1;
/* create the l2fib entry for the bvi interface */
- mac = *((u64 *) hi->hw_address);
- l2fib_add_fwd_entry (mac, bd_index, sw_if_index, 1, 1); /* static + bvi */
+ l2fib_add_fwd_entry (hi->hw_address, bd_index, sw_if_index, 1, 1); /* static + bvi */
/* Disable learning by default. no use since l2fib entry is static. */
config->feature_bitmap &= ~L2INPUT_FEAT_LEARN;
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 27085d940bb..1152fbb8e0d 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -382,7 +382,7 @@ static void *vl_api_l2fib_add_del_t_print
s = format (0, "SCRIPT: l2fib_add_del ");
- s = format (s, "mac %U ", format_ethernet_address, &mp->mac);
+ s = format (s, "mac %U ", format_ethernet_address, mp->mac);
s = format (s, "bd_id %d ", ntohl (mp->bd_id));
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 8e7235659be..d84012b2d2b 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -195,7 +195,7 @@ class VppPapiProvider(object):
return cli + "\n" + str(self.cli(cli))
def _convert_mac(self, mac):
- return int(mac.replace(":", ""), 16) << 16
+ return mac.replace(':', '').decode('hex')
def show_version(self):
""" """