From patchwork Fri Sep 14 20:20:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 970093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iX3ZwK/T"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Bn310FLpz9s3l for ; Sat, 15 Sep 2018 06:21:00 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E961DE68; Fri, 14 Sep 2018 20:20:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AA69EE66 for ; Fri, 14 Sep 2018 20:20:56 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 314ED7E2 for ; Fri, 14 Sep 2018 20:20:56 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id f1-v6so4683371plt.4 for ; Fri, 14 Sep 2018 13:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=o8iwOwHMW/+N7UmjQQfcF+QLRi7FLOuWrQRyq72j4Js=; b=iX3ZwK/TGe69iN1n6HrtczgcT5H/Sl67Mv6OhWGjxpTCR9PQALdy/HlDD1Ppr4HhBI aTEJTYtFy3JomeDZAylAZiyUofGIjKPBW9t1ffn5wndlvsyEpEQ9SrYbUiea1N8JfMEA g0C1yKJ0aQNyZl3CX/GYMAXXInhQ0m6XCuAxIA5ocmrMuugk4yUegfZBGXk6pbVMTNg3 5FwA8yVFaCK4OpCbcllg+IUH1UzmcqPwxBtkIgaT811DbR8Xu5CKzbAq8WSLgYXZa6hN a7XQiZnxS4TLE9W1Tw629QiG6Dytd5hiIzrCj/x6t74vbJu1XPxkH2WwEkPGwzAb3E+t habQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=o8iwOwHMW/+N7UmjQQfcF+QLRi7FLOuWrQRyq72j4Js=; b=sgOunxg/CUVoS/e0qDmt31zliMW/9Xh85xzPk2qe7JZDLm9SN6AlOZHpvy5cBPhpFP eNa5ZE8MXeAWtqf4/s/mdfhR8S0y4FhV4DTVnBESUSboLNhUxMUHjR6p0rTSpF8Mjd3L QotPh6uzjlb+yhSx1BJOxsyyQ1W9Lg7NaLD0r9pGM/6PlV5n2EF49V2QOJZ5E+kyExqv U+hYMPLmXY6qxJn83PCK42lpJelyfcjwWsXnzAGX/MS8OPeBUSgLECZMwdHITH3na8+d eBY0gwZOBV5WvQFAFXdg+0vebFxM6K9rnzm+hXllwWZ/lR2ZIR3iO7gE2DwlFSoSIvRZ Hyjw== X-Gm-Message-State: APzg51DPAeHhkjn0kHp3C0Eu+toQfpNzxRqul49yhjs7kTjBa2cJhWBH nSozilyKWm4EqS+zIKTo+rcXX5+B X-Google-Smtp-Source: ANB0VdaZBVUmD5HSLvSKg5DteV8VvjmlVkKvn9BxTac4O6NT7VpGWnGuCZLOjjX4hn9Zt1dmrz7Sfg== X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr13793843pld.312.1536956455478; Fri, 14 Sep 2018 13:20:55 -0700 (PDT) Received: from kern417.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id m27-v6sm11085942pff.152.2018.09.14.13.20.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Sep 2018 13:20:54 -0700 (PDT) From: Yifeng Sun To: dev@openvswitch.org Date: Fri, 14 Sep 2018 13:20:49 -0700 Message-Id: <1536956449-3001-1-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v3] gre: Rename fallback devices to avoid udev's interference X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org On certain kernel versions, when openvswitch kernel module creates a gre0 interface, the kernel’s gre module will jump out and compete to control the gre0 interface. This will cause the failure of openvswitch kernel module loading. This fix renames fallback devices by adding a prefix "ovs-". Signed-off-by: Yifeng Sun VMware Issue: #2162866 --- Please backport this patch to upstream OVS down to 2.9, thanks. v1->v2: Added sanity check for device names, thanks Justin. v2->v3: Fix an indent error. datapath/linux/compat/ip6_gre.c | 9 +++++++-- datapath/linux/compat/ip6_tunnel.c | 10 +++++++--- datapath/linux/compat/ip_gre.c | 2 +- datapath/linux/compat/ip_tunnel.c | 5 +++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/datapath/linux/compat/ip6_gre.c b/datapath/linux/compat/ip6_gre.c index 00dbefc9b099..cbd002ed23f6 100644 --- a/datapath/linux/compat/ip6_gre.c +++ b/datapath/linux/compat/ip6_gre.c @@ -377,7 +377,7 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net, if (parms->name[0]) strlcpy(name, parms->name, IFNAMSIZ); else - strcpy(name, "ip6gre%d"); + strlcpy(name, "ovs-ip6gre%d", IFNAMSIZ); dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, ip6gre_tunnel_setup); @@ -1710,9 +1710,14 @@ static void ip6gre_destroy_tunnels(struct net *net, struct list_head *head) static int __net_init ip6gre_init_net(struct net *net) { struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); + const char *dev_name = "ovs-ip6gre0"; int err; - ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0", + if (strlen(dev_name) > IFNAMSIZ) + return -E2BIG; + + ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), + dev_name, NET_NAME_UNKNOWN, ip6gre_tunnel_setup); if (!ign->fb_tunnel_dev) { diff --git a/datapath/linux/compat/ip6_tunnel.c b/datapath/linux/compat/ip6_tunnel.c index 56fd8b4dd342..a7a1a586c920 100644 --- a/datapath/linux/compat/ip6_tunnel.c +++ b/datapath/linux/compat/ip6_tunnel.c @@ -355,7 +355,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p) if (p->name[0]) strlcpy(name, p->name, IFNAMSIZ); else - sprintf(name, "ip6tnl%%d"); + strlcpy(name, "ovs-ip6tnl%%d", IFNAMSIZ); dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, ip6_tnl_dev_setup); @@ -1410,7 +1410,7 @@ ip6_tnl_parm_to_user(struct ip6_tnl_parm *u, const struct __ip6_tnl_parm *p) * %SIOCCHGTUNNEL: change tunnel parameters to those given * %SIOCDELTUNNEL: delete tunnel * - * The fallback device "ip6tnl0", created during module + * The fallback device "ovs-ip6tnl0", created during module * initialization, can be used for creating other tunnel devices. * * Return: @@ -2087,13 +2087,17 @@ static int __net_init ip6_tnl_init_net(struct net *net) { struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); struct ip6_tnl *t = NULL; + const char *dev_name = "ovs-ip6tnl0"; int err; + if (strlen(dev_name) > IFNAMSIZ) + return -E2BIG; + ip6n->tnls[0] = ip6n->tnls_wc; ip6n->tnls[1] = ip6n->tnls_r_l; err = -ENOMEM; - ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6tnl0", + ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), dev_name, NET_NAME_UNKNOWN, ip6_tnl_dev_setup); if (!ip6n->fb_tnl_dev) diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c index 05132ba9494a..b7322c58e420 100644 --- a/datapath/linux/compat/ip_gre.c +++ b/datapath/linux/compat/ip_gre.c @@ -1463,7 +1463,7 @@ static struct pernet_operations erspan_net_ops = { static int __net_init ipgre_tap_init_net(struct net *net) { - return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "gretap0"); + return ip_tunnel_init_net(net, gre_tap_net_id, &ipgre_tap_ops, "ovs-gretap0"); } static void __net_exit ipgre_tap_exit_net(struct net *net) diff --git a/datapath/linux/compat/ip_tunnel.c b/datapath/linux/compat/ip_tunnel.c index d16e60fbfef0..0da8a06ecd26 100644 --- a/datapath/linux/compat/ip_tunnel.c +++ b/datapath/linux/compat/ip_tunnel.c @@ -130,11 +130,12 @@ static struct net_device *__ip_tunnel_create(struct net *net, if (parms->name[0]) strlcpy(name, parms->name, IFNAMSIZ); else { - if (strlen(ops->kind) > (IFNAMSIZ - 3)) { + if (strlen(ops->kind) > (IFNAMSIZ - 7)) { err = -E2BIG; goto failed; } - strlcpy(name, ops->kind, IFNAMSIZ); + strlcpy(name, "ovs-", IFNAMSIZ); + strlcat(name, ops->kind, IFNAMSIZ); strncat(name, "%d", 2); }