diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-10-15 15:01:39 +0200 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2020-08-21 13:37:08 +0200 | 
| commit | e4552d667aa43a518c5adaf3f06295be05c01d57 (patch) | |
| tree | 21246c810c9c7ee7e55071b3a8e309f0a39e5e43 /lib/prefix.c | |
| parent | 92b4f625d53df3b29a8b5075029b031cc4016e8b (diff) | |
lib: add family attribute for flowspec prefix structure
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>
Diffstat (limited to 'lib/prefix.c')
| -rw-r--r-- | lib/prefix.c | 13 | 
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 697e1a6239..0a88f9eca6 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -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,  | 
