[haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration
- From: pulkomandy@xxxxxxxxxxxxx
- To: haiku-development@xxxxxxxxxxxxx
- Date: Wed, 14 Feb 2024 17:47:54 +0000
Hi All,
I am facing some doubts while trying to address the review comments
from (https://review.haiku-os.org/c/haiku/+/7259?tab=comments) , so would
like to clarify the following points
1) I read in Google that a network device represents a physical
adapter like wifi , bluetooth etc. A device can have multiple interfaces .
Each interface can support only one address family at a time . Is this
understanding correct ?
I don't see how it's possible to have only one address family per interface.
For a typical Ethernet (or Wifi) interface, you have AF_ETHER (Ethernet, MAC
addresses), AF_INET (IPv4) and AF_INET6 (IPv6). All on the same interface, of
course.
In theory there could be multiple interfaces on the same device (at the
physical level, for example if you have an Ethernet card with 4 ports), but I
think this is not something the network stack should worry about, it will be
handled purely in the ethernet drivers. So you can assume a "device" and an
"interface" are the same thing. They are normally identified by the device
path: /dev/net/ipro1000/0 for example.
So for me it works like this:
- 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).
Here is an example configuration from Linux:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group
default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP
group default qlen 1000
link/ether f0:de:f1:bc:4b:d7 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.2/24 brd 192.168.1.255 scope global enp0s25
valid_lft forever preferred_lft forever
inet6 2a02:842a:14d:9801:f2de:f1ff:febc:4bd7/64 scope global dynamic
mngtmpaddr
valid_lft 604770sec preferred_lft 604770sec
inet6 fe80::f2de:f1ff:febc:4bd7/64 scope link
valid_lft forever preferred_lft forever
Here we have two interfaces: lo and enp0s25.
We have two devices: lo and enp0 which each correspond to one of the interfaces.
If my ethernet card had multiple ports, these could show as multiple interfaces
here (enp's26, enp0s27, etc for example). But in Haiku this can simply be
handled by the driver publishing multiple device files in /dev/net/, which the
network stack can then handle fully independently.
lo has 3 addresses:
- One MAC address in the AF_ETHER Family
- One IPv4 address (AF_INET)
- One IPv6 address (AF_INET6)
enp0s25 has 4 addresses:
- One MAC address in the AF_ETHER Family
- One IPv4 address (AF_INET)
- Two IPv6 addresses (AF_INET6), one global and the other link-local
Each address has it's own flags, for example you can see the "valid_lft" which
is the lifetime (how long this address is valid before auto-negociation must be
re-done). In this example, only the global IPv6 address is auto-configured
(Linux calls this "dynamic") and has a lifetime. The other addresses are
statically configured (in a configuration file) and so they are static.
Each interface also has its flags (UP, LOWER_UP, mtu, ...). Note that there is
no flag at the interface level that relates to address configuration. The
"dynamic" flag is not attached to an interface, but to an address. In Haiku
this is currently not done correctly: the "auto configured" or "auto
configuring" flag is incorrectly attached to the interface, instead of a
specific address or address family.
--
Adrien / PulkoMandy.
Other related posts:
- » [haiku-development] Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration - pulkomandy
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- Adrien Destugues
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- Adrien Destugues
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- pulkomandy
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- Adrien Destugues
- » [haiku-development] Re: Relationship between network device , network interface , network interface address and their configuration- sayan chaudhuri