pim6d: IPv6-adjust assert-related addrs

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2022-01-14 19:53:55 +01:00
parent da6bed2bbe
commit efd66f7bad
4 changed files with 22 additions and 40 deletions

View File

@ -87,14 +87,10 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,
} }
} }
static void on_trace(const char *label, struct interface *ifp, static void on_trace(const char *label, struct interface *ifp, pim_addr src)
struct in_addr src)
{ {
if (PIM_DEBUG_PIM_TRACE) { if (PIM_DEBUG_PIM_TRACE)
char src_str[INET_ADDRSTRLEN]; zlog_debug("%s: from %pPAs on %s", label, &src, ifp->name);
pim_inet4_dump("<src?>", src, src_str, sizeof(src_str));
zlog_debug("%s: from %s on %s", label, src_str, ifp->name);
}
} }
static int preferred_assert(const struct pim_ifchannel *ch, static int preferred_assert(const struct pim_ifchannel *ch,
@ -213,7 +209,7 @@ static int dispatch_assert(struct interface *ifp, pim_addr source_addr,
} }
int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh, int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
struct in_addr src_addr, uint8_t *buf, int buf_size) pim_addr src_addr, uint8_t *buf, int buf_size)
{ {
pim_sgaddr sg; pim_sgaddr sg;
pim_addr msg_source_addr; pim_addr msg_source_addr;
@ -235,10 +231,9 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
memset(&sg, 0, sizeof(sg)); memset(&sg, 0, sizeof(sg));
offset = pim_parse_addr_group(&sg, curr, curr_size); offset = pim_parse_addr_group(&sg, curr, curr_size);
if (offset < 1) { if (offset < 1) {
char src_str[INET_ADDRSTRLEN]; zlog_warn(
pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str)); "%s: pim_parse_addr_group() failure: from %pPAs on %s",
zlog_warn("%s: pim_parse_addr_group() failure: from %s on %s", __func__, &src_addr, ifp->name);
__func__, src_str, ifp->name);
return -1; return -1;
} }
curr += offset; curr += offset;
@ -250,21 +245,18 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
offset = pim_parse_addr_ucast(&msg_source_addr, curr, curr_size, offset = pim_parse_addr_ucast(&msg_source_addr, curr, curr_size,
&wrong_af); &wrong_af);
if (offset < 1 || wrong_af) { if (offset < 1 || wrong_af) {
char src_str[INET_ADDRSTRLEN]; zlog_warn(
pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str)); "%s: pim_parse_addr_ucast() failure: from %pPAs on %s",
zlog_warn("%s: pim_parse_addr_ucast() failure: from %s on %s", __func__, &src_addr, ifp->name);
__func__, src_str, ifp->name);
return -2; return -2;
} }
curr += offset; curr += offset;
curr_size -= offset; curr_size -= offset;
if (curr_size < 8) { if (curr_size < 8) {
char src_str[INET_ADDRSTRLEN];
pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
zlog_warn( zlog_warn(
"%s: preference/metric size is less than 8 bytes: size=%d from %s on interface %s", "%s: preference/metric size is less than 8 bytes: size=%d from %pPAs on interface %s",
__func__, curr_size, src_str, ifp->name); __func__, curr_size, &src_addr, ifp->name);
return -3; return -3;
} }
@ -286,17 +278,13 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
msg_metric.route_metric = pim_read_uint32_host(curr); msg_metric.route_metric = pim_read_uint32_host(curr);
if (PIM_DEBUG_PIM_TRACE) { if (PIM_DEBUG_PIM_TRACE)
char neigh_str[INET_ADDRSTRLEN];
pim_inet4_dump("<neigh?>", src_addr, neigh_str,
sizeof(neigh_str));
zlog_debug( zlog_debug(
"%s: from %s on %s: (S,G)=(%pPAs,%pPAs) pref=%u metric=%u rpt_bit=%u", "%s: from %pPAs on %s: (S,G)=(%pPAs,%pPAs) pref=%u metric=%u rpt_bit=%u",
__func__, neigh_str, ifp->name, &msg_source_addr, __func__, &src_addr, ifp->name, &msg_source_addr,
&sg.grp, msg_metric.metric_preference, &sg.grp, msg_metric.metric_preference,
msg_metric.route_metric, msg_metric.route_metric,
PIM_FORCE_BOOLEAN(msg_metric.rpt_bit_flag)); PIM_FORCE_BOOLEAN(msg_metric.rpt_bit_flag));
}
msg_metric.ip_address = src_addr; msg_metric.ip_address = src_addr;

View File

@ -59,7 +59,7 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch,
struct pim_assert_metric winner_metric); struct pim_assert_metric winner_metric);
int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh, int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
struct in_addr src_addr, uint8_t *buf, int buf_size); pim_addr src_addr, uint8_t *buf, int buf_size);
int pim_assert_metric_better(const struct pim_assert_metric *m1, int pim_assert_metric_better(const struct pim_assert_metric *m1,
const struct pim_assert_metric *m2); const struct pim_assert_metric *m2);

View File

@ -1363,23 +1363,17 @@ void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch)
if (pim_assert_metric_match(&my_metric_new, &ch->ifassert_my_metric)) if (pim_assert_metric_match(&my_metric_new, &ch->ifassert_my_metric))
return; return;
if (PIM_DEBUG_PIM_EVENTS) { if (PIM_DEBUG_PIM_EVENTS)
char old_addr_str[INET_ADDRSTRLEN];
char new_addr_str[INET_ADDRSTRLEN];
pim_inet4_dump("<old_addr?>", ch->ifassert_my_metric.ip_address,
old_addr_str, sizeof(old_addr_str));
pim_inet4_dump("<new_addr?>", my_metric_new.ip_address,
new_addr_str, sizeof(new_addr_str));
zlog_debug( zlog_debug(
"%s: my_assert_metric(%pPAs,%pPAs,%s) changed from %u,%u,%u,%s to %u,%u,%u,%s", "%s: my_assert_metric(%pPAs,%pPAs,%s) changed from %u,%u,%u,%pPAs to %u,%u,%u,%pPAs",
__func__, &ch->sg.src, &ch->sg.grp, ch->interface->name, __func__, &ch->sg.src, &ch->sg.grp, ch->interface->name,
ch->ifassert_my_metric.rpt_bit_flag, ch->ifassert_my_metric.rpt_bit_flag,
ch->ifassert_my_metric.metric_preference, ch->ifassert_my_metric.metric_preference,
ch->ifassert_my_metric.route_metric, old_addr_str, ch->ifassert_my_metric.route_metric,
&ch->ifassert_my_metric.ip_address,
my_metric_new.rpt_bit_flag, my_metric_new.rpt_bit_flag,
my_metric_new.metric_preference, my_metric_new.metric_preference,
my_metric_new.route_metric, new_addr_str); my_metric_new.route_metric, &my_metric_new.ip_address);
}
ch->ifassert_my_metric = my_metric_new; ch->ifassert_my_metric = my_metric_new;

View File

@ -103,7 +103,7 @@ void pim_router_init(void)
PIM_ASSERT_METRIC_PREFERENCE_MAX; PIM_ASSERT_METRIC_PREFERENCE_MAX;
router->infinite_assert_metric.route_metric = router->infinite_assert_metric.route_metric =
PIM_ASSERT_ROUTE_METRIC_MAX; PIM_ASSERT_ROUTE_METRIC_MAX;
router->infinite_assert_metric.ip_address.s_addr = INADDR_ANY; router->infinite_assert_metric.ip_address = PIMADDR_ANY;
router->rpf_cache_refresh_delay_msec = 50; router->rpf_cache_refresh_delay_msec = 50;
router->register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT; router->register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;
router->packet_process = PIM_DEFAULT_PACKET_PROCESS; router->packet_process = PIM_DEFAULT_PACKET_PROCESS;