mbox series

[net-next,0/3] net: Preserve netdev_ops equality tests

Message ID 20200712221625.287763-1-f.fainelli@gmail.com
Headers show
Series net: Preserve netdev_ops equality tests | expand

Message

Florian Fainelli July 12, 2020, 10:16 p.m. UTC
Hi David, Jakub,

This patch series addresses a long standing with no known impact today
with the overloading of netdev_ops done by the DSA layer.

First we introduce a ndo_equal netdev_ops function pointer, then we have
DSA utilize it, and finally all in tree users are converted to using
either netdev_ops_equal() or __netdev_ops_equal() (for const struct
net_device reference).

I did my best to build test each driver being changed here.

A coccinelle script will be submitted later on when it works with the
coccicheck target integration.

Florian Fainelli (3):
  net: Introduce netdev_ops_equal
  net: dsa: Implement ndo_equal for CPU port net_device
  net: treewide: Convert to netdev_ops_equal()

 drivers/net/ethernet/broadcom/bcmsysport.c    |  4 +--
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c |  2 +-
 .../net/ethernet/cavium/liquidio/lio_vf_rep.c |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_rep.c  |  4 +--
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   |  2 +-
 .../net/ethernet/mellanox/mlxsw/spectrum.c    |  2 +-
 drivers/net/ethernet/mscc/ocelot_net.c        |  2 +-
 drivers/net/ethernet/netronome/nfp/nfp_net.h  |  2 +-
 .../net/ethernet/netronome/nfp/nfp_net_repr.h |  2 +-
 drivers/net/ethernet/rocker/rocker_main.c     |  2 +-
 drivers/net/ethernet/sfc/efx.c                |  2 +-
 drivers/net/ethernet/sfc/falcon/efx.c         |  2 +-
 .../net/ethernet/stmicro/stmmac/stmmac_main.c |  2 +-
 drivers/net/ethernet/ti/cpsw_new.c            |  2 +-
 drivers/net/ethernet/via/via-velocity.c       |  2 +-
 drivers/net/gtp.c                             |  2 +-
 drivers/net/hyperv/netvsc_drv.c               |  4 +--
 drivers/net/ipvlan/ipvlan_main.c              |  2 +-
 drivers/net/ppp/ppp_generic.c                 |  2 +-
 drivers/net/team/team.c                       |  2 +-
 drivers/net/tun.c                             |  4 +--
 .../broadcom/brcm80211/brcmfmac/core.c        |  4 +--
 drivers/net/wireless/quantenna/qtnfmac/core.c |  2 +-
 drivers/s390/net/qeth_l3_main.c               |  4 +--
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c       |  2 +-
 .../staging/unisys/visornic/visornic_main.c   |  2 +-
 include/linux/netdevice.h                     | 26 +++++++++++++++++++
 net/atm/clip.c                                |  2 +-
 net/dsa/master.c                              |  9 +++++++
 net/dsa/slave.c                               |  2 +-
 net/openvswitch/vport-internal_dev.c          |  4 +--
 net/openvswitch/vport-internal_dev.h          |  2 +-
 33 files changed, 73 insertions(+), 38 deletions(-)

Comments

Jakub Kicinski July 13, 2020, 8:09 p.m. UTC | #1
On Sun, 12 Jul 2020 15:16:22 -0700 Florian Fainelli wrote:
> Hi David, Jakub,
> 
> This patch series addresses a long standing with no known impact today
> with the overloading of netdev_ops done by the DSA layer.

Do you plan to make use of this comparison? Or trying to protect the
MAC driver from misbehaving because it's unaware the DSA may replace
its ops? For non-DSA experts I think it may be worth stating :)

> First we introduce a ndo_equal netdev_ops function pointer, then we have
> DSA utilize it, and finally all in tree users are converted to using
> either netdev_ops_equal() or __netdev_ops_equal() (for const struct
> net_device reference).

The experience with TCP ULPs made me dislike hijacking ops :( 
Maybe it's just my limited capability to comprehend complex systems
but the moment there is more than one entity that tries to insert
itself as a proxy, ordering etc. gets quite hairy.. Perhaps we 
have some well understood rules for ndo replacement but if that's not
the case I prefer the interception to be done explicitly in the caller.
(e.g. add separate dsa_ops to struct net_device and call that prior to/
/instead of calling the ndo).

At the very least I'd think it's better to create an explicit hierarchy
of the ops by linking them (add "const struct net_device_ops *base_ops"
to ndos) rather than one-off callback for comparisons.

That's just my 2ยข..
Florian Fainelli July 13, 2020, 9:20 p.m. UTC | #2
On 7/13/2020 1:09 PM, Jakub Kicinski wrote:
> On Sun, 12 Jul 2020 15:16:22 -0700 Florian Fainelli wrote:
>> Hi David, Jakub,
>>
>> This patch series addresses a long standing with no known impact today
>> with the overloading of netdev_ops done by the DSA layer.
> 
> Do you plan to make use of this comparison? Or trying to protect the
> MAC driver from misbehaving because it's unaware the DSA may replace
> its ops? For non-DSA experts I think it may be worth stating :)

We have at least one network device driver that is always used in a DSA
set-up (bcmsysport.c) which does check DSA notifiers against its own
netdev_ops, however this happens before the mangling of DSA netdev_ops
is done, so the check is not defeated there.

> 
>> First we introduce a ndo_equal netdev_ops function pointer, then we have
>> DSA utilize it, and finally all in tree users are converted to using
>> either netdev_ops_equal() or __netdev_ops_equal() (for const struct
>> net_device reference).
> 
> The experience with TCP ULPs made me dislike hijacking ops :( 
> Maybe it's just my limited capability to comprehend complex systems
> but the moment there is more than one entity that tries to insert
> itself as a proxy, ordering etc. gets quite hairy.. Perhaps we 
> have some well understood rules for ndo replacement but if that's not
> the case I prefer the interception to be done explicitly in the caller.
> (e.g. add separate dsa_ops to struct net_device and call that prior to/
> /instead of calling the ndo).
> 
> At the very least I'd think it's better to create an explicit hierarchy
> of the ops by linking them (add "const struct net_device_ops *base_ops"
> to ndos) rather than one-off callback for comparisons.

Initially I was going to introduce a way to do recursive operations, but
the problem with that approach is that you need to impose an ordering
within the core about how operations are invoked.

The idea to add dsa_ops as a singleton that DSA would provide (very much
like the recent ethtool_phy_ops introduction) is probably the sanest
approach.

Thanks for the suggestions and review Jakub!