Author: marek Date: 2010-03-25 02:39:32 +0100 (Thu, 25 Mar 2010) New Revision: 1614
Modified: trunk/batman-adv-kernelland/gateway_client.c trunk/batman-adv-kernelland/gateway_client.h trunk/batman-adv-kernelland/routing.c Log: batman-adv: fix gateway selection
The sysfs conversion left some global variables which were not properly removed and made a gateway selection impossible. This patch fixes that.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batman-adv-kernelland/gateway_client.c =================================================================== --- trunk/batman-adv-kernelland/gateway_client.c 2010-03-22 22:30:52 UTC (rev 1613) +++ trunk/batman-adv-kernelland/gateway_client.c 2010-03-25 01:39:32 UTC (rev 1614) @@ -31,7 +31,6 @@ static LIST_HEAD(gw_list); static DEFINE_SPINLOCK(curr_gw_lock); static DEFINE_SPINLOCK(gw_list_lock); -atomic_t gw_clnt_class; static struct gw_node *curr_gateway;
void *gw_get_selected(void) @@ -57,6 +56,8 @@
void gw_election(void) { + /* FIXME: get bat_priv */ + struct bat_priv *bat_priv = netdev_priv(soft_device); struct gw_node *gw_node, *curr_gw_tmp = NULL; uint8_t max_tq = 0; uint32_t max_gw_factor = 0, tmp_gw_factor = 0; @@ -68,7 +69,7 @@ * hear about. This check is based on the daemon's uptime which we * don't have. **/ - if (atomic_read(&gw_clnt_class) == 0) + if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT) return;
if (curr_gateway) @@ -94,7 +95,7 @@ if (gw_node->deleted) continue;
- switch (atomic_read(&gw_clnt_class)) { + switch (atomic_read(&bat_priv->gw_class)) { case 1: /* fast connection */ gw_srv_class_to_kbit(gw_node->orig_node->gw_flags, &down, &up); @@ -155,7 +156,7 @@ spin_unlock(&curr_gw_lock); }
-void gw_check_election(struct orig_node *orig_node) +void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node) { struct gw_node *curr_gateway_tmp; uint8_t gw_tq_avg, orig_tq_avg; @@ -191,8 +192,8 @@ * if the routing class is greater than 3 the value tells us how much * greater the TQ value of the new gateway must be **/ - if ((atomic_read(&gw_clnt_class) > 3) && - (orig_tq_avg - gw_tq_avg < atomic_read(&gw_clnt_class))) + if ((atomic_read(&bat_priv->gw_class) > 3) && + (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_class))) return;
bat_dbg(DBG_BATMAN,
Modified: trunk/batman-adv-kernelland/gateway_client.h =================================================================== --- trunk/batman-adv-kernelland/gateway_client.h 2010-03-22 22:30:52 UTC (rev 1613) +++ trunk/batman-adv-kernelland/gateway_client.h 2010-03-25 01:39:32 UTC (rev 1614) @@ -19,12 +19,10 @@ * */
-extern atomic_t gw_clnt_class; - void gw_deselect(void); void gw_election(void); void *gw_get_selected(void); -void gw_check_election(struct orig_node *orig_node); +void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node); void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags); void gw_node_delete(struct orig_node *orig_node); void gw_node_purge_deleted(void);
Modified: trunk/batman-adv-kernelland/routing.c =================================================================== --- trunk/batman-adv-kernelland/routing.c 2010-03-22 22:30:52 UTC (rev 1613) +++ trunk/batman-adv-kernelland/routing.c 2010-03-25 01:39:32 UTC (rev 1614) @@ -233,6 +233,8 @@ unsigned char *hna_buff, int hna_buff_len, char is_duplicate) { + /* FIXME: get bat_priv */ + struct bat_priv *bat_priv = netdev_priv(soft_device); struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; int tmp_hna_buff_len;
@@ -317,8 +319,8 @@ orig_node->gw_flags = batman_packet->gw_flags;
/* restart gateway selection if fast or late switching was enabled */ - if ((orig_node->gw_flags) && (atomic_read(&gw_clnt_class) > 2)) - gw_check_election(orig_node); + if ((orig_node->gw_flags) && (atomic_read(&bat_priv->gw_class) > 2)) + gw_check_election(bat_priv, orig_node); }
static char count_real_packets(struct ethhdr *ethhdr,