From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1A47220359A8A for ; Thu, 9 Nov 2017 22:52:08 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2017 22:56:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,373,1505804400"; d="scan'208";a="458163" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 09 Nov 2017 22:56:10 -0800 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 9 Nov 2017 22:56:09 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 9 Nov 2017 22:56:09 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.175]) with mapi id 14.03.0319.002; Fri, 10 Nov 2017 14:56:07 +0800 From: "Wu, Jiaxin" To: "Fu, Siyuan" , "edk2-devel@lists.01.org" CC: "Ye, Ting" Thread-Topic: [Patch] MdeModulePkg: Update IP4 stack to support point-to-point link with 31-bit mask. Thread-Index: AQHTR9BaeEdSHzWoGkubscKaryTK4qMNUi+g Date: Fri, 10 Nov 2017 06:56:06 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B727416345B44@SHSMSX103.ccr.corp.intel.com> References: <20171018051705.13832-1-siyuan.fu@intel.com> In-Reply-To: <20171018051705.13832-1-siyuan.fu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjM5NDZkZTAtZDM2Ni00ODU3LThkNzgtNDFlNDU0ODgyY2JmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InNtRUU0ZHNaSnpCeXhYVEk1WmpmdXpYSjhcLzE0S25waXJEZ3had0c1dk9ZPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] MdeModulePkg: Update IP4 stack to support point-to-point link with 31-bit mask. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Nov 2017 06:52:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Wu Jiaxin > -----Original Message----- > From: Fu, Siyuan > Sent: Wednesday, October 18, 2017 1:17 PM > To: edk2-devel@lists.01.org > Cc: Wu, Jiaxin ; Ye, Ting > Subject: [Patch] MdeModulePkg: Update IP4 stack to support point-to-point > link with 31-bit mask. >=20 > This patch is to follow RFC3021 which allows to use 31-bit mask > in point-to-point link. > If a 31-bit subnet mask is assigned to a point-to-point link, it > leaves the with only 1 bit. Consequently, only two > possible addresses may result: > {, 0} and {, -1} > These addresses have historically been associated with network and > broadcast addresses (see Section 2.2). In a point-to-point link with > a 31-bit subnet mask, the two addresses above MUST be interpreted as > host addresses. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Fu Siyuan > Cc: Wu Jiaxin > Cc: Ye Ting > --- > MdeModulePkg/Include/Library/NetLib.h | 6 ++++-- > MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 14 ++++++++++---- > MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c | 20 > +++++++++++++------- > 3 files changed, 27 insertions(+), 13 deletions(-) >=20 > diff --git a/MdeModulePkg/Include/Library/NetLib.h > b/MdeModulePkg/Include/Library/NetLib.h > index 4cd4227..b9df46c 100644 > --- a/MdeModulePkg/Include/Library/NetLib.h > +++ b/MdeModulePkg/Include/Library/NetLib.h > @@ -414,8 +414,10 @@ NetGetIpClass ( >=20 > ASSERT if NetMask is zero. >=20 > - If all bits of the host address of IP are 0 or 1, IP is also not a val= id unicast > address. > - > + If all bits of the host address of IP are 0 or 1, IP is also not a val= id unicast > address, > + except when the originator is one of the endpoints of a point-to-point= link > with a 31-bit > + mask (RFC3021). > + > @param[in] Ip The IP to check against. > @param[in] NetMask The mask of the IP. >=20 > diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > index 1ee77fe..b8544b8 100644 > --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c > @@ -637,7 +637,9 @@ NetGetIpClass ( >=20 > ASSERT if NetMask is zero. >=20 > - If all bits of the host address of IP are 0 or 1, IP is also not a val= id unicast > address. > + If all bits of the host address of IP are 0 or 1, IP is also not a val= id unicast > address, > + except when the originator is one of the endpoints of a point-to-point= link > with a 31-bit > + mask (RFC3021). >=20 > @param[in] Ip The IP to check against. > @param[in] NetMask The mask of the IP. > @@ -657,9 +659,13 @@ NetIp4IsUnicast ( > if (Ip =3D=3D 0 || IP4_IS_LOCAL_BROADCAST (Ip)) { > return FALSE; > } > - > - if (((Ip &~NetMask) =3D=3D ~NetMask) || ((Ip &~NetMask) =3D=3D 0)) { > - return FALSE; > + > + if (NetGetMaskLength (NetMask) !=3D 31) { > + if (((Ip &~NetMask) =3D=3D ~NetMask) || ((Ip &~NetMask) =3D=3D 0)) { > + return FALSE; > + } > + } else { > + return TRUE; > } >=20 > return TRUE; > diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c > b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c > index 7c7d182..b8160c1 100644 > --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c > +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.c > @@ -314,16 +314,22 @@ Ip4StationAddressValid ( >=20 > // > // Station address can't be subnet broadcast/net broadcast address > + // RFC3021: In a point-to-point network with 31-bit mask, the number> only has > + // 1 bit, only two possible addresses may result: > + // {, 0} and {, -1} > + // The two address above must be interpreted as host addresses. > // > - if ((Ip =3D=3D (Ip & Netmask)) || (Ip =3D=3D (Ip | ~Netmask))) { > - return FALSE; > - } > + if (Len !=3D 31) { > + if ((Ip =3D=3D (Ip & Netmask)) || (Ip =3D=3D (Ip | ~Netmask))) { > + return FALSE; > + } >=20 > - NetBrdcastMask =3D gIp4AllMasks[MIN (Len, Type << 3)]; > + NetBrdcastMask =3D gIp4AllMasks[MIN (Len, Type << 3)]; >=20 > - if (Ip =3D=3D (Ip | ~NetBrdcastMask)) { > - return FALSE; > + if (Ip =3D=3D (Ip | ~NetBrdcastMask)) { > + return FALSE; > + } > } >=20 > return TRUE; > -} > \ No newline at end of file > +} > -- > 1.9.5.msysgit.1