From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796094266; b=beSUA9N2NIP7mQN4i83IwCAe+MEvHBoL3VPgxe2EEmmTTDFN3+qzK+tTwQemsvAZBuhH knIeK88AXksgLy0JUGJ+vYHjeLSv7yjyUuA0Wr2A499JexQ+aQfMtU47P2IyVs9YnY7AI XhgrAWauzbkK0RObCJ7HHEXLx3Pt1OzRWsgg/NfA1ahFv/mZwhesQzdjhqzJpheazQhCl 1Yoc6ozdubj08OToh8j/Ovg7LvXOVOfD9UUIDDxccwIDBcm720ANV67mJGsftTHS1olm3 tEtaoIPMsPgLn+Xs3/yczLrWaqDdQLo8ltnKjs7Z014j2r69w4Ph5glA4UJ25WBILfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796094266; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=WrS1eNvOEgAupB9J7MHixEzhyGobRch6lkQygzat1KM=; b=aqZxzhk+F6iPggVPuqWMmzL6sYN+mskOraIyoxJyRCixei5wWbwmWXDx9FS7x0X0exs2 BHO5bMR7Rw0+GOMiC/N31q6bwLy5Py+nI3UCw4VAKHAVILdalkyiu/2jtKv9O+2Qf7nvB qYi63BDvz5G7//TzSFpgST+LrufYOp5LzLOPtX+iB0S/s4SOPF98cMbjna52d11Y7U2FD 3afXmg3hb5swgNEBT1DwrwDcvUg6D687CM+Omm3+Ei8EiH7oq2ZxnKhhuNXkp5H/WIbYv iNs1arC4WsV8VhgFXTAjWFGGQ6oGrJdYxPaoxIDviKDwQTwblr/PK3GzxiD6rw5qKew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--yuyanghuang.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=VdQi9FM0; arc=none smtp.remote-ip=209.85.214.200 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A3B0606A31A for ; Tue, 1 Dec 2026 03:04:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5A3B0606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yuyanghuang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=VdQi9FM0 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2f053f9631cso143365405ad.1 for ; Mon, 30 Nov 2026 19:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796094266; x=1796699066; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WrS1eNvOEgAupB9J7MHixEzhyGobRch6lkQygzat1KM=; b=VdQi9FM0iGeFIY1JSZPpLMMR/or/Vk6+AQ//21yFBLGEp9bdWTZAvNVxsBMUd9ajP9 Wyx+nCZ2rRIgDUr6gJDz4xnTu63a2UYUVUwTqtL7+E2f8B9CK9TN+yNLM91B1Un8wx59 eI5Va/beRj58ry+0UlASkiDVGdRxsrCjAEaJTKXP/SkpFSBGaWj9qLr5LqGvQN+1uF0J t47GlwHMgfhJESfnsZA62b2iD8+vF9bPGBcugwVfrjdqZfWl+4cVEyHbdaik2AWu6vQn IXhFGPXKclSo+QRz5we4r7szGLo868ks703P4JNQP/CUZxu0SITGZTXCYR+uzKK361GF ZLFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796094266; x=1796699066; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WrS1eNvOEgAupB9J7MHixEzhyGobRch6lkQygzat1KM=; b=aX/QFG5OsGSJLRw+LcvZOK89pWpLIUKHRtoSP+E2rypJeYxizotpWD1Q6Mkyr6Ud9w 7F/bit/LzARud6tZ/l0BGYmCA7nzYeqxXaVX30bp+oYAMQdppTANPitxnbh8Nm/t0KcR 3DUBUDSzo7EAT+YXTHNrBtOBc8Yavf2Zph8BYqR773W08jV9cTQ1t8+WEAe1rQGqQ7C+ lwt9NxAyy+3pJAl1AeEzXDIF4B5nzcwDvEku8PPWE7dsjgoWlxVi7tIumkoGMGzy9EeL 6mbQxDJT8bAxEWcxHuJontJOqypC3StwHETQvg8G8+9WwBieyrG2zouFBB0cRKkOle53 GnVw== X-Forwarded-Encrypted: i=1; AL+hErHOoIEJS04WZZUqkQRWtIF5XeSfZW5JEriAP4RsBYbS1XuIhHNRHvKjhH2Te/werDZRudIDQ9o=@vger.kernel.org X-Gm-Message-State: APuU4Z//th8pB58pJYSTtihpc+wFiBubtUJwrbZ3PJJqwwTIRTRbbpKa bX3Yc6V9zHPkNC+geLBm7SPyqHFS8lesRd1jgA9LEDVC3yg4IoWKK9kbv0PcoaQE4zh73aD+Xsl 1d73kd81HyA4WDCho6dmqCZTDcg== X-Received: from pfn14.prod.google.com ([2002:a05:6a00:a20e:b0:8bb:1b05:dd2a]) (user=yuyanghuang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:748b:b0:3f8:c7b1:688b with SMTP id adf61e73a8af0-4014d4579b7mr39732097637.34.1796094265245; Mon, 30 Nov 2026 19:04:25 -0800 (PST) Date: Tue, 1 Dec 2026 12:04:17 +0900 In-Reply-To: <20261201030417.49274-1-yuyanghuang@google.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261201030417.49274-1-yuyanghuang@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261201030417.49274-2-yuyanghuang@google.com> Subject: [PATCH iproute2-next v2 1/1] ipmaddr: read link-layer multicast addresses via netlink From: Yuyang Huang To: Yuyang Huang Cc: David Ahern , netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" "ip maddr show" gets the IPv4 and IPv6 entries from RTM_GETMULTICAST dumps but still parses /proc/net/dev_mcast for the link-layer ones. The kernel now also dumps the device multicast list (dev->mc) for RTM_GETMULTICAST requests with ifa_family AF_PACKET, so use it for those too. The dump carries every column of /proc/net/dev_mcast: IFA_MULTICAST is the address, IFA_MC_USERS the reference count and IFA_F_GLOBAL in IFA_FLAGS the "static" column, set for entries added explicitly, e.g. by "ip maddr add". The output does not change. Older kernels reject the AF_PACKET dump with EOPNOTSUPP, in which case /proc/net/dev_mcast is parsed as before. Signed-off-by: Yuyang Huang --- ip/ipmaddr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c index 95b703d2..2df520a3 100644 --- a/ip/ipmaddr.c +++ b/ip/ipmaddr.c @@ -261,6 +261,10 @@ static int accept_maddr(struct nlmsghdr *n, void *arg) ma->addr.bitlen = ma->addr.bytelen << 3; memcpy(ma->addr.data, RTA_DATA(tb[IFA_MULTICAST]), ma->addr.bytelen); ma->users = rta_getattr_u32(tb[IFA_MC_USERS]); + /* IFA_F_GLOBAL is the "static" column of /proc/net/dev_mcast */ + if (ifm->ifa_family == AF_PACKET && tb[IFA_FLAGS] && + (rta_getattr_u32(tb[IFA_FLAGS]) & IFA_F_GLOBAL)) + ma->features = "static"; maddr_ins(&ctx->list, ma); return 0; @@ -388,8 +392,10 @@ static int multiaddr_list(int argc, char **argv) } } - if (!filter.family || filter.family == AF_PACKET) - read_dev_mcast(&list); + if (!filter.family || filter.family == AF_PACKET) { + if (read_maddr_netlink(AF_PACKET, &list) < 0) + read_dev_mcast(&list); + } if (!filter.family || filter.family == AF_INET) { if (read_maddr_netlink(AF_INET, &list) < 0) read_igmp(&list); -- 2.56.1.839.g22a8290db9-goog