brintos

brintos / linux-shallow public Read only

0
0
Text · 480 B · 7ea0863 Raw
25 lines · c
1// SPDX-License-Identifier: GPL-2.02/* Copyright (C) 2022 Linutronix GmbH */3 4#include <linux/bpf.h>5#include <bpf/bpf_helpers.h>6 7char _license[] SEC("license") = "GPL";8 9SEC("tc")10int time_tai(struct __sk_buff *skb)11{12	__u64 ts1, ts2;13 14	/* Get TAI timestamps */15	ts1 = bpf_ktime_get_tai_ns();16	ts2 = bpf_ktime_get_tai_ns();17 18	/* Save TAI timestamps (Note: skb->hwtstamp is read-only) */19	skb->tstamp = ts1;20	skb->cb[0] = ts2 & 0xffffffff;21	skb->cb[1] = ts2 >> 32;22 23	return 0;24}25