af-packet: correctly set up hardware offload

pull/3952/head
Eric Leblond 8 years ago committed by Victor Julien
parent 7f60be83f5
commit 0c3e1e8579

@ -494,6 +494,7 @@ static void *ParseAFPConfig(const char *iface)
aconf->xdp_mode = XDP_FLAGS_DRV_MODE;
} else if (!strcmp(xdp_mode, "hw")) {
aconf->xdp_mode = XDP_FLAGS_HW_MODE;
aconf->ebpf_t_config.flags |= EBPF_XDP_HW_MODE;
} else {
SCLogWarning(SC_ERR_INVALID_VALUE,
"Invalid xdp-mode value: '%s'", xdp_mode);

@ -310,6 +310,16 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section,
return -1;
}
if (config->flags & EBPF_XDP_HW_MODE) {
unsigned int ifindex = if_nametoindex(iface);
bpf_object__for_each_program(bpfprog, bpfobj) {
bpf_program__set_ifindex(bpfprog, ifindex);
}
bpf_map__for_each(map, bpfobj) {
bpf_map__set_ifindex(map, ifindex);
}
}
/* Let's check that our section is here */
bpf_object__for_each_program(bpfprog, bpfobj) {
const char *title = bpf_program__title(bpfprog, 0);

@ -64,6 +64,7 @@ struct pair {
#define EBPF_SOCKET_FILTER (1<<0)
#define EBPF_XDP_CODE (1<<1)
#define EBPF_PINNED_MAPS (1<<2)
#define EBPF_XDP_HW_MODE (1<<3)
int EBPFGetMapFDByName(const char *iface, const char *name);
int EBPFLoadFile(const char *iface, const char *path, const char * section,

Loading…
Cancel
Save