Re: [PATCH] flow_dissector: Fix vlan header offset in __skb_flow_dissect

From: Jiri Pirko
Date: Thu Jun 20 2019 - 03:25:26 EST


Wed, Jun 19, 2019 at 08:39:38PM CEST, sdf@xxxxxxxxxxx wrote:
>On 06/20, YueHaibing wrote:
>> We build vlan on top of bonding interface, which vlan offload
>> is off, bond mode is 802.3ad (LACP) and xmit_hash_policy is
>> BOND_XMIT_POLICY_ENCAP34.
>>
>> __skb_flow_dissect() fails to get information from protocol headers
>> encapsulated within vlan, because 'nhoff' is points to IP header,
>> so bond hashing is based on layer 2 info, which fails to distribute
>> packets across slaves.
>>
>> Fixes: d5709f7ab776 ("flow_dissector: For stripped vlan, get vlan info from skb->vlan_tci")
>> Signed-off-by: YueHaibing <yuehaibing@xxxxxxxxxx>
>> ---
>> net/core/flow_dissector.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
>> index 415b95f..2a52abb 100644
>> --- a/net/core/flow_dissector.c
>> +++ b/net/core/flow_dissector.c
>> @@ -785,6 +785,9 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
>> skb && skb_vlan_tag_present(skb)) {
>> proto = skb->protocol;
>> } else {
>> + if (dissector_vlan == FLOW_DISSECTOR_KEY_MAX)
>> + nhoff -= sizeof(*vlan);
>> +
>Should we instead fix the place where the skb is allocated to properly
>pull vlan (skb_vlan_untag)? I'm not sure this particular place is

Yes.

>supposed to work with an skb. Having an skb with nhoff pointing to
>IP header but missing skb_vlan_tag_present() when with
>proto==ETH_P_8021xx seems weird.
>
>> vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan),
>> data, hlen, &_vlan);
>> if (!vlan) {
>> --
>> 2.7.0
>>
>>