From efd66f7bad62cbeb7c5987bf834099920a27813a Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 14 Jan 2022 19:53:55 +0100 Subject: [PATCH] pim6d: IPv6-adjust assert-related addrs Signed-off-by: David Lamparter --- pimd/pim_assert.c | 42 +++++++++++++++--------------------------- pimd/pim_assert.h | 2 +- pimd/pim_ifchannel.c | 16 +++++----------- pimd/pimd.c | 2 +- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index 7d2ebffab1..56d3a79b71 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -87,14 +87,10 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch, } } -static void on_trace(const char *label, struct interface *ifp, - struct in_addr src) +static void on_trace(const char *label, struct interface *ifp, pim_addr src) { - if (PIM_DEBUG_PIM_TRACE) { - char src_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", src, src_str, sizeof(src_str)); - zlog_debug("%s: from %s on %s", label, src_str, ifp->name); - } + if (PIM_DEBUG_PIM_TRACE) + zlog_debug("%s: from %pPAs on %s", label, &src, ifp->name); } 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, - 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_addr msg_source_addr; @@ -235,10 +231,9 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh, memset(&sg, 0, sizeof(sg)); offset = pim_parse_addr_group(&sg, curr, curr_size); if (offset < 1) { - char src_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", src_addr, src_str, sizeof(src_str)); - zlog_warn("%s: pim_parse_addr_group() failure: from %s on %s", - __func__, src_str, ifp->name); + zlog_warn( + "%s: pim_parse_addr_group() failure: from %pPAs on %s", + __func__, &src_addr, ifp->name); return -1; } 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, &wrong_af); if (offset < 1 || wrong_af) { - char src_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", src_addr, src_str, sizeof(src_str)); - zlog_warn("%s: pim_parse_addr_ucast() failure: from %s on %s", - __func__, src_str, ifp->name); + zlog_warn( + "%s: pim_parse_addr_ucast() failure: from %pPAs on %s", + __func__, &src_addr, ifp->name); return -2; } curr += offset; curr_size -= offset; if (curr_size < 8) { - char src_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", src_addr, src_str, sizeof(src_str)); zlog_warn( - "%s: preference/metric size is less than 8 bytes: size=%d from %s on interface %s", - __func__, curr_size, src_str, ifp->name); + "%s: preference/metric size is less than 8 bytes: size=%d from %pPAs on interface %s", + __func__, curr_size, &src_addr, ifp->name); 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); - if (PIM_DEBUG_PIM_TRACE) { - char neigh_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", src_addr, neigh_str, - sizeof(neigh_str)); + if (PIM_DEBUG_PIM_TRACE) zlog_debug( - "%s: from %s on %s: (S,G)=(%pPAs,%pPAs) pref=%u metric=%u rpt_bit=%u", - __func__, neigh_str, ifp->name, &msg_source_addr, + "%s: from %pPAs on %s: (S,G)=(%pPAs,%pPAs) pref=%u metric=%u rpt_bit=%u", + __func__, &src_addr, ifp->name, &msg_source_addr, &sg.grp, msg_metric.metric_preference, msg_metric.route_metric, PIM_FORCE_BOOLEAN(msg_metric.rpt_bit_flag)); - } msg_metric.ip_address = src_addr; diff --git a/pimd/pim_assert.h b/pimd/pim_assert.h index c7c11039af..22bab67c59 100644 --- a/pimd/pim_assert.h +++ b/pimd/pim_assert.h @@ -59,7 +59,7 @@ void pim_ifassert_winner_set(struct pim_ifchannel *ch, struct pim_assert_metric winner_metric); 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, const struct pim_assert_metric *m2); diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index a21277cde3..b26bbcd6d7 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -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)) return; - if (PIM_DEBUG_PIM_EVENTS) { - char old_addr_str[INET_ADDRSTRLEN]; - char new_addr_str[INET_ADDRSTRLEN]; - pim_inet4_dump("", ch->ifassert_my_metric.ip_address, - old_addr_str, sizeof(old_addr_str)); - pim_inet4_dump("", my_metric_new.ip_address, - new_addr_str, sizeof(new_addr_str)); + if (PIM_DEBUG_PIM_EVENTS) 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, ch->ifassert_my_metric.rpt_bit_flag, 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.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; diff --git a/pimd/pimd.c b/pimd/pimd.c index 992bb931bd..16a0c7251c 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -103,7 +103,7 @@ void pim_router_init(void) PIM_ASSERT_METRIC_PREFERENCE_MAX; router->infinite_assert_metric.route_metric = 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->register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT; router->packet_process = PIM_DEFAULT_PACKET_PROCESS; -- 2.39.5