Currently EoR markers use a full byte in struct prefix what can be done in
a bit. Use the last flags field so that that 1 byte is available again.
I already have a need for that byte this is why I came up with this
change.
 
-- 
:wq Claudio

? obj
Index: rde.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.h,v
retrieving revision 1.247
diff -u -p -r1.247 rde.h
--- rde.h       2 Mar 2022 16:51:43 -0000       1.247
+++ rde.h       15 Mar 2022 14:59:27 -0000
@@ -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 */
 };
Index: rde_rib.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_rib.c,v
retrieving revision 1.233
diff -u -p -r1.233 rde_rib.c
--- rde_rib.c   15 Mar 2022 14:39:34 -0000      1.233
+++ rde_rib.c   15 Mar 2022 14:59:28 -0000
@@ -875,10 +875,10 @@ prefix_index_cmp(struct prefix *a, struc
 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, ui
        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;
Index: rde_update.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_update.c,v
retrieving revision 1.136
diff -u -p -r1.136 rde_update.c
--- rde_update.c        2 Mar 2022 16:51:43 -0000       1.136
+++ rde_update.c        15 Mar 2022 14:59:28 -0000
@@ -586,7 +586,7 @@ up_is_eor(struct rde_peer *peer, uint8_t
        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, str
                    np->communities != p->communities ||
                    np->nexthop != p->nexthop ||
                    np->nhflags != p->nhflags ||
-                   np->eor)
+                   (np->flags & PREFIX_FLAG_EOR))
                        done = 1;
 
 

Reply via email to