Commit b791160b authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki Committed by David S. Miller
Browse files

[XFRM]: Fix ordering issue in xfrm_dst_hash_transfer().

Keep ordering of policy entries with same selector in

Issue should not appear in usual cases because multiple policy entries
with same selector are basically not allowed so far.  Bug was pointed
out by Sebastien Decugis <>.

We could convert bydst from hlist to list and use list_add_tail()

Signed-off-by: default avatarYOSHIFUJI Hideaki <>
Acked-by: default avatarSebastien Decugis <>
Signed-off-by: default avatarDavid S. Miller <>
parent 82453021
......@@ -331,15 +331,31 @@ static void xfrm_dst_hash_transfer(struct hlist_head *list,
struct hlist_head *ndsttable,
unsigned int nhashmask)
struct hlist_node *entry, *tmp;
struct hlist_node *entry, *tmp, *entry0 = NULL;
struct xfrm_policy *pol;
unsigned int h0 = 0;
hlist_for_each_entry_safe(pol, entry, tmp, list, bydst) {
unsigned int h;
h = __addr_hash(&pol->selector.daddr, &pol->selector.saddr,
pol->family, nhashmask);
hlist_add_head(&pol->bydst, ndsttable+h);
if (!entry0) {
hlist_add_head(&pol->bydst, ndsttable+h);
h0 = h;
} else {
if (h != h0)
hlist_add_after(entry0, &pol->bydst);
entry0 = entry;
if (!hlist_empty(list)) {
entry0 = NULL;
goto redo;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment