aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vat/api_format.c16
-rw-r--r--src/vnet/srv6/sr.api85
-rw-r--r--src/vnet/srv6/sr_api.c184
-rwxr-xr-xsrc/vnet/srv6/sr_localsid.c3
-rw-r--r--src/vpp/api/custom_dump.c30
-rw-r--r--test/test_srv6.py45
-rw-r--r--test/vpp_papi_provider.py15
-rw-r--r--test/vpp_srv6.py35
8 files changed, 293 insertions, 120 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index f2d10b78de5..14f66c31fa7 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -10758,7 +10758,10 @@ api_sr_localsid_add_del (vat_main_t * vam)
u8 behavior = ~0;
u32 sw_if_index;
u32 fib_table = ~(u32) 0;
- ip6_address_t next_hop;
+ ip6_address_t nh_addr6;
+ ip4_address_t nh_addr4;
+ memset (&nh_addr6, 0, sizeof (ip6_address_t));
+ memset (&nh_addr4, 0, sizeof (ip4_address_t));
bool nexthop_set = 0;
@@ -10769,7 +10772,9 @@ api_sr_localsid_add_del (vat_main_t * vam)
if (unformat (i, "del"))
is_del = 1;
else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
- else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
+ else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
+ nexthop_set = 1;
+ else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
nexthop_set = 1;
else if (unformat (i, "behavior %u", &behavior));
else if (unformat (i, "sw_if_index %u", &sw_if_index));
@@ -10781,9 +10786,12 @@ api_sr_localsid_add_del (vat_main_t * vam)
M (SR_LOCALSID_ADD_DEL, mp);
- clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
+ clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
if (nexthop_set)
- clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
+ {
+ clib_memcpy (mp->nh_addr6, &nh_addr4, sizeof (mp->nh_addr6));
+ clib_memcpy (mp->nh_addr4, &nh_addr6, sizeof (mp->nh_addr4));
+ }
mp->behavior = behavior;
mp->sw_if_index = ntohl (sw_if_index);
mp->fib_table = ntohl (fib_table);
diff --git a/src/vnet/srv6/sr.api b/src/vnet/srv6/sr.api
index 181192817b2..27b5ac6f89e 100644
--- a/src/vnet/srv6/sr.api
+++ b/src/vnet/srv6/sr.api
@@ -14,7 +14,21 @@
* limitations under the License.
*/
-option version = "1.0.1";
+option version = "1.2.0";
+
+/** \brief SRv6 SID
+*/
+typeonly define srv6_sid
+{
+ u8 addr[16];
+};
+
+typeonly define srv6_sid_list
+{
+ u8 num_sids;
+ u32 weight;
+ vl_api_srv6_sid_t sids[16];
+};
/** \brief IPv6 SR LocalSID add/del request
@param client_index - opaque cookie to identify the sender
@@ -27,20 +41,22 @@ option version = "1.0.1";
fib_table.
@param vlan_index Only for L2 xconnect. Outgoing VLAN tag.
@param fib_table FIB table in which we should install the localsid entry
- @param nh_addr Next Hop IPv4/IPv6 address. Only for L2/L3 xconnect.
+ @param nh_addr6 Next Hop IPv6 address. Only for L2/L3 xconnect.
+ @param nh_addr4 Next Hop IPv4 address. Only for L2/L3 xconnect.
*/
autoreply define sr_localsid_add_del
{
u32 client_index;
u32 context;
u8 is_del;
- u8 localsid_addr[16];
+ vl_api_srv6_sid_t localsid;
u8 end_psp;
u8 behavior;
u32 sw_if_index;
u32 vlan_index;
u32 fib_table;
- u8 nh_addr[16];
+ u8 nh_addr6[16];
+ u8 nh_addr4[4];
};
typeonly define sr_ip6_address
@@ -56,7 +72,7 @@ typeonly define sr_ip6_address
@param is_encap is the behavior of the SR policy. (0.SRH insert // 1.Encapsulation)
@param type is the type of the SR policy. (0.Default // 1.Spray)
@param fib_table is the VRF where to install the FIB entry for the BSID
- @param segments is a vector of IPv6 address composing the segment list
+ @param sids is a srv6_sid_list object
*/
autoreply define sr_policy_add
{
@@ -67,8 +83,7 @@ autoreply define sr_policy_add
u8 is_encap;
u8 type;
u32 fib_table;
- u8 n_segments;
- vl_api_sr_ip6_address_t segments[n_segments];
+ vl_api_srv6_sid_list_t sids;
};
/** \brief IPv6 SR policy modification
@@ -78,10 +93,9 @@ autoreply define sr_policy_add
@param sr_policy_index is the index of the SR policy
@param fib_table is the VRF where to install the FIB entry for the BSID
@param operation is the operation to perform (among the top ones)
- @param segments is a vector of IPv6 address composing the segment list
@param sl_index is the index of the Segment List to modify/delete
@param weight is the weight of the sid list. optional.
- @param is_encap Mode. Encapsulation or SRH insertion.
+ @param sids is a srv6_sid_list object
*/
autoreply define sr_policy_mod
{
@@ -93,8 +107,7 @@ autoreply define sr_policy_mod
u8 operation;
u32 sl_index;
u32 weight;
- u8 n_segments;
- vl_api_sr_ip6_address_t segments[n_segments];
+ vl_api_srv6_sid_list_t sids;
};
/** \brief IPv6 SR policy deletion
@@ -107,7 +120,7 @@ autoreply define sr_policy_del
{
u32 client_index;
u32 context;
- u8 bsid_addr[16];
+ vl_api_srv6_sid_t bsid_addr;
u32 sr_policy_index;
};
@@ -163,14 +176,58 @@ define sr_localsids_dump
define sr_localsids_details
{
u32 context;
- u8 address[16];
+ vl_api_srv6_sid_t addr;
u8 end_psp;
u16 behavior;
u32 fib_table;
- u8 xconnect_next_hop[16];
+ u32 vlan_index;
+ u8 xconnect_nh_addr6[16];
+ u8 xconnect_nh_addr4[4];
u32 xconnect_iface_or_vrf_table;
};
+/** \brief Dump the list of SR policies
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+define sr_policies_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+define sr_policies_details
+{
+ u32 context;
+ vl_api_srv6_sid_t bsid;
+ u8 type;
+ u8 is_encap;
+ u32 fib_table;
+ u8 num_sid_lists;
+ vl_api_srv6_sid_list_t sid_lists[num_sid_lists];
+};
+
+/** \brief Dump the steering policies
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+define sr_steering_pol_dump
+{
+ u32 client_index;
+ u32 context;
+};
+
+define sr_steering_pol_details
+{
+ u32 context;
+ u8 traffic_type;
+ u32 fib_table;
+ u8 prefix_addr[16];
+ u32 mask_width;
+ u32 sw_if_index;
+ vl_api_srv6_sid_t bsid;
+};
+
/*
* fd.io coding-style-patch-verification: OFF
* Local Variables:
diff --git a/src/vnet/srv6/sr_api.c b/src/vnet/srv6/sr_api.c
index d696e06a396..17d4821ec1d 100644
--- a/src/vnet/srv6/sr_api.c
+++ b/src/vnet/srv6/sr_api.c
@@ -45,11 +45,14 @@
#define foreach_vpe_api_msg \
_(SR_LOCALSID_ADD_DEL, sr_localsid_add_del) \
+_(SR_POLICY_ADD, sr_policy_add) \
+_(SR_POLICY_MOD, sr_policy_mod) \
_(SR_POLICY_DEL, sr_policy_del) \
_(SR_STEERING_ADD_DEL, sr_steering_add_del) \
_(SR_SET_ENCAP_SOURCE, sr_set_encap_source) \
-_(SR_LOCALSIDS_DUMP, sr_localsids_dump)
-//_(SR_LOCALSID_BEHAVIORS, sr_localsid_behaviors_dump)
+_(SR_LOCALSIDS_DUMP, sr_localsids_dump) \
+_(SR_POLICIES_DUMP, sr_policies_dump) \
+_(SR_STEERING_POL_DUMP, sr_steering_pol_dump)
static void vl_api_sr_localsid_add_del_t_handler
(vl_api_sr_localsid_add_del_t * mp)
@@ -61,20 +64,29 @@ static void vl_api_sr_localsid_add_del_t_handler
* char end_psp, u8 behavior, u32 sw_if_index, u32 vlan_index, u32 fib_table,
* ip46_address_t *nh_addr, void *ls_plugin_mem)
*/
+ if (mp->behavior == SR_BEHAVIOR_X ||
+ mp->behavior == SR_BEHAVIOR_DX6 ||
+ mp->behavior == SR_BEHAVIOR_DX4 || mp->behavior == SR_BEHAVIOR_DX2)
+ VALIDATE_SW_IF_INDEX (mp);
- VALIDATE_SW_IF_INDEX (mp);
+ ip46_address_t prefix;
+
+ memset (&prefix, 0, sizeof (ip46_address_t));
+ if ((mp->nh_addr4[0] | mp->nh_addr4[1] | mp->
+ nh_addr4[2] | mp->nh_addr4[3]) != 0)
+ memcpy (&prefix.ip4, mp->nh_addr4, sizeof (prefix.ip4));
+ else
+ memcpy (&prefix.ip6, mp->nh_addr6, sizeof (prefix.ip6));
rv = sr_cli_localsid (mp->is_del,
- (ip6_address_t *) & mp->localsid_addr,
+ (ip6_address_t *) & mp->localsid,
mp->end_psp,
mp->behavior,
ntohl (mp->sw_if_index),
ntohl (mp->vlan_index),
- ntohl (mp->fib_table),
- (ip46_address_t *) & mp->nh_addr, NULL);
+ ntohl (mp->fib_table), &prefix, NULL);
BAD_SW_IF_INDEX_LABEL;
-
REPLY_MACRO (VL_API_SR_LOCALSID_ADD_DEL_REPLY);
}
@@ -83,10 +95,10 @@ vl_api_sr_policy_add_t_handler (vl_api_sr_policy_add_t * mp)
{
vl_api_sr_policy_add_reply_t *rmp;
ip6_address_t *segments = 0, *seg;
- ip6_address_t *this_address = (ip6_address_t *) mp->segments;
+ ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
int i;
- for (i = 0; i < mp->n_segments; i++)
+ for (i = 0; i < mp->sids.num_sids; i++)
{
vec_add2 (segments, seg, 1);
clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
@@ -100,7 +112,7 @@ vl_api_sr_policy_add_t_handler (vl_api_sr_policy_add_t * mp)
int rv = 0;
rv = sr_policy_add ((ip6_address_t *) & mp->bsid_addr,
segments,
- ntohl (mp->weight),
+ ntohl (mp->sids.weight),
mp->type, ntohl (mp->fib_table), mp->is_encap);
REPLY_MACRO (VL_API_SR_POLICY_ADD_REPLY);
@@ -112,10 +124,10 @@ vl_api_sr_policy_mod_t_handler (vl_api_sr_policy_mod_t * mp)
vl_api_sr_policy_mod_reply_t *rmp;
ip6_address_t *segments = 0, *seg;
- ip6_address_t *this_address = (ip6_address_t *) mp->segments;
+ ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
int i;
- for (i = 0; i < mp->n_segments; i++)
+ for (i = 0; i < mp->sids.num_sids; i++)
{
vec_add2 (segments, seg, 1);
clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
@@ -133,7 +145,8 @@ vl_api_sr_policy_mod_t_handler (vl_api_sr_policy_mod_t * mp)
ntohl (mp->sr_policy_index),
ntohl (mp->fib_table),
mp->operation,
- segments, ntohl (mp->sl_index), ntohl (mp->weight));
+ segments, ntohl (mp->sl_index),
+ ntohl (mp->sids.weight));
REPLY_MACRO (VL_API_SR_POLICY_MOD_REPLY);
}
@@ -174,8 +187,8 @@ static void vl_api_sr_steering_add_del_t_handler
* u32 table_id, ip46_address_t *prefix, u32 mask_width, u32 sw_if_index,
* u8 traffic_type)
*/
-
- VALIDATE_SW_IF_INDEX (mp);
+ if (mp->traffic_type == SR_STEER_L2)
+ VALIDATE_SW_IF_INDEX (mp);
rv = sr_steering_policy (mp->is_del,
(ip6_address_t *) & mp->bsid_addr,
@@ -186,7 +199,6 @@ static void vl_api_sr_steering_add_del_t_handler
ntohl (mp->sw_if_index), mp->traffic_type);
BAD_SW_IF_INDEX_LABEL;
-
REPLY_MACRO (VL_API_SR_STEERING_ADD_DEL_REPLY);
}
@@ -198,11 +210,17 @@ static void send_sr_localsid_details
rmp = vl_msg_api_alloc (sizeof (*rmp));
memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_SR_LOCALSIDS_DETAILS);
- memcpy (rmp->address, &t->localsid, sizeof (ip6_address_t));
+ clib_memcpy (rmp->addr.addr, &t->localsid, sizeof (ip6_address_t));
rmp->end_psp = t->end_psp;
rmp->behavior = htons (t->behavior);
rmp->fib_table = htonl (t->fib_table);
- memcpy (rmp->xconnect_next_hop, &t->next_hop, sizeof (ip6_address_t));
+ rmp->vlan_index = htonl (t->vlan_index);
+ if (ip46_address_is_ip4 (&t->next_hop))
+ clib_memcpy (rmp->xconnect_nh_addr4, &t->next_hop.ip4,
+ sizeof (ip4_address_t));
+ else
+ clib_memcpy (rmp->xconnect_nh_addr6, &t->next_hop.ip6,
+ sizeof (ip6_address_t));
rmp->xconnect_iface_or_vrf_table = htonl (t->sw_if_index);
rmp->context = context;
@@ -228,6 +246,114 @@ static void vl_api_sr_localsids_dump_t_handler
/* *INDENT-ON* */
}
+static void send_sr_policies_details
+ (ip6_sr_policy_t * t, vl_api_registration_t * reg, u32 context)
+{
+ vl_api_sr_policies_details_t *rmp;
+ ip6_sr_main_t *sm = &sr_main;
+
+ u32 *sl_index;
+ ip6_sr_sl_t *segment_list = 0;
+ vl_api_srv6_sid_list_t *write_sid_list;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp) +
+ vec_len (t->segments_lists) *
+ sizeof (vl_api_srv6_sid_list_t));
+ memset (rmp, 0,
+ (sizeof (*rmp) +
+ vec_len (t->segments_lists) * sizeof (vl_api_srv6_sid_list_t)));
+
+ rmp->_vl_msg_id = ntohs (VL_API_SR_POLICIES_DETAILS);
+ clib_memcpy (rmp->bsid.addr, &t->bsid, sizeof (ip6_address_t));
+ rmp->is_encap = t->is_encap;
+ rmp->type = t->type;
+ rmp->fib_table = htonl (t->fib_table);
+ rmp->num_sid_lists = vec_len (t->segments_lists);
+
+ /* Fill in all the segments lists */
+ vec_foreach (sl_index, t->segments_lists)
+ {
+ segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
+ write_sid_list = &rmp->sid_lists[sl_index - t->segments_lists];
+ write_sid_list->num_sids = vec_len (segment_list->segments);
+ write_sid_list->weight = htonl (segment_list->weight);
+ clib_memcpy (write_sid_list->sids, segment_list->segments,
+ vec_len (segment_list->segments) * sizeof (ip6_address_t));
+ }
+
+ rmp->context = context;
+ vl_api_send_msg (reg, (u8 *) rmp);
+}
+
+static void
+vl_api_sr_policies_dump_t_handler (vl_api_sr_policies_dump_t * mp)
+{
+ vl_api_registration_t *reg;
+ ip6_sr_main_t *sm = &sr_main;
+ ip6_sr_policy_t *t;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ /* *INDENT-OFF* */
+ pool_foreach (t, sm->sr_policies,
+ ({
+ send_sr_policies_details(t, reg, mp->context);
+ }));
+ /* *INDENT-ON* */
+}
+
+static void send_sr_steering_pol_details
+ (ip6_sr_steering_policy_t * t, vl_api_registration_t * reg, u32 context)
+{
+ vl_api_sr_steering_pol_details_t *rmp;
+ ip6_sr_main_t *sm = &sr_main;
+
+ rmp = vl_msg_api_alloc (sizeof (*rmp));
+ memset (rmp, 0, sizeof (*rmp));
+ rmp->_vl_msg_id = ntohs (VL_API_SR_STEERING_POL_DETAILS);
+
+ //Get the SR policy BSID
+ ip6_sr_policy_t *p;
+ p = pool_elt_at_index (sm->sr_policies, t->sr_policy);
+ clib_memcpy (rmp->bsid.addr, &p->bsid, sizeof (ip6_address_t));
+
+ //Get the steering
+ rmp->traffic_type = t->classify.traffic_type;
+ rmp->fib_table = htonl (t->classify.l3.fib_table);
+ rmp->mask_width = htonl (t->classify.l3.mask_width);
+ if (ip46_address_is_ip4 (&t->classify.l3.prefix))
+ clib_memcpy (rmp->prefix_addr, &t->classify.l3.prefix.ip4,
+ sizeof (ip4_address_t));
+ else
+ clib_memcpy (rmp->prefix_addr, &t->classify.l3.prefix.ip6,
+ sizeof (ip6_address_t));
+
+ rmp->sw_if_index = htonl (t->classify.l2.sw_if_index);
+
+ rmp->context = context;
+ vl_api_send_msg (reg, (u8 *) rmp);
+}
+
+static void vl_api_sr_steering_pol_dump_t_handler
+ (vl_api_sr_policies_dump_t * mp)
+{
+ vl_api_registration_t *reg;
+ ip6_sr_main_t *sm = &sr_main;
+ ip6_sr_steering_policy_t *t;
+
+ reg = vl_api_client_index_to_registration (mp->client_index);
+ if (!reg)
+ return;
+
+ /* *INDENT-OFF* */
+ pool_foreach (t, sm->steer_policies,
+ ({
+ send_sr_steering_pol_details(t, reg, mp->context);
+ }));
+ /* *INDENT-ON* */
+}
/*
* sr_api_hookup
@@ -264,28 +390,6 @@ sr_api_hookup (vlib_main_t * vm)
#undef _
/*
- * Manually register the sr policy add msg, so we trace
- * enough bytes to capture a typical segment list
- */
- vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD,
- "sr_policy_add",
- vl_api_sr_policy_add_t_handler,
- vl_noop_handler,
- vl_api_sr_policy_add_t_endian,
- vl_api_sr_policy_add_t_print, 256, 1);
-
- /*
- * Manually register the sr policy mod msg, so we trace
- * enough bytes to capture a typical segment list
- */
- vl_msg_api_set_handlers (VL_API_SR_POLICY_MOD,
- "sr_policy_mod",
- vl_api_sr_policy_mod_t_handler,
- vl_noop_handler,
- vl_api_sr_policy_mod_t_endian,
- vl_api_sr_policy_mod_t_print, 256, 1);
-
- /*
* Set up the (msg_name, crc, message-id) table
*/
setup_message_id_table (am);
diff --git a/src/vnet/srv6/sr_localsid.c b/src/vnet/srv6/sr_localsid.c
index c90a265ef0a..09c336e70bd 100755
--- a/src/vnet/srv6/sr_localsid.c
+++ b/src/vnet/srv6/sr_localsid.c
@@ -473,8 +473,7 @@ show_sr_localsid_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_output (vm,
"\tAddress: \t%U\n\tBehavior: \tT (Endpoint with specific IPv6 table lookup)"
"\n\tTable: \t%u",
- format_ip6_address, &ls->localsid,
- format_vnet_sw_if_index_name, vnm, ls->vrf_index);
+ format_ip6_address, &ls->localsid, ls->vrf_index);
break;
case SR_BEHAVIOR_DX4:
vlib_cli_output (vm,
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index b57313158b4..0bd4fb8c467 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -1200,7 +1200,7 @@ static void *vl_api_sr_localsid_add_del_t_print
{
case SR_BEHAVIOR_END:
s = format (s, "Address: %U\nBehavior: End",
- format_ip6_address, (ip6_address_t *) mp->localsid_addr);
+ format_ip6_address, (ip6_address_t *) mp->localsid.addr);
s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
break;
case SR_BEHAVIOR_X:
@@ -1208,9 +1208,9 @@ static void *vl_api_sr_localsid_add_del_t_print
format (s,
"Address: %U\nBehavior: X (Endpoint with Layer-3 cross-connect)"
"\nIface: %U\nNext hop: %U", format_ip6_address,
- (ip6_address_t *) mp->localsid_addr,
+ (ip6_address_t *) mp->localsid.addr,
format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index),
- format_ip6_address, (ip6_address_t *) mp->nh_addr);
+ format_ip6_address, (ip6_address_t *) mp->nh_addr6);
s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False"));
break;
case SR_BEHAVIOR_DX4:
@@ -1218,25 +1218,25 @@ static void *vl_api_sr_localsid_add_del_t_print
format (s,
"Address: %U\nBehavior: DX4 (Endpoint with decapsulation with IPv4 cross-connect)"
"\nIface: %U\nNext hop: %U", format_ip6_address,
- (ip6_address_t *) mp->localsid_addr,
+ (ip6_address_t *) mp->localsid.addr,
format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index),
- format_ip4_address, (ip4_address_t *) mp->nh_addr);
+ format_ip4_address, (ip4_address_t *) mp->nh_addr4);
break;
case SR_BEHAVIOR_DX6:
s =
format (s,
"Address: %U\nBehavior: DX6 (Endpoint with decapsulation with IPv6 cross-connect)"
"\nIface: %UNext hop: %U", format_ip6_address,
- (ip6_address_t *) mp->localsid_addr,
+ (ip6_address_t *) mp->localsid.addr,
format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index),
- format_ip6_address, (ip6_address_t *) mp->nh_addr);
+ format_ip6_address, (ip6_address_t *) mp->nh_addr6);
break;
case SR_BEHAVIOR_DX2:
s =
format (s,
"Address: %U\nBehavior: DX2 (Endpoint with decapulation and Layer-2 cross-connect)"
"\nIface: %U", format_ip6_address,
- (ip6_address_t *) mp->localsid_addr,
+ (ip6_address_t *) mp->localsid.addr,
format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index));
break;
case SR_BEHAVIOR_DT6:
@@ -1244,20 +1244,20 @@ static void *vl_api_sr_localsid_add_del_t_print
format (s,
"Address: %U\nBehavior: DT6 (Endpoint with decapsulation and specific IPv6 table lookup)"
"\nTable: %u", format_ip6_address,
- (ip6_address_t *) mp->localsid_addr, ntohl (mp->fib_table));
+ (ip6_address_t *) mp->localsid.addr, ntohl (mp->fib_table));
break;
case SR_BEHAVIOR_DT4:
s =
format (s,
"Address: %U\nBehavior: DT4 (Endpoint with decapsulation and specific IPv4 table lookup)"
"\nTable: %u", format_ip6_address,
- (ip6_address_t *) mp->localsid_addr, ntohl (mp->fib_table));
+ (ip6_address_t *) mp->localsid.addr, ntohl (mp->fib_table));
break;
default:
if (mp->behavior >= SR_BEHAVIOR_LAST)
{
s = format (s, "Address: %U\n Behavior: %u",
- format_ip6_address, (ip6_address_t *) mp->localsid_addr,
+ format_ip6_address, (ip6_address_t *) mp->localsid.addr,
mp->behavior);
}
else
@@ -1310,10 +1310,10 @@ static void *vl_api_sr_policy_add_t_print
u8 *s;
ip6_address_t *segments = 0, *seg;
- ip6_address_t *this_address = (ip6_address_t *) mp->segments;
+ ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
int i;
- for (i = 0; i < mp->n_segments; i++)
+ for (i = 0; i < mp->sids.num_sids; i++)
{
vec_add2 (segments, seg, 1);
clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
@@ -1352,10 +1352,10 @@ static void *vl_api_sr_policy_mod_t_print
u8 *s;
ip6_address_t *segments = 0, *seg;
- ip6_address_t *this_address = (ip6_address_t *) mp->segments;
+ ip6_address_t *this_address = (ip6_address_t *) mp->sids.sids;
int i;
- for (i = 0; i < mp->n_segments; i++)
+ for (i = 0; i < mp->sids.num_sids; i++)
{
vec_add2 (segments, seg, 1);
clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
diff --git a/test/test_srv6.py b/test/test_srv6.py
index b64d3bc8367..3e5f856316d 100644
--- a/test/test_srv6.py
+++ b/test/test_srv6.py
@@ -514,9 +514,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End without PSP behavior
localsid = VppSRv6LocalSID(
- self, localsid_addr='A3::0',
+ self, localsid={'addr': 'A3::0'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_END,
- nh_addr='::',
+ nh_addr4='0.0.0.0',
+ nh_addr6='::',
end_psp=0,
sw_if_index=0,
vlan_index=0,
@@ -585,9 +586,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End with PSP behavior
localsid = VppSRv6LocalSID(
- self, localsid_addr='A3::0',
+ self, localsid={'addr': 'A3::0'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_END,
- nh_addr='::',
+ nh_addr4='0.0.0.0',
+ nh_addr6='::',
end_psp=1,
sw_if_index=0,
vlan_index=0,
@@ -660,9 +662,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.X without PSP behavior
# End.X points to interface pg1
localsid = VppSRv6LocalSID(
- self, localsid_addr='A3::C4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_X,
- nh_addr=self.pg1.remote_ip6,
+ nh_addr4='0.0.0.0',
+ nh_addr6=self.pg1.remote_ip6,
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -737,9 +740,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End with PSP behavior
localsid = VppSRv6LocalSID(
- self, localsid_addr='A3::C4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_X,
- nh_addr=self.pg1.remote_ip6,
+ nh_addr4='0.0.0.0',
+ nh_addr6=self.pg1.remote_ip6,
end_psp=1,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -802,9 +806,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.DX6 behavior
localsid = VppSRv6LocalSID(
- self, localsid_addr='a3::c4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DX6,
- nh_addr=self.pg1.remote_ip6,
+ nh_addr4='0.0.0.0',
+ nh_addr6=self.pg1.remote_ip6,
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -890,9 +895,10 @@ class TestSRv6(VppTestCase):
# fib_table: where the localsid is installed
# sw_if_index: in T-variants of localsid this is the vrf table_id
localsid = VppSRv6LocalSID(
- self, localsid_addr='a3::c4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DT6,
- nh_addr='::',
+ nh_addr4='0.0.0.0',
+ nh_addr6='::',
end_psp=0,
sw_if_index=vrf_1,
vlan_index=0,
@@ -955,9 +961,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.DX4 behavior
localsid = VppSRv6LocalSID(
- self, localsid_addr='a3::c4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DX4,
- nh_addr=self.pg1.remote_ip4,
+ nh_addr4=self.pg1.remote_ip4,
+ nh_addr6='::',
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
@@ -1043,9 +1050,10 @@ class TestSRv6(VppTestCase):
# fib_table: where the localsid is installed
# sw_if_index: in T-variants of localsid: vrf table_id
localsid = VppSRv6LocalSID(
- self, localsid_addr='a3::c4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DT4,
- nh_addr='::',
+ nh_addr4='0.0.0.0',
+ nh_addr6='::',
end_psp=0,
sw_if_index=vrf_1,
vlan_index=0,
@@ -1107,9 +1115,10 @@ class TestSRv6(VppTestCase):
# configure SRv6 localSID End.DX2 behavior
localsid = VppSRv6LocalSID(
- self, localsid_addr='a3::c4',
+ self, localsid={'addr': 'A3::C4'},
behavior=SRv6LocalSIDBehaviors.SR_BEHAVIOR_DX2,
- nh_addr='::',
+ nh_addr4='0.0.0.0',
+ nh_addr6='::',
end_psp=0,
sw_if_index=self.pg1.sw_if_index,
vlan_index=0,
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index 34010125e3a..b0b452e8c9c 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -2667,9 +2667,10 @@ class VppPapiProvider(object):
'client_mac': client_mac})
def sr_localsid_add_del(self,
- localsid_addr,
+ localsid,
behavior,
- nh_addr,
+ nh_addr4,
+ nh_addr6,
is_del=0,
end_psp=0,
sw_if_index=0xFFFFFFFF,
@@ -2678,10 +2679,11 @@ class VppPapiProvider(object):
):
""" Add/del IPv6 SR local-SID.
- :param localsid_addr:
+ :param localsid:
:param behavior: END=1; END.X=2; END.DX2=4; END.DX6=5;
:param behavior: END.DX4=6; END.DT6=7; END.DT4=8
- :param nh_addr:
+ :param nh_addr4:
+ :param nh_addr6:
:param is_del: (Default value = 0)
:param end_psp: (Default value = 0)
:param sw_if_index: (Default value = 0xFFFFFFFF)
@@ -2691,13 +2693,14 @@ class VppPapiProvider(object):
return self.api(
self.papi.sr_localsid_add_del,
{'is_del': is_del,
- 'localsid_addr': localsid_addr,
+ 'localsid': localsid,
'end_psp': end_psp,
'behavior': behavior,
'sw_if_index': sw_if_index,
'vlan_index': vlan_index,
'fib_table': fib_table,
- 'nh_addr': nh_addr
+ 'nh_addr4': nh_addr4,
+ 'nh_addr6': nh_addr6
}
)
diff --git a/test/vpp_srv6.py b/test/vpp_srv6.py
index 28ff4b85991..7701cf35bc3 100644
--- a/test/vpp_srv6.py
+++ b/test/vpp_srv6.py
@@ -40,24 +40,15 @@ class VppSRv6LocalSID(VppObject):
SRv6 LocalSID
"""
- def __init__(self, test, localsid_addr, behavior, nh_addr, end_psp,
- sw_if_index, vlan_index, fib_table):
+ def __init__(self, test, localsid, behavior, nh_addr4, nh_addr6,
+ end_psp, sw_if_index, vlan_index, fib_table):
self._test = test
- self.localsid_addr = localsid_addr
- # keep binary format in _localsid_addr
- self._localsid_addr = inet_pton(AF_INET6, self.localsid_addr)
+ self.localsid = localsid
+ # keep binary format in _localsid
+ self.localsid["addr"] = inet_pton(AF_INET6, self.localsid["addr"])
self.behavior = behavior
- self.nh_addr = nh_addr
- # keep binary format in _nh_addr
- if ':' in nh_addr:
- # IPv6
- self._nh_addr = inet_pton(AF_INET6, nh_addr)
- else:
- # IPv4
- # API expects 16 octets (128 bits)
- # last 4 octets are used for IPv4
- # --> prepend 12 octets
- self._nh_addr = ('\x00' * 12) + inet_pton(AF_INET, nh_addr)
+ self.nh_addr4 = inet_pton(AF_INET, nh_addr4)
+ self.nh_addr6 = inet_pton(AF_INET6, nh_addr6)
self.end_psp = end_psp
self.sw_if_index = sw_if_index
self.vlan_index = vlan_index
@@ -66,9 +57,10 @@ class VppSRv6LocalSID(VppObject):
def add_vpp_config(self):
self._test.vapi.sr_localsid_add_del(
- self._localsid_addr,
+ self.localsid,
self.behavior,
- self._nh_addr,
+ self.nh_addr4,
+ self.nh_addr6,
is_del=0,
end_psp=self.end_psp,
sw_if_index=self.sw_if_index,
@@ -78,9 +70,10 @@ class VppSRv6LocalSID(VppObject):
def remove_vpp_config(self):
self._test.vapi.sr_localsid_add_del(
- self._localsid_addr,
+ self.localsid,
self.behavior,
- self._nh_addr,
+ self.nh_addr4,
+ self.nh_addr6,
is_del=1,
end_psp=self.end_psp,
sw_if_index=self.sw_if_index,
@@ -99,7 +92,7 @@ class VppSRv6LocalSID(VppObject):
def object_id(self):
return ("%d;%s,%d"
% (self.fib_table,
- self.localsid_addr,
+ self.localsid,
self.behavior))