Commit Graph

111 Commits

Author SHA1 Message Date
Laszlo Ersek 3f55418d53 NetworkPkg/UefiPxeBcDxe: handle competing DHCP servers (more) gracefully
When DHCP is misconfigured on a network segment, such that two DHCP
servers attempt to reply to requests (and therefore race with each other),
the edk2 PXE client can confuse itself.

In PxeBcDhcp4BootInfo() / PxeBcDhcp6BootInfo(), the client may refer to a
DHCP reply packet as an "earlier" packet from the "same" DHCP server, when
in reality both packets are unrelated, and arrive from different DHCP
servers.

While the edk2 PXE client can do nothing to fix this, it should at least
not ASSERT() -- ASSERT() is for catching programming errors (violations of
invariants that are under the control of the programmer). ASSERT()s should
in particular not refer to external data (such as network packets). What's
more, in RELEASE builds, we get NULL pointer references.

Check the problem conditions with actual "if"s, and return
EFI_PROTOCOL_ERROR. This will trickle out to PxeBcLoadBootFile(), and be
reported as "PXE-E99: Unexpected network error".

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200331004749.16128-1-lersek@redhat.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
2020-04-01 14:12:09 +00:00
Antoine Coeur 5add2c5577 NetworkPkg/UefiPxeBcDxe: Fix various typos
Fix various typos in comments and documentation.
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Maciej Rabeda <maciej.rabeda@intel.com>
Signed-off-by: Antoine Coeur <coeur@gmx.fr>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@intel.com>
Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
Message-Id: <20200207010831.9046-53-philmd@redhat.com>
2020-02-10 22:30:07 +00:00
Liming Gao 0b73027eb1 NetworkPkg: Remove unnecessary MdeModulePkg/MdeModulePkg.dec dependency in INF
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
2019-10-08 09:20:34 +08:00
Liming Gao 047ede3199 NetworkPkg UefiPxeBcDxe: Consume PcdTftpBlockSize defined in NetworkPkg.dec
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2195

Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
2019-10-08 09:20:33 +08:00
Xue, ShengfengX b29e6365c3 NetworkPkg/UefiPxeBcDxe:Add two PCD to control PXE.
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1695

Setup need provide an item for user to control IPV46 PXE boot.
Origin UefiPxeBcDxe driver doesn't have such interface.
This change added two PCD to control IPV4/6 PXE in PxeBcSupported().
Platform code should override this two PCD according to Setup value.
code change no side effect on current PXE function with default PCD.

Signed-off-by: Xue ShengfengX <shengfengx.xue@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
2019-04-22 09:14:45 +08:00
Michael D Kinney ecf98fbcf8 NetworkPkg: Replace BSD License with BSD+Patent License
https://bugzilla.tianocore.org/show_bug.cgi?id=1373

Replace BSD 2-Clause License with BSD+Patent License.  This change is
based on the following emails:

  https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html
  https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html

RFCs with detailed process for the license change:

  V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html
  V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html
  V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
2019-04-09 10:58:15 -07:00
Ashish Singhal 22b35e8bd1 NetworkPkg: Protocol Uninstallation Cleanup
Use UEFILib provided protocol uninstallation abstraction
instead of direct API for a proper cleanup.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1444

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2019-01-14 13:12:17 +08:00
Siyuan Fu a1b7461db3 NetworkPkg: Remove some clarification from UefiPxeBcDxe.inf
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1278

This patch is to remove the clarification about usage/difference between
those drivers in MdeModulePkg and NetworkPkg, since the MdeModulePkg one
have been deleted.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-12-24 15:10:14 +08:00
Jiaxin Wu ddc6d41d12 NetworkPkg: Correct the time stamp and fix the integer overflow issue.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=883.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
2018-10-22 09:04:56 +08:00
Jiaxin Wu e8601e972f NetworkPkg/UefiPxeBcDxe: Correct comments to align with the input parameter.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1230

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Bi Dandan <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2018-10-09 08:43:35 +08:00
Jiaxin Wu 24c55f5dcc NetworkPkg/UefiPxeBcDxe: Add the clarification compared to UefiPxeBcDxe in MdeModulePkg.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1205

This patch is to add the driver usage/difference clarification
compared to UefiPxeBcDxe in MdeModulePkg.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2018-09-27 09:00:07 +08:00
Jiaxin Wu 160b082e64 NetworkPkg/UefiPxeBcDxe: Use the specified MTFTP windowsize.
*v2: Since the new PCD (PcdPxeTftpWindowSize) was renamed/defined in
NetworkPkg instead of MdeModulePkg, this new version is to update the
consuming PXE driver.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=886

This patch is to use the specified MTFTP windowsize to benefit the PXE
download performance.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Shao Ming <ming.shao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
2018-09-27 09:00:02 +08:00
edk2-devel-bounces@lists.01.org cde5a72d36 NetworkPkg: UefiPxeBcDxe: Add EXCLUSIVE attribute when opening SNP protocol installed by PXE.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1152

v2: Sync the same logic to Ipv6 and update code comments.

The PXE driver installs a SNP and open this SNP with attribute BY_DRIVER
to avoid it being opened by MNP driver, this SNP is also expected not to
be opened by other drivers with EXCLUSIVE attribute. In some cases, other
drivers may happen to do this by error, and thus cause a system crash.
This patch adds EXCLUSIVE attribute when opening SNP in PXE driver, and
will reject all OpenProtocol requests by EXCLUSIVE.

Cc: Subramanian, Sriram <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2018-09-17 14:32:35 +08:00
Songpeng Li b701aae6a8 NetworkPkg: UefiPxeBcDxe: Remove the redundant code.
The function PxeBcFreeBootFileOption that is never called
have been removed.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1064
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Songpeng Li <songpeng.li@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-08-23 16:30:47 +08:00
chenc2 4fcb0d5458 NetworkPkg: Removing ipf which is no longer supported from edk2.
Removing rules for Ipf sources file:
* Remove the source file which path with "ipf" and also listed in
  [Sources.IPF] section of INF file.
* Remove the source file which listed in [Components.IPF] section
  of DSC file and not listed in any other [Components] section.
* Remove the embedded Ipf code for MDE_CPU_IPF.

Removing rules for Inf file:
* Remove IPF from VALID_ARCHITECTURES comments.
* Remove DXE_SAL_DRIVER from LIBRARY_CLASS in [Defines] section.
* Remove the INF which only listed in [Components.IPF] section in DSC.
* Remove statements from [BuildOptions] that provide IPF specific flags.
* Remove any IPF sepcific sections.

Removing rules for Dec file:
* Remove [Includes.IPF] section from Dec.

Removing rules for Dsc file:
* Remove IPF from SUPPORTED_ARCHITECTURES in [Defines] section of DSC.
* Remove any IPF specific sections.
* Remove statements from [BuildOptions] that provide IPF specific flags.

Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2018-08-14 08:58:30 +08:00
Liming Gao f75a7f568e NetworkPkg: Clean up source files
1. Do not use tab characters
2. No trailing white space in one line
3. All files must end with CRLF

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
2018-06-28 11:19:49 +08:00
Jiaxin Wu 2f1b849dc8 NetworkPkg/UefiPxeBcDxe: Configure the ARP Instance/RouteTable with new address
After completed a DHCP D.O.R.A process and got the new address, the ARP Instance
and RouteTable should be configured so as to avoid the later Pxe.Arp failure.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2018-03-22 08:25:20 +08:00
Fu Siyuan ccd05ddd50 NetworkPkg: Add warning message for PXE if failed to read system GUID from SMBIOS.
Current PXE driver uses zero GUID if failed to get the system GUID from smbios
table, and some OS PXE boot may fail in such case. This patch is to add a warning
message to inform user that smbios table is missed on the platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
2018-02-05 13:38:40 +08:00
Fu Siyuan cf9ff46b08 NetworkPkg: Fix incorrect parameter check in PXE.Mtftp() function.
According to UEFI spec, the PXE.Mtftp() should return invalid parameter if the
BufferPtr parameter was NULL and the DontUseBuffer parameter was FALSE.
The DontUseBuffer is only used when perform MTFTP/TFTP read operation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-15 18:02:01 +08:00
Fu Siyuan bee14e9ebc NetworkPkg: Update PXE driver to check for NULL pointer before use it.
This patch is to fix the issue that dereferencing of "This" (EFI_LOAD_FILE_PROTOCOL)
in EfiPxeLoadFile() is happening before the NULL check.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:07:48 +08:00
Fu Siyuan 9d1c98e699 NetworkPkg: Add assert for buffer pointer from DHCP driver.
The PxeBcDhcp4CallBack() is provided for DHCP driver to invoke packet check
during DHCP process, the DHCP driver should make sure Packet and NewPacket
has meaningful value. This patch adds assert for this.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:07:40 +08:00
Fu Siyuan 2fad330f6b NetworkPkg: Fix memory leak problem in PXE driver.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:07:32 +08:00
Fu Siyuan 9f4f29cbee NetworkPkg: Check allocated buffer pointer before use.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:07:23 +08:00
Fu Siyuan 6a4eed9bad NetworkPkg: Abort the PXE process if DHCP has been started by other instance.
PXE need to use extended DHCP options and check received offers in callback
function, so there is no need to continue the PXE process if DHCP driver has
been started by other instance but not PXE driver itself.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2018-01-04 09:07:16 +08:00
Fu Siyuan 3c06e6a9e2 NetworkPkg: Recycle the ICMP error message in PXE driver.
This patch updates PxeBcIcmpErrorDpcHandle() and PxeBcIcmp6ErrorDpcHandle() to
recycle the ICMP packet after copy it to PXE mode data.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2017-12-22 15:36:32 +08:00
Fu Siyuan 673abfb749 NetworkPkg: Remove redundant check in PXE driver.
The IP protocol has been configured to only receive ICMP packet in PXE driver.
So this patch removes the unnecessary check for NextHeader field and replace it
with ASSERT.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2017-12-22 15:34:19 +08:00
fanwang2 152f2d5e45 NetworkPkg: Update Api from NetLibDetectMedia to NetLibDetectMediaWaitTimeout.
Since new Api NetLibDetectMediaWaitTimeout was involved to support connecting
state handling, and it is forward compatible. So apply this Api in NetworkPkg.

V2:
   *Define time period in a macro instead of hard code.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Signed-off-by: fanwang2 <fan.wang@intel.com>
2017-12-18 16:38:24 +08:00
Jiaxin Wu f8e13a24b7 NetworkPkg/UefiPxeBcDxe: Allow the NULL configuration for NewStationIP/NewSubnetMask
According the UEFI Spec for PxeBc.SetStationIP():
If NewStationIP is NULL, then the current IP address will not be modified.
...
If NewSubnetMask is NULL, then the current subnet mask will not be modified.

Currently, EfiPxeBcSetStationIP() doesn't comply with UEFI Spec. This patch is
to fix the issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2017-12-15 08:47:04 +08:00
Jiaxin Wu 09cddd088c NetworkPkg/UefiPxeBcDxe: Correct the handle for PXE Base Code Callback Protocol.
According UEFI Spec:
The PXE Base Code Callback Protocol must be on the same handle as the PXE
Base Code Protocol.

But current implementation doesn't follow that. This patch is fix that issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2017-12-15 08:46:46 +08:00
Jiaxin Wu 10e6244236 NetworkPkg/UefiPxeBcDxe: Fix Pxe.Dhcp() return status code.
According UEFI Spec, if valid PXE offer is not received, Pxe.Dhcp()
should return EFI_NO_RESPONSE, but currently, EFI_TIMEOUT is returned
from Pxe.Dhcp().

This patch is to fix the above issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2017-12-15 08:46:31 +08:00
Jiaxin Wu 69cc013ca5 NetworkPkg/UefiPxeBcDxe: Fix the redundant condition check
Cc: Santhapur Naveen <naveens@amiindia.co.in>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
2017-09-29 09:01:29 +08:00
Jiaxin Wu be37315a08 NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer received.
In case of the DHCP and PXE services on different servers,PXEv6 boot will
failure when DhcpBinl offer received. The issue is caused by the following
reasons:
* PXE Client doesn't append VENDOR_CLASS request parameter, so the
offer replied from DHCP service will not contain VENDOR_CLASS option
(16).
* Once the DhcpBinl offer is selected, the boot discover message should
be sent out to request the bootfile by this offer. Current implementation
always use servers multi-cast address instead of BootFileUrl address in
dhcp6 offer. we should check it first, then decide whether use multi-cast
address or not.
* If DhcpBinl offer is selected, the boot discover message shouldn't
find server ID Option from DhcpBinl offer. That's incorrect because DHCP
service and PXE service on different servers. In such a case, we can ignore
the Server ID Option.

With the above fix in the patch, PXEv6 can boot successfully when DhcpBinl
offer received.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
2017-05-03 11:28:44 +08:00
Jiaxin Wu 8cdd559be6 NetworkPkg: Correct the proxy DHCP offer handing
When PXE10/WFM11a offer received, we should only cache
the first PXE10/WFM11a offer, and discard the others. But
Current we discard all PXE10/WFM11a offer. This patch is
to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
2017-04-21 13:04:53 +08:00
Jiaxin Wu ba0252808b NetworkPkg: Fix potential ASSERT if NetIp4IsUnicast is called
Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Cc: Subramanian Sriram <sriram-s@hpe.com>
Cc: Zhang Lubo <lubo.zhang@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: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
2017-03-23 11:39:31 +08:00
Hao Wu ce5c3273c3 NetworkPkg: Refine casting expression result to bigger size
There are cases that the operands of an expression are all with rank less
than UINT64/INT64 and the result of the expression is explicitly cast to
UINT64/INT64 to fit the target size.

An example will be:
UINT32 a,b;
// a and b can be any unsigned int type with rank less than UINT64, like
// UINT8, UINT16, etc.
UINT64 c;
c = (UINT64) (a + b);

Some static code checkers may warn that the expression result might
overflow within the rank of "int" (integer promotions) and the result is
then cast to a bigger size.

The commit refines codes by the following rules:
1). When the expression is possible to overflow the range of unsigned int/
int:
c = (UINT64)a + b;

2). When the expression will not overflow within the rank of "int", remove
the explicit type casts:
c = a + b;

3). When the expression will be cast to pointer of possible greater size:
UINT32 a,b;
VOID *c;
c = (VOID *)(UINTN)(a + b); --> c = (VOID *)((UINTN)a + b);

4). When one side of a comparison expression contains only operands with
rank less than UINT32:
UINT8 a;
UINT16 b;
UINTN c;
if ((UINTN)(a + b) > c) {...} --> if (((UINT32)a + b) > c) {...}

For rule 4), if we remove the 'UINTN' type cast like:
if (a + b > c) {...}
The VS compiler will complain with warning C4018 (signed/unsigned
mismatch, level 3 warning) due to promoting 'a + b' to type 'int'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2017-03-06 14:33:23 +08:00
Hao Wu 413535bb33 NetworkPkg: Refine UintnToAscDecWithFormat functions logic
This commit refines the logic for HttpBootUintnToAscDecWithFormat and
PxeBcUintnToAscDecWithFormat. It avoids using the decrement operator '--'
for array index to prevent possible mis-reports by static code checkers.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2016-12-22 16:17:22 +08:00
Fu Siyuan a35dc6499b NetworkPkg: Replace ASSERT with error return code in PXE and HTTP boot driver.
This patch remove the ASSERT when receive a DHCP packet large than the maximum
cache buffer size.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2016-12-19 08:54:18 +08:00
Fu Siyuan 632dcfd685 NetworkPkg: Check for the max DHCP packet length before use it.
This patch updates the PXE and HTTP boot driver to drop the input DHCP packet
if it exceed the maximum length.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>
2016-11-18 16:30:50 +08:00
Fu Siyuan b340056060 NetworkPkg: Check for NULL pointer before dereference it.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2016-10-31 16:04:02 +08:00
Zhang Lubo 92ec8772df NetworkPkg: Add error handling logic when using AllocateZeroPool
Add error handling logic if failed to apply new memory.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-By: Fu Siyuan <siyuan.fu@intel.com>
2016-10-31 10:07:31 +08:00
Fu Siyuan 6c12fe63f9 NetworkPkg: Update IP4 stack drivers for classless address unicast check.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2016-10-28 14:20:25 +08:00
Zhang Lubo 6692d51954 NetworkPkg: Add dns support for pxe boot based on IPv6.
The BootFileURL option (59) in dhcpv6 is used to deliver
the next server address with bootfile name, as an example
"tftp://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]/BOOTFILE_NAME;
mode=octet", it can also be “tftp://domain_name/BOOTFILE_NAME;
mode=octet”, this patch is to support this case.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2016-10-26 16:42:35 +08:00
Hao Wu b4815479d6 NetworkPkg UefiPxeBcDxe: Fix build error for lastest VS2015 compiler
The UefiPxeBcDxe module encounters a build error for IA32 arch using the
latest version of VS2015:

UefiPxeBcDxe.lib(PxeBcBoot.obj) : error LNK2001: unresolved external
symbol __allmul

The cause is line 148 in file NetworkPkg\UefiPxeBcDxe\PxeBcBoot.c. The
third parameter for gBS->SetTimer() function is of type UINT64, so the
multiplication should use the MultU64x32() function now.

Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-07-26 13:44:01 +08:00
Fu Siyuan e895641ba9 NetworkPkg: Update PXE driver to follow edk2 coding standards.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Samer El-Haj-Mahmoud <smahmoud@lenovo.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
2016-07-12 08:50:36 +08:00
Zhang Lubo 142c00c3d6 NetworkPkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.
v2:
*Since we have redefined the name of arch types in Dhcp.h for http boot,
it need to change corresponding codes.

Add a new head file Dhcp.h in Mde/Include/IndustryStandard, normalize the
universal option numbers and other network number tags.

Cc: Sriram Subramanian <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2016-06-23 09:39:38 +08:00
Fu Siyuan aa437778fc NetworkPkg: Ignore BootFileName if it is overloaded.
Make sure "File" field is not overloaded to carry other DHCP options before use
it in PXE driver.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
2016-05-06 11:42:24 +08:00
Fu Siyuan 6f2f4116eb NetworkPkg: Do not use hard coded TTL/ToS in PXE driver.
EFI_PXE_BASE_CODE_PROTOCOL has interface to set the TTL and ToS value, but
not used by the UdpWrite() interface. The code always use a hard coded 16
for the TTL and 0 for ToS.
This patch update the UpdWrite() to use the TTL and ToS which have been set
by the SetParameters().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-By: Samer El-Haj-Mahmoud <elhaj@hpe.com>
2016-05-05 09:08:24 +08:00
Samer El-Haj-Mahmoud 93aea44f42 NetworkPkg: Reword PXE download message
Fix a minor grammatical error in the PXE boot message.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
2016-02-14 10:18:54 +08:00
Zhang Lubo bec55c33c7 NetworkPkg: Fix suspicious dereference of pointer 'Mode.Ia'
This patch is used to fix suspicious dereference of pointer 'Mode.Ia'
before NULL check.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
2016-02-03 11:43:19 +08:00
Zhang Lubo ce22514e48 NetworkPkg:Fix Network memory leak when calling GetModeData interface
Multiple network protocols have a GetModeData() interface, which may
allocate memory resource in the return mode data structure. It's
callers responsibility to free these buffers.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19758 6f19259b-4bc3-4df7-8a09-765794883524
2016-01-28 02:32:43 +00:00