From patchwork Sun Nov 28 01:15:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 73315 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 C57E4B70AF for ; Sun, 28 Nov 2010 12:16:03 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753754Ab0K1BP6 (ORCPT ); Sat, 27 Nov 2010 20:15:58 -0500 Received: from mail-bw0-f46.google.com ([209.85.214.46]:35883 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753403Ab0K1BPy (ORCPT ); Sat, 27 Nov 2010 20:15:54 -0500 Received: by bwz15 with SMTP id 15so2883359bwz.19 for ; Sat, 27 Nov 2010 17:15:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=1UfSQdebZbaJe0Fph7Wt36rwK4qFNg4/J6ga+pP7Ges=; b=AoGB8LVlXoBl882qSWklFS0DSQpSMDfLyDnHdL4I+8YSQ68mfyKyOgX7Ysg1Ds18O1 2LYS+wZa1uQwFRPIjZ7bnA/0bUkCoHOsxI16z4sOcSFofrdffZq7QwtNk8n8aZEgVYlY o1VRq3lJVCFROBxYSWiufPp0nwTjqy5R8V/8M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=I7jTBMUX8ULk3hjknkA4I6oOPC4NwK6suecxxeHoqehyvkZVv8KTHm/pYG+BZ9mwgm yaVBlhSUrVe6HyTVdjXstkFtJ16bL9/n8LYuLGGSFGo5ELZdPFeU8wmryCk3i8OmcM/t Ez09NDONUQkuU77Jfrk5+TUtaP320i5Ao28tM= Received: by 10.204.69.11 with SMTP id x11mr3389618bki.42.1290906950393; Sat, 27 Nov 2010 17:15:50 -0800 (PST) Received: from maxim-laptop ([77.125.106.90]) by mx.google.com with ESMTPS id g8sm1231117bkg.23.2010.11.27.17.15.48 (version=SSLv3 cipher=RC4-MD5); Sat, 27 Nov 2010 17:15:49 -0800 (PST) From: Maxim Levitsky To: linux1394-devel Cc: Stefan Richter , netdev@vger.kernel.org, Maxim Levitsky Subject: [PATCH 3/5] NET: ARP: allow to invalidate specific ARP entries Date: Sun, 28 Nov 2010 03:15:34 +0200 Message-Id: <1290906936-14472-4-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1290906936-14472-1-git-send-email-maximlevitsky@gmail.com> References: <1290906936-14472-1-git-send-email-maximlevitsky@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org IPv4 over firewire needs to be able to remove ARP entries from cache that belong to nodes that are removed, because IPv4 over firewire uses ARP packets for private information about nodes. This information becames invalid on node removal, thus as soon as it is connected again, ARP packet should be sent to it which is not done due to valid cache entry. CC: netdev@vger.kernel.org Signed-off-by: Maxim Levitsky --- include/net/arp.h | 1 + net/ipv4/arp.c | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/net/arp.h b/include/net/arp.h index f4cf6ce..91f0568 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -25,5 +25,6 @@ extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, const unsigned char *src_hw, const unsigned char *target_hw); extern void arp_xmit(struct sk_buff *skb); +int arp_invalidate(struct net_device *dev, __be32 ip); #endif /* _ARP_H */ diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index d8e540c..35b1272 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1142,6 +1142,23 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev) return err; } +int arp_invalidate(struct net_device *dev, __be32 ip) +{ + int err = -ENXIO; + struct neighbour *neigh = neigh_lookup(&arp_tbl, &ip, dev); + + if (neigh) { + if (neigh->nud_state & ~NUD_NOARP) + err = neigh_update(neigh, NULL, NUD_FAILED, + NEIGH_UPDATE_F_OVERRIDE| + NEIGH_UPDATE_F_ADMIN); + neigh_release(neigh); + } + + return err; +} +EXPORT_SYMBOL(arp_invalidate); + static int arp_req_delete_public(struct net *net, struct arpreq *r, struct net_device *dev) { @@ -1162,7 +1179,6 @@ static int arp_req_delete(struct net *net, struct arpreq *r, { int err; __be32 ip; - struct neighbour *neigh; if (r->arp_flags & ATF_PUBL) return arp_req_delete_public(net, r, dev); @@ -1180,16 +1196,7 @@ static int arp_req_delete(struct net *net, struct arpreq *r, if (!dev) return -EINVAL; } - err = -ENXIO; - neigh = neigh_lookup(&arp_tbl, &ip, dev); - if (neigh) { - if (neigh->nud_state & ~NUD_NOARP) - err = neigh_update(neigh, NULL, NUD_FAILED, - NEIGH_UPDATE_F_OVERRIDE| - NEIGH_UPDATE_F_ADMIN); - neigh_release(neigh); - } - return err; + return arp_invalidate(dev, ip); } /*