diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-06-05 22:34:46 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-06-05 22:34:46 +0000 |
commit | 637897ed02de73e77d8087fcaf4bb06dfca62df0 (patch) | |
tree | ea25f649cbfbf4631cb7a56dc84ddf29553e8157 /usr.sbin/ldpd/packet.c | |
parent | 805f83430ffd35a86cb5f71bd2ff83fc35c65484 (diff) |
Correctly send notification messages when errors occur.
ok claudio@ laurent@
Diffstat (limited to 'usr.sbin/ldpd/packet.c')
-rw-r--r-- | usr.sbin/ldpd/packet.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c index 41e18fdc215..de2a157b711 100644 --- a/usr.sbin/ldpd/packet.c +++ b/usr.sbin/ldpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.1 2009/06/01 20:59:45 michele Exp $ */ +/* $OpenBSD: packet.c,v 1.2 2009/06/05 22:34:45 michele Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -297,7 +297,7 @@ session_recv_packet(int fd, short event, void *bula) if (nbr == NULL) { /* If there is no neighbor matching there is no Hello adjacency: send notification */ - send_notification(S_NO_HELLO, iface, newfd); + send_notification(S_NO_HELLO, iface, newfd, 0, 0); close(newfd); return; } @@ -325,21 +325,14 @@ another_packet: ldp_hdr = (struct ldp_hdr *)buf; if (ntohs(ldp_hdr->version) != LDP_VERSION) { - log_debug("session_read: nbr ID %s invalid LDP version %d", - inet_ntoa(nbr->id), ldp_hdr->version); - send_notification_nbr(nbr, S_BAD_PROTO_VER); - session_close(nbr); - /* XXX: notify lde */ + session_shutdown(nbr, S_BAD_PROTO_VER, 0, 0); return; } pdu_len = ntohs(ldp_hdr->length); if (pdu_len < LDP_HDR_SIZE || pdu_len > LDP_MAX_LEN) { - log_debug("session_read: packet malformed"); - send_notification_nbr(nbr, S_BAD_MSG_LEN); - session_close(nbr); - /* XXX: notify lde */ + session_shutdown(nbr, S_BAD_MSG_LEN, 0, 0); return; } @@ -405,14 +398,19 @@ another_packet: } void -session_write(struct bufferevent *bev, void *arg) +session_error(struct bufferevent *bev, short what, void *arg) { + struct nbr *nbr = arg; + + nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); } void -session_error(struct bufferevent *bev, short what, void *arg) +session_shutdown(struct nbr *nbr, u_int32_t status, u_int32_t msgid, + u_int32_t type) { - struct nbr *nbr = arg; + send_notification_nbr(nbr, status, msgid, type); + send_notification_nbr(nbr, S_SHUTDOWN, msgid, type); nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); } |