From patchwork Sat Jul 13 17:18:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 258836 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 865C72C0159 for ; Sun, 14 Jul 2013 03:18:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758129Ab3GMRSX (ORCPT ); Sat, 13 Jul 2013 13:18:23 -0400 Received: from mail-pb0-f49.google.com ([209.85.160.49]:33362 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758021Ab3GMRSW (ORCPT ); Sat, 13 Jul 2013 13:18:22 -0400 Received: by mail-pb0-f49.google.com with SMTP id jt11so10008428pbb.22 for ; Sat, 13 Jul 2013 10:18:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=Tb3UoChfJFk+/Z8qf1pAMS8Qfc/FhwNcLs+5fa0Tfmo=; b=laiCcs8dqtITEeqSXQUXjMJzEbNE+BN+FZT09a/c6FDJCy88NFLUdI8NvaFSjMRRrO 3pP2UOuw7g/tHn4yDbKkcrg7Uxt3A092Rr0haZS5fOE4gCLDoYa+zcOc7KF/4p8PLy3l ENrEgrz9KpW02uw6WVT6dxALhSr+A5R2Z/thWQ7AjXfHRw4qLQrYmZkuFyJnrfLHpCiy GSjz2FB8xAwm44SS4FYE9ahqtbAB3DWtThWv56Fav9fdAXqeHuip3h2Z9ef2e5AEWtEK Rptez2+Q9wbNSOKGYgCJmOy5sqx+AXPsg1IoaCLSpr3UCbMSv71x4WIC/UYKRpcqkb3Z WaKg== X-Received: by 10.66.185.14 with SMTP id ey14mr49178312pac.23.1373735902111; Sat, 13 Jul 2013 10:18:22 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-71-109.bvtn.or.frontiernet.net. [50.53.71.109]) by mx.google.com with ESMTPSA id kq2sm54688295pab.19.2013.07.13.10.18.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 13 Jul 2013 10:18:21 -0700 (PDT) Date: Sat, 13 Jul 2013 10:18:18 -0700 From: Stephen Hemminger To: Pravin Shelar Cc: netdev@vger.kernel.org Subject: [PATCH net] vxlan: add necessary locking on device removal Message-ID: <20130713101818.0d4fa8e0@nehalam.linuxnetplumber.net> In-Reply-To: References: <1373493884-7915-1-git-send-email-pshelar@nicira.com> <20130710155840.73e8da09@nehalam.linuxnetplumber.net> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Gm-Message-State: ALoCoQm7hX5KwQpgK+QjVs7G/PKslAyEFC2OSzaZEE1UtPsUs4rEaakgK74sIAEL3CCvqAVoAZuR Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The socket management is now done in workqueue (outside of RTNL) and protected by vn->sock_lock. There were two possible bugs, first the vxlan device was removed from the VNI hash table per socket without holding lock. And there was a race when device is created and the workqueue could run after deletion. Signed-off-by: Stephen Hemminger --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/net/vxlan.c 2013-07-08 16:31:50.080744429 -0700 +++ b/drivers/net/vxlan.c 2013-07-10 20:15:47.337653899 -0700 @@ -1767,9 +1767,15 @@ static int vxlan_newlink(struct net *net static void vxlan_dellink(struct net_device *dev, struct list_head *head) { + struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); struct vxlan_dev *vxlan = netdev_priv(dev); + flush_workqueue(vxlan_wq); + + spin_lock(&vn->sock_lock); hlist_del_rcu(&vxlan->hlist); + spin_unlock(&vn->sock_lock); + list_del(&vxlan->next); unregister_netdevice_queue(dev, head); }