From: Florian Westphal <fw@strlen.de>
To: <mptcp@lists.linux.dev>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH mptcp-next 2/8] sock: expose so_timestamp options for mptcp
Date: Thu, 6 May 2021 12:22:37 +0200 [thread overview]
Message-ID: <20210506102243.2390-3-fw@strlen.de> (raw)
In-Reply-To: <20210506102243.2390-1-fw@strlen.de>
This exports SO_TIMESTAMP_* function for re-use by MPTCP.
Without this there is too much copy & paste needed to support
this from mptcp setsockopt path.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/net/sock.h | 1 +
net/core/sock.c | 26 +++++++++++++++++++-------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 42bc5e1a627f..7ee2347846b6 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2741,6 +2741,7 @@ static inline bool sk_dev_equal_l3scope(struct sock *sk, int dif)
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);
void sock_enable_timestamps(struct sock *sk);
void sock_no_linger(struct sock *sk);
void sock_set_keepalive(struct sock *sk);
diff --git a/net/core/sock.c b/net/core/sock.c
index c761c4a0b66b..294b5a9bf520 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -776,6 +776,24 @@ void sock_enable_timestamps(struct sock *sk)
}
EXPORT_SYMBOL(sock_enable_timestamps);
+void sock_set_timestamp(struct sock *sk, int optname, bool valbool)
+{
+ switch (optname) {
+ case SO_TIMESTAMP_OLD:
+ __sock_set_timestamps(sk, valbool, false, false);
+ break;
+ case SO_TIMESTAMP_NEW:
+ __sock_set_timestamps(sk, valbool, true, false);
+ break;
+ case SO_TIMESTAMPNS_OLD:
+ __sock_set_timestamps(sk, valbool, false, true);
+ break;
+ case SO_TIMESTAMPNS_NEW:
+ __sock_set_timestamps(sk, valbool, true, true);
+ break;
+ }
+}
+
void sock_set_keepalive(struct sock *sk)
{
lock_sock(sk);
@@ -989,16 +1007,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
break;
case SO_TIMESTAMP_OLD:
- __sock_set_timestamps(sk, valbool, false, false);
- break;
case SO_TIMESTAMP_NEW:
- __sock_set_timestamps(sk, valbool, true, false);
- break;
case SO_TIMESTAMPNS_OLD:
- __sock_set_timestamps(sk, valbool, false, true);
- break;
case SO_TIMESTAMPNS_NEW:
- __sock_set_timestamps(sk, valbool, true, true);
+ sock_set_timestamp(sk, valbool, optname);
break;
case SO_TIMESTAMPING_NEW:
case SO_TIMESTAMPING_OLD:
--
2.26.3
next prev parent reply other threads:[~2021-05-06 10:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 10:22 [PATCH mptcp-next 0/8] add cmsg support to receive path Florian Westphal
2021-05-06 10:22 ` [PATCH mptcp-next 1/8] mptcp: enable busypoll from mptcp " Florian Westphal
2021-05-11 0:02 ` Mat Martineau
2021-05-06 10:22 ` Florian Westphal [this message]
2021-05-06 10:22 ` [PATCH mptcp-next 3/8] sock: expose so_timestamping options for mptcp Florian Westphal
2021-05-06 10:22 ` [PATCH mptcp-next 4/8] mptcp: sockopt: propagate timestamp request to subflows Florian Westphal
2021-05-06 10:22 ` [PATCH mptcp-next 5/8] mptcp: setsockopt: handle SOL_SOCKET in one place only Florian Westphal
2021-05-11 0:05 ` Mat Martineau
2021-05-11 13:36 ` Florian Westphal
2021-05-06 10:22 ` [PATCH mptcp-next 6/8] tcp: export timestamp helpers for mptcp Florian Westphal
2021-05-06 10:22 ` [PATCH mptcp-next 7/8] mptcp: receive path cmsg support Florian Westphal
2021-05-06 10:22 ` [PATCH mptcp-next 8/8] selftests: mptcp_connect: add SO_TIMESTAMPNS " Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210506102243.2390-3-fw@strlen.de \
--to=fw@strlen.de \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.