Re: [PATCH v2 nf-next 1/2] netfilter: nf_tables: use struct nlattr * to store userdata for nft_table

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

 



On Mon, Mar 11, 2024 at 12:09:23AM +0100, Florian Westphal wrote:
> Quan Tian <tianquan23@xxxxxxxxx> wrote:
> > To prepare for the support for table comment updates, the patch changes
> > to store userdata in struct nlattr *, which can be updated atomically on
> > updates.
> > 
> > Signed-off-by: Quan Tian <tianquan23@xxxxxxxxx>
> > ---
> > v2: Change to store userdata in struct nlattr * to ensure atomical update
> 
> Looks good, one minor nit below.
> 
> >  	if (nla[NFTA_TABLE_USERDATA]) {
> > -		table->udata = nla_memdup(nla[NFTA_TABLE_USERDATA], GFP_KERNEL_ACCOUNT);
> > +		table->udata = kmemdup(nla[NFTA_TABLE_USERDATA],
> > +				       nla_total_size(nla_len(nla[NFTA_TABLE_USERDATA])),
> > +				       GFP_KERNEL_ACCOUNT);
> 
> I think its correct but it might make sense to add a small helper for
> this kmemdup so we don't need to copypaste in case this should get
> extended to e.g. chain udata update support.

Extracted a function as suggested in v3, and also used it when
duplicating the userdata when preparing trans for table updates.
After this is merged, I could extend comment update support for other
objects in the same fashion.

Thanks,
Quan




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux