From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 992581A683E for ; Mon, 4 May 2026 12:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777897931; cv=none; b=GNLN6lt2mb9yrO1ngm25pKuIaiw/S/sG8kJmlxI5uVOGPpbsJeUiVmdg5Db5l07i/5dbq56K6pioiexDRPHEgSJmQlf3WOE/4CS1iWAfkDjWrIZIPRhepk+A5E2/Mbi0OpUuHUHp2sNucopVTQ3zFwpA6JrpbO6CJ1UDHtUNAf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777897931; c=relaxed/simple; bh=k4QL8qvkzMM84LE0VCc92a90Vt/42H1pZ5NNSERDBUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YwYRVtWoXTvZVTv7C/4w4lPi/LOdkcjghZRUriemx02z5TPZDACnEq8PqecnNYUyjM13QI3AvTTm+vJQDFU7s3UkAwFTxsh5HTg1KtrqAfljg8AILH//7IpkkVtYU/r7qP4Wms72YZAANVbMRfBfzjKO5vi84dr3VyxPuWANiAw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=UjjImKM7; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=f2Am95ZI; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=O9MkyMDO; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=+N1UyPBC; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="UjjImKM7"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="f2Am95ZI"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="O9MkyMDO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+N1UyPBC" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EED385C547; Mon, 4 May 2026 12:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777897919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HpNtzM/lNNWKN+0w7GrcPbMne22lAOtj7Q4395GVrqI=; b=UjjImKM7mC9/KENyStIBjExtWHbFcns/8VTU83lXw4snQOr6nNbdmJEC/lmCdVZuG6ZXTJ RMzFhpS8m0p4Q47QzRRg8trCcl3bjvPz6kgo+9fSPQMUmRtTy0asC96pXPn2k9R/elh149 S34kfgFjuSxkjfBzhE2rWbj0kOztx7w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777897919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HpNtzM/lNNWKN+0w7GrcPbMne22lAOtj7Q4395GVrqI=; b=f2Am95ZItL8unQKXIu55+eo84BDj+APiR2Ul2gwr02gwVVcQv1XXFO1Z5/7RHmEaF/rpdi DGierZl6S5FyA9Dw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777897918; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HpNtzM/lNNWKN+0w7GrcPbMne22lAOtj7Q4395GVrqI=; b=O9MkyMDOghUtp+kyU+W9nYaYopMGkVARwD0OmTm8SHe2cymD8Tpqns5L872kGeXh6UbgvP dkUl12M9ag+RVCI8zh1t0vWuoJjK3spym+N7vZxWLIFioi8fnFc92iwBj0Bl0Xz4XUiIHE 6HEcl+EoEU6fIqdwLv0Ne1osg18aJ3k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777897918; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HpNtzM/lNNWKN+0w7GrcPbMne22lAOtj7Q4395GVrqI=; b=+N1UyPBCfxId/ZI6twQ+X/CH+5tzCcQ3LcphZBlZEfsLF+i/ih8qlm1cQ4ODYE5jcZmaDm VwIlNt6W8GU15ZAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5A222593A3; Mon, 4 May 2026 12:31:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AOgOE76R+GnBXQAAD6G6ig (envelope-from ); Mon, 04 May 2026 12:31:58 +0000 From: Fernando Fernandez Mancera To: netdev@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, horms@kernel.org, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, idosch@nvidia.com, dsahern@kernel.org, Fernando Fernandez Mancera Subject: [PATCH 3/3 net-next v3] selftests: net: add test for IPv4 devconf netlink notifications Date: Mon, 4 May 2026 14:31:43 +0200 Message-ID: <20260504123143.6284-3-fmancera@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260504123143.6284-1-fmancera@suse.de> References: <20260504123143.6284-1-fmancera@suse.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; URIBL_BLOCKED(0.00)[lib.py:url,imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[10]; R_RATELIMIT(0.00)[to_ip_from(RLrr9ek4ud4f4qwi71m7motjzt)]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO Introduce a new test, `ipv4_devconf_notify`, to verify that the kernel sends the appropriate netlink notifications when IPv4 devconf parameters are modified. Since YNL currently has a bug where it declares an array of u32 values instead of the nested attributes expected by the kernel for devconf set operations, a temporary hack (`patched_add_attr`) is included to pack the netlink attributes correctly. Signed-off-by: Fernando Fernandez Mancera --- v3: added this patch to the series as requested by Paolo. --- tools/testing/selftests/net/rtnetlink.py | 75 ++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/rtnetlink.py b/tools/testing/selftests/net/rtnetlink.py index e9ad5e88da97..99c5a3e7f1f0 100755 --- a/tools/testing/selftests/net/rtnetlink.py +++ b/tools/testing/selftests/net/rtnetlink.py @@ -1,17 +1,22 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 -from lib.py import ksft_exit, ksft_run, ksft_ge, RtnlAddrFamily +from lib.py import bkg, ip, ksft_exit, ksft_run, ksft_ge, ksft_true +from lib.py import NetNS, NetNSEnter, RtnlAddrFamily, RtnlFamily import socket +import struct +import time +import types IPV4_ALL_HOSTS_MULTICAST = b'\xe0\x00\x00\x01' -def dump_mcaddr_check(rtnl: RtnlAddrFamily) -> None: +def dump_mcaddr_check() -> None: """ Verify that at least one interface has the IPv4 all-hosts multicast address. At least the loopback interface should have this address. """ + rtnl = RtnlAddrFamily() addresses = rtnl.getmulticast({"ifa-family": socket.AF_INET}, dump=True) all_host_multicasts = [ @@ -21,9 +26,71 @@ def dump_mcaddr_check(rtnl: RtnlAddrFamily) -> None: ksft_ge(len(all_host_multicasts), 1, "No interface found with the IPv4 all-hosts multicast address") +def ipv4_devconf_notify() -> None: + """ + Configure an interface and set ipv4-devconf values through netlink + to verify that the appropriate netlink notifications are being sent. + """ + + with NetNS() as ns: + with NetNSEnter(str(ns)): + rtnl = RtnlFamily() + + ifname = "dummy1" + ip(f"link add name {ifname} type dummy", ns=str(ns)) + + link_info = ip(f"link show dev {ifname}", ns=str(ns), json=True) + ksft_true(bool(link_info), f"Failed to retrieve link info for {ifname}") + ifindex = link_info[0]["ifindex"] + notification_found = False + + # YNL do not support netconf notifications yet + with bkg(f"ip monitor", ns=str(ns)) as cmd_obj: + original_add_attr = rtnl._add_attr + time.sleep(0.5) + + # Currently YNL has a bug for applying devconf values, + # this hack fixes it. In essence, YNL is declaring an + # array of u32 values, while kernel expects a nested attribute + # on set operation. + def patched_add_attr(self, space, name, value, search_attrs): + if name == 'conf' and value == b"MAGIC_CONF": + fwd_attr = struct.pack("=HHI", 8, 1, 1) + proxy_arp_attr = struct.pack("=HHI", 8, 3, 1) + rp_filter_attr = struct.pack("=HHI", 8, 8, 1) + ignore_routes_attr = struct.pack("=HHI", 8, 29, 1) + + return struct.pack("=HH", 36, 0x8001) + fwd_attr \ + + proxy_arp_attr \ + + rp_filter_attr \ + + ignore_routes_attr + + return original_add_attr(space, name, value, search_attrs) + + rtnl._add_attr = types.MethodType(patched_add_attr, rtnl) + + req = { + "ifi-index": ifindex, + "af-spec": { + "inet": { + "conf": b"MAGIC_CONF" + } + } + } + rtnl.newlink(req) + time.sleep(0.5) + + ksft_true(f"inet {ifname} ignore_routes_with_linkdown on" in cmd_obj.stdout, + f"No 'ignore_routes_with_linkdown on' notificiation found for interface {ifname}") + ksft_true(f"inet {ifname} rp_filter strict" in cmd_obj.stdout, + f"No 'rp_filter strict' notificiation found for interface {ifname}") + ksft_true(f"inet {ifname} proxy_neigh on" in cmd_obj.stdout, + f"No 'proxy_neigh on' notificiation found for interface {ifname}") + ksft_true(f"inet {ifname} forwarding on" in cmd_obj.stdout, + f"No 'forwarding on' notificiation found for interface {ifname}") + def main() -> None: - rtnl = RtnlAddrFamily() - ksft_run([dump_mcaddr_check], args=(rtnl, )) + ksft_run([dump_mcaddr_check, ipv4_devconf_notify]) ksft_exit() if __name__ == "__main__": -- 2.53.0