The _safe variant used here gets the next element before running the callback, avoiding the endless loop condition.
Unified · Split
| @@ -2189,7 +2189,7 @@ static long bpf_for_each_hash_elem(struct bpf_map *map, bpf_callback_t callback_ · 2188 unmodified lines | |||
| 2189 | b = &htab->buckets[i]; | 2189 | b = &htab->buckets[i]; |
| 2190 | rcu_read_lock(); | 2190 | rcu_read_lock(); |
| 2191 | head = &b->head; | 2191 | head = &b->head; |
| 2192 | hlist_nulls_for_each_entry_rcu(elem, n, head, hash_node) { | 2192 | hlist_nulls_for_each_entry_safe(elem, n, head, hash_node) { |
| 2193 | key = elem->key; | 2193 | key = elem->key; |
| 2194 | if (is_percpu) { | 2194 | if (is_percpu) { |
| 2195 | /* current cpu value for percpu map */ | 2195 | /* current cpu value for percpu map */ |