From 9548274ed50bcd9ee706faf41746c755980596a9 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Sun, 17 Nov 2024 11:02:59 +0100 Subject: [PATCH] usb_rndis: remove reattach code The MAC address is randomly generated each time the device is connected. So there is no way to match with a previous session and reattach the interface transparently. Change-Id: I8aea95d5a09621a0dcdd7ce89787663a38435001 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8576 Haiku-Format: Haiku-format Bot Tested-by: Commit checker robot Reviewed-by: Adrien Destugues --- .../network/ether/usb_rndis/Driver.cpp | 12 ----- .../network/ether/usb_rndis/RNDISDevice.cpp | 53 ------------------- .../network/ether/usb_rndis/RNDISDevice.h | 2 - 3 files changed, 67 deletions(-) diff --git a/src/add-ons/kernel/drivers/network/ether/usb_rndis/Driver.cpp b/src/add-ons/kernel/drivers/network/ether/usb_rndis/Driver.cpp index da7bbf1d29..ec8f5a646e 100644 --- a/src/add-ons/kernel/drivers/network/ether/usb_rndis/Driver.cpp +++ b/src/add-ons/kernel/drivers/network/ether/usb_rndis/Driver.cpp @@ -26,18 +26,6 @@ usb_rndis_device_added(usb_device device, void **cookie) // check if this is a replug of an existing device first mutex_lock(&gDriverLock); - for (int32 i = 0; i < MAX_DEVICES; i++) { - if (gRNDISDevices[i] == NULL) - continue; - - if (gRNDISDevices[i]->CompareAndReattach(device) != B_OK) - continue; - - TRACE_ALWAYS("rndis device %" B_PRId32 " replugged\n", i); - *cookie = gRNDISDevices[i]; - mutex_unlock(&gDriverLock); - return B_OK; - } // no such device yet, create a new one RNDISDevice *rndisDevice = new RNDISDevice(device); diff --git a/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.cpp b/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.cpp index 896396e72c..50576db500 100644 --- a/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.cpp +++ b/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.cpp @@ -482,59 +482,6 @@ RNDISDevice::Removed() } -status_t -RNDISDevice::CompareAndReattach(usb_device device) -{ - const usb_device_descriptor *deviceDescriptor - = gUSBModule->get_device_descriptor(device); - - if (deviceDescriptor == NULL) { - TRACE_ALWAYS("failed to get device descriptor\n"); - return B_ERROR; - } - - if (deviceDescriptor->vendor_id != fVendorID - && deviceDescriptor->product_id != fProductID) { - // this certainly isn't the same device - return B_BAD_VALUE; - } - - // this might be the same device that was replugged - read the MAC address - // (which should be at the same index) to make sure - uint8 macBuffer[6]; - if (_ReadMACAddress(device, macBuffer) != B_OK - || memcmp(macBuffer, fMACAddress, sizeof(macBuffer)) != 0) { - // reading the MAC address failed or they are not the same - return B_BAD_VALUE; - } - - // this is the same device that was replugged - clear the removed state, - // re-setup the endpoints and transfers and open the device if it was - // previously opened - fDevice = device; - fRemoved = false; - status_t result = _SetupDevice(); - if (result != B_OK) { - fRemoved = true; - return result; - } - - // in case notifications do not work we will have a hardcoded connection - // need to register that and notify the network stack ourselfs if this is - // the case as the open will not result in a corresponding notification - bool noNotifications = (fMediaConnectState == MEDIA_STATE_CONNECTED); - - if (fOpen) { - fOpen = false; - result = Open(); - if (result == B_OK && noNotifications && fLinkStateChangeSem >= B_OK) - release_sem_etc(fLinkStateChangeSem, 1, B_DO_NOT_RESCHEDULE); - } - - return B_OK; -} - - status_t RNDISDevice::_SendCommand(const void* data, size_t length) { diff --git a/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.h b/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.h index 872739faa5..0c53f78dfe 100644 --- a/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.h +++ b/src/add-ons/kernel/drivers/network/ether/usb_rndis/RNDISDevice.h @@ -28,8 +28,6 @@ public: void Removed(); bool IsRemoved() { return fRemoved; }; - status_t CompareAndReattach(usb_device device); - private: static void _ReadCallback(void *cookie, int32 status, void *data, size_t actualLength);