From patchwork Sun Dec 22 01:05:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yuyang Huang X-Patchwork-Id: 13917959 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 47EF628F4 for ; Sun, 22 Dec 2024 01:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734829555; cv=none; b=ZaQyAs3WLw8gJ7Ru+arm80JzDJqD59Zw3uaKTQ/DfDZs6tatBuutfXJ3wB945zjQgk8eA2p78kaIsP+e+zjGsgirYcxfC6pwx9zL9vHwYzz/NX5NveB7BCnG1OhaGcJnJ738VXXCCcmi6t5YEVzPsie68R1fPBC5hQeQndbgVHg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734829555; c=relaxed/simple; bh=ykHqtnrOUM43vFoKo0w69pPswU0xfasFdMqcpH0S+qI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=RHj5L+yJsTVH9FjwtXP+oMxDIPZbCGJjCxVJSM3MUvFh0gHSk/uEG7uSm8eKzjjQ5Rv3+w6eyKW8DhkbznIYe2tqAY4JGOQ8tAxDYDpODjAYIzR317Iey0sp6ymKVdVaa6UYbEaSw1OsEfOBUAXt5mSCdaHAuMa6MplhbvIykYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yuyanghuang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=04EMcE9o; arc=none smtp.client-ip=209.85.216.74 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.b="04EMcE9o" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef7fbd99a6so2756049a91.1 for ; Sat, 21 Dec 2024 17:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734829553; x=1735434353; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=ci72wKlVPSJOABEt4uTAfJhgxKeP2GzBpC5K4QDLH3M=; b=04EMcE9ofLqw9+swxI71wWqK1rPwdXW4A7vHVSKwnEdXJWyewmSsSfeuz5lRHfSAaX m0u+f8mHJemTAl3l2hBJtBgyDyAsqDoxcHi8We1kNzAx695762ekFSwlZ0D4aufVfcyd bF9N6f3uh7UkkOlWyZg858fUj5L703eFuGUkFj9E1KVamXtjJGKFIiGiqr9T3wzrpph+ DaG47+ZEOjSpt0oKF7Odn+6X1rRRZEWLcBA1U/w0+nkqL9EJpwgp9u64r7TtDUgYWnVC IH05dsCaFoLMzptj4mBAusfd6/44twcDrO63djWcziK1hxYbO1xhG6pL/Z0vzJmwajfi 6Ymg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734829553; x=1735434353; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ci72wKlVPSJOABEt4uTAfJhgxKeP2GzBpC5K4QDLH3M=; b=h+kX/KaCv+P46JBrfJpsrr+O5n2zPVXfnD5EpXwr79OGjHR8qTNKKr3bmghT6fnyvd LTDBPE7heAYCUw+8oMOo1fgoD+a6ROGzbEjeVxXSPE2py3RSa4MsmdWm5ZP8uVEsZ/Qy OmlNy1CzEx3MPmJHoqIVgj5wA0VTWUqVPoBsoyHWrNHFhWB8moYeBKb52EDRmxNv6KGz FPg3d8VWtOUrGh/b6Ne/DQXKfjB6fK2GEyoUL8n8fDJ8p5N5nAZ9xtfFDpi0FBaoStOi +75wFRCK4B7TRpma3+Nn+jQFSAbMTNz5OK0RwbGMCUrIZJtfPEzYFZI1SdknmZ/Afb+C Y+VQ== X-Forwarded-Encrypted: i=1; AJvYcCXtAxmfUgYCSFv3EUfo4heWp08k1GN6foqfRlDMQbws9QzWghsXhFLKnTuRWrZp4Y6fWrrCtW8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+Ea5rfASTjuGb9hAshP5pSFpCFxvV540roIfMuk93214PDO6x n8DeMabNSUSkBzG5kbswWpZbtRBPsN1wxJ2nGde7bWuirzmF+P0kN6er/YODHW10LHuWB16ajj7 XkBGYTUsIk+JNDqdE4LxsrQ== X-Google-Smtp-Source: AGHT+IFifdA5nn3jegLimpEltuuCvJABgIT8Sry/mjioQhiOf6NIamBsa3NpjeQerEd0pONkvZ/McT3zdF5HP+FC5A== X-Received: from pjj11.prod.google.com ([2002:a17:90b:554b:b0:2ef:6ef8:6567]) (user=yuyanghuang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:54cb:b0:2ee:ba84:5cac with SMTP id 98e67ed59e1d1-2f452dfd2eamr12759602a91.7.1734829553613; Sat, 21 Dec 2024 17:05:53 -0800 (PST) Date: Sun, 22 Dec 2024 10:05:47 +0900 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241222010548.2304540-1-yuyanghuang@google.com> Subject: [PATCH iproute2-next 1/2] iproute2: expose anycast netlink constants in UAPI From: Yuyang Huang To: Yuyang Huang Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , David Ahern , roopa@cumulusnetworks.com, jiri@resnulli.us, stephen@networkplumber.org, jimictw@google.com, prohr@google.com, liuhangbin@gmail.com, nicolas.dichtel@6wind.com, andrew@lunn.ch, netdev@vger.kernel.org, " =?utf-8?q?Maciej_=C5=BBenczykow?= =?utf-8?q?ski?= " , Lorenzo Colitti X-Patchwork-Delegate: dsahern@gmail.com This change adds the following anycast related netlink constants to the UAPI: * RTNLGRP_IPV6_ACADDR: Netlink multicast groups for IPv6 anycast address changes. * RTM_NEWANYCAST and RTM_DELANYCAST: Netlink message types for anycast address additions and deletions. Cc: Maciej Żenczykowski Cc: Lorenzo Colitti Signed-off-by: Yuyang Huang --- include/uapi/linux/rtnetlink.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h index 458e5670..1d074add 100644 --- a/include/uapi/linux/rtnetlink.h +++ b/include/uapi/linux/rtnetlink.h @@ -100,7 +100,11 @@ enum { RTM_GETMULTICAST, #define RTM_GETMULTICAST RTM_GETMULTICAST - RTM_GETANYCAST = 62, + RTM_NEWANYCAST = 60, +#define RTM_NEWANYCAST RTM_NEWANYCAST + RTM_DELANYCAST, +#define RTM_DELANYCAST RTM_DELANYCAST + RTM_GETANYCAST, #define RTM_GETANYCAST RTM_GETANYCAST RTM_NEWNEIGHTBL = 64, @@ -780,6 +784,8 @@ enum rtnetlink_groups { #define RTNLGRP_IPV4_MCADDR RTNLGRP_IPV4_MCADDR RTNLGRP_IPV6_MCADDR, #define RTNLGRP_IPV6_MCADDR RTNLGRP_IPV6_MCADDR + RTNLGRP_IPV6_ACADDR, +#define RTNLGRP_IPV6_ACADDR RTNLGRP_IPV6_ACADDR __RTNLGRP_MAX }; #define RTNLGRP_MAX (__RTNLGRP_MAX - 1) From patchwork Sun Dec 22 01:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yuyang Huang X-Patchwork-Id: 13917960 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 2D336A35 for ; Sun, 22 Dec 2024 01:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734829560; cv=none; b=uERiL0QlrDNfvnmbfRmYNovTTgl37EA8gCMD0xLk0/yxbVZPtrCTy0UGaMKzQ8nK+rU0EpJ0opsoMspJgQpiF0XtdSwBTY3xDLRNi3Sa+VLXhvGMf9aFJ+ikJWM0gIQtpbdSKaA4kG0McWqChyWMzgoyUh7WbJpmIApGGL79iyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734829560; c=relaxed/simple; bh=+qGrks+uyLQLas9NBDcBG4u9F439P7UZtFfqWBV1bac=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=HajR9FBXfVyPqlRCyQ9jPo0MQXWw3fQoCV+qOiVZUaW8SafhQNOSx9octQQHQgc4NkdP1yFWDr+BMrscKaWET+PnayeF805O9OQcosoZkXP91h2RCcco7RVn43unfj1NCcVY15YbdQbuWF9zcqI0Ci/I9Ih3qLcLkWwipLSPrVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yuyanghuang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=0C9Cdijl; arc=none smtp.client-ip=209.85.210.202 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.b="0C9Cdijl" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-728eda1754eso4235557b3a.2 for ; Sat, 21 Dec 2024 17:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734829558; x=1735434358; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=YawHiG3JIeegYRVjqdd7y7CVotwKx+gKxbQBIqJzU0o=; b=0C9CdijlAryFnBkorcN5oFm6IgOhqDk8PSHeHfG0tNJ5rAF5y35lqjitOS8Pq4EWO7 87qHRlXrICtRu0xsNFYKF8tW0jhFYu/2KubpiNeV8WSInkAJ2Z3AyEqYqL2/bXmcL0k5 53yFGoEyvy7yEAQQk0qaKy1VL/lMoIaLXD+v3lvLss3iLcyAHQ49N3goJqy3B++T1HAu JOK1Uo9nCYnUEVsbvfA1DhMLXtdyl9D7LCdSGGgJqWXZ6kq8DFxkXLnZJ/1ZTl0tmpo6 3NMcyTwN5Rl09IFjys/KwlNDf73+Q62cCwGG8fCDQIoAKLj00k+QKq78iywzZX4w/FpQ X8cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734829558; x=1735434358; h=content-transfer-encoding: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; bh=YawHiG3JIeegYRVjqdd7y7CVotwKx+gKxbQBIqJzU0o=; b=vv6stJRnMM22t114H0PeDt7rdjp++aPg/Q+ZyMG32lnr7ZVPT0ZnZdysXy4fVX8rDn FGeJIVG4ZLJXl7K/dZW/d7ASWMSkxgZyLuMrI8LZ9HlYX84twV5+ct6s/qFgnn4nMWxW 8beRWnz6gIVH4iCYOEWwCPvCMUFx/s67YQTfVY75WGrSQGX5zLW6QqnZfsKNLB77B7kp heGchurp1f3i6Pyi2KUuJOrH4x84MQIBhh5o/ICXsI/i9aJ6qigUwmiA4Bptd5M/OyYK fmP/aaehiP20OPS955YMz7ZNq2IkSvjH7iV9//uUaDQo8wp4OaBx/MWbUkmYSn/cAPvg VFHg== X-Forwarded-Encrypted: i=1; AJvYcCVOja25Ypg5Lxy0YubYaphOR8VG9WeG2iJ9jIahCKoqyeKTkGB1ztezJY+QCKCqtfAbZQgGjqU=@vger.kernel.org X-Gm-Message-State: AOJu0YwtnHzvYL8pv4/FA3NNRSZsgUR80p5MynveCI8AgKHVWwFj8xGN ueikQGuDjnGqQFr/8VRHYbIldmJCy4tlNsvlKIo5vMybhptqnbC0jFN8Rp2zrCM19ouuWLZtA/k OKV6e910OC1cfVUYnBAgD3A== X-Google-Smtp-Source: AGHT+IFjiSJ0FTZv8Ho4KY6EjLk2tByZnqElXOjNvddlOXI2nWtmpEUT3S/brwoIIroHIaki47BpHZ3m2yoMNMeeiA== X-Received: from pfbds10.prod.google.com ([2002:a05:6a00:4aca:b0:725:defb:79b1]) (user=yuyanghuang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:a91:b0:726:c23f:4e5c with SMTP id d2e1a72fcca58-72abdd20f88mr11526283b3a.1.1734829558338; Sat, 21 Dec 2024 17:05:58 -0800 (PST) Date: Sun, 22 Dec 2024 10:05:48 +0900 In-Reply-To: <20241222010548.2304540-1-yuyanghuang@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241222010548.2304540-1-yuyanghuang@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Message-ID: <20241222010548.2304540-2-yuyanghuang@google.com> Subject: [PATCH iproute2-next 2/2] iproute2: add 'ip monitor acaddress' support From: Yuyang Huang To: Yuyang Huang Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , David Ahern , roopa@cumulusnetworks.com, jiri@resnulli.us, stephen@networkplumber.org, jimictw@google.com, prohr@google.com, liuhangbin@gmail.com, nicolas.dichtel@6wind.com, andrew@lunn.ch, netdev@vger.kernel.org, " =?utf-8?q?Maciej_=C5=BBenczykow?= =?utf-8?q?ski?= " , Lorenzo Colitti X-Patchwork-Delegate: dsahern@gmail.com Enhanced the 'ip monitor' command to track changes in IPv6 anycast addresses. This update allows the command to listen for events related to anycast address additions and deletions by registering to the newly introduced RTNLGRP_IPV6_ACADDR netlink group. This patch depends on the kernel patch that adds RTNLGRP_IPV6_ACADDR being merged first. Here is an example usage: root@uml-x86-64:/# ip monitor acaddress 2: if2 inet6 any 2001:db8:7b:0:528e:a53a:9224:c9c5 scope global valid_lft forever preferred_lft forever Deleted 2: if2 inet6 any 2001:db8:7b:0:528e:a53a:9224:c9c5 scope global valid_lft forever preferred_lft forever Cc: Maciej Żenczykowski Cc: Lorenzo Colitti Signed-off-by: Yuyang Huang --- ip/ipaddress.c | 8 ++++++-- ip/ipmonitor.c | 18 ++++++++++++++++-- man/man8/ip-monitor.8 | 5 +++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 679b4c00..70b3d513 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -1507,7 +1507,9 @@ int print_addrinfo(struct nlmsghdr *n, void *arg) if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR && n->nlmsg_type != RTM_NEWMULTICAST && - n->nlmsg_type != RTM_DELMULTICAST) + n->nlmsg_type != RTM_DELMULTICAST && + n->nlmsg_type != RTM_NEWANYCAST && + n->nlmsg_type != RTM_DELANYCAST) return 0; len -= NLMSG_LENGTH(sizeof(*ifa)); if (len < 0) { @@ -1567,7 +1569,9 @@ int print_addrinfo(struct nlmsghdr *n, void *arg) print_headers(fp, "[ADDR]"); - if (n->nlmsg_type == RTM_DELADDR || n->nlmsg_type == RTM_DELMULTICAST) + if (n->nlmsg_type == RTM_DELADDR || + n->nlmsg_type == RTM_DELMULTICAST || + n->nlmsg_type == RTM_DELANYCAST) print_bool(PRINT_ANY, "deleted", "Deleted ", true); if (!brief) { diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c index b28faa20..eec48d83 100644 --- a/ip/ipmonitor.c +++ b/ip/ipmonitor.c @@ -30,8 +30,8 @@ static void usage(void) fprintf(stderr, "Usage: ip monitor [ all | OBJECTS ] [ FILE ] [ label ] [ all-nsid ]\n" " [ dev DEVICE ]\n" - "OBJECTS := address | link | mroute | maddress | neigh | netconf |\n" - " nexthop | nsid | prefix | route | rule | stats\n" + "OBJECTS := address | link | mroute | maddress | acaddress | neigh |\n" + " netconf | nexthop | nsid | prefix | route | rule | stats\n" "FILE := file FILENAME\n"); exit(-1); } @@ -154,6 +154,8 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl, case RTM_DELMULTICAST: case RTM_NEWMULTICAST: + case RTM_DELANYCAST: + case RTM_NEWANYCAST: print_addrinfo(n, arg); return 0; @@ -184,6 +186,7 @@ static int accept_msg(struct rtnl_ctrl_data *ctrl, #define IPMON_LNSID BIT(9) #define IPMON_LNEXTHOP BIT(10) #define IPMON_LMADDR BIT(11) +#define IPMON_LACADDR BIT(12) #define IPMON_L_ALL (~0) @@ -210,6 +213,8 @@ int do_ipmonitor(int argc, char **argv) lmask |= IPMON_LADDR; } else if (matches(*argv, "maddress") == 0) { lmask |= IPMON_LMADDR; + } else if (matches(*argv, "acaddress") == 0) { + lmask |= IPMON_LACADDR; } else if (matches(*argv, "route") == 0) { lmask |= IPMON_LROUTE; } else if (matches(*argv, "mroute") == 0) { @@ -349,6 +354,15 @@ int do_ipmonitor(int argc, char **argv) } } + if (lmask & IPMON_LACADDR) { + if ((!preferred_family || preferred_family == AF_INET6) && + rtnl_add_nl_group(&rth, RTNLGRP_IPV6_ACADDR) < 0) { + fprintf(stderr, + "Failed to add ipv6 acaddr group to list\n"); + exit(1); + } + } + if (listen_all_nsid && rtnl_listen_all_nsid(&rth) < 0) exit(1); diff --git a/man/man8/ip-monitor.8 b/man/man8/ip-monitor.8 index a3c099ae..6cb585ba 100644 --- a/man/man8/ip-monitor.8 +++ b/man/man8/ip-monitor.8 @@ -54,8 +54,9 @@ command is the first in the command line and then the object list follows: .I OBJECT-LIST is the list of object types that we want to monitor. It may contain -.BR link ", " address ", " route ", " mroute ", " maddress ", " prefix ", " -.BR neigh ", " netconf ", " rule ", " stats ", " nsid " and " nexthop "." +.BR link ", " address ", " route ", " mroute ", " maddress ", " acaddress ", " +.BR prefix ", "neigh ", " netconf ", " rule ", " stats ", " nsid " and " +.BR nexthop "." If no .B file argument is given,