From 5f36c26c5f640a6cf021bd47b08d7ed775e8615a Mon Sep 17 00:00:00 2001 From: Ghasem Naddaf Date: Wed, 11 Mar 2020 12:50:10 -0700 Subject: [PATCH] nhrpd: resolve formatting warnings Signed-off-by: Ghasem Naddaf --- nhrpd/netlink_arp.c | 7 +++---- nhrpd/nhrp_cache.c | 40 ++++++++++++++++++---------------------- nhrpd/nhrp_peer.c | 14 +++++--------- nhrpd/nhrp_shortcut.c | 19 ++++++------------- 4 files changed, 32 insertions(+), 48 deletions(-) diff --git a/nhrpd/netlink_arp.c b/nhrpd/netlink_arp.c index 187c66767e..cf338a0876 100644 --- a/nhrpd/netlink_arp.c +++ b/nhrpd/netlink_arp.c @@ -70,6 +70,7 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb) char buf[4][SU_ADDRSTRLEN]; int state; + memset(&lladdr, 0, sizeof(lladdr)); ndm = znl_pull(zb, sizeof(*ndm)); if (!ndm) return; @@ -98,8 +99,7 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb) return; debugf(NHRP_DEBUG_KERNEL, - "Netlink: %s %s dev %s lladdr %s nud 0x%x " - "cache used %u type %u", + "Netlink: %s %s dev %s lladdr %s nud 0x%x cache used %u type %u", (msg->nlmsg_type == RTM_GETNEIGH) ? "who-has" : (msg->nlmsg_type == RTM_NEWNEIGH) ? "new-neigh" @@ -112,8 +112,7 @@ static void netlink_neigh_msg(struct nlmsghdr *msg, struct zbuf *zb) if (c->cur.type >= NHRP_CACHE_CACHED) { nhrp_cache_set_used(c, 1); debugf(NHRP_DEBUG_KERNEL, - "Netlink: update binding for %s dev %s from c " - "%s peer.vc.nbma %s to lladdr %s", + "Netlink: update binding for %s dev %s from c %s peer.vc.nbma %s to lladdr %s", sockunion2str(&addr, buf[0], sizeof(buf[0])), ifp->name, sockunion2str(&c->cur.remote_nbma_natoa, buf[1], diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index d7ab897d23..42f6a88f95 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -131,9 +131,7 @@ static void nhrp_cache_update_route(struct nhrp_cache *c) * nbma. */ debugf(NHRP_DEBUG_COMMON, - "cache (peer check ok, remote_nbma_natoa is set): " - "Update binding for %s dev %s from (deleted) " - "peer.vc.nbma %s to %s", + "cache (remote_nbma_natoa set): Update binding for %s dev %s from (deleted) peer.vc.nbma %s to %s", sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])), p->ifp->name, @@ -145,11 +143,9 @@ static void nhrp_cache_update_route(struct nhrp_cache *c) netlink_update_binding(p->ifp, &c->remote_addr, &c->cur.remote_nbma_natoa); } else { - // update binding to peer->vc->remote->nbma + /* update binding to peer->vc->remote->nbma */ debugf(NHRP_DEBUG_COMMON, - "cache (peer check ok, remote_nbma_natoa unspec): " - "Update binding for %s dev %s from (deleted) " - "to peer.vc.nbma %s", + "cache (remote_nbma_natoa unspec): Update binding for %s dev %s from (deleted) to peer.vc.nbma %s", sockunion2str(&c->remote_addr, buf[0], sizeof(buf[0])), p->ifp->name, @@ -174,12 +170,11 @@ static void nhrp_cache_update_route(struct nhrp_cache *c) c->route_installed = 1; } } else { - // debug the reason for peer check fail + /* debug the reason for peer check fail */ if (p) { nifp = p->ifp->info; debugf(NHRP_DEBUG_COMMON, - "cache (peer check failed: " - "online?%d requested?%d ipsec?%d)", + "cache (peer check failed: online?%d requested?%d ipsec?%d)", p->online, p->requested, nifp->ipsec_profile ? 1 : 0); } else @@ -280,21 +275,21 @@ static void nhrp_cache_authorize_binding(struct nhrp_reqid *r, void *arg) if (sockunion_family(&c->cur.remote_nbma_natoa) != AF_UNSPEC) { debugf(NHRP_DEBUG_COMMON, - "cache: update binding for %s dev %s from " - "(deleted) peer.vc.nbma %s to %s", + "cache: update binding for %s dev %s from (deleted) peer.vc.nbma %s to %s", sockunion2str(&c->remote_addr, buf[0], - sizeof buf[0]), + sizeof(buf[0])), c->ifp->name, (c->cur.peer ? sockunion2str( &c->cur.peer->vc->remote.nbma, buf[1], - sizeof buf[1]) + sizeof(buf[1])) : "(no peer)"), sockunion2str(&c->cur.remote_nbma_natoa, buf[2], - sizeof buf[2])); + sizeof(buf[2]))); - netlink_update_binding(c->cur.peer->ifp, - &c->remote_addr, - &c->cur.remote_nbma_natoa); + if (c->cur.peer) + netlink_update_binding( + c->cur.peer->ifp, &c->remote_addr, + &c->cur.remote_nbma_natoa); } nhrp_cache_update_route(c); @@ -341,6 +336,7 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, uint32_t mtu, union sockunion *nbma_oa) { char buf[2][SU_ADDRSTRLEN]; + if (c->cur.type > type || c->new.type > type) { nhrp_peer_unref(p); return 0; @@ -368,21 +364,21 @@ int nhrp_cache_update_binding(struct nhrp_cache *c, enum nhrp_cache_type type, nhrp_cache_reset_new(c); if (c->cur.type == type && c->cur.peer == p && c->cur.mtu == mtu) { debugf(NHRP_DEBUG_COMMON, - "cache: same type %u, updating " - "expiry and changing nbma addr from %s to %s", + "cache: same type %u, updating expiry and changing nbma addr from %s to %s", type, buf[0], nbma_oa ? buf[1] : "(NULL)"); if (holding_time > 0) c->cur.expires = monotime(NULL) + holding_time; + if (nbma_oa) c->cur.remote_nbma_natoa = *nbma_oa; else memset(&c->cur.remote_nbma_natoa, 0, sizeof(c->cur.remote_nbma_natoa)); + nhrp_peer_unref(p); } else { debugf(NHRP_DEBUG_COMMON, - "cache: new type %u/%u, or peer %s, " - "or mtu %u/%u, nbma %s --> %s (map %d)", + "cache: new type %u/%u, or peer %s, or mtu %u/%u, nbma %s --> %s (map %d)", c->cur.type, type, (c->cur.peer == p) ? "same" : "diff", c->cur.mtu, mtu, buf[0], nbma_oa ? buf[1] : "(NULL)", c->map); diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 471a138f98..2dc019ce65 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -358,8 +358,7 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *pp) != NULL) { prefix_len = cie->prefix_length; debugf(NHRP_DEBUG_COMMON, - "shortcut res_rep: parsing CIE with " - "prefixlen=%u", + "shortcut res_rep: parsing CIE with prefixlen=%u", prefix_len); if (prefix_len == 0 || prefix_len >= hostprefix_len) prefix_len = hostprefix_len; @@ -386,8 +385,7 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *pp) holdtime = htons(cie->holding_time); debugf(NHRP_DEBUG_COMMON, - "shortcut res_rep: holdtime is %u " - "(if 0, using %u)", + "shortcut res_rep: holdtime is %u (if 0, using %u)", holdtime, pp->if_ad->holdtime); if (!holdtime) holdtime = pp->if_ad->holdtime; @@ -395,17 +393,15 @@ static void nhrp_handle_resolution_req(struct nhrp_packet_parser *pp) c = nhrp_cache_get(ifp, proto_addr, 1); if (!c) { debugf(NHRP_DEBUG_COMMON, - "shortcut res_rep: no cache " - "found"); + "shortcut res_rep: no cache found"); cie->code = NHRP_CODE_INSUFFICIENT_RESOURCES; continue; } if (nbma_addr) - sockunion2str(nbma_addr, buf, sizeof buf); + sockunion2str(nbma_addr, buf, sizeof(buf)); debugf(NHRP_DEBUG_COMMON, - "shortcut res_rep: updating " - "binding for nmba addr %s", + "shortcut res_rep: updating binding for nmba addr %s", nbma_addr ? buf : "(NULL)"); if (!nhrp_cache_update_binding(c, NHRP_CACHE_DYNAMIC, holdtime, nhrp_peer_ref(pp->peer), diff --git a/nhrpd/nhrp_shortcut.c b/nhrpd/nhrp_shortcut.c index 561645e2bd..1c2b2b28f2 100644 --- a/nhrpd/nhrp_shortcut.c +++ b/nhrpd/nhrp_shortcut.c @@ -62,8 +62,7 @@ static void nhrp_shortcut_cache_notify(struct notifier_block *n, case NOTIFY_CACHE_UP: if (!s->route_installed) { debugf(NHRP_DEBUG_ROUTE, - "Shortcut: route install " - "%s nh (unspec) dev %s", + "Shortcut: route install %s nh (unspec) dev %s", prefix2str(s->p, buf, sizeof(buf)), s->cache->ifp->name); @@ -109,9 +108,7 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, * change */ s->route_installed = 0; debugf(NHRP_DEBUG_ROUTE, - "Shortcut: forcing route install to " - "announce prefix change for peer %s " - "ht %u cur nbma %s dev %s", + "Shortcut: forcing renewal of zebra announce on prefix change peer %s ht %u cur nbma %s dev %s", sockunion2str(&s->cache->remote_addr, buf[0], sizeof(buf[0])), holding_time, @@ -125,8 +122,7 @@ static void nhrp_shortcut_update_binding(struct nhrp_shortcut *s, } if (!s->cache || !s->cache->route_installed) { debugf(NHRP_DEBUG_ROUTE, - "Shortcut: notify cache down " - "because cache?%s or ri?%s", + "Shortcut: notify cache down because cache?%s or ri?%s", s->cache ? "yes" : "no", s->cache ? (s->cache->route_installed ? "yes" : "no") @@ -326,8 +322,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, if (ps) { ps->addr = s->addr; debugf(NHRP_DEBUG_COMMON, - "Shortcut: " - "calling nhrp_shortcut_update_binding"); + "Shortcut: calling update_binding"); nhrp_shortcut_update_binding(ps, NHRP_CACHE_DYNAMIC, c, holding_time); } else { @@ -336,8 +331,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid, } } else { debugf(NHRP_DEBUG_COMMON, - "NO Shortcut because c NULL?%s or " - "same proto?%s", + "NO Shortcut because c NULL?%s or same proto?%s", c ? "no" : "yes", proto && pp && sockunion_same(proto, &pp->dst_proto) ? "yes" @@ -392,8 +386,7 @@ static void nhrp_shortcut_send_resolution_req(struct nhrp_shortcut *s) cie->holding_time = htons(if_ad->holdtime); cie->mtu = htons(if_ad->mtu); debugf(NHRP_DEBUG_COMMON, - "Shortcut res_req: set cie holdtime to %u " - "and mtu to %u. shortcut's holdtime is %u.", + "Shortcut res_req: set cie ht to %u and mtu to %u. shortcut ht is %u", ntohs(cie->holding_time), ntohs(cie->mtu), s->holding_time); nhrp_ext_request(zb, hdr, ifp); -- 2.39.5