Re: [PATCH net-next v4 2/5] net: dsa: add out-of-band tagging protocol

From: Vladimir Oltean
Date: Fri Sep 16 2022 - 20:15:41 EST


Hi Maxime,

On Fri, Sep 09, 2022 at 05:24:51PM +0200, Maxime Chevallier wrote:
> +int dsa_oob_tag_push(struct sk_buff *skb, struct dsa_oob_tag_info *ti)
> +{
> + struct dsa_oob_tag_info *tag_info;
> +
> + tag_info = (struct dsa_oob_tag_info *)skb->head;
> +
> + tag_info->proto = ti->proto;
> + tag_info->dp = ti->dp;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(dsa_oob_tag_push);
> +
> +int dsa_oob_tag_pop(struct sk_buff *skb, struct dsa_oob_tag_info *ti)
> +{
> + struct dsa_oob_tag_info *tag_info;
> +
> + tag_info = (struct dsa_oob_tag_info *)skb->head;
> +
> + if (tag_info->proto != DSA_TAG_PROTO_OOB)
> + return -EINVAL;
> +
> + ti->proto = tag_info->proto;
> + ti->dp = tag_info->dp;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(dsa_oob_tag_pop);
> +
> +static struct sk_buff *oob_tag_xmit(struct sk_buff *skb,
> + struct net_device *dev)
> +{
> + struct dsa_port *dp = dsa_slave_to_port(dev);
> + struct dsa_oob_tag_info tag_info;
> +
> + tag_info.dp = dp->index;
> + tag_info.proto = DSA_TAG_PROTO_OOB;
> +
> + if (dsa_oob_tag_push(skb, &tag_info))
> + return NULL;
> +
> + return skb;
> +}

I don't have too many comments on this patch set, except for a very
fundamental one. It is impossible to pass a DSA out of band header
between the switch tagging protocol driver and the host Ethernet
controller via the beginning of skb->head, and just putting some magic
bytes there and hoping that no random junk in the buffer will have the
same value (and that skb_push() calls will not eat into your tag_info
structure which isn't accounted for in any way by skb->data).

Please create an skb extension for this, it is the only unambiguous way
to deal with the given hardware, which will not give lots of headaches
in the future.