net/sched: act_gate: fix configuration of the periodic timer
authorDavide Caratti <dcaratti@redhat.com>
Tue, 16 Jun 2020 20:25:21 +0000 (22:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Jun 2020 03:17:49 +0000 (20:17 -0700)
commitc362a06e96eae16ccb7b0f4f93f19224279b8610
treebb65728fc572399d82ed0387886c5c335bb582be
parent7024339a1cfa0d5bbfa628a7a35b67789cc86d7f
net/sched: act_gate: fix configuration of the periodic timer

assigning a dummy value of 'clock_id' to avoid cancellation of the cycle
timer before its initialization was a temporary solution, and we still
need to handle the case where act_gate timer parameters are changed by
commands like the following one:

 # tc action replace action gate <parameters>

the fix consists in the following items:

1) remove the workaround assignment of 'clock_id', and init the list of
   entries before the first error path after IDR atomic check/allocation
2) validate 'clock_id' earlier: there is no need to do IDR atomic
   check/allocation if we know that 'clock_id' is a bad value
3) use a dedicated function, 'gate_setup_timer()', to ensure that the
   timer is cancelled and re-initialized on action overwrite, and also
   ensure we initialize the timer in the error path of tcf_gate_init()

v3: improve comment in the error path of tcf_gate_init() (thanks to
    Vladimir Oltean)
v2: avoid 'goto' in gate_setup_timer (thanks to Cong Wang)

CC: Ivan Vecera <ivecera@redhat.com>
Fixes: a01c245438c5 ("net/sched: fix a couple of splats in the error path of tfc_gate_init()")
Fixes: a51c328df310 ("net: qos: introduce a gate control flow action")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Acked-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_gate.c