Skip to content

Commit

Permalink
pimd: Use a better name for oil_parent
Browse files Browse the repository at this point in the history
Use oil_incoming_vif instead of oil_parent.  I had
to go look this up as that I failed to remember that
the linux kernel calls this parent for some bizarre
reason.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Sep 19, 2023
1 parent e7f0bbb commit 5f57d30
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 40 deletions.
14 changes: 7 additions & 7 deletions pimd/pim_cmd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ void pim_show_state(struct pim_instance *pim, struct vty *vty,
oil_mcastgrp(c_oil));
snprintfrr(src_str, sizeof(src_str), "%pPAs",
oil_origin(c_oil));
ifp_in = pim_if_find_by_vif_index(pim, *oil_parent(c_oil));
ifp_in = pim_if_find_by_vif_index(pim, *oil_incoming_vif(c_oil));

if (ifp_in)
strlcpy(in_ifname, ifp_in->name, sizeof(in_ifname));
Expand Down Expand Up @@ -3723,7 +3723,7 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (pim_channel_oil_empty(c_oil))
strlcat(state_str, "P", sizeof(state_str));

ifp_in = pim_if_find_by_vif_index(pim, *oil_parent(c_oil));
ifp_in = pim_if_find_by_vif_index(pim, *oil_incoming_vif(c_oil));

if (ifp_in)
strlcpy(in_ifname, ifp_in->name, sizeof(in_ifname));
Expand Down Expand Up @@ -3789,7 +3789,7 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_MUTE)
continue;

if (*oil_parent(c_oil) == oif_vif_index &&
if (*oil_incoming_vif(c_oil) == oif_vif_index &&
!pim_mroute_allow_iif_in_oil(c_oil, oif_vif_index))
continue;

Expand Down Expand Up @@ -3840,7 +3840,7 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
"inboundInterface",
in_ifname);
json_object_int_add(json_ifp_out, "iVifI",
*oil_parent(c_oil));
*oil_incoming_vif(c_oil));
json_object_string_add(json_ifp_out,
"outboundInterface",
out_ifname);
Expand Down Expand Up @@ -3989,9 +3989,9 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
json_object_string_add(json_ifp_out,
"inboundInterface",
in_ifname);
json_object_int_add(
json_ifp_out, "iVifI",
*oil_parent(&s_route->c_oil));
json_object_int_add(json_ifp_out, "iVifI",
*oil_incoming_vif(
&s_route->c_oil));
json_object_string_add(json_ifp_out,
"outboundInterface",
out_ifname);
Expand Down
41 changes: 20 additions & 21 deletions pimd/pim_mroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ int pim_mroute_msg_nocache(int fd, struct interface *ifp, const kernmsg *msg)
up->channel_oil->cc.pktcnt++;
// resolve mfcc_parent prior to mroute_add in channel_add_oif
if (up->rpf.source_nexthop.interface &&
*oil_parent(up->channel_oil) >= MAXVIFS) {
*oil_incoming_vif(up->channel_oil) >= MAXVIFS) {
pim_upstream_mroute_iif_update(up->channel_oil, __func__);
}
pim_register_join(up);
Expand Down Expand Up @@ -1042,10 +1042,10 @@ static inline void pim_mroute_copy(struct channel_oil *out,

*oil_origin(out) = *oil_origin(in);
*oil_mcastgrp(out) = *oil_mcastgrp(in);
*oil_parent(out) = *oil_parent(in);
*oil_incoming_vif(out) = *oil_incoming_vif(in);

for (i = 0; i < MAXVIFS; ++i) {
if (*oil_parent(out) == i &&
if (*oil_incoming_vif(out) == i &&
!pim_mroute_allow_iif_in_oil(in, i)) {
oil_if_set(out, i, 0);
continue;
Expand Down Expand Up @@ -1080,7 +1080,7 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
* in the case of a (*,G).
*/
if (pim_addr_is_any(*oil_origin(c_oil))) {
oil_if_set(tmp_oil, *oil_parent(c_oil), 1);
oil_if_set(tmp_oil, *oil_incoming_vif(c_oil), 1);
}

/*
Expand All @@ -1090,18 +1090,17 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
* the packets to be forwarded. Then set it
* to the correct IIF afterwords.
*/
if (!c_oil->installed && !pim_addr_is_any(*oil_origin(c_oil))
&& *oil_parent(c_oil) != 0) {
*oil_parent(tmp_oil) = 0;
if (!c_oil->installed && !pim_addr_is_any(*oil_origin(c_oil)) &&
*oil_incoming_vif(c_oil) != 0) {
*oil_incoming_vif(tmp_oil) = 0;
}
/* For IPv6 MRT_ADD_MFC is defined to MRT6_ADD_MFC */
err = setsockopt(pim->mroute_socket, PIM_IPPROTO, MRT_ADD_MFC,
&tmp_oil->oil, sizeof(tmp_oil->oil));

if (!err && !c_oil->installed
&& !pim_addr_is_any(*oil_origin(c_oil))
&& *oil_parent(c_oil) != 0) {
*oil_parent(tmp_oil) = *oil_parent(c_oil);
if (!err && !c_oil->installed && !pim_addr_is_any(*oil_origin(c_oil)) &&
*oil_incoming_vif(c_oil) != 0) {
*oil_incoming_vif(tmp_oil) = *oil_incoming_vif(c_oil);
err = setsockopt(pim->mroute_socket, PIM_IPPROTO, MRT_ADD_MFC,
&tmp_oil->oil, sizeof(tmp_oil->oil));
}
Expand Down Expand Up @@ -1158,7 +1157,7 @@ static int pim_upstream_mroute_update(struct channel_oil *c_oil,
{
char buf[1000];

if (*oil_parent(c_oil) >= MAXVIFS) {
if (*oil_incoming_vif(c_oil) >= MAXVIFS) {
/* the c_oil cannot be installed as a mroute yet */
if (PIM_DEBUG_MROUTE)
zlog_debug(
Expand Down Expand Up @@ -1205,13 +1204,13 @@ int pim_upstream_mroute_add(struct channel_oil *c_oil, const char *name)

iif = pim_upstream_get_mroute_iif(c_oil, name);

if (*oil_parent(c_oil) != iif) {
*oil_parent(c_oil) = iif;
if (*oil_incoming_vif(c_oil) != iif) {
*oil_incoming_vif(c_oil) = iif;
if (pim_addr_is_any(*oil_origin(c_oil)) &&
c_oil->up)
pim_upstream_all_sources_iif_update(c_oil->up);
} else {
*oil_parent(c_oil) = iif;
*oil_incoming_vif(c_oil) = iif;
}

return pim_upstream_mroute_update(c_oil, name);
Expand All @@ -1226,11 +1225,11 @@ int pim_upstream_mroute_iif_update(struct channel_oil *c_oil, const char *name)
char buf[1000];

iif = pim_upstream_get_mroute_iif(c_oil, name);
if (*oil_parent(c_oil) == iif) {
if (*oil_incoming_vif(c_oil) == iif) {
/* no change */
return 0;
}
*oil_parent(c_oil) = iif;
*oil_incoming_vif(c_oil) = iif;

if (pim_addr_is_any(*oil_origin(c_oil)) &&
c_oil->up)
Expand All @@ -1255,10 +1254,10 @@ void pim_static_mroute_iif_update(struct channel_oil *c_oil,
int input_vif_index,
const char *name)
{
if (*oil_parent(c_oil) == input_vif_index)
if (*oil_incoming_vif(c_oil) == input_vif_index)
return;

*oil_parent(c_oil) = input_vif_index;
*oil_incoming_vif(c_oil) = input_vif_index;
if (input_vif_index == MAXVIFS)
pim_mroute_del(c_oil, name);
else
Expand All @@ -1277,8 +1276,8 @@ int pim_mroute_del(struct channel_oil *c_oil, const char *name)
if (PIM_DEBUG_MROUTE) {
char buf[1000];
struct interface *iifp =
pim_if_find_by_vif_index(pim,
*oil_parent(c_oil));
pim_if_find_by_vif_index(pim, *oil_incoming_vif(
c_oil));

zlog_debug("%s %s: incoming interface %s for route is %s not installed, do not need to send del req. ",
__FILE__, __func__,
Expand Down
11 changes: 5 additions & 6 deletions pimd/pim_oil.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)

sg.src = *oil_origin(c_oil);
sg.grp = *oil_mcastgrp(c_oil);
ifp = pim_if_find_by_vif_index(c_oil->pim, *oil_parent(c_oil));
ifp = pim_if_find_by_vif_index(c_oil->pim, *oil_incoming_vif(c_oil));
snprintfrr(buf, size, "%pSG IIF: %s, OIFS: ", &sg,
ifp ? ifp->name : "(?)");

Expand Down Expand Up @@ -135,7 +135,7 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
*oil_mcastgrp(c_oil) = sg->grp;
*oil_origin(c_oil) = sg->src;

*oil_parent(c_oil) = MAXVIFS;
*oil_incoming_vif(c_oil) = MAXVIFS;
c_oil->oil_ref_count = 1;
c_oil->installed = 0;
c_oil->up = pim_upstream_find(pim, sg);
Expand Down Expand Up @@ -164,7 +164,7 @@ void pim_clear_nocache_state(struct pim_interface *pim_ifp)
!(PIM_UPSTREAM_FLAG_TEST_SRC_NOCACHE(c_oil->up->flags)))
continue;

if (*oil_parent(c_oil) != pim_ifp->mroute_vif_index)
if (*oil_incoming_vif(c_oil) != pim_ifp->mroute_vif_index)
continue;

EVENT_OFF(c_oil->up->t_ka_timer);
Expand Down Expand Up @@ -288,8 +288,7 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
if (PIM_DEBUG_MROUTE) {
struct interface *iifp =
pim_if_find_by_vif_index(pim_ifp->pim,
*oil_parent(channel_oil));

*oil_incoming_vif(channel_oil));

zlog_debug("%s(%s): (S,G)=(%pPAs,%pPAs): proto_mask=%u IIF:%s OIF=%s vif_index=%d",
__func__, caller, oil_origin(channel_oil),
Expand Down Expand Up @@ -525,7 +524,7 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
/* channel_oil->oil.mfcc_parent != MAXVIFS indicate this entry is not
* valid to get installed in kernel.
*/
if (*oil_parent(channel_oil) != MAXVIFS) {
if (*oil_incoming_vif(channel_oil) != MAXVIFS) {
if (pim_upstream_mroute_add(channel_oil, __func__)) {
if (PIM_DEBUG_MROUTE) {
zlog_debug(
Expand Down
4 changes: 2 additions & 2 deletions pimd/pim_oil.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static inline pim_addr *oil_mcastgrp(struct channel_oil *c_oil)
return &c_oil->oil.mfcc_mcastgrp;
}

static inline vifi_t *oil_parent(struct channel_oil *c_oil)
static inline vifi_t *oil_incoming_vif(struct channel_oil *c_oil)
{
return &c_oil->oil.mfcc_parent;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ static inline pim_addr *oil_mcastgrp(struct channel_oil *c_oil)
return &c_oil->oil.mf6cc_mcastgrp.sin6_addr;
}

static inline mifi_t *oil_parent(struct channel_oil *c_oil)
static inline mifi_t *oil_incoming_vif(struct channel_oil *c_oil)
{
return &c_oil->oil.mf6cc_parent;
}
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static struct static_route *static_route_new(ifindex_t iif, ifindex_t oif,
s_route->c_oil.oil_ref_count = 1;
*oil_origin(&s_route->c_oil) = source;
*oil_mcastgrp(&s_route->c_oil) = group;
*oil_parent(&s_route->c_oil) = iif;
*oil_incoming_vif(&s_route->c_oil) = iif;
oil_if_set(&s_route->c_oil, oif, 1);
s_route->c_oil.oif_creation[oif] = pim_time_monotonic_sec();

Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up)
return false;

pim_ifp = ifp->info;
if (pim_ifp->mroute_vif_index != *oil_parent(c_oil))
if (pim_ifp->mroute_vif_index != *oil_incoming_vif(c_oil))
return false;

if (pim_if_connected_to_source(up->rpf.source_nexthop.interface,
Expand Down
4 changes: 2 additions & 2 deletions pimd/pim_zlookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
int ret;
pim_sgaddr more = {};
struct interface *ifp =
pim_if_find_by_vif_index(c_oil->pim, *oil_parent(c_oil));
pim_if_find_by_vif_index(c_oil->pim, *oil_incoming_vif(c_oil));

if (PIM_DEBUG_ZEBRA) {
more.src = *oil_origin(c_oil);
more.grp = *oil_mcastgrp(c_oil);
zlog_debug("Sending Request for New Channel Oil Information%pSG VIIF %d(%s:%s)",
&more, *oil_parent(c_oil),
&more, *oil_incoming_vif(c_oil),
ifp ? ifp->name : "Unknown", c_oil->pim->vrf->name);
}

Expand Down

0 comments on commit 5f57d30

Please sign in to comment.