mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
UPSTREAM: netfilter: nfnetlink_log: always add a timestamp
Compared to all the other work we're already doing to deliver
an skb to userspace this is very cheap - at worse an extra
call to ktime_get_real() - and very useful.
(and indeed it may even be cheaper if we're running from other hooks)
(background: Android occasionally logs packets which
caused wake from sleep/suspend and we'd like to have
timestamps reliably associated with these events)
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
(cherry picked from commit 1d85594fd3)
Change-Id: Id9b8bc046204c11bf3321e73a67b444777d387dd
This commit is contained in:
committed by
Treehugger Robot
parent
4db95aa21a
commit
ec6b3d552a
@@ -460,7 +460,6 @@ __build_packet_message(struct nfnl_log_net *log,
|
|||||||
sk_buff_data_t old_tail = inst->skb->tail;
|
sk_buff_data_t old_tail = inst->skb->tail;
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
const unsigned char *hwhdrp;
|
const unsigned char *hwhdrp;
|
||||||
ktime_t tstamp;
|
|
||||||
|
|
||||||
nlh = nfnl_msg_put(inst->skb, 0, 0,
|
nlh = nfnl_msg_put(inst->skb, 0, 0,
|
||||||
nfnl_msg_type(NFNL_SUBSYS_ULOG, NFULNL_MSG_PACKET),
|
nfnl_msg_type(NFNL_SUBSYS_ULOG, NFULNL_MSG_PACKET),
|
||||||
@@ -589,10 +588,9 @@ __build_packet_message(struct nfnl_log_net *log,
|
|||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
tstamp = skb_tstamp_cond(skb, false);
|
if (hooknum <= NF_INET_FORWARD) {
|
||||||
if (hooknum <= NF_INET_FORWARD && tstamp) {
|
struct timespec64 kts = ktime_to_timespec64(skb_tstamp_cond(skb, true));
|
||||||
struct nfulnl_msg_packet_timestamp ts;
|
struct nfulnl_msg_packet_timestamp ts;
|
||||||
struct timespec64 kts = ktime_to_timespec64(tstamp);
|
|
||||||
ts.sec = cpu_to_be64(kts.tv_sec);
|
ts.sec = cpu_to_be64(kts.tv_sec);
|
||||||
ts.usec = cpu_to_be64(kts.tv_nsec / NSEC_PER_USEC);
|
ts.usec = cpu_to_be64(kts.tv_nsec / NSEC_PER_USEC);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user