net: rxrpc: Replace time_t type with time64_t type

Since the 'expiry' variable of 'struct key_preparsed_payload' has been
changed to 'time64_t' type, which is year 2038 safe on 32bits system.

In net/rxrpc subsystem, we need convert 'u32' type to 'time64_t' type
when copying ticket expires time to 'prep->expiry', then this patch
introduces two helper functions to help convert 'u32' to 'time64_t'
type.

This patch also uses ktime_get_real_seconds() to get current time instead
of get_seconds() which is not year 2038 safe on 32bits system.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
Baolin Wang
2017-08-29 10:15:40 +01:00
committed by David Howells
parent c8488a8ad7
commit 10674a03c6
4 changed files with 45 additions and 16 deletions

View File

@@ -127,4 +127,27 @@ struct rxrpc_key_data_v1 {
#define AFSTOKEN_K5_ADDRESSES_MAX 16 /* max K5 addresses */
#define AFSTOKEN_K5_AUTHDATA_MAX 16 /* max K5 pieces of auth data */
/*
* Truncate a time64_t to the range from 1970 to 2106 as in the network
* protocol.
*/
static inline u32 rxrpc_time64_to_u32(time64_t time)
{
if (time < 0)
return 0;
if (time > UINT_MAX)
return UINT_MAX;
return (u32)time;
}
/*
* Extend u32 back to time64_t using the same 1970-2106 range.
*/
static inline time64_t rxrpc_u32_to_time64(u32 time)
{
return (time64_t)time;
}
#endif /* _KEYS_RXRPC_TYPE_H */