Hi,
just some ideas (maybe not all of them are good):
[...]
ethhdr = eth_hdr(skb);
switch (ntohs(ethhdr->h_proto)) {
case ETH_P_IP:
iphdr = skb_header_pointer(skb, ETH_HLEN, sizeof(tmp_iphdr),
&tmp_iphdr);
break;
case ETH_P_8021Q:
vhdr = skb_header_pointer(skb, 0, sizeof(tmp_vhdr),
&tmp_vhdr);
if (!vhdr)
break;
Do we need to continue here when there is no vhdr? Maybe just return.
if (ntohs(vhdr->h_vlan_encapsulated_proto) == ETH_P_IP) {
Maybe the check here could be inverted to just return when this is not ETH_P_IP
iphdr = skb_header_pointer(skb, sizeof(tmp_vhdr),
sizeof(tmp_iphdr),
&tmp_iphdr);
}
break;
}
if (iphdr) {
You could just modify the check to:
if (!iphdr) return;
Kind regards, Sven