lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] Desiderata for 2.2.0 for debian and virtualsquare


From: Simon Goldschmidt
Subject: Re: [lwip-devel] Desiderata for 2.2.0 for debian and virtualsquare
Date: Sat, 1 Jul 2023 21:56:36 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0



On 01.07.2023 16:27, Renzo Davoli wrote:
Hi Simon,

Hi Renzo,

as much as I can understand your patch and the need for it, let's

 a) go the default way and keep patches and the discussion about them
in our bugtracker and

 b) not rush this: I'd very much prefer to get 2.2.0 just out now.
Let's not defer it with even more patch discussions. I promise, once we
have a release on master, releases will come faster again. This whole
master/stable branch + merging was a pain I don't want to have again
soon ;-)

We can do this changes once 2.2.0 is out and you can then use an
upstream commit to do your further work. Would that work?

Regards,
Simon


I have seen the new git tag 2.2.0 RC1.

I am proposing again the patch here attached.
It is an optimization by itself (it avoids the generation of useless events)
and it permits to reduce significantly the amount of duplicated code in the
interfacing layer between lwip an libioth (Internet of Threads).

Purpose of the patch.
---------------------
File: src/api/sockets.c, function lwip_accept.
Current code:
Line 702/720 (chunk A) generate events if data comes in when the new socket has 
not
been created yet.
Line 721/748 (chunk B) copy the peer address and address len values using the 
pointers
'addr' and 'addrlen' if requested (addr != NULL && addrlen != NULL).
Line 749/752 finalize the function and return the new socket number.

This patch swaps the code of chunk A and the code of chunk B.

chunk B can fail (if netconn_peer fails) so the current code can generate events
(in chunk A) for a socket that the caller of lwip_accept will never have heard 
of.

Given that chunk A and B perform two independent actions they can be swapped,
in this way the events of chunk A are generated when lwip_accept cannot fail
any more, so the caller receives events only for known sockets.

Necessity of the patch.
-----------------------

While for lwip itself this is just a harmless optimization it is important for
libioth.

Libioth provides a unified API for networking stacks implemented in user space
as libraries. A program can decide to use a specific network implementation
just by setting the value of a string parameter.
Network implementations are loaded at run time as plugins. It is possible to 
write
programs using different network implementations at the same time, e.g.
a program can use a socket implemented by lwip and another provided by picotcp.

libioth supports select/poll/epoll... using vpoll
https://github.com/rd235/libvpoll-eventfd
This library uses a kernel module to provide real file descriptors whose
events can be generated as required using specific functions.

Thus, libioth sockets do not need specific functions to handle select/poll
(as lwip_select or lwip_poll). Events on file descriptors can be waited for
simply using the poll/select/epoll system calls etc.

I overrride the event callback in lwip's socket.c to 'feed' vpoll.
Unfortunately without this patch lwip_accept may send events for a socket that
will never be created, and there is not even an event to notify this failure...

Without this patch I'd have to etirely reimplement socket.c in the
ioth-lwip module duplicating a large amount of code.

Thank you.

        renzo







reply via email to

[Prev in Thread] Current Thread [Next in Thread]