Re: [PATCH v4 bpf-next/net 3/5] bpf: Introduce SK_BPF_MEMCG_FLAGS and SK_BPF_MEMCG_SOCK_ISOLATED.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 2, 2025 at 1:02 PM Martin KaFai Lau <martin.lau@xxxxxxxxx> wrote:
>
> On 8/28/25 6:00 PM, Kuniyuki Iwashima wrote:
> >   static int sol_socket_sockopt(struct sock *sk, int optname,
> >                             char *optval, int *optlen,
> >                             bool getopt)
> > @@ -5284,6 +5313,7 @@ static int sol_socket_sockopt(struct sock *sk, int optname,
> >       case SO_BINDTOIFINDEX:
> >       case SO_TXREHASH:
> >       case SK_BPF_CB_FLAGS:
> > +     case SK_BPF_MEMCG_FLAGS:
> >               if (*optlen != sizeof(int))
> >                       return -EINVAL;
> >               break;
> > @@ -5293,8 +5323,15 @@ static int sol_socket_sockopt(struct sock *sk, int optname,
> >               return -EINVAL;
> >       }
> >
> > -     if (optname == SK_BPF_CB_FLAGS)
> > +     switch (optname) {
> > +     case SK_BPF_CB_FLAGS:
> >               return sk_bpf_set_get_cb_flags(sk, optval, getopt);
> > +     case SK_BPF_MEMCG_FLAGS:
>
> I would remove the getsockopt only support from the other hooks that cannot do
> the setsockopt. There are other ways for them to read sk->sk_memcg if it is
> really needed.

Ah, I forgot bpf_core_cast().

>
> > +             if (!IS_ENABLED(CONFIG_MEMCG) || !getopt)
> > +                     return -EOPNOTSUPP;
> > +
> > +             return sk_bpf_get_memcg_flags(sk, optval);
>
> Instead, do this only in bpf_sock_create_getsockopt.

Will do.

Thanks!





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux