mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
net: check for driver support in netmem TX
We should not enable netmem TX for drivers that don't declare support. Check for driver netmem TX support during devmem TX binding and fail if the driver does not have the functionality. Check for driver support in validate_xmit_skb as well. Signed-off-by: Mina Almasry <almasrymina@google.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250508004830.4100853-9-almasrymina@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
c32532670c
commit
ae28cb1147
@@ -3896,12 +3896,42 @@ sw_checksum:
|
||||
}
|
||||
EXPORT_SYMBOL(skb_csum_hwoffload_help);
|
||||
|
||||
static struct sk_buff *validate_xmit_unreadable_skb(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct skb_shared_info *shinfo;
|
||||
struct net_iov *niov;
|
||||
|
||||
if (likely(skb_frags_readable(skb)))
|
||||
goto out;
|
||||
|
||||
if (!dev->netmem_tx)
|
||||
goto out_free;
|
||||
|
||||
shinfo = skb_shinfo(skb);
|
||||
|
||||
if (shinfo->nr_frags > 0) {
|
||||
niov = netmem_to_net_iov(skb_frag_netmem(&shinfo->frags[0]));
|
||||
if (net_is_devmem_iov(niov) &&
|
||||
net_devmem_iov_binding(niov)->dev != dev)
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
out:
|
||||
return skb;
|
||||
|
||||
out_free:
|
||||
kfree_skb(skb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev, bool *again)
|
||||
{
|
||||
netdev_features_t features;
|
||||
|
||||
if (!skb_frags_readable(skb))
|
||||
goto out_kfree_skb;
|
||||
skb = validate_xmit_unreadable_skb(skb, dev);
|
||||
if (unlikely(!skb))
|
||||
goto out_null;
|
||||
|
||||
features = netif_skb_features(skb);
|
||||
skb = validate_xmit_vlan(skb, features);
|
||||
|
||||
Reference in New Issue
Block a user