platform/trivial: rename ObjectType to NMPObjectType
After doing all the refactoring, rename the ObjectType enum to NMPObjectType. I didn't do this earlier to avoid problems with rebasing. But since I will backport the platform changes to nm-1-0, this is the right time to get the name right.
This commit is contained in:
@@ -468,7 +468,7 @@ _nl_sock_request_link (NMPlatform *platform, struct nl_sock *sk, int ifindex, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_nl_sock_request_all (NMPlatform *platform, struct nl_sock *sk, ObjectType obj_type, guint32 *out_seq)
|
_nl_sock_request_all (NMPlatform *platform, struct nl_sock *sk, NMPObjectType obj_type, guint32 *out_seq)
|
||||||
{
|
{
|
||||||
const NMPClass *klass;
|
const NMPClass *klass;
|
||||||
struct rtgenmsg gmsg = { 0 };
|
struct rtgenmsg gmsg = { 0 };
|
||||||
@@ -758,7 +758,7 @@ nm_linux_platform_setup (void)
|
|||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
ObjectType
|
NMPObjectType
|
||||||
_nlo_get_object_type (const struct nl_object *object)
|
_nlo_get_object_type (const struct nl_object *object)
|
||||||
{
|
{
|
||||||
const char *type_str;
|
const char *type_str;
|
||||||
@@ -767,22 +767,22 @@ _nlo_get_object_type (const struct nl_object *object)
|
|||||||
return OBJECT_TYPE_UNKNOWN;
|
return OBJECT_TYPE_UNKNOWN;
|
||||||
|
|
||||||
if (!strcmp (type_str, "route/link"))
|
if (!strcmp (type_str, "route/link"))
|
||||||
return OBJECT_TYPE_LINK;
|
return NMP_OBJECT_TYPE_LINK;
|
||||||
else if (!strcmp (type_str, "route/addr")) {
|
else if (!strcmp (type_str, "route/addr")) {
|
||||||
switch (rtnl_addr_get_family ((struct rtnl_addr *) object)) {
|
switch (rtnl_addr_get_family ((struct rtnl_addr *) object)) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
return OBJECT_TYPE_IP4_ADDRESS;
|
return NMP_OBJECT_TYPE_IP4_ADDRESS;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return OBJECT_TYPE_IP6_ADDRESS;
|
return NMP_OBJECT_TYPE_IP6_ADDRESS;
|
||||||
default:
|
default:
|
||||||
return OBJECT_TYPE_UNKNOWN;
|
return OBJECT_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
} else if (!strcmp (type_str, "route/route")) {
|
} else if (!strcmp (type_str, "route/route")) {
|
||||||
switch (rtnl_route_get_family ((struct rtnl_route *) object)) {
|
switch (rtnl_route_get_family ((struct rtnl_route *) object)) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
return OBJECT_TYPE_IP4_ROUTE;
|
return NMP_OBJECT_TYPE_IP4_ROUTE;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return OBJECT_TYPE_IP6_ROUTE;
|
return NMP_OBJECT_TYPE_IP6_ROUTE;
|
||||||
default:
|
default:
|
||||||
return OBJECT_TYPE_UNKNOWN;
|
return OBJECT_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -1420,27 +1420,27 @@ do_emit_signal (NMPlatform *platform, const NMPObject *obj, NMPCacheOpsType cach
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static DelayedActionType
|
static DelayedActionType
|
||||||
delayed_action_refresh_from_object_type (ObjectType obj_type)
|
delayed_action_refresh_from_object_type (NMPObjectType obj_type)
|
||||||
{
|
{
|
||||||
switch (obj_type) {
|
switch (obj_type) {
|
||||||
case OBJECT_TYPE_LINK: return DELAYED_ACTION_TYPE_REFRESH_ALL_LINKS;
|
case NMP_OBJECT_TYPE_LINK: return DELAYED_ACTION_TYPE_REFRESH_ALL_LINKS;
|
||||||
case OBJECT_TYPE_IP4_ADDRESS: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ADDRESSES;
|
case NMP_OBJECT_TYPE_IP4_ADDRESS: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ADDRESSES;
|
||||||
case OBJECT_TYPE_IP6_ADDRESS: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ADDRESSES;
|
case NMP_OBJECT_TYPE_IP6_ADDRESS: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ADDRESSES;
|
||||||
case OBJECT_TYPE_IP4_ROUTE: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ROUTES;
|
case NMP_OBJECT_TYPE_IP4_ROUTE: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ROUTES;
|
||||||
case OBJECT_TYPE_IP6_ROUTE: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ROUTES;
|
case NMP_OBJECT_TYPE_IP6_ROUTE: return DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ROUTES;
|
||||||
default: g_return_val_if_reached (DELAYED_ACTION_TYPE_NONE);
|
default: g_return_val_if_reached (DELAYED_ACTION_TYPE_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ObjectType
|
static NMPObjectType
|
||||||
delayed_action_refresh_to_object_type (DelayedActionType action_type)
|
delayed_action_refresh_to_object_type (DelayedActionType action_type)
|
||||||
{
|
{
|
||||||
switch (action_type) {
|
switch (action_type) {
|
||||||
case DELAYED_ACTION_TYPE_REFRESH_ALL_LINKS: return OBJECT_TYPE_LINK;
|
case DELAYED_ACTION_TYPE_REFRESH_ALL_LINKS: return NMP_OBJECT_TYPE_LINK;
|
||||||
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ADDRESSES: return OBJECT_TYPE_IP4_ADDRESS;
|
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ADDRESSES: return NMP_OBJECT_TYPE_IP4_ADDRESS;
|
||||||
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ADDRESSES: return OBJECT_TYPE_IP6_ADDRESS;
|
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ADDRESSES: return NMP_OBJECT_TYPE_IP6_ADDRESS;
|
||||||
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ROUTES: return OBJECT_TYPE_IP4_ROUTE;
|
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ROUTES: return NMP_OBJECT_TYPE_IP4_ROUTE;
|
||||||
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ROUTES: return OBJECT_TYPE_IP6_ROUTE;
|
case DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ROUTES: return NMP_OBJECT_TYPE_IP6_ROUTE;
|
||||||
default: g_return_val_if_reached (OBJECT_TYPE_UNKNOWN);
|
default: g_return_val_if_reached (OBJECT_TYPE_UNKNOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1626,7 +1626,7 @@ delayed_action_schedule (NMPlatform *platform, DelayedActionType action_type, gp
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cache_prune_candidates_record_all (NMPlatform *platform, ObjectType obj_type)
|
cache_prune_candidates_record_all (NMPlatform *platform, NMPObjectType obj_type)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
|
||||||
@@ -1768,7 +1768,7 @@ cache_pre_hook (NMPCache *cache, const NMPObject *old, const NMPObject *new, NMP
|
|||||||
: ""));
|
: ""));
|
||||||
|
|
||||||
switch (klass->obj_type) {
|
switch (klass->obj_type) {
|
||||||
case OBJECT_TYPE_LINK:
|
case NMP_OBJECT_TYPE_LINK:
|
||||||
{
|
{
|
||||||
/* check whether changing a slave link can cause a master link (bridge or bond) to go up/down */
|
/* check whether changing a slave link can cause a master link (bridge or bond) to go up/down */
|
||||||
if ( old
|
if ( old
|
||||||
@@ -1839,14 +1839,14 @@ cache_pre_hook (NMPCache *cache, const NMPObject *old, const NMPObject *new, NMP
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJECT_TYPE_IP4_ADDRESS:
|
case NMP_OBJECT_TYPE_IP4_ADDRESS:
|
||||||
case OBJECT_TYPE_IP6_ADDRESS:
|
case NMP_OBJECT_TYPE_IP6_ADDRESS:
|
||||||
{
|
{
|
||||||
/* Address deletion is sometimes accompanied by route deletion. We need to
|
/* Address deletion is sometimes accompanied by route deletion. We need to
|
||||||
* check all routes belonging to the same interface. */
|
* check all routes belonging to the same interface. */
|
||||||
if (ops_type == NMP_CACHE_OPS_REMOVED) {
|
if (ops_type == NMP_CACHE_OPS_REMOVED) {
|
||||||
delayed_action_schedule (platform,
|
delayed_action_schedule (platform,
|
||||||
(klass->obj_type == OBJECT_TYPE_IP4_ADDRESS)
|
(klass->obj_type == NMP_OBJECT_TYPE_IP4_ADDRESS)
|
||||||
? DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ROUTES
|
? DELAYED_ACTION_TYPE_REFRESH_ALL_IP4_ROUTES
|
||||||
: DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ROUTES,
|
: DELAYED_ACTION_TYPE_REFRESH_ALL_IP6_ROUTES,
|
||||||
NULL);
|
NULL);
|
||||||
@@ -1947,7 +1947,7 @@ do_request_link (NMPlatform *platform, int ifindex, const char *name, gboolean h
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_request_one_type (NMPlatform *platform, ObjectType obj_type, gboolean handle_delayed_action)
|
do_request_one_type (NMPlatform *platform, NMPObjectType obj_type, gboolean handle_delayed_action)
|
||||||
{
|
{
|
||||||
do_request_all (platform, delayed_action_refresh_from_object_type (obj_type), handle_delayed_action);
|
do_request_all (platform, delayed_action_refresh_from_object_type (obj_type), handle_delayed_action);
|
||||||
}
|
}
|
||||||
@@ -1969,11 +1969,11 @@ do_request_all (NMPlatform *platform, DelayedActionType action_type, gboolean ha
|
|||||||
|
|
||||||
for (iflags = (DelayedActionType) 0x1LL; iflags <= DELAYED_ACTION_TYPE_MAX; iflags <<= 1) {
|
for (iflags = (DelayedActionType) 0x1LL; iflags <= DELAYED_ACTION_TYPE_MAX; iflags <<= 1) {
|
||||||
if (NM_FLAGS_HAS (action_type, iflags)) {
|
if (NM_FLAGS_HAS (action_type, iflags)) {
|
||||||
ObjectType obj_type = delayed_action_refresh_to_object_type (iflags);
|
NMPObjectType obj_type = delayed_action_refresh_to_object_type (iflags);
|
||||||
|
|
||||||
/* clear any delayed action that request a refresh of this object type. */
|
/* clear any delayed action that request a refresh of this object type. */
|
||||||
priv->delayed_action.flags &= ~iflags;
|
priv->delayed_action.flags &= ~iflags;
|
||||||
if (obj_type == OBJECT_TYPE_LINK) {
|
if (obj_type == NMP_OBJECT_TYPE_LINK) {
|
||||||
priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_LINK;
|
priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_LINK;
|
||||||
g_ptr_array_set_size (priv->delayed_action.list_refresh_link, 0);
|
g_ptr_array_set_size (priv->delayed_action.list_refresh_link, 0);
|
||||||
}
|
}
|
||||||
@@ -1993,7 +1993,7 @@ do_request_all (NMPlatform *platform, DelayedActionType action_type, gboolean ha
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
kernel_add_object (NMPlatform *platform, ObjectType obj_type, const struct nl_object *nlo)
|
kernel_add_object (NMPlatform *platform, NMPObjectType obj_type, const struct nl_object *nlo)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
int nle;
|
int nle;
|
||||||
@@ -2001,15 +2001,15 @@ kernel_add_object (NMPlatform *platform, ObjectType obj_type, const struct nl_ob
|
|||||||
g_return_val_if_fail (nlo, FALSE);
|
g_return_val_if_fail (nlo, FALSE);
|
||||||
|
|
||||||
switch (obj_type) {
|
switch (obj_type) {
|
||||||
case OBJECT_TYPE_LINK:
|
case NMP_OBJECT_TYPE_LINK:
|
||||||
nle = rtnl_link_add (priv->nlh, (struct rtnl_link *) nlo, NLM_F_CREATE);
|
nle = rtnl_link_add (priv->nlh, (struct rtnl_link *) nlo, NLM_F_CREATE);
|
||||||
break;
|
break;
|
||||||
case OBJECT_TYPE_IP4_ADDRESS:
|
case NMP_OBJECT_TYPE_IP4_ADDRESS:
|
||||||
case OBJECT_TYPE_IP6_ADDRESS:
|
case NMP_OBJECT_TYPE_IP6_ADDRESS:
|
||||||
nle = rtnl_addr_add (priv->nlh, (struct rtnl_addr *) nlo, NLM_F_CREATE | NLM_F_REPLACE);
|
nle = rtnl_addr_add (priv->nlh, (struct rtnl_addr *) nlo, NLM_F_CREATE | NLM_F_REPLACE);
|
||||||
break;
|
break;
|
||||||
case OBJECT_TYPE_IP4_ROUTE:
|
case NMP_OBJECT_TYPE_IP4_ROUTE:
|
||||||
case OBJECT_TYPE_IP6_ROUTE:
|
case NMP_OBJECT_TYPE_IP6_ROUTE:
|
||||||
nle = rtnl_route_add (priv->nlh, (struct rtnl_route *) nlo, NLM_F_CREATE | NLM_F_REPLACE);
|
nle = rtnl_route_add (priv->nlh, (struct rtnl_route *) nlo, NLM_F_CREATE | NLM_F_REPLACE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2026,7 +2026,7 @@ kernel_add_object (NMPlatform *platform, ObjectType obj_type, const struct nl_ob
|
|||||||
/* NLE_EXIST is considered equivalent to success to avoid race conditions. You
|
/* NLE_EXIST is considered equivalent to success to avoid race conditions. You
|
||||||
* never know when something sends an identical object just before
|
* never know when something sends an identical object just before
|
||||||
* NetworkManager. */
|
* NetworkManager. */
|
||||||
if (obj_type != OBJECT_TYPE_LINK)
|
if (obj_type != NMP_OBJECT_TYPE_LINK)
|
||||||
return -NLE_SUCCESS;
|
return -NLE_SUCCESS;
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
default:
|
default:
|
||||||
@@ -2035,21 +2035,21 @@ kernel_add_object (NMPlatform *platform, ObjectType obj_type, const struct nl_ob
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
kernel_delete_object (NMPlatform *platform, ObjectType object_type, const struct nl_object *object)
|
kernel_delete_object (NMPlatform *platform, NMPObjectType object_type, const struct nl_object *object)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
int nle;
|
int nle;
|
||||||
|
|
||||||
switch (object_type) {
|
switch (object_type) {
|
||||||
case OBJECT_TYPE_LINK:
|
case NMP_OBJECT_TYPE_LINK:
|
||||||
nle = rtnl_link_delete (priv->nlh, (struct rtnl_link *) object);
|
nle = rtnl_link_delete (priv->nlh, (struct rtnl_link *) object);
|
||||||
break;
|
break;
|
||||||
case OBJECT_TYPE_IP4_ADDRESS:
|
case NMP_OBJECT_TYPE_IP4_ADDRESS:
|
||||||
case OBJECT_TYPE_IP6_ADDRESS:
|
case NMP_OBJECT_TYPE_IP6_ADDRESS:
|
||||||
nle = rtnl_addr_delete (priv->nlh, (struct rtnl_addr *) object, 0);
|
nle = rtnl_addr_delete (priv->nlh, (struct rtnl_addr *) object, 0);
|
||||||
break;
|
break;
|
||||||
case OBJECT_TYPE_IP4_ROUTE:
|
case NMP_OBJECT_TYPE_IP4_ROUTE:
|
||||||
case OBJECT_TYPE_IP6_ROUTE:
|
case NMP_OBJECT_TYPE_IP6_ROUTE:
|
||||||
nle = rtnl_route_delete (priv->nlh, (struct rtnl_route *) object, 0);
|
nle = rtnl_route_delete (priv->nlh, (struct rtnl_route *) object, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2064,7 +2064,7 @@ kernel_delete_object (NMPlatform *platform, ObjectType object_type, const struct
|
|||||||
nmp_class_from_type (object_type)->obj_type_name, nl_geterror (nle), -nle);
|
nmp_class_from_type (object_type)->obj_type_name, nl_geterror (nle), -nle);
|
||||||
return -NLE_SUCCESS;
|
return -NLE_SUCCESS;
|
||||||
case -NLE_FAILURE:
|
case -NLE_FAILURE:
|
||||||
if (object_type == OBJECT_TYPE_IP6_ADDRESS) {
|
if (object_type == NMP_OBJECT_TYPE_IP6_ADDRESS) {
|
||||||
/* On RHEL7 kernel, deleting a non existing address fails with ENXIO (which libnl maps to NLE_FAILURE) */
|
/* On RHEL7 kernel, deleting a non existing address fails with ENXIO (which libnl maps to NLE_FAILURE) */
|
||||||
_LOGT ("kernel-delete-%s: deleting address failed with \"%s\" (%d), meaning the address was already removed",
|
_LOGT ("kernel-delete-%s: deleting address failed with \"%s\" (%d), meaning the address was already removed",
|
||||||
nmp_class_from_type (object_type)->obj_type_name, nl_geterror (nle), -nle);
|
nmp_class_from_type (object_type)->obj_type_name, nl_geterror (nle), -nle);
|
||||||
@@ -2072,7 +2072,7 @@ kernel_delete_object (NMPlatform *platform, ObjectType object_type, const struct
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case -NLE_NOADDR:
|
case -NLE_NOADDR:
|
||||||
if (object_type == OBJECT_TYPE_IP4_ADDRESS || object_type == OBJECT_TYPE_IP6_ADDRESS) {
|
if (object_type == NMP_OBJECT_TYPE_IP4_ADDRESS || object_type == NMP_OBJECT_TYPE_IP6_ADDRESS) {
|
||||||
_LOGT ("kernel-delete-%s: deleting address failed with \"%s\" (%d), meaning the address was already removed",
|
_LOGT ("kernel-delete-%s: deleting address failed with \"%s\" (%d), meaning the address was already removed",
|
||||||
nmp_class_from_type (object_type)->obj_type_name, nl_geterror (nle), -nle);
|
nmp_class_from_type (object_type)->obj_type_name, nl_geterror (nle), -nle);
|
||||||
return -NLE_SUCCESS;
|
return -NLE_SUCCESS;
|
||||||
@@ -2274,7 +2274,7 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||||||
switch (msghdr->nlmsg_type) {
|
switch (msghdr->nlmsg_type) {
|
||||||
|
|
||||||
case RTM_NEWLINK:
|
case RTM_NEWLINK:
|
||||||
if ( NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK
|
if ( NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK
|
||||||
&& g_hash_table_lookup (priv->delayed_deletion, obj) != NULL) {
|
&& g_hash_table_lookup (priv->delayed_deletion, obj) != NULL) {
|
||||||
/* the object is scheduled for delayed deletion. Replace that object
|
/* the object is scheduled for delayed deletion. Replace that object
|
||||||
* by clearing the value from priv->delayed_deletion. */
|
* by clearing the value from priv->delayed_deletion. */
|
||||||
@@ -2288,7 +2288,7 @@ event_notification (struct nl_msg *msg, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RTM_DELLINK:
|
case RTM_DELLINK:
|
||||||
if ( NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK
|
if ( NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK
|
||||||
&& g_hash_table_contains (priv->delayed_deletion, obj)) {
|
&& g_hash_table_contains (priv->delayed_deletion, obj)) {
|
||||||
/* We sometimes receive spurious RTM_DELLINK events. In this case, we want to delay
|
/* We sometimes receive spurious RTM_DELLINK events. In this case, we want to delay
|
||||||
* the deletion of the object until later. */
|
* the deletion of the object until later. */
|
||||||
@@ -2496,8 +2496,8 @@ link_get_all (NMPlatform *platform)
|
|||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
OBJECT_TYPE_LINK,
|
NMP_OBJECT_TYPE_LINK,
|
||||||
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, OBJECT_TYPE_LINK, TRUE));
|
nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, NMP_OBJECT_TYPE_LINK, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -2579,7 +2579,7 @@ do_add_link (NMPlatform *platform, const char *name, const struct rtnl_link *nlo
|
|||||||
|
|
||||||
event_handler_read_netlink_all (platform, FALSE);
|
event_handler_read_netlink_all (platform, FALSE);
|
||||||
|
|
||||||
nle = kernel_add_object (platform, OBJECT_TYPE_LINK, (const struct nl_object *) nlo);
|
nle = kernel_add_object (platform, NMP_OBJECT_TYPE_LINK, (const struct nl_object *) nlo);
|
||||||
if (nle < 0) {
|
if (nle < 0) {
|
||||||
_LOGE ("do-add-link: failure adding link '%s': %s", name, nl_geterror (nle));
|
_LOGE ("do-add-link: failure adding link '%s': %s", name, nl_geterror (nle));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -2627,8 +2627,8 @@ do_add_addrroute (NMPlatform *platform, const NMPObject *obj_id, const struct nl
|
|||||||
int nle;
|
int nle;
|
||||||
|
|
||||||
nm_assert (NM_IN_SET (NMP_OBJECT_GET_TYPE (obj_id),
|
nm_assert (NM_IN_SET (NMP_OBJECT_GET_TYPE (obj_id),
|
||||||
OBJECT_TYPE_IP4_ADDRESS, OBJECT_TYPE_IP6_ADDRESS,
|
NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS,
|
||||||
OBJECT_TYPE_IP4_ROUTE, OBJECT_TYPE_IP6_ROUTE));
|
NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE));
|
||||||
|
|
||||||
event_handler_read_netlink_all (platform, FALSE);
|
event_handler_read_netlink_all (platform, FALSE);
|
||||||
|
|
||||||
@@ -2681,7 +2681,7 @@ do_delete_object (NMPlatform *platform, const NMPObject *obj_id, const struct nl
|
|||||||
|
|
||||||
/* FIXME: instead of re-requesting the deleted object, add it via nlh_event
|
/* FIXME: instead of re-requesting the deleted object, add it via nlh_event
|
||||||
* so that the events are in sync. */
|
* so that the events are in sync. */
|
||||||
if (NMP_OBJECT_GET_TYPE (obj_id) == OBJECT_TYPE_LINK) {
|
if (NMP_OBJECT_GET_TYPE (obj_id) == NMP_OBJECT_TYPE_LINK) {
|
||||||
const NMPObject *obj;
|
const NMPObject *obj;
|
||||||
|
|
||||||
obj = nmp_cache_lookup_link_full (priv->cache, obj_id->link.ifindex, obj_id->link.ifindex <= 0 && obj_id->link.name[0] ? obj_id->link.name : NULL, FALSE, NM_LINK_TYPE_NONE, NULL, NULL);
|
obj = nmp_cache_lookup_link_full (priv->cache, obj_id->link.ifindex, obj_id->link.ifindex <= 0 && obj_id->link.name[0] ? obj_id->link.name : NULL, FALSE, NM_LINK_TYPE_NONE, NULL, NULL);
|
||||||
@@ -4016,11 +4016,11 @@ link_get_driver_info (NMPlatform *platform,
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ipx_address_get_all (NMPlatform *platform, int ifindex, ObjectType obj_type)
|
ipx_address_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
|
|
||||||
nm_assert (NM_IN_SET (obj_type, OBJECT_TYPE_IP4_ADDRESS, OBJECT_TYPE_IP6_ADDRESS));
|
nm_assert (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS));
|
||||||
|
|
||||||
return nmp_cache_lookup_multi_to_array (priv->cache,
|
return nmp_cache_lookup_multi_to_array (priv->cache,
|
||||||
obj_type,
|
obj_type,
|
||||||
@@ -4032,13 +4032,13 @@ ipx_address_get_all (NMPlatform *platform, int ifindex, ObjectType obj_type)
|
|||||||
static GArray *
|
static GArray *
|
||||||
ip4_address_get_all (NMPlatform *platform, int ifindex)
|
ip4_address_get_all (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return ipx_address_get_all (platform, ifindex, OBJECT_TYPE_IP4_ADDRESS);
|
return ipx_address_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP4_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip6_address_get_all (NMPlatform *platform, int ifindex)
|
ip6_address_get_all (NMPlatform *platform, int ifindex)
|
||||||
{
|
{
|
||||||
return ipx_address_get_all (platform, ifindex, OBJECT_TYPE_IP6_ADDRESS);
|
return ipx_address_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP6_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
|
#define IPV4LL_NETWORK (htonl (0xA9FE0000L))
|
||||||
@@ -4283,12 +4283,12 @@ check_for_route:
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ipx_route_get_all (NMPlatform *platform, int ifindex, ObjectType obj_type, NMPlatformGetRouteMode mode)
|
ipx_route_get_all (NMPlatform *platform, int ifindex, NMPObjectType obj_type, NMPlatformGetRouteMode mode)
|
||||||
{
|
{
|
||||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
gboolean with_default = FALSE, with_non_default = FALSE;
|
gboolean with_default = FALSE, with_non_default = FALSE;
|
||||||
|
|
||||||
nm_assert (NM_IN_SET (obj_type, OBJECT_TYPE_IP4_ROUTE, 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 (mode == NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT)
|
||||||
with_non_default = TRUE;
|
with_non_default = TRUE;
|
||||||
@@ -4312,13 +4312,13 @@ ipx_route_get_all (NMPlatform *platform, int ifindex, ObjectType obj_type, NMPla
|
|||||||
static GArray *
|
static GArray *
|
||||||
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip4_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
||||||
{
|
{
|
||||||
return ipx_route_get_all (platform, ifindex, OBJECT_TYPE_IP4_ROUTE, mode);
|
return ipx_route_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP4_ROUTE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GArray *
|
static GArray *
|
||||||
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
ip6_route_get_all (NMPlatform *platform, int ifindex, NMPlatformGetRouteMode mode)
|
||||||
{
|
{
|
||||||
return ipx_route_get_all (platform, ifindex, OBJECT_TYPE_IP6_ROUTE, mode);
|
return ipx_route_get_all (platform, ifindex, NMP_OBJECT_TYPE_IP6_ROUTE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4485,7 +4485,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen
|
|||||||
* FIXME: once our ip4_address_add() is sure that upon return we have
|
* FIXME: once our ip4_address_add() is sure that upon return we have
|
||||||
* the latest state from in the platform cache, we might save this
|
* the latest state from in the platform cache, we might save this
|
||||||
* additional expensive cache-resync. */
|
* additional expensive cache-resync. */
|
||||||
do_request_one_type (platform, OBJECT_TYPE_IP4_ROUTE, TRUE);
|
do_request_one_type (platform, NMP_OBJECT_TYPE_IP4_ROUTE, TRUE);
|
||||||
|
|
||||||
obj = nmp_cache_lookup_obj (priv->cache, &obj_needle);
|
obj = nmp_cache_lookup_obj (priv->cache, &obj_needle);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
@@ -134,7 +134,7 @@ _nmp_object_fixup_link_udev_fields (NMPObject *obj, gboolean use_udev)
|
|||||||
const char *driver = NULL;
|
const char *driver = NULL;
|
||||||
gboolean initialized = FALSE;
|
gboolean initialized = FALSE;
|
||||||
|
|
||||||
nm_assert (NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK);
|
nm_assert (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK);
|
||||||
|
|
||||||
/* The link contains internal fields that are combined by
|
/* The link contains internal fields that are combined by
|
||||||
* properties from netlink and udev. Update those properties */
|
* properties from netlink and udev. Update those properties */
|
||||||
@@ -169,7 +169,7 @@ _nmp_object_fixup_link_udev_fields (NMPObject *obj, gboolean use_udev)
|
|||||||
static void
|
static void
|
||||||
_nmp_object_fixup_link_master_connected (NMPObject *obj, const NMPCache *cache)
|
_nmp_object_fixup_link_master_connected (NMPObject *obj, const NMPCache *cache)
|
||||||
{
|
{
|
||||||
nm_assert (NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK);
|
nm_assert (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK);
|
||||||
|
|
||||||
if (nmp_cache_link_connected_needs_toggle (cache, obj, NULL, NULL))
|
if (nmp_cache_link_connected_needs_toggle (cache, obj, NULL, NULL))
|
||||||
obj->link.connected = !obj->link.connected;
|
obj->link.connected = !obj->link.connected;
|
||||||
@@ -178,7 +178,7 @@ _nmp_object_fixup_link_master_connected (NMPObject *obj, const NMPCache *cache)
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
const NMPClass *
|
const NMPClass *
|
||||||
nmp_class_from_type (ObjectType obj_type)
|
nmp_class_from_type (NMPObjectType obj_type)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (obj_type > OBJECT_TYPE_UNKNOWN && obj_type <= OBJECT_TYPE_MAX, NULL);
|
g_return_val_if_fail (obj_type > OBJECT_TYPE_UNKNOWN && obj_type <= OBJECT_TYPE_MAX, NULL);
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ _nmp_object_new_from_class (const NMPClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMPObject *
|
NMPObject *
|
||||||
nmp_object_new (ObjectType obj_type, const NMPlatformObject *plobj)
|
nmp_object_new (NMPObjectType obj_type, const NMPlatformObject *plobj)
|
||||||
{
|
{
|
||||||
const NMPClass *klass = nmp_class_from_type (obj_type);
|
const NMPClass *klass = nmp_class_from_type (obj_type);
|
||||||
NMPObject *obj;
|
NMPObject *obj;
|
||||||
@@ -258,7 +258,7 @@ nmp_object_new_link (int ifindex)
|
|||||||
{
|
{
|
||||||
NMPObject *obj;
|
NMPObject *obj;
|
||||||
|
|
||||||
obj = nmp_object_new (OBJECT_TYPE_LINK, NULL);
|
obj = nmp_object_new (NMP_OBJECT_TYPE_LINK, NULL);
|
||||||
obj->link.ifindex = ifindex;
|
obj->link.ifindex = ifindex;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ _nmp_object_stackinit_from_class (NMPObject *obj, const NMPClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NMPObject *
|
const NMPObject *
|
||||||
nmp_object_stackinit (NMPObject *obj, ObjectType obj_type, const NMPlatformObject *plobj)
|
nmp_object_stackinit (NMPObject *obj, NMPObjectType obj_type, const NMPlatformObject *plobj)
|
||||||
{
|
{
|
||||||
const NMPClass *klass = nmp_class_from_type (obj_type);
|
const NMPClass *klass = nmp_class_from_type (obj_type);
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src)
|
|||||||
const NMPObject *
|
const NMPObject *
|
||||||
nmp_object_stackinit_id_link (NMPObject *obj, int ifindex)
|
nmp_object_stackinit_id_link (NMPObject *obj, int ifindex)
|
||||||
{
|
{
|
||||||
nmp_object_stackinit (obj, OBJECT_TYPE_LINK, NULL);
|
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_LINK, NULL);
|
||||||
obj->link.ifindex = ifindex;
|
obj->link.ifindex = ifindex;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -314,7 +314,7 @@ _vt_cmd_obj_stackinit_id_link (NMPObject *obj, const NMPObject *src)
|
|||||||
const NMPObject *
|
const NMPObject *
|
||||||
nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, int plen)
|
nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, int plen)
|
||||||
{
|
{
|
||||||
nmp_object_stackinit (obj, OBJECT_TYPE_IP4_ADDRESS, NULL);
|
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP4_ADDRESS, NULL);
|
||||||
obj->ip4_address.ifindex = ifindex;
|
obj->ip4_address.ifindex = ifindex;
|
||||||
obj->ip4_address.address = address;
|
obj->ip4_address.address = address;
|
||||||
obj->ip4_address.plen = plen;
|
obj->ip4_address.plen = plen;
|
||||||
@@ -330,7 +330,7 @@ _vt_cmd_obj_stackinit_id_ip4_address (NMPObject *obj, const NMPObject *src)
|
|||||||
const NMPObject *
|
const NMPObject *
|
||||||
nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, int plen)
|
nmp_object_stackinit_id_ip6_address (NMPObject *obj, int ifindex, const struct in6_addr *address, int plen)
|
||||||
{
|
{
|
||||||
nmp_object_stackinit (obj, OBJECT_TYPE_IP6_ADDRESS, NULL);
|
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP6_ADDRESS, NULL);
|
||||||
obj->ip4_address.ifindex = ifindex;
|
obj->ip4_address.ifindex = ifindex;
|
||||||
if (address)
|
if (address)
|
||||||
obj->ip6_address.address = *address;
|
obj->ip6_address.address = *address;
|
||||||
@@ -347,7 +347,7 @@ _vt_cmd_obj_stackinit_id_ip6_address (NMPObject *obj, const NMPObject *src)
|
|||||||
const NMPObject *
|
const NMPObject *
|
||||||
nmp_object_stackinit_id_ip4_route (NMPObject *obj, int ifindex, guint32 network, int plen, guint32 metric)
|
nmp_object_stackinit_id_ip4_route (NMPObject *obj, int ifindex, guint32 network, int plen, guint32 metric)
|
||||||
{
|
{
|
||||||
nmp_object_stackinit (obj, OBJECT_TYPE_IP4_ROUTE, NULL);
|
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP4_ROUTE, NULL);
|
||||||
obj->ip4_route.ifindex = ifindex;
|
obj->ip4_route.ifindex = ifindex;
|
||||||
obj->ip4_route.network = network;
|
obj->ip4_route.network = network;
|
||||||
obj->ip4_route.plen = plen;
|
obj->ip4_route.plen = plen;
|
||||||
@@ -364,7 +364,7 @@ _vt_cmd_obj_stackinit_id_ip4_route (NMPObject *obj, const NMPObject *src)
|
|||||||
const NMPObject *
|
const NMPObject *
|
||||||
nmp_object_stackinit_id_ip6_route (NMPObject *obj, int ifindex, const struct in6_addr *network, int plen, guint32 metric)
|
nmp_object_stackinit_id_ip6_route (NMPObject *obj, int ifindex, const struct in6_addr *network, int plen, guint32 metric)
|
||||||
{
|
{
|
||||||
nmp_object_stackinit (obj, OBJECT_TYPE_IP6_ROUTE, NULL);
|
nmp_object_stackinit (obj, NMP_OBJECT_TYPE_IP6_ROUTE, NULL);
|
||||||
obj->ip6_route.ifindex = ifindex;
|
obj->ip6_route.ifindex = ifindex;
|
||||||
if (network)
|
if (network)
|
||||||
obj->ip6_route.network = *network;
|
obj->ip6_route.network = *network;
|
||||||
@@ -409,7 +409,7 @@ nmp_object_to_string (const NMPObject *obj, NMPObjectToStringMode to_string_mode
|
|||||||
case NMP_OBJECT_TO_STRING_ALL:
|
case NMP_OBJECT_TO_STRING_ALL:
|
||||||
g_strlcpy (buf2, NMP_OBJECT_GET_CLASS (obj)->cmd_plobj_to_string (&obj->object), sizeof (buf2));
|
g_strlcpy (buf2, NMP_OBJECT_GET_CLASS (obj)->cmd_plobj_to_string (&obj->object), sizeof (buf2));
|
||||||
|
|
||||||
if (NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK) {
|
if (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK) {
|
||||||
g_snprintf (buf3, sizeof (buf3),
|
g_snprintf (buf3, sizeof (buf3),
|
||||||
",%cin-nl,%p",
|
",%cin-nl,%p",
|
||||||
obj->_link.netlink.is_in_netlink ? '+' : '-',
|
obj->_link.netlink.is_in_netlink ? '+' : '-',
|
||||||
@@ -806,7 +806,7 @@ _vt_cmd_obj_is_visible_ipx_route (const NMPObject *obj)
|
|||||||
NMPObject *
|
NMPObject *
|
||||||
nmp_object_from_nl (NMPlatform *platform, const struct nl_object *nlo, gboolean id_only, gboolean complete_from_cache)
|
nmp_object_from_nl (NMPlatform *platform, const struct nl_object *nlo, gboolean id_only, gboolean complete_from_cache)
|
||||||
{
|
{
|
||||||
ObjectType obj_type = _nlo_get_object_type (nlo);
|
NMPObjectType obj_type = _nlo_get_object_type (nlo);
|
||||||
NMPObject *obj;
|
NMPObject *obj;
|
||||||
|
|
||||||
if (obj_type == OBJECT_TYPE_UNKNOWN)
|
if (obj_type == OBJECT_TYPE_UNKNOWN)
|
||||||
@@ -882,7 +882,7 @@ _nmp_cache_id_init (NMPCacheId *id, NMPCacheIdType id_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMPCacheId *
|
NMPCacheId *
|
||||||
nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type, gboolean visible_only)
|
nmp_cache_id_init_object_type (NMPCacheId *id, NMPObjectType obj_type, gboolean visible_only)
|
||||||
{
|
{
|
||||||
_nmp_cache_id_init (id, visible_only
|
_nmp_cache_id_init (id, visible_only
|
||||||
? NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY
|
? NMP_CACHE_ID_TYPE_OBJECT_TYPE_VISIBLE_ONLY
|
||||||
@@ -893,12 +893,12 @@ nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type, gboolean vis
|
|||||||
|
|
||||||
NMPCacheId *
|
NMPCacheId *
|
||||||
nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id,
|
nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id,
|
||||||
ObjectType obj_type,
|
NMPObjectType obj_type,
|
||||||
int ifindex)
|
int ifindex)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IN_SET (obj_type,
|
g_return_val_if_fail (NM_IN_SET (obj_type,
|
||||||
OBJECT_TYPE_IP4_ADDRESS, OBJECT_TYPE_IP4_ROUTE,
|
NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP4_ROUTE,
|
||||||
OBJECT_TYPE_IP6_ADDRESS, OBJECT_TYPE_IP6_ROUTE), NULL);
|
NMP_OBJECT_TYPE_IP6_ADDRESS, NMP_OBJECT_TYPE_IP6_ROUTE), NULL);
|
||||||
|
|
||||||
if (ifindex <= 0)
|
if (ifindex <= 0)
|
||||||
return nmp_cache_id_init_object_type (id, obj_type, TRUE);
|
return nmp_cache_id_init_object_type (id, obj_type, TRUE);
|
||||||
@@ -911,12 +911,12 @@ nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id,
|
|||||||
|
|
||||||
NMPCacheId *
|
NMPCacheId *
|
||||||
nmp_cache_id_init_routes_visible (NMPCacheId *id,
|
nmp_cache_id_init_routes_visible (NMPCacheId *id,
|
||||||
ObjectType obj_type,
|
NMPObjectType obj_type,
|
||||||
gboolean with_default,
|
gboolean with_default,
|
||||||
gboolean with_non_default,
|
gboolean with_non_default,
|
||||||
int ifindex)
|
int ifindex)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IN_SET (obj_type, OBJECT_TYPE_IP4_ROUTE, OBJECT_TYPE_IP6_ROUTE), NULL);
|
g_return_val_if_fail (NM_IN_SET (obj_type, NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE), NULL);
|
||||||
|
|
||||||
if (with_default && with_non_default) {
|
if (with_default && with_non_default) {
|
||||||
if (ifindex <= 0)
|
if (ifindex <= 0)
|
||||||
@@ -1092,7 +1092,7 @@ nmp_cache_link_connected_needs_toggle (const NMPCache *cache, const NMPObject *m
|
|||||||
guint len, i;
|
guint len, i;
|
||||||
|
|
||||||
if ( !master
|
if ( !master
|
||||||
|| NMP_OBJECT_GET_TYPE (master) != OBJECT_TYPE_LINK
|
|| NMP_OBJECT_GET_TYPE (master) != NMP_OBJECT_TYPE_LINK
|
||||||
|| master->link.ifindex <= 0
|
|| master->link.ifindex <= 0
|
||||||
|| !nmp_object_is_visible (master)
|
|| !nmp_object_is_visible (master)
|
||||||
|| !NM_IN_SET (master->link.type, NM_LINK_TYPE_BRIDGE, NM_LINK_TYPE_BOND))
|
|| !NM_IN_SET (master->link.type, NM_LINK_TYPE_BRIDGE, NM_LINK_TYPE_BOND))
|
||||||
@@ -1103,7 +1103,7 @@ nmp_cache_link_connected_needs_toggle (const NMPCache *cache, const NMPObject *m
|
|||||||
if (!NM_FLAGS_HAS (master->link.flags, IFF_LOWER_UP))
|
if (!NM_FLAGS_HAS (master->link.flags, IFF_LOWER_UP))
|
||||||
return !!master->link.connected;
|
return !!master->link.connected;
|
||||||
|
|
||||||
if (potential_slave && NMP_OBJECT_GET_TYPE (potential_slave) != OBJECT_TYPE_LINK)
|
if (potential_slave && NMP_OBJECT_GET_TYPE (potential_slave) != NMP_OBJECT_TYPE_LINK)
|
||||||
potential_slave = NULL;
|
potential_slave = NULL;
|
||||||
|
|
||||||
if ( potential_slave
|
if ( potential_slave
|
||||||
@@ -1113,12 +1113,12 @@ nmp_cache_link_connected_needs_toggle (const NMPCache *cache, const NMPObject *m
|
|||||||
&& potential_slave->link.connected) {
|
&& potential_slave->link.connected) {
|
||||||
is_lower_up = TRUE;
|
is_lower_up = TRUE;
|
||||||
} else {
|
} else {
|
||||||
links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, OBJECT_TYPE_LINK, FALSE), &len);
|
links = (const NMPlatformLink *const *) nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (NMP_CACHE_ID_STATIC, NMP_OBJECT_TYPE_LINK, FALSE), &len);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const NMPlatformLink *link = links[i];
|
const NMPlatformLink *link = links[i];
|
||||||
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
|
const NMPObject *obj = NMP_OBJECT_UP_CAST ((NMPlatformObject *) link);
|
||||||
|
|
||||||
nm_assert (NMP_OBJECT_GET_TYPE (NMP_OBJECT_UP_CAST ((NMPlatformObject *) link)) == OBJECT_TYPE_LINK);
|
nm_assert (NMP_OBJECT_GET_TYPE (NMP_OBJECT_UP_CAST ((NMPlatformObject *) link)) == NMP_OBJECT_TYPE_LINK);
|
||||||
|
|
||||||
if ( (!potential_slave || potential_slave->link.ifindex != link->ifindex)
|
if ( (!potential_slave || potential_slave->link.ifindex != link->ifindex)
|
||||||
&& ignore_slave != obj
|
&& ignore_slave != obj
|
||||||
@@ -1177,7 +1177,7 @@ nmp_cache_lookup_multi (const NMPCache *cache, const NMPCacheId *cache_id, guint
|
|||||||
}
|
}
|
||||||
|
|
||||||
GArray *
|
GArray *
|
||||||
nmp_cache_lookup_multi_to_array (const NMPCache *cache, ObjectType obj_type, const NMPCacheId *cache_id)
|
nmp_cache_lookup_multi_to_array (const NMPCache *cache, NMPObjectType obj_type, const NMPCacheId *cache_id)
|
||||||
{
|
{
|
||||||
const NMPClass *klass = nmp_class_from_type (obj_type);
|
const NMPClass *klass = nmp_class_from_type (obj_type);
|
||||||
guint len, i;
|
guint len, i;
|
||||||
@@ -1240,7 +1240,7 @@ nmp_cache_lookup_link_full (const NMPCache *cache,
|
|||||||
} else if (!ifname && !match_fn)
|
} else if (!ifname && !match_fn)
|
||||||
return NULL;
|
return NULL;
|
||||||
else {
|
else {
|
||||||
list = nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (&cache_id, OBJECT_TYPE_LINK, visible_only), &len);
|
list = nmp_cache_lookup_multi (cache, nmp_cache_id_init_object_type (&cache_id, NMP_OBJECT_TYPE_LINK, visible_only), &len);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
obj = NMP_OBJECT_UP_CAST (list[i]);
|
obj = NMP_OBJECT_UP_CAST (list[i]);
|
||||||
|
|
||||||
@@ -1393,7 +1393,7 @@ nmp_cache_remove (NMPCache *cache, const NMPObject *obj, gboolean equals_by_ptr,
|
|||||||
NMPCacheOpsType
|
NMPCacheOpsType
|
||||||
nmp_cache_remove_netlink (NMPCache *cache, const NMPObject *obj_needle, NMPObject **out_obj, gboolean *out_was_visible, NMPCachePreHook pre_hook, gpointer user_data)
|
nmp_cache_remove_netlink (NMPCache *cache, const NMPObject *obj_needle, NMPObject **out_obj, gboolean *out_was_visible, NMPCachePreHook pre_hook, gpointer user_data)
|
||||||
{
|
{
|
||||||
if (NMP_OBJECT_GET_TYPE (obj_needle) == OBJECT_TYPE_LINK) {
|
if (NMP_OBJECT_GET_TYPE (obj_needle) == NMP_OBJECT_TYPE_LINK) {
|
||||||
NMPObject *old;
|
NMPObject *old;
|
||||||
auto_nmp_obj NMPObject *obj = NULL;
|
auto_nmp_obj NMPObject *obj = NULL;
|
||||||
|
|
||||||
@@ -1479,7 +1479,7 @@ nmp_cache_update_netlink (NMPCache *cache, NMPObject *obj, NMPObject **out_obj,
|
|||||||
/* A link object from netlink must have the udev related fields unset.
|
/* A link object from netlink must have the udev related fields unset.
|
||||||
* We could implement to handle that, but there is no need to support such
|
* We could implement to handle that, but there is no need to support such
|
||||||
* a use-case */
|
* a use-case */
|
||||||
nm_assert (NMP_OBJECT_GET_TYPE (obj) != OBJECT_TYPE_LINK ||
|
nm_assert (NMP_OBJECT_GET_TYPE (obj) != NMP_OBJECT_TYPE_LINK ||
|
||||||
( !obj->_link.udev.device
|
( !obj->_link.udev.device
|
||||||
&& !obj->link.driver));
|
&& !obj->link.driver));
|
||||||
|
|
||||||
@@ -1494,7 +1494,7 @@ nmp_cache_update_netlink (NMPCache *cache, NMPObject *obj, NMPObject **out_obj,
|
|||||||
if (!nmp_object_is_alive (obj))
|
if (!nmp_object_is_alive (obj))
|
||||||
return NMP_CACHE_OPS_UNCHANGED;
|
return NMP_CACHE_OPS_UNCHANGED;
|
||||||
|
|
||||||
if (NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK) {
|
if (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK) {
|
||||||
_nmp_object_fixup_link_master_connected (obj, cache);
|
_nmp_object_fixup_link_master_connected (obj, cache);
|
||||||
_nmp_object_fixup_link_udev_fields (obj, cache->use_udev);
|
_nmp_object_fixup_link_udev_fields (obj, cache->use_udev);
|
||||||
}
|
}
|
||||||
@@ -1536,7 +1536,7 @@ nmp_cache_update_netlink (NMPCache *cache, NMPObject *obj, NMPObject **out_obj,
|
|||||||
if (out_was_visible)
|
if (out_was_visible)
|
||||||
*out_was_visible = nmp_object_is_visible (old);
|
*out_was_visible = nmp_object_is_visible (old);
|
||||||
|
|
||||||
if (NMP_OBJECT_GET_TYPE (obj) == OBJECT_TYPE_LINK) {
|
if (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK) {
|
||||||
if (!obj->_link.netlink.is_in_netlink) {
|
if (!obj->_link.netlink.is_in_netlink) {
|
||||||
if (!old->_link.netlink.is_in_netlink) {
|
if (!old->_link.netlink.is_in_netlink) {
|
||||||
nm_assert (old->_link.udev.device);
|
nm_assert (old->_link.udev.device);
|
||||||
@@ -1603,7 +1603,7 @@ nmp_cache_update_link_udev (NMPCache *cache, int ifindex, GUdevDevice *udev_devi
|
|||||||
if (!udev_device)
|
if (!udev_device)
|
||||||
return NMP_CACHE_OPS_UNCHANGED;
|
return NMP_CACHE_OPS_UNCHANGED;
|
||||||
|
|
||||||
obj = nmp_object_new (OBJECT_TYPE_LINK, NULL);
|
obj = nmp_object_new (NMP_OBJECT_TYPE_LINK, NULL);
|
||||||
obj->link.ifindex = ifindex;
|
obj->link.ifindex = ifindex;
|
||||||
obj->_link.udev.device = g_object_ref (udev_device);
|
obj->_link.udev.device = g_object_ref (udev_device);
|
||||||
|
|
||||||
@@ -1793,8 +1793,8 @@ ASSERT_nmp_cache_is_consistent (const NMPCache *cache)
|
|||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
||||||
const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
||||||
[OBJECT_TYPE_LINK - 1] = {
|
[NMP_OBJECT_TYPE_LINK - 1] = {
|
||||||
.obj_type = OBJECT_TYPE_LINK,
|
.obj_type = NMP_OBJECT_TYPE_LINK,
|
||||||
.sizeof_data = sizeof (NMPObjectLink),
|
.sizeof_data = sizeof (NMPObjectLink),
|
||||||
.sizeof_public = sizeof (NMPlatformLink),
|
.sizeof_public = sizeof (NMPlatformLink),
|
||||||
.obj_type_name = "link",
|
.obj_type_name = "link",
|
||||||
@@ -1818,8 +1818,8 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_link_to_string,
|
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_link_to_string,
|
||||||
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_link_cmp,
|
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_link_cmp,
|
||||||
},
|
},
|
||||||
[OBJECT_TYPE_IP4_ADDRESS - 1] = {
|
[NMP_OBJECT_TYPE_IP4_ADDRESS - 1] = {
|
||||||
.obj_type = OBJECT_TYPE_IP4_ADDRESS,
|
.obj_type = NMP_OBJECT_TYPE_IP4_ADDRESS,
|
||||||
.sizeof_data = sizeof (NMPObjectIP4Address),
|
.sizeof_data = sizeof (NMPObjectIP4Address),
|
||||||
.sizeof_public = sizeof (NMPlatformIP4Address),
|
.sizeof_public = sizeof (NMPlatformIP4Address),
|
||||||
.obj_type_name = "ip4-address",
|
.obj_type_name = "ip4-address",
|
||||||
@@ -1842,8 +1842,8 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_ip4_address_to_string,
|
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_ip4_address_to_string,
|
||||||
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip4_address_cmp,
|
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip4_address_cmp,
|
||||||
},
|
},
|
||||||
[OBJECT_TYPE_IP6_ADDRESS - 1] = {
|
[NMP_OBJECT_TYPE_IP6_ADDRESS - 1] = {
|
||||||
.obj_type = OBJECT_TYPE_IP6_ADDRESS,
|
.obj_type = NMP_OBJECT_TYPE_IP6_ADDRESS,
|
||||||
.sizeof_data = sizeof (NMPObjectIP6Address),
|
.sizeof_data = sizeof (NMPObjectIP6Address),
|
||||||
.sizeof_public = sizeof (NMPlatformIP6Address),
|
.sizeof_public = sizeof (NMPlatformIP6Address),
|
||||||
.obj_type_name = "ip6-address",
|
.obj_type_name = "ip6-address",
|
||||||
@@ -1866,8 +1866,8 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_ip6_address_to_string,
|
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_ip6_address_to_string,
|
||||||
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip6_address_cmp
|
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip6_address_cmp
|
||||||
},
|
},
|
||||||
[OBJECT_TYPE_IP4_ROUTE - 1] = {
|
[NMP_OBJECT_TYPE_IP4_ROUTE - 1] = {
|
||||||
.obj_type = OBJECT_TYPE_IP4_ROUTE,
|
.obj_type = NMP_OBJECT_TYPE_IP4_ROUTE,
|
||||||
.sizeof_data = sizeof (NMPObjectIP4Route),
|
.sizeof_data = sizeof (NMPObjectIP4Route),
|
||||||
.sizeof_public = sizeof (NMPlatformIP4Route),
|
.sizeof_public = sizeof (NMPlatformIP4Route),
|
||||||
.obj_type_name = "ip4-route",
|
.obj_type_name = "ip4-route",
|
||||||
@@ -1890,8 +1890,8 @@ const NMPClass _nmp_classes[OBJECT_TYPE_MAX] = {
|
|||||||
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_ip4_route_to_string,
|
.cmd_plobj_to_string = (const char *(*) (const NMPlatformObject *obj)) nm_platform_ip4_route_to_string,
|
||||||
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip4_route_cmp,
|
.cmd_plobj_cmp = (int (*) (const NMPlatformObject *obj1, const NMPlatformObject *obj2)) nm_platform_ip4_route_cmp,
|
||||||
},
|
},
|
||||||
[OBJECT_TYPE_IP6_ROUTE - 1] = {
|
[NMP_OBJECT_TYPE_IP6_ROUTE - 1] = {
|
||||||
.obj_type = OBJECT_TYPE_IP6_ROUTE,
|
.obj_type = NMP_OBJECT_TYPE_IP6_ROUTE,
|
||||||
.sizeof_data = sizeof (NMPObjectIP6Route),
|
.sizeof_data = sizeof (NMPObjectIP6Route),
|
||||||
.sizeof_public = sizeof (NMPlatformIP6Route),
|
.sizeof_public = sizeof (NMPlatformIP6Route),
|
||||||
.obj_type_name = "ip6-route",
|
.obj_type_name = "ip6-route",
|
||||||
|
@@ -33,14 +33,14 @@
|
|||||||
|
|
||||||
typedef enum { /*< skip >*/
|
typedef enum { /*< skip >*/
|
||||||
OBJECT_TYPE_UNKNOWN,
|
OBJECT_TYPE_UNKNOWN,
|
||||||
OBJECT_TYPE_LINK,
|
NMP_OBJECT_TYPE_LINK,
|
||||||
OBJECT_TYPE_IP4_ADDRESS,
|
NMP_OBJECT_TYPE_IP4_ADDRESS,
|
||||||
OBJECT_TYPE_IP6_ADDRESS,
|
NMP_OBJECT_TYPE_IP6_ADDRESS,
|
||||||
OBJECT_TYPE_IP4_ROUTE,
|
NMP_OBJECT_TYPE_IP4_ROUTE,
|
||||||
OBJECT_TYPE_IP6_ROUTE,
|
NMP_OBJECT_TYPE_IP6_ROUTE,
|
||||||
__OBJECT_TYPE_LAST,
|
__OBJECT_TYPE_LAST,
|
||||||
OBJECT_TYPE_MAX = __OBJECT_TYPE_LAST - 1,
|
OBJECT_TYPE_MAX = __OBJECT_TYPE_LAST - 1,
|
||||||
} ObjectType;
|
} NMPObjectType;
|
||||||
|
|
||||||
typedef enum { /*< skip >*/
|
typedef enum { /*< skip >*/
|
||||||
NMP_OBJECT_TO_STRING_ID,
|
NMP_OBJECT_TO_STRING_ID,
|
||||||
@@ -105,14 +105,14 @@ typedef struct {
|
|||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT */
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_NO_DEFAULT */
|
||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT */
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_ONLY_DEFAULT */
|
||||||
guint8 _id_type;
|
guint8 _id_type;
|
||||||
guint8 obj_type; /* ObjectType as guint8 */
|
guint8 obj_type; /* NMPObjectType as guint8 */
|
||||||
} object_type;
|
} object_type;
|
||||||
struct {
|
struct {
|
||||||
/* NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX */
|
/* NMP_CACHE_ID_TYPE_ADDRROUTE_VISIBLE_BY_IFINDEX */
|
||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT */
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_NO_DEFAULT */
|
||||||
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT */
|
/* NMP_CACHE_ID_TYPE_ROUTES_VISIBLE_BY_IFINDEX_ONLY_DEFAULT */
|
||||||
guint8 _id_type;
|
guint8 _id_type;
|
||||||
guint8 obj_type; /* ObjectType as guint8 */
|
guint8 obj_type; /* NMPObjectType as guint8 */
|
||||||
int ifindex;
|
int ifindex;
|
||||||
} object_type_by_ifindex;
|
} object_type_by_ifindex;
|
||||||
};
|
};
|
||||||
@@ -122,7 +122,7 @@ extern NMPCacheId _nmp_cache_id_static;
|
|||||||
#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static)
|
#define NMP_CACHE_ID_STATIC (&_nmp_cache_id_static)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ObjectType obj_type;
|
NMPObjectType obj_type;
|
||||||
int addr_family;
|
int addr_family;
|
||||||
int rtm_gettype;
|
int rtm_gettype;
|
||||||
int sizeof_data;
|
int sizeof_data;
|
||||||
@@ -260,7 +260,7 @@ NMP_OBJECT_GET_CLASS (const NMPObject *obj)
|
|||||||
return obj->_class;
|
return obj->_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ObjectType
|
static inline NMPObjectType
|
||||||
NMP_OBJECT_GET_TYPE (const NMPObject *obj)
|
NMP_OBJECT_GET_TYPE (const NMPObject *obj)
|
||||||
{
|
{
|
||||||
nm_assert (!obj || NMP_OBJECT_IS_VALID (obj));
|
nm_assert (!obj || NMP_OBJECT_IS_VALID (obj));
|
||||||
@@ -270,14 +270,14 @@ NMP_OBJECT_GET_TYPE (const NMPObject *obj)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const NMPClass *nmp_class_from_type (ObjectType obj_type);
|
const NMPClass *nmp_class_from_type (NMPObjectType obj_type);
|
||||||
|
|
||||||
NMPObject *nmp_object_ref (NMPObject *object);
|
NMPObject *nmp_object_ref (NMPObject *object);
|
||||||
void nmp_object_unref (NMPObject *object);
|
void nmp_object_unref (NMPObject *object);
|
||||||
NMPObject *nmp_object_new (ObjectType obj_type, const NMPlatformObject *plob);
|
NMPObject *nmp_object_new (NMPObjectType obj_type, const NMPlatformObject *plob);
|
||||||
NMPObject *nmp_object_new_link (int ifindex);
|
NMPObject *nmp_object_new_link (int ifindex);
|
||||||
|
|
||||||
const NMPObject *nmp_object_stackinit (NMPObject *obj, ObjectType obj_type, const NMPlatformObject *plobj);
|
const NMPObject *nmp_object_stackinit (NMPObject *obj, NMPObjectType obj_type, const NMPlatformObject *plobj);
|
||||||
const NMPObject *nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src);
|
const NMPObject *nmp_object_stackinit_id (NMPObject *obj, const NMPObject *src);
|
||||||
const NMPObject *nmp_object_stackinit_id_link (NMPObject *obj, int ifindex);
|
const NMPObject *nmp_object_stackinit_id_link (NMPObject *obj, int ifindex);
|
||||||
const NMPObject *nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, int plen);
|
const NMPObject *nmp_object_stackinit_id_ip4_address (NMPObject *obj, int ifindex, guint32 address, int plen);
|
||||||
@@ -314,12 +314,12 @@ guint nmp_cache_id_hash (const NMPCacheId *id);
|
|||||||
NMPCacheId *nmp_cache_id_clone (const NMPCacheId *id);
|
NMPCacheId *nmp_cache_id_clone (const NMPCacheId *id);
|
||||||
void nmp_cache_id_destroy (NMPCacheId *id);
|
void nmp_cache_id_destroy (NMPCacheId *id);
|
||||||
|
|
||||||
NMPCacheId *nmp_cache_id_init_object_type (NMPCacheId *id, ObjectType obj_type, gboolean visible_only);
|
NMPCacheId *nmp_cache_id_init_object_type (NMPCacheId *id, NMPObjectType obj_type, gboolean visible_only);
|
||||||
NMPCacheId *nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id, ObjectType obj_type, int ifindex);
|
NMPCacheId *nmp_cache_id_init_addrroute_visible_by_ifindex (NMPCacheId *id, NMPObjectType obj_type, int ifindex);
|
||||||
NMPCacheId *nmp_cache_id_init_routes_visible (NMPCacheId *id, ObjectType obj_type, gboolean with_default, gboolean with_non_default, int ifindex);
|
NMPCacheId *nmp_cache_id_init_routes_visible (NMPCacheId *id, NMPObjectType obj_type, gboolean with_default, gboolean with_non_default, int ifindex);
|
||||||
|
|
||||||
const NMPlatformObject *const *nmp_cache_lookup_multi (const NMPCache *cache, const NMPCacheId *cache_id, guint *out_len);
|
const NMPlatformObject *const *nmp_cache_lookup_multi (const NMPCache *cache, const NMPCacheId *cache_id, guint *out_len);
|
||||||
GArray *nmp_cache_lookup_multi_to_array (const NMPCache *cache, ObjectType obj_type, const NMPCacheId *cache_id);
|
GArray *nmp_cache_lookup_multi_to_array (const NMPCache *cache, NMPObjectType obj_type, const NMPCacheId *cache_id);
|
||||||
const NMPObject *nmp_cache_lookup_obj (const NMPCache *cache, const NMPObject *obj);
|
const NMPObject *nmp_cache_lookup_obj (const NMPCache *cache, const NMPObject *obj);
|
||||||
const NMPObject *nmp_cache_lookup_link (const NMPCache *cache, int ifindex);
|
const NMPObject *nmp_cache_lookup_link (const NMPCache *cache, int ifindex);
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ struct nl_object *nmp_object_to_nl (NMPlatform *platform, const NMPObject *obj,
|
|||||||
|
|
||||||
/* the following functions are currently implemented inside nm-linux-platform, because
|
/* the following functions are currently implemented inside nm-linux-platform, because
|
||||||
* they depend on utility functions there. */
|
* they depend on utility functions there. */
|
||||||
ObjectType _nlo_get_object_type (const struct nl_object *nlo);
|
NMPObjectType _nlo_get_object_type (const struct nl_object *nlo);
|
||||||
gboolean _nmp_vt_cmd_plobj_init_from_nl_link (NMPlatform *platform, NMPlatformObject *_obj, const struct nl_object *_nlo, gboolean id_only, gboolean complete_from_cache);
|
gboolean _nmp_vt_cmd_plobj_init_from_nl_link (NMPlatform *platform, NMPlatformObject *_obj, const struct nl_object *_nlo, gboolean id_only, gboolean complete_from_cache);
|
||||||
gboolean _nmp_vt_cmd_plobj_init_from_nl_ip4_address (NMPlatform *platform, NMPlatformObject *_obj, const struct nl_object *_nlo, gboolean id_only, gboolean complete_from_cache);
|
gboolean _nmp_vt_cmd_plobj_init_from_nl_ip4_address (NMPlatform *platform, NMPlatformObject *_obj, const struct nl_object *_nlo, gboolean id_only, gboolean complete_from_cache);
|
||||||
gboolean _nmp_vt_cmd_plobj_init_from_nl_ip6_address (NMPlatform *platform, NMPlatformObject *_obj, const struct nl_object *_nlo, gboolean id_only, gboolean complete_from_cache);
|
gboolean _nmp_vt_cmd_plobj_init_from_nl_ip6_address (NMPlatform *platform, NMPlatformObject *_obj, const struct nl_object *_nlo, gboolean id_only, gboolean complete_from_cache);
|
||||||
|
@@ -228,7 +228,7 @@ test_cache_link (void)
|
|||||||
nmp_cache_use_udev_set (cache, g_rand_int_range (nmtst_get_rand (), 0, 2));
|
nmp_cache_use_udev_set (cache, g_rand_int_range (nmtst_get_rand (), 0, 2));
|
||||||
|
|
||||||
/* if we have a link, and don't set is_in_netlink, adding it has no effect. */
|
/* if we have a link, and don't set is_in_netlink, adding it has no effect. */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
||||||
g_assert (NMP_OBJECT_UP_CAST (&obj1->object) == obj1);
|
g_assert (NMP_OBJECT_UP_CAST (&obj1->object) == obj1);
|
||||||
g_assert (!nmp_object_is_alive (obj1));
|
g_assert (!nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_UNCHANGED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_UNCHANGED);
|
||||||
@@ -240,7 +240,7 @@ test_cache_link (void)
|
|||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
|
|
||||||
/* Only when setting @is_in_netlink the link is added. */
|
/* Only when setting @is_in_netlink the link is added. */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
||||||
obj1->_link.netlink.is_in_netlink = TRUE;
|
obj1->_link.netlink.is_in_netlink = TRUE;
|
||||||
g_assert (nmp_object_is_alive (obj1));
|
g_assert (nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_ADDED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_ADDED);
|
||||||
@@ -250,13 +250,13 @@ test_cache_link (void)
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
|
||||||
/* updating the same link with identical value, has no effect. */
|
/* updating the same link with identical value, has no effect. */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
||||||
obj1->_link.netlink.is_in_netlink = TRUE;
|
obj1->_link.netlink.is_in_netlink = TRUE;
|
||||||
g_assert (nmp_object_is_alive (obj1));
|
g_assert (nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_UNCHANGED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_UNCHANGED);
|
||||||
@@ -270,7 +270,7 @@ test_cache_link (void)
|
|||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
|
||||||
/* remove the link from netlink */
|
/* remove the link from netlink */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
||||||
g_assert (!nmp_object_is_alive (obj1));
|
g_assert (!nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_REMOVED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_REMOVED);
|
||||||
ASSERT_nmp_cache_is_consistent (cache);
|
ASSERT_nmp_cache_is_consistent (cache);
|
||||||
@@ -290,13 +290,13 @@ test_cache_link (void)
|
|||||||
g_assert (!was_visible);
|
g_assert (!was_visible);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (!nmp_object_is_visible (obj2));
|
g_assert (!nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add it in netlink too. */
|
/* add it in netlink too. */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
||||||
obj1->_link.netlink.is_in_netlink = TRUE;
|
obj1->_link.netlink.is_in_netlink = TRUE;
|
||||||
g_assert (nmp_object_is_alive (obj1));
|
g_assert (nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, udev_device_2 ? NMP_CACHE_OPS_UPDATED : NMP_CACHE_OPS_ADDED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, udev_device_2 ? NMP_CACHE_OPS_UPDATED : NMP_CACHE_OPS_ADDED);
|
||||||
@@ -306,13 +306,13 @@ test_cache_link (void)
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
|
||||||
/* remove again from netlink. */
|
/* remove again from netlink. */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_2);
|
||||||
obj1->_link.netlink.is_in_netlink = FALSE;
|
obj1->_link.netlink.is_in_netlink = FALSE;
|
||||||
g_assert (!nmp_object_is_alive (obj1));
|
g_assert (!nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, udev_device_2 ? NMP_CACHE_OPS_UPDATED : NMP_CACHE_OPS_REMOVED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, udev_device_2 ? NMP_CACHE_OPS_UPDATED : NMP_CACHE_OPS_REMOVED);
|
||||||
@@ -323,8 +323,8 @@ test_cache_link (void)
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == obj2);
|
||||||
g_assert (!nmp_object_is_visible (obj2));
|
g_assert (!nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
} else {
|
} else {
|
||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == NULL);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == NULL);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == NULL);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_2.ifindex)) == NULL);
|
||||||
@@ -343,14 +343,14 @@ test_cache_link (void)
|
|||||||
g_assert (!was_visible);
|
g_assert (!was_visible);
|
||||||
g_assert (!nmp_object_is_visible (obj2));
|
g_assert (!nmp_object_is_visible (obj2));
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, FALSE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, FALSE);
|
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, FALSE);
|
||||||
g_assert_cmpint (obj2->link.initialized, ==, FALSE);
|
g_assert_cmpint (obj2->link.initialized, ==, FALSE);
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
|
||||||
/* add it in netlink too. */
|
/* add it in netlink too. */
|
||||||
obj1 = nmp_object_new (OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_3);
|
obj1 = nmp_object_new (NMP_OBJECT_TYPE_LINK, (NMPlatformObject *) &pl_link_3);
|
||||||
obj1->_link.netlink.is_in_netlink = TRUE;
|
obj1->_link.netlink.is_in_netlink = TRUE;
|
||||||
g_assert (nmp_object_is_alive (obj1));
|
g_assert (nmp_object_is_alive (obj1));
|
||||||
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_UPDATED);
|
_nmp_cache_update_netlink (cache, obj1, &obj2, &was_visible, NMP_CACHE_OPS_UPDATED);
|
||||||
@@ -361,8 +361,8 @@ test_cache_link (void)
|
|||||||
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, obj1) == obj2);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
||||||
g_assert_cmpint (obj2->link.initialized, ==, TRUE);
|
g_assert_cmpint (obj2->link.initialized, ==, TRUE);
|
||||||
nmp_object_unref (obj1);
|
nmp_object_unref (obj1);
|
||||||
@@ -375,8 +375,8 @@ test_cache_link (void)
|
|||||||
g_assert (was_visible);
|
g_assert (was_visible);
|
||||||
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
g_assert (nmp_cache_lookup_obj (cache, nmp_object_stackinit_id_link (&objs1, pl_link_3.ifindex)) == obj2);
|
||||||
g_assert (nmp_object_is_visible (obj2));
|
g_assert (nmp_object_is_visible (obj2));
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, TRUE), obj2, TRUE);
|
||||||
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
_assert_cache_multi_lookup_contains (cache, nmp_cache_id_init_object_type (&cache_id_storage, NMP_OBJECT_TYPE_LINK, FALSE), obj2, TRUE);
|
||||||
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
g_assert_cmpint (obj2->_link.netlink.is_in_netlink, ==, TRUE);
|
||||||
g_assert_cmpint (obj2->link.initialized, ==, !nmp_cache_use_udev_get (cache));
|
g_assert_cmpint (obj2->link.initialized, ==, !nmp_cache_use_udev_get (cache));
|
||||||
nmp_object_unref (obj2);
|
nmp_object_unref (obj2);
|
||||||
|
Reference in New Issue
Block a user