On 10/16/2020 1:02 PM, Christian Eggers wrote:
Ensure that the skb is not cloned and has enough tail room for the tail tag. This code will be removed from the drivers in the next commits. Signed-off-by: Christian Eggers <cegg...@arri.de> ---
[snip]
+ /* We have to pad he packet to the minimum Ethernet frame size, + * if necessary, before adding the trailer (tail tagging only). + */ + padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; + + /* To keep the slave's xmit() methods simple, don't pass cloned skbs to + * them. Additionally ensure, that suitable room for tail tagging is + * available. + */ + if (skb_cloned(skb) || + (p->tail_tag && skb_tailroom(skb) < (padlen + p->overhead))) { + struct sk_buff *nskb; + + nskb = alloc_skb(NET_IP_ALIGN + skb->len + + padlen + p->overhead, GFP_ATOMIC); + if (!nskb) { + kfree_skb(skb); + return NETDEV_TX_OK; + } + skb_reserve(nskb, NET_IP_ALIGN); + + skb_reset_mac_header(nskb); + skb_set_network_header(nskb, + skb_network_header(skb) - skb->head); + skb_set_transport_header(nskb, + skb_transport_header(skb) - skb->head); + skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len)); + consume_skb(skb); + + if (padlen) + skb_put_zero(nskb, padlen); + + skb = nskb; + }
Given the low number of tail taggers, maybe this should be a helper function that is used by them where applicable? If nothing else you may want to sprinkle unlikely() conditions to sort of hing the processor that these are unlikely conditions.
-- Florian