Lorenzo Bianconi lorenzo@kernel.org wrote:
Lorenzo Bianconi lorenzo@kernel.org wrote:
+static bool nf_flow_ip4_encap_proto(struct sk_buff *skb, u16 *size) +{
- struct iphdr *iph;
- if (!pskb_may_pull(skb, sizeof(*iph)))
return false;
Nit: I think this could be 2 * sizeof() and a comment that we will also need the inner ip header later, might save one reallocation.
nf_flow_ip4_encap_proto() is used even for plain IP traffic but I guess we can assume the IP payload is at least 20B, right?
Oh, right, I missed that. But even if we have a.g. ip header with icmp header, then the postconditions are the same, no?
as-is: pskb_may_pull -> ok, then iph->protocol == IPPROTO_IPIP -> return false
with 2*iph: pskb_may_pull -> return false
... but I'll leave it up to you, if you prefer pskb_may_pull(skb, sizeof(*iph))) for clarity then lets keep it as-is.
- iph = (struct iphdr *)skb_network_header(skb);
- *size = iph->ihl << 2;
I think this should be sanity tested vs. sizeof(iph).
I guess this is already done in ip_has_options(), agree?
Indeed it is! Nevermind then :-)