]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
sitnl: fix ignoring EEXIST when sending a netlink command
authorAntonio Quartulli <a@unstable.cc>
Sat, 18 Apr 2020 09:43:50 +0000 (11:43 +0200)
committerGert Doering <gert@greenie.muc.de>
Sun, 19 Apr 2020 09:58:15 +0000 (11:58 +0200)
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 <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200418094350.26349-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19777.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/networking_sitnl.c

index 7adcb64c79a5b60e6351408c7a2bbf00e0c35788..713a213a1a2ab2841336ac24c3a31056d8a5fd0e 100644 (file)
@@ -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;
     }