summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Bächle <ralf@dea.linux-mips.net>2002-08-04 05:39:58 +0200
committerRalf Bächle <ralf@dea.linux-mips.net>2002-08-04 05:39:58 +0200
commit4b04ea0bf73ed6cf4eb63e4e2ac818043263ddec (patch)
tree435b2cf35880769cee46e4abded420a940f8c0b7
parent6a7ae9313a83f4599593b2459d2221d276909277 (diff)
Eleminate race caused by static variable in ax25_rt_find_route.
-rw-r--r--include/net/ax25.h3
-rw-r--r--net/ax25/ax25_ip.c4
-rw-r--r--net/ax25/ax25_route.c29
3 files changed, 17 insertions, 19 deletions
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 2e141a48c15e..3e61c7eb5ebd 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -289,7 +289,8 @@ extern void ax25_rt_device_down(struct net_device *);
extern int ax25_rt_ioctl(unsigned int, void *);
extern int ax25_rt_get_info(char *, char **, off_t, int);
extern int ax25_rt_autobind(ax25_cb *, ax25_address *);
-extern ax25_route *ax25_rt_find_route(ax25_address *, struct net_device *);
+extern ax25_route *ax25_rt_find_route(ax25_route *, ax25_address *,
+ struct net_device *);
extern struct sk_buff *ax25_rt_build_path(struct sk_buff *, ax25_address *, ax25_address *, ax25_digi *);
extern void ax25_rt_free(void);
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c
index 055061d82c26..980e8955f0d7 100644
--- a/net/ax25/ax25_ip.c
+++ b/net/ax25/ax25_ip.c
@@ -112,8 +112,8 @@ int ax25_rebuild_header(struct sk_buff *skb)
unsigned char *bp = skb->data;
struct net_device *dev;
ax25_address *src, *dst;
- ax25_route *route;
ax25_dev *ax25_dev;
+ ax25_route _route, *route = &_route;
dst = (ax25_address *)(bp + 1);
src = (ax25_address *)(bp + 8);
@@ -121,7 +121,7 @@ int ax25_rebuild_header(struct sk_buff *skb)
if (arp_find(bp + 1, skb))
return 1;
- route = ax25_rt_find_route(dst, NULL);
+ route = ax25_rt_find_route(route, dst, NULL);
dev = route->dev;
if (dev == NULL)
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index f22db95579b7..2828cca5bf47 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -439,28 +439,25 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
return 0;
}
-/*
- * dl1bke 960117: build digipeater path
- * dl1bke 960301: use the default route if it exists
- */
-ax25_route *ax25_rt_find_route(ax25_address *addr, struct net_device *dev)
+ax25_route *ax25_rt_find_route(ax25_route * route, ax25_address *addr,
+ struct net_device *dev)
{
- static ax25_route route;
ax25_route *ax25_rt;
- if ((ax25_rt = ax25_find_route(addr, dev)) == NULL) {
- route.next = NULL;
- route.callsign = *addr;
- route.dev = dev;
- route.digipeat = NULL;
- route.ip_mode = ' ';
- return &route;
- }
+ if (ax25_rt = ax25_find_route(addr, dev))
+ return ax25_rt;
+
+ route->next = NULL;
+ route->callsign = *addr;
+ route->dev = dev;
+ route->digipeat = NULL;
+ route->ip_mode = ' ';
- return ax25_rt;
+ return route;
}
-struct sk_buff *ax25_rt_build_path(struct sk_buff *skb, ax25_address *src, ax25_address *dest, ax25_digi *digi)
+struct sk_buff *ax25_rt_build_path(struct sk_buff *skb, ax25_address *src,
+ ax25_address *dest, ax25_digi *digi)
{
struct sk_buff *skbn;
unsigned char *bp;