Date: Fri, 4 Oct 1996 12:12:22 -0400 (EDT) From: John Capo <jc@irbs.com> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/1722: Routed byte order problem Message-ID: <199610041612.MAA25241@irbs.irbs.com> Resent-Message-ID: <199610041620.JAA26794@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 1722
>Category: bin
>Synopsis: Routed byte order problem
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Oct 4 09:20:01 PDT 1996
>Last-Modified:
>Originator: John Capo
>Organization:
>Release: FreeBSD 2.2 i386
>Environment:
>Description:
Routed expects networks to be in host order and addresses to be in
network order. parms.c:getnet() and trace.c:trace_if() get it
wrong. There may be other places also.
routed: bad "subnet=199.182.75.128/28" in "subnet=199.182.75.128/28"
Add interface tun0 199.182.75.131 -->1.1.9.192/32
>How-To-Repeat:
Try to use subnet=somenet/somemask in /etc/gateways or with -P.
Configure a point-to-point and turn on net.inet.ip.forwarding.
>Fix:
Index: parms.c
===================================================================
RCS file: /usr/cvs/src/sbin/routed/parms.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 parms.c
*** parms.c 1996/09/16 16:51:31 1.1.1.1
--- parms.c 1996/10/04 15:33:54
***************
*** 574,580 ****
if (np != 0) {
in.s_addr = (naddr)np->n_net;
} else if (inet_aton(name, &in) == 1) {
! HTONL(in.s_addr);
} else {
return 0;
}
--- 574,580 ----
if (np != 0) {
in.s_addr = (naddr)np->n_net;
} else if (inet_aton(name, &in) == 1) {
! NTOHL(in.s_addr);
} else {
return 0;
}
***************
*** 584,590 ****
* looked at them yet.
*/
mask = std_mask(in.s_addr);
! if ((~mask & ntohl(in.s_addr)) != 0)
mask = HOST_MASK;
} else {
mask = (naddr)strtoul(mname, &p, 0);
--- 584,590 ----
* looked at them yet.
*/
mask = std_mask(in.s_addr);
! if ((~mask & in.s_addr) != 0)
mask = HOST_MASK;
} else {
mask = (naddr)strtoul(mname, &p, 0);
***************
*** 594,603 ****
}
if (mask != 0 && in.s_addr == RIP_DEFAULT)
return 0;
! if ((~mask & ntohl(in.s_addr)) != 0)
return 0;
! *addrp = in.s_addr;
*maskp = mask;
return 1;
}
--- 594,604 ----
}
if (mask != 0 && in.s_addr == RIP_DEFAULT)
return 0;
!
! if ((~mask & in.s_addr) != 0)
return 0;
! *addrp = htonl(in.s_addr);
*maskp = mask;
return 1;
}
Index: trace.c
===================================================================
RCS file: /usr/cvs/src/sbin/routed/trace.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 trace.c
*** trace.c 1996/09/16 16:51:32 1.1.1.1
--- trace.c 1996/10/04 16:05:33
***************
*** 498,506 ****
(void)fprintf(ftrace, "%s interface %-4s ", act, ifp->int_name);
(void)fprintf(ftrace, "%-15s-->%-15s ",
naddr_ntoa(ifp->int_addr),
! addrname(htonl((ifp->int_if_flags & IFF_POINTOPOINT)
? ifp->int_dstaddr
! : ifp->int_net),
ifp->int_mask, 1));
if (ifp->int_metric != 0)
(void)fprintf(ftrace, "metric=%d ", ifp->int_metric);
--- 498,506 ----
(void)fprintf(ftrace, "%s interface %-4s ", act, ifp->int_name);
(void)fprintf(ftrace, "%-15s-->%-15s ",
naddr_ntoa(ifp->int_addr),
! addrname((ifp->int_if_flags & IFF_POINTOPOINT)
? ifp->int_dstaddr
! : htonl(ifp->int_net),
ifp->int_mask, 1));
if (ifp->int_metric != 0)
(void)fprintf(ftrace, "metric=%d ", ifp->int_metric);
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610041612.MAA25241>
