From patchwork Mon Jun 25 18:28:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eldad Zack X-Patchwork-Id: 167215 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 2B872B6FA9 for ; Tue, 26 Jun 2012 04:29:15 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756084Ab2FYS3M (ORCPT ); Mon, 25 Jun 2012 14:29:12 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:46036 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755880Ab2FYS3K (ORCPT ); Mon, 25 Jun 2012 14:29:10 -0400 Received: by yenl2 with SMTP id l2so3092256yen.19 for ; Mon, 25 Jun 2012 11:29:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=SY1bIN/QxmqyVkFyU/E4g3QiXA2aZ9HF5JhmQwj+qqQ=; b=ES1zZO29VpHnzvJerIMuVYURz2/0AeI5auC6gusc6DXCt/X/DMofONJ2fH0DrgaFFi QmygkTZ0OUijrCNDCQp6Q28A1UeT6Ie/0CFm2MaUFi3u4gs341yMeeThxH9UaSxJNpLq SH+n7u/9RmyxnMWAJUT0sJtgXWJ7Wx6jp9ypxR/gBdDaSy95Hz4w1259W5uBiBuimrk4 hKcufISY4E1H1YZyonKEJidbPiv5FtZYnCHdl9UmJeO+uAd+0I9oM+MxP4xFPRIBpFf5 /150Em9oEpmnIIGF5U+GjST1NulKjHzgwNkT5oltQFuaRZ7QyFM+M35xB54Ctrn9bt+k CL2g== Received: by 10.236.79.6 with SMTP id h6mr14582116yhe.71.1340648949952; Mon, 25 Jun 2012 11:29:09 -0700 (PDT) Received: from localhost ([2001:470:8876:65c9:906d:b9bd:c3bf:daf8]) by mx.google.com with ESMTPS id k67sm15634552yhj.18.2012.06.25.11.29.08 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jun 2012 11:29:09 -0700 (PDT) From: Eldad Zack To: netdev@vger.kernel.org Cc: Eldad Zack Subject: [PATCH 8/8] 8021q/vlan: process NETDEV_GOING_DOWN Date: Mon, 25 Jun 2012 20:28:20 +0200 Message-Id: <1340648900-6547-9-git-send-email-eldad@fogrefinery.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1340648900-6547-1-git-send-email-eldad@fogrefinery.com> References: <1340648900-6547-1-git-send-email-eldad@fogrefinery.com> X-Gm-Message-State: ALoCoQnuLcxQRJeggLPSlBqHwr9XvXZ6FnmPvj2dmpQf4lXCpcZHW16Up7zE+4+tIJ8yIn+jv4u7 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the current flow, when you take down a physical device that has VLANs configured on it, the NETDEV_GOING_DOWN notification will be sent too late, i.e., no data can be sent to the wire anymore. static int __dev_close_many(struct list_head *head) { ... list_for_each_entry(dev, head, unreg_list) { call_netdevice_notifiers(NETDEV_GOING_DOWN, dev); ... } ... list_for_each_entry(dev, head, unreg_list) { if (ops->ndo_stop) ops->ndo_stop(dev); } ... } static int dev_close_many(struct list_head *head) { ... __dev_close_many(head); list_for_each_entry(dev, head, unreg_list) { rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING); call_netdevice_notifiers(NETDEV_DOWN, dev); } } In a setup like this: eth0 with VLANs 2, 3 the flow would be: eth0 - NETDEV_GOING_DOWN ndo_stop is called on the device eth0.2 - NETDEV_GOING_DOWN eth0.2 - NETDEV_DOWN eth0.3 - NETDEV_GOING_DOWN eth0.3 - NETDEV_DOWN eth0 - NETDEV_DOWN If instead NETDEV_GOING_DOWN is processed, the flow would be: eth0.2 - NETDEV_GOING_DOWN eth0.2 - NETDEV_DOWN eth0.3 - NETDEV_GOING_DOWN eth0.3 - NETDEV_DOWN eth0 - NETDEV_GOING_DOWN eth0 - NETDEV_DOWN ndo_stop is called on the device Signed-off-by: Eldad Zack --- net/8021q/vlan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 6089f0c..fd87ecc 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -402,6 +402,12 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, break; + case NETDEV_GOING_DOWN: /* NETDEV_DOWN */ + /* If the parent device is going down it will call ndo_stop after + * it sends out NETDEV_GOING_DOWN but before sending out NETDEV_DOWN, + * The effect of which is, that no data can be sent anymore + * by the time the VLAN device sends out its NETDEV_GOING_DOWN. + */ case NETDEV_DOWN: /* Put all VLANs for this dev in the down state too. */ for (i = 0; i < VLAN_N_VID; i++) {