Opened 18 years ago
Last modified 9 months ago
#804 new enhancement
"ifconfig" should support :x notion
Reported by: | axeld | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | R1.1 |
Component: | Network & Internet | Version: | |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
The "ifconfig" command should allow merging different interfaces with the same base name, as well as creating additional interfaces for a specific base via the ":x" notion. Ie. if the first interface is "loop0" (with base "loop0"), it could also be addressed (in ifconfig only) via "loop0:0". The second interface with base "loop0" will be called "loop0:1", and so on.
Change History (10)
comment:1 by , 18 years ago
Platform: | → All |
---|---|
Priority: | normal → low |
comment:2 by , 18 years ago
comment:3 by , 18 years ago
I would think yes, because it's needed to have two IP adresses on one interface.
comment:4 by , 17 years ago
Milestone: | R1 Network Stack → R1 |
---|
comment:5 by , 9 years ago
Milestone: | R1 → Unscheduled |
---|
comment:7 by , 4 years ago
Milestone: | R1 → R1.1 |
---|
comment:8 by , 9 months ago
Trying to add an IPv4 address for /dev/net/virtio/0:0, ifconfig returns General system error.
The following patch helps to get it working. register_device_handler() fails to add itself a second time for a specific device.
ifconfig then shows the second interface like the first one, statistics included.
I checked on Ubuntu, and there the :x notion is only for IPv4, not IPv6. Maybe the code should check whether the protocol accepts multiple addresses, before adding alias interfaces.
diff --git a/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp b/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp index 747e44855c..d010fa80fe 100644 --- a/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp +++ b/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp @@ -979,13 +979,17 @@ arp_init_protocol(net_interface* interface, net_domain* domain, status_t status = sStackModule->register_device_handler(interface->device, B_NET_FRAME_TYPE(IFT_ETHER, ETHER_TYPE_ARP), &arp_receive, NULL); - if (status != B_OK) + /*if (status != B_OK) { + dprintf("register_device_handler failed\n"); return status; + }*/ status = sStackModule->register_domain_device_handler( interface->device, B_NET_FRAME_TYPE(IFT_ETHER, ETHER_TYPE_IP), domain); - if (status != B_OK) + /*if (status != B_OK) { + dprintf("register_domain_device_handler failed\n"); return status; + }*/ arp_protocol* protocol = new(std::nothrow) arp_protocol; if (protocol == NULL) diff --git a/src/add-ons/kernel/network/stack/device_interfaces.cpp b/src/add-ons/kernel/network/stack/device_interfaces.cpp index 90d2bf4db0..9fe43e5099 100644 --- a/src/add-ons/kernel/network/stack/device_interfaces.cpp +++ b/src/add-ons/kernel/network/stack/device_interfaces.cpp @@ -167,8 +167,13 @@ find_device_interface(const char* name) ASSERT_LOCKED_MUTEX(&sLock); DeviceInterfaceList::Iterator iterator = sInterfaces.GetIterator(); + uint32 length = strlen(name); + const char* last = strchr(name, ':'); + if (last != NULL) + length = last - name; + while (net_device_interface* interface = iterator.Next()) { - if (!strcmp(interface->device->name, name)) + if (!strncmp(interface->device->name, name, length)) return interface; }
comment:9 by , 9 months ago
What is the status code exactly for the error checks that you commented out? Can we ignore just that error? (for example I would imagine something like EALREADY if the device handler is already attached to the device?)
Or do we need to find the already attached device handler and modify its address list instead? (more similar to the code to change the IP address, except it wouldn't remove the old one?)
comment:10 by , 9 months ago
It's B_ERROR, at https://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/network/stack/device_interfaces.cpp#n677 The problem is on uninit unregister_device_handler is called. This might need a reference count.
Do we really need if aliases ? I know BONE supports them but it's a bit buggy and I as probably the only one to ever use, hmm, try it.