Subject: Re: [PATCH RFC 8/9] vti: Update the ipv4 side to use it's own receive hook.

From: Steffen Klassert <[email-masked]>
Date: Fri, 13 Dec 2013 10:56:48 +0100

On Thu, Dec 12, 2013 at 05:26:55PM +0100, Nicolas Dichtel wrote:
> Le 05/12/2013 13:05, Steffen Klassert a écrit :
> >
> >-/* We dont digest the packet therefore let the packet pass */
> >  static int vti_rcv(struct sk_buff *skb)
> >  {
> >  	struct ip_tunnel *tunnel;
> >@@ -60,48 +61,72 @@ static int vti_rcv(struct sk_buff *skb)
> >  	tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY,
> >  				  iph->saddr, iph->daddr, 0);
> >  	if (tunnel != NULL) {
> >-		struct pcpu_tstats *tstats;
> >-		u32 oldmark = skb->mark;
> >-		int ret;
> >+		if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
> >+			goto drop;
> >+
> >+		XFRM_TUNNEL_SKB_CB(skb)->tunnel = tunnel;
> >+
> >+		/* Partially clear the buffer, the rest is done by xfrm_input. */
> >+		if (!net_eq(tunnel->net, dev_net(tunnel->dev)))
> >+			skb_orphan(skb);
> >+		skb->tstamp.tv64 = 0;
> >+		skb->pkt_type = PACKET_HOST;
> >+		skb->skb_iif = 0;
> >+		nf_reset_trace(skb);
> >+		secpath_reset(skb);
> Is it not better to call skb_scrub_packet() (if necessary adding a new
> argument to skip some operations)?

Yes, looks like we can simply use skb_scrub_packet(). xfrm_input()
will do nf_reset() and skb_dst_drop() again, but this should not
harm too much.

I'll incorporate this into the v2 patchest.

Thanks!