Skip to content

Commit 580031f

Browse files
Martin KaFai Lauborkmann
authored andcommitted
bpf: tcp: Use sock_gen_put instead of sock_put in bpf_iter_tcp
While reviewing the udp-iter batching patches, noticed the bpf_iter_tcp calling sock_put() is incorrect. It should call sock_gen_put instead because bpf_iter_tcp is iterating the ehash table which has the req sk and tw sk. This patch replaces all sock_put with sock_gen_put in the bpf_iter_tcp codepath. Fixes: 04c7820 ("bpf: tcp: Bpf iter batching and lock_sock") Signed-off-by: Martin KaFai Lau <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 45977e5 commit 580031f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,7 +2780,7 @@ static int tcp_prog_seq_show(struct bpf_prog *prog, struct bpf_iter_meta *meta,
27802780
static void bpf_iter_tcp_put_batch(struct bpf_tcp_iter_state *iter)
27812781
{
27822782
while (iter->cur_sk < iter->end_sk)
2783-
sock_put(iter->batch[iter->cur_sk++]);
2783+
sock_gen_put(iter->batch[iter->cur_sk++]);
27842784
}
27852785

27862786
static int bpf_iter_tcp_realloc_batch(struct bpf_tcp_iter_state *iter,
@@ -2941,7 +2941,7 @@ static void *bpf_iter_tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
29412941
* st->bucket. See tcp_seek_last_pos().
29422942
*/
29432943
st->offset++;
2944-
sock_put(iter->batch[iter->cur_sk++]);
2944+
sock_gen_put(iter->batch[iter->cur_sk++]);
29452945
}
29462946

29472947
if (iter->cur_sk < iter->end_sk)

0 commit comments

Comments
 (0)