Unable to distinguish vlan nativeMode is tagged or untagged for linux bridge
Software environment
- Operating system:fedora rawhide
- Architecture:x86_64
- kernel version:6.14.0-0.rc7.20250318git76b6905c11fd.57.fc43.x86_64
- libvirt version:11.2.0-1.fc43.x86_64
- Hypervisor and version:qemu-kvm-9.2.2-8.fc43.x86_64
Description of problem
This patch involved support for linux bridge vlan, but the nativeMode=tagged/untagged can not be distinguished with the suggested 'bridge vlan' cmd. https://patchew.org/Libvirt/20250108193415.200555-1-leigh@solinno.co.uk/
Steps to reproduce
1.setup a linux bridge 'br0' 2.start a host-bridge network with br0 and portgroup vlan settings:
<network connections='1'>
<name>host-bridge</name>
<uuid>ecfe7e14-65fc-417e-acdc-fc3c72fa0590</uuid>
<forward mode='bridge'/>
<bridge name='br0'/>
<portgroup name='port_42'>
<vlan trunk='yes'>
<tag id='50'/>
<tag id='42' nativeMode='untagged'/>
</vlan>
</portgroup>
<portgroup name='port_4'>
<vlan>
<tag id='4' nativeMode='tagged'/>
</vlan>
</portgroup>
</network>
3.define a vm with interface pointing 'port_4' which has only 1 native-tagged vlan:
<interface type="network">
<mac address="52:54:00:72:af:0b"/>
<source network="host-bridge" portgroup="port_4"/>
<model type="virtio"/>
</interface>
- start vm and check nativeMode value in xml and cmd:
# virsh dumpxml rhel-test --xpath //interface
<interface type="bridge">
<mac address="52:54:00:72:af:0b"/>
<source network="host-bridge" portgroup="port_4" portid="7150a205-b3cc-4a3b-9b3f-4506f31b287f" bridge="br0"/>
<vlan>
<tag id="4" nativeMode="tagged"/>
</vlan>
<target dev="vnet22"/>
<model type="virtio"/>
<alias name="net0"/>
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>
# bridge vlan
port vlan-id
eno1 1 PVID Egress Untagged
virbr0 1 PVID Egress Untagged
...
vnet22 4 PVID Egress **Untagged**
If vm interface points to "port_4", still get the same result. The ovs-vsctl cmd can not be used since it's nothing about OVS, and no vlan id in “ip -d link” cmd output. No sure if any other cmds can get the accurate value.
Additional information
For a ovs bridge test, we can get natie-tagged in ovs-vsctl cmd:
<network connections='1'>
<name>ovs-net</name>
<uuid>ecfe7e14-65fc-417e-acdc-fc3c72fa0590</uuid>
<forward mode='bridge'/>
<bridge name='ovsbr0' />
<virtualport type='openvswitch'>
<parameters interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/>
</virtualport>
<portgroup name='port_42'>
<vlan trunk='yes'>
<tag id='50'/>
<tag id='42' nativeMode='untagged'/>
</vlan>
</portgroup>
<portgroup name='port_4'>
<vlan>
<tag id='4' nativeMode='tagged'/>
</vlan>
</portgroup>
</network>
<interface type="network">
<source network="ovs-net" portgroup="port_4"/>
<model type="virtio"/>
</interface>
# ovs-vsctl list port vnet0
uuid : 7845fb82-2b47-44a3-8cd6-6f238013ab46
...
vlan_mode : native-tagged
(it will shows native-untagged if vm interface points to port_42)