summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2022-03-15 16:50:30 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2022-03-15 16:50:30 +0000
commitd9e8ee470ccbc28e2d82af46902b24a095b81040 (patch)
tree28c0709a0615dace1e79000f2e879faf10b2feb9 /usr.sbin
parentc8975a9f24b2e84651c6e01e04fb115d49020398 (diff)
Replace the eor member of struct prefix with a flag. Saves a byte that
will be reused soon. OK denis@ tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/rde.h5
-rw-r--r--usr.sbin/bgpd/rde_rib.c15
-rw-r--r--usr.sbin/bgpd/rde_update.c6
3 files changed, 13 insertions, 13 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h
index 66df239fa01..05569cac8e2 100644
--- a/usr.sbin/bgpd/rde.h
+++ b/usr.sbin/bgpd/rde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.h,v 1.247 2022/03/02 16:51:43 claudio Exp $ */
+/* $OpenBSD: rde.h,v 1.248 2022/03/15 16:50:29 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@@ -333,7 +333,7 @@ struct prefix {
uint32_t path_id_tx;
uint8_t validation_state;
uint8_t nhflags;
- uint8_t eor;
+ uint8_t unused;
uint8_t flags;
#define PREFIX_FLAG_WITHDRAW 0x01 /* enqueued on withdraw queue */
#define PREFIX_FLAG_UPDATE 0x02 /* enqueued on update queue */
@@ -341,6 +341,7 @@ struct prefix {
#define PREFIX_FLAG_STALE 0x08 /* stale entry (graceful reload) */
#define PREFIX_FLAG_MASK 0x0f /* mask for the prefix types */
#define PREFIX_FLAG_ADJOUT 0x10 /* prefix is in the adj-out rib */
+#define PREFIX_FLAG_EOR 0x20 /* prefix is EoR */
#define PREFIX_NEXTHOP_LINKED 0x40 /* prefix is linked onto nexthop list */
#define PREFIX_FLAG_LOCKED 0x80 /* locked by rib walker */
};
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index 5c424bf0732..d8f61ade728 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.233 2022/03/15 14:39:34 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.234 2022/03/15 16:50:29 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -875,10 +875,10 @@ prefix_index_cmp(struct prefix *a, struct prefix *b)
static inline int
prefix_cmp(struct prefix *a, struct prefix *b)
{
- if (a->eor != b->eor)
- return a->eor - b->eor;
- /* if EOR marker no need to check the rest also a->eor == b->eor */
- if (a->eor)
+ if ((a->flags & PREFIX_FLAG_EOR) != (b->flags & PREFIX_FLAG_EOR))
+ return (a->flags & PREFIX_FLAG_EOR) ? 1 : -1;
+ /* if EOR marker no need to check the rest */
+ if (a->flags & PREFIX_FLAG_EOR)
return 0;
if (a->aspath != b->aspath)
@@ -1152,8 +1152,7 @@ prefix_add_eor(struct rde_peer *peer, uint8_t aid)
struct prefix *p;
p = prefix_alloc();
- p->flags = PREFIX_FLAG_ADJOUT | PREFIX_FLAG_UPDATE;
- p->eor = 1;
+ p->flags = PREFIX_FLAG_ADJOUT | PREFIX_FLAG_UPDATE | PREFIX_FLAG_EOR;
if (RB_INSERT(prefix_tree, &peer->updates[aid], p) != NULL)
/* no need to add if EoR marker already present */
prefix_free(p);
@@ -1290,7 +1289,7 @@ prefix_adjout_destroy(struct prefix *p)
if ((p->flags & PREFIX_FLAG_ADJOUT) == 0)
fatalx("%s: prefix without PREFIX_FLAG_ADJOUT hit", __func__);
- if (p->eor) {
+ if (p->flags & PREFIX_FLAG_EOR) {
/* EOR marker is not linked in the index */
prefix_free(p);
return;
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c
index 3b14b7135b7..fe72cb03e34 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.136 2022/03/02 16:51:43 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.137 2022/03/15 16:50:29 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -586,7 +586,7 @@ up_is_eor(struct rde_peer *peer, uint8_t aid)
struct prefix *p;
p = RB_MIN(prefix_tree, &peer->updates[aid]);
- if (p != NULL && p->eor) {
+ if (p != NULL && (p->flags & PREFIX_FLAG_EOR)) {
/*
* Need to remove eor from update tree because
* prefix_adjout_destroy() can't handle that.
@@ -635,7 +635,7 @@ up_dump_prefix(u_char *buf, int len, struct prefix_tree *prefix_head,
np->communities != p->communities ||
np->nexthop != p->nexthop ||
np->nhflags != p->nhflags ||
- np->eor)
+ (np->flags & PREFIX_FLAG_EOR))
done = 1;