Problem in client_find() in CVS head

Nicolas Baradakis nbk at sitadelle.com
Thu Jun 30 19:21:06 CEST 2005


I get errors "Ignoring request from unknown client ..." when using the
CVS head version. I think there is a problem in the IPv4 addresses
comparison in client_find().

The following patch solved the problem for me, but perhaps there is a
better solution. If I get approval, I can commit it to the CVS.

Index: src/main/client.c
===================================================================
RCS file: /source/radiusd/src/main/client.c,v
retrieving revision 1.35
diff -u -r1.35 client.c
--- src/main/client.c	12 May 2005 22:22:48 -0000	1.35
+++ src/main/client.c	30 Jun 2005 16:04:34 -0000
@@ -271,7 +271,8 @@
 		switch (ipaddr->af) {
 		case AF_INET:
 			if (cl->prefix) {
-				if ((htonl(ipaddr->ipaddr.ip4addr.s_addr) & (~0 << cl->prefix)) == (htonl(cl->ipaddr.ipaddr.ip4addr.s_addr) & (~0 << cl->prefix))) {
+				uint32_t mask = htonl(~((1 << (32 - cl->prefix)) - 1));
+				if ((ipaddr->ipaddr.ip4addr.s_addr & mask) == (cl->ipaddr.ipaddr.ip4addr.s_addr & mask)) {
 					match = cl;
 				} else
 					break;

-- 
Nicolas Baradakis




More information about the Freeradius-Devel mailing list