diff --git a/ldpd/address.c b/ldpd/address.c index 1c4c116f21..0bb4e048eb 100644 --- a/ldpd/address.c +++ b/ldpd/address.c @@ -177,7 +177,7 @@ recv_address(struct nbr *nbr, char *buf, uint16_t len) return (0); break; default: - send_notification_nbr(nbr, S_UNSUP_ADDR, msg.id, msg.type); + send_notification(nbr->tcp, S_UNSUP_ADDR, msg.id, msg.type); return (-1); } buf += sizeof(alt); diff --git a/ldpd/init.c b/ldpd/init.c index ed6b53c02d..030bff2f51 100644 --- a/ldpd/init.c +++ b/ldpd/init.c @@ -118,7 +118,7 @@ recv_init(struct nbr *nbr, char *buf, uint16_t len) return (-1); default: if (!(ntohs(tlv.type) & UNKNOWN_FLAG)) - send_notification_nbr(nbr, S_UNKNOWN_TLV, + send_notification(nbr->tcp, S_UNKNOWN_TLV, msg.id, msg.type); /* ignore unknown tlv */ break; diff --git a/ldpd/labelmapping.c b/ldpd/labelmapping.c index 15861cfd9a..34cc1f83a2 100644 --- a/ldpd/labelmapping.c +++ b/ldpd/labelmapping.c @@ -163,7 +163,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) memcpy(&ft, buf, sizeof(ft)); if (ntohs(ft.type) != TLV_TYPE_FEC) { - send_notification_nbr(nbr, S_MISS_MSG, msg.id, msg.type); + send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type); return (-1); } feclen = ntohs(ft.length); @@ -187,7 +187,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) !(map.flags & F_MAP_PW_ID) && type != MSG_TYPE_LABELWITHDRAW && type != MSG_TYPE_LABELRELEASE) { - send_notification_nbr(nbr, S_MISS_MSG, msg.id, + send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type); return (-1); } @@ -341,7 +341,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type) break; default: if (!(ntohs(tlv.type) & UNKNOWN_FLAG)) - send_notification_nbr(nbr, S_UNKNOWN_TLV, + send_notification(nbr->tcp, S_UNKNOWN_TLV, msg.id, msg.type); /* ignore unknown tlv */ break; @@ -462,7 +462,7 @@ tlv_decode_label(struct nbr *nbr, struct ldp_msg *msg, char *buf, memcpy(<, buf, sizeof(lt)); if (!(ntohs(lt.type) & TLV_TYPE_GENERICLABEL)) { - send_notification_nbr(nbr, S_MISS_MSG, msg->id, msg->type); + send_notification(nbr->tcp, S_MISS_MSG, msg->id, msg->type); return (-1); } @@ -642,7 +642,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf, map->fec.prefix.af = AF_INET6; break; default: - send_notification_nbr(nbr, S_UNSUP_ADDR, msg->id, + send_notification(nbr->tcp, S_UNSUP_ADDR, msg->id, msg->type); return (-1); } @@ -753,7 +753,7 @@ tlv_decode_fec_elm(struct nbr *nbr, struct ldp_msg *msg, char *buf, return (off); default: - send_notification_nbr(nbr, S_UNKNOWN_FEC, msg->id, msg->type); + send_notification(nbr->tcp, S_UNKNOWN_FEC, msg->id, msg->type); break; } diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index 052439df88..d79c9a82ca 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -166,9 +166,7 @@ int recv_keepalive(struct nbr *, char *, uint16_t); /* notification.c */ void send_notification_full(struct tcp_conn *, struct notify_msg *); -void send_notification(uint32_t, struct tcp_conn *, uint32_t, - uint16_t); -void send_notification_nbr(struct nbr *, uint32_t, uint32_t, uint16_t); +void send_notification(struct tcp_conn *, uint32_t, uint32_t, uint16_t); int recv_notification(struct nbr *, char *, uint16_t); int gen_status_tlv(struct ibuf *, uint32_t, uint32_t, uint16_t); diff --git a/ldpd/notification.c b/ldpd/notification.c index d306361d5c..f70af76bad 100644 --- a/ldpd/notification.c +++ b/ldpd/notification.c @@ -63,17 +63,19 @@ send_notification_full(struct tcp_conn *tcp, struct notify_msg *nm) return; } - if (tcp->nbr) + if (tcp->nbr) { debug_msg_send("notification: lsr-id %s status %s%s", inet_ntoa(tcp->nbr->id), status_code_name(nm->status_code), (nm->status_code & STATUS_FATAL) ? " (fatal)" : ""); + nbr_fsm(tcp->nbr, NBR_EVT_PDU_SENT); + } evbuf_enqueue(&tcp->wbuf, buf); } /* send a notification without optional tlvs */ void -send_notification(uint32_t status_code, struct tcp_conn *tcp, uint32_t msg_id, +send_notification(struct tcp_conn *tcp, uint32_t status_code, uint32_t msg_id, uint16_t msg_type) { struct notify_msg nm; @@ -86,14 +88,6 @@ send_notification(uint32_t status_code, struct tcp_conn *tcp, uint32_t msg_id, send_notification_full(tcp, &nm); } -void -send_notification_nbr(struct nbr *nbr, uint32_t status_code, uint32_t msg_id, - uint16_t msg_type) -{ - send_notification(status_code, nbr->tcp, msg_id, msg_type); - nbr_fsm(nbr, NBR_EVT_PDU_SENT); -} - int recv_notification(struct nbr *nbr, char *buf, uint16_t len) { @@ -172,7 +166,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len) break; default: if (!(ntohs(tlv.type) & UNKNOWN_FLAG)) - send_notification_nbr(nbr, S_UNKNOWN_TLV, + send_notification(nbr->tcp, S_UNKNOWN_TLV, msg.id, msg.type); /* ignore unknown tlv */ break; @@ -183,7 +177,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len) if (nm.status_code == S_PW_STATUS) { if (!(nm.flags & (F_NOTIF_PW_STATUS|F_NOTIF_FEC))) { - send_notification_nbr(nbr, S_MISS_MSG, + send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type); return (-1); } @@ -192,7 +186,7 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len) case MAP_TYPE_PWID: break; default: - send_notification_nbr(nbr, S_BAD_TLV_VAL, + send_notification(nbr->tcp, S_BAD_TLV_VAL, msg.id, msg.type); return (-1); } diff --git a/ldpd/packet.c b/ldpd/packet.c index b085cac055..653f67b8c2 100644 --- a/ldpd/packet.c +++ b/ldpd/packet.c @@ -564,7 +564,7 @@ session_read(struct thread *thread) log_debug("%s: unknown LDP message from nbr %s", __func__, inet_ntoa(nbr->id)); if (!(ntohs(msg->type) & UNKNOWN_FLAG)) - send_notification_nbr(nbr, + send_notification(nbr->tcp, S_UNKNOWN_MSG, msg->id, msg->type); /* ignore the message */ ret = 0; @@ -632,7 +632,7 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id, case NBR_STA_OPER: log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id)); - send_notification_nbr(nbr, status, msg_id, msg_type); + send_notification(nbr->tcp, status, msg_id, msg_type); nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); break; @@ -788,7 +788,7 @@ pending_conn_timeout(struct thread *thread) * notification message reliably. */ tcp = tcp_new(pconn->fd, NULL); - send_notification(S_NO_HELLO, tcp, 0, 0); + send_notification(tcp, S_NO_HELLO, 0, 0); msgbuf_write(&tcp->wbuf.wbuf); pending_conn_del(pconn);