All of lore.kernel.org
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: "'Herbert Xu'" <herbert@gondor.apana.org.au>, netdev@vger.kernel.org
Subject: Re: raw PF_PACKET protocol selection
Date: Tue, 9 Oct 2007 12:17:52 +0400	[thread overview]
Message-ID: <20071009081752.GA31369@2ka.mipt.ru> (raw)
In-Reply-To: <1191916285.6682.83.camel@gentoo-jocke.transmode.se>

On Tue, Oct 09, 2007 at 09:51:25AM +0200, Joakim Tjernlund (joakim.tjernlund@transmode.se) wrote:
> On Tue, 2007-10-09 at 11:34 +0400, Evgeniy Polyakov wrote:
> > On Tue, Oct 09, 2007 at 09:27:38AM +0200, Joakim Tjernlund (joakim.tjernlund@transmode.se) wrote:
> > > > Did you change eth_type_trans() to catch your proto?
> > > > 
> > > 
> > > Just fond out something:
> > > if I redirect my prog like so:
> > > ./sniff > log
> > > and press Ctrl-C after a packet has been sent to it, 
> > > it does NOT work. I don't get ANY output in my "log" file, not
> > > even the printf("---------\n") appears.
> > > But if I run whithout redirect it works(at least with ETH_P_BPQ)
> > > Anyone else see this too?
> > 
> > I only tested with IP and ARP packets - I can not say when packet was
> > actually received and written to log, but it does start filling up, but
> > maybe not immediately - it can be output buffering in shell though.
> 
> Did you receive many packets? Seems like when I receive just 1 or 2 pkgs
> I get the empty log. If I strace ./sniff > log I see that recvfrom gets
> pkgs, but there are no trace of writes. I guess this
> is a bash(3.2_p17) or glibc(2.5.-r4) bug?

I received 1396 bytes of logs before terminated, which is 27 ARP packets, 
so there is quite big number of packet there. 
Your application works correctly (although you swapped source and
destination ethernet fields) - buffered writing is not a bug,
if you do not like it, use write(2), mmap(2) or turn buffering off as
Herbert suggested. To get packets with your own ethernet protocol number
you have to change eth_type_trans() function in kernel, which parses
ethernet header and returns protocol number, under some conditions it
will just return your number automatically, but you should check it.

-- 
	Evgeniy Polyakov

  reply	other threads:[~2007-10-09  8:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-08 18:36 raw PF_PACKET protocol selection Joakim Tjernlund
2007-10-09  3:17 ` Herbert Xu
2007-10-09  6:08   ` Joakim Tjernlund
2007-10-09  7:13     ` Evgeniy Polyakov
2007-10-09  7:27       ` Joakim Tjernlund
2007-10-09  7:34         ` Evgeniy Polyakov
2007-10-09  7:51           ` Joakim Tjernlund
2007-10-09  8:17             ` Evgeniy Polyakov [this message]
2007-10-09  9:00               ` Joakim Tjernlund
2007-10-09  7:56         ` Herbert Xu

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=20071009081752.GA31369@2ka.mipt.ru \
    --to=johnpol@2ka.mipt.ru \
    --cc=herbert@gondor.apana.org.au \
    --cc=joakim.tjernlund@transmode.se \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.