struct pim_assert_metric recv_metric)
{
struct pim_ifchannel *ch;
+ struct prefix sg;
- ch = pim_ifchannel_add(ifp, source_addr, group_addr);
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source_addr;
+ sg.u.sg.grp = group_addr;
+ ch = pim_ifchannel_add(ifp, &sg);
if (!ch) {
- char source_str[100];
- char group_str[100];
- pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
- pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
- zlog_warn("%s: (S,G)=(%s,%s) failure creating channel on interface %s",
+ zlog_warn("%s: (S,G)=%s failure creating channel on interface %s",
__PRETTY_FUNCTION__,
- source_str, group_str, ifp->name);
+ pim_str_sg_dump (&sg), ifp->name);
return -1;
}
break;
default:
{
- char source_str[100];
- char group_str[100];
- pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
- pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
- zlog_warn("%s: (S,G)=(%s,%s) invalid assert state %d on interface %s",
+ zlog_warn("%s: (S,G)=%s invalid assert state %d on interface %s",
__PRETTY_FUNCTION__,
- source_str, group_str, ch->ifassert_state, ifp->name);
+ pim_str_sg_dump (&sg), ch->ifassert_state, ifp->name);
}
return -2;
}
}
struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,
- struct in_addr source_addr,
- struct in_addr group_addr)
+ struct prefix *sg)
{
struct pim_interface *pim_ifp;
struct listnode *ch_node;
pim_ifp = ifp->info;
if (!pim_ifp) {
- char src_str[100];
- char grp_str[100];
- pim_inet4_dump("<src?>", source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", group_addr, grp_str, sizeof(grp_str));
- zlog_warn("%s: (S,G)=(%s,%s): multicast not enabled on interface %s",
+ zlog_warn("%s: (S,G)=%s: multicast not enabled on interface %s",
__PRETTY_FUNCTION__,
- src_str, grp_str,
+ pim_str_sg_dump (sg),
ifp->name);
return 0;
}
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
if (
- (source_addr.s_addr == ch->sg.u.sg.src.s_addr) &&
- (group_addr.s_addr == ch->sg.u.sg.grp.s_addr)
+ (sg->u.sg.src.s_addr == ch->sg.u.sg.src.s_addr) &&
+ (sg->u.sg.grp.s_addr == ch->sg.u.sg.grp.s_addr)
) {
return ch;
}
}
struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
- struct in_addr source_addr,
- struct in_addr group_addr)
+ struct prefix *sg)
{
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
struct pim_upstream *up;
- char src_str[100];
- char grp_str[100];
- ch = pim_ifchannel_find(ifp, source_addr, group_addr);
+ ch = pim_ifchannel_find(ifp, sg);
if (ch)
return ch;
pim_ifp = ifp->info;
zassert(pim_ifp);
- up = pim_upstream_add(source_addr, group_addr, NULL);
+ up = pim_upstream_add(sg, NULL);
if (!up) {
- char src_str[100];
- char grp_str[100];
- pim_inet4_dump("<src?>", source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", group_addr, grp_str, sizeof(grp_str));
- zlog_err("%s: could not attach upstream (S,G)=(%s,%s) on interface %s",
+ zlog_err("%s: could not attach upstream (S,G)=%s on interface %s",
__PRETTY_FUNCTION__,
- src_str, grp_str, ifp->name);
+ pim_str_sg_dump (sg), ifp->name);
return NULL;
}
ch = XMALLOC(MTYPE_PIM_IFCHANNEL, sizeof(*ch));
if (!ch) {
- pim_inet4_dump("<src?>", source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", group_addr, grp_str, sizeof(grp_str));
- zlog_warn("%s: pim_ifchannel_new() failure for (S,G)=(%s,%s) on interface %s",
+ zlog_warn("%s: pim_ifchannel_new() failure for (S,G)=%s on interface %s",
__PRETTY_FUNCTION__,
- src_str, grp_str, ifp->name);
+ pim_str_sg_dump (sg), ifp->name);
return NULL;
}
ch->flags = 0;
ch->upstream = up;
ch->interface = ifp;
- ch->sg.u.sg.src = source_addr;
- ch->sg.u.sg.grp = group_addr;
+ ch->sg = *sg;
ch->local_ifmembership = PIM_IFMEMBERSHIP_NOINFO;
ch->ifjoin_state = PIM_IFJOIN_NOINFO;
int holdtime)
{
struct pim_upstream *up;
+ struct prefix sg;
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source_addr;
+ sg.u.sg.grp = group_addr;
/* Upstream (S,G) in Joined state ? */
- up = pim_upstream_find(source_addr, group_addr);
+ up = pim_upstream_find(&sg);
if (!up)
return;
if (up->join_state != PIM_UPSTREAM_JOINED)
{
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
+ struct prefix sg;
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source_addr;
+ sg.u.sg.grp = group_addr;
if (nonlocal_upstream(1 /* join */, ifp, upstream,
source_addr, group_addr, source_flags, holdtime)) {
return;
}
- ch = pim_ifchannel_add(ifp, source_addr, group_addr);
+ ch = pim_ifchannel_add(ifp, &sg);
if (!ch)
return;
address of the join message is our primary address.
*/
if (ch->ifassert_state == PIM_IFASSERT_I_AM_LOSER) {
- char src_str[100];
- char grp_str[100];
char neigh_str[100];
- pim_inet4_dump("<src?>", source_addr, src_str, sizeof(src_str));
- pim_inet4_dump("<grp?>", group_addr, grp_str, sizeof(grp_str));
pim_inet4_dump("<neigh?>", neigh_addr, neigh_str, sizeof(neigh_str));
- zlog_warn("%s: Assert Loser recv Join(%s,%s) from %s on %s",
+ zlog_warn("%s: Assert Loser recv Join%s from %s on %s",
__PRETTY_FUNCTION__,
- src_str, grp_str, neigh_str, ifp->name);
+ pim_str_sg_dump (&sg), neigh_str, ifp->name);
assert_action_a5(ch);
}
{
struct pim_ifchannel *ch;
int jp_override_interval_msec;
+ struct prefix sg;
+
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source_addr;
+ sg.u.sg.grp = group_addr;
if (nonlocal_upstream(0 /* prune */, ifp, upstream,
source_addr, group_addr, source_flags, holdtime)) {
return;
}
- ch = pim_ifchannel_add(ifp, source_addr, group_addr);
+ ch = pim_ifchannel_add(ifp, &sg);
if (!ch)
return;
{
struct pim_ifchannel *ch;
struct pim_interface *pim_ifp;
+ struct prefix sg;
+
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source_addr;
+ sg.u.sg.grp = group_addr;
/* PIM enabled on interface? */
pim_ifp = ifp->info;
if (!PIM_IF_TEST_PIM(pim_ifp->options))
return;
- ch = pim_ifchannel_add(ifp, source_addr, group_addr);
+ ch = pim_ifchannel_add(ifp, &sg);
if (!ch) {
return;
}
{
struct pim_ifchannel *ch;
struct pim_interface *pim_ifp;
+ struct prefix sg;
+
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source_addr;
+ sg.u.sg.grp = group_addr;
/* PIM enabled on interface? */
pim_ifp = ifp->info;
if (!PIM_IF_TEST_PIM(pim_ifp->options))
return;
- ch = pim_ifchannel_find(ifp, source_addr, group_addr);
+ ch = pim_ifchannel_find(ifp, &sg);
if (!ch)
return;
void pim_ifchannel_membership_clear(struct interface *ifp);
void pim_ifchannel_delete_on_noinfo(struct interface *ifp);
struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp,
- struct in_addr source_addr,
- struct in_addr group_addr);
+ struct prefix *sg);
struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
- struct in_addr source_addr,
- struct in_addr group_addr);
+ struct prefix *sg);
void pim_ifchannel_join_add(struct interface *ifp,
struct in_addr neigh_addr,
struct in_addr upstream,
__PRETTY_FUNCTION__, grp_str, src_str);
}
+ memset (&sg, 0, sizeof (struct prefix));
sg.u.sg.src = msg->im_src;
sg.u.sg.grp = msg->im_dst;
- up = pim_upstream_add(msg->im_src, msg->im_dst, ifp);
+ up = pim_upstream_add (&sg, ifp);
if (!up) {
if (PIM_DEBUG_PIM_TRACE) {
- zlog_debug("%s: Failure to add upstream information for (%s,%s)",
+ zlog_debug("%s: Failure to add upstream information for %s",
__PRETTY_FUNCTION__,
- src_str, grp_str);
+ pim_str_sg_dump (&sg));
}
return 0;
}
}
up->channel_oil->cc.pktcnt++;
up->fhr = 1;
- ch = pim_ifchannel_add (pim_regiface, msg->im_src, msg->im_dst);
+ ch = pim_ifchannel_add (pim_regiface, &sg);
pim_ifchannel_ifjoin_switch (__PRETTY_FUNCTION__, ch, PIM_IFJOIN_JOIN_PIMREG);
up->join_state = PIM_UPSTREAM_JOINED;
const char *src_str, const char *grp_str)
{
struct pim_interface *pim_ifp;
- struct in_addr group;
- struct in_addr src;
+ struct prefix sg;
struct pim_rpf *rpg;
const struct ip *ip_hdr;
struct pim_upstream *up;
ip_hdr = (const struct ip *)buf;
- src = ip_hdr->ip_src;
- group = ip_hdr->ip_dst;
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = ip_hdr->ip_src;
+ sg.u.sg.grp = ip_hdr->ip_dst;
- up = pim_upstream_find(src, group);
+ up = pim_upstream_find(&sg);
if (!up) {
if (PIM_DEBUG_PIM_TRACE) {
- zlog_debug("%s: Unable to find upstream channel WHOLEPKT(%s,%s)",
- __PRETTY_FUNCTION__, src_str, grp_str);
+ zlog_debug("%s: Unable to find upstream channel WHOLEPKT%s",
+ __PRETTY_FUNCTION__, pim_str_sg_dump (&sg));
}
return 0;
}
pim_ifp = up->rpf.source_nexthop.interface->info;
- rpg = RP(group);
+ rpg = RP(sg.u.sg.grp);
if ((rpg->rpf_addr.s_addr == INADDR_NONE) ||
(!pim_ifp) ||
{
struct pim_ifchannel *ch;
struct pim_interface *pim_ifp;
+ struct prefix sg;
/*
Send Assert(S,G) on iif as response to WRONGVIF kernel upcall.
return -2;
}
- ch = pim_ifchannel_find(ifp, msg->im_src, msg->im_dst);
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = msg->im_src;
+ sg.u.sg.grp = msg->im_dst;
+ ch = pim_ifchannel_find(ifp, &sg);
if (!ch) {
if (PIM_DEBUG_PIM_TRACE) {
zlog_debug("%s: WRONGVIF (S,G)=(%s,%s) could not find channel on interface %s",
struct pim_upstream *upstream = NULL;
struct prefix source;
struct prefix group;
+ struct prefix sg;
int l;
if (PIM_DEBUG_PIM_PACKETDUMP_RECV)
buf += l;
buf_size -= l;
l = pim_parse_addr_ucast (&source, buf, buf_size);
- upstream = pim_upstream_find (source.u.prefix4, group.u.prefix4);
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source.u.prefix4;
+ sg.u.sg.grp = group.u.prefix4;
+ upstream = pim_upstream_find (&sg);
if (!upstream)
{
return 0;
{
int sentRegisterStop = 0;
struct ip *ip_hdr;
- //size_t hlen;
struct in_addr group = { .s_addr = 0 };
struct in_addr source = { .s_addr = 0 };
- //uint8_t *msg;
+ struct prefix sg;
uint32_t *bits;
if (!pim_check_is_my_ip_address (dest_addr)) {
}
}
- struct pim_upstream *upstream = pim_upstream_find (source, group);
+ memset (&sg, 0, sizeof (struct prefix));
+ sg.u.sg.src = source;
+ sg.u.sg.grp = group;
+ struct pim_upstream *upstream = pim_upstream_find (&sg);
/*
* If we don't have a place to send ignore the packet
*/
if (!upstream)
{
- upstream = pim_upstream_add (source, group, ifp);
+ upstream = pim_upstream_add (&sg, ifp);
pim_upstream_switch (upstream, PIM_UPSTREAM_PRUNE);
}
}
rpf_ch = pim_ifchannel_find(up->rpf.source_nexthop.interface,
- up->sg.u.sg.src, up->sg.u.sg.grp);
+ &up->sg);
if (rpf_ch) {
if (rpf_ch->ifassert_state == PIM_IFASSERT_I_AM_LOSER) {
return rpf_ch->ifassert_winner;
}
}
-static struct pim_upstream *pim_upstream_new(struct in_addr source_addr,
- struct in_addr group_addr,
+static struct pim_upstream *pim_upstream_new(struct prefix *sg,
struct interface *incoming)
{
struct pim_upstream *up;
return NULL;
}
- up->sg.u.sg.src = source_addr;
- if (!pim_rp_set_upstream_addr (&up->upstream_addr, source_addr))
+ up->sg = *sg;
+ if (!pim_rp_set_upstream_addr (&up->upstream_addr, sg->u.sg.src))
{
if (PIM_DEBUG_PIM_TRACE)
zlog_debug("%s: Received a (*,G) with no RP configured", __PRETTY_FUNCTION__);
return NULL;
}
- up->sg.u.sg.grp = group_addr;
up->flags = 0;
up->ref_count = 1;
up->t_join_timer = NULL;
return up;
}
-struct pim_upstream *pim_upstream_find(struct in_addr source_addr,
- struct in_addr group_addr)
+struct pim_upstream *pim_upstream_find(struct prefix *sg)
{
struct listnode *up_node;
struct pim_upstream *up;
for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
- if (group_addr.s_addr == up->sg.u.sg.grp.s_addr) {
+ if (sg->u.sg.grp.s_addr == up->sg.u.sg.grp.s_addr) {
if ((up->sg.u.sg.src.s_addr == INADDR_ANY) ||
- (source_addr.s_addr == up->sg.u.sg.src.s_addr)) {
+ (sg->u.sg.src.s_addr == up->sg.u.sg.src.s_addr)) {
return up;
}
}
return NULL;
}
-struct pim_upstream *pim_upstream_add(struct in_addr source_addr,
- struct in_addr group_addr,
+struct pim_upstream *pim_upstream_add(struct prefix *sg,
struct interface *incoming)
{
struct pim_upstream *up;
- up = pim_upstream_find(source_addr, group_addr);
+ up = pim_upstream_find(sg);
if (up) {
++up->ref_count;
}
else {
- up = pim_upstream_new(source_addr, group_addr, incoming);
+ up = pim_upstream_new(sg, incoming);
}
return up;
struct pim_upstream {
int fhr;
struct in_addr upstream_addr;/* Who we are talking to */
- struct prefix sg;
- //struct in_addr source_addr; /* (S,G) source key */
- //struct in_addr group_addr; /* (S,G) group key */
+ struct prefix sg; /* (S,G) group key */
uint32_t flags;
struct channel_oil *channel_oil;
void pim_upstream_free(struct pim_upstream *up);
void pim_upstream_delete(struct pim_upstream *up);
-struct pim_upstream *pim_upstream_find(struct in_addr source_addr,
- struct in_addr group_addr);
-struct pim_upstream *pim_upstream_add(struct in_addr source_addr,
- struct in_addr group_addr,
+struct pim_upstream *pim_upstream_find (struct prefix *sg);
+struct pim_upstream *pim_upstream_add (struct prefix *sg,
struct interface *ifp);
void pim_upstream_del(struct pim_upstream *up);