summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-05-23 19:20:56 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-05-23 19:20:56 +0000
commitd00be4666a628ac6a374665d25858475823f5feb (patch)
tree087b08dac048f926a56bb3021d49dfd49f3dc66b /usr.sbin
parent95732ab88a662f585b052bfcc9ff881f527464be (diff)
Add support for manually resetting neighbors.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldpd/control.c9
-rw-r--r--usr.sbin/ldpd/ldpd.h3
-rw-r--r--usr.sbin/ldpd/ldpe.h3
-rw-r--r--usr.sbin/ldpd/neighbor.c18
4 files changed, 29 insertions, 4 deletions
diff --git a/usr.sbin/ldpd/control.c b/usr.sbin/ldpd/control.c
index 1671da2e9f2..4ac6b114b27 100644
--- a/usr.sbin/ldpd/control.c
+++ b/usr.sbin/ldpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.26 2016/05/23 19:11:42 renato Exp $ */
+/* $OpenBSD: control.c,v 1.27 2016/05/23 19:20:55 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -263,6 +263,13 @@ control_dispatch_imsg(int fd, short event, void *bula)
case IMSG_CTL_SHOW_NBR:
ldpe_nbr_ctl(c);
break;
+ case IMSG_CTL_CLEAR_NBR:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE +
+ sizeof(struct ctl_nbr))
+ break;
+
+ nbr_clear_ctl(imsg.data);
+ break;
case IMSG_CTL_LOG_VERBOSE:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(verbose))
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index 6767285616c..b02eab3c013 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.75 2016/05/23 19:16:00 renato Exp $ */
+/* $OpenBSD: ldpd.h,v 1.76 2016/05/23 19:20:55 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -77,6 +77,7 @@ enum imsg_type {
IMSG_CTL_SHOW_LIB,
IMSG_CTL_SHOW_L2VPN_PW,
IMSG_CTL_SHOW_L2VPN_BINDING,
+ IMSG_CTL_CLEAR_NBR,
IMSG_CTL_FIB_COUPLE,
IMSG_CTL_FIB_DECOUPLE,
IMSG_CTL_KROUTE,
diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h
index 67ee322476d..288aa25d5a8 100644
--- a/usr.sbin/ldpd/ldpe.h
+++ b/usr.sbin/ldpd/ldpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.h,v 1.56 2016/05/23 19:16:00 renato Exp $ */
+/* $OpenBSD: ldpe.h,v 1.57 2016/05/23 19:20:55 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -237,6 +237,7 @@ struct nbr_params *nbr_params_new(struct in_addr);
struct nbr_params *nbr_params_find(struct ldpd_conf *, struct in_addr);
uint16_t nbr_get_keepalive(int, struct in_addr);
struct ctl_nbr *nbr_to_ctl(struct nbr *);
+void nbr_clear_ctl(struct ctl_nbr *);
/* packet.c */
int gen_ldp_hdr(struct ibuf *, uint16_t);
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index 652b33f220b..5755bd1fa11 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.71 2016/05/23 19:14:03 renato Exp $ */
+/* $OpenBSD: neighbor.c,v 1.72 2016/05/23 19:20:55 renato Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -678,3 +678,19 @@ nbr_to_ctl(struct nbr *nbr)
return (&nctl);
}
+
+void
+nbr_clear_ctl(struct ctl_nbr *nctl)
+{
+ struct nbr *nbr;
+
+ RB_FOREACH(nbr, nbr_addr_head, &nbrs_by_addr) {
+ if (ldp_addrisset(nctl->af, &nctl->raddr) &&
+ ldp_addrcmp(nctl->af, &nctl->raddr, &nbr->raddr))
+ continue;
+
+ log_debug("%s: neighbor %s manually cleared", __func__,
+ log_addr(nbr->af, &nbr->raddr));
+ session_shutdown(nbr, S_SHUTDOWN, 0, 0);
+ }
+}