* [RFC PATCH] [XFRM]: Fix ordering issue in xfrm_dst_hash_transfer().
@ 2008-02-15 2:24 YOSHIFUJI Hideaki / 吉藤英明
2008-02-15 5:45 ` Sebastien Decugis
0 siblings, 1 reply; 3+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2008-02-15 2:24 UTC (permalink / raw)
To: davem; +Cc: herbert, sdecugis, kazunori, yoshfuji, netdev
Keep ordering of policy entries with same selector in xfrm_dst_hash_transfer().
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 <sdecugis@hongo.wide.ad.jp>.
We could convert bydst from hlist to list and use list_add_tail() instead.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
----
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 47219f9..9fc4c31 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -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;
+redo:
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_del(entry);
+ hlist_add_head(&pol->bydst, ndsttable+h);
+ h0 = h;
+ } else {
+ if (h != h0)
+ continue;
+ hlist_del(entry);
+ hlist_add_after(entry0, &pol->bydst);
+ }
+ entry0 = entry;
+ }
+ if (!hlist_empty(list)) {
+ entry0 = NULL;
+ goto redo;
}
}
--
YOSHIFUJI Hideaki @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG-FP : 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] [XFRM]: Fix ordering issue in xfrm_dst_hash_transfer().
2008-02-15 2:24 [RFC PATCH] [XFRM]: Fix ordering issue in xfrm_dst_hash_transfer() YOSHIFUJI Hideaki / 吉藤英明
@ 2008-02-15 5:45 ` Sebastien Decugis
2008-02-18 7:29 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Sebastien Decugis @ 2008-02-15 5:45 UTC (permalink / raw)
To: YOSHIFUJI Hideaki / 吉藤英明
Cc: davem, herbert, kazunori, yoshfuji, netdev
It works, thank you!
Acked-by: Sebastien Decugis <sdecugis@hongo.wide.ad.jp>
YOSHIFUJI Hideaki / 吉藤英明 a écrit :
> Keep ordering of policy entries with same selector in xfrm_dst_hash_transfer().
>
> 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 <sdecugis@hongo.wide.ad.jp>.
>
> We could convert bydst from hlist to list and use list_add_tail() instead.
>
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>
> ----
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index 47219f9..9fc4c31 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -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;
>
> +redo:
> 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_del(entry);
> + hlist_add_head(&pol->bydst, ndsttable+h);
> + h0 = h;
> + } else {
> + if (h != h0)
> + continue;
> + hlist_del(entry);
> + hlist_add_after(entry0, &pol->bydst);
> + }
> + entry0 = entry;
> + }
> + if (!hlist_empty(list)) {
> + entry0 = NULL;
> + goto redo;
> }
> }
>
>
--
Sebastien Decugis
http://www.nautilus6.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] [XFRM]: Fix ordering issue in xfrm_dst_hash_transfer().
2008-02-15 5:45 ` Sebastien Decugis
@ 2008-02-18 7:29 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2008-02-18 7:29 UTC (permalink / raw)
To: sdecugis; +Cc: yoshfuji, herbert, kazunori, yoshfuji, netdev
From: Sebastien Decugis <sdecugis@hongo.wide.ad.jp>
Date: Fri, 15 Feb 2008 14:45:04 +0900
> It works, thank you!
>
> Acked-by: Sebastien Decugis <sdecugis@hongo.wide.ad.jp>
Patch applied, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-18 7:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-15 2:24 [RFC PATCH] [XFRM]: Fix ordering issue in xfrm_dst_hash_transfer() YOSHIFUJI Hideaki / 吉藤英明
2008-02-15 5:45 ` Sebastien Decugis
2008-02-18 7:29 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).