From 4d99418beb40898c043efb77543ff19228cee211 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 24 Jul 2016 01:15:09 -0400 Subject: [PATCH] pimd: Find the parent on newly created upstream's When we create a new upstream data structure find the parent. Signed-off-by: Donald Sharp --- pimd/pim_upstream.c | 31 +++++++++++++++++++++++++++++++ pimd/pim_upstream.h | 1 + 2 files changed, 32 insertions(+) diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 7d20de6bda..b404e144e8 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -50,6 +50,36 @@ static void join_timer_start(struct pim_upstream *up); static void pim_upstream_update_assert_tracking_desired(struct pim_upstream *up); +/* + * If we have a (*,*) || (S,*) there is no parent + * If we have a (S,G), find the (*,G) + * If we have a (*,G), find the (*,*) + */ +static struct pim_upstream * +pim_upstream_find_parent (struct prefix *sg) +{ + struct prefix any = *sg; + + // (*,*) || (S,*) + if (((sg->u.sg.src.s_addr == INADDR_ANY) && + (sg->u.sg.grp.s_addr == INADDR_ANY)) || + ((sg->u.sg.src.s_addr != INADDR_ANY) && + (sg->u.sg.grp.s_addr == INADDR_ANY))) + return NULL; + + // (S,G) + if ((sg->u.sg.src.s_addr != INADDR_ANY) && + (sg->u.sg.grp.s_addr != INADDR_ANY)) + { + any.u.sg.src.s_addr = INADDR_ANY; + return pim_upstream_find (&any); + } + + // (*,G) + any.u.sg.grp.s_addr = INADDR_ANY; + return pim_upstream_find (&any); +} + void pim_upstream_free(struct pim_upstream *up) { XFREE(MTYPE_PIM_UPSTREAM, up); @@ -347,6 +377,7 @@ static struct pim_upstream *pim_upstream_new(struct prefix *sg, return NULL; } + up->parent = pim_upstream_find_parent (sg); up->flags = 0; up->ref_count = 1; up->t_join_timer = NULL; diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index 2fb193d42d..92535c46b0 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -87,6 +87,7 @@ enum pim_upstream_sptbit { See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message */ struct pim_upstream { + struct pim_upstream *parent; int fhr; struct in_addr upstream_addr;/* Who we are talking to */ struct prefix sg; /* (S,G) group key */ -- 2.39.5