aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2012-09-23 16:38:35 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-11-14 15:00:36 -0500
commit47c94655c3d8086d92825760e1f1d9b12a5976e4 (patch)
tree8bbb66f868da769080049dddeb39a427318e3063 /net/batman-adv
parent7c1fd91da5a5eecc91674991199940c05f87cb3a (diff)
batman-adv: refactor code to simplify long lines
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/translation-table.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index d7418511448d..c24e60425289 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -242,86 +242,84 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr,
242 int ifindex) 242 int ifindex)
243{ 243{
244 struct batadv_priv *bat_priv = netdev_priv(soft_iface); 244 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
245 struct batadv_tt_local_entry *tt_local_entry = NULL; 245 struct batadv_tt_local_entry *tt_local = NULL;
246 struct batadv_tt_global_entry *tt_global_entry = NULL; 246 struct batadv_tt_global_entry *tt_global = NULL;
247 struct hlist_head *head; 247 struct hlist_head *head;
248 struct hlist_node *node; 248 struct hlist_node *node;
249 struct batadv_tt_orig_list_entry *orig_entry; 249 struct batadv_tt_orig_list_entry *orig_entry;
250 int hash_added; 250 int hash_added;
251 251
252 tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); 252 tt_local = batadv_tt_local_hash_find(bat_priv, addr);
253 253
254 if (tt_local_entry) { 254 if (tt_local) {
255 tt_local_entry->last_seen = jiffies; 255 tt_local->last_seen = jiffies;
256 /* possibly unset the BATADV_TT_CLIENT_PENDING flag */ 256 /* possibly unset the BATADV_TT_CLIENT_PENDING flag */
257 tt_local_entry->common.flags &= ~BATADV_TT_CLIENT_PENDING; 257 tt_local->common.flags &= ~BATADV_TT_CLIENT_PENDING;
258 goto out; 258 goto out;
259 } 259 }
260 260
261 tt_local_entry = kmalloc(sizeof(*tt_local_entry), GFP_ATOMIC); 261 tt_local = kmalloc(sizeof(*tt_local), GFP_ATOMIC);
262 if (!tt_local_entry) 262 if (!tt_local)
263 goto out; 263 goto out;
264 264
265 batadv_dbg(BATADV_DBG_TT, bat_priv, 265 batadv_dbg(BATADV_DBG_TT, bat_priv,
266 "Creating new local tt entry: %pM (ttvn: %d)\n", addr, 266 "Creating new local tt entry: %pM (ttvn: %d)\n", addr,
267 (uint8_t)atomic_read(&bat_priv->tt.vn)); 267 (uint8_t)atomic_read(&bat_priv->tt.vn));
268 268
269 memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); 269 memcpy(tt_local->common.addr, addr, ETH_ALEN);
270 tt_local_entry->common.flags = BATADV_NO_FLAGS; 270 tt_local->common.flags = BATADV_NO_FLAGS;
271 if (batadv_is_wifi_iface(ifindex)) 271 if (batadv_is_wifi_iface(ifindex))
272 tt_local_entry->common.flags |= BATADV_TT_CLIENT_WIFI; 272 tt_local->common.flags |= BATADV_TT_CLIENT_WIFI;
273 atomic_set(&tt_local_entry->common.refcount, 2); 273 atomic_set(&tt_local->common.refcount, 2);
274 tt_local_entry->last_seen = jiffies; 274 tt_local->last_seen = jiffies;
275 tt_local_entry->common.added_at = tt_local_entry->last_seen; 275 tt_local->common.added_at = tt_local->last_seen;
276 276
277 /* the batman interface mac address should never be purged */ 277 /* the batman interface mac address should never be purged */
278 if (batadv_compare_eth(addr, soft_iface->dev_addr)) 278 if (batadv_compare_eth(addr, soft_iface->dev_addr))
279 tt_local_entry->common.flags |= BATADV_TT_CLIENT_NOPURGE; 279 tt_local->common.flags |= BATADV_TT_CLIENT_NOPURGE;
280 280
281 /* The local entry has to be marked as NEW to avoid to send it in 281 /* The local entry has to be marked as NEW to avoid to send it in
282 * a full table response going out before the next ttvn increment 282 * a full table response going out before the next ttvn increment
283 * (consistency check) 283 * (consistency check)
284 */ 284 */
285 tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW; 285 tt_local->common.flags |= BATADV_TT_CLIENT_NEW;
286 286
287 hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt, 287 hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt,
288 batadv_choose_orig, 288 batadv_choose_orig, &tt_local->common,
289 &tt_local_entry->common, 289 &tt_local->common.hash_entry);
290 &tt_local_entry->common.hash_entry);
291 290
292 if (unlikely(hash_added != 0)) { 291 if (unlikely(hash_added != 0)) {
293 /* remove the reference for the hash */ 292 /* remove the reference for the hash */
294 batadv_tt_local_entry_free_ref(tt_local_entry); 293 batadv_tt_local_entry_free_ref(tt_local);
295 goto out; 294 goto out;
296 } 295 }
297 296
298 batadv_tt_local_event(bat_priv, addr, tt_local_entry->common.flags); 297 batadv_tt_local_event(bat_priv, addr, tt_local->common.flags);
299 298
300 /* remove address from global hash if present */ 299 /* remove address from global hash if present */
301 tt_global_entry = batadv_tt_global_hash_find(bat_priv, addr); 300 tt_global = batadv_tt_global_hash_find(bat_priv, addr);
302 301
303 /* Check whether it is a roaming! */ 302 /* Check whether it is a roaming! */
304 if (tt_global_entry) { 303 if (tt_global) {
305 /* These node are probably going to update their tt table */ 304 /* These node are probably going to update their tt table */
306 head = &tt_global_entry->orig_list; 305 head = &tt_global->orig_list;
307 rcu_read_lock(); 306 rcu_read_lock();
308 hlist_for_each_entry_rcu(orig_entry, node, head, list) { 307 hlist_for_each_entry_rcu(orig_entry, node, head, list) {
309 batadv_send_roam_adv(bat_priv, 308 batadv_send_roam_adv(bat_priv, tt_global->common.addr,
310 tt_global_entry->common.addr,
311 orig_entry->orig_node); 309 orig_entry->orig_node);
312 } 310 }
313 rcu_read_unlock(); 311 rcu_read_unlock();
314 /* The global entry has to be marked as ROAMING and 312 /* The global entry has to be marked as ROAMING and
315 * has to be kept for consistency purpose 313 * has to be kept for consistency purpose
316 */ 314 */
317 tt_global_entry->common.flags |= BATADV_TT_CLIENT_ROAM; 315 tt_global->common.flags |= BATADV_TT_CLIENT_ROAM;
318 tt_global_entry->roam_at = jiffies; 316 tt_global->roam_at = jiffies;
319 } 317 }
320out: 318out:
321 if (tt_local_entry) 319 if (tt_local)
322 batadv_tt_local_entry_free_ref(tt_local_entry); 320 batadv_tt_local_entry_free_ref(tt_local);
323 if (tt_global_entry) 321 if (tt_global)
324 batadv_tt_global_entry_free_ref(tt_global_entry); 322 batadv_tt_global_entry_free_ref(tt_global);
325} 323}
326 324
327static void batadv_tt_realloc_packet_buff(unsigned char **packet_buff, 325static void batadv_tt_realloc_packet_buff(unsigned char **packet_buff,