From: Xin Long <lucien.xin@gmail.com>
To: Yajun Deng <yajun.deng@linux.dev>
Cc: davem <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>,
Vlad Yasevich <vyasevich@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Paolo Abeni <pabeni@redhat.com>,
mathew.j.martineau@linux.intel.com,
Eric Dumazet <edumazet@google.com>,
aahringo@redhat.com, linmiaohe@huawei.com,
Florian Westphal <fw@strlen.de>,
xiangxia.m.yue@gmail.com, Kees Cook <keescook@chromium.org>,
LKML <linux-kernel@vger.kernel.org>,
"linux-sctp @ vger . kernel . org" <linux-sctp@vger.kernel.org>
Subject: Re: [PATCH] net: Fix called net_enable_timestamp() in sctp_copy_sock()
Date: Mon, 5 Jul 2021 21:12:54 -0400 [thread overview]
Message-ID: <CADvbK_dXKK4-t02hUDMPf_O=L8WD7_=aH7c9VmL0ZgtVE_4nUg@mail.gmail.com> (raw)
In-Reply-To: <20210705123405.6089-1-yajun.deng@linux.dev>
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
>
prev parent reply other threads:[~2021-07-06 1:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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='CADvbK_dXKK4-t02hUDMPf_O=L8WD7_=aH7c9VmL0ZgtVE_4nUg@mail.gmail.com' \
--to=lucien.xin@gmail.com \
--cc=aahringo@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=mathew.j.martineau@linux.intel.com \
--cc=nhorman@tuxdriver.com \
--cc=pabeni@redhat.com \
--cc=vyasevich@gmail.com \
--cc=xiangxia.m.yue@gmail.com \
--cc=yajun.deng@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).