diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-09-06 08:55:02 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:48:59 -0400 |
commit | 50f17787e9b0222ce65cc831407c3ba4790db3ff (patch) | |
tree | 71a1a509cf307105a920d81d9b97b8a2e5ada95b | |
parent | c7261872256f9172eb26438b96725b6f2115e955 (diff) |
[AF_PACKET]: Don't enable global timestamps.
Andi mentioned he did something like this already, but never submitted
it.
The dhcp client application uses AF_PACKET with a packet filter to
receive data. The application doesn't even use timestamps, but because
the AF_PACKET API has timestamps, they get turned on globally which
causes an expensive time of day lookup for every packet received on
any system that uses the standard DHCP client.
The fix is to not enable the timestamp (but use if if available).
This causes the time lookup to only occur on those packets that are
destined for the AF_PACKET socket. The timestamping occurs after
packet filtering so all packets dropped by filtering to not cause a
clock call.
The one downside of this a a few microseconds additional delay added
from the normal timestamping location (netif_rx) until the receive
callback in AF_PACKET. But since the offset is fairly consistent it
should not upset applications that do want really use timestamps, like
wireshark.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/packet/af_packet.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 1322d62b5d97..9c26dd9ee649 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -640,11 +640,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe | |||
640 | h->tp_snaplen = snaplen; | 640 | h->tp_snaplen = snaplen; |
641 | h->tp_mac = macoff; | 641 | h->tp_mac = macoff; |
642 | h->tp_net = netoff; | 642 | h->tp_net = netoff; |
643 | if (skb->tstamp.tv64 == 0) { | 643 | if (skb->tstamp.tv64) |
644 | __net_timestamp(skb); | 644 | tv = ktime_to_timeval(skb->tstamp); |
645 | sock_enable_timestamp(sk); | 645 | else |
646 | } | 646 | do_gettimeofday(&tv); |
647 | tv = ktime_to_timeval(skb->tstamp); | ||
648 | h->tp_sec = tv.tv_sec; | 647 | h->tp_sec = tv.tv_sec; |
649 | h->tp_usec = tv.tv_usec; | 648 | h->tp_usec = tv.tv_usec; |
650 | 649 | ||