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

  • From: sayan chaudhuri <sayanchaudhuri758@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 7 Apr 2024 00:43:23 +0530

Hi Adrian,
               The Concept of configuring, configured, unconfigured, which
is applicable for an (interface, address family ) pair, is a runtime
information , is that correct ? If Yes, then do we need to use ioctl calls
to store that info , with a new type of request code ?

     Thanks,
Sayan Chaudhuri


On Fri, Mar 1, 2024 at 12:48 AM <pulkomandy@xxxxxxxxxxxxx> wrote:

21 février 2024 à 17:53 "sayan chaudhuri" <sayanchaudhuri758@xxxxxxxxx> a
écrit:




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.

The NetServer.cpp code that you linked already has fDeviceMap that is
implemented using C++ standard std::map.
I think you can also use an std::map from standard C++ for your needs here.

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 them0. Would
like to have community feedback on this approach .

The "devicesAlreadyConfigured" variable is currently a simple BStringList
(a list of strings containing just device names).
This will need some changes, both in the _ConfigureDevices function but
also in _ConfigureInterfacesFromSettings and _BringUpInterfaces, to make it
more explicit what is configured and what isn't. Maybe introduce a new
class to track the state of each device and each address family inside that
device, instead of the currently used string list.

I hope this helps,
--
Adrien / PulkoMandy.


Other related posts: