Fixing a bug in team driver due to incorrect 'unsigned int' to 'int' conversion
authorAlex Sidorenko <alexandre.sidorenko@hpe.com>
Fri, 7 Oct 2016 13:02:33 +0000 (09:02 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sat, 8 Oct 2016 03:50:39 +0000 (23:50 -0400)
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.

Signed-off-by: Alex Sidorenko <alexandre.sidorenko@hpe.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_team.h

index 174f43f43affc1dcfd7a4a67a0efcf06547607fb..c05216a8fbac95cb34a123d70b76431888f35ed7 100644 (file)
@@ -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);