]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ldpd: send correct status code on error condition
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)
The Unknown TLV status code is reserved for cases where we don't know
how to process a given TLV and its Unknown TLV bit is not set.

In the case of Address Messages, the Address List TLV is mandatory and
should appear before any optional TLV in the message. If that doesn't
happen the correct status notification to send is "Missing Message
Parameters" (non-fatal error).

Also, add a missing htons when creating an Address List TLV. Since the
value of TLV_TYPE_ADDRLIST is 0x0101 this missing htons wasn't noticed
earlier.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ldpd/address.c

index cb2f505f7b7d10b2d0e54b5f6c65557e78b2fd42..25c03b811b8027282ce7176b012db84c6b76b176 100644 (file)
@@ -162,7 +162,7 @@ recv_address(struct nbr *nbr, char *buf, uint16_t len)
                return (-1);
        }
        if (ntohs(alt.type) != TLV_TYPE_ADDRLIST) {
-               session_shutdown(nbr, S_UNKNOWN_TLV, msg.id, msg.type);
+               send_notification(nbr->tcp, S_MISS_MSG, msg.id, msg.type);
                return (-1);
        }
        switch (ntohs(alt.family)) {
@@ -242,7 +242,7 @@ gen_address_list_tlv(struct ibuf *buf, uint16_t size, int af,
        int                      err = 0;
 
        memset(&alt, 0, sizeof(alt));
-       alt.type = TLV_TYPE_ADDRLIST;
+       alt.type = htons(TLV_TYPE_ADDRLIST);
        alt.length = htons(size - TLV_HDR_SIZE);
 
        switch (af) {