return 0;
}
+#if PIM_IPV == 4
static const char *const igmpmsgtype2str[IGMPMSG_WRVIFWHOLE + 1] = {
"<unknown_upcall?>", "NOCACHE", "WRONGVIF", "WHOLEPKT", "WRVIFWHOLE"};
* the Interface type is SSM we don't need to
* do anything here
*/
- if (!rpg || pim_rpf_addr_is_inaddr_none(rpg)) {
+ if (!rpg || pim_rpf_addr_is_inaddr_any(rpg)) {
if (PIM_DEBUG_MROUTE_DETAIL)
zlog_debug(
"%s: Interface is not configured correctly to handle incoming packet: Could be !pim_ifp, !SM, !RP",
if (!(PIM_I_am_DR(pim_ifp))) {
if (PIM_DEBUG_MROUTE_DETAIL)
- zlog_debug(
- "%s: Interface is not the DR blackholing incoming traffic for %s",
- __func__, pim_str_sg_dump(&sg));
+ zlog_debug("%s: Interface is not the DR blackholing incoming traffic for %pSG",
+ __func__, &sg);
/*
* We are not the DR, but we are still receiving packets
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);
up = pim_upstream_find(pim_ifp->pim, &sg);
if (!up) {
pim_sgaddr star = sg;
- star.src.s_addr = INADDR_ANY;
+ star.src = PIMADDR_ANY;
up = pim_upstream_find(pim_ifp->pim, &star);
__func__, NULL);
if (!up) {
if (PIM_DEBUG_MROUTE)
- zlog_debug(
- "%s: Unable to create upstream information for %s",
- __func__, pim_str_sg_dump(&sg));
+ zlog_debug("%s: Unable to create upstream information for %pSG",
+ __func__, &sg);
return 0;
}
pim_upstream_keep_alive_timer_start(
return 0;
}
if (PIM_DEBUG_MROUTE_DETAIL) {
- zlog_debug(
- "%s: Unable to find upstream channel WHOLEPKT%s",
- __func__, pim_str_sg_dump(&sg));
+ zlog_debug("%s: Unable to find upstream channel WHOLEPKT%pSG",
+ __func__, &sg);
}
return 0;
}
rpg = pim_ifp ? RP(pim_ifp->pim, sg.grp) : NULL;
- if ((pim_rpf_addr_is_inaddr_none(rpg)) || (!pim_ifp)
- || (!(PIM_I_am_DR(pim_ifp)))) {
+ if ((pim_rpf_addr_is_inaddr_any(rpg)) || (!pim_ifp) ||
+ (!(PIM_I_am_DR(pim_ifp)))) {
if (PIM_DEBUG_MROUTE) {
zlog_debug("%s: Failed Check send packet", __func__);
}
if (!up->t_rs_timer) {
if (pim_is_grp_ssm(pim_ifp->pim, sg.grp)) {
if (PIM_DEBUG_PIM_REG)
- zlog_debug(
- "%s register forward skipped as group is SSM",
- pim_str_sg_dump(&sg));
+ zlog_debug("%pSG register forward skipped as group is SSM",
+ &sg);
return 0;
}
if (!ifp) {
if (PIM_DEBUG_MROUTE)
- zlog_debug(
- "%s: WRONGVIF (S,G)=%s could not find input interface for input_vif_index=%d",
- __func__, pim_str_sg_dump(&sg), msg->im_vif);
+ zlog_debug("%s: WRONGVIF (S,G)=%pSG could not find input interface for input_vif_index=%d",
+ __func__, &sg, msg->im_vif);
return -1;
}
pim_ifp = ifp->info;
if (!pim_ifp) {
if (PIM_DEBUG_MROUTE)
- zlog_debug(
- "%s: WRONGVIF (S,G)=%s multicast not enabled on interface %s",
- __func__, pim_str_sg_dump(&sg), ifp->name);
+ zlog_debug("%s: WRONGVIF (S,G)=%pSG multicast not enabled on interface %s",
+ __func__, &sg, ifp->name);
return -2;
}
if (!ch) {
pim_sgaddr star_g = sg;
if (PIM_DEBUG_MROUTE)
- zlog_debug(
- "%s: WRONGVIF (S,G)=%s could not find channel on interface %s",
- __func__, pim_str_sg_dump(&sg), ifp->name);
+ zlog_debug("%s: WRONGVIF (S,G)=%pSG could not find channel on interface %s",
+ __func__, &sg, ifp->name);
- star_g.src.s_addr = INADDR_ANY;
+ star_g.src = PIMADDR_ANY;
ch = pim_ifchannel_find(ifp, &star_g);
if (!ch) {
if (PIM_DEBUG_MROUTE)
- zlog_debug(
- "%s: WRONGVIF (*,G)=%s could not find channel on interface %s",
- __func__, pim_str_sg_dump(&star_g),
- ifp->name);
+ zlog_debug("%s: WRONGVIF (*,G)=%pSG could not find channel on interface %s",
+ __func__, &star_g,
+ ifp->name);
return -3;
}
}
}
star_g = sg;
- star_g.src.s_addr = INADDR_ANY;
+ star_g.src = PIMADDR_ANY;
pim = pim_ifp->pim;
/*
NULL);
if (!up) {
if (PIM_DEBUG_MROUTE)
- zlog_debug(
- "%s: WRONGVIF%s unable to create upstream on interface",
- pim_str_sg_dump(&sg), ifp->name);
+ zlog_debug("%pSG: WRONGVIF%s unable to create upstream on interface",
+ &sg, ifp->name);
return -2;
}
PIM_UPSTREAM_FLAG_SET_SRC_STREAM(up->flags);
int buf_size, ifindex_t ifindex)
{
struct interface *ifp;
- struct pim_interface *pim_ifp;
const struct ip *ip_hdr;
const struct igmpmsg *msg;
- struct in_addr ifaddr;
- struct gm_sock *igmp;
- const struct prefix *connected_src;
if (buf_size < (int)sizeof(struct ip))
return 0;
ip_hdr = (const struct ip *)buf;
if (ip_hdr->ip_p == IPPROTO_IGMP) {
+#if PIM_IPV == 4
+ struct pim_interface *pim_ifp;
+ struct in_addr ifaddr;
+ struct gm_sock *igmp;
+ const struct prefix *connected_src;
/* We have the IP packet but we do not know which interface this
* packet was
zlog_debug("No IGMP socket on interface: %s with connected source: %pFX",
ifp->name, connected_src);
}
+#endif
} else if (ip_hdr->ip_p) {
if (PIM_DEBUG_MROUTE_DETAIL) {
zlog_debug(
return 0;
}
+#else /* PIM_IPV != 4 */
-static int mroute_read(struct thread *t)
+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 void mroute_read(struct thread *t)
{
struct pim_instance *pim;
static long long count;
char buf[10000];
- int result = 0;
int cont = 1;
int rd;
ifindex_t ifindex;
goto done;
}
- result = pim_mroute_msg(pim, buf, rd, ifindex);
+ pim_mroute_msg(pim, buf, rd, ifindex);
count++;
if (count % router->packet_process == 0)
/* Keep reading */
done:
mroute_read_on(pim);
-
- return result;
}
static void mroute_read_on(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;
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;
}
#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));
}
}
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();
/* 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);
}
/*
* 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) {
{
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(
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);
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);
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
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;
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;
if (PIM_DEBUG_MROUTE) {
pim_sgaddr sg;
- sg.src = c_oil->oil.mfcc_origin;
- sg.grp = c_oil->oil.mfcc_mcastgrp;
- zlog_debug(
- "Channel%s is not installed no need to collect data from kernel",
- pim_str_sg_dump(&sg));
+ 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)=%s: errno=%d: %s",
- (unsigned long)SIOCGETSGCNT, pim_str_sg_dump(&sg),
+ zlog_warn("ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=%pSG: errno=%d: %s",
+ (unsigned long)SIOCGETSGCNT, &sg,
errno, safe_strerror(errno));
return;
}
c_oil->cc.pktcnt = sgreq.pktcnt;
c_oil->cc.bytecnt = sgreq.bytecnt;
c_oil->cc.wrong_if = sgreq.wrong_if;
-
+#endif
return;
}