On Saturday 02 July 2016 06:09:50 Linus Lüssing wrote:
[...]
> +
> +     if (vid & BATADV_VLAN_HAS_TAG)
> +             skb = vlan_insert_tag(skb, htons(ETH_P_8021Q),
> +                                   vid & VLAN_VID_MASK);
> +
> +     skb_reset_mac_header(skb);
> +
> +     return skb;
> +}

vlan_insert_tag can return NULL when an error happens. Thus simply doing
a skb_reset_mac_header on it without checking skb's value for !NULL is a
bad idea.

But you can simply move the skb_reset_mac_header (when it is really
necessary) in front of the 'if (vid & BATADV_VLAN_HAS_TAG)'.

Doing it in front would result in (written as absolute values - in
reality mac_header is an offset):

    skb->mac_header = skb->data
    skb->data -= VLAN_HLEN
    skb->mac_header -= VLAN_HLEN

Writing it after the vlan_insert_tag would result in:

    skb->data -= VLAN_HLEN
    skb->mac_header -= VLAN_HLEN
    skb->mac_header = skb->data

Both calculations should result in skb->mac_header == skb->data

Kind regards,
        Sven

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to