On Saturday 21 June 2014 16:57:42 Simon Wunderlich wrote:
Looks like copy & paste from batadv_bla_process_claim() ? How about using a shared function ?
Yeah, it's copy and pasted. The only thing which we could put into a common function are the 4 checks, the local variables are used in a different way for the further code in each function. This didn't really look worth it so I didn't bother to refactor in that patch, if you feel otherwise let me know and i'll refactor in v2.
How about moving the while loop into batadv_bla_process_claim() itself ?
Something like:
if (vid & BATADV_VLAN_HAS_TAG) { vhdr = vlan_eth_hdr(skb); proto = vhdr->h_vlan_encapsulated_proto; headlen += VLAN_HLEN; }
if (proto == htons(ETH_P_8021Q)) { do { vhdr_ptr = skb_header_pointer(skb, headlen, VLAN_HLEN, &vhdr); if (!vhdr_ptr) return 0;
headlen += VLAN_HLEN;
} while (vhdr_ptr->h_vlan_encapsulated_proto == htons(ETH_P_8021Q));
proto = vhdr->h_vlan_encapsulated_proto; }
if (proto != htons(ETH_P_ARP)) return 0; /* not a claim frame */
Towards the BLA claim check you can then check whether this BLA frame was encapsulated more than once (through a local variable).
Cheers, Marek