mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>
Cc: Geliang Tang <tanggeliang@kylinos.cn>,
	netdev@vger.kernel.org, mptcp@lists.linux.dev,
	linux-sctp@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
	Neal Cardwell <ncardwell@google.com>,
	Mat Martineau <martineau@kernel.org>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Xin Long <lucien.xin@gmail.com>
Subject: Re: [PATCH net-next 1/4] sock: add sock_kmemdup helper
Date: Thu, 27 Feb 2025 09:45:01 +0100	[thread overview]
Message-ID: <773003d9-bbee-4941-a3e7-3590ea80bdb2@kernel.org> (raw)
In-Reply-To: <a26c04cba801be45ce01a41b6a14a871246177c5.1740643844.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 27/02/2025 09:23, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> This patch adds the sock version of kmemdup() helper, named sock_kmemdup(),
> to duplicate the input "src" memory block using the socket's option memory
> buffer.

Thank you for suggesting this series.

(...)

> diff --git a/net/core/sock.c b/net/core/sock.c
> index 5ac445f8244b..95e81d24f4cc 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -2819,6 +2819,21 @@ void *sock_kmalloc(struct sock *sk, int size, gfp_t priority)
>  }
>  EXPORT_SYMBOL(sock_kmalloc);
>  
> +/*
> + * Duplicate the input "src" memory block using the socket's
> + * option memory buffer.
> + */
> +void *sock_kmemdup(struct sock *sk, const void *src,
> +		   int size, gfp_t priority)
> +{
> +	void *mem;
> +
> +	mem = sock_kmalloc(sk, size, priority);
> +	if (mem)
> +		memcpy(mem, src, size);
> +	return mem;
> +}


I think you will need to add an EXPORT_SYMBOL() here, if you plan to use
it in SCTP which can be compiled as a module.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2025-02-27  8:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27  8:23 [PATCH net-next 0/4] add sock_kmemdup helper Geliang Tang
2025-02-27  8:23 ` [PATCH net-next 1/4] sock: " Geliang Tang
2025-02-27  8:45   ` Matthieu Baerts [this message]
2025-02-27  9:05     ` Geliang Tang
2025-02-27  8:23 ` [PATCH net-next 2/4] net: use sock_kmemdup for ip_options Geliang Tang
2025-02-27  8:23 ` [PATCH net-next 3/4] mptcp: use sock_kmemdup for address entry Geliang Tang
2025-02-27  8:23 ` [PATCH net-next 4/4] net/tcp_ao: use sock_kmemdup for tcp_ao_key Geliang Tang
2025-02-27  8:35   ` Eric Dumazet
2025-02-27  9:04     ` Geliang Tang
2025-02-27  9:33 ` [PATCH net-next 0/4] add sock_kmemdup helper MPTCP CI

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=773003d9-bbee-4941-a3e7-3590ea80bdb2@kernel.org \
    --to=matttbe@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=geliang@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-sctp@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=marcelo.leitner@gmail.com \
    --cc=martineau@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tanggeliang@kylinos.cn \
    --cc=willemb@google.com \
    /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).