From 9c27ef9b9c26db0af507869c2866c4a8463f4ae7 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 4 May 2006 07:32:57 +0000 Subject: [ospfd] Fix SPF of virtual-links 2006-04-24 Paul Jakma * (general) More Virtual-link fixes, again with much help in testing / debug from Juergen Kammer. Primarily in SPF. * ospf_spf.h: Add guard. ospf_interface.h will include this header. * ospf_interface.h: Modify ospf_vl_lookup definition to take struct ospf as argument, so as to allow for NULL area argument. (struct ospf_vl_data) Remove out_oi, instead add a struct vertex_nexthop, to use as initial nexthop for backbone paths through a vlink. * ospf_interface.c: (ospf_vl_lookup) Modified to allow NULL area to be passed to indicate "any" (first) area. Add extra debug. (ospf_vl_set_params) vl_oi -> nexthop. Add extra debug. (ospf_vl_up_check) Fix debug, inet_ntoa returns a static buffer.. * ospf_route.c: (ospf_intra_add_router) Vlinks dont go through backbone, don't bother checking. * ospf_spf.c: (static struct list vertex_list) Record vertices that will need to be freed. (cmp) Order network before router vertices, as required, wasn't implemented. (vertex_nexthop_free) Mild additional robustness check. (vertex_parent_free) Take void argument, as this function is passed as list deconstructor for vertex parent list. (ospf_vertex_new) More debug. Set deconstructor for parent list. Track allocated vertices on the vertex_list. (ospf_vertex_free) Get rid of the tricky recursive cleanup of vertices. Now frees only the given vertex. (ospf_vertex_add_parent) Fix assert. (ospf_nexthop_calculation) Fix calculation of nexthop for VLink vertices, lookup the vl_data and use its previously recorded nexthop information. (ospf_spf_calculate) Vertices are freed simply by deleting vertex_list nodes and letting ospf_vertex_free as deconstructor work per-node. (ospf_spf_calculate_timer) Trivial optimisation, leave backbone SPF calculation till last to reduce SPF churn on VLink updates. * ospf_vty.c: (ospf_find_vl_data) update call to ospf_vl_lookup (no_ospf_area_vlink_cmd) ditto. (show_ip_ospf_interface_sub) For Vlinks, the peer address is more interesting than the output interface. --- ospfd/ospf_vty.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0b74bdf1..74361bcb 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -722,7 +722,7 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config) return NULL; } - if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL) + if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) { vl_data = ospf_vl_data_new (area, vl_config->vl_peer); if (vl_data->vl_oi == NULL) @@ -1074,7 +1074,7 @@ DEFUN (no_ospf_area_vlink, { /* Basic VLink no command */ /* Thats all folks! - BUGS B. strikes again!!!*/ - if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer))) + if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) ospf_vl_delete (ospf, vl_data); ospf_area_check_free (ospf, vl_config.area_id); @@ -2736,10 +2736,27 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, vty_out (vty, " Internet Address %s/%d,", inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); - if (oi->connected->destination) - vty_out (vty, " %s %s,", - ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"), - inet_ntoa (oi->connected->destination->u.prefix4)); + if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) + { + struct in_addr *dest; + const char *dstr; + + if ((ifp->flags & IFF_POINTOPOINT) + || oi->type == OSPF_IFTYPE_VIRTUALLINK) + dstr = "Peer"; + else + dstr = "Broadcast"; + + /* For Vlinks, showing the peer address is probably more + * informative than the local interface that is being used + */ + if (oi->type == OSPF_IFTYPE_VIRTUALLINK) + dest = &oi->vl_data->peer_addr; + else + dest = &oi->connected->destination->u.prefix4; + + vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); + } vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), VTY_NEWLINE); -- cgit v1.2.3 From cac3b5c435613b51eddf7db4518aa6b730afb031 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 11 May 2006 13:31:11 +0000 Subject: [ospfd] Fix missing check for ospf_lookup NULL return, CID #70 2006-05-11 Paul Jakma * ospf_vty.c: (general) Audit ospf_lookup calls in commands, ensure check for NULL result, make vty messages consistent. (show_ip_ospf_interface) Missing NULL check on ospf_lookup result, fixes Coverity CID #70. --- ospfd/ospf_vty.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 74361bcb..c5a69dce 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2860,6 +2860,11 @@ DEFUN (show_ip_ospf_interface, struct listnode *node; ospf = ospf_lookup (); + if (ospf == NULL) + { + vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); + return CMD_SUCCESS; + } /* Show All Interfaces. */ if (argc == 0) @@ -3976,7 +3981,10 @@ DEFUN (show_ip_ospf_database, ospf = ospf_lookup (); if (ospf == NULL) - return CMD_SUCCESS; + { + vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); + return CMD_SUCCESS; + } vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); @@ -4114,7 +4122,10 @@ DEFUN (show_ip_ospf_database_type_adv_router, ospf = ospf_lookup (); if (ospf == NULL) - return CMD_SUCCESS; + { + vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); + return CMD_SUCCESS; + } vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); @@ -4736,10 +4747,7 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, struct ospf_if_params *params; struct ospf_interface *oi; struct route_node *rn; - struct ospf *ospf; - ospf = ospf_lookup (); - params = IF_DEF_PARAMS (ifp); if (nbr_str) @@ -4787,7 +4795,8 @@ ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, /* Update timer values in neighbor structure. */ if (nbr_str) { - if (ospf) + struct ospf *ospf; + if ((ospf = ospf_lookup())) { oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); if (oi) @@ -4877,9 +4886,6 @@ DEFUN (no_ip_ospf_dead_interval, struct ospf_if_params *params; struct ospf_interface *oi; struct route_node *rn; - struct ospf *ospf; - - ospf = ospf_lookup (); ifp = vty->index; params = IF_DEF_PARAMS (ifp); @@ -4914,7 +4920,9 @@ DEFUN (no_ip_ospf_dead_interval, /* Update timer values in neighbor structure. */ if (argc == 1) { - if (ospf) + struct ospf *ospf; + + if ((ospf = ospf_lookup())) { oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); if (oi) @@ -7138,10 +7146,9 @@ DEFUN (show_ip_ospf_border_routers, { struct ospf *ospf; - ospf = ospf_lookup (); - if (ospf == NULL) + if ((ospf = ospf_lookup ()) == NULL) { - vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); + vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); return CMD_SUCCESS; } @@ -7170,10 +7177,9 @@ DEFUN (show_ip_ospf_route, { struct ospf *ospf; - ospf = ospf_lookup (); - if (ospf == NULL) + if ((ospf = ospf_lookup ()) == NULL) { - vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); + vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); return CMD_SUCCESS; } -- cgit v1.2.3 From 1a8ec2b9a3557e4f6ad3c8780b72b35be6d86a3e Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 11 May 2006 13:34:08 +0000 Subject: [ospfd] Check NULL result from ospf_area_lookup_by_area_id, CID #69 2006-05-11 Paul Jakma * ospf_vty.c: (no_ospf_area_filter_list) Check NULL result from ospf_area_lookup_by_area_id, fixes Coverity CID #69 --- ospfd/ospf_vty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c5a69dce..8d6ff31f 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -1896,7 +1896,9 @@ DEFUN (no_ospf_area_filter_list, VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); - area = ospf_area_lookup_by_area_id (ospf, area_id); + if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) + return CMD_SUCCESS; + plist = prefix_list_lookup (AFI_IP, argv[1]); if (strncmp (argv[2], "in", 2) == 0) { -- cgit v1.2.3 From 429ac78cc64e0e29bab7cbc00ee991abcdec3f81 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 15 Jun 2006 18:40:49 +0000 Subject: [ospfd] Fix multicast membership drop bug 2006-06-15 Paul Jakma * Reported by Milan Koci * ospf_interface.h: (struct ospf_if_info) Add reference counts for multicast group memberships. Add various macros to help manipulate/check membership state. * ospf_interface.c: (ospf_if_set_multicast) Maintain the ospf_if_info reference counts, and only actually drop memberships if it hits 0, to avoid losing membership when OSPF is disabled on an interface with multiple active OSPF interfaces. * ospf_packet.c: (ospf_{hello,read}) Use the new macros to check/set multicast membership. * ospf_vty.c: (show_ip_ospf_interface_sub) ditto. --- ospfd/ospf_vty.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 8d6ff31f..10580ab7 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2811,12 +2811,15 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, } vty_out (vty, " Multicast group memberships:"); - if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS)) - vty_out (vty, " OSPFAllRouters"); - if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS)) - vty_out (vty, " OSPFDesignatedRouters"); - if (!CHECK_FLAG(oi->multicast_memberships, - MEMBER_ALLROUTERS|MEMBER_DROUTERS)) + if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) + || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) + { + if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) + vty_out (vty, " OSPFAllRouters"); + if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) + vty_out (vty, " OSPFDesignatedRouters"); + } + else vty_out (vty, " "); vty_out (vty, "%s", VTY_NEWLINE); -- cgit v1.2.3 From 6e72cb6a0940bd3dae2d4f023ef94f84af3b723c Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Sun, 18 Jun 2006 00:45:48 +0000 Subject: [ospfd] Fix ospf passive-interface subcommand to create interface if necessary 2006-06-17 Andrew J. Schorr * ospf_vty.c: ({no_,}ospf_passive_interface) Replace if_lookup_by_name with a call to if_get_by_name -- if the interface does not exist already, it should be created. And remove the obsolete warning message. --- ospfd/ospf_vty.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 10580ab7..7c367ea2 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -261,13 +261,7 @@ DEFUN (ospf_passive_interface, struct ospf_if_params *params; struct route_node *rn; - ifp = if_lookup_by_name (argv[0]); - - if (ifp == NULL) - { - vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); - return CMD_WARNING; - } + ifp = if_get_by_name (argv[0]); params = IF_DEF_PARAMS (ifp); @@ -331,13 +325,7 @@ DEFUN (no_ospf_passive_interface, int ret; struct route_node *rn; - ifp = if_lookup_by_name (argv[0]); - - if (ifp == NULL) - { - vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); - return CMD_WARNING; - } + ifp = if_get_by_name (argv[0]); params = IF_DEF_PARAMS (ifp); -- cgit v1.2.3 From d1c65c211ce6259b95ec8922f3f3127dc74e118f Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 27 Jun 2006 08:01:43 +0000 Subject: [ospfd] Replace redistribution strings with new route_types.h defines. 2006-05-23 Paul Jakma * ospf_vty.c: (general) Replace in-place route redistribution command and help strings with the new auto-generated defines from lib/route_types.h --- ospfd/ospf_vty.c | 132 ++++++++++++++++++------------------------------------- 1 file changed, 43 insertions(+), 89 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 7c367ea2..20dc940a 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -5562,13 +5562,10 @@ ALIAS (no_ip_ospf_transmit_delay, DEFUN (ospf_redistribute_source_metric_type, ospf_redistribute_source_metric_type_routemap_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD + " metric <0-16777214> metric-type (1|2) route-map WORD", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n" "OSPF exterior metric type for redistributed routes\n" @@ -5606,13 +5603,10 @@ DEFUN (ospf_redistribute_source_metric_type, ALIAS (ospf_redistribute_source_metric_type, ospf_redistribute_source_metric_type_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD + " metric <0-16777214> metric-type (1|2)", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n" "OSPF exterior metric type for redistributed routes\n" @@ -5621,25 +5615,18 @@ ALIAS (ospf_redistribute_source_metric_type, ALIAS (ospf_redistribute_source_metric_type, ospf_redistribute_source_metric_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n") DEFUN (ospf_redistribute_source_type_metric, ospf_redistribute_source_type_metric_routemap_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD + " metric-type (1|2) metric <0-16777214> route-map WORD", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "OSPF exterior metric type for redistributed routes\n" "Set OSPF External Type 1 metrics\n" "Set OSPF External Type 2 metrics\n" @@ -5677,13 +5664,10 @@ DEFUN (ospf_redistribute_source_type_metric, ALIAS (ospf_redistribute_source_type_metric, ospf_redistribute_source_type_metric_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD + " metric-type (1|2) metric <0-16777214>", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "OSPF exterior metric type for redistributed routes\n" "Set OSPF External Type 1 metrics\n" "Set OSPF External Type 2 metrics\n" @@ -5692,36 +5676,25 @@ ALIAS (ospf_redistribute_source_type_metric, ALIAS (ospf_redistribute_source_type_metric, ospf_redistribute_source_type_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "OSPF exterior metric type for redistributed routes\n" "Set OSPF External Type 1 metrics\n" "Set OSPF External Type 2 metrics\n") ALIAS (ospf_redistribute_source_type_metric, ospf_redistribute_source_cmd, - "redistribute (kernel|connected|static|rip|bgp)", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n") + "redistribute " QUAGGA_REDIST_STR_OSPFD, + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD) DEFUN (ospf_redistribute_source_metric_routemap, ospf_redistribute_source_metric_routemap_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD + " metric <0-16777214> route-map WORD", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n" "Route map reference\n" @@ -5750,13 +5723,10 @@ DEFUN (ospf_redistribute_source_metric_routemap, DEFUN (ospf_redistribute_source_type_routemap, ospf_redistribute_source_type_routemap_cmd, - "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD + " metric-type (1|2) route-map WORD", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "OSPF exterior metric type for redistributed routes\n" "Set OSPF External Type 1 metrics\n" "Set OSPF External Type 2 metrics\n" @@ -5786,13 +5756,9 @@ DEFUN (ospf_redistribute_source_type_routemap, DEFUN (ospf_redistribute_source_routemap, ospf_redistribute_source_routemap_cmd, - "redistribute (kernel|connected|static|rip|bgp) route-map WORD", - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n" + "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD", + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD "Route map reference\n" "Pointer to route-map entries\n") { @@ -5813,14 +5779,10 @@ DEFUN (ospf_redistribute_source_routemap, DEFUN (no_ospf_redistribute_source, no_ospf_redistribute_source_cmd, - "no redistribute (kernel|connected|static|rip|bgp)", + "no redistribute " QUAGGA_REDIST_STR_OSPFD, NO_STR - "Redistribute information from another routing protocol\n" - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n") + REDIST_STR + QUAGGA_REDIST_HELP_STR_OSPFD) { struct ospf *ospf = vty->index; int source; @@ -5834,15 +5796,11 @@ DEFUN (no_ospf_redistribute_source, DEFUN (ospf_distribute_list_out, ospf_distribute_list_out_cmd, - "distribute-list WORD out (kernel|connected|static|rip|bgp)", + "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, "Filter networks in routing updates\n" "Access-list name\n" OUT_STR - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n") + QUAGGA_REDIST_HELP_STR_OSPFD) { struct ospf *ospf = vty->index; int source; @@ -5856,16 +5814,12 @@ DEFUN (ospf_distribute_list_out, DEFUN (no_ospf_distribute_list_out, no_ospf_distribute_list_out_cmd, - "no distribute-list WORD out (kernel|connected|static|rip|bgp)", + "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, NO_STR "Filter networks in routing updates\n" "Access-list name\n" OUT_STR - "Kernel routes\n" - "Connected\n" - "Static routes\n" - "Routing Information Protocol (RIP)\n" - "Border Gateway Protocol (BGP)\n") + QUAGGA_REDIST_HELP_STR_OSPFD) { struct ospf *ospf = vty->index; int source; -- cgit v1.2.3 From d7e60dd7a9f0213aaa82d256a78ab74887946e53 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Thu, 29 Jun 2006 20:20:52 +0000 Subject: [ospfd] Implement new ospf router subcommand "log-adjacency-changes [detail]" 2006-06-28 Erik Muller * ospfd.h: Define 2 new struct ospf config flags: OSPF_LOG_ADJACENCY_CHANGES and OSPF_LOG_ADJACENCY_DETAIL * ospf_nsm.c (nsm_change_state): Log adjacency changes if requested. * ospf_vty.c (ospf_log_adjacency_changes): New command function to implement ospf subcommand "log-adjacency-changes [detail]". (no_ospf_log_adjacency_changes) Turn off log-adjacency-changes. (show_ip_ospf) Show whether adjacency changes are logged. (ospf_config_write) Add "log-adjacency-changes [detail]" to config. (ospf_vty_init) Add ospf_log_adjacency_changes and no_ospf_log_adjacency_changes. * ospfd.texi: Document new ospf router subcommand "log-adjacency-changes [detail]". --- ospfd/ospf_vty.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 20dc940a..0298af22 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2056,6 +2056,56 @@ DEFUN (no_ospf_abr_type, return CMD_SUCCESS; } +DEFUN (ospf_log_adjacency_changes, + ospf_log_adjacency_changes_cmd, + "log-adjacency-changes", + "Log changes in adjacency state\n") +{ + struct ospf *ospf = vty->index; + + SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); + return CMD_SUCCESS; +} + +DEFUN (ospf_log_adjacency_changes_detail, + ospf_log_adjacency_changes_detail_cmd, + "log-adjacency-changes detail", + "Log changes in adjacency state\n" + "Log all state changes\n") +{ + struct ospf *ospf = vty->index; + + SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); + SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); + return CMD_SUCCESS; +} + +DEFUN (no_ospf_log_adjacency_changes, + no_ospf_log_adjacency_changes_cmd, + "no log-adjacency-changes", + NO_STR + "Log changes in adjacency state\n") +{ + struct ospf *ospf = vty->index; + + UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); + UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); + return CMD_SUCCESS; +} + +DEFUN (no_ospf_log_adjacency_changes_detail, + no_ospf_log_adjacency_changes_detail_cmd, + "no log-adjacency-changes detail", + NO_STR + "Log changes in adjacency state\n" + "Log all state changes\n") +{ + struct ospf *ospf = vty->index; + + UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); + return CMD_SUCCESS; +} + DEFUN (ospf_compatible_rfc1583, ospf_compatible_rfc1583_cmd, "compatible rfc1583", @@ -2676,8 +2726,18 @@ DEFUN (show_ip_ospf, ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); #endif /* HAVE_OPAQUE_LSA */ /* Show number of areas attached. */ - vty_out (vty, " Number of areas attached to this router: %d%s%s", - listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); + vty_out (vty, " Number of areas attached to this router: %d%s", + listcount (ospf->areas), VTY_NEWLINE); + + if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) + { + if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) + vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); + else + vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); + } + + vty_out (vty, "%s",VTY_NEWLINE); /* Show each area status. */ for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) @@ -7752,6 +7812,15 @@ ospf_config_write (struct vty *vty) vty_out (vty, " ospf abr-type %s%s", ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); + /* log-adjacency-changes flag print. */ + if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) + { + vty_out(vty, " log-adjacency-changes"); + if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) + vty_out(vty, " detail"); + vty_out(vty, "%s", VTY_NEWLINE); + } + /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); @@ -8123,6 +8192,12 @@ ospf_vty_init (void) install_element (OSPF_NODE, &ospf_abr_type_cmd); install_element (OSPF_NODE, &no_ospf_abr_type_cmd); + /* "ospf log-adjacency-changes" commands. */ + install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); + install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); + install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); + install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); + /* "ospf rfc1583-compatible" commands. */ install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); -- cgit v1.2.3 From 1c066bfe62951fa1e2f90f02b528342d60fcd6f9 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Fri, 30 Jun 2006 16:53:47 +0000 Subject: [ospfd] Fix "show ip ospf neighbor A.B.C.D" to show all matches 2006-06-30 Andrew J. Schorr * ospf_vty.c: (show_ip_ospf_neighbor_id) Should show all instances of that neighbor (since it may appear on multiple interfaces) instead of bailing out after showing the first match. --- ospfd/ospf_vty.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0298af22..ec002017 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3222,12 +3222,8 @@ DEFUN (show_ip_ospf_neighbor_id, for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) - { - show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); - return CMD_SUCCESS; - } + show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); - /* Nothing to show. */ return CMD_SUCCESS; } -- cgit v1.2.3 From 90c33177f53ae36a8765f5f27bf34a90663806d3 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 11 Jul 2006 17:57:25 +0000 Subject: [ospfd] record timestamp and event of last NSM state change for neighbour 2006-07-10 Paul Jakma * ospf_nsm.c: (ospf_nsm_event) Record state change timestamp and event in nbr struct. * ospf_neighbor.h: (struct ospf_neighbor) Add fields to record timestamp of last NSM change and event. * ospf_vty.c: (show_ip_ospf_neighbor_detail_sub) Print last state change timestamp and event, if available. --- ospfd/ospf_vty.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index ec002017..44049d8c 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3155,7 +3155,14 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); /* Show state changes. */ vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); - + if (nbr->ts_last_change.tv_sec || nbr->ts_last_change.tv_usec) + { + struct timeval res = tv_sub (recent_time, nbr->ts_last_change); + vty_out (vty, " Last state change %s ago, due to %s%s", + ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), + (nbr->last_event_str ? nbr->last_event_str : "??"), + VTY_NEWLINE); + } /* Show Designated Rotuer ID. */ vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); /* Show Backup Designated Rotuer ID. */ -- cgit v1.2.3 From 3fed4160cd23f1767d8980e8cba10bc3933947d5 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Tue, 25 Jul 2006 20:44:12 +0000 Subject: [ospfd] Additional NSM neighbour state change stats/information 2006-07-25 Paul Jakma * ospf_neigbor.h: (struct ospf_neighbor) Add some additional neighbour state statistics fields, timestamps for progressive and regressive state changes, and pointer to event string for the latter state change. * ospf_nsm.c: (nsm_notice_state_change) Update new state changs history as required. * ospf_vty.c: (show_ip_ospf_neighbor_detail_sub) Print out above new per-neighbour state change stats. --- ospfd/ospf_vty.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 44049d8c..912f1d09 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3155,12 +3155,21 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); /* Show state changes. */ vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); - if (nbr->ts_last_change.tv_sec || nbr->ts_last_change.tv_usec) + if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) { - struct timeval res = tv_sub (recent_time, nbr->ts_last_change); - vty_out (vty, " Last state change %s ago, due to %s%s", + struct timeval res = tv_sub (recent_time, nbr->ts_last_progress); + vty_out (vty, " Most recent state change statistics:%s", + VTY_NEWLINE); + vty_out (vty, " Progressive change %s ago%s", + ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), + VTY_NEWLINE); + } + if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) + { + struct timeval res = tv_sub (recent_time, nbr->ts_last_regress); + vty_out (vty, " Regressive change %s ago, due to %s%s", ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), - (nbr->last_event_str ? nbr->last_event_str : "??"), + (nbr->last_regress_str ? nbr->last_regress_str : "??"), VTY_NEWLINE); } /* Show Designated Rotuer ID. */ -- cgit v1.2.3 From 2518efd15b75687d4791a5eb4b0d7febc36cffbc Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 27 Aug 2006 06:49:29 +0000 Subject: [ospfd] Bug #134, ospfd should be more robust to backward time change 2006-08-25 Paul Jakma * (general) Bug #134. Be more robust to backward time changes, use the newly added libzebra time functions. In most cases: recent_time -> recent_relative_time() gettimeofday -> quagga_gettime (QUAGGA_CLK_MONOTONIC, ..) time -> quagga_time. (ospf_make_md5_digest) time() call deliberately not changed. (ospf_external_lsa_refresh) remove useless gettimeofday, LSA tv_orig time was already set in ospf_lsa_new, called via ospf_external_lsa_new. --- ospfd/ospf_vty.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 912f1d09..04e1df46 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2691,7 +2691,7 @@ DEFUN (show_ip_ospf, vty_out (vty, " SPF algorithm "); if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) { - result = tv_sub (recent_time, ospf->ts_spf); + result = tv_sub (recent_relative_time (), ospf->ts_spf); vty_out (vty, "last executed %s ago%s", ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), VTY_NEWLINE); @@ -3157,7 +3157,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) { - struct timeval res = tv_sub (recent_time, nbr->ts_last_progress); + struct timeval res + = tv_sub (recent_relative_time (), nbr->ts_last_progress); vty_out (vty, " Most recent state change statistics:%s", VTY_NEWLINE); vty_out (vty, " Progressive change %s ago%s", @@ -3166,7 +3167,8 @@ show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, } if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) { - struct timeval res = tv_sub (recent_time, nbr->ts_last_regress); + struct timeval res + = tv_sub (recent_relative_time (), nbr->ts_last_regress); vty_out (vty, " Regressive change %s ago, due to %s%s", ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), (nbr->last_regress_str ? nbr->last_regress_str : "??"), -- cgit v1.2.3 From 7ffa8fa2322fb759cf1f93730cde2cee3d4ad8ee Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 22 Oct 2006 20:07:53 +0000 Subject: [ospfd] Add passive-interface default support 2006-10-22 Yar Tikhiy * (general) Add support for passive-interface default (with minor edits by Paul Jakma). * ospf_interface.h: Add OSPF_IF_PASSIVE_STATUS macro, looking at configured value, or the global 'default' value, as required. * ospf_interface.c: (ospf_if_new_hook) Leave passive unconfigured per default, allowing global 'default' to take effect for unconfigured interfaces. * ospf_packet.c: (various) use OSPF_IF_PASSIVE_STATUS * ospf_vty.c: (ospf_passive_interface_default) new function, unset passive from all interfaces if default is enabled, as the per-iface settings become redundant. (ospf_passive_interface_update) new func, update passive setting taking global default into account. ({no,}ospf_passive_interface_addr_cmd) Add support for 'default' variant of command. (show_ip_ospf_interface_sub) Update to take global default into account when printing passive status. (ospf_config_write) ditto. * ospfd.c: (ospf_new) set global passive-interface default. * ospfd.h: (struct ospf) Add field for global passive-interface. --- ospfd/ospf_vty.c | 191 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 143 insertions(+), 48 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 04e1df46..0e3a77d8 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -249,39 +249,98 @@ ALIAS (no_ospf_router_id, NO_STR "router-id for the OSPF process\n") +static void +ospf_passive_interface_default (struct ospf *ospf) +{ + struct listnode *ln; + struct interface *ifp; + struct ospf_interface *oi; + + for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) + { + if (ifp && + OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) + UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); + } + for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) + { + if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) + UNSET_IF_PARAM (oi->params, passive_interface); + } +} + +static void +ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, + struct in_addr addr, + struct ospf_if_params *params, u_char value) +{ + u_char dflt; + + params->passive_interface = value; + if (params != IF_DEF_PARAMS (ifp)) + { + if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) + dflt = IF_DEF_PARAMS (ifp)->passive_interface; + else + dflt = ospf->passive_interface_default; + + if (value != dflt) + SET_IF_PARAM (params, passive_interface); + else + UNSET_IF_PARAM (params, passive_interface); + + ospf_free_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + else + { + if (value != ospf->passive_interface_default) + SET_IF_PARAM (params, passive_interface); + else + UNSET_IF_PARAM (params, passive_interface); + } +} + DEFUN (ospf_passive_interface, ospf_passive_interface_addr_cmd, "passive-interface IFNAME A.B.C.D", "Suppress routing updates on an interface\n" "Interface's name\n") { - struct interface *ifp; - struct in_addr addr; - int ret; - struct ospf_if_params *params; - struct route_node *rn; + struct interface *ifp; + struct in_addr addr; + int ret; + struct ospf_if_params *params; + struct route_node *rn; + struct ospf *ospf = vty->index; - ifp = if_get_by_name (argv[0]); + ifp = if_get_by_name (argv[0]); params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 0) { - ret = inet_aton(argv[1], &addr); - if (!ret) - { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - params = ospf_get_if_params (ifp, addr); - ospf_if_update_params (ifp, addr); + ospf->passive_interface_default = OSPF_IF_PASSIVE; + ospf_passive_interface_default (ospf); } + else + { + if (argc == 2) + { + ret = inet_aton(argv[1], &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } - SET_IF_PARAM (params, passive_interface); - params->passive_interface = OSPF_IF_PASSIVE; - + params = ospf_get_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); + } + ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); + } + /* XXX We should call ospf_if_set_multicast on exactly those * interfaces for which the passive property changed. It is too much * work to determine this set, so we do this for every interface. @@ -289,6 +348,7 @@ DEFUN (ospf_passive_interface, * record of joined groups to avoid systems calls if the desired * memberships match the current memership. */ + for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) { struct ospf_interface *oi = rn->info; @@ -312,6 +372,12 @@ ALIAS (ospf_passive_interface, "Suppress routing updates on an interface\n" "Interface's name\n") +ALIAS (ospf_passive_interface, + ospf_passive_interface_default_cmd, + "passive-interface default", + "Suppress routing updates on an interface\n" + "Suppress routing updates on interfaces by default\n") + DEFUN (no_ospf_passive_interface, no_ospf_passive_interface_addr_cmd, "no passive-interface IFNAME A.B.C.D", @@ -324,33 +390,34 @@ DEFUN (no_ospf_passive_interface, struct ospf_if_params *params; int ret; struct route_node *rn; + struct ospf *ospf = vty->index; ifp = if_get_by_name (argv[0]); params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 0) { - ret = inet_aton(argv[1], &addr); - if (!ret) - { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTY_NEWLINE); - return CMD_WARNING; - } - - params = ospf_lookup_if_params (ifp, addr); - if (params == NULL) - return CMD_SUCCESS; + ospf->passive_interface_default = OSPF_IF_ACTIVE; + ospf_passive_interface_default (ospf); } - - UNSET_IF_PARAM (params, passive_interface); - params->passive_interface = OSPF_IF_ACTIVE; - - if (params != IF_DEF_PARAMS (ifp)) + else { - ospf_free_if_params (ifp, addr); - ospf_if_update_params (ifp, addr); + if (argc == 2) + { + ret = inet_aton(argv[1], &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } + + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; + } + ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); } /* XXX We should call ospf_if_set_multicast on exactly those @@ -378,6 +445,13 @@ ALIAS (no_ospf_passive_interface, "Allow routing updates on an interface\n" "Interface's name\n") +ALIAS (no_ospf_passive_interface, + no_ospf_passive_interface_default_cmd, + "no passive-interface default", + NO_STR + "Allow routing updates on an interface\n" + "Allow routing updates on interfaces by default\n") + DEFUN (ospf_network_area, ospf_network_area_cmd, "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", @@ -2883,14 +2957,14 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, OSPF_IF_PARAM (oi, retransmit_interval), VTY_NEWLINE); - if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) + if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) { char timebuf[OSPF_TIME_DUMP_SIZE]; vty_out (vty, " Hello due in %s%s", ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), VTY_NEWLINE); } - else /* OSPF_IF_PASSIVE is set */ + else /* passive-interface is set */ vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", @@ -7868,17 +7942,36 @@ ospf_config_write (struct vty *vty) config_write_ospf_redistribute (vty, ospf); /* passive-interface print. */ + if (ospf->passive_interface_default == OSPF_IF_PASSIVE) + vty_out (vty, " passive-interface default%s", VTY_NEWLINE); + for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) - if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) - vty_out (vty, " passive-interface %s%s", - ifp->name, VTY_NEWLINE); - + if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) + && IF_DEF_PARAMS (ifp)->passive_interface != + ospf->passive_interface_default) + { + vty_out (vty, " %spassive-interface %s%s", + IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", + ifp->name, VTY_NEWLINE); + } for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) - if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && - oi->params->passive_interface == OSPF_IF_PASSIVE) - vty_out (vty, " passive-interface %s %s%s", + { + if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) + continue; + if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), + passive_interface)) + { + if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) + continue; + } + else if (oi->params->passive_interface == ospf->passive_interface_default) + continue; + + vty_out (vty, " %spassive-interface %s %s%s", + oi->params->passive_interface ? "" : "no ", oi->ifp->name, inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); + } /* Network area print. */ config_write_network_area (vty, ospf); @@ -8199,8 +8292,10 @@ ospf_vty_init (void) /* "passive-interface" commands. */ install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); install_element (OSPF_NODE, &ospf_passive_interface_cmd); + install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); + install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); /* "ospf abr-type" commands. */ install_element (OSPF_NODE, &ospf_abr_type_cmd); -- cgit v1.2.3 From 435408866187f3bc3c49b26f11bc83c374e55dd5 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 28 Nov 2006 16:36:39 +0000 Subject: [ospfd] Fix bug in passive-interface default commands. 2006-11-28 Andrew J. Schorr * ospf_vty.c: (ospf_passive_interface_default) Take additional 'newval' arg so we can update ospf->passive_interface_default inside this function. More importantly, we now call ospf_if_set_multicast on all ospf_interfaces. (ospf_passive_interface, no_ospf_passive_interface) Fix bug: for 'default' case, argv[0] is undefined, so we must test for (argc == 0) before using argv[0]. And since ospf_passive_interface_default now calls ospf_if_set_multicast as needed, we can just return after calling ospf_passive_interface_default. --- ospfd/ospf_vty.c | 86 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0e3a77d8..d6da11dc 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -250,12 +250,14 @@ ALIAS (no_ospf_router_id, "router-id for the OSPF process\n") static void -ospf_passive_interface_default (struct ospf *ospf) +ospf_passive_interface_default (struct ospf *ospf, u_char newval) { struct listnode *ln; struct interface *ifp; struct ospf_interface *oi; + ospf->passive_interface_default = newval; + for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) { if (ifp && @@ -266,6 +268,8 @@ ospf_passive_interface_default (struct ospf *ospf) { if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) UNSET_IF_PARAM (oi->params, passive_interface); + /* update multicast memberships */ + ospf_if_set_multicast(oi); } } @@ -314,33 +318,31 @@ DEFUN (ospf_passive_interface, struct route_node *rn; struct ospf *ospf = vty->index; + if (argc == 0) + { + ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); + return CMD_SUCCESS; + } + ifp = if_get_by_name (argv[0]); params = IF_DEF_PARAMS (ifp); - if (argc == 0) - { - ospf->passive_interface_default = OSPF_IF_PASSIVE; - ospf_passive_interface_default (ospf); - } - else + if (argc == 2) { - if (argc == 2) - { - ret = inet_aton(argv[1], &addr); - if (!ret) - { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTY_NEWLINE); - return CMD_WARNING; - } + ret = inet_aton(argv[1], &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } - params = ospf_get_if_params (ifp, addr); - ospf_if_update_params (ifp, addr); - } - ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); + params = ospf_get_if_params (ifp, addr); + ospf_if_update_params (ifp, addr); } - + ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); + /* XXX We should call ospf_if_set_multicast on exactly those * interfaces for which the passive property changed. It is too much * work to determine this set, so we do this for every interface. @@ -354,7 +356,7 @@ DEFUN (ospf_passive_interface, struct ospf_interface *oi = rn->info; if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) - ospf_if_set_multicast(oi); + ospf_if_set_multicast(oi); } /* * XXX It is not clear what state transitions the interface needs to @@ -391,34 +393,32 @@ DEFUN (no_ospf_passive_interface, int ret; struct route_node *rn; struct ospf *ospf = vty->index; + + if (argc == 0) + { + ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); + return CMD_SUCCESS; + } ifp = if_get_by_name (argv[0]); params = IF_DEF_PARAMS (ifp); - if (argc == 0) - { - ospf->passive_interface_default = OSPF_IF_ACTIVE; - ospf_passive_interface_default (ospf); - } - else + if (argc == 2) { - if (argc == 2) - { - ret = inet_aton(argv[1], &addr); - if (!ret) - { - vty_out (vty, "Please specify interface address by A.B.C.D%s", - VTY_NEWLINE); - return CMD_WARNING; - } + ret = inet_aton(argv[1], &addr); + if (!ret) + { + vty_out (vty, "Please specify interface address by A.B.C.D%s", + VTY_NEWLINE); + return CMD_WARNING; + } - params = ospf_lookup_if_params (ifp, addr); - if (params == NULL) - return CMD_SUCCESS; - } - ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); + params = ospf_lookup_if_params (ifp, addr); + if (params == NULL) + return CMD_SUCCESS; } + ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); /* XXX We should call ospf_if_set_multicast on exactly those * interfaces for which the passive property changed. It is too much @@ -2865,7 +2865,7 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct in_addr *dest; const char *dstr; - if ((ifp->flags & IFF_POINTOPOINT) + if ((ifp->flags & IFF_POINTOPOINT) || oi->type == OSPF_IFTYPE_VIRTUALLINK) dstr = "Peer"; else -- cgit v1.2.3 From e4529636b77124285cca96a62799d0ff6a7addeb Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 12 Dec 2006 19:18:21 +0000 Subject: [PtP over ethernet] New peer flag allows much more addressing flexibility 2006-12-12 Andrew J. Schorr * if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating whether a peer address has been configured. Comment now shows the new interpretation of the destination addr: if ZEBRA_IFA_PEER is set, then it must contain the destination address, otherwise it may contain the broadcast address or be NULL. (CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete macros that were specific to IPv4 and not fully general. (CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag. (CONNECTED_PREFIX) New macro giving the prefix to insert into the RIB: if CONNECTED_PEER, then use the destination (peer) address, else use the address field. (CONNECTED_ID) New macro to come up with an identifying address for the struct connected. * if.c: (if_lookup_address, connected_lookup_address) Streamline logic with new CONNECTED_PREFIX macro. * prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros for better performance than the general prefix_copy function. * zclient.c: (zebra_interface_address_read) For non-null destination addresses, set prefixlen to equal the address prefixlen. This is needed to get the new CONNECTED_PREFIX macro to work properly. * connected.c: (connected_up_ipv4, connected_down_ipv4, connected_up_ipv6, connected_down_ipv6) Simplify logic using the new CONNECTED_PREFIX macro. (connected_add_ipv4) Set prefixlen in destination addresses (required by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead of testing for IFF_POINTOPOINT. Delete invalid warning message. Warn about cases where the ZEBRA_IFA_PEER is set but no destination address has been supplied (and turn off the flag). (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning. Set prefixlen in destination address so CONNECTED_PREFIX will work. * connected.h: (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. * interface.c: (connected_dump_vty) Use CONNECTED_PEER macro to decide whether the destination address is a peer or broadcast address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT). * if_ioctl.c: (if_getaddrs) Instead of setting a peer address only when the IFF_POINTOPOINT is set, we now accept a peer address whenever it is available and not the same as the local address. Otherwise (no peer address assigned), we check for a broadcast address (regardless of the IFF_BROADCAST flag). And must now pass a flags value of ZEBRA_IFA_PEER to connected_add_ipv4 when a peer address is assigned. The same new logic is used with the IPv6 code as well (and we pass the new flags argument to connected_add_ipv6). (if_get_addr) Do not bother to check IFF_POINTOPOINT: just issue the SIOCGIFDSTADDR ioctl and see if we get back a peer address not matching the local address (and set the ZEBRA_IFA_PEER in that case). If there's no peer address, try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set. * if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl without bothering to check the IFF_POINTOPOINT flag. And if no peer address was found, just try the SIOCGLIFBRDADDR ioctl without checking the IFF_BROADCAST flag. Call connected_add_ipv4 and connected_add_ipv6 with appropriate flags. * if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to connected_add_ipv6. * kernel_socket.c: (ifam_read) Must pass new flags argument to connected_add_ipv6. * rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2 to determine local and possible peer address (so there's no longer a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately. Pass new flags argument to connected_add_ipv6. (netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast to determine whether the connected destination address is a broadcast address. * bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete) Simplify logic by using new CONNECTED_PREFIX macro. * ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix, ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX macro. * ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX macro, both options collapse into the same code. * ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new CONNECTED_ID macro. (ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX macro. * ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro instead of testing the IFF_POINTOPOINT flag. * ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro instead of testing with if_is_pointopoint. And add commented-out code to implement alternative (in my opinion) more elegant behavior that has no special-case treatment for PtP addresses. (ospf_network_run) Use new CONNECTED_ID macro to simplify logic. * rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID macro to simplify logic. (rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does not give a useful result if prefixlen is 32 (we require a peer address in such cases). * ripd.c: (rip_update_interface) Fix same bug as above. --- ospfd/ospf_vty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index d6da11dc..dd700b0e 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2865,8 +2865,8 @@ show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct in_addr *dest; const char *dstr; - if ((ifp->flags & IFF_POINTOPOINT) - || oi->type == OSPF_IFTYPE_VIRTUALLINK) + if (CONNECTED_PEER(oi->connected) + || oi->type == OSPF_IFTYPE_VIRTUALLINK) dstr = "Peer"; else dstr = "Broadcast"; -- cgit v1.2.3 From 5dcf71df9649cf9c7afd26e0fd3772486ab262f6 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 10 May 2007 03:00:09 +0000 Subject: [ospfd] Fix address qualified 'ip ospf auth' commands 2007-05-09 Milan Kocian * ospf_vty.c: Fix commands: 'ip ospf authentication A.B.C.D', 'no ip ospf authentication A.B.C.D', 'no ip ospf authentication-key A.B.C.D'. Simply fix argv's indexes and argc check in DEFUN functions. --- ospfd/ospf_vty.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index dd700b0e..5f9fa2cb 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -4403,7 +4403,7 @@ DEFUN (ip_ospf_authentication, if (argc == 1) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[0], &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -4447,7 +4447,7 @@ DEFUN (no_ip_ospf_authentication, if (argc == 1) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[0], &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", @@ -4551,9 +4551,9 @@ DEFUN (no_ip_ospf_authentication_key, ifp = vty->index; params = IF_DEF_PARAMS (ifp); - if (argc == 2) + if (argc == 1) { - ret = inet_aton(argv[1], &addr); + ret = inet_aton(argv[0], &addr); if (!ret) { vty_out (vty, "Please specify interface address by A.B.C.D%s", -- cgit v1.2.3 From 30a2231a4881f53deca61ef7a62b225a43dab4c5 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Fri, 15 Aug 2008 14:05:22 +0100 Subject: [warnings] Fix various SOS warnings 2008-08-15 Paul Jakma * */*: Fix various problems flagged by Sun Studio compiler. - ' ' obsolescent in declarations - empty statements (';' after ALIAS definitions) - implicit declarations (e.g printstack in lib/log.c) - "\%" in printf string instead of "%%" - loops that return on the first iteration (legitimately, but compiler can't really know), e.g. bgp_routemap.c - internal declarations which mask prototypes. --- ospfd/ospf_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 5f9fa2cb..5307b413 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -50,7 +50,7 @@ #include "ospfd/ospf_dump.h" -const static char *ospf_network_type_str[] = +static const char *ospf_network_type_str[] = { "Null", "POINTOPOINT", -- cgit v1.2.3 From 35f891404a6d2f0d034ca0fb724904db72baf552 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Tue, 1 Jul 2008 16:54:07 +0200 Subject: Fix SEGV in ip ospf neighbor all Dont use vty->index in show_ip_ospf_neighbor_all_cmd(), It is invalid, use ospf_lookup() instead. --- ospfd/ospf_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ospfd/ospf_vty.c') diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 5307b413..11f12c5c 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3093,7 +3093,7 @@ DEFUN (show_ip_ospf_neighbor_all, "Neighbor list\n" "include down status neighbor\n") { - struct ospf *ospf = vty->index; + struct ospf *ospf = ospf_lookup (); struct listnode *node; struct ospf_interface *oi; -- cgit v1.2.3