linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about ipip implementation
@ 2001-05-11 14:39 ` Alexey Vyskubov
  2001-05-12 17:40   ` Andi Kleen
  2001-05-13 13:16   ` Olaf Titz
  0 siblings, 2 replies; 6+ messages in thread
From: Alexey Vyskubov @ 2001-05-11 14:39 UTC (permalink / raw)
  To: linux-kernel

Hello!

I read net/ipv4/ipip.c. It seems to me that ipip_rcv() function after
"unwrapping" tunelled IP packet creates "virtual Ethernet header" and submit
corresponding sk_buff to netif_rx().

Is there a some reason to do things this way instead of calling ip_rcv() for
"unwrapped" IP packet?

-- 
Alexey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question about ipip implementation
  2001-05-11 14:39 ` Question about ipip implementation Alexey Vyskubov
@ 2001-05-12 17:40   ` Andi Kleen
  2001-05-13 13:16   ` Olaf Titz
  1 sibling, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2001-05-12 17:40 UTC (permalink / raw)
  To: Alexey Vyskubov; +Cc: linux-kernel

On Fri, May 11, 2001 at 05:39:40PM +0300, Alexey Vyskubov wrote:
> Hello!
> 
> I read net/ipv4/ipip.c. It seems to me that ipip_rcv() function after
> "unwrapping" tunelled IP packet creates "virtual Ethernet header" and submit
> corresponding sk_buff to netif_rx().
> 
> Is there a some reason to do things this way instead of calling ip_rcv() for
> "unwrapped" IP packet?

e.g. packet sockets still work and it doesn't break the layering.


-Andi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question about ipip implementation
  2001-05-11 14:39 ` Question about ipip implementation Alexey Vyskubov
  2001-05-12 17:40   ` Andi Kleen
@ 2001-05-13 13:16   ` Olaf Titz
  2001-05-14 11:07     ` Alexey Vyskubov
  2001-05-15 11:15     ` Olaf Titz
  1 sibling, 2 replies; 6+ messages in thread
From: Olaf Titz @ 2001-05-13 13:16 UTC (permalink / raw)
  To: linux-kernel

> I read net/ipv4/ipip.c. It seems to me that ipip_rcv() function after
> "unwrapping" tunelled IP packet creates "virtual Ethernet header" and submit

Does it? ipip_rcv() does this:

	iph = skb->nh.iph;
	skb->mac.raw = skb->nh.raw;

i.e. the "MAC header" pointer of the packet is the same as the IP
header, iow. no MAC header available

	skb->nh.raw = skb->data;

Although I don't exactly understand this :-) it does not add a header

	memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));

this must be cleared before processing the packet

	skb->protocol = __constant_htons(ETH_P_IP);
	skb->pkt_type = PACKET_HOST;

mark it as an IP packet

	read_lock(&ipip_lock);
	if ((tunnel = ipip_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) {
		tunnel->stat.rx_packets++;
		tunnel->stat.rx_bytes += skb->len;
		skb->dev = tunnel->dev;

mark the incoming device

		dst_release(skb->dst);
		skb->dst = NULL;
#ifdef CONFIG_NETFILTER
		nf_conntrack_put(skb->nfct);
		skb->nfct = NULL;
#ifdef CONFIG_NETFILTER_DEBUG
		skb->nf_debug = 0;
#endif
#endif

more clearing of fields / release of resources associated with the packet

		ipip_ecn_decapsulate(iph, skb);

handle ECN flags

		netif_rx(skb);

The packet as submitted starts with the IP header and the skb pointers
are set up so that the MAC header has zero size.

Olaf

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question about ipip implementation
  2001-05-13 13:16   ` Olaf Titz
@ 2001-05-14 11:07     ` Alexey Vyskubov
  2001-05-15 11:15     ` Olaf Titz
  1 sibling, 0 replies; 6+ messages in thread
From: Alexey Vyskubov @ 2001-05-14 11:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: olaf

> > I read net/ipv4/ipip.c. It seems to me that ipip_rcv() function after
> > "unwrapping" tunelled IP packet creates "virtual Ethernet header" and submit
> 
> Does it? ipip_rcv() does this:

[SKIP]

> 		netif_rx(skb);
> 
> The packet as submitted starts with the IP header and the skb pointers
> are set up so that the MAC header has zero size.


Yes, I was wrong. But is it possible in similar situation just call ip_rcv for
the sk_buff?

-- 
Alexey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question about ipip implementation
  2001-05-13 13:16   ` Olaf Titz
  2001-05-14 11:07     ` Alexey Vyskubov
@ 2001-05-15 11:15     ` Olaf Titz
  2001-05-16  7:53       ` Olaf Titz
  1 sibling, 1 reply; 6+ messages in thread
From: Olaf Titz @ 2001-05-15 11:15 UTC (permalink / raw)
  To: Alexey Vyskubov; +Cc: linux-kernel

> Yes, I was wrong. But is it possible in similar situation just call
> ip_rcv for the sk_buff?

What does "just call" mean? The additional setup done by the ipip
receiver is the minimum necessary to get the various parameters in the
sk_buff in a clean state (things like making sure all header pointers
are valid, clearing the private options field etc). These are either
done by all network drivers, or are necessary because we use an
existing and already handled (as opposed to newly allocated) sk_buff.

Olaf

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Question about ipip implementation
  2001-05-15 11:15     ` Olaf Titz
@ 2001-05-16  7:53       ` Olaf Titz
  0 siblings, 0 replies; 6+ messages in thread
From: Olaf Titz @ 2001-05-16  7:53 UTC (permalink / raw)
  To: Alexey Vyskubov; +Cc: linux-kernel

> Well, I understand that ipip_rcv does some work cleaning sk_buff.
> But why after that sk_buff cannot be submitted to ip_rcv, not
> netif_rx?

Oops, now I see that you're talking about ip_rcv, not netif_rx...

I'm doing roughly what you're proposing in CIPE (get IP packet
encapsulated in UDP packet via UDP receiver mechanism, strip UDP and
optional SOCKS5 headers, submit to processing) but I'm using netif_rx
simply because I copied code from the ipip driver ;-)
(and because this is the standard way a network driver is supposed to
submit input).

I'm not exactly sure if it is supposed to be possible to deliver
directly into ip_rcv. The code which gets invoked after queuing
(net_rx_action() in net/core/dev.c) does something more than just
dispatching into the receiver, like handling diversion and bridges,
and manipulates fields of the skb itself.

Olaf

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-05-16  8:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20010516102436.B1972@Hews1193nrc>
2001-05-11 14:39 ` Question about ipip implementation Alexey Vyskubov
2001-05-12 17:40   ` Andi Kleen
2001-05-13 13:16   ` Olaf Titz
2001-05-14 11:07     ` Alexey Vyskubov
2001-05-15 11:15     ` Olaf Titz
2001-05-16  7:53       ` Olaf Titz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).