@@ -395,7 +395,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
395
395
ether_addr_copy (ethhdr -> h_source , mac );
396
396
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
397
397
"bla_send_claim(): CLAIM %pM on vid %d\n" , mac ,
398
- BATADV_PRINT_VID (vid ));
398
+ batadv_print_vid (vid ));
399
399
break ;
400
400
case BATADV_CLAIM_TYPE_UNCLAIM :
401
401
/* unclaim frame
@@ -404,7 +404,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
404
404
ether_addr_copy (hw_src , mac );
405
405
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
406
406
"bla_send_claim(): UNCLAIM %pM on vid %d\n" , mac ,
407
- BATADV_PRINT_VID (vid ));
407
+ batadv_print_vid (vid ));
408
408
break ;
409
409
case BATADV_CLAIM_TYPE_ANNOUNCE :
410
410
/* announcement frame
@@ -413,7 +413,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
413
413
ether_addr_copy (hw_src , mac );
414
414
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
415
415
"bla_send_claim(): ANNOUNCE of %pM on vid %d\n" ,
416
- ethhdr -> h_source , BATADV_PRINT_VID (vid ));
416
+ ethhdr -> h_source , batadv_print_vid (vid ));
417
417
break ;
418
418
case BATADV_CLAIM_TYPE_REQUEST :
419
419
/* request frame
@@ -425,14 +425,14 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
425
425
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
426
426
"bla_send_claim(): REQUEST of %pM to %pM on vid %d\n" ,
427
427
ethhdr -> h_source , ethhdr -> h_dest ,
428
- BATADV_PRINT_VID (vid ));
428
+ batadv_print_vid (vid ));
429
429
break ;
430
430
case BATADV_CLAIM_TYPE_LOOPDETECT :
431
431
ether_addr_copy (ethhdr -> h_source , mac );
432
432
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
433
433
"bla_send_claim(): LOOPDETECT of %pM to %pM on vid %d\n" ,
434
434
ethhdr -> h_source , ethhdr -> h_dest ,
435
- BATADV_PRINT_VID (vid ));
435
+ batadv_print_vid (vid ));
436
436
437
437
break ;
438
438
}
@@ -475,9 +475,9 @@ static void batadv_bla_loopdetect_report(struct work_struct *work)
475
475
476
476
batadv_info (bat_priv -> soft_iface ,
477
477
"Possible loop on VLAN %d detected which can't be handled by BLA - please check your network setup!\n" ,
478
- BATADV_PRINT_VID (backbone_gw -> vid ));
478
+ batadv_print_vid (backbone_gw -> vid ));
479
479
snprintf (vid_str , sizeof (vid_str ), "%d" ,
480
- BATADV_PRINT_VID (backbone_gw -> vid ));
480
+ batadv_print_vid (backbone_gw -> vid ));
481
481
vid_str [sizeof (vid_str ) - 1 ] = 0 ;
482
482
483
483
batadv_throw_uevent (bat_priv , BATADV_UEV_BLA , BATADV_UEV_LOOPDETECT ,
@@ -510,7 +510,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig,
510
510
511
511
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
512
512
"bla_get_backbone_gw(): not found (%pM, %d), creating new entry\n" ,
513
- orig , BATADV_PRINT_VID (vid ));
513
+ orig , batadv_print_vid (vid ));
514
514
515
515
entry = kzalloc (sizeof (* entry ), GFP_ATOMIC );
516
516
if (!entry )
@@ -719,7 +719,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
719
719
720
720
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
721
721
"bla_add_claim(): adding new entry %pM, vid %d to hash ...\n" ,
722
- mac , BATADV_PRINT_VID (vid ));
722
+ mac , batadv_print_vid (vid ));
723
723
724
724
kref_get (& claim -> refcount );
725
725
hash_added = batadv_hash_add (bat_priv -> bla .claim_hash ,
@@ -739,8 +739,8 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
739
739
goto claim_free_ref ;
740
740
741
741
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
742
- "bla_add_claim(): changing ownership for %pM, vid %d\n" ,
743
- mac , BATADV_PRINT_VID (vid ));
742
+ "bla_add_claim(): changing ownership for %pM, vid %d to gw %pM \n" ,
743
+ mac , batadv_print_vid (vid ), backbone_gw -> orig );
744
744
745
745
remove_crc = true;
746
746
}
@@ -809,7 +809,7 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
809
809
return ;
810
810
811
811
batadv_dbg (BATADV_DBG_BLA , bat_priv , "bla_del_claim(): %pM, vid %d\n" ,
812
- mac , BATADV_PRINT_VID (vid ));
812
+ mac , batadv_print_vid (vid ));
813
813
814
814
batadv_hash_remove (bat_priv -> bla .claim_hash , batadv_compare_claim ,
815
815
batadv_choose_claim , claim );
@@ -849,7 +849,7 @@ static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
849
849
850
850
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
851
851
"handle_announce(): ANNOUNCE vid %d (sent by %pM)... CRC = %#.4x\n" ,
852
- BATADV_PRINT_VID (vid ), backbone_gw -> orig , crc );
852
+ batadv_print_vid (vid ), backbone_gw -> orig , crc );
853
853
854
854
spin_lock_bh (& backbone_gw -> crc_lock );
855
855
backbone_crc = backbone_gw -> crc ;
@@ -859,7 +859,7 @@ static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
859
859
batadv_dbg (BATADV_DBG_BLA , backbone_gw -> bat_priv ,
860
860
"handle_announce(): CRC FAILED for %pM/%d (my = %#.4x, sent = %#.4x)\n" ,
861
861
backbone_gw -> orig ,
862
- BATADV_PRINT_VID (backbone_gw -> vid ),
862
+ batadv_print_vid (backbone_gw -> vid ),
863
863
backbone_crc , crc );
864
864
865
865
batadv_bla_send_request (backbone_gw );
@@ -904,7 +904,7 @@ static bool batadv_handle_request(struct batadv_priv *bat_priv,
904
904
905
905
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
906
906
"handle_request(): REQUEST vid %d (sent by %pM)...\n" ,
907
- BATADV_PRINT_VID (vid ), ethhdr -> h_source );
907
+ batadv_print_vid (vid ), ethhdr -> h_source );
908
908
909
909
batadv_bla_answer_request (bat_priv , primary_if , vid );
910
910
return true;
@@ -941,7 +941,7 @@ static bool batadv_handle_unclaim(struct batadv_priv *bat_priv,
941
941
/* this must be an UNCLAIM frame */
942
942
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
943
943
"handle_unclaim(): UNCLAIM %pM on vid %d (sent by %pM)...\n" ,
944
- claim_addr , BATADV_PRINT_VID (vid ), backbone_gw -> orig );
944
+ claim_addr , batadv_print_vid (vid ), backbone_gw -> orig );
945
945
946
946
batadv_bla_del_claim (bat_priv , claim_addr , vid );
947
947
batadv_backbone_gw_put (backbone_gw );
@@ -1161,7 +1161,7 @@ static bool batadv_bla_process_claim(struct batadv_priv *bat_priv,
1161
1161
if (ret == 1 )
1162
1162
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
1163
1163
"bla_process_claim(): received a claim frame from another group. From: %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n" ,
1164
- ethhdr -> h_source , BATADV_PRINT_VID (vid ), hw_src ,
1164
+ ethhdr -> h_source , batadv_print_vid (vid ), hw_src ,
1165
1165
hw_dst );
1166
1166
1167
1167
if (ret < 2 )
@@ -1197,7 +1197,7 @@ static bool batadv_bla_process_claim(struct batadv_priv *bat_priv,
1197
1197
1198
1198
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
1199
1199
"bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n" ,
1200
- ethhdr -> h_source , BATADV_PRINT_VID (vid ), hw_src , hw_dst );
1200
+ ethhdr -> h_source , batadv_print_vid (vid ), hw_src , hw_dst );
1201
1201
return true;
1202
1202
}
1203
1203
@@ -1295,10 +1295,13 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
1295
1295
goto skip ;
1296
1296
1297
1297
batadv_dbg (BATADV_DBG_BLA , bat_priv ,
1298
- "bla_purge_claims(): %pM, vid %d, time out\n" ,
1299
- claim -> addr , claim -> vid );
1298
+ "bla_purge_claims(): timed out.\n" );
1300
1299
1301
1300
purge_now :
1301
+ batadv_dbg (BATADV_DBG_BLA , bat_priv ,
1302
+ "bla_purge_claims(): %pM, vid %d\n" ,
1303
+ claim -> addr , claim -> vid );
1304
+
1302
1305
batadv_handle_unclaim (bat_priv , primary_if ,
1303
1306
backbone_gw -> orig ,
1304
1307
claim -> addr , claim -> vid );
@@ -1846,6 +1849,13 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1846
1849
/* possible optimization: race for a claim */
1847
1850
/* No claim exists yet, claim it for us!
1848
1851
*/
1852
+
1853
+ batadv_dbg (BATADV_DBG_BLA , bat_priv ,
1854
+ "bla_rx(): Unclaimed MAC %pM found. Claim it. Local: %s\n" ,
1855
+ ethhdr -> h_source ,
1856
+ batadv_is_my_client (bat_priv ,
1857
+ ethhdr -> h_source , vid ) ?
1858
+ "yes" : "no" );
1849
1859
batadv_handle_claim (bat_priv , primary_if ,
1850
1860
primary_if -> net_dev -> dev_addr ,
1851
1861
ethhdr -> h_source , vid );
@@ -1963,10 +1973,22 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1963
1973
/* if yes, the client has roamed and we have
1964
1974
* to unclaim it.
1965
1975
*/
1966
- batadv_handle_unclaim (bat_priv , primary_if ,
1967
- primary_if -> net_dev -> dev_addr ,
1968
- ethhdr -> h_source , vid );
1969
- goto allow ;
1976
+ if (batadv_has_timed_out (claim -> lasttime , 100 )) {
1977
+ /* only unclaim if the last claim entry is
1978
+ * older than 100 ms to make sure we really
1979
+ * have a roaming client here.
1980
+ */
1981
+ batadv_dbg (BATADV_DBG_BLA , bat_priv , "bla_tx(): Roaming client %pM detected. Unclaim it.\n" ,
1982
+ ethhdr -> h_source );
1983
+ batadv_handle_unclaim (bat_priv , primary_if ,
1984
+ primary_if -> net_dev -> dev_addr ,
1985
+ ethhdr -> h_source , vid );
1986
+ goto allow ;
1987
+ } else {
1988
+ batadv_dbg (BATADV_DBG_BLA , bat_priv , "bla_tx(): Race for claim %pM detected. Drop packet.\n" ,
1989
+ ethhdr -> h_source );
1990
+ goto handled ;
1991
+ }
1970
1992
}
1971
1993
1972
1994
/* check if it is a multicast/broadcast frame */
@@ -2042,7 +2064,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
2042
2064
backbone_crc = backbone_gw -> crc ;
2043
2065
spin_unlock_bh (& backbone_gw -> crc_lock );
2044
2066
seq_printf (seq , " * %pM on %5d by %pM [%c] (%#.4x)\n" ,
2045
- claim -> addr , BATADV_PRINT_VID (claim -> vid ),
2067
+ claim -> addr , batadv_print_vid (claim -> vid ),
2046
2068
backbone_gw -> orig ,
2047
2069
(is_own ? 'x' : ' ' ),
2048
2070
backbone_crc );
@@ -2274,7 +2296,7 @@ int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
2274
2296
2275
2297
seq_printf (seq , " * %pM on %5d %4i.%03is (%#.4x)\n" ,
2276
2298
backbone_gw -> orig ,
2277
- BATADV_PRINT_VID (backbone_gw -> vid ), secs ,
2299
+ batadv_print_vid (backbone_gw -> vid ), secs ,
2278
2300
msecs , backbone_crc );
2279
2301
}
2280
2302
rcu_read_unlock ();
@@ -2449,3 +2471,52 @@ int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb)
2449
2471
2450
2472
return ret ;
2451
2473
}
2474
+
2475
+ #ifdef CONFIG_BATMAN_ADV_DAT
2476
+ /**
2477
+ * batadv_bla_check_claim - check if address is claimed
2478
+ *
2479
+ * @bat_priv: the bat priv with all the soft interface information
2480
+ * @addr: mac address of which the claim status is checked
2481
+ * @vid: the VLAN ID
2482
+ *
2483
+ * addr is checked if this address is claimed by the local device itself.
2484
+ *
2485
+ * Return: true if bla is disabled or the mac is claimed by the device,
2486
+ * false if the device addr is already claimed by another gateway
2487
+ */
2488
+ bool batadv_bla_check_claim (struct batadv_priv * bat_priv ,
2489
+ u8 * addr , unsigned short vid )
2490
+ {
2491
+ struct batadv_bla_claim search_claim ;
2492
+ struct batadv_bla_claim * claim = NULL ;
2493
+ struct batadv_hard_iface * primary_if = NULL ;
2494
+ bool ret = true;
2495
+
2496
+ if (!atomic_read (& bat_priv -> bridge_loop_avoidance ))
2497
+ return ret ;
2498
+
2499
+ primary_if = batadv_primary_if_get_selected (bat_priv );
2500
+ if (!primary_if )
2501
+ return ret ;
2502
+
2503
+ /* First look if the mac address is claimed */
2504
+ ether_addr_copy (search_claim .addr , addr );
2505
+ search_claim .vid = vid ;
2506
+
2507
+ claim = batadv_claim_hash_find (bat_priv , & search_claim );
2508
+
2509
+ /* If there is a claim and we are not owner of the claim,
2510
+ * return false.
2511
+ */
2512
+ if (claim ) {
2513
+ if (!batadv_compare_eth (claim -> backbone_gw -> orig ,
2514
+ primary_if -> net_dev -> dev_addr ))
2515
+ ret = false;
2516
+ batadv_claim_put (claim );
2517
+ }
2518
+
2519
+ batadv_hardif_put (primary_if );
2520
+ return ret ;
2521
+ }
2522
+ #endif
0 commit comments