From patchwork Sat Jan 8 23:57:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 77994 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 84FF6B70DF for ; Sun, 9 Jan 2011 10:57:25 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751816Ab1AHX5U (ORCPT ); Sat, 8 Jan 2011 18:57:20 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:44877 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434Ab1AHX5T (ORCPT ); Sat, 8 Jan 2011 18:57:19 -0500 Received: by eye27 with SMTP id 27so8134928eye.19 for ; Sat, 08 Jan 2011 15:57:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=JQPF5YRJRNq+59yWVUNcBMV56KyUCOZziUZ8IFTQJDo=; b=ppC0imkq4ExH4a6gbU9DoI0do5yR5LtKwf45RS4Z/4OzTaoBKplx+o/YHISTKKQo91 zm2hdSN/2/PwT6lX49JRAGjE+k5ipTA6yNYbys//xEbojMQjnEvgO3TdHarMORKAR2ee De7rVyCn8BjpJUqsvTJax3Wgs3/nzQW6xOEoE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=p+TBL9ba5PFTJasIXoST9C8l2PzqtTykwCpuGCe5LhF349PqiBnhffiTLamLjmMbpc IfwpqF0BCG0FayZcM1v67vth3GDeIXEw9lKbiLUvT2t8XS4B1CTwP30AbKK9MlT2DEHf xjz4F+eUwIFGS3xveeSTa+w2kpWxcIV1H85m8= Received: by 10.213.26.74 with SMTP id d10mr661178ebc.61.1294531037996; Sat, 08 Jan 2011 15:57:17 -0800 (PST) Received: from [10.0.0.2] (IGLD-84-228-236-190.inter.net.il [84.228.236.190]) by mx.google.com with ESMTPS id u1sm3444014eeh.16.2011.01.08.15.57.14 (version=SSLv3 cipher=RC4-MD5); Sat, 08 Jan 2011 15:57:16 -0800 (PST) Subject: Re: [PATCH 3/5] NET: IPV4: ARP: allow to invalidate specific ARP entries From: Maxim Levitsky To: Eric Dumazet Cc: linux1394-devel , Stefan Richter , netdev@vger.kernel.org, "David S. Miller" , Alexey Kuznetsov , James Morris , Patrick McHardy In-Reply-To: <1294405062.3306.11.camel@edumazet-laptop> References: <1290996593-32416-1-git-send-email-maximlevitsky@gmail.com> <1290996593-32416-4-git-send-email-maximlevitsky@gmail.com> <1294404478.7674.0.camel@maxim-laptop> <1294405062.3306.11.camel@edumazet-laptop> Date: Sun, 09 Jan 2011 01:57:12 +0200 Message-ID: <1294531032.25396.11.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 2011-01-07 at 13:57 +0100, Eric Dumazet wrote: > Le vendredi 07 janvier 2011 à 14:47 +0200, Maxim Levitsky a écrit : > > On Mon, 2010-11-29 at 04:09 +0200, Maxim Levitsky wrote: > > > IPv4 over firewire needs to be able to remove ARP entries > > > from the ARP cache that belong to nodes that are removed, because > > > IPv4 over firewire uses ARP packets for private information > > > about nodes. > > > > > > This information becomes invalid as soon as node drops > > > off the bus and when it reconnects, its only possible > > > to start takling to is after it responded to an ARP packet. > > > But ARP cache prevents such packets from being sent. > > > > > > CC: netdev@vger.kernel.org > > > CC: "David S. Miller" > > > CC: Alexey Kuznetsov > > > CC: James Morris > > > CC: Patrick McHardy > > > > Anybody? > > > > Best regards, > > Maxim Levitsky > > > > > > > > > > > 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); > > > } > > > > > > /* > > > > Hi Maxim > > You were supposed to respin your patch after my commit : > > (941666c2e3e0f9f6a1 net: RCU conversion of dev_getbyhwaddr() and > arp_ioctl()) > > Thanks Hi, After looking at the code (and honestly its hard to work with it as it has no documentation at all), I think I don't need any changes in my patch. Here is the latest version for I use with the above commit applied (it is in mainline now). --- commit 7da91d68d78b6a44ba6337be3b29b22ba2909b9e Author: Maxim Levitsky Date: Sat Nov 27 00:50:45 2010 +0200 NET: IPV4: ARP: allow to invalidate specific ARP entries IPv4 over firewire needs to be able to remove ARP entries from the ARP cache that belong to nodes that are removed, because IPv4 over firewire uses ARP packets for private information about nodes. This information becomes invalid as soon as node drops off the bus and when it reconnects, its only possible to start takling to is after it responded to an ARP packet. But ARP cache prevents such packets from being sent. CC: netdev@vger.kernel.org CC: "David S. Miller" CC: Alexey Kuznetsov CC: James Morris CC: Patrick McHardy Signed-off-by: Maxim Levitsky -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 a2fc7b9..e941c75 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1143,6 +1143,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) { @@ -1163,7 +1180,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); @@ -1181,16 +1197,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); } /*