From patchwork Mon Aug 5 13:28:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 264662 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 9E8882C008F for ; Mon, 5 Aug 2013 23:32:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752693Ab3HENcE (ORCPT ); Mon, 5 Aug 2013 09:32:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25229 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156Ab3HENcD (ORCPT ); Mon, 5 Aug 2013 09:32:03 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r75DVx1c029096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Aug 2013 09:31:59 -0400 Received: from boza.brq.redhat.com (dhcp-1-132.brq.redhat.com [10.34.1.132]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r75DVsoN032377; Mon, 5 Aug 2013 09:31:57 -0400 From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: fubar@us.ibm.com, andy@greyhouse.net, davem@davemloft.net Subject: [PATCH net-next 2/3] bonding: change the bond's vlan syncing functions with the standard ones Date: Mon, 5 Aug 2013 15:28:23 +0200 Message-Id: <1375709304-16778-3-git-send-email-nikolay@redhat.com> In-Reply-To: <1375709304-16778-1-git-send-email-nikolay@redhat.com> References: <1375709304-16778-1-git-send-email-nikolay@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nikolay Aleksandrov Now we have vlan_vids_add/del_by_dev() which serve the same purpose as bond's bond_add/del_vlans_on_slave() with the good side effect of reverting the changes if one of the additions fails. Signed-off-by: Nikolay Aleksandrov Acked-by: Veaceslav Falico --- drivers/net/bonding/bond_main.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 5df8bcd..ed1d261 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -521,33 +521,6 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev, return __bond_vlan_rx_kill_vid(bond_dev, proto, vid); } -static void bond_add_vlans_on_slave(struct bonding *bond, struct net_device *slave_dev) -{ - struct vlan_entry *vlan; - int res; - - list_for_each_entry(vlan, &bond->vlan_list, vlan_list) { - res = vlan_vid_add(slave_dev, htons(ETH_P_8021Q), - vlan->vlan_id); - if (res) - pr_warning("%s: Failed to add vlan id %d to device %s\n", - bond->dev->name, vlan->vlan_id, - slave_dev->name); - } -} - -static void bond_del_vlans_from_slave(struct bonding *bond, - struct net_device *slave_dev) -{ - struct vlan_entry *vlan; - - list_for_each_entry(vlan, &bond->vlan_list, vlan_list) { - if (!vlan->vlan_id) - continue; - vlan_vid_del(slave_dev, htons(ETH_P_8021Q), vlan->vlan_id); - } -} - /*------------------------------- Link status -------------------------------*/ /* @@ -1656,7 +1629,9 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) dev_mc_add(slave_dev, lacpdu_multicast); } - bond_add_vlans_on_slave(bond, slave_dev); + if (vlan_vids_add_by_dev(slave_dev, bond_dev)) + pr_warn("%s: couldn't add bond vlan ids to %s", + bond_dev->name, slave_dev->name); write_lock_bh(&bond->lock); @@ -1832,7 +1807,7 @@ err_detach: if (!USES_PRIMARY(bond->params.mode)) bond_hw_addr_flush(bond_dev, slave_dev); - bond_del_vlans_from_slave(bond, slave_dev); + vlan_vids_del_by_dev(slave_dev, bond_dev); write_lock_bh(&bond->lock); bond_detach_slave(bond, new_slave); if (bond->primary_slave == new_slave) @@ -2028,7 +2003,7 @@ static int __bond_release_one(struct net_device *bond_dev, /* must do this from outside any spinlocks */ bond_destroy_slave_symlinks(bond_dev, slave_dev); - bond_del_vlans_from_slave(bond, slave_dev); + vlan_vids_del_by_dev(slave_dev, bond_dev); /* If the mode USES_PRIMARY, then this cases was handled above by * bond_change_active_slave(..., NULL)