BNetworkInterfaceAddress needs to store auto-configuration flags

Hi All,
I am looking to work on this bug #7228 . I need help in understanding the issue described in the bug . I read in google about the auto configuration feature of Ipv6 but I am not finding mention of flags . If anyone can kindly brief, what we are trying to fix in this bug …

1 Like

better ask on the ticket directly : )

1 Like

May I ask why you are looking to work on this specific bug if you don’t understand it? To me it seems better to fix bugs in code you know about or things that directly create problems in your usage of Haiku.

Not necessarily, sometimes it’s best to keep the noise level low on the ticket itself.

The first thing the ticket says is:

BNetworkInterfaceAddress needs to store auto-configuration flags instead of BNetworkInterface.

This is not directly related to IPv6 protocol. Instead it is about how we remember if an interace is configured manually or automatically (for example with DHCP). Currently there is a single flag per interface for this, stored in the BNetworkInterface class.

This is a problem if you want to use IPv6 and IPv4 at the same time, and you want to configure one manually, and the other automatically.

This means the handling of these flags can’t be done at the network interface level. It has to be done at the address level instead. For each address on an interface, we’ll need to remember if that address was configured manually (from network preferences) or automatically (from DHCP, for example).

1 Like

Hi, No specific reason for looking into this bug. I was skimming through the gsoc ideas page. Saw this bug and tried to understand the issue .


Thanks for looking into helping with bugs. Hope you find some that you can contribute to! Welcome to Haiku!


Thanks for the thumbs up .

1 Like

I observed that if I disable ipv6 on a interface and set the ipv4 as static in Network preferences, and then change the ipv6 to automatic by giving the command (ifconfig [interface name] ipv6 auto-config), the ipv4 is automatically changed to dhcp from static for that interface . I hope this is the issue being discussed in this bug #7228 . @PulkoMandy

I performed this in my oracle VM .

Yes, that’s the problem. It is not possible to have static IPv4 and dynamic IPv6 (or the opposite) on the same network interface.

I tried to do a code walkthrough to figure out how both the types of ip addresses are getting affected when I am setting one to auto-config through ifconfig .
The function flow goes like this
Bnetworkinterface::Autoconfig → BMessenger::SendMessage ----> Bmessage::Private::Sendmessage → Bmessage::_Sendmessage → write_port_etc (in file port.c) ----> _kern_write_port_etc .When this last function gets executed , I see the static ip of ipv4 for that interface gets changed to dhcp automatically . Where can I find the definitio of this function as current checkout does not have the definition for the function ?
Also, Why this procedure is being followed for auto-configuring the ipaddress ? Why cant’ we directly set the flags to auto-config mode and pass that to the SetFlags function of Bnetworkinterface class ?

_kern_write_port_etc is a system call, if you want to look at its implementation on the kernel side, it is in _user_write_port_etc. However, I don’t think this will be very useful: this is just an internal function for sending a message to another process or thread, so you will not learn much by looking at that.

Insted you should look at who the message is targeted at. It is going from the BNetworkInterface class (used by ifconfig, but also the Network preferences and any app who wants to use it) to the net_server (the server/daemon that handles all network related things). The change can’t be made directly to the interface because it requires some coordination to avoid multiple apps trying to change settings at the same time.

In the message sent, I see everything looks correct: we indicate that we want auto-config, and for which address family. The problem will be on the other side, when the net_server (which you can find in src/servers/network) processes this message. It seems that it will ignore the “family” field in the message or at least not handle it properly.

It is true that the netserver is not handling the family field of the message . But the issue is I think with the SetFlags() function of NetworkInterface class that does not take into account the family of the flags and sets everything for ipv4 .
Although, I didn’t observe the ReceiveMessage function of the netserver class getting called neither did I observe the SetFlags function getting called . (in both I had put print statements.). In fact , I changed the do_request api used inside SetFlags from NetworkInterface class , to use IPV6 for setting flags (earlier it was IPv4) but I still see the ipv4 address getting changed from static to dynamic as described in the original post .
I also verfied that the message is indeed getting sent to the net_server as the team id of net_server matches with the team_id to which it is sending the message .
Is the printf/fprintf disabled anyway inside NetServer.cpp ?

1 Like

They run in the net_server application which is normally started by launch daemon. So, it is not attached to a terminal. If you were expecting to see these messages in Terminal, it’s normal that you don’t get them there.

I think it’s possible to get the output by attaching Debugger to the net_server? Then it has an stdout/stderr panel at the bottom. Another option is to use syslog() instead of printf() and look for the output in /var/log/syslog

1 Like

Hi, Thanks for the useful info regarding syslog . I have been able to identify the reason for the ipv4 being changed to dhcp from static if I change the ipv6 to automatic .
As you already said , netserver:: ReceiveMessage is not handling the family field of the message . But I feel, that it should be decided inside AutoconfigLooper::_ReadyToRun() because it is always creating a DHCP request for IPV4 by default . The _ConfigureIPv6() is commented out .
Inside NetServer::ReceiveMessage, an Autoconfiglooper object is created and therefore this _ReadyToRun() function is invoked .

I observe the fields for IPV6 is empty in NetworkStatus window when the mode is set to Automatic for the same . Is the AutoConfiguration for IPv6 not yet implemented ? @PulkoMandy


@PulkoMandy in oracle virtual box, for Haiku, there should be a ipv6 address based on SLAAC, besides ipv4, is that correct ? Because I am seeing the ipv6 fields being empty .

I think we don’t implement slaac yet? So you would get only a link-local address and you would need to set up anything else manually for now?

Sorry, ya that is Link Local address and not SLAAC . But that is not also not configured during boot up time since IPV6 fields are empty if we open the NetworkStatus app .

@PulkoMandy I want to understand about this function call do_request() in NetworkInterface.cpp which is used for setting flags for the interface . The first parameter to this function call takes in the family of the address where we are always passing AF_INET . So, is this function call only designed to operate on IPv4 addresses or should it work if I pass AF_INET6 ? I tried using this function call to obtain flag values by passing AF_INET and AF_INET6 respectively during a normal ifconfig command and I find that the flag value for the cases is equal .

The IPv6 support is incomplete, so, some things may not work. I have not played much with it so it’s hard to say more. Maybe other people in this forum will know more about it.

@marcoapc would you be able to kindly guide me a little on this ?

@PulkoMandy If you can kindly mention someone who might be able to tell more about this .