Skip to content

Commit a818f75

Browse files
Jesus Sanchez-Palenciadavem330
authored andcommitted
net: ipv6: Hook into time based transmission
Add a struct sockcm_cookie parameter to ip6_setup_cork() so we can easily re-use the transmit_time field from struct inet_cork for most paths, by copying the timestamp from the CMSG cookie. This is later copied into the skb during __ip6_make_skb(). For the raw fast path, also pass the sockcm_cookie as a parameter so we can just perform the copy at rawv6_send_hdrinc() directly. Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bc969a9 commit a818f75

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

net/ipv6/ip6_output.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,8 @@ static void ip6_append_data_mtu(unsigned int *mtu,
11581158

11591159
static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
11601160
struct inet6_cork *v6_cork, struct ipcm6_cookie *ipc6,
1161-
struct rt6_info *rt, struct flowi6 *fl6)
1161+
struct rt6_info *rt, struct flowi6 *fl6,
1162+
const struct sockcm_cookie *sockc)
11621163
{
11631164
struct ipv6_pinfo *np = inet6_sk(sk);
11641165
unsigned int mtu;
@@ -1226,6 +1227,8 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
12261227
cork->base.flags |= IPCORK_ALLFRAG;
12271228
cork->base.length = 0;
12281229

1230+
cork->base.transmit_time = sockc->transmit_time;
1231+
12291232
return 0;
12301233
}
12311234

@@ -1575,7 +1578,7 @@ int ip6_append_data(struct sock *sk,
15751578
* setup for corking
15761579
*/
15771580
err = ip6_setup_cork(sk, &inet->cork, &np->cork,
1578-
ipc6, rt, fl6);
1581+
ipc6, rt, fl6, sockc);
15791582
if (err)
15801583
return err;
15811584

@@ -1673,6 +1676,8 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
16731676
skb->priority = sk->sk_priority;
16741677
skb->mark = sk->sk_mark;
16751678

1679+
skb->tstamp = cork->base.transmit_time;
1680+
16761681
skb_dst_set(skb, dst_clone(&rt->dst));
16771682
IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len);
16781683
if (proto == IPPROTO_ICMPV6) {
@@ -1765,7 +1770,7 @@ struct sk_buff *ip6_make_skb(struct sock *sk,
17651770
cork->base.opt = NULL;
17661771
cork->base.dst = NULL;
17671772
v6_cork.opt = NULL;
1768-
err = ip6_setup_cork(sk, cork, &v6_cork, ipc6, rt, fl6);
1773+
err = ip6_setup_cork(sk, cork, &v6_cork, ipc6, rt, fl6, sockc);
17691774
if (err) {
17701775
ip6_cork_release(cork, &v6_cork);
17711776
return ERR_PTR(err);

net/ipv6/raw.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
620620

621621
static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
622622
struct flowi6 *fl6, struct dst_entry **dstp,
623-
unsigned int flags)
623+
unsigned int flags, const struct sockcm_cookie *sockc)
624624
{
625625
struct ipv6_pinfo *np = inet6_sk(sk);
626626
struct net *net = sock_net(sk);
@@ -650,6 +650,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
650650
skb->protocol = htons(ETH_P_IPV6);
651651
skb->priority = sk->sk_priority;
652652
skb->mark = sk->sk_mark;
653+
skb->tstamp = sockc->transmit_time;
653654
skb_dst_set(skb, &rt->dst);
654655
*dstp = NULL;
655656

@@ -848,6 +849,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
848849
fl6.flowi6_oif = sk->sk_bound_dev_if;
849850

850851
sockc.tsflags = sk->sk_tsflags;
852+
sockc.transmit_time = 0;
851853
if (msg->msg_controllen) {
852854
opt = &opt_space;
853855
memset(opt, 0, sizeof(struct ipv6_txoptions));
@@ -921,7 +923,8 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
921923

922924
back_from_confirm:
923925
if (inet->hdrincl)
924-
err = rawv6_send_hdrinc(sk, msg, len, &fl6, &dst, msg->msg_flags);
926+
err = rawv6_send_hdrinc(sk, msg, len, &fl6, &dst,
927+
msg->msg_flags, &sockc);
925928
else {
926929
ipc6.opt = opt;
927930
lock_sock(sk);

net/ipv6/udp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
11481148
ipc6.dontfrag = -1;
11491149
ipc6.gso_size = up->gso_size;
11501150
sockc.tsflags = sk->sk_tsflags;
1151+
sockc.transmit_time = 0;
11511152

11521153
/* destination address check */
11531154
if (sin6) {

0 commit comments

Comments
 (0)