summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-06-13 23:01:38 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-06-13 23:01:38 +0000
commitaf679c1db978876131a39dc7e81e16cda681d46e (patch)
tree955c4d022b423e871583d11f019ca1b9e92fc302 /usr.sbin
parent4f19f299b2a7a17778e0c21facd68eac7bab5071 (diff)
Implement support for the Configuration Sequence Number TLV.
The Configuration Sequence Number optional TLV is documented in RFC 5036, pages 53 and 54. Fixes IxANVL LDP test 23.10.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldpd/hello.c18
-rw-r--r--usr.sbin/ldpd/ldpd.h3
-rw-r--r--usr.sbin/ldpd/ldpe.c3
-rw-r--r--usr.sbin/ldpd/ldpe.h3
-rw-r--r--usr.sbin/ldpd/neighbor.c3
5 files changed, 23 insertions, 7 deletions
diff --git a/usr.sbin/ldpd/hello.c b/usr.sbin/ldpd/hello.c
index c8ae8d205b3..42278036f89 100644
--- a/usr.sbin/ldpd/hello.c
+++ b/usr.sbin/ldpd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.48 2016/06/13 20:13:34 renato Exp $ */
+/* $OpenBSD: hello.c,v 1.49 2016/06/13 23:01:37 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -88,6 +88,7 @@ send_hello(enum hello_type type, struct iface_af *ia, struct tnbr *tnbr)
default:
fatalx("send_hello: unknown af");
}
+ size += sizeof(struct hello_prms_opt4_tlv);
if (ldp_is_dual_stack(leconf))
size += sizeof(struct hello_prms_opt4_tlv);
@@ -119,6 +120,9 @@ send_hello(enum hello_type type, struct iface_af *ia, struct tnbr *tnbr)
fatalx("send_hello: unknown af");
}
+ gen_opt4_hello_prms_tlv(buf, TLV_TYPE_CONFIG,
+ htonl(global.conf_seqnum));
+
/*
* RFC 7552 - Section 6.1.1:
* "A Dual-stack LSR (i.e., an LSR supporting Dual-stack LDP for a peer)
@@ -145,7 +149,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af,
int ds_tlv;
union ldpd_addr trans_addr;
uint32_t scope_id = 0;
- uint32_t conf_number;
+ uint32_t conf_seqnum;
uint16_t trans_pref;
int r;
struct hello_source source;
@@ -178,7 +182,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af,
len -= r;
r = tlv_decode_opt_hello_prms(buf, len, &tlvs_rcvd, af, &trans_addr,
- &conf_number, &trans_pref);
+ &conf_seqnum, &trans_pref);
if (r == -1) {
log_debug("%s: lsr-id %s: failed to decode optional params",
__func__, inet_ntoa(lsr_id));
@@ -353,6 +357,14 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *lm, int af,
(trans_pref == DUAL_STACK_LDPOV6 && af != AF_INET6))))
nbr = nbr_new(lsr_id, af, ds_tlv, &trans_addr, scope_id);
+ /* update neighbor's configuration sequence number */
+ if (nbr && (tlvs_rcvd & F_HELLO_TLV_RCVD_CONF)) {
+ if (conf_seqnum > nbr->conf_seqnum &&
+ nbr_pending_idtimer(nbr))
+ nbr_stop_idtimer(nbr);
+ nbr->conf_seqnum = conf_seqnum;
+ }
+
/* always update the holdtime to properly handle runtime changes */
switch (source.type) {
case HELLO_LINK:
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index b02eab3c013..3c59cc19783 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.76 2016/05/23 19:20:55 renato Exp $ */
+/* $OpenBSD: ldpd.h,v 1.77 2016/06/13 23:01:37 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -396,6 +396,7 @@ struct ldpd_global {
time_t uptime;
struct ldpd_af_global ipv4;
struct ldpd_af_global ipv6;
+ uint32_t conf_seqnum;
int pfkeysock;
struct if_addr_head addr_list;
LIST_HEAD(, adj) adj_list;
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 50b051d277f..51fe0b9b864 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.65 2016/06/13 20:15:58 renato Exp $ */
+/* $OpenBSD: ldpe.c,v 1.66 2016/06/13 23:01:37 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -438,6 +438,7 @@ ldpe_dispatch_main(int fd, short event, void *bula)
case IMSG_RECONF_END:
merge_config(leconf, nconf);
nconf = NULL;
+ global.conf_seqnum++;
break;
case IMSG_CTL_KROUTE:
case IMSG_CTL_KROUTE_ADDR:
diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h
index 62341870b52..dfdb19f3a99 100644
--- a/usr.sbin/ldpd/ldpe.h
+++ b/usr.sbin/ldpd/ldpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.h,v 1.60 2016/06/13 20:19:40 renato Exp $ */
+/* $OpenBSD: ldpe.h,v 1.61 2016/06/13 23:01:37 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -89,6 +89,7 @@ struct nbr {
time_t uptime;
int fd;
int state;
+ uint32_t conf_seqnum;
int idtimer_cnt;
uint16_t keepalive;
uint16_t max_pdu_len;
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index 4b607c0ce3f..8f8cf4fe003 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.73 2016/06/13 20:19:40 renato Exp $ */
+/* $OpenBSD: neighbor.c,v 1.74 2016/06/13 23:01:37 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -244,6 +244,7 @@ nbr_new(struct in_addr id, int af, int ds_tlv, union ldpd_addr *addr,
nbr->laddr = (ldp_af_conf_get(leconf, af))->trans_addr;
nbr->raddr = *addr;
nbr->raddr_scope = scope_id;
+ nbr->conf_seqnum = 0;
LIST_FOREACH(adj, &global.adj_list, global_entry) {
if (adj->lsr_id.s_addr == nbr->id.s_addr) {