| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
/* <linux/bpf.h> must precede <bpf/bpf_helpers.h> due to integer types |
| 4 |
* in bpf helpers signatures. |
| 5 |
*/ |
| 6 |
#include <linux/bpf.h> |
| 7 |
#include <bpf/bpf_helpers.h> |
| 8 |
|
| 9 |
/* VRF interface index to bind sockets to, set from userspace */ |
| 10 |
const volatile __u32 ifindex = 0; |
| 11 |
|
| 12 |
SEC("cgroup/sock_create") |
| 13 |
int sd_bind_interface(struct bpf_sock *ctx) { |
| 14 |
/* Bind the socket to the VRF interface */ |
| 15 |
ctx->bound_dev_if = ifindex; |
| 16 |
return 1; |
| 17 |
} |
| 18 |
|
| 19 |
static const char _license[] SEC("license") = "LGPL-2.1-or-later"; |