summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2013-06-29 20:29:43 (GMT)
committerThomas Graf <tgraf@suug.ch>2013-07-01 10:41:42 (GMT)
commit408a1b8f07205a82b1d142633bb37bc478c55116 (patch)
treeb1c5c8c697ea4a33347899fba6fb763630871be7
parent2d0810eb93704defb2375d9861892d6041da4623 (diff)
downloadlibnl-408a1b8f07205a82b1d142633bb37bc478c55116.zip
libnl-408a1b8f07205a82b1d142633bb37bc478c55116.tar.gz
libnl-408a1b8f07205a82b1d142633bb37bc478c55116.tar.bz2
cache: Return -NLE_PROTO_MISMATCH if socket provided mismatches cache protocol
Signed-off-by: Thomas Graf <tgraf@suug.ch>
-rw-r--r--lib/cache.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/cache.c b/lib/cache.c
index e99e9d2..5418051 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -642,6 +642,9 @@ void nl_cache_set_flags(struct nl_cache *cache, unsigned int flags)
static int nl_cache_request_full_dump(struct nl_sock *sk,
struct nl_cache *cache)
{
+ if (sk->s_proto != cache->c_ops->co_protocol)
+ return -NLE_PROTO_MISMATCH;
+
if (cache->c_ops->co_request_update == NULL)
return -NLE_OPNOTSUPP;
@@ -744,6 +747,9 @@ int nl_cache_pickup(struct nl_sock *sk, struct nl_cache *cache)
.pp_arg = cache,
};
+ if (sk->s_proto != cache->c_ops->co_protocol)
+ return -NLE_PROTO_MISMATCH;
+
return __cache_pickup(sk, cache, &p);
}
@@ -840,6 +846,9 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
};
int err;
+ if (sk->s_proto != cache->c_ops->co_protocol)
+ return -NLE_PROTO_MISMATCH;
+
NL_DBG(1, "Resyncing cache %p <%s>...\n", cache, nl_cache_name(cache));
/* Mark all objects so we can see if some of them are obsolete */
@@ -953,6 +962,9 @@ int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
struct nl_af_group *grp;
int err;
+ if (sk->s_proto != cache->c_ops->co_protocol)
+ return -NLE_PROTO_MISMATCH;
+
nl_cache_clear(cache);
grp = cache->c_ops->co_groups;
do {