Revision: 18245
http://sourceforge.net/p/edk2/code/18245
Author: jiaxinwu
Date: 2015-08-20 06:47:13 +0000 (Thu, 20 Aug 2015)
Log Message:
-----------
MdeModulePkg: Fix default router table and interface missing error
Ip4StartAutoConfig() will always free its default router table and interface,
which may cause IP instance missing its correct default interface. e.g. when
the policy is dhcp, and one child is configured to use default address.
Cc: Ye Ting <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <[email protected]>
Reviwed-by: Ye Ting <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
2015-08-20 06:45:19 UTC (rev 18244)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
2015-08-20 06:47:13 UTC (rev 18245)
@@ -149,6 +149,7 @@
// Start the dhcp configuration.
//
if (NewPolicy == Ip4Config2PolicyDhcp) {
+ IpSb->Reconfig = TRUE;
Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
}
@@ -463,7 +464,7 @@
/**
Set the station address and subnetmask for the default interface.
- @param[in] Instance The pointer to the IP4 config2 instance data.
+ @param[in] IpSb The pointer to the IP4 service binding
instance.
@param[in] StationAddress Ip address to be set.
@param[in] SubnetMask Subnet to be set.
@@ -473,13 +474,12 @@
**/
EFI_STATUS
Ip4Config2SetDefaultAddr (
- IN IP4_CONFIG2_INSTANCE *Instance,
+ IN IP4_SERVICE *IpSb,
IN IP4_ADDR StationAddress,
IN IP4_ADDR SubnetMask
)
{
EFI_STATUS Status;
- IP4_SERVICE *IpSb;
IP4_INTERFACE *IpIf;
IP4_PROTOCOL *Ip4Instance;
EFI_ARP_PROTOCOL *Arp;
@@ -487,7 +487,6 @@
IP4_ADDR Subnet;
IP4_ROUTE_TABLE *RouteTable;
- IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
IpIf = IpSb->DefaultInterface;
ASSERT (IpIf != NULL);
@@ -496,35 +495,37 @@
return EFI_SUCCESS;
}
- //
- // The default address is changed, free the previous interface first.
- //
- if (IpSb->DefaultRouteTable != NULL) {
- Ip4FreeRouteTable (IpSb->DefaultRouteTable);
- IpSb->DefaultRouteTable = NULL;
- }
+ if (IpSb->Reconfig) {
+ //
+ // The default address is changed, free the previous interface first.
+ //
+ if (IpSb->DefaultRouteTable != NULL) {
+ Ip4FreeRouteTable (IpSb->DefaultRouteTable);
+ IpSb->DefaultRouteTable = NULL;
+ }
- Ip4CancelReceive (IpSb->DefaultInterface);
- Ip4FreeInterface (IpSb->DefaultInterface, NULL);
- IpSb->DefaultInterface = NULL;
- //
- // Create new default interface and route table.
- //
- IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
- if (IpIf == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
+ Ip4CancelReceive (IpSb->DefaultInterface);
+ Ip4FreeInterface (IpSb->DefaultInterface, NULL);
+ IpSb->DefaultInterface = NULL;
+ //
+ // Create new default interface and route table.
+ //
+ IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
+ if (IpIf == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
- RouteTable = Ip4CreateRouteTable ();
- if (RouteTable == NULL) {
- Ip4FreeInterface (IpIf, NULL);
- return EFI_OUT_OF_RESOURCES;
+ RouteTable = Ip4CreateRouteTable ();
+ if (RouteTable == NULL) {
+ Ip4FreeInterface (IpIf, NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ IpSb->DefaultInterface = IpIf;
+ InsertHeadList (&IpSb->Interfaces, &IpIf->Link);
+ IpSb->DefaultRouteTable = RouteTable;
+ Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
}
-
- IpSb->DefaultInterface = IpIf;
- InsertHeadList (&IpSb->Interfaces, &IpIf->Link);
- IpSb->DefaultRouteTable = RouteTable;
- Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
if (IpSb->State == IP4_SERVICE_CONFIGED) {
IpSb->State = IP4_SERVICE_UNSTARTED;
@@ -578,6 +579,8 @@
);
IpSb->State = IP4_SERVICE_CONFIGED;
+ IpSb->Reconfig = FALSE;
+
return EFI_SUCCESS;
}
@@ -604,7 +607,9 @@
EFI_STATUS Status;
IP4_SERVICE *IpSb;
- Status = Ip4Config2SetDefaultAddr (Instance, StationAddress, SubnetMask);
+ IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
+
+ Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -612,7 +617,6 @@
//
// Create a route if there is a default router.
//
- IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
if (GatewayAddress != IP4_ALLZERO_ADDRESS) {
Ip4AddRoute (
IpSb->DefaultRouteTable,
@@ -1071,7 +1075,10 @@
IP4_ADDR StationAddress;
IP4_ADDR SubnetMask;
VOID *Ptr;
+ IP4_SERVICE *IpSb;
+ IpSb = IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE (Instance);
+
ASSERT (Instance->DataItem[Ip4Config2DataTypeManualAddress].Status !=
EFI_NOT_READY);
if (((DataSize % sizeof (EFI_IP4_CONFIG2_MANUAL_ADDRESS)) != 0) || (DataSize
== 0)) {
@@ -1105,7 +1112,8 @@
StationAddress = EFI_NTOHL (NewAddress.Address);
SubnetMask = EFI_NTOHL (NewAddress.SubnetMask);
- Status = Ip4Config2SetDefaultAddr (Instance, StationAddress, SubnetMask);
+ IpSb->Reconfig = TRUE;
+ Status = Ip4Config2SetDefaultAddr (IpSb, StationAddress, SubnetMask);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
2015-08-20 06:45:19 UTC (rev 18244)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Driver.c
2015-08-20 06:47:13 UTC (rev 18245)
@@ -211,6 +211,8 @@
IpSb->Timer = NULL;
IpSb->ReconfigEvent = NULL;
+
+ IpSb->Reconfig = FALSE;
IpSb->MediaPresent = TRUE;
@@ -396,6 +398,8 @@
IpSb->ReconfigEvent = NULL;
}
+ IpSb->Reconfig = FALSE;
+
if (IpSb->MacString != NULL) {
FreePool (IpSb->MacString);
}
Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 2015-08-20
06:45:19 UTC (rev 18244)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c 2015-08-20
06:47:13 UTC (rev 18245)
@@ -584,6 +584,8 @@
if (IpSb->State > IP4_SERVICE_UNSTARTED) {
IpSb->State = IP4_SERVICE_UNSTARTED;
}
+
+ IpSb->Reconfig = TRUE;
Ip4StartAutoConfig (&IpSb->Ip4Config2Instance);
Modified: trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h 2015-08-20
06:45:19 UTC (rev 18244)
+++ trunk/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h 2015-08-20
06:47:13 UTC (rev 18245)
@@ -205,6 +205,8 @@
EFI_EVENT ReconfigEvent;
+ BOOLEAN Reconfig;
+
//
// Underlying media present status.
//
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits