mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-03 14:34:25 +00:00
pimd: Add code to find neighbor by secondary
With RFC 5549 we need a methodology to find a neighbor based upon a nexthop that is v6 based. This commit sets us up for that by allowing you to find the neigbor by the secondary list. In a future commit we will add code to pass the v6 secondary addresses. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
7399328a6f
commit
07b17d5927
@ -1105,6 +1105,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
|
|||||||
struct listnode *neighnode;
|
struct listnode *neighnode;
|
||||||
struct pim_neighbor *neigh;
|
struct pim_neighbor *neigh;
|
||||||
struct pim_interface *pim_ifp;
|
struct pim_interface *pim_ifp;
|
||||||
|
struct prefix p;
|
||||||
|
|
||||||
zassert(ifp);
|
zassert(ifp);
|
||||||
|
|
||||||
@ -1116,6 +1117,10 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.family = AF_INET;
|
||||||
|
p.u.prefix4 = addr;
|
||||||
|
p.prefixlen = IPV4_MAX_PREFIXLEN;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
|
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
|
||||||
|
|
||||||
/* primary address ? */
|
/* primary address ? */
|
||||||
@ -1123,7 +1128,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
|
|||||||
return neigh;
|
return neigh;
|
||||||
|
|
||||||
/* secondary address ? */
|
/* secondary address ? */
|
||||||
if (pim_neighbor_find_secondary(neigh, addr))
|
if (pim_neighbor_find_secondary(neigh, &p))
|
||||||
return neigh;
|
return neigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,6 +423,31 @@ void pim_neighbor_free(struct pim_neighbor *neigh)
|
|||||||
XFREE(MTYPE_PIM_NEIGHBOR, neigh);
|
XFREE(MTYPE_PIM_NEIGHBOR, neigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct pim_neighbor *
|
||||||
|
pim_neighbor_find_by_secondary (struct interface *ifp,
|
||||||
|
struct prefix *src)
|
||||||
|
{
|
||||||
|
struct pim_interface *pim_ifp;
|
||||||
|
struct listnode *node, *pnode;
|
||||||
|
struct pim_neighbor *neigh;
|
||||||
|
struct prefix *p;
|
||||||
|
|
||||||
|
pim_ifp = ifp->info;
|
||||||
|
if (!pim_ifp)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, node, neigh))
|
||||||
|
{
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, pnode, p))
|
||||||
|
{
|
||||||
|
if (prefix_same (p, src))
|
||||||
|
return neigh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
|
struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
|
||||||
struct in_addr source_addr)
|
struct in_addr source_addr)
|
||||||
{
|
{
|
||||||
@ -669,7 +694,7 @@ void pim_neighbor_delete_all(struct interface *ifp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
|
struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
|
||||||
struct in_addr addr)
|
struct prefix *addr)
|
||||||
{
|
{
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct prefix *p;
|
struct prefix *p;
|
||||||
@ -678,14 +703,11 @@ struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, node, p)) {
|
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, node, p)) {
|
||||||
if (p->family == AF_INET) {
|
if (prefix_same (p, addr))
|
||||||
if (addr.s_addr == p->u.prefix4.s_addr) {
|
return p;
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -729,7 +751,7 @@ static void delete_from_neigh_addr(struct interface *ifp,
|
|||||||
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neigh_node,
|
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neigh_node,
|
||||||
neigh)) {
|
neigh)) {
|
||||||
{
|
{
|
||||||
struct prefix *p = pim_neighbor_find_secondary(neigh, addr->u.prefix4);
|
struct prefix *p = pim_neighbor_find_secondary(neigh, addr);
|
||||||
if (p) {
|
if (p) {
|
||||||
char addr_str[INET_ADDRSTRLEN];
|
char addr_str[INET_ADDRSTRLEN];
|
||||||
char this_neigh_str[INET_ADDRSTRLEN];
|
char this_neigh_str[INET_ADDRSTRLEN];
|
||||||
|
@ -50,7 +50,8 @@ void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime);
|
|||||||
void pim_neighbor_free(struct pim_neighbor *neigh);
|
void pim_neighbor_free(struct pim_neighbor *neigh);
|
||||||
struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
|
struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
|
||||||
struct in_addr source_addr);
|
struct in_addr source_addr);
|
||||||
|
struct pim_neighbor *pim_neighbor_find_by_secondary (struct interface *ifp,
|
||||||
|
struct prefix *src);
|
||||||
struct pim_neighbor *pim_neighbor_find_if (struct interface *ifp);
|
struct pim_neighbor *pim_neighbor_find_if (struct interface *ifp);
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ void pim_neighbor_update(struct pim_neighbor *neigh,
|
|||||||
uint32_t dr_priority,
|
uint32_t dr_priority,
|
||||||
struct list *addr_list);
|
struct list *addr_list);
|
||||||
struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
|
struct prefix *pim_neighbor_find_secondary(struct pim_neighbor *neigh,
|
||||||
struct in_addr addr);
|
struct prefix *addr);
|
||||||
int pim_if_dr_election(struct interface *ifp);
|
int pim_if_dr_election(struct interface *ifp);
|
||||||
|
|
||||||
#endif /* PIM_NEIGHBOR_H */
|
#endif /* PIM_NEIGHBOR_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user