summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorrenato <renato@openbsd.org>2017-03-03 23:53:50 +0000
committerrenato <renato@openbsd.org>2017-03-03 23:53:50 +0000
commite95c1c119241af93e09f231dea73da059e8ab4bc (patch)
tree300027801a288bec252bcb8480449d42a8fb087e /usr.sbin/ldpd
parentCreate helper functions to log sent/received messages. (diff)
downloadwireguard-openbsd-e95c1c119241af93e09f231dea73da059e8ab4bc.tar.xz
wireguard-openbsd-e95c1c119241af93e09f231dea73da059e8ab4bc.zip
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.
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/address.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.sbin/ldpd/address.c b/usr.sbin/ldpd/address.c
index cfb80511d4b..238765af5ed 100644
--- a/usr.sbin/ldpd/address.c
+++ b/usr.sbin/ldpd/address.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: address.c,v 1.32 2017/03/03 23:50:45 renato Exp $ */
+/* $OpenBSD: address.c,v 1.33 2017/03/03 23:53:50 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -164,7 +164,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)) {
@@ -244,7 +244,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) {