[ovs-dev] [PATCH 3/3] datapath: Do not fail to load on gre protocol conflict

Greg Rose gvrose8192 at gmail.com
Mon Jun 4 20:14:38 UTC 2018


The ERSPAN feature depends on the gre kernel module so on systems where
the ERSPAN feature isn't supported the openvswitch kernel module would
attempt to grab the ipv4 GRE protocol entry point and would fail to load
if it could not.

This patch modifies openvswitch to not fail to load when the gre kernel
module is loaded and instead it will print a warning message to the
kernel system log indicating that the ERSPAN feature may not be
available.

We need this patch because users are experiencing failures due to the
conflicts and high priority bugs are resulting.

Signed-off-by: Greg Rose <gvrose8192 at gmail.com>
---
 datapath/linux/compat/gre.c |  2 +-
 datapath/vport.c            | 27 ++++++++++++++++++---------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/datapath/linux/compat/gre.c b/datapath/linux/compat/gre.c
index 7f2b545..2b14c5a 100644
--- a/datapath/linux/compat/gre.c
+++ b/datapath/linux/compat/gre.c
@@ -127,7 +127,7 @@ int rpl_gre_init(void)
 
 	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
 		pr_err("can't add protocol\n");
-		return -EAGAIN;
+		return -EEXIST;
 	}
 	return 0;
 }
diff --git a/datapath/vport.c b/datapath/vport.c
index 73dd778..56096ef 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -42,6 +42,7 @@
 #include "vport-internal_dev.h"
 
 static LIST_HEAD(vport_ops_list);
+static bool compat_gre_loaded = false;
 
 /* Protected by RCU read lock for reading, ovs_mutex for writing. */
 static struct hlist_head *dev_table;
@@ -64,9 +65,17 @@ int ovs_vport_init(void)
 	err = lisp_init_module();
 	if (err)
 		goto err_lisp;
-	err = ipgre_init();
-	if (err)
-		goto err_ipgre;
+	err = gre_init();
+	if (err && err != -EEXIST)
+		goto err_gre;
+	else if (err == -EEXIST)
+		pr_warn("Cannot take GRE protocol entry - The ERSPAN feature may not be supported\n");
+	else {
+		err = ipgre_init();
+		if (err && err != -EEXIST) 
+			goto err_ipgre;
+		compat_gre_loaded = true;
+	}
 	err = ip6gre_init();
 	if (err)
 		goto err_ip6gre;
@@ -82,12 +91,8 @@ int ovs_vport_init(void)
 	err = ovs_stt_init_module();
 	if (err)
 		goto err_stt;
-	err = gre_init();
-	if (err)
-		goto err_gre;
 
 	return 0;
-err_gre:
 	ovs_stt_cleanup_module();
 err_stt:
 	vxlan_cleanup_module();
@@ -100,6 +105,8 @@ err_ip6_tunnel:
 err_ip6gre:
 	ipgre_fini();
 err_ipgre:
+	gre_exit();
+err_gre:
 	lisp_cleanup_module();
 err_lisp:
 	kfree(dev_table);
@@ -113,13 +120,15 @@ err_lisp:
  */
 void ovs_vport_exit(void)
 {
-	gre_exit();
+	if (compat_gre_loaded) {
+		gre_exit();
+		ipgre_fini();
+	}
 	ovs_stt_cleanup_module();
 	vxlan_cleanup_module();
 	geneve_cleanup_module();
 	ip6_tunnel_cleanup();
 	ip6gre_fini();
-	ipgre_fini();
 	lisp_cleanup_module();
 	kfree(dev_table);
 }
-- 
1.8.3.1



More information about the dev mailing list