* kenel level packet capturing [not found] <CAKj1SsP+GE=QqN8nx7aaAxXE8BODKb=vns_=SnbyySQjZp3-pg@mail.gmail.com> @ 2011-10-19 6:54 ` raviraj joshi 2011-10-19 7:12 ` Eric Dumazet ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: raviraj joshi @ 2011-10-19 6:54 UTC (permalink / raw) To: netdev, netfilter-devel, netfilter Hi, We are making a kernel level packet capture module as a part of our BE project . We are finding it difficult to understand kenel networking code. We studied structures and functions like sk_buff, netif_rx(),dev_alloc_skb. However we were not able to trace the actual path a simple packet follows. Moreover we tried to count the no of times netif_rx function was called it was much much lower than amount of packets actually being received. Can anyone please let us know the reason for this and how to approach the problem of writing a kernel level packet capture module ,resoruces we need to refer to (we are currently constrained to documents on kernel-networking available online). And even from where to get information about how forwarding(or packet flow) occours when we have virtual bridges (in terms of networking code). regards, Raviraj Joshi PICT,Pune. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-10-19 6:54 ` kenel level packet capturing raviraj joshi @ 2011-10-19 7:12 ` Eric Dumazet 2011-10-19 7:13 ` David Miller 2011-10-19 12:37 ` Benjamin Poirier 2 siblings, 0 replies; 12+ messages in thread From: Eric Dumazet @ 2011-10-19 7:12 UTC (permalink / raw) To: raviraj joshi; +Cc: netdev, netfilter-devel, netfilter Le mercredi 19 octobre 2011 à 12:24 +0530, raviraj joshi a écrit : > Hi, > > We are making a kernel level packet capture module as a part of our BE project . > We are finding it difficult to understand kenel networking code. > We studied structures and functions like sk_buff, netif_rx(),dev_alloc_skb. > > However we were not able to trace the actual path a simple packet follows. > > Moreover we tried to count the no of times netif_rx function was > called it was much much lower than amount of packets actually being > received. > > Can anyone please let us know the reason for this and how to approach > the problem of writing a kernel level packet capture module ,resoruces > we need to refer to (we are currently constrained to documents on > kernel-networking available online). > Most drivers call netif_receive_skb() from softirq handler netif_rx() is used only on cases where we are in hard irq handler, or we want to avoid a recursion (tunnels for example) To install a packet capture, you should take a look at dev_add_pack() and friends [ net/packet/af_packet.c being a good reference ] -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-10-19 6:54 ` kenel level packet capturing raviraj joshi 2011-10-19 7:12 ` Eric Dumazet @ 2011-10-19 7:13 ` David Miller 2011-10-19 8:52 ` Ajith Adapa 2011-10-19 12:37 ` Benjamin Poirier 2 siblings, 1 reply; 12+ messages in thread From: David Miller @ 2011-10-19 7:13 UTC (permalink / raw) To: raviraj.j1991; +Cc: netdev, netfilter-devel, netfilter From: raviraj joshi <raviraj.j1991@gmail.com> Date: Wed, 19 Oct 2011 12:24:01 +0530 > We are finding it difficult to understand kenel networking code. That's surprising, because the Linux networking stack is the cleanest real world networking implementation on the planet. Perhaps you should think about re-evaluating your project choice? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-10-19 7:13 ` David Miller @ 2011-10-19 8:52 ` Ajith Adapa 2011-10-19 12:30 ` Richard Cochran 0 siblings, 1 reply; 12+ messages in thread From: Ajith Adapa @ 2011-10-19 8:52 UTC (permalink / raw) To: David Miller; +Cc: raviraj.j1991, netdev, netfilter-devel, netfilter Yeah you are right David. But .. For a newbie who just know more about linux userspace level need to know starting steps like where to start from and flow of packet might be confusing because of the level of abstraction being used. I guess it might take some time until you are really serious about making hands dirty :) Regards, Ajith On Wed, Oct 19, 2011 at 12:43 PM, David Miller <davem@davemloft.net> wrote: > > From: raviraj joshi <raviraj.j1991@gmail.com> > Date: Wed, 19 Oct 2011 12:24:01 +0530 > > > We are finding it difficult to understand kenel networking code. > > That's surprising, because the Linux networking stack is the cleanest > real world networking implementation on the planet. > > Perhaps you should think about re-evaluating your project choice? > -- > To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-10-19 8:52 ` Ajith Adapa @ 2011-10-19 12:30 ` Richard Cochran 0 siblings, 0 replies; 12+ messages in thread From: Richard Cochran @ 2011-10-19 12:30 UTC (permalink / raw) To: Ajith Adapa Cc: David Miller, raviraj.j1991, netdev, netfilter-devel, netfilter On Wed, Oct 19, 2011 at 02:22:35PM +0530, Ajith Adapa wrote: > Yeah you are right David. But .. > > For a newbie who just know more about linux userspace level need to > know starting steps like where to start from and flow of packet might > be confusing because of the level of abstraction being used. I guess > it might take some time until you are really serious about making > hands dirty :) For working with or just reading kernel sources I recommend getting to know the cscope tool. Do a "make cscope" and then use one of the front end browsers. If you use emacs, then you really should have this set ; When working on the kernel (setq cscope-do-not-update-database t) otherwise it tries to re-index after every search. HTH, Richard ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-10-19 6:54 ` kenel level packet capturing raviraj joshi 2011-10-19 7:12 ` Eric Dumazet 2011-10-19 7:13 ` David Miller @ 2011-10-19 12:37 ` Benjamin Poirier 2011-12-13 12:04 ` raviraj joshi 2 siblings, 1 reply; 12+ messages in thread From: Benjamin Poirier @ 2011-10-19 12:37 UTC (permalink / raw) To: raviraj joshi; +Cc: netdev, netfilter-devel, netfilter On 11/10/19 12:24, raviraj joshi wrote: > Hi, > > We are making a kernel level packet capture module as a part of our BE project . > We are finding it difficult to understand kenel networking code. > We studied structures and functions like sk_buff, netif_rx(),dev_alloc_skb. > > However we were not able to trace the actual path a simple packet follows. You might find http://vger.kernel.org/netconf2011_slides/jesse_brandeburg_netconf2011.pdf interesting. It contains call chains of UDP processing at all levels in the stack (driver, below ip stack, above ip stack) for tx and rx. -Ben ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-10-19 12:37 ` Benjamin Poirier @ 2011-12-13 12:04 ` raviraj joshi 2011-12-13 18:36 ` David Miller 0 siblings, 1 reply; 12+ messages in thread From: raviraj joshi @ 2011-12-13 12:04 UTC (permalink / raw) To: netdev, netfilter-devel, netfilter Hi, We have to implement a kernel module for capturing of packets and dumping onto disk as a part of our BE project. We have decided to use PF_RING(a kernel module to capture packets) for the same due to the number of advantages. We have to now write a kernel module that will interact with pf_ring module to get data and dump it onto disk. To do this we figured out two approaches : 1. pf_ring has provided userland code to communicate with kernel module which in turn used "socket" system calls and specified protocol family as PF_RING(socket(PF_RING, SOCK_RAW, htons(ETH_P_ALL));) and subsequently used other functions like setsockopt to get packets. So one approach can be to use kernel counterparts of socket and setsockopt and reuse the userland code in our kernel module(this will save us from writing code to built some specific data structures and handleing exceptional conditions). 2. second approach can be to identify functions which capture packets in PF_RING kernel module and invoke them from our kernel moduel. Can anyone please comment on these approachs or tell us about other options available, we have to essentially use services provided by pf_ring module via a kernel module? and what things should we follow to accomplish these approaches ? PF_RING specific questions(if any one is aware of pf_ring please answer this): We went through the userland code of pf_ring and got to know that using pf_ring involves 1.setting up socket connection 2.binding the address 3.setting socket options 4.enabling socket ring 5.use packet_recv function to get packets 6.finally display packets and close the socket connection. is this procedure which we figured out right? we also found that the data we receive has two parts 1.pfring_pkthdr 2.sk_buff struct is this correct? we know this is not the right place to ask questions about pf_ring and we are extremely sorry for this ,but we posted the same questions on ntop mailing list and there was no response. thanking, Raviraj Joshi PICT,Pune. On Wed, Oct 19, 2011 at 6:07 PM, Benjamin Poirier <benjamin.poirier@gmail.com> wrote: > On 11/10/19 12:24, raviraj joshi wrote: >> Hi, >> >> We are making a kernel level packet capture module as a part of our BE project . >> We are finding it difficult to understand kenel networking code. >> We studied structures and functions like sk_buff, netif_rx(),dev_alloc_skb. >> >> However we were not able to trace the actual path a simple packet follows. > > You might find > http://vger.kernel.org/netconf2011_slides/jesse_brandeburg_netconf2011.pdf > interesting. It contains call chains of UDP processing at all levels in > the stack (driver, below ip stack, above ip stack) for tx and rx. > > -Ben ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-12-13 12:04 ` raviraj joshi @ 2011-12-13 18:36 ` David Miller 2011-12-14 10:46 ` raviraj joshi 0 siblings, 1 reply; 12+ messages in thread From: David Miller @ 2011-12-13 18:36 UTC (permalink / raw) To: raviraj.j1991; +Cc: netdev, netfilter-devel, netfilter From: raviraj joshi <raviraj.j1991@gmail.com> Date: Tue, 13 Dec 2011 17:34:22 +0530 > We have decided to use PF_RING(a kernel module to capture packets) for > the same due to the number of advantages. What "advantages"? The AF_PACKET socket layer already upstream in the kernel supports every relevant performance feature PF_RING does, and then some. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-12-13 18:36 ` David Miller @ 2011-12-14 10:46 ` raviraj joshi 2011-12-14 13:31 ` Jan Engelhardt 2011-12-14 16:09 ` David Miller 0 siblings, 2 replies; 12+ messages in thread From: raviraj joshi @ 2011-12-14 10:46 UTC (permalink / raw) To: David Miller; +Cc: netdev, netfilter-devel, netfilter On Wed, Dec 14, 2011 at 12:06 AM, David Miller <davem@davemloft.net> wrote: > From: raviraj joshi <raviraj.j1991@gmail.com> > Date: Tue, 13 Dec 2011 17:34:22 +0530 > >> We have decided to use PF_RING(a kernel module to capture packets) for >> the same due to the number of advantages. > > What "advantages"? The AF_PACKET socket layer already upstream in the > kernel supports every relevant performance feature PF_RING does, and > then some. I refered to the document on "A Measurement Study of Packet Reception using Linux"[1] which said pf_ring maintains a ring buffer, so we dont have to issue a receive system call for each packet in contrast to AF_PACKET which issues a system call for each packet(pls correct me if i am wrong). I would like to know can we use AF_PACKET services from a kernel module as we are not bound to pf_ring and can use AF_PACKET if its efficient and easy to use? thanking, Raviraj Joshi [1] http://www.cs.wustl.edu/~jain/cse567-11/ftp/pkt_recp/index.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-12-14 10:46 ` raviraj joshi @ 2011-12-14 13:31 ` Jan Engelhardt 2011-12-14 16:09 ` David Miller 1 sibling, 0 replies; 12+ messages in thread From: Jan Engelhardt @ 2011-12-14 13:31 UTC (permalink / raw) To: raviraj joshi; +Cc: David Miller, netdev, netfilter-devel, netfilter On Wednesday 2011-12-14 11:46, raviraj joshi wrote: >On Wed, Dec 14, 2011 at 12:06 AM, David Miller wrote: >> >>>We have decided to use PF_RING(a kernel module to capture packets) >>>for the same due to the number of advantages. >> >>What "advantages"? The AF_PACKET socket layer already upstream in >>the kernel supports every relevant performance feature PF_RING >>does, and then some. > >I refered to the document on "A Measurement Study of Packet >Reception using Linux"[1] which said pf_ring maintains a ring >buffer, so we dont have to issue a receive system call for each >packet in contrast to AF_PACKET which issues a system call for each >packet(pls correct me if i am wrong). AF_PACKET has had mmap support for a loooong time. The initial code traces back to 2.3.15pre3 (1999-Aug-23). So much for $academia. >[1] >http://www.cs.wustl.edu/~jain/cse567-11/ftp/pkt_recp/index.html -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-12-14 10:46 ` raviraj joshi 2011-12-14 13:31 ` Jan Engelhardt @ 2011-12-14 16:09 ` David Miller 2011-12-15 15:19 ` Eduardo Panisset 1 sibling, 1 reply; 12+ messages in thread From: David Miller @ 2011-12-14 16:09 UTC (permalink / raw) To: raviraj.j1991; +Cc: netdev, netfilter-devel, netfilter From: raviraj joshi <raviraj.j1991@gmail.com> Date: Wed, 14 Dec 2011 16:16:01 +0530 > On Wed, Dec 14, 2011 at 12:06 AM, David Miller <davem@davemloft.net> wrote: >> From: raviraj joshi <raviraj.j1991@gmail.com> >> Date: Tue, 13 Dec 2011 17:34:22 +0530 >> >>> We have decided to use PF_RING(a kernel module to capture packets) for >>> the same due to the number of advantages. >> >> What "advantages"? The AF_PACKET socket layer already upstream in the >> kernel supports every relevant performance feature PF_RING does, and >> then some. > I refered to the document on "A Measurement Study of Packet Reception > using Linux"[1] which said pf_ring maintains > a ring buffer, so we dont have to issue a receive system call for each > packet in contrast to AF_PACKET which issues a system call for each > packet(pls correct me if i am wrong). AF_PACKET supports mmap()'d packet rings, and even supports variable packet lengths within those rings. AF_PACKET supports all the worthwhile performance features of PR_RING and it's upstream, stop kidding yourself. I'm really sick and tired of people saying PF_RING is better than what we have upstream, it really isn't. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: kenel level packet capturing 2011-12-14 16:09 ` David Miller @ 2011-12-15 15:19 ` Eduardo Panisset 0 siblings, 0 replies; 12+ messages in thread From: Eduardo Panisset @ 2011-12-15 15:19 UTC (permalink / raw) To: David Miller; +Cc: raviraj.j1991, netdev, netfilter-devel, netfilter Hi Raviraj, You could be interested in taking a look at "Documentation/networking/packet_mmap.txt" (this talks about mmap()'d packet ring implementation for AF_PACKET). Rgds, Eduardo Panisset. On Wed, Dec 14, 2011 at 2:09 PM, David Miller <davem@davemloft.net> wrote: > From: raviraj joshi <raviraj.j1991@gmail.com> > Date: Wed, 14 Dec 2011 16:16:01 +0530 > >> On Wed, Dec 14, 2011 at 12:06 AM, David Miller <davem@davemloft.net> wrote: >>> From: raviraj joshi <raviraj.j1991@gmail.com> >>> Date: Tue, 13 Dec 2011 17:34:22 +0530 >>> >>>> We have decided to use PF_RING(a kernel module to capture packets) for >>>> the same due to the number of advantages. >>> >>> What "advantages"? The AF_PACKET socket layer already upstream in the >>> kernel supports every relevant performance feature PF_RING does, and >>> then some. >> I refered to the document on "A Measurement Study of Packet Reception >> using Linux"[1] which said pf_ring maintains >> a ring buffer, so we dont have to issue a receive system call for each >> packet in contrast to AF_PACKET which issues a system call for each >> packet(pls correct me if i am wrong). > > AF_PACKET supports mmap()'d packet rings, and even supports variable > packet lengths within those rings. > > AF_PACKET supports all the worthwhile performance features of PR_RING > and it's upstream, stop kidding yourself. > > I'm really sick and tired of people saying PF_RING is better than > what we have upstream, it really isn't. > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-12-15 15:19 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CAKj1SsP+GE=QqN8nx7aaAxXE8BODKb=vns_=SnbyySQjZp3-pg@mail.gmail.com> 2011-10-19 6:54 ` kenel level packet capturing raviraj joshi 2011-10-19 7:12 ` Eric Dumazet 2011-10-19 7:13 ` David Miller 2011-10-19 8:52 ` Ajith Adapa 2011-10-19 12:30 ` Richard Cochran 2011-10-19 12:37 ` Benjamin Poirier 2011-12-13 12:04 ` raviraj joshi 2011-12-13 18:36 ` David Miller 2011-12-14 10:46 ` raviraj joshi 2011-12-14 13:31 ` Jan Engelhardt 2011-12-14 16:09 ` David Miller 2011-12-15 15:19 ` Eduardo Panisset
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).