62 lines
1.9 KiB
Diff
62 lines
1.9 KiB
Diff
|
|
From c0ce219ead0086f1bf79ff6071df1822ee0804c9 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Ilya Maximets <i.maximets@ovn.org>
|
||
|
|
Date: Sat, 7 Dec 2019 15:46:17 +0100
|
||
|
|
Subject: netdev-afxdp: Avoid removing of XDP program if not loaded.
|
||
|
|
|
||
|
|
'bpf_set_link_xdp_fd' generates netlink event regardless of actual
|
||
|
|
changes it does, so if-notifier will receive link update even if
|
||
|
|
there was no XDP program previously loaded on the interface.
|
||
|
|
|
||
|
|
OVS tries to remove XDP program if device configuration was not
|
||
|
|
successful triggering if-notifier that triggers bridge reconfiguration
|
||
|
|
and another attempt to add failed port. And so on in the infinite
|
||
|
|
loop.
|
||
|
|
|
||
|
|
This patch avoids the issue by not removing XDP program if it wasn't
|
||
|
|
loaded. Since loading of the XDP program is one of the last steps
|
||
|
|
of port configuration, this should help to avoid infinite re-addition
|
||
|
|
for most types of misconfiguration.
|
||
|
|
|
||
|
|
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
|
||
|
|
Acked-by: William Tu <u9012063@gmail.com>
|
||
|
|
---
|
||
|
|
lib/netdev-afxdp.c | 14 +++++++++++++-
|
||
|
|
1 file changed, 13 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
|
||
|
|
index 7b452c459..ad66e8e7c 100644
|
||
|
|
--- a/lib/netdev-afxdp.c
|
||
|
|
+++ b/lib/netdev-afxdp.c
|
||
|
|
@@ -568,7 +568,7 @@ netdev_afxdp_get_numa_id(const struct netdev *netdev)
|
||
|
|
static void
|
||
|
|
xsk_remove_xdp_program(uint32_t ifindex, int xdpmode)
|
||
|
|
{
|
||
|
|
- uint32_t flags;
|
||
|
|
+ uint32_t ret, flags, prog_id = 0;
|
||
|
|
|
||
|
|
flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
|
||
|
|
|
||
|
|
@@ -578,6 +578,18 @@ xsk_remove_xdp_program(uint32_t ifindex, int xdpmode)
|
||
|
|
flags |= XDP_FLAGS_DRV_MODE;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ /* Check whether XDP program is loaded. */
|
||
|
|
+ ret = bpf_get_link_xdp_id(ifindex, &prog_id, flags);
|
||
|
|
+ if (ret) {
|
||
|
|
+ VLOG_ERR("Failed to get XDP prog id (%s)", ovs_strerror(errno));
|
||
|
|
+ return;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ if (!prog_id) {
|
||
|
|
+ VLOG_INFO("No XDP program is loaded at ifindex %d", ifindex);
|
||
|
|
+ return;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
bpf_set_link_xdp_fd(ifindex, -1, flags);
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.14.1
|
||
|
|
|
||
|
|
|