On Sat, Dec 07, 2019 at 03:46:17PM +0100, Ilya Maximets wrote:
> '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.maxim...@ovn.org>

Thanks! this also fixes the issue reported from Eelco
about infinite loop when enable loading XDP program at
https://patchwork.ozlabs.org/patch/1199734/

Acked-by: William Tu <u9012...@gmail.com>

> ---
>  lib/netdev-afxdp.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
> index ca2dfd005..bdabf97f4 100644
> --- a/lib/netdev-afxdp.c
> +++ b/lib/netdev-afxdp.c
> @@ -710,6 +710,19 @@ static void
>  xsk_remove_xdp_program(uint32_t ifindex, enum afxdp_mode mode)
>  {
>      uint32_t flags = xdp_modes[mode].xdp_flags | XDP_FLAGS_UPDATE_IF_NOEXIST;
> +    uint32_t ret, prog_id = 0;
> +
> +    /* 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.17.1
> 
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to