Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/ldpd Don't try to connect to peers before sending h...



details:   https://anonhg.NetBSD.org/src/rev/bbbb0381fc8a
branches:  trunk
changeset: 784618:bbbb0381fc8a
user:      kefren <kefren%NetBSD.org@localhost>
date:      Sun Feb 03 19:41:59 2013 +0000

description:
Don't try to connect to peers before sending hellos

diffstat:

 usr.sbin/ldpd/fsm.c       |  7 ++++---
 usr.sbin/ldpd/fsm.h       |  4 ++--
 usr.sbin/ldpd/socketops.c |  8 ++++++--
 3 files changed, 12 insertions(+), 7 deletions(-)

diffs (89 lines):

diff -r fbbfa72111f1 -r bbbb0381fc8a usr.sbin/ldpd/fsm.c
--- a/usr.sbin/ldpd/fsm.c       Sun Feb 03 19:16:06 2013 +0000
+++ b/usr.sbin/ldpd/fsm.c       Sun Feb 03 19:41:59 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsm.c,v 1.8 2013/01/28 20:06:52 kefren Exp $ */
+/* $NetBSD: fsm.c,v 1.9 2013/02/03 19:41:59 kefren Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
 /* Processing a hello */
 void
 run_ldp_hello(struct ldp_pdu * pduid, struct hello_tlv * ht,
-    struct sockaddr * padd, struct in_addr * ladd, int mysock)
+    struct sockaddr * padd, struct in_addr * ladd, int mysock, bool may_connect)
 {
        struct ldp_peer *peer = NULL;
        struct transport_address_tlv *trtlv;
@@ -133,7 +133,8 @@
                 * otherwise it is passive.
                 */
                /* XXX TODO: check for IPv6 too */
-               if (hi->transport_address.sa.sa_family == AF_INET &&
+               if (may_connect == true &&
+                   hi->transport_address.sa.sa_family == AF_INET &&
                    ntohl(hi->transport_address.sin.sin_addr.s_addr) <
                    ntohl(ladd->s_addr)) {
                        peer = ldp_peer_new(&pduid->ldp_id, padd,
diff -r fbbfa72111f1 -r bbbb0381fc8a usr.sbin/ldpd/fsm.h
--- a/usr.sbin/ldpd/fsm.h       Sun Feb 03 19:16:06 2013 +0000
+++ b/usr.sbin/ldpd/fsm.h       Sun Feb 03 19:41:59 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsm.h,v 1.2 2013/01/26 17:29:55 kefren Exp $ */
+/* $NetBSD: fsm.h,v 1.3 2013/02/03 19:41:59 kefren Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "pdu.h"
 
 void   run_ldp_hello(struct ldp_pdu *, struct hello_tlv *,
-               struct sockaddr *, struct in_addr *, int);
+               struct sockaddr *, struct in_addr *, int, bool);
 struct address_list_tlv *      build_address_list_tlv(void);
 int    set_my_ldp_id(void);
 
diff -r fbbfa72111f1 -r bbbb0381fc8a usr.sbin/ldpd/socketops.c
--- a/usr.sbin/ldpd/socketops.c Sun Feb 03 19:16:06 2013 +0000
+++ b/usr.sbin/ldpd/socketops.c Sun Feb 03 19:41:59 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.c,v 1.23 2013/01/28 21:35:35 kefren Exp $ */
+/* $NetBSD: socketops.c,v 1.24 2013/02/03 19:41:59 kefren Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -75,6 +75,7 @@
 int    ldp_holddown_time = LDP_HOLDTIME;
 int    no_default_route = 1;
 int    loop_detection = 0;
+bool   may_connect;
 
 void   recv_pdu(int);
 void   send_hello_alarm(int);
@@ -703,7 +704,7 @@
 
        /* Fill the TLV messages */
        t = get_hello_tlv(recvspace + i, c - i);
-       run_ldp_hello(&rpdu, t, &sender.sa, &local_addr, sock);
+       run_ldp_hello(&rpdu, t, &sender.sa, &local_addr, sock, may_connect);
 }
 
 void 
@@ -714,6 +715,8 @@
        time_t          t = time(NULL);
        int             olderrno = errno;
 
+       if (may_connect == false)
+               may_connect = true;
        /* Send hellos */
        if (!(t % ldp_hello_time))
                send_hello();
@@ -798,6 +801,7 @@
        signal(SIGTERM, bail_out);
 
        /* Send first hellos in 5 seconds. Avoid No hello notifications */
+       may_connect = false;
        alarm(5);
 
        route_socket = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);



Home | Main Index | Thread Index | Old Index