lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200421150504.GZ6581@nanopsycho.orion>
Date:   Tue, 21 Apr 2020 17:05:04 +0200
From:   Jiri Pirko <jiri@...nulli.us>
To:     Maor Gottlieb <maorg@...lanox.com>
Cc:     davem@...emloft.net, jgg@...lanox.com, dledford@...hat.com,
        j.vosburgh@...il.com, vfalico@...il.com, andy@...yhouse.net,
        kuba@...nel.org, jiri@...lanox.com, dsahern@...nel.org,
        leonro@...lanox.com, saeedm@...lanox.com,
        linux-rdma@...r.kernel.org, netdev@...r.kernel.org,
        alexr@...lanox.com
Subject: Re: [PATCH V3 mlx5-next 01/15] net/core: Introduce
 master_get_xmit_slave

Tue, Apr 21, 2020 at 12:28:30PM CEST, maorg@...lanox.com wrote:
>Add new ndo to get the xmit slave of master device.
>User should release the slave when it's not longer needed.

"User" is a bit misleading.
Perhaps "Caller should call dev_put() when it no longer works with slave
netdevice". "


>When slave selection method is based on hash, then the user can ask to
>get the xmit slave assume all the slaves can transmit.

This is not specific for selection method.


>
>Signed-off-by: Maor Gottlieb <maorg@...lanox.com>
>---
> include/linux/netdevice.h | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
>diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>index 130a668049ab..ab324a2b04c8 100644
>--- a/include/linux/netdevice.h
>+++ b/include/linux/netdevice.h
>@@ -1389,6 +1389,9 @@ struct net_device_ops {
> 						 struct netlink_ext_ack *extack);
> 	int			(*ndo_del_slave)(struct net_device *dev,
> 						 struct net_device *slave_dev);
>+	struct net_device*	(*ndo_get_xmit_slave)(struct net_device *dev,
>+						      struct sk_buff *skb,
>+						      bool all_slaves);
> 	netdev_features_t	(*ndo_fix_features)(struct net_device *dev,
> 						    netdev_features_t features);
> 	int			(*ndo_set_features)(struct net_device *dev,
>@@ -4676,6 +4679,36 @@ static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol,
> 	skb->mac_len = mac_len;
> }
> 
>+/**
>+ * master_get_xmit_slave - Get the xmit slave of master device
>+ * @skb: The packet
>+ * @all_slaves: assume all the slaves are active
>+ *
>+ * This can be called from any context and does its own locking.
>+ * The returned handle has the usage count incremented and the caller must
>+ * use dev_put() to release it when it is no longer needed.
>+ * %NULL is returned if no slave is found.
>+ */
>+
>+static inline
>+struct net_device *master_get_xmit_slave(struct net_device *dev,
>+					 struct sk_buff *skb,
>+					 bool all_slaves)

1) this function is a bit too big to be inline. Conside moving it to
dev.c
2) Please rename the function to contain netdev_ prefix preferably:
netdev_get_xmit_slave()
the ndo does not contain "master", don't have it here.


>+{
>+	const struct net_device_ops *ops = dev->netdev_ops;
>+	struct net_device *slave_dev;
>+
>+	if (!ops->ndo_get_xmit_slave)
>+		return NULL;
>+
>+	rcu_read_lock();
>+	slave_dev = ops->ndo_get_xmit_slave(dev, skb, all_slaves);
>+	if (slave_dev)
>+		dev_hold(slave_dev);
>+	rcu_read_unlock();
>+	return slave_dev;
>+}
>+
> static inline bool netif_is_macsec(const struct net_device *dev)
> {
> 	return dev->priv_flags & IFF_MACSEC;
>-- 
>2.17.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ