diff options
author | Thomas Haller <thaller@redhat.com> | 2016-04-05 14:10:51 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-05-13 13:22:56 +0200 |
commit | 0c790c222e9e1abfa33d45010c49152628535c93 (patch) | |
tree | 32baae77bda119565d25769eb41bffe016517ba9 /shared/nm-test-utils.h | |
parent | ca6f1e7f25daad1b635a1d7b00056bed10316c49 (diff) | |
download | NetworkManager-th/platform-route-identity.tar.gz |
WIP: platform: properly handle same routes in platform cacheth/platform-route-identity
From kernels point of view, you can add a new routes as long as
there is no existing route that is exactly identical. That effectively
means, that every field of the route is part of the ID.
Currently, we handle that wrong, thus when kernel notifies platform
about two such routes, we would wrongly merge them together.
For example:
ip link add dev0 type dummy
ip link add dev1 type dummy
ip link set dev0 up
ip link set dev1 up
ip addr add 192.168.200.4/24 dev dev0
ip addr add 192.168.201.4/24 dev dev1
ip route add 10.132.5.0/24 dev dev0
ip route append 10.132.5.0/24 via 192.168.212.1 dev dev0
ip route append 10.132.5.0/24 via 192.168.212.1 dev dev0 proto 5
ip route show dev dev0
ip route add 1:2:3:4:5::/64 via fe80::1:a dev dev0
ip route append 1:2:3:4:5::/64 via fe80::1:b dev dev0
ip route append 1:2:3:4:5::/64 via fe80::1:b dev dev0 proto 5
ip -6 route show dev dev0
Note the difference here are the netlink flags:
`ip route append` (NLM_F_CREATE|NLM_F_APPEND)
`ip route prepend` (NLM_F_CREATE)
`ip route add` (NLM_F_CREATE|NLM_F_EXCL)
`ip route change` (NLM_F_REPLACE)
`ip route replace` (NLM_F_CREATE|NLM_F_REPLACE)
Extend platform to consider every property of a route to be part
of the ID. Also update the API like route_add(), route_get() and
route_delete() to accept full route structures as arguments.
For delete, that means you can only delete a route that you know
about. But that isn't really actually a problem.
Diffstat (limited to 'shared/nm-test-utils.h')
-rw-r--r-- | shared/nm-test-utils.h | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/shared/nm-test-utils.h b/shared/nm-test-utils.h index 0875518cdd..e044ae59ac 100644 --- a/shared/nm-test-utils.h +++ b/shared/nm-test-utils.h @@ -1177,6 +1177,13 @@ _nmtst_assert_resolve_relative_path_equals (const char *f1, const char *f2, cons #ifdef __NETWORKMANAGER_PLATFORM_H__ +#define nmtst_ip4_address_to_ptr(addr) \ + ({ \ + guint32 *__addr = g_alloca (sizeof (guint32)); \ + *__addr = (addr); \ + (const NMIPAddr *) __addr; \ + }) + inline static NMPlatformIP4Address * nmtst_platform_ip4_address (const char *address, const char *peer_address, guint plen) { @@ -1251,7 +1258,9 @@ nmtst_platform_ip6_address_full (const char *address, const char *peer_address, } inline static NMPlatformIP4Route * -nmtst_platform_ip4_route (const char *network, guint plen, const char *gateway) +nmtst_platform_ip4_route (const char *network, + guint8 plen, + const char *gateway) { static NMPlatformIP4Route route; @@ -1266,10 +1275,15 @@ nmtst_platform_ip4_route (const char *network, guint plen, const char *gateway) } inline static NMPlatformIP4Route * -nmtst_platform_ip4_route_full (const char *network, guint plen, const char *gateway, - int ifindex, NMIPConfigSource source, - guint metric, guint mss, +nmtst_platform_ip4_route_full (int ifindex, + const char *network, + guint8 plen, + const char *gateway, + NMIPConfigSource source, + guint32 metric, + guint32 mss, guint8 scope, + bool scope_is_set, const char *pref_src) { NMPlatformIP4Route *route = nmtst_platform_ip4_route (network, plen, gateway); @@ -1278,14 +1292,17 @@ nmtst_platform_ip4_route_full (const char *network, guint plen, const char *gate route->rt_source = source; route->metric = metric; route->mss = mss; - route->scope_inv = nm_platform_route_scope_inv (scope); + route->rt_scope = scope; + route->rt_scope_is_set = scope_is_set; route->pref_src = nmtst_inet4_from_string (pref_src); return route; } inline static NMPlatformIP6Route * -nmtst_platform_ip6_route (const char *network, guint plen, const char *gateway) +nmtst_platform_ip6_route (const char *network, + guint8 plen, + const char *gateway) { static NMPlatformIP6Route route; @@ -1300,9 +1317,13 @@ nmtst_platform_ip6_route (const char *network, guint plen, const char *gateway) } inline static NMPlatformIP6Route * -nmtst_platform_ip6_route_full (const char *network, guint plen, const char *gateway, - int ifindex, NMIPConfigSource source, - guint metric, guint mss) +nmtst_platform_ip6_route_full (int ifindex, + const char *network, + guint8 plen, + const char *gateway, + NMIPConfigSource source, + guint32 metric, + guint32 mss) { NMPlatformIP6Route *route = nmtst_platform_ip6_route (network, plen, gateway); |