mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
net: dsa: check out-of-range ageing time value
If a DSA switch driver cannot program an ageing time value due to it being out-of-range, switchdev will raise a stack trace before failing. To fix this, add ageing_time_min and ageing_time_max members to the dsa_switch in order for the switch drivers to optionally specify their supported ageing time limits. The DSA core will now check for provided ageing time limits and return -ERANGE from the switchdev prepare phase if the value is out-of-range. Signed-off-by: Vivien Didelot <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
e893de1ba1
commit
0f3da6afee
2 changed files with 10 additions and 2 deletions
|
|
@ -443,9 +443,13 @@ static int dsa_slave_ageing_time(struct net_device *dev,
|
|||
unsigned long ageing_jiffies = clock_t_to_jiffies(attr->u.ageing_time);
|
||||
unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies);
|
||||
|
||||
/* bridge skips -EOPNOTSUPP, so skip the prepare phase */
|
||||
if (switchdev_trans_ph_prepare(trans))
|
||||
if (switchdev_trans_ph_prepare(trans)) {
|
||||
if (ds->ageing_time_min && ageing_time < ds->ageing_time_min)
|
||||
return -ERANGE;
|
||||
if (ds->ageing_time_max && ageing_time > ds->ageing_time_max)
|
||||
return -ERANGE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Keep the fastest ageing time in case of multiple bridges */
|
||||
p->dp->ageing_time = ageing_time;
|
||||
|
|
|
|||
Loading…
Reference in a new issue