Skip to content

Commit 37846ef

Browse files
Alexander Duyckdavem330
authored andcommitted
net-timestamp: Merge shared code between phy and regular timestamping
This change merges the shared bits that exist between skb_tx_tstamp and skb_complete_tx_timestamp. By doing this we can avoid the two diverging as there were already changes pushed into skb_tx_tstamp that hadn't made it into the other function. In addition this resolves issues with the fact that skb_complete_tx_timestamp was included in linux/skbuff.h even though it was only compiled in if phy timestamping was enabled. Signed-off-by: Alexander Duyck <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d546c62 commit 37846ef

File tree

2 files changed

+42
-52
lines changed

2 files changed

+42
-52
lines changed

net/core/skbuff.c

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,33 +3511,13 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
35113511
}
35123512
EXPORT_SYMBOL(sock_dequeue_err_skb);
35133513

3514-
void __skb_tstamp_tx(struct sk_buff *orig_skb,
3515-
struct skb_shared_hwtstamps *hwtstamps,
3516-
struct sock *sk, int tstype)
3514+
static void __skb_complete_tx_timestamp(struct sk_buff *skb,
3515+
struct sock *sk,
3516+
int tstype)
35173517
{
35183518
struct sock_exterr_skb *serr;
3519-
struct sk_buff *skb;
35203519
int err;
35213520

3522-
if (!sk)
3523-
return;
3524-
3525-
if (hwtstamps) {
3526-
*skb_hwtstamps(orig_skb) =
3527-
*hwtstamps;
3528-
} else {
3529-
/*
3530-
* no hardware time stamps available,
3531-
* so keep the shared tx_flags and only
3532-
* store software time stamp
3533-
*/
3534-
orig_skb->tstamp = ktime_get_real();
3535-
}
3536-
3537-
skb = skb_clone(orig_skb, GFP_ATOMIC);
3538-
if (!skb)
3539-
return;
3540-
35413521
serr = SKB_EXT_ERR(skb);
35423522
memset(serr, 0, sizeof(*serr));
35433523
serr->ee.ee_errno = ENOMSG;
@@ -3554,6 +3534,45 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
35543534
if (err)
35553535
kfree_skb(skb);
35563536
}
3537+
3538+
void skb_complete_tx_timestamp(struct sk_buff *skb,
3539+
struct skb_shared_hwtstamps *hwtstamps)
3540+
{
3541+
struct sock *sk = skb->sk;
3542+
3543+
skb->sk = NULL;
3544+
3545+
if (hwtstamps) {
3546+
*skb_hwtstamps(skb) = *hwtstamps;
3547+
__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND);
3548+
} else {
3549+
kfree_skb(skb);
3550+
}
3551+
3552+
sock_put(sk);
3553+
}
3554+
EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp);
3555+
3556+
void __skb_tstamp_tx(struct sk_buff *orig_skb,
3557+
struct skb_shared_hwtstamps *hwtstamps,
3558+
struct sock *sk, int tstype)
3559+
{
3560+
struct sk_buff *skb;
3561+
3562+
if (!sk)
3563+
return;
3564+
3565+
if (hwtstamps)
3566+
*skb_hwtstamps(orig_skb) = *hwtstamps;
3567+
else
3568+
orig_skb->tstamp = ktime_get_real();
3569+
3570+
skb = skb_clone(orig_skb, GFP_ATOMIC);
3571+
if (!skb)
3572+
return;
3573+
3574+
__skb_complete_tx_timestamp(skb, sk, tstype);
3575+
}
35573576
EXPORT_SYMBOL_GPL(__skb_tstamp_tx);
35583577

35593578
void skb_tstamp_tx(struct sk_buff *orig_skb,

net/core/timestamping.c

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,6 @@ void skb_clone_tx_timestamp(struct sk_buff *skb)
6363
}
6464
EXPORT_SYMBOL_GPL(skb_clone_tx_timestamp);
6565

66-
void skb_complete_tx_timestamp(struct sk_buff *skb,
67-
struct skb_shared_hwtstamps *hwtstamps)
68-
{
69-
struct sock *sk = skb->sk;
70-
struct sock_exterr_skb *serr;
71-
int err;
72-
73-
if (!hwtstamps) {
74-
sock_put(sk);
75-
kfree_skb(skb);
76-
return;
77-
}
78-
79-
*skb_hwtstamps(skb) = *hwtstamps;
80-
81-
serr = SKB_EXT_ERR(skb);
82-
memset(serr, 0, sizeof(*serr));
83-
serr->ee.ee_errno = ENOMSG;
84-
serr->ee.ee_origin = SO_EE_ORIGIN_TIMESTAMPING;
85-
skb->sk = NULL;
86-
87-
err = sock_queue_err_skb(sk, skb);
88-
89-
sock_put(sk);
90-
if (err)
91-
kfree_skb(skb);
92-
}
93-
EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp);
94-
9566
bool skb_defer_rx_timestamp(struct sk_buff *skb)
9667
{
9768
struct phy_device *phydev;

0 commit comments

Comments
 (0)