Module Name:    src
Committed By:   kefren
Date:           Tue Jun 14 11:23:02 UTC 2011

Modified Files:
        src/usr.sbin/ldpd: fsm.c

Log Message:
Use IN_LOOPBACKNET where is the case
Don't forget to freeifaddrs() in case of error
Update a couple of debug messages


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/ldpd/fsm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ldpd/fsm.c
diff -u src/usr.sbin/ldpd/fsm.c:1.3 src/usr.sbin/ldpd/fsm.c:1.4
--- src/usr.sbin/ldpd/fsm.c:1.3	Mon Dec 13 01:25:19 2010
+++ src/usr.sbin/ldpd/fsm.c	Tue Jun 14 11:23:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: fsm.c,v 1.3 2010/12/13 01:25:19 christos Exp $ */
+/* $NetBSD: fsm.c,v 1.4 2011/06/14 11:23:02 kefren Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
 struct sockaddr	mplssockaddr;
 
 /* Processing a hello */
-void 
+void
 run_ldp_hello(struct ldp_pdu * pduid, struct hello_tlv * ht,
     struct in_addr * padd, struct in_addr * ladd, int mysock)
 {
@@ -62,7 +62,7 @@
 	if ((!pduid) || (!ht))
 		return;
 
-	debugp("Received it on address: %s\n", inet_ntoa(*ladd));
+	debugp("Hello received for address: %s\n", inet_ntoa(*ladd));
 	debugp("Hello: Type: 0x%.4X Length: %.2d ID: %.8X\n", ht->type,
 	    ht->length, ht->messageid);
 
@@ -73,7 +73,7 @@
 	if (hi == NULL) {
 		hi = malloc(sizeof(*hi));
 		if (!hi) {
-			fatalp("Cannot alloc a hello info");
+			fatalp("Cannot alloc a hello info structure");
 			return;
 		}
 		hi->ldp_id.s_addr = pduid->ldp_id.s_addr;
@@ -143,13 +143,14 @@
 		if ((ifb->ifa_addr->sa_family == AF_INET) &&
 		    (ifb->ifa_flags & IFF_UP)) {
 			sa = (struct sockaddr_in *) ifb->ifa_addr;
-			if (sa->sin_addr.s_addr << 24 >> 24 != 127)
+			if (ntohl(sa->sin_addr.s_addr) >> 24 != IN_LOOPBACKNET)
 				adrcount++;
 		}
 	t = malloc(sizeof(*t) + (adrcount - 1) * sizeof(struct in_addr));
 
 	if (!t) {
 		fatalp("build_address_list_tlv: malloc problem\n");
+		freeifaddrs(ifa);
 		return NULL;
 	}
 
@@ -191,7 +192,7 @@
 	struct sockaddr_in *sa;
 
 	a.s_addr = 0;
-	my_ldp_id[0] = 0;
+	my_ldp_id[0] = '\0';
 	mplssockaddr.sa_len = 0;
 
 	if (getifaddrs(&ifa) == -1)
@@ -208,7 +209,7 @@
 				continue;
 
 			sa = (struct sockaddr_in *) ifb->ifa_addr;
-			if (ntohl(sa->sin_addr.s_addr) >> 24 == 127)
+			if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
 				continue;	/* No 127/8 */
 			if (ntohl(sa->sin_addr.s_addr) > ntohl(a.s_addr))
 				a.s_addr = sa->sin_addr.s_addr;

Reply via email to