From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796065879; b=eXTrL/vTwjrsXl1CvQsFfqFHv5MWFAajpuC8ufmTSJr3638vJbSbT4imB9txb8dY4+HS ocOLuW30ZeNk86tbkd8KeFiZySd+mUIzKGWXGGnoHoTuu3Kf2FcI9R+C0YtWuQUqrSskb d+ZkttQcB5i2yx9aj1E2CwlfvRKbmITuGdqCFQsC1nk8+DjXVYSsbRv2ZnnHMeS5idpux Zsn7oGyx2kXrzmqnH+SjGzRu4buKND4VwOd7mAzXqo7vEZNy7h7LIWJKZi1cV2X3x5ryT agirhb2kTG6BxiBKJmmChTp0Zz1L2u+9Py3Rm/nZAHMA/AuiB5aUpZNO0O28DvjWsKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796065879; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=JfrUO95LIQuJSUyWIxV9sGxvgUH3og21ncWT67tSA2I=; b=DDsD/DfDKrb2i/H7J0f6CI/zBtOpHMSqvEssBhroiCDV4v2KetlrwoCoJVHc5YigmUBh Dn/xQcZlmIHtHtczu0gQdQWNMTpifDYV+vJ/ViQIrRz6oP3H36WsB2G4osegG6VCPJsqI SBQkOQt466uXtrjWofaus+YDziz9AyVoRCPvSJL2eo0yl3ikfqhX8gGOcMn8dJPatfQSQ 1OdWzISJjtF+4wha1U/XKCWmq7BZFyKdKlbvDcu+rDML1aTQYh5s3ZkouxbrrZe/mz0SD M+td2Ol7PWDEga9OUwsiTrTMxDkwuxdowTHH3pq7FpI2/iLMOYWaYJNLTIs95GlMVDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=networkplumber.org; spf=pass smtp.mailfrom=networkplumber.org; dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=dm7nW5uV; arc=none smtp.remote-ip=209.85.216.54 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 9D8FF606A31C for ; Mon, 30 Nov 2026 19:11:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9D8FF606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=dm7nW5uV Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3b44bdcea8aso6441355a91.1 for ; Mon, 30 Nov 2026 11:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796065878; x=1796670678; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JfrUO95LIQuJSUyWIxV9sGxvgUH3og21ncWT67tSA2I=; b=dm7nW5uV0QTjhl6Uu2R/c7B0hfOral0GooGWkwD//KHRMtRmBUUSX0X9UdFzjkMUZD jhtVzNVeCRGKTlFLNdlqBtdzgItKIh1P9IoFpLxPzTxBwRpqSI7/4NoHhcbg8SBfE6Z2 uTZBwrxboYf2OSOHQPTA9hmyCzERqquXhjMZkP+QkRUPHVl1uN6sN599o28xaF6pYt/7 FcGyvS8OWOuSHGMO/rTLk+dviRqCibXgaGXJPEtFq8sF4ysjWrJhw3DEuBN0agX0WHqm tUVpVPTCSUBM/WqjxiC2z7c1eEq3bJDYLnG56xv5U07sR2QEAKLRwX4vzps0dqM1r8rW 6VDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796065878; x=1796670678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JfrUO95LIQuJSUyWIxV9sGxvgUH3og21ncWT67tSA2I=; b=BDoZQYViPtVDYlHywHowROao5J5SRWpdgi8z76C1ytowf+ZFqmezRa0RNGtD6st1vr jeq2JjBg9AyKd9hKNQVFYLIfDP7NW7doAu0+qEiIGVVCDz26LvKXjkVtKhT/gla08RTp fcmTnNXix3REm9b0NXvG4M63lIpR2w1iC2oyNrs/7tnNNWVEqjwFZFLV3ORmEa0ZZqRs mHObHeyczTfdR3W4Lkxp0scJ4wLYV1rECHaPiob8o7lr+HiHOd08bUNnlzxDIKBb6d7f b4hUYv+gDBkJ2gEnCjD9ueYjwFPWWZr0rtE19M20VUg9+qlSuucJF/DEAl6Ucso1RMa8 IdWA== X-Gm-Message-State: APuU4Z8KdzqgeU9RxlY3F/DfK2ZM21rROgy4loYiTmYjGgmPt5NQ3ebd 6c1Hs9HOvhxTujfmOYgHWLFXiI9do0hwE1IcnkY5glHP287JJo7wYH8g8lAbthMFuNvMdlZnbkQ zraC7VtA= X-Gm-Gg: AZFdTZeVJvehxMd8eZCDKXMk1h9Os8W+sCKF3Eq+48/6VaRxLkzuvgqsL4ZOB37/q2l 8P1Yyl1pJnLv7vV9sn2+svL36QdrC47jjuPgLhQjM0iefNQd/jEU8r6RN68/gtOMZwDsAO/Hdr9 1XWh2pnumaAP6ik/BRrGjczkeLA8JV7KGSTJ19im199Fv6Gv7HFNHVElbVzvbWTtH16LtFrKMbF k0ubgRleYv7L71Q5vk1JJOAoqirx4abomzH6o65fOuNe+Qmev9M+gv4ibJ/zdNqkEd+2slmIHeF 4DDXLyVcTIe29IxNhXoBBrFodHv8EhTRKc6a5BfDOiFA6b/vjKX4PYH4/BClGGdQ/wVtdUPkpER 6vWwaG3qMa/WJykvEQ3AT9SpP7bYWs/+p6P99qi/Rtd64VzI9K7HigSmAlEhTivfT7aGby8fC8B QxXyAWtH36fV+1hsCknHbr8Dm+sopbm9iudoYb6d0hEzfwkkpqafwm5W7BmznzQp5sYkpEFVHTq PW8pk8JTEp/+4FwoGnbVFcYjY1hhv5unER4syZRj47qoz88eG+Bdmy8NIZm3g1gkCpIxvuZNH4c QkT9EDdxbKrf1szEH/I0gLrndRy6cY9jfep5EiYzsHG197RaJeOum+LU14za5wkRfajODXX8/G6 5boYsFKTRs/scIQ== X-Received: by 2002:a17:90b:4b85:b0:3ac:b6eb:e0de with SMTP id 98e67ed59e1d1-3b41c7bc5d5mr23649663a91.4.1796065877845; Mon, 30 Nov 2026 11:11:17 -0800 (PST) Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b40f4312dfsm55591195a91.3.2026.11.30.11.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 11:11:17 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: dsahern@kernel.org, Stephen Hemminger Subject: [PATCH iproute2-next 04/10] xfrm: rename local netlink handles that shadow the global rth Date: Mon, 30 Nov 2026 10:47:05 -0800 Message-ID: <20261130184752.545119-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130184752.545119-1-stephen@networkplumber.org> References: <20261130184752.545119-1-stephen@networkplumber.org> 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 Content-Transfer-Encoding: 8bit The xfrm commands open their own NETLINK_XFRM handle in a local named rth, shadowing the global rth declared in ip_common.h. Rename the locals to xrth. xfrm_state_keep() and xfrm_policy_keep() aliased xb->rth into a local rth used once; drop the alias and dereference xb->rth directly. Signed-off-by: Stephen Hemminger --- ip/xfrm_policy.c | 81 ++++++++++++++++++++++++------------------------ ip/xfrm_state.c | 69 ++++++++++++++++++++--------------------- 2 files changed, 74 insertions(+), 76 deletions(-) diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c index 5261a292..ea7e8c0c 100644 --- a/ip/xfrm_policy.c +++ b/ip/xfrm_policy.c @@ -227,7 +227,7 @@ int xfrm_sctx_parse(char *ctxstr, char *s, static int xfrm_policy_modify(int cmd, unsigned int flags, int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_userpolicy_info xpinfo; @@ -399,16 +399,16 @@ static int xfrm_policy_modify(int cmd, unsigned int flags, int argc, char **argv sizeof(xuo)); } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (req.xpinfo.sel.family == AF_UNSPEC) req.xpinfo.sel.family = AF_INET; - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } @@ -574,7 +574,7 @@ int xfrm_policy_print(struct nlmsghdr *n, void *arg) static int xfrm_policy_get_or_delete(int argc, char **argv, int delete, struct nlmsghdr **answer) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_userpolicy_id xpid; @@ -669,7 +669,7 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete, if (selp && indexp) duparg2("SELECTOR", "INDEX"); - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (req.xpid.sel.family == AF_UNSPEC) @@ -692,10 +692,10 @@ static int xfrm_policy_get_or_delete(int argc, char **argv, int delete, if (is_if_id_set) addattr32(&req.n, sizeof(req.buf), XFRMA_IF_ID, if_id); - if (rtnl_talk(&rth, &req.n, answer) < 0) + if (rtnl_talk(&xrth, &req.n, answer) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } @@ -727,7 +727,6 @@ static int xfrm_policy_get(int argc, char **argv) static int xfrm_policy_keep(struct nlmsghdr *n, void *arg) { struct xfrm_buffer *xb = (struct xfrm_buffer *)arg; - struct rtnl_handle *rth = xb->rth; struct xfrm_userpolicy_info *xpinfo = NLMSG_DATA(n); int len = n->nlmsg_len; struct rtattr *tb[XFRMA_MAX+1]; @@ -774,7 +773,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg) new_n->nlmsg_len = NLMSG_LENGTH(sizeof(*xpid)); new_n->nlmsg_flags = NLM_F_REQUEST; new_n->nlmsg_type = XFRM_MSG_DELPOLICY; - new_n->nlmsg_seq = ++rth->seq; + new_n->nlmsg_seq = ++xb->rth->seq; xpid = NLMSG_DATA(new_n); memcpy(&xpid->sel, &xpinfo->sel, sizeof(xpid->sel)); @@ -804,7 +803,7 @@ static int xfrm_policy_keep(struct nlmsghdr *n, void *arg) static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) { char *selp = NULL; - struct rtnl_handle rth; + struct rtnl_handle xrth; if (argc > 0 || preferred_family != AF_UNSPEC) filter.use = 1; @@ -872,7 +871,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) argc--; argv++; } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (deleteall) { @@ -882,7 +881,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) xb.buf = buf; xb.size = sizeof(buf); - xb.rth = &rth; + xb.rth = &xrth; for (i = 0; ; i++) { struct { @@ -892,7 +891,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) .n.nlmsg_len = NLMSG_HDRLEN, .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, .n.nlmsg_type = XFRM_MSG_GETPOLICY, - .n.nlmsg_seq = rth.dump = ++rth.seq, + .n.nlmsg_seq = xrth.dump = ++xrth.seq, }; xb.offset = 0; @@ -901,12 +900,12 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) if (show_stats > 1) fprintf(stderr, "Delete-all round = %d\n", i); - if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) { + if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) { perror("Cannot send dump request"); exit(1); } - if (rtnl_dump_filter(&rth, xfrm_policy_keep, &xb) < 0) { + if (rtnl_dump_filter(&xrth, xfrm_policy_keep, &xb) < 0) { fprintf(stderr, "Delete-all terminated\n"); exit(1); } @@ -916,7 +915,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) break; } - if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) { + if (rtnl_send_check(&xrth, xb.buf, xb.offset) < 0) { perror("Failed to send delete-all request"); exit(1); } @@ -934,21 +933,21 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall) .n.nlmsg_len = NLMSG_HDRLEN, .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, .n.nlmsg_type = XFRM_MSG_GETPOLICY, - .n.nlmsg_seq = rth.dump = ++rth.seq, + .n.nlmsg_seq = xrth.dump = ++xrth.seq, }; - if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) { + if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) { perror("Cannot send dump request"); exit(1); } - if (rtnl_dump_filter(&rth, xfrm_policy_print, stdout) < 0) { + if (rtnl_dump_filter(&xrth, xfrm_policy_print, stdout) < 0) { fprintf(stderr, "Dump terminated\n"); exit(1); } } - rtnl_close(&rth); + rtnl_close(&xrth); exit(0); } @@ -1045,7 +1044,7 @@ static int print_spdinfo(struct nlmsghdr *n, void *arg) static int xfrm_spd_setinfo(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; __u32 flags; @@ -1098,20 +1097,20 @@ static int xfrm_spd_setinfo(int argc, char **argv) argc--; argv++; } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } static int xfrm_spd_getinfo(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; __u32 flags; @@ -1123,16 +1122,16 @@ static int xfrm_spd_getinfo(int argc, char **argv) }; struct nlmsghdr *answer; - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); - if (rtnl_talk(&rth, &req.n, &answer) < 0) + if (rtnl_talk(&xrth, &req.n, &answer) < 0) exit(2); print_spdinfo(answer, (void *)stdout); free(answer); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } @@ -1167,7 +1166,7 @@ static char *xfrm_policy_to_str(uint8_t policy) static int xfrm_spd_setdefault(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_userpolicy_default up; @@ -1206,13 +1205,13 @@ static int xfrm_spd_setdefault(int argc, char **argv) argc--; argv++; } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } @@ -1239,7 +1238,7 @@ int xfrm_policy_default_print(struct nlmsghdr *n, FILE *fp) static int xfrm_spd_getdefault(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_userpolicy_default up; @@ -1250,23 +1249,23 @@ static int xfrm_spd_getdefault(int argc, char **argv) }; struct nlmsghdr *answer; - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); - if (rtnl_talk(&rth, &req.n, &answer) < 0) + if (rtnl_talk(&xrth, &req.n, &answer) < 0) exit(2); xfrm_policy_default_print(answer, (FILE *)stdout); free(answer); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } static int xfrm_policy_flush(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; char buf[RTA_BUF_SIZE]; @@ -1297,16 +1296,16 @@ static int xfrm_policy_flush(int argc, char **argv) (void *)&upt, sizeof(upt)); } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (show_stats > 1) fprintf(stderr, "Flush policy\n"); - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c index dcd08d59..db80a0e0 100644 --- a/ip/xfrm_state.c +++ b/ip/xfrm_state.c @@ -269,7 +269,7 @@ static void xfrm_dir_parse(__u8 *dir, int *argcp, char ***argvp) static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_usersa_info xsinfo; @@ -761,7 +761,7 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv) if (output_mark.m) addattr32(&req.n, sizeof(req.buf), XFRMA_SET_MARK_MASK, output_mark.m); - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (dir) { @@ -778,17 +778,17 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv) if (req.xsinfo.family == AF_UNSPEC) req.xsinfo.family = AF_INET; - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } static int xfrm_state_allocspi(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_userspi_info xspi; @@ -917,14 +917,14 @@ static int xfrm_state_allocspi(int argc, char **argv) if (pcpu_num != -1) addattr32(&req.n, sizeof(req.buf), XFRMA_SA_PCPU, pcpu_num); - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (req.xspi.info.family == AF_UNSPEC) req.xspi.info.family = AF_INET; - if (rtnl_talk(&rth, &req.n, &answer) < 0) + if (rtnl_talk(&xrth, &req.n, &answer) < 0) exit(2); if (xfrm_state_print(answer, (void *)stdout) < 0) { @@ -933,7 +933,7 @@ static int xfrm_state_allocspi(int argc, char **argv) } free(answer); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } @@ -1067,7 +1067,7 @@ static int xfrm_state_print_nokeys(struct nlmsghdr *n, void *arg) static int xfrm_state_get_or_delete(int argc, char **argv, int delete) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_usersa_id xsid; @@ -1118,19 +1118,19 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete) } } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (req.xsid.family == AF_UNSPEC) req.xsid.family = AF_INET; if (delete) { - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); } else { struct nlmsghdr *answer; - if (rtnl_talk(&rth, &req.n, &answer) < 0) + if (rtnl_talk(&xrth, &req.n, &answer) < 0) exit(2); if (xfrm_state_print(answer, (void *)stdout) < 0) { @@ -1141,7 +1141,7 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete) free(answer); } - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } @@ -1153,7 +1153,6 @@ static int xfrm_state_get_or_delete(int argc, char **argv, int delete) static int xfrm_state_keep(struct nlmsghdr *n, void *arg) { struct xfrm_buffer *xb = (struct xfrm_buffer *)arg; - struct rtnl_handle *rth = xb->rth; struct xfrm_usersa_info *xsinfo = NLMSG_DATA(n); int len = n->nlmsg_len; struct nlmsghdr *new_n; @@ -1188,7 +1187,7 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg) new_n->nlmsg_len = NLMSG_LENGTH(sizeof(*xsid)); new_n->nlmsg_flags = NLM_F_REQUEST; new_n->nlmsg_type = XFRM_MSG_DELSA; - new_n->nlmsg_seq = ++rth->seq; + new_n->nlmsg_seq = ++xb->rth->seq; xsid = NLMSG_DATA(new_n); xsid->family = xsinfo->family; @@ -1219,7 +1218,7 @@ static int xfrm_state_keep(struct nlmsghdr *n, void *arg) static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) { char *idp = NULL; - struct rtnl_handle rth; + struct rtnl_handle xrth; bool nokeys = false; if (argc > 0 || preferred_family != AF_UNSPEC) @@ -1261,7 +1260,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) argc--; argv++; } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (deleteall) { @@ -1271,7 +1270,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) xb.buf = buf; xb.size = sizeof(buf); - xb.rth = &rth; + xb.rth = &xrth; for (i = 0; ; i++) { struct { @@ -1281,7 +1280,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) .n.nlmsg_len = NLMSG_HDRLEN, .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, .n.nlmsg_type = XFRM_MSG_GETSA, - .n.nlmsg_seq = rth.dump = ++rth.seq, + .n.nlmsg_seq = xrth.dump = ++xrth.seq, }; xb.offset = 0; @@ -1290,12 +1289,12 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) if (show_stats > 1) fprintf(stderr, "Delete-all round = %d\n", i); - if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) { + if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) { perror("Cannot send dump request"); exit(1); } - if (rtnl_dump_filter(&rth, xfrm_state_keep, &xb) < 0) { + if (rtnl_dump_filter(&xrth, xfrm_state_keep, &xb) < 0) { fprintf(stderr, "Delete-all terminated\n"); exit(1); } @@ -1305,7 +1304,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) break; } - if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) { + if (rtnl_send_check(&xrth, xb.buf, xb.offset) < 0) { perror("Failed to send delete-all request\n"); exit(1); } @@ -1331,7 +1330,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) .n.nlmsg_len = NLMSG_HDRLEN, .n.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, .n.nlmsg_type = XFRM_MSG_GETSA, - .n.nlmsg_seq = rth.dump = ++rth.seq, + .n.nlmsg_seq = xrth.dump = ++xrth.seq, }; if (filter.xsinfo.id.proto) @@ -1340,20 +1339,20 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall) addattr_l(&req.n, sizeof(req), XFRMA_ADDRESS_FILTER, &addrfilter, sizeof(addrfilter)); - if (rtnl_send(&rth, (void *)&req, req.n.nlmsg_len) < 0) { + if (rtnl_send(&xrth, (void *)&req, req.n.nlmsg_len) < 0) { perror("Cannot send dump request"); exit(1); } - rtnl_filter_t filter = nokeys ? + rtnl_filter_t dump_filter = nokeys ? xfrm_state_print_nokeys : xfrm_state_print; - if (rtnl_dump_filter(&rth, filter, stdout) < 0) { + if (rtnl_dump_filter(&xrth, dump_filter, stdout) < 0) { fprintf(stderr, "Dump terminated\n"); exit(1); } } - rtnl_close(&rth); + rtnl_close(&xrth); exit(0); } @@ -1409,7 +1408,7 @@ static int print_sadinfo(struct nlmsghdr *n, void *arg) static int xfrm_sad_getinfo(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; __u32 flags; @@ -1421,23 +1420,23 @@ static int xfrm_sad_getinfo(int argc, char **argv) }; struct nlmsghdr *answer; - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); - if (rtnl_talk(&rth, &req.n, &answer) < 0) + if (rtnl_talk(&xrth, &req.n, &answer) < 0) exit(2); print_sadinfo(answer, (void *)stdout); free(answer); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } static int xfrm_state_flush(int argc, char **argv) { - struct rtnl_handle rth; + struct rtnl_handle xrth; struct { struct nlmsghdr n; struct xfrm_usersa_flush xsf; @@ -1469,17 +1468,17 @@ static int xfrm_state_flush(int argc, char **argv) argc--; argv++; } - if (rtnl_open_byproto(&rth, 0, NETLINK_XFRM) < 0) + if (rtnl_open_byproto(&xrth, 0, NETLINK_XFRM) < 0) exit(1); if (show_stats > 1) fprintf(stderr, "Flush state with XFRM-PROTO value \"%s\"\n", strxf_xfrmproto(req.xsf.proto)); - if (rtnl_talk(&rth, &req.n, NULL) < 0) + if (rtnl_talk(&xrth, &req.n, NULL) < 0) exit(2); - rtnl_close(&rth); + rtnl_close(&xrth); return 0; } -- 2.53.0