diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2014-09-04 13:31:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-05 20:43:45 -0400 |
commit | 62bccb8cdb69051b95a55ab0c489e3cab261c8ef (patch) | |
tree | f1a545f5635070e5022e2bc0ab7b1260644c8588 /net/core/timestamping.c | |
parent | 37846ef0188335e49f2491a5bbf4e0dc7d407ea0 (diff) |
net-timestamp: Make the clone operation stand-alone from phy timestamping
The phy timestamping takes a different path than the regular timestamping
does in that it will create a clone first so that the packets needing to be
timestamped can be placed in a queue, or the context block could be used.
In order to support these use cases I am pulling the core of the code out
so it can be used in other drivers beyond just phy devices.
In addition I have added a destructor named sock_efree which is meant to
provide a simple way for dropping the reference to skb exceptions that
aren't part of either the receive or send windows for the socket, and I
have removed some duplication in spots where this destructor could be used
in place of sock_edemux.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/timestamping.c')
-rw-r--r-- | net/core/timestamping.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/net/core/timestamping.c b/net/core/timestamping.c index f48a59fd8f39..43d3dd62fcc8 100644 --- a/net/core/timestamping.c +++ b/net/core/timestamping.c | |||
@@ -36,10 +36,9 @@ void skb_clone_tx_timestamp(struct sk_buff *skb) | |||
36 | { | 36 | { |
37 | struct phy_device *phydev; | 37 | struct phy_device *phydev; |
38 | struct sk_buff *clone; | 38 | struct sk_buff *clone; |
39 | struct sock *sk = skb->sk; | ||
40 | unsigned int type; | 39 | unsigned int type; |
41 | 40 | ||
42 | if (!sk) | 41 | if (!skb->sk) |
43 | return; | 42 | return; |
44 | 43 | ||
45 | type = classify(skb); | 44 | type = classify(skb); |
@@ -48,16 +47,9 @@ void skb_clone_tx_timestamp(struct sk_buff *skb) | |||
48 | 47 | ||
49 | phydev = skb->dev->phydev; | 48 | phydev = skb->dev->phydev; |
50 | if (likely(phydev->drv->txtstamp)) { | 49 | if (likely(phydev->drv->txtstamp)) { |
51 | if (!atomic_inc_not_zero(&sk->sk_refcnt)) | 50 | clone = skb_clone_sk(skb); |
51 | if (!clone) | ||
52 | return; | 52 | return; |
53 | |||
54 | clone = skb_clone(skb, GFP_ATOMIC); | ||
55 | if (!clone) { | ||
56 | sock_put(sk); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | clone->sk = sk; | ||
61 | phydev->drv->txtstamp(phydev, clone, type); | 53 | phydev->drv->txtstamp(phydev, clone, type); |
62 | } | 54 | } |
63 | } | 55 | } |