[PATCH] use net_*_match consistently

Asbjørn Sloth Tønnesen ast at 2e8.dk
Mon Dec 30 17:40:54 CET 2019


---
 lib/net.h       | 9 +++++----
 nest/rt-table.c | 2 +-
 proto/mrt/mrt.c | 3 +--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/net.h b/lib/net.h
index 0cd5f735..102cbfb0 100644
--- a/lib/net.h
+++ b/lib/net.h
@@ -38,6 +38,7 @@
 
 #define NB_IP		(NB_IP4 | NB_IP6)
 #define NB_VPN		(NB_VPN4 | NB_VPN6)
+#define NB_ROA		(NB_ROA4 | NB_ROA6)
 #define NB_FLOW		(NB_FLOW4 | NB_FLOW6)
 #define NB_DEST		(NB_IP | NB_IP6_SADR | NB_VPN | NB_MPLS)
 #define NB_ANY		0xffffffff
@@ -257,16 +258,16 @@ static inline int net_type_match(const net_addr *a, u32 mask)
 { return net_val_match(a->type, mask); }
 
 static inline int net_is_ip(const net_addr *a)
-{ return (a->type == NET_IP4) || (a->type == NET_IP6); }
+{ return net_type_match(a, NB_IP); }
 
 static inline int net_is_vpn(const net_addr *a)
-{ return (a->type == NET_VPN4) || (a->type == NET_VPN6); }
+{ return net_type_match(a, NB_VPN); }
 
 static inline int net_is_roa(const net_addr *a)
-{ return (a->type == NET_ROA4) || (a->type == NET_ROA6); }
+{ return net_type_match(a, NB_ROA); }
 
 static inline int net_is_flow(const net_addr *a)
-{ return (a->type == NET_FLOW4) || (a->type == NET_FLOW6); }
+{ return net_type_match(a, NB_FLOW); }
 
 static inline int net_is_sadr(const net_addr *a)
 { return (a->type == NET_IP6_SADR); }
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 4adc278e..d2800584 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -2186,7 +2186,7 @@ rt_new_table(struct symbol *s, uint addr_type)
   /* Hack that allows to 'redefine' the master table */
   if ((s->class == SYM_TABLE) &&
       (s->table == new_config->def_tables[addr_type]) &&
-      ((addr_type == NET_IP4) || (addr_type == NET_IP6)))
+      net_val_match(addr_type, NB_IP))
     return s->table;
 
   struct rtable_config *c = cfg_allocz(sizeof(struct rtable_config));
diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c
index 7a396a84..258f8470 100644
--- a/proto/mrt/mrt.c
+++ b/proto/mrt/mrt.c
@@ -227,8 +227,7 @@ mrt_next_table_(rtable *tab, rtable *tab_ptr, const char *pattern)
   for (tab = !tab ? HEAD(routing_tables) : NODE_NEXT(tab);
        NODE_VALID(tab);
        tab = NODE_NEXT(tab))
-    if (patmatch(pattern, tab->name) &&
-	((tab->addr_type == NET_IP4) || (tab->addr_type == NET_IP6)))
+    if (patmatch(pattern, tab->name) && net_val_match(tab->addr_type, NB_IP))
       return tab;
 
   return NULL;
-- 
2.24.0



More information about the Bird-users mailing list