From 4632f8a8bb9ca9c08a1cf61297947bd12003139a Mon Sep 17 00:00:00 2001 From: Pavaman Subramaniyam Date: Wed, 25 Feb 2026 20:37:59 +0530 Subject: [PATCH] Adding the check for module to be the same as driver to be tested Introducing the check for making sure if the network adapter is physically present in the machine Thereby if the driver of the network interface is the same as the kernel module to be tested Signed-off-by: Pavaman Subramaniyam --- io/driver/driver_parameter.py | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/io/driver/driver_parameter.py b/io/driver/driver_parameter.py index c89c8ab17..bbdc8bed8 100755 --- a/io/driver/driver_parameter.py +++ b/io/driver/driver_parameter.py @@ -50,6 +50,9 @@ def setUp(self): self.module = self.params.get('module', default=None) if not self.module: self.cancel("Please provide the Module name") + + # Validate that the interface belongs to the specified driver + self.validate_interface_driver() self.ipaddr = self.params.get("host_ip", default="") self.netmask = self.params.get("netmask", default="") self.peer = self.params.get("peer_ip") @@ -85,6 +88,50 @@ def setUp(self): self.cancel("Param %s is not Valid for Module %s" % (self.param_name, self.module)) + def get_interface_driver(self): + """ + Get the driver module name for the specified interface using ethtool. + Returns the driver name or None if unable to determine. + Assisted with AI tool + """ + try: + cmd = "ethtool -i %s" % self.ifaces + output = process.system_output(cmd, ignore_status=False).decode('utf-8') + for line in output.split('\n'): + if line.startswith('driver:'): + driver = line.split(':', 1)[1].strip() + self.log.info("Interface %s is using driver: %s" % + (self.ifaces, driver)) + return driver + except Exception as e: + self.log.warning("Failed to get driver info for %s: %s" % + (self.ifaces, str(e))) + return None + return None + + def validate_interface_driver(self): + """ + Validate that the interface belongs to the driver module specified in YAML. + Raises an error if there's a mismatch between the YAML-specified module + and the interface's actual driver. + Assisted with AI tool + """ + actual_driver = self.get_interface_driver() + + if actual_driver is None: + self.cancel("Unable to determine driver for interface %s. " + "Please verify the interface exists and ethtool is available." + % self.ifaces) + + if actual_driver != self.module: + self.cancel("Driver mismatch detected: Interface %s is using driver '%s' " + "but YAML configuration specifies module '%s'. " + "Please ensure the interface belongs to the correct driver." + % (self.ifaces, actual_driver, self.module)) + + self.log.info("Driver validation passed: Interface %s belongs to module %s" + % (self.ifaces, self.module)) + def built_in_module(self, module): """ checking whether the given module is built_in module or not