diff options
author | Ralf Baechle DL5RB <ralf@linux-mips.org> | 2006-07-03 19:30:18 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-07-03 19:30:18 -0700 |
commit | 006f68b84fe19fc5015a8cf838a10d75f91f0218 (patch) | |
tree | 2c9377778e4e09bb8d10084341207ba1352f600a /include/net/ax25.h | |
parent | 8dc22d2b642f8a6f14ef8878777a05311e5d1d7e (diff) | |
download | op-kernel-dev-006f68b84fe19fc5015a8cf838a10d75f91f0218.zip op-kernel-dev-006f68b84fe19fc5015a8cf838a10d75f91f0218.tar.gz |
[AX.25]: Reference counting for AX.25 routes.
In the past routes could be freed even though the were possibly in use ...
Signed-off-by: Ralf Baechle DL5RB <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/ax25.h')
-rw-r--r-- | include/net/ax25.h | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/include/net/ax25.h b/include/net/ax25.h index 7cd528e..69374cd 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h @@ -182,14 +182,26 @@ typedef struct { typedef struct ax25_route { struct ax25_route *next; - atomic_t ref; + atomic_t refcount; ax25_address callsign; struct net_device *dev; ax25_digi *digipeat; char ip_mode; - struct timer_list timer; } ax25_route; +static inline void ax25_hold_route(ax25_route *ax25_rt) +{ + atomic_inc(&ax25_rt->refcount); +} + +extern void __ax25_put_route(ax25_route *ax25_rt); + +static inline void ax25_put_route(ax25_route *ax25_rt) +{ + if (atomic_dec_and_test(&ax25_rt->refcount)) + __ax25_put_route(ax25_rt); +} + typedef struct { char slave; /* slave_mode? */ struct timer_list slave_timer; /* timeout timer */ @@ -348,17 +360,11 @@ extern int ax25_check_iframes_acked(ax25_cb *, unsigned short); extern void ax25_rt_device_down(struct net_device *); extern int ax25_rt_ioctl(unsigned int, void __user *); extern struct file_operations ax25_route_fops; +extern ax25_route *ax25_get_route(ax25_address *addr, struct net_device *dev); extern int ax25_rt_autobind(ax25_cb *, ax25_address *); -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); -static inline void ax25_put_route(ax25_route *ax25_rt) -{ - atomic_dec(&ax25_rt->ref); -} - /* ax25_std_in.c */ extern int ax25_std_frame_in(ax25_cb *, struct sk_buff *, int); |