Commit fe2c802a authored by Bernard Pidoux's avatar Bernard Pidoux Committed by David S. Miller

rose: improving AX25 routing frames via ROSE network

ROSE network is organized through nodes connected via hamradio or Internet.
AX25 packet radio frames sent to a remote ROSE address destination are routed
through these nodes.

Without the present patch, automatic routing mechanism did not work optimally
due to an improper parameter checking.

rose_get_neigh() function is called either by rose_connect() or by
rose_route_frame().

In the case of a call from rose_connect(), f0 timer is checked to find if a connection
is already pending. In that case it returns the address of the neighbour, or returns a NULL otherwise.

When called by rose_route_frame() the purpose was to route a packet AX25 frame
through an adjacent node given a destination rose address.
However, in that case, t0 timer checked does not indicate if the adjacent node
is actually connected even if the timer is not null. Thus, for each frame sent, the
function often tried to start a new connexion even if the adjacent node was already connected.

The patch adds a "new" parameter that is true when the function is called by
rose route_frame().
This instructs rose_get_neigh() to check node parameter "restarted". 
If restarted is true it means that the route to the destination address is opened via a neighbour
node already connected.
If "restarted" is false the function returns a NULL.
In that case the calling function will initiate a new connection as before.

This results in a fast routing of frames, from nodes to nodes, until
destination is reached, as originaly specified by ROSE protocole.
Signed-off-by: default avatarBernard Pidoux <f6bvp@amsat.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e92481f9
...@@ -201,7 +201,7 @@ extern void rose_link_device_down(struct net_device *); ...@@ -201,7 +201,7 @@ extern void rose_link_device_down(struct net_device *);
extern struct net_device *rose_dev_first(void); extern struct net_device *rose_dev_first(void);
extern struct net_device *rose_dev_get(rose_address *); extern struct net_device *rose_dev_get(rose_address *);
extern struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *); extern struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
extern struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *, unsigned char *); extern struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *, unsigned char *, int);
extern int rose_rt_ioctl(unsigned int, void __user *); extern int rose_rt_ioctl(unsigned int, void __user *);
extern void rose_link_failed(ax25_cb *, int); extern void rose_link_failed(ax25_cb *, int);
extern int rose_route_frame(struct sk_buff *, ax25_cb *); extern int rose_route_frame(struct sk_buff *, ax25_cb *);
......
...@@ -757,7 +757,7 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le ...@@ -757,7 +757,7 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause, rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause,
&diagnostic); &diagnostic, 0);
if (!rose->neighbour) { if (!rose->neighbour) {
err = -ENETUNREACH; err = -ENETUNREACH;
goto out_release; goto out_release;
...@@ -853,7 +853,7 @@ rose_try_next_neigh: ...@@ -853,7 +853,7 @@ rose_try_next_neigh:
if (sk->sk_state != TCP_ESTABLISHED) { if (sk->sk_state != TCP_ESTABLISHED) {
/* Try next neighbour */ /* Try next neighbour */
rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause, &diagnostic); rose->neighbour = rose_get_neigh(&addr->srose_addr, &cause, &diagnostic, 0);
if (rose->neighbour) if (rose->neighbour)
goto rose_try_next_neigh; goto rose_try_next_neigh;
......
...@@ -662,27 +662,34 @@ struct rose_route *rose_route_free_lci(unsigned int lci, struct rose_neigh *neig ...@@ -662,27 +662,34 @@ struct rose_route *rose_route_free_lci(unsigned int lci, struct rose_neigh *neig
} }
/* /*
* Find a neighbour given a ROSE address. * Find a neighbour or a route given a ROSE address.
*/ */
struct rose_neigh *rose_get_neigh(rose_address *addr, unsigned char *cause, struct rose_neigh *rose_get_neigh(rose_address *addr, unsigned char *cause,
unsigned char *diagnostic) unsigned char *diagnostic, int new)
{ {
struct rose_neigh *res = NULL; struct rose_neigh *res = NULL;
struct rose_node *node; struct rose_node *node;
int failed = 0; int failed = 0;
int i; int i;
spin_lock_bh(&rose_node_list_lock); if (!new) spin_lock_bh(&rose_node_list_lock);
for (node = rose_node_list; node != NULL; node = node->next) { for (node = rose_node_list; node != NULL; node = node->next) {
if (rosecmpm(addr, &node->address, node->mask) == 0) { if (rosecmpm(addr, &node->address, node->mask) == 0) {
for (i = 0; i < node->count; i++) { for (i = 0; i < node->count; i++) {
if (!rose_ftimer_running(node->neighbour[i])) { if (new) {
res = node->neighbour[i]; if (node->neighbour[i]->restarted) {
goto out; res = node->neighbour[i];
} else goto out;
failed = 1; }
}
else {
if (!rose_ftimer_running(node->neighbour[i])) {
res = node->neighbour[i];
goto out;
} else
failed = 1;
}
} }
break;
} }
} }
...@@ -695,7 +702,7 @@ struct rose_neigh *rose_get_neigh(rose_address *addr, unsigned char *cause, ...@@ -695,7 +702,7 @@ struct rose_neigh *rose_get_neigh(rose_address *addr, unsigned char *cause,
} }
out: out:
spin_unlock_bh(&rose_node_list_lock); if (!new) spin_unlock_bh(&rose_node_list_lock);
return res; return res;
} }
...@@ -1018,7 +1025,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) ...@@ -1018,7 +1025,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
rose_route = rose_route->next; rose_route = rose_route->next;
} }
if ((new_neigh = rose_get_neigh(dest_addr, &cause, &diagnostic)) == NULL) { if ((new_neigh = rose_get_neigh(dest_addr, &cause, &diagnostic, 1)) == NULL) {
rose_transmit_clear_request(rose_neigh, lci, cause, diagnostic); rose_transmit_clear_request(rose_neigh, lci, cause, diagnostic);
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment