BPF Syscall BPF_LINK_GET_NEXT_ID command
This syscall command is used to iterate over all loaded links.
Return type
This command will return 0 on success or a error number (negative integer) if something went wrong.
Usage
This syscall command will populate the next_id field with the ID of the "next" link which will have a higher number than start_id. If no link IDs are known, start_id can be left at 0. If no links exist higher than start_id, next_id is set to -1 and the syscall will return an -ENOENT error code.
So to iterate or discover all loaded links:
- call this command repeatably with the same attribute pointer and the attributes initialized at zero
- move
next_idtostart_idbetween each call - record all
next_idvalues - stop when we get an error
The IDs returned by this command can be used with the BPF_LINK_GET_FD_BY_ID syscall command to get a file descriptor to the actual link.
Attributes
start_id
The ID from which we wish to start iterating. next_id will always be higher than this field.
next_id
This field will be set to the next link ID, or -1 if no next link exists.