From d588b995f938a5c2b81e2763b8b0cfc4a8659e0f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 15 Mar 2021 10:56:08 -0400 Subject: [PATCH 1/2] bgpd: use appropriate printf formatter for some uint32_t newm and existm are uint32_t so let's use %u instead of %d to print them out. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 9165dcc1d7..87fd5f28ca 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -995,7 +995,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, if (newm < existm) { if (debug) zlog_debug( - "%s: %s wins over %s due to IGP metric %d < %d", + "%s: %s wins over %s due to IGP metric %u < %u", pfx_buf, new_buf, exist_buf, newm, existm); ret = 1; } @@ -1003,7 +1003,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, if (newm > existm) { if (debug) zlog_debug( - "%s: %s loses to %s due to IGP metric %d > %d", + "%s: %s loses to %s due to IGP metric %u > %u", pfx_buf, new_buf, exist_buf, newm, existm); ret = 0; } @@ -1025,7 +1025,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, if (newm < existm) { if (debug) zlog_debug( - "%s: %s wins over %s due to CLUSTER_LIST length %d < %d", + "%s: %s wins over %s due to CLUSTER_LIST length %u < %u", pfx_buf, new_buf, exist_buf, newm, existm); ret = 1; @@ -1034,7 +1034,7 @@ static int bgp_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new, if (newm > existm) { if (debug) zlog_debug( - "%s: %s loses to %s due to CLUSTER_LIST length %d > %d", + "%s: %s loses to %s due to CLUSTER_LIST length %u > %u", pfx_buf, new_buf, exist_buf, newm, existm); ret = 0; From 531d4171c7c1cc3b490f78ce208267a32b5a8cbe Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 15 Mar 2021 11:12:38 -0400 Subject: [PATCH 2/2] pimd: Fix clang issue with -Waddress-of-packed-member Recent change in commit: 6b73800ba27e7f69453a191dfb873c2e07194516 Caused this error to pop up in pim_igmp_mtrace.c: error: taking address of packed member 'rsp_addr' of class or structure 'igmp_mtrace' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] Follow the pattern used in the code to solve this problem for clang Signed-off-by: Donald Sharp --- pimd/pim_igmp_mtrace.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c index 5223fcf311..d36a275f85 100644 --- a/pimd/pim_igmp_mtrace.c +++ b/pimd/pim_igmp_mtrace.c @@ -192,11 +192,14 @@ static void mtrace_rsp_init(struct igmp_mtrace_rsp *mtrace_rspp) static void mtrace_rsp_debug(uint32_t qry_id, int rsp, struct igmp_mtrace_rsp *mrspp) { + struct in_addr incoming = mrspp->incoming; + struct in_addr outgoing = mrspp->outgoing; + struct in_addr prev_hop = mrspp->prev_hop; + zlog_debug( "Rx mt(%d) qid=%ud arr=%x in=%pI4 out=%pI4 prev=%pI4 proto=%d fwd=%d", - rsp, ntohl(qry_id), mrspp->arrival, &mrspp->incoming, - &mrspp->outgoing, &mrspp->prev_hop, mrspp->rtg_proto, - mrspp->fwd_code); + rsp, ntohl(qry_id), mrspp->arrival, &incoming, &outgoing, + &prev_hop, mrspp->rtg_proto, mrspp->fwd_code); } static void mtrace_debug(struct pim_interface *pim_ifp, @@ -269,10 +272,11 @@ static int mtrace_send_packet(struct interface *ifp, if (PIM_DEBUG_MTRACE) { struct in_addr if_addr; + struct in_addr rsp_addr = mtracep->rsp_addr; if_addr = mtrace_primary_address(ifp); - zlog_debug("Sending mtrace packet to %pI4 on %pI4", - &mtracep->rsp_addr, &if_addr); + zlog_debug("Sending mtrace packet to %pI4 on %pI4", &rsp_addr, + &if_addr); } fd = pim_socket_raw(IPPROTO_IGMP); @@ -487,9 +491,11 @@ static int mtrace_send_mc_response(struct pim_instance *pim, if (c_oil == NULL) { if (PIM_DEBUG_MTRACE) { + struct in_addr rsp_addr = mtracep->rsp_addr; + zlog_debug( "Dropping mtrace multicast response packet len=%u to %pI4", - (unsigned int)mtrace_len, &mtracep->rsp_addr); + (unsigned int)mtrace_len, &rsp_addr); } return -1; } @@ -532,9 +538,11 @@ static int mtrace_send_response(struct pim_instance *pim, p_rpf = pim_rp_g(pim, mtracep->rsp_addr); if (p_rpf == NULL) { - if (PIM_DEBUG_MTRACE) - zlog_debug("mtrace no RP for %pI4", - &mtracep->rsp_addr); + if (PIM_DEBUG_MTRACE) { + struct in_addr rsp_addr = mtracep->rsp_addr; + + zlog_debug("mtrace no RP for %pI4", &rsp_addr); + } return -1; } nexthop = p_rpf->source_nexthop;