提交 580031ff 编写于 作者: M Martin KaFai Lau 提交者: Daniel Borkmann

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: 04c7820b ("bpf: tcp: Bpf iter batching and lock_sock")
Signed-off-by: NMartin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230328004232.2134233-1-martin.lau@linux.dev
上级 45977e58
...@@ -2780,7 +2780,7 @@ static int tcp_prog_seq_show(struct bpf_prog *prog, struct bpf_iter_meta *meta, ...@@ -2780,7 +2780,7 @@ static int tcp_prog_seq_show(struct bpf_prog *prog, struct bpf_iter_meta *meta,
static void bpf_iter_tcp_put_batch(struct bpf_tcp_iter_state *iter) static void bpf_iter_tcp_put_batch(struct bpf_tcp_iter_state *iter)
{ {
while (iter->cur_sk < iter->end_sk) while (iter->cur_sk < iter->end_sk)
sock_put(iter->batch[iter->cur_sk++]); sock_gen_put(iter->batch[iter->cur_sk++]);
} }
static int bpf_iter_tcp_realloc_batch(struct bpf_tcp_iter_state *iter, 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) ...@@ -2941,7 +2941,7 @@ static void *bpf_iter_tcp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
* st->bucket. See tcp_seek_last_pos(). * st->bucket. See tcp_seek_last_pos().
*/ */
st->offset++; st->offset++;
sock_put(iter->batch[iter->cur_sk++]); sock_gen_put(iter->batch[iter->cur_sk++]);
} }
if (iter->cur_sk < iter->end_sk) if (iter->cur_sk < iter->end_sk)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册