From nobody Tue Jun 13 06:27:01 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QgJVt3TS8z4dLVS; Tue, 13 Jun 2023 06:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QgJVt0NNYz3nKK; Tue, 13 Jun 2023 06:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686637622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/GrKQ9lHWXl6AD4Di4UXo144oUklI838kDlc2Y1cb6Y=; b=nnGffBTpeSLPlPfIB/mdbJbDqR+gDo+34Na4lb8AZi91iUSbXmy4dp31Hz+YhrAVvBsHcM g0Vb7VKBf1Pq8mbnkOMAOu9H6RMdU6Hu6oPcPXkV4IVXK6OCGl2jj9cop4qnjflsaK4h+H JvcdKSIvedIvjI3r7ystYgywHaIa1Q6Gq04V4WM13KForZ1Qg7XLnlKrzpQw8iJ2Rdz/j8 vHR0y3H8uu+uIBMlkehniJFU91HE506eRI3CEyO0Hcn0sKTU+DKP0a50ncZ814YT+XfuB5 pgThLNd6Cty2xR4YRbh0G74fHg/HX+kLNlDlqsETLiS/clqy8Mkmf2DUAideTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686637622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/GrKQ9lHWXl6AD4Di4UXo144oUklI838kDlc2Y1cb6Y=; b=ubI0UP3ETVASh/n8KN3lRW96P6Qbt5DHIIky1DyBTykT6oHaCIYiliAu477KH6twDXnky+ olFZHLoEsZVEn8I90Y65x5yf92i//nIapwkgVV6BjsdpuJ9w20/ZV/DZPr9XJpEoh0J1RN 7mCp8htjBW+S7vQRmbmI8yuLDJli+H0oeQroO4zwvizxIIe7BxIEygEk1NnYapDLeppilv iHPxrxJlFvR5oII2iy3luuRZ01HUXL+Xn3hXZrAo8z5bAHHFUoiUL5LjNLFfBBhX7pyTyp mbIxJgTYuudONIZ7mrflwrbZyXNQHfLzVKXL1pQtfwHjhIxV5B2kEivRRY/Teg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686637622; a=rsa-sha256; cv=none; b=ASoJKLsLrV9OXtp2kDpN00Nh38XayoSDejbIxgHM5zFPoElpD4JD+8d7vDQdmI0U1vLpc0 fKpc+w9HTqZuDKpDfO6YGb28Zlxo+hs5JVhh2w5z7UUPKVq/lpD51eIQYw0nRQ8ahoSIq5 wAK7iLHqezDOnDg1pcfYfJOE/WcR9BIq4ljcwE+X4ZHv4RASJ+R1OoMIgy9WK0C8kzLFCx abJ/nALY5nBiPnbriru8JoEjPpSBY4+LYiH+HF/fVQ4WOzD4cRG7MjxKRQdSSFSjpbpLMU PWOowCbOT5bclpC8AJ9M6UEOB4OsmSIq4dso0jqoFyx8NJCpWwBAG4pCswK1KA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QgJVs6Gxyz19kt; Tue, 13 Jun 2023 06:27:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35D6R1Dr031017; Tue, 13 Jun 2023 06:27:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35D6R1sh031016; Tue, 13 Jun 2023 06:27:01 GMT (envelope-from git) Date: Tue, 13 Jun 2023 06:27:01 GMT Message-Id: <202306130627.35D6R1sh031016@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: c6f0602f2349 - main - ifconfig: pass if_ctx instead of socket to the tunnel handlers. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6f0602f2349d64bc7a3fdfd6a2ead388e6226d6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=c6f0602f2349d64bc7a3fdfd6a2ead388e6226d6 commit c6f0602f2349d64bc7a3fdfd6a2ead388e6226d6 Author: Alexander V. Chernikov AuthorDate: 2023-06-13 06:19:50 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-06-13 06:20:00 +0000 ifconfig: pass if_ctx instead of socket to the tunnel handlers. This is a pre-requisite for the global 'name' variable removal. Reviewed By: kp Differential Revision: https://reviews.freebsd.org/D40432 MFC after: 2 weeks --- sbin/ifconfig/af_inet.c | 10 +++++----- sbin/ifconfig/af_inet6.c | 10 +++++----- sbin/ifconfig/ifconfig.c | 12 ++++++------ sbin/ifconfig/ifconfig.h | 9 +++++---- sbin/ifconfig/ifconfig_netlink.c | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c index df1d9cab959e..0538f9415272 100644 --- a/sbin/ifconfig/af_inet.c +++ b/sbin/ifconfig/af_inet.c @@ -490,7 +490,7 @@ in_postproc(if_ctx *ctx __unused, int newaddr, int ifflags) } static void -in_status_tunnel(int s) +in_status_tunnel(if_ctx *ctx) { char src[NI_MAXHOST]; char dst[NI_MAXHOST]; @@ -500,14 +500,14 @@ in_status_tunnel(int s) memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, name, IFNAMSIZ); - if (ioctl(s, SIOCGIFPSRCADDR, (caddr_t)&ifr) < 0) + if (ioctl_ctx(ctx, SIOCGIFPSRCADDR, (caddr_t)&ifr) < 0) return; if (sa->sa_family != AF_INET) return; if (getnameinfo(sa, sa->sa_len, src, sizeof(src), 0, 0, NI_NUMERICHOST) != 0) src[0] = '\0'; - if (ioctl(s, SIOCGIFPDSTADDR, (caddr_t)&ifr) < 0) + if (ioctl_ctx(ctx, SIOCGIFPDSTADDR, (caddr_t)&ifr) < 0) return; if (sa->sa_family != AF_INET) return; @@ -518,7 +518,7 @@ in_status_tunnel(int s) } static void -in_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) +in_set_tunnel(if_ctx *ctx, struct addrinfo *srcres, struct addrinfo *dstres) { struct in_aliasreq addreq; @@ -527,7 +527,7 @@ in_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) memcpy(&addreq.ifra_addr, srcres->ai_addr, srcres->ai_addr->sa_len); memcpy(&addreq.ifra_dstaddr, dstres->ai_addr, dstres->ai_addr->sa_len); - if (ioctl(s, SIOCSIFPHYADDR, &addreq) < 0) + if (ioctl_ctx(ctx, SIOCSIFPHYADDR, &addreq) < 0) warn("SIOCSIFPHYADDR"); } diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index f791646c5133..610fd70c04c1 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -647,7 +647,7 @@ in6_postproc(if_ctx *ctx, int newaddr __unused, } static void -in6_status_tunnel(int s) +in6_status_tunnel(if_ctx *ctx) { char src[NI_MAXHOST]; char dst[NI_MAXHOST]; @@ -657,7 +657,7 @@ in6_status_tunnel(int s) memset(&in6_ifr, 0, sizeof(in6_ifr)); strlcpy(in6_ifr.ifr_name, name, sizeof(in6_ifr.ifr_name)); - if (ioctl(s, SIOCGIFPSRCADDR_IN6, (caddr_t)&in6_ifr) < 0) + if (ioctl_ctx(ctx, SIOCGIFPSRCADDR_IN6, (caddr_t)&in6_ifr) < 0) return; if (sa->sa_family != AF_INET6) return; @@ -665,7 +665,7 @@ in6_status_tunnel(int s) NI_NUMERICHOST) != 0) src[0] = '\0'; - if (ioctl(s, SIOCGIFPDSTADDR_IN6, (caddr_t)&in6_ifr) < 0) + if (ioctl_ctx(ctx, SIOCGIFPDSTADDR_IN6, (caddr_t)&in6_ifr) < 0) return; if (sa->sa_family != AF_INET6) return; @@ -677,7 +677,7 @@ in6_status_tunnel(int s) } static void -in6_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) +in6_set_tunnel(if_ctx *ctx, struct addrinfo *srcres, struct addrinfo *dstres) { struct in6_aliasreq in6_addreq; @@ -687,7 +687,7 @@ in6_set_tunnel(int s, struct addrinfo *srcres, struct addrinfo *dstres) memcpy(&in6_addreq.ifra_dstaddr, dstres->ai_addr, dstres->ai_addr->sa_len); - if (ioctl(s, SIOCSIFPHYADDR_IN6, &in6_addreq) < 0) + if (ioctl_ctx(ctx, SIOCSIFPHYADDR_IN6, &in6_addreq) < 0) warn("SIOCSIFPHYADDR_IN6"); } diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 28677e57065c..a250062d69e1 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -967,7 +967,7 @@ af_other_status(if_ctx *ctx) } static void -af_all_tunnel_status(int s) +af_all_tunnel_status(if_ctx *ctx) { struct afswtch *afp; uint8_t afmask[howmany(AF_MAX, NBBY)]; @@ -978,7 +978,7 @@ af_all_tunnel_status(int s) continue; if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af)) continue; - afp->af_status_tunnel(s); + afp->af_status_tunnel(ctx); setbit(afmask, afp->af_af); } } @@ -1271,7 +1271,7 @@ settunnel(if_ctx *ctx, const char *src, const char *dst) errx(1, "source and destination address families do not match"); - afp->af_settunnel(ctx->io_s, srcres, dstres); + afp->af_settunnel(ctx, srcres, dstres); freeaddrinfo(srcres); freeaddrinfo(dstres); @@ -1747,7 +1747,7 @@ status(struct ifconfig_args *args, const struct sockaddr_dl *sdl, print_ifcap(args, s); - tunnel_status(s); + tunnel_status(ctx); for (ift = ifa; ift != NULL; ift = ift->ifa_next) { if (ift->ifa_addr == NULL) @@ -1794,9 +1794,9 @@ status(struct ifconfig_args *args, const struct sockaddr_dl *sdl, #endif void -tunnel_status(int s) +tunnel_status(if_ctx *ctx) { - af_all_tunnel_status(s); + af_all_tunnel_status(ctx); } static void diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 7b9c64cdaef1..5e0dfcd7e8c5 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -181,6 +181,8 @@ typedef void af_other_status_f(if_ctx *ctx); typedef void af_postproc_f(if_ctx *ctx, int newaddr, int ifflags); typedef int af_exec_f(if_ctx *ctx, unsigned long action, void *data); typedef void af_copyaddr_f(if_ctx *ctx, int to, int from); +typedef void af_status_tunnel_f(if_ctx *ctx); +typedef void af_settunnel_f(if_ctx *ctx, struct addrinfo *srcres, struct addrinfo *dstres); struct afswtch { const char *af_name; /* as given on cmd line, e.g. "inet" */ @@ -214,9 +216,8 @@ struct afswtch { struct afswtch *af_next; /* XXX doesn't fit model */ - void (*af_status_tunnel)(int); - void (*af_settunnel)(int s, struct addrinfo *srcres, - struct addrinfo *dstres); + af_status_tunnel_f *af_status_tunnel; + af_settunnel_f *af_settunnel; }; void af_register(struct afswtch *); int af_exec_ioctl(if_ctx *ctx, unsigned long action, void *data); @@ -278,7 +279,7 @@ bool match_if_flags(struct ifconfig_args *args, int if_flags); int ifconfig(if_ctx *ctx, int iscreate, const struct afswtch *uafp); bool group_member(const char *ifname, const char *match, const char *nomatch); void print_ifcap(struct ifconfig_args *args, int s); -void tunnel_status(int s); +void tunnel_status(if_ctx *ctx); struct afswtch *af_getbyfamily(int af); void af_other_status(if_ctx *ctx); void print_ifstatus(int s); diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c index 07e4429cfecb..bded84484a52 100644 --- a/sbin/ifconfig/ifconfig_netlink.c +++ b/sbin/ifconfig/ifconfig_netlink.c @@ -366,7 +366,7 @@ status_nl(if_ctx *ctx, struct iface *iface) /* TODO: convert to netlink */ strlcpy(ifr.ifr_name, link->ifla_ifname, sizeof(ifr.ifr_name)); print_ifcap(args, ctx->io_s); - tunnel_status(ctx->io_s); + tunnel_status(ctx); if (args->allfamilies | (args->afp != NULL && args->afp->af_af == AF_LINK)) { /* Start with link-level */