From patchwork Sun Aug 4 23:25:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 795 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id gK4WFbX2R10CEwAAIUCqbw for ; Mon, 05 Aug 2019 05:28:21 -0400 Received: from proxy3.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id sLTqFLX2R10CUQAAalYnBA ; Mon, 05 Aug 2019 05:28:21 -0400 Received: from smtp40.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.ord1d.rsapps.net with LMTP id 8GyTFLX2R13tbQAA7WKfLA ; Mon, 05 Aug 2019 05:28:21 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp40.gate.ord1c.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 5cfeee8c-b763-11e9-9722-525400b3abc9-1-1 Received: from [216.105.38.7] ([216.105.38.7:41978] helo=lists.sourceforge.net) by smtp40.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 8D/68-05047-4B6F74D5; Mon, 05 Aug 2019 05:28:20 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1huZH8-00040S-RX; Mon, 05 Aug 2019 09:27:30 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1huZH7-0003zz-Ow for openvpn-devel@lists.sourceforge.net; Mon, 05 Aug 2019 09:27:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1Ol1C7T+GRLF+ml3OXV2QA1sKevrgVegivp0k0EpY8s=; b=B5hWcF1CocmZQSswXK+Nruf0nv JQECeLpvKyROB3Y9izM2UcDBVqq59ZzxYedKJF20UAwh6li6xwEOlh8aASDlPc13M12pAmJrcw/OF inG6YJXXLsFPhDL6MdqJGJhwy8fxJYOeuIwaNeO3saIcITOADF/S3+FD0RVALtn7YT5w=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1Ol1C7T+GRLF+ml3OXV2QA1sKevrgVegivp0k0EpY8s=; b=ADSROCbfNSh4stQW1CnLmlfpH/ rqVJEYsEybp4jzYrQaIlDOogPJY9yXmJITjT9oXV96anBGYKp4SkELtFkG/wInfaK1ehAiaWTX5lo Yfhp93I3m0cprp7YTb0YINNjbG+URbsGGxgMWZeePXpRWiUnhcuQSDSC2kMJtGVenZkQ=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1huZH5-00BSio-HM for openvpn-devel@lists.sourceforge.net; Mon, 05 Aug 2019 09:27:29 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Mon, 5 Aug 2019 11:25:25 +0200 Message-Id: <20190805092529.9467-3-a@unstable.cc> In-Reply-To: <20190805092529.9467-1-a@unstable.cc> References: <20190805092529.9467-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1huZH5-00BSio-HM Subject: [Openvpn-devel] [PATCH 2/6] networking/best_gw: remove useless prefixlen parameter X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli The prefixlen parameter is not used at all while retrieving a route therefore it can safely be removed. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/networking.h | 7 ++----- src/openvpn/networking_iproute2.c | 4 ++-- src/openvpn/networking_sitnl.c | 20 +++++++++----------- src/openvpn/route.c | 4 ++-- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/openvpn/networking.h b/src/openvpn/networking.h index add45edc..cf967116 100644 --- a/src/openvpn/networking.h +++ b/src/openvpn/networking.h @@ -241,15 +241,13 @@ int net_route_v6_del(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, * * @param ctx the implementation specific context * @param dst The destination to lookup - * @param prefixlen The length of the prefix of the destination * @param best_gw Location where the retrieved GW has to be stored * @param best_iface Location where the retrieved interface has to be stored * * @return 0 on success, a negative error code otherwise */ int net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, - int prefixlen, in_addr_t *best_gw, - openvpn_net_iface_t *best_iface); + in_addr_t *best_gw, openvpn_net_iface_t *best_iface); /** * Retrieve the gateway and outgoing interface for the specified IPv6 @@ -257,14 +255,13 @@ int net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, * * @param ctx the implementation specific context * @param dst The destination to lookup - * @param prefixlen The length of the prefix of the destination * @param best_gw Location where the retrieved GW has to be stored * @param best_iface Location where the retrieved interface has to be stored * * @return 0 on success, a negative error code otherwise */ int net_route_v6_best_gw(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, - int prefixlen, struct in6_addr *best_gw, + struct in6_addr *best_gw, openvpn_net_iface_t *best_iface); #endif /* ENABLE_SITNL || ENABLE_IPROUTE */ diff --git a/src/openvpn/networking_iproute2.c b/src/openvpn/networking_iproute2.c index a5824306..5db9a78b 100644 --- a/src/openvpn/networking_iproute2.c +++ b/src/openvpn/networking_iproute2.c @@ -325,7 +325,7 @@ net_route_v6_del(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, int net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, - int prefixlen, in_addr_t *best_gw, char *best_iface) + in_addr_t *best_gw, char *best_iface) { best_iface[0] = '\0'; @@ -378,7 +378,7 @@ net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, * uses the sitnl implementation from networking_sitnl.c. * * int - * net_route_v6_best_gw(const struct in6_addr *dst, int prefixlen, + * net_route_v6_best_gw(const struct in6_addr *dst, * struct in6_addr *best_gw, char *best_iface) */ diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index ea730ec7..21563905 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -451,7 +451,7 @@ sitnl_route_save(struct nlmsghdr *n, void *arg) static int sitnl_route_best_gw(sa_family_t af_family, const inet_address_t *dst, - int prefixlen, void *best_gw, char *best_iface) + void *best_gw, char *best_iface) { struct sitnl_route_req req; route_res_t res; @@ -468,7 +468,6 @@ sitnl_route_best_gw(sa_family_t af_family, const inet_address_t *dst, req.n.nlmsg_flags = NLM_F_REQUEST; req.r.rtm_family = af_family; - req.r.rtm_dst_len = prefixlen; switch (af_family) { @@ -503,7 +502,7 @@ err: /* used by iproute2 implementation too */ int net_route_v6_best_gw(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, - int prefixlen, struct in6_addr *best_gw, char *best_iface) + struct in6_addr *best_gw, char *best_iface) { inet_address_t dst_v6 = {0}; char buf[INET6_ADDRSTRLEN]; @@ -514,11 +513,10 @@ net_route_v6_best_gw(openvpn_net_ctx_t *ctx, const struct in6_addr *dst, dst_v6.ipv6 = *dst; } - msg(D_ROUTE, "%s query: dst %s/%d", __func__, - inet_ntop(AF_INET6, &dst_v6.ipv6, buf, sizeof(buf)), prefixlen); + msg(D_ROUTE, "%s query: dst %s", __func__, + inet_ntop(AF_INET6, &dst_v6.ipv6, buf, sizeof(buf))); - ret = sitnl_route_best_gw(AF_INET6, &dst_v6, prefixlen, best_gw, - best_iface); + ret = sitnl_route_best_gw(AF_INET6, &dst_v6, best_gw, best_iface); if (ret < 0) { return ret; @@ -544,7 +542,7 @@ net_ctx_init(struct context *c, openvpn_net_ctx_t *ctx) int net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, - int prefixlen, in_addr_t *best_gw, char *best_iface) + in_addr_t *best_gw, char *best_iface) { inet_address_t dst_v4 = {0}; char buf[INET_ADDRSTRLEN]; @@ -555,10 +553,10 @@ net_route_v4_best_gw(openvpn_net_ctx_t *ctx, const in_addr_t *dst, dst_v4.ipv4 = htonl(*dst); } - msg(D_ROUTE, "%s query: dst %s/%d", __func__, - inet_ntop(AF_INET, &dst_v4.ipv4, buf, sizeof(buf)), prefixlen); + msg(D_ROUTE, "%s query: dst %s", __func__, + inet_ntop(AF_INET, &dst_v4.ipv4, buf, sizeof(buf))); - ret = sitnl_route_best_gw(AF_INET, &dst_v4, prefixlen, best_gw, best_iface); + ret = sitnl_route_best_gw(AF_INET, &dst_v4, best_gw, best_iface); if (ret < 0) { return ret; diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 1341b4d2..bf036689 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -3172,7 +3172,7 @@ get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) #ifndef TARGET_ANDROID /* get default gateway IP addr */ - if (net_route_v4_best_gw(ctx, NULL, 0, &rgi->gateway.addr, best_name) == 0) + if (net_route_v4_best_gw(ctx, NULL, &rgi->gateway.addr, best_name) == 0) { rgi->flags |= RGI_ADDR_DEFINED; if (!rgi->gateway.addr && best_name[0]) @@ -3330,7 +3330,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6, CLEAR(*rgi6); - if (net_route_v6_best_gw(ctx, dest, 0, &rgi6->gateway.addr_ipv6, + if (net_route_v6_best_gw(ctx, dest, &rgi6->gateway.addr_ipv6, rgi6->iface) == 0) { if (!IN6_IS_ADDR_UNSPECIFIED(rgi6->gateway.addr_ipv6.s6_addr))