[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181119132234.GF2223@nanopsycho.orion>
Date: Mon, 19 Nov 2018 14:22:34 +0100
From: Jiri Pirko <jiri@...nulli.us>
To: Pablo Neira Ayuso <pablo@...filter.org>
Cc: netdev@...r.kernel.org, davem@...emloft.net,
thomas.lendacky@....com, f.fainelli@...il.com,
ariel.elior@...ium.com, michael.chan@...adcom.com,
santosh@...lsio.com, madalin.bucur@....com,
yisen.zhuang@...wei.com, salil.mehta@...wei.com,
jeffrey.t.kirsher@...el.com, tariqt@...lanox.com,
saeedm@...lanox.com, jiri@...lanox.com, idosch@...lanox.com,
jakub.kicinski@...ronome.com, peppe.cavallaro@...com,
grygorii.strashko@...com, andrew@...n.ch,
vivien.didelot@...oirfairelinux.com, alexandre.torgue@...com,
joabreu@...opsys.com, linux-net-drivers@...arflare.com,
ganeshgr@...lsio.com, ogerlitz@...lanox.com
Subject: Re: [PATCH net-next,v2 04/12] cls_api: add translator to flow_action
representation
Mon, Nov 19, 2018 at 02:21:41PM CET, pablo@...filter.org wrote:
>On Mon, Nov 19, 2018 at 01:12:51PM +0100, Jiri Pirko wrote:
>> Mon, Nov 19, 2018 at 01:15:11AM CET, pablo@...filter.org wrote:
>> >@@ -2567,6 +2575,111 @@ int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts,
>> > }
>> > EXPORT_SYMBOL(tc_setup_cb_call);
>> >
>> >+int tc_setup_flow_action(struct flow_action *flow_action,
>> >+ const struct tcf_exts *exts)
>> >+{
>> >+ const struct tc_action *act;
>> >+ int num_acts = 0, i, j, k;
>> >+
>> >+ if (!exts)
>> >+ return 0;
>> >+
>> >+ tcf_exts_for_each_action(i, act, exts) {
>> >+ if (is_tcf_pedit(act))
>> >+ num_acts += tcf_pedit_nkeys(act);
>> >+ else
>> >+ num_acts++;
>> >+ }
>> >+ if (!num_acts)
>> >+ return 0;
>> >+
>> >+ if (flow_action_init(flow_action, num_acts) < 0)
>>
>> This is actually a "alloc" function. And the counterpart is "free".
>
>I can rename it to _alloc() if you prefer.
>
>> How about to allocate the container struct which would have the [0]
>> trick for the array of action?
>
>You mean turn *keys into keys[0] stub in struct flow_action? This is
>embedded into struct tc_cls_flower_offload, I may need to make a
>second look but I think it won't fly.
>
>BTW, side note: I will rename keys to "array" given keys is not
>semantically appropriate as you mentioned, BTW.
What I suggest is this:
struct flow_actions {
unsinged int action_count;
struct flow_action action[0];
};
And then to have
struct flow_actions *flow_actions_alloc(unsigned int action_count)
{
return kzalloc(sizeof(struct flow_actions) + sizeof(struct flow_action) * action_count, ..);
}
Something like this.
>
>Thanks!
Powered by blists - more mailing lists