summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-02-05 21:30:03 -0500
committerDonald Sharp <sharpd@cumulusnetworks.com>2020-02-06 07:24:53 -0500
commite26c305530618cacf8b64a52882683bd4dba573d (patch)
treebeddd35ab40e601dcbd9ce0b8b0ef90de1c87072
parentaf34d2da11139cab5ffea89d264eedb79495c2fd (diff)
bgpd: Store data in final temp variable
There is no need to have a temp variable to then store that data in another temporary variable. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_nexthop.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index ed264a9665..49111ff8c8 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -473,7 +473,6 @@ static void bgp_connected_cleanup(struct route_table *table,
int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
struct attr *attr, struct bgp_node *rn)
{
- struct prefix p = {0};
uint8_t new_afi = afi == AFI_IP ? AF_INET : AF_INET6;
struct bgp_addr tmp_addr = {0}, *addr = NULL;
struct tip_addr tmp_tip, *tip = NULL;
@@ -486,46 +485,45 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
if (!is_bgp_static_route)
new_afi = BGP_ATTR_NEXTHOP_AFI_IP6(attr) ? AF_INET6 : AF_INET;
- p.family = new_afi;
+ tmp_addr.p.family = new_afi;
switch (new_afi) {
case AF_INET:
if (is_bgp_static_route) {
- p.u.prefix4 = rn->p.u.prefix4;
- p.prefixlen = rn->p.prefixlen;
+ tmp_addr.p.u.prefix4 = rn->p.u.prefix4;
+ tmp_addr.p.prefixlen = rn->p.prefixlen;
} else {
/* Here we need to find out which nexthop to be used*/
if (attr->flag &
ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
- p.u.prefix4 = attr->nexthop;
- p.prefixlen = IPV4_MAX_BITLEN;
+ tmp_addr.p.u.prefix4 = attr->nexthop;
+ tmp_addr.p.prefixlen = IPV4_MAX_BITLEN;
} else if ((attr->mp_nexthop_len) &&
((attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_IPV4) ||
(attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_VPNV4))) {
- p.u.prefix4 =
+ tmp_addr.p.u.prefix4 =
attr->mp_nexthop_global_in;
- p.prefixlen = IPV4_MAX_BITLEN;
+ tmp_addr.p.prefixlen = IPV4_MAX_BITLEN;
} else
return 0;
}
break;
case AF_INET6:
if (is_bgp_static_route) {
- p.u.prefix6 = rn->p.u.prefix6;
- p.prefixlen = rn->p.prefixlen;
+ tmp_addr.p.u.prefix6 = rn->p.u.prefix6;
+ tmp_addr.p.prefixlen = rn->p.prefixlen;
} else {
- p.u.prefix6 = attr->mp_nexthop_global;
- p.prefixlen = IPV6_MAX_BITLEN;
+ tmp_addr.p.u.prefix6 = attr->mp_nexthop_global;
+ tmp_addr.p.prefixlen = IPV6_MAX_BITLEN;
}
break;
default:
break;
}
- tmp_addr.p = p;
addr = hash_lookup(bgp->address_hash, &tmp_addr);
if (addr)
return 1;