* [1/2] cdc_ncm: Handle multicast Ethernet traffic
@ 2018-06-29 18:15 Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2018-06-29 18:15 UTC (permalink / raw)
To: Miguel Rodríguez Pérez; +Cc: linux-usb
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [1/2] cdc_ncm: Handle multicast Ethernet traffic
@ 2018-06-30 14:24 Miguel Rodríguez Pérez
0 siblings, 0 replies; 6+ messages in thread
From: Miguel Rodríguez Pérez @ 2018-06-30 14:24 UTC (permalink / raw)
To: Oliver Neukum, linux-usb
There is nothing wrong with it, but there was no way cdc_ncm driver
could use it, as it currently overwrites the struct net_device_ops, so
the usbnet function set_rx_mode was not ever getting called.
This patch restores the right behavior, so that usbnet's set _rx_mode
gets called again for cdn_ncm devices. The second patch (the one with
the wrong subject) hooks into set_rx_mode to accept multicast traffic
when asked to do so.
Regards.
On 29/06/18 22:37, Oliver Neukum wrote:
> On Fr, 2018-06-29 at 16:45 +0200, Miguel Rodríguez Pérez wrote:
>> Subject: [PATCH 1/2] Hook into usbnet_change_mtu respecting usbnet
>> driver_info
>>
>> Change the way cdc_ncm_change_mtu hooks into the netdev_ops
>> structure so that changes into usbnet driver_info operations
>> can be respected. Without this, is was not possible to hook
>> into usbnet_set_rx_mode.
>
> Hi,
>
> what is wrong with the existing hook?
>
> 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);
> }
>
> If you cannot use it, I would prefer you to actually fix that.
>
> Regards
> Oliver
>
^ permalink raw reply [flat|nested] 6+ messages in thread* [1/2] cdc_ncm: Handle multicast Ethernet traffic
@ 2018-06-30 13:41 Miguel Rodríguez Pérez
0 siblings, 0 replies; 6+ messages in thread
From: Miguel Rodríguez Pérez @ 2018-06-30 13:41 UTC (permalink / raw)
To: Oliver Neukum, linux-usb
There is nothing wrong with it, but there was no way cdc_ncm driver
could use it, as it currently overwrites the struct net_device_ops, so
the usbnet function set_rx_mode was not ever getting called.
This patch restores the right behavior, so that usbnet's set _rx_mode
gets called again for cdn_ncm devices. The second patch (the one with
the wrong subject) hooks into set_rx_mode to accept multicast traffic
when asked to do so.
Regards.
On 29/06/18 22:37, Oliver Neukum wrote:
> On Fr, 2018-06-29 at 16:45 +0200, Miguel Rodríguez Pérez wrote:
>> Subject: [PATCH 1/2] Hook into usbnet_change_mtu respecting usbnet
>> driver_info
>>
>> Change the way cdc_ncm_change_mtu hooks into the netdev_ops
>> structure so that changes into usbnet driver_info operations
>> can be respected. Without this, is was not possible to hook
>> into usbnet_set_rx_mode.
>
> Hi,
>
> what is wrong with the existing hook?
>
> 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);
> }
>
> If you cannot use it, I would prefer you to actually fix that.
>
> Regards
> Oliver
>
^ permalink raw reply [flat|nested] 6+ messages in thread* [1/2] cdc_ncm: Handle multicast Ethernet traffic
@ 2018-06-29 20:37 Oliver Neukum
0 siblings, 0 replies; 6+ messages in thread
From: Oliver Neukum @ 2018-06-29 20:37 UTC (permalink / raw)
To: Miguel Rodríguez Pérez, linux-usb
On Fr, 2018-06-29 at 16:45 +0200, Miguel Rodríguez Pérez wrote:
> Subject: [PATCH 1/2] Hook into usbnet_change_mtu respecting usbnet
> driver_info
>
> Change the way cdc_ncm_change_mtu hooks into the netdev_ops
> structure so that changes into usbnet driver_info operations
> can be respected. Without this, is was not possible to hook
> into usbnet_set_rx_mode.
Hi,
what is wrong with the existing hook?
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);
}
If you cannot use it, I would prefer you to actually fix that.
Regards
Oliver
---
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
^ permalink raw reply [flat|nested] 6+ messages in thread* [1/2] cdc_ncm: Handle multicast Ethernet traffic
@ 2018-06-29 14:47 Miguel Rodríguez Pérez
0 siblings, 0 replies; 6+ messages in thread
From: Miguel Rodríguez Pérez @ 2018-06-29 14:47 UTC (permalink / raw)
To: linux-usb
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 */
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 = {
^ permalink raw reply related [flat|nested] 6+ messages in thread* [1/2] cdc_ncm: Handle multicast Ethernet traffic
@ 2018-06-29 14:45 Miguel Rodríguez Pérez
0 siblings, 0 replies; 6+ messages in thread
From: Miguel Rodríguez Pérez @ 2018-06-29 14:45 UTC (permalink / raw)
To: linux-usb
Subject: [PATCH 1/2] Hook into usbnet_change_mtu respecting usbnet
driver_info
Change the way cdc_ncm_change_mtu hooks into the netdev_ops
structure so that changes into usbnet driver_info operations
can be respected. Without this, is was not possible to hook
into usbnet_set_rx_mode.
Signed-off-by: Miguel Rodríguez Pérez <miguel@det.uvigo.gal>
---
drivers/net/usb/cdc_ncm.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
u8 data_altsetting, int drvflags)
{
@@ -939,6 +930,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct
usb_interface *intf, u8 data_
dev->net->sysfs_groups[0] = &cdc_ncm_sysfs_attr_group;
/* must handle MTU changes */
+ cdc_ncm_netdev_ops = *dev->net->netdev_ops;
+ cdc_ncm_netdev_ops.ndo_change_mtu = cdc_ncm_change_mtu;
dev->net->netdev_ops = &cdc_ncm_netdev_ops;
dev->net->max_mtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev);
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 9e1b74590682..d6b51e2b9495 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -750,16 +750,7 @@ int cdc_ncm_change_mtu(struct net_device *net, int
new_mtu)
}
EXPORT_SYMBOL_GPL(cdc_ncm_change_mtu);
-static const struct net_device_ops cdc_ncm_netdev_ops = {
- .ndo_open = usbnet_open,
- .ndo_stop = usbnet_stop,
- .ndo_start_xmit = usbnet_start_xmit,
- .ndo_tx_timeout = usbnet_tx_timeout,
- .ndo_get_stats64 = usbnet_get_stats64,
- .ndo_change_mtu = cdc_ncm_change_mtu,
- .ndo_set_mac_address = eth_mac_addr,
- .ndo_validate_addr = eth_validate_addr,
-};
+static struct net_device_ops cdc_ncm_netdev_ops;
int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf,
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-06-30 14:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-29 18:15 [1/2] cdc_ncm: Handle multicast Ethernet traffic Greg KH
-- strict thread matches above, loose matches on Subject: below --
2018-06-30 14:24 Miguel Rodríguez Pérez
2018-06-30 13:41 Miguel Rodríguez Pérez
2018-06-29 20:37 Oliver Neukum
2018-06-29 14:47 Miguel Rodríguez Pérez
2018-06-29 14:45 Miguel Rodríguez Pérez
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).