summaryrefslogtreecommitdiff
path: root/lib/netdev-native-tnl.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-06-23 16:47:59 +0000
committerBen Pfaff <blp@ovn.org>2017-06-27 17:28:30 -0400
commit875ab13020b16269e0401b11fe0efc74e2cd952a (patch)
treeb474fb6bbb68be94bffd7ce6d4cd9a889408689c /lib/netdev-native-tnl.c
parent3d4b2e6eb74ed5bb5b35373aa8a489536938fee6 (diff)
downloadopenvswitch-875ab13020b16269e0401b11fe0efc74e2cd952a.tar.gz
userspace: Handling of versatile tunnel ports
In netdev_gre_build_header(), GRE protocol and VXLAN next_potocol is set based on packet_type of flow. If it's about an Ethernet packet, it is set to ETP_TYPE_TEB. Otherwise, if the name space is OFPHTN_ETHERNET, it is set according to the name space type. Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/netdev-native-tnl.c')
-rw-r--r--lib/netdev-native-tnl.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index c7a299345..7f3cf984e 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -463,10 +463,13 @@ netdev_gre_build_header(const struct netdev *netdev,
greh = netdev_tnl_ip_build_header(data, params, IPPROTO_GRE);
- if (tnl_cfg->is_layer3) {
- greh->protocol = params->flow->dl_type;
- } else {
+ if (params->flow->packet_type == htonl(PT_ETH)) {
greh->protocol = htons(ETH_TYPE_TEB);
+ } else if (pt_ns(params->flow->packet_type) == OFPHTN_ETHERTYPE) {
+ greh->protocol = pt_ns_type_be(params->flow->packet_type);
+ } else {
+ ovs_mutex_unlock(&dev->mutex);
+ return 1;
}
greh->flags = 0;
@@ -575,8 +578,10 @@ netdev_vxlan_build_header(const struct netdev *netdev,
put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS | VXLAN_HF_GPE));
put_16aligned_be32(&vxh->vx_vni,
htonl(ntohll(params->flow->tunnel.tun_id) << 8));
- if (tnl_cfg->is_layer3) {
- switch (ntohs(params->flow->dl_type)) {
+ if (params->flow->packet_type == htonl(PT_ETH)) {
+ vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+ } else if (pt_ns(params->flow->packet_type) == OFPHTN_ETHERTYPE) {
+ switch (pt_ns_type(params->flow->packet_type)) {
case ETH_TYPE_IP:
vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_IPV4;
break;
@@ -586,9 +591,11 @@ netdev_vxlan_build_header(const struct netdev *netdev,
case ETH_TYPE_TEB:
vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
break;
+ default:
+ goto drop;
}
} else {
- vxh->vx_gpe.next_protocol = VXLAN_GPE_NP_ETHERNET;
+ goto drop;
}
} else {
put_16aligned_be32(&vxh->vx_flags, htonl(VXLAN_FLAGS));
@@ -600,6 +607,10 @@ netdev_vxlan_build_header(const struct netdev *netdev,
data->header_len += sizeof *vxh;
data->tnl_type = OVS_VPORT_TYPE_VXLAN;
return 0;
+
+drop:
+ ovs_mutex_unlock(&dev->mutex);
+ return 1;
}
struct dp_packet *