From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F208DC74A5B for ; Thu, 23 Mar 2023 19:45:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D46E85764; Thu, 23 Mar 2023 20:45:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=microsoft.com header.i=@microsoft.com header.b="TMFIsEbA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B4E885850; Thu, 23 Mar 2023 17:44:43 +0100 (CET) Received: from DM5PR00CU002.outbound.protection.outlook.com (mail-cusazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c111::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 28F2E85664 for ; Thu, 23 Mar 2023 17:44:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=emohandesi@microsoft.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KnyygggceuNQCA7jR/ITIV+27YVaifvwe/LGSPBXRm1GOW/9sHWVUJyT9+94nDvgwtgkFECbJ9OuRwvvsqDMMhWbwhAocg8XYqKDV7V7tYSAPVzWVhmmibfcqvnn0vHQCeXvC2ro3fHwxOGEGYIRltlhdkFJbdP6qEFyXVRaOvfKzqMBkuDf2WjUwBnt58YT0pAEpwJ/yojtK/7J174XderwZAgKwflfFuS0DndkANrsHIzZ0vvlCLvaz1FQvAuD77MEwO0mgPB5+/YbUzaQ6VhdzyGJQWtHGaKY1VTzq7g/bAVUPpKSWNom5ZcD0xWAV2eS9yThEF3kywZBZQoSnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Uqy6a4gG3IpyaLOyKZasrwbjLANOVU8Q5QAc5Pjad44=; b=IM+ptJLubJnkmRAP6I6sqBOg+xGx9Rt1IJ9NwTiKFRcMQylww/FXpkt0QrXpV6C57hQVx1RXoZCI1bTLW/0ioPf4gswfzNK+GfbnRtrPHbICJhK5vE07L4JONbGOqMxq7ggSD0GIr0Kzw2pA/nmgzTRpNmWrYWcqtk+TuQx9wLuTnh0xN7gzc3LwOizN2h1tPQBlNHQqBmw7pvr1b/UAPLHKhVrz5sMuYSPQax36ju8XK0ubwvW+DYYyl2zJDkXdaaCTBhtYTRPksBI3vYWPvf2mQDjjzh6IplY/im4RUSm4C/vthqoaTMIyPCcUAuRz339XzYoyrksfyLxmBbZdVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uqy6a4gG3IpyaLOyKZasrwbjLANOVU8Q5QAc5Pjad44=; b=TMFIsEbAm0qjZSc1IicP/KbkkZ8tUpbZijyNc1ehD+2ZJYhu9ggsBDn8dhmg8OjT0FsqhG1BgYtc+A4XyuQLvL6CZkBmcksDMdNcx/lUmXFeqE1qvj/ohrarj1SUCHyuCwpbXpNZTaoX65oCbJdn9Q0IWY9IiNNH63bYETluwrY= Received: from PH0PR00MB1032.namprd00.prod.outlook.com (2603:10b6:510:48::9) by CY8PR00MB1433.namprd00.prod.outlook.com (2603:10b6:930:63::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6270.0; Thu, 23 Mar 2023 16:44:27 +0000 Received: from PH0PR00MB1032.namprd00.prod.outlook.com ([fe80::5a54:fe02:6815:2283]) by PH0PR00MB1032.namprd00.prod.outlook.com ([fe80::5a54:fe02:6815:2283%6]) with mapi id 15.20.6270.000; Thu, 23 Mar 2023 16:44:27 +0000 From: Ehsan Mohandesi To: "Vyacheslav V. Mitrofanov" , "u-boot@lists.denx.de" , "emohandesi@linux.microsoft.com" CC: "joe.hershberger@ni.com" , "xypron.glpk@gmx.de" , "dphadke@linux.microsoft.com" , "saproj@gmail.com" , "rfried.dev@gmail.com" , "ilias.apalodimas@linaro.org" , "john@metanate.com" , "sjg@chromium.org" , "masahisa.kojima@linaro.org" Subject: RE: [PATCH] net: ipv6: Add support for default gateway discovery. Thread-Topic: [PATCH] net: ipv6: Add support for default gateway discovery. Thread-Index: AQHZTSgzEDImSigfVUmtJA6aVOCd0q79LXMAgAt1lqA= Date: Thu, 23 Mar 2023 16:44:27 +0000 Message-ID: References: <1677776290-11067-1-git-send-email-emohandesi@linux.microsoft.com> <3ec9fe22fd0eedf4af0ceac8f12bb27272421f2b.camel@yadro.com> In-Reply-To: <3ec9fe22fd0eedf4af0ceac8f12bb27272421f2b.camel@yadro.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=1198f2b2-97d5-4af2-9428-883ef9eaa949; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2023-03-23T15:46:47Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR00MB1032:EE_|CY8PR00MB1433:EE_ x-ms-office365-filtering-correlation-id: ddd4e93f-6baf-492c-e900-08db2bbdddbd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JFZsbbZBzKW/KkK/QFj+B3qlDn5HD3WDHAEis8EB8xabfGLBX6gyakIQUjbaY49us/Cj3OSsw4Npf+Gw8AbaG5OLBXdQrlY0ywwuIKpEnYOtzmF6ykHC1yNEG6Nu0OlByyDpcOG/0Yes39jRo3qZAQgeu4Gs8XMC07hzqUJckKxzdSD3H6nGmkga3dRNI6h1oMFUFjYBp8pmLhOhp4vBbVBk/FfrjqdeMIKMTrEqjanNihuz8pk66umV92Ndyz13iB7VysmKGs4HcM+Y71CLK6aVoKcSKX9/jMqlv1cLRYgq7SEOmc8fMyDqTaTIYgU6PSkDth21SYLRpEHC0taJK1mtveLf8VZjJAXyEmwluuDcjtmW93+3v+7L4crLgEwMLly31cE97zAWJoPgvusbMB78RZP/wB3+kCkDmfC/0R1Vo5Wj9EZPkibhejrzK4WdrHVYS6i02p+NgxrHSgSdrZsJ5CUDA6AXa6d0V0RP/WKjeZF0F7xpVtTwadYkPwu/0kdh1CRANfdUxufb1uaIKeWr55DPyM0/9YPYQhdCWLC0hRBUNFaCb6cd00VSomOQkx9mb9id2X0HHyNt2PP2TFSQdeZcj+nX9+Rs0EXBbIH9grmOjzaZ740ivcoOPNpzsRpP5CGaG+N3AezePTx9Ig== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:cs; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR00MB1032.namprd00.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(136003)(366004)(39860400002)(376002)(396003)(346002)(451199018)(66946007)(4326008)(76116006)(8676002)(8936002)(41300700001)(82950400001)(82960400001)(54906003)(66476007)(64756008)(66556008)(66446008)(110136005)(66574015)(83380400001)(316002)(122000001)(38100700002)(5660300002)(52536014)(7416002)(10290500003)(478600001)(2906002)(38070700005)(186003)(8990500004)(9686003)(7696005)(26005)(71200400001)(6506007)(86362001)(55016003)(53546011)(33656002)(966005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?jjAPT05G13QEylzfJ10rYPZLAZDU1lfxPXzGaRK2c1lF5YIbmcwWOBKPcO7l?= =?us-ascii?Q?EWRu4ipsDoXUPxocTUf8NaGR1pyfJkgPooj1yuH2aVLiM8YA/oCmwPCGi10+?= =?us-ascii?Q?I5j5a7MGgKDR6Rxw7NR+wblmyOhb0kxmVF+6VRAk74Da9autrANvCjOlTE5b?= =?us-ascii?Q?6EFtEaLd5nJZBqaHzGXAE/81me/44kgeghJ0gMXmoT2XJ5C24k5v6BBNjtp8?= =?us-ascii?Q?LBloudYay0sCfrdsjuapiRfzUwVBFCJwXjDCLL0gFibQiAJzJJnCqiK3bkrZ?= =?us-ascii?Q?lvgv+81mKcaqZdCkh1JdcZax1DyUM8qOcEYMaf8uh27A7zbFVpN0EPJZrVwW?= =?us-ascii?Q?e9kwJm/XYBkssHy6c4MSEXFdN6oseT4O8pXydJMGHS/5smaKL3/6PrDwn/JZ?= =?us-ascii?Q?PbO2CdJXbrHu7yaHAa4i0ZUNevi/9S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RQzC+8Ii0pighC4SoxNLvCW913xDIV/2osBrTZDcbDhKf3Sagp?= =?us-ascii?Q?o9VH1l/RDeMeD60Yv/CRY/UNZ6mYPFs/KQPVXS0GTI1BrGWqjad3SAL92cZY?= =?us-ascii?Q?VhQyo8wUjFJ/7ObJuP0VQoZIemNRY12oMl9jYLmek7mZG7qPVg42buYCBNKL?= =?us-ascii?Q?7GULmZQeex3Yn83PqeA4dqpc1rMiualYoGA+?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR00MB1032.namprd00.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddd4e93f-6baf-492c-e900-08db2bbdddbd X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 16:44:27.2000 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: TlKUGIjOck8BE1owUl5mBz5g8rNyf5EMtGC4ndVLTZMHUp3zGrxuNb2Ghyt3qUaKscfIrjxT2UAifKm9XIR6gbXPyEA+9svtX29L6IT26bI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR00MB1433 X-Mailman-Approved-At: Thu, 23 Mar 2023 20:45:04 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hi Viacheslav, > -----Original Message----- > From: Vyacheslav V. Mitrofanov > Sent: Thursday, March 16, 2023 3:47 AM > To: u-boot@lists.denx.de; emohandesi@linux.microsoft.com > Cc: joe.hershberger@ni.com; xypron.glpk@gmx.de; > dphadke@linux.microsoft.com; saproj@gmail.com; rfried.dev@gmail.com; > ilias.apalodimas@linaro.org; Ehsan Mohandesi ; > john@metanate.com; sjg@chromium.org; masahisa.kojima@linaro.org > Subject: [EXTERNAL] Re: [PATCH] net: ipv6: Add support for default gatewa= y > discovery. > > On Thu, 2023-03-02 at 08:58 -0800, emohandesi@linux.microsoft.com > wrote: > > > > From: Ehsan Mohandesi > > > > In IPv6, the default gateway and prefix length are determined by > > receiving a router advertisement as defined in - > > > https://www.rf/ > c- > editor.org%2Frfc%2Frfc4861&data=3D05%7C01%7Cemohandesi%40microsoft.co > m%7C6dec635abc8c4861feb708db25fb05d6%7C72f988bf86f141af91ab2d7cd01 > 1db47%7C1%7C0%7C638145532341238481%7CUnknown%7CTWFpbGZsb3d8ey > JWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C > 3000%7C%7C%7C&sdata=3DtAhREBvBgVQKOFqEQT2%2FKphGxYXUMo3UF5vvQpY > B%2Be0%3D&reserved=3D0. > > > > Add support for sending router solicitation (RS) and processing router > > advertisements (RA). > > > > If the RA has prefix info option and following conditions are met, > > then > > gatewayip6 and net_prefix_length of ip6addr env variables are > > initialized. > > These are later consumed by IPv6 code for non-local destination IP. > > > > - "Router Lifetime" !=3D 0 > > - Prefix is NOT link-local prefix (0xfe80::/10) > > - L flag is 1 > > - "Valid Lifetime" !=3D 0 > > > > Timing Parameters: > > - MAX_RTR_SOLICITATION_DELAY (0-1s) > > - RTR_SOLICITATION_INTERVAL (4s) (min retransmit delay) > > - MAX_RTR_SOLICITATIONS (3 RS transmissions) > > > > The functionality is enabled by CONFIG_IPV6_ROUTER_DISCOVERY and > > invoked automatically from net_init_loop(). > > > > Signed-off-by: Ehsan Mohandesi > > > > Conflicts: > > cmd/Kconfig > > include/net.h > > net/net.c > > --- > > cmd/Kconfig | 7 ++ > > include/ndisc.h | 23 ++++++ > > include/net.h | 2 +- > > include/net6.h | 40 ++++++++++ > > net/ndisc.c | 243 > > +++++++++++++++++++++++++++++++++++++++++++++++++++++--- > > net/net.c | 23 +++++- > > net/net6.c | 1 + > > 7 files changed, 327 insertions(+), 12 deletions(-) > > > > I reviewed this patch and it looks good. I have no critical remarks, only= some > small notes. > > I've tested it on SiFive Unmatched board. > > > > > > +config IPV6_ROUTER_DISCOVERY > > + bool "Do router discovery" > > + depends on IPV6 > > + help > > + Will automatically perform router solicitation on first > > IPv6 > > + network operation > > + > > endif > > > I think it is better to write sth like Do IPv6 router discovery because > IPv4 has also router discovery protocol and it could lead to misunderstan= ding > > > > > > net_set_timeout_handler(0, 0); > > > Maybe net_set_timeout_handler(0, NULL); is better > > > > > +/* > > + * validate_ra() - Validate the router advertisement message. > > + * > > + * @ip6: > > + * @len: Length of the router advertisement packet > > + * > > + * Check if the router advertisement message is valid. Conditions > > are > > + * according to RFC 4861 section 6.1.2. Validation of Router > > Advertisement > > + * Messages. > > + * > > + * Return: true if the message is valid and false if it is invalid. > > + */ > > +static bool validate_ra(struct ip6_hdr *ip6, int len) { > > + struct icmp6hdr *icmp =3D (struct icmp6hdr *)(ip6 + 1); > > + > > + /* ICMP length (derived from the IP length) should be 16 or > > more octets. */ > > + if (ip6->payload_len < 16) > > + return false; > > + > > + /* Source IP Address should be a valid link-local address. */ > > + if ((ntohs(ip6->saddr.s6_addr16[0]) & IPV6_LINK_LOCAL_MASK) > > !=3D > > + IPV6_LINK_LOCAL_PREFIX) > > + return false; > > + > > + /* > > + * The IP Hop Limit field should have a value of 255, i.e., > > the packet > > + * could not possibly have been forwarded by a router. > > + */ > > + if (ip6->hop_limit !=3D 255) > > + return false; > > + > Unicast hop limit only? Sorry, I do not understand what you mean here. What kind of scenario are yo= u talking about? It does not matter if the router advertisement is unicast or multicast. In = both cases, the hop limit needs to be 255. A router always sets the hop lim= it to 255. We do not want an advertisement that is forwarded from another n= ode. Refer to this for more information. https://www.rfc-editor.org/rfc/rfc4861#section-6.1.2 > > > diff --git a/net/net.c b/net/net.c > > index c9a749f..39f0b81 100644 > > --- a/net/net.c > > +++ b/net/net.c > > @@ -24,7 +24,7 @@ > > * - name of bootfile > > * Next step: ARP > > * > > - * LINK_LOCAL: > > + * LINKLOCAL: > > > Maybe it is better to move to other patch?! The underscore change on this line is a needed change. LINKLOCAL is used th= is way in the code. In the comment, it has an extra _ in it. It causes conf= usion. An important feature of Linux coding is being able to grep for strin= gs. When I grepped for LINK_LOCAL I did not find what I was looking for. If= there are more important reasons not to make this change, please let me kn= ow to revert it. I did not directly change any LINKLOCAL code, but I needed= it for writing my code. It could happen to anyone. I think it is better to= fix it here and save everyone's time now. > > > Reviewed-by: Viacheslav Mitrofanov > Tested-by: Viacheslav Mitrofanov