Commit bd1200b7 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

drop_monitor: Make timestamps y2038 safe

Timestamps are currently communicated to user space as 'struct
timespec', which is not considered y2038 safe since it uses a 32-bit
signed value for seconds.

Fix this while the API is still not part of any official kernel release
by using 64-bit nanoseconds timestamps instead.

Fixes: ca30707d ("drop_monitor: Add packet alert mode")
Fixes: 5e58109b ("drop_monitor: Add support for packet alert mode for hardware drops")
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bf1867db
...@@ -75,7 +75,7 @@ enum net_dm_attr { ...@@ -75,7 +75,7 @@ enum net_dm_attr {
NET_DM_ATTR_PC, /* u64 */ NET_DM_ATTR_PC, /* u64 */
NET_DM_ATTR_SYMBOL, /* string */ NET_DM_ATTR_SYMBOL, /* string */
NET_DM_ATTR_IN_PORT, /* nested */ NET_DM_ATTR_IN_PORT, /* nested */
NET_DM_ATTR_TIMESTAMP, /* struct timespec */ NET_DM_ATTR_TIMESTAMP, /* u64 */
NET_DM_ATTR_PROTO, /* u16 */ NET_DM_ATTR_PROTO, /* u16 */
NET_DM_ATTR_PAYLOAD, /* binary */ NET_DM_ATTR_PAYLOAD, /* binary */
NET_DM_ATTR_PAD, NET_DM_ATTR_PAD,
......
...@@ -552,7 +552,7 @@ static size_t net_dm_packet_report_size(size_t payload_len) ...@@ -552,7 +552,7 @@ static size_t net_dm_packet_report_size(size_t payload_len)
/* NET_DM_ATTR_IN_PORT */ /* NET_DM_ATTR_IN_PORT */
net_dm_in_port_size() + net_dm_in_port_size() +
/* NET_DM_ATTR_TIMESTAMP */ /* NET_DM_ATTR_TIMESTAMP */
nla_total_size(sizeof(struct timespec)) + nla_total_size(sizeof(u64)) +
/* NET_DM_ATTR_ORIG_LEN */ /* NET_DM_ATTR_ORIG_LEN */
nla_total_size(sizeof(u32)) + nla_total_size(sizeof(u32)) +
/* NET_DM_ATTR_PROTO */ /* NET_DM_ATTR_PROTO */
...@@ -592,7 +592,6 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, ...@@ -592,7 +592,6 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
u64 pc = (u64)(uintptr_t) NET_DM_SKB_CB(skb)->pc; u64 pc = (u64)(uintptr_t) NET_DM_SKB_CB(skb)->pc;
char buf[NET_DM_MAX_SYMBOL_LEN]; char buf[NET_DM_MAX_SYMBOL_LEN];
struct nlattr *attr; struct nlattr *attr;
struct timespec ts;
void *hdr; void *hdr;
int rc; int rc;
...@@ -615,8 +614,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, ...@@ -615,8 +614,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
if (rc) if (rc)
goto nla_put_failure; goto nla_put_failure;
if (ktime_to_timespec_cond(skb->tstamp, &ts) && if (nla_put_u64_64bit(msg, NET_DM_ATTR_TIMESTAMP,
nla_put(msg, NET_DM_ATTR_TIMESTAMP, sizeof(ts), &ts)) ktime_to_ns(skb->tstamp), NET_DM_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(msg, NET_DM_ATTR_ORIG_LEN, skb->len)) if (nla_put_u32(msg, NET_DM_ATTR_ORIG_LEN, skb->len))
...@@ -716,7 +715,7 @@ net_dm_hw_packet_report_size(size_t payload_len, ...@@ -716,7 +715,7 @@ net_dm_hw_packet_report_size(size_t payload_len,
/* NET_DM_ATTR_IN_PORT */ /* NET_DM_ATTR_IN_PORT */
net_dm_in_port_size() + net_dm_in_port_size() +
/* NET_DM_ATTR_TIMESTAMP */ /* NET_DM_ATTR_TIMESTAMP */
nla_total_size(sizeof(struct timespec)) + nla_total_size(sizeof(u64)) +
/* NET_DM_ATTR_ORIG_LEN */ /* NET_DM_ATTR_ORIG_LEN */
nla_total_size(sizeof(u32)) + nla_total_size(sizeof(u32)) +
/* NET_DM_ATTR_PROTO */ /* NET_DM_ATTR_PROTO */
...@@ -730,7 +729,6 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg, ...@@ -730,7 +729,6 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg,
{ {
struct net_dm_hw_metadata *hw_metadata; struct net_dm_hw_metadata *hw_metadata;
struct nlattr *attr; struct nlattr *attr;
struct timespec ts;
void *hdr; void *hdr;
hw_metadata = NET_DM_SKB_CB(skb)->hw_metadata; hw_metadata = NET_DM_SKB_CB(skb)->hw_metadata;
...@@ -761,8 +759,8 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg, ...@@ -761,8 +759,8 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg,
goto nla_put_failure; goto nla_put_failure;
} }
if (ktime_to_timespec_cond(skb->tstamp, &ts) && if (nla_put_u64_64bit(msg, NET_DM_ATTR_TIMESTAMP,
nla_put(msg, NET_DM_ATTR_TIMESTAMP, sizeof(ts), &ts)) ktime_to_ns(skb->tstamp), NET_DM_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(msg, NET_DM_ATTR_ORIG_LEN, skb->len)) if (nla_put_u32(msg, NET_DM_ATTR_ORIG_LEN, skb->len))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment