From 4021b60aad57f71f5d3d5c105127f93bd77bf800 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Fri, 12 May 2006 22:55:41 +0000 Subject: [ospfd] Squash another ospf_lookup call 2006-05-11 Paul Jakma * ospf_lsa.c: (ospf_default_originate_timer) Let the thread take (struct ospf *) as thread argument, rather than (struct ospf *)->default_originate, thus avoiding having to call ospf_lookup. * ospf_zebra.c: (ospf_redistribute_default_set) change setup of ospf_default_originate_timer thread to match. * ospfd.c: (ospf_router_id_update) ditto. --- ospfd/ospf_zebra.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ospfd/ospf_zebra.c') diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 494f63ce..11c4d99b 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -615,8 +615,7 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate, if (ospf->router_id.s_addr == 0) ospf->external_origin |= (1 << DEFAULT_ROUTE); else - thread_add_timer (master, ospf_default_originate_timer, - &ospf->default_originate, 1); + thread_add_timer (master, ospf_default_originate_timer, ospf, 1); ospf_asbr_status_update (ospf, ++ospf->redistribute); -- cgit v1.2.3 From 6db3a6f75c7206050b096dcbd4fde439b4bcb6e6 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Fri, 12 May 2006 23:02:46 +0000 Subject: [ospfd] CID #28, remove another ospf_lookup call - ospf_redistribute_withdraw 2006-05-12 Paul Jakma * ospf_asbr.c: (ospf_redistribute_withdraw) remove ospf_lookup call by taking the struct ospf * as argument, which the caller has, fixing CID #28. * ospf_asbr.h: (ospf_redistribute_withdraw) update declaration * ospf_zebra.c: (ospf_redistribute_unset) update call to ospf_redistribute_withdraw to match. --- ospfd/ospf_zebra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ospfd/ospf_zebra.c') diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 11c4d99b..5a722e05 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -565,7 +565,7 @@ ospf_redistribute_unset (struct ospf *ospf, int type) ospf->dmetric[type].value = -1; /* Remove the routes from OSPF table. */ - ospf_redistribute_withdraw (type); + ospf_redistribute_withdraw (ospf, type); ospf_asbr_status_update (ospf, --ospf->redistribute); -- cgit v1.2.3 From 8fb8a504e2c7c216b34c58e5658d84cb7dbe79b0 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 24 Oct 2006 19:04:26 +0000 Subject: [ospfd] Stop losing subsequent default-information originate 'always' info 2006-10-24 Andrew J. Schorr * ospf_zebra.c: (ospf_redistribute_default_set) Fix bug where a new value for ospf->default_originate was being ignored if a previous 'default-information originate' command had already been processed. --- ospfd/ospf_zebra.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'ospfd/ospf_zebra.c') diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 5a722e05..aaee31e1 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -576,21 +576,15 @@ int ospf_redistribute_default_set (struct ospf *ospf, int originate, int mtype, int mvalue) { - int force = 0; + ospf->default_originate = originate; + ospf->dmetric[DEFAULT_ROUTE].type = mtype; + ospf->dmetric[DEFAULT_ROUTE].value = mvalue; if (ospf_is_type_redistributed (DEFAULT_ROUTE)) { - if (mtype != ospf->dmetric[DEFAULT_ROUTE].type) - { - ospf->dmetric[DEFAULT_ROUTE].type = mtype; - force = 1; - } - if (mvalue != ospf->dmetric[DEFAULT_ROUTE].value) - { - force = 1; - ospf->dmetric[DEFAULT_ROUTE].value = mvalue; - } - + /* if ospf->default_originate changes value, is calling + ospf_external_lsa_refresh_default sufficient to implement + the change? */ ospf_external_lsa_refresh_default (ospf); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) @@ -601,10 +595,6 @@ ospf_redistribute_default_set (struct ospf *ospf, int originate, return CMD_SUCCESS; } - ospf->default_originate = originate; - ospf->dmetric[DEFAULT_ROUTE].type = mtype; - ospf->dmetric[DEFAULT_ROUTE].value = mvalue; - zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient); if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) -- cgit v1.2.3 From 7f643ebf2bca2ef446cdf4f4a3e7b16958c18069 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Thu, 30 Nov 2006 16:17:02 +0000 Subject: [ospfd] Add debug messages for a few zebra messages that had been overlooked 2006-11-30 Andrew J. Schorr * ospf_zebra.c: (ospf_router_id_update_zebra, ospf_interface_address_add, ospf_interface_address_delete) If (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) is enabled, then add a debug message about what Zebra is telling us. (ospf_zebra_add_discard) Add a debug message matching the one already in ospf_zebra_delete_discard. --- ospfd/ospf_zebra.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ospfd/ospf_zebra.c') diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index aaee31e1..bdd01424 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -65,6 +65,13 @@ ospf_router_id_update_zebra (int command, struct zclient *zclient, struct prefix router_id; zebra_router_id_update_read(zclient->ibuf,&router_id); + if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) + { + char buf[128]; + prefix2str(&router_id, buf, sizeof(buf)); + zlog_debug("Zebra rcvd: router id update %s", buf); + } + router_id_zebra = router_id.u.prefix4; ospf = ospf_lookup (); @@ -256,6 +263,13 @@ ospf_interface_address_add (int command, struct zclient *zclient, if (c == NULL) return 0; + if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) + { + char buf[128]; + prefix2str(c->address, buf, sizeof(buf)); + zlog_debug("Zebra: interface %s address add %s", c->ifp->name, buf); + } + ospf = ospf_lookup (); if (ospf != NULL) ospf_if_update (ospf); @@ -283,6 +297,13 @@ ospf_interface_address_delete (int command, struct zclient *zclient, if (c == NULL) return 0; + if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) + { + char buf[128]; + prefix2str(c->address, buf, sizeof(buf)); + zlog_debug("Zebra: interface %s address delete %s", c->ifp->name, buf); + } + ifp = c->ifp; p = *c->address; p.prefixlen = IPV4_MAX_PREFIXLEN; @@ -470,6 +491,10 @@ ospf_zebra_add_discard (struct prefix_ipv4 *p) api.ifindex_num = 0; zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient, p, &api); + + if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) + zlog_debug ("Zebra: Route add discard %s/%d", + inet_ntoa (p->prefix), p->prefixlen); } } -- cgit v1.2.3 From 56b3ea09bb613b066824c03290a58f8f2dfae9fd Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Wed, 14 Mar 2007 20:21:43 +0000 Subject: [ospfd] Fix two debug messages that used inet_ntoa more than once 2007-03-14 Andrew J. Schorr * ospf_zebra.c: (ospf_zebra_add, ospf_zebra_delete) Fix bug where inet_ntoa was used twice in the same debug message, which doesn't work because there's a single shared buffer for the returned string. The fix is to use inet_ntop. --- ospfd/ospf_zebra.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'ospfd/ospf_zebra.c') diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index bdd01424..f302d28d 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -396,9 +396,13 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) { - zlog_debug ("Zebra: Route add %s/%d nexthop %s", - inet_ntoa (p->prefix), - p->prefixlen, inet_ntoa (path->nexthop)); + char buf[2][INET_ADDRSTRLEN]; + zlog_debug("Zebra: Route add %s/%d nexthop %s", + inet_ntop(AF_INET, &p->prefix, + buf[0], sizeof(buf[0])), + p->prefixlen, + inet_ntop(AF_INET, &path->nexthop, + buf[1], sizeof(buf[1]))); } } @@ -462,9 +466,12 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or) if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE) && api.nexthop_num) { - zlog_debug ("Zebra: Route delete %s/%d nexthop %s", - inet_ntoa (p->prefix), - p->prefixlen, inet_ntoa (**api.nexthop)); + char buf[2][INET_ADDRSTRLEN]; + zlog_debug("Zebra: Route delete %s/%d nexthop %s", + inet_ntop(AF_INET, &p->prefix, buf[0], sizeof(buf[0])), + p->prefixlen, + inet_ntop(AF_INET, *api.nexthop, + buf[1], sizeof(buf[1]))); } if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE) && api.ifindex_num) { -- cgit v1.2.3 From a49eb30a178547189147c8a35bf9e35f429abb66 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Tue, 2 Sep 2008 19:06:31 +0100 Subject: [ospfd] Restructure opsf_if_update() and ospf_network_run() Add an struct interface paramenter and adjust the affected code accordingly. The old code was a mess looping over all interfaces several times when one interface was added/changed. * ospfd/ospfd.h: Add struct interface parameter to ospf_if_update() * ospfd/ospf_zebra.c: Add ifp arg to ospf_if_update() calls. (ospf_interface_address_delete) delete ospf_if_update() call, redundant as function calls ospf_if_free() itself. * ospfd/ospfd.c: (ospf_network_unset) handle deconfiguration here, rather than ospf_if_update. (ospf_network_run_interface) ospf_network_run, for any given interface. (ospf_network_run) move guts to previous, and use it. (ospf_if_update) Adjust to take struct interface as argument, as all callers have a specific ifp in mind. Iterate over ifp's connected list and call ospf_network_run_interface instead of ospf_network_run, turning this path into O(nm) rather than O(n^2). Adjust all code dealing with opsf_if_update and ospf_network_run to pass the new struct interface * arg. (some minor modifications and bug-additions by Paul Jakma). Signed-off-by: Paul Jakma --- ospfd/ospf_zebra.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'ospfd/ospf_zebra.c') diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index f302d28d..e27f1394 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -87,7 +87,6 @@ static int ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) { struct interface *ifp; - struct ospf *ospf; ifp = zebra_interface_add_read (zclient->ibuf); @@ -103,9 +102,7 @@ ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); } - ospf = ospf_lookup (); - if (ospf != NULL) - ospf_if_update (ospf); + ospf_if_update (NULL, ifp); #ifdef HAVE_SNMP ospf_snmp_if_update (ifp); @@ -255,7 +252,6 @@ static int ospf_interface_address_add (int command, struct zclient *zclient, zebra_size_t length) { - struct ospf *ospf; struct connected *c; c = zebra_interface_address_read (command, zclient->ibuf); @@ -270,9 +266,7 @@ ospf_interface_address_add (int command, struct zclient *zclient, zlog_debug("Zebra: interface %s address add %s", c->ifp->name, buf); } - ospf = ospf_lookup (); - if (ospf != NULL) - ospf_if_update (ospf); + ospf_if_update (NULL, c->ifp); #ifdef HAVE_SNMP ospf_snmp_if_update (c->ifp); @@ -285,7 +279,6 @@ static int ospf_interface_address_delete (int command, struct zclient *zclient, zebra_size_t length) { - struct ospf *ospf; struct connected *c; struct interface *ifp; struct ospf_interface *oi; @@ -327,10 +320,6 @@ ospf_interface_address_delete (int command, struct zclient *zclient, connected_free (c); - ospf = ospf_lookup (); - if (ospf != NULL) - ospf_if_update (ospf); - return 0; } -- cgit v1.2.3