Table of Contents

LwIP

Student: Ambarisha Bhatlapenumarthi
Mentors: Tomas Hruby, Dirk Vogt
git repository: minix-lwipgsoc

Abstract

The project aims to complete LwIP integration into MINIX 3. Basic support has already been added but it isn't complete and hasn't been tested properly yet. This project will be about completing that work and then adding new features like IP routing, forwarding, IPv6 support, NPF support. There are also some secondary goals like developing core LwIP for the benefit of both MINIX 3 and LwIP communities.

Current Status

DoneItemPercentage CompleteComments
Complete lwIP integration95% Testing named remains
Improve routing in lwIP, IP Forwarding100%
Improve IPv6 functionality80% Testing IPv6 connections and support for raw ip sockets remain
Add support for NPF0%
Secondary goals0%

Status Reports

Week 1(May 28th - June 3rd)

Imported LwIP-trunk codebase. LwIP is currently in 1.4.1rc1. LwIP-trunk contains alot of major IPv6 patches which will be coming out in 1.5.0.
After a few changes to the Makefiles everything compiles.
Noticed a couple of random glitches after installing LwIP-trunk. Otherwise lwip server runs fine.
Looked into DHCP client. Need to consider ISC's dhclient vs Roy Marvels' dhcpcd(being used by netbsd).

Week 2, 3(June 4th - June 17th)

I worked on porting ISC's dhclient to MINIX. dhclient comes with bind which is a DNS software. Support for IPv6 is also available. So once it works, most of the basic functionality will be available. For now all the code compiles. I still need to fix a few things(mentioned below) and then test the client. I defined a couple of dummy functions to make the IPv6 code compile. Once IPv6 module is completed these dummy functions can be replaced.

int utimes(const char *path, const struct timeval times[2])

bind maintains a journal file for IXFR zone transfers. It uses utimes() for timestamping each time it accesses this journal file. utimes() is not available in MINIX, so instead of using the utimes we maintain a timestamp variable for the journal file.

IP_HDRINCL

There are three Network API available. BPF, LPF and raw sockets. For raw sockets, they are trying to use a handcrafted IP header by setting the IP_HDRINCL socket option. But IP_HDRINCL isn't available in /usr/include. Also I am not sure why handcrafted IP header is necessary. For BPF, LPF it has to handcrafted anyway. So, probably this is so for reusing that code.

Broadcast sockets

dhclient requires SO_BROADCAST which is a socket option for broadcasting. But SO_BROADCAST isn't available in MINIX.

Week 4(June 18th - June 24th)

This week I first fixed the problems from last week:

I got the NetBSD's dhclient-script and modified it to work with MINIX as our ifconfig command is very restricted. Also typecasts between struct sockaddr_in and struct sockaddr aren't working as expected. Currently working on fixing this. (Edit: It was just because of a mistake, I was including the wrong file)

Week 5(June 25th - July 1st)

This week I worked DNS and IP forwarding.

Week 6, 7(July 2nd - July 15th)

I have been working on integrating dhclient and bind into minix src tree. I also successfully tested IP forwarding.

Week 8(July 16th - July 22nd)

I laid out the makefiles and modified them for minix. I found out that bind has 2 sets of libraries BIND9 libraries and bind export libraries. Bind export libraries separate code which is closely tied to bind binaries (especially named). Since we are porting both dhclient and named, I figured we could merge both libraries. After building everything and running, I learnt that the libraries are not compatible with each other internally. I got this confirmed on bind-workers mailing list. So, now we have two sets of bind libraries which are somewhat different. I have placed the export libraries under libbindexport in src/lib. I am finally finished with integrating dhclient into minix src tree. Though there still seems to be a problem with broadcast receive messages. I am now working to fix this.

I have also setup IPv6 lan with my host for starting work on IPv6. I looked at liblwip, lwip server from IPv6 perspective. liblwip has a LWIP_IPV6 option which turns on IPv6 in lwip. We first turn that on, then modify lwip server to handle ioctls on ipv6 sockets. Perhaps this might become more clear after discussing with Tomas and Dirk today.

Week 9 & 10 (July 23rd - August 5th)

Last week I couldn't get much work done except implementing NWIOGIP6CONF ioctl and IPv6 changes at IP layer because I had problems with setting up a serial console and implemented NWIOSIP6CONF the wrong way(fixed now). Here are the changes from this week :

I have pushed most of the changes to the repository. Any remaining changes will appear by tommorrow.

Week 11 & 12 (August 6th - August 19th)

These last couple of weeks, I continued the work on IPv6:

Design

Module 1: Making lwIP a complete replacement of inet

LwIP is not yet a complete substitute for inet. It has to be improved and tested before it can replace inet.Firstly, DHCP has to be fixed. dhcpd currently doesn't work so well with lwIP. There are two approaches to fix this:

The interface between lwIP and VFS also requires some polishing. The socket interface is provided with the help of VFS. It seems there are some problems with the raw socket functionality. Also, lwIP has to be tested further. Sometimes, I experience the system going into infinite loop with ftp listings and such. There are other little things like displaying error messages about ioctl when an ftp port command fails. These need to be put down formally, reproduced and then patched. All that testing will be included in this module.

Module 2: Adding routing and IP forwarding support

Currently lwIP doesn't support extensive routing or IP forwarding. Looking at ip_route() in liblwip/src/core/ipv4/ip.c, we see that, as of now, a packet is checked for match on the subnets of all the available network interfaces . If it doesn't match the packet is sent on a default interface. This needs to be improved. The state information required to decide the route has to be acquired and the route calculated. I have also looked through inet codebase. Perhaps, src/servers/inet/ipr.c could be a starting point.

[EDIT : Confirmed that improving routing support in lwip is out of the scope of the project. It seems, the lwIP community is also not so interested bringing in extensive routing in “lw”IP ]

Module 3: Adding IPv6 support

lwIP has IPv6 support, but it is not at all complete. A lot of patches were added after the 1.4.0 release according to lwIP mailing list discussion and they haven't been tested thoroughly as yet. Testing IPv6 would also be a major task of this module. LwIP currently supports the dual stack. I have a decent understanding of IPv6. But it is not profound. I will have to study this a little more. So, this module is perhaps the largest.

NetBSD

This would involve adding hooks to let NPF know when a packet arrives and passing the packet to NPF after stripping the datalink headers.

Module 5: Secondary goals

There are also some secondary goals like adding features to LwIP and upstreamed.

Schedule

Pre-Coding Period (Apr 23 - May 20)

Week 1, 2, 3 (May 21 - Jun 10)

Week 4 (Jun 11 - Jun 17)

Week 5 (Jun 18 - Jun 24)

Buffer

MIDTERM milestones : Complete lwIP replacement for Inet

Week 6-9 (Jun 25 - Jul 22)

Week 10 (Jul 23 - Jul 29)

Week 11, 12(Jul 30 - Aug 12)

Week 13 (Aug 13 - Aug 19) - FINAL

Resources