diff options
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/distributed-arp-table.c | 13 | ||||
-rw-r--r-- | net/batman-adv/main.c | 19 | ||||
-rw-r--r-- | net/batman-adv/network-coding.c | 8 | ||||
-rw-r--r-- | net/batman-adv/originator.c | 16 | ||||
-rw-r--r-- | net/batman-adv/originator.h | 1 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 1 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 7 |
7 files changed, 57 insertions, 8 deletions
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 8e15d966d9b0..239992021b1d 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
@@ -837,6 +837,19 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, | |||
837 | 837 | ||
838 | dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst); | 838 | dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst); |
839 | if (dat_entry) { | 839 | if (dat_entry) { |
840 | /* If the ARP request is destined for a local client the local | ||
841 | * client will answer itself. DAT would only generate a | ||
842 | * duplicate packet. | ||
843 | * | ||
844 | * Moreover, if the soft-interface is enslaved into a bridge, an | ||
845 | * additional DAT answer may trigger kernel warnings about | ||
846 | * a packet coming from the wrong port. | ||
847 | */ | ||
848 | if (batadv_is_my_client(bat_priv, dat_entry->mac_addr)) { | ||
849 | ret = true; | ||
850 | goto out; | ||
851 | } | ||
852 | |||
840 | skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, | 853 | skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src, |
841 | bat_priv->soft_iface, ip_dst, hw_src, | 854 | bat_priv->soft_iface, ip_dst, hw_src, |
842 | dat_entry->mac_addr, hw_src); | 855 | dat_entry->mac_addr, hw_src); |
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 3e30a0f1b908..51aafd669cbb 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c | |||
@@ -163,16 +163,25 @@ void batadv_mesh_free(struct net_device *soft_iface) | |||
163 | batadv_vis_quit(bat_priv); | 163 | batadv_vis_quit(bat_priv); |
164 | 164 | ||
165 | batadv_gw_node_purge(bat_priv); | 165 | batadv_gw_node_purge(bat_priv); |
166 | batadv_originator_free(bat_priv); | ||
167 | batadv_nc_free(bat_priv); | 166 | batadv_nc_free(bat_priv); |
167 | batadv_dat_free(bat_priv); | ||
168 | batadv_bla_free(bat_priv); | ||
168 | 169 | ||
170 | /* Free the TT and the originator tables only after having terminated | ||
171 | * all the other depending components which may use these structures for | ||
172 | * their purposes. | ||
173 | */ | ||
169 | batadv_tt_free(bat_priv); | 174 | batadv_tt_free(bat_priv); |
170 | 175 | ||
171 | batadv_bla_free(bat_priv); | 176 | /* Since the originator table clean up routine is accessing the TT |
172 | 177 | * tables as well, it has to be invoked after the TT tables have been | |
173 | batadv_dat_free(bat_priv); | 178 | * freed and marked as empty. This ensures that no cleanup RCU callbacks |
179 | * accessing the TT data are scheduled for later execution. | ||
180 | */ | ||
181 | batadv_originator_free(bat_priv); | ||
174 | 182 | ||
175 | free_percpu(bat_priv->bat_counters); | 183 | free_percpu(bat_priv->bat_counters); |
184 | bat_priv->bat_counters = NULL; | ||
176 | 185 | ||
177 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); | 186 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); |
178 | } | 187 | } |
@@ -475,7 +484,7 @@ static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) | |||
475 | char *algo_name = (char *)val; | 484 | char *algo_name = (char *)val; |
476 | size_t name_len = strlen(algo_name); | 485 | size_t name_len = strlen(algo_name); |
477 | 486 | ||
478 | if (algo_name[name_len - 1] == '\n') | 487 | if (name_len > 0 && algo_name[name_len - 1] == '\n') |
479 | algo_name[name_len - 1] = '\0'; | 488 | algo_name[name_len - 1] = '\0'; |
480 | 489 | ||
481 | bat_algo_ops = batadv_algo_get(algo_name); | 490 | bat_algo_ops = batadv_algo_get(algo_name); |
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index f7c54305a918..e84629ece9b7 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c | |||
@@ -1514,6 +1514,7 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, | |||
1514 | struct ethhdr *ethhdr, ethhdr_tmp; | 1514 | struct ethhdr *ethhdr, ethhdr_tmp; |
1515 | uint8_t *orig_dest, ttl, ttvn; | 1515 | uint8_t *orig_dest, ttl, ttvn; |
1516 | unsigned int coding_len; | 1516 | unsigned int coding_len; |
1517 | int err; | ||
1517 | 1518 | ||
1518 | /* Save headers temporarily */ | 1519 | /* Save headers temporarily */ |
1519 | memcpy(&coded_packet_tmp, skb->data, sizeof(coded_packet_tmp)); | 1520 | memcpy(&coded_packet_tmp, skb->data, sizeof(coded_packet_tmp)); |
@@ -1568,8 +1569,11 @@ batadv_nc_skb_decode_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, | |||
1568 | coding_len); | 1569 | coding_len); |
1569 | 1570 | ||
1570 | /* Resize decoded skb if decoded with larger packet */ | 1571 | /* Resize decoded skb if decoded with larger packet */ |
1571 | if (nc_packet->skb->len > coding_len + h_size) | 1572 | if (nc_packet->skb->len > coding_len + h_size) { |
1572 | pskb_trim_rcsum(skb, coding_len + h_size); | 1573 | err = pskb_trim_rcsum(skb, coding_len + h_size); |
1574 | if (err) | ||
1575 | return NULL; | ||
1576 | } | ||
1573 | 1577 | ||
1574 | /* Create decoded unicast packet */ | 1578 | /* Create decoded unicast packet */ |
1575 | unicast_packet = (struct batadv_unicast_packet *)skb->data; | 1579 | unicast_packet = (struct batadv_unicast_packet *)skb->data; |
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 2f3452546636..fad1a2093e15 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -156,12 +156,28 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu) | |||
156 | kfree(orig_node); | 156 | kfree(orig_node); |
157 | } | 157 | } |
158 | 158 | ||
159 | /** | ||
160 | * batadv_orig_node_free_ref - decrement the orig node refcounter and possibly | ||
161 | * schedule an rcu callback for freeing it | ||
162 | * @orig_node: the orig node to free | ||
163 | */ | ||
159 | void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node) | 164 | void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node) |
160 | { | 165 | { |
161 | if (atomic_dec_and_test(&orig_node->refcount)) | 166 | if (atomic_dec_and_test(&orig_node->refcount)) |
162 | call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); | 167 | call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); |
163 | } | 168 | } |
164 | 169 | ||
170 | /** | ||
171 | * batadv_orig_node_free_ref_now - decrement the orig node refcounter and | ||
172 | * possibly free it (without rcu callback) | ||
173 | * @orig_node: the orig node to free | ||
174 | */ | ||
175 | void batadv_orig_node_free_ref_now(struct batadv_orig_node *orig_node) | ||
176 | { | ||
177 | if (atomic_dec_and_test(&orig_node->refcount)) | ||
178 | batadv_orig_node_free_rcu(&orig_node->rcu); | ||
179 | } | ||
180 | |||
165 | void batadv_originator_free(struct batadv_priv *bat_priv) | 181 | void batadv_originator_free(struct batadv_priv *bat_priv) |
166 | { | 182 | { |
167 | struct batadv_hashtable *hash = bat_priv->orig_hash; | 183 | struct batadv_hashtable *hash = bat_priv->orig_hash; |
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h index 7df48fa7669d..734e5a3d8a5b 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h | |||
@@ -26,6 +26,7 @@ int batadv_originator_init(struct batadv_priv *bat_priv); | |||
26 | void batadv_originator_free(struct batadv_priv *bat_priv); | 26 | void batadv_originator_free(struct batadv_priv *bat_priv); |
27 | void batadv_purge_orig_ref(struct batadv_priv *bat_priv); | 27 | void batadv_purge_orig_ref(struct batadv_priv *bat_priv); |
28 | void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node); | 28 | void batadv_orig_node_free_ref(struct batadv_orig_node *orig_node); |
29 | void batadv_orig_node_free_ref_now(struct batadv_orig_node *orig_node); | ||
29 | struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv, | 30 | struct batadv_orig_node *batadv_get_orig_node(struct batadv_priv *bat_priv, |
30 | const uint8_t *addr); | 31 | const uint8_t *addr); |
31 | struct batadv_neigh_node * | 32 | struct batadv_neigh_node * |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 6f20d339e33a..819dfb006cdf 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -505,6 +505,7 @@ unreg_debugfs: | |||
505 | batadv_debugfs_del_meshif(dev); | 505 | batadv_debugfs_del_meshif(dev); |
506 | free_bat_counters: | 506 | free_bat_counters: |
507 | free_percpu(bat_priv->bat_counters); | 507 | free_percpu(bat_priv->bat_counters); |
508 | bat_priv->bat_counters = NULL; | ||
508 | 509 | ||
509 | return ret; | 510 | return ret; |
510 | } | 511 | } |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 5e89deeb9542..9e8748575845 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -144,7 +144,12 @@ static void batadv_tt_orig_list_entry_free_rcu(struct rcu_head *rcu) | |||
144 | struct batadv_tt_orig_list_entry *orig_entry; | 144 | struct batadv_tt_orig_list_entry *orig_entry; |
145 | 145 | ||
146 | orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); | 146 | orig_entry = container_of(rcu, struct batadv_tt_orig_list_entry, rcu); |
147 | batadv_orig_node_free_ref(orig_entry->orig_node); | 147 | |
148 | /* We are in an rcu callback here, therefore we cannot use | ||
149 | * batadv_orig_node_free_ref() and its call_rcu(): | ||
150 | * An rcu_barrier() wouldn't wait for that to finish | ||
151 | */ | ||
152 | batadv_orig_node_free_ref_now(orig_entry->orig_node); | ||
148 | kfree(orig_entry); | 153 | kfree(orig_entry); |
149 | } | 154 | } |
150 | 155 | ||