Skip to content

[Draft] KVM: enable no-mac-spoofing on virtual nics #8951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,7 @@
}
if (_macAddr != null) {
netBuilder.append("<mac address='" + _macAddr + "'/>\n");
netBuilder.append("<filterref filter='no-mac-spoofing'/>\n");

Check warning on line 1600 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java#L1600

Added line #L1600 was not covered by tests
}
if (_model != null) {
netBuilder.append("<model type='" + _model + "'/>\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void testInterfaceTypeUserWithNetwork() {

String expected = "<interface type='user'>\n" +
"<mac address='00:11:22:aa:bb:dd'/>\n" +
"<filterref filter='no-mac-spoofing'/>\n" +
"<model type='virtio'/>\n" +
"<ip family='ipv4' address='192.168.100.0' prefix='24'/>\n" +
"</interface>\n";
Expand All @@ -68,6 +69,7 @@ public void testInterfaceTypeUserWithoutNetwork() {

String expected = "<interface type='user'>\n" +
"<mac address='00:11:22:aa:bb:dd'/>\n" +
"<filterref filter='no-mac-spoofing'/>\n" +
"<model type='virtio'/>\n" +
"</interface>\n";

Expand All @@ -83,6 +85,7 @@ public void testInterfaceEthernet() {
"<interface type='ethernet'>\n"
+ "<target dev='targetDeviceName'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<link state='up'/>\n"
+ "</interface>\n";
Expand All @@ -99,6 +102,7 @@ public void testInterfaceDirectNet() {
"<interface type='" + LibvirtVMDef.InterfaceDef.GuestNetType.DIRECT + "'>\n"
+ "<source dev='targetDeviceName' mode='private'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<link state='up'/>\n"
+ "</interface>\n";
Expand All @@ -116,6 +120,7 @@ public void testInterfaceBridgeSlot() {
"<interface type='" + LibvirtVMDef.InterfaceDef.GuestNetType.BRIDGE + "'>\n"
+ "<source bridge='targetDeviceName'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<link state='up'/>\n"
+ "<address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>\n"
Expand All @@ -131,6 +136,7 @@ public void testInterfaceBridgeSlot() {
+ "<source bridge='targetDeviceName'/>\n"
+ "<target dev='vnet11'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<link state='down'/>\n"
+ "<address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>\n"
Expand All @@ -152,6 +158,7 @@ public void testInterfaceWithMultiQueueAndPacked() {
"<interface type='" + LibvirtVMDef.InterfaceDef.GuestNetType.BRIDGE + "'>\n"
+ "<source bridge='targetDeviceName'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<driver queues='6'/>\n"
+ "<link state='up'/>\n"
Expand All @@ -163,6 +170,7 @@ public void testInterfaceWithMultiQueueAndPacked() {
"<interface type='" + LibvirtVMDef.InterfaceDef.GuestNetType.BRIDGE + "'>\n"
+ "<source bridge='targetDeviceName'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<driver queues='6' packed='on'/>\n"
+ "<link state='up'/>\n"
Expand All @@ -174,6 +182,7 @@ public void testInterfaceWithMultiQueueAndPacked() {
"<interface type='" + LibvirtVMDef.InterfaceDef.GuestNetType.BRIDGE + "'>\n"
+ "<source bridge='targetDeviceName'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<driver packed='on'/>\n"
+ "<link state='up'/>\n"
Expand All @@ -185,6 +194,7 @@ public void testInterfaceWithMultiQueueAndPacked() {
"<interface type='" + LibvirtVMDef.InterfaceDef.GuestNetType.BRIDGE + "'>\n"
+ "<source bridge='targetDeviceName'/>\n"
+ "<mac address='00:11:22:aa:bb:dd'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<link state='up'/>\n"
+ "</interface>\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class LibvirtReplugNicCommandWrapperTest {
private static final String part_2 =
" <interface type='bridge'>\n"
+ " <mac address='02:00:7c:98:00:02'/>\n"
+ " <filterref filter='no-mac-spoofing'/>\n"
+ " <source bridge='breth2-234'/>\n"
+ " <bandwidth>\n"
+ " <inbound average='25600' peak='25600'/>\n"
Expand Down Expand Up @@ -247,6 +248,7 @@ public void testReplugNic() throws LibvirtException {
+ "<source bridge='breth2-234'/>\n"
+ "<target dev='vnet10'/>\n"
+ "<mac address='02:00:7c:98:00:02'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<bandwidth>\n"
+ "<inbound average='25600' peak='25600'/>\n"
Expand All @@ -259,6 +261,7 @@ public void testReplugNic() throws LibvirtException {
+ "<source bridge='eth0'/>\n"
+ "<target dev='vnet10'/>\n"
+ "<mac address='02:00:7c:98:00:02'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<virtualport type='openvswitch'>\n"
+ "</virtualport>\n"
Expand All @@ -273,6 +276,7 @@ public void testReplugNic() throws LibvirtException {
+ "<source bridge='eth0'/>\n"
+ "<target dev='vnet10'/>\n"
+ "<mac address='02:00:7c:98:00:02'/>\n"
+ "<filterref filter='no-mac-spoofing'/>\n"
+ "<model type='virtio'/>\n"
+ "<virtualport type='openvswitch'>\n"
+ "</virtualport>\n"
Expand Down
Loading