Vitaly Lavrov
2015-Dec-14  19:21 UTC
[Bridge] [RFC] The problem with the mirrored traffic: setageing 0 not work
Hi!
After commit c62987bbd8a1a1664f99e89e3959339350a6131e (bridge: push bridge
setting ageing_time down to switchdev)
impossible to handle mirrored traffic through netfilter and it is impossible to
transfer it to a virtual machine.
The problem code is net/bridge/br_stp.c:br_set_ageing_time() line 580
---------------------------------------------------------------------
570 int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
571 {
572         struct switchdev_attr attr = {
573                 .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
574                 .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
575                 .u.ageing_time = ageing_time,
576         };
577         unsigned long t = clock_t_to_jiffies(ageing_time);
578         int err;
579
580         if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
581                 return -ERANGE;
582
583         err = switchdev_port_attr_set(br->dev, &attr);
584         if (err)
585                 return err;
586
587         br->ageing_time = t;
-----------------------------------------------------------------------
To handle the mirrored traffic we must have ageing_time = 0.
IMHO check aging_time need to move in ops->switchdev_port_attr_set().
If it is a hardware switch and it has restrictions on ageing_time, then it must
return -ERANGE.
For a software implementation of a switch(brigde) we can allow the special value
"0" ageing_time.
The second problem is in the line 584 - Do not check the error code
"EOPNOTSUPP"
This line must be  "if (err && err != -EOPNOTSUPP)"
How better to done in such situation?