summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extras/vom/vom/bridge_domain_arp_entry.cpp9
-rw-r--r--extras/vom/vom/bridge_domain_arp_entry_cmds.cpp12
-rw-r--r--src/vat/api_format.c37
-rw-r--r--src/vnet/l2/l2.api17
-rw-r--r--src/vnet/l2/l2_api.c44
-rw-r--r--src/vpp/api/custom_dump.c6
-rw-r--r--test/test_gbp.py9
-rw-r--r--test/test_l2bd_arp_term.py7
-rw-r--r--test/vpp_l2.py42
9 files changed, 95 insertions, 88 deletions
diff --git a/extras/vom/vom/bridge_domain_arp_entry.cpp b/extras/vom/vom/bridge_domain_arp_entry.cpp
index 7221c3f2578..f468e0f977f 100644
--- a/extras/vom/vom/bridge_domain_arp_entry.cpp
+++ b/extras/vom/vom/bridge_domain_arp_entry.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/bridge_domain_arp_entry.hpp"
+#include "vom/api_types.hpp"
#include "vom/bridge_domain_arp_entry_cmds.hpp"
#include "vom/singular_db_funcs.hpp"
@@ -174,10 +175,10 @@ bridge_domain_arp_entry::event_handler::handle_populate(
for (auto& record : *cmd) {
auto& payload = record.get_payload();
- std::shared_ptr<bridge_domain> bd = bridge_domain::find(payload.bd_id);
- bridge_domain_arp_entry bd_ae(
- *bd, from_bytes(payload.is_ipv6, payload.ip_address),
- mac_address_t(payload.mac_address));
+ std::shared_ptr<bridge_domain> bd =
+ bridge_domain::find(payload.entry.bd_id);
+ bridge_domain_arp_entry bd_ae(*bd, from_api(payload.entry.ip),
+ from_api(payload.entry.mac));
VOM_LOG(log_level_t::DEBUG) << "dump: " << bd_ae.to_string();
diff --git a/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp b/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
index a72ad3ed874..e1a80908271 100644
--- a/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
+++ b/extras/vom/vom/bridge_domain_arp_entry_cmds.cpp
@@ -43,10 +43,10 @@ create_cmd::issue(connection& con)
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
- payload.bd_id = m_bd;
+ payload.entry.bd_id = m_bd;
payload.is_add = 1;
- to_api(m_mac, payload.mac);
- to_api(m_ip_addr, payload.ip);
+ to_api(m_mac, payload.entry.mac);
+ to_api(m_ip_addr, payload.entry.ip);
VAPI_CALL(req.execute());
@@ -88,10 +88,10 @@ delete_cmd::issue(connection& con)
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
- payload.bd_id = m_bd;
+ payload.entry.bd_id = m_bd;
payload.is_add = 0;
- to_api(m_mac, payload.mac);
- to_api(m_ip_addr, payload.ip);
+ to_api(m_mac, payload.entry.mac);
+ to_api(m_ip_addr, payload.entry.ip);
VAPI_CALL(req.execute());
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 536c4b06ba2..d9a9d223804 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -7300,11 +7300,11 @@ api_bd_ip_mac_add_del (vat_main_t * vam)
M (BD_IP_MAC_ADD_DEL, mp);
- mp->bd_id = ntohl (bd_id);
+ mp->entry.bd_id = ntohl (bd_id);
mp->is_add = is_add;
- clib_memcpy (&mp->ip, &ip, sizeof (ip));
- clib_memcpy (&mp->mac, &mac, sizeof (mac));
+ clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
+ clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
S (mp);
W (ret);
@@ -7349,21 +7349,12 @@ static void vl_api_bd_ip_mac_details_t_handler
(vl_api_bd_ip_mac_details_t * mp)
{
vat_main_t *vam = &vat_main;
- u8 *ip = 0;
-
- if (!mp->is_ipv6)
- ip =
- format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
- else
- ip =
- format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
print (vam->ofp,
- "\n%-5d %-7s %-20U %-30s",
- ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
- format_ethernet_address, mp->mac_address, ip);
-
- vec_free (ip);
+ "\n%-5d %U %U",
+ ntohl (mp->entry.bd_id),
+ format_vl_api_mac_address, mp->entry.mac,
+ format_vl_api_address, &mp->entry.ip);
}
static void vl_api_bd_ip_mac_details_t_handler_json
@@ -7380,19 +7371,13 @@ static void vl_api_bd_ip_mac_details_t_handler_json
node = vat_json_array_add (&vam->json_tree);
vat_json_init_object (node);
- vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
- vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
+ vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
vat_json_object_add_string_copy (node, "mac_address",
- format (0, "%U", format_ethernet_address,
- &mp->mac_address));
+ format (0, "%U", format_vl_api_mac_address,
+ &mp->entry.mac));
u8 *ip = 0;
- if (!mp->is_ipv6)
- ip =
- format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
- else
- ip =
- format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
+ ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
vat_json_object_add_string_copy (node, "ip_address", ip);
vec_free (ip);
}
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api
index f756b87868c..4b1029d90f8 100644
--- a/src/vnet/l2/l2.api
+++ b/src/vnet/l2/l2.api
@@ -482,14 +482,20 @@ autoreply define sw_interface_set_l2_bridge
@param ip - ipv4 or ipv6 address
@param mac - MAC address
*/
+
+typedef bd_ip_mac
+{
+ u32 bd_id;
+ vl_api_address_t ip;
+ vl_api_mac_address_t mac;
+};
+
autoreply define bd_ip_mac_add_del
{
u32 client_index;
u32 context;
- u32 bd_id;
u8 is_add;
- vl_api_address_t ip;
- vl_api_mac_address_t mac;
+ vl_api_bd_ip_mac_t entry;
};
/** \brief Flush bridge domain IP to MAC entries
@@ -512,10 +518,7 @@ autoreply define bd_ip_mac_flush
define bd_ip_mac_details
{
u32 context;
- u32 bd_id;
- u8 is_ipv6;
- u8 ip_address[16];
- vl_api_mac_address_t mac_address;
+ vl_api_bd_ip_mac_t entry;
};
/** \brief Dump bridge domain IP to MAC entries
diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c
index 47942ecfb2a..255e91b2e0a 100644
--- a/src/vnet/l2/l2_api.c
+++ b/src/vnet/l2/l2_api.c
@@ -786,8 +786,10 @@ out:
static void
send_bd_ip_mac_entry (vpe_api_main_t * am,
vl_api_registration_t * reg,
- u32 bd_id, u8 is_ipv6,
- u8 * ip_address, u8 * mac_address, u32 context)
+ u32 bd_id,
+ const ip46_address_t * ip,
+ ip46_type_t itype,
+ const mac_address_t * mac, u32 context)
{
vl_api_bd_ip_mac_details_t *mp;
@@ -795,12 +797,11 @@ send_bd_ip_mac_entry (vpe_api_main_t * am,
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_BD_IP_MAC_DETAILS);
- mp->bd_id = ntohl (bd_id);
-
- clib_memcpy (mp->mac_address, mac_address, 6);
- mp->is_ipv6 = is_ipv6;
- clib_memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);
mp->context = context;
+ mp->entry.bd_id = ntohl (bd_id);
+
+ ip_address_encode (ip, itype, &mp->entry.ip);
+ mac_address_encode (mac, mp->entry.mac);
vl_api_send_msg (reg, (u8 *) mp);
}
@@ -845,18 +846,31 @@ vl_api_bd_ip_mac_dump_t_handler (vl_api_bd_ip_mac_dump_t * mp)
{
ip4_address_t ip4_addr;
ip6_address_t *ip6_addr;
- u64 mac_addr;
+ mac_address_t mac;
+ u64 mac64;
bd_id = bd_config->bd_id;
/* *INDENT-OFF* */
- hash_foreach (ip4_addr.as_u32, mac_addr, bd_config->mac_by_ip4,
+ hash_foreach (ip4_addr.as_u32, mac64, bd_config->mac_by_ip4,
({
- send_bd_ip_mac_entry (am, reg, bd_id, 0, (u8 *) &(ip4_addr.as_u8), (u8 *) &mac_addr, mp->context);
+ ip46_address_t ip = {
+ .ip4 = ip4_addr,
+ };
+ mac_address_from_u64(&mac, mac64);
+
+ send_bd_ip_mac_entry (am, reg, bd_id, &ip, IP46_TYPE_IP4,
+ &mac, mp->context);
}));
- hash_foreach_mem (ip6_addr, mac_addr, bd_config->mac_by_ip6,
+ hash_foreach_mem (ip6_addr, mac64, bd_config->mac_by_ip6,
({
- send_bd_ip_mac_entry (am, reg, bd_id, 1, (u8 *) &(ip6_addr->as_u8), (u8 *) &mac_addr, mp->context);
+ ip46_address_t ip = {
+ .ip6 = *ip6_addr,
+ };
+ mac_address_from_u64(&mac, mac64);
+
+ send_bd_ip_mac_entry (am, reg, bd_id, &ip, IP46_TYPE_IP6,
+ &mac, mp->context);
}));
/* *INDENT-ON* */
}
@@ -875,7 +889,7 @@ vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
int rv = 0;
uword *p;
- bd_id = ntohl (mp->bd_id);
+ bd_id = ntohl (mp->entry.bd_id);
if (bd_id == 0)
{
@@ -891,8 +905,8 @@ vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
}
bd_index = p[0];
- type = ip_address_decode (&mp->ip, &ip_addr);
- mac_address_decode (mp->mac, &mac);
+ type = ip_address_decode (&mp->entry.ip, &ip_addr);
+ mac_address_decode (mp->entry.mac, &mac);
if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, mp->is_add))
rv = VNET_API_ERROR_UNSPECIFIED;
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 494e1ab5cc8..94a868e0353 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -511,10 +511,10 @@ static void *vl_api_bd_ip_mac_add_del_t_print
u8 *s;
s = format (0, "SCRIPT: bd_ip_mac_add_del ");
- s = format (s, "bd_id %d ", ntohl (mp->bd_id));
+ s = format (s, "bd_id %d ", ntohl (mp->entry.bd_id));
- s = format (s, "%U ", format_vl_api_address, &mp->ip);
- s = format (s, "%U ", format_vl_api_mac_address, &mp->mac);
+ s = format (s, "%U ", format_vl_api_address, &mp->entry.ip);
+ s = format (s, "%U ", format_vl_api_mac_address, &mp->entry.mac);
if (mp->is_add == 0)
s = format (s, "del ");
diff --git a/test/test_gbp.py b/test/test_gbp.py
index 42defbf0d5c..0580fff2b6f 100644
--- a/test/test_gbp.py
+++ b/test/test_gbp.py
@@ -841,10 +841,10 @@ class TestGBP(VppTestCase):
# add the BD ARP termination entry for BVI IP
epg.bd_arp_ip4 = VppBridgeDomainArpEntry(self, epg.bd.bd,
str(self.router_mac),
- epg.bvi_ip4)
+ epg.bvi_ip4.address)
epg.bd_arp_ip6 = VppBridgeDomainArpEntry(self, epg.bd.bd,
str(self.router_mac),
- epg.bvi_ip6)
+ epg.bvi_ip6.address)
epg.bd_arp_ip4.add_vpp_config()
epg.bd_arp_ip6.add_vpp_config()
@@ -917,7 +917,8 @@ class TestGBP(VppTestCase):
# add the BD ARP termination entry for floating IP
for fip in ep.fips:
- ba = VppBridgeDomainArpEntry(self, epg_nat.bd.bd, ep.mac, fip)
+ ba = VppBridgeDomainArpEntry(self, epg_nat.bd.bd, ep.mac,
+ fip.address)
ba.add_vpp_config()
# floating IPs route via EPG recirc
@@ -2063,7 +2064,7 @@ class TestGBP(VppTestCase):
# add the BD ARP termination entry for BVI IP
epg.bd_arp_ip4 = VppBridgeDomainArpEntry(self, epg.bd.bd,
str(self.router_mac),
- epg.bvi_ip4)
+ epg.bvi_ip4.address)
epg.bd_arp_ip4.add_vpp_config()
# EPG in VPP
diff --git a/test/test_l2bd_arp_term.py b/test/test_l2bd_arp_term.py
index fa67acc18ec..bdf0a80caa7 100644
--- a/test/test_l2bd_arp_term.py
+++ b/test/test_l2bd_arp_term.py
@@ -78,8 +78,11 @@ class TestL2bdArpTerm(VppTestCase):
def add_del_arp_term_hosts(self, entries, bd_id=1, is_add=1, is_ipv6=0):
for e in entries:
ip = e.ip4 if is_ipv6 == 0 else e.ip6
- self.vapi.bd_ip_mac_add_del(bd_id=bd_id, is_add=is_add, ip=ip,
- mac=e.mac)
+ self.vapi.bd_ip_mac_add_del(is_add=is_add,
+ entry={
+ 'bd_id': bd_id,
+ 'ip': ip,
+ 'mac': e.mac})
@classmethod
def mac_list(cls, b6_range):
diff --git a/test/vpp_l2.py b/test/vpp_l2.py
index 90de91695f2..3ee0d35384e 100644
--- a/test/vpp_l2.py
+++ b/test/vpp_l2.py
@@ -8,6 +8,10 @@ from vpp_ip import VppIpAddress
from vpp_lo_interface import VppLoInterface
from vpp_papi import MACAddress
from vpp_sub_interface import L2_VTR_OP
+try:
+ text_type = unicode
+except NameError:
+ text_type = str
class L2_PORT_TYPE:
@@ -41,19 +45,11 @@ def find_bridge_domain_port(test, bd_id, sw_if_index):
def find_bridge_domain_arp_entry(test, bd_id, mac, ip):
- vmac = MACAddress(mac)
- vip = VppIpAddress(ip)
-
- if vip.version == 4:
- n = 4
- else:
- n = 16
-
arps = test.vapi.bd_ip_mac_dump(bd_id)
for arp in arps:
# do IP addr comparison too once .api is fixed...
- if vmac.packed == arp.mac_address and \
- vip.bytes == arp.ip_address[:n]:
+ if mac == str(arp.entry.mac) and \
+ ip == str(arp.entry.ip):
return True
return False
@@ -136,28 +132,32 @@ class VppBridgeDomainArpEntry(VppObject):
def __init__(self, test, bd, mac, ip):
self._test = test
self.bd = bd
- self.mac = MACAddress(mac)
- self.ip = VppIpAddress(ip)
+ self.mac = mac
+ self.ip = ip
def add_vpp_config(self):
- self._test.vapi.bd_ip_mac_add_del(bd_id=self.bd.bd_id, is_add=1,
- ip=self.ip.encode(),
- mac=self.mac.packed)
+ self._test.vapi.bd_ip_mac_add_del(is_add=1,
+ entry={
+ 'bd_id': self.bd.bd_id,
+ 'ip': self.ip,
+ 'mac': self.mac})
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
- self._test.vapi.bd_ip_mac_add_del(bd_id=self.bd.bd_id, is_add=0,
- ip=self.ip.encode(),
- mac=self.mac.packed)
+ self._test.vapi.bd_ip_mac_add_del(is_add=0,
+ entry={
+ 'bd_id': self.bd.bd_id,
+ 'ip': self.ip,
+ 'mac': self.mac})
def query_vpp_config(self):
return find_bridge_domain_arp_entry(self._test,
self.bd.bd_id,
- self.mac.packed,
- self.ip.address)
+ self.mac,
+ self.ip)
def object_id(self):
- return "BD-Arp-Entry-%s-%s-%s" % (self.bd, self.mac, self.ip.address)
+ return "BD-Arp-Entry-%s-%s-%s" % (self.bd, self.mac, self.ip)
class VppL2FibEntry(VppObject):