diff options
author | Richard Cochran <richardcochran@gmail.com> | 2011-10-20 20:49:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-24 02:54:50 -0400 |
commit | da92b194cc36b5dc1fbd85206aeeffd80bee0c39 (patch) | |
tree | 375ead604156d8a8afc5ecef8d76415e999ce903 /include/linux/skbuff.h | |
parent | f7ff19871bb4a3451e1ca2cf660bf633018cfbec (diff) |
net: hold sock reference while processing tx timestamps
The pair of functions,
* skb_clone_tx_timestamp()
* skb_complete_tx_timestamp()
were designed to allow timestamping in PHY devices. The first
function, called during the MAC driver's hard_xmit method, identifies
PTP protocol packets, clones them, and gives them to the PHY device
driver. The PHY driver may hold onto the packet and deliver it at a
later time using the second function, which adds the packet to the
socket's error queue.
As pointed out by Johannes, nothing prevents the socket from
disappearing while the cloned packet is sitting in the PHY driver
awaiting a timestamp. This patch fixes the issue by taking a reference
on the socket for each such packet. In addition, the comments
regarding the usage of these function are expanded to highlight the
rule that PHY drivers must use skb_complete_tx_timestamp() to release
the packet, in order to release the socket reference, too.
These functions first appeared in v2.6.36.
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
Cc: <stable@vger.kernel.org>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8bd383caa363..0f966460a345 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -2020,8 +2020,13 @@ static inline bool skb_defer_rx_timestamp(struct sk_buff *skb) | |||
2020 | /** | 2020 | /** |
2021 | * skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps | 2021 | * skb_complete_tx_timestamp() - deliver cloned skb with tx timestamps |
2022 | * | 2022 | * |
2023 | * PHY drivers may accept clones of transmitted packets for | ||
2024 | * timestamping via their phy_driver.txtstamp method. These drivers | ||
2025 | * must call this function to return the skb back to the stack, with | ||
2026 | * or without a timestamp. | ||
2027 | * | ||
2023 | * @skb: clone of the the original outgoing packet | 2028 | * @skb: clone of the the original outgoing packet |
2024 | * @hwtstamps: hardware time stamps | 2029 | * @hwtstamps: hardware time stamps, may be NULL if not available |
2025 | * | 2030 | * |
2026 | */ | 2031 | */ |
2027 | void skb_complete_tx_timestamp(struct sk_buff *skb, | 2032 | void skb_complete_tx_timestamp(struct sk_buff *skb, |