SR-MPLS: binary API and automated steering
Change-Id: Iacfbaaa91ea8bd92790dec9fce567063bdbc5d64 Signed-off-by: Pablo Camarillo <pcamaril@cisco.com>
This commit is contained in:

committed by
Dave Barach

parent
d2fec4a255
commit
42998828c9
@ -772,11 +772,15 @@ API_FILES += vnet/srv6/sr.api
|
||||
|
||||
libvnet_la_SOURCES += \
|
||||
vnet/srmpls/sr_mpls_policy.c \
|
||||
vnet/srmpls/sr_mpls_steering.c
|
||||
vnet/srmpls/sr_mpls_steering.c \
|
||||
vnet/srmpls/sr_mpls_api.c
|
||||
|
||||
|
||||
nobase_include_HEADERS += \
|
||||
vnet/srmpls/sr.h
|
||||
vnet/srmpls/sr_mpls.h \
|
||||
vnet/srmpls/sr_mpls.api.h
|
||||
|
||||
API_FILES += vnet/srmpls/sr_mpls.api
|
||||
|
||||
########################################
|
||||
# IPFIX / netflow v10
|
||||
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Segment Routing MPLS data structures definitions
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef included_vnet_srmpls_h
|
||||
#define included_vnet_srmpls_h
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
#include <vnet/mpls/packet.h>
|
||||
#include <vnet/fib/mpls_fib.h>
|
||||
#include <vnet/ip/ip.h>
|
||||
#include <vnet/ip/lookup.h>
|
||||
#include <vnet/dpo/dpo.h>
|
||||
#include <vnet/dpo/replicate_dpo.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* SR policy types */
|
||||
#define SR_POLICY_TYPE_DEFAULT 0
|
||||
#define SR_POLICY_TYPE_SPRAY 1
|
||||
|
||||
#define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
|
||||
|
||||
#define SR_STEER_IPV4 4
|
||||
#define SR_STEER_IPV6 6
|
||||
|
||||
/**
|
||||
* @brief SR Segment List (SID list)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* SIDs (key)
|
||||
*/
|
||||
mpls_label_t *segments;
|
||||
|
||||
/**
|
||||
* SID list weight (wECMP / UCMP)
|
||||
*/
|
||||
u32 weight;
|
||||
|
||||
} mpls_sr_sl_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 *segments_lists; /**< Pool of SID lists indexes */
|
||||
|
||||
mpls_label_t bsid; /**< BindingSID (key) */
|
||||
|
||||
u8 type; /**< Type (default is 0) */
|
||||
/* SR Policy specific DPO */
|
||||
/* IF Type = DEFAULT Then Load Balancer DPO among SID lists */
|
||||
/* IF Type = SPRAY then Spray DPO with all SID lists */
|
||||
|
||||
} mpls_sr_policy_t;
|
||||
|
||||
/**
|
||||
* @brief Steering db key
|
||||
*
|
||||
* L3 is IPv4/IPv6 + mask
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ip46_address_t prefix; /**< IP address of the prefix */
|
||||
u32 mask_width; /**< Mask width of the prefix */
|
||||
u32 fib_table; /**< VRF of the prefix */
|
||||
u8 traffic_type; /**< Traffic type (IPv4, IPv6, L2) */
|
||||
u8 padding[3];
|
||||
} sr_mpls_steering_key_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sr_mpls_steering_key_t classify; /**< Traffic classification */
|
||||
u32 sr_policy; /**< SR Policy index */
|
||||
} mpls_sr_steering_policy_t;
|
||||
|
||||
/**
|
||||
* @brief Segment Routing main datastructure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/**
|
||||
* SR SID lists
|
||||
*/
|
||||
mpls_sr_sl_t *sid_lists;
|
||||
|
||||
/**
|
||||
* SR MPLS policies
|
||||
*/
|
||||
mpls_sr_policy_t *sr_policies;
|
||||
|
||||
/**
|
||||
* Hash table mapping BindingSID to SR MPLS policy
|
||||
*/
|
||||
uword *sr_policies_index_hash;
|
||||
|
||||
/**
|
||||
* Pool of SR steer policies instances
|
||||
*/
|
||||
mpls_sr_steering_policy_t *steer_policies;
|
||||
|
||||
/**
|
||||
* MHash table mapping steering rules to SR steer instance
|
||||
*/
|
||||
mhash_t sr_steer_policies_hash;
|
||||
|
||||
/**
|
||||
* convenience
|
||||
*/
|
||||
vlib_main_t *vlib_main;
|
||||
vnet_main_t *vnet_main;
|
||||
} mpls_sr_main_t;
|
||||
|
||||
extern mpls_sr_main_t sr_mpls_main;
|
||||
|
||||
extern int
|
||||
sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
|
||||
u8 behavior, u32 weight);
|
||||
|
||||
extern int
|
||||
sr_mpls_policy_mod (mpls_label_t bsid, u32 index, u8 operation,
|
||||
mpls_label_t * segments, u32 sl_index, u32 weight);
|
||||
|
||||
extern int sr_mpls_policy_del (mpls_label_t bsid, u32 index);
|
||||
|
||||
#endif /* included_vnet_sr_mpls_h */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
@ -64,7 +64,6 @@ Note that this CLI cannot be used to remove the last SID list of a policy. Inste
|
||||
The weight of a SID list can also be modified with:
|
||||
|
||||
sr mpls policy mod bsid 40001 mod sl index 1 weight 4
|
||||
sr mpls policy mod index 1 mod sl index 1 weight 4
|
||||
|
||||
### SR Policies: Spray policies
|
||||
|
||||
@ -80,8 +79,43 @@ Spray policies are used for removing multicast state from a network core domain,
|
||||
|
||||
## Steering packets into a SR Policy
|
||||
|
||||
To steer packets in Transit into an SR policy, the user needs to create an 'sr steering policy'.
|
||||
Segment Routing supports three methos of steering traffic into an SR policy.
|
||||
|
||||
### Local steering
|
||||
|
||||
In this variant incoming packets match a routing policy which directs them on a local SR policy.
|
||||
|
||||
In order to achieve this behavior the user needs to create an 'sr steering policy via sr policy bsid'.
|
||||
|
||||
sr mpls steer l3 2001::/64 via sr policy bsid 40001
|
||||
sr mpls steer l3 2001::/64 via sr policy bsid 40001 fib-table 3
|
||||
sr mpls steer l3 10.0.0.0/16 via sr policy bsid 40001
|
||||
sr mpls steer l3 10.0.0.0/16 via sr policy bsid 40001 vpn-label 500
|
||||
|
||||
### Remote steering
|
||||
|
||||
In this variant incoming packets have an active SID matching a local BSID at the head-end.
|
||||
|
||||
In order to achieve this behavior the packets should simply arrive with an active SID equal to the Binding SID of a locally instantiated SR policy.
|
||||
|
||||
### Automated steering
|
||||
|
||||
In this variant incoming packets match a BGP/Service route which recurses on the BSID of a local policy.
|
||||
|
||||
In order to achieve this behavior the user first needs to color the SR policies. He can do so by using the CLI:
|
||||
|
||||
sr mpls policy te bsid xxxxx endpoint x.x.x.x color 12341234
|
||||
|
||||
Notice that an SR policy can have a single endpoint and a single color. Notice that the *endpoint* value is an IP46 address and the color a u32.
|
||||
|
||||
|
||||
Then, for any BGP/Service route the user has to use the API to steer prefixes:
|
||||
|
||||
sr steer l3 2001::/64 via next-hop 2001::1 color 1234 co 2
|
||||
sr steer l3 2001::/64 via next-hop 2001::1 color 1234 co 2 vpn-label 500
|
||||
|
||||
Notice that *co* refers to the CO-bits (values [0|1|2|3]).
|
||||
|
||||
Notice also that a given prefix might be steered over several colors (same next-hop and same co-bit value). In order to add new colors just execute the API several times (or with the del parameter to delete the color).
|
||||
|
||||
This variant is meant to be used in conjunction with a control plane agent that uses the underlying binary API bindings of *sr_mpls_steering_policy_add*/*sr_mpls_steering_policy_del* for any BGP service route received.
|
126
src/vnet/srmpls/sr_mpls.api
Normal file
126
src/vnet/srmpls/sr_mpls.api
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Cisco and/or its affiliates. Licensed under the
|
||||
* Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
vl_api_version 1.0 .0
|
||||
/** \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
|
||||
*/
|
||||
autoreply define sr_mpls_policy_add
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 bsid;
|
||||
u32 weight;
|
||||
u8 type;
|
||||
u8 n_segments;
|
||||
u32 segments[n_segments];
|
||||
};
|
||||
|
||||
/** \brief MPLS SR policy modification
|
||||
@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 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 MPLS labels 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.
|
||||
*/
|
||||
autoreply define sr_mpls_policy_mod
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 bsid;
|
||||
u8 operation;
|
||||
u32 sl_index;
|
||||
u32 weight;
|
||||
u8 n_segments;
|
||||
u32 segments[n_segments];
|
||||
};
|
||||
|
||||
/** \brief MPLS SR policy deletion
|
||||
@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)
|
||||
*/
|
||||
autoreply define sr_mpls_policy_del
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 bsid;
|
||||
};
|
||||
|
||||
/** \brief MPLS SR steering add/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)
|
||||
*/
|
||||
autoreply define sr_mpls_steering_add_del
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 is_del;
|
||||
u32 bsid;
|
||||
u32 table_id;
|
||||
u8 prefix_addr[16];
|
||||
u32 mask_width;
|
||||
u8 traffic_type;
|
||||
u8 next_hop[16];
|
||||
u8 nh_type;
|
||||
u32 color;
|
||||
u8 co_bits;
|
||||
u32 vpn_label;
|
||||
};
|
||||
|
||||
/** \brief MPLS SR steering add/del
|
||||
@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
|
||||
@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
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 bsid;
|
||||
u8 endpoint[16];
|
||||
u8 endpoint_type;
|
||||
u32 color;
|
||||
};
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON Local Variables: eval:
|
||||
* (c-set-style "gnu") End:
|
||||
*/
|
177
src/vnet/srmpls/sr_mpls.h
Executable file
177
src/vnet/srmpls/sr_mpls.h
Executable file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco and/or its affiliates. Licensed under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Segment Routing MPLS data structures definitions
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef included_vnet_srmpls_h
|
||||
#define included_vnet_srmpls_h
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
#include <vnet/mpls/packet.h>
|
||||
#include <vnet/fib/mpls_fib.h>
|
||||
#include <vnet/ip/ip.h>
|
||||
#include <vnet/ip/lookup.h>
|
||||
#include <vnet/dpo/dpo.h>
|
||||
#include <vnet/dpo/replicate_dpo.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* SR policy types */
|
||||
#define SR_POLICY_TYPE_DEFAULT 0
|
||||
#define SR_POLICY_TYPE_SPRAY 1
|
||||
|
||||
#define SR_SEGMENT_LIST_WEIGHT_DEFAULT 1
|
||||
|
||||
#define SR_STEER_IPV4 4
|
||||
#define SR_STEER_IPV6 6
|
||||
|
||||
#define SR_TE_CO_BITS_00 0
|
||||
#define SR_TE_CO_BITS_01 1
|
||||
#define SR_TE_CO_BITS_10 2
|
||||
#define SR_TE_CO_BITS_11 3
|
||||
|
||||
/**
|
||||
* @brief SR Segment List (SID list)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* SIDs (key) */
|
||||
mpls_label_t *segments;
|
||||
|
||||
/* SID list weight (wECMP / UCMP) */
|
||||
u32 weight;
|
||||
|
||||
} mpls_sr_sl_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 *segments_lists; /**< Pool of SID lists indexes */
|
||||
|
||||
mpls_label_t bsid; /**< BindingSID (key) */
|
||||
|
||||
u8 type; /**< Type (default is 0) */
|
||||
/* SR Policy specific DPO */
|
||||
/* IF Type = DEFAULT Then Load Balancer DPO among SID lists */
|
||||
/* IF Type = SPRAY then Spray DPO with all SID lists */
|
||||
|
||||
ip46_address_t endpoint; /**< Optional NH for SR TE */
|
||||
u8 endpoint_type;
|
||||
u32 color; /**< Optional color for SR TE */
|
||||
} mpls_sr_policy_t;
|
||||
|
||||
/**
|
||||
* @brief Steering db key
|
||||
*
|
||||
* L3 is IPv4/IPv6 + mask
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ip46_address_t prefix; /**< IP address of the prefix */
|
||||
u32 mask_width; /**< Mask width of the prefix */
|
||||
u32 fib_table; /**< VRF of the prefix */
|
||||
u8 traffic_type; /**< Traffic type (IPv4, IPv6, L2) */
|
||||
u8 padding[3];
|
||||
} sr_mpls_steering_key_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sr_mpls_steering_key_t classify; /**< Traffic classification */
|
||||
mpls_label_t bsid; /**< SR Policy index */
|
||||
ip46_address_t next_hop; /**< SR TE NH */
|
||||
char nh_type;
|
||||
u32 *color; /**< Vector of SR TE colors */
|
||||
char co_bits; /**< Color-Only bits */
|
||||
mpls_label_t vpn_label;
|
||||
} mpls_sr_steering_policy_t;
|
||||
|
||||
/**
|
||||
* @brief Segment Routing main datastructure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* SR SID lists */
|
||||
mpls_sr_sl_t *sid_lists;
|
||||
|
||||
/* SR MPLS policies */
|
||||
mpls_sr_policy_t *sr_policies;
|
||||
|
||||
/* Hash table mapping BindingSID to SR MPLS policy */
|
||||
uword *sr_policies_index_hash;
|
||||
|
||||
/* Pool of SR steer policies instances */
|
||||
mpls_sr_steering_policy_t *steer_policies;
|
||||
|
||||
/* MHash table mapping steering rules to SR steer instance */
|
||||
mhash_t sr_steer_policies_hash;
|
||||
|
||||
/** SR TE **/
|
||||
/* Hash table mapping (Color->Endpoint->BSID) for SR policies */
|
||||
mhash_t sr_policies_c2e2eclabel_hash;
|
||||
/* SR TE (internal) fib table (Endpoint, Color) */
|
||||
u32 fib_table_EC;
|
||||
/* Pool of (Endpoint, Color) hidden labels */
|
||||
u32 *ec_labels;
|
||||
|
||||
/* convenience */
|
||||
vlib_main_t *vlib_main;
|
||||
vnet_main_t *vnet_main;
|
||||
} mpls_sr_main_t;
|
||||
|
||||
extern mpls_sr_main_t sr_mpls_main;
|
||||
|
||||
extern int
|
||||
sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
|
||||
u8 behavior, u32 weight);
|
||||
|
||||
extern int
|
||||
sr_mpls_policy_mod (mpls_label_t bsid, u8 operation,
|
||||
mpls_label_t * segments, u32 sl_index, u32 weight);
|
||||
|
||||
extern int sr_mpls_policy_del (mpls_label_t bsid);
|
||||
|
||||
extern int
|
||||
sr_mpls_policy_assign_endpoint_color (mpls_label_t bsid,
|
||||
ip46_address_t * endpoint,
|
||||
u8 endpoint_type, u32 color);
|
||||
|
||||
extern int
|
||||
sr_mpls_steering_policy_add (mpls_label_t bsid, u32 table_id,
|
||||
ip46_address_t * prefix, u32 mask_width,
|
||||
u8 traffic_type, ip46_address_t * next_hop,
|
||||
u8 nh_type, u32 color, char co_bits,
|
||||
mpls_label_t vpn_label);
|
||||
|
||||
extern int
|
||||
sr_mpls_steering_policy_del (ip46_address_t * prefix,
|
||||
u32 mask_width, u8 traffic_type, u32 table_id,
|
||||
u32 color);
|
||||
|
||||
extern u32 find_or_create_internal_label (ip46_address_t endpoint, u32 color);
|
||||
|
||||
extern void internal_label_lock (ip46_address_t endpoint, u32 color);
|
||||
|
||||
extern void internal_label_unlock (ip46_address_t endpoint, u32 color);
|
||||
|
||||
#endif /* included_vnet_sr_mpls_h */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables: eval: (c-set-style "gnu") End:
|
||||
*/
|
228
src/vnet/srmpls/sr_mpls_api.c
Normal file
228
src/vnet/srmpls/sr_mpls_api.c
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* ------------------------------------------------------------------
|
||||
* sr_api.c - ipv6 segment routing api
|
||||
*
|
||||
* Copyright (c) 2016 Cisco and/or its affiliates. Licensed under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
#include <vnet/srmpls/sr_mpls.h>
|
||||
#include <vlibmemory/api.h>
|
||||
|
||||
#include <vnet/interface.h>
|
||||
#include <vnet/api_errno.h>
|
||||
#include <vnet/feature/feature.h>
|
||||
|
||||
#include <vnet/vnet_msg_enum.h>
|
||||
|
||||
#define vl_typedefs /* define message structures */
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_typedefs
|
||||
|
||||
#define vl_endianfun /* define message structures */
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_endianfun
|
||||
|
||||
/* instantiate all the print functions we know about */
|
||||
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
|
||||
#define vl_printfun
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_printfun
|
||||
|
||||
#include <vlibapi/api_helper_macros.h>
|
||||
|
||||
#define foreach_vpe_api_msg \
|
||||
_(SR_MPLS_POLICY_DEL, sr_mpls_policy_del) \
|
||||
_(SR_MPLS_STEERING_ADD_DEL, sr_mpls_steering_add_del) \
|
||||
_(SR_MPLS_POLICY_ASSIGN_ENDPOINT_COLOR, sr_mpls_policy_assign_endpoint_color)
|
||||
|
||||
|
||||
static void
|
||||
vl_api_sr_mpls_policy_add_t_handler (vl_api_sr_mpls_policy_add_t * mp)
|
||||
{
|
||||
vl_api_sr_mpls_policy_add_reply_t *rmp;
|
||||
|
||||
mpls_label_t *segments = 0, *seg;
|
||||
mpls_label_t this_address = 0;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < mp->n_segments; i++)
|
||||
{
|
||||
vec_add2 (segments, seg, 1);
|
||||
this_address = ntohl (mp->segments[i]);
|
||||
clib_memcpy (seg, &this_address, sizeof (this_address));
|
||||
}
|
||||
|
||||
int rv = 0;
|
||||
rv = sr_mpls_policy_add (ntohl (mp->bsid),
|
||||
segments, mp->type, ntohl (mp->weight));
|
||||
|
||||
REPLY_MACRO (VL_API_SR_MPLS_POLICY_ADD_REPLY);
|
||||
}
|
||||
|
||||
static void
|
||||
vl_api_sr_mpls_policy_mod_t_handler (vl_api_sr_mpls_policy_mod_t * mp)
|
||||
{
|
||||
vl_api_sr_mpls_policy_mod_reply_t *rmp;
|
||||
|
||||
mpls_label_t *segments = 0, *seg;
|
||||
mpls_label_t this_address = 0;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < mp->n_segments; i++)
|
||||
{
|
||||
vec_add2 (segments, seg, 1);
|
||||
this_address = ntohl (mp->segments[i]);
|
||||
clib_memcpy (seg, &this_address, sizeof (this_address));
|
||||
}
|
||||
|
||||
int rv = 0;
|
||||
rv = sr_mpls_policy_mod (ntohl (mp->bsid),
|
||||
mp->operation, segments, ntohl (mp->sl_index),
|
||||
ntohl (mp->weight));
|
||||
|
||||
REPLY_MACRO (VL_API_SR_MPLS_POLICY_MOD_REPLY);
|
||||
}
|
||||
|
||||
static void
|
||||
vl_api_sr_mpls_policy_del_t_handler (vl_api_sr_mpls_policy_del_t * mp)
|
||||
{
|
||||
vl_api_sr_mpls_policy_del_reply_t *rmp;
|
||||
int rv = 0;
|
||||
rv = sr_mpls_policy_del (ntohl (mp->bsid));
|
||||
|
||||
REPLY_MACRO (VL_API_SR_MPLS_POLICY_DEL_REPLY);
|
||||
}
|
||||
|
||||
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;
|
||||
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));
|
||||
|
||||
int rv = 0;
|
||||
if (mp->is_del)
|
||||
rv = sr_mpls_steering_policy_del (&prefix,
|
||||
ntohl (mp->mask_width),
|
||||
mp->traffic_type,
|
||||
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,
|
||||
ntohl (mp->color), mp->co_bits,
|
||||
ntohl (mp->vpn_label));
|
||||
|
||||
REPLY_MACRO (VL_API_SR_MPLS_STEERING_ADD_DEL_REPLY);
|
||||
}
|
||||
|
||||
static void vl_api_sr_mpls_policy_assign_endpoint_color_t_handler
|
||||
(vl_api_sr_mpls_policy_assign_endpoint_color_t * mp)
|
||||
{
|
||||
vl_api_sr_mpls_policy_assign_endpoint_color_reply_t *rmp;
|
||||
int rv = 0;
|
||||
|
||||
ip46_address_t endpoint;
|
||||
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));
|
||||
|
||||
rv = sr_mpls_policy_assign_endpoint_color (ntohl (mp->bsid),
|
||||
&endpoint, mp->endpoint_type,
|
||||
ntohl (mp->color));
|
||||
|
||||
REPLY_MACRO (VL_API_SR_MPLS_POLICY_ASSIGN_ENDPOINT_COLOR_REPLY);
|
||||
}
|
||||
|
||||
/*
|
||||
* sr_mpls_api_hookup Add vpe's API message handlers to the table. vlib has
|
||||
* alread mapped shared memory and added the client registration handlers.
|
||||
* See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
|
||||
*/
|
||||
#define vl_msg_name_crc_list
|
||||
#include <vnet/vnet_all_api_h.h>
|
||||
#undef vl_msg_name_crc_list
|
||||
|
||||
static void
|
||||
setup_message_id_table (api_main_t * am)
|
||||
{
|
||||
#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
|
||||
foreach_vl_msg_name_crc_sr_mpls;
|
||||
#undef _
|
||||
}
|
||||
|
||||
static clib_error_t *
|
||||
sr_mpls_api_hookup (vlib_main_t * vm)
|
||||
{
|
||||
api_main_t *am = &api_main;
|
||||
|
||||
#define _(N,n) \
|
||||
vl_msg_api_set_handlers(VL_API_##N, #n, \
|
||||
vl_api_##n##_t_handler, \
|
||||
vl_noop_handler, \
|
||||
vl_api_##n##_t_endian, \
|
||||
vl_api_##n##_t_print, \
|
||||
sizeof(vl_api_##n##_t), 1);
|
||||
foreach_vpe_api_msg;
|
||||
#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_MPLS_POLICY_ADD,
|
||||
"sr_mpls_policy_add",
|
||||
vl_api_sr_mpls_policy_add_t_handler,
|
||||
vl_noop_handler,
|
||||
vl_api_sr_mpls_policy_add_t_endian,
|
||||
vl_api_sr_mpls_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_MPLS_POLICY_MOD,
|
||||
"sr_mpls_policy_mod",
|
||||
vl_api_sr_mpls_policy_mod_t_handler,
|
||||
vl_noop_handler,
|
||||
vl_api_sr_mpls_policy_mod_t_endian,
|
||||
vl_api_sr_mpls_policy_mod_t_print, 256, 1);
|
||||
|
||||
/*
|
||||
* Set up the (msg_name, crc, message-id) table
|
||||
*/
|
||||
setup_message_id_table (am);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VLIB_API_INIT_FUNCTION (sr_mpls_api_hookup);
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables: eval: (c-set-style "gnu") End:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,28 +1,28 @@
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* ------------------------------------------------------------------
|
||||
* vl_memory_api_h.h - memory API headers, in a specific order.
|
||||
*
|
||||
* Copyright (c) 2009-2010 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
* Copyright (c) 2009-2010 Cisco and/or its affiliates. Licensed under the
|
||||
* Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*------------------------------------------------------------------
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Add to the bottom of the #include list, or elves will steal your
|
||||
* keyboard in the middle of the night!
|
||||
* Add to the bottom of the #include list, or elves will steal your keyboard
|
||||
* in the middle of the night!
|
||||
*
|
||||
* Include current layer (2) last, or an artistic disagreement
|
||||
* about message numbering will occur
|
||||
* Include current layer (2) last, or an artistic disagreement about message
|
||||
* numbering will occur
|
||||
*/
|
||||
|
||||
#ifndef included_from_layer_3
|
||||
@ -54,6 +54,7 @@
|
||||
#include <vnet/session/session.api.h>
|
||||
#include <vnet/mpls/mpls.api.h>
|
||||
#include <vnet/srv6/sr.api.h>
|
||||
#include <vnet/srmpls/sr_mpls.api.h>
|
||||
#include <vnet/classify/classify.api.h>
|
||||
#include <vnet/flow/flow.api.h>
|
||||
#include <vnet/dhcp/dhcp.api.h>
|
||||
@ -71,7 +72,5 @@
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
* Local Variables: eval: (c-set-style "gnu") End:
|
||||
*/
|
||||
|
@ -1,20 +1,20 @@
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* ------------------------------------------------------------------
|
||||
* custom_dump.c - pretty-print API messages for replay
|
||||
*
|
||||
* Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
* Copyright (c) 2014-2016 Cisco and/or its affiliates. Licensed under the
|
||||
* Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*------------------------------------------------------------------
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
@ -25,6 +25,7 @@
|
||||
#include <vnet/l2tp/l2tp.h>
|
||||
#include <vnet/l2/l2_input.h>
|
||||
#include <vnet/srv6/sr.h>
|
||||
#include <vnet/srmpls/sr_mpls.h>
|
||||
#include <vnet/vxlan-gpe/vxlan_gpe.h>
|
||||
#include <vnet/geneve/geneve.h>
|
||||
#include <vnet/classify/policer_classify.h>
|
||||
@ -2064,7 +2065,6 @@ format_policer_action (u8 * s, va_list * va)
|
||||
}
|
||||
s = format (s, "%s", t);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -2610,7 +2610,6 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print
|
||||
s = format (s, "seid %U ", format_lisp_flat_eid,
|
||||
mp->eid_type, mp->seid, mp->seid_len);
|
||||
}
|
||||
|
||||
rloc_num = clib_net_to_host_u32 (mp->rloc_num);
|
||||
|
||||
if (0 == rloc_num)
|
||||
@ -2833,7 +2832,6 @@ static void *vl_api_lisp_eid_table_dump_t_print
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
@ -2946,7 +2944,6 @@ static void *vl_api_l2_interface_pbb_tag_rewrite_t_print
|
||||
s = format (s, "sid %d ", ntohl (mp->i_sid));
|
||||
s = format (s, "vlanid %d ", ntohs (mp->b_vlanid));
|
||||
}
|
||||
|
||||
FINISH;
|
||||
}
|
||||
|
||||
@ -3503,7 +3500,5 @@ vl_msg_api_custom_dump_configure (api_main_t * am)
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
* Local Variables: eval: (c-set-style "gnu") End:
|
||||
*/
|
||||
|
Reference in New Issue
Block a user