From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 2DA398194A for ; Sun, 8 Jan 2017 23:54:36 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 08 Jan 2017 23:54:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,339,1477983600"; d="scan'208";a="27894180" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 08 Jan 2017 23:54:32 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 8 Jan 2017 23:54:24 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Mon, 9 Jan 2017 15:54:20 +0800 From: "Wu, Jiaxin" To: "Zhang, Lubo" , "edk2-devel@lists.01.org" CC: Santhapur Naveen , "Ye, Ting" , "Fu, Siyuan" Thread-Topic: [patch] ShellPkg: Add check logic for the gateway validity. Thread-Index: AQHSZ/2Uz406yk2OS0KbQEgUKSJyTKEvyyBQ Date: Mon, 9 Jan 2017 07:54:20 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B727416292389@SHSMSX103.ccr.corp.intel.com> References: <1483694175-41876-1-git-send-email-lubo.zhang@intel.com> In-Reply-To: <1483694175-41876-1-git-send-email-lubo.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTQwOGI1ODktMDQyMC00NWM3LWE0ZGYtMjUwMjk4Zjg5ZmFhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Im0zNlwvWmlBQ1BuT1wvY1B2R1dCK2VzOXZpZ1ptTjZDVTdnZEFSeDFjZGoydz0ifQ== x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] ShellPkg: Add check logic for the gateway validity. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2017 07:54:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Wu Jiaxin > -----Original Message----- > From: Zhang, Lubo > Sent: Friday, January 6, 2017 5:16 PM > To: edk2-devel@lists.01.org > Cc: Santhapur Naveen ; Ye, Ting > ; Fu, Siyuan ; Wu, Jiaxin > > Subject: [patch] ShellPkg: Add check logic for the gateway validity. >=20 > if we set a static IP using command > 'ifconfig -s eth0 static 192.168.0.121 255.255.255.0 0.0.0.0' > The system says 'Failed to set address.' but using > 'ifconfig -l', the static IP can be assigned successfully. > so we need to check the gateway validity before setting manual > address to keep the ifconfig -s command more consistent. >=20 > Signed-off-by: Zhang Lubo > Cc: Santhapur Naveen > Cc: Ye Ting > Cc: Fu Siyuan > Cc: Wu Jiaxin > --- > .../Library/UefiShellNetwork1CommandsLib/Ifconfig.c | 19 > ++++++++++++++++++- > .../UefiShellNetwork1CommandsLib.uni | 3 ++- > 2 files changed, 20 insertions(+), 2 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > index 5e243d5..4db07b2 100644 > --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c > @@ -1,10 +1,10 @@ > /** @file > The implementation for Shell command ifconfig based on IP4Config2 > protocol. >=20 > (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
> - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
>=20 > This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at > http://opensource.org/licenses/bsd-license.php. > @@ -835,10 +835,12 @@ IfConfigSetInterfaceInfo ( >=20 > EFI_IP4_CONFIG2_POLICY Policy; > EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress; > UINTN DataSize; > EFI_IPv4_ADDRESS Gateway; > + IP4_ADDR SubnetMask; > + IP4_ADDR TempGateway; > EFI_IPv4_ADDRESS *Dns; > ARG_LIST *Tmp; > UINTN Index; >=20 > CONST CHAR16* TempString; > @@ -1017,10 +1019,25 @@ IfConfigSetInterfaceInfo ( > ShellStatus =3D SHELL_INVALID_PARAMETER; > goto ON_EXIT; > } >=20 > // > + // Need to check the gateway validity before set Manual Address. > + // In case we can set manual address but fail to configure Gateway= . > + // > + CopyMem (&SubnetMask, &ManualAddress.SubnetMask, sizeof > (IP4_ADDR)); > + CopyMem (&TempGateway, &Gateway, sizeof (IP4_ADDR)); > + SubnetMask =3D NTOHL (SubnetMask); > + TempGateway =3D NTOHL (TempGateway); > + if ((SubnetMask !=3D 0) && > + !NetIp4IsUnicast (TempGateway, SubnetMask)) { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN > (STR_IFCONFIG_INVALID_GATEWAY), gShellNetwork1HiiHandle, VarArg- > >Arg); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + goto ON_EXIT; > + } > + > + // > // Set manual config policy. > // > Policy =3D Ip4Config2PolicyStatic; > Status =3D IfCb->IfCfg->SetData ( > IfCb->IfCfg, > diff --git > a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > index 4566cd1..d9bbb20 100644 > --- > a/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > +++ > b/ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Com > mandsLib.uni > @@ -1,9 +1,9 @@ > // /** > // > // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
> -// Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. > +// Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. > // This program and the accompanying materials > // are licensed and made available under the terms and conditions of the > BSD License > // which accompanies this distribution. The full text of the license may= be > found at > // http://opensource.org/licenses/bsd-license.php > // > @@ -64,10 +64,11 @@ > #string STR_IFCONFIG_LACK_OPTION #language en-US "Flags = lack. > Please type 'ifConfig -?' for help info.\n" > #string STR_IFCONFIG_LACK_INTERFACE #language en-US "Lack > interface name.\n" > #string STR_IFCONFIG_LACK_COMMAND #language en-US "Lack > interface config option.\n" > #string STR_IFCONFIG_INVALID_INTERFACE #language en-US "Invali= d > interface name.\n" > #string STR_IFCONFIG_INVALID_IPADDRESS #language en-US "Invali= d > ipv4 address: '%H%s%N'\n" > +#string STR_IFCONFIG_INVALID_GATEWAY #language en-US "Invali= d > gateway address: '%H%s%N'\n" > #string STR_IFCONFIG_DUPLICATE_COMMAND #language en-US > "Duplicate commands. Bad command %H%s%N is skipped.\n" > #string STR_IFCONFIG_CONFLICT_COMMAND #language en-US > "Conflict commands. Bad command %H%s%N is skipped.\n" > #string STR_IFCONFIG_UNKNOWN_COMMAND #language en-US > "Unknown commands. Bad command %H%s%N is skipped.\n" > #string STR_IFCONFIG_SET_ADDR_FAILED #language en-US "Failed= to > set address.\n" > #string STR_IFCONFIG_ROUTES_SIZE #language en-US "\n%H > Routes (%d entries):\n" > -- > 1.9.5.msysgit.1