]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/table.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / table.c
index d7ecdd8d7fb95ed91ba2655b7cdb6aa8fd1c6591..0026b7692be758f4fa8c922aee9aaf1b4c67cea2 100644 (file)
@@ -33,7 +33,7 @@ DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
 
 static void route_table_free(struct route_table *);
 
-static int route_table_hash_cmp(const void *a, const void *b)
+static bool route_table_hash_cmp(const void *a, const void *b)
 {
        const struct prefix *pa = a, *pb = b;
        return prefix_cmp(pa, pb) == 0;
@@ -74,7 +74,6 @@ static struct route_node *route_node_set(struct route_table *table,
        node = route_node_new(table);
 
        prefix_copy(&node->p, prefix);
-       apply_mask(&node->p);
        node->table = table;
 
        inserted = hash_get(node->table->hash, node, hash_alloc_intern);
@@ -143,20 +142,26 @@ static void route_table_free(struct route_table *rt)
 }
 
 /* Utility mask array. */
-static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
-                                0xf8, 0xfc, 0xfe, 0xff};
+static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
+                                 0xf8, 0xfc, 0xfe, 0xff};
 
 /* Common prefix route genaration. */
 static void route_common(const struct prefix *n, const struct prefix *p,
                         struct prefix *new)
 {
        int i;
-       u_char diff;
-       u_char mask;
+       uint8_t diff;
+       uint8_t mask;
+       const uint8_t *np;
+       const uint8_t *pp;
+       uint8_t *newp;
 
-       const u_char *np = (const u_char *)&n->u.prefix;
-       const u_char *pp = (const u_char *)&p->u.prefix;
-       u_char *newp = (u_char *)&new->u.prefix;
+       if (n->family == AF_FLOWSPEC)
+               return prefix_copy(new, p);
+       np = (const uint8_t *)&n->u.prefix;
+       pp = (const uint8_t *)&p->u.prefix;
+
+       newp = (uint8_t *)&new->u.prefix;
 
        for (i = 0; i < p->prefixlen / 8; i++) {
                if (np[i] == pp[i])
@@ -278,10 +283,10 @@ struct route_node *route_node_get(struct route_table *const table,
        struct route_node *node;
        struct route_node *match;
        struct route_node *inserted;
-       u_char prefixlen = p->prefixlen;
-       const u_char *prefix = &p->u.prefix;
+       uint8_t prefixlen = p->prefixlen;
+       const uint8_t *prefix = &p->u.prefix;
 
-       apply_mask((struct prefix *)&p);
+       apply_mask((struct prefix *)p);
        node = hash_get(table->hash, (void *)p, NULL);
        if (node && node->info)
                return route_lock_node(node);