diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2019-05-14 10:41:40 -0700 | 
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2019-05-23 12:21:15 -0400 | 
| commit | 2ed74b933dbf980422cc5d4da76b168297e133e6 (patch) | |
| tree | 0cbc8320fa7e6d242b6c6019aab5ece34b883a7f /lib/nexthop.c | |
| parent | ff0e16daf981c4351db29a3b599b32cd4523b205 (diff) | |
lib: Update nexthop_same to use nexthop_cmp
Simplify the code a bit by making nexthop_same()
just use nexthop_cmp() internally.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop.c')
| -rw-r--r-- | lib/nexthop.c | 41 | 
1 files changed, 3 insertions, 38 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c index 0153fef3f7..7cc77a7674 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -68,7 +68,7 @@ int nexthop_cmp(const struct nexthop *next1, const struct nexthop *next2)  {  	int ret = 0;  	uint32_t n1 = 0; -	uint32_2 n2 = 0; +	uint32_t n2 = 0;  	if (next1->vrf_id < next2->vrf_id)  		return -1; @@ -255,45 +255,10 @@ bool nexthop_same(const struct nexthop *nh1, const struct nexthop *nh2)  	if (nh1 == nh2)  		return true; -	if (nh1->vrf_id != nh2->vrf_id) +	if (nexthop_cmp(nh1, nh2) != 0)  		return false; -	if (nh1->type != nh2->type) -		return false; - -	switch (nh1->type) { -	case NEXTHOP_TYPE_IFINDEX: -		if (nh1->ifindex != nh2->ifindex) -			return false; -		break; -	case NEXTHOP_TYPE_IPV4: -		if (nh1->gate.ipv4.s_addr != nh2->gate.ipv4.s_addr) -			return false; -		break; -	case NEXTHOP_TYPE_IPV4_IFINDEX: -		if (nh1->gate.ipv4.s_addr != nh2->gate.ipv4.s_addr) -			return false; -		if (nh1->ifindex != nh2->ifindex) -			return false; -		break; -	case NEXTHOP_TYPE_IPV6: -		if (memcmp(&nh1->gate.ipv6, &nh2->gate.ipv6, 16)) -			return false; -		break; -	case NEXTHOP_TYPE_IPV6_IFINDEX: -		if (memcmp(&nh1->gate.ipv6, &nh2->gate.ipv6, 16)) -			return false; -		if (nh1->ifindex != nh2->ifindex) -			return false; -		break; -	case NEXTHOP_TYPE_BLACKHOLE: -		if (nh1->bh_type != nh2->bh_type) -			return false; -		break; -	} - -	/* Compare labels too (if present) */ -	return (!!nexthop_labels_match(nh1, nh2)); +	return true;  }  /* Update nexthop with label information. */  | 
