summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-12-23 17:34:05 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-12-23 17:34:05 +0000
commit5aa55c8cae3f09157d0018257a671d2676233849 (patch)
tree8ea0b5c45fcb7d020ea9547c62794c7239daf7cb /usr.sbin
parentca9954d10d24735e439dc8235e9a466d66252396 (diff)
in getpeerbydesc(), complain if we find more than one match and return NULL
Diffstat (limited to 'usr.sbin')
-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 *