Re: [PATCH net-next 1/4] sock: add sock_kmemdup helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> > 
> > 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





[Index of Archives]     [Linux Networking Development]     [Linux OMAP]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     SCTP

  Powered by Linux