diff options
author | David S. Miller <davem@davemloft.net> | 2014-08-05 19:39:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-08-05 19:39:47 -0400 |
commit | 6ff4e36f8b69540b99aac75964154e14e7d6a6db (patch) | |
tree | 064246ae8554b93ffbd5e15c881dea7b48662713 /net | |
parent | ff204cce75d75678bf75fdd48c4c89fa30c555d3 (diff) | |
parent | 71b75d0e95b7699394f1d7d76628df719e859ef1 (diff) |
Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge
Antonio Quartulli says:
====================
pull request: batman-adv 2014-08-05
this is a pull request intended for net-next/linux-3.17 (yeah..it's really
late).
Patches 1, 2 and 4 are really minor changes:
- kmalloc_array is substituted to kmalloc when possible (as suggested by
checkpatch);
- net_ratelimited() is now used properly and the "suppressed" message is not
printed anymore if not needed;
- the internal version number has been increased to reflect our current version.
Patch 3 instead is introducing a change in the metric computation function
by changing the penalty applied at each mesh hop from 15/255 (~6%) to
30/255 (~11%). This change is introduced by Simon Wunderlich after having
observed a performance improvement in several networks when using the new value.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/bat_iv_ogm.c | 13 | ||||
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 3 | ||||
-rw-r--r-- | net/batman-adv/hash.c | 6 | ||||
-rw-r--r-- | net/batman-adv/main.h | 22 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 18 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 2 |
6 files changed, 37 insertions, 27 deletions
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index f04224c32005..1e8053976e83 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c | |||
@@ -108,14 +108,15 @@ static int batadv_iv_ogm_orig_add_if(struct batadv_orig_node *orig_node, | |||
108 | int max_if_num) | 108 | int max_if_num) |
109 | { | 109 | { |
110 | void *data_ptr; | 110 | void *data_ptr; |
111 | size_t data_size, old_size; | 111 | size_t old_size; |
112 | int ret = -ENOMEM; | 112 | int ret = -ENOMEM; |
113 | 113 | ||
114 | spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock); | 114 | spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock); |
115 | 115 | ||
116 | data_size = max_if_num * sizeof(unsigned long) * BATADV_NUM_WORDS; | ||
117 | old_size = (max_if_num - 1) * sizeof(unsigned long) * BATADV_NUM_WORDS; | 116 | old_size = (max_if_num - 1) * sizeof(unsigned long) * BATADV_NUM_WORDS; |
118 | data_ptr = kmalloc(data_size, GFP_ATOMIC); | 117 | data_ptr = kmalloc_array(max_if_num, |
118 | BATADV_NUM_WORDS * sizeof(unsigned long), | ||
119 | GFP_ATOMIC); | ||
119 | if (!data_ptr) | 120 | if (!data_ptr) |
120 | goto unlock; | 121 | goto unlock; |
121 | 122 | ||
@@ -123,7 +124,7 @@ static int batadv_iv_ogm_orig_add_if(struct batadv_orig_node *orig_node, | |||
123 | kfree(orig_node->bat_iv.bcast_own); | 124 | kfree(orig_node->bat_iv.bcast_own); |
124 | orig_node->bat_iv.bcast_own = data_ptr; | 125 | orig_node->bat_iv.bcast_own = data_ptr; |
125 | 126 | ||
126 | data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); | 127 | data_ptr = kmalloc_array(max_if_num, sizeof(uint8_t), GFP_ATOMIC); |
127 | if (!data_ptr) { | 128 | if (!data_ptr) { |
128 | kfree(orig_node->bat_iv.bcast_own); | 129 | kfree(orig_node->bat_iv.bcast_own); |
129 | goto unlock; | 130 | goto unlock; |
@@ -164,7 +165,7 @@ static int batadv_iv_ogm_orig_del_if(struct batadv_orig_node *orig_node, | |||
164 | goto free_bcast_own; | 165 | goto free_bcast_own; |
165 | 166 | ||
166 | chunk_size = sizeof(unsigned long) * BATADV_NUM_WORDS; | 167 | chunk_size = sizeof(unsigned long) * BATADV_NUM_WORDS; |
167 | data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); | 168 | data_ptr = kmalloc_array(max_if_num, chunk_size, GFP_ATOMIC); |
168 | if (!data_ptr) | 169 | if (!data_ptr) |
169 | goto unlock; | 170 | goto unlock; |
170 | 171 | ||
@@ -183,7 +184,7 @@ free_bcast_own: | |||
183 | if (max_if_num == 0) | 184 | if (max_if_num == 0) |
184 | goto free_own_sum; | 185 | goto free_own_sum; |
185 | 186 | ||
186 | data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC); | 187 | data_ptr = kmalloc_array(max_if_num, sizeof(uint8_t), GFP_ATOMIC); |
187 | if (!data_ptr) { | 188 | if (!data_ptr) { |
188 | kfree(orig_node->bat_iv.bcast_own); | 189 | kfree(orig_node->bat_iv.bcast_own); |
189 | goto unlock; | 190 | goto unlock; |
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index f2c066b21716..b5981113c9a7 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -537,7 +537,8 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) | |||
537 | if (!bat_priv->orig_hash) | 537 | if (!bat_priv->orig_hash) |
538 | return NULL; | 538 | return NULL; |
539 | 539 | ||
540 | res = kmalloc(BATADV_DAT_CANDIDATES_NUM * sizeof(*res), GFP_ATOMIC); | 540 | res = kmalloc_array(BATADV_DAT_CANDIDATES_NUM, sizeof(*res), |
541 | GFP_ATOMIC); | ||
541 | if (!res) | 542 | if (!res) |
542 | return NULL; | 543 | return NULL; |
543 | 544 | ||
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c index 63bdf7e94f1e..7c1c63080e20 100644 --- a/net/batman-adv/hash.c +++ b/net/batman-adv/hash.c | |||
@@ -46,12 +46,12 @@ struct batadv_hashtable *batadv_hash_new(uint32_t size) | |||
46 | if (!hash) | 46 | if (!hash) |
47 | return NULL; | 47 | return NULL; |
48 | 48 | ||
49 | hash->table = kmalloc(sizeof(*hash->table) * size, GFP_ATOMIC); | 49 | hash->table = kmalloc_array(size, sizeof(*hash->table), GFP_ATOMIC); |
50 | if (!hash->table) | 50 | if (!hash->table) |
51 | goto free_hash; | 51 | goto free_hash; |
52 | 52 | ||
53 | hash->list_locks = kmalloc(sizeof(*hash->list_locks) * size, | 53 | hash->list_locks = kmalloc_array(size, sizeof(*hash->list_locks), |
54 | GFP_ATOMIC); | 54 | GFP_ATOMIC); |
55 | if (!hash->list_locks) | 55 | if (!hash->list_locks) |
56 | goto free_table; | 56 | goto free_table; |
57 | 57 | ||
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 118b990bae25..a1fcd884f0b1 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -24,7 +24,7 @@ | |||
24 | #define BATADV_DRIVER_DEVICE "batman-adv" | 24 | #define BATADV_DRIVER_DEVICE "batman-adv" |
25 | 25 | ||
26 | #ifndef BATADV_SOURCE_VERSION | 26 | #ifndef BATADV_SOURCE_VERSION |
27 | #define BATADV_SOURCE_VERSION "2014.3.0" | 27 | #define BATADV_SOURCE_VERSION "2014.4.0" |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | /* B.A.T.M.A.N. parameters */ | 30 | /* B.A.T.M.A.N. parameters */ |
@@ -238,21 +238,29 @@ enum batadv_dbg_level { | |||
238 | int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) | 238 | int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) |
239 | __printf(2, 3); | 239 | __printf(2, 3); |
240 | 240 | ||
241 | #define batadv_dbg(type, bat_priv, fmt, arg...) \ | 241 | /* possibly ratelimited debug output */ |
242 | #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...) \ | ||
242 | do { \ | 243 | do { \ |
243 | if (atomic_read(&bat_priv->log_level) & type) \ | 244 | if (atomic_read(&bat_priv->log_level) & type && \ |
245 | (!ratelimited || net_ratelimit())) \ | ||
244 | batadv_debug_log(bat_priv, fmt, ## arg);\ | 246 | batadv_debug_log(bat_priv, fmt, ## arg);\ |
245 | } \ | 247 | } \ |
246 | while (0) | 248 | while (0) |
247 | #else /* !CONFIG_BATMAN_ADV_DEBUG */ | 249 | #else /* !CONFIG_BATMAN_ADV_DEBUG */ |
248 | __printf(3, 4) | 250 | __printf(4, 5) |
249 | static inline void batadv_dbg(int type __always_unused, | 251 | static inline void _batadv_dbg(int type __always_unused, |
250 | struct batadv_priv *bat_priv __always_unused, | 252 | struct batadv_priv *bat_priv __always_unused, |
251 | const char *fmt __always_unused, ...) | 253 | int ratelimited __always_unused, |
254 | const char *fmt __always_unused, ...) | ||
252 | { | 255 | { |
253 | } | 256 | } |
254 | #endif | 257 | #endif |
255 | 258 | ||
259 | #define batadv_dbg(type, bat_priv, arg...) \ | ||
260 | _batadv_dbg(type, bat_priv, 0, ## arg) | ||
261 | #define batadv_dbg_ratelimited(type, bat_priv, arg...) \ | ||
262 | _batadv_dbg(type, bat_priv, 1, ## arg) | ||
263 | |||
256 | #define batadv_info(net_dev, fmt, arg...) \ | 264 | #define batadv_info(net_dev, fmt, arg...) \ |
257 | do { \ | 265 | do { \ |
258 | struct net_device *_netdev = (net_dev); \ | 266 | struct net_device *_netdev = (net_dev); \ |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 35141534938e..35f76f2f7824 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -706,11 +706,11 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, | |||
706 | if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) { | 706 | if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) { |
707 | if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, | 707 | if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, |
708 | ethhdr->h_dest, vid)) | 708 | ethhdr->h_dest, vid)) |
709 | net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, | 709 | batadv_dbg_ratelimited(BATADV_DBG_TT, |
710 | bat_priv, | 710 | bat_priv, |
711 | "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n", | 711 | "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n", |
712 | unicast_packet->dest, | 712 | unicast_packet->dest, |
713 | ethhdr->h_dest); | 713 | ethhdr->h_dest); |
714 | /* at this point the mesh destination should have been | 714 | /* at this point the mesh destination should have been |
715 | * substituted with the originator address found in the global | 715 | * substituted with the originator address found in the global |
716 | * table. If not, let the packet go untouched anyway because | 716 | * table. If not, let the packet go untouched anyway because |
@@ -752,10 +752,10 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, | |||
752 | */ | 752 | */ |
753 | if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, | 753 | if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, |
754 | ethhdr->h_dest, vid)) { | 754 | ethhdr->h_dest, vid)) { |
755 | net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv, | 755 | batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv, |
756 | "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", | 756 | "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", |
757 | unicast_packet->dest, ethhdr->h_dest, | 757 | unicast_packet->dest, ethhdr->h_dest, |
758 | old_ttvn, curr_ttvn); | 758 | old_ttvn, curr_ttvn); |
759 | return 1; | 759 | return 1; |
760 | } | 760 | } |
761 | 761 | ||
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index e0a723991c54..5467955eb27c 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -751,7 +751,7 @@ static int batadv_softif_init_late(struct net_device *dev) | |||
751 | atomic_set(&bat_priv->gw.bandwidth_down, 100); | 751 | atomic_set(&bat_priv->gw.bandwidth_down, 100); |
752 | atomic_set(&bat_priv->gw.bandwidth_up, 20); | 752 | atomic_set(&bat_priv->gw.bandwidth_up, 20); |
753 | atomic_set(&bat_priv->orig_interval, 1000); | 753 | atomic_set(&bat_priv->orig_interval, 1000); |
754 | atomic_set(&bat_priv->hop_penalty, 15); | 754 | atomic_set(&bat_priv->hop_penalty, 30); |
755 | #ifdef CONFIG_BATMAN_ADV_DEBUG | 755 | #ifdef CONFIG_BATMAN_ADV_DEBUG |
756 | atomic_set(&bat_priv->log_level, 0); | 756 | atomic_set(&bat_priv->log_level, 0); |
757 | #endif | 757 | #endif |