Skip to content

Commit bc969a9

Browse files
Jesus Sanchez-Palenciadavem330
authored andcommitted
net: ipv4: Hook into time based transmission
Add a transmit_time field to struct inet_cork, then copy the timestamp from the CMSG cookie at ip_setup_cork() so we can safely copy it into the skb later during __ip_make_skb(). For the raw fast path, just perform the copy at raw_send_hdrinc(). Signed-off-by: Richard Cochran <rcochran@linutronix.de> Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 80b14de commit bc969a9

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed

include/net/inet_sock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct inet_cork {
148148
__s16 tos;
149149
char priority;
150150
__u16 gso_size;
151+
u64 transmit_time;
151152
};
152153

153154
struct inet_cork_full {

net/ipv4/icmp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
437437
ipc.tx_flags = 0;
438438
ipc.ttl = 0;
439439
ipc.tos = -1;
440+
ipc.sockc.transmit_time = 0;
440441

441442
if (icmp_param->replyopts.opt.opt.optlen) {
442443
ipc.opt = &icmp_param->replyopts.opt;
@@ -715,6 +716,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
715716
ipc.tx_flags = 0;
716717
ipc.ttl = 0;
717718
ipc.tos = -1;
719+
ipc.sockc.transmit_time = 0;
718720

719721
rt = icmp_route_lookup(net, &fl4, skb_in, iph, saddr, tos, mark,
720722
type, code, &icmp_param);

net/ipv4/ip_output.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,7 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
11541154
cork->tos = ipc->tos;
11551155
cork->priority = ipc->priority;
11561156
cork->tx_flags = ipc->tx_flags;
1157+
cork->transmit_time = ipc->sockc.transmit_time;
11571158

11581159
return 0;
11591160
}
@@ -1414,6 +1415,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
14141415

14151416
skb->priority = (cork->tos != -1) ? cork->priority: sk->sk_priority;
14161417
skb->mark = sk->sk_mark;
1418+
skb->tstamp = cork->transmit_time;
14171419
/*
14181420
* Steal rt from cork.dst to avoid a pair of atomic_inc/atomic_dec
14191421
* on dst refcount
@@ -1551,6 +1553,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
15511553
ipc.tx_flags = 0;
15521554
ipc.ttl = 0;
15531555
ipc.tos = -1;
1556+
ipc.sockc.transmit_time = 0;
15541557

15551558
if (replyopts.opt.opt.optlen) {
15561559
ipc.opt = &replyopts.opt;

net/ipv4/ping.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
746746
ipc.tx_flags = 0;
747747
ipc.ttl = 0;
748748
ipc.tos = -1;
749+
ipc.sockc.transmit_time = 0;
749750

750751
if (msg->msg_controllen) {
751752
err = ip_cmsg_send(sk, msg, &ipc, false);

net/ipv4/raw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
381381

382382
skb->priority = sk->sk_priority;
383383
skb->mark = sk->sk_mark;
384+
skb->tstamp = sockc->transmit_time;
384385
skb_dst_set(skb, &rt->dst);
385386
*rtp = NULL;
386387

@@ -562,6 +563,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
562563
}
563564

564565
ipc.sockc.tsflags = sk->sk_tsflags;
566+
ipc.sockc.transmit_time = 0;
565567
ipc.addr = inet->inet_saddr;
566568
ipc.opt = NULL;
567569
ipc.tx_flags = 0;

net/ipv4/udp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
930930
ipc.tx_flags = 0;
931931
ipc.ttl = 0;
932932
ipc.tos = -1;
933+
ipc.sockc.transmit_time = 0;
933934

934935
getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
935936

0 commit comments

Comments
 (0)