I've advanced in several fronts during the last two weeks, like the initial configuration of the stack from the command line, by using libargp, or reading and writing a new configuration in run time, through fsysopts. The aim is to support exactly the same options pfinet does, so we'll be able to replace pfinet by the LwIP translator transparently for the rest of the system.
For this reason, I've started again from the pfinet's code and have done some changes to adapt it to LwIP. The result is much more simpler than the original code, since pfinet performs the initialization of the stack from the very option parsing function and, besides, has to handle some restrictions like being sure there's only one gateway and some corner cases. Therefore, I've been able to achieve the same functionality and remove a large part of the original code.
This has been all the work I've been able to do in the first week, when I still had to combine my GSoC with my exams for the UOC. Fortunately, from June 19th I'm working full-time on this project. I started this last week adding support for fsysopts, that mainly consisted on making some changes in the parse function to be sure it would still work fine when called after the stack is initialized and running. Most of the work consisted on taking care of the memory management. As a curious factor, it's worth mentioning that pfinet had a memory leak that I could manage to fix.
Once the configuration from the command line is added, I checked that the translator now admits working with multiple interfaces simultaneously and routing between them. The limitation of having only one gateway has been left behind, but in return now a criteria to decide which gateway is the default one is needed. I haven't talked to the Hurd's developers about this, but for the moment, the first valid gateway provided by the user is set as the default one.
Another remarkable issue I've had to deal with this week has been the bug that made the translator crash when combined with eth-multiplexer, a translator that allows an Ethernet device to be shared among multiple servers. This bug revealed that the code for reading incoming data was wrong because the output condition of its loop was incorrect: a pbuf chain ends when q->tot_len == q->len
and not when q->next == 0
. It's interesting to note that the example code LwIP maintainers provide is wrong as well.
The initial plan for this week was to start adding support for IPv6, but some issues delayed me a bit. However, automatic IPv6 configuration with SLAAC, creation of link-local addresses and IPv4-IPv6 dual-stack mode are yet implemented. I won't explain more details about this for the moment I think this is a very interesting topic and is worth to be thoroughly explained in the next post.