From: fanwang2 <fan.wang@intel.com>
To: edk2-devel@lists.01.org
Cc: Jiaxin Wu <jiaxin.wu@intel.com>, Ye Ting <ting.ye@intel.com>,
Fu Siyuan <siyuan.fu@intel.com>, Wang Fan <fan.wang@intel.com>
Subject: [Patch] MdeModulePkg: Add error handling when IP address is Class E
Date: Mon, 20 Nov 2017 14:31:13 +0800 [thread overview]
Message-ID: <1511159473-7968-1-git-send-email-fan.wang@intel.com> (raw)
The Dhcp4.TransmitReceive() API should be able to use at any time
according to UEFI spec. While in classless addressing network, the
netmask must be explicitly provided together with the station address.
But if the DHCP instance haven't be configured with a valid netmask,
we need compute it according to the classful addressing rule. In such
case, if the user configures with class E IP address, ASSERT will
happen, we need to handle this case and return error status code.
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
---
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index 1db4c66..65ea64e 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -1173,12 +1173,14 @@ EfiDhcp4Build (
Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instance.
@param[in] UdpIo The UdpIo being created.
@param[in] Context Dhcp4 instance.
- @retval EFI_SUCCESS UdpIo is configured successfully.
- @retval other Other error occurs.
+ @retval EFI_SUCCESS UdpIo is configured successfully.
+ @retval EFI_INVALID_PARAMETER Class E IP address is not supported or other parameters
+ are not valid.
+ @retval other Other error occurs.
**/
EFI_STATUS
EFIAPI
Dhcp4InstanceConfigUdpIo (
IN UDP_IO *UdpIo,
@@ -1216,11 +1218,25 @@ Dhcp4InstanceConfigUdpIo (
// provided together with the station address.
// If the DHCP instance haven't be configured with a valid netmask, we could only
// compute it according to the classful addressing rule.
//
Class = NetGetIpClass (ClientAddr);
+
+ //
+ // IP4_ADDR_CLASSA 1 // Deprecated
+ // IP4_ADDR_CLASSB 2 // Deprecated
+ // IP4_ADDR_CLASSC 3 // Deprecated
+ // IP4_ADDR_CLASSD 4
+ // IP4_ADDR_CLASSE 5
+ //
+ // Class E IP address is not supported here!
+ //
ASSERT (Class < IP4_ADDR_CLASSE);
+ if (Class == IP4_ADDR_CLASSE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
SubnetMask = gIp4AllMasks[Class << 3];
} else {
SubnetMask = DhcpSb->Netmask;
}
--
1.9.5.msysgit.1
reply other threads:[~2017-11-20 6:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511159473-7968-1-git-send-email-fan.wang@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox