X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip6_link.c;h=082033a9de9e831d593bb8fd852e94d7de4c8da8;hb=e2fe09742;hp=b73fbe2125f3ad9597a805108bb5f0a0533d07a1;hpb=cbe25aab3be72154f2c706c39eeba6a77f34450f;p=vpp.git diff --git a/src/vnet/ip/ip6_link.c b/src/vnet/ip/ip6_link.c index b73fbe2125f..082033a9de9 100644 --- a/src/vnet/ip/ip6_link.c +++ b/src/vnet/ip/ip6_link.c @@ -146,7 +146,7 @@ ip6_link_is_enabled (u32 sw_if_index) int -ip6_link_enable (u32 sw_if_index) +ip6_link_enable (u32 sw_if_index, const ip6_address_t * link_local_addr) { ip6_link_t *il; int rv; @@ -182,14 +182,16 @@ ip6_link_enable (u32 sw_if_index) vec_validate (ip6_links, sw_if_index); il = &ip6_links[sw_if_index]; - il->il_locks = 1; + il->il_locks = 0; il->il_sw_if_index = sw_if_index; sw = vnet_get_sup_sw_interface (vnm, sw_if_index); - if (sw->type == VNET_SW_INTERFACE_TYPE_SUB || - sw->type == VNET_SW_INTERFACE_TYPE_PIPE || - sw->type == VNET_SW_INTERFACE_TYPE_P2P) + 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) { il->il_ll_addr.as_u64[0] = clib_host_to_net_u64 (0xFE80000000000000ULL); @@ -202,7 +204,8 @@ ip6_link_enable (u32 sw_if_index) } else { - ip6_link_local_address_from_mac (&il->il_ll_addr, eth->address); + ip6_link_local_address_from_mac (&il->il_ll_addr, + eth->address.mac.bytes); } { @@ -236,6 +239,8 @@ ip6_link_enable (u32 sw_if_index) rv = VNET_API_ERROR_VALUE_EXIST; } + il->il_locks++; + out: return (rv); } @@ -245,14 +250,12 @@ ip6_link_delegate_flush (ip6_link_t * il) { ip6_link_delegate_t *ild; - /* *INDET-OFF* */ - FOREACH_IP6_LINK_DELEGATE (ild, il, ( - { - il_delegate_vfts[ild-> - ild_type].ildv_disable - (ild->ild_index); - })); - /* *INDET-ON* */ + /* *INDENT-OFF* */ + FOREACH_IP6_LINK_DELEGATE (ild, il, + ({ + il_delegate_vfts[ild->ild_type].ildv_disable(ild->ild_index); + })); + /* *INDENT-ON* */ vec_free (il->il_delegates); il->il_delegates = NULL; @@ -334,42 +337,7 @@ ip6_link_get_mcast_adj (u32 sw_if_index) } int -ip6_src_address_for_packet (u32 sw_if_index, - const ip6_address_t * dst, ip6_address_t * src) -{ - ip_lookup_main_t *lm; - - lm = &ip6_main.lookup_main; - - if (ip6_address_is_link_local_unicast (dst)) - { - ip6_address_copy (src, ip6_get_link_local_address (sw_if_index)); - - return (!0); - } - else - { - u32 if_add_index = - lm->if_address_pool_index_by_sw_if_index[sw_if_index]; - if (PREDICT_TRUE (if_add_index != ~0)) - { - ip_interface_address_t *if_add = - pool_elt_at_index (lm->if_address_pool, if_add_index); - ip6_address_t *if_ip = - ip_interface_address_get_address (lm, if_add); - *src = *if_ip; - return (!0); - } - } - - src->as_u64[0] = 0; - src->as_u64[1] = 0; - - return (0); -} - -int -ip6_set_link_local_address (u32 sw_if_index, const ip6_address_t * address) +ip6_link_set_local_address (u32 sw_if_index, const ip6_address_t * address) { ip6_link_delegate_t *ild; ip6_link_t *il; @@ -377,7 +345,7 @@ ip6_set_link_local_address (u32 sw_if_index, const ip6_address_t * address) il = ip6_link_get (sw_if_index); if (NULL == il) - return (VNET_API_ERROR_IP6_NOT_ENABLED); + return ip6_link_enable (sw_if_index, address); ip6_ll_prefix_t ilp = { .ilp_addr = il->il_ll_addr, @@ -796,7 +764,7 @@ enable_ip6_interface_cmd (vlib_main_t * vm, if (unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index)) { - if (ip6_link_enable (sw_if_index)) + if (ip6_link_enable (sw_if_index, NULL)) error = clib_error_return (0, "Failed\n"); } else