linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: Matthieu Baerts <matttbe@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 17:05:54 +0800	[thread overview]
Message-ID: <61415314eec15410e42d31fd6d1a8411a937e747.camel@kernel.org> (raw)
In-Reply-To: <773003d9-bbee-4941-a3e7-3590ea80bdb2@kernel.org>

On Thu, 2025-02-27 at 09:45 +0100, Matthieu Baerts wrote:
> 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.

Yes, indeed. I'll add this in v2.

Thanks,
-Geliang

> 
> Cheers,
> Matt


  reply	other threads:[~2025-02-27  9:09 UTC|newest]

Thread overview: 9+ 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
2025-02-27  9:05     ` Geliang Tang [this message]
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

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=61415314eec15410e42d31fd6d1a8411a937e747.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --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=matttbe@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).