• M
    net: cdc_ncm: switch to eth%d interface naming · 198e342b
    Maciej Żenczykowski 提交于
    stable inclusion
    from stable-5.10.46
    commit 11fac7e9127078fe3275642742cf5e2336fa934a
    bugzilla: 168323
    CVE: NA
    
    --------------------------------
    
    [ Upstream commit c1a3d406 ]
    
    This is meant to make the host side cdc_ncm interface consistently
    named just like the older CDC protocols: cdc_ether & cdc_ecm
    (and even rndis_host), which all use 'FLAG_ETHER | FLAG_POINTTOPOINT'.
    
    include/linux/usb/usbnet.h:
      #define FLAG_ETHER	0x0020		/* maybe use "eth%d" names */
      #define FLAG_WLAN	0x0080		/* use "wlan%d" names */
      #define FLAG_WWAN	0x0400		/* use "wwan%d" names */
      #define FLAG_POINTTOPOINT 0x1000	/* possibly use "usb%d" names */
    
    drivers/net/usb/usbnet.c @ line 1711:
      strcpy (net->name, "usb%d");
      ...
      // heuristic:  "usb%d" for links we know are two-host,
      // else "eth%d" when there's reasonable doubt.  userspace
      // can rename the link if it knows better.
      if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
          ((dev->driver_info->flags & FLAG_POINTTOPOINT) == 0 ||
           (net->dev_addr [0] & 0x02) == 0))
              strcpy (net->name, "eth%d");
      /* WLAN devices should always be named "wlan%d" */
      if ((dev->driver_info->flags & FLAG_WLAN) != 0)
              strcpy(net->name, "wlan%d");
      /* WWAN devices should always be named "wwan%d" */
      if ((dev->driver_info->flags & FLAG_WWAN) != 0)
              strcpy(net->name, "wwan%d");
    
    So by using ETHER | POINTTOPOINT the interface naming is
    either usb%d or eth%d based on the global uniqueness of the
    mac address of the device.
    
    Without this 2.5gbps ethernet dongles which all seem to use the cdc_ncm
    driver end up being called usb%d instead of eth%d even though they're
    definitely not two-host.  (All 1gbps & 5gbps ethernet usb dongles I've
    tested don't hit this problem due to use of different drivers, primarily
    r8152 and aqc111)
    
    Fixes tag is based purely on git blame, and is really just here to make
    sure this hits LTS branches newer than v4.5.
    
    Cc: Lorenzo Colitti <lorenzo@google.com>
    Fixes: 4d06dd53 ("cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind")
    Signed-off-by: NMaciej Żenczykowski <maze@google.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NChen Jun <chenjun102@huawei.com>
    Acked-by: NWeilong Chen <chenweilong@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    198e342b
cdc_ncm.c 61.2 KB