From patchwork Wed Oct 19 18:27:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pravin Shelar X-Patchwork-Id: 684300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3szgQs1JF7z9ryZ for ; Thu, 20 Oct 2016 05:27:31 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id B9CF910310; Wed, 19 Oct 2016 11:27:28 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 016AF101D0 for ; Wed, 19 Oct 2016 11:27:28 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 73AD11628E6 for ; Wed, 19 Oct 2016 12:27:27 -0600 (MDT) X-ASG-Debug-ID: 1476901646-0b32376915974a0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar6.cudamail.com with ESMTP id 0N2xLMFCVhLCq4Q1 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 19 Oct 2016 12:27:26 -0600 (MDT) X-Barracuda-Envelope-From: pshelar@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO relay3-d.mail.gandi.net) (217.70.183.195) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 19 Oct 2016 18:27:26 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at ovn.org designates 217.70.183.195 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.195 X-Barracuda-RBL-IP: 217.70.183.195 Received: from mfilter44-d.gandi.net (mfilter44-d.gandi.net [217.70.178.175]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id C2A21A80E5; Wed, 19 Oct 2016 20:27:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter44-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter44-d.gandi.net (mfilter44-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 9W7Ir6JSA6OD; Wed, 19 Oct 2016 20:27:22 +0200 (CEST) X-Originating-IP: 208.91.2.4 Received: from localhost.localdomain.localdomain (unknown [208.91.2.4]) (Authenticated sender: pshelar@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 771B2A80C1; Wed, 19 Oct 2016 20:27:21 +0200 (CEST) X-CudaMail-Envelope-Sender: pshelar@ovn.org From: Pravin B Shelar To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1018039252 X-CudaMail-DTE: 101916 X-CudaMail-Originating-IP: 217.70.183.195 Date: Wed, 19 Oct 2016 11:27:16 -0700 X-ASG-Orig-Subj: [##CM-V3-1018039252##][PATCH] datapath: compat: tunnel: Check if device is UP. Message-Id: <1476901636-3910-1-git-send-email-pshelar@ovn.org> X-Mailer: git-send-email 1.8.3.1 X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1476901646 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH] datapath: compat: tunnel: Check if device is UP. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" On upstream kernel datapath OVS make use of networking devices where networking stack does check if device is UP. following patch adds same check in case of compat tunneling implementation. This check also fixes kernel crash in case vxlan device was brought down by user. CPU: 4 PID: 12988 Comm: handler903 Tainted: RIP: 0010:[] vxlan_xmit_one.constprop.50+0x47/0x1210 [openvswitch] Call Trace: [] rpl_vxlan_xmit+0x55/0x80 [openvswitch] [] ovs_vport_send+0x44/0xb0 [openvswitch] [] do_output+0x65/0x180 [openvswitch] [] do_execute_actions+0x10c/0x860 [openvswitch] [] ovs_execute_actions+0x40/0x130 [openvswitch] [] ovs_packet_cmd_execute+0x2c9/0x2f0 [openvswitch] [] genl_family_rcv_msg+0x1cd/0x400 [] genl_rcv_msg+0x91/0xd0 [] netlink_rcv_skb+0xa9/0xc0 [] genl_rcv+0x28/0x40 [] netlink_unicast+0x16a/0x210 [] netlink_sendmsg+0x317/0x430 [] sock_sendmsg+0xb0/0xf0 [] ___sys_sendmsg+0x3a9/0x3c0 [] __sys_sendmsg+0x51/0x90 [] SyS_sendmsg+0x12/0x20 [] system_call_fastpath+0x16/0x1b Reported-by: Huanglili (lee) Signed-off-by: Pravin B Shelar --- datapath/linux/compat/geneve.c | 6 ++++++ datapath/linux/compat/ip_gre.c | 3 +++ datapath/linux/compat/lisp.c | 5 +++++ datapath/linux/compat/stt.c | 8 +++++++- datapath/linux/compat/vxlan.c | 5 ++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/datapath/linux/compat/geneve.c b/datapath/linux/compat/geneve.c index 0c5b58a..1cd4f75 100644 --- a/datapath/linux/compat/geneve.c +++ b/datapath/linux/compat/geneve.c @@ -1118,6 +1118,12 @@ netdev_tx_t rpl_geneve_xmit(struct sk_buff *skb) struct geneve_dev *geneve = netdev_priv(dev); struct ip_tunnel_info *info = NULL; + if (unlikely(!(dev->flags & IFF_UP))) { + dev->stats.tx_dropped++; + kfree_skb(skb); + return NETDEV_TX_OK; + } + if (geneve->collect_md) info = skb_tunnel_info(skb); diff --git a/datapath/linux/compat/ip_gre.c b/datapath/linux/compat/ip_gre.c index 03c5435..c77b834 100644 --- a/datapath/linux/compat/ip_gre.c +++ b/datapath/linux/compat/ip_gre.c @@ -285,6 +285,9 @@ netdev_tx_t rpl_gre_fb_xmit(struct sk_buff *skb) __be16 df, flags; int err; + if (unlikely(!(dev->flags & IFF_UP))) + goto err_free_skb; + tun_info = skb_tunnel_info(skb); if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) || ip_tunnel_info_af(tun_info) != AF_INET)) diff --git a/datapath/linux/compat/lisp.c b/datapath/linux/compat/lisp.c index 3a4bebc..6aadfa7 100644 --- a/datapath/linux/compat/lisp.c +++ b/datapath/linux/compat/lisp.c @@ -325,6 +325,11 @@ netdev_tx_t rpl_lisp_xmit(struct sk_buff *skb) __be16 df; int err; + if (unlikely(!(dev->flags & IFF_UP))) { + dev->stats.tx_dropped++; + goto error; + } + info = skb_tunnel_info(skb); if (unlikely(!info)) { err = -EINVAL; diff --git a/datapath/linux/compat/stt.c b/datapath/linux/compat/stt.c index ca9f039..9e851c5 100644 --- a/datapath/linux/compat/stt.c +++ b/datapath/linux/compat/stt.c @@ -1009,6 +1009,11 @@ netdev_tx_t ovs_stt_xmit(struct sk_buff *skb) __be16 df; int err; + if (unlikely(!(dev->flags & IFF_UP))) { + dev->stats.tx_dropped++; + goto free; + } + tun_info = skb_tunnel_info(skb); if (unlikely(!tun_info)) { err = -EINVAL; @@ -1032,8 +1037,9 @@ netdev_tx_t ovs_stt_xmit(struct sk_buff *skb) df, sport, dport, tun_key->tun_id); return NETDEV_TX_OK; error: - kfree_skb(skb); dev->stats.tx_errors++; +free: + kfree_skb(skb); return NETDEV_TX_OK; } EXPORT_SYMBOL(ovs_stt_xmit); diff --git a/datapath/linux/compat/vxlan.c b/datapath/linux/compat/vxlan.c index 47a5a68..211d0c3 100644 --- a/datapath/linux/compat/vxlan.c +++ b/datapath/linux/compat/vxlan.c @@ -1231,6 +1231,9 @@ netdev_tx_t rpl_vxlan_xmit(struct sk_buff *skb) struct vxlan_dev *vxlan = netdev_priv(dev); const struct ip_tunnel_info *info; + if (unlikely(!(dev->flags & IFF_UP))) + goto drop; + info = skb_tunnel_info(skb); skb_reset_mac_header(skb); if (vxlan->flags & VXLAN_F_COLLECT_METADATA) { @@ -1239,7 +1242,7 @@ netdev_tx_t rpl_vxlan_xmit(struct sk_buff *skb) return NETDEV_TX_OK; } } - +drop: dev->stats.tx_dropped++; kfree_skb(skb); return NETDEV_TX_OK;