From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Prashant Batra (prbatra)" <prbatra@cisco.com>
Cc: netdev@vger.kernel.org
Subject: Re: Query regarding pf_packet sockets
Date: Wed, 21 Mar 2012 21:28:42 -0700 [thread overview]
Message-ID: <1332390522.9433.17.camel@edumazet-glaptop> (raw)
In-Reply-To: <B97B134FACB2024DB45F524AB0A7B7F2063EB8C6@XMB-BGL-419.cisco.com>
On Thu, 2012-03-22 at 08:52 +0530, Prashant Batra (prbatra) wrote:
> Hi ,
>
> I am trying to use PF_PACKET socket along with filters applied on the socket through setsockopt, SO_ATTACH_FILTER.
> Now as I create this socket, any packet coming to the kernel would be copied into the socket buffer for this socket.
>
> So, even if I apply the filter, first few packets would always be those which do not match the filter.
>
> Is there a way (some socket option), to make socket passive and active, so that I will set the socket in passive mode after creation,
> and then set it as active, after I apply the filter, so that I only receive the filtered packet in user space.
>
> Thanks,
> Prashant
>
1) open PF_PACKET
2) Install a "deny all packets" filter
3) read all packets that might have been captured right before 2)
4) Install your filter
This is what is done by libpcap
next prev parent reply other threads:[~2012-03-22 4:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 3:22 Query regarding pf_packet sockets Prashant Batra (prbatra)
2012-03-22 4:28 ` Eric Dumazet [this message]
2012-03-22 5:16 ` Prashant Batra (prbatra)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332390522.9433.17.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=prbatra@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox