Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pim6d: (WIP) PIM Zebra Interface changes #10594

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/route_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ZEBRA_ROUTE_OSPF6, ospf6, ospf6d, 'O', 0, 1, 1, "OSPFv3", os
ZEBRA_ROUTE_ISIS, isis, isisd, 'I', 1, 1, 1, "IS-IS", isisd
ZEBRA_ROUTE_BGP, bgp, bgpd, 'B', 1, 1, 1, "BGP", bgpd
ZEBRA_ROUTE_PIM, pim, pimd, 'P', 0, 0, 0, "PIM", pimd
ZEBRA_ROUTE_PIM6, pim6, pim6d, 'P', 0, 0, 0, "PIM6", pim6d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to introduce another protocol, why not just leave it ZEBRA_ROUTE_PIM?

ZEBRA_ROUTE_EIGRP, eigrp, eigrpd, 'E', 1, 0, 1, "EIGRP", eigrpd
ZEBRA_ROUTE_NHRP, nhrp, nhrpd, 'N', 1, 1, 1, "NHRP", nhrpd
# HSLS and OLSR both are AFI independent (so: 1, 1), however
Expand Down Expand Up @@ -101,6 +102,7 @@ ZEBRA_ROUTE_OSPF6, "Open Shortest Path First (IPv6) (OSPFv3)"
ZEBRA_ROUTE_ISIS, "Intermediate System to Intermediate System (IS-IS)"
ZEBRA_ROUTE_BGP, "Border Gateway Protocol (BGP)"
ZEBRA_ROUTE_PIM, "Protocol Independent Multicast (PIM)"
ZEBRA_ROUTE_PIM6, "Protocol Independent Multicast (PIMv6)"
ZEBRA_ROUTE_EIGRP, "Enhanced Interior Gateway Routing Protocol (EIGRP)"
ZEBRA_ROUTE_NHRP, "Next Hop Resolution Protocol (NHRP)"
ZEBRA_ROUTE_HSLS, "Hazy-Sighted Link State Protocol (HSLS)"
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_neighbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ struct pim_neighbor *pim_neighbor_find_by_secondary(struct interface *ifp,
}

struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
struct in_addr source_addr)
pim_addr source_addr)
{
struct pim_interface *pim_ifp;
struct listnode *node;
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_neighbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct pim_neighbor {
void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime);
void pim_neighbor_free(struct pim_neighbor *neigh);
struct pim_neighbor *pim_neighbor_find(struct interface *ifp,
struct in_addr source_addr);
pim_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);
Expand Down
62 changes: 57 additions & 5 deletions pimd/pim_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
pim_ifp = c->ifp->info;
p = c->address;

#if PIM_IPV == 4
if (PIM_DEBUG_ZEBRA) {
zlog_debug("%s: %s(%u) connected IP address %pFX flags %u %s",
__func__, c->ifp->name, vrf_id, p, c->flags,
Expand All @@ -144,7 +145,8 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
if (!CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)) {
/* trying to add primary address */

struct in_addr primary_addr = pim_find_primary_addr(c->ifp);
pim_addr primary_addr = pim_find_primary_addr(c->ifp);

if (p->family != AF_INET
|| primary_addr.s_addr != p->u.prefix4.s_addr) {
if (PIM_DEBUG_ZEBRA)
Expand All @@ -153,7 +155,9 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
__func__, c->ifp->name, p);
SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY);
}

}
#endif

pim_if_addr_add(c);
if (pim_ifp) {
Expand Down Expand Up @@ -200,6 +204,8 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
return 0;

p = c->address;

#if PIM_IPV == 4
if (p->family == AF_INET) {
if (PIM_DEBUG_ZEBRA) {
zlog_debug(
Expand All @@ -214,10 +220,13 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
#endif
}

pim_if_addr_del(c, 0);
pim_rp_setup(pim);
pim_i_am_rp_re_evaluate(pim);
}
#endif /* PIM_IPV == 4 */

pim_if_addr_del(c, 0);
pim_rp_setup(pim);
pim_i_am_rp_re_evaluate(pim);


connected_free(&c);
return 0;
Expand All @@ -240,7 +249,11 @@ void pim_zebra_update_all_interfaces(struct pim_instance *pim)
struct pim_rpf rpf;

rpf.source_nexthop.interface = ifp;
#if PIM_IPV == 4
rpf.rpf_addr.u.prefix4 = us->address;
#else
rpf.rpf_addr.u.prefix6 = us->address;
#endif
pim_joinprune_send(&rpf, us->us);
pim_jp_agg_clear_group(us->us);
}
Expand All @@ -254,8 +267,14 @@ void pim_zebra_upstream_rpf_changed(struct pim_instance *pim,
if (old->source_nexthop.interface) {
struct pim_neighbor *nbr;

#if PIM_IPV == 4
nbr = pim_neighbor_find(old->source_nexthop.interface,
old->rpf_addr.u.prefix4);
#else
nbr = pim_neighbor_find(old->source_nexthop.interface,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use pim_neighbor_find_prefix()

old->rpf_addr.u.prefix6);
#endif

if (nbr)
pim_jp_agg_remove_group(nbr->upstream_jp_agg, up, nbr);

Expand Down Expand Up @@ -337,8 +356,14 @@ static int pim_zebra_vxlan_sg_proc(ZAPI_CALLBACK_ARGS)
s = zclient->ibuf;

prefixlen = stream_getl(s);

#if PIM_IPV == 4
stream_get(&sg.src.s_addr, s, prefixlen);
stream_get(&sg.grp.s_addr, s, prefixlen);
#else
stream_get(&sg.src.s6_addr, s, prefixlen);
stream_get(&sg.grp.s6_addr, s, prefixlen);
#endif

if (PIM_DEBUG_ZEBRA)
zlog_debug("%u:recv SG %s %pSG", vrf_id,
Expand Down Expand Up @@ -451,6 +476,7 @@ static zclient_handler *const pim_handlers[] = {

void pim_zebra_init(void)
{
#if PIM_IPV == 4
/* Socket for receiving updates from Zebra daemon */
zclient = zclient_new(router->master, &zclient_options_default,
pim_handlers, array_size(pim_handlers));
Expand All @@ -464,6 +490,22 @@ void pim_zebra_init(void)
}

zclient_lookup_new();
#else
/* Socket for receiving updates from Zebra daemon */
zclient = zclient_new(router->master, &zclient_options_default,
pim_handlers, array_size(pim_handlers));

zclient->zebra_capabilities = pim_zebra_capabilities;
zclient->zebra_connected = pim_zebra_connected;

zclient_init(zclient, ZEBRA_ROUTE_PIM6, 0, &pimd_privs);
if (PIM_DEBUG_PIM_TRACE) {
zlog_notice("%s: zclient socket initialized", __func__);
}

zclient_lookup_new();

#endif
}

void igmp_anysource_forward_start(struct pim_instance *pim,
Expand Down Expand Up @@ -606,7 +648,7 @@ void igmp_source_forward_start(struct pim_instance *pim,
}

if (!source->source_channel_oil) {
struct in_addr vif_source;
pim_addr vif_source;
struct prefix src, grp;
struct pim_nexthop nexthop;
struct pim_upstream *up = NULL;
Expand All @@ -619,13 +661,23 @@ void igmp_source_forward_start(struct pim_instance *pim,
}

else {
#if PIM_IPV == 4
src.family = AF_INET;
src.prefixlen = IPV4_MAX_BITLEN;
src.u.prefix4 = vif_source; // RP or Src address
grp.family = AF_INET;
grp.prefixlen = IPV4_MAX_BITLEN;
grp.u.prefix4 = sg.grp;
#else

src.family = AF_INET6;
src.prefixlen = IPV6_MAX_BITLEN;
src.u.prefix6 = vif_source; // RP or Src address
grp.family = AF_INET6;
grp.prefixlen = IPV6_MAX_BITLEN;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use pim_addr_to_prefix

grp.u.prefix6 = sg.grp;

#endif
up = pim_upstream_find(pim, &sg);
if (up) {
memcpy(&nexthop, &up->rpf.source_nexthop,
Expand Down
37 changes: 11 additions & 26 deletions pimd/pim_zlookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void zclient_lookup_new(void)
static int zclient_read_nexthop(struct pim_instance *pim,
struct zclient *zlookup,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size, struct in_addr addr)
const int tab_size, pim_addr addr)
{
int num_ifindex = 0;
struct stream *s;
Expand Down Expand Up @@ -326,7 +326,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,

static int zclient_lookup_nexthop_once(struct pim_instance *pim,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size, struct in_addr addr)
const int tab_size, pim_addr addr)
{
struct stream *s;
int ret;
Expand Down Expand Up @@ -397,7 +397,7 @@ int zclient_lookup_read_pipe(struct thread *thread)

int zclient_lookup_nexthop(struct pim_instance *pim,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size, struct in_addr addr,
const int tab_size, pim_addr addr,
int max_lookup)
{
int lookup;
Expand All @@ -415,12 +415,9 @@ int zclient_lookup_nexthop(struct pim_instance *pim,
tab_size, addr);
if (num_ifindex < 1) {
if (PIM_DEBUG_PIM_NHT) {
char addr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<addr?>", addr, addr_str,
sizeof(addr_str));
zlog_debug(
"%s: lookup=%d/%d: could not find nexthop ifindex for address %s(%s)",
__func__, lookup, max_lookup, addr_str,
"%s: lookup=%d/%d: could not find nexthop ifindex for address %pPAs",
__func__, lookup, max_lookup, &addr,
pim->vrf->name);
}
return -1;
Expand Down Expand Up @@ -452,14 +449,10 @@ int zclient_lookup_nexthop(struct pim_instance *pim,
/* Report non-recursive success after first
* lookup */
if (PIM_DEBUG_PIM_NHT) {
char addr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<addr?>", addr,
addr_str,
sizeof(addr_str));
zlog_debug(
"%s: lookup=%d/%d: found non-recursive ifindex=%d for address %s(%s) dist=%d met=%d",
"%s: lookup=%d/%d: found non-recursive ifindex=%d for address %pPAs dist=%d met=%d",
__func__, lookup, max_lookup,
first_ifindex, addr_str,
first_ifindex, &addr,
pim->vrf->name,
nexthop_tab[0]
.protocol_distance,
Expand All @@ -479,16 +472,10 @@ int zclient_lookup_nexthop(struct pim_instance *pim,
}

if (PIM_DEBUG_PIM_NHT) {
char addr_str[INET_ADDRSTRLEN];
char nexthop_str[PREFIX_STRLEN];
pim_inet4_dump("<addr?>", addr, addr_str,
sizeof(addr_str));
pim_addr_dump("<nexthop?>", &nexthop_addr, nexthop_str,
sizeof(nexthop_str));
zlog_debug(
"%s: lookup=%d/%d: zebra returned recursive nexthop %s for address %s(%s) dist=%d met=%d",
__func__, lookup, max_lookup, nexthop_str,
addr_str, pim->vrf->name,
"%s: lookup=%d/%d: zebra returned recursive nexthop %pPAs for address %pPAs dist=%d met=%d",
__func__, lookup, max_lookup, &nexthop_addr,
&addr, pim->vrf->name,
nexthop_tab[0].protocol_distance,
nexthop_tab[0].route_metric);
}
Expand All @@ -499,11 +486,9 @@ int zclient_lookup_nexthop(struct pim_instance *pim,
} /* for (max_lookup) */

if (PIM_DEBUG_PIM_NHT) {
char addr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
zlog_warn(
"%s: lookup=%d/%d: failure searching recursive nexthop ifindex for address %s(%s)",
__func__, lookup, max_lookup, addr_str, pim->vrf->name);
__func__, lookup, max_lookup, &addr, pim->vrf->name);
}

return -2;
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_zlookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void zclient_lookup_free(void);

int zclient_lookup_nexthop(struct pim_instance *pim,
struct pim_zlookup_nexthop nexthop_tab[],
const int tab_size, struct in_addr addr,
const int tab_size, pim_addr addr,
int max_lookup);

void pim_zlookup_show_ip_multicast(struct vty *vty);
Expand Down