Skip to content

Commit

Permalink
team: send port changed when added
Browse files Browse the repository at this point in the history
On some hw, link is not up during adding iface to team. That causes event
not being sent to userspace and that may cause confusion.
Fix this bug by sending port changed event once it's added to team.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Sep 22, 2012
1 parent ab43ed8 commit 0b121fd
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ static struct netpoll_info *team_netpoll_info(struct team *team)
}
#endif

static void __team_port_change_check(struct team_port *port, bool linkup);
static void __team_port_change_port_added(struct team_port *port, bool linkup);

static int team_port_add(struct team *team, struct net_device *port_dev)
{
Expand Down Expand Up @@ -948,7 +948,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
team_port_enable(team, port);
list_add_tail_rcu(&port->list, &team->port_list);
__team_compute_features(team);
__team_port_change_check(port, !!netif_carrier_ok(port_dev));
__team_port_change_port_added(port, !!netif_carrier_ok(port_dev));
__team_options_change_check(team);

netdev_info(dev, "Port device %s added\n", portname);
Expand Down Expand Up @@ -983,6 +983,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
return err;
}

static void __team_port_change_port_removed(struct team_port *port);

static int team_port_del(struct team *team, struct net_device *port_dev)
{
struct net_device *dev = team->dev;
Expand All @@ -999,8 +1001,7 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
__team_option_inst_mark_removed_port(team, port);
__team_options_change_check(team);
__team_option_inst_del_port(team, port);
port->removed = true;
__team_port_change_check(port, false);
__team_port_change_port_removed(port);
team_port_disable(team, port);
list_del_rcu(&port->list);
netdev_rx_handler_unregister(port_dev);
Expand Down Expand Up @@ -2251,13 +2252,11 @@ static void __team_options_change_check(struct team *team)
}

/* rtnl lock is held */
static void __team_port_change_check(struct team_port *port, bool linkup)

static void __team_port_change_send(struct team_port *port, bool linkup)
{
int err;

if (!port->removed && port->state.linkup == linkup)
return;

port->changed = true;
port->state.linkup = linkup;
team_refresh_port_linkup(port);
Expand All @@ -2282,6 +2281,23 @@ static void __team_port_change_check(struct team_port *port, bool linkup)

}

static void __team_port_change_check(struct team_port *port, bool linkup)
{
if (port->state.linkup != linkup)
__team_port_change_send(port, linkup);
}

static void __team_port_change_port_added(struct team_port *port, bool linkup)
{
__team_port_change_send(port, linkup);
}

static void __team_port_change_port_removed(struct team_port *port)
{
port->removed = true;
__team_port_change_send(port, false);
}

static void team_port_change_check(struct team_port *port, bool linkup)
{
struct team *team = port->team;
Expand Down

0 comments on commit 0b121fd

Please sign in to comment.