aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2020-01-31 10:17:29 +0100
committerOle Trøan <otroan@employees.org>2020-02-26 11:45:25 +0000
commit00ec4019b399132a72467ed4c3fb039d4f2466b7 (patch)
tree72fc06bcc5ee1376b24bfe94413a5b8b2ef7067c /src
parent908965db7e3075ba7bacd924bfb0df203fe6cc7d (diff)
sr: API cleanup
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I6238ec79b916c23c07c3f7e2ac8e635f5a0d6112 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c2
-rw-r--r--src/vnet/srmpls/sr_mpls.api57
-rw-r--r--src/vnet/srmpls/sr_mpls_api.c46
-rw-r--r--src/vpp/api/custom_dump.c2
4 files changed, 58 insertions, 49 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index f85e94a50b7..da64a8151fd 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -8548,7 +8548,7 @@ api_sr_mpls_policy_add (vat_main_t * vam)
mp->bsid = htonl (bsid);
mp->weight = htonl (weight);
- mp->type = type;
+ mp->is_spray = type;
mp->n_segments = n_segments;
memcpy (mp->segments, segments, sizeof (u32) * n_segments);
vec_free (segments);
diff --git a/src/vnet/srmpls/sr_mpls.api b/src/vnet/srmpls/sr_mpls.api
index 2c981417089..4c9181839ce 100644
--- a/src/vnet/srmpls/sr_mpls.api
+++ b/src/vnet/srmpls/sr_mpls.api
@@ -13,15 +13,18 @@
* under the License.
*/
-option version = "1.0.0";
+option version = "2.0.0";
+
+import "vnet/interface_types.api";
+import "vnet/ip/ip_types.api";
/** \brief MPLS SR policy add
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
- @param bsid is the bindingSID of the SR Policy. MPLS label (20bit)
- @param weight is the weight of the sid list. optional.
- @param type is the type of the SR policy. (0.Default // 1.Spray)
- @param segments vector of labels (20bit) composing the segment list
+ @param bsid - is the bindingSID of the SR Policy. MPLS label (20bit)
+ @param weight - is the weight of the sid list. optional.
+ @param is_spray - is the type of the SR policy. (0.Default // 1.Spray)
+ @param segments - vector of labels (20bit) composing the segment list
*/
autoreply define sr_mpls_policy_add
{
@@ -29,11 +32,20 @@ autoreply define sr_mpls_policy_add
u32 context;
u32 bsid;
u32 weight;
- u8 type;
+ bool is_spray;
u8 n_segments;
u32 segments[n_segments];
};
+enum sr_mpls_policy_op
+{
+ SR_MPLS_POLICY_OP_API_NONE = 0,
+ SR_MPLS_POLICY_OP_API_ADD = 1,
+ SR_MPLS_POLICY_OP_API_DEL = 2,
+ SR_MPLS_POLICY_OP_API_MOD = 3,
+
+};
+
/** \brief MPLS SR policy modification
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -51,7 +63,7 @@ autoreply define sr_mpls_policy_mod
u32 client_index;
u32 context;
u32 bsid;
- u8 operation;
+ vl_api_sr_mpls_policy_op_t operation;
u32 sl_index;
u32 weight;
u8 n_segments;
@@ -74,30 +86,25 @@ autoreply define sr_mpls_policy_del
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param is_del
- @param bsid is the bindingSID of the SR Policy (~0 is no bsid)
- @param table_id is the VRF where to install the FIB entry for the BSID
- @param prefix is the IPv4/v6 address for L3 traffic type. If IPv4 (first 4B).
- @param mask_width is the mask for L3 traffic type
- @param sw_if_index is the incoming interface for L2 traffic
- @param traffic_type describes the type of traffic
- @param next_hop describes the next_hop (in case no BSID)
- @param nh_type describes type of NH (IPv4=4, IPv6=6)
- @param color describes the color
- @param co_bits are the CO_bits of the steering policy
- @param vpn_label is an additonal last VPN label. (~0 is no label)
+ @param bsid - is the bindingSID of the SR Policy (~0 is no bsid)
+ @param table_id - is the VRF where to install the FIB entry for the BSID
+ @param prefix - is the IPv4/v6 address for L3 traffic type.
+ @param mask_width - is the mask for L3 traffic type
+ @param next_hop - describes the next_hop (in case no BSID)
+ @param color - describes the color
+ @param co_bits - are the CO_bits of the steering policy
+ @param vpn_label - is an additonal last VPN label. (~0 is no label)
*/
autoreply define sr_mpls_steering_add_del
{
u32 client_index;
u32 context;
- u8 is_del;
+ bool is_del[default = false];
u32 bsid;
u32 table_id;
- u8 prefix_addr[16];
+ vl_api_prefix_t prefix;
u32 mask_width;
- u8 traffic_type;
- u8 next_hop[16];
- u8 nh_type;
+ vl_api_address_t next_hop;
u32 color;
u8 co_bits;
u32 vpn_label;
@@ -108,7 +115,6 @@ autoreply define sr_mpls_steering_add_del
@param context - sender context, to match reply w/ request
@param bsid is the bindingSID of the SR Policy
@param endpoint is the endpoint of the SR policy
- @param endpoint_type describes type of NH (IPv4=4, IPv6=6)
@param color is the color of the sr policy
*/
autoreply define sr_mpls_policy_assign_endpoint_color
@@ -116,8 +122,7 @@ autoreply define sr_mpls_policy_assign_endpoint_color
u32 client_index;
u32 context;
u32 bsid;
- u8 endpoint[16];
- u8 endpoint_type;
+ vl_api_address_t endpoint;
u32 color;
};
diff --git a/src/vnet/srmpls/sr_mpls_api.c b/src/vnet/srmpls/sr_mpls_api.c
index f17c8b482e3..359d7446aab 100644
--- a/src/vnet/srmpls/sr_mpls_api.c
+++ b/src/vnet/srmpls/sr_mpls_api.c
@@ -24,6 +24,8 @@
#include <vnet/api_errno.h>
#include <vnet/feature/feature.h>
+#include <vnet/ip/ip_types_api.h>
+
#include <vnet/vnet_msg_enum.h>
#define vl_typedefs /* define message structures */
@@ -66,7 +68,7 @@ vl_api_sr_mpls_policy_add_t_handler (vl_api_sr_mpls_policy_add_t * mp)
int rv = 0;
rv = sr_mpls_policy_add (ntohl (mp->bsid),
- segments, mp->type, ntohl (mp->weight));
+ segments, mp->is_spray, ntohl (mp->weight));
vec_free (segments);
REPLY_MACRO (VL_API_SR_MPLS_POLICY_ADD_REPLY);
@@ -90,8 +92,8 @@ vl_api_sr_mpls_policy_mod_t_handler (vl_api_sr_mpls_policy_mod_t * mp)
int rv = 0;
rv = sr_mpls_policy_mod (ntohl (mp->bsid),
- mp->operation, segments, ntohl (mp->sl_index),
- ntohl (mp->weight));
+ ntohl (mp->operation), segments,
+ ntohl (mp->sl_index), ntohl (mp->weight));
vec_free (segments);
REPLY_MACRO (VL_API_SR_MPLS_POLICY_MOD_REPLY);
@@ -111,28 +113,31 @@ static void vl_api_sr_mpls_steering_add_del_t_handler
(vl_api_sr_mpls_steering_add_del_t * mp)
{
vl_api_sr_mpls_steering_add_del_reply_t *rmp;
- ip46_address_t prefix;
+ fib_prefix_t prefix;
+ ip46_address_t next_hop;
clib_memset (&prefix, 0, sizeof (ip46_address_t));
- if (mp->traffic_type == SR_STEER_IPV4)
- memcpy (&prefix.ip4, mp->prefix_addr, sizeof (prefix.ip4));
- else
- memcpy (&prefix, mp->prefix_addr, sizeof (prefix.ip6));
+
+ ip_prefix_decode (&mp->prefix, &prefix);
+ ip_address_decode (&mp->next_hop, &next_hop);
int rv = 0;
if (mp->is_del)
- rv = sr_mpls_steering_policy_del (&prefix,
- ntohl (mp->mask_width),
- mp->traffic_type,
+ rv = sr_mpls_steering_policy_del (&prefix.fp_addr,
+ prefix.fp_len,
+ ip46_address_is_ip4 (&prefix.fp_addr) ?
+ SR_STEER_IPV4 : SR_STEER_IPV6,
ntohl (mp->table_id),
ntohl (mp->color));
else
rv = sr_mpls_steering_policy_add (ntohl (mp->bsid),
ntohl (mp->table_id),
- &prefix,
- ntohl (mp->mask_width),
- mp->traffic_type,
- (ip46_address_t *) & mp->next_hop,
- mp->nh_type,
+ &prefix.fp_addr,
+ prefix.fp_len,
+ ip46_address_is_ip4 (&prefix.fp_addr) ?
+ SR_STEER_IPV4 : SR_STEER_IPV6,
+ &next_hop,
+ ip46_address_is_ip4 (&next_hop) ?
+ SR_STEER_IPV4 : SR_STEER_IPV6,
ntohl (mp->color), mp->co_bits,
ntohl (mp->vpn_label));
@@ -147,13 +152,12 @@ static void vl_api_sr_mpls_policy_assign_endpoint_color_t_handler
ip46_address_t endpoint;
clib_memset (&endpoint, 0, sizeof (ip46_address_t));
- if (mp->endpoint_type == SR_STEER_IPV4)
- memcpy (&endpoint.ip4, mp->endpoint, sizeof (endpoint.ip4));
- else
- memcpy (&endpoint, mp->endpoint, sizeof (endpoint.ip6));
+ ip_address_decode (&mp->endpoint, &endpoint);
rv = sr_mpls_policy_assign_endpoint_color (ntohl (mp->bsid),
- &endpoint, mp->endpoint_type,
+ &endpoint,
+ ip46_address_is_ip4 (&endpoint) ?
+ SR_STEER_IPV4 : SR_STEER_IPV6,
ntohl (mp->color));
REPLY_MACRO (VL_API_SR_MPLS_POLICY_ASSIGN_ENDPOINT_COLOR_REPLY);
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 806fee69ddb..2a660312981 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -867,7 +867,7 @@ static void *vl_api_sr_mpls_policy_add_t_print
if (mp->weight != htonl ((u32) 1))
s = format (s, "%d ", (mp->weight));
- if (mp->type)
+ if (mp->is_spray)
s = format (s, "spray ");
if (mp->n_segments)