diff mbox

[1/2] cdc_ncm: Handle multicast Ethernet traffic

Message ID d555efc0-10a9-0200-e886-08742c79541f@det.uvigo.gal (mailing list archive)
State New, archived
Headers show

Commit Message

Miguel Rodríguez Pérez June 29, 2018, 2:47 p.m. UTC
Some CDC_NCM devices are used as docks for laptops. In this case, it
makes sense to accept multicast Ethernet traffic, as these devices
can reside in a proper LAN. Without this, mDNS or IPv6 simply do not
work.

Signed-off-by: Miguel Rodríguez Pérez <miguel@det.uvigo.gal>
---
 drivers/net/usb/cdc_ncm.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

 	.get_link          = usbnet_get_link,
 	.nway_reset        = usbnet_nway_reset,
@@ -1652,6 +1679,7 @@ static const struct driver_info cdc_ncm_info = {
 	.status = cdc_ncm_status,
 	.rx_fixup = cdc_ncm_rx_fixup,
 	.tx_fixup = cdc_ncm_tx_fixup,
+	.set_rx_mode = cdc_ncm_update_filter,
 };

 /* Same as cdc_ncm_info, but with FLAG_WWAN */

Comments

Greg KH June 29, 2018, 6:15 p.m. UTC | #1
On Fri, Jun 29, 2018 at 04:47:28PM +0200, Miguel Rodríguez Pérez wrote:
> Some CDC_NCM devices are used as docks for laptops. In this case, it
> makes sense to accept multicast Ethernet traffic, as these devices
> can reside in a proper LAN. Without this, mDNS or IPv6 simply do not
> work.
> 
> Signed-off-by: Miguel Rodríguez Pérez <miguel@det.uvigo.gal>
> ---
>  drivers/net/usb/cdc_ncm.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

This had the same subject as the previous patch, which is not correct.

Also, please use scripts/get_maintainer.pl to determine what lists to
send this to, you need to add the netdev list for it to be picked up
properly.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index d6b51e2b9495..50af1d9d0102 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -132,6 +132,33 @@  static void cdc_ncm_get_strings(struct net_device
__always_unused *netdev, u32 s

 static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32
new_tx);

+static void cdc_ncm_update_filter(struct usbnet *dev)
+{
+       struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
+	u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
+	struct net_device *net = dev->net;
+
+	u16 cdc_filter = USB_CDC_PACKET_TYPE_DIRECTED
+			| USB_CDC_PACKET_TYPE_BROADCAST;
+
+	/* filtering on the device is an optional feature and not worth
+	 * the hassle so we just roughly care about snooping and if any
+	 * multicast is requested, we take every multicast
+	 */
+	if (net->flags & IFF_PROMISC)
+		cdc_filter |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
+	if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI))
+		cdc_filter |= USB_CDC_PACKET_TYPE_ALL_MULTICAST;
+
+	usbnet_write_cmd(dev,
+			USB_CDC_SET_ETHERNET_PACKET_FILTER,
+			USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE,
+			cdc_filter,
+			iface_no,
+			NULL,
+			0);
+}
+
 static const struct ethtool_ops cdc_ncm_ethtool_ops = {