Question about ipip implementation
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?
Signature · 1 line
Alexey
Quoted 8 lines · Alexey Vyskubov
Hello!
I read
net/ipv4/ipip.c. It seems to me thatipip_rcv()function after "unwrapping" tunelled IP packet creates "virtual Ethernet header" and submit correspondingsk_bufftonetif_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
Quoted 2 lines
I read
net/ipv4/ipip.c. It seems to me thatipip_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
Quoted 4 lines
Quoted 2 lines
I read
net/ipv4/ipip.c. It seems to me thatipip_rcv()function after "unwrapping" tunelled IP packet creates "virtual Ethernet header" and submitDoes it?
ipip_rcv()does this:
[SKIP]
Quoted 4 lines
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?
Signature · 1 line
Alexey
Quoted 2 lines
Yes, I was wrong. But is it possible in similar situation just call
ip_rcvfor thesk_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