From patchwork Fri Jan 17 03:47:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 311926 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 7B1822C0091 for ; Fri, 17 Jan 2014 14:47:50 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbaAQDrq (ORCPT ); Thu, 16 Jan 2014 22:47:46 -0500 Received: from mail-la0-f50.google.com ([209.85.215.50]:38595 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbaAQDrp (ORCPT ); Thu, 16 Jan 2014 22:47:45 -0500 Received: by mail-la0-f50.google.com with SMTP id ec20so3258037lab.9 for ; Thu, 16 Jan 2014 19:47:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=qEbV4RgxD6ByA4+UZCJwoFboacAaX6ESpiZ5JdQertw=; b=chUyniaOrpxF7i34JtX5RxRjwZoCKdO1mcEcQ1GvgoDNgyjCgV6YubYxFipziPJ0do 619ByJDF+117sBSs6HjqoLAF6XpkmMRlzU2xiwuI5Sg8loMGANRS1/g01UevA6LXFwCf +DgwbqXngcV/flC3JxABDDtbBDF2sHVs6N6Ews7qEQ3H4K+d47en6/m566+zsjqYuW9i V4QB8KeV/Oe1LHGhKUxFW9mhJfRXnBVXJJbBLOZi6qvNasiwxGHTnHoyd08ute7OBWEh Txbt/899jNN7rzUZe1p8NTLK/nE635gCrIwnYPtUGJbTcTRjF9SuHGKcXYTnMPCMUkcl 2rdg== X-Gm-Message-State: ALoCoQnuPyAwnpLIMKWvosKvsWX3AGuCpiEIU1lAj+2e16ktE//ofXB3ExlHHUharKCX8eaIM2mP MIME-Version: 1.0 X-Received: by 10.152.19.170 with SMTP id g10mr7109859lae.9.1389930463768; Thu, 16 Jan 2014 19:47:43 -0800 (PST) Received: by 10.114.192.2 with HTTP; Thu, 16 Jan 2014 19:47:43 -0800 (PST) In-Reply-To: <20140116180318.00004f53@unknown> References: <20140116171428.00004da1@unknown> <20140116180318.00004f53@unknown> Date: Thu, 16 Jan 2014 19:47:43 -0800 Message-ID: Subject: Re: PANIC in vxlan From: Cong Wang To: Jesse Brandeburg Cc: netdev , Daniel Borkmann Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Jan 16, 2014 at 6:03 PM, Jesse Brandeburg wrote: > > It appears that the bug is in acaf4e70997f (net: vxlan: when lower dev > unregisters remove vxlan dev as well). > > reverting that patch avoids the panic. I wasn't able to see > immediately what was wrong in the patch. It seems vxlan pernet ops is run after loopback register. Please try the attached (totally untested) patch? diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index a2dee80..2812559 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2655,36 +2655,30 @@ static struct rtnl_link_ops vxlan_link_ops __read_mostly = { .fill_info = vxlan_fill_info, }; -static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn, - struct net_device *dev) -{ - struct vxlan_dev *vxlan, *next; - LIST_HEAD(list_kill); - - list_for_each_entry_safe(vxlan, next, &vn->vxlan_list, next) { - struct vxlan_rdst *dst = &vxlan->default_dst; - - /* In case we created vxlan device with carrier - * and we loose the carrier due to module unload - * we also need to remove vxlan device. In other - * cases, it's not necessary and remote_ifindex - * is 0 here, so no matches. - */ - if (dst->remote_ifindex == dev->ifindex) - vxlan_dellink(vxlan->dev, &list_kill); - } - - unregister_netdevice_many(&list_kill); -} - static int vxlan_lowerdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { - struct net_device *dev = netdev_notifier_info_to_dev(ptr); - struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); + if (event == NETDEV_UNREGISTER) { + struct net_device *dev = netdev_notifier_info_to_dev(ptr); + struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); + struct vxlan_dev *vxlan, *next; + LIST_HEAD(list_kill); + + list_for_each_entry_safe(vxlan, next, &vn->vxlan_list, next) { + struct vxlan_rdst *dst = &vxlan->default_dst; + + /* In case we created vxlan device with carrier + * and we loose the carrier due to module unload + * we also need to remove vxlan device. In other + * cases, it's not necessary and remote_ifindex + * is 0 here, so no matches. + */ + if (dst->remote_ifindex == dev->ifindex) + vxlan_dellink(vxlan->dev, &list_kill); + } - if (event == NETDEV_UNREGISTER) - vxlan_handle_lowerdev_unregister(vn, dev); + unregister_netdevice_many(&list_kill); + } return NOTIFY_DONE; }