@@ -2917,6 +2917,7 @@ void sock_def_readable(struct sock *sk);
int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk);
void sock_set_timestamp(struct sock *sk, int optname, bool valbool);
+int sock_set_tskey(struct sock *sk, int val, int bpf_type);
int sock_set_timestamping(struct sock *sk, int optname,
struct so_timestamping timestamping);
@@ -891,21 +891,16 @@ static int sock_timestamping_bind_phc(struct sock *sk, int phc_index)
return 0;
}
-int sock_set_timestamping(struct sock *sk, int optname,
- struct so_timestamping timestamping)
+int sock_set_tskey(struct sock *sk, int val, int bpf_type)
{
- int val = timestamping.flags;
- int ret;
-
- if (val & ~SOF_TIMESTAMPING_MASK)
- return -EINVAL;
+ u32 tsflags = bpf_type ? sk->sk_tsflags_bpf : sk->sk_tsflags;
if (val & SOF_TIMESTAMPING_OPT_ID_TCP &&
!(val & SOF_TIMESTAMPING_OPT_ID))
return -EINVAL;
if (val & SOF_TIMESTAMPING_OPT_ID &&
- !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
+ !(tsflags & SOF_TIMESTAMPING_OPT_ID)) {
if (sk_is_tcp(sk)) {
if ((1 << sk->sk_state) &
(TCPF_CLOSE | TCPF_LISTEN))
@@ -919,6 +914,22 @@ int sock_set_timestamping(struct sock *sk, int optname,
}
}
+ return 0;
+}
+
+int sock_set_timestamping(struct sock *sk, int optname,
+ struct so_timestamping timestamping)
+{
+ int val = timestamping.flags;
+ int ret;
+
+ if (val & ~SOF_TIMESTAMPING_MASK)
+ return -EINVAL;
+
+ ret = sock_set_tskey(sk, val, 0);
+ if (ret)
+ return ret;
+
if (val & SOF_TIMESTAMPING_OPT_STATS &&
!(val & SOF_TIMESTAMPING_OPT_TSONLY))
return -EINVAL;