Skip to contentSkip to conversation

: tunnel mode processing

RFC jamal 2 participants 7 messages Sep 1, 2006

Subsystems (2)
lore
Share & tools
lore

jamal

author
#0 lore raw

At the moment transport mode processing is not dependent on skb->dst being passed. Tunnel mode derives the ip->id and ttl from it. More like computes ip->id.

I am trying to generate traffic via pktgen and it would be nice if i could get the same behavior on tunnel mode as in transport mode. I dont think it matters what the values of those two fields are.

Would it be reasonable to do a check so that incase a skb->dst doesnt exist, the inner headers values can be used i.e something along xfrm4_tunnel_output()::

----

        top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
                0 : (iph->frag_off & htons(IP_DF));
	if (dst) {
		if (!top_iph->frag_off) 
			__ip_select_ident(top_iph, dst->child, 0);
		top_iph->ttl = dst_metric(dst->child, RTAX_HOPLIMIT);
	} else {
		top_iph->id = iph->id;
		top_iph->ttl = iph->ttl;
	}

----

cheers,
jamal

#1 lore raw
Quoted 4 lines · jamal

Would it be reasonable to do a check so that incase a skb->dst doesnt exist, the inner headers values can be used i.e something along xfrm4_tunnel_output()::

If you didn't care what values they were, couldn't you just stuff some bogus dst into the skb? If this packet is going somewhere you're going to have a dst one way or another :)

Also, the IPID is only generated if DF is not set on the packet. Otherwise this path is already as fast as it can be.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author
#2 lore raw
Quoted 8 lines · Herbert Xu
Quoted 4 lines · jamal

Would it be reasonable to do a check so that incase a skb->dst doesnt exist, the inner headers values can be used i.e something along xfrm4_tunnel_output()::

If you didn't care what values they were, couldn't you just stuff some bogus dst into the skb?

That bogus dst is NULL ;->

Quoted 2 lines

If this packet is going somewhere you're going
to have a dst one way or another :)

If i was going to use routing/layer 3, then true. At the pktgen level "somewhere" is just "shove down the ether". Actually (i havent thought clearly about this) wouldnt a bump in the wire implementation aka bridging level also not care about route details?
Note: This does not absolve the need for a secure ipid or a proper ttl.

Quoted 2 lines

Also, the IPID is only generated if DF is not set on the packet. Otherwise this path is already as fast as it can be.

In the case of traffic generation, if i could shave even more cycles the better since i want to generate high speed. In this case the cycles would be in creating a fake dst and attaching it some fake values.

I do agree that it is an awkward way of achieving my goals - but i dont know of a clever way to do it ;->

cheers,
jamal

#3 lore raw
Quoted 4 lines · jamal

In the case of traffic generation, if i could shave even more cycles the better since i want to generate high speed. In this case the cycles would be in creating a fake dst and attaching it some fake values.

Right, you're testing the receiver side. In that case I suggest that you replicate the IPsec transport mode logic in the generator. Just as pktgen doesn't use net/ipv4/udp.c to generate UDP traffic, it doesn't really need to use xfrm4_output.c to generate IPsec traffic.

You can still call down to esp4.c through the type pointer of course.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author
#4 lore raw
Quoted 1 line · Herbert Xu

Right, you're testing the receiver side.

both in/out sides (on the receiver); i just count and drop all packets coming back to the sender (the pktgenerator)

Quoted 2 lines

In that case I suggest that
you replicate the IPsec transport mode logic in the generator.

Tunnel mode you mean, i think.

Quoted 4 lines

Just
as pktgen doesn't use net/ipv4/udp.c to generate UDP traffic, it doesn't really need to use xfrm4_output.c to generate IPsec traffic.

IPsec is slightly different since i need to use state in the core. i.e it is stateful. Nothing that pktgen does today has such requirements.

Quoted 1 line

You can still call down to esp4.c through the type pointer of course.

Thats one idea i havent thought of.

i.e the code would look like:
-----

        if (mode == tunnel) 
		err = mytunneloutput (x, skb);
	else 
        	err = x->mode->output(x, skb);
        if (err)
                goto error;
        err = x->type->output(x, skb);

--

This is what you are suggesting?
I am probably better off going back to creating a dummy dst with just those two fields when in tunnel mode;->

cheers,
jamal

#5 lore raw
Quoted 12 lines · jamal

Thats one idea i havent thought of.

i.e the code would look like:
-----

        if (mode == tunnel) 
		err = mytunneloutput (x, skb);
	else 
        	err = x->mode->output(x, skb);
        if (err)
                goto error;
        err = x->type->output(x, skb);
Quoted 3 lines

--

This is what you are suggesting?

Yes, I suppose you could even replace x->mode directly.

Quoted 2 lines

I am probably better off going back to creating a dummy dst with just those two fields when in tunnel mode;->

Probably. Although if you write your own output function you could make it go faster by adapting it to the specifics of pktgen.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author
#6 lore raw
Quoted 7 lines · Herbert Xu

Yes, I suppose you could even replace x->mode directly.

Quoted 2 lines

I am probably better off going back to creating a dummy dst with just those two fields when in tunnel mode;->

Probably. Although if you write your own output function you could make it go faster by adapting it to the specifics of pktgen.

gah. Ok, probably better solution to go this path then ;->

cheers,
jamal