All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Fix called net_enable_timestamp() in sctp_copy_sock()
@ 2021-07-05 12:34 Yajun Deng
  2021-07-06  1:12 ` Xin Long
  0 siblings, 1 reply; 2+ messages in thread
From: Yajun Deng @ 2021-07-05 12:34 UTC (permalink / raw)
  To: davem, kuba, vyasevich, nhorman, marcelo.leitner, pabeni,
	mathew.j.martineau, edumazet, aahringo, linmiaohe, fw,
	xiangxia.m.yue, keescook
  Cc: linux-kernel, linux-sctp, Yajun Deng

Add sock_needs_netstamp() judgment condition when need to call
net_enable_timestamp().

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 include/net/sock.h | 1 +
 net/core/sock.c    | 2 +-
 net/sctp/socket.c  | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 8bdd80027ffb..e36563576758 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2757,6 +2757,7 @@ 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_timestamping(struct sock *sk, int optname, int val);
 
+bool sock_needs_netstamp(const struct sock *sk);
 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 ba1c0f75cd45..ce6ec9f8ac7c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -429,7 +429,7 @@ static int sock_set_timeout(long *timeo_p, sockptr_t optval, int optlen,
 	return 0;
 }
 
-static bool sock_needs_netstamp(const struct sock *sk)
+bool sock_needs_netstamp(const struct sock *sk)
 {
 	switch (sk->sk_family) {
 	case AF_UNSPEC:
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e64e01f61b11..30d90735beb0 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -9449,7 +9449,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
 	newinet->mc_index = 0;
 	newinet->mc_list = NULL;
 
-	if (newsk->sk_flags & SK_FLAGS_TIMESTAMP)
+	if (sock_needs_netstamp(newsk) && newsk->sk_flags & SK_FLAGS_TIMESTAMP)
 		net_enable_timestamp();
 
 	/* Set newsk security attributes from original sk and connection
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: Fix called net_enable_timestamp() in sctp_copy_sock()
  2021-07-05 12:34 [PATCH] net: Fix called net_enable_timestamp() in sctp_copy_sock() Yajun Deng
@ 2021-07-06  1:12 ` Xin Long
  0 siblings, 0 replies; 2+ messages in thread
From: Xin Long @ 2021-07-06  1:12 UTC (permalink / raw)
  To: Yajun Deng
  Cc: davem, Jakub Kicinski, Vlad Yasevich, Neil Horman,
	Marcelo Ricardo Leitner, Paolo Abeni, mathew.j.martineau,
	Eric Dumazet, aahringo, linmiaohe, Florian Westphal,
	xiangxia.m.yue, Kees Cook, LKML,
	linux-sctp @ vger . kernel . org

On Mon, Jul 5, 2021 at 8:34 AM Yajun Deng <yajun.deng@linux.dev> wrote:
>
> Add sock_needs_netstamp() judgment condition when need to call
> net_enable_timestamp().
Why do we need this when it always returns true for SCTP?

>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  include/net/sock.h | 1 +
>  net/core/sock.c    | 2 +-
>  net/sctp/socket.c  | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 8bdd80027ffb..e36563576758 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2757,6 +2757,7 @@ 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_timestamping(struct sock *sk, int optname, int val);
>
> +bool sock_needs_netstamp(const struct sock *sk);
>  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 ba1c0f75cd45..ce6ec9f8ac7c 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -429,7 +429,7 @@ static int sock_set_timeout(long *timeo_p, sockptr_t optval, int optlen,
>         return 0;
>  }
>
> -static bool sock_needs_netstamp(const struct sock *sk)
> +bool sock_needs_netstamp(const struct sock *sk)
>  {
>         switch (sk->sk_family) {
>         case AF_UNSPEC:
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index e64e01f61b11..30d90735beb0 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -9449,7 +9449,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
>         newinet->mc_index = 0;
>         newinet->mc_list = NULL;
>
> -       if (newsk->sk_flags & SK_FLAGS_TIMESTAMP)
> +       if (sock_needs_netstamp(newsk) && newsk->sk_flags & SK_FLAGS_TIMESTAMP)
>                 net_enable_timestamp();
>
>         /* Set newsk security attributes from original sk and connection
> --
> 2.32.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-06  1:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 12:34 [PATCH] net: Fix called net_enable_timestamp() in sctp_copy_sock() Yajun Deng
2021-07-06  1:12 ` Xin Long

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.