summaryrefslogtreecommitdiffstats
path: root/src/vnet/flow/flow_api.c
diff options
context:
space:
mode:
authorChenmin Sun <chenmin.sun@intel.com>2020-09-04 06:50:22 +0800
committerDamjan Marion <dmarion@me.com>2021-04-22 14:44:10 +0000
commitc7e7819ad5c152168a5f1a217c3b72043fd48797 (patch)
tree7a7c3938beb5db8c12ba83ff858a81927f3b4fd7 /src/vnet/flow/flow_api.c
parentf04a8d111407374a4b0a83617a6ec76e055bc2a3 (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/vnet/flow/flow_api.c')
-rw-r--r--src/vnet/flow/flow_api.c58
1 files changed, 58 insertions, 0 deletions
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;