socket: Use old_timeval types for socket timestamps

As part of y2038 solution, all internal uses of
struct timeval are replaced by struct __kernel_old_timeval
and struct compat_timeval by struct old_timeval32.
Make socket timestamps use these new types.

This is mainly to be able to verify that the kernel build
is y2038 safe when such non y2038 safe types are not
supported anymore.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Cc: isdn@linux-pingi.de
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Deepa Dinamani 2019-02-02 07:34:48 -08:00 committed by David S. Miller
parent bcb3fc3247
commit 13c6ee2a92
7 changed files with 12 additions and 12 deletions

View File

@ -103,7 +103,7 @@ mISDN_ctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
static inline void static inline void
mISDN_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) mISDN_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
{ {
struct timeval tv; struct __kernel_old_timeval tv;
if (_pms(sk)->cmask & MISDN_TIME_STAMP) { if (_pms(sk)->cmask & MISDN_TIME_STAMP) {
skb_get_timestamp(skb, &tv); skb_get_timestamp(skb, &tv);

View File

@ -3486,16 +3486,16 @@ static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
/** /**
* skb_get_timestamp - get timestamp from a skb * skb_get_timestamp - get timestamp from a skb
* @skb: skb to get stamp from * @skb: skb to get stamp from
* @stamp: pointer to struct timeval to store stamp in * @stamp: pointer to struct __kernel_old_timeval to store stamp in
* *
* Timestamps are stored in the skb as offsets to a base timestamp. * Timestamps are stored in the skb as offsets to a base timestamp.
* This function converts the offset back to a struct timeval and stores * This function converts the offset back to a struct timeval and stores
* it in stamp. * it in stamp.
*/ */
static inline void skb_get_timestamp(const struct sk_buff *skb, static inline void skb_get_timestamp(const struct sk_buff *skb,
struct timeval *stamp) struct __kernel_old_timeval *stamp)
{ {
*stamp = ktime_to_timeval(skb->tstamp); *stamp = ns_to_kernel_old_timeval(skb->tstamp);
} }
static inline void skb_get_timestampns(const struct sk_buff *skb, static inline void skb_get_timestampns(const struct sk_buff *skb,

View File

@ -1383,9 +1383,9 @@ static void hci_sock_cmsg(struct sock *sk, struct msghdr *msg,
if (mask & HCI_CMSG_TSTAMP) { if (mask & HCI_CMSG_TSTAMP) {
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
struct compat_timeval ctv; struct old_timeval32 ctv;
#endif #endif
struct timeval tv; struct __kernel_old_timeval tv;
void *data; void *data;
int len; int len;

View File

@ -209,8 +209,8 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
{ {
struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control; struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
struct compat_cmsghdr cmhdr; struct compat_cmsghdr cmhdr;
struct compat_timeval ctv; struct old_timeval32 ctv;
struct compat_timespec cts[3]; struct old_timespec32 cts[3];
int cmlen; int cmlen;
if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) { if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) {
@ -220,7 +220,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
if (!COMPAT_USE_64BIT_TIME) { if (!COMPAT_USE_64BIT_TIME) {
if (level == SOL_SOCKET && type == SO_TIMESTAMP_OLD) { if (level == SOL_SOCKET && type == SO_TIMESTAMP_OLD) {
struct timeval *tv = (struct timeval *)data; struct __kernel_old_timeval *tv = (struct __kernel_old_timeval *)data;
ctv.tv_sec = tv->tv_sec; ctv.tv_sec = tv->tv_sec;
ctv.tv_usec = tv->tv_usec; ctv.tv_usec = tv->tv_usec;
data = &ctv; data = &ctv;

View File

@ -1861,7 +1861,7 @@ static void tcp_update_recv_tstamps(struct sk_buff *skb,
static void tcp_recv_timestamp(struct msghdr *msg, const struct sock *sk, static void tcp_recv_timestamp(struct msghdr *msg, const struct sock *sk,
struct scm_timestamping *tss) struct scm_timestamping *tss)
{ {
struct timeval tv; struct __kernel_old_timeval tv;
bool has_timestamping = false; bool has_timestamping = false;
if (tss->ts[0].tv_sec || tss->ts[0].tv_nsec) { if (tss->ts[0].tv_sec || tss->ts[0].tv_nsec) {

View File

@ -549,7 +549,7 @@ static int rds_cmsg_recv(struct rds_incoming *inc, struct msghdr *msg,
if ((inc->i_rx_tstamp != 0) && if ((inc->i_rx_tstamp != 0) &&
sock_flag(rds_rs_to_sk(rs), SOCK_RCVTSTAMP)) { sock_flag(rds_rs_to_sk(rs), SOCK_RCVTSTAMP)) {
struct timeval tv = ktime_to_timeval(inc->i_rx_tstamp); struct __kernel_old_timeval tv = ns_to_kernel_old_timeval(inc->i_rx_tstamp);
ret = put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD, ret = put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
sizeof(tv), &tv); sizeof(tv), &tv);
if (ret) if (ret)

View File

@ -719,7 +719,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
if (need_software_tstamp) { if (need_software_tstamp) {
if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) { if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) {
struct timeval tv; struct __kernel_old_timeval tv;
skb_get_timestamp(skb, &tv); skb_get_timestamp(skb, &tv);
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD, put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
sizeof(tv), &tv); sizeof(tv), &tv);