#ifdef HAVE_PACKET_EBPF
SCLogConfig("af-packet will use '%s' as eBPF load balancing file",
ebpf_file);
-#endif
aconf->ebpf_lb_file = ebpf_file;
+ aconf->ebpf_t_config.flags |= EBPF_SOCKET_FILTER;
+#endif
+ }
+
+ if (ConfGetChildValueBoolWithDefault(if_root, if_default, "pinned-maps", (int *)&boolval) != 1) {
+ if (boolval) {
+ SCLogConfig("Using pinned maps on iface %s",
+ aconf->iface);
+ aconf->ebpf_t_config.flags |= EBPF_PINNED_MAPS;
+ }
}
#ifdef HAVE_PACKET_EBPF
/* One shot loading of the eBPF file */
if (aconf->ebpf_lb_file && cluster_type == PACKET_FANOUT_EBPF) {
int ret = EBPFLoadFile(aconf->iface, aconf->ebpf_lb_file, "loadbalancer",
- &aconf->ebpf_lb_fd, EBPF_SOCKET_FILTER);
+ &aconf->ebpf_lb_fd,
+ aconf->ebpf_t_config.flags);
if (ret != 0) {
SCLogWarning(SC_ERR_INVALID_VALUE, "Error when loading eBPF lb file");
}
if (aconf->ebpf_filter_file) {
#ifdef HAVE_PACKET_EBPF
int ret = EBPFLoadFile(aconf->iface, aconf->ebpf_filter_file, "filter",
- &aconf->ebpf_filter_fd, EBPF_SOCKET_FILTER);
+ &aconf->ebpf_filter_fd,
+ aconf->ebpf_t_config.flags);
if (ret != 0) {
SCLogWarning(SC_ERR_INVALID_VALUE,
"Error when loading eBPF filter file");
SCLogInfo("af-packet will use '%s' as XDP filter file",
ebpf_file);
aconf->ebpf_t_config.mode = AFP_MODE_XDP_BYPASS;
+ aconf->ebpf_t_config.flags |= EBPF_XDP_CODE;
aconf->xdp_filter_file = ebpf_file;
ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
if (conf_val) {
if (aconf->xdp_filter_file) {
#ifdef HAVE_PACKET_XDP
int ret = EBPFLoadFile(aconf->iface, aconf->xdp_filter_file, "xdp",
- &aconf->xdp_filter_fd, EBPF_XDP_CODE);
+ &aconf->xdp_filter_fd,
+ aconf->ebpf_t_config.flags);
if (ret != 0) {
SCLogWarning(SC_ERR_INVALID_VALUE,
"Error when loading XDP filter file");
BpfMapsInfoFree(bpf_map_data);
return -1;
}
- /* TODO pin */
- /* sudo mount bpf -t bpf /sys/fs/bpf/ */
- SCLogNotice("Pinning: %d to %s", bpf_map_data->array[bpf_map_data->last].fd,
+ if (flags & EBPF_PINNED_MAPS) {
+ SCLogNotice("Pinning: %d to %s", bpf_map_data->array[bpf_map_data->last].fd,
bpf_map_data->array[bpf_map_data->last].name);
- char buf[1024];
- snprintf(buf, sizeof(buf), "/sys/fs/bpf/suricata-%s-%s", iface,
- bpf_map_data->array[bpf_map_data->last].name);
- int ret = bpf_obj_pin(bpf_map_data->array[bpf_map_data->last].fd, buf);
- if (ret != 0) {
- SCLogError(SC_ERR_AFP_CREATE, "Can not pin: %s", strerror(errno));
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "/sys/fs/bpf/suricata-%s-%s", iface,
+ bpf_map_data->array[bpf_map_data->last].name);
+ int ret = bpf_obj_pin(bpf_map_data->array[bpf_map_data->last].fd, buf);
+ if (ret != 0) {
+ SCLogError(SC_ERR_AFP_CREATE, "Can not pin: %s", strerror(errno));
+ }
}
bpf_map_data->last++;
}