diff options
author | jhay <jhay@FreeBSD.org> | 1997-07-06 07:38:36 +0000 |
---|---|---|
committer | jhay <jhay@FreeBSD.org> | 1997-07-06 07:38:36 +0000 |
commit | 18fa8ff2b470b736a50fb803e1e891bc2f4d247b (patch) | |
tree | 99ed7bad5d7b247fd7423644806e43dc4dc3a8dc /usr.sbin/IPXrouted/tables.c | |
parent | 60f787e21f64c5425b302b242c9a638f55ebb6ad (diff) | |
download | FreeBSD-src-18fa8ff2b470b736a50fb803e1e891bc2f4d247b.zip FreeBSD-src-18fa8ff2b470b736a50fb803e1e891bc2f4d247b.tar.gz |
Major IPXrouted rework.
In rt_change() remember to update the interface pointer otherwise we will
send the RIP packets to the wrong interface(s) in future.
Update the hash generator and increase the size of the hash tables.
Only use the network and host parts when comparing IPX interface addresses.
Immediately broadscast RIP and SAP changes.
Change the alarm code to use the setitimer() call and only set a flag in
the alarm signal handler. This gets rid of possible race conditions.
Remove the host routing table. IPX RIP cannot do host routes, only net routes.
Make the delay between broadcast packets 50ms. It seems that some Netware
4.x servers is very slow and don't have much input buffering.
Handle received messages about networks and services that go down, better.
Add tracing of RIP and SAP changes. It gets sysloged with a level of
LOG_DEBUG.
Diffstat (limited to 'usr.sbin/IPXrouted/tables.c')
-rw-r--r-- | usr.sbin/IPXrouted/tables.c | 79 |
1 files changed, 23 insertions, 56 deletions
diff --git a/usr.sbin/IPXrouted/tables.c b/usr.sbin/IPXrouted/tables.c index 17b2660..9fe7f45 100644 --- a/usr.sbin/IPXrouted/tables.c +++ b/usr.sbin/IPXrouted/tables.c @@ -32,7 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: tables.c,v 1.4 1997/02/22 16:01:03 peter Exp $ + * $Id: tables.c,v 1.5 1997/07/01 00:33:42 bde Exp $ */ #ifndef lint @@ -58,7 +58,6 @@ int install = !DEBUG; /* if 1 call kernel */ int delete = 1; struct rthash nethash[ROUTEHASHSIZ]; -struct rthash hosthash[ROUTEHASHSIZ]; /* * Lookup dst in the tables for an exact match. @@ -71,26 +70,18 @@ rtlookup(dst) register struct rthash *rh; register u_int hash; struct afhash h; - int doinghost = 1; if (dst->sa_family >= AF_MAX) return (0); (*afswitch[dst->sa_family].af_hash)(dst, &h); - hash = h.afh_hosthash; - rh = &hosthash[hash & ROUTEHASHMASK]; -again: + hash = h.afh_nethash; + rh = &nethash[hash & ROUTEHASHMASK]; for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { if (rt->rt_hash != hash) continue; if (equal(&rt->rt_dst, dst)) return (rt); } - if (doinghost) { - doinghost = 0; - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - goto again; - } return (0); } @@ -106,34 +97,21 @@ rtfind(dst) register u_int hash; struct afhash h; int af = dst->sa_family; - int doinghost = 1, (*match)() = 0; + int (*match)() = 0; if (af >= AF_MAX) return (0); (*afswitch[af].af_hash)(dst, &h); - hash = h.afh_hosthash; - rh = &hosthash[hash & ROUTEHASHMASK]; -again: + hash = h.afh_nethash; + rh = &nethash[hash & ROUTEHASHMASK]; + match = afswitch[af].af_netmatch; for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { if (rt->rt_hash != hash) continue; - if (doinghost) { - if (equal(&rt->rt_dst, dst)) - return (rt); - } else { - if (rt->rt_dst.sa_family == af && - (match != 0) && - (*match)(&rt->rt_dst, dst)) - return (rt); - } - } - if (doinghost) { - doinghost = 0; - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - match = afswitch[af].af_netmatch; - goto again; + if (rt->rt_dst.sa_family == af && + (*match)(&rt->rt_dst, dst)) + return (rt); } return (0); } @@ -156,13 +134,8 @@ rtadd(dst, gate, metric, ticks, state) return; (*afswitch[af].af_hash)(dst, &h); flags = (*afswitch[af].af_ishost)(dst) ? RTF_HOST : 0; - if (flags & RTF_HOST) { - hash = h.afh_hosthash; - rh = &hosthash[hash & ROUTEHASHMASK]; - } else { - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - } + hash = h.afh_nethash; + rh = &nethash[hash & ROUTEHASHMASK]; rt = (struct rt_entry *)malloc(sizeof (*rt)); if (rt == 0) return; @@ -179,7 +152,7 @@ rtadd(dst, gate, metric, ticks, state) if (metric) rt->rt_flags |= RTF_GATEWAY; insque(rt, rh); - TRACE_ACTION(ADD, rt); + TRACE_ACTION("ADD", rt); /* * If the ioctl fails because the gateway is unreachable * from this host, discard the entry. This should only @@ -189,7 +162,7 @@ rtadd(dst, gate, metric, ticks, state) if (errno != EEXIST) perror("SIOCADDRT"); if (errno == ENETUNREACH) { - TRACE_ACTION(DELETE, rt); + TRACE_ACTION("DELETE", rt); remque(rt); free((char *)rt); } @@ -215,13 +188,8 @@ rtadd_clone(ort, dst, gate, metric, ticks, state) return; (*afswitch[af].af_hash)(dst, &h); flags = (*afswitch[af].af_ishost)(dst) ? RTF_HOST : 0; - if (flags & RTF_HOST) { - hash = h.afh_hosthash; - rh = &hosthash[hash & ROUTEHASHMASK]; - } else { - hash = h.afh_nethash; - rh = &nethash[hash & ROUTEHASHMASK]; - } + hash = h.afh_nethash; + rh = &nethash[hash & ROUTEHASHMASK]; rt = (struct rt_entry *)malloc(sizeof (*rt)); if (rt == 0) return; @@ -243,7 +211,7 @@ rtadd_clone(ort, dst, gate, metric, ticks, state) while(ort->rt_clone != NULL) ort = ort->rt_clone; ort->rt_clone = rt; - TRACE_ACTION(ADD_CLONE, rt); + TRACE_ACTION("ADD_CLONE", rt); } void @@ -319,7 +287,7 @@ rtchange(rt, gate, metric, ticks) if ((metric != rt->rt_metric) || (ticks != rt->rt_ticks)) metricchanged++; if (doioctl || metricchanged) { - TRACE_ACTION(CHANGE FROM, rt); + TRACE_ACTION("CHANGE FROM", rt); if (doioctl) { oldroute = rt->rt_rt; rt->rt_router = *gate; @@ -340,15 +308,16 @@ rtchange(rt, gate, metric, ticks) rt->rt_flags |= RTF_GATEWAY; else rt->rt_flags &= ~RTF_GATEWAY; + rt->rt_ifp = if_ifwithnet(&rt->rt_router); rt->rt_state |= RTS_CHANGED; - TRACE_ACTION(CHANGE TO, rt); + TRACE_ACTION("CHANGE TO", rt); } if (doioctl && install) { #ifndef RTM_ADD if (rtioctl(ADD, &rt->rt_rt) < 0) syslog(LOG_ERR, "rtioctl ADD dst %s, gw %s: %m", - xns_ntoa(&((struct sockaddr_ns *)&rt->rt_dst)->sns_addr), - xns_ntoa(&((struct sockaddr_ns *)&rt->rt_router)->sns_addr)); + ipx_ntoa(&((struct sockaddr_ipx *)&rt->rt_dst)->sipx_addr), + ipx_ntoa(&((struct sockaddr_ipx *)&rt->rt_router)->sipx_addr)); if (delete && rtioctl(DELETE, &oldroute) < 0) perror("rtioctl DELETE"); #else @@ -392,7 +361,7 @@ rtdelete(rt) syslog(LOG_ERR, "deleting route to interface ??? (timed out)"); } - TRACE_ACTION(DELETE, rt); + TRACE_ACTION("DELETE", rt); if (install && rtioctl(DELETE, &rt->rt_rt) < 0) perror("rtioctl DELETE"); remque(rt); @@ -406,8 +375,6 @@ rtinit(void) for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) rh->rt_forw = rh->rt_back = (struct rt_entry *)rh; - for (rh = hosthash; rh < &hosthash[ROUTEHASHSIZ]; rh++) - rh->rt_forw = rh->rt_back = (struct rt_entry *)rh; } int seqno; |