summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2010-05-28 12:27:17 +0000
committerclaudio <claudio@openbsd.org>2010-05-28 12:27:17 +0000
commit30d700d059847d434b538a5428a9b8ce6a62d209 (patch)
tree2971ddf480921ec1d230f469d3b73e8ecaa186d2
parentAdd mpls/-mpls commands to enable MPLS label switching on an interface. (diff)
downloadwireguard-openbsd-30d700d059847d434b538a5428a9b8ce6a62d209.tar.xz
wireguard-openbsd-30d700d059847d434b538a5428a9b8ce6a62d209.zip
Send the IMSG_NEIGHBOR_UP msg when the neighbor is going into operational
status instead upon creation (when the first HELLO is received). The LDE needs only to know about operational neighbors or it may happen that the LDE is sending messages to neighbors that have no session open resulting in a crash because of unitialized structures. OK michele@
-rw-r--r--usr.sbin/ldpd/neighbor.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index db1e1f9dc86..c48749ea846 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.15 2010/05/26 13:56:08 nicm Exp $ */
+/* $OpenBSD: neighbor.c,v 1.16 2010/05/28 12:27:17 claudio Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -42,6 +42,7 @@
int nbr_establish_connection(struct nbr *);
void nbr_send_labelmappings(struct nbr *);
+int nbr_act_session_operational(struct nbr *);
LIST_HEAD(nbr_head, nbr);
@@ -148,6 +149,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
nbr_reset_ktimer(nbr);
break;
case NBR_ACT_STRT_KTIMER:
+ nbr_act_session_operational(nbr);
nbr_start_ktimer(nbr);
nbr_start_ktimeout(nbr);
send_address(nbr, NULL);
@@ -161,6 +163,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
send_keepalive(nbr);
break;
case NBR_ACT_KEEPALIVE_SEND:
+ nbr_act_session_operational(nbr);
nbr_start_ktimer(nbr);
nbr_start_ktimeout(nbr);
send_keepalive(nbr);
@@ -225,7 +228,6 @@ nbr_new(u_int32_t nbr_id, u_int16_t lspace, struct iface *iface)
{
struct nbr_head *head;
struct nbr *nbr;
- struct lde_nbr rn;
if ((nbr = calloc(1, sizeof(*nbr))) == NULL)
fatal("nbr_new");
@@ -259,13 +261,6 @@ nbr_new(u_int32_t nbr_id, u_int16_t lspace, struct iface *iface)
evtimer_set(&nbr->keepalive_timer, nbr_ktimer, nbr);
evtimer_set(&nbr->initdelay_timer, nbr_idtimer, nbr);
- bzero(&rn, sizeof(rn));
- rn.id.s_addr = nbr->id.s_addr;
- rn.lspace = nbr->lspace;
- rn.ifindex = nbr->iface->ifindex;
- ldpe_imsg_compose_lde(IMSG_NEIGHBOR_UP, nbr->peerid, 0, &rn,
- sizeof(rn));
-
return (nbr);
}
@@ -582,6 +577,19 @@ nbr_act_session_establish(struct nbr *nbr, int active)
return (0);
}
+int
+nbr_act_session_operational(struct nbr *nbr)
+{
+ struct lde_nbr rn;
+
+ bzero(&rn, sizeof(rn));
+ rn.id.s_addr = nbr->id.s_addr;
+ rn.lspace = nbr->lspace;
+
+ return (ldpe_imsg_compose_lde(IMSG_NEIGHBOR_UP, nbr->peerid, 0, &rn,
+ sizeof(rn)));
+}
+
void
nbr_send_labelmappings(struct nbr *nbr)
{