From patchwork Fri Jan 17 03:20:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yuyang Huang X-Patchwork-Id: 13942796 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 40D5725A645 for ; Fri, 17 Jan 2025 03:21:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737084061; cv=none; b=fri26O7gPXgD3nsbsohTk0udeYgKd7VfHzqXzySB57V8Yn4qBNRiAOs5p+AuK+BcMsc7c3rckJoVAltoYx432cf6qIHCzzd7hpAh8xv1StsiHXtnbkux54CTNiWE9PtPT2QfLM9LkX3Kb3ByiMYpvtgWNnz/q7uSOR4WMNL3ZQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737084061; c=relaxed/simple; bh=+Z331O+dwQFWIfcz5y6k24mU9VksTk0u1PlmkGD/l2g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dAuXn7DiX7ZrlF2K5ct9UfRq0+kGjiyCjKPk13Wxj+02hKFlkcB7xBPVvCyLK9UhPYSPA7y4ieJIxniFxdR5RDHhhd+LIKrMBJYW9LS2MLB8tGTHwRqi6L0j1EQ8dRHKEhZ+/an2sO328yqLUl1Zm+n+8bt2QakqrQJmhZAG08I= 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=2drVUrQ6; arc=none smtp.client-ip=209.85.214.201 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="2drVUrQ6" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2165433e229so34503895ad.1 for ; Thu, 16 Jan 2025 19:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737084059; x=1737688859; 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=0If6DrQeE2EZRsaz5JFRc6xigp6fj64mwTYgrUT4HIQ=; b=2drVUrQ6LQM4QaEdyrOutM0f/YOsdgwXwzTBNnU9CnHZ5BCTk+Rr1YUoWpg9GYfHuG LunGIVEF1aqdiLPK9B7KZjQ9SiDrwhsYrpa/jQpY3YWz8kqQ/dU2Imzd1vjfHuR3mu66 1dWX9Yy0bhBVQ0EQDk9wrrlyASkvbYDOfhmaUhpYTnNpB51CSV+trblu+AgvxlSARiv3 3kNrR0n7bXTtp0Lv32rzg2bXpdAtUFKSJsmv+sd1A4idAuQ2AZQkb9lB2EOXiyQ309PJ X/LGh9UE+H1bbArzTcXggdh6yetlYvf9TxwKQvyEiKTdp0USs4OWMwua7gJVkLK8fPcs 9lrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737084059; x=1737688859; 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=0If6DrQeE2EZRsaz5JFRc6xigp6fj64mwTYgrUT4HIQ=; b=d5tgWBU5R9KeaISQ2SGGAOr3v7GRNcmnsuT+4xqDMBDz827G/FOhNeQXdCaNyVunhE gguMuox2GfBjjgPFwW8xqz55h9hXyvGPNLw26UBegZiksMwc0w+3iYwhSZGwc0ACZLjl HUZwX560DYnnHhtKWmeTAzEmD40cpFXlbfGNqM9Au+6vLcHg3j7PZ5hhGku1dkOEsu98 qPhxFtaT6DhtwLcT3bMb/EazOSEU7+W4xZ5WULN8IC6yidwUkoONp38A5XmHZ9wcHFuw 1zU2fRhx8vlKxGivYXKuijL3TpK2O2ORf9dBljrpp0aim4dm1VcXfnUW2Em9GeURHPwI 52SA== X-Forwarded-Encrypted: i=1; AJvYcCVbxtqydL1b2aZXlKDZO+F14kwEuflN0/6fevt5+aKwBNDgeyvxt+iN9W1Dz/yp8TtdxQDy7yU=@vger.kernel.org X-Gm-Message-State: AOJu0YzA14mDu4q+K8e5tjONKYuimNL6lpZBAkrYcYdeuAbrI85BFgn6 xKlPx0H6UY1eBAqAlRMdNwPkWBldpv631bOEGj+Dx/MRCzh4JmxT28hQj/dGWdF3EqBWBoYm9rI Wf9lysIopm/+XCxCApE+nTQ== X-Google-Smtp-Source: AGHT+IGZcxsDb0OZPKHVMFp2fk/r5ltq1LP9/dPoWC13s1iH1d515VWpf6ObJXBoJoyf8W7gxFYqOVhsXrSig9QYpw== X-Received: from pgbbw35.prod.google.com ([2002:a05:6a02:4a3:b0:7fd:581a:dbd5]) (user=yuyanghuang job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:b72f:b0:1e6:b2d7:4cf0 with SMTP id adf61e73a8af0-1eb215fb5d5mr1421010637.41.1737084059610; Thu, 16 Jan 2025 19:20:59 -0800 (PST) Date: Fri, 17 Jan 2025 12:20:40 +0900 In-Reply-To: <20250117032041.28124-1-yuyanghuang@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250117032041.28124-1-yuyanghuang@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250117032041.28124-2-yuyanghuang@google.com> Subject: [PATCH RESEND 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 , netdev@vger.kernel.org, " =?utf-8?q?Mac?= =?utf-8?q?iej_=C5=BBenczykowski?= " , 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 478c9d83..6c652145 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, @@ -781,6 +785,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 Fri Jan 17 03:20:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yuyang Huang X-Patchwork-Id: 13942797 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 8861F15852E for ; Fri, 17 Jan 2025 03:21:04 +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=1737084066; cv=none; b=ZDYgtn/MxRV+keet6D8EPMyzqVNeREkKZ+VNpG11/WCvg5Egl7+XtQcQUIAgW4o8jEQs5extVze/lwM5a+YZSSui3FutGjI0MPAWEERfpxAuwuWNpUW59kb1igoQLUkQQ9O1D7M/QqVZt0ZTzOWpKFmKV3FwK5Ig9ZQlmd74r2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737084066; c=relaxed/simple; bh=JvIyAuBydC5IAJguV7aMVKBZwkO41750fj3I/avcWZI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SrMz5eju/ikS4AUZ9JlCaeBUO1k0nv2UqdZ9kisG8HTCQi63YhbwOmO+pRDH28hPmRuKLG7o1sbxQMJ7JRWzQigBFMW+fLCxj51MhkCf3dcR4AFxzauC7gpangUcpyvICYWbyrF0lezR3Vz3hA+RXpxtEUlTx+dGM7NgFPvkmHM= 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=2k/u/DsV; 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="2k/u/DsV" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ee8ced572eso3382332a91.0 for ; Thu, 16 Jan 2025 19:21:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737084064; x=1737688864; 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=G5veukhpj4uZXGaHUg2R7rO4ahGvmkNOdHypTdSvIys=; b=2k/u/DsVfmet6ZfGDNWhGEwUwUuE/CZzOp2QQPBiY7C/pv7yuTQWmeElv+zBOkdS2I mnGPnIeFLR1HN692sjUT//3mHBYHq9kH2JQPAvSqz02UWwu7jhTPwZzEfmsliOa9zWK0 r6btAjyckTuzUQyCZXtcrCWS7LBWR2N/EPrPLGRtWonWAlME0pS5TvgwvTF3E97XwvLx vNEN71dnXhC81P3i8iEGd4ld5WM4uaiRpne8P7m7iqcEYW++lexPmqjmeCltaWP2LFWQ sEzBMDRVgWAHSZKYaYolrPPiGmVdE76Jjr36zZVlPOuu+hOPCW1jis5QsVpIJ1937/nZ JE3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737084064; x=1737688864; 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=G5veukhpj4uZXGaHUg2R7rO4ahGvmkNOdHypTdSvIys=; b=cJFPqQaiFAdtICAfAW9DOqj/TEyzd1Gi3A7tTWldSbdby3HwWu7KFXwRs6SWIV866J tQANbDtxzZsanTqPTymcHgh1Snx5gF+XKx2HmnoN9wCjhWYX7paCiCoBdeSU0WF/+Hmj b7M2zawB+VKIk2lRhBMnX3J3Wh15mH4PSFV2uFYDK3k53KCJ5pjsOMmC/aomO4BncvGg DAmC5LCFuw3nEq8osmpi/QOLmbLhUkkCQDmW1iCOm0c0eZcKbn/FeDFNwicnB/q3iJ08 ddn1nUFpeKhTJ6jdXiC/XmM6SPgg58rsztQC2wOCRQwV6XZOz1rV2mTDBGMY1sm9ADyz N62A== X-Forwarded-Encrypted: i=1; AJvYcCXo5KwM35Z2o315wHfpKxUoRr0qpacJfsS5dFouOGOUxrIg8LZq88+hswc49WfekTxPUhTJp0Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzdA9yw3I0eykLu2IlcxuXzAjmS2mDe0bkKEK67HaPn14rWRR2U u/xwt+C6sWldMbUOjwS0sJLKAXHDVDV7NcIkcuC3/OXNZjPshg3fiR6zYMNHglyr7Tc38xFjrsi FsEerbi9mYK/3N3e1HUSbVQ== X-Google-Smtp-Source: AGHT+IEcD+Q/JGIec65s7xCFmjFn8F6w5dVFiye0MfGVJY6X5owQRvrJi6FtfWADENrBS2ZnnWQ9m3MCnbKsP3CxAQ== X-Received: from pjbsh1.prod.google.com ([2002:a17:90b:5241:b0:2ee:4b69:50e1]) (user=yuyanghuang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:e18f:b0:2ee:693e:ed7a with SMTP id 98e67ed59e1d1-2f782d8651amr1448319a91.35.1737084063752; Thu, 16 Jan 2025 19:21:03 -0800 (PST) Date: Fri, 17 Jan 2025 12:20:41 +0900 In-Reply-To: <20250117032041.28124-1-yuyanghuang@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250117032041.28124-1-yuyanghuang@google.com> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog Message-ID: <20250117032041.28124-3-yuyanghuang@google.com> Subject: [PATCH RESEND 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 , netdev@vger.kernel.org, " =?utf-8?q?Mac?= =?utf-8?q?iej_=C5=BBenczykowski?= " , 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,