Re: [PATCH bpf v7 3/5] bpf: disable non stream socket for strparser

From: Jiayuan Chen
Date: Sat Jan 18 2025 - 10:49:20 EST


On Sat, Jan 18, 2025 at 04:03:33PM +0100, Jakub Sitnicki wrote:
> On Thu, Jan 16, 2025 at 10:05 PM +08, Jiayuan Chen wrote:
> > + if (sk_is_tcp(sk))
> > + return true;
> > + return false;
> > +}
> > +
>
> We don't need this yet, so please don't add it. Especially since this is
> fix. It should be kept down to a minimum. Do the sk_is_tcp() check
> directly from sock_map_link().
>
Ok, I will do this.
> > static int sock_map_link(struct bpf_map *map, struct sock *sk)
> > {
> > struct sk_psock_progs *progs = sock_map_progs(map);
> > @@ -303,7 +311,10 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk)
> >
> > write_lock_bh(&sk->sk_callback_lock);
> > if (stream_parser && stream_verdict && !psock->saved_data_ready) {
> > - ret = sk_psock_init_strp(sk, psock);
> > + if (sock_map_sk_strp_allowed(sk))
> > + ret = sk_psock_init_strp(sk, psock);
> > + else
> > + ret = -EOPNOTSUPP;
> > if (ret) {
> > write_unlock_bh(&sk->sk_callback_lock);
> > sk_psock_put(sk, psock);