[From nobody Sun May 29 05:38:44 2016
Received: from zmta04.collab.prod.int.phx2.redhat.com (LHLO
 zmta04.collab.prod.int.phx2.redhat.com) (10.5.81.11) by
 zmail21.collab.prod.int.phx2.redhat.com with LMTP; Mon, 2 Nov 2015 17:11:41
 -0500 (EST)
Received: from int-mx09.intmail.prod.int.phx2.redhat.com
 (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by
 zmta04.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 61BEADA0F3
 for &lt;thaller@mail.corp.redhat.com&gt;; Mon,  2 Nov 2015 17:11:41 -0500 (EST)
Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com
 [10.5.110.26]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4)
 with ESMTP id tA2MBf75008353 (version=TLSv1/SSLv3
 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for
 &lt;thaller@redhat.com&gt;; Mon, 2 Nov 2015 17:11:41 -0500
Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com
 [209.85.220.45]) by mx1.redhat.com (Postfix) with ESMTPS id 4505B4C64A for
 &lt;thaller@redhat.com&gt;; Mon,  2 Nov 2015 22:11:40 +0000 (UTC)
Received: by padec8 with SMTP id ec8so51403291pad.1 for
 &lt;thaller@redhat.com&gt;; Mon, 02 Nov 2015 14:11:39 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id;
 bh=E/SLbVF/fZD1Lfrxt6yAfzDANFIrPGIJ4p0KBYuL5hQ=;
 b=Qponn38RgHyKPwLAXWa8SFRH/R2U1op9YFGdogJH3bGecjFpWvS1U0wdkbcySmnLoV
 E28zhgmCGh7RXh8NfAZ6MUJBU49SSTIT0R3Jyg0+TeyIrNlTEEB94gV+V+PbUPNHoUTU
 QqJVRMm966T/POlJBuZ0i37/kXRSBT9uc9FRE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;
 s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id;
 bh=E/SLbVF/fZD1Lfrxt6yAfzDANFIrPGIJ4p0KBYuL5hQ=;
 b=Mgras7MJvxCCAqzSf8MJix1jJyeDZjP6Y9fJdZpXeYAQQhMbhbm58YQ3+qss0IHLqZ
 N+oh0oz7wnl8U+EOXODOdz9wG+cMsBJDGnud0fjjCY2zF+wYxewfWXgOhqGFiES337WP
 lYDZmTi7bl9BD0gi4OizAO9R11mUb/DB6nbWIESPnpum7l6Ucxy3rfpY6kE6qnlhWNJW
 0zwMmbdAHGTOJpatr6Hrg2tIpR3QiwnhvjR/BYBwLAr2IWjY6kxmvx9X0LCP9VZgGHQl
 MhqIWGZxLicVN3NXqGv6Jfexh+gyMkvcLftXHsFQjHWHI/Zy/uVt+UcygpZ8bD2ZtnEU QKTA==
X-Gm-Message-State: ALoCoQkpZXl7lsuqmoObku9JYFK7+Qw61WSkfH1FocRoGOHpyN7CJlHC77OrC+pZxowX8dg7wgYd
X-Received: by 10.68.135.132 with SMTP id
 ps4mr29610906pbb.74.1446501939856; Mon, 02 Nov 2015 14:05:39 -0800 (PST)
Received: from hydra-01.cumulusnetworks.com ([216.129.126.126]) by
 smtp.googlemail.com with ESMTPSA id bz1sm25892966pab.20.2015.11.02.14.05.39
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02
 Nov 2015 14:05:39 -0800 (PST)
From: Roopa Prabhu &lt;roopa@cumulusnetworks.com&gt;
X-Google-Original-From: Roopa Prabhu
To: libnl@lists.infradead.org
Cc: thaller@redhat.com, roopa@cumulusnetworks.com
Subject: [PATCH 5/6] cache: add new NL_OBJ_DUMP cache flag (ce_flags)
Date: Mon,  2 Nov 2015 14:05:28 -0800
Message-Id: &lt;1446501929-32003-6-git-send-email-roopa@cumulusnetworks.com&gt;
X-RedHat-Spam-Score: 2.08 **
 (ANY_BOUNCE_MESSAGE, BAYES_50, BOUNCE_MESSAGE, DCC_REPUT_13_19, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DSN_NO_MIMEVERSION, RCVD_IN_DNSWL_LOW,
 RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED)
 209.85.220.45 mail-pa0-f45.google.com 209.85.220.45 mail-pa0-f45.google.com
 &lt;&gt;
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
X-Scanned-By: MIMEDefang 2.75 on 10.5.110.26
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable

From: Roopa Prabhu &lt;roopa@cumulusnetworks.com&gt;

kernel does not include NLM_F_APPEND or NLM_F_REPLACE flags
during dumps. This flag helps distinguish object cache inclusion due to
netlink dumps from those resulting from netlink notifications.

Signed-off-by: Roopa Prabhu &lt;roopa@cumulusnetworks.com&gt;
---
 include/netlink-private/types.h |    1 +
 lib/cache.c                     |   18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/netlink-private/types.h b/include/netlink-private/type=
s.h
index 5da8f59..853f44c 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -113,6 +113,7 @@ struct nl_parser_param;
 #define LOOSE_COMPARISON	1
=20
 #define NL_OBJ_MARK		1
+#define NL_OBJ_DUMP		2	/* object received due to a dump */
=20
 struct nl_data
 {
diff --git a/lib/cache.c b/lib/cache.c
index 9b69fe8..960459d 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -714,6 +714,7 @@ static int pickup_checkdup_cb(struct nl_object *c, stru=
ct nl_parser_param *p)
 {
 	struct nl_cache *cache =3D (struct nl_cache *)p-&gt;pp_arg;
 	struct nl_object *old;
+	int ret;
=20
 	old =3D nl_cache_search(cache, c);
 	if (old) {
@@ -726,7 +727,11 @@ static int pickup_checkdup_cb(struct nl_object *c, str=
uct nl_parser_param *p)
 		nl_object_put(old);
 	}
=20
-	return nl_cache_add(cache, c);
+	c-&gt;ce_flags |=3D NL_OBJ_DUMP;
+	ret =3D nl_cache_add(cache, c);
+	c-&gt;ce_flags &amp;=3D ~NL_OBJ_DUMP;
+
+	return ret;
 }
=20
 static int pickup_cb(struct nl_object *c, struct nl_parser_param *p)
@@ -783,8 +788,10 @@ int nl_cache_pickup(struct nl_sock *sk, struct nl_cach=
e *cache)
 	return __nl_cache_pickup(sk, cache, 0);
 }
=20
+
 static int cache_include(struct nl_cache *cache, struct nl_object *obj,
-			 struct nl_msgtype *type, change_func_t cb, void *data)
+			 struct nl_msgtype *type, change_func_t cb,
+			 void *data)
 {
 	struct nl_object *old;
=20
@@ -856,8 +863,13 @@ int nl_cache_include(struct nl_cache *cache, struct nl=
_object *obj,
 static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
 {
 	struct nl_cache_assoc *ca =3D p-&gt;pp_arg;
+	int ret;
+
+	c-&gt;ce_flags |=3D NL_OBJ_DUMP;
+	ret =3D nl_cache_include(ca-&gt;ca_cache, c, ca-&gt;ca_change, ca-&gt;ca_change_da=
ta);
+	c-&gt;ce_flags &amp;=3D ~NL_OBJ_DUMP;
=20
-	return nl_cache_include(ca-&gt;ca_cache, c, ca-&gt;ca_change, ca-&gt;ca_change_dat=
a);
+    return ret;
 }
=20
 int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
--=20
1.7.10.4

]