team: do not allow to map disabled ports

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2012-06-26 06:52:46 +00:00 committed by David S. Miller
parent 122bb046bc
commit 52a4fd7780
3 changed files with 6 additions and 4 deletions

View File

@ -614,8 +614,6 @@ static int team_change_mode(struct team *team, const char *kind)
* Rx path frame handler * Rx path frame handler
************************/ ************************/
static bool team_port_enabled(struct team_port *port);
/* note: already called with rcu_read_lock */ /* note: already called with rcu_read_lock */
static rx_handler_result_t team_handle_frame(struct sk_buff **pskb) static rx_handler_result_t team_handle_frame(struct sk_buff **pskb)
{ {
@ -673,10 +671,11 @@ static bool team_port_find(const struct team *team,
return false; return false;
} }
static bool team_port_enabled(struct team_port *port) bool team_port_enabled(struct team_port *port)
{ {
return port->index != -1; return port->index != -1;
} }
EXPORT_SYMBOL(team_port_enabled);
/* /*
* Enable/disable port by adding to enabled port hashlist and setting * Enable/disable port by adding to enabled port hashlist and setting

View File

@ -359,7 +359,8 @@ static int lb_tx_hash_to_port_mapping_set(struct team *team,
unsigned char hash = ctx->info->array_index; unsigned char hash = ctx->info->array_index;
list_for_each_entry(port, &team->port_list, list) { list_for_each_entry(port, &team->port_list, list) {
if (ctx->data.u32_val == port->dev->ifindex) { if (ctx->data.u32_val == port->dev->ifindex &&
team_port_enabled(port)) {
rcu_assign_pointer(LB_HTPM_PORT_BY_HASH(lb_priv, hash), rcu_assign_pointer(LB_HTPM_PORT_BY_HASH(lb_priv, hash),
port); port);
return 0; return 0;

View File

@ -64,6 +64,8 @@ struct team_port {
long mode_priv[0]; long mode_priv[0];
}; };
extern bool team_port_enabled(struct team_port *port);
struct team_mode_ops { struct team_mode_ops {
int (*init)(struct team *team); int (*init)(struct team *team);
void (*exit)(struct team *team); void (*exit)(struct team *team);