]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
MdeModulePkg/Ip4Dxe: Ignore duplicated DNS address check
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Config2Impl.c
index d868957896e6ec6e691cf3efc1ee392b63563814..6c7ac68791c3c3e638731c1d723d6f047496d679 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of EFI IPv4 Configuration II Protocol.\r
 \r
-  Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   This program and the accompanying materials\r
@@ -705,7 +705,6 @@ Ip4Config2SetDnsServerWorker (
 {\r
   UINTN                 OldIndex;\r
   UINTN                 NewIndex;\r
-  UINTN                 Index1;\r
   EFI_IPv4_ADDRESS      *OldDns;\r
   EFI_IPv4_ADDRESS      *NewDns;\r
   UINTN                 OldDnsCount;\r
@@ -737,20 +736,14 @@ Ip4Config2SetDnsServerWorker (
 \r
   for (NewIndex = 0; NewIndex < NewDnsCount; NewIndex++) {\r
     CopyMem (&DnsAddress, NewDns + NewIndex, sizeof (IP4_ADDR));\r
-\r
-    if (!NetIp4IsUnicast (NTOHL (DnsAddress), 0)) {\r
+    if (IP4_IS_UNSPECIFIED (NTOHL (DnsAddress)) || IP4_IS_LOCAL_BROADCAST (NTOHL (DnsAddress))) {\r
       //\r
       // The dns server address must be unicast.\r
       //\r
-      FreePool (Tmp);\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    for (Index1 = NewIndex + 1; Index1 < NewDnsCount; Index1++) {\r
-      if (EFI_IP4_EQUAL (NewDns + NewIndex, NewDns + Index1)) {\r
+      if (Tmp != NULL) {\r
         FreePool (Tmp);\r
-        return EFI_INVALID_PARAMETER;\r
       }\r
+      return EFI_INVALID_PARAMETER;\r
     }\r
 \r
     if (OneAdded) {\r
@@ -1256,6 +1249,13 @@ Ip4Config2SetMaunualAddress (
 \r
   NewAddress = *((EFI_IP4_CONFIG2_MANUAL_ADDRESS *) Data);\r
 \r
+  StationAddress = EFI_NTOHL (NewAddress.Address);\r
+  SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);\r
+\r
+  if (NetGetMaskLength (SubnetMask) == IP4_MASK_NUM) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   //\r
   // Store the new data, and init the DataItem status to EFI_NOT_READY because\r
   // we may have an asynchronous configuration process.\r
@@ -1274,26 +1274,19 @@ Ip4Config2SetMaunualAddress (
   DataItem->DataSize = DataSize;\r
   DataItem->Status   = EFI_NOT_READY;\r
 \r
-  StationAddress = EFI_NTOHL (NewAddress.Address);\r
-  SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);\r
-\r
   IpSb->Reconfig = TRUE;\r
   Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);\r
-  if (EFI_ERROR (Status)) {\r
-    goto ON_EXIT;\r
-  }  \r
 \r
-  DataItem->Status = EFI_SUCCESS;   \r
+  DataItem->Status = Status; \r
 \r
-ON_EXIT:\r
-  if (EFI_ERROR (DataItem->Status)) {\r
+  if (EFI_ERROR (DataItem->Status) && DataItem->Status != EFI_NOT_READY) {\r
     if (Ptr != NULL) {\r
       FreePool (Ptr);\r
     }\r
     DataItem->Data.Ptr = NULL; \r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -1347,14 +1340,15 @@ Ip4Config2SetGateway (
     return EFI_WRITE_PROTECTED;\r
   }\r
 \r
+  IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
 \r
   NewGateway      = (EFI_IPv4_ADDRESS *) Data;\r
   NewGatewayCount = DataSize / sizeof (EFI_IPv4_ADDRESS);\r
   for (Index1 = 0; Index1 < NewGatewayCount; Index1++) {\r
     CopyMem (&Gateway, NewGateway + Index1, sizeof (IP4_ADDR));\r
-    \r
-    if (!NetIp4IsUnicast (NTOHL (Gateway), 0)) {\r
 \r
+    if ((IpSb->DefaultInterface->SubnetMask != 0) && \r
+        !NetIp4IsUnicast (NTOHL (Gateway), IpSb->DefaultInterface->SubnetMask)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
@@ -1365,7 +1359,6 @@ Ip4Config2SetGateway (
     }\r
   }\r
  \r
-  IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);\r
   DataItem = &Instance->DataItem[Ip4Config2DataTypeGateway];\r
   OldGateway      = DataItem->Data.Gateway;\r
   OldGatewayCount = DataItem->DataSize / sizeof (EFI_IPv4_ADDRESS);\r
@@ -1489,11 +1482,12 @@ Ip4Config2InitIfInfo (
   OUT EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo\r
   )\r
 {\r
-  IfInfo->Name[0] = L'e';\r
-  IfInfo->Name[1] = L't';\r
-  IfInfo->Name[2] = L'h';\r
-  IfInfo->Name[3] = (CHAR16) (L'0' + IpSb->Ip4Config2Instance.IfIndex);\r
-  IfInfo->Name[4] = 0;\r
+  UnicodeSPrint (\r
+    IfInfo->Name,\r
+    EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE,\r
+    L"eth%d",\r
+    IpSb->Ip4Config2Instance.IfIndex\r
+  );\r
 \r
   IfInfo->IfType        = IpSb->SnpMode.IfType;\r
   IfInfo->HwAddressSize = IpSb->SnpMode.HwAddressSize;\r