moved IFF_LINK handling to the device module (ethernet in this case). Now domain interfaces only keep specific flags such as IFF_UP and the configuration flags. IFF_LINK, IFF_BROADCAST etc are maintained exclusively by the device.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20612 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fb300cfd25
commit
ae074c5d15
@ -67,6 +67,11 @@ update_link_state(ethernet_device *device, bool notify = true)
|
||||
device->link_quality = state.quality;
|
||||
device->link_speed = state.speed;
|
||||
|
||||
if (device->media & IFM_ACTIVE)
|
||||
device->flags |= IFF_LINK;
|
||||
else
|
||||
device->flags &= ~IFF_LINK;
|
||||
|
||||
dprintf("%s: media change, media 0x%0x quality %u speed %u\n",
|
||||
device->name, (unsigned int)device->media,
|
||||
(unsigned int)device->link_quality,
|
||||
@ -132,7 +137,7 @@ ethernet_init(const char *name, net_device **_device)
|
||||
memset(device, 0, sizeof(ethernet_device));
|
||||
|
||||
strcpy(device->name, name);
|
||||
device->flags = IFF_BROADCAST;
|
||||
device->flags = IFF_BROADCAST | IFF_LINK;
|
||||
device->type = IFT_ETHER;
|
||||
device->mtu = 1500;
|
||||
device->media = IFM_ACTIVE | IFM_ETHER;
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_media.h>
|
||||
#include <new>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -85,9 +86,10 @@ loopback_init(const char *name, net_device **_device)
|
||||
memset(device, 0, sizeof(loopback_device));
|
||||
|
||||
strcpy(device->name, name);
|
||||
device->flags = IFF_LOOPBACK;
|
||||
device->flags = IFF_LOOPBACK | IFF_LINK;
|
||||
device->type = IFT_LOOP;
|
||||
device->mtu = 16384;
|
||||
device->media = IFM_ACTIVE;
|
||||
|
||||
*_device = device;
|
||||
return B_OK;
|
||||
|
@ -619,7 +619,7 @@ interface_protocol_control(net_datalink_protocol *_protocol,
|
||||
{
|
||||
// get flags
|
||||
struct ifreq request;
|
||||
request.ifr_flags = interface->flags;
|
||||
request.ifr_flags = interface->flags | interface->device->flags;
|
||||
|
||||
return user_memcpy(&((struct ifreq *)argument)->ifr_flags,
|
||||
&request.ifr_flags, sizeof(request.ifr_flags));
|
||||
|
@ -224,28 +224,28 @@ domain_interface_control(net_domain_private *domain, int32 option,
|
||||
break;
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
if (((uint32)request->ifr_flags & IFF_UP)
|
||||
!= (interface->flags & IFF_UP)) {
|
||||
if (interface->flags & IFF_UP) {
|
||||
interface_set_down(interface);
|
||||
} else {
|
||||
{
|
||||
uint32 requestFlags = request->ifr_flags;
|
||||
request->ifr_flags &= ~(IFF_UP | IFF_LINK | IFF_BROADCAST);
|
||||
|
||||
if ((requestFlags & IFF_UP) != (interface->flags & IFF_UP)) {
|
||||
if (requestFlags & IFF_UP) {
|
||||
status = interface->first_info->interface_up(
|
||||
interface->first_protocol);
|
||||
if (status == B_OK) {
|
||||
if (status == B_OK)
|
||||
interface->flags |= IFF_UP;
|
||||
// TODO this doesn't belong here
|
||||
if (interface->device->media & IFM_ACTIVE)
|
||||
interface->flags |= IFF_LINK;
|
||||
}
|
||||
} else {
|
||||
interface_set_down(interface);
|
||||
}
|
||||
}
|
||||
|
||||
if (status == B_OK)
|
||||
interface->flags |= request->ifr_flags & ~(IFF_UP | IFF_LINK);
|
||||
interface->flags |= request->ifr_flags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the SIOCDIFADDR call above removed the last interface
|
||||
// associated with the device interface, this put_() will
|
||||
@ -256,38 +256,6 @@ domain_interface_control(net_domain_private *domain, int32 option,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
domain_interfaces_link_changed(net_device *device)
|
||||
{
|
||||
// TODO: notify listeners about this!
|
||||
|
||||
BenaphoreLocker locker(sDomainLock);
|
||||
|
||||
net_domain_private *domain = NULL;
|
||||
while (true) {
|
||||
domain = (net_domain_private *)list_get_next_item(&sDomains, domain);
|
||||
if (domain == NULL)
|
||||
break;
|
||||
|
||||
BenaphoreLocker locker(domain->lock);
|
||||
|
||||
net_interface *interface = NULL;
|
||||
while (true) {
|
||||
interface = (net_interface *)list_get_next_item(&domain->interfaces,
|
||||
interface);
|
||||
if (interface == NULL)
|
||||
break;
|
||||
|
||||
if (interface->device == device) {
|
||||
// update IFF_LINK flag
|
||||
interface->flags = (interface->flags & ~IFF_LINK)
|
||||
| (device->media & IFM_ACTIVE ? IFF_LINK : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
domain_interface_went_down(net_interface *interface)
|
||||
{
|
||||
|
@ -36,7 +36,6 @@ uint32 count_domain_interfaces();
|
||||
status_t list_domain_interfaces(void *buffer, size_t *_bufferSize);
|
||||
status_t add_interface_to_domain(net_domain *domain, struct ifreq& request);
|
||||
status_t remove_interface_from_domain(net_interface *interface);
|
||||
void domain_interfaces_link_changed(net_device *device);
|
||||
void domain_interface_went_down(net_interface *);
|
||||
void domain_removed_device_interface(net_device_interface *);
|
||||
status_t domain_interface_control(net_domain_private *domain, int32 option,
|
||||
|
@ -141,7 +141,7 @@ create_interface(net_domain *domain, const char *name, const char *baseName,
|
||||
interface->mask = NULL;
|
||||
|
||||
interface->index = ++sInterfaceIndex;
|
||||
interface->flags = deviceInterface->device->flags & ~IFF_UP;
|
||||
interface->flags = 0;
|
||||
interface->type = 0;
|
||||
interface->mtu = deviceInterface->device->mtu;
|
||||
interface->metric = 0;
|
||||
@ -169,8 +169,7 @@ interface_set_down(net_interface *interface)
|
||||
if ((interface->flags & IFF_UP) == 0)
|
||||
return;
|
||||
|
||||
// TODO: IFF_LINK should belong in device only
|
||||
interface->flags &= ~(IFF_UP | IFF_LINK);
|
||||
interface->flags &= ~IFF_UP;
|
||||
interface->first_info->interface_down(interface->first_protocol);
|
||||
}
|
||||
|
||||
@ -658,7 +657,6 @@ unregister_device_monitor(struct net_device *device,
|
||||
status_t
|
||||
device_link_changed(net_device *device)
|
||||
{
|
||||
domain_interfaces_link_changed(device);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user