ip: add API to retrieve IPv6 link-layer address
Type: feature Change-Id: I5739869490155b0b9674b4faf61882d97e66a4ed Signed-off-by: Benoît Ganne <bganne@cisco.com>
This commit is contained in:

committed by
Neale Ranns

parent
b2525922cd
commit
58a1915b50
@ -20,7 +20,7 @@
|
|||||||
called through a shared memory interface.
|
called through a shared memory interface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
option version = "3.0.1";
|
option version = "3.0.2";
|
||||||
|
|
||||||
import "vnet/interface_types.api";
|
import "vnet/interface_types.api";
|
||||||
import "vnet/fib/fib_types.api";
|
import "vnet/fib/fib_types.api";
|
||||||
@ -549,6 +549,29 @@ autoreply define sw_interface_ip6_set_link_local_address
|
|||||||
vl_api_ip6_address_t ip;
|
vl_api_ip6_address_t ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** \brief IPv6 get link local address on interface request
|
||||||
|
@param client_index - opaque cookie to identify the sender
|
||||||
|
@param context - sender context, to match reply w/ request
|
||||||
|
@param sw_if_index - interface to set link local on
|
||||||
|
*/
|
||||||
|
define sw_interface_ip6_get_link_local_address
|
||||||
|
{
|
||||||
|
u32 client_index;
|
||||||
|
u32 context;
|
||||||
|
vl_api_interface_index_t sw_if_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief IPv6 link local address detail
|
||||||
|
@param context - sender context, to match reply w/ request
|
||||||
|
@param ip - the link local address
|
||||||
|
*/
|
||||||
|
define sw_interface_ip6_get_link_local_address_reply
|
||||||
|
{
|
||||||
|
u32 context;
|
||||||
|
i32 retval;
|
||||||
|
vl_api_ip6_address_t ip;
|
||||||
|
};
|
||||||
|
|
||||||
/** \brief IOAM enable : Enable in-band OAM
|
/** \brief IOAM enable : Enable in-band OAM
|
||||||
@param id - profile id
|
@param id - profile id
|
||||||
@param seqno - To enable Seqno Processing
|
@param seqno - To enable Seqno Processing
|
||||||
|
@ -67,40 +67,42 @@
|
|||||||
|
|
||||||
#include <vnet/format_fns.h>
|
#include <vnet/format_fns.h>
|
||||||
|
|
||||||
#define foreach_ip_api_msg \
|
#define foreach_ip_api_msg \
|
||||||
_(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \
|
_ (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \
|
||||||
_(IP_TABLE_DUMP, ip_table_dump) \
|
_ (IP_TABLE_DUMP, ip_table_dump) \
|
||||||
_(IP_ROUTE_DUMP, ip_route_dump) \
|
_ (IP_ROUTE_DUMP, ip_route_dump) \
|
||||||
_(IP_MTABLE_DUMP, ip_mtable_dump) \
|
_ (IP_MTABLE_DUMP, ip_mtable_dump) \
|
||||||
_(IP_MROUTE_DUMP, ip_mroute_dump) \
|
_ (IP_MROUTE_DUMP, ip_mroute_dump) \
|
||||||
_(IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
|
_ (IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
|
||||||
_(MFIB_SIGNAL_DUMP, mfib_signal_dump) \
|
_ (MFIB_SIGNAL_DUMP, mfib_signal_dump) \
|
||||||
_(IP_ADDRESS_DUMP, ip_address_dump) \
|
_ (IP_ADDRESS_DUMP, ip_address_dump) \
|
||||||
_(IP_UNNUMBERED_DUMP, ip_unnumbered_dump) \
|
_ (IP_UNNUMBERED_DUMP, ip_unnumbered_dump) \
|
||||||
_(IP_DUMP, ip_dump) \
|
_ (IP_DUMP, ip_dump) \
|
||||||
_(IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \
|
_ (IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \
|
||||||
_(IP_TABLE_REPLACE_END, ip_table_replace_end) \
|
_ (IP_TABLE_REPLACE_END, ip_table_replace_end) \
|
||||||
_(IP_TABLE_FLUSH, ip_table_flush) \
|
_ (IP_TABLE_FLUSH, ip_table_flush) \
|
||||||
_(IP_ROUTE_ADD_DEL, ip_route_add_del) \
|
_ (IP_ROUTE_ADD_DEL, ip_route_add_del) \
|
||||||
_(IP_ROUTE_LOOKUP, ip_route_lookup) \
|
_ (IP_ROUTE_LOOKUP, ip_route_lookup) \
|
||||||
_(IP_TABLE_ADD_DEL, ip_table_add_del) \
|
_ (IP_TABLE_ADD_DEL, ip_table_add_del) \
|
||||||
_(IP_PUNT_POLICE, ip_punt_police) \
|
_ (IP_PUNT_POLICE, ip_punt_police) \
|
||||||
_(IP_PUNT_REDIRECT, ip_punt_redirect) \
|
_ (IP_PUNT_REDIRECT, ip_punt_redirect) \
|
||||||
_(SET_IP_FLOW_HASH,set_ip_flow_hash) \
|
_ (SET_IP_FLOW_HASH, set_ip_flow_hash) \
|
||||||
_(IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \
|
_ (IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \
|
||||||
_(IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \
|
_ (IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \
|
||||||
_(IOAM_ENABLE, ioam_enable) \
|
_ (IOAM_ENABLE, ioam_enable) \
|
||||||
_(IOAM_DISABLE, ioam_disable) \
|
_ (IOAM_DISABLE, ioam_disable) \
|
||||||
_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
|
_ (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
|
||||||
ip_source_and_port_range_check_add_del) \
|
ip_source_and_port_range_check_add_del) \
|
||||||
_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
|
_ (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
|
||||||
ip_source_and_port_range_check_interface_add_del) \
|
ip_source_and_port_range_check_interface_add_del) \
|
||||||
_(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
|
_ (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
|
||||||
sw_interface_ip6_set_link_local_address) \
|
sw_interface_ip6_set_link_local_address) \
|
||||||
_(IP_REASSEMBLY_SET, ip_reassembly_set) \
|
_ (SW_INTERFACE_IP6_GET_LINK_LOCAL_ADDRESS, \
|
||||||
_(IP_REASSEMBLY_GET, ip_reassembly_get) \
|
sw_interface_ip6_get_link_local_address) \
|
||||||
_(IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \
|
_ (IP_REASSEMBLY_SET, ip_reassembly_set) \
|
||||||
_(IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump)
|
_ (IP_REASSEMBLY_GET, ip_reassembly_get) \
|
||||||
|
_ (IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \
|
||||||
|
_ (IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vl_api_sw_interface_ip6_enable_disable_t_handler
|
vl_api_sw_interface_ip6_enable_disable_t_handler
|
||||||
@ -1363,6 +1365,30 @@ static void
|
|||||||
REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
|
REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vl_api_sw_interface_ip6_get_link_local_address_t_handler (
|
||||||
|
vl_api_sw_interface_ip6_get_link_local_address_t *mp)
|
||||||
|
{
|
||||||
|
vl_api_sw_interface_ip6_get_link_local_address_reply_t *rmp;
|
||||||
|
const ip6_address_t *ip = NULL;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
VALIDATE_SW_IF_INDEX (mp);
|
||||||
|
|
||||||
|
ip = ip6_get_link_local_address (ntohl (mp->sw_if_index));
|
||||||
|
if (NULL == ip)
|
||||||
|
rv = VNET_API_ERROR_IP6_NOT_ENABLED;
|
||||||
|
|
||||||
|
BAD_SW_IF_INDEX_LABEL;
|
||||||
|
/* clang-format off */
|
||||||
|
REPLY_MACRO2 (VL_API_SW_INTERFACE_IP6_GET_LINK_LOCAL_ADDRESS_REPLY,
|
||||||
|
({
|
||||||
|
if (!rv)
|
||||||
|
ip6_address_encode (ip, rmp->ip);
|
||||||
|
}))
|
||||||
|
/* clang-format on */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vl_api_ip_table_replace_begin_t_handler (vl_api_ip_table_replace_begin_t * mp)
|
vl_api_ip_table_replace_begin_t_handler (vl_api_ip_table_replace_begin_t * mp)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,10 @@ class VppInterface(metaclass=abc.ABCMeta):
|
|||||||
@property
|
@property
|
||||||
def local_ip6_ll(self):
|
def local_ip6_ll(self):
|
||||||
"""Local IPv6 link-local address on VPP interface (string)."""
|
"""Local IPv6 link-local address on VPP interface (string)."""
|
||||||
|
if not self._local_ip6_ll:
|
||||||
|
self._local_ip6_ll = str(
|
||||||
|
self.test.vapi.sw_interface_ip6_get_link_local_address(
|
||||||
|
self.sw_if_index).ip)
|
||||||
return self._local_ip6_ll
|
return self._local_ip6_ll
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -192,7 +196,6 @@ class VppInterface(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
def set_mac(self, mac):
|
def set_mac(self, mac):
|
||||||
self._local_mac = str(mac)
|
self._local_mac = str(mac)
|
||||||
self._local_ip6_ll = mk_ll_addr(self._local_mac)
|
|
||||||
self.test.vapi.sw_interface_set_mac_address(
|
self.test.vapi.sw_interface_set_mac_address(
|
||||||
self.sw_if_index, mac.packed)
|
self.sw_if_index, mac.packed)
|
||||||
return self
|
return self
|
||||||
@ -234,8 +237,8 @@ class VppInterface(metaclass=abc.ABCMeta):
|
|||||||
"Could not find interface with sw_if_index %d "
|
"Could not find interface with sw_if_index %d "
|
||||||
"in interface dump %s" %
|
"in interface dump %s" %
|
||||||
(self.sw_if_index, moves.reprlib.repr(r)))
|
(self.sw_if_index, moves.reprlib.repr(r)))
|
||||||
self._local_ip6_ll = mk_ll_addr(self.local_mac)
|
|
||||||
self._remote_ip6_ll = mk_ll_addr(self.remote_mac)
|
self._remote_ip6_ll = mk_ll_addr(self.remote_mac)
|
||||||
|
self._local_ip6_ll = None
|
||||||
|
|
||||||
def config_ip4(self):
|
def config_ip4(self):
|
||||||
"""Configure IPv4 address on the VPP interface."""
|
"""Configure IPv4 address on the VPP interface."""
|
||||||
|
Reference in New Issue
Block a user