Enable vlan support for standard linux bridges

Adjust domain and network validation to permit vlan configuration on
standard linux bridges.

Update calls to virNetDevBridgeAddPort to pass the vlan configuration.

Signed-off-by: Leigh Brown <leigh@solinno.co.uk>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Leigh Brown 2025-01-08 13:31:29 +00:00 committed by Laine Stump
parent 582f0966f9
commit c1a0d08518
4 changed files with 12 additions and 8 deletions

View File

@ -2077,7 +2077,8 @@ virDomainActualNetDefValidate(const virDomainNetDef *net)
(actualType == VIR_DOMAIN_NET_TYPE_DIRECT && (actualType == VIR_DOMAIN_NET_TYPE_DIRECT &&
virDomainNetGetActualDirectMode(net) == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) || virDomainNetGetActualDirectMode(net) == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) ||
(actualType == VIR_DOMAIN_NET_TYPE_BRIDGE && (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE &&
vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH))) { vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) ||
(actualType == VIR_DOMAIN_NET_TYPE_BRIDGE && !vport))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("interface %1$s - vlan tag not supported for this connection type"), _("interface %1$s - vlan tag not supported for this connection type"),
macstr); macstr);

View File

@ -289,7 +289,7 @@ virLXCProcessSetupInterfaceTap(virDomainDef *vm,
vport, virDomainNetGetActualVlan(net)) < 0) vport, virDomainNetGetActualVlan(net)) < 0)
return NULL; return NULL;
} else { } else {
if (virNetDevBridgeAddPort(brname, parentVeth, NULL) < 0) if (virNetDevBridgeAddPort(brname, parentVeth, virDomainNetGetActualVlan(net)) < 0)
return NULL; return NULL;
if (virDomainNetGetActualPortOptionsIsolated(net) == VIR_TRISTATE_BOOL_YES && if (virDomainNetGetActualPortOptionsIsolated(net) == VIR_TRISTATE_BOOL_YES &&

View File

@ -2999,7 +2999,8 @@ networkValidate(virNetworkDriverState *driver,
/* The only type of networks that currently support transparent /* The only type of networks that currently support transparent
* vlan configuration are those using hostdev sr-iov devices from * vlan configuration are those using hostdev sr-iov devices from
* a pool, and those using an Open vSwitch bridge. * a pool, those using an Open vSwitch bridge, and standard linux
* bridges.
*/ */
vlanAllowed = (def->forward.type == VIR_NETWORK_FORWARD_HOSTDEV || vlanAllowed = (def->forward.type == VIR_NETWORK_FORWARD_HOSTDEV ||
@ -3007,15 +3008,17 @@ networkValidate(virNetworkDriverState *driver,
(def->forward.type == VIR_NETWORK_FORWARD_BRIDGE && (def->forward.type == VIR_NETWORK_FORWARD_BRIDGE &&
def->virtPortProfile && def->virtPortProfile &&
def->virtPortProfile->virtPortType def->virtPortProfile->virtPortType
== VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)); == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) ||
(def->forward.type == VIR_NETWORK_FORWARD_BRIDGE &&
!def->virtPortProfile));
vlanUsed = def->vlan.nTags > 0; vlanUsed = def->vlan.nTags > 0;
for (i = 0; i < def->nPortGroups; i++) { for (i = 0; i < def->nPortGroups; i++) {
if (vlanUsed || def->portGroups[i].vlan.nTags > 0) { if (vlanUsed || def->portGroups[i].vlan.nTags > 0) {
/* anyone using this portgroup will get a vlan tag. Verify /* anyone using this portgroup will get a vlan tag. Verify
* that they will also be using an openvswitch connection, * that they will also be using an openvswitch connection
* as that is the only type of network that currently * or a standard linux bridge as they are the only types of
* supports a vlan tag. * network that currently support a vlan tag.
*/ */
if (def->portGroups[i].virtPortProfile) { if (def->portGroups[i].virtPortProfile) {
if (def->forward.type != VIR_NETWORK_FORWARD_BRIDGE || if (def->forward.type != VIR_NETWORK_FORWARD_BRIDGE ||

View File

@ -483,7 +483,7 @@ virNetDevTapAttachBridge(const char *tapname,
return -1; return -1;
} }
} else { } else {
if (virNetDevBridgeAddPort(brname, tapname, NULL) < 0) if (virNetDevBridgeAddPort(brname, tapname, virtVlan) < 0)
return -1; return -1;
if (isolatedPort == VIR_TRISTATE_BOOL_YES && if (isolatedPort == VIR_TRISTATE_BOOL_YES &&