From patchwork Fri Apr 17 23:43:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1091 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 qIuwICnMml5CLQAAIUCqbw for ; Sat, 18 Apr 2020 05:45:13 -0400 Received: from proxy19.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id OOadICnMml59AwAAalYnBA ; Sat, 18 Apr 2020 05:45:13 -0400 Received: from smtp25.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy19.mail.ord1d.rsapps.net with LMTP id WHo/ICnMml48KQAAyH2SIw ; Sat, 18 Apr 2020 05:45:13 -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: smtp25.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: 4cb0a118-8159-11ea-bbf3-b8ca3a673c88-1-1 Received: from [216.105.38.7] ([216.105.38.7:35704] helo=lists.sourceforge.net) by smtp25.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 0F/A5-28421-92CCA9E5; Sat, 18 Apr 2020 05:45:13 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jPk1M-0000BY-O0; Sat, 18 Apr 2020 09:44:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jPk1L-0000BP-JP for openvpn-devel@lists.sourceforge.net; Sat, 18 Apr 2020 09:44:19 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yRdpWZrEASIEOhrGvPIk47xjk93tuZjWuv9pDlhemZQ=; b=V75ECP6ctA9eZLP8pTKGOPF87+ XFqPeqyd0IRCrFMH0dhrve1Wa0HDRtmhpiSQ+vRl0/6WhUmEHgknbxhThnT417LaVOUt2s5Qym4+c XJRkLNG64HQoo8I8muDlPq7lVacmRHV/4ad2iTx185pqwW/N7+LBNofCxbm6HJ2TMNlo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=yRdpWZrEASIEOhrGvPIk47xjk93tuZjWuv9pDlhemZQ=; b=d 9gkb4z+KxFcGUAyzWvVBa0FXtus1/KGlLahhlLy2Bi/wVutFTIyQ0l/gJJAapxP9SIuC9qhryiyH9 e3VAlnRN5fud0yxJTgPvxqfWqZzbXfBVpH68wQiAZ97DfpLITW3nsOguIy3xDEWQnRX5QTqYtW5iO yw59yhdZRTuEbV7w=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jPk1J-006I2v-8z for openvpn-devel@lists.sourceforge.net; Sat, 18 Apr 2020 09:44:19 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sat, 18 Apr 2020 11:43:50 +0200 Message-Id: <20200418094350.26349-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 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: unstable.cc] -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: 1jPk1J-006I2v-8z Subject: [Openvpn-devel] [PATCH] sitnl: fix ignoring EEXIST when sending a netlink command 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 The logic is to treat EEXIST as non-error because it means that the address/soute we wanted to install already exists, therefore we can move on and not fail. However, this logic is currently based on checking errno == EEXIST. This is wrong, because sitnl_send() does not set errno, but returns the error directly as negative value. Fix this issue by directly comparing the the return value with -EEXIST. Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/networking_sitnl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index 7adcb64c..713a213a 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -717,7 +717,7 @@ sitnl_addr_set(int cmd, uint32_t flags, int ifindex, sa_family_t af_family, } ret = sitnl_send(&req.n, 0, 0, NULL, NULL); - if ((ret < 0) && (errno == EEXIST)) + if (ret == -EEXIST) { ret = 0; } @@ -858,7 +858,7 @@ sitnl_route_set(int cmd, uint32_t flags, int ifindex, sa_family_t af_family, } ret = sitnl_send(&req.n, 0, 0, NULL, NULL); - if ((ret < 0) && (errno == EEXIST)) + if (ret == -EEXIST) { ret = 0; }