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  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]
Date:   Fri, 3 May 2019 19:07:37 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Vladimir Oltean <olteanv@...il.com>, vivien.didelot@...il.com,
        andrew@...n.ch, davem@...emloft.net
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 5/9] net: dsa: Add support for deferred xmit



On 5/3/2019 6:18 PM, Vladimir Oltean wrote:
> Some hardware needs to take some convincing work in order to receive
> frames on the CPU port (such as the sja1105 which takes temporary L2
> forwarding rules over SPI that last for a single frame). Such work needs
> a sleepable context, and because the regular .ndo_start_xmit is atomic,
> this cannot be done in the tagger. So introduce a generic DSA mechanism
> that sets up a transmit skb queue and a workqueue for deferred
> transmission.
> 
> The new driver callback (.port_deferred_xmit) is in dsa_switch and not
> in the tagger because the operations that require sleeping typically
> also involve interacting with the hardware, and not simply skb
> manipulations. Therefore having it there simplifies the structure a bit
> and makes it unnecessary to export functions from the driver to the
> tagger.
> 
> The driver is responsible of calling dsa_enqueue_skb which transfers it
> to the master netdevice. This is so that it has a chance of performing
> some more work afterwards, such as cleanup or TX timestamping.
> 
> To tell DSA that skb xmit deferral is required, I have thought about
> changing the return type of the tagger .xmit from struct sk_buff * into
> a enum dsa_tx_t that could potentially encode a DSA_XMIT_DEFER value.
> 
> But the trailer tagger is reallocating every skb on xmit and therefore
> making a valid use of the pointer return value. So instead of reworking
> the API in complicated ways, right now a boolean property in the newly
> introduced DSA_SKB_CB is set.
> 
> Signed-off-by: Vladimir Oltean <olteanv@...il.com>
> ---

[snip]

>  static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
>  {
>  	struct dsa_slave_priv *p = netdev_priv(dev);
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 8ad9bf957da1..cfb8cba6458c 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -120,6 +120,9 @@ static int dsa_slave_close(struct net_device *dev)
>  	struct net_device *master = dsa_slave_to_master(dev);
>  	struct dsa_port *dp = dsa_slave_to_port(dev);
>  
> +	cancel_work_sync(&dp->xmit_work);
> +	skb_queue_purge(&dp->xmit_queue);
> +
>  	phylink_stop(dp->pl);

Don't you also need to do that for dsa_slave_suspend() in case the
xmit() raced with netif_device_detach() somehow?


-- 
Florian

Powered by blists - more mailing lists