Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277547
b: refs/heads/master
c: 588f033
h: refs/heads/master
i:
  277545: 69d0953
  277543: f0a1db4
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 16, 2011
1 parent fbbfce3 commit 0e3a890
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 66846048f55c6c05a4c46c2daabb773173f8f28d
refs/heads/master: 588f033075d8c7efe28695402114eab3f9da47c4
32 changes: 14 additions & 18 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
#include <linux/if_pppox.h>
#include <linux/ppp_defs.h>
#include <linux/net_tstamp.h>
#include <linux/jump_label.h>

#include "net-sysfs.h"

Expand Down Expand Up @@ -1449,34 +1450,32 @@ int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
}
EXPORT_SYMBOL(call_netdevice_notifiers);

/* When > 0 there are consumers of rx skb time stamps */
static atomic_t netstamp_needed = ATOMIC_INIT(0);
static struct jump_label_key netstamp_needed __read_mostly;

void net_enable_timestamp(void)
{
atomic_inc(&netstamp_needed);
jump_label_inc(&netstamp_needed);
}
EXPORT_SYMBOL(net_enable_timestamp);

void net_disable_timestamp(void)
{
atomic_dec(&netstamp_needed);
jump_label_dec(&netstamp_needed);
}
EXPORT_SYMBOL(net_disable_timestamp);

static inline void net_timestamp_set(struct sk_buff *skb)
{
if (atomic_read(&netstamp_needed))
skb->tstamp.tv64 = 0;
if (static_branch(&netstamp_needed))
__net_timestamp(skb);
else
skb->tstamp.tv64 = 0;
}

static inline void net_timestamp_check(struct sk_buff *skb)
{
if (!skb->tstamp.tv64 && atomic_read(&netstamp_needed))
__net_timestamp(skb);
}
#define net_timestamp_check(COND, SKB) \
if (static_branch(&netstamp_needed)) { \
if ((COND) && !(SKB)->tstamp.tv64) \
__net_timestamp(SKB); \
} \

static int net_hwtstamp_validate(struct ifreq *ifr)
{
Expand Down Expand Up @@ -2997,8 +2996,7 @@ int netif_rx(struct sk_buff *skb)
if (netpoll_rx(skb))
return NET_RX_DROP;

if (netdev_tstamp_prequeue)
net_timestamp_check(skb);
net_timestamp_check(netdev_tstamp_prequeue, skb);

trace_netif_rx(skb);
#ifdef CONFIG_RPS
Expand Down Expand Up @@ -3230,8 +3228,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
int ret = NET_RX_DROP;
__be16 type;

if (!netdev_tstamp_prequeue)
net_timestamp_check(skb);
net_timestamp_check(!netdev_tstamp_prequeue, skb);

trace_netif_receive_skb(skb);

Expand Down Expand Up @@ -3362,8 +3359,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
*/
int netif_receive_skb(struct sk_buff *skb)
{
if (netdev_tstamp_prequeue)
net_timestamp_check(skb);
net_timestamp_check(netdev_tstamp_prequeue, skb);

if (skb_defer_rx_timestamp(skb))
return NET_RX_SUCCESS;
Expand Down

0 comments on commit 0e3a890

Please sign in to comment.