Confusingly, nm-platform-compat's rtnl_link_set_oif adds a new nexthop
with ifindex set, while rtnl_link_set_gateway sets gateway for an
existing nexthop. Keeping the behavior to avoid potential problems.
Kernel ifindexes are always greater than zero (see dev_new_index()
in net/core/dev.c). Also don't bother warning about ifindex
lookup failures for devices we know aren't kernel network interfaces.
Add two helper functions, one for IPv4 and one for IPv6, to ensure
that the core code benefits from compiler type checking when adding
routes. Previously nm_netlink_route_add() took a void* which meant
we messed up adding IPv6 routes sometimes due to confusion over
what was supposed to be passed to it. Also fixes what appears to
be a C&P error with add_ip6_route_to_gateway().
Reported by Tomáš Trnka <tomastrnka@gmx.com>
Callers of this function have a better idea of they want to
log errors or not. Let them handle it, since they already
do, and having a warning here was causing duplicate log
messages.
Flags are not getting set when a route is added (e.g. NLM_F_REPLACE).
Apparently this was fixed in Ubuntu, but I didn't see a patch here, so
here it is.