From: pravin <pravins@calsoftinc.com>
To: netdev@oss.sgi.com
Cc: "David S. Miller" <davem@davemloft.net>,
"Herbert Xu" <herbert@gondor.apana.org.au>
Subject: [PATCH] : bug fix in multipath drr code.
Date: Mon, 23 May 2005 17:56:39 +0530 [thread overview]
Message-ID: <4291CBFF.6080106@calsoftinc.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
hi
AFAIU, there is a race condition in multipath_drr code,
these code paths try to access & change last_selection variable
without any synchronization.
Please correct me if I am wrong.
Code Path - 1
__ip_route_output_key(...)
{
...
calls drr_select_route
if(FLOWI_FLAG_MULTIPATHOLDROUTE set){
check last_selection.
return last_selection //so it can return NULL pointer
}
....
}
Code Path - 2
rt_secret_rebuild()
{
.....
rt_run_flush(..);
->rt_free(rth);
-> multipath_remove(rt)
->drr_remove()
reset last_selection.
....
}
Attached patch also fixes bug in function drr_init ::
multipath_alg_register(..) is called with wrong algorithm ID.
Regards
Pravin.
[-- Attachment #2: multipath-last_selection-race-fix.patch --]
[-- Type: text/x-patch, Size: 1913 bytes --]
Signed-off by: Pravin B. Shelar <pravins@calsoftinc.com>
Index: linux-2.6.12-rc4/net/ipv4/multipath_drr.c
===================================================================
--- linux-2.6.12-rc4.orig/net/ipv4/multipath_drr.c 2005-05-06 22:20:31.000000000 -0700
+++ linux-2.6.12-rc4/net/ipv4/multipath_drr.c 2005-05-22 06:41:39.000000000 -0700
@@ -145,11 +145,13 @@
int cur_min_devidx = -1;
/* if necessary and possible utilize the old alternative */
- if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 &&
- last_selection != NULL) {
- result = last_selection;
- *rp = result;
- return;
+ if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 ) {
+ struct rtable *last_result = last_selection;
+ if(last_result != NULL &&
+ multipath_comparekeys(&last_result->fl, flp)) {
+ *rp = last_result;
+ return;
+ }
}
/* 1. make sure all alt. nexthops have the same GC related data */
@@ -244,7 +246,7 @@
if (err)
return err;
- err = multipath_alg_register(&drr_ops, IP_MP_ALG_RR);
+ err = multipath_alg_register(&drr_ops, IP_MP_ALG_DRR);
if (err)
goto fail;
Index: linux-2.6.12-rc4/net/ipv4/multipath_rr.c
===================================================================
--- linux-2.6.12-rc4.orig/net/ipv4/multipath_rr.c 2005-05-06 22:20:31.000000000 -0700
+++ linux-2.6.12-rc4/net/ipv4/multipath_rr.c 2005-05-22 06:41:20.000000000 -0700
@@ -64,10 +64,13 @@
int min_use = -1;
/* if necessary and possible utilize the old alternative */
- if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 &&
- last_used != NULL) {
- result = last_used;
- goto out;
+ if ((flp->flags & FLOWI_FLAG_MULTIPATHOLDROUTE) != 0 ) {
+ struct rtable *last_result = last_used;
+ if(last_result != NULL &&
+ multipath_comparekeys(&last_result->fl, flp)) {
+ result = last_result;
+ goto out;
+ }
}
/* 1. make sure all alt. nexthops have the same GC related data
next reply other threads:[~2005-05-23 12:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-23 12:26 pravin [this message]
2005-05-23 23:22 ` [PATCH] : bug fix in multipath drr code Herbert Xu
2005-05-24 6:46 ` pravin b shelar
2005-05-24 7:11 ` Herbert Xu
2005-05-24 9:57 ` pravin b shelar
2005-05-26 22:13 ` David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4291CBFF.6080106@calsoftinc.com \
--to=pravins@calsoftinc.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).