Subject: Re: bin/17613
To: Jason R. Fink <jrf@adresearch.com>
From: Quentin Garnier <netbsd@quatriemek.com>
List: netbsd-bugs
Date: 04/04/2003 18:35:04
Le Fri, 4 Apr 2003 10:48:05 -0500
Jason R. Fink a ecrit :
[...]
> Otherwise, just using 224 causes inet_pton4
> to translate it differently. I don't really
> see a way to "fix" this.
As in inet_pton(3), a calue with no dots is interpreted by inet_network as
a 32-bits plain address. Thus the 'net' value passed to
inet_makenetandmask is (in that case) 224, which is interpreted as a class
B address, which is, of course, completely bogus.
inet_makenetandmask makes only three tests to guess the class, where I
think it should be more fine-grained. The following patch brings the
expected behaviour.
Index: route.c
===================================================================
RCS file: /cvsroot/src/sbin/route/route.c,v
retrieving revision 1.61
diff -u -r1.61 route.c
--- route.c 2002/10/18 00:21:23 1.61
+++ route.c 2003/04/04 16:33:56
@@ -1056,10 +1056,34 @@
else if (net < 128) {
addr = net << IN_CLASSA_NSHIFT;
mask = IN_CLASSA_NET;
- } else if (net < 65536) {
+ } else if (net < 192) {
+ addr = net << IN_CLASSA_NSHIFT;
+ mask = IN_CLASSB_NET;
+ } else if (net < 224) {
+ addr = net << IN_CLASSA_NSHIFT;
+ mask = IN_CLASSC_NET;
+ } else if (net < 256) {
+ /*
+ * XXX I don't know anything about
+ * how multicast addresses and the
+ * remaining ones (class E) should
+ * be handled
+ */
+ addr = net << IN_CLASSA_NSHIFT;
+ mask = IN_CLASSC_NET;
+ } else if (net < 49152) { /* 192 * 256 */
+ addr = net << IN_CLASSB_NSHIFT;
+ mask = IN_CLASSB_NET;
+ } else if (net < 57344) { /* 224 * 256, this is getting silly */
+ addr = net << IN_CLASSB_NSHIFT;
+ mask = IN_CLASSC_NET;
+ } else if (net < 65536) { /* XXX See above */
addr = net << IN_CLASSB_NSHIFT;
mask = IN_CLASSB_NET;
- } else if (net < 16777216L) {
+ } else if (net < 14680064L) { /* 224 * 65536 */
+ addr = net << IN_CLASSC_NSHIFT;
+ mask = IN_CLASSC_NET;
+ } else if (net < 16777216L) { /* XXX See above */
addr = net << IN_CLASSC_NSHIFT;
mask = IN_CLASSC_NET;
} else {
--
Quentin Garnier - cube@cubidou.net
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.