diff --git a/ovn-tester/cms/openstack/openstack.py b/ovn-tester/cms/openstack/openstack.py index 27216273..84a8bb5e 100644 --- a/ovn-tester/cms/openstack/openstack.py +++ b/ovn-tester/cms/openstack/openstack.py @@ -34,6 +34,7 @@ class NeutronNetwork: network: LSwitch ports: Dict[str, LSPort] name: str + mtu: int security_group: Optional[PortGroup] = None def __post_init__(self): @@ -204,7 +205,8 @@ def new_external_network( """ ext_net_uuid = uuid.uuid4() ext_net_name = f"ext_net_{ext_net_uuid}" - ext_net = self._create_project_net(f"ext_net_{ext_net_uuid}", 1500) + mtu = 1500 + ext_net = self._create_project_net(f"ext_net_{ext_net_uuid}", mtu) ext_net_port = self._add_metadata_port(ext_net, str(ext_net_uuid)) provider_port = self._add_provider_network_port( ext_net, provider_network @@ -216,6 +218,7 @@ def new_external_network( provider_port.uuid: provider_port, }, name=ext_net_name, + mtu=mtu, ) def connect_external_network_to_project( @@ -273,7 +276,8 @@ def add_internal_network_to_project( :return: None """ int_net_name = f"int_net_{project.uuid}" - int_net = self._create_project_net(int_net_name, 1442) + mtu = 1442 + int_net = self._create_project_net(int_net_name, mtu) int_net_port = self._add_metadata_port(int_net, project.uuid) security_group = self._create_default_security_group() @@ -281,6 +285,7 @@ def add_internal_network_to_project( network=int_net, ports={int_net_port.uuid: int_net_port}, name=int_net_name, + mtu=mtu, security_group=security_group, ) @@ -301,7 +306,7 @@ def add_vm_to_project(self, project: Project, vm_name: str): vm_port = self._add_vm_port( project.int_net, project.uuid, compute, vm_name ) - compute.bind_port(vm_port) + compute.bind_port(vm_port, mtu_request=project.int_net.mtu) project.vm_ports.append(vm_port) @@ -442,9 +447,7 @@ def _add_vm_port( "neutron:subnet_pool_addr_scope4": "", "neutron:subnet_pool_addr_scope6": "", } - port_options = ( - f"requested-chassis={chassis.container}" - ) + port_options = f"requested-chassis={chassis.container}" ls_port = self.nbctl.ls_port_add( lswitch=neutron_net.network, name=port_name, @@ -543,7 +546,7 @@ def _add_router_port_external_gw( """ port_ip = self.next_external_ip() return self._add_router_port( - neutron_net.network, router, port_ip, "", True + neutron_net.network, router, port_ip, "", True, neutron_net.mtu ) def _add_router_port( @@ -553,6 +556,7 @@ def _add_router_port( port_ip: DualStackIP, project_id: str = "", is_gw: bool = False, + mtu: Optional[int] = None, ) -> (LSPort, LRPort): """Add a pair of ports that connect Logical Router and Logical Switch. @@ -594,7 +598,12 @@ def _add_router_port( } lr_port = self.nbctl.lr_port_add( - router, router_port_name, str(RandMac()), port_ip, lrp_external_ids + router, + router_port_name, + str(RandMac()), + port_ip, + lrp_external_ids, + {"gateway_mtu": str(mtu)} if mtu else None, ) ls_port = self.nbctl.ls_port_add( diff --git a/ovn-tester/ovn_utils.py b/ovn-tester/ovn_utils.py index 8915c9ca..e73a14ec 100644 --- a/ovn-tester/ovn_utils.py +++ b/ovn-tester/ovn_utils.py @@ -209,7 +209,14 @@ def set_global_external_id(self, key, value): ("external_ids", {key: str(value)}), ).execute(check_error=True) - def add_port(self, port, bridge, internal=True, ifaceid=None): + def add_port( + self, + port, + bridge, + internal=True, + ifaceid=None, + mtu_request: Optional[int] = None, + ): name = port.name with self.idl.transaction(check_error=True) as txn: txn.add(self.idl.add_port(bridge, name)) @@ -221,6 +228,12 @@ def add_port(self, port, bridge, internal=True, ifaceid=None): txn.add( self.idl.iface_set_external_id(name, "iface-id", ifaceid) ) + if mtu_request: + txn.add( + self.idl.db_set( + "Interface", name, ("mtu_request", mtu_request) + ) + ) def del_port(self, port): self.idl.del_port(port.name).execute(check_error=True) @@ -448,7 +461,13 @@ def lr_add(self, name, ext_ids: Optional[Dict] = None): return LRouter(name=name, uuid=uuid) def lr_port_add( - self, router, name, mac, dual_ip=None, ext_ids: Optional[Dict] = None + self, + router, + name, + mac, + dual_ip=None, + ext_ids: Optional[Dict] = None, + options: Optional[Dict] = None, ): ext_ids = {} if ext_ids is None else ext_ids networks = [] @@ -458,7 +477,12 @@ def lr_port_add( networks.append(f'{dual_ip.ip6}/{dual_ip.plen6}') self.idl.lrp_add( - router.uuid, name, str(mac), networks, external_ids=ext_ids + router.uuid, + name, + str(mac), + networks, + external_ids=ext_ids, + options=options, ).execute() return LRPort(name=name, mac=mac, ip=dual_ip) diff --git a/ovn-tester/ovn_workload.py b/ovn-tester/ovn_workload.py index c482938e..0ca0a59a 100644 --- a/ovn-tester/ovn_workload.py +++ b/ovn-tester/ovn_workload.py @@ -203,9 +203,15 @@ def unprovision_port(self, cluster, port): self.lports.remove(port) @ovn_stats.timeit - def bind_port(self, port): + def bind_port(self, port, mtu_request: Optional[int] = None): log.info(f'Binding lport {port.name} on {self.container}') - self.vsctl.add_port(port, 'br-int', internal=True, ifaceid=port.name) + self.vsctl.add_port( + port, + 'br-int', + internal=True, + ifaceid=port.name, + mtu_request=mtu_request, + ) # Skip creating a netns for "passive" ports, we won't be sending # traffic on those. if not port.passive: