aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-02-16 02:44:05 -0800
committerNeale Ranns <neale.ranns@cisco.com>2018-02-16 02:44:08 -0800
commitc819fc612f9a79eaba2981dc2e8f7c31552db5ea (patch)
treeba19a3f7b2f223ebd28e3fe87ad5f73ef81d9745
parent25d417f28680c78a709792d997884dd80227bb70 (diff)
Allow providers to override glean behaviour
and update glean address on local interface MAC change Change-Id: I530826d60c7e9db2b0fa2d45754139d82c5ea807 Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
-rw-r--r--src/vnet/adj/adj_glean.c64
-rw-r--r--src/vnet/adj/adj_glean.h19
-rw-r--r--src/vnet/adj/adj_internal.h15
-rw-r--r--src/vnet/adj/adj_midchain.c9
-rw-r--r--src/vnet/adj/adj_nbr.c15
-rw-r--r--src/vnet/ethernet/arp.c10
-rw-r--r--src/vnet/interface.c4
-rw-r--r--src/vnet/ip/ip6_neighbor.c10
-rw-r--r--src/vnet/ip/lookup.c41
-rw-r--r--test/test_bier.py2
-rw-r--r--test/test_neighbor.py70
-rw-r--r--test/vpp_papi_provider.py5
12 files changed, 186 insertions, 78 deletions
diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c
index 82023f12dd2..82d0a46eb1f 100644
--- a/src/vnet/adj/adj_glean.c
+++ b/src/vnet/adj/adj_glean.c
@@ -68,26 +68,55 @@ adj_glean_add_or_lock (fib_protocol_t proto,
adj->sub_type.glean.receive_addr = *nh_addr;
}
+ adj->rewrite_header.sw_if_index = sw_if_index;
adj->rewrite_header.data_bytes = 0;
+ adj_lock(adj_get_index(adj));
- vnet_rewrite_for_sw_interface(vnet_get_main(),
- adj_fib_proto_2_nd(proto),
- sw_if_index,
- adj_get_glean_node(proto)->index,
- VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST,
- &adj->rewrite_header,
- sizeof (adj->rewrite_data));
+ vnet_update_adjacency_for_sw_interface(vnet_get_main(),
+ sw_if_index,
+ adj_get_index(adj));
}
else
{
adj = adj_get(adj_gleans[proto][sw_if_index]);
+ adj_lock(adj_get_index(adj));
}
- adj_lock(adj_get_index(adj));
-
return (adj_get_index(adj));
}
+/**
+ * adj_glean_update_rewrite
+ */
+void
+adj_glean_update_rewrite (adj_index_t adj_index)
+{
+ ip_adjacency_t *adj;
+
+ ASSERT(ADJ_INDEX_INVALID != adj_index);
+
+ adj = adj_get(adj_index);
+
+ vnet_rewrite_for_sw_interface(vnet_get_main(),
+ adj_fib_proto_2_nd(adj->ia_nh_proto),
+ adj->rewrite_header.sw_if_index,
+ adj_get_glean_node(adj->ia_nh_proto)->index,
+ VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST,
+ &adj->rewrite_header,
+ sizeof (adj->rewrite_data));
+}
+
+adj_index_t
+adj_glean_get (fib_protocol_t proto,
+ u32 sw_if_index)
+{
+ if (sw_if_index < vec_len(adj_gleans[proto]))
+ {
+ return (adj_gleans[proto][sw_if_index]);
+ }
+ return (ADJ_INDEX_INVALID);
+}
+
void
adj_glean_remove (fib_protocol_t proto,
u32 sw_if_index)
@@ -227,12 +256,17 @@ format_adj_glean (u8* s, va_list *ap)
vnet_main_t * vnm = vnet_get_main();
ip_adjacency_t * adj = adj_get(index);
- return (format(s, "%U-glean: %U",
- format_fib_protocol, adj->ia_nh_proto,
- format_vnet_sw_interface_name,
- vnm,
- vnet_get_sw_interface(vnm,
- adj->rewrite_header.sw_if_index)));
+ s = format(s, "%U-glean: %U",
+ format_fib_protocol, adj->ia_nh_proto,
+ format_vnet_sw_interface_name,
+ vnm,
+ vnet_get_sw_interface(vnm,
+ adj->rewrite_header.sw_if_index));
+ s = format (s, " %U",
+ format_vnet_rewrite,
+ &adj->rewrite_header, sizeof (adj->rewrite_data), 0);
+
+ return (s);
}
diff --git a/src/vnet/adj/adj_glean.h b/src/vnet/adj/adj_glean.h
index 640bd2f91eb..47cddfbed2b 100644
--- a/src/vnet/adj/adj_glean.h
+++ b/src/vnet/adj/adj_glean.h
@@ -48,6 +48,25 @@ extern adj_index_t adj_glean_add_or_lock(fib_protocol_t proto,
const ip46_address_t *nh_addr);
/**
+ * @brief Get an existing glean
+ *
+ * @return INVALID if it does not exist
+ */
+extern adj_index_t adj_glean_get(fib_protocol_t proto,
+ u32 sw_if_index);
+
+/**
+ * adj_glean_update_rewrite
+ *
+ * Called by an adjacency provider (an interface type) to configure
+ * a glean adj (i.e. and adjacency linked to a connected prefix) to
+ * its default behaviour.
+ * Other interface types (i.e. 6RD tunnels) can can choose not to use
+ * glean behaviour on an adjacency liked to a connected prefix.
+ */
+extern void adj_glean_update_rewrite(adj_index_t adj_index);
+
+/**
* @brief Format/display a glean adjacency.
*/
extern u8* format_adj_glean(u8* s, va_list *ap);
diff --git a/src/vnet/adj/adj_internal.h b/src/vnet/adj/adj_internal.h
index e6d276e4d02..3b7ddb2f10c 100644
--- a/src/vnet/adj/adj_internal.h
+++ b/src/vnet/adj/adj_internal.h
@@ -78,6 +78,21 @@ adj_fib_proto_2_nd (fib_protocol_t fp)
return (0);
}
+static inline ip46_type_t
+adj_proto_to_46 (fib_protocol_t proto)
+{
+ switch (proto)
+ {
+ case FIB_PROTOCOL_IP4:
+ return (IP46_TYPE_IP4);
+ case FIB_PROTOCOL_IP6:
+ return (IP46_TYPE_IP6);
+ default:
+ return (IP46_TYPE_IP4);
+ }
+ return (IP46_TYPE_IP4);
+}
+
/**
* @brief
* Get a pointer to an adjacency object from its index
diff --git a/src/vnet/adj/adj_midchain.c b/src/vnet/adj/adj_midchain.c
index 9fd3246b15a..b6cb8240a52 100644
--- a/src/vnet/adj/adj_midchain.c
+++ b/src/vnet/adj/adj_midchain.c
@@ -519,7 +519,9 @@ adj_nbr_midchain_update_rewrite (adj_index_t adj_index,
* one time only update. since we don't support chainging the tunnel
* src,dst, this is all we need.
*/
- ASSERT(adj->lookup_next_index == IP_LOOKUP_NEXT_ARP);
+ ASSERT((adj->lookup_next_index == IP_LOOKUP_NEXT_ARP) ||
+ (adj->lookup_next_index == IP_LOOKUP_NEXT_GLEAN));
+
/*
* tunnels can always provide a rewrite.
*/
@@ -590,8 +592,9 @@ format_adj_midchain (u8* s, va_list *ap)
ip_adjacency_t * adj = adj_get(index);
s = format (s, "%U", format_vnet_link, adj->ia_link);
- s = format (s, " via %U ",
- format_ip46_address, &adj->sub_type.nbr.next_hop);
+ s = format (s, " via %U",
+ format_ip46_address, &adj->sub_type.nbr.next_hop,
+ adj_proto_to_46(adj->ia_nh_proto));
s = format (s, " %U",
format_vnet_rewrite,
&adj->rewrite_header, sizeof (adj->rewrite_data), indent);
diff --git a/src/vnet/adj/adj_nbr.c b/src/vnet/adj/adj_nbr.c
index fc7a7fcd93c..97940da0271 100644
--- a/src/vnet/adj/adj_nbr.c
+++ b/src/vnet/adj/adj_nbr.c
@@ -968,21 +968,6 @@ VLIB_CLI_COMMAND (ip4_show_fib_command, static) = {
.function = adj_nbr_show,
};
-static ip46_type_t
-adj_proto_to_46 (fib_protocol_t proto)
-{
- switch (proto)
- {
- case FIB_PROTOCOL_IP4:
- return (IP46_TYPE_IP4);
- case FIB_PROTOCOL_IP6:
- return (IP46_TYPE_IP6);
- default:
- return (IP46_TYPE_IP4);
- }
- return (IP46_TYPE_IP4);
-}
-
u8*
format_adj_nbr_incomplete (u8* s, va_list *ap)
{
diff --git a/src/vnet/ethernet/arp.c b/src/vnet/ethernet/arp.c
index 149f0a5dc96..4e5f867e8b1 100644
--- a/src/vnet/ethernet/arp.c
+++ b/src/vnet/ethernet/arp.c
@@ -455,8 +455,10 @@ arp_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai)
switch (adj->lookup_next_index)
{
- case IP_LOOKUP_NEXT_ARP:
case IP_LOOKUP_NEXT_GLEAN:
+ adj_glean_update_rewrite (ai);
+ break;
+ case IP_LOOKUP_NEXT_ARP:
if (NULL != e)
{
adj_nbr_walk_nh4 (sw_if_index,
@@ -2480,6 +2482,7 @@ ethernet_arp_change_mac (u32 sw_if_index)
{
ethernet_arp_main_t *am = &ethernet_arp_main;
ethernet_arp_ip4_entry_t *e;
+ adj_index_t ai;
/* *INDENT-OFF* */
pool_foreach (e, am->ip4_entry_pool,
@@ -2487,6 +2490,11 @@ ethernet_arp_change_mac (u32 sw_if_index)
change_arp_mac (sw_if_index, e);
}));
/* *INDENT-ON* */
+
+ ai = adj_glean_get (FIB_PROTOCOL_IP4, sw_if_index);
+
+ if (ADJ_INDEX_INVALID != ai)
+ adj_glean_update_rewrite (ai);
}
void
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 7516aec0e71..b197aa1e073 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -1453,8 +1453,10 @@ default_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai)
switch (adj->lookup_next_index)
{
- case IP_LOOKUP_NEXT_ARP:
case IP_LOOKUP_NEXT_GLEAN:
+ adj_glean_update_rewrite (ai);
+ break;
+ case IP_LOOKUP_NEXT_ARP:
/*
* default rewirte in neighbour adj
*/
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index 82b402ff263..4c1b1bb10e6 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -566,8 +566,10 @@ ip6_ethernet_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai)
switch (adj->lookup_next_index)
{
- case IP_LOOKUP_NEXT_ARP:
case IP_LOOKUP_NEXT_GLEAN:
+ adj_glean_update_rewrite (ai);
+ break;
+ case IP_LOOKUP_NEXT_ARP:
if (NULL != nbr)
{
adj_nbr_walk_nh6 (sw_if_index, &nbr->key.ip6_address,
@@ -4256,6 +4258,7 @@ ethernet_ndp_change_mac (u32 sw_if_index)
{
ip6_neighbor_main_t *nm = &ip6_neighbor_main;
ip6_neighbor_t *n;
+ adj_index_t ai;
/* *INDENT-OFF* */
pool_foreach (n, nm->neighbor_pool,
@@ -4268,6 +4271,11 @@ ethernet_ndp_change_mac (u32 sw_if_index)
}
}));
/* *INDENT-ON* */
+
+ ai = adj_glean_get (FIB_PROTOCOL_IP6, sw_if_index);
+
+ if (ADJ_INDEX_INVALID != ai)
+ adj_glean_update_rewrite (ai);
}
void
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index f2880bf8cd9..256000a2242 100644
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -255,47 +255,6 @@ format_ip_flow_hash_config (u8 * s, va_list * args)
}
u8 *
-format_ip_lookup_next (u8 * s, va_list * args)
-{
- /* int promotion of ip_lookup_next_t */
- ip_lookup_next_t n = va_arg (*args, int);
- char *t = 0;
-
- switch (n)
- {
- default:
- s = format (s, "unknown %d", n);
- return s;
-
- case IP_LOOKUP_NEXT_DROP:
- t = "drop";
- break;
- case IP_LOOKUP_NEXT_PUNT:
- t = "punt";
- break;
- case IP_LOOKUP_NEXT_ARP:
- t = "arp";
- break;
- case IP_LOOKUP_NEXT_MIDCHAIN:
- t = "midchain";
- break;
- case IP_LOOKUP_NEXT_GLEAN:
- t = "glean";
- break;
- case IP_LOOKUP_NEXT_MCAST:
- t = "mcast";
- break;
- case IP_LOOKUP_NEXT_REWRITE:
- break;
- }
-
- if (t)
- vec_add (s, t, strlen (t));
-
- return s;
-}
-
-u8 *
format_ip_adjacency_packet_data (u8 * s, va_list * args)
{
u32 adj_index = va_arg (*args, u32);
diff --git a/test/test_bier.py b/test/test_bier.py
index a70dd0978cb..ae7b46a130c 100644
--- a/test/test_bier.py
+++ b/test/test_bier.py
@@ -195,7 +195,7 @@ class TestBier(VppTestCase):
self.bier_midpoint(BIERLength.BIER_LEN_128, 16, 128)
def test_bier_midpoint_64(self):
- """BIER midpoint BSL:256"""
+ """BIER midpoint BSL:64"""
self.bier_midpoint(BIERLength.BIER_LEN_64, 8, 64)
def test_bier_head(self):
diff --git a/test/test_neighbor.py b/test/test_neighbor.py
index 47e9c5bed76..7798fdd5e7c 100644
--- a/test/test_neighbor.py
+++ b/test/test_neighbor.py
@@ -1144,6 +1144,76 @@ class ARPTestCase(VppTestCase):
self.pg2.unconfig_ip4()
self.pg2.set_table_ip4(0)
+ def test_arp_incomplete(self):
+ """ ARP Incomplete"""
+ self.pg1.generate_remote_hosts(3)
+
+ p0 = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
+ IP(src=self.pg0.remote_ip4,
+ dst=self.pg1.remote_hosts[1].ip4) /
+ UDP(sport=1234, dport=1234) /
+ Raw())
+ p1 = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
+ IP(src=self.pg0.remote_ip4,
+ dst=self.pg1.remote_hosts[2].ip4) /
+ UDP(sport=1234, dport=1234) /
+ Raw())
+
+ #
+ # a packet to an unresolved destination generates an ARP request
+ #
+ rx = self.send_and_expect(self.pg0, [p0], self.pg1)
+ self.verify_arp_req(rx[0],
+ self.pg1.local_mac,
+ self.pg1.local_ip4,
+ self.pg1._remote_hosts[1].ip4)
+
+ #
+ # add a neighbour for remote host 1
+ #
+ static_arp = VppNeighbor(self,
+ self.pg1.sw_if_index,
+ self.pg1.remote_hosts[1].mac,
+ self.pg1.remote_hosts[1].ip4,
+ is_static=1)
+ static_arp.add_vpp_config()
+
+ #
+ # change the interface's MAC
+ #
+ mac = [chr(0x00), chr(0x00), chr(0x00),
+ chr(0x33), chr(0x33), chr(0x33)]
+ mac_string = ''.join(mac)
+
+ self.vapi.sw_interface_set_mac_address(self.pg1.sw_if_index,
+ mac_string)
+
+ #
+ # now ARP requests come from the new source mac
+ #
+ rx = self.send_and_expect(self.pg0, [p1], self.pg1)
+ self.verify_arp_req(rx[0],
+ "00:00:00:33:33:33",
+ self.pg1.local_ip4,
+ self.pg1._remote_hosts[2].ip4)
+
+ #
+ # packets to the resolved host also have the new source mac
+ #
+ rx = self.send_and_expect(self.pg0, [p0], self.pg1)
+ self.verify_ip(rx[0],
+ "00:00:00:33:33:33",
+ self.pg1.remote_hosts[1].mac,
+ self.pg0.remote_ip4,
+ self.pg1.remote_hosts[1].ip4)
+
+ #
+ # set the mac address on the inteface that does not have a
+ # configured subnet and thus no glean
+ #
+ self.vapi.sw_interface_set_mac_address(self.pg2.sw_if_index,
+ mac_string)
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index cdbe08d6a71..8e53333b624 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -639,6 +639,11 @@ class VppPapiProvider(object):
{'sw_if_index': sw_if_index,
'mtu': mtu})
+ def sw_interface_set_mac_address(self, sw_if_index, mac):
+ return self.api(self.papi.sw_interface_set_mac_address,
+ {'sw_if_index': sw_if_index,
+ 'mac_address': mac})
+
def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0):