From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ml01.01.org (Postfix) with ESMTP id C9C541A1E0F for ; Mon, 15 Aug 2016 18:27:50 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 15 Aug 2016 18:27:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,527,1464678000"; d="scan'208";a="749172198" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 15 Aug 2016 18:27:50 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 15 Aug 2016 18:27:50 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.181]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.8]) with mapi id 14.03.0248.002; Tue, 16 Aug 2016 09:27:47 +0800 From: "Wu, Jiaxin" To: "Cohen, Eugene" , "edk2-devel@lists.01.org" Thread-Topic: IP4 Config Troubles with DHCP Thread-Index: AdHzLtnEw2gfDCBbQ1OtxXknLLKMhQAabX6gANlk4IAAFmGWYA== Date: Tue, 16 Aug 2016 01:27:47 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274137C7C7A@SHSMSX103.ccr.corp.intel.com> References: <895558F6EA4E3B41AC93A00D163B7274137C5EF1@SHSMSX103.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: IP4 Config Troubles with DHCP 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: Tue, 16 Aug 2016 01:27:51 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > > Actually, you don't need to retry the UDP configuration loop according > > the Ip4Mode.IsConfigured flag. You are only recommended to set a timer > > to check the mapping status after the configuration: > > > > For example: > > Status =3D Nlc->Udp4->Configure(Nlc->Udp4, &Nlc->UdpConfig); > > if (EFI_ERROR (Status) && (Status !=3D EFI_NO_MAPPING)) { > > return Status; > > } > > if (Status =3D=3D EFI_NO_MAPPING && !UdpGetMapping (Nlc->Udp4)) { > > return Status; > > } > > > > In UdpGetMapping () function, create one timer to check > > Ip4Mode.IsConfigured: > > > > For example: > > UdpGetMapping () { > > IsMapDone =3D FALSE; > > gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, > > &TimeoutEvent); > > gBS->SetTimer (TimeoutEvent, TimerRelative, AnyValue); > > while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) { > > Udp4->Poll (Udp4); > > Udp4->GetModeData (Udp4, &Udp4Mode, & Ip4Mode, NULL, NULL); > > if (Ip4Mode.IsConfigured) { > > IsMapDone =3D TRUE; > > break; > > } > > } > > return IsMapDone; > > } > > > > If DHCP process succeed, Ip4Mode.IsConfigured should be updated. If > > not, any bug may be existed. >=20 > In testing the new patch (removing RECONFIG=3DTRUE) I see that the > statement you made above is not accurate when the protocol is TCP. When > Configure is called the first time it returns EFI_NO_MAPPING. This seems= to > be remembered in the socket state: ((Sock)->ConfigureState =3D=3D > SO_NO_MAPPING) so that any attempt to use the instance after > Ip4Mode.IsConfigured goes TRUE fails (like for a TCP4 Listen). >=20 > So for TCP we must issue another Configure request to clean up this state= so > it's not as simple as just polling the GetModeData result, at least for T= CP. Yeah. When I was drafting the UDP APP to test the new fix, I found the same= case you mentioned. We must issue another UDP Configure () to clean the pr= evious state once the Ip4Mode.IsConfigured is TRUE. So, the above example = is not accurate with my the current implementation:(. But I'm still not rec= ommend to loop the UDP configuration every time if Ip4Mode.IsConfigured is = false. The right behavior for UDP/TCP is 1) timer check the Ip4Mode.IsConfi= gured, 2) Once Ip4Mode.IsConfigured is TRUE, reconfigure the instance again= . Sorry for the above example was troubling you. Also use UDP as example, c= orrect as below: Udata.UseDefaultAddress =3D TRUE; Status =3D Udp4->Configure (Udp4, &Udata); if (EFI_ERROR (Status) && (Status !=3D EFI_NO_MAPPING)) { return Status; } if ((Status =3D=3D EFI_NO_MAPPING) && !UdpGetMapping (Udp4, &Udata)) { return Status; } In UdpGetMapping () function: BOOLEAN UdpGetMapping ( IN EFI_UDP4_PROTOCOL *Udp4, IN EFI_UDP4_CONFIG_DATA *UdpCfgData ) { EFI_STATUS Status; EFI_EVENT TimeoutEvent; EFI_IP4_MODE_DATA Ip4ModeData; BOOLEAN IsMapDone; IsMapDone =3D FALSE; ZeroMem (&Ip4ModeData, sizeof (EFI_IP4_MODE_DATA)); Status =3D gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timeou= tEvent); if (EFI_ERROR (Status)) { return IsMapDone; } // // Start the timer, it will timeout after 5 seconds. // gBS->SetTimer (TimeoutEvent, TimerRelative, 500000000); while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) { Udp4->Poll (Udp4); if (!EFI_ERROR (Udp4->GetModeData (Udp4, NULL, &Ip4ModeData, NULL, NULL= )) && Ip4ModeData.IsConfigured) { Udp4->Configure (Udp4, NULL); IsMapDone =3D (BOOLEAN) (Udp4->Configure (Udp4, UdpCfgData) =3D=3D EF= I_SUCCESS); break; } } gBS->CloseEvent (TimeoutEvent); return IsMapDone; } >=20 > Do you believe this is expected behavior? >=20 > Thanks, >=20 > Eugene >=20