Re: Tracing IPv6 packets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jay,

You can do an identifier search of "ipv6_rcv" on lxr.linux.no, and
then you will find the a ipv6_packet_type has the structure:
60 static struct packet_type ipv6_packet_type = {
61         .type = __constant_htons(ETH_P_IPV6),
62         .func = ipv6_rcv,
63 };

Then search for ipv6_packet_type:
You will see that it is added by the device in:
696 void __init ipv6_packet_init(void)
697 {
698         dev_add_pack(&ipv6_packet_type);
699 }

Now search for dev_add_pack; you will see that list_add_rcu is invoked:
272 void dev_add_pack(struct packet_type *pt)
273 {
274         int hash;
275
276         spin_lock_bh(&ptype_lock);
277         if (pt->type == htons(ETH_P_ALL)) {
278                 netdev_nit++;
279                 list_add_rcu(&pt->list, &ptype_all);
280         } else {
281                 hash = ntohs(pt->type) & 15;
282                 list_add_rcu(&pt->list, &ptype_base[hash]);
283         }
284         spin_unlock_bh(&ptype_lock);
285 }

Now search for netif_receive_skb; (invoked when an skb is queued):
This effectively calls deliver_skb (which pushes the packet up the stack)
Now look for deliver_skb; you will find that it will call:
1559         return pt_prev->func(skb, skb->dev, pt_prev);

So now ipv6_rcv would be called if it is an IPv6 packet.

Ok now the packet can finally take the flow for a regular IPv6 packet! :-)

Thanks,
Avinash.

On 7/25/06, Jay Cliburn <jacliburn@xxxxxxxxxxxxx> wrote:
I'm trying to trace a received IPv6 packet through the kernel, but I'm
having a hard time.  I can't find the point at which a packet IP header
is examined by the kernel which then says, "You're IPv4; you go this
way," or "You're IPv6; you go that way."

I can follow the packet through the device driver until it's handed up
to netif_rx() in net/core/dev.c, at which time it gets enqueued and an
interrupt is raised, but I can't find the entry point for the packet on
the other side of the interrupt.  It looks like the packet eventually
ends up at ipv6_rcv() in /net/ipv6/ip6_input.c, but I can't find how it
gets there, nor what happened after it was enqueued that identified it
as an IPv6 packet.

Can someone point me in the right direction?

Thanks,
Jay

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux