Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to receive packets on a virtual interface?

    Hi i would receive packets that arrives on a NIC also on a virtual interfaces...these packets are of type ETH_P_802_2. I would open a raw socket (AF_PACKET), bind it on the virtual interface (let's say virt0) and sniff...So which is the correct way to do this? I found only a way: register a new protocol handler for packets of type ETH_P_802_2 and pass the packets to virt0 by netif_receive_skb method. However the system restarts when my method is called (the system doesn't restart if i comment the call to netif_receive_skb) Maybe i'm missing something...


    - Which are the difference between netif_rx and netif_receive_skb?
    if i use netif_rx instead of netif_receive_skb the system doesn't crash but becomes very slow...By debugging a UML system i noticed that if i send only one packet
    netif_receive_skb is called a lot of time like there was a loop...

    - When my protocol handler is called the skb->data points to the beginning of the eth header or it was already stripped out?

    - Which is the correct way to set skb->protocol field?

    Thank you all for the help!

    Last edited by MirkoBanchi; 07-27-2011 at 11:45 AM.

  2. #2
    Maybe i found the reason for the crash...setting skb->protocol in the following manner:
    skb->dev = virt0;
    skb->protocol = eth_type_trans(skb, skb->dev);
    the system doesn't crash and doesn't become slow. However in user space i don't receive nothing if i bind the socket with interface can i pass the frame to user-space?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts