network/stack: Do not invoke SIOCGIFMEDIA but just return the already-fetched media.

This functionally disables most of the functionality of the BSD-style
SIOCGIFMEDIA, but it was never used in userland (because if it had,
it would have triggered SMAP violations in the compatibility layer.)

SIOCGIFMEDIA returns BSD-style media values, which mostly overlap
with Haiku ones but have a few differences still. These are taken care
of in the compat layer by ETHER_GET_LINK_STATE, which is where this
media value comes from, but are not by SIOCGIFMEDIA which just passes
back whatever the drivers do.

Fixes #17770, at least for ethernet drivers.
This commit is contained in:
Augustin Cavalier 2022-06-13 20:32:57 -04:00
parent b5fae38254
commit 83ac9b727c
2 changed files with 10 additions and 18 deletions

View File

@ -922,19 +922,15 @@ interface_protocol_control(net_datalink_protocol* _protocol, int32 option,
return B_BAD_VALUE;
struct ifmediareq request;
if (user_memcpy(&request, argument, sizeof(ifmediareq)) != B_OK)
if (user_memcpy(&request, argument, sizeof(request)) != B_OK)
return B_BAD_ADDRESS;
// TODO: see above.
if (interface->device->module->control(interface->device,
SIOCGIFMEDIA, &request,
sizeof(struct ifmediareq)) != B_OK) {
memset(&request, 0, sizeof(struct ifmediareq));
request.ifm_active = request.ifm_current
= interface->device->media;
}
// TODO: Support retrieving the media list?
memset(&request, 0, sizeof(struct ifmediareq));
request.ifm_active = request.ifm_current
= interface->device->media;
return user_memcpy(argument, &request, sizeof(struct ifmediareq));
return user_memcpy(argument, &request, sizeof(request));
}
case SIOCGIFMETRIC:

View File

@ -472,14 +472,10 @@ link_control(net_protocol* _protocol, int level, int option, void* value,
return B_BAD_ADDRESS;
}
// TODO: see above.
if (interface->device->module->control(interface->device,
SIOCGIFMEDIA, &request,
sizeof(struct ifmediareq)) != B_OK) {
memset(&request, 0, sizeof(struct ifmediareq));
request.ifm_active = request.ifm_current
= interface->device->media;
}
// We do not support SIOCSIFMEDIA here, so ignore the media list.
memset(&request, 0, sizeof(struct ifmediareq));
request.ifm_active = request.ifm_current = interface->device->media;
put_device_interface(interface);
return user_memcpy(value, &request, sizeof(struct ifmediareq));