IP6 SR multicast replicator
- adds ability to name tunnel - creates policy as a collection of tunnel names - map ip6 multicast address to policy and replicate packet - adds zero memcpy for invariant portion of packet Change-Id: Icd2fe6a2cf65c09906e82ed1afbb0eae8df79452 Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
This commit is contained in:
Keith Burns (alagalah)
committed by
Keith Burns
parent
6de2ff28fe
commit
52fc44d61b
@ -527,7 +527,8 @@ nobase_include_HEADERS += \
|
||||
|
||||
if WITH_IPV6SR
|
||||
libvnet_la_SOURCES += \
|
||||
vnet/sr/sr.c
|
||||
vnet/sr/sr.c \
|
||||
vnet/sr/sr_replicate.c
|
||||
endif
|
||||
|
||||
nobase_include_HEADERS += \
|
||||
|
@ -72,7 +72,9 @@ _(NOT_CONNECTED, -78, "Not connected to the data plane") \
|
||||
_(IF_ALREADY_EXISTS, -79, "Interface already exists") \
|
||||
_(BOND_SLAVE_NOT_ALLOWED, -80, "Operation not allowed on slave of BondEthernet") \
|
||||
_(VALUE_EXIST, -81, "Value already exists") \
|
||||
_(SAME_SRC_DST, -82, "Source and destination are the same")
|
||||
_(SAME_SRC_DST, -82, "Source and destination are the same") \
|
||||
_(IP6_MULTICAST_ADDRESS_NOT_PRESENT, -83, "IP6 multicast address required") \
|
||||
_(SR_POLICY_NAME_NOT_PRESENT, -84, "Segement routing policy name required")
|
||||
|
||||
typedef enum {
|
||||
#define _(a,b,c) VNET_API_ERROR_##a = (b),
|
||||
|
@ -77,7 +77,7 @@ dpdk_set_mc_filter (vnet_hw_interface_t * hi,
|
||||
}
|
||||
}
|
||||
|
||||
static struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b)
|
||||
struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b)
|
||||
{
|
||||
vlib_main_t * vm = vlib_get_main();
|
||||
vlib_buffer_main_t * bm = vm->buffer_main;
|
||||
@ -147,6 +147,74 @@ static struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b)
|
||||
return first_mb;
|
||||
}
|
||||
|
||||
struct rte_mbuf * dpdk_zerocopy_replicate_packet_mb (vlib_buffer_t * b)
|
||||
{
|
||||
vlib_main_t * vm = vlib_get_main();
|
||||
vlib_buffer_main_t * bm = vm->buffer_main;
|
||||
struct rte_mbuf * first_mb = 0, * new_mb, * pkt_mb, ** prev_mb_next = 0;
|
||||
u8 nb_segs, nb_segs_left;
|
||||
unsigned socket_id = rte_socket_id();
|
||||
|
||||
ASSERT (bm->pktmbuf_pools[socket_id]);
|
||||
pkt_mb = rte_mbuf_from_vlib_buffer(b);
|
||||
nb_segs = pkt_mb->nb_segs;
|
||||
for (nb_segs_left = nb_segs; nb_segs_left; nb_segs_left--)
|
||||
{
|
||||
if (PREDICT_FALSE(pkt_mb == 0))
|
||||
{
|
||||
clib_warning ("Missing %d mbuf chain segment(s): "
|
||||
"(nb_segs = %d, nb_segs_left = %d)!",
|
||||
nb_segs - nb_segs_left, nb_segs, nb_segs_left);
|
||||
if (first_mb)
|
||||
rte_pktmbuf_free(first_mb);
|
||||
return NULL;
|
||||
}
|
||||
new_mb = rte_pktmbuf_clone(pkt_mb, bm->pktmbuf_pools[socket_id]);
|
||||
if (PREDICT_FALSE(new_mb == 0))
|
||||
{
|
||||
if (first_mb)
|
||||
rte_pktmbuf_free(first_mb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy packet info into 1st segment.
|
||||
*/
|
||||
if (first_mb == 0)
|
||||
{
|
||||
first_mb = new_mb;
|
||||
rte_pktmbuf_pkt_len (first_mb) = pkt_mb->pkt_len;
|
||||
first_mb->nb_segs = pkt_mb->nb_segs;
|
||||
first_mb->port = pkt_mb->port;
|
||||
#ifdef DAW_FIXME // TX Offload support TBD
|
||||
first_mb->vlan_macip = pkt_mb->vlan_macip;
|
||||
first_mb->hash = pkt_mb->hash;
|
||||
first_mb->ol_flags = pkt_mb->ol_flags
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(prev_mb_next != 0);
|
||||
*prev_mb_next = new_mb;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy packet segment data into new mbuf segment.
|
||||
*/
|
||||
rte_pktmbuf_data_len (new_mb) = pkt_mb->data_len;
|
||||
|
||||
prev_mb_next = &new_mb->next;
|
||||
pkt_mb = pkt_mb->next;
|
||||
}
|
||||
|
||||
ASSERT(pkt_mb == 0);
|
||||
__rte_mbuf_sanity_check(first_mb, 1);
|
||||
|
||||
return first_mb;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
dpdk_tx_trace_buffer (dpdk_main_t * dm,
|
||||
vlib_node_runtime_t * node,
|
||||
@ -686,7 +754,7 @@ dpdk_interface_tx (vlib_main_t * vm,
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
n_left -= 2;
|
||||
}
|
||||
while (n_left > 0)
|
||||
|
@ -468,6 +468,9 @@ u32 dpdk_get_handoff_node_index (void);
|
||||
|
||||
void set_efd_bitmap (u8 *bitmap, u32 value, u32 op);
|
||||
|
||||
struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b);
|
||||
struct rte_mbuf * dpdk_zerocopy_replicate_packet_mb (vlib_buffer_t * b);
|
||||
|
||||
#define foreach_dpdk_error \
|
||||
_(NONE, "no error") \
|
||||
_(RX_PACKET_ERROR, "Rx packet errors") \
|
||||
|
@ -1031,7 +1031,7 @@ static u32 vhost_user_if_input ( vlib_main_t * vm,
|
||||
error = VHOST_USER_INPUT_FUNC_ERROR_UNDERSIZED_FRAME;
|
||||
}
|
||||
|
||||
VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b);
|
||||
VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b_head);
|
||||
|
||||
vnet_buffer (b_head)->sw_if_index[VLIB_RX] = vui->sw_if_index;
|
||||
vnet_buffer (b_head)->sw_if_index[VLIB_TX] = (u32)~0;
|
||||
|
@ -471,9 +471,13 @@ ip_update_adjacency (ip_lookup_main_t * lm,
|
||||
static inline int
|
||||
ip_adjacency_is_multipath(ip_lookup_main_t * lm, u32 adj_index)
|
||||
{
|
||||
if (!vec_len(lm->multipath_adjacencies))
|
||||
return 0;
|
||||
|
||||
if (vec_len(lm->multipath_adjacencies) < adj_index - 1)
|
||||
return 0;
|
||||
|
||||
|
||||
return (lm->multipath_adjacencies[adj_index].adj_index == adj_index &&
|
||||
lm->multipath_adjacencies[adj_index].n_adj_in_block > 0);
|
||||
}
|
||||
|
4
vnet/vnet/sr/examples/sr_multicastmap.script
Normal file
4
vnet/vnet/sr/examples/sr_multicastmap.script
Normal file
@ -0,0 +1,4 @@
|
||||
sr_tunnel_add_del name sr2 src ::a:1:1:0:6 dst ff15::2/128 next ::a:1:1:0:f next ::a:1:1:0:1a next ff15::1 tag ::a:1:1:0:7 clean
|
||||
sr_tunnel_add_del name sr3 src ::b:1:1:0:6 dst ff16::2/128 next ::a:1:1:0:13 next ::a:1:1:0:1a next ff15::1 tag ::a:1:1:0:7 clean
|
||||
sr_policy_add_del name pol1 tunnel sr2 tunnel sr3
|
||||
sr_multicast_map_add_del address ff15::1 sr-policy pol1
|
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,9 @@ typedef struct {
|
||||
/* src, dst address */
|
||||
ip6_sr_tunnel_key_t key;
|
||||
|
||||
/* optional tunnel name */
|
||||
u8 * name;
|
||||
|
||||
/* mask width for FIB entry */
|
||||
u32 dst_mask_width;
|
||||
|
||||
@ -49,6 +52,10 @@ typedef struct {
|
||||
|
||||
/* The actual ip6 sr header */
|
||||
u8 * rewrite;
|
||||
|
||||
/* Indicates that this tunnel is part of a policy comprising
|
||||
of multiple tunnels. */
|
||||
u32 policy_index;
|
||||
} ip6_sr_tunnel_t;
|
||||
|
||||
typedef struct {
|
||||
@ -63,6 +70,12 @@ typedef struct {
|
||||
u32 rx_table_id;
|
||||
u32 tx_table_id;
|
||||
|
||||
/* optional name argument - for referencing SR tunnel/policy by name */
|
||||
u8 * name;
|
||||
|
||||
/* optional policy name */
|
||||
u8 * policy_name;
|
||||
|
||||
/* segment list, when inserting an ip6 SR header*/
|
||||
ip6_address_t *segments;
|
||||
|
||||
@ -82,13 +95,58 @@ typedef struct {
|
||||
u8 is_del;
|
||||
} ip6_sr_add_del_tunnel_args_t;
|
||||
|
||||
typedef struct {
|
||||
/* policy name */
|
||||
u8 * name;
|
||||
|
||||
/* tunnel names */
|
||||
u8 ** tunnel_names;
|
||||
|
||||
/* Delete the policy? */
|
||||
u8 is_del;
|
||||
} ip6_sr_add_del_policy_args_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* name of policy */
|
||||
u8 * name;
|
||||
|
||||
/* vector to SR tunnel index */
|
||||
u32 * tunnel_indices;
|
||||
|
||||
} ip6_sr_policy_t;
|
||||
|
||||
typedef struct {
|
||||
/* multicast IP6 address */
|
||||
ip6_address_t *multicast_address;
|
||||
|
||||
/* name of policy to map to */
|
||||
u8 * policy_name;
|
||||
|
||||
/* Delete the mapping */
|
||||
u8 is_del;
|
||||
|
||||
} ip6_sr_add_del_multicastmap_args_t;
|
||||
|
||||
typedef struct {
|
||||
/* pool of tunnel instances, sr entry only */
|
||||
ip6_sr_tunnel_t *tunnels;
|
||||
|
||||
/* find an sr "tunnel" by its outer-IP src/dst */
|
||||
uword * tunnel_index_by_key;
|
||||
|
||||
|
||||
/* find an sr "tunnel" by its name */
|
||||
uword * tunnel_index_by_name;
|
||||
|
||||
/* policy pool */
|
||||
ip6_sr_policy_t * policies;
|
||||
|
||||
/* find a policy by name */
|
||||
uword * policy_index_by_policy_name;
|
||||
|
||||
/* multicast address to policy mapping */
|
||||
uword * policy_index_by_multicast_address;
|
||||
|
||||
/* ip6-lookup next index for imposition FIB entries */
|
||||
u32 ip6_lookup_sr_next_index;
|
||||
|
||||
@ -98,6 +156,9 @@ typedef struct {
|
||||
/* ip6-rewrite next index for reinstalling the original dst address */
|
||||
u32 ip6_rewrite_sr_next_index;
|
||||
|
||||
/* ip6-replicate next index for multicast tunnel */
|
||||
u32 ip6_lookup_sr_replicate_index;
|
||||
|
||||
/* application API callback */
|
||||
void *sr_local_cb;
|
||||
|
||||
@ -126,7 +187,15 @@ format_function_t format_ip6_sr_header_with_length;
|
||||
|
||||
vlib_node_registration_t ip6_sr_input_node;
|
||||
|
||||
vlib_node_registration_t sr_replicate_node;
|
||||
|
||||
int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a);
|
||||
int ip6_sr_add_del_policy (ip6_sr_add_del_policy_args_t * a);
|
||||
int ip6_sr_add_del_multicastmap (ip6_sr_add_del_multicastmap_args_t * a);
|
||||
|
||||
void vnet_register_sr_app_callback (void *cb);
|
||||
|
||||
void sr_fix_hmac (ip6_sr_main_t * sm, ip6_header_t * ip,
|
||||
ip6_sr_header_t * sr);
|
||||
|
||||
#endif /* included_vnet_sr_h */
|
||||
|
366
vnet/vnet/sr/sr_replicate.c
Normal file
366
vnet/vnet/sr/sr_replicate.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -2159,6 +2159,8 @@ _(sw_interface_ip6nd_ra_config_reply) \
|
||||
_(set_arp_neighbor_limit_reply) \
|
||||
_(l2_patch_add_del_reply) \
|
||||
_(sr_tunnel_add_del_reply) \
|
||||
_(sr_policy_add_del_reply) \
|
||||
_(sr_multicast_map_add_del_reply) \
|
||||
_(classify_add_del_session_reply) \
|
||||
_(classify_set_interface_ip_table_reply) \
|
||||
_(classify_set_interface_l2_tables_reply) \
|
||||
@ -2298,6 +2300,8 @@ _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
|
||||
_(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
|
||||
_(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
|
||||
_(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
|
||||
_(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
|
||||
_(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
|
||||
_(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
|
||||
_(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
|
||||
_(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
|
||||
@ -5537,6 +5541,7 @@ static int api_trace_profile_del (vat_main_t *vam)
|
||||
S; W;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int api_sr_tunnel_add_del (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t * i = vam->input;
|
||||
@ -5557,11 +5562,17 @@ static int api_sr_tunnel_add_del (vat_main_t * vam)
|
||||
ip6_address_t * tags = 0;
|
||||
ip6_address_t * this_tag;
|
||||
ip6_address_t next_address, tag;
|
||||
u8 * name = 0;
|
||||
u8 * policy_name = 0;
|
||||
|
||||
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (i, "del"))
|
||||
is_del = 1;
|
||||
else if (unformat (i, "name %s", &name))
|
||||
;
|
||||
else if (unformat (i, "policy %s", &policy_name))
|
||||
;
|
||||
else if (unformat (i, "rx_fib_id %d", &rx_table_id))
|
||||
;
|
||||
else if (unformat (i, "tx_fib_id %d", &tx_table_id))
|
||||
@ -5650,6 +5661,8 @@ static int api_sr_tunnel_add_del (vat_main_t * vam)
|
||||
|
||||
mp->outer_vrf_id = ntohl (rx_table_id);
|
||||
mp->inner_vrf_id = ntohl (tx_table_id);
|
||||
memcpy (mp->name, name, vec_len(name));
|
||||
memcpy (mp->policy_name, policy_name, vec_len(policy_name));
|
||||
|
||||
vec_free (segments);
|
||||
vec_free (tags);
|
||||
@ -5658,6 +5671,136 @@ static int api_sr_tunnel_add_del (vat_main_t * vam)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static int api_sr_policy_add_del (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t * input = vam->input;
|
||||
vl_api_sr_policy_add_del_t *mp;
|
||||
f64 timeout;
|
||||
int is_del = 0;
|
||||
u8 * name = 0;
|
||||
u8 * tunnel_name = 0;
|
||||
u8 ** tunnel_names = 0;
|
||||
|
||||
int name_set = 0 ;
|
||||
int tunnel_set = 0;
|
||||
int j = 0;
|
||||
int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
|
||||
int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
|
||||
|
||||
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (input, "del"))
|
||||
is_del = 1;
|
||||
else if (unformat (input, "name %s", &name))
|
||||
name_set = 1;
|
||||
else if (unformat (input, "tunnel %s", &tunnel_name))
|
||||
{
|
||||
if (tunnel_name)
|
||||
{
|
||||
vec_add1 (tunnel_names, tunnel_name);
|
||||
/* For serializer:
|
||||
- length = #bytes to store in serial vector
|
||||
- +1 = byte to store that length
|
||||
*/
|
||||
tunnel_names_length += (vec_len (tunnel_name) + 1);
|
||||
tunnel_set = 1;
|
||||
tunnel_name = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (!name_set)
|
||||
{
|
||||
errmsg ("policy name required\n");
|
||||
return -99;
|
||||
}
|
||||
|
||||
if ((!tunnel_set) && (!is_del))
|
||||
{
|
||||
errmsg ("tunnel name required\n");
|
||||
return -99;
|
||||
}
|
||||
|
||||
M2(SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
|
||||
|
||||
|
||||
|
||||
mp->is_add = !is_del;
|
||||
|
||||
memcpy (mp->name, name, vec_len(name));
|
||||
// Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
|
||||
u8 * serial_orig = 0;
|
||||
vec_validate (serial_orig, tunnel_names_length);
|
||||
*serial_orig = vec_len(tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
|
||||
serial_orig += 1; // Move along one byte to store the length of first tunnel_name
|
||||
|
||||
for (j=0; j < vec_len(tunnel_names); j++)
|
||||
{
|
||||
tun_name_len = vec_len (tunnel_names[j]);
|
||||
*serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
|
||||
serial_orig += 1; // Move along one byte to store the actual tunnel name
|
||||
memcpy (serial_orig, tunnel_names[j], tun_name_len);
|
||||
serial_orig += tun_name_len; // Advance past the copy
|
||||
}
|
||||
memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
|
||||
|
||||
vec_free (tunnel_names);
|
||||
vec_free (tunnel_name);
|
||||
|
||||
S; W;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static int api_sr_multicast_map_add_del (vat_main_t * vam)
|
||||
{
|
||||
unformat_input_t * input = vam->input;
|
||||
vl_api_sr_multicast_map_add_del_t *mp;
|
||||
f64 timeout;
|
||||
int is_del = 0;
|
||||
ip6_address_t multicast_address;
|
||||
u8 * policy_name = 0;
|
||||
int multicast_address_set = 0;
|
||||
|
||||
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
|
||||
{
|
||||
if (unformat (input, "del"))
|
||||
is_del = 1;
|
||||
else if (unformat (input, "address %U", unformat_ip6_address, &multicast_address))
|
||||
multicast_address_set = 1;
|
||||
else if (unformat (input, "sr-policy %s", &policy_name))
|
||||
;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_del && !policy_name)
|
||||
{
|
||||
errmsg ("sr-policy name required\n");
|
||||
return -99;
|
||||
}
|
||||
|
||||
|
||||
if (!multicast_address_set)
|
||||
{
|
||||
errmsg ("address required\n");
|
||||
return -99;
|
||||
}
|
||||
|
||||
M(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
|
||||
|
||||
mp->is_add = !is_del;
|
||||
memcpy (mp->policy_name, policy_name, vec_len(policy_name));
|
||||
clib_memcpy (mp->multicast_address, &multicast_address, sizeof (mp->multicast_address));
|
||||
|
||||
|
||||
vec_free (policy_name);
|
||||
|
||||
S; W;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
|
||||
#define foreach_ip4_proto_field \
|
||||
_(src_address) \
|
||||
@ -10508,8 +10651,13 @@ _(mpls_ethernet_add_del_tunnel_2, \
|
||||
"inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
|
||||
"resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
|
||||
_(sr_tunnel_add_del, \
|
||||
"src <ip6-addr> dst <ip6-addr>/<mw> (next <ip6-addr>)+\n" \
|
||||
" [tag <ip6-addr>]* [clean] [reroute]") \
|
||||
"[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
|
||||
"(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
|
||||
"[policy <policy_name>]") \
|
||||
_(sr_policy_add_del, \
|
||||
"name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
|
||||
_(sr_multicast_map_add_del, \
|
||||
"address [ip6 multicast address] sr-policy [policy name] [del]") \
|
||||
_(classify_add_del_table, \
|
||||
"buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
|
||||
"[del] mask <mask-value>\n" \
|
||||
|
117
vpp/api/api.c
117
vpp/api/api.c
@ -42,6 +42,7 @@
|
||||
#include <vppinfra/format.h>
|
||||
#include <vppinfra/error.h>
|
||||
|
||||
#include <vnet/api_errno.h> // alagalah TODO : committers please pay note, is this ok?
|
||||
#include <vnet/vnet.h>
|
||||
#include <vnet/l2/l2_input.h>
|
||||
#include <vnet/l2/l2_bd.h>
|
||||
@ -329,7 +330,8 @@ _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
|
||||
_(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
|
||||
_(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump) \
|
||||
_(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
|
||||
_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump)
|
||||
_(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
|
||||
_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del)
|
||||
|
||||
#define QUOTE_(x) #x
|
||||
#define QUOTE(x) QUOTE_(x)
|
||||
@ -3389,7 +3391,15 @@ static void vl_api_sr_tunnel_add_del_t_handler
|
||||
a->is_del = (mp->is_add == 0);
|
||||
a->rx_table_id = ntohl(mp->outer_vrf_id);
|
||||
a->tx_table_id = ntohl(mp->inner_vrf_id);
|
||||
|
||||
|
||||
a->name = format(0, "%s", mp->name);
|
||||
if (!(vec_len(a->name)))
|
||||
a->name = 0;
|
||||
|
||||
a->policy_name = format(0, "%s", mp->policy_name);
|
||||
if (!(vec_len(a->policy_name)))
|
||||
a->policy_name = 0;
|
||||
|
||||
/* Yank segments and tags out of the API message */
|
||||
this_address = (ip6_address_t *)mp->segs_and_tags;
|
||||
for (i = 0; i < mp->n_segments; i++) {
|
||||
@ -3414,6 +3424,96 @@ out:
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vl_api_sr_policy_add_del_t_handler
|
||||
(vl_api_sr_policy_add_del_t *mp)
|
||||
{
|
||||
#if IPV6SR == 0
|
||||
clib_warning ("unimplemented");
|
||||
#else
|
||||
ip6_sr_add_del_policy_args_t _a, *a=&_a;
|
||||
int rv = 0;
|
||||
vl_api_sr_policy_add_del_reply_t * rmp;
|
||||
int i;
|
||||
|
||||
memset (a, 0, sizeof (*a));
|
||||
a->is_del = (mp->is_add == 0);
|
||||
|
||||
a->name = format(0, "%s", mp->name);
|
||||
if (!(vec_len(a->name)))
|
||||
{
|
||||
rv = VNET_API_ERROR_NO_SUCH_NODE2;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(mp->tunnel_names))
|
||||
{
|
||||
rv = VNET_API_ERROR_NO_SUCH_NODE2;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// start deserializing tunnel_names
|
||||
int num_tunnels = mp->tunnel_names[0]; //number of tunnels
|
||||
u8 * deser_tun_names = mp->tunnel_names;
|
||||
deser_tun_names += 1; //moving along
|
||||
|
||||
u8 * tun_name = 0;
|
||||
int tun_name_len = 0;
|
||||
|
||||
for (i=0; i < num_tunnels; i++)
|
||||
{
|
||||
tun_name_len= *deser_tun_names;
|
||||
deser_tun_names += 1;
|
||||
vec_resize (tun_name, tun_name_len);
|
||||
memcpy(tun_name, deser_tun_names, tun_name_len);
|
||||
vec_add1 (a->tunnel_names, tun_name);
|
||||
deser_tun_names += tun_name_len;
|
||||
tun_name = 0;
|
||||
}
|
||||
|
||||
rv = ip6_sr_add_del_policy (a);
|
||||
|
||||
out:
|
||||
|
||||
REPLY_MACRO(VL_API_SR_POLICY_ADD_DEL_REPLY);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vl_api_sr_multicast_map_add_del_t_handler
|
||||
(vl_api_sr_multicast_map_add_del_t *mp)
|
||||
{
|
||||
#if IPV6SR == 0
|
||||
clib_warning ("unimplemented");
|
||||
#else
|
||||
ip6_sr_add_del_multicastmap_args_t _a, *a=&_a;
|
||||
int rv = 0;
|
||||
vl_api_sr_multicast_map_add_del_reply_t * rmp;
|
||||
|
||||
memset (a, 0, sizeof (*a));
|
||||
a->is_del = (mp->is_add == 0);
|
||||
|
||||
a->multicast_address = (ip6_address_t *)&mp->multicast_address;
|
||||
a->policy_name = format(0, "%s", mp->policy_name);
|
||||
|
||||
if (a->multicast_address == 0)
|
||||
{
|
||||
rv = -1 ;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(a->policy_name))
|
||||
{
|
||||
rv = -2 ;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rv = ip6_sr_add_del_multicastmap (a);
|
||||
|
||||
out:
|
||||
|
||||
REPLY_MACRO(VL_API_SR_MULTICAST_MAP_ADD_DEL_REPLY);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define foreach_classify_add_del_table_field \
|
||||
_(table_index) \
|
||||
_(nbuckets) \
|
||||
@ -5827,6 +5927,19 @@ vpe_api_hookup (vlib_main_t *vm)
|
||||
vl_api_sr_tunnel_add_del_t_print,
|
||||
256, 1);
|
||||
|
||||
|
||||
/*
|
||||
* Manually register the sr policy add del msg, so we trace
|
||||
* enough bytes to capture a typical tunnel name list
|
||||
*/
|
||||
vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD_DEL,
|
||||
"sr_policy_add_del",
|
||||
vl_api_sr_policy_add_del_t_handler,
|
||||
vl_noop_handler,
|
||||
vl_api_sr_policy_add_del_t_endian,
|
||||
vl_api_sr_policy_add_del_t_print,
|
||||
256, 1);
|
||||
|
||||
/*
|
||||
* Trace space for 8 MPLS encap labels, classifier mask+match
|
||||
*/
|
||||
|
@ -1014,6 +1014,9 @@ static void *vl_api_sr_tunnel_add_del_t_print
|
||||
|
||||
s = format (0, "SCRIPT: sr_tunnel_add_del ");
|
||||
|
||||
if (mp->name)
|
||||
s = format (s, "name %s ", mp->name);
|
||||
|
||||
s = format (s, "src %U dst %U/%d ", format_ip6_address,
|
||||
(ip6_address_t *) mp->src_address,
|
||||
format_ip6_address,
|
||||
@ -1062,12 +1065,78 @@ static void *vl_api_sr_tunnel_add_del_t_print
|
||||
}
|
||||
}
|
||||
|
||||
if (mp->policy_name)
|
||||
s = format (s, "policy_name %s ", mp->policy_name);
|
||||
|
||||
if (mp->is_add == 0)
|
||||
s = format (s, "del ");
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_sr_policy_add_del_t_print
|
||||
(vl_api_sr_policy_add_del_t * mp, void *handle)
|
||||
{
|
||||
u8 * s;
|
||||
int i;
|
||||
|
||||
s = format (0, "SCRIPT: sr_policy_add_del ");
|
||||
|
||||
if (mp->name)
|
||||
s = format (s, "name %s ", mp->name);
|
||||
|
||||
|
||||
if (mp->tunnel_names)
|
||||
{
|
||||
// start deserializing tunnel_names
|
||||
int num_tunnels = mp->tunnel_names[0]; //number of tunnels
|
||||
u8 * deser_tun_names = mp->tunnel_names;
|
||||
deser_tun_names += 1; //moving along
|
||||
|
||||
u8 * tun_name = 0;
|
||||
int tun_name_len = 0;
|
||||
|
||||
for (i=0; i < num_tunnels; i++)
|
||||
{
|
||||
tun_name_len= *deser_tun_names;
|
||||
deser_tun_names += 1;
|
||||
vec_resize (tun_name, tun_name_len);
|
||||
memcpy(tun_name, deser_tun_names, tun_name_len);
|
||||
s = format (s, "tunnel %s ", tun_name);
|
||||
deser_tun_names += tun_name_len;
|
||||
tun_name = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (mp->is_add == 0)
|
||||
s = format (s, "del ");
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
static void *vl_api_sr_multicast_map_add_del_t_print
|
||||
(vl_api_sr_multicast_map_add_del_t * mp, void *handle)
|
||||
{
|
||||
|
||||
u8 * s = 0;
|
||||
/* int i; */
|
||||
|
||||
s = format (0, "SCRIPT: sr_multicast_map_add_del ");
|
||||
|
||||
if (mp->multicast_address)
|
||||
s = format (s, "address %U ", format_ip6_address, &mp->multicast_address);
|
||||
|
||||
if (mp->policy_name)
|
||||
s = format (s, "sr-policy %s ", &mp->policy_name);
|
||||
|
||||
|
||||
if (mp->is_add == 0)
|
||||
s = format (s, "del ");
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
|
||||
static void *vl_api_classify_add_del_table_t_print
|
||||
(vl_api_classify_add_del_table_t * mp, void *handle)
|
||||
{
|
||||
@ -1808,6 +1877,8 @@ _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
|
||||
_(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
|
||||
_(L2_PATCH_ADD_DEL, l2_patch_add_del) \
|
||||
_(SR_TUNNEL_ADD_DEL, sr_tunnel_add_del) \
|
||||
_(SR_POLICY_ADD_DEL, sr_policy_add_del) \
|
||||
_(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
|
||||
_(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
|
||||
_(L2FIB_ADD_DEL, l2fib_add_del) \
|
||||
_(L2_FLAGS, l2_flags) \
|
||||
@ -1816,7 +1887,7 @@ _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
|
||||
_(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
|
||||
_(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
|
||||
_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
|
||||
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
|
||||
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
|
||||
_(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
|
||||
_(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
|
||||
_(ADD_NODE_NEXT, add_node_next) \
|
||||
|
@ -1145,6 +1145,7 @@ define l2_patch_add_del_reply {
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param is_add - add the tunnel if non-zero, else delete it
|
||||
@param name[] - tunnel name (len. 64)
|
||||
@param src_address[] -
|
||||
@param dst_address[] -
|
||||
@param dst_mask_width -
|
||||
@ -1154,11 +1155,13 @@ define l2_patch_add_del_reply {
|
||||
@param n_segments -
|
||||
@param n_tags -
|
||||
@param segs_and_tags[] -
|
||||
@param policy_name[] - name of policy to associate this tunnel to (len. 64)
|
||||
*/
|
||||
define sr_tunnel_add_del {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_add;
|
||||
u8 name[64];
|
||||
u8 src_address[16];
|
||||
u8 dst_address[16];
|
||||
u8 dst_mask_width;
|
||||
@ -1168,6 +1171,7 @@ define sr_tunnel_add_del {
|
||||
u8 n_segments;
|
||||
u8 n_tags;
|
||||
u8 segs_and_tags[0];
|
||||
u8 policy_name[64];
|
||||
};
|
||||
|
||||
/** \brief IPv6 segment routing tunnel add / del response
|
||||
@ -1179,6 +1183,54 @@ define sr_tunnel_add_del_reply {
|
||||
i32 retval;
|
||||
};
|
||||
|
||||
/** \brief IPv6 segment routing policy add / del request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param is_add - add the tunnel if non-zero, else delete it
|
||||
@param name[] - policy name (len. 64)
|
||||
@param tunnel_names[] -
|
||||
*/
|
||||
define sr_policy_add_del {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_add;
|
||||
u8 name[64];
|
||||
u8 tunnel_names[0];
|
||||
};
|
||||
|
||||
/** \brief IPv6 segment routing policy add / del response
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param retval - return value for request
|
||||
*/
|
||||
define sr_policy_add_del_reply {
|
||||
u32 context;
|
||||
i32 retval;
|
||||
};
|
||||
|
||||
/** \brief IPv6 segment routing multicast map to policy add / del request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param is_add - add the tunnel if non-zero, else delete it
|
||||
@param multicast_address[] - IP6 multicast address
|
||||
@param policy_name[] = policy name (len.64)
|
||||
*/
|
||||
define sr_multicast_map_add_del {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_add;
|
||||
u8 multicast_address[16];
|
||||
u8 policy_name[64];
|
||||
};
|
||||
|
||||
/** \brief IPv6 segment routing multicast map to policy add / del response
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param retval - return value for request
|
||||
*/
|
||||
define sr_multicast_map_add_del_reply {
|
||||
u32 context;
|
||||
i32 retval;
|
||||
};
|
||||
|
||||
/** \brief Interface set vpath request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
|
Reference in New Issue
Block a user