Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 7a6acc45 authored by Maciej Żenczykowski's avatar Maciej Żenczykowski
Browse files

add a comment about bpf_get_socket_cookie()



Kernel implementation:

  net/core/filter.c:
    BPF_CALL_1(bpf_get_socket_cookie, struct sk_buff *, skb) {
      return skb->sk ? sock_gen_cookie(skb->sk) : 0;
    }

  net/core/sock_diag.c:
    static atomic64_t cookie_gen;

    u64 sock_gen_cookie(struct sock *sk) {
      while (1) {
        u64 res = atomic64_read(&sk->sk_cookie);

        if (res) return res;
        res = atomic64_inc_return(&cookie_gen);
        atomic64_cmpxchg(&sk->sk_cookie, 0, res);
      }
    }

As we can see sock_gen_cookie cannot return 0.

Test: N/A, comment update only
Bug: 141532657
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Change-Id: I387e1b1570599c4e0c8b169316289ce39fe6a441
parent 8c906bbf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment