]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Clarified code when hashing/comparing cached policies in kernel-netlink
authorTobias Brunner <tobias@strongswan.org>
Fri, 28 Sep 2012 16:30:16 +0000 (18:30 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 28 Sep 2012 16:30:16 +0000 (18:30 +0200)
src/libhydra/plugins/kernel_netlink/kernel_netlink_ipsec.c

index 677b6557e8f7e0a1b535f389fa6b7c7b5fdf79ab..ed7a622b5191060f470022304e7c75fcfaf7180b 100644 (file)
@@ -590,9 +590,8 @@ static void policy_entry_destroy(private_kernel_netlink_ipsec_t *this,
  */
 static u_int policy_hash(policy_entry_t *key)
 {
-       chunk_t chunk = chunk_create((void*)&key->sel,
-                                                       sizeof(struct xfrm_selector) + sizeof(u_int32_t));
-       return chunk_hash(chunk);
+       chunk_t chunk = chunk_from_thing(key->sel);
+       return chunk_hash_inc(chunk, chunk_hash(chunk_from_thing(key->mark)));
 }
 
 /**
@@ -600,8 +599,8 @@ static u_int policy_hash(policy_entry_t *key)
  */
 static bool policy_equals(policy_entry_t *key, policy_entry_t *other_key)
 {
-       return memeq(&key->sel, &other_key->sel,
-                                sizeof(struct xfrm_selector) + sizeof(u_int32_t)) &&
+       return memeq(&key->sel, &other_key->sel, sizeof(struct xfrm_selector)) &&
+                  key->mark == other_key->mark &&
                   key->direction == other_key->direction;
 }