mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-24 00:30:30 +01:00
platform: fix nmp_lookup_init_route_by_weak_id() to honor the route-table
The route table is part of the weak-id. You can see that with: ip route replace unicast 1.2.3.4/32 dev eth0 table 57 ip route replace unicast 1.2.3.4/32 dev eth0 table 58 afterwards, `ip route show table all` will list both routes. The replace operation is only per-table. Note that NMP_CACHE_ID_TYPE_ROUTES_BY_WEAK_ID already got this right. Fixes:10ac675299('platform: add support for routing tables to platform cache') (cherry picked from commita3cea7f6fb)
This commit is contained in:
parent
c6685f0179
commit
4c42f90e3c
3 changed files with 46 additions and 21 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/if_tun.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
#include "n-acd/src/n-acd.h"
|
||||
|
||||
|
|
@ -540,7 +541,7 @@ _ip4_route_get(NMPlatform *platform,
|
|||
|
||||
_init_platform(&platform, FALSE);
|
||||
|
||||
nmp_lookup_init_ip4_route_by_weak_id(&lookup, network, plen, metric, tos);
|
||||
nmp_lookup_init_ip4_route_by_weak_id(&lookup, RT_TABLE_MAIN, network, plen, metric, tos);
|
||||
|
||||
c = 0;
|
||||
nmp_cache_iter_for_each (&iter, nm_platform_lookup(platform, &lookup), &o) {
|
||||
|
|
@ -633,7 +634,13 @@ _ip6_route_get(NMPlatform *platform,
|
|||
|
||||
_init_platform(&platform, FALSE);
|
||||
|
||||
nmp_lookup_init_ip6_route_by_weak_id(&lookup, network, plen, metric, src, src_plen);
|
||||
nmp_lookup_init_ip6_route_by_weak_id(&lookup,
|
||||
RT_TABLE_MAIN,
|
||||
network,
|
||||
plen,
|
||||
metric,
|
||||
src,
|
||||
src_plen);
|
||||
|
||||
c = 0;
|
||||
nmp_cache_iter_for_each (&iter, nm_platform_lookup(platform, &lookup), &o) {
|
||||
|
|
|
|||
|
|
@ -2204,19 +2204,23 @@ nmp_lookup_init_route_by_weak_id(NMPLookup *lookup, const NMPObject *obj)
|
|||
switch (NMP_OBJECT_GET_TYPE(obj)) {
|
||||
case NMP_OBJECT_TYPE_IP4_ROUTE:
|
||||
r4 = NMP_OBJECT_CAST_IP4_ROUTE(obj);
|
||||
return nmp_lookup_init_ip4_route_by_weak_id(lookup,
|
||||
r4->network,
|
||||
r4->plen,
|
||||
r4->metric,
|
||||
r4->tos);
|
||||
return nmp_lookup_init_ip4_route_by_weak_id(
|
||||
lookup,
|
||||
nm_platform_route_table_uncoerce(r4->table_coerced, TRUE),
|
||||
r4->network,
|
||||
r4->plen,
|
||||
r4->metric,
|
||||
r4->tos);
|
||||
case NMP_OBJECT_TYPE_IP6_ROUTE:
|
||||
r6 = NMP_OBJECT_CAST_IP6_ROUTE(obj);
|
||||
return nmp_lookup_init_ip6_route_by_weak_id(lookup,
|
||||
&r6->network,
|
||||
r6->plen,
|
||||
r6->metric,
|
||||
&r6->src,
|
||||
r6->src_plen);
|
||||
return nmp_lookup_init_ip6_route_by_weak_id(
|
||||
lookup,
|
||||
nm_platform_route_table_uncoerce(r6->table_coerced, TRUE),
|
||||
&r6->network,
|
||||
r6->plen,
|
||||
r6->metric,
|
||||
&r6->src,
|
||||
r6->src_plen);
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
return NULL;
|
||||
|
|
@ -2225,6 +2229,7 @@ nmp_lookup_init_route_by_weak_id(NMPLookup *lookup, const NMPObject *obj)
|
|||
|
||||
const NMPLookup *
|
||||
nmp_lookup_init_ip4_route_by_weak_id(NMPLookup *lookup,
|
||||
guint32 route_table,
|
||||
in_addr_t network,
|
||||
guint plen,
|
||||
guint32 metric,
|
||||
|
|
@ -2235,9 +2240,10 @@ nmp_lookup_init_ip4_route_by_weak_id(NMPLookup *lookup,
|
|||
nm_assert(lookup);
|
||||
|
||||
o = _nmp_object_stackinit_from_type(&lookup->selector_obj, NMP_OBJECT_TYPE_IP4_ROUTE);
|
||||
o->ip4_route.ifindex = 1;
|
||||
o->ip4_route.plen = plen;
|
||||
o->ip4_route.metric = metric;
|
||||
o->ip4_route.ifindex = 1;
|
||||
o->ip4_route.plen = plen;
|
||||
o->ip4_route.table_coerced = nm_platform_route_table_coerce(route_table);
|
||||
o->ip4_route.metric = metric;
|
||||
if (network)
|
||||
o->ip4_route.network = network;
|
||||
o->ip4_route.tos = tos;
|
||||
|
|
@ -2247,6 +2253,7 @@ nmp_lookup_init_ip4_route_by_weak_id(NMPLookup *lookup,
|
|||
|
||||
const NMPLookup *
|
||||
nmp_lookup_init_ip6_route_by_weak_id(NMPLookup *lookup,
|
||||
guint32 route_table,
|
||||
const struct in6_addr *network,
|
||||
guint plen,
|
||||
guint32 metric,
|
||||
|
|
@ -2258,9 +2265,10 @@ nmp_lookup_init_ip6_route_by_weak_id(NMPLookup *lookup,
|
|||
nm_assert(lookup);
|
||||
|
||||
o = _nmp_object_stackinit_from_type(&lookup->selector_obj, NMP_OBJECT_TYPE_IP6_ROUTE);
|
||||
o->ip6_route.ifindex = 1;
|
||||
o->ip6_route.plen = plen;
|
||||
o->ip6_route.metric = metric;
|
||||
o->ip6_route.ifindex = 1;
|
||||
o->ip6_route.plen = plen;
|
||||
o->ip6_route.table_coerced = nm_platform_route_table_coerce(route_table);
|
||||
o->ip6_route.metric = metric;
|
||||
if (network)
|
||||
o->ip6_route.network = *network;
|
||||
if (src)
|
||||
|
|
|
|||
|
|
@ -811,11 +811,13 @@ nmp_lookup_init_object_by_ifindex(NMPLookup *lookup, NMPObjectType obj_type, int
|
|||
const NMPLookup *nmp_lookup_init_route_default(NMPLookup *lookup, NMPObjectType obj_type);
|
||||
const NMPLookup *nmp_lookup_init_route_by_weak_id(NMPLookup *lookup, const NMPObject *obj);
|
||||
const NMPLookup *nmp_lookup_init_ip4_route_by_weak_id(NMPLookup *lookup,
|
||||
guint32 route_table,
|
||||
in_addr_t network,
|
||||
guint plen,
|
||||
guint32 metric,
|
||||
guint8 tos);
|
||||
const NMPLookup *nmp_lookup_init_ip6_route_by_weak_id(NMPLookup *lookup,
|
||||
guint32 route_table,
|
||||
const struct in6_addr *network,
|
||||
guint plen,
|
||||
guint32 metric,
|
||||
|
|
@ -1074,6 +1076,7 @@ nm_platform_lookup_route_default_clone(NMPlatform *platform,
|
|||
|
||||
static inline const NMDedupMultiHeadEntry *
|
||||
nm_platform_lookup_ip4_route_by_weak_id(NMPlatform *platform,
|
||||
guint32 route_table,
|
||||
in_addr_t network,
|
||||
guint plen,
|
||||
guint32 metric,
|
||||
|
|
@ -1081,12 +1084,13 @@ nm_platform_lookup_ip4_route_by_weak_id(NMPlatform *platform,
|
|||
{
|
||||
NMPLookup lookup;
|
||||
|
||||
nmp_lookup_init_ip4_route_by_weak_id(&lookup, network, plen, metric, tos);
|
||||
nmp_lookup_init_ip4_route_by_weak_id(&lookup, route_table, network, plen, metric, tos);
|
||||
return nm_platform_lookup(platform, &lookup);
|
||||
}
|
||||
|
||||
static inline const NMDedupMultiHeadEntry *
|
||||
nm_platform_lookup_ip6_route_by_weak_id(NMPlatform *platform,
|
||||
guint32 route_table,
|
||||
const struct in6_addr *network,
|
||||
guint plen,
|
||||
guint32 metric,
|
||||
|
|
@ -1095,7 +1099,13 @@ nm_platform_lookup_ip6_route_by_weak_id(NMPlatform *platform,
|
|||
{
|
||||
NMPLookup lookup;
|
||||
|
||||
nmp_lookup_init_ip6_route_by_weak_id(&lookup, network, plen, metric, src, src_plen);
|
||||
nmp_lookup_init_ip6_route_by_weak_id(&lookup,
|
||||
route_table,
|
||||
network,
|
||||
plen,
|
||||
metric,
|
||||
src,
|
||||
src_plen);
|
||||
return nm_platform_lookup(platform, &lookup);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue