From 78abd72799a91febaeca4b0300a56af38af4a1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 9 Aug 2010 17:08:41 +0000 Subject: [PATCH] * Made the work-around that Atis added to ifconfig and the net_server in order to be able to use SIOCSIFADDR (and friends) on a net yet added family superfluous; we now add a new address when needed on the fly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37990 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/network/stack/interfaces.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/network/stack/interfaces.cpp b/src/add-ons/kernel/network/stack/interfaces.cpp index fad592eb33..83b6bfa457 100644 --- a/src/add-ons/kernel/network/stack/interfaces.cpp +++ b/src/add-ons/kernel/network/stack/interfaces.cpp @@ -746,13 +746,26 @@ Interface::Control(net_domain* domain, int32 option, ifreq& request, address->local, (sockaddr*)&newAddress)) break; } + + if (address == NULL) + return B_BAD_VALUE; } else { // Just use the first address for this family address = _FirstForFamily(domain->family); - } + if (address == NULL) { + // Create new on the fly + address = new(std::nothrow) InterfaceAddress(this, domain); + if (address == NULL) + return B_NO_MEMORY; - if (address == NULL) - return B_BAD_VALUE; + status_t status = AddAddress(address); + if (status != B_OK) + return status; + + // Note, even if setting the address failed, the empty + // address added here will still be added to the interface. + } + } return _ChangeAddress(locker, address, option, *address->AddressFor(option),