platform: tighten return value from do_add_addrroute()
Only return TRUE, if the netlink request was responded with success and the object exists after adding.
This commit is contained in:
@@ -3683,9 +3683,11 @@ do_add_link_with_lookup (NMPlatform *platform,
|
|||||||
static gboolean
|
static gboolean
|
||||||
do_add_addrroute (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *nlmsg)
|
do_add_addrroute (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *nlmsg)
|
||||||
{
|
{
|
||||||
|
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||||
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
||||||
int nle;
|
int nle;
|
||||||
char s_buf[256];
|
char s_buf[256];
|
||||||
|
const NMPObject *obj;
|
||||||
|
|
||||||
nm_assert (NM_IN_SET (NMP_OBJECT_GET_TYPE (obj_id),
|
nm_assert (NM_IN_SET (NMP_OBJECT_GET_TYPE (obj_id),
|
||||||
NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS,
|
NMP_OBJECT_TYPE_IP4_ADDRESS, NMP_OBJECT_TYPE_IP6_ADDRESS,
|
||||||
@@ -3721,13 +3723,17 @@ do_add_addrroute (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *
|
|||||||
* whether the object exists.
|
* whether the object exists.
|
||||||
*
|
*
|
||||||
* FIXME: if the object already existed previously, we might not notice a
|
* FIXME: if the object already existed previously, we might not notice a
|
||||||
* missing update. */
|
* missing update. It's not clear how to fix that reliably without refechting
|
||||||
if (!nmp_cache_lookup_obj (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, obj_id))
|
* all the time. */
|
||||||
|
obj = nmp_cache_lookup_obj (priv->cache, obj_id);
|
||||||
|
if (!obj) {
|
||||||
do_request_one_type (platform, NMP_OBJECT_GET_TYPE (obj_id));
|
do_request_one_type (platform, NMP_OBJECT_GET_TYPE (obj_id));
|
||||||
|
obj = nmp_cache_lookup_obj (priv->cache, obj_id);
|
||||||
|
}
|
||||||
|
|
||||||
/* The return value doesn't say, whether the object is in the platform cache after adding
|
/* Adding is only successful, if kernel reported success *and* we have the
|
||||||
* it. Instead the return value says, whether the netlink request succeeded. */
|
* expected object in cache afterwards. */
|
||||||
return seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK;
|
return obj && seq_result == WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Reference in New Issue
Block a user