Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 266932
b: refs/heads/master
c: da92b19
h: refs/heads/master
v: v3
  • Loading branch information
Richard Cochran authored and David S. Miller committed Oct 24, 2011
1 parent 54d5015 commit 3c56ee8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 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: f7ff19871bb4a3451e1ca2cf660bf633018cfbec
refs/heads/master: da92b194cc36b5dc1fbd85206aeeffd80bee0c39
2 changes: 1 addition & 1 deletion trunk/include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ struct phy_driver {

/*
* Requests a Tx timestamp for 'skb'. The phy driver promises
* to deliver it to the socket's error queue as soon as a
* to deliver it using skb_complete_tx_timestamp() as soon as a
* timestamp becomes available. One of the PTP_CLASS_ values
* is passed in 'type'.
*/
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -2020,8 +2020,13 @@ static inline bool skb_defer_rx_timestamp(struct sk_buff *skb)
/**
* skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps
*
* PHY drivers may accept clones of transmitted packets for
* timestamping via their phy_driver.txtstamp method. These drivers
* must call this function to return the skb back to the stack, with
* or without a timestamp.
*
* @skb: clone of the the original outgoing packet
* @hwtstamps: hardware time stamps
* @hwtstamps: hardware time stamps, may be NULL if not available
*
*/
void skb_complete_tx_timestamp(struct sk_buff *skb,
Expand Down
12 changes: 10 additions & 2 deletions trunk/net/core/timestamping.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ void skb_clone_tx_timestamp(struct sk_buff *skb)
case PTP_CLASS_V2_VLAN:
phydev = skb->dev->phydev;
if (likely(phydev->drv->txtstamp)) {
if (!atomic_inc_not_zero(&sk->sk_refcnt))
return;
clone = skb_clone(skb, GFP_ATOMIC);
if (!clone)
if (!clone) {
sock_put(sk);
return;
}
clone->sk = sk;
phydev->drv->txtstamp(phydev, clone, type);
}
Expand All @@ -77,8 +81,11 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
struct sock_exterr_skb *serr;
int err;

if (!hwtstamps)
if (!hwtstamps) {
sock_put(sk);
kfree_skb(skb);
return;
}

*skb_hwtstamps(skb) = *hwtstamps;
serr = SKB_EXT_ERR(skb);
Expand All @@ -87,6 +94,7 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
skb->sk = NULL;
err = sock_queue_err_skb(sk, skb);
sock_put(sk);
if (err)
kfree_skb(skb);
}
Expand Down

0 comments on commit 3c56ee8

Please sign in to comment.