aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip6_link.c
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2021-05-20 16:28:12 +0000
committerBeno�t Ganne <bganne@cisco.com>2021-05-27 12:06:57 +0000
commitdfef64b4cd99a610159a790faa618584157edc63 (patch)
tree68403ddc9f7c31aa4f57476c59290f5198a0de3d /src/vnet/ip/ip6_link.c
parent3f3da0d27dcf83808f2691205b891a42ac2b4679 (diff)
ip: allow the 'ip6 enable' on tunnel interface types
Type: feature This was limited to HW interface types (for historical reason AFAICT) Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: I3785a356ae31722fa60d84f64ec9aa53ebdd615f
Diffstat (limited to 'src/vnet/ip/ip6_link.c')
-rw-r--r--src/vnet/ip/ip6_link.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/vnet/ip/ip6_link.c b/src/vnet/ip/ip6_link.c
index 0527b2ffc52..afa9d8e3ea9 100644
--- a/src/vnet/ip/ip6_link.c
+++ b/src/vnet/ip/ip6_link.c
@@ -155,43 +155,38 @@ ip6_link_enable (u32 sw_if_index, const ip6_address_t * link_local_addr)
if (NULL == il)
{
- const vnet_sw_interface_t *sw, *sw_sup;
+ const vnet_sw_interface_t *sw_sup;
const ethernet_interface_t *eth;
vnet_main_t *vnm;
+ eth = NULL;
vnm = vnet_get_main ();
IP6_LINK_INFO ("enable: %U",
format_vnet_sw_if_index_name, vnm, sw_if_index);
sw_sup = vnet_get_sup_sw_interface (vnm, sw_if_index);
- if (sw_sup->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
- {
- rv = VNET_API_ERROR_UNSUPPORTED;
- goto out;
- }
-
- eth = ethernet_get_interface (&ethernet_main, sw_sup->hw_if_index);
-
- if (NULL == eth)
- {
- rv = VNET_API_ERROR_UNSUPPORTED;
- goto out;
- }
-
vec_validate (ip6_links, sw_if_index);
il = &ip6_links[sw_if_index];
il->il_locks = 0;
il->il_sw_if_index = sw_if_index;
+ il->il_mcast_adj = ADJ_INDEX_INVALID;
- sw = vnet_get_sup_sw_interface (vnm, sw_if_index);
+ if (sw_sup->type == VNET_SW_INTERFACE_TYPE_HARDWARE)
+ eth = ethernet_get_interface (&ethernet_main, sw_sup->hw_if_index);
+ /* use a user provided LL address if given */
if (NULL != link_local_addr)
ip6_address_copy (&il->il_ll_addr, link_local_addr);
- else if (sw->type == VNET_SW_INTERFACE_TYPE_SUB ||
- sw->type == VNET_SW_INTERFACE_TYPE_PIPE ||
- sw->type == VNET_SW_INTERFACE_TYPE_P2P)
+
+ /* generate from ethernet MAC */
+ if (ip6_address_is_zero (&il->il_ll_addr) && NULL != eth)
+ ip6_link_local_address_from_mac (&il->il_ll_addr,
+ eth->address.mac.bytes);
+
+ /* choose a random address */
+ if (ip6_address_is_zero (&il->il_ll_addr))
{
il->il_ll_addr.as_u64[0] =
clib_host_to_net_u64 (0xFE80000000000000ULL);
@@ -202,11 +197,6 @@ ip6_link_enable (u32 sw_if_index, const ip6_address_t * link_local_addr)
/* clear u bit */
il->il_ll_addr.as_u8[8] &= 0xfd;
}
- else
- {
- ip6_link_local_address_from_mac (&il->il_ll_addr,
- eth->address.mac.bytes);
- }
{
ip6_ll_prefix_t ilp = {
@@ -221,8 +211,11 @@ ip6_link_enable (u32 sw_if_index, const ip6_address_t * link_local_addr)
ip6_mfib_interface_enable_disable (sw_if_index, 1);
ip6_sw_interface_enable_disable (sw_if_index, 1);
- il->il_mcast_adj = adj_mcast_add_or_lock (FIB_PROTOCOL_IP6,
- VNET_LINK_IP6, sw_if_index);
+ /* only ehternet interfaces support MLD and RA, which use the mcast adj
+ */
+ if (NULL != eth)
+ il->il_mcast_adj =
+ adj_mcast_add_or_lock (FIB_PROTOCOL_IP6, VNET_LINK_IP6, sw_if_index);
/* inform all register clients */
ip6_link_delegate_id_t id;
@@ -241,7 +234,6 @@ ip6_link_enable (u32 sw_if_index, const ip6_address_t * link_local_addr)
il->il_locks++;
-out:
return (rv);
}