[syslinux] [PATCH] efi: reuse UDP port with sendto

Celelibi celelibi at gmail.com
Thu Nov 28 19:24:13 PST 2013


2013/11/29, Gene Cumm <gene.cumm at gmail.com>:
> On Thu, Nov 28, 2013 at 9:47 PM, Gene Cumm <gene.cumm at gmail.com> wrote:
>> On Thu, Nov 28, 2013 at 9:34 PM, Celelibi <celelibi at gmail.com> wrote:
>>> Without an assigned source port, Transmit function assign a random new
>>> source port to the packet being sent. It thus have to be set before
>>> calling Transmit if the source port have already been decided.
>>> Conversly, we have to save the assigned port to reuse it later if
>>> needed.
>>>
>>> Resolve bug #35.
>>>
>>> Signed-off-by: Celelibi <celelibi at gmail.com>
>>> ---
>>>  efi/udp.c | 18 ++++++++++++++++++
>>>  1 file changed, 18 insertions(+)
>>>
>>> diff --git a/efi/udp.c b/efi/udp.c
>>> index 59bb426..7271f1f 100644
>>> --- a/efi/udp.c
>>> +++ b/efi/udp.c
>>> @@ -336,6 +336,9 @@ void core_udp_sendto(struct pxe_pvt_inode *socket,
>>> const void *data,
>>>
>>>      memset(&udata, 0, sizeof(udata));
>>>
>>> +    /* Re-use the existing local port number if any */
>>> +    udata.StationPort = socket->net.efi.localport;
>>> +
>>
>> As HPA noted, this shouldn't be saved here.  Commit 7ec052b on my
>> branch efi-fixes (will be renamed to efi-fixes-for-mfleming once Jason
>> gives more feedback).
>
> To clarify, this code-quote reuses (needed) while the removed one
> saves and should be in core_udp_open().  Perhaps a fallback-save in
> here if the local port is somehow still NULL.
>

If I understand the behavior of UEFI UDP network stack, the local port
choice is made by the firmware only on a call to Transmit. Thus
core_udp_open can't chose the local port, or if it does, it's a
"manual" choice, not a choice from the firmware itself.

As I proposed in the discussion with Jason, the only ways to solve
this bug is either to wait for a call to Transmit to chose a port, or
to chose a port "by hand" in core_udp_open.
This patch I propose implements the first solution.


More information about the Syslinux mailing list