Merge branch 'cdc-ether'
Olivier Blin says:
====================
cdc-ether: handle promiscuous mode
Since kernel 3.16, my Lenovo USB network adapters (RTL8153) using
cdc-ether are not working anymore in a bridge.
This is due to commit c472ab68ad
, which
resets the packet filter when the device is bound.
The default packet filter set by cdc-ether does not include
promiscuous, while the adapter seemed to have promiscuous enabled by
default.
This patch series allows to support promiscuous mode for cdc-ether, by
hooking into set_rx_mode.
Incidentally, maybe this device should be handled by the r8152 driver,
but this patch series is still nice for other adapters.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Oliver Neukum <oneukum@suse.de>
This commit is contained in:
commit
068301f2be
|
@ -67,6 +67,35 @@ static const u8 mbm_guid[16] = {
|
||||||
0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
|
0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void usbnet_cdc_update_filter(struct usbnet *dev)
|
||||||
|
{
|
||||||
|
struct cdc_state *info = (void *) &dev->data;
|
||||||
|
struct usb_interface *intf = info->control;
|
||||||
|
|
||||||
|
u16 cdc_filter =
|
||||||
|
USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED |
|
||||||
|
USB_CDC_PACKET_TYPE_BROADCAST;
|
||||||
|
|
||||||
|
if (dev->net->flags & IFF_PROMISC)
|
||||||
|
cdc_filter |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
|
||||||
|
|
||||||
|
/* FIXME cdc-ether has some multicast code too, though it complains
|
||||||
|
* in routine cases. info->ether describes the multicast support.
|
||||||
|
* Implement that here, manipulating the cdc filter as needed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
usb_control_msg(dev->udev,
|
||||||
|
usb_sndctrlpipe(dev->udev, 0),
|
||||||
|
USB_CDC_SET_ETHERNET_PACKET_FILTER,
|
||||||
|
USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||||
|
cdc_filter,
|
||||||
|
intf->cur_altsetting->desc.bInterfaceNumber,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
USB_CTRL_SET_TIMEOUT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* probes control interface, claims data interface, collects the bulk
|
/* probes control interface, claims data interface, collects the bulk
|
||||||
* endpoints, activates data interface (if needed), maybe sets MTU.
|
* endpoints, activates data interface (if needed), maybe sets MTU.
|
||||||
* all pure cdc, except for certain firmware workarounds, and knowing
|
* all pure cdc, except for certain firmware workarounds, and knowing
|
||||||
|
@ -347,16 +376,8 @@ next_desc:
|
||||||
* don't do reset all the way. So the packet filter should
|
* don't do reset all the way. So the packet filter should
|
||||||
* be set to a sane initial value.
|
* be set to a sane initial value.
|
||||||
*/
|
*/
|
||||||
usb_control_msg(dev->udev,
|
usbnet_cdc_update_filter(dev);
|
||||||
usb_sndctrlpipe(dev->udev, 0),
|
|
||||||
USB_CDC_SET_ETHERNET_PACKET_FILTER,
|
|
||||||
USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
|
||||||
USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED | USB_CDC_PACKET_TYPE_BROADCAST,
|
|
||||||
intf->cur_altsetting->desc.bInterfaceNumber,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
USB_CTRL_SET_TIMEOUT
|
|
||||||
);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bad_desc:
|
bad_desc:
|
||||||
|
@ -468,10 +489,6 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME cdc-ether has some multicast code too, though it complains
|
|
||||||
* in routine cases. info->ether describes the multicast support.
|
|
||||||
* Implement that here, manipulating the cdc filter as needed.
|
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
|
EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
|
||||||
|
@ -482,6 +499,7 @@ static const struct driver_info cdc_info = {
|
||||||
.bind = usbnet_cdc_bind,
|
.bind = usbnet_cdc_bind,
|
||||||
.unbind = usbnet_cdc_unbind,
|
.unbind = usbnet_cdc_unbind,
|
||||||
.status = usbnet_cdc_status,
|
.status = usbnet_cdc_status,
|
||||||
|
.set_rx_mode = usbnet_cdc_update_filter,
|
||||||
.manage_power = usbnet_manage_power,
|
.manage_power = usbnet_manage_power,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -491,6 +509,7 @@ static const struct driver_info wwan_info = {
|
||||||
.bind = usbnet_cdc_bind,
|
.bind = usbnet_cdc_bind,
|
||||||
.unbind = usbnet_cdc_unbind,
|
.unbind = usbnet_cdc_unbind,
|
||||||
.status = usbnet_cdc_status,
|
.status = usbnet_cdc_status,
|
||||||
|
.set_rx_mode = usbnet_cdc_update_filter,
|
||||||
.manage_power = usbnet_manage_power,
|
.manage_power = usbnet_manage_power,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1052,6 +1052,21 @@ static void __handle_link_change(struct usbnet *dev)
|
||||||
clear_bit(EVENT_LINK_CHANGE, &dev->flags);
|
clear_bit(EVENT_LINK_CHANGE, &dev->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usbnet_set_rx_mode(struct net_device *net)
|
||||||
|
{
|
||||||
|
struct usbnet *dev = netdev_priv(net);
|
||||||
|
|
||||||
|
usbnet_defer_kevent(dev, EVENT_SET_RX_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __handle_set_rx_mode(struct usbnet *dev)
|
||||||
|
{
|
||||||
|
if (dev->driver_info->set_rx_mode)
|
||||||
|
(dev->driver_info->set_rx_mode)(dev);
|
||||||
|
|
||||||
|
clear_bit(EVENT_SET_RX_MODE, &dev->flags);
|
||||||
|
}
|
||||||
|
|
||||||
/* work that cannot be done in interrupt context uses keventd.
|
/* work that cannot be done in interrupt context uses keventd.
|
||||||
*
|
*
|
||||||
* NOTE: with 2.5 we could do more of this using completion callbacks,
|
* NOTE: with 2.5 we could do more of this using completion callbacks,
|
||||||
|
@ -1157,6 +1172,10 @@ skip_reset:
|
||||||
if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
|
if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
|
||||||
__handle_link_change(dev);
|
__handle_link_change(dev);
|
||||||
|
|
||||||
|
if (test_bit (EVENT_SET_RX_MODE, &dev->flags))
|
||||||
|
__handle_set_rx_mode(dev);
|
||||||
|
|
||||||
|
|
||||||
if (dev->flags)
|
if (dev->flags)
|
||||||
netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
|
netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
|
||||||
}
|
}
|
||||||
|
@ -1525,6 +1544,7 @@ static const struct net_device_ops usbnet_netdev_ops = {
|
||||||
.ndo_stop = usbnet_stop,
|
.ndo_stop = usbnet_stop,
|
||||||
.ndo_start_xmit = usbnet_start_xmit,
|
.ndo_start_xmit = usbnet_start_xmit,
|
||||||
.ndo_tx_timeout = usbnet_tx_timeout,
|
.ndo_tx_timeout = usbnet_tx_timeout,
|
||||||
|
.ndo_set_rx_mode = usbnet_set_rx_mode,
|
||||||
.ndo_change_mtu = usbnet_change_mtu,
|
.ndo_change_mtu = usbnet_change_mtu,
|
||||||
.ndo_set_mac_address = eth_mac_addr,
|
.ndo_set_mac_address = eth_mac_addr,
|
||||||
.ndo_validate_addr = eth_validate_addr,
|
.ndo_validate_addr = eth_validate_addr,
|
||||||
|
|
|
@ -78,6 +78,7 @@ struct usbnet {
|
||||||
# define EVENT_NO_RUNTIME_PM 9
|
# define EVENT_NO_RUNTIME_PM 9
|
||||||
# define EVENT_RX_KILL 10
|
# define EVENT_RX_KILL 10
|
||||||
# define EVENT_LINK_CHANGE 11
|
# define EVENT_LINK_CHANGE 11
|
||||||
|
# define EVENT_SET_RX_MODE 12
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct usb_driver *driver_of(struct usb_interface *intf)
|
static inline struct usb_driver *driver_of(struct usb_interface *intf)
|
||||||
|
@ -159,6 +160,9 @@ struct driver_info {
|
||||||
/* called by minidriver when receiving indication */
|
/* called by minidriver when receiving indication */
|
||||||
void (*indication)(struct usbnet *dev, void *ind, int indlen);
|
void (*indication)(struct usbnet *dev, void *ind, int indlen);
|
||||||
|
|
||||||
|
/* rx mode change (device changes address list filtering) */
|
||||||
|
void (*set_rx_mode)(struct usbnet *dev);
|
||||||
|
|
||||||
/* for new devices, use the descriptor-reading code instead */
|
/* for new devices, use the descriptor-reading code instead */
|
||||||
int in; /* rx endpoint */
|
int in; /* rx endpoint */
|
||||||
int out; /* tx endpoint */
|
int out; /* tx endpoint */
|
||||||
|
|
Loading…
Reference in a new issue