Thread (22 messages) flat view 22 messages, 2 authors, 2025-09-04

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

From: Kuniyuki Iwashima <kuniyu@google.com>
Date: 2025-09-02 20:13:42
Also in: bpf

On Tue, Sep 2, 2025 at 1:02 PM Martin KaFai Lau [off-list ref] wrote:
On 8/28/25 6:00 PM, Kuniyuki Iwashima wrote:
quoted
  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().
quoted
+             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!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help