Re: [PATCH net] net: sched: set xt_tgchk_param par.net properly in ipt_init_target

2017-08-07 Thread Xin Long
On Tue, Aug 8, 2017 at 9:00 AM, Cong Wang  wrote:
> On Sat, Aug 5, 2017 at 1:48 AM, Xin Long  wrote:
>> -static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
>> +static int __tcf_ipt_init(struct net *net, struct nlattr *nla,
>>   struct nlattr *est, struct tc_action **a,
>>   const struct tc_action_ops *ops, int ovr, int bind)
>>  {
>> +   struct tc_action_net *tn = net_generic(net, xt_net_id);
>
> ...
>
>> @@ -193,18 +195,14 @@ static int tcf_ipt_init(struct net *net, struct nlattr 
>> *nla,
>> struct nlattr *est, struct tc_action **a, int ovr,
>> int bind)
>>  {
>> -   struct tc_action_net *tn = net_generic(net, ipt_net_id);
>> -
>> -   return __tcf_ipt_init(tn, nla, est, a, _ipt_ops, ovr, bind);
>> +   return __tcf_ipt_init(net, nla, est, a, _ipt_ops, ovr, bind);
>>  }
>>
>>  static int tcf_xt_init(struct net *net, struct nlattr *nla,
>>struct nlattr *est, struct tc_action **a, int ovr,
>>int bind)
>>  {
>> -   struct tc_action_net *tn = net_generic(net, xt_net_id);
>> -
>> -   return __tcf_ipt_init(tn, nla, est, a, _xt_ops, ovr, bind);
>> +   return __tcf_ipt_init(net, nla, est, a, _xt_ops, ovr, bind);
>
> This is not correct.
>
> You miss ipt_net_id != xt_net_id.
right, that's a silly mistake. seems no better way but to pass both
net and net_id to __tcf_ipt_init. will send v2. thanks.


Re: [PATCH net] net: sched: set xt_tgchk_param par.net properly in ipt_init_target

2017-08-07 Thread Cong Wang
On Sat, Aug 5, 2017 at 1:48 AM, Xin Long  wrote:
> -static int __tcf_ipt_init(struct tc_action_net *tn, struct nlattr *nla,
> +static int __tcf_ipt_init(struct net *net, struct nlattr *nla,
>   struct nlattr *est, struct tc_action **a,
>   const struct tc_action_ops *ops, int ovr, int bind)
>  {
> +   struct tc_action_net *tn = net_generic(net, xt_net_id);

...

> @@ -193,18 +195,14 @@ static int tcf_ipt_init(struct net *net, struct nlattr 
> *nla,
> struct nlattr *est, struct tc_action **a, int ovr,
> int bind)
>  {
> -   struct tc_action_net *tn = net_generic(net, ipt_net_id);
> -
> -   return __tcf_ipt_init(tn, nla, est, a, _ipt_ops, ovr, bind);
> +   return __tcf_ipt_init(net, nla, est, a, _ipt_ops, ovr, bind);
>  }
>
>  static int tcf_xt_init(struct net *net, struct nlattr *nla,
>struct nlattr *est, struct tc_action **a, int ovr,
>int bind)
>  {
> -   struct tc_action_net *tn = net_generic(net, xt_net_id);
> -
> -   return __tcf_ipt_init(tn, nla, est, a, _xt_ops, ovr, bind);
> +   return __tcf_ipt_init(net, nla, est, a, _xt_ops, ovr, bind);

This is not correct.

You miss ipt_net_id != xt_net_id.