Skip to contentSkip to conversation

Fixing a bug in team driver due to incorrect 'unsigned int' to 'int' conversion

PATCH In review Alex Sidorenko 2 participants 2 messages Oct 7, 2016 – Oct 8, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Fixing a bug in team driver due to incorrect 'unsigned int' to 'int' conversion

Roundrobin runner of team driver uses 'unsigned int' variable to count the number of sent_packets. Later it is passed to a subroutine team_num_to_port_index(struct team *team, int num) as 'num' and when we reach MAXINT (2**31-1), 'num' becomes negative.

This leads to using incorrect hash-bucket for port lookup and as a result, packets are dropped. The fix consists of changing 'int num' to 'unsigned int num'. Testing of a fixed kernel shows that there is no packet drop anymore.

---
v2: fixed formatting

 include/linux/if_team.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/if_team.h +1 -1
index 174f43f..c05216a 100644
@@ -245,7 +245,7 @@ static inline struct team_port *team_get_port_by_index(struct team *team,
 	return NULL;
 }
 
-static inline int team_num_to_port_index(struct team *team, int num)
+static inline int team_num_to_port_index(struct team *team, unsigned int num)
 {
 	int en_port_count = ACCESS_ONCE(team->en_port_count);
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

From: Alex Sidorenko <[email protected]>
Date: Fri, 07 Oct 2016 09:02:33 -0400

Quoted 5 lines

Roundrobin runner of team driver uses 'unsigned int' variable to count the number of sent_packets. Later it is passed to a subroutine team_num_to_port_index(struct team *team, int num) as 'num' and when we reach MAXINT (2**31-1), 'num' becomes negative.

Quoted 7 lines

This leads to using incorrect hash-bucket for port lookup and as a result, packets are dropped. The fix consists of changing 'int num' to 'unsigned int num'. Testing of a fixed kernel shows that there is no packet drop anymore.

Applied and queued up for -stable, thanks.