diff options
author | 2019-05-31 09:46:31 +0000 | |
---|---|---|
committer | 2019-05-31 09:46:31 +0000 | |
commit | f9e88ec20eb8adf82da1c480edefec6496816617 (patch) | |
tree | 82af90b3b5030b50ee6b38f9929564468e0cab5d | |
parent | add tests for the "new" tying bugs. first one on the way, second one (diff) | |
download | wireguard-openbsd-f9e88ec20eb8adf82da1c480edefec6496816617.tar.xz wireguard-openbsd-f9e88ec20eb8adf82da1c480edefec6496816617.zip |
Exit the attribute loop early if there are no unknown attributes left
and the loop passed all attributes known by bgpd. Saves about 80% of
time in up_generate_attr().
OK phessler@
-rw-r--r-- | usr.sbin/bgpd/rde.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_update.c | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 09b02c52eb4..a49a3553387 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.211 2019/03/07 07:42:36 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.212 2019/05/31 09:46:31 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -142,6 +142,7 @@ enum attrtypes { ATTR_AS4_PATH=17, ATTR_AS4_AGGREGATOR=18, ATTR_LARGE_COMMUNITIES=32, + ATTR_FIRST_UNKNOWN, /* after this all attributes are unknown */ }; /* attribute flags. 4 low order bits reserved */ diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index 20277490f0a..6073886a43a 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.111 2019/05/13 21:13:04 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.112 2019/05/31 09:46:31 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -518,6 +518,10 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, } break; default: + if (oa == NULL && type >= ATTR_FIRST_UNKNOWN) + /* there is no attribute left to dump */ + goto done; + if (oa == NULL || oa->type != type) break; @@ -537,9 +541,10 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, return (-1); break; } - wlen += r; len -= r; + wlen += r; + len -= r; } - +done: return (wlen); } |