Global static volatile
Marco <[email protected]> Sat, 30 Mar 2024 15:08:39 +0100
| Newsgroups | org.kernel.vger.xdp-newbies |
|---|---|
| Message-ID | <CAAVAo4MxNCmEi3A=V+oqyK9_qZ2CBSQAC28g6tAH2t535cSZ4Q@mail.gmail.com> |
Helo
I tried to use a secondary variable fib_params_test as a global
variable at the beginning of my XDP program like this:
static volatile struct bpf_fib_lookup fib_params_test;
.
.
static __always_inline int function_process_packet(struct xdp_md *ctx,
u32 flags)
{
const __u32 ifingress = ctx->ingress_ifindex;
void *data_end = (void *)(long)ctx->data_end;
void *data = (void *)(long)ctx->data;
void *l3hdr = NULL;
struct bpf_fib_lookup fib_params;
bpf_printk("Ingress interface %d", fib_params_test.ifindex); /*
the value displayed is always right */
.
.
}
Once "fib_params_test" was initialized with the first packet received,
upon subsequent packets coming from different incoming vlan
interfaces, "fib_params_test.ifindex" always returned the interface I
expected.
Obviously I have always done tests with little traffic so I have the
doubt that in a real situation there may be unexpected values for the
fib_params_test.ifindex variable. This is possible?
Thank you.
Marco