Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2 v2 0/2]
@ 2026-11-16 11:09 Kurt Van Dijck
  2026-11-16 11:09 ` [PATCH iproute2 1/2] ip address: allow labeled proto arguments Kurt Van Dijck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kurt Van Dijck @ 2026-11-16 11:09 UTC (permalink / raw)
  To: netdev

Current implementation of address protocols in iproute2 allow to add
them, and iproute2 will show them, but you cannot use them to really filter.
These 2 patches fix 2 shortcomings of current iproute2's 'proto' parameter
handling:
1/2: allow to use labels from rt_addrprotos tables
2/2: treat addresses with no addrproto as PROTO_UNSPEC

Original patch series: https://lore.kernel.org/netdev/20261113123200.17784-1-dev.kurt@vandijck-laurijssen.be/

Changes in v2:
* improved explanation in commits
* cover letter


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH iproute2 1/2] ip address: allow labeled proto arguments
  2026-11-16 11:09 [PATCH iproute2 v2 0/2] Kurt Van Dijck
@ 2026-11-16 11:09 ` Kurt Van Dijck
  2026-11-16 11:09 ` [PATCH iproute2 2/2] ip address: proto filters rejects items without proto Kurt Van Dijck
  2026-11-16 18:00 ` [PATCH iproute2 v2 0/2] patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kurt Van Dijck @ 2026-11-16 11:09 UTC (permalink / raw)
  To: netdev; +Cc: Kurt Van Dijck

'ip address add' allows to use labels from rt_addrproto table.
Allow 'ip address list' to use the same list.

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
 ip/ipaddress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index ff85792f..e9d9c2e5 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -2231,7 +2231,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 			__u8 proto;
 
 			NEXT_ARG();
-			if (get_u8(&proto, *argv, 0))
+			if (rtnl_addrprot_a2n(&proto, *argv))
 				invarg("\"proto\" value is invalid\n", *argv);
 			filter.have_proto = true;
 			filter.proto = proto;
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH iproute2 2/2] ip address: proto filters rejects items without proto
  2026-11-16 11:09 [PATCH iproute2 v2 0/2] Kurt Van Dijck
  2026-11-16 11:09 ` [PATCH iproute2 1/2] ip address: allow labeled proto arguments Kurt Van Dijck
@ 2026-11-16 11:09 ` Kurt Van Dijck
  2026-11-16 18:00 ` [PATCH iproute2 v2 0/2] patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kurt Van Dijck @ 2026-11-16 11:09 UTC (permalink / raw)
  To: netdev; +Cc: Kurt Van Dijck

When selecting addresses with 'proto <VALUE>',
treat addresses without a proto value as IFAPROT_UNSPEC.

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
---
 ip/ipaddress.c           | 19 ++++++++++++++++---
 man/man8/ip-address.8.in |  5 +++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index e9d9c2e5..4a4a87d9 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1542,9 +1542,13 @@ int print_addrinfo(struct nlmsghdr *n, void *arg)
 
 	if (filter.family && filter.family != ifa->ifa_family)
 		return 0;
-	if (filter.have_proto && rta_tb[IFA_PROTO] &&
-	    filter.proto != rta_getattr_u8(rta_tb[IFA_PROTO]))
-		return 0;
+	if (filter.have_proto) {
+		__u8 proto = rta_tb[IFA_PROTO] ?
+			rta_getattr_u8(rta_tb[IFA_PROTO]) : IFAPROT_UNSPEC;
+
+		if (filter.proto != proto)
+			return 0;
+	}
 
 	if (ifa_label_match_rta(ifa->ifa_index, rta_tb[IFA_LABEL]))
 		return 0;
@@ -1929,6 +1933,15 @@ static void ipaddr_filter(struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo)
 			if ((filter.flags ^ ifa_flags) & filter.flagmask)
 				continue;
 
+			if (filter.have_proto) {
+				__u8 proto = tb[IFA_PROTO] ?
+					rta_getattr_u8(tb[IFA_PROTO]) :
+					IFAPROT_UNSPEC;
+
+				if (filter.proto != proto)
+					continue;
+			}
+
 			if (ifa_label_match_rta(ifa->ifa_index, tb[IFA_LABEL]))
 				continue;
 
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
index 79942c1a..55cb7e63 100644
--- a/man/man8/ip-address.8.in
+++ b/man/man8/ip-address.8.in
@@ -449,8 +449,9 @@ This is an alias for
 
 .TP
 .BI proto " ADDRPROTO"
-Only show addresses with a given protocol, or those for which the kernel
-response did not include protocol. See the corresponding argument to
+Only show addresses with a given protocol. Addresses for which the kernel
+response did not include protocol are considered to have protocol 0. See the
+corresponding argument to
 .B ip address add
 for details about address protocols.
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2 v2 0/2]
  2026-11-16 11:09 [PATCH iproute2 v2 0/2] Kurt Van Dijck
  2026-11-16 11:09 ` [PATCH iproute2 1/2] ip address: allow labeled proto arguments Kurt Van Dijck
  2026-11-16 11:09 ` [PATCH iproute2 2/2] ip address: proto filters rejects items without proto Kurt Van Dijck
@ 2026-11-16 18:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-16 18:00 UTC (permalink / raw)
  To: Kurt Van Dijck; +Cc: netdev

Hello:

This series was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Mon, 16 Nov 2026 12:09:37 +0100 you wrote:
> Current implementation of address protocols in iproute2 allow to add
> them, and iproute2 will show them, but you cannot use them to really filter.
> These 2 patches fix 2 shortcomings of current iproute2's 'proto' parameter
> handling:
> 1/2: allow to use labels from rt_addrprotos tables
> 2/2: treat addresses with no addrproto as PROTO_UNSPEC
> 
> [...]

Here is the summary with links:
  - [iproute2,1/2] ip address: allow labeled proto arguments
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=e7ea8f74e81a
  - [iproute2,2/2] ip address: proto filters rejects items without proto
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=75fc1c7d6d19

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-16 18:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 11:09 [PATCH iproute2 v2 0/2] Kurt Van Dijck
2026-11-16 11:09 ` [PATCH iproute2 1/2] ip address: allow labeled proto arguments Kurt Van Dijck
2026-11-16 11:09 ` [PATCH iproute2 2/2] ip address: proto filters rejects items without proto Kurt Van Dijck
2026-11-16 18:00 ` [PATCH iproute2 v2 0/2] patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox