From a4c7176fe946c7325cfef19c1a516e4802978779 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 5 Aug 2015 18:20:00 +0200 Subject: [PATCH] platform: optimize event_notification() not to create full nmp-objects for delete-events For delete-events, we only need a shallow object with the key fields set. That sufficies to lookup in the cache and find the object to delete. One other issue is that _nmp_vt_cmd_plobj_init_from_nl_link() and link_extract_type() might call to ethtool for the already deleted instance. Just avoid that. https://bugzilla.redhat.com/show_bug.cgi?id=1247156 --- src/platform/nm-linux-platform.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 60fe737a9c..a4f4e249dd 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2305,11 +2305,25 @@ event_notification (struct nl_msg *msg, gpointer user_data) if (_support_user_ipv6ll_still_undecided() && msghdr->nlmsg_type == RTM_NEWLINK) _support_user_ipv6ll_detect ((struct rtnl_link *) nlo); - obj = nmp_object_from_nl (platform, nlo, FALSE, TRUE); + switch (msghdr->nlmsg_type) { + case RTM_DELADDR: + case RTM_DELLINK: + case RTM_DELROUTE: + /* The event notifies about a deleted object. We don't need to initialize all the + * fields of the nmp-object. Shortcut nmp_object_from_nl(). */ + obj = nmp_object_from_nl (platform, nlo, TRUE, TRUE); + _LOGD ("event-notification: %s, seq %u: %s", + _nl_nlmsg_type_to_str (msghdr->nlmsg_type, buf_nlmsg_type, sizeof (buf_nlmsg_type)), + msghdr->nlmsg_seq, nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_ID, NULL, 0)); + break; + default: + obj = nmp_object_from_nl (platform, nlo, FALSE, TRUE); + _LOGD ("event-notification: %s, seq %u: %s", + _nl_nlmsg_type_to_str (msghdr->nlmsg_type, buf_nlmsg_type, sizeof (buf_nlmsg_type)), + msghdr->nlmsg_seq, nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0)); + break; + } - _LOGD ("event-notification: %s, seq %u: %s", - _nl_nlmsg_type_to_str (msghdr->nlmsg_type, buf_nlmsg_type, sizeof (buf_nlmsg_type)), - msghdr->nlmsg_seq, nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0)); if (obj) { auto_nmp_obj NMPObject *obj_cache = NULL;