Subject: Re: net/netfilter/nf_conntrack_proto_tcp.c:1606:9: error: ‘struct nf_proto_net’ has no member named ‘user’

From: Gao feng <[email-masked]>
Date: Tue, 12 Jun 2012 09:46:06 +0800

于 2012年06月12日 08:26, Pablo Neira Ayuso 写道:
> Hi again David,
> 
> On Mon, Jun 11, 2012 at 03:23:44PM -0700, David Miller wrote:
>> From: Pablo Neira Ayuso <[email-masked]>
>> Date: Tue, 12 Jun 2012 00:15:21 +0200
>>
>>> Could you please apply the following patch to net-next to resolve
>>> this? Thanks.
>>
>> Applied, but you have to be kidding me with those ifdefs.
>>
>> This is exactly the same kind of thing Gao suggested for
>> the inetpeer code recently and which I flat out rejected.
>>
>> You can't pepper foo.c files with ifdefs all over the place.
> 
> Would you be OK if I send you patches to move all sysctl part of
> nf_conntrack_proto_*.c to nf_conntrack_proto_*_sysctl.c
> 
> I can also do the same for nf_conntrack_proto.c.
> 
> This means more files under the net/netfilter directory, but less
> ifdef kludges in the code.
> 
> Please, have a look at the patch enclosed to this email in case you
> want to see how it would look like in the end with my proposal.

I am sorry for all the trouble aroused by my negligence.

>  static int tcpv4_init_net(struct net *net)
>  {
>  	int i;
> @@ -1600,11 +1373,7 @@ static int tcpv4_init_net(struct net *net)
>  	struct nf_tcp_net *tn = tcp_pernet(net);
>  	struct nf_proto_net *pn = (struct nf_proto_net *)tn;
>  
> -#ifdef CONFIG_SYSCTL
> -	if (!pn->ctl_table) {
> -#else
>  	if (!pn->users++) {

nf_proto_net.users has different meaning when SYSCTL enabled or disabled.

when SYSCTL enabled,it means if both tcpv4 and tcpv6 register the sysctl,
it is increased when register sysctl success and decreased when unregister sysctl.
we can regard it as the refcnt of ctl_table.

when SYSCTL disabled,it just used to identify if the proto's pernet data
has been initialized.