Deployment and upgrade failure is quite often caused by that openvswitch.ko was built upon kernel x.y.z-release-A while it is loaded into a running kernel of x.y.z-release-B. This patch proposes to enforce the matching of the two kernel release numbers at the moment of deployment and upgrading.
Signed-off-by: Yifeng Sun <[email protected]> --- datapath/datapath.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/datapath/datapath.c b/datapath/datapath.c index 178081993b42..0e3a1db63847 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -51,6 +51,8 @@ #include <net/genetlink.h> #include <net/net_namespace.h> #include <net/netns/generic.h> +#include <generated/utsrelease.h> +#include <linux/utsname.h> #include "datapath.h" #include "conntrack.h" @@ -61,6 +63,8 @@ #include "vport-internal_dev.h" #include "vport-netdev.h" +static const char *build_kernel_release = UTS_RELEASE; + unsigned int ovs_net_id __read_mostly; static struct genl_family dp_packet_genl_family; @@ -2406,6 +2410,15 @@ static int __init dp_init(void) BUILD_BUG_ON(sizeof(struct ovs_skb_cb) > FIELD_SIZEOF(struct sk_buff, cb)); + if (strcmp(build_kernel_release, utsname()->release)) { + pr_err("Failed to load Open vSwitch kernel module: " + "the modules' built-on kernel release (%s) " + "doesn't match the running kernel's release (%s)\n", + build_kernel_release, utsname()->release); + err = -EINVAL; + goto error; + } + pr_info("Open vSwitch switching datapath %s\n", VERSION); err = action_fifos_init(); -- 2.7.4 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
