summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_nexthop.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 7116c80941..46cc6dd65b 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -180,7 +180,7 @@ void bgp_tip_del(struct bgp *bgp, struct in_addr *tip)
/* BGP own address structure */
struct bgp_addr {
- struct prefix *p;
+ struct prefix p;
struct list *ifp_name_list;
};
@@ -192,14 +192,14 @@ static void show_address_entry(struct hash_bucket *bucket, void *args)
struct listnode *node;
char str[INET6_ADDRSTRLEN] = {0};
- if (addr->p->family == AF_INET) {
+ if (addr->p.family == AF_INET) {
vty_out(vty, "addr: %s, count: %d : ", inet_ntop(AF_INET,
- &(addr->p->u.prefix4),
+ &(addr->p.u.prefix4),
str, INET_ADDRSTRLEN),
addr->ifp_name_list->count);
- } else if (addr->p->family == AF_INET6) {
+ } else if (addr->p.family == AF_INET6) {
vty_out(vty, "addr: %s, count: %d : ", inet_ntop(AF_INET6,
- &(addr->p->u.prefix6),
+ &(addr->p.u.prefix6),
str, INET6_ADDRSTRLEN),
addr->ifp_name_list->count);
}
@@ -231,8 +231,7 @@ static void *bgp_address_hash_alloc(void *p)
struct bgp_addr *addr = NULL;
addr = XMALLOC(MTYPE_BGP_ADDR, sizeof(struct bgp_addr));
- addr->p = prefix_new();
- prefix_copy(addr->p, copy_addr->p);
+ prefix_copy(&addr->p, &copy_addr->p);
addr->ifp_name_list = list_new();
addr->ifp_name_list->del = bgp_address_hash_string_del;
@@ -244,7 +243,6 @@ static void bgp_address_hash_free(void *data)
{
struct bgp_addr *addr = data;
- prefix_free(&addr->p);
list_delete(&addr->ifp_name_list);
XFREE(MTYPE_BGP_ADDR, addr);
}
@@ -253,7 +251,7 @@ static unsigned int bgp_address_hash_key_make(const void *p)
{
const struct bgp_addr *addr = p;
- return prefix_hash_key((const void *)(addr->p));
+ return prefix_hash_key(&addr->p);
}
static bool bgp_address_hash_cmp(const void *p1, const void *p2)
@@ -261,7 +259,7 @@ static bool bgp_address_hash_cmp(const void *p1, const void *p2)
const struct bgp_addr *addr1 = p1;
const struct bgp_addr *addr2 = p2;
- return prefix_same(addr1->p, addr2->p);
+ return prefix_same(&addr1->p, &addr2->p);
}
void bgp_address_init(struct bgp *bgp)
@@ -288,12 +286,12 @@ static void bgp_address_add(struct bgp *bgp, struct connected *ifc,
struct listnode *node;
char *name;
- tmp.p = p;
+ tmp.p = *p;
- if (tmp.p->family == AF_INET)
- tmp.p->prefixlen = IPV4_MAX_BITLEN;
- else if (tmp.p->family == AF_INET6)
- tmp.p->prefixlen = IPV6_MAX_BITLEN;
+ if (tmp.p.family == AF_INET)
+ tmp.p.prefixlen = IPV4_MAX_BITLEN;
+ else if (tmp.p.family == AF_INET6)
+ tmp.p.prefixlen = IPV6_MAX_BITLEN;
addr = hash_get(bgp->address_hash, &tmp, bgp_address_hash_alloc);
@@ -315,12 +313,12 @@ static void bgp_address_del(struct bgp *bgp, struct connected *ifc,
struct listnode *node;
char *name;
- tmp.p = p;
+ tmp.p = *p;
- if (tmp.p->family == AF_INET)
- tmp.p->prefixlen = IPV4_MAX_BITLEN;
- else if (tmp.p->family == AF_INET6)
- tmp.p->prefixlen = IPV6_MAX_BITLEN;
+ if (tmp.p.family == AF_INET)
+ tmp.p.prefixlen = IPV4_MAX_BITLEN;
+ else if (tmp.p.family == AF_INET6)
+ tmp.p.prefixlen = IPV6_MAX_BITLEN;
addr = hash_lookup(bgp->address_hash, &tmp);
/* may have been deleted earlier by bgp_interface_down() */
@@ -484,7 +482,7 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
{
struct prefix p = {0};
afi_t new_afi = afi;
- struct bgp_addr tmp_addr = {0}, *addr = NULL;
+ struct bgp_addr tmp_addr = {{0}}, *addr = NULL;
struct tip_addr tmp_tip, *tip = NULL;
bool is_bgp_static_route = ((type == ZEBRA_ROUTE_BGP)
@@ -536,7 +534,7 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
break;
}
- tmp_addr.p = &p;
+ tmp_addr.p = p;
addr = hash_lookup(bgp->address_hash, &tmp_addr);
if (addr)
return 1;
@@ -548,9 +546,8 @@ int bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type, uint8_t sub_type,
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
tmp_tip.addr = attr->nexthop;
} else if ((attr->mp_nexthop_len) &&
- ((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
- || (attr->mp_nexthop_len ==
- BGP_ATTR_NHLEN_VPNV4))) {
+ ((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
+ || (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV4))) {
tmp_tip.addr = attr->mp_nexthop_global_in;
}