On Saturday, April 27, 2013 23:59:53 Antonio Quartulli wrote:
--- a/gateway_common.c +++ b/gateway_common.c @@ -202,8 +202,8 @@ static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, gateway.bandwidth_up = 0; } else { gateway_ptr = tvlv_value;
gateway.bandwidth_down =
ntohl(gateway_ptr->bandwidth_down); - gateway.bandwidth_up = ntohl(gateway_ptr->bandwidth_up); + gateway.bandwidth_down = gateway_ptr->bandwidth_down; + gateway.bandwidth_up = gateway_ptr->bandwidth_up; if ((gateway.bandwidth_down == 0) || (gateway.bandwidth_up == 0)) { gateway.bandwidth_down = 0;
There is no bug. The original code converted the incoming big endian value to host endian (whatever that is) and works with that value internally. Now that you reversed the logic you have to adjust *all* occurences. Especially, when the tvlv bandwidth value is copied into a gw_node struct. You can use sparse to help you find the sections in the code by changing gw_node to be32 as well.
However, I am not convinced that converting the values every single time we access the variable is the optimal approach.
Cheers, Marek