Module Name:    src
Committed By:   kefren
Date:           Sun Feb  3 19:41:59 UTC 2013

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

Log Message:
Don't try to connect to peers before sending hellos


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/ldpd/fsm.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/ldpd/fsm.h
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/ldpd/socketops.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.8 src/usr.sbin/ldpd/fsm.c:1.9
--- src/usr.sbin/ldpd/fsm.c:1.8	Mon Jan 28 20:06:52 2013
+++ src/usr.sbin/ldpd/fsm.c	Sun Feb  3 19:41:59 2013
@@ -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 @@ struct sockaddr	mplssockaddr;
 /* 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 @@ run_ldp_hello(struct ldp_pdu * pduid, st
 		 * 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,

Index: src/usr.sbin/ldpd/fsm.h
diff -u src/usr.sbin/ldpd/fsm.h:1.2 src/usr.sbin/ldpd/fsm.h:1.3
--- src/usr.sbin/ldpd/fsm.h:1.2	Sat Jan 26 17:29:55 2013
+++ src/usr.sbin/ldpd/fsm.h	Sun Feb  3 19:41:59 2013
@@ -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);
 

Index: src/usr.sbin/ldpd/socketops.c
diff -u src/usr.sbin/ldpd/socketops.c:1.23 src/usr.sbin/ldpd/socketops.c:1.24
--- src/usr.sbin/ldpd/socketops.c:1.23	Mon Jan 28 21:35:35 2013
+++ src/usr.sbin/ldpd/socketops.c	Sun Feb  3 19:41:59 2013
@@ -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_keepalive_time = LDP_KEEPALIVE_T
 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 @@ recv_pdu(int sock)
 
 	/* 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 @@ send_hello_alarm(int unused)
 	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 @@ the_big_loop(void)
 	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);

Reply via email to