2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

userspace: add erspan tunnel support.

ERSPAN is a tunneling protocol based on GRE tunnel.  The patch
add erspan tunnel support for ovs-vswitchd with userspace datapath.
Configuring erspan tunnel is similar to gre tunnel, but with
additional erspan's parameters.  Matching a flow on erspan's
metadata is also supported, see ovs-fields for more details.

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
William Tu
2018-05-15 16:10:48 -04:00
committed by Ben Pfaff
parent 0ffff49753
commit 7dc18ae96d
30 changed files with 1183 additions and 27 deletions

View File

@@ -231,6 +231,14 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
return !wc->masks.tunnel.gbp_id;
case MFF_TUN_GBP_FLAGS:
return !wc->masks.tunnel.gbp_flags;
case MFF_TUN_ERSPAN_VER:
return !wc->masks.tunnel.erspan_ver;
case MFF_TUN_ERSPAN_IDX:
return !wc->masks.tunnel.erspan_idx;
case MFF_TUN_ERSPAN_DIR:
return !wc->masks.tunnel.erspan_dir;
case MFF_TUN_ERSPAN_HWID:
return !wc->masks.tunnel.erspan_hwid;
CASE_MFF_TUN_METADATA:
return !ULLONG_GET(wc->masks.tunnel.metadata.present.map,
mf->id - MFF_TUN_METADATA0);
@@ -513,6 +521,10 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value)
case MFF_TUN_TTL:
case MFF_TUN_GBP_ID:
case MFF_TUN_GBP_FLAGS:
case MFF_TUN_ERSPAN_IDX:
case MFF_TUN_ERSPAN_VER:
case MFF_TUN_ERSPAN_DIR:
case MFF_TUN_ERSPAN_HWID:
CASE_MFF_TUN_METADATA:
case MFF_METADATA:
case MFF_IN_PORT:
@@ -680,6 +692,18 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow,
case MFF_TUN_TOS:
value->u8 = flow->tunnel.ip_tos;
break;
case MFF_TUN_ERSPAN_VER:
value->u8 = flow->tunnel.erspan_ver;
break;
case MFF_TUN_ERSPAN_IDX:
value->be32 = htonl(flow->tunnel.erspan_idx);
break;
case MFF_TUN_ERSPAN_DIR:
value->u8 = flow->tunnel.erspan_dir;
break;
case MFF_TUN_ERSPAN_HWID:
value->u8 = flow->tunnel.erspan_hwid;
break;
CASE_MFF_TUN_METADATA:
tun_metadata_read(&flow->tunnel, mf, value);
break;
@@ -994,6 +1018,18 @@ mf_set_value(const struct mf_field *mf,
case MFF_TUN_TTL:
match_set_tun_ttl(match, value->u8);
break;
case MFF_TUN_ERSPAN_VER:
match_set_tun_erspan_ver(match, value->u8);
break;
case MFF_TUN_ERSPAN_IDX:
match_set_tun_erspan_idx(match, ntohl(value->be32));
break;
case MFF_TUN_ERSPAN_DIR:
match_set_tun_erspan_dir(match, value->u8);
break;
case MFF_TUN_ERSPAN_HWID:
match_set_tun_erspan_hwid(match, value->u8);
break;
CASE_MFF_TUN_METADATA:
tun_metadata_set_match(mf, value, NULL, match, err_str);
break;
@@ -1391,6 +1427,18 @@ mf_set_flow_value(const struct mf_field *mf,
case MFF_TUN_TTL:
flow->tunnel.ip_ttl = value->u8;
break;
case MFF_TUN_ERSPAN_VER:
flow->tunnel.erspan_ver = value->u8;
break;
case MFF_TUN_ERSPAN_IDX:
flow->tunnel.erspan_idx = ntohl(value->be32);
break;
case MFF_TUN_ERSPAN_DIR:
flow->tunnel.erspan_dir = value->u8;
break;
case MFF_TUN_ERSPAN_HWID:
flow->tunnel.erspan_hwid = value->u8;
break;
CASE_MFF_TUN_METADATA:
tun_metadata_write(&flow->tunnel, mf, value);
break;
@@ -1700,6 +1748,10 @@ mf_is_pipeline_field(const struct mf_field *mf)
case MFF_TUN_FLAGS:
case MFF_TUN_GBP_ID:
case MFF_TUN_GBP_FLAGS:
case MFF_TUN_ERSPAN_VER:
case MFF_TUN_ERSPAN_IDX:
case MFF_TUN_ERSPAN_DIR:
case MFF_TUN_ERSPAN_HWID:
CASE_MFF_TUN_METADATA:
case MFF_METADATA:
case MFF_IN_PORT:
@@ -1876,6 +1928,18 @@ mf_set_wild(const struct mf_field *mf, struct match *match, char **err_str)
case MFF_TUN_TTL:
match_set_tun_ttl_masked(match, 0, 0);
break;
case MFF_TUN_ERSPAN_VER:
match_set_tun_erspan_ver_masked(match, 0, 0);
break;
case MFF_TUN_ERSPAN_IDX:
match_set_tun_erspan_idx_masked(match, 0, 0);
break;
case MFF_TUN_ERSPAN_DIR:
match_set_tun_erspan_dir_masked(match, 0, 0);
break;
case MFF_TUN_ERSPAN_HWID:
match_set_tun_erspan_hwid_masked(match, 0, 0);
break;
CASE_MFF_TUN_METADATA:
tun_metadata_set_match(mf, NULL, NULL, match, err_str);
break;
@@ -2256,6 +2320,19 @@ mf_set(const struct mf_field *mf,
case MFF_TUN_TOS:
match_set_tun_tos_masked(match, value->u8, mask->u8);
break;
case MFF_TUN_ERSPAN_VER:
match_set_tun_erspan_ver_masked(match, value->u8, mask->u8);
break;
case MFF_TUN_ERSPAN_IDX:
match_set_tun_erspan_idx_masked(match, ntohl(value->be32),
ntohl(mask->be32));
break;
case MFF_TUN_ERSPAN_DIR:
match_set_tun_erspan_dir_masked(match, value->u8, mask->u8);
break;
case MFF_TUN_ERSPAN_HWID:
match_set_tun_erspan_hwid_masked(match, value->u8, mask->u8);
break;
CASE_MFF_TUN_METADATA:
tun_metadata_set_match(mf, value, mask, match, err_str);
break;