]> git.puffer.fish Git - mirror/frr.git/commitdiff
ldpd: kill send_notification_nbr()
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 3 Mar 2017 20:50:22 +0000 (17:50 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 3 Mar 2017 20:50:22 +0000 (17:50 -0300)
Be more clever and trigger the PDU SENT event inside send_notification()
when tcp->nbr is set. This way we can eliminate send_notification_nbr()
and always use send_notification() instead.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ldpd/address.c
ldpd/init.c
ldpd/labelmapping.c
ldpd/ldpe.h
ldpd/notification.c
ldpd/packet.c

index 1c4c116f216f7ecd6d1cad73a473620bd88dec35..0bb4e048eb6fa5f8dea4ea542d709d6b57c9650d 100644 (file)
@@ -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);
index ed6b53c02db95995a5b031015f0cac91d8f8e13c..030bff2f51a6da1db2609792cf9f91862d2b7afb 100644 (file)
@@ -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;
index 15861cfd9ac2c37ff32a3fc3db653119810ed68e..34cc1f83a2224e31c2e4a8340159bf22739dffb1 100644 (file)
@@ -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(&lt, 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;
        }
 
index 052439df888c75e722ee02822ef9d1731281a8df..d79c9a82ca8b1697d85942feb3cca7f2c199eb87 100644 (file)
@@ -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);
 
index d306361d5c2d78a4280107d13aa4ecd0197ac662..f70af76bad28816240dafa2e1012d42d5d550e9f 100644 (file)
@@ -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);
                }
index b085cac055e5bbab863d65ceb5c9dad8040c86ea..653f67b8c27dee12805aa9e819d21ea0fe353bd3 100644 (file)
@@ -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);