netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Timo Teräs" <timo.teras@iki.fi>
To: netdev@vger.kernel.org
Cc: "Timo Teräs" <timo.teras@iki.fi>, "Patrick McHardy" <kaber@trash.net>
Subject: [PATCH net-next] arp: flush arp cache on IFF_NOARP change
Date: Mon, 20 May 2013 16:29:01 +0300	[thread overview]
Message-ID: <1369056541-4523-1-git-send-email-timo.teras@iki.fi> (raw)

IFF_NOARP affects what kind of neighbor entries are created
(nud NOARP or nud INCOMPLETE). If the flag changes, flush the arp
cache to refresh all entries.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Cc: Patrick McHardy <kaber@trash.net>
---
Original patch sent some years ago and the review is at:
 http://patchwork.ozlabs.org/patch/46806/

This is updated per Patrick's suggestion to use priv_flags as the
place to notify that NOARP flag changed.

 include/uapi/linux/if.h | 1 +
 net/core/dev.c          | 5 +++++
 net/ipv4/arp.c          | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
index 1ec407b..ace4aec 100644
--- a/include/uapi/linux/if.h
+++ b/include/uapi/linux/if.h
@@ -83,6 +83,7 @@
 #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
 #define IFF_LIVE_ADDR_CHANGE 0x100000	/* device supports hardware address
 					 * change when it's running */
+#define IFF_NOARP_CHANGED 0x200000	/* IFF_NOARP changed state recently */
 
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
diff --git a/net/core/dev.c b/net/core/dev.c
index 18e9730..7135fe1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4691,6 +4691,11 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags)
 {
 	unsigned int changes = dev->flags ^ old_flags;
 
+	if (changes & IFF_NOARP)
+		dev->priv_flags |= IFF_NOARP_CHANGED;
+	else
+		dev->priv_flags &= ~IFF_NOARP_CHANGED;
+
 	if (changes & IFF_UP) {
 		if (dev->flags & IFF_UP)
 			call_netdevice_notifiers(NETDEV_UP, dev);
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 247ec19..375b2f2 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1241,6 +1241,10 @@ static int arp_netdev_event(struct notifier_block *this, unsigned long event,
 		neigh_changeaddr(&arp_tbl, dev);
 		rt_cache_flush(dev_net(dev));
 		break;
+	case NETDEV_CHANGE:
+		if (dev->priv_flags & IFF_NOARP_CHANGED)
+			neigh_changeaddr(&arp_tbl, dev);
+		break;
 	default:
 		break;
 	}
-- 
1.8.2.3

             reply	other threads:[~2013-05-20 13:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 13:29 Timo Teräs [this message]
2013-05-20 20:46 ` [PATCH net-next] arp: flush arp cache on IFF_NOARP change David Miller
2013-05-21 10:23   ` [PATCH v2 " Timo Teräs
2013-05-21 16:25     ` Ben Hutchings
2013-05-21 18:29       ` Timo Teras
2013-05-21 18:54         ` Ben Hutchings
2013-05-23  7:01     ` David Miller
2013-05-23  7:49       ` Timo Teras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369056541-4523-1-git-send-email-timo.teras@iki.fi \
    --to=timo.teras@iki.fi \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).