[ovs-dev,05/10] netdev-native-tnl: Selection of gre protocol based on packet_type

Message ID AM2PR07MB1042C24DEA7652507FDE94B38A190@AM2PR07MB1042.eurprd07.prod.outlook.com
State Deferred
Headers show

Commit Message

Zoltán Balogh April 18, 2017, 11:20 a.m.
From: Jan Scheurich <jan.scheurich@ericsson.com>

In netdev_gre_build_header(), GRE protocol 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>
---
 lib/netdev-native-tnl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 2d947c2..76dd07e 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -462,10 +462,12 @@  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 {
+        return 1;
     }
     greh->flags = 0;