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

net: sock: make sock_tx_timestamp void

Currently, sock_tx_timestamp() always returns 0. The comment that
describes the sock_tx_timestamp() function wrongly says that it
returns an error when an invalid argument is passed (from commit
20d4947353be, ``net: socket infrastructure for SO_TIMESTAMPING'').
Make the function void, so that we can also remove all the unneeded
if conditions that check for such a _non-existant_ error case in the
output path.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
bf84a010 9d9f163c

+16 -25
+2 -3
include/net/sock.h
··· 2159 2159 * @sk: socket sending this packet 2160 2160 * @tx_flags: filled with instructions for time stamping 2161 2161 * 2162 - * Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if 2163 - * parameters are invalid. 2162 + * Currently only depends on SOCK_TIMESTAMPING* flags. 2164 2163 */ 2165 - extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags); 2164 + extern void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags); 2166 2165 2167 2166 /** 2168 2167 * sk_eat_skb - Release a skb if it is no longer needed
+2 -3
net/can/raw.c
··· 711 711 err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); 712 712 if (err < 0) 713 713 goto free_skb; 714 - err = sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags); 715 - if (err < 0) 716 - goto free_skb; 714 + 715 + sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags); 717 716 718 717 skb->dev = dev; 719 718 skb->sk = sk;
+2 -3
net/ipv4/ping.c
··· 514 514 ipc.opt = NULL; 515 515 ipc.oif = sk->sk_bound_dev_if; 516 516 ipc.tx_flags = 0; 517 - err = sock_tx_timestamp(sk, &ipc.tx_flags); 518 - if (err) 519 - return err; 517 + 518 + sock_tx_timestamp(sk, &ipc.tx_flags); 520 519 521 520 if (msg->msg_controllen) { 522 521 err = ip_cmsg_send(sock_net(sk), msg, &ipc);
+3 -3
net/ipv4/udp.c
··· 902 902 ipc.addr = inet->inet_saddr; 903 903 904 904 ipc.oif = sk->sk_bound_dev_if; 905 - err = sock_tx_timestamp(sk, &ipc.tx_flags); 906 - if (err) 907 - return err; 905 + 906 + sock_tx_timestamp(sk, &ipc.tx_flags); 907 + 908 908 if (msg->msg_controllen) { 909 909 err = ip_cmsg_send(sock_net(sk), msg, &ipc); 910 910 if (err)
+2 -5
net/ipv6/ip6_output.c
··· 1224 1224 } 1225 1225 1226 1226 /* For UDP, check if TX timestamp is enabled */ 1227 - if (sk->sk_type == SOCK_DGRAM) { 1228 - err = sock_tx_timestamp(sk, &tx_flags); 1229 - if (err) 1230 - goto error; 1231 - } 1227 + if (sk->sk_type == SOCK_DGRAM) 1228 + sock_tx_timestamp(sk, &tx_flags); 1232 1229 1233 1230 /* 1234 1231 * Let's try using as much space as possible.
+4 -6
net/packet/af_packet.c
··· 1505 1505 skb->dev = dev; 1506 1506 skb->priority = sk->sk_priority; 1507 1507 skb->mark = sk->sk_mark; 1508 - err = sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags); 1509 - if (err < 0) 1510 - goto out_unlock; 1508 + 1509 + sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags); 1511 1510 1512 1511 if (unlikely(extra_len == 4)) 1513 1512 skb->no_fcs = 1; ··· 2311 2312 err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov, 0, len); 2312 2313 if (err) 2313 2314 goto out_free; 2314 - err = sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags); 2315 - if (err < 0) 2316 - goto out_free; 2315 + 2316 + sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags); 2317 2317 2318 2318 if (!gso_type && (len > dev->mtu + reserve + extra_len)) { 2319 2319 /* Earlier code assumed this would be a VLAN pkt,
+1 -2
net/socket.c
··· 600 600 } 601 601 EXPORT_SYMBOL(sock_release); 602 602 603 - int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags) 603 + void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags) 604 604 { 605 605 *tx_flags = 0; 606 606 if (sock_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE)) ··· 609 609 *tx_flags |= SKBTX_SW_TSTAMP; 610 610 if (sock_flag(sk, SOCK_WIFI_STATUS)) 611 611 *tx_flags |= SKBTX_WIFI_STATUS; 612 - return 0; 613 612 } 614 613 EXPORT_SYMBOL(sock_tx_timestamp); 615 614