diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 27 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 8 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 12 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 15 | ||||
-rw-r--r-- | net/batman-adv/types.h | 2 |
5 files changed, 47 insertions, 17 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 0a9084ad19a6..fd8d5afec0dd 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
@@ -1167,6 +1167,8 @@ int batadv_bla_init(struct batadv_priv *bat_priv) | |||
1167 | uint16_t crc; | 1167 | uint16_t crc; |
1168 | unsigned long entrytime; | 1168 | unsigned long entrytime; |
1169 | 1169 | ||
1170 | spin_lock_init(&bat_priv->bla.bcast_duplist_lock); | ||
1171 | |||
1170 | batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n"); | 1172 | batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n"); |
1171 | 1173 | ||
1172 | /* setting claim destination address */ | 1174 | /* setting claim destination address */ |
@@ -1210,8 +1212,8 @@ int batadv_bla_init(struct batadv_priv *bat_priv) | |||
1210 | /** | 1212 | /** |
1211 | * batadv_bla_check_bcast_duplist | 1213 | * batadv_bla_check_bcast_duplist |
1212 | * @bat_priv: the bat priv with all the soft interface information | 1214 | * @bat_priv: the bat priv with all the soft interface information |
1213 | * @bcast_packet: originator mac address | 1215 | * @bcast_packet: encapsulated broadcast frame plus batman header |
1214 | * @hdr_size: maximum length of the frame | 1216 | * @bcast_packet_len: length of encapsulated broadcast frame plus batman header |
1215 | * | 1217 | * |
1216 | * check if it is on our broadcast list. Another gateway might | 1218 | * check if it is on our broadcast list. Another gateway might |
1217 | * have sent the same packet because it is connected to the same backbone, | 1219 | * have sent the same packet because it is connected to the same backbone, |
@@ -1224,20 +1226,22 @@ int batadv_bla_init(struct batadv_priv *bat_priv) | |||
1224 | */ | 1226 | */ |
1225 | int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, | 1227 | int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, |
1226 | struct batadv_bcast_packet *bcast_packet, | 1228 | struct batadv_bcast_packet *bcast_packet, |
1227 | int hdr_size) | 1229 | int bcast_packet_len) |
1228 | { | 1230 | { |
1229 | int i, length, curr; | 1231 | int i, length, curr, ret = 0; |
1230 | uint8_t *content; | 1232 | uint8_t *content; |
1231 | uint16_t crc; | 1233 | uint16_t crc; |
1232 | struct batadv_bcast_duplist_entry *entry; | 1234 | struct batadv_bcast_duplist_entry *entry; |
1233 | 1235 | ||
1234 | length = hdr_size - sizeof(*bcast_packet); | 1236 | length = bcast_packet_len - sizeof(*bcast_packet); |
1235 | content = (uint8_t *)bcast_packet; | 1237 | content = (uint8_t *)bcast_packet; |
1236 | content += sizeof(*bcast_packet); | 1238 | content += sizeof(*bcast_packet); |
1237 | 1239 | ||
1238 | /* calculate the crc ... */ | 1240 | /* calculate the crc ... */ |
1239 | crc = crc16(0, content, length); | 1241 | crc = crc16(0, content, length); |
1240 | 1242 | ||
1243 | spin_lock_bh(&bat_priv->bla.bcast_duplist_lock); | ||
1244 | |||
1241 | for (i = 0; i < BATADV_DUPLIST_SIZE; i++) { | 1245 | for (i = 0; i < BATADV_DUPLIST_SIZE; i++) { |
1242 | curr = (bat_priv->bla.bcast_duplist_curr + i); | 1246 | curr = (bat_priv->bla.bcast_duplist_curr + i); |
1243 | curr %= BATADV_DUPLIST_SIZE; | 1247 | curr %= BATADV_DUPLIST_SIZE; |
@@ -1259,9 +1263,12 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, | |||
1259 | /* this entry seems to match: same crc, not too old, | 1263 | /* this entry seems to match: same crc, not too old, |
1260 | * and from another gw. therefore return 1 to forbid it. | 1264 | * and from another gw. therefore return 1 to forbid it. |
1261 | */ | 1265 | */ |
1262 | return 1; | 1266 | ret = 1; |
1267 | goto out; | ||
1263 | } | 1268 | } |
1264 | /* not found, add a new entry (overwrite the oldest entry) */ | 1269 | /* not found, add a new entry (overwrite the oldest entry) |
1270 | * and allow it, its the first occurence. | ||
1271 | */ | ||
1265 | curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1); | 1272 | curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1); |
1266 | curr %= BATADV_DUPLIST_SIZE; | 1273 | curr %= BATADV_DUPLIST_SIZE; |
1267 | entry = &bat_priv->bla.bcast_duplist[curr]; | 1274 | entry = &bat_priv->bla.bcast_duplist[curr]; |
@@ -1270,8 +1277,10 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, | |||
1270 | memcpy(entry->orig, bcast_packet->orig, ETH_ALEN); | 1277 | memcpy(entry->orig, bcast_packet->orig, ETH_ALEN); |
1271 | bat_priv->bla.bcast_duplist_curr = curr; | 1278 | bat_priv->bla.bcast_duplist_curr = curr; |
1272 | 1279 | ||
1273 | /* allow it, its the first occurence. */ | 1280 | out: |
1274 | return 0; | 1281 | spin_unlock_bh(&bat_priv->bla.bcast_duplist_lock); |
1282 | |||
1283 | return ret; | ||
1275 | } | 1284 | } |
1276 | 1285 | ||
1277 | 1286 | ||
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 939fc01371df..376b4cc6ca82 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -1124,8 +1124,14 @@ int batadv_recv_bcast_packet(struct sk_buff *skb, | |||
1124 | 1124 | ||
1125 | spin_unlock_bh(&orig_node->bcast_seqno_lock); | 1125 | spin_unlock_bh(&orig_node->bcast_seqno_lock); |
1126 | 1126 | ||
1127 | /* keep skb linear for crc calculation */ | ||
1128 | if (skb_linearize(skb) < 0) | ||
1129 | goto out; | ||
1130 | |||
1131 | bcast_packet = (struct batadv_bcast_packet *)skb->data; | ||
1132 | |||
1127 | /* check whether this has been sent by another originator before */ | 1133 | /* check whether this has been sent by another originator before */ |
1128 | if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, hdr_size)) | 1134 | if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, skb->len)) |
1129 | goto out; | 1135 | goto out; |
1130 | 1136 | ||
1131 | /* rebroadcast packet */ | 1137 | /* rebroadcast packet */ |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index b9a28d2dd3e8..ce0684a1fc83 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -325,6 +325,12 @@ void batadv_interface_rx(struct net_device *soft_iface, | |||
325 | 325 | ||
326 | soft_iface->last_rx = jiffies; | 326 | soft_iface->last_rx = jiffies; |
327 | 327 | ||
328 | /* Let the bridge loop avoidance check the packet. If will | ||
329 | * not handle it, we can safely push it up. | ||
330 | */ | ||
331 | if (batadv_bla_rx(bat_priv, skb, vid, is_bcast)) | ||
332 | goto out; | ||
333 | |||
328 | if (orig_node) | 334 | if (orig_node) |
329 | batadv_tt_add_temporary_global_entry(bat_priv, orig_node, | 335 | batadv_tt_add_temporary_global_entry(bat_priv, orig_node, |
330 | ethhdr->h_source); | 336 | ethhdr->h_source); |
@@ -332,12 +338,6 @@ void batadv_interface_rx(struct net_device *soft_iface, | |||
332 | if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) | 338 | if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) |
333 | goto dropped; | 339 | goto dropped; |
334 | 340 | ||
335 | /* Let the bridge loop avoidance check the packet. If will | ||
336 | * not handle it, we can safely push it up. | ||
337 | */ | ||
338 | if (batadv_bla_rx(bat_priv, skb, vid, is_bcast)) | ||
339 | goto out; | ||
340 | |||
341 | netif_rx(skb); | 341 | netif_rx(skb); |
342 | goto out; | 342 | goto out; |
343 | 343 | ||
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 112edd371b2f..baae71585804 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -769,6 +769,12 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv, | |||
769 | */ | 769 | */ |
770 | tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_TEMP; | 770 | tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_TEMP; |
771 | 771 | ||
772 | /* the change can carry possible "attribute" flags like the | ||
773 | * TT_CLIENT_WIFI, therefore they have to be copied in the | ||
774 | * client entry | ||
775 | */ | ||
776 | tt_global_entry->common.flags |= flags; | ||
777 | |||
772 | /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only | 778 | /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only |
773 | * one originator left in the list and we previously received a | 779 | * one originator left in the list and we previously received a |
774 | * delete + roaming change for this originator. | 780 | * delete + roaming change for this originator. |
@@ -1496,7 +1502,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | |||
1496 | 1502 | ||
1497 | memcpy(tt_change->addr, tt_common_entry->addr, | 1503 | memcpy(tt_change->addr, tt_common_entry->addr, |
1498 | ETH_ALEN); | 1504 | ETH_ALEN); |
1499 | tt_change->flags = BATADV_NO_FLAGS; | 1505 | tt_change->flags = tt_common_entry->flags; |
1500 | 1506 | ||
1501 | tt_count++; | 1507 | tt_count++; |
1502 | tt_change++; | 1508 | tt_change++; |
@@ -2450,6 +2456,13 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv, | |||
2450 | { | 2456 | { |
2451 | bool ret = false; | 2457 | bool ret = false; |
2452 | 2458 | ||
2459 | /* if the originator is a backbone node (meaning it belongs to the same | ||
2460 | * LAN of this node) the temporary client must not be added because to | ||
2461 | * reach such destination the node must use the LAN instead of the mesh | ||
2462 | */ | ||
2463 | if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig)) | ||
2464 | goto out; | ||
2465 | |||
2453 | if (!batadv_tt_global_add(bat_priv, orig_node, addr, | 2466 | if (!batadv_tt_global_add(bat_priv, orig_node, addr, |
2454 | BATADV_TT_CLIENT_TEMP, | 2467 | BATADV_TT_CLIENT_TEMP, |
2455 | atomic_read(&orig_node->last_ttvn))) | 2468 | atomic_read(&orig_node->last_ttvn))) |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 2ed82caacdca..ac1e07a80454 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -205,6 +205,8 @@ struct batadv_priv_bla { | |||
205 | struct batadv_hashtable *backbone_hash; | 205 | struct batadv_hashtable *backbone_hash; |
206 | struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; | 206 | struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; |
207 | int bcast_duplist_curr; | 207 | int bcast_duplist_curr; |
208 | /* protects bcast_duplist and bcast_duplist_curr */ | ||
209 | spinlock_t bcast_duplist_lock; | ||
208 | struct batadv_bla_claim_dst claim_dest; | 210 | struct batadv_bla_claim_dst claim_dest; |
209 | struct delayed_work work; | 211 | struct delayed_work work; |
210 | }; | 212 | }; |