From c5cb17ececc1828908c2d1b7a58f49f3ec9001ab Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 2 Oct 2015 12:27:27 -0400 Subject: [PATCH] pimd: Cleanup interface startup This patch cleans up some interface startup, removes duplicate debug messages and protects against some always being displayed. Signed-off-by: Donald Sharp --- pimd/pim_iface.c | 47 ++++++++--------------------------------------- pimd/pim_zebra.c | 26 ++++++++++---------------- 2 files changed, 18 insertions(+), 55 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 32d10f1c15..9ef3115815 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -255,35 +255,6 @@ static void pim_addr_change(struct interface *ifp) pim_hello_restart_now(ifp); /* send hello and restart timer */ } -static void on_primary_address_change(struct interface *ifp, - const char *caller, - struct in_addr old_addr, - struct in_addr new_addr) -{ - struct pim_interface *pim_ifp; - - if (PIM_DEBUG_ZEBRA) { - char old_str[100]; - char new_str[100]; - pim_inet4_dump("", old_addr, old_str, sizeof(old_str)); - pim_inet4_dump("", new_addr, new_str, sizeof(new_str)); - zlog_debug("%s: %s: primary address changed from %s to %s on interface %s", - __PRETTY_FUNCTION__, caller, - old_str, new_str, ifp->name); - } - - pim_ifp = ifp->info; - if (!pim_ifp) { - return; - } - - if (!PIM_IF_TEST_PIM(pim_ifp->options)) { - return; - } - - pim_addr_change(ifp); -} - static int detect_primary_address_change(struct interface *ifp, int force_prim_as_any, const char *caller) @@ -315,10 +286,13 @@ static int detect_primary_address_change(struct interface *ifp, } if (changed) { - struct in_addr old_addr = pim_ifp->primary_address; pim_ifp->primary_address = new_prim_addr; - on_primary_address_change(ifp, caller, old_addr, new_prim_addr); + if (!PIM_IF_TEST_PIM(pim_ifp->options)) { + return changed; + } + + pim_addr_change(ifp); } return changed; @@ -335,14 +309,9 @@ static void detect_secondary_address_change(struct interface *ifp, return; changed = 1; /* true */ - zlog_info("FIXME T31 C15 %s: on interface %s: acting on any addr change", - __PRETTY_FUNCTION__, ifp->name); - - if (PIM_DEBUG_ZEBRA) { - zlog_debug("%s: on interface %s: %s", - __PRETTY_FUNCTION__, - ifp->name, changed ? "changed" : "unchanged"); - } + if (PIM_DEBUG_ZEBRA) + zlog_debug("FIXME T31 C15 %s: on interface %s: acting on any addr change", + __PRETTY_FUNCTION__, ifp->name); if (!changed) { return; diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 5510ceae1b..b2bdb0d7f3 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -150,8 +150,6 @@ static int pim_zebra_if_state_up(int command, struct zclient *zclient, if (!ifp) return 0; - zlog_info("INTERFACE UP: %s ifindex=%d", ifp->name, ifp->ifindex); - if (PIM_DEBUG_ZEBRA) { zlog_debug("%s: %s index %d flags %ld metric %d mtu %d operative %d", __PRETTY_FUNCTION__, @@ -182,8 +180,6 @@ static int pim_zebra_if_state_down(int command, struct zclient *zclient, if (!ifp) return 0; - zlog_info("INTERFACE DOWN: %s ifindex=%d", ifp->name, ifp->ifindex); - if (PIM_DEBUG_ZEBRA) { zlog_debug("%s: %s index %d flags %ld metric %d mtu %d operative %d", __PRETTY_FUNCTION__, @@ -242,8 +238,6 @@ static int pim_zebra_if_address_add(int command, struct zclient *zclient, struct connected *c; struct prefix *p; - zassert(command == ZEBRA_INTERFACE_ADDRESS_ADD); - /* zebra api notifies address adds/dels events by using the same call interface_add_read below, see comments in lib/zclient.c @@ -278,17 +272,19 @@ static int pim_zebra_if_address_add(int command, struct zclient *zclient, struct in_addr primary_addr = pim_find_primary_addr(c->ifp); if (primary_addr.s_addr != p->u.prefix4.s_addr) { - /* but we had a primary address already */ + if (PIM_DEBUG_ZEBRA) { + /* but we had a primary address already */ - char buf[BUFSIZ]; - char old[100]; + char buf[BUFSIZ]; + char old[100]; - prefix2str(p, buf, BUFSIZ); - pim_inet4_dump("", primary_addr, old, sizeof(old)); + prefix2str(p, buf, BUFSIZ); + pim_inet4_dump("", primary_addr, old, sizeof(old)); - zlog_warn("%s: %s primary addr old=%s: forcing secondary flag on new=%s", - __PRETTY_FUNCTION__, - c->ifp->name, old, buf); + zlog_warn("%s: %s primary addr old=%s: forcing secondary flag on new=%s", + __PRETTY_FUNCTION__, + c->ifp->name, old, buf); + } SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY); } } @@ -304,8 +300,6 @@ static int pim_zebra_if_address_del(int command, struct zclient *client, struct connected *c; struct prefix *p; - zassert(command == ZEBRA_INTERFACE_ADDRESS_DELETE); - /* zebra api notifies address adds/dels events by using the same call interface_add_read below, see comments in lib/zclient.c -- 2.39.5