Skip to content
Snippets Groups Projects
Commit 96f17d6b authored by Daniel Salzman's avatar Daniel Salzman
Browse files

xdp: add KNOT_XDP_LOAD_BPF_ALWAYS_UNLOAD mode

parent 70c245d5
No related branches found
No related tags found
No related merge requests found
Pipeline #63385 passed
......@@ -234,6 +234,12 @@ static iface_t *server_init_xdp_iface(struct sockaddr_storage *addr, unsigned *t
(i == 0 ? KNOT_XDP_LOAD_BPF_ALWAYS : KNOT_XDP_LOAD_BPF_NEVER);
ret = knot_xdp_init(new_if->xdp_sockets + i, iface.name, i,
iface.port, mode);
if (ret == -EBUSY && i == 0) {
log_notice("XDP interface %s@%u is busy, retrying initializaion",
iface.name, iface.port);
ret = knot_xdp_init(new_if->xdp_sockets + i, iface.name, i,
iface.port, KNOT_XDP_LOAD_BPF_ALWAYS_UNLOAD);
}
if (ret != KNOT_EOK) {
log_warning("failed to initialize XDP interface %s@%u, queue %d (%s)",
iface.name, iface.port, i, knot_strerror(ret));
......
......@@ -238,6 +238,10 @@ int kxsk_iface_new(const char *if_name, int if_queue, knot_xdp_load_bpf_t load_b
}
}
break;
case KNOT_XDP_LOAD_BPF_ALWAYS_UNLOAD:
(void)bpf_set_link_xdp_fd(iface->if_index, -1, 0);
sleep(1);
// FALLTHROUGH
case KNOT_XDP_LOAD_BPF_ALWAYS:
ret = ensure_prog(iface, true);
break;
......
......@@ -44,9 +44,10 @@ struct knot_xdp_msg {
* a compatible BPF program is loaded on the interface.
*/
typedef enum {
KNOT_XDP_LOAD_BPF_NEVER, /*!< Do not load; error out if not loaded already. */
KNOT_XDP_LOAD_BPF_ALWAYS, /*!< Always load a program (overwrite it). */
KNOT_XDP_LOAD_BPF_MAYBE, /*!< Try with present program or load if none. */
KNOT_XDP_LOAD_BPF_NEVER, /*!< Do not load; error out if not loaded already. */
KNOT_XDP_LOAD_BPF_ALWAYS, /*!< Always load a program (overwrite it). */
KNOT_XDP_LOAD_BPF_ALWAYS_UNLOAD, /*!< KNOT_XDP_LOAD_BPF_ALWAYS + unload previous. */
KNOT_XDP_LOAD_BPF_MAYBE, /*!< Try with present program or load if none. */
/* Implementation caveat: when re-using program in _MAYBE case, we get a message:
* libbpf: Kernel error message: XDP program already attached */
} knot_xdp_load_bpf_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment