[Cake] [PATCH net v2] sched: consistently handle layer3 header accesses in the presence of VLANs
Roman Mashak
mrv at mojatatu.com
Fri Jul 3 16:16:15 EDT 2020
Toke Høiland-Jørgensen <toke at redhat.com> writes:
[...]
> +/* A getter for the SKB protocol field which will handle VLAN tags consistently
> + * whether VLAN acceleration is enabled or not.
> + */
> +static inline __be16 skb_protocol(const struct sk_buff *skb, bool skip_vlan)
> +{
> + unsigned int offset = skb_mac_offset(skb) + sizeof(struct ethhdr);
> + __be16 proto = skb->protocol;
> + struct vlan_hdr vhdr, *vh;
Nit: you could move vhdr and *vh definitions inside the while loop,
because of their inner scope use.
> +
> + if (!skip_vlan)
> + /* VLAN acceleration strips the VLAN header from the skb and
> + * moves it to skb->vlan_proto
> + */
> + return skb_vlan_tag_present(skb) ? skb->vlan_proto : proto;
> +
> + while (eth_type_vlan(proto)) {
> + vh = skb_header_pointer(skb, offset, sizeof(vhdr), &vhdr);
> + if (!vh)
> + break;
> +
> + proto = vh->h_vlan_encapsulated_proto;
> + offset += sizeof(vhdr);
> + }
[...]
More information about the Cake
mailing list