Skip to content

Commit bf84a01

Browse files
Daniel Borkmanndavem330
authored andcommitted
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 20d4947, ``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>
1 parent 9d9f163 commit bf84a01

7 files changed

Lines changed: 16 additions & 25 deletions

File tree

‎include/net/sock.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,10 +2159,9 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
21592159
* @sk: socket sending this packet
21602160
* @tx_flags: filled with instructions for time stamping
21612161
*
2162-
* Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if
2163-
* parameters are invalid.
2162+
* Currently only depends on SOCK_TIMESTAMPING* flags.
21642163
*/
2165-
extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);
2164+
extern void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);
21662165

21672166
/**
21682167
* sk_eat_skb - Release a skb if it is no longer needed

‎net/can/raw.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
711711
err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
712712
if (err < 0)
713713
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);
717716

718717
skb->dev = dev;
719718
skb->sk = sk;

‎net/ipv4/ping.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,8 @@ static int ping_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
514514
ipc.opt = NULL;
515515
ipc.oif = sk->sk_bound_dev_if;
516516
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);
520519

521520
if (msg->msg_controllen) {
522521
err = ip_cmsg_send(sock_net(sk), msg, &ipc);

‎net/ipv4/udp.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,9 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
902902
ipc.addr = inet->inet_saddr;
903903

904904
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+
908908
if (msg->msg_controllen) {
909909
err = ip_cmsg_send(sock_net(sk), msg, &ipc);
910910
if (err)

‎net/ipv6/ip6_output.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,8 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
12241224
}
12251225

12261226
/* 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);
12321229

12331230
/*
12341231
* Let's try using as much space as possible.

‎net/packet/af_packet.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,9 +1505,8 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
15051505
skb->dev = dev;
15061506
skb->priority = sk->sk_priority;
15071507
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);
15111510

15121511
if (unlikely(extra_len == 4))
15131512
skb->no_fcs = 1;
@@ -2312,9 +2311,8 @@ static int packet_snd(struct socket *sock,
23122311
err = skb_copy_datagram_from_iovec(skb, offset, msg->msg_iov, 0, len);
23132312
if (err)
23142313
goto out_free;
2315-
err = sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags);
2316-
if (err < 0)
2317-
goto out_free;
2314+
2315+
sock_tx_timestamp(sk, &skb_shinfo(skb)->tx_flags);
23182316

23192317
if (!gso_type && (len > dev->mtu + reserve + extra_len)) {
23202318
/* Earlier code assumed this would be a VLAN pkt,

‎net/socket.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ void sock_release(struct socket *sock)
600600
}
601601
EXPORT_SYMBOL(sock_release);
602602

603-
int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags)
603+
void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags)
604604
{
605605
*tx_flags = 0;
606606
if (sock_flag(sk, SOCK_TIMESTAMPING_TX_HARDWARE))
@@ -609,7 +609,6 @@ int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags)
609609
*tx_flags |= SKBTX_SW_TSTAMP;
610610
if (sock_flag(sk, SOCK_WIFI_STATUS))
611611
*tx_flags |= SKBTX_WIFI_STATUS;
612-
return 0;
613612
}
614613
EXPORT_SYMBOL(sock_tx_timestamp);
615614

0 commit comments

Comments
 (0)