diff options
author | Ralf Baechle DL5RB <ralf@linux-mips.org> | 2006-07-03 22:30:18 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-07-03 22:30:18 -0400 |
commit | 006f68b84fe19fc5015a8cf838a10d75f91f0218 (patch) | |
tree | 2c9377778e4e09bb8d10084341207ba1352f600a /net/ax25/ax25_ip.c | |
parent | 8dc22d2b642f8a6f14ef8878777a05311e5d1d7e (diff) |
[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 'net/ax25/ax25_ip.c')
-rw-r--r-- | net/ax25/ax25_ip.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c index 9be5c15e63d3..136c3aefa9de 100644 --- a/net/ax25/ax25_ip.c +++ b/net/ax25/ax25_ip.c | |||
@@ -103,11 +103,13 @@ int ax25_rebuild_header(struct sk_buff *skb) | |||
103 | { | 103 | { |
104 | struct sk_buff *ourskb; | 104 | struct sk_buff *ourskb; |
105 | unsigned char *bp = skb->data; | 105 | unsigned char *bp = skb->data; |
106 | struct net_device *dev; | 106 | ax25_route *route; |
107 | struct net_device *dev = NULL; | ||
107 | ax25_address *src, *dst; | 108 | ax25_address *src, *dst; |
109 | ax25_digi *digipeat = NULL; | ||
108 | ax25_dev *ax25_dev; | 110 | ax25_dev *ax25_dev; |
109 | ax25_route _route, *route = &_route; | ||
110 | ax25_cb *ax25; | 111 | ax25_cb *ax25; |
112 | char ip_mode = ' '; | ||
111 | 113 | ||
112 | dst = (ax25_address *)(bp + 1); | 114 | dst = (ax25_address *)(bp + 1); |
113 | src = (ax25_address *)(bp + 8); | 115 | src = (ax25_address *)(bp + 8); |
@@ -115,8 +117,12 @@ int ax25_rebuild_header(struct sk_buff *skb) | |||
115 | if (arp_find(bp + 1, skb)) | 117 | if (arp_find(bp + 1, skb)) |
116 | return 1; | 118 | return 1; |
117 | 119 | ||
118 | route = ax25_rt_find_route(route, dst, NULL); | 120 | route = ax25_get_route(dst, NULL); |
119 | dev = route->dev; | 121 | if (route) { |
122 | digipeat = route->digipeat; | ||
123 | dev = route->dev; | ||
124 | ip_mode = route->ip_mode; | ||
125 | }; | ||
120 | 126 | ||
121 | if (dev == NULL) | 127 | if (dev == NULL) |
122 | dev = skb->dev; | 128 | dev = skb->dev; |
@@ -126,7 +132,7 @@ int ax25_rebuild_header(struct sk_buff *skb) | |||
126 | } | 132 | } |
127 | 133 | ||
128 | if (bp[16] == AX25_P_IP) { | 134 | if (bp[16] == AX25_P_IP) { |
129 | if (route->ip_mode == 'V' || (route->ip_mode == ' ' && ax25_dev->values[AX25_VALUES_IPDEFMODE])) { | 135 | if (ip_mode == 'V' || (ip_mode == ' ' && ax25_dev->values[AX25_VALUES_IPDEFMODE])) { |
130 | /* | 136 | /* |
131 | * We copy the buffer and release the original thereby | 137 | * We copy the buffer and release the original thereby |
132 | * keeping it straight | 138 | * keeping it straight |
@@ -172,7 +178,7 @@ int ax25_rebuild_header(struct sk_buff *skb) | |||
172 | ourskb, | 178 | ourskb, |
173 | ax25_dev->values[AX25_VALUES_PACLEN], | 179 | ax25_dev->values[AX25_VALUES_PACLEN], |
174 | &src_c, | 180 | &src_c, |
175 | &dst_c, route->digipeat, dev); | 181 | &dst_c, digipeat, dev); |
176 | if (ax25) { | 182 | if (ax25) { |
177 | ax25_cb_put(ax25); | 183 | ax25_cb_put(ax25); |
178 | } | 184 | } |
@@ -190,7 +196,7 @@ int ax25_rebuild_header(struct sk_buff *skb) | |||
190 | 196 | ||
191 | skb_pull(skb, AX25_KISS_HEADER_LEN); | 197 | skb_pull(skb, AX25_KISS_HEADER_LEN); |
192 | 198 | ||
193 | if (route->digipeat != NULL) { | 199 | if (digipeat != NULL) { |
194 | if ((ourskb = ax25_rt_build_path(skb, src, dst, route->digipeat)) == NULL) { | 200 | if ((ourskb = ax25_rt_build_path(skb, src, dst, route->digipeat)) == NULL) { |
195 | kfree_skb(skb); | 201 | kfree_skb(skb); |
196 | goto put; | 202 | goto put; |
@@ -202,7 +208,8 @@ int ax25_rebuild_header(struct sk_buff *skb) | |||
202 | ax25_queue_xmit(skb, dev); | 208 | ax25_queue_xmit(skb, dev); |
203 | 209 | ||
204 | put: | 210 | put: |
205 | ax25_put_route(route); | 211 | if (route) |
212 | ax25_put_route(route); | ||
206 | 213 | ||
207 | return 1; | 214 | return 1; |
208 | } | 215 | } |