]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Eattr flags (originated and fresh) get their own struct fields
authorMaria Matejka <mq@ucw.cz>
Mon, 14 Mar 2022 09:06:44 +0000 (10:06 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 6 Apr 2022 16:14:08 +0000 (18:14 +0200)
filter/f-inst.c
nest/route.h
nest/rt-attr.c
proto/bgp/attrs.c
proto/bgp/packets.c

index 83d8629547bab9070d30aaa6d74beffd76d8108e..e2212c5b96c93152d062658aa39ce0e23e574c30 100644 (file)
       l->count = 1;
       l->attrs[0].id = da.ea_code;
       l->attrs[0].flags = 0;
-      l->attrs[0].type = da.type | EAF_ORIGINATED | EAF_FRESH;
+      l->attrs[0].type = da.type;
+      l->attrs[0].originated = 1;
+      l->attrs[0].fresh = 1;
 
       switch (da.type) {
       case EAF_TYPE_INT:
       l->count = 1;
       l->attrs[0].id = da.ea_code;
       l->attrs[0].flags = 0;
-      l->attrs[0].type = EAF_TYPE_UNDEF | EAF_ORIGINATED | EAF_FRESH;
+      l->attrs[0].type = EAF_TYPE_UNDEF;
+      l->attrs[0].originated = 1;
+      l->attrs[0].fresh = 1;
       l->attrs[0].u.data = 0;
 
       f_rta_cow(fs);
index 595acabd96ca8a02ce2823db621256c89fe87b76..9fbac8982c4814e81165907139a2d621dabee8e9 100644 (file)
@@ -502,7 +502,9 @@ static inline int rte_is_reachable(rte *r)
 typedef struct eattr {
   word id;                             /* EA_CODE(PROTOCOL_..., protocol-dependent ID) */
   byte flags;                          /* Protocol-dependent flags */
-  byte type;                           /* Attribute type and several flags (EAF_...) */
+  byte type:5;                         /* Attribute type */
+  byte originated:1;                   /* The attribute has originated locally */
+  byte fresh:1;                                /* An uncached attribute (e.g. modified in export filter) */
   union {
     uintptr_t data;
     const struct adata *ptr;           /* Attribute data elsewhere */
@@ -541,8 +543,6 @@ const char *ea_custom_name(uint ea);
 #define EAF_TYPE_UNDEF 0x1f            /* `force undefined' entry */
 #define EAF_EMBEDDED 0x01              /* Data stored in eattr.u.data (part of type spec) */
 #define EAF_VAR_LENGTH 0x02            /* Attribute length is variable (part of type spec) */
-#define EAF_ORIGINATED 0x20            /* The attribute has originated locally */
-#define EAF_FRESH 0x40                 /* An uncached attribute (e.g. modified in export filter) */
 
 typedef struct adata {
   uint length;                         /* Length of data */
index 863d411bec1098926afa193988b6326641e8cfcd..2f0395c743f1cb2012fb3a5c48fd1b5cd434087a 100644 (file)
@@ -623,7 +623,10 @@ ea_do_prune(ea_list *e)
       *d = *s0;
 
       /* Preserve info whether it originated locally */
-      d->type = (d->type & ~(EAF_ORIGINATED|EAF_FRESH)) | (s[-1].type & EAF_ORIGINATED);
+      d->originated = s[-1].originated;
+
+      /* Not fresh any more, we prefer surstroemming */
+      d->fresh = 0;
 
       /* Next destination */
       d++;
@@ -737,6 +740,8 @@ ea_same(ea_list *x, ea_list *y)
       if (a->id != b->id ||
          a->flags != b->flags ||
          a->type != b->type ||
+         a->originated != b->originated ||
+         a->fresh != b->fresh ||
          ((a->type & EAF_EMBEDDED) ? a->u.data != b->u.data : !adata_same(a->u.ptr, b->u.ptr)))
        return 0;
     }
@@ -1004,7 +1009,7 @@ ea_dump(ea_list *e)
          eattr *a = &e->attrs[i];
          debug(" %02x:%02x.%02x", EA_PROTO(a->id), EA_ID(a->id), a->flags);
          debug("=%c", "?iO?I?P???S?????" [a->type & EAF_TYPE_MASK]);
-         if (a->type & EAF_ORIGINATED)
+         if (a->originated)
            debug("o");
          if (a->type & EAF_EMBEDDED)
            debug(":%08x", a->u.data);
index 76b99c41e98f1773c9fa738043cd2e521d54dc74..0513dd7c2378587e9f6653ba54dd0cd5a8d78c46 100644 (file)
@@ -1153,7 +1153,7 @@ bgp_export_attr(struct bgp_export_state *s, eattr *a, ea_list *to)
     a->flags = (a->flags & BAF_PARTIAL) | desc->flags;
 
     /* Set partial bit if new opt-trans attribute is attached to non-local route */
-    if ((s->src != NULL) && (a->type & EAF_ORIGINATED) &&
+    if ((s->src != NULL) && (a->originated) &&
        (a->flags & BAF_OPTIONAL) && (a->flags & BAF_TRANSITIVE))
       a->flags |= BAF_PARTIAL;
 
@@ -1776,7 +1776,7 @@ bgp_update_attrs(struct bgp_proto *p, struct bgp_channel *c, rte *e, ea_list *at
 
     /* MULTI_EXIT_DESC attribute - accept only if set in export filter */
     a = bgp_find_attr(attrs0, BA_MULTI_EXIT_DISC);
-    if (a && !(a->type & EAF_FRESH))
+    if (a && !(a->fresh))
       bgp_unset_attr(&attrs, pool, BA_MULTI_EXIT_DISC);
   }
 
index 66f14150b395a281394b477024856e4f104232ad..7e978919483de7f43222cbb805a2b08b5ab637e0 100644 (file)
@@ -1062,7 +1062,7 @@ bgp_use_next_hop(struct bgp_export_state *s, eattr *a)
     return 1;
 
   /* Keep it when explicitly set in export filter */
-  if (a->type & EAF_FRESH)
+  if (a->fresh)
     return 1;
 
   /* Check for non-matching AF */