From patchwork Thu Mar 22 08:18:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UGV0ZXIgUGFuKOa9mOWNq+W5syk=?= X-Patchwork-Id: 148186 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 39BCEB6F6E for ; Thu, 22 Mar 2012 19:25:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964887Ab2CVIYU (ORCPT ); Thu, 22 Mar 2012 04:24:20 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:33685 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755398Ab2CVIYR (ORCPT ); Thu, 22 Mar 2012 04:24:17 -0400 Received: by dajr28 with SMTP id r28so2804138daj.19 for ; Thu, 22 Mar 2012 01:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=vDfo7d5dCEpBkSs9zbyFKupm/9ueNi5GzTDHGWNnaNc=; b=Am5l3KnAz+7uugynCfcbeIzaCGDFlj1F2hpH6sdGxZvnF+GDD6ngp4vKabHSFwq9v4 U82bG9yF0YNWpIUW93sYCpbHC6oirWmAQOAwc0sypsUTghNN/yMw9ajNP6IXwcxU/Sdk 0t4xGF9pKS4Fjqs0aEEcs335p+qhwtc6aOrRrrAmzLIvDzw0PpCKRvbFDbd38h3W9bPk MbNrotr2n09DanTZ8bI8YNmvcqAG86tx7gm/DnvebL4LZh4br/b7jCEjT51MZR8pgjUc sUZ3Zv/uOBMkx1YOdVbdt8tmTTVDJycOOR+63oHb8Ov9ihdmSBTq3U3QwrPc8GC7uGCs GnaA== Received: by 10.68.229.73 with SMTP id so9mr18354915pbc.163.1332404657027; Thu, 22 Mar 2012 01:24:17 -0700 (PDT) Received: from localhost.localdomain.com ([203.114.244.88]) by mx.google.com with ESMTPS id b10sm3314845pbr.46.2012.03.22.01.24.14 (version=SSLv3 cipher=OTHER); Thu, 22 Mar 2012 01:24:16 -0700 (PDT) From: Weiping Pan Cc: Weiping Pan , Jay Vosburgh (supporter:BONDING DRIVER), Andy Gospodarek (supporter:BONDING DRIVER), netdev@vger.kernel.org (open list:BONDING DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net 1/2] bonding:delete rlb entry if bond's ip is deleted Date: Thu, 22 Mar 2012 16:18:31 +0800 Message-Id: X-Mailer: git-send-email 1.7.4 In-Reply-To: References: In-Reply-To: References: 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 When the ip of bonding is deleted, its rlb table still contains old invalid mappings, just delete them to avoid poisoning other clients arp cache. Signed-off-by: Weiping Pan --- drivers/net/bonding/bond_alb.c | 35 +++++++++++++++++++++++++++++++++++ drivers/net/bonding/bond_alb.h | 2 ++ drivers/net/bonding/bond_main.c | 1 + 3 files changed, 38 insertions(+), 0 deletions(-) diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index f820b26..bca1039 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -853,6 +853,41 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id) _unlock_rx_hashtbl_bh(bond); } +/* delete all rlb entries whose ip_src equals ip */ +void bond_alb_delete_entry(struct bonding *bond, __be32 ip) +{ + struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); + u32 curr_index; + + _lock_rx_hashtbl_bh(bond); + + curr_index = bond_info->rx_hashtbl_head; + while (curr_index != RLB_NULL_INDEX) { + struct rlb_client_info *curr = &(bond_info->rx_hashtbl[curr_index]); + u32 next_index = bond_info->rx_hashtbl[curr_index].next; + u32 prev_index = bond_info->rx_hashtbl[curr_index].prev; + if (curr->assigned && (curr->ip_src == ip)) { + if (curr_index == bond_info->rx_hashtbl_head) { + bond_info->rx_hashtbl_head = next_index; + } + + if (prev_index != RLB_NULL_INDEX) { + bond_info->rx_hashtbl[prev_index].next = next_index; + } + + if (next_index != RLB_NULL_INDEX) { + bond_info->rx_hashtbl[next_index].prev = prev_index; + } + + rlb_init_table_entry(curr); + } + + curr_index = next_index; + } + + _unlock_rx_hashtbl_bh(bond); +} + /*********************** tlb/rlb shared functions *********************/ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h index 90f140a..38863fc 100644 --- a/drivers/net/bonding/bond_alb.h +++ b/drivers/net/bonding/bond_alb.h @@ -163,5 +163,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); void bond_alb_monitor(struct work_struct *); int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id); + +void bond_alb_delete_entry(struct bonding *bond, __be32 ip); #endif /* __BOND_ALB_H__ */ diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 435984a..ec071b9 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3315,6 +3315,7 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event, return NOTIFY_OK; case NETDEV_DOWN: bond->master_ip = 0; + bond_alb_delete_entry(bond, ifa->ifa_local); return NOTIFY_OK; default: return NOTIFY_DONE;