:p
atchew
Login
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/770 While the original issue report describes scenario where libnl devel package wasn't installed, it's perfectly reproducible with -Dlibnl=disabled passed to meson. Michal Prívozník (5): libvirt_private.syms: Export virNetlinkBridgeVlanFilterSet virnetlink: Provide stub for virNetlinkBridgeVlanFilterSet() virnetdevbridge.c: Fix comments in virNetDevBridgeSetupVlans() virnetdevbridge: Include virnetlink.h always virnetlink: Split virNetlinkBridgeVlanFilterSet() src/libvirt_private.syms | 2 + src/util/virnetdevbridge.c | 18 ++++----- src/util/virnetlink.c | 82 ++++++++++++++++++++++++++++++++++---- src/util/virnetlink.h | 5 ++- 4 files changed, 89 insertions(+), 18 deletions(-) -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> The function was introduced in v11.0.0-rc1~23 but corresponding change to the private syms file was missing. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt_private.syms | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index XXXXXXX..XXXXXXX 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -XXX,XX +XXX,XX @@ virNetDevVPortProfileOpTypeToString; # util/virnetlink.h +virNetlinkBridgeVlanFilterSet; virNetlinkCommand; virNetlinkDelLink; virNetlinkDumpCommand; -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> In virnetlink.c there are two sections: the first one when building WITH_LIBNL support, the other that provides stubs for functions declared in the corresponding header file when building without netlink support. But the stub implementation for virNetlinkBridgeVlanFilterSet() was missing. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virnetlink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -XXX,XX +XXX,XX @@ virNetlinkNewLink(const char *ifname G_GNUC_UNUSED, } +int +virNetlinkBridgeVlanFilterSet(const char *ifname G_GNUC_UNUSED, + int cmd G_GNUC_UNUSED, + const unsigned short fflags G_GNUC_UNUSED, + const short vid G_GNUC_UNUSED, + int *error G_GNUC_UNUSED) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return -1; +} + int virNetlinkGetNeighbor(void **nlData G_GNUC_UNUSED, uint32_t src_pid G_GNUC_UNUSED, -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> We still use C89 style of comments. Fix C99 style of comments used in virNetDevBridgeSetupVlans(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virnetdevbridge.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) if (!virtVlan || !virtVlan->nTags) return 0; - // The interface will have been automatically added to vlan 1, so remove it + /* The interface will have been automatically added to vlan 1, so remove it. */ if (virNetlinkBridgeVlanFilterSet(ifname, RTM_DELLINK, 0, 1, &error) < 0) { if (error != 0) { virReportSystemError(-error, @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) return -1; } - // If trunk mode, add the native VLAN then add the others, if any + /* If trunk mode, add the native VLAN then add the others, if any. */ if (virtVlan->trunk) { size_t i; @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) } } } else { - // In native mode, add the single VLAN as pvid untagged + /* In native mode, add the single VLAN as pvid untagged. */ flags = BRIDGE_VLAN_INFO_PVID | BRIDGE_VLAN_INFO_UNTAGGED; if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, flags, virtVlan->tag[0], &error) < 0) { -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> The whole point of virnetlink.h is that it hides away the build time dependency on netlink. It wraps netlink functions in our functions which then have a stub implementation in case netlink support was disabled. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virnetdevbridge.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -XXX,XX +XXX,XX @@ #include "virerror.h" #include "virfile.h" #include "virlog.h" +#include "virnetlink.h" #include "virstring.h" #ifdef WITH_NET_IF_H @@ -XXX,XX +XXX,XX @@ #endif #ifdef __linux__ -# if defined(WITH_LIBNL) -# include "virnetlink.h" -# endif # include <linux/sockios.h> # include <linux/param.h> /* HZ */ # include <linux/in6.h> -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> Currently, virNetlinkBridgeVlanFilterSet() takes @cmd as the second argument where either RTM_SETLINK or RTM_DELLINK is expected. Both of these constants come from linux/rtnetlink.h and thus are undefined when building without netlink. This design also clashes with the whole point of virnetlink: to offload netlink dependency onto a single file. Therefore, drop the argument, turn virNetlinkBridgeVlanFilterSet() into just setter, effectively, and introduce virNetlinkBridgeVlanFilterDel() for the case when RTM_DELLINK would be passed as @cmd. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/770 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt_private.syms | 1 + src/util/virnetdevbridge.c | 8 ++--- src/util/virnetlink.c | 73 +++++++++++++++++++++++++++++++++----- src/util/virnetlink.h | 5 ++- 4 files changed, 74 insertions(+), 13 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index XXXXXXX..XXXXXXX 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -XXX,XX +XXX,XX @@ virNetDevVPortProfileOpTypeToString; # util/virnetlink.h +virNetlinkBridgeVlanFilterDel; virNetlinkBridgeVlanFilterSet; virNetlinkCommand; virNetlinkDelLink; diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) return 0; /* The interface will have been automatically added to vlan 1, so remove it. */ - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_DELLINK, 0, 1, &error) < 0) { + if (virNetlinkBridgeVlanFilterDel(ifname, 1, &error) < 0) { if (error != 0) { virReportSystemError(-error, _("error removing vlan filter from interface %1$s"), @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) flags |= BRIDGE_VLAN_INFO_UNTAGGED; } - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, flags, + if (virNetlinkBridgeVlanFilterSet(ifname, flags, virtVlan->nativeTag, &error) < 0) { goto error; } @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) for (i = 0; i < virtVlan->nTags; i++) { if (virtVlan->tag[i] != virtVlan->nativeTag) - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, 0, + if (virNetlinkBridgeVlanFilterSet(ifname, 0, virtVlan->tag[i], &error) < 0) { goto error; } @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) } else { /* In native mode, add the single VLAN as pvid untagged. */ flags = BRIDGE_VLAN_INFO_PVID | BRIDGE_VLAN_INFO_UNTAGGED; - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, flags, + if (virNetlinkBridgeVlanFilterSet(ifname, flags, virtVlan->tag[0], &error) < 0) { goto error; } diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -XXX,XX +XXX,XX @@ virNetlinkDelLink(const char *ifname, virNetlinkTalkFallback fallback) } /** - * virNetlinkBridgeVlanFilterSet: + * virNetlinkBridgeVlanFilterHelper: * * @ifname: name of the link * @cmd: netlink command, either RTM_SETLINK or RTM_DELLINK @@ -XXX,XX +XXX,XX @@ virNetlinkDelLink(const char *ifname, virNetlinkTalkFallback fallback) * non-zero, then a netlink failure occurred, but no error message * is generated leaving it up to the caller to handle the condition. */ -int -virNetlinkBridgeVlanFilterSet(const char *ifname, - int cmd, - const unsigned short flags, - const short vid, - int *error) +static int +virNetlinkBridgeVlanFilterHelper(const char *ifname, + int cmd, + const unsigned short flags, + const short vid, + int *error) { struct ifinfomsg ifm = { .ifi_family = PF_BRIDGE }; struct bridge_vlan_info vinfo = { .flags = flags, .vid = vid }; @@ -XXX,XX +XXX,XX @@ virNetlinkBridgeVlanFilterSet(const char *ifname, return 0; } + +/** + * virNetlinkBridgeVlanFilterSet: + * + * @ifname: name of the link + * @flags: flags to use when adding the vlan filter + * @vid: vlan id to add + * @error: netlink error code + * + * Add a vlan filter from an interface associated with a bridge. + * + * Returns 0 on success, -1 on error. Additionally, if the @error is + * non-zero, then a netlink failure occurred, but no error message + * is generated leaving it up to the caller to handle the condition. + */ +int +virNetlinkBridgeVlanFilterSet(const char *ifname, + const unsigned short flags, + const short vid, + int *error) +{ + return virNetlinkBridgeVlanFilterHelper(ifname, RTM_SETLINK, + flags, vid, error); +} + + +/** + * virNetlinkBridgeVlanFilterDel: + * + * @ifname: name of the link + * @vid: vlan id to remove + * @error: netlink error code + * + * Remove a vlan filter from an interface associated with a bridge. + * + * Returns 0 on success, -1 on error. Additionally, if the @error is + * non-zero, then a netlink failure occurred, but no error message + * is generated leaving it up to the caller to handle the condition. + */ +int +virNetlinkBridgeVlanFilterDel(const char *ifname, + const short vid, + int *error) +{ + return virNetlinkBridgeVlanFilterHelper(ifname, + RTM_DELLINK, 0, vid, error); +} + + /** * virNetlinkGetNeighbor: * @@ -XXX,XX +XXX,XX @@ virNetlinkNewLink(const char *ifname G_GNUC_UNUSED, int virNetlinkBridgeVlanFilterSet(const char *ifname G_GNUC_UNUSED, - int cmd G_GNUC_UNUSED, const unsigned short fflags G_GNUC_UNUSED, const short vid G_GNUC_UNUSED, int *error G_GNUC_UNUSED) @@ -XXX,XX +XXX,XX @@ virNetlinkBridgeVlanFilterSet(const char *ifname G_GNUC_UNUSED, return -1; } +int +virNetlinkBridgeVlanFilterDel(const char *ifname G_GNUC_UNUSED, + const short vid G_GNUC_UNUSED, + int *error G_GNUC_UNUSED) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return -1; +} + int virNetlinkGetNeighbor(void **nlData G_GNUC_UNUSED, uint32_t src_pid G_GNUC_UNUSED, diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetlink.h +++ b/src/util/virnetlink.h @@ -XXX,XX +XXX,XX @@ typedef int (*virNetlinkTalkFallback)(const char *ifname); int virNetlinkDelLink(const char *ifname, virNetlinkTalkFallback fallback); int virNetlinkBridgeVlanFilterSet(const char *ifname, - int cmd, const unsigned short flags, const short vid, int *error); +int virNetlinkBridgeVlanFilterDel(const char *ifname, + const short vid, + int *error); + int virNetlinkGetErrorCode(struct nlmsghdr *resp, unsigned int recvbuflen); int virNetlinkDumpLink(const char *ifname, int ifindex, -- 2.49.0
v2 of: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/VYUE7LQB4D5UTEXOEM65ZPJWS2ROZWAW/ diff to v1: 1) Patch 1/5 from the original is dropped, no symbol addition to the private syms file, 2) The "virnetlink.h" is included more often in patch 3/4, 3) Some fixes around virNetlinkBridgeVlanFilterSet() stub Michal Prívozník (4): virnetlink: Provide stub for virNetlinkBridgeVlanFilterSet() virnetdevbridge.c: Fix comments in virNetDevBridgeSetupVlans() virnetdevbridge: Include virnetlink.h more often virnetlink: Split virNetlinkBridgeVlanFilterSet() src/util/virnetdevbridge.c | 18 ++++----- src/util/virnetlink.c | 83 ++++++++++++++++++++++++++++++++++---- src/util/virnetlink.h | 5 ++- 3 files changed, 88 insertions(+), 18 deletions(-) -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> In virnetlink.c there are two sections: the first one when building WITH_LIBNL support, the other that provides stubs for functions declared in the corresponding header file when building without netlink support. But the stub implementation for virNetlinkBridgeVlanFilterSet() was missing. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virnetlink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -XXX,XX +XXX,XX @@ virNetlinkNewLink(const char *ifname G_GNUC_UNUSED, } +int +virNetlinkBridgeVlanFilterSet(const char *ifname G_GNUC_UNUSED, + int cmd G_GNUC_UNUSED, + const unsigned short unusedflags G_GNUC_UNUSED, + const short vid G_GNUC_UNUSED, + int *error) +{ + *error = 0; + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return -1; +} + int virNetlinkGetNeighbor(void **nlData G_GNUC_UNUSED, uint32_t src_pid G_GNUC_UNUSED, -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> We still use C89 style of comments. Fix C99 style of comments used in virNetDevBridgeSetupVlans(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virnetdevbridge.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) if (!virtVlan || !virtVlan->nTags) return 0; - // The interface will have been automatically added to vlan 1, so remove it + /* The interface will have been automatically added to vlan 1, so remove it. */ if (virNetlinkBridgeVlanFilterSet(ifname, RTM_DELLINK, 0, 1, &error) < 0) { if (error != 0) { virReportSystemError(-error, @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) return -1; } - // If trunk mode, add the native VLAN then add the others, if any + /* If trunk mode, add the native VLAN then add the others, if any. */ if (virtVlan->trunk) { size_t i; @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) } } } else { - // In native mode, add the single VLAN as pvid untagged + /* In native mode, add the single VLAN as pvid untagged. */ flags = BRIDGE_VLAN_INFO_PVID | BRIDGE_VLAN_INFO_UNTAGGED; if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, flags, virtVlan->tag[0], &error) < 0) { -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> The whole point of virnetlink.h is that it hides away the build time dependency on netlink. It wraps netlink functions in our functions which then have a stub implementation in case netlink support was disabled. Though, netlink is still Linux specific, so keep it in the '#ifdef __linux__` block to cause a compilation error should anybody try to use any of the wrapped functions on non-Linux. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virnetdevbridge.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -XXX,XX +XXX,XX @@ #endif #ifdef __linux__ -# if defined(WITH_LIBNL) -# include "virnetlink.h" -# endif +# include "virnetlink.h" # include <linux/sockios.h> # include <linux/param.h> /* HZ */ # include <linux/in6.h> -- 2.49.0
From: Michal Privoznik <mprivozn@redhat.com> Currently, virNetlinkBridgeVlanFilterSet() takes @cmd as the second argument where either RTM_SETLINK or RTM_DELLINK is expected. Both of these constants come from linux/rtnetlink.h and thus are undefined when building without netlink. This design also clashes with the whole point of virnetlink: to offload netlink dependency onto a single file. Therefore, drop the argument, turn virNetlinkBridgeVlanFilterSet() into just setter, effectively, and introduce virNetlinkBridgeVlanFilterDel() for the case when RTM_DELLINK would be passed as @cmd. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/770 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virnetdevbridge.c | 8 ++--- src/util/virnetlink.c | 73 +++++++++++++++++++++++++++++++++----- src/util/virnetlink.h | 5 ++- 3 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) return 0; /* The interface will have been automatically added to vlan 1, so remove it. */ - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_DELLINK, 0, 1, &error) < 0) { + if (virNetlinkBridgeVlanFilterDel(ifname, 1, &error) < 0) { if (error != 0) { virReportSystemError(-error, _("error removing vlan filter from interface %1$s"), @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) flags |= BRIDGE_VLAN_INFO_UNTAGGED; } - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, flags, + if (virNetlinkBridgeVlanFilterSet(ifname, flags, virtVlan->nativeTag, &error) < 0) { goto error; } @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) for (i = 0; i < virtVlan->nTags; i++) { if (virtVlan->tag[i] != virtVlan->nativeTag) - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, 0, + if (virNetlinkBridgeVlanFilterSet(ifname, 0, virtVlan->tag[i], &error) < 0) { goto error; } @@ -XXX,XX +XXX,XX @@ virNetDevBridgeSetupVlans(const char *ifname, const virNetDevVlan *virtVlan) } else { /* In native mode, add the single VLAN as pvid untagged. */ flags = BRIDGE_VLAN_INFO_PVID | BRIDGE_VLAN_INFO_UNTAGGED; - if (virNetlinkBridgeVlanFilterSet(ifname, RTM_SETLINK, flags, + if (virNetlinkBridgeVlanFilterSet(ifname, flags, virtVlan->tag[0], &error) < 0) { goto error; } diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -XXX,XX +XXX,XX @@ virNetlinkDelLink(const char *ifname, virNetlinkTalkFallback fallback) } /** - * virNetlinkBridgeVlanFilterSet: + * virNetlinkBridgeVlanFilterHelper: * * @ifname: name of the link * @cmd: netlink command, either RTM_SETLINK or RTM_DELLINK @@ -XXX,XX +XXX,XX @@ virNetlinkDelLink(const char *ifname, virNetlinkTalkFallback fallback) * non-zero, then a netlink failure occurred, but no error message * is generated leaving it up to the caller to handle the condition. */ -int -virNetlinkBridgeVlanFilterSet(const char *ifname, - int cmd, - const unsigned short flags, - const short vid, - int *error) +static int +virNetlinkBridgeVlanFilterHelper(const char *ifname, + int cmd, + const unsigned short flags, + const short vid, + int *error) { struct ifinfomsg ifm = { .ifi_family = PF_BRIDGE }; struct bridge_vlan_info vinfo = { .flags = flags, .vid = vid }; @@ -XXX,XX +XXX,XX @@ virNetlinkBridgeVlanFilterSet(const char *ifname, return 0; } + +/** + * virNetlinkBridgeVlanFilterSet: + * + * @ifname: name of the link + * @flags: flags to use when adding the vlan filter + * @vid: vlan id to add + * @error: netlink error code + * + * Add a vlan filter from an interface associated with a bridge. + * + * Returns 0 on success, -1 on error. Additionally, if the @error is + * non-zero, then a netlink failure occurred, but no error message + * is generated leaving it up to the caller to handle the condition. + */ +int +virNetlinkBridgeVlanFilterSet(const char *ifname, + const unsigned short flags, + const short vid, + int *error) +{ + return virNetlinkBridgeVlanFilterHelper(ifname, RTM_SETLINK, + flags, vid, error); +} + + +/** + * virNetlinkBridgeVlanFilterDel: + * + * @ifname: name of the link + * @vid: vlan id to remove + * @error: netlink error code + * + * Remove a vlan filter from an interface associated with a bridge. + * + * Returns 0 on success, -1 on error. Additionally, if the @error is + * non-zero, then a netlink failure occurred, but no error message + * is generated leaving it up to the caller to handle the condition. + */ +int +virNetlinkBridgeVlanFilterDel(const char *ifname, + const short vid, + int *error) +{ + return virNetlinkBridgeVlanFilterHelper(ifname, + RTM_DELLINK, 0, vid, error); +} + + /** * virNetlinkGetNeighbor: * @@ -XXX,XX +XXX,XX @@ virNetlinkNewLink(const char *ifname G_GNUC_UNUSED, int virNetlinkBridgeVlanFilterSet(const char *ifname G_GNUC_UNUSED, - int cmd G_GNUC_UNUSED, const unsigned short unusedflags G_GNUC_UNUSED, const short vid G_GNUC_UNUSED, int *error) @@ -XXX,XX +XXX,XX @@ virNetlinkBridgeVlanFilterSet(const char *ifname G_GNUC_UNUSED, return -1; } +int +virNetlinkBridgeVlanFilterDel(const char *ifname G_GNUC_UNUSED, + const short vid G_GNUC_UNUSED, + int *error G_GNUC_UNUSED) +{ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); + return -1; +} + int virNetlinkGetNeighbor(void **nlData G_GNUC_UNUSED, uint32_t src_pid G_GNUC_UNUSED, diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h index XXXXXXX..XXXXXXX 100644 --- a/src/util/virnetlink.h +++ b/src/util/virnetlink.h @@ -XXX,XX +XXX,XX @@ typedef int (*virNetlinkTalkFallback)(const char *ifname); int virNetlinkDelLink(const char *ifname, virNetlinkTalkFallback fallback); int virNetlinkBridgeVlanFilterSet(const char *ifname, - int cmd, const unsigned short flags, const short vid, int *error); +int virNetlinkBridgeVlanFilterDel(const char *ifname, + const short vid, + int *error); + int virNetlinkGetErrorCode(struct nlmsghdr *resp, unsigned int recvbuflen); int virNetlinkDumpLink(const char *ifname, int ifindex, -- 2.49.0