]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Repair special-casing of EEXIST for Linux/SITNL route install
authorGert Doering <gert@greenie.muc.de>
Wed, 18 Jan 2023 07:46:33 +0000 (08:46 +0100)
committerGert Doering <gert@greenie.muc.de>
Thu, 19 Jan 2023 07:20:05 +0000 (08:20 +0100)
commitadc54f483b210484ff1488e01c8aee1b2b0ea477
tree57111d123a20d9d94b65e1d3b09de4f95d20e60e
parent328cc40c8368a9e1f9abc92eb4d34687470e3a92
Repair special-casing of EEXIST for Linux/SITNL route install

The code in sitnl_route_set() used to treat "route can not be installed
because it already exists" (EEXIST) as "not an error".

This is arguably a reasonable approach, but needs to handled higher
up - if the low level add_route() function say "no error", we will try
to remove that route later on in delete_route(), possibly removing
someone else's "already existing" route then.

So:
 - remove special case in sitnl_route_set()
 - do not pass NLM_F_REPLACE flag to sitnl_route_set() call - this would
   cause netlink to just replace existing routes, never return EEXIST
   (see "man netlink(7)")
 - add detailed return code handling to add_route(), assign "2" on
"-EEXIST"
   (and log appropriate message).

(Note: sitnl_route_set() is a common function for sitnl route add and
delete, but EEXIST can not happen on delete - so this change has no
impact for the "delete" case)

v2: use RTA_ macros, also adjust add_route_ipv6()

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230118074633.27586-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26046.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/networking_sitnl.c
src/openvpn/route.c