Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: raw: add support for SO_TXTIME/SCM_TXTIME

This patch calls into sock_cmsg_send() to parse the user supplied
control information into a struct sockcm_cookie. Then assign the
requested transmit time to the skb.

This makes it possible to use the Earliest TXTIME First (ETF) packet
scheduler with the CAN_RAW protocol. The user can send a CAN_RAW frame
with a TXTIME and the kernel (with the ETF scheduler) will take care
of sending it to the network interface.

Link: https://lore.kernel.org/all/20220502091946.1916211-3-mkl@pengutronix.de
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

+10 -1
+10 -1
net/can/raw.c
··· 772 772 { 773 773 struct sock *sk = sock->sk; 774 774 struct raw_sock *ro = raw_sk(sk); 775 + struct sockcm_cookie sockc; 775 776 struct sk_buff *skb; 776 777 struct net_device *dev; 777 778 int ifindex; ··· 818 817 if (err < 0) 819 818 goto free_skb; 820 819 821 - skb_setup_tx_timestamp(skb, sk->sk_tsflags); 820 + sockcm_init(&sockc, sk); 821 + if (msg->msg_controllen) { 822 + err = sock_cmsg_send(sk, msg, &sockc); 823 + if (unlikely(err)) 824 + goto free_skb; 825 + } 822 826 823 827 skb->dev = dev; 824 828 skb->priority = sk->sk_priority; 829 + skb->tstamp = sockc.transmit_time; 830 + 831 + skb_setup_tx_timestamp(skb, sockc.tsflags); 825 832 826 833 err = can_send(skb, ro->loopback); 827 834