[haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration

  • From: sayan chaudhuri <sayanchaudhuri758@xxxxxxxxx>
  • To: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
  • Date: Wed, 21 Feb 2024 22:29:14 +0530

So, this line of code that stores only the configured device name and not a
pair of  configured(device name, address) is a blocker for the review
request (https://review.haiku-os.org/c/haiku/+/7259?tab=comments) .
I am thinking of a solution like this
1. inside function NetServer::_ConfigureInterfacesFromSettings, we have the
below two lines
         if (_ConfigureInterface(interface) == B_OK)
devicesSet.Add(device); instead of this , may be we can have devicesSet
type as a map of (BNetworkDevice,BNetworkInterfaceAddress) and then add the
configured device and address family pairs from the message
variable "interface" to devicesSet. I do not know / could not find if any
map class already exists in Haiku. 2. Similarly inside
NetServer::_ConfigureDevices,
instead of checking only for the device
if (entry.GetName(name) != B_OK
|| entry.GetPath(&path) != B_OK
|| entry.GetStat(&stat) != B_OK
|| devicesAlreadyConfigured.HasString(path.Path())) we can check for
combination of device and address family being present . if the pair is not
present . then move on to auto_configure them, Would like to have community
feedback on this approach . Thanks, Sayan Chaudhuri

On Thu, Feb 15, 2024 at 1:26 PM Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
wrote:



Le mercredi 14 février 2024 20:49:19 (+01:00), sayan chaudhuri a écrit :

 One device is the same as one interface
- Each interface can have multiple addresses
- Each address belongs to one address family
- There can be multiple addresses for the same interface with the same
family (you can have two IPv4 addresses at the same time, although it is
rarely used; with IPv6 you will have a link-local address and at least one
routable address)
- There can be multiple addresses for the same interface with different
families as well (IPv4 + IPv6 + ethernet for example)
- An address can be configured manually (in the settings file) or
auto-configured (DHCP, ...)
- An (interface, address family) pair can be either configured (the
interface has at least one address in that family), unconfigured (the
interface does not use this address family), or configuring (the interface
is trying to acquire an address for this family).


If one of the address family for the interface gets configured from the
settings file , but the other address family does not get configured
because it is not present in the setttings file, should the interface be
considered as configured ?   Reference code --> (
https://git.haiku-os.org/haiku/tree/src/servers/net/NetServer.cpp#n767)


The notion of "configured" or not is not applicable to an interface as a
whole. It is applicable to an (interface, address family) pair, as I wrote
above.
So an interface can be simultaneously:
- Configured for AF_INET
- And also not configured for AF_INET6

Similarly, it can be "configuring" for one address family and not for the
other.

The existing code does not match this, so it needs to be changed.

--
Adrien / PulkoMandy

Other related posts: