From patchwork Fri Jun 29 14:47:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Miguel_Rodr=C3=ADguez_P=C3=A9rez?= X-Patchwork-Id: 10496799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 558226016C for ; Fri, 29 Jun 2018 14:47:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FDC0299C7 for ; Fri, 29 Jun 2018 14:47:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4454B299F0; Fri, 29 Jun 2018 14:47:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2493299C7 for ; Fri, 29 Jun 2018 14:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936349AbeF2Ord (ORCPT ); Fri, 29 Jun 2018 10:47:33 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44909 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932254AbeF2Orc (ORCPT ); Fri, 29 Jun 2018 10:47:32 -0400 Received: by mail-wr0-f194.google.com with SMTP id p12-v6so9099129wrn.11 for ; Fri, 29 Jun 2018 07:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=det.uvigo.gal; s=clouddet; h=subject:from:to:references:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pNpu9NtFjhwPpfNY/agavyotG+Fb6Mve2FzCNrLDw6k=; b=Bcrhv7SLbs46CP34iU7F7J1cbCLd1qfsF6BbKM5Hq0Xrc4GNLsnp44N4BtoPxQaTY6 QFu6xFh9AfRKlded1KRVb5o0EfAAnT8CnN61XP+FTXa4bvRlfeJRJ9jAD+xs/ROVmtfn Cc0TGY69K6hRMFzQqH4SRKWd/ZQIyIZ/hJuZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=pNpu9NtFjhwPpfNY/agavyotG+Fb6Mve2FzCNrLDw6k=; b=mwe4NwobLQ/7qVwTp0nYHTlGb47lUMdVDzKxXwM2f86gXtBFB46knMwN1ZInkZ81Fe P3pxvmq03uhPKqEWzj3gLpVicKzTFQpUD8RP83pXbt/sM++VYnwdUuVk8Yj9OtaZy61T L06O4LqzI2sHzIsxUiQfKNAA0Il86nIdoawJTknr0cwInJN3AXD0H4xaeuQJgxFiquh7 NlyMGqT6H8H40+V/+dSb/NiquT4K4W4KOK/Fn1ctS7VzuHozAGobZsnLSHreKMaXVa8m cTUKcqB/MxH8QHeTclnxJzrGwMsI65p5TpAWGsru1YszYmTcnWryZjyrkcxtmsv1VZT+ P7Pw== X-Gm-Message-State: APt69E31YONwgXkCQLS6bhwSf9TUxxLYUtpXF8/So8i1wBMb7P+dMsG+ uUYXDbh+ruKsqI6RIjN1n1loeQbzSpnzSf2TbzvmLgTSrdtokSH5l/dy5m1Y/tM9EnlPNHMY1OP B+Y+jfAe4xaXpyF6f+zPcxOhtnCeowCdaOSE2fvKsuQryr99XC4GbdBRLxU+HijrGe2I/6+A= X-Google-Smtp-Source: AAOMgperprT4BfOgnre95wXA8Y+2QOjosj7TPl6IxGzAhf/7JLrpsBD1SREpnrAHBI8gYT/0cH6daw== X-Received: by 2002:adf:9c12:: with SMTP id f18-v6mr12587203wrc.40.1530283650710; Fri, 29 Jun 2018 07:47:30 -0700 (PDT) Received: from [192.168.0.166] (static-74-52-84-188.ipcom.comunitel.net. [188.84.52.74]) by smtp.gmail.com with ESMTPSA id e17-v6sm10868049wrr.85.2018.06.29.07.47.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 07:47:30 -0700 (PDT) Subject: Re: [PATCH 1/2 ] cdc_ncm: Handle multicast Ethernet traffic From: =?UTF-8?Q?Miguel_Rodr=c3=adguez_P=c3=a9rez?= To: linux-usb@vger.kernel.org References: <8ff3fe73-db19-1859-1b97-32b4c25beff6@det.uvigo.gal> <05205f33-1e1a-663c-c43d-8ce3f4e2a32f@det.uvigo.gal> Openpgp: preference=signencrypt Autocrypt: addr=miguel@det.uvigo.gal; prefer-encrypt=mutual; keydata= xsFNBFKN0FkBEADwUPUfsvRB6B3st20xFpvP1OPXbjYcNFaTLEgvELYnTGJWFatqrQqdODO9 QEbVRopidVe/gndDijKxBrwTMLgX6CqIKX0TPcj1Nu5YqwJEKuKyY+O2Y9dZxFa9mohnAJ7D lB9pKFvPXVzBnGoD8/ziOKanDgawsJPLQ5GlNvozl6RveFvuSKfif4XM++EJjDpY1GQjF/Ux F/TdskY205QUz+rHV6K5GZ0GyqysRULg/hC7UyW0FJ3zl+ic7IVerXQmF8N+qcI+4D87bJPA GMHfTvu0HJkaN6TG+wrnKp7BTJ2Qa/aD6+N0Nrr/WVkOaZ3he3lZlfrkAs4X8/6M4LW1YtBu hUvIA7fOB17ND5B2TTmazalUQ+oiSs8SPg9nVKYj+x4McqxhWcon9l3oFRxhdRMlAWKkw5zF eB3rP/Br2WQSqcJI6djQvhQitZLH0aIWjPnCbGamNfmZB2uJ8Pz5aQbhyTB9T0MHNudbdQ36 0br+EA86qZhnvx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2A7mpfVIf5E3zcymGEdV7tGWmb+pVSQainZQMcTzUso+Kv/TnhMpFMc+0rVqjf6vg Xq+an/PFFql9I2LELacTOncMzXTX5TF30rxFQCOwghAZXdEY2dk9IBwOhTG08m2MOcplNlN/ iZwsnmqybwfRBKOEunVvLdpIMIZ44x5dJTJiGIP/I9sftxOU92AW8Xpgf+q6ZshOm3YoJcfO 1zb9pCXtARf7K2jKmB5NRSoW4dnCA0xmi3pBSjiZE3XYwKG4t4JppTmvuGhQuJPQ11/i4oHN YHInhj+XVbAEvSrkZFlI6GfCPjY= Message-ID: Date: Fri, 29 Jun 2018 16:47:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <05205f33-1e1a-663c-c43d-8ce3f4e2a32f@det.uvigo.gal> Content-Language: es-ES Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 = {