aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <a@unstable.cc>2016-05-05 14:46:38 -0400
committerSimon Wunderlich <sw@simonwunderlich.de>2016-06-30 04:29:43 -0400
commit3a24a63e74af1bffc7aeb5d83adcd63b37e38425 (patch)
treeaaac1fe9753860837d89608acc158a96dd16eb8b /net/batman-adv
parentc149ca72e58ac511ad8bf71df833efa9764115a4 (diff)
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>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/gateway_client.c12
-rw-r--r--net/batman-adv/gateway_common.c6
-rw-r--r--net/batman-adv/soft-interface.c6
-rw-r--r--net/batman-adv/sysfs.c10
-rw-r--r--net/batman-adv/types.h8
5 files changed, 21 insertions, 21 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index b9d72e9536b6..18c3715e5e27 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -192,7 +192,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
192 192
193 tq_avg = router_ifinfo->bat_iv.tq_avg; 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 case 1: /* fast connection */ 196 case 1: /* fast connection */
197 tmp_gw_factor = tq_avg * tq_avg; 197 tmp_gw_factor = tq_avg * tq_avg;
198 tmp_gw_factor *= gw_node->bandwidth_down; 198 tmp_gw_factor *= gw_node->bandwidth_down;
@@ -255,7 +255,7 @@ void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
255{ 255{
256 struct batadv_gw_node *curr_gw; 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 return; 259 return;
260 260
261 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); 261 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
@@ -283,7 +283,7 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
283 struct batadv_neigh_ifinfo *router_ifinfo = NULL; 283 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
284 char gw_addr[18] = { '\0' }; 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 goto out; 287 goto out;
288 288
289 curr_gw = batadv_gw_get_selected_gw_node(bat_priv); 289 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
@@ -402,8 +402,8 @@ void batadv_gw_check_election(struct batadv_priv *bat_priv,
402 /* if the routing class is greater than 3 the value tells us how much 402 /* if the routing class is greater than 3 the value tells us how much
403 * greater the TQ value of the new gateway must be 403 * greater the TQ value of the new gateway must be
404 */ 404 */
405 if ((atomic_read(&bat_priv->gw_sel_class) > 3) && 405 if ((atomic_read(&bat_priv->gw.sel_class) > 3) &&
406 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw_sel_class))) 406 (orig_tq_avg - gw_tq_avg < atomic_read(&bat_priv->gw.sel_class)))
407 goto out; 407 goto out;
408 408
409 batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 409 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
@@ -820,7 +820,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
820 if (!gw_node) 820 if (!gw_node)
821 goto out; 821 goto out;
822 822
823 switch (atomic_read(&bat_priv->gw_mode)) { 823 switch (atomic_read(&bat_priv->gw.mode)) {
824 case BATADV_GW_MODE_SERVER: 824 case BATADV_GW_MODE_SERVER:
825 /* If we are a GW then we are our best GW. We can artificially 825 /* If we are a GW then we are our best GW. We can artificially
826 * set the tq towards ourself as the maximum value 826 * set the tq towards ourself as the maximum value
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
index 4423047889e1..3c269457776e 100644
--- a/net/batman-adv/gateway_common.c
+++ b/net/batman-adv/gateway_common.c
@@ -144,7 +144,7 @@ void batadv_gw_tvlv_container_update(struct batadv_priv *bat_priv)
144 u32 down, up; 144 u32 down, up;
145 char gw_mode; 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 switch (gw_mode) { 149 switch (gw_mode) {
150 case BATADV_GW_MODE_OFF: 150 case BATADV_GW_MODE_OFF:
@@ -241,8 +241,8 @@ static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
241 241
242 /* restart gateway selection if fast or late switching was enabled */ 242 /* restart gateway selection if fast or late switching was enabled */
243 if ((gateway.bandwidth_down != 0) && 243 if ((gateway.bandwidth_down != 0) &&
244 (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_CLIENT) && 244 (atomic_read(&bat_priv->gw.mode) == BATADV_GW_MODE_CLIENT) &&
245 (atomic_read(&bat_priv->gw_sel_class) > 2)) 245 (atomic_read(&bat_priv->gw.sel_class) > 2))
246 batadv_gw_check_election(bat_priv, orig); 246 batadv_gw_check_election(bat_priv, orig);
247} 247}
248 248
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 343d2c904399..81665b159a41 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -255,7 +255,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
255 if (batadv_compare_eth(ethhdr->h_dest, ectp_addr)) 255 if (batadv_compare_eth(ethhdr->h_dest, ectp_addr))
256 goto dropped; 256 goto dropped;
257 257
258 gw_mode = atomic_read(&bat_priv->gw_mode); 258 gw_mode = atomic_read(&bat_priv->gw.mode);
259 if (is_multicast_ether_addr(ethhdr->h_dest)) { 259 if (is_multicast_ether_addr(ethhdr->h_dest)) {
260 /* if gw mode is off, broadcast every packet */ 260 /* if gw mode is off, broadcast every packet */
261 if (gw_mode == BATADV_GW_MODE_OFF) { 261 if (gw_mode == BATADV_GW_MODE_OFF) {
@@ -815,8 +815,8 @@ static int batadv_softif_init_late(struct net_device *dev)
815 atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0); 815 atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0);
816 atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0); 816 atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0);
817#endif 817#endif
818 atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); 818 atomic_set(&bat_priv->gw.mode, BATADV_GW_MODE_OFF);
819 atomic_set(&bat_priv->gw_sel_class, 20); 819 atomic_set(&bat_priv->gw.sel_class, 20);
820 atomic_set(&bat_priv->gw.bandwidth_down, 100); 820 atomic_set(&bat_priv->gw.bandwidth_down, 100);
821 atomic_set(&bat_priv->gw.bandwidth_up, 20); 821 atomic_set(&bat_priv->gw.bandwidth_up, 20);
822 atomic_set(&bat_priv->orig_interval, 1000); 822 atomic_set(&bat_priv->orig_interval, 1000);
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index ef5832f4aaba..233abcf33c03 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -427,7 +427,7 @@ static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
427 struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); 427 struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
428 int bytes_written; 428 int bytes_written;
429 429
430 switch (atomic_read(&bat_priv->gw_mode)) { 430 switch (atomic_read(&bat_priv->gw.mode)) {
431 case BATADV_GW_MODE_CLIENT: 431 case BATADV_GW_MODE_CLIENT:
432 bytes_written = sprintf(buff, "%s\n", 432 bytes_written = sprintf(buff, "%s\n",
433 BATADV_GW_MODE_CLIENT_NAME); 433 BATADV_GW_MODE_CLIENT_NAME);
@@ -476,10 +476,10 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
476 return -EINVAL; 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 return count; 480 return count;
481 481
482 switch (atomic_read(&bat_priv->gw_mode)) { 482 switch (atomic_read(&bat_priv->gw.mode)) {
483 case BATADV_GW_MODE_CLIENT: 483 case BATADV_GW_MODE_CLIENT:
484 curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME; 484 curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME;
485 break; 485 break;
@@ -508,7 +508,7 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
508 * state 508 * state
509 */ 509 */
510 batadv_gw_check_client_stop(bat_priv); 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 batadv_gw_tvlv_container_update(bat_priv); 512 batadv_gw_tvlv_container_update(bat_priv);
513 return count; 513 return count;
514} 514}
@@ -624,7 +624,7 @@ BATADV_ATTR_SIF_UINT(orig_interval, orig_interval, S_IRUGO | S_IWUSR,
624 2 * BATADV_JITTER, INT_MAX, NULL); 624 2 * BATADV_JITTER, INT_MAX, NULL);
625BATADV_ATTR_SIF_UINT(hop_penalty, hop_penalty, S_IRUGO | S_IWUSR, 0, 625BATADV_ATTR_SIF_UINT(hop_penalty, hop_penalty, S_IRUGO | S_IWUSR, 0,
626 BATADV_TQ_MAX_VALUE, NULL); 626 BATADV_TQ_MAX_VALUE, NULL);
627BATADV_ATTR_SIF_UINT(gw_sel_class, gw_sel_class, S_IRUGO | S_IWUSR, 1, 627BATADV_ATTR_SIF_UINT(gw_sel_class, gw.sel_class, S_IRUGO | S_IWUSR, 1,
628 BATADV_TQ_MAX_VALUE, batadv_post_gw_reselect); 628 BATADV_TQ_MAX_VALUE, batadv_post_gw_reselect);
629static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth, 629static BATADV_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, batadv_show_gw_bwidth,
630 batadv_store_gw_bwidth); 630 batadv_store_gw_bwidth);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index b70b6ae5edae..32c6d0e42fde 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -707,6 +707,8 @@ struct batadv_priv_debug_log {
707 * @list: list of available gateway nodes 707 * @list: list of available gateway nodes
708 * @list_lock: lock protecting gw_list & curr_gw 708 * @list_lock: lock protecting gw_list & curr_gw
709 * @curr_gw: pointer to currently selected gateway node 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 * @bandwidth_down: advertised uplink download bandwidth (if gw_mode server) 712 * @bandwidth_down: advertised uplink download bandwidth (if gw_mode server)
711 * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server) 713 * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server)
712 * @reselect: bool indicating a gateway re-selection is in progress 714 * @reselect: bool indicating a gateway re-selection is in progress
@@ -715,6 +717,8 @@ struct batadv_priv_gw {
715 struct hlist_head list; 717 struct hlist_head list;
716 spinlock_t list_lock; /* protects gw_list & curr_gw */ 718 spinlock_t list_lock; /* protects gw_list & curr_gw */
717 struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */ 719 struct batadv_gw_node __rcu *curr_gw; /* rcu protected pointer */
720 atomic_t mode;
721 atomic_t sel_class;
718 atomic_t bandwidth_down; 722 atomic_t bandwidth_down;
719 atomic_t bandwidth_up; 723 atomic_t bandwidth_up;
720 atomic_t reselect; 724 atomic_t reselect;
@@ -865,8 +869,6 @@ struct batadv_priv_bat_v {
865 * enabled 869 * enabled
866 * @multicast_mode: Enable or disable multicast optimizations on this node's 870 * @multicast_mode: Enable or disable multicast optimizations on this node's
867 * sender/originating side 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 * @orig_interval: OGM broadcast interval in milliseconds 872 * @orig_interval: OGM broadcast interval in milliseconds
871 * @hop_penalty: penalty which will be applied to an OGM's tq-field on every hop 873 * @hop_penalty: penalty which will be applied to an OGM's tq-field on every hop
872 * @log_level: configured log level (see batadv_dbg_level) 874 * @log_level: configured log level (see batadv_dbg_level)
@@ -922,8 +924,6 @@ struct batadv_priv {
922#ifdef CONFIG_BATMAN_ADV_MCAST 924#ifdef CONFIG_BATMAN_ADV_MCAST
923 atomic_t multicast_mode; 925 atomic_t multicast_mode;
924#endif 926#endif
925 atomic_t gw_mode;
926 atomic_t gw_sel_class;
927 atomic_t orig_interval; 927 atomic_t orig_interval;
928 atomic_t hop_penalty; 928 atomic_t hop_penalty;
929#ifdef CONFIG_BATMAN_ADV_DEBUG 929#ifdef CONFIG_BATMAN_ADV_DEBUG