patch-2.1.22 linux/net/netrom/nr_route.c
Next file: linux/net/netrom/nr_subr.c
Previous file: linux/net/netrom/nr_out.c
Back to the patch index
Back to the overall index
- Lines: 252
- Date:
Sun Jan 19 15:47:29 1997
- Orig file:
v2.1.21/linux/net/netrom/nr_route.c
- Orig date:
Thu Jan 2 15:55:28 1997
diff -u --recursive --new-file v2.1.21/linux/net/netrom/nr_route.c linux/net/netrom/nr_route.c
@@ -21,8 +21,9 @@
* as node callsign.
* Alan Cox(GW4PTS) Added the firewall hooks.
* NET/ROM 006 Jonathan(G4KLX) Added the setting of digipeated neighbours.
+ * Tomi(OH2BNS) Routing quality and link failure changes.
*/
-
+
#include <linux/config.h>
#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
#include <linux/errno.h>
@@ -83,6 +84,9 @@
if (ax25cmp(ax25, &nr_neigh->callsign) == 0 && nr_neigh->dev == dev)
break;
+ if (nr_neigh != NULL)
+ nr_neigh->failed = 0;
+
if (quality == 0 && nr_neigh != NULL && nr_node != NULL)
return 0;
@@ -93,10 +97,7 @@
nr_neigh->callsign = *ax25;
nr_neigh->digipeat = NULL;
nr_neigh->dev = dev;
- if (ax25cmp(nr, ax25) == 0)
- nr_neigh->quality = quality;
- else
- nr_neigh->quality = sysctl_netrom_default_path_quality;
+ nr_neigh->quality = sysctl_netrom_default_path_quality;
nr_neigh->locked = 0;
nr_neigh->count = 0;
nr_neigh->number = nr_neigh_no++;
@@ -118,6 +119,9 @@
restore_flags(flags);
}
+ if (quality != 0 && ax25cmp(nr, ax25) == 0)
+ nr_neigh->quality = quality;
+
if (nr_node == NULL) {
if ((nr_node = (struct nr_node *)kmalloc(sizeof(*nr_node), GFP_ATOMIC)) == NULL)
return -ENOMEM;
@@ -131,7 +135,7 @@
nr_node->routes[0].quality = quality;
nr_node->routes[0].obs_count = obs_count;
nr_node->routes[0].neighbour = nr_neigh;
-
+
save_flags(flags);
cli();
@@ -139,15 +143,15 @@
nr_node_list = nr_node;
restore_flags(flags);
-
+
nr_neigh->count++;
return 0;
- } else {
- if (nr_node->mnemonic[0] == '\0')
- strcpy(nr_node->mnemonic, mnemonic);
}
+ if (quality != 0)
+ strcpy(nr_node->mnemonic, mnemonic);
+
for (found = 0, i = 0; i < nr_node->count; i++) {
if (nr_node->routes[i].neighbour == nr_neigh) {
nr_node->routes[i].quality = quality;
@@ -166,7 +170,7 @@
nr_node->routes[0].quality = quality;
nr_node->routes[0].obs_count = obs_count;
nr_node->routes[0].neighbour = nr_neigh;
-
+
nr_node->which++;
nr_node->count++;
nr_neigh->count++;
@@ -174,10 +178,10 @@
/* It must be better than the worst */
if (quality > nr_node->routes[2].quality) {
nr_node->routes[2].neighbour->count--;
-
+
if (nr_node->routes[2].neighbour->count == 0 && !nr_node->routes[2].neighbour->locked)
nr_remove_neigh(nr_node->routes[2].neighbour);
-
+
nr_node->routes[2].quality = quality;
nr_node->routes[2].obs_count = obs_count;
nr_node->routes[2].neighbour = nr_neigh;
@@ -240,7 +244,7 @@
{
struct nr_node *s;
unsigned long flags;
-
+
save_flags(flags);
cli();
@@ -307,7 +311,7 @@
struct nr_node *nr_node;
struct nr_neigh *nr_neigh;
int i;
-
+
for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next)
if (ax25cmp(callsign, &nr_node->callsign) == 0)
break;
@@ -319,7 +323,7 @@
break;
if (nr_neigh == NULL) return -EINVAL;
-
+
for (i = 0; i < nr_node->count; i++) {
if (nr_node->routes[i].neighbour == nr_neigh) {
nr_neigh->count--;
@@ -328,7 +332,7 @@
nr_remove_neigh(nr_neigh);
nr_node->count--;
-
+
if (nr_node->count == 0) {
nr_remove_node(nr_node);
} else {
@@ -375,6 +379,7 @@
nr_neigh->locked = 1;
nr_neigh->count = 0;
nr_neigh->number = nr_neigh_no++;
+ nr_neigh->failed = 0;
if (ax25_digi != NULL && ax25_digi->ndigi > 0) {
if ((nr_neigh->digipeat = kmalloc(sizeof(*ax25_digi), GFP_KERNEL)) == NULL) {
@@ -386,7 +391,7 @@
save_flags(flags);
cli();
-
+
nr_neigh->next = nr_neigh_list;
nr_neigh_list = nr_neigh;
@@ -443,9 +448,9 @@
case 1: /* From 1 -> 0 */
nr_neigh = s->routes[i].neighbour;
-
+
nr_neigh->count--;
-
+
if (nr_neigh->count == 0 && !nr_neigh->locked)
nr_remove_neigh(nr_neigh);
@@ -487,14 +492,14 @@
while (nr_neigh != NULL) {
s = nr_neigh;
nr_neigh = nr_neigh->next;
-
+
if (s->dev == dev) {
nr_node = nr_node_list;
while (nr_node != NULL) {
t = nr_node;
nr_node = nr_node->next;
-
+
for (i = 0; i < t->count; i++) {
if (t->routes[i].neighbour == s) {
t->count--;
@@ -509,11 +514,11 @@
}
}
}
-
+
if (t->count <= 0)
nr_remove_node(t);
}
-
+
nr_remove_neigh(s);
}
}
@@ -561,7 +566,7 @@
for (dev = dev_base; dev != NULL; dev = dev->next)
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0)
return dev;
-
+
return NULL;
}
@@ -658,9 +663,11 @@
for (nr_neigh = nr_neigh_list; nr_neigh != NULL; nr_neigh = nr_neigh->next)
if (ax25cmp(&nr_neigh->callsign, callsign) == 0 && nr_neigh->dev == dev)
break;
-
+
if (nr_neigh == NULL) return;
-
+
+ if (++nr_neigh->failed < sysctl_netrom_link_fails_count) return;
+
for (nr_node = nr_node_list; nr_node != NULL; nr_node = nr_node->next)
if (nr_node->which < nr_node->count && nr_node->routes[nr_node->which].neighbour == nr_neigh)
nr_node->which++;
@@ -677,7 +684,7 @@
struct nr_node *nr_node;
struct device *dev;
unsigned char *dptr;
-
+
#ifdef CONFIG_FIREWALL
if (ax25 != NULL && call_in_firewall(PF_NETROM, skb->dev, skb->data, NULL) != FW_ACCEPT)
return 0;
@@ -786,16 +793,17 @@
cli();
- len += sprintf(buffer, "addr callsign dev qual lock count digipeaters\n");
+ len += sprintf(buffer, "addr callsign dev qual lock count failed digipeaters\n");
for (nr_neigh = nr_neigh_list; nr_neigh != NULL; nr_neigh = nr_neigh->next) {
- len += sprintf(buffer + len, "%05d %-9s %-4s %3d %d %3d",
+ len += sprintf(buffer + len, "%05d %-9s %-4s %3d %d %3d %3d",
nr_neigh->number,
ax2asc(&nr_neigh->callsign),
nr_neigh->dev ? nr_neigh->dev->name : "???",
nr_neigh->quality,
nr_neigh->locked,
- nr_neigh->count);
+ nr_neigh->count,
+ nr_neigh->failed);
if (nr_neigh->digipeat != NULL) {
for (i = 0; i < nr_neigh->digipeat->ndigi; i++)
@@ -810,7 +818,7 @@
len = 0;
begin = pos;
}
-
+
if (pos > offset + length)
break;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov