From patchwork Tue Nov 15 08:36:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Weiping Pan X-Patchwork-Id: 125706 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 CBBB3B6F65 for ; Tue, 15 Nov 2011 19:36:23 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654Ab1KOIgE (ORCPT ); Tue, 15 Nov 2011 03:36:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753484Ab1KOIgB (ORCPT ); Tue, 15 Nov 2011 03:36:01 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAF8Zxq3002566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Nov 2011 03:35:59 -0500 Received: from localhost.localdomain.com (wlan-5-115.nay.redhat.com [10.66.12.115] (may be forged)) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pAF8ZtMc030928; Tue, 15 Nov 2011 03:35:55 -0500 From: Weiping Pan Cc: Weiping Pan , Patrick McHardy (maintainer:VLAN (802.1Q)), "David S. Miller" (maintainer:NETWORKING [GENERAL]), netdev@vger.kernel.org (open list:VLAN (802.1Q)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] vlan:return error when real dev is enslaved Date: Tue, 15 Nov 2011 16:36:52 +0800 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 To: unlisted-recipients:; (no To-header on input) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Qinhuibin reported a kernel panic when he do some operation about vlan. https://lkml.org/lkml/2011/11/6/218 The operation is as below: ifconfig eth2 up modprobe bonding modprobe 8021q ifconfig bond0 up ifenslave bond0 eth2 vconfig add eth2 3300 vconfig add bond0 33 vconfig rem eth2.3300 the panic stack is as below: [] panic_event+0x49/0x70 [ipmi_msghandler] [] notifier_call_chain+0x37/0x70 [] panic+0xa2/0x195 [] oops_end+0xd8/0x140 [] no_context+0xf7/0x280 [] __bad_area_nosemaphore+0x175/0x250 [] page_fault+0x28/0x30 [] igb_vlan_rx_kill_vid+0x4d/0x100 [igb] [] bond_vlan_rx_kill_vid+0x9f/0x290 [bonding] [] unregister_vlan_dev+0x136/0x180 [8021q] [] vlan_ioctl_handler+0x170/0x3f0 [8021q] [] sock_ioctl+0x21f/0x280 [] vfs_ioctl+0x2f/0xb0 [] do_vfs_ioctl+0x3cb/0x5a0 [] sys_ioctl+0xa1/0xb0 [] system_call_fastpath+0x16/0x1b [<00007f108a2b8bd7>] 0x7f108a2b8bd7 And the nic is as below: [root@localhost ~]# ethtool -i eth2 driver: igb version: 3.0.6-k2 firmware-version: 1.2-1 bus-info: 0000:04:00.0 kernel version: 2.6.32.12-0.7 also happen in 2.6.32-131 For kernel 2.6.32, the reason of this bug is that when we do "vconfig add bond0 33", adapter->vlgrp is overwritten in igb_vlan_rx_register. So when we do "vconfig rem eth2.3300", it can't find the correct vlgrp. And this bug is avoided by vlan cleanup patchset from Jiri Pirko , especially commit b2cb09b1a772(igb: do vlan cleanup). But it is not a correct operation to creat a vlan interface on eth2 when it have been enslaved by bond0, so this patch is to return error when the real dev is already enslaved. Signed-off-by: Weiping Pan --- net/8021q/vlan.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 5471628..8ba9226 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -148,6 +148,11 @@ int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id) const char *name = real_dev->name; const struct net_device_ops *ops = real_dev->netdev_ops; + if (real_dev->flags & IFF_SLAVE) { + pr_info("Error, %s was already enslaved\n", name); + return -EOPNOTSUPP; + } + if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { pr_info("VLANs not supported on %s\n", name); return -EOPNOTSUPP;