diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2019-08-13 12:13:27 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2019-08-13 12:13:27 +0000 |
commit | 51caac5ea98d45716914fddf9ef9a47a1d6a3dcd (patch) | |
tree | f2dcbd4b8a843bda997c24dce095c8cbe9b4c8d1 /usr.sbin/bgpd | |
parent | 6311af6848f1aaed10132beaf218c2c935b8ee7a (diff) |
Do not use the SE global conf struct for the bgpd_config but actually
the bgpd_config pointer passed to these functions. Luckily the affected
functions were not used outside of the SE. While there also use
getpeerbyid() to check if an peer id is in use instead of the rather
dumb linear loop.
OK benno@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/session.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 42008c85f53..a1012623a2b 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.389 2019/08/12 14:15:27 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.390 2019/08/13 12:13:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -2894,7 +2894,7 @@ getpeerbydesc(struct bgpd_config *c, const char *descr) struct peer *p, *res = NULL; int match = 0; - RB_FOREACH(p, peer_head, &conf->peers) + RB_FOREACH(p, peer_head, &c->peers) if (!strcmp(p->conf.descr, descr)) { res = p; match++; @@ -2920,13 +2920,13 @@ getpeerbyip(struct bgpd_config *c, struct sockaddr *ip) sa2addr(ip, &addr, NULL); /* we might want a more effective way to find peers by IP */ - RB_FOREACH(p, peer_head, &conf->peers) + RB_FOREACH(p, peer_head, &c->peers) if (!p->conf.template && !memcmp(&addr, &p->conf.remote_addr, sizeof(addr))) return (p); /* try template matching */ - RB_FOREACH(p, peer_head, &conf->peers) + RB_FOREACH(p, peer_head, &c->peers) if (p->conf.template && p->conf.remote_addr.aid == addr.aid && session_match_mask(p, &addr)) @@ -2940,10 +2940,7 @@ getpeerbyip(struct bgpd_config *c, struct sockaddr *ip) fatal(NULL); memcpy(newpeer, loose, sizeof(struct peer)); for (id = PEER_ID_DYN_MAX; id > PEER_ID_STATIC_MAX; id--) { - RB_FOREACH(p, peer_head, &conf->peers) - if (p->conf.id == id) - break; - if (p == NULL) /* we found a free id */ + if (getpeerbyid(c, id) == NULL) /* we found a free id */ break; } newpeer->template = loose; |