char iface[IFNAMSIZ];
char * name;
int fd;
+ uint8_t unlink;
};
struct bpf_maps_info {
int i;
for (i = 0; i < bpfinfo->last; i ++) {
if (bpfinfo->array[i].name) {
- char pinnedpath[1024];
- snprintf(pinnedpath, sizeof(pinnedpath),
- "/sys/fs/bpf/suricata-%s-%s",
- bpfinfo->array[i].iface,
- bpfinfo->array[i].name);
- /* Unlink the pinned entry */
- unlink(pinnedpath);
+ if (bpfinfo->array[i].unlink) {
+ char pinnedpath[1024];
+ snprintf(pinnedpath, sizeof(pinnedpath),
+ "/sys/fs/bpf/suricata-%s-%s",
+ bpfinfo->array[i].iface,
+ bpfinfo->array[i].name);
+ /* Unlink the pinned entry */
+ unlink(pinnedpath);
+ }
SCFree(bpfinfo->array[i].name);
}
}
BpfMapsInfoFree(bpf_map_data);
return -1;
}
+ bpf_map_data->array[bpf_map_data->last].unlink = 0;
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);
if (ret != 0) {
SCLogError(SC_ERR_AFP_CREATE, "Can not pin: %s", strerror(errno));
}
+ /* Don't unlink pinned maps in XDP mode to avoid a state reset */
+ if (flags & EBPF_XDP_CODE) {
+ bpf_map_data->array[bpf_map_data->last].unlink = 0;
+ } else {
+ bpf_map_data->array[bpf_map_data->last].unlink = 1;
+ }
}
bpf_map_data->last++;
}