diff --git a/src/core/platform/tests/test-route.c b/src/core/platform/tests/test-route.c index 41debb7eb1..a05362f215 100644 --- a/src/core/platform/tests/test-route.c +++ b/src/core/platform/tests/test-route.c @@ -574,6 +574,7 @@ test_ip4_route_get(void) result = nm_platform_ip_route_get(NM_PLATFORM_GET, AF_INET, &a, + 0, nmtst_get_rand_uint32() % 2 ? 0 : ifindex, &route); @@ -766,6 +767,7 @@ test_ip6_route_get(void) result = nm_platform_ip_route_get(NM_PLATFORM_GET, AF_INET6, a, + 0, nmtst_get_rand_uint32() % 2 ? 0 : ifindex, &route); diff --git a/src/core/vpn/nm-vpn-connection.c b/src/core/vpn/nm-vpn-connection.c index 845a743251..0d430e5910 100644 --- a/src/core/vpn/nm-vpn-connection.c +++ b/src/core/vpn/nm-vpn-connection.c @@ -1203,6 +1203,7 @@ _parent_device_l3cd_add_gateway_route(NML3ConfigData *l3cd, r = nm_platform_ip_route_get(platform, addr_family, vpn_gw, + 0, ifindex, (NMPObject **) &route_resolved); if (r >= 0) { diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 61dc61cf97..f12032aff1 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -10591,6 +10591,7 @@ static int ip_route_get(NMPlatform *platform, int addr_family, gconstpointer address, + guint32 fwmark, int oif_ifindex, NMPObject **out_route) { @@ -10625,6 +10626,11 @@ ip_route_get(NMPlatform *platform, if (!_nl_addattr_l(&req.n, sizeof(req), RTA_DST, address, addr_len)) nm_assert_not_reached(); + if (fwmark != 0) { + if (!_nl_addattr_l(&req.n, sizeof(req), RTA_MARK, &fwmark, sizeof(fwmark))) + nm_assert_not_reached(); + } + if (oif_ifindex > 0) { gint32 ii = oif_ifindex; diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 085b141703..ff45cf3d03 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -5603,6 +5603,7 @@ int nm_platform_ip_route_get(NMPlatform *self, int addr_family, gconstpointer address /* in_addr_t or struct in6_addr */, + guint32 fwmark, int oif_ifindex, NMPObject **out_route) { @@ -5611,21 +5612,23 @@ nm_platform_ip_route_get(NMPlatform *self, int result; char buf[NM_INET_ADDRSTRLEN]; char buf_oif[64]; + char buf_fwmark[64]; _CHECK_SELF(self, klass, FALSE); g_return_val_if_fail(address, -NME_BUG); g_return_val_if_fail(NM_IN_SET(addr_family, AF_INET, AF_INET6), -NME_BUG); - _LOGT("route: get IPv%c route for: %s%s", + _LOGT("route: get IPv%c route for: %s%s%s", nm_utils_addr_family_to_char(addr_family), inet_ntop(addr_family, address, buf, sizeof(buf)), - oif_ifindex > 0 ? nm_sprintf_buf(buf_oif, " oif %d", oif_ifindex) : ""); + oif_ifindex > 0 ? nm_sprintf_buf(buf_oif, " oif %d", oif_ifindex) : "", + fwmark > 0 ? nm_sprintf_buf(buf_fwmark, " fwmark %u", fwmark) : ""); if (!klass->ip_route_get) result = -NME_PL_OPNOTSUPP; else { - result = klass->ip_route_get(self, addr_family, address, oif_ifindex, &route); + result = klass->ip_route_get(self, addr_family, address, fwmark, oif_ifindex, &route); } if (result < 0) { diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 34f890603b..30d9037e6d 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -1321,6 +1321,7 @@ typedef struct { int (*ip_route_get)(NMPlatform *self, int addr_family, gconstpointer address, + guint32 fwmark, int oif_ifindex, NMPObject **out_route); @@ -2432,6 +2433,7 @@ gboolean nm_platform_ip_route_flush(NMPlatform *self, int addr_family, int ifind int nm_platform_ip_route_get(NMPlatform *self, int addr_family, gconstpointer address, + guint32 fwmark, int oif_ifindex, NMPObject **out_route);