summaryrefslogtreecommitdiffstats
path: root/usr.sbin/eigrpd
diff options
context:
space:
mode:
authorrenato <renato@openbsd.org>2016-01-15 12:36:41 +0000
committerrenato <renato@openbsd.org>2016-01-15 12:36:41 +0000
commit0e96235e0fe6ebdbb2e8a9699f3b24ee3da4eb12 (patch)
tree1e8778b4a85b85e0d5d972693006f762486dc7c0 /usr.sbin/eigrpd
parentDo not set the EoT flag in the last startup update. (diff)
downloadwireguard-openbsd-0e96235e0fe6ebdbb2e8a9699f3b24ee3da4eb12.tar.xz
wireguard-openbsd-0e96235e0fe6ebdbb2e8a9699f3b24ee3da4eb12.zip
Add support for manually clearing neighbors.
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r--usr.sbin/eigrpd/control.c9
-rw-r--r--usr.sbin/eigrpd/eigrpd.h3
-rw-r--r--usr.sbin/eigrpd/eigrpe.c4
-rw-r--r--usr.sbin/eigrpd/eigrpe.h7
-rw-r--r--usr.sbin/eigrpd/hello.c36
-rw-r--r--usr.sbin/eigrpd/interface.c4
-rw-r--r--usr.sbin/eigrpd/neighbor.c29
-rw-r--r--usr.sbin/eigrpd/rde_dual.c6
-rw-r--r--usr.sbin/eigrpd/rtp.c4
9 files changed, 83 insertions, 19 deletions
diff --git a/usr.sbin/eigrpd/control.c b/usr.sbin/eigrpd/control.c
index ff5a1f03bd1..1b1e08f951a 100644
--- a/usr.sbin/eigrpd/control.c
+++ b/usr.sbin/eigrpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.3 2015/12/13 18:55:53 renato Exp $ */
+/* $OpenBSD: control.c,v 1.4 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -281,6 +281,13 @@ control_dispatch_imsg(int fd, short event, void *bula)
case IMSG_CTL_SHOW_STATS:
eigrpe_stats_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/eigrpd/eigrpd.h b/usr.sbin/eigrpd/eigrpd.h
index a2d1db7dae8..dd4bc9f3fef 100644
--- a/usr.sbin/eigrpd/eigrpd.h
+++ b/usr.sbin/eigrpd/eigrpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpd.h,v 1.6 2015/12/13 18:55:53 renato Exp $ */
+/* $OpenBSD: eigrpd.h,v 1.7 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -72,6 +72,7 @@ enum imsg_type {
IMSG_CTL_SHOW_NBR,
IMSG_CTL_SHOW_TOPOLOGY,
IMSG_CTL_SHOW_STATS,
+ IMSG_CTL_CLEAR_NBR,
IMSG_CTL_FIB_COUPLE,
IMSG_CTL_FIB_DECOUPLE,
IMSG_CTL_IFACE,
diff --git a/usr.sbin/eigrpd/eigrpe.c b/usr.sbin/eigrpd/eigrpe.c
index 1955558ed69..577c2191afb 100644
--- a/usr.sbin/eigrpd/eigrpe.c
+++ b/usr.sbin/eigrpd/eigrpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.c,v 1.11 2016/01/15 12:32:34 renato Exp $ */
+/* $OpenBSD: eigrpe.c,v 1.12 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -545,7 +545,7 @@ eigrpe_dispatch_rde(int fd, short event, void *bula)
break;
}
/* announce that this neighborship is dead */
- send_hello(nbr->ei, NULL, 0, 1);
+ send_peerterm(nbr);
nbr_del(nbr);
break;
case IMSG_CTL_SHOW_TOPOLOGY:
diff --git a/usr.sbin/eigrpd/eigrpe.h b/usr.sbin/eigrpd/eigrpe.h
index e142ea89d92..a021983330a 100644
--- a/usr.sbin/eigrpd/eigrpe.h
+++ b/usr.sbin/eigrpd/eigrpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: eigrpe.h,v 1.6 2016/01/15 12:32:34 renato Exp $ */
+/* $OpenBSD: eigrpe.h,v 1.7 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -130,6 +130,7 @@ void nbr_update_peerid(struct nbr *);
struct nbr *nbr_find(struct eigrp_iface *, union eigrpd_addr *);
struct nbr *nbr_find_peerid(uint32_t);
struct ctl_nbr *nbr_to_ctl(struct nbr *);
+void nbr_clear_ctl(struct ctl_nbr *);
void nbr_timeout(int, short, void *);
void nbr_start_timeout(struct nbr *);
void nbr_stop_timeout(struct nbr *);
@@ -179,8 +180,8 @@ void metric_encode_mtu(uint8_t *, int);
int metric_decode_mtu(uint8_t *);
/* hello.c */
-void send_hello(struct eigrp_iface *, struct seq_addr_head *, uint32_t,
- int);
+void send_hello(struct eigrp_iface *, struct seq_addr_head *, uint32_t);
+void send_peerterm(struct nbr *);
void recv_hello(struct eigrp_iface *, union eigrpd_addr *, struct nbr *,
struct tlv_parameter *);
diff --git a/usr.sbin/eigrpd/hello.c b/usr.sbin/eigrpd/hello.c
index 90828653981..36b08c8af9d 100644
--- a/usr.sbin/eigrpd/hello.c
+++ b/usr.sbin/eigrpd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.3 2016/01/15 12:32:34 renato Exp $ */
+/* $OpenBSD: hello.c,v 1.4 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -28,7 +28,7 @@
void
send_hello(struct eigrp_iface *ei, struct seq_addr_head *seq_addr_list,
- uint32_t mcast_seq, int peerterm)
+ uint32_t mcast_seq)
{
struct eigrp *eigrp = ei->eigrp;
struct ibuf *buf;
@@ -42,7 +42,7 @@ send_hello(struct eigrp_iface *ei, struct seq_addr_head *seq_addr_list,
if (gen_eigrp_hdr(buf, EIGRP_OPC_HELLO, flags, 0, eigrp->as))
goto fail;
- if (gen_parameter_tlv(buf, ei, peerterm))
+ if (gen_parameter_tlv(buf, ei, 0))
goto fail;
if (gen_sw_version_tlv(buf))
@@ -65,6 +65,34 @@ fail:
}
void
+send_peerterm(struct nbr *nbr)
+{
+ struct eigrp *eigrp = nbr->ei->eigrp;
+ struct ibuf *buf;
+ uint8_t flags = 0;
+
+ if ((buf = ibuf_dynamic(PKG_DEF_SIZE,
+ IP_MAXPACKET - sizeof(struct ip))) == NULL)
+ fatal("send_hello");
+
+ /* EIGRP header */
+ if (gen_eigrp_hdr(buf, EIGRP_OPC_HELLO, flags, 0, eigrp->as))
+ goto fail;
+
+ if (gen_parameter_tlv(buf, nbr->ei, 1))
+ goto fail;
+
+ /* send unreliably */
+ send_packet(nbr->ei, nbr, 0, buf);
+ ibuf_free(buf);
+ return;
+fail:
+ log_warnx("%s: failed to send message", __func__);
+ ibuf_free(buf);
+}
+
+
+void
recv_hello(struct eigrp_iface *ei, union eigrpd_addr *src, struct nbr *nbr,
struct tlv_parameter *tp)
{
@@ -95,7 +123,7 @@ recv_hello(struct eigrp_iface *ei, union eigrpd_addr *src, struct nbr *nbr,
nbr = nbr_new(ei, src, ntohs(tp->holdtime), 0);
/* send an expedited hello */
- send_hello(ei, NULL, 0, 0);
+ send_hello(ei, NULL, 0);
send_update(nbr->ei, nbr, EIGRP_HDR_FLAG_INIT, NULL);
}
diff --git a/usr.sbin/eigrpd/interface.c b/usr.sbin/eigrpd/interface.c
index 09c323bfc41..3f8437a6057 100644
--- a/usr.sbin/eigrpd/interface.c
+++ b/usr.sbin/eigrpd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.10 2016/01/15 12:25:43 renato Exp $ */
+/* $OpenBSD: interface.c,v 1.11 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -453,7 +453,7 @@ eigrp_if_hello_timer(int fd, short event, void *arg)
struct eigrp_iface *ei = arg;
struct timeval tv;
- send_hello(ei, NULL, 0, 0);
+ send_hello(ei, NULL, 0);
/* reschedule hello_timer */
timerclear(&tv);
diff --git a/usr.sbin/eigrpd/neighbor.c b/usr.sbin/eigrpd/neighbor.c
index 0cee4aa3450..b88f4b0da69 100644
--- a/usr.sbin/eigrpd/neighbor.c
+++ b/usr.sbin/eigrpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.4 2016/01/15 12:23:45 renato Exp $ */
+/* $OpenBSD: neighbor.c,v 1.5 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -225,6 +225,33 @@ nbr_to_ctl(struct nbr *nbr)
return (&nctl);
}
+void
+nbr_clear_ctl(struct ctl_nbr *nctl)
+{
+ struct eigrp *eigrp;
+ struct nbr *nbr, *safe;
+
+ TAILQ_FOREACH(eigrp, &econf->instances, entry) {
+ if (nctl->af && nctl->af != eigrp->af)
+ continue;
+ if (nctl->as && nctl->as != eigrp->as)
+ continue;
+
+ RB_FOREACH_SAFE(nbr, nbr_addr_head, &eigrp->nbrs, safe) {
+ if (nbr->flags & (F_EIGRP_NBR_PENDING|F_EIGRP_NBR_SELF))
+ continue;
+ if (eigrp_addrisset(nctl->af, &nctl->addr) &&
+ eigrp_addrcmp(nctl->af, &nctl->addr, &nbr->addr))
+ continue;
+
+ log_debug("%s: neighbor %s manually cleared", __func__,
+ log_addr(nbr->ei->eigrp->af, &nbr->addr));
+ send_peerterm(nbr);
+ nbr_del(nbr);
+ }
+ }
+}
+
/* timers */
/* ARGSUSED */
diff --git a/usr.sbin/eigrpd/rde_dual.c b/usr.sbin/eigrpd/rde_dual.c
index 02fdb555565..483986d3330 100644
--- a/usr.sbin/eigrpd/rde_dual.c
+++ b/usr.sbin/eigrpd/rde_dual.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_dual.c,v 1.13 2016/01/15 12:23:45 renato Exp $ */
+/* $OpenBSD: rde_dual.c,v 1.14 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -1300,11 +1300,11 @@ rde_nbr_new(uint32_t peerid, struct rde_nbr *new)
}
void
-rde_nbr_del(struct rde_nbr *nbr, int send_peerterm)
+rde_nbr_del(struct rde_nbr *nbr, int peerterm)
{
struct reply_node *reply;
- if (send_peerterm)
+ if (peerterm)
rde_imsg_compose_eigrpe(IMSG_NEIGHBOR_DOWN, nbr->peerid,
0, NULL, 0);
diff --git a/usr.sbin/eigrpd/rtp.c b/usr.sbin/eigrpd/rtp.c
index 5a5f3bdc139..8ef01d8ec4c 100644
--- a/usr.sbin/eigrpd/rtp.c
+++ b/usr.sbin/eigrpd/rtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtp.c,v 1.3 2015/10/21 03:48:09 renato Exp $ */
+/* $OpenBSD: rtp.c,v 1.4 2016/01/15 12:36:41 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -192,7 +192,7 @@ rtp_send_mcast(struct eigrp_iface *ei, struct ibuf *buf)
TAILQ_INSERT_TAIL(&seq_addr_list, sa, entry);
}
- send_hello(ei, &seq_addr_list, eigrp->seq_num, 0);
+ send_hello(ei, &seq_addr_list, eigrp->seq_num);
seq_addr_list_clr(&seq_addr_list);
}
send_packet(ei, NULL, flags, buf);