SCCS-vsn: sbin/routed/input.c 4.7
SCCS-vsn: sbin/routed/main.c 4.9
SCCS-vsn: sbin/routed/output.c 4.5
SCCS-vsn: include/protocols/routed.h 4.11
SCCS-vsn: sbin/routed/table.h 4.2
SCCS-vsn: sbin/routed/tables.c 4.6
SCCS-vsn: sbin/routed/timer.c 4.5
SCCS-vsn: sbin/routed/trace.c 4.6
SCCS-vsn: sbin/routed/trace.h 4.4
-/* routed.h 4.10 83/08/11 */
+/* routed.h 4.11 84/04/09 */
/*
* Routing Information Protocol
*
/*
* Routing Information Protocol
*
-static char sccsid[] = "@(#)input.c 4.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)input.c 4.7 (Berkeley) %G%";
case RIPCMD_TRACEON:
case RIPCMD_TRACEOFF:
case RIPCMD_TRACEON:
case RIPCMD_TRACEOFF:
- /* verify message came from a priviledged port */
+ /* verify message came from a privileged port */
if ((*afp->af_portcheck)(from) == 0)
return;
packet[size] = '\0';
if ((*afp->af_portcheck)(from) == 0)
return;
packet[size] = '\0';
ifp = if_ifwithaddr(from);
if (ifp) {
rt = rtfind(from);
ifp = if_ifwithaddr(from);
if (ifp) {
rt = rtfind(from);
+ if (rt == 0 || (rt->rt_state & RTS_INTERFACE) == 0)
addrouteforif(ifp);
else
rt->rt_timer = 0;
return;
}
addrouteforif(ifp);
else
rt->rt_timer = 0;
return;
}
+ /* update timer for interface on which the packet arrived */
+ if ((rt = rtfind(from)) && (rt->rt_state & RTS_INTERFACE))
+ rt->rt_timer = 0;
size -= 4 * sizeof (char);
n = msg->rip_nets;
for (; size > 0; size -= sizeof (struct netinfo), n++) {
size -= 4 * sizeof (char);
n = msg->rip_nets;
for (; size > 0; size -= sizeof (struct netinfo), n++) {
* stale and equivalent.
*/
if (equal(from, &rt->rt_router) ||
* stale and equivalent.
*/
if (equal(from, &rt->rt_router) ||
- (unsigned) n->rip_metric < rt->rt_metric ||
+ (unsigned) (n->rip_metric) < rt->rt_metric ||
(rt->rt_timer > (EXPIRE_TIME/2) &&
rt->rt_metric == n->rip_metric)) {
rtchange(rt, from, n->rip_metric);
(rt->rt_timer > (EXPIRE_TIME/2) &&
rt->rt_metric == n->rip_metric)) {
rtchange(rt, from, n->rip_metric);
-static char sccsid[] = "@(#)main.c 4.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 4.9 (Berkeley) %G%";
int supplier = -1; /* process should supply updates */
struct rip *msg = (struct rip *)packet;
int supplier = -1; /* process should supply updates */
struct rip *msg = (struct rip *)packet;
main(argc, argv)
int argc;
main(argc, argv)
int argc;
msg->rip_nets[0].rip_metric = htonl(HOPCNT_INFINITY);
toall(sendmsg);
signal(SIGALRM, timer);
msg->rip_nets[0].rip_metric = htonl(HOPCNT_INFINITY);
toall(sendmsg);
signal(SIGALRM, timer);
-static char sccsid[] = "@(#)output.c 4.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)output.c 4.5 (Berkeley) %G%";
-/* table.h 4.1 83/01/11 */
+/* table.h 4.2 84/04/09 */
/*
* Routing table management daemon.
/*
* Routing table management daemon.
* "State" of routing table entry.
*/
#define RTS_CHANGED 0x1 /* route has been altered recently */
* "State" of routing table entry.
*/
#define RTS_CHANGED 0x1 /* route has been altered recently */
-#define RTS_PASSIVE 0x20 /* don't time out route */
-#define RTS_INTERFACE 0x40 /* route is for network interface */
-#define RTS_REMOTE 0x80 /* route is for ``remote'' entity */
+#define RTS_PASSIVE IFF_PASSIVE /* don't time out route */
+#define RTS_INTERFACE IFF_INTERFACE /* route is for network interface */
+#define RTS_REMOTE IFF_REMOTE /* route is for ``remote'' entity */
struct rthash nethash[ROUTEHASHSIZ];
struct rthash hosthash[ROUTEHASHSIZ];
struct rthash nethash[ROUTEHASHSIZ];
struct rthash hosthash[ROUTEHASHSIZ];
-static char sccsid[] = "@(#)tables.c 4.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)tables.c 4.6 (Berkeley) %G%";
{
int doioctl = 0, metricchanged = 0;
struct rtentry oldroute;
{
int doioctl = 0, metricchanged = 0;
struct rtentry oldroute;
+#define NDEBUG
+#ifdef NDEBUG
+ int turntraceoff = 0;
+#endif
if (!equal(&rt->rt_router, gate))
doioctl++;
if (!equal(&rt->rt_router, gate))
doioctl++;
- if (metric != rt->rt_metric) {
+ if (metric != rt->rt_metric)
- rt->rt_metric = metric;
- }
if (doioctl || metricchanged) {
if (doioctl || metricchanged) {
- TRACE_ACTION(CHANGE, rt);
+#ifdef NDEBUG
+ if (rt->rt_state & RTS_INTERFACE) {
+ if (!tracing) {
+ traceon("/usr/adm/routed.log");
+ turntraceoff = 1;
+ fprintf(ftrace, "**** Changing route from interface\n");
+ fprintf(ftrace, "rt_timer = %d\n", rt->rt_timer);
+ }
+ }
+#endif
+ TRACE_ACTION(CHANGE FROM, rt);
+ if (doioctl) {
+ oldroute = rt->rt_rt;
+ rt->rt_router = *gate;
+ }
+ rt->rt_metric = metric;
+ rt->rt_state &= ~RTS_INTERFACE;
+ if (metric)
+ rt->rt_state |= RTF_GATEWAY;
rt->rt_state |= RTS_CHANGED;
rt->rt_state |= RTS_CHANGED;
+ TRACE_ACTION(CHANGE TO, rt);
- if (doioctl) {
- oldroute = rt->rt_rt;
- rt->rt_router = *gate;
- if (install) {
- if (ioctl(s, SIOCADDRT, (char *)&rt->rt_rt) < 0)
- perror("SIOCADDRT");
- if (ioctl(s, SIOCDELRT, (char *)&oldroute) < 0)
- perror("SIOCDELRT");
- }
+ if (doioctl && install) {
+ if (ioctl(s, SIOCADDRT, (char *)&rt->rt_rt) < 0)
+ perror("SIOCADDRT");
+ if (ioctl(s, SIOCDELRT, (char *)&oldroute) < 0)
+ perror("SIOCDELRT");
+#ifdef NDEBUG
+ if (turntraceoff)
+ traceoff();
+#endif
-static char sccsid[] = "@(#)timer.c 4.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)timer.c 4.5 (Berkeley) %G%";
toall(supply);
alarm(TIMER_RATE);
}
toall(supply);
alarm(TIMER_RATE);
}
+
+/*
+ * On hangup, let everyone know we're going away.
+ */
+hup()
+{
+ register struct rthash *rh;
+ register struct rt_entry *rt;
+ struct rthash *base = hosthash;
+ int doinghost = 1;
+
+ if (supplier) {
+again:
+ for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) {
+ rt = rh->rt_forw;
+ for (; rt != (struct rt_entry *)rh; rt = rt->rt_forw)
+ rt->rt_metric = HOPCNT_INFINITY;
+ }
+ if (doinghost) {
+ doinghost = 0;
+ base = nethash;
+ goto again;
+ }
+ toall(supply);
+ }
+ exit(1);
+}
-static char sccsid[] = "@(#)trace.c 4.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)trace.c 4.6 (Berkeley) %G%";
if (ifd->ifd_records == 0)
return (0);
ifd->ifd_front = ifd->ifd_records;
if (ifd->ifd_records == 0)
return (0);
ifd->ifd_front = ifd->ifd_records;
for (t = ifd->ifd_records; t < ifd->ifd_records + NRECORDS; t++) {
t->ift_size = 0;
t->ift_packet = 0;
for (t = ifd->ifd_records; t < ifd->ifd_records + NRECORDS; t++) {
t->ift_size = 0;
t->ift_packet = 0;
t = ifd->ifd_front++;
if (ifd->ifd_front >= ifd->ifd_records + NRECORDS)
ifd->ifd_front = ifd->ifd_records;
t = ifd->ifd_front++;
if (ifd->ifd_front >= ifd->ifd_records + NRECORDS)
ifd->ifd_front = ifd->ifd_records;
+ if (ifd->ifd_count < NRECORDS)
+ ifd->ifd_count++;
if (t->ift_size > 0 && t->ift_packet)
free(t->ift_packet);
t->ift_packet = 0;
if (t->ift_size > 0 && t->ift_packet)
free(t->ift_packet);
t->ift_packet = 0;
dumpif(fd, ifp)
register struct interface *ifp;
{
dumpif(fd, ifp)
register struct interface *ifp;
{
- register struct ifdebug *ifd;
-
- fprintf(fd, "*** Packet history for interface %s ***\n",
- ifp->int_name);
- dumptrace(fd, "to", &ifp->int_output);
- dumptrace(fd, "from", &ifp->int_output);
- fprintf(fd, "*** end packet history ***\n");
+ if (ifp->int_input.ifd_count || ifp->int_output.ifd_count) {
+ fprintf(fd, "*** Packet history for interface %s ***\n",
+ ifp->int_name);
+ dumptrace(fd, "to", &ifp->int_output);
+ dumptrace(fd, "from", &ifp->int_input);
+ fprintf(fd, "*** end packet history ***\n");
+ }
}
dumptrace(fd, dir, ifd)
}
dumptrace(fd, dir, ifd)
return;
}
fprintf(fd, "%s trace:\n", cp);
return;
}
fprintf(fd, "%s trace:\n", cp);
- for (t = ifd->ifd_front; t <= ifd->ifd_records + NRECORDS; t++) {
- if (t->ift_size == 0)
- continue;
- fprintf(fd, "%.24s: metric=%d\n", ctime(&t->ift_stamp),
- t->ift_metric);
- dumppacket(fd, dir, &t->ift_who, t->ift_packet, t->ift_size);
- }
- for (t = ifd->ifd_records; t < ifd->ifd_front; t++) {
+ t = ifd->ifd_front - ifd->ifd_count;
+ if (t < ifd->ifd_records)
+ t += NRECORDS;
+ for ( ; ifd->ifd_count; ifd->ifd_count--, t++) {
+ if (t >= ifd->ifd_records + NRECORDS)
+ t = ifd->ifd_records;
if (t->ift_size == 0)
continue;
fprintf(fd, "%.24s: metric=%d\n", ctime(&t->ift_stamp),
if (t->ift_size == 0)
continue;
fprintf(fd, "%.24s: metric=%d\n", ctime(&t->ift_stamp),
-/* trace.h 4.3 83/05/25 */
+/* trace.h 4.4 84/04/09 */
/*
* Routing table management daemon.
/*
* Routing table management daemon.
struct ifdebug {
struct iftrace *ifd_records; /* array of trace records */
struct iftrace *ifd_front; /* next empty trace record */
struct ifdebug {
struct iftrace *ifd_records; /* array of trace records */
struct iftrace *ifd_front; /* next empty trace record */
+ int ifd_count; /* number of unprinted records */
struct interface *ifd_if; /* for locating stuff */
};
struct interface *ifd_if; /* for locating stuff */
};