summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-06-08 23:14:04 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-06-08 23:14:04 +0000
commit2205165babde0e7e7932792888f4a6cf6624e97e (patch)
tree3da987a8117be43c59859c71c542c2f056bc9328 /usr.sbin/ldpd
parentf7026681fcda1e012ad75f49760e218e9540961c (diff)
Discard Hello packet if advertised transport address is of different AF.
IxANVL LDP test 5.13 was failing for ldpd(8) because we were not discarding IPv4 Hello messages with an IPv6 transport address (and vice-versa). Once again, the RFC is not very explicit about what to do in this case. Since the IPv4 and IPv6 Transport Address TLVs are optional, what we were doing is to just ignore them in this case and use source address of the packet as the implicit transport address. But the IxANVL team had a different interpretation on this. They think that discarding the Hello message is the right thing to do in this case. Let's follow their interpretation because that's probably what most implementations are doing. NOTE1: with this patch we still keep ignoring additional Transport Address TLVs as specified in RFC 7552; NOTE2: in order to check if a Transport Address TLV was already received or not, use the F_HELLO_TLV_RCVD_ADDR flag instead of comparing if the address is zero or not (easier to read). Fixes IxANVL LDP test 5.13.
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/hello.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c
index 721fd0ddf4e..1e16691de2e 100644
--- a/usr.sbin/ldpd/hello.c
+++ b/usr.sbin/ldpd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.43 2016/05/23 19:14:03 renato Exp $ */
+/* $OpenBSD: hello.c,v 1.44 2016/06/08 23:14:03 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -478,7 +478,9 @@ tlv_decode_opt_hello_prms(char *buf, uint16_t len, int *tlvs_rcvd, int af,
case TLV_TYPE_IPV4TRANSADDR:
if (tlv_len != sizeof(addr->v4))
return (-1);
- if (af != AF_INET || ldp_addrisset(AF_INET, addr))
+ if (af != AF_INET)
+ return (-1);
+ if (*tlvs_rcvd & F_HELLO_TLV_RCVD_ADDR)
break;
memcpy(&addr->v4, buf + TLV_HDR_LEN, sizeof(addr->v4));
*tlvs_rcvd |= F_HELLO_TLV_RCVD_ADDR;
@@ -486,7 +488,9 @@ tlv_decode_opt_hello_prms(char *buf, uint16_t len, int *tlvs_rcvd, int af,
case TLV_TYPE_IPV6TRANSADDR:
if (tlv_len != sizeof(addr->v6))
return (-1);
- if (af != AF_INET6 || ldp_addrisset(AF_INET6, addr))
+ if (af != AF_INET6)
+ return (-1);
+ if (*tlvs_rcvd & F_HELLO_TLV_RCVD_ADDR)
break;
memcpy(&addr->v6, buf + TLV_HDR_LEN, sizeof(addr->v6));
*tlvs_rcvd |= F_HELLO_TLV_RCVD_ADDR;