Skip to contentSkip to conversation

team: fall back to hash if table entry is empty

PATCH Applied Jim Hanko 2 participants 2 messages Sep 19, 2017

Subsystems (3)
lore
Share & tools
lore

Jim Hanko

author
#0 lore raw

PATCH 1/1 team: fall back to hash if table entry is empty

If the hash to port mapping table does not have a valid port (i.e. when a port goes down), fall back to the simple hashing mechanism to avoid dropping packets.

---
 drivers/net/team/team_mode_loadbalance.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/team/team_mode_loadbalance.c +7 -1
index 1468ddf..a5ef970 100644
@@ -137,7 +137,13 @@ static struct team_port *lb_htpm_select_tx_port(struct team *team,
 						struct sk_buff *skb,
 						unsigned char hash)
 {
-	return rcu_dereference_bh(LB_HTPM_PORT_BY_HASH(lb_priv, hash));
+	struct team_port *port;
+
+	port = rcu_dereference_bh(LB_HTPM_PORT_BY_HASH(lb_priv, hash));
+	if (likely(port))
+		return port;
+	/* If no valid port in the table, fall back to simple hash */
+	return lb_hash_select_tx_port(team, lb_priv, skb, hash);
 }
 
 struct lb_select_tx_port {
Signature · 1 line
2.7.4