[ovs-dev] [PATCH V2 31/41] lib/dpif-netlink: Fix miscompare of gre ports

Greg Rose gvrose8192 at gmail.com
Fri May 18 01:57:44 UTC 2018


In netdev_to_ovs_vport_type() it checks for netdev types matching
"gre" with a strstr().  This makes it match ip6gre as well and return
OVS_VPORT_TYPE_GRE, which is clearly wrong.

Move the usage of strstr() *after* all the exact matches with strcmp()
to avoid the problem permanently because when I added the ip6gre
type I ran into a very difficult to detect bug.

Cc: Ben Pfaff <blp at ovn.org>
Signed-off-by: Greg Rose <gvrose8192 at gmail.com>
---

V2 - Removed strstr for gre completely as per Ben's feedback.
---
 lib/dpif-netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 607b497..20e1921 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -817,8 +817,6 @@ netdev_to_ovs_vport_type(const char *type)
         return OVS_VPORT_TYPE_STT;
     } else if (!strcmp(type, "geneve")) {
         return OVS_VPORT_TYPE_GENEVE;
-    } else if (strstr(type, "gre")) {
-        return OVS_VPORT_TYPE_GRE;
     } else if (!strcmp(type, "vxlan")) {
         return OVS_VPORT_TYPE_VXLAN;
     } else if (!strcmp(type, "lisp")) {
@@ -829,6 +827,8 @@ netdev_to_ovs_vport_type(const char *type)
         return OVS_VPORT_TYPE_IP6ERSPAN;
     } else if (!strcmp(type, "ip6gre")) {
         return OVS_VPORT_TYPE_IP6GRE;
+    } else if (strcmp(type, "gre")) {
+        return OVS_VPORT_TYPE_GRE;
     } else {
         return OVS_VPORT_TYPE_UNSPEC;
     }
-- 
1.8.3.1



More information about the dev mailing list