Commit 3e34819e0eafaa6c873e9704bb478c0cdd6bb481

Authored by Sven Eckelmann
Committed by Antonio Quartulli
1 parent ee11ad61f2

batman-adv: Prefix remaining function like macros with batadv_

Signed-off-by: Sven Eckelmann <sven@narfation.org>

Showing 11 changed files with 98 additions and 89 deletions Side-by-side Diff

net/batman-adv/bat_debugfs.c
... ... @@ -360,8 +360,8 @@
360 360 bat_priv->debug_dir,
361 361 dev, &(*bat_debug)->fops);
362 362 if (!file) {
363   - bat_err(dev, "Can't add debugfs file: %s/%s\n",
364   - dev->name, ((*bat_debug)->attr).name);
  363 + batadv_err(dev, "Can't add debugfs file: %s/%s\n",
  364 + dev->name, ((*bat_debug)->attr).name);
365 365 goto rem_attr;
366 366 }
367 367 }
net/batman-adv/bat_iv_ogm.c
... ... @@ -373,7 +373,7 @@
373 373  
374 374 /* own packet should always be scheduled */
375 375 if (!own_packet) {
376   - if (!atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
  376 + if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
377 377 batadv_dbg(DBG_BATMAN, bat_priv,
378 378 "batman packet queue full\n");
379 379 goto out;
net/batman-adv/bat_sysfs.c
... ... @@ -191,18 +191,17 @@
191 191 enabled = 0;
192 192  
193 193 if (enabled < 0) {
194   - bat_info(net_dev,
195   - "%s: Invalid parameter received: %s\n",
196   - attr_name, buff);
  194 + batadv_info(net_dev, "%s: Invalid parameter received: %s\n",
  195 + attr_name, buff);
197 196 return -EINVAL;
198 197 }
199 198  
200 199 if (atomic_read(attr) == enabled)
201 200 return count;
202 201  
203   - bat_info(net_dev, "%s: Changing from: %s to: %s\n", attr_name,
204   - atomic_read(attr) == 1 ? "enabled" : "disabled",
205   - enabled == 1 ? "enabled" : "disabled");
  202 + batadv_info(net_dev, "%s: Changing from: %s to: %s\n", attr_name,
  203 + atomic_read(attr) == 1 ? "enabled" : "disabled",
  204 + enabled == 1 ? "enabled" : "disabled");
206 205  
207 206 atomic_set(attr, (unsigned int)enabled);
208 207 return count;
209 208  
210 209  
211 210  
... ... @@ -235,29 +234,28 @@
235 234  
236 235 ret = kstrtoul(buff, 10, &uint_val);
237 236 if (ret) {
238   - bat_info(net_dev,
239   - "%s: Invalid parameter received: %s\n",
240   - attr_name, buff);
  237 + batadv_info(net_dev, "%s: Invalid parameter received: %s\n",
  238 + attr_name, buff);
241 239 return -EINVAL;
242 240 }
243 241  
244 242 if (uint_val < min) {
245   - bat_info(net_dev, "%s: Value is too small: %lu min: %u\n",
246   - attr_name, uint_val, min);
  243 + batadv_info(net_dev, "%s: Value is too small: %lu min: %u\n",
  244 + attr_name, uint_val, min);
247 245 return -EINVAL;
248 246 }
249 247  
250 248 if (uint_val > max) {
251   - bat_info(net_dev, "%s: Value is too big: %lu max: %u\n",
252   - attr_name, uint_val, max);
  249 + batadv_info(net_dev, "%s: Value is too big: %lu max: %u\n",
  250 + attr_name, uint_val, max);
253 251 return -EINVAL;
254 252 }
255 253  
256 254 if (atomic_read(attr) == uint_val)
257 255 return count;
258 256  
259   - bat_info(net_dev, "%s: Changing from: %i to: %lu\n",
260   - attr_name, atomic_read(attr), uint_val);
  257 + batadv_info(net_dev, "%s: Changing from: %i to: %lu\n",
  258 + attr_name, atomic_read(attr), uint_val);
261 259  
262 260 atomic_set(attr, uint_val);
263 261 return count;
... ... @@ -299,6 +297,7 @@
299 297 struct bat_priv *bat_priv = netdev_priv(net_dev);
300 298 unsigned long val;
301 299 int ret, vis_mode_tmp = -1;
  300 + const char *old_mode, *new_mode;
302 301  
303 302 ret = kstrtoul(buff, 10, &val);
304 303  
305 304  
306 305  
... ... @@ -315,20 +314,28 @@
315 314 if (buff[count - 1] == '\n')
316 315 buff[count - 1] = '\0';
317 316  
318   - bat_info(net_dev,
319   - "Invalid parameter for 'vis mode' setting received: %s\n",
320   - buff);
  317 + batadv_info(net_dev,
  318 + "Invalid parameter for 'vis mode' setting received: %s\n",
  319 + buff);
321 320 return -EINVAL;
322 321 }
323 322  
324 323 if (atomic_read(&bat_priv->vis_mode) == vis_mode_tmp)
325 324 return count;
326 325  
327   - bat_info(net_dev, "Changing vis mode from: %s to: %s\n",
328   - atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE ?
329   - "client" : "server", vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE ?
330   - "client" : "server");
  326 + if (atomic_read(&bat_priv->vis_mode) == VIS_TYPE_CLIENT_UPDATE)
  327 + old_mode = "client";
  328 + else
  329 + old_mode = "server";
331 330  
  331 + if (vis_mode_tmp == VIS_TYPE_CLIENT_UPDATE)
  332 + new_mode = "client";
  333 + else
  334 + new_mode = "server";
  335 +
  336 + batadv_info(net_dev, "Changing vis mode from: %s to: %s\n", old_mode,
  337 + new_mode);
  338 +
332 339 atomic_set(&bat_priv->vis_mode, (unsigned int)vis_mode_tmp);
333 340 return count;
334 341 }
... ... @@ -391,9 +398,9 @@
391 398 gw_mode_tmp = GW_MODE_SERVER;
392 399  
393 400 if (gw_mode_tmp < 0) {
394   - bat_info(net_dev,
395   - "Invalid parameter for 'gw mode' setting received: %s\n",
396   - buff);
  401 + batadv_info(net_dev,
  402 + "Invalid parameter for 'gw mode' setting received: %s\n",
  403 + buff);
397 404 return -EINVAL;
398 405 }
399 406  
... ... @@ -412,8 +419,8 @@
412 419 break;
413 420 }
414 421  
415   - bat_info(net_dev, "Changing gw mode from: %s to: %s\n",
416   - curr_gw_mode_str, buff);
  422 + batadv_info(net_dev, "Changing gw mode from: %s to: %s\n",
  423 + curr_gw_mode_str, buff);
417 424  
418 425 batadv_gw_deselect(bat_priv);
419 426 atomic_set(&bat_priv->gw_mode, (unsigned int)gw_mode_tmp);
... ... @@ -500,8 +507,8 @@
500 507 bat_priv->mesh_obj = kobject_create_and_add(SYSFS_IF_MESH_SUBDIR,
501 508 batif_kobject);
502 509 if (!bat_priv->mesh_obj) {
503   - bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
504   - SYSFS_IF_MESH_SUBDIR);
  510 + batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
  511 + SYSFS_IF_MESH_SUBDIR);
505 512 goto out;
506 513 }
507 514  
... ... @@ -509,9 +516,9 @@
509 516 err = sysfs_create_file(bat_priv->mesh_obj,
510 517 &((*bat_attr)->attr));
511 518 if (err) {
512   - bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
513   - dev->name, SYSFS_IF_MESH_SUBDIR,
514   - ((*bat_attr)->attr).name);
  519 + batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n",
  520 + dev->name, SYSFS_IF_MESH_SUBDIR,
  521 + ((*bat_attr)->attr).name);
515 522 goto rem_attr;
516 523 }
517 524 }
518 525  
... ... @@ -669,17 +676,17 @@
669 676 hardif_kobject);
670 677  
671 678 if (!*hardif_obj) {
672   - bat_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
673   - SYSFS_IF_BAT_SUBDIR);
  679 + batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name,
  680 + SYSFS_IF_BAT_SUBDIR);
674 681 goto out;
675 682 }
676 683  
677 684 for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) {
678 685 err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr));
679 686 if (err) {
680   - bat_err(dev, "Can't add sysfs file: %s/%s/%s\n",
681   - dev->name, SYSFS_IF_BAT_SUBDIR,
682   - ((*bat_attr)->attr).name);
  687 + batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n",
  688 + dev->name, SYSFS_IF_BAT_SUBDIR,
  689 + ((*bat_attr)->attr).name);
683 690 goto rem_attr;
684 691 }
685 692 }
net/batman-adv/gateway_client.c
... ... @@ -197,7 +197,7 @@
197 197 if (atomic_read(&bat_priv->gw_mode) != GW_MODE_CLIENT)
198 198 goto out;
199 199  
200   - if (!atomic_dec_not_zero(&bat_priv->gw_reselect))
  200 + if (!batadv_atomic_dec_not_zero(&bat_priv->gw_reselect))
201 201 goto out;
202 202  
203 203 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
net/batman-adv/gateway_common.c
... ... @@ -97,9 +97,9 @@
97 97  
98 98 ret = kstrtol(buff, 10, &ldown);
99 99 if (ret) {
100   - bat_err(net_dev,
101   - "Download speed of gateway mode invalid: %s\n",
102   - buff);
  100 + batadv_err(net_dev,
  101 + "Download speed of gateway mode invalid: %s\n",
  102 + buff);
103 103 return false;
104 104 }
105 105  
... ... @@ -122,9 +122,9 @@
122 122  
123 123 ret = kstrtol(slash_ptr + 1, 10, &lup);
124 124 if (ret) {
125   - bat_err(net_dev,
126   - "Upload speed of gateway mode invalid: %s\n",
127   - slash_ptr + 1);
  125 + batadv_err(net_dev,
  126 + "Upload speed of gateway mode invalid: %s\n",
  127 + slash_ptr + 1);
128 128 return false;
129 129 }
130 130  
... ... @@ -164,13 +164,13 @@
164 164 return count;
165 165  
166 166 batadv_gw_deselect(bat_priv);
167   - bat_info(net_dev,
168   - "Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n",
169   - atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
170   - (down > 2048 ? down / 1024 : down),
171   - (down > 2048 ? "MBit" : "KBit"),
172   - (up > 2048 ? up / 1024 : up),
173   - (up > 2048 ? "MBit" : "KBit"));
  167 + batadv_info(net_dev,
  168 + "Changing gateway bandwidth from: '%i' to: '%ld' (propagating: %d%s/%d%s)\n",
  169 + atomic_read(&bat_priv->gw_bandwidth), gw_bandwidth_tmp,
  170 + (down > 2048 ? down / 1024 : down),
  171 + (down > 2048 ? "MBit" : "KBit"),
  172 + (up > 2048 ? up / 1024 : up),
  173 + (up > 2048 ? "MBit" : "KBit"));
174 174  
175 175 atomic_set(&bat_priv->gw_bandwidth, gw_bandwidth_tmp);
176 176  
net/batman-adv/hard-interface.c
... ... @@ -234,8 +234,8 @@
234 234 if (!primary_if)
235 235 batadv_primary_if_select(bat_priv, hard_iface);
236 236  
237   - bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
238   - hard_iface->net_dev->name);
  237 + batadv_info(hard_iface->soft_iface, "Interface activated: %s\n",
  238 + hard_iface->net_dev->name);
239 239  
240 240 batadv_update_min_mtu(hard_iface->soft_iface);
241 241  
... ... @@ -252,8 +252,8 @@
252 252  
253 253 hard_iface->if_status = IF_INACTIVE;
254 254  
255   - bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
256   - hard_iface->net_dev->name);
  255 + batadv_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
  256 + hard_iface->net_dev->name);
257 257  
258 258 batadv_update_min_mtu(hard_iface->soft_iface);
259 259 }
260 260  
261 261  
262 262  
... ... @@ -315,29 +315,29 @@
315 315 dev_add_pack(&hard_iface->batman_adv_ptype);
316 316  
317 317 atomic_set(&hard_iface->frag_seqno, 1);
318   - bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
319   - hard_iface->net_dev->name);
  318 + batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
  319 + hard_iface->net_dev->name);
320 320  
321 321 if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
322 322 ETH_DATA_LEN + BAT_HEADER_LEN)
323   - bat_info(hard_iface->soft_iface,
324   - "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n",
325   - hard_iface->net_dev->name, hard_iface->net_dev->mtu,
326   - ETH_DATA_LEN + BAT_HEADER_LEN);
  323 + batadv_info(hard_iface->soft_iface,
  324 + "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n",
  325 + hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  326 + ETH_DATA_LEN + BAT_HEADER_LEN);
327 327  
328 328 if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
329 329 ETH_DATA_LEN + BAT_HEADER_LEN)
330   - bat_info(hard_iface->soft_iface,
331   - "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n",
332   - hard_iface->net_dev->name, hard_iface->net_dev->mtu,
333   - ETH_DATA_LEN + BAT_HEADER_LEN);
  330 + batadv_info(hard_iface->soft_iface,
  331 + "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n",
  332 + hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  333 + ETH_DATA_LEN + BAT_HEADER_LEN);
334 334  
335 335 if (batadv_hardif_is_iface_up(hard_iface))
336 336 batadv_hardif_activate_interface(hard_iface);
337 337 else
338   - bat_err(hard_iface->soft_iface,
339   - "Not using interface %s (retrying later): interface not active\n",
340   - hard_iface->net_dev->name);
  338 + batadv_err(hard_iface->soft_iface,
  339 + "Not using interface %s (retrying later): interface not active\n",
  340 + hard_iface->net_dev->name);
341 341  
342 342 /* begin scheduling originator messages on that interface */
343 343 batadv_schedule_bat_ogm(hard_iface);
... ... @@ -363,8 +363,8 @@
363 363 if (hard_iface->if_status != IF_INACTIVE)
364 364 goto out;
365 365  
366   - bat_info(hard_iface->soft_iface, "Removing interface: %s\n",
367   - hard_iface->net_dev->name);
  366 + batadv_info(hard_iface->soft_iface, "Removing interface: %s\n",
  367 + hard_iface->net_dev->name);
368 368 dev_remove_pack(&hard_iface->batman_adv_ptype);
369 369  
370 370 bat_priv->num_ifaces--;
net/batman-adv/main.h
... ... @@ -190,14 +190,14 @@
190 190 }
191 191 #endif
192 192  
193   -#define bat_info(net_dev, fmt, arg...) \
  193 +#define batadv_info(net_dev, fmt, arg...) \
194 194 do { \
195 195 struct net_device *_netdev = (net_dev); \
196 196 struct bat_priv *_batpriv = netdev_priv(_netdev); \
197 197 batadv_dbg(DBG_ALL, _batpriv, fmt, ## arg); \
198 198 pr_info("%s: " fmt, _netdev->name, ## arg); \
199 199 } while (0)
200   -#define bat_err(net_dev, fmt, arg...) \
  200 +#define batadv_err(net_dev, fmt, arg...) \
201 201 do { \
202 202 struct net_device *_netdev = (net_dev); \
203 203 struct bat_priv *_batpriv = netdev_priv(_netdev); \
204 204  
... ... @@ -226,10 +226,10 @@
226 226 return time_is_before_jiffies(timestamp + msecs_to_jiffies(timeout));
227 227 }
228 228  
229   -#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
  229 +#define batadv_atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
230 230  
231 231 /* Returns the smallest signed integer in two's complement with the sizeof x */
232   -#define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
  232 +#define batadv_smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u)))
233 233  
234 234 /* Checks if a sequence number x is a predecessor/successor of y.
235 235 * they handle overflows/underflows and can correctly check for a
... ... @@ -241,12 +241,12 @@
241 241 * - when adding 128 - it is neither a predecessor nor a successor,
242 242 * - after adding more than 127 to the starting value - it is a successor
243 243 */
244   -#define seq_before(x, y) ({typeof(x) _d1 = (x); \
245   - typeof(y) _d2 = (y); \
246   - typeof(x) _dummy = (_d1 - _d2); \
247   - (void) (&_d1 == &_d2); \
248   - _dummy > smallest_signed_int(_dummy); })
249   -#define seq_after(x, y) seq_before(y, x)
  244 +#define batadv_seq_before(x, y) ({typeof(x) _d1 = (x); \
  245 + typeof(y) _d2 = (y); \
  246 + typeof(x) _dummy = (_d1 - _d2); \
  247 + (void) (&_d1 == &_d2); \
  248 + _dummy > batadv_smallest_signed_int(_dummy); })
  249 +#define batadv_seq_after(x, y) batadv_seq_before(y, x)
250 250  
251 251 /* Stop preemption on local cpu while incrementing the counter */
252 252 static inline void batadv_add_counter(struct bat_priv *bat_priv, size_t idx,
net/batman-adv/routing.c
... ... @@ -922,6 +922,7 @@
922 922 struct hard_iface *primary_if;
923 923 struct unicast_packet *unicast_packet;
924 924 bool tt_poss_change;
  925 + int is_old_ttvn;
925 926  
926 927 /* I could need to modify it */
927 928 if (skb_cow(skb, sizeof(struct unicast_packet)) < 0)
... ... @@ -945,7 +946,8 @@
945 946 }
946 947  
947 948 /* Check whether I have to reroute the packet */
948   - if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) {
  949 + is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn);
  950 + if (is_old_ttvn || tt_poss_change) {
949 951 /* check if there is enough data before accessing it */
950 952 if (pskb_may_pull(skb, sizeof(struct unicast_packet) +
951 953 ETH_HLEN) < 0)
net/batman-adv/send.c
... ... @@ -141,7 +141,7 @@
141 141 struct bcast_packet *bcast_packet;
142 142 struct sk_buff *newskb;
143 143  
144   - if (!atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
  144 + if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
145 145 batadv_dbg(DBG_BATMAN, bat_priv, "bcast packet queue full\n");
146 146 goto out;
147 147 }
net/batman-adv/translation-table.c
... ... @@ -1930,7 +1930,7 @@
1930 1930 ROAMING_MAX_TIME))
1931 1931 continue;
1932 1932  
1933   - if (!atomic_dec_not_zero(&tt_roam_node->counter))
  1933 + if (!batadv_atomic_dec_not_zero(&tt_roam_node->counter))
1934 1934 /* Sorry, you roamed too many times! */
1935 1935 goto unlock;
1936 1936 ret = true;
... ... @@ -2162,7 +2162,7 @@
2162 2162  
2163 2163 /* if the changes have been sent often enough */
2164 2164 if ((tt_num_changes < 0) &&
2165   - (!atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) {
  2165 + (!batadv_atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) {
2166 2166 batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len,
2167 2167 packet_min_len, packet_min_len);
2168 2168 tt_num_changes = 0;
net/batman-adv/vis.c
... ... @@ -424,8 +424,8 @@
424 424  
425 425 if (old_info) {
426 426 old_packet = (struct vis_packet *)old_info->skb_packet->data;
427   - if (!seq_after(ntohl(vis_packet->seqno),
428   - ntohl(old_packet->seqno))) {
  427 + if (!batadv_seq_after(ntohl(vis_packet->seqno),
  428 + ntohl(old_packet->seqno))) {
429 429 if (old_packet->seqno == vis_packet->seqno) {
430 430 batadv_recv_list_add(bat_priv,
431 431 &old_info->recv_list,