Skip to content

Helper function bpf_get_socket_cookie

v4.12

Definition

Copyright (c) 2015 The Libbpf Authors. All rights reserved.

If the struct sk_buff pointed by skb has a known socket, retrieve the cookie (generated by the kernel) of this socket. If no cookie has been set yet, generate a new cookie. Once generated, the socket cookie remains stable for the life of the socket. This helper can be useful for monitoring per socket networking traffic statistics as it provides a global socket identifier that can be assumed unique.

Returns

A 8-byte long unique number on success, or 0 if the socket field is missing inside skb.

static __u64 (* const bpf_get_socket_cookie)(void *ctx) = (void *) 46;

Usage

Docs could be improved

This part of the docs is incomplete, contributions are very welcome

Program types

This helper call can be used in the following program types:

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome