From patchwork Sun Aug 4 23:25:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 797 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.28.255.1]) by backend30.mail.ord1d.rsapps.net with LMTP id oJFfMsf2R120WQAAIUCqbw for ; Mon, 05 Aug 2019 05:28:39 -0400 Received: from proxy2.mail.ord1c.rsapps.net ([172.28.255.1]) by director9.mail.ord1d.rsapps.net with LMTP id mNAyMsf2R10BUQAAalYnBA ; Mon, 05 Aug 2019 05:28:39 -0400 Received: from smtp11.gate.ord1c ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.ord1c.rsapps.net with LMTP id IC2VMcf2R13WCAAA311kuQ ; Mon, 05 Aug 2019 05:28:39 -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: smtp11.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: 6719aa74-b763-11e9-980d-bc305beffa54-1-1 Received: from [216.105.38.7] ([216.105.38.7:46140] helo=lists.sourceforge.net) by smtp11.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 21/17-25345-5C6F74D5; Mon, 05 Aug 2019 05:28:37 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1huZHB-0000gB-BP; Mon, 05 Aug 2019 09:27:33 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1huZHA-0000g3-2y for openvpn-devel@lists.sourceforge.net; Mon, 05 Aug 2019 09:27:32 +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=TqogQfxSvnM4ZFUCEUtxzaJ5UbsruIi9poTNgaVzZyU=; b=Dlhx1dtKgpVx2o3ahZ+AwQxQPv ICvWBRpmgTHb6GOX96raaWYPPMQ5gk5XM9+9EwiRtLH4xQIlqmFFVc8VxRO2obPL+7du7S4TNAgkl 0a6//wqmVcgEysM+8WgzLNOlcDUJoHNplgFxULIRtmaSF/Z5ZMZ7jXipUM/rguIDcQ9c=; 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=TqogQfxSvnM4ZFUCEUtxzaJ5UbsruIi9poTNgaVzZyU=; b=l9Np8JJBERyxKOSnI8jbYsmhn2 1SMfrJz43WVOi3/61XbmRGEiIKU76TMDvGoYvyB1uICq38ZiWiHUJHLKJD8PmUegAGZAQX398Of8v vjPNZjdJZurKPuajd+0A24X9oj4/dyk7tPV4Js4jS/pyO63WyzEWXxSvj+fdtJKeeTdI=; 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 1huZH8-00BSiz-Hi for openvpn-devel@lists.sourceforge.net; Mon, 05 Aug 2019 09:27:32 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Mon, 5 Aug 2019 11:25:28 +0200 Message-Id: <20190805092529.9467-6-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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1huZH8-00BSiz-Hi Subject: [Openvpn-devel] [PATCH 5/6] networking_sitnl.c: uncrustify file 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 , Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Give this file a run under uncrustify to fix a few style glitches here and there. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/networking_sitnl.c | 62 +++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index 976ecd28..e5c48932 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -45,7 +45,7 @@ #define SITNL_ADDATTR(_msg, _max_size, _attr, _data, _size) \ { \ - if (sitnl_addattr(_msg, _max_size, _attr, _data, _size) < 0)\ + if (sitnl_addattr(_msg, _max_size, _attr, _data, _size) < 0) \ { \ goto err; \ } \ @@ -335,16 +335,16 @@ sitnl_send(struct nlmsghdr *payload, pid_t peer, unsigned int groups, } /* if (((int)nladdr.nl_pid != peer) || (h->nlmsg_pid != nladdr.nl_pid) - || (h->nlmsg_seq != seq)) - { - rcv_len -= NLMSG_ALIGN(len); - h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len)); - msg(M_DEBUG, "%s: skipping unrelated message. nl_pid:%d (peer:%d) nl_msg_pid:%d nl_seq:%d seq:%d", - __func__, (int)nladdr.nl_pid, peer, h->nlmsg_pid, - h->nlmsg_seq, seq); - continue; - } -*/ + * || (h->nlmsg_seq != seq)) + * { + * rcv_len -= NLMSG_ALIGN(len); + * h = (struct nlmsghdr *)((char *)h + NLMSG_ALIGN(len)); + * msg(M_DEBUG, "%s: skipping unrelated message. nl_pid:%d (peer:%d) nl_msg_pid:%d nl_seq:%d seq:%d", + * __func__, (int)nladdr.nl_pid, peer, h->nlmsg_pid, + * h->nlmsg_seq, seq); + * continue; + * } + */ if (h->nlmsg_type == NLMSG_ERROR) { err = (struct nlmsgerr *)NLMSG_DATA(h); @@ -359,7 +359,9 @@ sitnl_send(struct nlmsghdr *payload, pid_t peer, unsigned int groups, { ret = 0; if (cb) + { ret = cb(h, arg_cb); + } } else { @@ -427,9 +429,11 @@ sitnl_route_save(struct nlmsghdr *n, void *arg) case RTA_OIF: ifindex = *(unsigned int *)RTA_DATA(rta); break; + /* route prefix */ case RTA_DST: break; + /* GW for the route */ case RTA_GATEWAY: memcpy(&res->gw, RTA_DATA(rta), res->addr_size); @@ -475,9 +479,11 @@ sitnl_route_best_gw(sa_family_t af_family, const inet_address_t *dst, res.addr_size = sizeof(in_addr_t); req.n.nlmsg_flags |= NLM_F_DUMP; break; + case AF_INET6: res.addr_size = sizeof(struct in6_addr); break; + default: /* unsupported */ return -EINVAL; @@ -598,7 +604,8 @@ net_iface_up(openvpn_net_ctx_t *ctx, const char *iface, bool up) } ifindex = if_nametoindex(iface); - if (ifindex == 0) { + if (ifindex == 0) + { msg(M_WARN, "%s: rtnl: cannot get ifindex for %s: %s", __func__, iface, strerror(errno)); return -ENOENT; @@ -612,9 +619,13 @@ net_iface_up(openvpn_net_ctx_t *ctx, const char *iface, bool up) req.i.ifi_index = ifindex; req.i.ifi_change |= IFF_UP; if (up) + { req.i.ifi_flags |= IFF_UP; + } else + { req.i.ifi_flags &= ~IFF_UP; + } msg(M_INFO, "%s: set %s %s", __func__, iface, up ? "up" : "down"); @@ -631,7 +642,8 @@ net_iface_mtu_set(openvpn_net_ctx_t *ctx, const char *iface, CLEAR(req); ifindex = if_nametoindex(iface); - if (ifindex == 0) { + if (ifindex == 0) + { msg(M_WARN | M_ERRNO, "%s: rtnl: cannot get ifindex for %s", __func__, iface); return -1; @@ -676,9 +688,11 @@ sitnl_addr_set(int cmd, uint32_t flags, int ifindex, sa_family_t af_family, case AF_INET: size = sizeof(struct in_addr); break; + case AF_INET6: size = sizeof(struct in6_addr); break; + default: msg(M_WARN, "%s: rtnl: unknown address family %d", __func__, af_family); @@ -723,10 +737,12 @@ sitnl_addr_ptp_add(sa_family_t af_family, const char *iface, { int ifindex; - switch (af_family) { + switch (af_family) + { case AF_INET: case AF_INET6: break; + default: return -EINVAL; } @@ -755,10 +771,12 @@ sitnl_addr_ptp_del(sa_family_t af_family, const char *iface, { int ifindex; - switch (af_family) { + switch (af_family) + { case AF_INET: case AF_INET6: break; + default: return -EINVAL; } @@ -796,9 +814,11 @@ sitnl_route_set(int cmd, uint32_t flags, int ifindex, sa_family_t af_family, case AF_INET: size = sizeof(in_addr_t); break; + case AF_INET6: size = sizeof(struct in6_addr); break; + default: return -EINVAL; } @@ -859,12 +879,14 @@ sitnl_addr_add(sa_family_t af_family, const char *iface, { int ifindex; - switch (af_family) { + switch (af_family) + { case AF_INET: case AF_INET6: break; + default: - return -EINVAL;; + return -EINVAL; } if (!iface) @@ -891,12 +913,14 @@ sitnl_addr_del(sa_family_t af_family, const char *iface, inet_address_t *addr, { int ifindex; - switch (af_family) { + switch (af_family) + { case AF_INET: case AF_INET6: break; + default: - return -EINVAL;; + return -EINVAL; } if (!iface)