summaryrefslogtreecommitdiffstats
path: root/net/mptcp
diff options
context:
space:
mode:
authorYangbo Lu <yangbo.lu@nxp.com>2021-06-30 16:11:59 +0800
committerDavid S. Miller <davem@davemloft.net>2021-07-01 13:08:18 -0700
commitd463126e23f112629edb01594141ca437a92a108 (patch)
tree65dc1baabdb9e2aefc4208f358f6eec3bf54154d /net/mptcp
parent6c9a0a0f2333b1e3c29fef47a8b12131fce4905b (diff)
downloadlinux-d463126e23f112629edb01594141ca437a92a108.tar.gz
linux-d463126e23f112629edb01594141ca437a92a108.tar.xz
net: sock: extend SO_TIMESTAMPING for PHC binding
Since PTP virtual clock support is added, there can be several PTP virtual clocks based on one PTP physical clock for timestamping. This patch is to extend SO_TIMESTAMPING API to support PHC (PTP Hardware Clock) binding by adding a new flag SOF_TIMESTAMPING_BIND_PHC. When PTP virtual clocks are in use, user space can configure to bind one for timestamping, but PTP physical clock is not supported and not needed to bind. This patch is preparation for timestamp conversion from raw timestamp to a specific PTP virtual clock time in core net. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mptcp')
-rw-r--r--net/mptcp/sockopt.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index ea38cbcd2ad4..8c03afac5ca0 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -207,14 +207,25 @@ static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk,
{
struct mptcp_subflow_context *subflow;
struct sock *sk = (struct sock *)msk;
- int val, ret;
+ struct so_timestamping timestamping;
+ int ret;
- ret = mptcp_get_int_option(msk, optval, optlen, &val);
- if (ret)
- return ret;
+ if (optlen == sizeof(timestamping)) {
+ if (copy_from_sockptr(&timestamping, optval,
+ sizeof(timestamping)))
+ return -EFAULT;
+ } else if (optlen == sizeof(int)) {
+ memset(&timestamping, 0, sizeof(timestamping));
+
+ if (copy_from_sockptr(&timestamping.flags, optval, sizeof(int)))
+ return -EFAULT;
+ } else {
+ return -EINVAL;
+ }
ret = sock_setsockopt(sk->sk_socket, SOL_SOCKET, optname,
- KERNEL_SOCKPTR(&val), sizeof(val));
+ KERNEL_SOCKPTR(&timestamping),
+ sizeof(timestamping));
if (ret)
return ret;
@@ -224,7 +235,7 @@ static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk,
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
bool slow = lock_sock_fast(ssk);
- sock_set_timestamping(sk, optname, val);
+ sock_set_timestamping(sk, optname, timestamping);
unlock_sock_fast(ssk, slow);
}