netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3] cdc-ether: handle promiscuous mode
@ 2014-10-24 17:42 Olivier Blin
  2014-10-24 17:43 ` [PATCH net 1/3] usbnet: add a callback for set_rx_mode Olivier Blin
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Olivier Blin @ 2014-10-24 17:42 UTC (permalink / raw)
  To: netdev; +Cc: oneukum, hayeswang, bjorn, davem, Olivier Blin

Hi,

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 c472ab68ad67db23c9907a27649b7dc0899b61f9, 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.

Thanks

Olivier Blin (3):
  usbnet: add a callback for set_rx_mode
  cdc-ether: extract usbnet_cdc_update_filter function
  cdc-ether: handle promiscuous mode with a set_rx_mode callback

 drivers/net/usb/cdc_ether.c | 47 +++++++++++++++++++++++++++++++--------------
 drivers/net/usb/usbnet.c    | 20 +++++++++++++++++++
 include/linux/usb/usbnet.h  |  4 ++++
 3 files changed, 57 insertions(+), 14 deletions(-)

-- 
2.1.2

-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net 1/3] usbnet: add a callback for set_rx_mode
  2014-10-24 17:42 [PATCH net 0/3] cdc-ether: handle promiscuous mode Olivier Blin
@ 2014-10-24 17:43 ` Olivier Blin
  2014-10-24 17:43 ` [PATCH net 2/3] cdc-ether: extract usbnet_cdc_update_filter function Olivier Blin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Olivier Blin @ 2014-10-24 17:43 UTC (permalink / raw)
  To: netdev; +Cc: oneukum, hayeswang, bjorn, davem, Olivier Blin

To delegate promiscuous mode and multicast filtering to the subdriver.

Signed-off-by: Olivier Blin <olivier.blin@softathome.com>
---
 drivers/net/usb/usbnet.c   | 20 ++++++++++++++++++++
 include/linux/usb/usbnet.h |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 5173821..53f51fc 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1051,6 +1051,21 @@ static void __handle_link_change(struct usbnet *dev)
 	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.
  *
  * NOTE:  with 2.5 we could do more of this using completion callbacks,
@@ -1156,6 +1171,10 @@ skip_reset:
 	if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
 		__handle_link_change(dev);
 
+	if (test_bit (EVENT_SET_RX_MODE, &dev->flags))
+		__handle_set_rx_mode(dev);
+
+
 	if (dev->flags)
 		netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
 }
@@ -1523,6 +1542,7 @@ static const struct net_device_ops usbnet_netdev_ops = {
 	.ndo_stop		= usbnet_stop,
 	.ndo_start_xmit		= usbnet_start_xmit,
 	.ndo_tx_timeout		= usbnet_tx_timeout,
+	.ndo_set_rx_mode	= usbnet_set_rx_mode,
 	.ndo_change_mtu		= usbnet_change_mtu,
 	.ndo_set_mac_address 	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 26088fe..d9a4905 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -78,6 +78,7 @@ struct usbnet {
 #		define EVENT_NO_RUNTIME_PM	9
 #		define EVENT_RX_KILL	10
 #		define EVENT_LINK_CHANGE	11
+#		define EVENT_SET_RX_MODE	12
 };
 
 static inline struct usb_driver *driver_of(struct usb_interface *intf)
@@ -159,6 +160,9 @@ struct driver_info {
 	/* called by minidriver when receiving indication */
 	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 */
 	int		in;		/* rx endpoint */
 	int		out;		/* tx endpoint */
-- 
2.1.2

-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 2/3] cdc-ether: extract usbnet_cdc_update_filter function
  2014-10-24 17:42 [PATCH net 0/3] cdc-ether: handle promiscuous mode Olivier Blin
  2014-10-24 17:43 ` [PATCH net 1/3] usbnet: add a callback for set_rx_mode Olivier Blin
@ 2014-10-24 17:43 ` Olivier Blin
  2014-10-24 17:43 ` [PATCH net 3/3] cdc-ether: handle promiscuous mode with a set_rx_mode callback Olivier Blin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Olivier Blin @ 2014-10-24 17:43 UTC (permalink / raw)
  To: netdev; +Cc: oneukum, hayeswang, bjorn, davem, Olivier Blin

This will be used by the set_rx_mode callback.

Also move a comment about multicast filtering in this new function.

Signed-off-by: Olivier Blin <olivier.blin@softathome.com>
---
 drivers/net/usb/cdc_ether.c | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 2a32d91..bee3689 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -67,6 +67,32 @@ static const u8 mbm_guid[16] = {
 	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;
+
+	/* 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
  * endpoints, activates data interface (if needed), maybe sets MTU.
  * all pure cdc, except for certain firmware workarounds, and knowing
@@ -347,16 +373,8 @@ next_desc:
 	 * don't do reset all the way. So the packet filter should
 	 * be set to a sane initial value.
 	 */
-	usb_control_msg(dev->udev,
-			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
-		);
+	usbnet_cdc_update_filter(dev);
+
 	return 0;
 
 bad_desc:
@@ -468,10 +486,6 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 		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;
 }
 EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
-- 
2.1.2

-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 3/3] cdc-ether: handle promiscuous mode with a set_rx_mode callback
  2014-10-24 17:42 [PATCH net 0/3] cdc-ether: handle promiscuous mode Olivier Blin
  2014-10-24 17:43 ` [PATCH net 1/3] usbnet: add a callback for set_rx_mode Olivier Blin
  2014-10-24 17:43 ` [PATCH net 2/3] cdc-ether: extract usbnet_cdc_update_filter function Olivier Blin
@ 2014-10-24 17:43 ` Olivier Blin
  2014-10-27 10:02 ` [PATCH net 0/3] cdc-ether: handle promiscuous mode Oliver Neukum
  2014-10-28 19:49 ` David Miller
  4 siblings, 0 replies; 8+ messages in thread
From: Olivier Blin @ 2014-10-24 17:43 UTC (permalink / raw)
  To: netdev; +Cc: oneukum, hayeswang, bjorn, davem, Olivier Blin

Promiscuous mode was not supported anymore with my Lenovo adapters
(RTL8153) since commit c472ab68ad67db23c9907a27649b7dc0899b61f9
(cdc-ether: clean packet filter upon probe).

It was not possible to use them in a bridge anymore.

Signed-off-by: Olivier Blin <olivier.blin@softathome.com>
Also-analyzed-by: Loïc Yhuel <loic.yhuel@softathome.com>
---
 drivers/net/usb/cdc_ether.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index bee3689..d3920b5 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -76,6 +76,9 @@ static void usbnet_cdc_update_filter(struct usbnet *dev)
 	    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.
@@ -496,6 +499,7 @@ static const struct driver_info	cdc_info = {
 	.bind =		usbnet_cdc_bind,
 	.unbind =	usbnet_cdc_unbind,
 	.status =	usbnet_cdc_status,
+	.set_rx_mode =	usbnet_cdc_update_filter,
 	.manage_power =	usbnet_manage_power,
 };
 
@@ -505,6 +509,7 @@ static const struct driver_info wwan_info = {
 	.bind =		usbnet_cdc_bind,
 	.unbind =	usbnet_cdc_unbind,
 	.status =	usbnet_cdc_status,
+	.set_rx_mode =	usbnet_cdc_update_filter,
 	.manage_power =	usbnet_manage_power,
 };
 
-- 
2.1.2

-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
-- This message and any attachments herein are confidential, intended solely for the addressees and are SoftAtHome.s ownership. Any unauthorized use or dissemination is prohibited. If you are not the intended addressee of this message, please cancel it immediately and inform the sender.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net 0/3] cdc-ether: handle promiscuous mode
  2014-10-24 17:42 [PATCH net 0/3] cdc-ether: handle promiscuous mode Olivier Blin
                   ` (2 preceding siblings ...)
  2014-10-24 17:43 ` [PATCH net 3/3] cdc-ether: handle promiscuous mode with a set_rx_mode callback Olivier Blin
@ 2014-10-27 10:02 ` Oliver Neukum
  2014-10-28 19:49 ` David Miller
  4 siblings, 0 replies; 8+ messages in thread
From: Oliver Neukum @ 2014-10-27 10:02 UTC (permalink / raw)
  To: Olivier Blin; +Cc: netdev, hayeswang, bjorn, davem

On Fri, 2014-10-24 at 19:42 +0200, Olivier Blin wrote:
> Hi,
> 
> 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 c472ab68ad67db23c9907a27649b7dc0899b61f9, 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.

Acked-by: Oliver Neukum <oneukum@suse.de>

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net 0/3] cdc-ether: handle promiscuous mode
  2014-10-24 17:42 [PATCH net 0/3] cdc-ether: handle promiscuous mode Olivier Blin
                   ` (3 preceding siblings ...)
  2014-10-27 10:02 ` [PATCH net 0/3] cdc-ether: handle promiscuous mode Oliver Neukum
@ 2014-10-28 19:49 ` David Miller
  2014-10-28 21:10   ` Oliver Neukum
  4 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2014-10-28 19:49 UTC (permalink / raw)
  To: olivier.blin; +Cc: netdev, oneukum, hayeswang, bjorn

From: Olivier Blin <olivier.blin@softathome.com>
Date: Fri, 24 Oct 2014 19:42:59 +0200

> 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 c472ab68ad67db23c9907a27649b7dc0899b61f9, 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.

Can a usbnet expert please review this series?

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net 0/3] cdc-ether: handle promiscuous mode
  2014-10-28 19:49 ` David Miller
@ 2014-10-28 21:10   ` Oliver Neukum
  2014-10-28 21:30     ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Neukum @ 2014-10-28 21:10 UTC (permalink / raw)
  To: David Miller; +Cc: olivier.blin, netdev, hayeswang, bjorn

On Tue, 2014-10-28 at 15:49 -0400, David Miller wrote:
> From: Olivier Blin <olivier.blin@softathome.com>
> Date: Fri, 24 Oct 2014 19:42:59 +0200
> 
> > 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 c472ab68ad67db23c9907a27649b7dc0899b61f9, 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.
> 
> Can a usbnet expert please review this series?

Acked-by: Oliver Neukum <oneukum@suse.de>

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net 0/3] cdc-ether: handle promiscuous mode
  2014-10-28 21:10   ` Oliver Neukum
@ 2014-10-28 21:30     ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2014-10-28 21:30 UTC (permalink / raw)
  To: oneukum; +Cc: olivier.blin, netdev, hayeswang, bjorn

From: Oliver Neukum <oneukum@suse.de>
Date: Tue, 28 Oct 2014 22:10:25 +0100

> On Tue, 2014-10-28 at 15:49 -0400, David Miller wrote:
>> From: Olivier Blin <olivier.blin@softathome.com>
>> Date: Fri, 24 Oct 2014 19:42:59 +0200
>> 
>> > 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 c472ab68ad67db23c9907a27649b7dc0899b61f9, 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.
>> 
>> Can a usbnet expert please review this series?
> 
> Acked-by: Oliver Neukum <oneukum@suse.de>

Series applied, thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-10-28 21:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-24 17:42 [PATCH net 0/3] cdc-ether: handle promiscuous mode Olivier Blin
2014-10-24 17:43 ` [PATCH net 1/3] usbnet: add a callback for set_rx_mode Olivier Blin
2014-10-24 17:43 ` [PATCH net 2/3] cdc-ether: extract usbnet_cdc_update_filter function Olivier Blin
2014-10-24 17:43 ` [PATCH net 3/3] cdc-ether: handle promiscuous mode with a set_rx_mode callback Olivier Blin
2014-10-27 10:02 ` [PATCH net 0/3] cdc-ether: handle promiscuous mode Oliver Neukum
2014-10-28 19:49 ` David Miller
2014-10-28 21:10   ` Oliver Neukum
2014-10-28 21:30     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).