summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_ifchannel.c6
-rw-r--r--pimd/pim_mroute.c108
-rw-r--r--pimd/pim_mroute.h16
-rw-r--r--pimd/pim_oil.c226
-rw-r--r--pimd/pim_oil.h57
-rw-r--r--pimd/pim_upstream.c2
6 files changed, 210 insertions, 205 deletions
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index a613c89b7..ca96d7038 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -306,8 +306,8 @@ void pim_ifchannel_ifjoin_switch(const char *caller, struct pim_ifchannel *ch,
* supplying the implied
* if channel. So remove it.
*/
- if (c_oil->oil.mfcc_ttls
- [pim_ifp->mroute_vif_index])
+ if (oil_if_has(c_oil,
+ pim_ifp->mroute_vif_index))
pim_channel_del_inherited_oif(
c_oil, ch->interface,
__func__);
@@ -1291,7 +1291,7 @@ void pim_ifchannel_local_membership_del(struct interface *ifp, pim_sgaddr *sg)
if (!pim_upstream_evaluate_join_desired_interface(
child, ch, starch) ||
(!chchannel &&
- c_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index])) {
+ oil_if_has(c_oil, pim_ifp->mroute_vif_index))) {
pim_channel_del_inherited_oif(c_oil, ifp,
__func__);
}
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 91b997f44..2fabd3d1b 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -145,6 +145,7 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
return 0;
}
+#if PIM_IPV == 4
static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = {
"<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"};
@@ -227,7 +228,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp,
up->channel_oil->cc.pktcnt++;
// resolve mfcc_parent prior to mroute_add in channel_add_oif
if (up->rpf.source_nexthop.interface &&
- up->channel_oil->oil.mfcc_parent >= MAXVIFS) {
+ *oil_parent(up->channel_oil) >= MAXVIFS) {
pim_upstream_mroute_iif_update(up->channel_oil, __func__);
}
pim_register_join(up);
@@ -676,6 +677,14 @@ static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
return 0;
}
+#else /* PIM_IPV != 4 */
+
+static int pim_mroute_msg(struct pim_instance *pim, const char *buf,
+ int buf_size, ifindex_t ifindex)
+{
+ return 0;
+}
+#endif /* PIM_IPV != 4 */
static int mroute_read(struct thread *t)
{
@@ -800,7 +809,7 @@ int pim_mroute_socket_disable(struct pim_instance *pim)
would be used for multicast forwarding, a corresponding multicast
interface must be added to the kernel.
*/
-int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,
+int pim_mroute_add_vif(struct interface *ifp, pim_addr ifaddr,
unsigned char flags)
{
struct pim_interface *pim_ifp = ifp->info;
@@ -839,15 +848,10 @@ int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,
err = setsockopt(pim_ifp->pim->mroute_socket, IPPROTO_IP, MRT_ADD_VIF,
(void *)&vc, sizeof(vc));
if (err) {
- char ifaddr_str[INET_ADDRSTRLEN];
-
- pim_inet4_dump("<ifaddr?>", ifaddr, ifaddr_str,
- sizeof(ifaddr_str));
-
zlog_warn(
- "%s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_VIF,vif_index=%d,ifaddr=%s,flag=%d): errno=%d: %s",
+ "%s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_VIF,vif_index=%d,ifaddr=%pPAs,flag=%d): errno=%d: %s",
__func__, pim_ifp->pim->mroute_socket, ifp->ifindex,
- ifaddr_str, flags, errno, safe_strerror(errno));
+ &ifaddr, flags, errno, safe_strerror(errno));
return -2;
}
@@ -921,26 +925,26 @@ bool pim_mroute_allow_iif_in_oil(struct channel_oil *c_oil,
#endif
}
-static inline void pim_mroute_copy(struct mfcctl *oil,
- struct channel_oil *c_oil)
+static inline void pim_mroute_copy(struct channel_oil *out,
+ struct channel_oil *in)
{
int i;
- oil->mfcc_origin = c_oil->oil.mfcc_origin;
- oil->mfcc_mcastgrp = c_oil->oil.mfcc_mcastgrp;
- oil->mfcc_parent = c_oil->oil.mfcc_parent;
+ *oil_origin(out) = *oil_origin(in);
+ *oil_mcastgrp(out) = *oil_mcastgrp(in);
+ *oil_parent(out) = *oil_parent(in);
for (i = 0; i < MAXVIFS; ++i) {
- if ((oil->mfcc_parent == i) &&
- !pim_mroute_allow_iif_in_oil(c_oil, i)) {
- oil->mfcc_ttls[i] = 0;
+ if (*oil_parent(out) == i &&
+ !pim_mroute_allow_iif_in_oil(in, i)) {
+ oil_if_set(out, i, 0);
continue;
}
- if (c_oil->oif_flags[i] & PIM_OIF_FLAG_MUTE)
- oil->mfcc_ttls[i] = 0;
+ if (in->oif_flags[i] & PIM_OIF_FLAG_MUTE)
+ oil_if_set(out, i, 0);
else
- oil->mfcc_ttls[i] = c_oil->oil.mfcc_ttls[i];
+ oil_if_set(out, i, oil_if_has(in, i));
}
}
@@ -950,7 +954,7 @@ static inline void pim_mroute_copy(struct mfcctl *oil,
static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
{
struct pim_instance *pim = c_oil->pim;
- struct mfcctl tmp_oil = { {0} };
+ struct channel_oil tmp_oil[1] = { };
int err;
pim->mroute_add_last = pim_time_monotonic_sec();
@@ -959,14 +963,14 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
/* Copy the oil to a temporary structure to fixup (without need to
* later restore) before sending the mroute add to the dataplane
*/
- pim_mroute_copy(&tmp_oil, c_oil);
+ pim_mroute_copy(tmp_oil, c_oil);
/* The linux kernel *expects* the incoming
* vif to be part of the outgoing list
* in the case of a (*,G).
*/
- if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY) {
- tmp_oil.mfcc_ttls[c_oil->oil.mfcc_parent] = 1;
+ if (pim_addr_is_any(*oil_origin(c_oil))) {
+ oil_if_set(tmp_oil, *oil_parent(c_oil), 1);
}
/*
@@ -976,19 +980,19 @@ 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 && c_oil->oil.mfcc_origin.s_addr != INADDR_ANY
- && c_oil->oil.mfcc_parent != 0) {
- tmp_oil.mfcc_parent = 0;
+ if (!c_oil->installed && !pim_addr_is_any(*oil_origin(c_oil))
+ && *oil_parent(c_oil) != 0) {
+ *oil_parent(tmp_oil) = 0;
}
err = setsockopt(pim->mroute_socket, IPPROTO_IP, MRT_ADD_MFC,
- &tmp_oil, sizeof(tmp_oil));
+ &tmp_oil->oil, sizeof(tmp_oil->oil));
if (!err && !c_oil->installed
- && c_oil->oil.mfcc_origin.s_addr != INADDR_ANY
- && c_oil->oil.mfcc_parent != 0) {
- tmp_oil.mfcc_parent = c_oil->oil.mfcc_parent;
+ && !pim_addr_is_any(*oil_origin(c_oil))
+ && *oil_parent(c_oil) != 0) {
+ *oil_parent(tmp_oil) = *oil_parent(c_oil);
err = setsockopt(pim->mroute_socket, IPPROTO_IP, MRT_ADD_MFC,
- &tmp_oil, sizeof(tmp_oil));
+ &tmp_oil->oil, sizeof(tmp_oil->oil));
}
if (err) {
@@ -1043,7 +1047,7 @@ static int pim_upstream_mroute_update(struct channel_oil *c_oil,
{
char buf[1000];
- if (c_oil->oil.mfcc_parent >= MAXVIFS) {
+ if (*oil_parent(c_oil) >= MAXVIFS) {
/* the c_oil cannot be installed as a mroute yet */
if (PIM_DEBUG_MROUTE)
zlog_debug(
@@ -1090,13 +1094,13 @@ int pim_upstream_mroute_add(struct channel_oil *c_oil, const char *name)
iif = pim_upstream_get_mroute_iif(c_oil, name);
- if (c_oil->oil.mfcc_parent != iif) {
- c_oil->oil.mfcc_parent = iif;
- if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY &&
+ if (*oil_parent(c_oil) != iif) {
+ *oil_parent(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 {
- c_oil->oil.mfcc_parent = iif;
+ *oil_parent(c_oil) = iif;
}
return pim_upstream_mroute_update(c_oil, name);
@@ -1111,13 +1115,13 @@ 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 (c_oil->oil.mfcc_parent == iif) {
+ if (*oil_parent(c_oil) == iif) {
/* no change */
return 0;
}
- c_oil->oil.mfcc_parent = iif;
+ *oil_parent(c_oil) = iif;
- if (c_oil->oil.mfcc_origin.s_addr == INADDR_ANY &&
+ if (pim_addr_is_any(*oil_origin(c_oil)) &&
c_oil->up)
pim_upstream_all_sources_iif_update(c_oil->up);
@@ -1140,10 +1144,10 @@ void pim_static_mroute_iif_update(struct channel_oil *c_oil,
int input_vif_index,
const char *name)
{
- if (c_oil->oil.mfcc_parent == input_vif_index)
+ if (*oil_parent(c_oil) == input_vif_index)
return;
- c_oil->oil.mfcc_parent = input_vif_index;
+ *oil_parent(c_oil) = input_vif_index;
if (input_vif_index == MAXVIFS)
pim_mroute_del(c_oil, name);
else
@@ -1163,7 +1167,7 @@ int pim_mroute_del(struct channel_oil *c_oil, const char *name)
char buf[1000];
zlog_debug(
"%s %s: vifi %d for route is %s not installed, do not need to send del req. ",
- __FILE__, __func__, c_oil->oil.mfcc_parent,
+ __FILE__, __func__, *oil_parent(c_oil),
pim_channel_oil_dump(c_oil, buf, sizeof(buf)));
}
return -2;
@@ -1196,7 +1200,6 @@ int pim_mroute_del(struct channel_oil *c_oil, const char *name)
void pim_mroute_update_counters(struct channel_oil *c_oil)
{
struct pim_instance *pim = c_oil->pim;
- struct sioc_sg_req sgreq;
c_oil->cc.oldpktcnt = c_oil->cc.pktcnt;
c_oil->cc.oldbytecnt = c_oil->cc.bytecnt;
@@ -1207,24 +1210,27 @@ void pim_mroute_update_counters(struct channel_oil *c_oil)
if (PIM_DEBUG_MROUTE) {
pim_sgaddr sg;
- sg.src = c_oil->oil.mfcc_origin;
- sg.grp = c_oil->oil.mfcc_mcastgrp;
+ sg.src = *oil_origin(c_oil);
+ sg.grp = *oil_mcastgrp(c_oil);
zlog_debug("Channel%pSG is not installed no need to collect data from kernel",
&sg);
}
return;
}
+#if PIM_IPV == 4
+ struct sioc_sg_req sgreq;
+
memset(&sgreq, 0, sizeof(sgreq));
- sgreq.src = c_oil->oil.mfcc_origin;
- sgreq.grp = c_oil->oil.mfcc_mcastgrp;
+ sgreq.src = *oil_origin(c_oil);
+ sgreq.grp = *oil_mcastgrp(c_oil);
pim_zlookup_sg_statistics(c_oil);
if (ioctl(pim->mroute_socket, SIOCGETSGCNT, &sgreq)) {
pim_sgaddr sg;
- sg.src = c_oil->oil.mfcc_origin;
- sg.grp = c_oil->oil.mfcc_mcastgrp;
+ sg.src = *oil_origin(c_oil);
+ sg.grp = *oil_mcastgrp(c_oil);
zlog_warn("ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=%pSG: errno=%d: %s",
(unsigned long)SIOCGETSGCNT, &sg,
@@ -1235,6 +1241,6 @@ void pim_mroute_update_counters(struct channel_oil *c_oil)
c_oil->cc.pktcnt = sgreq.pktcnt;
c_oil->cc.bytecnt = sgreq.bytecnt;
c_oil->cc.wrong_if = sgreq.wrong_if;
-
+#endif
return;
}
diff --git a/pimd/pim_mroute.h b/pimd/pim_mroute.h
index 4cd6b9f0a..14b0a8cca 100644
--- a/pimd/pim_mroute.h
+++ b/pimd/pim_mroute.h
@@ -37,6 +37,7 @@
#define PIM_MROUTE_MIN_TTL (1)
+#if PIM_IPV == 4
#if defined(HAVE_LINUX_MROUTE_H)
#include <linux/mroute.h>
#else
@@ -157,6 +158,19 @@ struct igmpmsg {
struct in_addr im_src, im_dst;
};
#endif
+
+#endif /* HAVE_LINUX_MROUTE_H */
+
+typedef struct mfcctl pim_mfcctl;
+
+#else /* PIM_IPV != 4 */
+#if defined(HAVE_LINUX_MROUTE6_H)
+#include <linux/mroute6.h>
+#endif
+
+typedef struct mf6cctl pim_mfcctl;
+
+#define MAXVIFS IF_SETSIZE
#endif
#ifndef IGMPMSG_WRVIFWHOLE
@@ -172,7 +186,7 @@ struct channel_oil;
int pim_mroute_socket_enable(struct pim_instance *pim);
int pim_mroute_socket_disable(struct pim_instance *pim);
-int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,
+int pim_mroute_add_vif(struct interface *ifp, pim_addr ifaddr,
unsigned char flags);
int pim_mroute_del_vif(struct interface *ifp);
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c
index b17f821dd..a499c884b 100644
--- a/pimd/pim_oil.c
+++ b/pimd/pim_oil.c
@@ -42,15 +42,15 @@ char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)
pim_sgaddr sg;
int i;
- sg.src = c_oil->oil.mfcc_origin;
- sg.grp = c_oil->oil.mfcc_mcastgrp;
- ifp = pim_if_find_by_vif_index(c_oil->pim, c_oil->oil.mfcc_parent);
+ 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));
snprintfrr(buf, size, "%pSG IIF: %s, OIFS: ", &sg,
ifp ? ifp->name : "(?)");
out = buf + strlen(buf);
for (i = 0; i < MAXVIFS; i++) {
- if (c_oil->oil.mfcc_ttls[i] != 0) {
+ if (oil_if_has(c_oil, i) != 0) {
ifp = pim_if_find_by_vif_index(c_oil->pim, i);
snprintf(out, buf + size - out, "%s ",
ifp ? ifp->name : "(?)");
@@ -61,25 +61,19 @@ char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)
return buf;
}
-int pim_channel_oil_compare(const struct channel_oil *c1,
- const struct channel_oil *c2)
+int pim_channel_oil_compare(const struct channel_oil *cc1,
+ const struct channel_oil *cc2)
{
- if (ntohl(c1->oil.mfcc_mcastgrp.s_addr)
- < ntohl(c2->oil.mfcc_mcastgrp.s_addr))
- return -1;
-
- if (ntohl(c1->oil.mfcc_mcastgrp.s_addr)
- > ntohl(c2->oil.mfcc_mcastgrp.s_addr))
- return 1;
-
- if (ntohl(c1->oil.mfcc_origin.s_addr)
- < ntohl(c2->oil.mfcc_origin.s_addr))
- return -1;
-
- if (ntohl(c1->oil.mfcc_origin.s_addr)
- > ntohl(c2->oil.mfcc_origin.s_addr))
- return 1;
-
+ struct channel_oil *c1 = (struct channel_oil *)cc1;
+ struct channel_oil *c2 = (struct channel_oil *)cc2;
+ int rv;
+
+ rv = pim_addr_cmp(*oil_mcastgrp(c1), *oil_mcastgrp(c2));
+ if (rv)
+ return rv;
+ rv = pim_addr_cmp(*oil_origin(c1), *oil_origin(c2));
+ if (rv)
+ return rv;
return 0;
}
@@ -109,8 +103,8 @@ struct channel_oil *pim_find_channel_oil(struct pim_instance *pim,
struct channel_oil *c_oil = NULL;
struct channel_oil lookup;
- lookup.oil.mfcc_mcastgrp = sg->grp;
- lookup.oil.mfcc_origin = sg->src;
+ *oil_mcastgrp(&lookup) = sg->grp;
+ *oil_origin(&lookup) = sg->src;
c_oil = rb_pim_oil_find(&pim->channel_oil_head, &lookup);
@@ -151,10 +145,10 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
c_oil = XCALLOC(MTYPE_PIM_CHANNEL_OIL, sizeof(*c_oil));
- c_oil->oil.mfcc_mcastgrp = sg->grp;
- c_oil->oil.mfcc_origin = sg->src;
+ *oil_mcastgrp(c_oil) = sg->grp;
+ *oil_origin(c_oil) = sg->src;
- c_oil->oil.mfcc_parent = MAXVIFS;
+ *oil_parent(c_oil) = MAXVIFS;
c_oil->oil_ref_count = 1;
c_oil->installed = 0;
c_oil->up = pim_upstream_find(pim, sg);
@@ -172,8 +166,8 @@ struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil,
const char *name)
{
if (PIM_DEBUG_MROUTE) {
- pim_sgaddr sg = {.src = c_oil->oil.mfcc_mcastgrp,
- .grp = c_oil->oil.mfcc_origin};
+ pim_sgaddr sg = {.src = *oil_mcastgrp(c_oil),
+ .grp = *oil_origin(c_oil)};
zlog_debug(
"%s(%s): Del oil for %pSG, Ref Count: %d (Predecrement)",
@@ -228,23 +222,15 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
*/
if (!(channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask)) {
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s %s: no existing protocol mask %u(%u) for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)",
+ "%s %s: no existing protocol mask %u(%u) for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, proto_mask,
channel_oil
->oif_flags[pim_ifp->mroute_vif_index],
oif->name, pim_ifp->mroute_vif_index,
- channel_oil->oil
- .mfcc_ttls[pim_ifp->mroute_vif_index],
- source_str, group_str);
+ oil_if_has(channel_oil, pim_ifp->mroute_vif_index),
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
return 0;
}
@@ -254,44 +240,29 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] &
PIM_OIF_FLAG_PROTO_ANY) {
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s %s: other protocol masks remain for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)",
+ "%s %s: other protocol masks remain for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, oif->name,
pim_ifp->mroute_vif_index,
- channel_oil->oil
- .mfcc_ttls[pim_ifp->mroute_vif_index],
- source_str, group_str);
+ oil_if_has(channel_oil, pim_ifp->mroute_vif_index),
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
return 0;
}
- channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = 0;
+ oil_if_set(channel_oil, pim_ifp->mroute_vif_index, false);
/* clear mute; will be re-evaluated when the OIF becomes valid again */
channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~PIM_OIF_FLAG_MUTE;
if (pim_upstream_mroute_add(channel_oil, __func__)) {
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s %s: could not remove output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)",
+ "%s %s: could not remove output interface %s (vif_index=%d) for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, oif->name,
- pim_ifp->mroute_vif_index, source_str,
- group_str);
+ pim_ifp->mroute_vif_index,
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
return -1;
}
@@ -299,16 +270,12 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
--channel_oil->oil_size;
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin,
- source_str, sizeof(source_str));
zlog_debug(
- "%s(%s): (S,G)=(%s,%s): proto_mask=%u IIF:%d OIF=%s vif_index=%d",
- __func__, caller, source_str, group_str, proto_mask,
- channel_oil->oil.mfcc_parent, oif->name,
+ "%s(%s): (S,G)=(%pPAs,%pPAs): proto_mask=%u IIF:%d OIF=%s vif_index=%d",
+ __func__, caller, oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil),
+ proto_mask,
+ *oil_parent(channel_oil), oif->name,
pim_ifp->mroute_vif_index);
}
@@ -397,7 +364,7 @@ void pim_channel_update_oif_mute(struct channel_oil *c_oil,
bool new_mute;
/* If pim_ifp is not a part of the OIL there is nothing to do */
- if (!c_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index])
+ if (!oil_if_has(c_oil, pim_ifp->mroute_vif_index))
return;
old_mute = !!(c_oil->oif_flags[pim_ifp->mroute_vif_index] &
@@ -455,21 +422,13 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
channel (S,G) multiple times */
if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask) {
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s %s: existing protocol mask %u requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)",
+ "%s %s: existing protocol mask %u requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, proto_mask, oif->name,
pim_ifp->mroute_vif_index,
- channel_oil->oil
- .mfcc_ttls[pim_ifp->mroute_vif_index],
- source_str, group_str);
+ oil_if_has(channel_oil, pim_ifp->mroute_vif_index),
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
return -3;
}
@@ -487,36 +446,21 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= proto_mask;
/* Check the OIF really exists before returning, and only log
warning otherwise */
- if (channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] < 1) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
+ if (oil_if_has(channel_oil, pim_ifp->mroute_vif_index) < 1) {
zlog_warn(
- "%s %s: new protocol mask %u requested nonexistent OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)",
+ "%s %s: new protocol mask %u requested nonexistent OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, proto_mask, oif->name,
pim_ifp->mroute_vif_index,
- channel_oil->oil
- .mfcc_ttls[pim_ifp->mroute_vif_index],
- source_str, group_str);
+ oil_if_has(channel_oil, pim_ifp->mroute_vif_index),
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s(%s): (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d added to 0x%x",
- __func__, caller, source_str, group_str,
+ "%s(%s): (S,G)=(%pPAs,%pPAs): proto_mask=%u OIF=%s vif_index=%d added to 0x%x",
+ __func__, caller, oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil),
proto_mask, oif->name,
pim_ifp->mroute_vif_index,
channel_oil
@@ -525,29 +469,21 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
return 0;
}
- old_ttl = channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index];
+ old_ttl = oil_if_has(channel_oil, pim_ifp->mroute_vif_index);
if (old_ttl > 0) {
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s %s: interface %s (vif_index=%d) is existing output for channel (S,G)=(%s,%s)",
+ "%s %s: interface %s (vif_index=%d) is existing output for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, oif->name,
- pim_ifp->mroute_vif_index, source_str,
- group_str);
+ pim_ifp->mroute_vif_index,
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
return -4;
}
- channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] =
- PIM_MROUTE_MIN_TTL;
+ oil_if_set(channel_oil, pim_ifp->mroute_vif_index, PIM_MROUTE_MIN_TTL);
/* Some OIFs are held in a muted state i.e. the PIM state machine
* decided to include the OIF but additional status check such as
@@ -564,26 +500,19 @@ 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 (channel_oil->oil.mfcc_parent != MAXVIFS) {
+ if (*oil_parent(channel_oil) != MAXVIFS) {
if (pim_upstream_mroute_add(channel_oil, __func__)) {
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>",
- channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>",
- channel_oil->oil.mfcc_origin, source_str,
- sizeof(source_str));
zlog_debug(
- "%s %s: could not add output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)",
+ "%s %s: could not add output interface %s (vif_index=%d) for channel (S,G)=(%pPAs,%pPAs)",
__FILE__, __func__, oif->name,
- pim_ifp->mroute_vif_index, source_str,
- group_str);
+ pim_ifp->mroute_vif_index,
+ oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil));
}
- channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index]
- = old_ttl;
+ oil_if_set(channel_oil, pim_ifp->mroute_vif_index,
+ old_ttl);
return -5;
}
}
@@ -594,15 +523,11 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= proto_mask;
if (PIM_DEBUG_MROUTE) {
- char group_str[INET_ADDRSTRLEN];
- char source_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin,
- source_str, sizeof(source_str));
zlog_debug(
- "%s(%s): (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d: DONE",
- __func__, caller, source_str, group_str, proto_mask,
+ "%s(%s): (S,G)=(%pPAs,%pPAs): proto_mask=%u OIF=%s vif_index=%d: DONE",
+ __func__, caller, oil_origin(channel_oil),
+ oil_mcastgrp(channel_oil),
+ proto_mask,
oif->name, pim_ifp->mroute_vif_index);
}
@@ -611,8 +536,6 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif,
int pim_channel_oil_empty(struct channel_oil *c_oil)
{
- static struct mfcctl null_oil;
-
if (!c_oil)
return 1;
@@ -620,6 +543,13 @@ int pim_channel_oil_empty(struct channel_oil *c_oil)
* non-NULL.
* pimreg device (in all vrfs) uses a vifi of
* 0 (PIM_OIF_PIM_REGISTER_VIF) so we simply mfcc_ttls[0] */
+#if PIM_IPV == 4
+ static pim_mfcctl null_oil;
+
return !memcmp(&c_oil->oil.mfcc_ttls[1], &null_oil.mfcc_ttls[1],
sizeof(null_oil.mfcc_ttls) - sizeof(null_oil.mfcc_ttls[0]));
+#else
+ CPP_NOTICE("FIXME STUB");
+ return false;
+#endif
}
diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h
index 696ef7064..a52e23351 100644
--- a/pimd/pim_oil.h
+++ b/pimd/pim_oil.h
@@ -98,7 +98,7 @@ struct channel_oil {
struct rb_pim_oil_item oil_rb;
- struct mfcctl oil;
+ pim_mfcctl oil;
int installed;
int oil_inherited_rescan;
int oil_size;
@@ -110,6 +110,61 @@ struct channel_oil {
time_t mroute_creation;
};
+#if PIM_IPV == 4
+static inline pim_addr *oil_origin(struct channel_oil *c_oil)
+{
+ return &c_oil->oil.mfcc_origin;
+}
+
+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)
+{
+ return &c_oil->oil.mfcc_parent;
+}
+
+static inline uint8_t oil_if_has(struct channel_oil *c_oil, vifi_t ifi)
+{
+ return c_oil->oil.mfcc_ttls[ifi];
+}
+
+static inline void oil_if_set(struct channel_oil *c_oil, vifi_t ifi, uint8_t set)
+{
+ c_oil->oil.mfcc_ttls[ifi] = set;
+}
+#else
+static inline pim_addr *oil_origin(struct channel_oil *c_oil)
+{
+ return &c_oil->oil.mf6cc_origin.sin6_addr;
+}
+
+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)
+{
+ return &c_oil->oil.mf6cc_parent;
+}
+
+static inline bool oil_if_has(struct channel_oil *c_oil, mifi_t ifi)
+{
+ return !!IF_ISSET(ifi, &c_oil->oil.mf6cc_ifset);
+}
+
+static inline void oil_if_set(struct channel_oil *c_oil, mifi_t ifi, bool set)
+{
+ if (set)
+ IF_SET(ifi, &c_oil->oil.mf6cc_ifset);
+ else
+ IF_CLR(ifi, &c_oil->oil.mf6cc_ifset);
+}
+#endif
+
extern int pim_channel_oil_compare(const struct channel_oil *c1,
const struct channel_oil *c2);
DECLARE_RBTREE_UNIQ(rb_pim_oil, struct channel_oil, oil_rb,
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index 40299ed9f..891364a9f 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -1997,7 +1997,7 @@ static bool pim_upstream_kat_start_ok(struct pim_upstream *up)
return false;
pim_ifp = ifp->info;
- if (pim_ifp->mroute_vif_index != c_oil->oil.mfcc_parent)
+ if (pim_ifp->mroute_vif_index != *oil_parent(c_oil))
return false;
if (pim_if_connected_to_source(up->rpf.source_nexthop.interface,