Received: by 10.213.65.68 with SMTP id h4csp1682670imn; Mon, 19 Mar 2018 10:26:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELtE794NRAZeTBqae8pKn2diOEKZNNJVx1bAILd0LPewOF6a26dfEX0drZrR4gRb5vCn1/vj X-Received: by 10.99.107.6 with SMTP id g6mr9838720pgc.109.1521480384407; Mon, 19 Mar 2018 10:26:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521480384; cv=none; d=google.com; s=arc-20160816; b=hROcIwcsTN8KoUs5v+gHyY3unBbZVdYffrt2ehdx2uuVk/AkiQ8Hkq3oKk32qW5vjq yTRmxpIE3f4dStlHgOAuK0ELpkS/nJfeJPZ0X7nrT6trmStsu69jrmOM4fd0XI/n2CYi MHKthNsQZxczfgzFx+gZmbXVFtSiJDJD3qINnoSkYkVD2xmdMar0uLD0fD/42Jtqas4A K2Hf1kNyViVM1dSo6WEcpAzM0mEjV/O/16xi+7Ab5rOk09QXnucCF14n/HtEye6XGHwX rFqcKA6B5ytBCxuJp4edxigGk5x9hfSmjIhl86tJXZPb35Hu9Fgep84NrvD+96qEoCyP BwIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=dwI/VIEAeuVGqHQ3nPDLeHp5zsfMcoUoItzeYd7xKo0=; b=D16BSNQViyDak337BZay+aF/JvVep1JWyUXWsGV13KRkfCiteq0eIgFpbIhhs9Po8i U4dpaOC9Z5SRfRwaFuB72eeDIAJggteWT5jJx1sWYSiwk0iMGyYlCNcdfJb3vD1eiCfE abxDbNTRS+L2thtems+MBuYt0f4/vMtm+uUg9lrFRTuHesXj6nEnDEJMwactRfUJUojU URkcquwMD6DZUDY7+qc+83cgpda/RhjMKVc3v6QawAHcpcDIAfvIO00dBGNSzfQYwO8l HaITBKY6WirDGb1U9ztkVs8l0Fi+7knmNGg8WWqjL6Wo9ST+ZcPxJCRgvwOYx8O0h46C 0Xtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=oDNFak4v; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9-v6si321080pls.127.2018.03.19.10.26.09; Mon, 19 Mar 2018 10:26:24 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=oDNFak4v; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966295AbeCSQI1 (ORCPT + 99 others); Mon, 19 Mar 2018 12:08:27 -0400 Received: from mail-dm3nam03on0098.outbound.protection.outlook.com ([104.47.41.98]:60247 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966265AbeCSQIN (ORCPT ); Mon, 19 Mar 2018 12:08:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dwI/VIEAeuVGqHQ3nPDLeHp5zsfMcoUoItzeYd7xKo0=; b=oDNFak4v/DDF0lMkLOJL+7xzMbNAYeKf/kF4TC2dMmOKsKSTyZZitFDwCaSZI/MxF7KUiATHnWvO0OopP+rInJH0sIujRVlRHsKPHXJ5y3x3ZT8OrGK8q5NGdwd9LMNKzmvQwrX2iJbJsqGsKE/bdHQCuiqo8FrlY5tPbXGoOn4= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0805.namprd21.prod.outlook.com (10.167.105.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.2; Mon, 19 Mar 2018 16:08:10 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 16:08:10 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Ihar Hrachyshka , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 043/167] arp: honour gratuitous ARP _replies_ Thread-Topic: [PATCH AUTOSEL for 4.4 043/167] arp: honour gratuitous ARP _replies_ Thread-Index: AQHTv5w1LqYMGGVo7Uuu/7kXASgtfg== Date: Mon, 19 Mar 2018 16:06:15 +0000 Message-ID: <20180319160513.16384-43-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0805;7:Su630mhZjNVA3U4hSY6yC8he4o1FWlZvD9ZaLLyYxZBouuSN3kHsNw8G29Iy4zMfHv8X83ZjpuMgxSHqsyTD5UnaW8ag9ZUzyb09MwlHRyhNpcmPE3hpD7y7Zk2ZaJ1lM5AghpA0tVg3tvgto/Mb4oaRTBuDvFd4bOMwSN2DYwdNJimYMTbCU8/QWxYhNiV0AxGYtNxTId4KkYEXVTRSZQIIOHobg/VaLHnm2OBFHYOhUkn7rlh0HwtbAzA2WNjz;20:FZFelZUUo5VdDyV5A3aRF+1l3rc/SnqpivNEuHeWNNDuMP5/HZoF/jYvyFxs/Nxk08XMbVpOoHrdpes5+HniynddpXph42TrPr4BdYko2OgrMLrYWVU+/cFuPwPGt5YLiDsz7IJAtHd8Jl/InyDOI0Tbommx9Q5FWZYKTNXe9OU= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0563b5ad-a8ef-4839-7270-08d58db39c35 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0805; x-ms-traffictypediagnostic: DM5PR2101MB0805: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0805;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0805; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(376002)(346002)(366004)(396003)(39860400002)(199004)(189003)(2950100002)(305945005)(186003)(86362001)(6506007)(3660700001)(5660300001)(6116002)(8936002)(3846002)(1076002)(26005)(7736002)(6486002)(2900100001)(6436002)(2906002)(86612001)(68736007)(81166006)(81156014)(10090500001)(102836004)(59450400001)(8676002)(14454004)(105586002)(107886003)(25786009)(478600001)(2501003)(5250100002)(53936002)(3280700002)(316002)(54906003)(4326008)(6512007)(72206003)(66066001)(22452003)(10290500003)(99286004)(76176011)(36756003)(97736004)(106356001)(110136005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0805;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: tE12QSHlDe/X/aUliShYnThVny2DMDlmDzWzSU59wIF9nSb+k9P0V1HvoZQS204DpANiReW5g8CvmN/8tB6P34i8dE9f8cu6VCNR8dXDS+Q2Uu5oRe/MVEI5Yp8OHz71On7AUPXk0cF6OmozMhcEJ5YcXRy+J08gv07dAHiZmDtduIGjN1EO+Csx83YPo0r1DEp+UUuukwzir4L8/yFleNglamzlIfcajtY2znyFufr0GqOcitTQOQ7JEAdJcY4C7vLgg5vR2PtmzTbLmdGLfKKUikEsOrjXkXgdxHX9dgwmF0UEa2yePUiSfaXu+fYxqMRHqIXtsg6fN0dn8Rq1wA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0563b5ad-a8ef-4839-7270-08d58db39c35 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 16:06:15.3540 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0805 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/ipv4/arp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index cb5eb649ad5f..6bc16a01f1ee 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -658,6 +658,7 @@ static int arp_process(struct net *net, struct sock *sk= , struct sk_buff *skb) unsigned char *arp_ptr; struct rtable *rt; unsigned char *sha; + unsigned char *tha =3D NULL; __be32 sip, tip; u16 dev_type =3D dev->type; int addr_type; @@ -729,6 +730,7 @@ static int arp_process(struct net *net, struct sock *sk= , struct sk_buff *skb) break; #endif default: + tha =3D arp_ptr; arp_ptr +=3D dev->addr_len; } memcpy(&tip, arp_ptr, 4); @@ -839,8 +841,18 @@ static int arp_process(struct net *net, struct sock *s= k, struct sk_buff *skb) It is possible, that this option should be enabled for some devices (strip is candidate) */ - is_garp =3D arp->ar_op =3D=3D htons(ARPOP_REQUEST) && tip =3D=3D sip && - addr_type =3D=3D RTN_UNICAST; + is_garp =3D tip =3D=3D sip && addr_type =3D=3D RTN_UNICAST; + + /* Unsolicited ARP _replies_ also require target hwaddr to be + * the same as source. + */ + if (is_garp && arp->ar_op =3D=3D htons(ARPOP_REPLY)) + is_garp =3D + /* IPv4 over IEEE 1394 doesn't provide target + * hardware address field in its ARP payload. + */ + tha && + !memcmp(tha, sha, dev->addr_len); =20 if (!n && ((arp->ar_op =3D=3D htons(ARPOP_REPLY) && --=20 2.14.1