Skip to content
  1. Mar 14, 2022
    • Vladimir Oltean's avatar
      net: dsa: report and change port default priority using dcbnl · d538eca8
      Vladimir Oltean authored
      The port-based default QoS class is assigned to packets that lack a
      VLAN PCP (or the port is configured to not trust the VLAN PCP),
      an IP DSCP (or the port is configured to not trust IP DSCP), and packets
      on which no tc-skbedit action has matched.
      
      Similar to other drivers, this can be exposed to user space using the
      DCB Application Priority Table. IEEE 802.1Q-2018 specifies in Table
      D-8 - Sel field values that when the Selector is 1, the Protocol ID
      value of 0 denotes the "Default application priority. For use when
      application priority is not otherwise specified."
      
      The way in which the dcbnl integration in DSA has been designed has to
      do with its requirements. Andrew Lunn explains that SOHO switches are
      expected to come with some sort of pre-configured QoS profile, and that
      it is desirable for this to come pre-loaded into the DSA slave interfaces'
      DCB application priority table.
      
      In the dcbnl design, this is possible because calls to dcb_ieee_setapp()
      can be initiated by anyone including being self-initiated by this device
      driver.
      
      However, what makes this challenging to implement in DSA is that the DSA
      core manages the net_devices (effectively hiding them from drivers),
      while drivers manage the hardware. The DSA core has no knowledge of what
      individual drivers' QoS policies are. DSA could export to drivers a
      wrapper over dcb_ieee_setapp() and these could call that function to
      pre-populate the app priority table, however drivers don't have a good
      moment in time to do this. The dsa_switch_ops :: setup() method gets
      called before the net_devices are created (dsa_slave_create), and so is
      dsa_switch_ops :: port_setup(). What remains is dsa_switch_ops ::
      port_enable(), but this gets called upon each ndo_open. If we add app
      table entries on every open, we'd need to remove them on close, to avoid
      duplicate entry errors. But if we delete app priority entries on close,
      what we delete may not be the initial, driver pre-populated entries, but
      rather user-added entries.
      
      So it is clear that letting drivers choose the timing of the
      dcb_ieee_setapp() call is inappropriate. The alternative which was
      chosen is to introduce hardware-specific ops in dsa_switch_ops, and
      effectively hide dcbnl details from drivers as well. For pre-populating
      the application table, dsa_slave_dcbnl_init() will call
      ds->ops->port_get_default_prio() which is supposed to read from
      hardware. If the operation succeeds, DSA creates a default-prio app
      table entry. The method is called as soon as the slave_dev is
      registered, but before we release the rtnl_mutex. This is done such that
      user space sees the app table entries as soon as it sees the interface
      being registered.
      
      The fact that we populate slave_dev->dcbnl_ops with a non-NULL pointer
      changes behavior in dcb_doit() from net/dcb/dcbnl.c, which used to
      return -EOPNOTSUPP for any dcbnl operation where netdev->dcbnl_ops is
      NULL. Because there are still dcbnl-unaware DSA drivers even if they
      have dcbnl_ops populated, the way to restore the behavior is to make all
      dcbnl_ops return -EOPNOTSUPP on absence of the hardware-specific
      dsa_switch_ops method.
      
      The dcbnl framework absurdly allows there to be more than one app table
      entry for the same selector and protocol (in other words, more than one
      port-based default priority). In the iproute2 dcb program, there is a
      "replace" syntactical sugar command which performs an "add" and a "del"
      to hide this away. But we choose the largest configured priority when we
      call ds->ops->port_set_default_prio(), using __fls(). When there is no
      default-prio app table entry left, the port-default priority is restored
      to 0.
      
      Link: https://patchwork.kernel.org/project/netdevbpf/patch/20210113154139.1803705-2-olteanv@gmail.com/
      
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d538eca8
    • Victor Nogueira's avatar
      selftests: tc-testing: Increase timeout in tdc config file · 102e4a8e
      Victor Nogueira authored
      
      
      Some tests, such as Test d052: Add 1M filters with the same action, may
      not work with a small timeout value.
      
      Increase timeout to 24 seconds.
      
      Signed-off-by: default avatarVictor Nogueira <victor@mojatatu.com>
      Acked-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      102e4a8e
    • Sebastian Andrzej Siewior's avatar
      net: Add lockdep asserts to ____napi_schedule(). · fbd9a2ce
      Sebastian Andrzej Siewior authored
      
      
      ____napi_schedule() needs to be invoked with disabled interrupts due to
      __raise_softirq_irqoff (in order not to corrupt the per-CPU list).
      ____napi_schedule() needs also to be invoked from an interrupt context
      so that the raised-softirq is processed while the interrupt context is
      left.
      
      Add lockdep asserts for both conditions.
      While this is the second time the irq/softirq check is needed, provide a
      generic lockdep_assert_softirq_will_run() which is used by both caller.
      
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fbd9a2ce
    • David S. Miller's avatar
      Merge branch 'macvlan-uaf' · d96657dc
      David S. Miller authored
      
      
      Ziyang Xuan says:
      
      ====================
      net: macvlan: fix potential UAF problem for lowerdev
      
      Add the reference operation to lowerdev of macvlan to avoid
      the potential UAF problem under the following known scenario:
      
      Someone module puts the NETDEV_UNREGISTER event handler to a
      work, and lowerdev is accessed in the work handler. But when
      the work is excuted, lowerdev has been destroyed because upper
      macvlan did not get reference to lowerdev correctly.
      
      In addition, add net device refcount tracker to macvlan.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d96657dc
    • Ziyang Xuan's avatar
      net: macvlan: add net device refcount tracker · 1f4a5983
      Ziyang Xuan authored
      
      
      Add net device refcount tracker to macvlan.
      
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1f4a5983
    • Ziyang Xuan's avatar
      net: macvlan: fix potential UAF problem for lowerdev · 291ac684
      Ziyang Xuan authored
      Add the reference operation to lowerdev of macvlan to avoid
      the potential UAF problem under the following known scenario:
      
      Someone module puts the NETDEV_UNREGISTER event handler to a
      work, and lowerdev is accessed in the work handler. But when
      the work is excuted, lowerdev has been destroyed because upper
      macvlan did not get reference to lowerdev correctly.
      
      That likes as the scenario occurred by
      commit 563bcbae
      
       ("net: vlan: fix a UAF in vlan_dev_real_dev()").
      
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      291ac684
  2. Mar 13, 2022
  3. Mar 12, 2022