diff options
author | Chenmin Sun <chenmin.sun@intel.com> | 2020-09-04 06:50:22 +0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-04-22 14:44:10 +0000 |
commit | c7e7819ad5c152168a5f1a217c3b72043fd48797 (patch) | |
tree | 7a7c3938beb5db8c12ba83ff858a81927f3b4fd7 /src | |
parent | f04a8d111407374a4b0a83617a6ec76e055bc2a3 (diff) |
flow: Add API implementation of IP4/IP6, IP4_VXLAN/IP6_VXLAN
This patch adds the API handler implementation of the below flows:
FLOW_TYPE_IP4,
FLOW_TYPE_IP6,
FLOW_TYPE_IP4_VXLAN,
FLOW_TYPE_IP6_VXLAN
Type: feature
Signed-off-by: Chenmin Sun <chenmin.sun@intel.com>
Change-Id: I62e1c466b46f940180e957c859d122086aa22f1c
Diffstat (limited to 'src')
-rw-r--r-- | src/vnet/flow/FEATURE.yaml | 4 | ||||
-rw-r--r-- | src/vnet/flow/flow.api | 2 | ||||
-rw-r--r-- | src/vnet/flow/flow_api.c | 58 |
3 files changed, 63 insertions, 1 deletions
diff --git a/src/vnet/flow/FEATURE.yaml b/src/vnet/flow/FEATURE.yaml index cd86429557c..a26571c35e8 100644 --- a/src/vnet/flow/FEATURE.yaml +++ b/src/vnet/flow/FEATURE.yaml @@ -4,6 +4,8 @@ maintainer: Damjan Marion <damarion@cisco.com> features: - Four APIs are provided - flow_add, flow_del, flow_enable and flow_disable - The below flow types are currently supported: + - FLOW_TYPE_IP4, + - FLOW_TYPE_IP6, - FLOW_TYPE_IP4_N_TUPLE, - FLOW_TYPE_IP6_N_TUPLE, - FLOW_TYPE_IP4_N_TUPLE_TAGGED, @@ -11,6 +13,8 @@ features: - FLOW_TYPE_IP4_L2TPV3OIP, - FLOW_TYPE_IP4_IPSEC_ESP, - FLOW_TYPE_IP4_IPSEC_AH, + - FLOW_TYPE_IP4_VXLAN, + - FLOW_TYPE_IP6_VXLAN, - FLOW_TYPE_IP4_GTPC, - FLOW_TYPE_IP4_GTPU - The below flow actions can be specified for the flows: diff --git a/src/vnet/flow/flow.api b/src/vnet/flow/flow.api index b819847e998..7bb21cdcd72 100644 --- a/src/vnet/flow/flow.api +++ b/src/vnet/flow/flow.api @@ -13,7 +13,7 @@ * limitations under the License. */ -option version = "0.0.1"; +option version = "0.0.2"; import "vnet/interface_types.api"; import "vnet/ip/ip_types.api"; diff --git a/src/vnet/flow/flow_api.c b/src/vnet/flow/flow_api.c index b24c8510be5..4d0c536f113 100644 --- a/src/vnet/flow/flow_api.c +++ b/src/vnet/flow/flow_api.c @@ -83,6 +83,24 @@ port_and_mask_convert (vl_api_ip_port_and_mask_t * vl_api_port, } static inline void +ipv4_flow_convert (vl_api_flow_ip4_t *vl_api_flow, vnet_flow_ip4_t *f) +{ + ipv4_addr_and_mask_convert (&vl_api_flow->src_addr, &f->src_addr); + ipv4_addr_and_mask_convert (&vl_api_flow->dst_addr, &f->dst_addr); + + protocol_and_mask_convert (&vl_api_flow->protocol, &f->protocol); +} + +static void +ipv6_flow_convert (vl_api_flow_ip6_t *vl_api_flow, vnet_flow_ip6_t *f) +{ + ipv6_addr_and_mask_convert (&vl_api_flow->src_addr, &f->src_addr); + ipv6_addr_and_mask_convert (&vl_api_flow->dst_addr, &f->dst_addr); + + protocol_and_mask_convert (&vl_api_flow->protocol, &f->protocol); +} + +static inline void ipv4_n_tuple_flow_convert (vl_api_flow_ip4_n_tuple_t * vl_api_flow, vnet_flow_ip4_n_tuple_t * f) { @@ -158,6 +176,34 @@ ipv4_ipsec_ah_flow_convert (vl_api_flow_ip4_ipsec_ah_t * vl_api_flow, } static inline void +ipv4_vxlan_flow_convert (vl_api_flow_ip4_vxlan_t *vl_api_flow, + vnet_flow_ip4_vxlan_t *f) +{ + ipv4_addr_and_mask_convert (&vl_api_flow->src_addr, &f->src_addr); + ipv4_addr_and_mask_convert (&vl_api_flow->dst_addr, &f->dst_addr); + protocol_and_mask_convert (&vl_api_flow->protocol, &f->protocol); + + port_and_mask_convert (&vl_api_flow->src_port, &f->src_port); + port_and_mask_convert (&vl_api_flow->dst_port, &f->dst_port); + + f->vni = ntohs (vl_api_flow->vni); +} + +static inline void +ipv6_vxlan_flow_convert (vl_api_flow_ip6_vxlan_t *vl_api_flow, + vnet_flow_ip6_vxlan_t *f) +{ + ipv6_addr_and_mask_convert (&vl_api_flow->src_addr, &f->src_addr); + ipv6_addr_and_mask_convert (&vl_api_flow->dst_addr, &f->dst_addr); + protocol_and_mask_convert (&vl_api_flow->protocol, &f->protocol); + + port_and_mask_convert (&vl_api_flow->src_port, &f->src_port); + port_and_mask_convert (&vl_api_flow->dst_port, &f->dst_port); + + f->vni = ntohs (vl_api_flow->vni); +} + +static inline void ipv4_gtpu_flow_convert (vl_api_flow_ip4_gtpu_t * vl_api_flow, vnet_flow_ip4_gtpu_t * f) { @@ -207,6 +253,12 @@ vl_api_flow_add_t_handler (vl_api_flow_add_t * mp) switch (flow.type) { + case VNET_FLOW_TYPE_IP4: + ipv4_flow_convert (&f->flow.ip4, &flow.ip4); + break; + case VNET_FLOW_TYPE_IP6: + ipv6_flow_convert (&f->flow.ip6, &flow.ip6); + break; case VNET_FLOW_TYPE_IP4_N_TUPLE: ipv4_n_tuple_flow_convert (&f->flow.ip4_n_tuple, &flow.ip4_n_tuple); break; @@ -232,6 +284,12 @@ vl_api_flow_add_t_handler (vl_api_flow_add_t * mp) case VNET_FLOW_TYPE_IP4_IPSEC_AH: ipv4_ipsec_ah_flow_convert (&f->flow.ip4_ipsec_ah, &flow.ip4_ipsec_ah); break; + case VNET_FLOW_TYPE_IP4_VXLAN: + ipv4_vxlan_flow_convert (&f->flow.ip4_vxlan, &flow.ip4_vxlan); + break; + case VNET_FLOW_TYPE_IP6_VXLAN: + ipv6_vxlan_flow_convert (&f->flow.ip6_vxlan, &flow.ip6_vxlan); + break; case VNET_FLOW_TYPE_IP4_GTPU: ipv4_gtpu_flow_convert (&f->flow.ip4_gtpu, &flow.ip4_gtpu); break; |