From 43b93e7bd98960b4743a1c9e80dfa6863f71ba26 Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Sat, 12 Dec 2020 22:57:07 +0100 Subject: [PATCH 01/36] rip out legacy code --- net/frr/Makefile | 2 +- .../src/opnsense/scripts/quagga/diag-bgp.sh | 20 - net/frr/src/opnsense/scripts/quagga/quagga.rb | 757 ------------------ .../conf/actions.d/actions_quagga.conf | 192 +++-- 4 files changed, 145 insertions(+), 826 deletions(-) delete mode 100755 net/frr/src/opnsense/scripts/quagga/diag-bgp.sh delete mode 100755 net/frr/src/opnsense/scripts/quagga/quagga.rb diff --git a/net/frr/Makefile b/net/frr/Makefile index 1cad170a0..ae31d1269 100644 --- a/net/frr/Makefile +++ b/net/frr/Makefile @@ -1,7 +1,7 @@ PLUGIN_NAME= frr PLUGIN_VERSION= 1.20 PLUGIN_COMMENT= The FRRouting Protocol Suite -PLUGIN_DEPENDS= frr7 ruby +PLUGIN_DEPENDS= frr7 PLUGIN_MAINTAINER= franz.fabian.94@gmail.com .include "../../Mk/plugins.mk" diff --git a/net/frr/src/opnsense/scripts/quagga/diag-bgp.sh b/net/frr/src/opnsense/scripts/quagga/diag-bgp.sh deleted file mode 100755 index 4d6e81f26..000000000 --- a/net/frr/src/opnsense/scripts/quagga/diag-bgp.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -case "$1" in - bgp) - vtysh -d bgpd -c "show ip bgp" - ;; - summary) - vtysh -d bgpd -c "show bgp summary" - ;; - neighbor) - vtysh -d bgpd -c "show ip bgp neighbors $2" - ;; - neighbor-adv) - vtysh -d bgpd -c "show ip bgp neighbors $2 advertised-routes" - ;; - *) - echo "Usage: $0 bgp|summary|neighbor |neighbor-adv " - exit 1 -esac -exit 0 diff --git a/net/frr/src/opnsense/scripts/quagga/quagga.rb b/net/frr/src/opnsense/scripts/quagga/quagga.rb deleted file mode 100755 index a59427855..000000000 --- a/net/frr/src/opnsense/scripts/quagga/quagga.rb +++ /dev/null @@ -1,757 +0,0 @@ -#!/usr/local/bin/ruby -=begin -Copyright 2017 Fabian Franz -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -=end - -require 'json' -require 'shellwords' -require 'pp' - -$QUAGGA_DEBUG = false - -class VTYSH - def initialize(path = '/usr/local/bin/vtysh') - @path = path - end - - def execute(param) - o = `#{@path} -c #{param.shellescape}` - raise "error" if o.length <= 2 - raise "command error - command: #{param}" if o.include? "% Unknown command" - o - end - - #def execute(param) - # fn = param.sub("show","sh").gsub(" ","_") - # File.read(fn) - #end -end - -class QuaggaTableReader - attr_accessor :headers - def initialize(headers = []) - @headers = headers - end - def read_headline(line, start_without_header = false, start_without_header_name = 'status') - # get begin of header (number of the first char of the string) - header = line - header_offset = {} - header_offset[0] = start_without_header_name if start_without_header - @headers.map do |x| - header_offset[header.index(x)] = x.strip - end - - - # make ranges: this will make a range of the first char of the sting until - # the the char befor the next heading begins - ranges = [] - 0.upto (header_offset.keys.length - 2) do |i| - ranges << ((header_offset.keys[i])...(header_offset.keys[i + 1])) - end - # the last one has no next heading - this will go to the end of the line - ranges.push ((header_offset.keys.last)..-1) # path - @header_offset = header_offset - @ranges = ranges - nil - end - - def read_entry(line, expand_fields = {}) - raise "heading missing" unless @ranges - tmp = {} - return tmp unless line&.strip.length > 2 - - @ranges.each do |r| - # the string starts here - b = r.begin - # get the heading starting where the string starts - n = @header_offset[b] - # get the data or return an empty string - tmp[n] = line[r]&.strip || "" - end - # replace characters by the meaning - expand_fields.keys.each do |key| - tmp[key] = tmp[key].split("").map {|x| {dn: expand_fields[key][x], abb: x} } if tmp[key] - end - tmp - end -end - -class General - def initialize(vtysh) - @vtysh = vtysh - end - def routes(ipv6 = false) - lines = @vtysh.execute("show ip#{ipv6 ? 'v6' : ''} route").lines - - # headers - meanings = {} - while (line = lines.shift.strip) != '' - line = line.gsub('Codes: ','') - line.split(",").each do |meaning| - short, long = meaning.strip.split(" - ") - meanings[short] = long - end - end - - # you don't have to understand this regex ;) - entry_regex = /(\S+?)\s+?(\S+?)(?: \[(\d+)\/(\d+)\])? (?:(?:via (\S+?)|is ([^,]+?)|), ([^,\n]+)|(unreachable \(blackhole\)))(?:, (\S+))?/ - entries = [] - while (line = lines.shift&.strip) - if line.length > 10 - code, network, ad, metric, via, direct, interface, unreachable, time = line.scan(entry_regex).first - code = code.split('').map {|c| {short: c, long: meanings[c]}} - entries << {code: code, network: (network || direct), ad: ad, via: via || unreachable, metric: metric, interface: interface, time: time } - end - end - entries - end - - def routes6 - routes(true) - end - -end - -class OSPF - def initialize(vtysh) - @vtysh = vtysh - end - def neighbors - qta = QuaggaTableReader.new(["Neighbor ID", "Pri", "State", "Dead Time", "Address", "Interface", "RXmtL", "RqstL", "DBsmL"]) - lines = @vtysh.execute("show ip ospf neighbor").lines - lines.shift # empty line - data = [] - qta.read_headline(lines.shift) - while (line = lines.shift) && (line.length > 2) - data << qta.read_entry(line) - end - data - end - - def interface - lines = @vtysh.execute("show ip ospf interface").lines - interfaces = {} - current_if = '' - while line = lines.shift - next if line.strip.length <= 1 - if line[0] != ' ' # we are in a heading - current_if = line.split(" ").first - interfaces[current_if] = {} - current_if = interfaces[current_if] - current_if[:enabled] = true - lines.shift - else - line.strip! - case line - when 'OSPF not enabled on this interface' - current_if[:enabled] = false - when /Internet Address ([^,]+?), Broadcast ([^,]+?), Area (.*)/ - current_if[:address] = $1 - current_if[:broadcast] = $2 - current_if[:area] = $3 - when /MTU mismatch detection:(.*)/ - current_if[:mtu_mismatch_detection] = ($1 == 'enabled') - when /Router ID ([^,]+?), Network Type ([^,]+?), Cost: (\d+)/ - current_if[:router_id] = $1 - current_if[:network_type] = $2 - current_if[:cost] = $3.to_i - when /Transmit Delay is (\d+) sec, State ([^,]+?), Priority (\d+)/ - current_if[:transmit_delay] = $1.to_i - current_if[:state] = $2 - current_if[:priority] = $3.to_i - when "No designated router on this network" - current_if[:designated_router] = nil - when /Designated Router \(ID\) ([^,]+?), Interface Address (.*)/ - current_if[:designated_router] = $1 - current_if[:designated_router_interface_address] = $2 - when "No backup designated router on this network" - current_if[:backup_designated_router] = nil - when /Timer intervals configured, Hello (\d+)s, Dead (\d+)s, Wait (\d+)s, Retransmit (\d+)/ - current_if[:intervals] = {hello: $1.to_i, dead: $2.to_i, wait: $3.to_i, retransmit: $4.to_i} - when /Multicast group memberships: (.*)/ - current_if[:multicast_group_memberships] = $1.split(" ") - when /Hello due in ([\d\.]+|inactive)s?/ - current_if[:hello_due_in] = $1 == 'inactive' ? $1 : $1.to_f - when /Neighbor Count is (\d+), Adjacent neighbor count is (\d+)/ - current_if[:neighbor_count] = $1.to_i - current_if[:adjacent_neighbor_count] = $2.to_i - else - # make sure there is an array to write in - current_if[:unparsed] ||= [] - current_if[:unparsed] << line - puts line if $QUAGGA_DEBUG - end - end - end - interfaces - end - - def database - lines = @vtysh.execute("show ip ospf database").lines - db = {} - heading = '' - router = '' - router_link_states_area = '' - mode = :none - qta = nil - while line = lines.shift - next if line == '' - if line[0] == ' ' # heading - heading = line.strip - case heading - when /OSPF Router with ID \(([\.\d]+)\)/ - router = $1 - db[router] ||= {} - mode = :router - when /Router Link States \(Area ([\.\d]+)\)/ - router_link_states_area = $1 - db[router]['router_link_state_area'] ||= {} - db[router]['router_link_state_area'][$1] ||= [] - mode = :router_link_state - qta = nil - when /Net Link States \(Area ([\.\d]+)\)/ - net_link_states_area = $1 - db[router]['net_link_state_area'] ||= {} - db[router]['net_link_state_area'][$1] ||= [] - mode = :net_link_state - qta = nil - when 'AS External Link States' - mode = :states - db[router]['external_states'] ||= [] - qta = nil - else - puts "unknown heading" if $QUAGGA_DEBUG - end - else - if qta == nil - case mode - when :router_link_state - qta = QuaggaTableReader.new(["Link ID", "ADV Router", "Age", "Seq#", "CkSum", "Link count"]) - when :net_link_state - qta = QuaggaTableReader.new(["Link ID", "ADV Router", "Age", "Seq#", "CkSum"]) - when :states - qta = QuaggaTableReader.new(["Link ID", "ADV Router", "Age", "Seq#", "CkSum", "Route\n"]) - else - next - end - headline = lines.shift - qta.read_headline(headline,true) - else - entry = qta.read_entry(line) - case mode - when :router_link_state - db[router]['router_link_state_area'][router_link_states_area] << entry - when :net_link_state - db[router]['net_link_state_area'][net_link_states_area] << entry - when :states - db[router]['external_states'] << entry - end - end - end - # table - end - db - end - - def route - lines = @vtysh.execute("show ip ospf route").lines - heading = '' - route = {} - last_line = [] - while line = lines.shift - if line[0] == "=" #heading - heading = line.scan(/=* ([^=]*) =*/).first.first - route[heading] = [] - else # data - case line.strip - when /N\s+([\d\.\/]+)\s+\[(\d+)\]\s+area:\s(.*)/ - last_line = {network: $1, cost: $2.to_i, area: $3, type: 'N'} - route[heading] << last_line - when /N (E(?:\d+) (?:\S+))\s+\[([\d\/]+)\] tag: (\d+)/ - last_line = {network: $1, cost: $2, tag: $3.to_i, type: 'N'} - route[heading] << last_line - when /(?:(directly attached) to|via ([^,]+),) (.*)/ - last_line[:via] = $1 || $2 - last_line[:via_interface] = $3 - when /R\s+(\S+)\s+\[(\d+)\] area: ([^,]+)(, ASBR)/ - last_line = {ip: $1, cost: $2.to_i, area: $3, asbr: (", ASBR" == $4), type: 'R'} - route[heading] << last_line - else - puts line if $QUAGGA_DEBUG - end - end - end - route - end - - def overview - lines = @vtysh.execute("show ip ospf").lines - overview = {rfc2328_conform: false, asbr: false} - while line = lines.shift&.strip - case line - when /OSPF Routing Process, Router ID: ([\d\.]+)/ - overview[:router_id] = $1 - when "This implementation conforms to RFC2328" - overview[:rfc2328_conform] = true - when /OpaqueCapability flag is (\S+)/ - overview[:opaque_capability] = ($1 == 'enabled') - when /Initial SPF scheduling delay (\d+) millisec\(s\)/ - overview[:initial_spf_scheduling_delay] = $1.to_i - when /(Min|Max)imum hold time between consecutive SPFs (\d+) millisec\(s\)/ - overview[:hold_time] ||= {} - overview[:hold_time][$1.downcase] = $2.to_i - when "This router is an ASBR (injecting external routing information)" - overview[:asbr] = true - when /Number of external LSA (\d+). Checksum Sum ([x\d]+)/ - overview[:external_lsa] = {count: $1.to_i, checksum: $2} - when /Number of opaque AS LSA (\d+). Checksum Sum ([x\d]+)/ - overview[:opaque_as_lsa] = {count: $1.to_i, checksum: $2} - when /Refresh timer (\d+) secs/ - overview[:refresh_timer] = $1.to_i - when /Number of areas attached to this router: (\d+)/ - overview[:areas_attached_count] = $1.to_i - when /Hold time multiplier is currently (\d+)/ - overview[:current_hold_time_multipier] = $1.to_i - when /RFC1583Compatibility flag is (\S+)/ - overview[:rfc1583_compatibility] = ($1 == 'enabled') - when /SPF timer is (.*)/ - overview[:spf_timer] = $1 - when "" - break - else - puts line if $QUAGGA_DEBUG - end - end - # general overview has ended - now the area overviews come - overview[:areas] = {} - current_area = {} - while line = lines.shift&.strip - case line - when /Area ID: (.*)/ - current_area = {} - overview[:areas][$1] = current_area - when /Number of interfaces in this area: Total: (\d+), Active: (\d+)/ - current_area[:interfaces] = {total: $1.to_i,active: $2.to_i} - when /Number of (router|network|summary) LSA (\d+). Checksum Sum ([\da-fx]+)/ - current_area[:lsa] ||= {} - current_area[:lsa][$1] = {count: $2.to_i, checksum: $3} - when /Number of LSA (\d+)/ - current_area[:lsa] ||= {} - current_area[:lsa][:count] = $1.to_i - when /Number of (opaque (?:area|link)|NSSA|ASBR summary) LSA (\d+). Checksum Sum ([\da-fx]+)/ - current_area[:lsa] ||= {} - current_area[:lsa][$1] = {count: $2.to_i, checksum: $3} - when /Number of fully adjacent neighbors in this area: (\d+)/ - current_area[:fully_adjacent_neighbor_count] = $1.to_i - when /SPF algorithm executed (\d) times/ - current_area[:spf_exec_count] = $1.to_i - when "Area has no authentication" - current_area[:auth] = "none" - else - puts line if $QUAGGA_DEBUG - end - end - overview - end -end - -class BGP - def initialize(sh) - @vtysh = sh - end - - def overview - output = @vtysh.execute('show ip bgp') - return {} if output.include? "No BGP process is configured" - return {} unless output.include? 'version' # we get an empty output if quagga is not running - output = output.split("\n") - bgp = {} - - # Process the header/definitions - while line = output.shift&.rstrip - case line - when /^BGP table version/ - x,y = line.scan(/.*?version is (\d+).*?ID is ([0-9\.]+).*/).first - bgp['table_version'] = x - bgp['local_router_id'] = y - when /^Status codes/ - # find out, what the status abbreviations mean - status_codes = {} - line.split(":").last.strip.split(",").each do |x| - k,v = x.strip.split(" ") - status_codes[k] = v - end - while line.end_with? "," - line = output.shift - line.strip.split(",").each do |x| - k,v = x.strip.split(" ") - status_codes[k] = v - end - end - when /^Origin codes/ - # same like before but for the origin codes - origin_codes = {} - line.split(":").last.strip.split(",").each do |x| - k,v = x.strip.split(" - ") - origin_codes[k] = v - end - when /^Nexthop codes/ - # Just eat this line, nothing to do with it - when "" - # Found the end of the header, reached the table - break - else - # eat all other (unexpected) lines - puts line if $QUAGGA_DEBUG - end - end - - # Process the tabular data - bgp['output'] = [] - qta = QuaggaTableReader.new(["Network", "Next Hop", "Metric", "LocPrf", "Weight", "Path"]) - qta.read_headline(output.shift,true) - while line = output.shift&.strip - break if line == '' - data = qta.read_entry(line) - data['status'] = data['status'].split("").map {|x| {dn: status_codes[x], abb: x} } - data['Path'] = data['Path'].split("").map {|x| {dn: origin_codes[x], abb: x} } - bgp['output'] << data - end - bgp - end -end - -class OSPFv3 - def initialize(sh) - @vtysh = sh - end - - def overview - lines = @vtysh.execute("show ipv6 ospf6").lines - overview = {} - while line = lines.shift&.strip - case line - when /OSPFv3 Routing Process \((\d+)\) with Router-ID ([\d\.]+)/ - overview[:router_id] = $2 - overview[:routing_process] = $1.to_i - when /Initial SPF scheduling delay (\d+) millisec\(s\)/ - overview[:initial_spf_scheduling_delay] = $1.to_i - # this line contains a typo in the output - I made it to work with and without - # this typo - when /(Min|Max)imum hold time between consecutive SPFs (\d+) milli?second\(s\)/ - overview[:hold_time] ||= {} - overview[:hold_time][$1.downcase] = $2.to_i - when "This router is an ASBR (injecting external routing information)" - overview[:asbr] = true - when /SPF timer is (.*)/ - overview[:spf_timer] = $1 - when /Running (.*)/ - overview[:running_time] = $1 - when /Number of AS scoped LSAs is (\d+)/ - overview[:number_as_scoped] = $1.to_i - when /Hold time multiplier is currently (\d+)/ - overview[:current_hold_time_multipier] = $1.to_i - when /Number of areas in this router is (\d+)/ - overview[:number_of_areas] = $1.to_i - when "" - break - else - # debug - puts line if $QUAGGA_DEBUG - end - end - # general overview has ended - now the area overviews come - overview[:areas] = {} - current_area = {} - while line = lines.shift&.strip - case line - when /^Area ([\d\.]*)/ - current_area = {} - overview[:areas][$1] = current_area - when /Interface attached to this area: (.*)/ - current_area[:interfaces] = $1.split(" ") - when /Number of Area scoped LSAs is (.*)/ - current_area[:number_lsas] = $1.to_i - else - puts line if $QUAGGA_DEBUG - end - end - overview - end - - def linkstate - lines = @vtysh.execute("show ipv6 ospf6 linkstate").lines - linkstate = {} - - qta = nil - current_area = [] - while line = lines.shift&.strip - case line - when /SPF Result in Area (.*)/ - linkstate[$1] = current_area = [] - qta = QuaggaTableReader.new(["Type","Router-ID", "Net-ID", "Rtr-Bits", "Options", "Cost"]) - lines.shift - qta.read_headline(lines.shift) - else - if line.length > 10 - current_area << qta.read_entry(line) - end - end - end - linkstate - end - - def route - route = [] - lines = @vtysh.execute("show ipv6 ospf6 route").lines - - lines.each do |line| - f1, f2, network, gateway, interface, time = line.strip.split(/\s+/) - route << { f1: f1, - f2: f2, - network: network, - gateway: gateway, - interface: interface, - time: time } - end - route - end - - def neighbors - qta = QuaggaTableReader.new(["Neighbor ID","Pri", "DeadTime", "State/IfState", "Duration I/F[State]"]) - neighbor = [] - nb = @vtysh.execute("show ipv6 ospf6 neighbor").lines - qta.read_headline(nb.shift.strip) - while line = nb.shift&.strip - puts line - if line.length > 10 - tmp = qta.read_entry(line) - tmp['Pri'] = tmp['Pri'].to_i - neighbor << tmp - end - end - neighbor - end - def database - lines = @vtysh.execute("show ipv6 ospf6 database").lines - database = {} - mode = :none - area = '' - qta = :none - while line = lines.shift&.strip - case line - when /Area Scoped Link State Database \(Area (.*)\)/ - mode = :scoped_link_db - database[:scoped_link_db] ||= {} - database[:scoped_link_db][$1] = area = [] - qta = database_qta(lines) - when /I\/F Scoped Link State Database \(I\/F (\S+) in Area (.*)\)/ - mode = :if_scoped_link_state - database[:if_scoped_link_state] ||= {} - database[:if_scoped_link_state][$1] ||= {} - area = database[:if_scoped_link_state][$1][$2] ||= [] - qta= database_qta(lines) - when "AS Scoped Link State Database" - mode = :as_scoped - area = database[:as_scoped] ||= [] - qta=database_qta(lines) - # note: i have no data for this but i think it looks like the others - else - if line.length > 10 - area << qta.read_entry(line) - end - end - end - database - end - - def interface - lines = @vtysh.execute("show ipv6 ospf6 interface").lines - int = {} - current_if = {} - while line = lines.shift - if line.length > 5 - case line.strip - when /(\S+) is (down|up), type ([A-Z]+)/ - current_if = int[$1] = {up: ($2 == "up" ? true : false), - type: $3, - enabled: true} - when /Interface ID: (\d+)/ - current_if[:id] = $1.to_i - when /OSPF not enabled on this interface/ - current_if[:enabled] = false - when /Instance ID (\d+), Interface MTU (\d+) \(autodetect: (\d+)\)/ - current_if[:instance_id] = $1.to_i - current_if[:interface_mtu] = $2.to_i - current_if[:interface_mtu_autodetect] = $3.to_i - when "Internet Address:" - # ignore - when /(inet |inet6): (\S+)/ - current_if[:IPv6] ||= [] - current_if[:IPv4] ||= [] - family = $1 == 'inet6' ? :IPv6 : :IPv4 - address = $2 - current_if[family] << address - when /MTU mismatch detection: (en|dis)abled/ - current_if[:mtu_mismatch_detection] = $1 == 'en' - when /DR: (\S+) BDR: (\S+)/ - current_if[:designated_router] = $1 - current_if[:backup_designated_router] = $2 - when /State (\S+), Transmit Delay (\d+) sec, Priority (\d+)/ - current_if[:state] = $1 - current_if[:transmit_delay] = $2.to_i - current_if[:priority] = $3.to_i - when /Number of I\/F scoped LSAs is (\d+)/ - current_if[:number_if_scoped_lsas] = $1.to_i - when /(\d+) Pending LSAs for (\S+) in Time ([\d:]+)(?: (.*))/ - current_if[:pending_lsas] ||= {} - current_if[:pending_lsas][$2] = {time: $3, - count: $1, - flags: $4} - when "Timer intervals configured:" - # ignore - when /Hello (\d+), Dead (\d+), Retransmit (\d+)/ - current_if[:timers] = {hello: $1.to_i, - dead: $2.to_i, - retransmit: $3.to_i } - when /Area ID (\S+), Cost (\d+)/ - current_if[:area_cost] ||= [] - current_if[:area_cost] << {area: $1, cost: $2.to_i } - else - puts line if $QUAGGA_DEBUG - end - end - end - int - end - - private - def database_qta(lines) - # DON'T REMOVE THE SPACES!!! - # For some reasons the fields are right aligned with the fields which makes it hard - # to parse. I don't know a better way to get the correct offset except automatically. - # (Detection of semantic of the fields) - qta = QuaggaTableReader.new(["Type", "LSId", "AdvRouter", " Age", " SeqNum"," Payload"]) - lines.shift - qta.read_headline(lines.shift) - qta - end -end - -require 'optparse' -options = {} - -OptionParser.new do |opts| - opts.banner = "Usage: #{__FILE__} -s section [section specific params]" - #### OSPFv2 - opts.on("-d", "--ospf-database", "Prints the OSPF Database") do |od| - options[:ospf_database] = od - end - opts.on("-r", "--ospf-route", 'print OSPF routing table') do |od| - options[:ospf_route] = od - end - opts.on("-i", "--ospf-interface", 'print OSPF interface information') do |od| - options[:ospf_interface] = od - end - opts.on("-n", "--ospf-neighbor", 'Print OSPF neighbors') do |od| - options[:ospf_neighbors] = od - end - opts.on("-o", "--ospf-overview", "Print OSPF summary") do |od| - options[:ospf_overview] = od - end - #### OSPFv3 - opts.on("-D", "--ospfv3-database", "Prints the OSPFv3 Database") do |od| - options[:ospfv3_database] = od - end - opts.on("-t", "--ospfv3-route", 'print OSPFv3 routing table') do |od| - options[:ospfv3_route] = od - end - opts.on("-I", "--ospfv3-interface", 'print OSPFv3 interface information') do |od| - options[:ospfv3_interface] = od - end - opts.on("-N", "--ospfv3-neighbor", 'Print OSPFv3 neighbors') do |od| - options[:ospfv3_neighbors] = od - end - opts.on("-O", "--ospfv3-overview", "Print OSPFv3 summary") do |od| - options[:ospfv3_overview] = od - end - #### general things about routing - opts.on("-R", "--general-routes", "Print Routing Table (IPv4)") do |od| - options[:general_routes] = od - end - opts.on("-6", "--general-routes6", "Print Routing Table (IPv6)") do |od| - options[:general_routes6] = od - end - ### BGP - opts.on("-B", "--bgp-overview", "Print an overview of BGP") do |od| - options[:bgp_overview] = od - end - ### program opts - opts.on("-H", "--human-readable", "Print the output human readable (not json)") do |od| - options[:human_readable] = od - end - opts.on("-X", "--debug", "Prints debug output") do |od| - $QUAGGA_DEBUG = true - end - opts.on("-h", "--help", "Prints this help") do - puts opts - exit - end -end.parse! -# use the lib -sh = VTYSH.new -ospf = OSPF.new sh -ospfv3 = OSPFv3.new sh -bgp = BGP.new sh -general = General.new sh - -result = {} -options.keys.each do |k| - # if it is true - if options[k] - begin - if k.to_s.include? 'ospf_' - cmd = k.to_s.split('_').last - result[k] = ospf.send(cmd) - elsif k.to_s.include? 'ospfv3' - cmd = k.to_s.split('_').last - result[k] = ospfv3.send(cmd) - elsif k.to_s.include? 'general' - cmd = k.to_s.split('_').last - result[k] = general.send(cmd) - elsif k.to_s.include? 'bgp' - cmd = k.to_s.split('_').last - result[k] = bgp.send(cmd) - end - rescue # do nothing on an error - result[k] = "error" - puts $! if $QUAGGA_DEBUG - end - end -end - -# ospf.database, general.routes, ospf.interface, ospf.neighbors, ospf.route, ospf.overview -if options[:human_readable] - pp result -else - print result.to_json -end diff --git a/net/frr/src/opnsense/service/conf/actions.d/actions_quagga.conf b/net/frr/src/opnsense/service/conf/actions.d/actions_quagga.conf index 1b3075f56..9875177da 100644 --- a/net/frr/src/opnsense/service/conf/actions.d/actions_quagga.conf +++ b/net/frr/src/opnsense/service/conf/actions.d/actions_quagga.conf @@ -22,92 +22,188 @@ parameters: type:script_output message:request quagga -[diag-bgp] -command:/usr/local/opnsense/scripts/quagga/diag-bgp.sh -parameters:%s -type:script_output -message:bgp diagnostics - -[diag-bgp2] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --bgp-overview +[diagnostics.general_running-config] +command:/usr/local/bin/vtysh -c "show running-config" parameters: type:script_output -message:bgp diagnostics +message:FRR diagnosticts "show running-config" -[ospf-database] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospf-database +[diagnostics.general_route] +command:/usr/local/bin/vtysh -c "show ip route" parameters: type:script_output -message: Shows the OSPF database +message:FRR diagnosticts "show ip route" -[ospf-route] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospf-route +[diagnostics.general_route_json] +command:/usr/local/bin/vtysh -c "show ip route json" parameters: type:script_output -message: print OSPF routing table +message:FRR diagnosticts "show ip route json" -[ospf-interface] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospf-interface +[diagnostics.general_route6] +command:/usr/local/bin/vtysh -c "show ipv6 route" parameters: type:script_output -message: print OSPF interface information +message:FRR diagnosticts "show ipv6 route" -[ospf-neighbor] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospf-neighbor +[diagnostics.general_route6_json] +command:/usr/local/bin/vtysh -c "show ipv6 route json" parameters: type:script_output -message: Print OSPF neighbors +message:FRR diagnosticts "show ipv6 route json" -[ospf-overview] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospf-overview +[diagnostics.bgp_overview] +command:/usr/local/bin/vtysh -c "show ip bgp" parameters: type:script_output -message: Print OSPF summary +message:FRR diagnostics "show ip bgp" -[ospfv3-database] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospfv3-database +[diagnostics.bgp_overview_json] +command:/usr/local/bin/vtysh -c "show ip bgp json" parameters: type:script_output -message: Shows the OSPF database +message:FRR diagnostics "show ip bgp json" -[ospfv3-route] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospfv3-route +[diagnostics.bgp_summary] +command:/usr/local/bin/vtysh -c "show ip bgp summary" parameters: type:script_output -message: print OSPF routing table +message:FRR diagnostics "show ip bgp summary" -[ospfv3-interface] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospfv3-interface +[diagnostics.bgp_summary_json] +command:/usr/local/bin/vtysh -c "show ip bgp summary json" parameters: type:script_output -message: print OSPF interface information +message:FRR diagnostics "show ip bgp summary json" -[ospfv3-neighbor] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospfv3-neighbor +[diagnostics.bgp_neighbors] +command:/usr/local/bin/vtysh -c "show ip bgp neighbors" parameters: type:script_output -message: Print OSPF neighbors +message:FRR diagnostics "show ip bgp neighbors" -[ospfv3-overview] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --ospfv3-overview +[diagnostics.bgp_neighbors_json] +command:/usr/local/bin/vtysh -c "show ip bgp neighbors json" parameters: type:script_output -message: Print OSPF summary +message:FRR diagnostics "show ip bgp neighbors json" -[general-routes] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --general-routes +[diagnostics.ospf_overview] +command:/usr/local/bin/vtysh -c "show ip ospf" parameters: type:script_output -message: Print IPv4 Routing Table +message:FRR diagnostics "show ip ospf" -[general-routes6] -command:/usr/local/opnsense/scripts/quagga/quagga.rb --general-routes6 +[diagnostics.ospf_overview_json] +command:/usr/local/bin/vtysh -c "show ip ospf json" parameters: type:script_output -message: Print IPv6 Routing Table +message:FRR diagnostics "show ip ospf json" -[general-runningconfig] -command:/usr/local/bin/vtysh -c "show run" +[diagnostics.ospf_neighbor] +command:/usr/local/bin/vtysh -c "show ip ospf neighbor" parameters: type:script_output -message: Show running configuration +message:FRR diagnostics "show ip ospf neighbor" + +[diagnostics.ospf_neighbor_json] +command:/usr/local/bin/vtysh -c "show ip ospf neighbor json" +parameters: +type:script_output +message:FRR diagnostics "show ip ospf neighbor json" + +[diagnostics.ospf_route] +command:/usr/local/bin/vtysh -c "show ip ospf route" +parameters: +type:script_output +message:FRR diagnostics "show ip ospf route" + +[diagnostics.ospf_route_json] +command:/usr/local/bin/vtysh -c "show ip ospf route json" +parameters: +type:script_output +message:FRR diagnostics "show ip ospf route json" + +[diagnostics.ospf_database] +command:/usr/local/bin/vtysh -c "show ip ospf database" +parameters: +type:script_output +message:FRR diagnostics "show ip ospf database" + +[diagnostics.ospf_database_json] +command:exit 1 +parameters: +type:script_output +message:FRR diagnostics "show ip ospf database json" (not implemented) + +[diagnostics.ospf_interface] +command:/usr/local/bin/vtysh -c "show ip ospf interface" +parameters: +type:script_output +message:FRR diagnostics "show ip ospf interface" + +[diagnostics.ospf_interface_json] +command:/usr/local/bin/vtysh -c "show ip ospf interface json" +parameters: +type:script_output +message:FRR diagnostics "show ip ospf interface json" + +[diagnostics.ospfv3_overview] +command:/usr/local/bin/vtysh -c "show ipv6 ospf6" +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6" + +[diagnostics.ospfv3_overview_json] +command:exit 1 +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 json" (not implemented) + +[diagnostics.ospfv3_neighbor] +command:/usr/local/bin/vtysh -c "show ipv6 ospf6 neighbor" +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 neighbor" + +[diagnostics.ospfv3_neighbor_json] +command:exit 1 +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 neighbor json" (not implemented) + +[diagnostics.ospfv3_route] +command:/usr/local/bin/vtysh -c "show ipv6 ospf6 route" +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 route" + +[diagnostics.ospfv3_route_json] +command:exit 1 +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 route json" (not implemented) + +[diagnostics.ospfv3_database] +command:/usr/local/bin/vtysh -c "show ipv6 ospf6 database" +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 database" + +[diagnostics.ospfv3_database_json] +command:exit 1 +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 database json" (not implemented) + +[diagnostics.ospfv3_interface] +command:/usr/local/bin/vtysh -c "show ipv6 ospf6 interface" +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 interface" + +[diagnostics.ospfv3_interface_json] +command:exit 1 +parameters: +type:script_output +message:FRR diagnostics "show ipv6 ospf6 interface json" (not implemented) From fb2c9f1af2aa32a980aa6836b2139e3d10ac725e Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Sat, 12 Dec 2020 22:57:47 +0100 Subject: [PATCH 02/36] rework and streamline API --- .../Quagga/Api/DiagnosticsController.php | 108 +++++++++--------- 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php index a6d8da8f4..a4f3e358c 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php @@ -41,96 +41,90 @@ use OPNsense\Core\Config; */ class DiagnosticsController extends ApiControllerBase { - /** - * show ip bgp - * @return array - */ - public function showipbgpAction() + private function getInformation(string $daemon, string $name, string $format): array { $backend = new Backend(); - $response = json_decode(trim($backend->configdRun("quagga diag-bgp2"))); - return array("response" => $response); + $response = $backend->configdRun("quagga diagnostics ".$daemon."_".$name.($format === "json" ? "_json" : "")); + return array("response" => ($format === "json" ? json_decode($response) : $response)); } - /** - * show ip bgp summary - * @return array - */ - public function showipbgpsummaryAction() + + public function generalrunningconfigAction(): array { - $backend = new Backend(); - $response = $backend->configdRun("quagga diag-bgp summary"); - return array("response" => $response); + return $this->getInformation("general", "running-config", "plain"); } - public function showrunningconfigAction() + + public function generalrouteAction($format = "json"): array { - $backend = new Backend(); - $response = $backend->configdRun("quagga general-runningconfig"); - return array("response" => $response); + return $this->getInformation("general", "route", $format); } - private function get_ospf_information($name) + + public function generalroute6Action($format = "json"): array { - $backend = new Backend(); - return array("response" => json_decode(trim($backend->configdRun("quagga ospf-$name")))); + return $this->getInformation("general", "route6", $format); } - private function get_ospf3_information($name) + + public function bgpoverviewAction($format = "json"): array { - $backend = new Backend(); - return array("response" => json_decode(trim($backend->configdRun("quagga ospfv3-$name")))); + return $this->getInformation("bgp", "overview", $format); } - // OSPFv2 - public function ospfoverviewAction() + + public function bgpsummaryAction($format = "json"): array { - return $this->get_ospf_information('overview'); + return $this->getInformation("bgp", "summary", $format); } - public function ospfneighborAction() + + public function bgpneighborsAction($format = "json"): array { - return $this->get_ospf_information('neighbor'); + return $this->getInformation("bgp", "neighbors", $format); } - public function ospfrouteAction() + + public function ospfoverviewAction($format = "json"): array { - return $this->get_ospf_information('route'); + return $this->getInformation("ospf", "overview", $format); } - public function ospfdatabaseAction() + + public function ospfneighborAction($format = "json"): array { - return $this->get_ospf_information('database'); + return $this->getInformation("ospf", "neighbor", $format); } - public function ospfinterfaceAction() + + public function ospfrouteAction($format = "json"): array { - return $this->get_ospf_information('interface'); + return $this->getInformation("ospf", "route", $format); } - // OSPFv3 - public function ospfv3overviewAction() + + public function ospfdatabaseAction($format = "json"): array { - return $this->get_ospf3_information('overview'); + return $this->getInformation("ospf", "database", $format); } - public function ospfv3neighborAction() + + public function ospfinterfaceAction($format = "json"): array { - return $this->get_ospf3_information('neighbor'); + return $this->getInformation("ospf", "interface", $format); } - public function ospfv3routeAction() + + public function ospfv3overviewAction($format = "json"): array { - return $this->get_ospf3_information('route'); + return $this->getInformation("ospfv3", "overview", $format); } - public function ospfv3databaseAction() + + public function ospfv3neighborAction($format = "json"): array { - return $this->get_ospf3_information('database'); + return $this->getInformation("ospfv3", "neighbor", $format); } - public function ospfv3interfaceAction() + + public function ospfv3routeAction($format = "json"): array { - return $this->get_ospf3_information('interface'); + return $this->getInformation("ospfv3", "route", $format); } - // General - private function get_general_information($name) + + public function ospfv3databaseAction($format = "json"): array { - $backend = new Backend(); - return array("response" => json_decode(trim($backend->configdRun("quagga general-$name")), true)); + return $this->getInformation("ospfv3", "database", $format); } - public function generalroutesAction() + + public function ospfv3interfaceAction($format = "json"): array { - return $this->get_general_information('routes'); - } - public function generalroutes6Action() - { - return $this->get_general_information('routes6'); + return $this->getInformation("ospfv3", "interface", $format); } } From 80a3b49c4f7996c9042bd1fa2a7b3afd00fa21bc Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Sat, 12 Dec 2020 23:21:04 +0100 Subject: [PATCH 03/36] start fixing frontend at least... something... is working --- .../opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt | 2 +- .../mvc/app/views/OPNsense/Quagga/diagnosticsgeneral.volt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt index 06818b0cd..4e4479dcf 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt @@ -91,7 +91,7 @@ $(document).ready(function() { $('#overview').html(content) }); - ajaxCall(url="/api/quagga/diagnostics/showipbgpsummary", sendData={}, callback=function(data,status) { + ajaxCall(url="/api/quagga/diagnostics/bgpsummary/plain", sendData={}, callback=function(data,status) { $("#summarycontent").text(data['response']); }); }); diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsgeneral.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsgeneral.volt index 4e15ea266..9728e1536 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsgeneral.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsgeneral.volt @@ -110,7 +110,7 @@ $(document).ready(function() { $('#routing6').html(content) //$('#routing6 table').bootgrid({converters: dataconverters}) }); - ajaxCall(url="/api/quagga/diagnostics/showrunningconfig", sendData={}, callback=function(data,status) { + ajaxCall(url="/api/quagga/diagnostics/generalrunningconfig", sendData={}, callback=function(data,status) { $("#runningconfig").text(data['response']); }); From 01348b31a53d4db18f05b6714480bd24c7427898 Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Sun, 13 Dec 2020 16:17:19 +0100 Subject: [PATCH 04/36] fix OSPF diagnostics page (wip) database not yet implemented tooltip for route type doesn't work --- .../OPNsense/Quagga/diagnosticsospf.volt | 303 +++++++++--------- 1 file changed, 155 insertions(+), 148 deletions(-) diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt index 0ac926d06..856dced2a 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt @@ -33,51 +33,47 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('RFC2328 Conform') }} - <%= checkmark(ospf_overview['rfc2328_conform']) %> + <%= checkmark(rfc2328Conform) %> {{ lang._('ASBR') }} - <%= checkmark(ospf_overview['asbr']) %> + <%= checkmark(asbrRouter == "injectingExternalRoutingInformation") %> {{ lang._('Router ID') }} - <%= ospf_overview['router_id'] %> + <%= routerId %> {{ lang._('RFC1583 Compatibility') }} - <%= checkmark(ospf_overview['rfc1583_compatibility']) %> + <%= checkmark(typeof rfc1583Compatibility != "undefined" && rfc1583Compatibility) %> {{ lang._('Opaque Capability') }} - <%= checkmark(ospf_overview['opaque_capability']) %> + <%= checkmark(typeof opaqueCapable != "undefined" && opaqueCapable) %> {{ lang._('Initial SPF Scheduling Delay') }} - <%= ospf_overview['initial_spf_scheduling_delay'] %> + <%= spfScheduleDelayMsecs %> {{ lang._('Milliseconds') }} {{ lang._('Minimum Hold Time') }} - <%= ospf_overview['hold_time']['min'] %> {{ lang._('Milliseconds') }} + <%= holdtimeMinMsecs %> {{ lang._('Milliseconds') }} {{ lang._('Maximum Hold Time') }} - <%= ospf_overview['hold_time']['max'] %> {{ lang._('Milliseconds') }} + <%= holdtimeMaxMsecs %> {{ lang._('Milliseconds') }} {{ lang._('Current Hold Time Multipier') }} - <%= ospf_overview['current_hold_time_multipier'] %> - - - {{ lang._('SPF Timer') }} - <%= ospf_overview['spf_timer'] %> + <%= holdtimeMultplier %> {{ lang._('Refresh Timer') }} - <%= ospf_overview['refresh_timer'] %> + <%= refreshTimerMsecs %> {{ lang._('Milliseconds') }} {{ lang._('Areas Attached Count') }} - <%= ospf_overview['areas_attached_count'] %> + <%= attachedAreaCounter %> @@ -94,67 +90,98 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('External LSA') }} - <%= ospf_overview['external_lsa']['count'] %> - <%= ospf_overview['external_lsa']['checksum'] %> + <%= lsaExternalCounter %> + <%= lsaExternalChecksum %> {{ lang._('Opaque AS LSA') }} - <%= ospf_overview['opaque_as_lsa']['count'] %> - <%= ospf_overview['opaque_as_lsa']['checksum'] %> + <%= lsaAsopaqueCounter %> + <%= lsaAsOpaqueChecksum %>

{{ lang._('Areas') }}

-<% if (ospf_overview['areas']) { %> - <% areas = ospf_overview['areas'] %> - <% _.each(_.keys(areas), function(areaname) { %> - <% area = areas[areaname] %> -

<%= areaname %>

- +<% if (areas) { %> + <% _.forEach(areas, function(area, areaname) { %> +
+
+ + + + + + - + - + - + - +
<%= areaname %>{{ lang._('Count') }}
{{ lang._('Interfaces: Total') }}<%= area['interfaces']['total'] %><%= area['areaIfTotalCounter'] %>
{{ lang._('Interfaces: Active') }}<%= area['interfaces']['active'] %><%= area['areaIfActiveCounter'] %>
{{ lang._('Fully Adjacent Neighbor Count') }}<%= area['fully_adjacent_neighbor_count'] %><%= area['nbrFullAdjacentCounter'] %>
{{ lang._('SPF Execution Count') }}<%= area['spf_exec_count'] %><%= area['spfExecutedCounter'] %>
- + - <% _.each(_.keys(area['lsa']), function(lsaname) { %> - <% lsa = area['lsa'][lsaname] %> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - <% }) %>
{{ lang._('LSA Type') }} {{ lang._('Count') }} {{ lang._('Checksum') }}
<%= translate(lsaname) %><%= lsa['count'] %><%= lsa['checksum'] %>{{ lang._('Router') }}<%= area['lsaRouterNumber'] %><%= area['lsaRouterChecksum'] %>
{{ lang._('Network') }}<%= area['lsaNetworkNumber'] %><%= area['lsaNetworkChecksum'] %>
{{ lang._('Summary') }}<%= area['lsaSummaryNumber'] %><%= area['lsaSummaryChecksum'] %>
{{ lang._('ASBR Summary') }}<%= area['lsaAsbrNumber'] %><%= area['lsaAsbrChecksum'] %>
{{ lang._('NSSA') }}<%= area['lsaNssaNumber'] %><%= area['lsaNssaChecksum'] %>
{{ lang._('Opaque Link') }}<%= area['lsaOpaqueLinkNumber'] %><%= area['lsaOpaqueLinkChecksum'] %>
{{ lang._('Opaque Area') }}<%= area['lsaOpaqueAreaNumber'] %><%= area['lsaOpaqueAreaNumber'] %>
<% }) %> <% } %> ---> + + --> -
-
-
-
-

-    
+
+
+
+

+  
diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt index f8dc9eee6..b27fc4a7f 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsospf.volt @@ -28,119 +28,118 @@ POSSIBILITY OF SUCH DAMAGE. #} - - + -
-
-
-
-

-    
-
-
+
+
+
+

+  
+
+
From 124a54153c030a902e2a144987b29d097a20c18d Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Mon, 14 Dec 2020 11:54:19 +0100 Subject: [PATCH 15/36] heading and one more small style/format fix --- .../mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt index fec0a295b..6e78fe80e 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt @@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #} - - + From 41ec7749c6562a01da08f6fd11f820a0d16368aa Mon Sep 17 00:00:00 2001 From: Marc Leuser Date: Mon, 14 Dec 2020 21:50:13 +0100 Subject: [PATCH 17/36] BGP ipv6 support and clearer protocol distinction --- .../Quagga/Api/DiagnosticsController.php | 23 +++- .../app/models/OPNsense/Quagga/Menu/Menu.xml | 4 +- .../views/OPNsense/Quagga/diagnosticsbgp.volt | 39 +++---- .../OPNsense/Quagga/diagnosticsgeneral.volt | 9 +- .../conf/actions.d/actions_quagga.conf | 104 +++++++++++++++--- 5 files changed, 130 insertions(+), 49 deletions(-) diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php index a4f3e358c..f19af0e86 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/DiagnosticsController.php @@ -55,7 +55,14 @@ class DiagnosticsController extends ApiControllerBase public function generalrouteAction($format = "json"): array { - return $this->getInformation("general", "route", $format); + $routes4 = $this->getInformation("general", "route4", $format)['response']; + $routes6 = $this->getInformation("general", "route6", $format)['response']; + return array("response" => ($format === "json" ? array("ipv4" => $routes4, "ipv6" => $routes6) : $routes4.$routes6)); + } + + public function generalroute4Action($format = "json"): array + { + return $this->getInformation("general", "route4", $format); } public function generalroute6Action($format = "json"): array @@ -63,9 +70,19 @@ class DiagnosticsController extends ApiControllerBase return $this->getInformation("general", "route6", $format); } - public function bgpoverviewAction($format = "json"): array + public function bgprouteAction($format = "json"): array { - return $this->getInformation("bgp", "overview", $format); + return $this->getInformation("bgp", "route", $format); + } + + public function bgproute4Action($format = "json"): array + { + return $this->getInformation("bgp", "route4", $format); + } + + public function bgproute6Action($format = "json"): array + { + return $this->getInformation("bgp", "route6", $format); } public function bgpsummaryAction($format = "json"): array diff --git a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml index 03dca32de..e294cc115 100644 --- a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml +++ b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml @@ -5,12 +5,12 @@ - + - + diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt index 2f26a136f..760745325 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/diagnosticsbgp.volt @@ -34,24 +34,10 @@ POSSIBILITY OF SUCH DAMAGE. - +