summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2020-01-09 15:50:35 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2020-01-09 15:50:35 +0000
commit488a132d9dce138ccd3c745c2849219f76d7d6a1 (patch)
treea8777c7721e1a1d07cee6f61911d6496ae045524 /usr.sbin/bgpd
parent9b36b4d43cd7adc0de1c044300bb2a4777388478 (diff)
Instead of calling SipHash24_Update() in path_hash for each element of
struct rde_aspath define aspath_hashstart and aspath_hashend and update all values in one call. Inspired by struct process and its ps_startcopy. OK deraadt@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/rde.h6
-rw-r--r--usr.sbin/bgpd/rde_rib.c10
2 files changed, 7 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index 7878aaac262..776c37a03f2 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.231 2020/01/09 14:44:55 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.232 2020/01/09 15:50:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -215,14 +215,16 @@ struct rde_aspath {
struct attr **others;
struct aspath *aspath;
u_int64_t hash;
+ int refcnt;
u_int32_t flags; /* internally used */
+#define aspath_hashstart med
u_int32_t med; /* multi exit disc */
u_int32_t lpref; /* local pref */
u_int32_t weight; /* low prio lpref */
- int refcnt;
u_int16_t rtlabelid; /* route label id */
u_int16_t pftableid; /* pf table id */
u_int8_t origin;
+#define aspath_hashend others_len
u_int8_t others_len;
};
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index 116e55cb531..2df44649e2f 100644
--- a/usr.sbin/bgpd/rde_rib.c
+++ b/usr.sbin/bgpd/rde_rib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.212 2020/01/09 11:55:25 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.213 2020/01/09 15:50:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -701,12 +701,8 @@ path_hash(struct rde_aspath *asp)
u_int64_t hash;
SipHash24_Init(&ctx, &pathtablekey);
- SipHash24_Update(&ctx, &asp->origin, sizeof(asp->origin));
- SipHash24_Update(&ctx, &asp->med, sizeof(asp->med));
- SipHash24_Update(&ctx, &asp->lpref, sizeof(asp->lpref));
- SipHash24_Update(&ctx, &asp->weight, sizeof(asp->weight));
- SipHash24_Update(&ctx, &asp->rtlabelid, sizeof(asp->rtlabelid));
- SipHash24_Update(&ctx, &asp->pftableid, sizeof(asp->pftableid));
+ SipHash24_Update(&ctx, &asp->aspath_hashstart,
+ (char *)&asp->aspath_hashend - (char *)&asp->aspath_hashstart);
if (asp->aspath)
SipHash24_Update(&ctx, asp->aspath->data, asp->aspath->len);