]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: add family attribute for flowspec prefix structure
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 15 Oct 2019 13:01:39 +0000 (15:01 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 21 Aug 2020 11:37:08 +0000 (13:37 +0200)
to recognize whether a flowspec prefix has been carried out by
ipv4 flowspec or ipv6 flowspec ( actually, the hypothesis is that only
ipv4 flowspec is supported), then a new attribute should contain the
family value: AF_INET or AF_INET6. That value will be further used in
the BGP flowspec code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
lib/prefix.c
lib/prefix.h

index 697e1a623957a42a99bd3fe56fdaddb96e0cf360..0a88f9eca6892590bf330b2aceeb505e47113f59 100644 (file)
@@ -188,6 +188,10 @@ int prefix_match(const struct prefix *n, const struct prefix *p)
 
        if (n->family == AF_FLOWSPEC) {
                /* prefixlen is unused. look at fs prefix len */
+               if (n->u.prefix_flowspec.family !=
+                   p->u.prefix_flowspec.family)
+                       return 0;
+
                if (n->u.prefix_flowspec.prefixlen >
                    p->u.prefix_flowspec.prefixlen)
                        return 0;
@@ -325,6 +329,8 @@ void prefix_copy(union prefixptr udest, union prefixconstptr usrc)
                len = src->u.prefix_flowspec.prefixlen;
                dest->u.prefix_flowspec.prefixlen =
                        src->u.prefix_flowspec.prefixlen;
+               dest->u.prefix_flowspec.family =
+                       src->u.prefix_flowspec.family;
                dest->family = src->family;
                temp = XCALLOC(MTYPE_PREFIX_FLOWSPEC, len);
                dest->u.prefix_flowspec.ptr = (uintptr_t)temp;
@@ -374,6 +380,9 @@ int prefix_same(union prefixconstptr up1, union prefixconstptr up2)
                                    sizeof(struct evpn_addr)))
                                return 1;
                if (p1->family == AF_FLOWSPEC) {
+                       if (p1->u.prefix_flowspec.family !=
+                           p2->u.prefix_flowspec.family)
+                               return 0;
                        if (p1->u.prefix_flowspec.prefixlen !=
                            p2->u.prefix_flowspec.prefixlen)
                                return 0;
@@ -415,6 +424,10 @@ int prefix_cmp(union prefixconstptr up1, union prefixconstptr up2)
                pp1 = (const uint8_t *)p1->u.prefix_flowspec.ptr;
                pp2 = (const uint8_t *)p2->u.prefix_flowspec.ptr;
 
+               if (p1->u.prefix_flowspec.family !=
+                   p2->u.prefix_flowspec.family)
+                       return 1;
+
                if (p1->u.prefix_flowspec.prefixlen !=
                    p2->u.prefix_flowspec.prefixlen)
                        return numcmp(p1->u.prefix_flowspec.prefixlen,
index 400f07386f90ee4f2e5eb2efcc33189d19f181a7..2a33d532c8b8c336e5ae086b940322efcce16fe9 100644 (file)
@@ -176,6 +176,7 @@ struct evpn_addr {
 #endif
 
 struct flowspec_prefix {
+       uint8_t family;
        uint16_t prefixlen; /* length in bytes */
        uintptr_t ptr;
 };