net_sched: actions - Add default lookup and walker
Subsystems (3)
Jamal Hadi Salim
maintainercover net_sched: actions - Add default lookup and walker
This set of patches provide defaults for lookup and walkers for actions. Users can override when needed.
Jamal Hadi Salim (4):
Provide default lookup function for actions that dont provide one Use default lookup functions. Users are free to override when needed. Provide default walker function for actions that dont provide one Use default walker functions. Users who need something special can
override.
net/sched/act_api.c | 7 +++++++ net/sched/act_csum.c | 2 -- net/sched/act_gact.c | 2 -- net/sched/act_ipt.c | 4 ---- net/sched/act_mirred.c | 2 -- net/sched/act_nat.c | 2 -- net/sched/act_pedit.c | 2 -- net/sched/act_police.c | 1 - net/sched/act_simple.c | 1 - net/sched/act_skbedit.c | 1 - 10 files changed, 7 insertions(+), 17 deletions(-)
Signature · 1 line
1.7.10.4
Jamal Hadi Salim
maintainerPATCH 1/4 Provide default lookup function for actions that dont provide one
--- net/sched/act_api.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sched/act_api.c +4 -0
@@ -279,6 +279,10 @@ int tcf_register_action(struct tc_action_ops *act) } act->next =NULL ; *ap = act; + +if (!act->lookup) + act->lookup = tcf_hash_search; +write_unlock (&act_mod_lock);return 0 ; }
Signature · 1 line
1.7.10.4
Jamal Hadi Salim
maintainerPATCH 2/4 Use default lookup functions. Users are free to override when needed.
In reply to Jamal Hadi Salim--- net/sched/act_csum.c | 1 - net/sched/act_gact.c | 1 - net/sched/act_ipt.c | 2 -- net/sched/act_mirred.c | 1 - net/sched/act_nat.c | 1 - net/sched/act_pedit.c | 1 - net/sched/act_police.c | 1 - 7 files changed, 8 deletions(-)
net/sched/act_csum.c +0 -1
@@ -585,7 +585,6 @@ static struct tc_action_ops act_csum_ops = { .act = tcf_csum, .dump = tcf_csum_dump, .cleanup = tcf_csum_cleanup, - .lookup = tcf_hash_search, .init = tcf_csum_init, .walk = tcf_generic_walker };
net/sched/act_gact.c +0 -1
@@ -206,7 +206,6 @@ static struct tc_action_ops act_gact_ops = { .act = tcf_gact, .dump = tcf_gact_dump, .cleanup = tcf_gact_cleanup, - .lookup = tcf_hash_search, .init = tcf_gact_init, .walk = tcf_generic_walker };
net/sched/act_ipt.c +0 -2
@@ -298,7 +298,6 @@ static struct tc_action_ops act_ipt_ops = { .act = tcf_ipt, .dump = tcf_ipt_dump, .cleanup = tcf_ipt_cleanup, - .lookup = tcf_hash_search, .init = tcf_ipt_init, .walk = tcf_generic_walker };
@@ -312,7 +311,6 @@ static struct tc_action_ops act_xt_ops = { .act = tcf_ipt, .dump = tcf_ipt_dump, .cleanup = tcf_ipt_cleanup, - .lookup = tcf_hash_search, .init = tcf_ipt_init, .walk = tcf_generic_walker };
net/sched/act_mirred.c +0 -1
@@ -271,7 +271,6 @@ static struct tc_action_ops act_mirred_ops = { .act = tcf_mirred, .dump = tcf_mirred_dump, .cleanup = tcf_mirred_cleanup, - .lookup = tcf_hash_search, .init = tcf_mirred_init, .walk = tcf_generic_walker };
net/sched/act_nat.c +0 -1
@@ -308,7 +308,6 @@ static struct tc_action_ops act_nat_ops = { .act = tcf_nat, .dump = tcf_nat_dump, .cleanup = tcf_nat_cleanup, - .lookup = tcf_hash_search, .init = tcf_nat_init, .walk = tcf_generic_walker };
net/sched/act_pedit.c +0 -1
@@ -243,7 +243,6 @@ static struct tc_action_ops act_pedit_ops = { .act = tcf_pedit, .dump = tcf_pedit_dump, .cleanup = tcf_pedit_cleanup, - .lookup = tcf_hash_search, .init = tcf_pedit_init, .walk = tcf_generic_walker };
net/sched/act_police.c +0 -1
@@ -407,7 +407,6 @@ static struct tc_action_ops act_police_ops = { .act = tcf_act_police, .dump = tcf_act_police_dump, .cleanup = tcf_act_police_cleanup, - .lookup = tcf_hash_search, .init = tcf_act_police_locate, .walk = tcf_act_police_walker };
Signature · 1 line
1.7.10.4
Jamal Hadi Salim
maintainerPATCH 3/4 Provide default walker function for actions that dont provide one
In reply to Jamal Hadi Salim--- net/sched/act_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/sched/act_api.c +3 -0
@@ -280,8 +280,11 @@ int tcf_register_action(struct tc_action_ops *act) act->next =NULL ; *ap = act; +/* Supply defaults */ if (!act->lookup) act->lookup = tcf_hash_search; +if (!act->walk) + act->walk = tcf_generic_walker;write_unlock (&act_mod_lock);return 0 ;
Signature · 1 line
1.7.10.4
Jamal Hadi Salim
maintainerPATCH 4/4 Use default walker functions. Users who need something special can override.
In reply to Jamal Hadi Salim--- net/sched/act_csum.c | 1 - net/sched/act_gact.c | 1 - net/sched/act_ipt.c | 2 -- net/sched/act_mirred.c | 1 - net/sched/act_nat.c | 1 - net/sched/act_pedit.c | 1 - net/sched/act_simple.c | 1 - net/sched/act_skbedit.c | 1 - 8 files changed, 9 deletions(-)
net/sched/act_csum.c +0 -1
@@ -586,7 +586,6 @@ static struct tc_action_ops act_csum_ops = { .dump = tcf_csum_dump, .cleanup = tcf_csum_cleanup, .init = tcf_csum_init, - .walk = tcf_generic_walker };MODULE_DESCRIPTION ("Checksum updating actions" );
net/sched/act_gact.c +0 -1
@@ -207,7 +207,6 @@ static struct tc_action_ops act_gact_ops = { .dump = tcf_gact_dump, .cleanup = tcf_gact_cleanup, .init = tcf_gact_init, - .walk = tcf_generic_walker };MODULE_AUTHOR ("Jamal Hadi Salim(2002-4)" );
net/sched/act_ipt.c +0 -2
@@ -299,7 +299,6 @@ static struct tc_action_ops act_ipt_ops = { .dump = tcf_ipt_dump, .cleanup = tcf_ipt_cleanup, .init = tcf_ipt_init, - .walk = tcf_generic_walker };static struct tc_action_ops act_xt_ops = {
@@ -312,7 +311,6 @@ static struct tc_action_ops act_xt_ops = { .dump = tcf_ipt_dump, .cleanup = tcf_ipt_cleanup, .init = tcf_ipt_init, - .walk = tcf_generic_walker };MODULE_AUTHOR ("Jamal Hadi Salim(2002-13)" );
net/sched/act_mirred.c +0 -1
@@ -272,7 +272,6 @@ static struct tc_action_ops act_mirred_ops = { .dump = tcf_mirred_dump, .cleanup = tcf_mirred_cleanup, .init = tcf_mirred_init, - .walk = tcf_generic_walker };MODULE_AUTHOR ("Jamal Hadi Salim(2002)" );
net/sched/act_nat.c +0 -1
@@ -309,7 +309,6 @@ static struct tc_action_ops act_nat_ops = { .dump = tcf_nat_dump, .cleanup = tcf_nat_cleanup, .init = tcf_nat_init, - .walk = tcf_generic_walker };MODULE_DESCRIPTION ("Stateless NAT actions" );
net/sched/act_pedit.c +0 -1
@@ -244,7 +244,6 @@ static struct tc_action_ops act_pedit_ops = { .dump = tcf_pedit_dump, .cleanup = tcf_pedit_cleanup, .init = tcf_pedit_init, - .walk = tcf_generic_walker };MODULE_AUTHOR ("Jamal Hadi Salim(2002-4)" );
net/sched/act_simple.c +0 -1
@@ -201,7 +201,6 @@ static struct tc_action_ops act_simp_ops = { .dump = tcf_simp_dump, .cleanup = tcf_simp_cleanup, .init = tcf_simp_init, - .walk = tcf_generic_walker, };MODULE_AUTHOR ("Jamal Hadi Salim(2005)" );
net/sched/act_skbedit.c +0 -1
@@ -203,7 +203,6 @@ static struct tc_action_ops act_skbedit_ops = { .dump = tcf_skbedit_dump, .cleanup = tcf_skbedit_cleanup, .init = tcf_skbedit_init, - .walk = tcf_generic_walker, };MODULE_AUTHOR ("Alexander Duyck, <[email protected]>" );
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: Jamal Hadi Salim <[email protected]>
Date: Sun, 1 Dec 2013 17:30:05 -0500
Quoted 9 lines
This set of patches provide defaults for lookup and walkers for actions. Users can override when needed.
Jamal Hadi Salim (4):
Provide default lookup function for actions that dont provide one Use default lookup functions. Users are free to override when needed. Provide default walker function for actions that dont provide one Use default walker functions. Users who need something special can
override.
Ok, but can you respin this set, adding in changes to remove the code that checks for NULL in these operations?
Specifically, we still have:
if (a->ops->lookup == NULL) goto err_mod;
in tcf_action_get_1(). And:
if (a_o->walk == NULL) {in tc_dump_action().
Furthermore, there is a hard assumption that a_o->init() is non-NULL as well. So maybe add a:
if (!act->init) return -EINVAL;
at the top of tcf_register_action().
It also occurred to me that it would be simpler to audit and be a simpler patch set to review if you just added the missing ".lookup =" assignments to the actions and added a similar "if (!act->lookup)" et al. check to tcf_register_action().
That looks more like a rigorous requirement to have a valid method present for these three operations: init, lookup, walk.
What do you think?
Thanks!
Jamal Hadi Salim
maintainerQuoted 6 lines · David Miller
Ok, but can you respin this set, adding in changes to remove the code that checks for NULL in these operations?
Specifically, we still have:
Quoted 9 lines
if (a->ops->lookup == NULL) goto err_mod;in
tcf_action_get_1(). And:if (a_o->walk == NULL) {in
tc_dump_action().
Ok, I think i finaly understood what you were saying earlier;-> I was too focused on the simple fix needed for Eric B. Will make this change ..
Quoted 8 lines
Furthermore, there is a hard assumption that
a_o->init()is non-NULL as well. So maybe add a:if (!act->init) return -EINVAL;at the top of
tcf_register_action().
Makes sense.
Quoted 3 lines
It also occurred to me that it would be simpler to audit and be a simpler patch set to review if you just added the missing ".lookup =" assignments to the actions
Those two methods have proven to be always the defaults and only the oddball action deviates. So my preference is to have defaults as per that earlier patch (and overrides for the oddball).
Quoted 7 lines
and added a similar "if (!act->lookup)" et
al. check totcf_register_action().That looks more like a rigorous requirement to have a valid method present for these three operations: init, lookup, walk.
What do you think?
Yep - makes sense (I think you meant act, dump, cleanup and init) I will add an extra patch..
cheers,
jamal
Quoted 2 lines
Thanks!