-/* $OpenBSD: bgpd.h,v 1.323 2018/07/11 14:08:46 benno Exp $ */
+/* $OpenBSD: bgpd.h,v 1.324 2018/07/11 16:34:36 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
IMSG_CTL_SHOW_RIB_LARGECOMMUNITY,
IMSG_CTL_SHOW_NETWORK,
IMSG_CTL_SHOW_RIB_MEM,
+ IMSG_CTL_SHOW_RIB_HASH,
IMSG_CTL_SHOW_TERSE,
IMSG_CTL_SHOW_TIMER,
IMSG_CTL_LOG_VERBOSE,
int64_t attr_dcnt;
};
+struct rde_hashstats {
+ char name[16];
+ int64_t num;
+ int64_t min;
+ int64_t max;
+ int64_t sum;
+ int64_t sumq;
+};
+
#define MRT_FILE_LEN 512
#define MRT2MC(x) ((struct mrt_config *)(x))
#define MRT_MAX_TIMEOUT 7200
-/* $OpenBSD: rde.c,v 1.390 2018/07/10 15:13:35 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.391 2018/07/11 16:34:36 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
struct ctl_show_rib_request req;
struct rde_peer *peer;
struct rde_aspath *asp;
+ struct rde_hashstats rdehash;
struct filter_set *s;
u_int8_t *asdata;
ssize_t n;
case IMSG_CTL_SHOW_RIB_MEM:
imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_RIB_MEM, 0,
imsg.hdr.pid, -1, &rdemem, sizeof(rdemem));
+ path_hash_stats(&rdehash);
+ imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_RIB_HASH, 0,
+ imsg.hdr.pid, -1, &rdehash, sizeof(rdehash));
+ aspath_hash_stats(&rdehash);
+ imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_RIB_HASH, 0,
+ imsg.hdr.pid, -1, &rdehash, sizeof(rdehash));
+ attr_hash_stats(&rdehash);
+ imsg_compose(ibuf_se_ctl, IMSG_CTL_SHOW_RIB_HASH, 0,
+ imsg.hdr.pid, -1, &rdehash, sizeof(rdehash));
+ imsg_compose(ibuf_se_ctl, IMSG_CTL_END, 0, imsg.hdr.pid,
+ -1, NULL, 0);
break;
case IMSG_CTL_LOG_VERBOSE:
/* already checked by SE */
-/* $OpenBSD: rde.h,v 1.176 2018/07/09 14:08:48 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.177 2018/07/11 16:34:36 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
u_int16_t);
void attr_init(u_int32_t);
void attr_shutdown(void);
+void attr_hash_stats(struct rde_hashstats *);
int attr_optadd(struct rde_aspath *, u_int8_t, u_int8_t,
void *, u_int16_t);
struct attr *attr_optget(const struct rde_aspath *, u_int8_t);
#define AS_ERR_SOFT -4
void aspath_init(u_int32_t);
void aspath_shutdown(void);
+void aspath_hash_stats(struct rde_hashstats *);
struct aspath *aspath_get(void *, u_int16_t);
void aspath_put(struct aspath *);
u_char *aspath_inflate(void *, u_int16_t, u_int16_t *);
void path_init(u_int32_t);
void path_init(u_int32_t);
void path_shutdown(void);
+void path_hash_stats(struct rde_hashstats *);
int path_update(struct rib *, struct rde_peer *,
struct rde_aspath *, struct bgpd_addr *, int, int);
int path_compare(struct rde_aspath *, struct rde_aspath *);
-/* $OpenBSD: rde_attr.c,v 1.102 2018/06/29 11:45:50 claudio Exp $ */
+/* $OpenBSD: rde_attr.c,v 1.103 2018/07/11 16:34:36 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
free(attrtable.hashtbl);
}
+void
+attr_hash_stats(struct rde_hashstats *hs)
+{
+ struct attr *a;
+ u_int32_t i;
+ int64_t n;
+
+ memset(hs, 0, sizeof(*hs));
+ strlcpy(hs->name, "attr hash", sizeof(hs->name));
+ hs->min = LLONG_MAX;
+ hs->num = attrtable.hashmask + 1;
+
+ for (i = 0; i <= attrtable.hashmask; i++) {
+ n = 0;
+ LIST_FOREACH(a, &attrtable.hashtbl[i], entry)
+ n++;
+ if (n < hs->min)
+ hs->min = n;
+ if (n > hs->max)
+ hs->max = n;
+ hs->sum += n;
+ hs->sumq += n * n;
+ }
+}
+
int
attr_optadd(struct rde_aspath *asp, u_int8_t flags, u_int8_t type,
void *data, u_int16_t len)
free(astable.hashtbl);
}
+void
+aspath_hash_stats(struct rde_hashstats *hs)
+{
+ struct aspath *a;
+ u_int32_t i;
+ int64_t n;
+
+ memset(hs, 0, sizeof(*hs));
+ strlcpy(hs->name, "aspath hash", sizeof(hs->name));
+ hs->min = LLONG_MAX;
+ hs->num = astable.hashmask + 1;
+
+ for (i = 0; i <= astable.hashmask; i++) {
+ n = 0;
+ LIST_FOREACH(a, &astable.hashtbl[i], entry)
+ n++;
+ if (n < hs->min)
+ hs->min = n;
+ if (n > hs->max)
+ hs->max = n;
+ hs->sum += n;
+ hs->sumq += n * n;
+ }
+}
+
struct aspath *
aspath_get(void *data, u_int16_t len)
{
-/* $OpenBSD: rde_rib.c,v 1.168 2018/07/10 07:58:13 benno Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.169 2018/07/11 16:34:36 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
#include <sys/types.h>
#include <sys/queue.h>
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <siphash.h>
free(pathtable.path_hashtbl);
}
+void
+path_hash_stats(struct rde_hashstats *hs)
+{
+ struct rde_aspath *a;
+ u_int32_t i;
+ int64_t n;
+
+ memset(hs, 0, sizeof(*hs));
+ strlcpy(hs->name, "path hash", sizeof(hs->name));
+ hs->min = LLONG_MAX;
+ hs->num = pathtable.path_hashmask + 1;
+
+ for (i = 0; i <= pathtable.path_hashmask; i++) {
+ n = 0;
+ LIST_FOREACH(a, &pathtable.path_hashtbl[i], path_l)
+ n++;
+ if (n < hs->min)
+ hs->min = n;
+ if (n > hs->max)
+ hs->max = n;
+ hs->sum += n;
+ hs->sumq += n * n;
+ }
+}
+
int
path_update(struct rib *rib, struct rde_peer *peer, struct rde_aspath *nasp,
struct bgpd_addr *prefix, int prefixlen, int flag)
-/* $OpenBSD: session.c,v 1.364 2017/05/29 14:22:51 benno Exp $ */
+/* $OpenBSD: session.c,v 1.365 2018/07/11 16:34:36 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
case IMSG_CTL_SHOW_RIB_PREFIX:
case IMSG_CTL_SHOW_RIB_ATTR:
case IMSG_CTL_SHOW_RIB_MEM:
+ case IMSG_CTL_SHOW_RIB_HASH:
case IMSG_CTL_SHOW_NETWORK:
case IMSG_CTL_SHOW_NEIGHBOR:
if (idx != PFD_PIPE_ROUTE_CTL)