]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/labelmapping.c
Merge pull request #3069 from donaldsharp/bgp_nexthop_address
[mirror_frr.git] / ldpd / labelmapping.c
index e8ce7fbdf534e34851905838951de5fda8344fd1..944f93331f002a3fb1ef6c6ae3cfaa4a6b27171f 100644 (file)
 
 #include "mpls.h"
 
-static void     enqueue_pdu(struct nbr *, struct ibuf *, uint16_t);
+static void     enqueue_pdu(struct nbr *, uint16_t, struct ibuf *, uint16_t);
 static int      gen_label_tlv(struct ibuf *, uint32_t);
 static int      gen_reqid_tlv(struct ibuf *, uint32_t);
 static void     log_msg_mapping(int, uint16_t, struct nbr *, struct map *);
 
 static void
-enqueue_pdu(struct nbr *nbr, struct ibuf *buf, uint16_t size)
+enqueue_pdu(struct nbr *nbr, uint16_t type, struct ibuf *buf, uint16_t size)
 {
        struct ldp_hdr          *ldp_hdr;
 
@@ -81,7 +81,7 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh)
 
                /* maximum pdu length exceeded, we need a new ldp pdu */
                if (size + msg_size > nbr->max_pdu_len) {
-                       enqueue_pdu(nbr, buf, size);
+                       enqueue_pdu(nbr, type, buf, size);
                        first = 1;
                        continue;
                }
@@ -108,11 +108,33 @@ send_labelmessage(struct nbr *nbr, uint16_t type, struct mapping_head *mh)
 
                log_msg_mapping(1, type, nbr, &me->map);
 
+               /* no errors - update per neighbor message counters */
+               switch (type) {
+               case MSG_TYPE_LABELMAPPING:
+                       nbr->stats.labelmap_sent++;
+                       break;
+                       case MSG_TYPE_LABELREQUEST:
+                       nbr->stats.labelreq_sent++;
+                       break;
+               case MSG_TYPE_LABELWITHDRAW:
+                       nbr->stats.labelwdraw_sent++;
+                       break;
+               case MSG_TYPE_LABELRELEASE:
+                       nbr->stats.labelrel_sent++;
+                       break;
+               case MSG_TYPE_LABELABORTREQ:
+                       nbr->stats.labelabreq_sent++;
+                       break;
+               default:
+                       break;
+               }
+
                TAILQ_REMOVE(mh, me, entry);
+               assert(me != TAILQ_FIRST(mh));
                free(me);
        }
 
-       enqueue_pdu(nbr, buf, size);
+       enqueue_pdu(nbr, type, buf, size);
 
        nbr_fsm(nbr, NBR_EVT_PDU_SENT);
 }
@@ -298,9 +320,9 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
                                /* do not accept invalid labels */
                                if (label > MPLS_LABEL_MAX ||
                                    (label <= MPLS_LABEL_RESERVED_MAX &&
-                                    label != MPLS_LABEL_IPV4NULL &&
-                                    label != MPLS_LABEL_IPV6NULL &&
-                                    label != MPLS_LABEL_IMPLNULL)) {
+                                    label != MPLS_LABEL_IPV4_EXPLICIT_NULL &&
+                                    label != MPLS_LABEL_IPV6_EXPLICIT_NULL &&
+                                    label != MPLS_LABEL_IMPLICIT_NULL)) {
                                        session_shutdown(nbr, S_BAD_TLV_VAL,
                                            msg.id, msg.type);
                                        goto err;
@@ -374,7 +396,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
                case MAP_TYPE_PREFIX:
                        switch (me->map.fec.prefix.af) {
                        case AF_INET:
-                               if (label == MPLS_LABEL_IPV6NULL) {
+                               if (label == MPLS_LABEL_IPV6_EXPLICIT_NULL) {
                                        session_shutdown(nbr, S_BAD_TLV_VAL,
                                            msg.id, msg.type);
                                        goto err;
@@ -383,7 +405,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
                                        goto next;
                                break;
                        case AF_INET6:
-                               if (label == MPLS_LABEL_IPV4NULL) {
+                               if (label == MPLS_LABEL_IPV4_EXPLICIT_NULL) {
                                        session_shutdown(nbr, S_BAD_TLV_VAL,
                                            msg.id, msg.type);
                                        goto err;
@@ -438,6 +460,7 @@ recv_labelmessage(struct nbr *nbr, char *buf, uint16_t len, uint16_t type)
 
  next:
                TAILQ_REMOVE(&mh, me, entry);
+               assert(me != TAILQ_FIRST(&mh));
                free(me);
        }