Skip to content

Commit

Permalink
Merge branch 'bridge_ageing_time'
Browse files Browse the repository at this point in the history
Stephen Hemminger says:

====================
bridge: ageing timer regression fix

This fixes regression in how ageing timer is managed.
Backing out the change required fixing switch drivers as well.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Mar 11, 2016
2 parents 8e2ad41 + 4c656c1 commit 5390dba
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ struct mlxsw_sp {
#define MLXSW_SP_DEFAULT_LEARNING_INTERVAL 100
unsigned int interval; /* ms */
} fdb_notify;
#define MLXSW_SP_MIN_AGEING_TIME 10
#define MLXSW_SP_MAX_AGEING_TIME 1000000
#define MLXSW_SP_DEFAULT_AGEING_TIME 300
u32 ageing_time;
struct mlxsw_sp_upper master_bridge;
Expand Down
9 changes: 7 additions & 2 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,13 @@ static int mlxsw_sp_port_attr_br_ageing_set(struct mlxsw_sp_port *mlxsw_sp_port,
unsigned long ageing_jiffies = clock_t_to_jiffies(ageing_clock_t);
u32 ageing_time = jiffies_to_msecs(ageing_jiffies) / 1000;

if (switchdev_trans_ph_prepare(trans))
return 0;
if (switchdev_trans_ph_prepare(trans)) {
if (ageing_time < MLXSW_SP_MIN_AGEING_TIME ||
ageing_time > MLXSW_SP_MAX_AGEING_TIME)
return -ERANGE;
else
return 0;
}

return mlxsw_sp_ageing_set(mlxsw_sp, ageing_time);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/rocker/rocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct rocker {
struct {
u64 id;
} hw;
unsigned long ageing_time;
spinlock_t cmd_ring_lock; /* for cmd ring accesses */
struct rocker_dma_ring_info cmd_ring;
struct rocker_dma_ring_info event_ring;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/rocker/rocker_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,8 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)

rocker->hw.id = rocker_read64(rocker, SWITCH_ID);

rocker->ageing_time = BR_DEFAULT_AGEING_TIME;

err = rocker_probe_ports(rocker);
if (err) {
dev_err(&pdev->dev, "failed to probe ports\n");
Expand Down
5 changes: 4 additions & 1 deletion drivers/net/ethernet/rocker/rocker_ofdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@ static void ofdpa_fdb_cleanup(unsigned long data)
struct ofdpa_port *ofdpa_port;
struct ofdpa_fdb_tbl_entry *entry;
struct hlist_node *tmp;
unsigned long next_timer = jiffies + BR_MIN_AGEING_TIME;
unsigned long next_timer = jiffies + ofdpa->rocker->ageing_time;
unsigned long expires;
unsigned long lock_flags;
int flags = OFDPA_OP_FLAG_NOWAIT | OFDPA_OP_FLAG_REMOVE |
Expand Down Expand Up @@ -2648,9 +2648,12 @@ ofdpa_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
struct switchdev_trans *trans)
{
struct ofdpa_port *ofdpa_port = rocker_port->wpriv;
struct rocker *rocker = rocker_port->rocker;

if (!switchdev_trans_ph_prepare(trans)) {
ofdpa_port->ageing_time = clock_t_to_jiffies(ageing_time);
if (ofdpa_port->ageing_time < rocker->ageing_time)
rocker->ageing_time = ofdpa_port->ageing_time;
mod_timer(&ofdpa_port->ofdpa->fdb_cleanup_timer, jiffies);
}

Expand Down
4 changes: 0 additions & 4 deletions include/linux/if_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ struct br_ip_list {
#define BR_LEARNING_SYNC BIT(9)
#define BR_PROXYARP_WIFI BIT(10)

/* values as per ieee8021QBridgeFdbAgingTime */
#define BR_MIN_AGEING_TIME (10 * HZ)
#define BR_MAX_AGEING_TIME (1000000 * HZ)

#define BR_DEFAULT_AGEING_TIME (300 * HZ)

extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
Expand Down
11 changes: 8 additions & 3 deletions net/bridge/br_stp.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)

}

/* Set time interval that dynamic forwarding entries live
* For pure software bridge, allow values outside the 802.1
* standard specification for special cases:
* 0 - entry never ages (all permanant)
* 1 - entry disappears (no persistance)
*
* Offloaded switch entries maybe more restrictive
*/
int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
{
struct switchdev_attr attr = {
Expand All @@ -573,9 +581,6 @@ int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
unsigned long t = clock_t_to_jiffies(ageing_time);
int err;

if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
return -ERANGE;

err = switchdev_port_attr_set(br->dev, &attr);
if (err)
return err;
Expand Down

0 comments on commit 5390dba

Please sign in to comment.