]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Allow a generic pointer in route extended attributes
authorMaria Matejka <mq@ucw.cz>
Tue, 11 Feb 2020 12:25:04 +0000 (13:25 +0100)
committerMaria Matejka <mq@ucw.cz>
Thu, 30 Apr 2020 14:14:26 +0000 (16:14 +0200)
nest/route.h
nest/rt-attr.c
nest/rt-table.c

index cb2c686f590bbbd9ce2a216f255cee9cd4e63bb3..1809f7ccf34c0893f731d905c88e939452e284aa 100644 (file)
@@ -512,8 +512,8 @@ typedef struct eattr {
   byte flags;                          /* Protocol-dependent flags */
   byte type;                           /* Attribute type and several flags (EAF_...) */
   union {
-    u32 data;
-    const struct adata *ptr;                   /* Attribute data elsewhere */
+    uintptr_t data;
+    const struct adata *ptr;           /* Attribute data elsewhere */
   } u;
 } eattr;
 
@@ -544,6 +544,7 @@ const char *ea_custom_name(uint ea);
 #define EAF_TYPE_AS_PATH 0x06          /* BGP AS path (encoding per RFC 1771:4.3) */
 #define EAF_TYPE_BITFIELD 0x09         /* 32-bit embedded bitfield */
 #define EAF_TYPE_INT_SET 0x0a          /* Set of u32's (e.g., a community list) */
+#define EAF_TYPE_PTR 0x0d              /* Pointer to an object */
 #define EAF_TYPE_EC_SET 0x0e           /* Set of pairs of u32's - ext. community list */
 #define EAF_TYPE_LC_SET 0x12           /* Set of triplets of u32's - large community list */
 #define EAF_TYPE_UNDEF 0x1f            /* `force undefined' entry */
@@ -598,7 +599,7 @@ struct ea_walk_state {
 
 eattr *ea_find(ea_list *, unsigned ea);
 eattr *ea_walk(struct ea_walk_state *s, uint id, uint max);
-int ea_get_int(ea_list *, unsigned ea, int def);
+uintptr_t ea_get_int(ea_list *, unsigned ea, uintptr_t def);
 void ea_dump(ea_list *);
 void ea_sort(ea_list *);               /* Sort entries in all sub-lists */
 unsigned ea_scan(ea_list *);           /* How many bytes do we need for merged ea_list */
index 4c07e9b13b024b4361bfd0fb9a5153bd07adf5ee..7cab13ea2b10daa844052690795b7579fb153281 100644 (file)
@@ -541,8 +541,8 @@ ea_walk(struct ea_walk_state *s, uint id, uint max)
  * by calling ea_find() to find the attribute, extracting its value or returning
  * a provided default if no such attribute is present.
  */
-int
-ea_get_int(ea_list *e, unsigned id, int def)
+uintptr_t
+ea_get_int(ea_list *e, unsigned id, uintptr_t def)
 {
   eattr *a = ea_find(e, id);
   if (!a)
index 6e92ae2592f5d49fc256119f72d261698ea54004..94e3af304a8c4952a03bad07525eb54a7cb9ac02 100644 (file)
@@ -2811,9 +2811,9 @@ if_local_addr(ip_addr a, struct iface *i)
 u32
 rt_get_igp_metric(rte *rt)
 {
-  eattr *ea = ea_find(rt->attrs->eattrs, EA_GEN_IGP_METRIC);
+  eattr *ea;
 
-  if (ea)
+  if (ea = ea_find(rt->attrs->eattrs, EA_GEN_IGP_METRIC))
     return ea->u.data;
 
   rta *a = rt->attrs;