platform: change NMPlatformGetRouteMode enum to NMPlatformGetRouteFlags flags
By having flags instead of an enum/mode, we can encode more combinations of filtering the result.
This commit is contained in:
@@ -3114,9 +3114,9 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat
|
|||||||
GArray *routes;
|
GArray *routes;
|
||||||
|
|
||||||
if (addr_family == AF_INET)
|
if (addr_family == AF_INET)
|
||||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT);
|
||||||
else
|
else
|
||||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT);
|
||||||
|
|
||||||
if (routes) {
|
if (routes) {
|
||||||
guint route_metric = G_MAXUINT32, m;
|
guint route_metric = G_MAXUINT32, m;
|
||||||
|
@@ -292,7 +292,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self,
|
|||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
/* prune all other default routes from this device. */
|
/* prune all other default routes from this device. */
|
||||||
routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT);
|
||||||
|
|
||||||
for (i = 0; i < routes->len; i++) {
|
for (i = 0; i < routes->len; i++) {
|
||||||
const NMPlatformIPRoute *route;
|
const NMPlatformIPRoute *route;
|
||||||
@@ -478,7 +478,7 @@ _resync_all (const VTableIP *vtable, NMDefaultRouteManager *self, const Entry *c
|
|||||||
|
|
||||||
entries = vtable->get_entries (priv);
|
entries = vtable->get_entries (priv);
|
||||||
|
|
||||||
routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT);
|
routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT);
|
||||||
|
|
||||||
assumed_metrics = _get_assumed_interface_metrics (vtable, self, routes);
|
assumed_metrics = _get_assumed_interface_metrics (vtable, self, routes);
|
||||||
|
|
||||||
|
@@ -229,7 +229,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||||||
g_array_unref (priv->routes);
|
g_array_unref (priv->routes);
|
||||||
|
|
||||||
priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
priv->routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
priv->routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
/* Extract gateway from default route */
|
/* Extract gateway from default route */
|
||||||
old_gateway = priv->gateway;
|
old_gateway = priv->gateway;
|
||||||
|
@@ -342,7 +342,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co
|
|||||||
g_array_unref (priv->routes);
|
g_array_unref (priv->routes);
|
||||||
|
|
||||||
priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
priv->routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
priv->routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
/* Extract gateway from default route */
|
/* Extract gateway from default route */
|
||||||
old_gateway = priv->gateway;
|
old_gateway = priv->gateway;
|
||||||
|
@@ -358,7 +358,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
|
|||||||
NMPlatformIPXRoute *cur_ipx_route;
|
NMPlatformIPXRoute *cur_ipx_route;
|
||||||
|
|
||||||
ipx_routes = vtable->vt->is_ip4 ? &priv->ip4_routes : &priv->ip6_routes;
|
ipx_routes = vtable->vt->is_ip4 ? &priv->ip4_routes : &priv->ip6_routes;
|
||||||
plat_routes = vtable->vt->route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
|
plat_routes = vtable->vt->route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
plat_routes_idx = _route_index_create (vtable, plat_routes);
|
plat_routes_idx = _route_index_create (vtable, plat_routes);
|
||||||
known_routes_idx = _route_index_create (vtable, known_routes);
|
known_routes_idx = _route_index_create (vtable, known_routes);
|
||||||
|
|
||||||
|
@@ -1034,26 +1034,27 @@ ip4_check_reinstall_device_route (NMPlatform *platform, int ifindex, const NMPla
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||||
GArray *routes;
|
GArray *routes;
|
||||||
NMPlatformIP4Route *route;
|
NMPlatformIP4Route *route;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IN_SET (mode, NM_PLATFORM_GET_ROUTE_MODE_ALL, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT), NULL);
|
|
||||||
|
|
||||||
routes = g_array_new (TRUE, TRUE, sizeof (NMPlatformIP4Route));
|
routes = g_array_new (TRUE, TRUE, sizeof (NMPlatformIP4Route));
|
||||||
|
|
||||||
|
if (!NM_FLAGS_ANY (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT))
|
||||||
|
flags |= NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT;
|
||||||
|
|
||||||
/* Fill routes */
|
/* Fill routes */
|
||||||
for (i = 0; i < priv->ip4_routes->len; i++) {
|
for (i = 0; i < priv->ip4_routes->len; i++) {
|
||||||
route = &g_array_index (priv->ip4_routes, NMPlatformIP4Route, i);
|
route = &g_array_index (priv->ip4_routes, NMPlatformIP4Route, i);
|
||||||
if (route && (!ifindex || route->ifindex == ifindex)) {
|
if (route && (!ifindex || route->ifindex == ifindex)) {
|
||||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
|
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
|
||||||
if (mode != NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT)
|
if (NM_FLAGS_HAS (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT))
|
||||||
g_array_append_val (routes, *route);
|
g_array_append_val (routes, *route);
|
||||||
} else {
|
} else {
|
||||||
if (mode != NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT)
|
if (NM_FLAGS_HAS (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT))
|
||||||
g_array_append_val (routes, *route);
|
g_array_append_val (routes, *route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1063,26 +1064,27 @@ ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
|
||||||
GArray *routes;
|
GArray *routes;
|
||||||
NMPlatformIP6Route *route;
|
NMPlatformIP6Route *route;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IN_SET (mode, NM_PLATFORM_GET_ROUTE_MODE_ALL, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT), NULL);
|
|
||||||
|
|
||||||
routes = g_array_new (TRUE, TRUE, sizeof (NMPlatformIP6Route));
|
routes = g_array_new (TRUE, TRUE, sizeof (NMPlatformIP6Route));
|
||||||
|
|
||||||
|
if (!NM_FLAGS_ANY (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT))
|
||||||
|
flags |= NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT;
|
||||||
|
|
||||||
/* Fill routes */
|
/* Fill routes */
|
||||||
for (i = 0; i < priv->ip6_routes->len; i++) {
|
for (i = 0; i < priv->ip6_routes->len; i++) {
|
||||||
route = &g_array_index (priv->ip6_routes, NMPlatformIP6Route, i);
|
route = &g_array_index (priv->ip6_routes, NMPlatformIP6Route, i);
|
||||||
if (route && (!ifindex || route->ifindex == ifindex)) {
|
if (route && (!ifindex || route->ifindex == ifindex)) {
|
||||||
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
|
if (NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) {
|
||||||
if (mode != NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT)
|
if (NM_FLAGS_HAS (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT))
|
||||||
g_array_append_val (routes, *route);
|
g_array_append_val (routes, *route);
|
||||||
} else {
|
} else {
|
||||||
if (mode != NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT)
|
if (NM_FLAGS_HAS (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT))
|
||||||
g_array_append_val (routes, *route);
|
g_array_append_val (routes, *route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4242,42 +4242,34 @@ ip4_check_reinstall_device_route (NMPlatform *platform, int ifindex, const NMPla
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ipx_route_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type, NMPlatformGetRouteMode mode)
|
ipx_route_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
gboolean with_default = FALSE, with_non_default = FALSE;
|
|
||||||
|
|
||||||
nm_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE));
|
nm_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE));
|
||||||
|
|
||||||
if (mode == NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT)
|
if (!NM_FLAGS_ANY (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT))
|
||||||
with_non_default = TRUE;
|
flags |= NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT;
|
||||||
else if (mode == NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT)
|
|
||||||
with_default = TRUE;
|
|
||||||
else if (mode == NM_PLATFORM_GET_ROUTE_MODE_ALL) {
|
|
||||||
with_non_default = TRUE;
|
|
||||||
with_default = TRUE;
|
|
||||||
} else
|
|
||||||
g_return_val_if_reached (NULL);
|
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
obj_type,
|
obj_type,
|
||||||
nmp_cache_id_init_routes_visible (NMP_CACHE_ID_STATIC,
|
nmp_cache_id_init_routes_visible (NMP_CACHE_ID_STATIC,
|
||||||
obj_type,
|
obj_type,
|
||||||
with_default,
|
NM_FLAGS_HAS (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT),
|
||||||
with_non_default,
|
NM_FLAGS_HAS (flags, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT),
|
||||||
ifindex));
|
ifindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
return ipx_route_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP4_ROUTE, mode);
|
return ipx_route_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP4_ROUTE, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
return ipx_route_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP6_ROUTE, mode);
|
return ipx_route_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP6_ROUTE, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -2148,25 +2148,23 @@ nm_platform_address_flush (NMPlatform *self, int ifindex)
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
GArray *
|
GArray *
|
||||||
nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode)
|
nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
_CHECK_SELF (self, klass, NULL);
|
_CHECK_SELF (self, klass, NULL);
|
||||||
|
|
||||||
g_return_val_if_fail (ifindex >= 0, NULL);
|
g_return_val_if_fail (ifindex >= 0, NULL);
|
||||||
g_return_val_if_fail (klass->ip4_route_get_all, NULL);
|
|
||||||
|
|
||||||
return klass->ip4_route_get_all (self, ifindex, mode);
|
return klass->ip4_route_get_all (self, ifindex, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
GArray *
|
GArray *
|
||||||
nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode)
|
nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags)
|
||||||
{
|
{
|
||||||
_CHECK_SELF (self, klass, NULL);
|
_CHECK_SELF (self, klass, NULL);
|
||||||
|
|
||||||
g_return_val_if_fail (ifindex >= 0, NULL);
|
g_return_val_if_fail (ifindex >= 0, NULL);
|
||||||
g_return_val_if_fail (klass->ip6_route_get_all, NULL);
|
|
||||||
|
|
||||||
return klass->ip6_route_get_all (self, ifindex, mode);
|
return klass->ip6_route_get_all (self, ifindex, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@@ -151,10 +151,14 @@ typedef enum {
|
|||||||
#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32
|
#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_ALL,
|
NM_PLATFORM_GET_ROUTE_FLAGS_NONE = 0,
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT,
|
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT,
|
/* Whether to include default-routes/non-default-routes. Omitting
|
||||||
} NMPlatformGetRouteMode;
|
* both WITH_DEFAULT and WITH_NON_DEFAULT, is equal to specifying
|
||||||
|
* both of them. */
|
||||||
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT = (1LL << 0),
|
||||||
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT = (1LL << 1),
|
||||||
|
} NMPlatformGetRouteFlags;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
__NMPlatformObject_COMMON;
|
__NMPlatformObject_COMMON;
|
||||||
@@ -308,7 +312,7 @@ typedef struct {
|
|||||||
gsize sizeof_route;
|
gsize sizeof_route;
|
||||||
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b);
|
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b);
|
||||||
const char *(*route_to_string) (const NMPlatformIPXRoute *route);
|
const char *(*route_to_string) (const NMPlatformIPXRoute *route);
|
||||||
GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
|
GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
||||||
gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
|
gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
|
||||||
gboolean (*route_delete) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
|
gboolean (*route_delete) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
|
||||||
gboolean (*route_delete_default) (NMPlatform *self, int ifindex, guint32 metric);
|
gboolean (*route_delete_default) (NMPlatform *self, int ifindex, guint32 metric);
|
||||||
@@ -517,8 +521,8 @@ typedef struct {
|
|||||||
|
|
||||||
gboolean (*ip4_check_reinstall_device_route) (NMPlatform *, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
|
gboolean (*ip4_check_reinstall_device_route) (NMPlatform *, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
|
||||||
|
|
||||||
GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteMode mode);
|
GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
|
||||||
GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteMode mode);
|
GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
|
||||||
gboolean (*ip4_route_add) (NMPlatform *, int ifindex, NMIPConfigSource source,
|
gboolean (*ip4_route_add) (NMPlatform *, int ifindex, NMIPConfigSource source,
|
||||||
in_addr_t network, int plen, in_addr_t gateway,
|
in_addr_t network, int plen, in_addr_t gateway,
|
||||||
guint32 pref_src, guint32 metric, guint32 mss);
|
guint32 pref_src, guint32 metric, guint32 mss);
|
||||||
@@ -707,8 +711,8 @@ gboolean nm_platform_address_flush (NMPlatform *self, int ifindex);
|
|||||||
|
|
||||||
gboolean nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
|
gboolean nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric);
|
||||||
|
|
||||||
GArray *nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
|
GArray *nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
||||||
GArray *nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode);
|
GArray *nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
||||||
gboolean nm_platform_ip4_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
|
gboolean nm_platform_ip4_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
|
||||||
in_addr_t network, int plen, in_addr_t gateway,
|
in_addr_t network, int plen, in_addr_t gateway,
|
||||||
guint32 pref_src, guint32 metric, guint32 mss);
|
guint32 pref_src, guint32 metric, guint32 mss);
|
||||||
|
@@ -86,8 +86,8 @@ dump_interface (NMPlatformLink *link)
|
|||||||
g_array_unref (ip4_addresses);
|
g_array_unref (ip4_addresses);
|
||||||
g_array_unref (ip6_addresses);
|
g_array_unref (ip6_addresses);
|
||||||
|
|
||||||
ip4_routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
ip4_routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
ip6_routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
ip6_routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
g_assert (ip4_routes);
|
g_assert (ip4_routes);
|
||||||
g_assert (ip6_routes);
|
g_assert (ip6_routes);
|
||||||
|
@@ -640,7 +640,7 @@ do_ip4_route_get_all (char **argv)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (ifindex) {
|
if (ifindex) {
|
||||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
for (i = 0; i < routes->len; i++) {
|
for (i = 0; i < routes->len; i++) {
|
||||||
route = &g_array_index (routes, NMPlatformIP4Route, i);
|
route = &g_array_index (routes, NMPlatformIP4Route, i);
|
||||||
inet_ntop (AF_INET, &route->network, networkstr, sizeof (networkstr));
|
inet_ntop (AF_INET, &route->network, networkstr, sizeof (networkstr));
|
||||||
@@ -664,7 +664,7 @@ do_ip6_route_get_all (char **argv)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (ifindex) {
|
if (ifindex) {
|
||||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
for (i = 0; i < routes->len; i++) {
|
for (i = 0; i < routes->len; i++) {
|
||||||
route = &g_array_index (routes, NMPlatformIP6Route, i);
|
route = &g_array_index (routes, NMPlatformIP6Route, i);
|
||||||
inet_ntop (AF_INET6, &route->network, networkstr, sizeof (networkstr));
|
inet_ntop (AF_INET6, &route->network, networkstr, sizeof (networkstr));
|
||||||
|
@@ -54,8 +54,8 @@ test_cleanup_internal (void)
|
|||||||
|
|
||||||
addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
g_assert_cmpint (addresses4->len, ==, 1);
|
g_assert_cmpint (addresses4->len, ==, 1);
|
||||||
g_assert_cmpint (addresses6->len, ==, 2); /* also has a IPv6 LL address. */
|
g_assert_cmpint (addresses6->len, ==, 2); /* also has a IPv6 LL address. */
|
||||||
@@ -72,8 +72,8 @@ test_cleanup_internal (void)
|
|||||||
|
|
||||||
addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex);
|
||||||
routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
g_assert_cmpint (addresses4->len, ==, 0);
|
g_assert_cmpint (addresses4->len, ==, 0);
|
||||||
g_assert_cmpint (addresses6->len, ==, 0);
|
g_assert_cmpint (addresses6->len, ==, 0);
|
||||||
|
@@ -155,7 +155,7 @@ test_ip4_route (void)
|
|||||||
accept_signals (route_changed, 0, 1);
|
accept_signals (route_changed, 0, 1);
|
||||||
|
|
||||||
/* Test route listing */
|
/* Test route listing */
|
||||||
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
memset (rts, 0, sizeof (rts));
|
memset (rts, 0, sizeof (rts));
|
||||||
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
||||||
rts[0].network = gateway;
|
rts[0].network = gateway;
|
||||||
@@ -242,7 +242,7 @@ test_ip6_route (void)
|
|||||||
accept_signals (route_changed, 0, 1);
|
accept_signals (route_changed, 0, 1);
|
||||||
|
|
||||||
/* Test route listing */
|
/* Test route listing */
|
||||||
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL);
|
routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
memset (rts, 0, sizeof (rts));
|
memset (rts, 0, sizeof (rts));
|
||||||
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
rts[0].source = NM_IP_CONFIG_SOURCE_USER;
|
||||||
rts[0].network = gateway;
|
rts[0].network = gateway;
|
||||||
|
@@ -144,10 +144,10 @@ ip4_routes (test_fixture *fixture)
|
|||||||
{
|
{
|
||||||
GArray *routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET,
|
GArray *routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET,
|
||||||
fixture->ifindex0,
|
fixture->ifindex0,
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
GArray *routes1 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET,
|
GArray *routes1 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET,
|
||||||
fixture->ifindex1,
|
fixture->ifindex1,
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
g_array_append_vals (routes, routes1->data, routes1->len);
|
g_array_append_vals (routes, routes1->data, routes1->len);
|
||||||
g_array_free (routes1, TRUE);
|
g_array_free (routes1, TRUE);
|
||||||
@@ -459,10 +459,10 @@ ip6_routes (test_fixture *fixture)
|
|||||||
{
|
{
|
||||||
GArray *routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET,
|
GArray *routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET,
|
||||||
fixture->ifindex0,
|
fixture->ifindex0,
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
GArray *routes1 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET,
|
GArray *routes1 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET,
|
||||||
fixture->ifindex1,
|
fixture->ifindex1,
|
||||||
NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT);
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
|
||||||
|
|
||||||
g_array_append_vals (routes, routes1->data, routes1->len);
|
g_array_append_vals (routes, routes1->data, routes1->len);
|
||||||
g_array_free (routes1, TRUE);
|
g_array_free (routes1, TRUE);
|
||||||
|
Reference in New Issue
Block a user