summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2004-12-23 17:34:04 +0000
committerhenning <henning@openbsd.org>2004-12-23 17:34:04 +0000
commitf36b855a52712b20cae65d6bc08a20f2ffc008ab (patch)
treee057d29f6279503a1b60362e187553bc1d87bdc4
parentallow "bgpctl neighbor" to take the peer's descr as argument as well (diff)
downloadwireguard-openbsd-f36b855a52712b20cae65d6bc08a20f2ffc008ab.tar.xz
wireguard-openbsd-f36b855a52712b20cae65d6bc08a20f2ffc008ab.zip
in getpeerbydesc(), complain if we find more than one match and return NULL
-rw-r--r--usr.sbin/bgpd/session.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index fe20bd8151c..f9f9e1551fa 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.211 2004/12/23 17:24:03 henning Exp $ */
+/* $OpenBSD: session.c,v 1.212 2004/12/23 17:34:04 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -2392,13 +2392,23 @@ getpeerbyaddr(struct bgpd_addr *addr)
struct peer *
getpeerbydesc(const char *descr)
{
- struct peer *p;
+ struct peer *p, *res = NULL;
+ int match = 0;
- for (p = peers; p != NULL && strcmp(p->conf.descr, descr);
- p = p->next)
- ; /* nothing */
+ for (p = peers; p != NULL; p = p->next)
+ if (!strcmp(p->conf.descr, descr)) {
+ res = p;
+ match++;
+ }
- return (p);
+ if (match > 1)
+ log_info("neighbor description \"%s\" not unique, request "
+ "aborted", descr);
+
+ if (match == 1)
+ return (res);
+ else
+ return (NULL);
}
struct peer *