From patchwork Thu Nov 2 19:01:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 833501 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bNlYgblf"; 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 3ySZGJ1RKYz9sNc for ; Fri, 3 Nov 2017 06:02:31 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 69B28D10; Thu, 2 Nov 2017 19:02:28 +0000 (UTC) X-Original-To: ovs-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 A4C78CCE for ; Thu, 2 Nov 2017 19:02:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3E5B879 for ; Thu, 2 Nov 2017 19:02:27 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id s75so428383pgs.0 for ; Thu, 02 Nov 2017 12:02:27 -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; bh=4uNlb5ILLKviCVQcRD+289ba4Mk9L11ylhM6Vmkp8jg=; b=bNlYgblf7fdZq4LcS3lqHFelhhQknwmlBBaqCmWH812YyVMucF9QdzABWTOvIvYUbF 70pVi9DfVy25yaR88V7sMH9aHbt2+iaT4x8j9rHUeUZ9xX3iLampZN1evdmlycHUtLS3 dRHqONH6peuKdfEOUzzkh5348oJ+DO20WZlpOZsrIs6mZTUNW1fsGpoZ3D1/1bBSKzj0 f1Sn3nGJlKqM2Gz5DVu7XDkpTddjOGj8D1Mpr97TmSmxyfjJ8AmlidblMin7rYiz0poI /mWxHbmn3GOiMR7Q8Ir46EtYolrWjm2ZvLYfgODq5O/8d7cyxu8OkLVPo8+Bd0e84zR2 gK4Q== 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; bh=4uNlb5ILLKviCVQcRD+289ba4Mk9L11ylhM6Vmkp8jg=; b=G1oXZ20W68ix1f2ZoQsOOyVeR9QU/CCCTB4ysYhjXlFxw8m/I2AtazcJansukfTtB3 2vbU1Msfq635/VtELGj6NZTUe9Zq2tZaVhSW4jtqGIiGtOeICRgcTJwUj9287cZUnGDA 2dIWLeCYUhBwLKN9PJSqMOBzVpL2fhA2zJAvkmSJV6DkTJ/WFfeD7uf5YUvHdoUz/4v2 +4Oy8KE99IP8rG20giIQZ0bTBpOdquAGKxZ948eEtrJVZDmhZy+Cj017NmZEUjSy1Qxk xmg1mLDgdzZnspky2zhzjeTUzkeK8WhCtCHZe/1UiPhUzzjVCh4tFFNux2br8sTQ0Lqb R7eA== X-Gm-Message-State: AMCzsaX6N64AKv3Kk4NrYR3fTvlc3FueWli+3S+3eYn5GG0i5rAVSyHm XE2AJhOgrWPRCH6FLFRsvWMaBejG X-Google-Smtp-Source: ABhQp+Q3xz/92QtWfT+HsB3KU1YS0yWI3udQhj/4FEENiDmwkmIf+W1uVJCuy/wqVDGDKgbZr0KbtQ== X-Received: by 10.159.252.194 with SMTP id o2mr2253170pls.38.1509649346472; Thu, 02 Nov 2017 12:02:26 -0700 (PDT) Received: from sc9-mailhost2.vmware.com ([24.5.191.4]) by smtp.gmail.com with ESMTPSA id o9sm7143745pfk.162.2017.11.02.12.02.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Nov 2017 12:02:25 -0700 (PDT) From: William Tu To: ovs-dev@openvswitch.org Date: Thu, 2 Nov 2017 12:01:17 -0700 Message-Id: <1509649277-49291-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Eric Garver , Gurucharan Shetty Subject: [ovs-dev] [PATCHv3] dpif-netlink-rtnl: Fix ovs_geneve probing after restart. 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When using the out-of-tree (openvswitch compat) geneve module, the first time oot tunnel probing returns true (correct). Without unloading the geneve module, if the userspace ovs-vswitchd restarts, because the 'geneve_sys_6081' still exists, the probing incorrectly returns false and loads the in-tree (upstream kernel) geneve module. The patch fixes it by querying the geneve device's kind when exists. The out-of-tree modules uses kind string as 'ovs_geneve', while the in-tree module uses 'geneve'. To reproduce the issue, start the ovs > /etc/init.d/openvswitch-switch start > creat a bridge and attach a geneve port using out-of-tree geneve > /etc/init.d/openvswitch-switch restart Fixes: 921c370a9df5 ("dpif-netlink: Probe for out-of-tree tunnels, decides used interface") Signed-off-by: William Tu Cc: Eric Garver Cc: Gurucharan Shetty Acked-by: Eric Garver --- v2->v3: Add return code checking for netlink parsing Fix memory leak v1->v2: Add detection of existing module, instead of unconditionally remote it and create. --- lib/dpif-netlink-rtnl.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c index 0c32e7d8ccb4..fe9c8ed7104f 100644 --- a/lib/dpif-netlink-rtnl.c +++ b/lib/dpif-netlink-rtnl.c @@ -440,6 +440,7 @@ dpif_netlink_rtnl_probe_oot_tunnels(void) error = netdev_open("ovs-system-probe", "geneve", &netdev); if (!error) { + struct ofpbuf *reply; const struct netdev_tunnel_config *tnl_cfg; tnl_cfg = netdev_get_tunnel_config(netdev); @@ -448,6 +449,44 @@ dpif_netlink_rtnl_probe_oot_tunnels(void) } name = netdev_vport_get_dpif_port(netdev, namebuf, sizeof namebuf); + + /* The geneve module exists when ovs-vswitchd crashes + * and restarts, handle the case here. + */ + error = dpif_netlink_rtnl_getlink(name, &reply); + if (!error) { + + struct nlattr *linkinfo[ARRAY_SIZE(linkinfo_policy)]; + struct nlattr *rtlink[ARRAY_SIZE(rtlink_policy)]; + const char *kind; + + if (!nl_policy_parse(reply, + NLMSG_HDRLEN + sizeof(struct ifinfomsg), + rtlink_policy, rtlink, + ARRAY_SIZE(rtlink_policy)) + || !nl_parse_nested(rtlink[IFLA_LINKINFO], linkinfo_policy, + linkinfo, ARRAY_SIZE(linkinfo_policy))) { + VLOG_ABORT("Error fetching Geneve tunnel device %s " + "linkinfo", name); + } + + kind = nl_attr_get_string(linkinfo[IFLA_INFO_KIND]); + + if (!strcmp(kind, "ovs_geneve")) { + out_of_tree = true; + } else if (!strcmp(kind, "geneve")) { + out_of_tree = false; + } else { + VLOG_ABORT("Geneve tunnel device %s with kind %s" + " not supported", name, kind); + } + + ofpbuf_delete(reply); + netdev_close(netdev); + + return out_of_tree; + } + error = dpif_netlink_rtnl_create(tnl_cfg, name, OVS_VPORT_TYPE_GENEVE, "ovs_geneve", (NLM_F_REQUEST | NLM_F_ACK