All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ihar Hrachyshka <ihrachys@redhat.com>
To: davem@davemloft.net, ja@ssi.bg
Cc: Ihar Hrachyshka <ihrachys@redhat.com>, netdev@vger.kernel.org
Subject: [PATCH v2 4/4] arp: always override existing neigh entries with gratuitous ARP
Date: Thu, 18 May 2017 12:41:21 -0700	[thread overview]
Message-ID: <e6632af3eda7467c9a61402e8561cef7d6b9d02b.1495136258.git.ihrachys@redhat.com> (raw)
In-Reply-To: <cover.1495136258.git.ihrachys@redhat.com>
In-Reply-To: <cover.1495136258.git.ihrachys@redhat.com>

Currently, when arp_accept is 1, we always override existing neigh
entries with incoming gratuitous ARP replies. Otherwise, we override
them only if new replies satisfy _locktime_ conditional (packets arrive
not earlier than _locktime_ seconds since the last update to the neigh
entry).

The idea behind locktime is to pick the very first (=> close) reply
received in a unicast burst when ARP proxies are used. This helps to
avoid ARP thrashing where Linux would switch back and forth from one
proxy to another.

This logic has nothing to do with gratuitous ARP replies that are
generally not aligned in time when multiple IP address carriers send
them into network.

This patch enforces overriding of existing neigh entries by all incoming
gratuitous ARP packets, irrespective of their time of arrival. This will
make the kernel honour all incoming gratuitous ARP packets.

Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
---
 net/ipv4/arp.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index c22103c..ae96e6f 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -863,16 +863,17 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
 
 	n = __neigh_lookup(&arp_tbl, &sip, dev, 0);
 
-	if (IN_DEV_ARP_ACCEPT(in_dev)) {
+	if (n || IN_DEV_ARP_ACCEPT(in_dev)) {
 		addr_type = -1;
+		is_garp = arp_is_garp(net, dev, &addr_type, arp->ar_op,
+				      sip, tip, sha, tha);
+	}
 
+	if (IN_DEV_ARP_ACCEPT(in_dev)) {
 		/* Unsolicited ARP is not accepted by default.
 		   It is possible, that this option should be enabled for some
 		   devices (strip is candidate)
 		 */
-		is_garp = arp_is_garp(net, dev, &addr_type, arp->ar_op,
-				      sip, tip, sha, tha);
-
 		if (!n &&
 		    (is_garp ||
 		     (arp->ar_op == htons(ARPOP_REPLY) &&
-- 
2.9.3

  parent reply	other threads:[~2017-05-18 19:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 19:41 [PATCH v2 0/4] arp: always override existing neigh entries with gratuitous ARP Ihar Hrachyshka
2017-05-18 19:41 ` [PATCH v2 1/4] arp: fixed error in a comment Ihar Hrachyshka
2017-05-18 19:41 ` [PATCH v2 2/4] arp: decompose is_garp logic into a separate function Ihar Hrachyshka
2017-05-18 20:49   ` Julian Anastasov
2017-05-24 21:38     ` Ihar Hrachyshka
2017-05-18 19:41 ` [PATCH v2 3/4] arp: postpone addr_type calculation to as late as possible Ihar Hrachyshka
2017-05-18 19:41 ` Ihar Hrachyshka [this message]
2017-05-21 17:27 ` [PATCH v2 0/4] arp: always override existing neigh entries with gratuitous ARP David Miller
2017-05-23 20:56 ` Arnd Bergmann
2017-05-24 21:32   ` Ihar Hrachyshka
2017-05-24 21:57     ` Arnd Bergmann

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=e6632af3eda7467c9a61402e8561cef7d6b9d02b.1495136258.git.ihrachys@redhat.com \
    --to=ihrachys@redhat.com \
    --cc=davem@davemloft.net \
    --cc=ja@ssi.bg \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.