Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: usb: cdc-ncm: check for filtering capability

If the decice does not support filtering, filtering
must not be used and all packets delivered for the
upper layers to sort.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Link: https://patch.msgid.link/20250717120649.2090929-1-oneukum@suse.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Oliver Neukum and committed by
Jakub Kicinski
61c3e894 72b4612a

+17 -4
+16 -4
drivers/net/usb/cdc_ncm.c
··· 892 892 } 893 893 } 894 894 895 + if (ctx->func_desc) 896 + ctx->filtering_supported = !!(ctx->func_desc->bmNetworkCapabilities 897 + & USB_CDC_NCM_NCAP_ETH_FILTER); 898 + 895 899 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; 896 900 897 901 /* Device-specific flags */ ··· 1902 1898 } 1903 1899 } 1904 1900 1901 + static void cdc_ncm_update_filter(struct usbnet *dev) 1902 + { 1903 + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; 1904 + 1905 + if (ctx->filtering_supported) 1906 + usbnet_cdc_update_filter(dev); 1907 + } 1908 + 1905 1909 static const struct driver_info cdc_ncm_info = { 1906 1910 .description = "CDC NCM (NO ZLP)", 1907 1911 .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET ··· 1920 1908 .status = cdc_ncm_status, 1921 1909 .rx_fixup = cdc_ncm_rx_fixup, 1922 1910 .tx_fixup = cdc_ncm_tx_fixup, 1923 - .set_rx_mode = usbnet_cdc_update_filter, 1911 + .set_rx_mode = cdc_ncm_update_filter, 1924 1912 }; 1925 1913 1926 1914 /* Same as cdc_ncm_info, but with FLAG_SEND_ZLP */ ··· 1934 1922 .status = cdc_ncm_status, 1935 1923 .rx_fixup = cdc_ncm_rx_fixup, 1936 1924 .tx_fixup = cdc_ncm_tx_fixup, 1937 - .set_rx_mode = usbnet_cdc_update_filter, 1925 + .set_rx_mode = cdc_ncm_update_filter, 1938 1926 }; 1939 1927 1940 1928 /* Same as cdc_ncm_info, but with FLAG_SEND_ZLP */ ··· 1976 1964 .status = cdc_ncm_status, 1977 1965 .rx_fixup = cdc_ncm_rx_fixup, 1978 1966 .tx_fixup = cdc_ncm_tx_fixup, 1979 - .set_rx_mode = usbnet_cdc_update_filter, 1967 + .set_rx_mode = cdc_ncm_update_filter, 1980 1968 }; 1981 1969 1982 1970 /* Same as wwan_info, but with FLAG_NOARP */ ··· 1990 1978 .status = cdc_ncm_status, 1991 1979 .rx_fixup = cdc_ncm_rx_fixup, 1992 1980 .tx_fixup = cdc_ncm_tx_fixup, 1993 - .set_rx_mode = usbnet_cdc_update_filter, 1981 + .set_rx_mode = cdc_ncm_update_filter, 1994 1982 }; 1995 1983 1996 1984 static const struct usb_device_id cdc_devs[] = {
+1
include/linux/usb/cdc_ncm.h
··· 119 119 u32 timer_interval; 120 120 u32 max_ndp_size; 121 121 u8 is_ndp16; 122 + u8 filtering_supported; 122 123 union { 123 124 struct usb_cdc_ncm_ndp16 *delayed_ndp16; 124 125 struct usb_cdc_ncm_ndp32 *delayed_ndp32;