Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/ldpd Use IN_LOOPBACKNET where is the case



details:   https://anonhg.NetBSD.org/src/rev/9059b2be7e71
branches:  trunk
changeset: 766050:9059b2be7e71
user:      kefren <kefren%NetBSD.org@localhost>
date:      Tue Jun 14 11:23:02 2011 +0000

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

diffstat:

 usr.sbin/ldpd/fsm.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (70 lines):

diff -r 71613986f2fd -r 9059b2be7e71 usr.sbin/ldpd/fsm.c
--- a/usr.sbin/ldpd/fsm.c       Tue Jun 14 07:53:29 2011 +0000
+++ b/usr.sbin/ldpd/fsm.c       Tue Jun 14 11:23:02 2011 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index