ldpd: send correct status code on error condition

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>
This commit is contained in:
Renato Westphal 2017-03-03 17:50:22 -03:00
parent faf757937f
commit a33df20073

View 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) {