netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rui <wirelesser@gmail.com>
To: netdev@vger.kernel.org
Subject: how to make sure that packet is inserted into PACKET_MMAP ring buffer strictly according to its timestamp order?
Date: Wed, 22 Dec 2010 12:33:40 +0800	[thread overview]
Message-ID: <AANLkTinaMX-yaWRcEf56dPxPdJBJNRnGf3rXEKO-_y86@mail.gmail.com> (raw)

hi

how to make sure that packet is inserted into PACKET_MMAP ring buffer
strictly according to its timestamp order?

I am studying the code below
as the function tpacket_rcv will be running in parallel in multi queue
nic supportted kernel,
is it possible that a later packet get the spinlock earlier,
thus it is copied to the ring buffer prior to packet which timestamp is earlier?


thanks
rui

af_packet.c
static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
		       struct packet_type *pt, struct net_device *orig_dev)
{
...
spin_lock(&sk->sk_receive_queue.lock);
	h.raw = packet_current_frame(po, &po->rx_ring, TP_STATUS_KERNEL);
	if (!h.raw)
		goto ring_is_full;
	packet_increment_head(&po->rx_ring);
	po->stats.tp_packets++;
	if (copy_skb) {
		status |= TP_STATUS_COPY;
		__skb_queue_tail(&sk->sk_receive_queue, copy_skb);
	}
	if (!po->stats.tp_drops)
		status &= ~TP_STATUS_LOSING;
	spin_unlock(&sk->sk_receive_queue.lock);

	skb_copy_bits(skb, 0, h.raw + macoff, snaplen);
}

                 reply	other threads:[~2010-12-22  4:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=AANLkTinaMX-yaWRcEf56dPxPdJBJNRnGf3rXEKO-_y86@mail.gmail.com \
    --to=wirelesser@gmail.com \
    --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 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).