Received: by 10.192.165.156 with SMTP id m28csp1069953imm; Wed, 11 Apr 2018 11:52:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Zuvqdkfn3jKwScpy0WPT9qBPzXuLqkXjcc2NxUxJEmRxSAV+DGv7lp2PFJQqFbSOtJS4m X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr6294039plc.214.1523472749897; Wed, 11 Apr 2018 11:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523472749; cv=none; d=google.com; s=arc-20160816; b=mb6nAw4Iq7uQ4hEX8bOprWy+QhI5VBJymm2SfaQspvswLPub6MFJojatGGWAgkLdUO rOTvMtlSX/dDqlUgDoNh1LG9qAQhCSIxSIitOhtyOBqg7cc87qR9OTcSUCIFML4gAY3s 1zIY23zjaIH0As7HZbpjSHP8lx/O2KzHcitXJhhsqC3wBvjxY92j5Cghqekeov0Ztiej 2I11E2HU3tpBoLNe78QhByaoCfMBoX95uG+/UD8zTciGRJc4tmt/zE6Gpe7bsfB3KcZ4 CxFDrCUXho71R1uz99JTgv+Q+jpFD56kduMryr6tfrtSXkAXCr2cUaSM7hrYJNUk+cK3 ryAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=McfO7NQFAh+tUlp9BDdPLAwvDyGtvh7ECyU80YpI+3Y=; b=i8aI95qiQfq3MEZ9VTUBn6K4Q+icY73n/Tr9wkg/lEyQ6kZ5vpgKfui3eIHBmSDxja DuyEaEbWHRxx8G6N0CuYRe0iVLnJqSbWXF14g89zaEvCxcxEC5uT/qq1YlWBi2wSCfOt W3BCw5KO8YSS9RXo52tYgELCsUvPA1qmpody8wge5Hh2iIsn/bW5HqQWtVGvEkmsbplw EeH/edU23sLBxVAnu6dexZZIM6bsHq/Jx/y+l2NJyS72EcjcWl10jVVTh6H8pDQnlTc8 bFFcurbUEEVBkQX4ErKD2W0rnvbXyZxL/06ngKTL2H2183q3/G2NQckrP1Ag1ZjqugKQ a5lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si1601995plk.411.2018.04.11.11.51.53; Wed, 11 Apr 2018 11:52:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755490AbeDKSpR (ORCPT + 99 others); Wed, 11 Apr 2018 14:45:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58546 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755480AbeDKSpP (ORCPT ); Wed, 11 Apr 2018 14:45:15 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DCBBAC9F; Wed, 11 Apr 2018 18:45:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ihar Hrachyshka , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 042/190] arp: honour gratuitous ARP _replies_ Date: Wed, 11 Apr 2018 20:34:48 +0200 Message-Id: <20180411183552.596346496@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183550.114495991@linuxfoundation.org> References: <20180411183550.114495991@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ihar Hrachyshka [ Upstream commit 23d268eb240954e6e78f7cfab04f2b1e79f84489 ] When arp_accept is 1, gratuitous ARPs are supposed to override matching entries irrespective of whether they arrive during locktime. This was implemented in commit 56022a8fdd87 ("ipv4: arp: update neighbour address when a gratuitous arp is received and arp_accept is set") There is a glitch in the patch though. RFC 2002, section 4.6, "ARP, Proxy ARP, and Gratuitous ARP", defines gratuitous ARPs so that they can be either of Request or Reply type. Those Reply gratuitous ARPs can be triggered with standard tooling, for example, arping -A option does just that. This patch fixes the glitch, making both Request and Reply flavours of gratuitous ARPs to behave identically. As per RFC, if gratuitous ARPs are of Reply type, their Target Hardware Address field should also be set to the link-layer address to which this cache entry should be updated. The field is present in ARP over Ethernet but not in IEEE 1394. In this patch, I don't consider any broadcasted ARP replies as gratuitous if the field is not present, to conform the standard. It's not clear whether there is such a thing for IEEE 1394 as a gratuitous ARP reply; until it's cleared up, we will ignore such broadcasts. Note that they will still update existing ARP cache entries, assuming they arrive out of locktime time interval. Signed-off-by: Ihar Hrachyshka Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/ipv4/arp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -658,6 +658,7 @@ static int arp_process(struct net *net, unsigned char *arp_ptr; struct rtable *rt; unsigned char *sha; + unsigned char *tha = NULL; __be32 sip, tip; u16 dev_type = dev->type; int addr_type; @@ -729,6 +730,7 @@ static int arp_process(struct net *net, break; #endif default: + tha = arp_ptr; arp_ptr += dev->addr_len; } memcpy(&tip, arp_ptr, 4); @@ -839,8 +841,18 @@ static int arp_process(struct net *net, It is possible, that this option should be enabled for some devices (strip is candidate) */ - is_garp = arp->ar_op == htons(ARPOP_REQUEST) && tip == sip && - addr_type == RTN_UNICAST; + is_garp = tip == sip && addr_type == RTN_UNICAST; + + /* Unsolicited ARP _replies_ also require target hwaddr to be + * the same as source. + */ + if (is_garp && arp->ar_op == htons(ARPOP_REPLY)) + is_garp = + /* IPv4 over IEEE 1394 doesn't provide target + * hardware address field in its ARP payload. + */ + tha && + !memcmp(tha, sha, dev->addr_len); if (!n && ((arp->ar_op == htons(ARPOP_REPLY) &&