Commit 3a24a63e74af1bffc7aeb5d83adcd63b37e38425

Authored by Antonio Quartulli
Committed by Simon Wunderlich
1 parent c149ca72e5

batman-adv: move GW mode and selection class to private data structure

To reduce the field pollution in our main batadv_priv data structure
we've already created some substructures so that we could group fields
in a convenient manner.

However gw_mode and gw_sel_class are still part of the main object.

More both fields to the GW private substructure.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>

Showing 5 changed files with 21 additions and 21 deletions Side-by-side Diff

net/batman-adv/gateway_client.c
... ... @@ -192,7 +192,7 @@
192 192  
193 193 tq_avg = router_ifinfo->bat_iv.tq_avg;
194 194  
195   - switch (atomic_read(&bat_priv->gw_sel_class)) {
  195 + switch (atomic_read(&bat_priv->gw.sel_class)) {
196 196 case 1: /* fast connection */
197 197 tmp_gw_factor = tq_avg * tq_avg;
198 198 tmp_gw_factor *= gw_node->bandwidth_down;
... ... @@ -255,7 +255,7 @@
255 255 {
256 256 struct batadv_gw_node *curr_gw;
257 257  
258   - if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT)
  258 + if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
259 259 return;
260 260  
261 261 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
... ... @@ -283,7 +283,7 @@
283 283 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
284 284 char gw_addr[18] = { '\0' };
285 285  
286   - if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_CLIENT)
  286 + if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
287 287 goto out;
288 288  
289 289 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
... ... @@ -402,8 +402,8 @@
402 402 /* if the routing class is greater than 3 the value tells us how much
403 403 * greater the TQ value of the new gateway must be
404 404 */
405   - if ((atomic_read(&bat_priv->gw_sel_class) > 3) &&
406   - (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class)))
  405 + if ((atomic_read(&bat_priv->gw.sel_class) > 3) &&
  406 + (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw.sel_class)))
407 407 goto out;
408 408  
409 409 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
... ... @@ -820,7 +820,7 @@
820 820 if (!gw_node)
821 821 goto out;
822 822  
823   - switch (atomic_read(&bat_priv->gw_mode)) {
  823 + switch (atomic_read(&bat_priv->gw.mode)) {
824 824 case BATADV_GW_MODE_SERVER:
825 825 /* If we are a GW then we are our best GW. We can artificially
826 826 * set the tq towards ourself as the maximum value
net/batman-adv/gateway_common.c
... ... @@ -144,7 +144,7 @@
144 144 u32 down, up;
145 145 char gw_mode;
146 146  
147   - gw_mode = atomic_read(&bat_priv->gw_mode);
  147 + gw_mode = atomic_read(&bat_priv->gw.mode);
148 148  
149 149 switch (gw_mode) {
150 150 case BATADV_GW_MODE_OFF:
... ... @@ -241,8 +241,8 @@
241 241  
242 242 /* restart gateway selection if fast or late switching was enabled */
243 243 if ((gateway.bandwidth_down != 0) &&
244   - (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_CLIENT) &&
245   - (atomic_read(&bat_priv->gw_sel_class) > 2))
  244 + (atomic_read(&bat_priv->gw.mode) == BATADV_GW_MODE_CLIENT) &&
  245 + (atomic_read(&bat_priv->gw.sel_class) > 2))
246 246 batadv_gw_check_election(bat_priv, orig);
247 247 }
248 248  
net/batman-adv/soft-interface.c
... ... @@ -255,7 +255,7 @@
255 255 if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
256 256 goto dropped;
257 257  
258   - gw_mode = atomic_read(&bat_priv->gw_mode);
  258 + gw_mode = atomic_read(&bat_priv->gw.mode);
259 259 if (is_multicast_ether_addr(ethhdr->h_dest)) {
260 260 /* if gw mode is off, broadcast every packet */
261 261 if (gw_mode == BATADV_GW_MODE_OFF) {
... ... @@ -815,8 +815,8 @@
815 815 atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0);
816 816 atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0);
817 817 #endif
818   - atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF);
819   - atomic_set(&bat_priv->gw_sel_class, 20);
  818 + atomic_set(&bat_priv->gw.mode, BATADV_GW_MODE_OFF);
  819 + atomic_set(&bat_priv->gw.sel_class, 20);
820 820 atomic_set(&bat_priv->gw.bandwidth_down, 100);
821 821 atomic_set(&bat_priv->gw.bandwidth_up, 20);
822 822 atomic_set(&bat_priv->orig_interval, 1000);
net/batman-adv/sysfs.c
... ... @@ -427,7 +427,7 @@
427 427 struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
428 428 int bytes_written;
429 429  
430   - switch (atomic_read(&bat_priv->gw_mode)) {
  430 + switch (atomic_read(&bat_priv->gw.mode)) {
431 431 case BATADV_GW_MODE_CLIENT:
432 432 bytes_written = sprintf(buff, "%s\n",
433 433 BATADV_GW_MODE_CLIENT_NAME);
434 434  
... ... @@ -476,10 +476,10 @@
476 476 return -EINVAL;
477 477 }
478 478  
479   - if (atomic_read(&bat_priv->gw_mode) == gw_mode_tmp)
  479 + if (atomic_read(&bat_priv->gw.mode) == gw_mode_tmp)
480 480 return count;
481 481  
482   - switch (atomic_read(&bat_priv->gw_mode)) {
  482 + switch (atomic_read(&bat_priv->gw.mode)) {
483 483 case BATADV_GW_MODE_CLIENT:
484 484 curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME;
485 485 break;
... ... @@ -508,7 +508,7 @@
508 508 * state
509 509 */
510 510 batadv_gw_check_client_stop(bat_priv);
511   - atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
  511 + atomic_set(&bat_priv->gw.mode, (unsigned int)gw_mode_tmp);
512 512 batadv_gw_tvlv_container_update(bat_priv);
513 513 return count;
514 514 }
... ... @@ -624,7 +624,7 @@
624 624 2 * BATADV_JITTER, INT_MAX, NULL);
625 625 BATADV_ATTR_SIF_UINT(hop_penalty, hop_penalty, S_IRUGO | S_IWUSR, 0,
626 626 BATADV_TQ_MAX_VALUE, NULL);
627   -BATADV_ATTR_SIF_UINT(gw_sel_class, gw_sel_class, S_IRUGO | S_IWUSR, 1,
  627 +BATADV_ATTR_SIF_UINT(gw_sel_class, gw.sel_class, S_IRUGO | S_IWUSR, 1,
628 628 BATADV_TQ_MAX_VALUE, batadv_post_gw_reselect);
629 629 static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
630 630 batadv_store_gw_bwidth);
net/batman-adv/types.h
... ... @@ -707,6 +707,8 @@
707 707 * @list: list of available gateway nodes
708 708 * @list_lock: lock protecting gw_list & curr_gw
709 709 * @curr_gw: pointer to currently selected gateway node
  710 + * @mode: gateway operation: off, client or server (see batadv_gw_modes)
  711 + * @sel_class: gateway selection class (applies if gw_mode client)
710 712 * @bandwidth_down: advertised uplink download bandwidth (if gw_mode server)
711 713 * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server)
712 714 * @reselect: bool indicating a gateway re-selection is in progress
... ... @@ -715,6 +717,8 @@
715 717 struct hlist_head list;
716 718 spinlock_t list_lock; /* protects gw_list & curr_gw */
717 719 struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */
  720 + atomic_t mode;
  721 + atomic_t sel_class;
718 722 atomic_t bandwidth_down;
719 723 atomic_t bandwidth_up;
720 724 atomic_t reselect;
... ... @@ -865,8 +869,6 @@
865 869 * enabled
866 870 * @multicast_mode: Enable or disable multicast optimizations on this node's
867 871 * sender/originating side
868   - * @gw_mode: gateway operation: off, client or server (see batadv_gw_modes)
869   - * @gw_sel_class: gateway selection class (applies if gw_mode client)
870 872 * @orig_interval: OGM broadcast interval in milliseconds
871 873 * @hop_penalty: penalty which will be applied to an OGM's tq-field on every hop
872 874 * @log_level: configured log level (see batadv_dbg_level)
... ... @@ -922,8 +924,6 @@
922 924 #ifdef CONFIG_BATMAN_ADV_MCAST
923 925 atomic_t multicast_mode;
924 926 #endif
925   - atomic_t gw_mode;
926   - atomic_t gw_sel_class;
927 927 atomic_t orig_interval;
928 928 atomic_t hop_penalty;
929 929 #ifdef CONFIG_BATMAN_ADV_DEBUG