Re: solution reqd

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

 



Perhaps you're having difficulty figuring out how the loopback device
receives packets because it never really anonymously receives anything
-- it only receives whenever someone transmits something on device lo.

On a transmit when the protocol stack determines the lo device is the
actual device the packet needs to be transmitted out, the lo device's
transmit routine (in loopback_init.c, dev->hard_start_xmit is set to
loopback_xmit) will disassociate the packet from the transmit socket and
place it on the incoming net receive queue.  netif_rx takes care of the
queueing.  Then the net receive code finds anyone who wants the packet
and then what you describe below takes place to queue the packet to the
receive queue of the interested socket and wake up any process blocked
on the socket (sk->data_ready) etc.

For a regular net device (eth for instance), the hardware gets a packet,
and an sk_buff is allocated out of the free pool.  The code in
loopback_xmit does the equivalent by "making the packet that needs to be
transmitted meet the conditions that a freshly allocated skbuff is in"
so it can be put on the net receive queue just like a real eth device
does.  For speed, when a single socket owns the packet, skb_orphan is
called to call the sk_buff destructor function which actually decrements
the transmit socket's sndbuf count -- this is what implements the send
queue on a socket and keeps a single socket from taking up too many
system buffers.  The skbuff is then available to be placed on a new
socket or in the general network receive queue.  When there's more than
one owner of the skb (skb->users > 1) then the existing skb information
is left alone and skb_clone is called to create a new skb info portion
that points to the same data and this is put on the general network
receive queue.  I'm not sure when more than one user of an sk_buff
occurs in the system -- perhaps someone else on the list can come up
with an example.

Hope this helps.

-Eric

siva prasad wrote:

> Hi all,
>
> In case of loopback , after searching
> and finding the right 'sock' to send to,
> sk->data_ready(sk,skb_len) is invoked .
> The appropriate protocol's xxx_create
> function initialises sk->data_ready()
> to a function which takes care of the
> rest of the story on the receiving side.
> Where does the loopback driver come into
> the scene..? Please explain...
>
> Thanking you in advance
>
> espe
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
> -
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> IRC Channel:   irc.openprojects.net / #kernelnewbies
> Web Page:      http://www.kernelnewbies.org/

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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