diff options
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r-- | net/batman-adv/routing.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index e7ee40d6d609..b3fd61c90f32 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -42,6 +42,7 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) | |||
42 | unsigned long *word; | 42 | unsigned long *word; |
43 | uint32_t i; | 43 | uint32_t i; |
44 | size_t word_index; | 44 | size_t word_index; |
45 | uint8_t *w; | ||
45 | 46 | ||
46 | for (i = 0; i < hash->size; i++) { | 47 | for (i = 0; i < hash->size; i++) { |
47 | head = &hash->table[i]; | 48 | head = &hash->table[i]; |
@@ -49,12 +50,12 @@ void batadv_slide_own_bcast_window(struct hard_iface *hard_iface) | |||
49 | rcu_read_lock(); | 50 | rcu_read_lock(); |
50 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { | 51 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
51 | spin_lock_bh(&orig_node->ogm_cnt_lock); | 52 | spin_lock_bh(&orig_node->ogm_cnt_lock); |
52 | word_index = hard_iface->if_num * NUM_WORDS; | 53 | word_index = hard_iface->if_num * BATADV_NUM_WORDS; |
53 | word = &(orig_node->bcast_own[word_index]); | 54 | word = &(orig_node->bcast_own[word_index]); |
54 | 55 | ||
55 | batadv_bit_get_packet(bat_priv, word, 1, 0); | 56 | batadv_bit_get_packet(bat_priv, word, 1, 0); |
56 | orig_node->bcast_own_sum[hard_iface->if_num] = | 57 | w = &orig_node->bcast_own_sum[hard_iface->if_num]; |
57 | bitmap_weight(word, TQ_LOCAL_WINDOW_SIZE); | 58 | *w = bitmap_weight(word, BATADV_TQ_LOCAL_WINDOW_SIZE); |
58 | spin_unlock_bh(&orig_node->ogm_cnt_lock); | 59 | spin_unlock_bh(&orig_node->ogm_cnt_lock); |
59 | } | 60 | } |
60 | rcu_read_unlock(); | 61 | rcu_read_unlock(); |
@@ -160,7 +161,7 @@ void batadv_bonding_candidate_add(struct orig_node *orig_node, | |||
160 | goto candidate_del; | 161 | goto candidate_del; |
161 | 162 | ||
162 | /* ... and is good enough to be considered */ | 163 | /* ... and is good enough to be considered */ |
163 | if (neigh_node->tq_avg < router->tq_avg - BONDING_TQ_THRESHOLD) | 164 | if (neigh_node->tq_avg < router->tq_avg - BATADV_BONDING_TQ_THRESHOLD) |
164 | goto candidate_del; | 165 | goto candidate_del; |
165 | 166 | ||
166 | /* check if we have another candidate with the same mac address or | 167 | /* check if we have another candidate with the same mac address or |
@@ -232,9 +233,10 @@ batadv_bonding_save_primary(const struct orig_node *orig_node, | |||
232 | int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, | 233 | int batadv_window_protected(struct bat_priv *bat_priv, int32_t seq_num_diff, |
233 | unsigned long *last_reset) | 234 | unsigned long *last_reset) |
234 | { | 235 | { |
235 | if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) || | 236 | if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE || |
236 | (seq_num_diff >= EXPECTED_SEQNO_RANGE)) { | 237 | seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) { |
237 | if (!batadv_has_timed_out(*last_reset, RESET_PROTECTION_MS)) | 238 | if (!batadv_has_timed_out(*last_reset, |
239 | BATADV_RESET_PROTECTION_MS)) | ||
238 | return 1; | 240 | return 1; |
239 | 241 | ||
240 | *last_reset = jiffies; | 242 | *last_reset = jiffies; |
@@ -316,7 +318,7 @@ static int batadv_recv_my_icmp_packet(struct bat_priv *bat_priv, | |||
316 | memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); | 318 | memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); |
317 | memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); | 319 | memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); |
318 | icmp_packet->msg_type = ECHO_REPLY; | 320 | icmp_packet->msg_type = ECHO_REPLY; |
319 | icmp_packet->header.ttl = TTL; | 321 | icmp_packet->header.ttl = BATADV_TTL; |
320 | 322 | ||
321 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); | 323 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); |
322 | ret = NET_RX_SUCCESS; | 324 | ret = NET_RX_SUCCESS; |
@@ -371,7 +373,7 @@ static int batadv_recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, | |||
371 | memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); | 373 | memcpy(icmp_packet->dst, icmp_packet->orig, ETH_ALEN); |
372 | memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); | 374 | memcpy(icmp_packet->orig, primary_if->net_dev->dev_addr, ETH_ALEN); |
373 | icmp_packet->msg_type = TTL_EXCEEDED; | 375 | icmp_packet->msg_type = TTL_EXCEEDED; |
374 | icmp_packet->header.ttl = TTL; | 376 | icmp_packet->header.ttl = BATADV_TTL; |
375 | 377 | ||
376 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); | 378 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); |
377 | ret = NET_RX_SUCCESS; | 379 | ret = NET_RX_SUCCESS; |
@@ -423,7 +425,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, struct hard_iface *recv_if) | |||
423 | 425 | ||
424 | /* add record route information if not full */ | 426 | /* add record route information if not full */ |
425 | if ((hdr_size == sizeof(struct icmp_packet_rr)) && | 427 | if ((hdr_size == sizeof(struct icmp_packet_rr)) && |
426 | (icmp_packet->rr_cur < BAT_RR_LEN)) { | 428 | (icmp_packet->rr_cur < BATADV_RR_LEN)) { |
427 | memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), | 429 | memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), |
428 | ethhdr->h_dest, ETH_ALEN); | 430 | ethhdr->h_dest, ETH_ALEN); |
429 | icmp_packet->rr_cur++; | 431 | icmp_packet->rr_cur++; |
@@ -603,7 +605,7 @@ int batadv_recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) | |||
603 | 605 | ||
604 | tt_query = (struct tt_query_packet *)skb->data; | 606 | tt_query = (struct tt_query_packet *)skb->data; |
605 | 607 | ||
606 | switch (tt_query->flags & TT_QUERY_TYPE_MASK) { | 608 | switch (tt_query->flags & BATADV_TT_QUERY_TYPE_MASK) { |
607 | case TT_REQUEST: | 609 | case TT_REQUEST: |
608 | batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); | 610 | batadv_inc_counter(bat_priv, BAT_CNT_TT_REQUEST_RX); |
609 | 611 | ||
@@ -699,8 +701,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct hard_iface *recv_if) | |||
699 | roam_adv_packet->src, roam_adv_packet->client); | 701 | roam_adv_packet->src, roam_adv_packet->client); |
700 | 702 | ||
701 | batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, | 703 | batadv_tt_global_add(bat_priv, orig_node, roam_adv_packet->client, |
702 | atomic_read(&orig_node->last_ttvn) + 1, true, | 704 | TT_CLIENT_ROAM, |
703 | false); | 705 | atomic_read(&orig_node->last_ttvn) + 1); |
704 | 706 | ||
705 | /* Roaming phase starts: I have new information but the ttvn has not | 707 | /* Roaming phase starts: I have new information but the ttvn has not |
706 | * been incremented yet. This flag will make me check all the incoming | 708 | * been incremented yet. This flag will make me check all the incoming |
@@ -922,6 +924,7 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv, | |||
922 | struct hard_iface *primary_if; | 924 | struct hard_iface *primary_if; |
923 | struct unicast_packet *unicast_packet; | 925 | struct unicast_packet *unicast_packet; |
924 | bool tt_poss_change; | 926 | bool tt_poss_change; |
927 | int is_old_ttvn; | ||
925 | 928 | ||
926 | /* I could need to modify it */ | 929 | /* I could need to modify it */ |
927 | if (skb_cow(skb, sizeof(struct unicast_packet)) < 0) | 930 | if (skb_cow(skb, sizeof(struct unicast_packet)) < 0) |
@@ -945,7 +948,8 @@ static int batadv_check_unicast_ttvn(struct bat_priv *bat_priv, | |||
945 | } | 948 | } |
946 | 949 | ||
947 | /* Check whether I have to reroute the packet */ | 950 | /* Check whether I have to reroute the packet */ |
948 | if (seq_before(unicast_packet->ttvn, curr_ttvn) || tt_poss_change) { | 951 | is_old_ttvn = batadv_seq_before(unicast_packet->ttvn, curr_ttvn); |
952 | if (is_old_ttvn || tt_poss_change) { | ||
949 | /* check if there is enough data before accessing it */ | 953 | /* check if there is enough data before accessing it */ |
950 | if (pskb_may_pull(skb, sizeof(struct unicast_packet) + | 954 | if (pskb_may_pull(skb, sizeof(struct unicast_packet) + |
951 | ETH_HLEN) < 0) | 955 | ETH_HLEN) < 0) |