summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_nexthop.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 1e565af894..896285676c 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;
};
@@ -193,7 +193,7 @@ static void show_address_entry(struct hash_bucket *bucket, void *args)
char str[INET6_ADDRSTRLEN] = {0};
vty_out(vty, "addr: %s, count: %d : ",
- inet_ntop(addr->p->family, &(addr->p->u.prefix),
+ inet_ntop(addr->p.family, &(addr->p.u.prefix),
str, INET6_ADDRSTRLEN),
addr->ifp_name_list->count);
@@ -224,8 +224,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;
@@ -237,7 +236,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);
}
@@ -246,7 +244,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)
@@ -254,7 +252,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)
@@ -281,12 +279,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);
@@ -308,12 +306,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() */
@@ -529,7 +527,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;
@@ -541,9 +539,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;
}