Commit Graph

482 Commits

Author SHA1 Message Date
Stephen Worley
e3dafc2580
Merge pull request #6227 from pguibert6WIND/show_nexthop_group_permit_netns
zebra: permit usage of show nexthop-group with namespace based vrfs
2020-05-13 10:53:52 -04:00
Philippe Guibert
2f90b900c8 zebra: permit usage of show nexthop-group with namespace based vrfs
namespace based vrfs can be used along with show nexthop-group command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-13 14:24:36 +02:00
Donald Sharp
630d596249 zebra: Remove typedef rib_table_info_t from system
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:10:49 -04:00
Donald Sharp
f921557186 zebra: Remove typedef rnh_type_t from system
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08 08:10:49 -04:00
Donald Sharp
a83014ccd6
Merge pull request #6247 from FRRouting/nb_conversions
Merge nb_converions branch to master
2020-04-16 19:39:14 -04:00
Chirag Shah
d36228c956 zebra: convert clear evpn dup addr command to nb
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:17:59 -07:00
Chirag Shah
e20755b23e zebra: clear dup detect cleanup for nb conversion
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:13:15 -07:00
David Lamparter
f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter
612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
vivek
ae0eaca5ce zebra: Display next hop's weight (if any) in route brief output
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:32 -07:00
vivek
09bdb655f7 zebra: Display next hop weight via JSON key
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
Mark Stapp
accf6280fc zebra: include backup info in show ip route
Add backup nexthop info to the show output (if present).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 11:50:03 -04:00
Mark Stapp
eeafa8cd43 zebra: include backup nexthops in nhe/nhg show output
Include backup nexthops (if any) in the output of 'show
nexthop-group xxx'.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 11:50:03 -04:00
Mark Stapp
d0636ead31 lib, *: add a common time interval formatting api
Add a common api that formats a time interval into a string
with different output for short and longer intervals. We do
this in several places, for cli/ui output.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-09 11:12:32 -04:00
Donatas Abraitis
0d6f7fd6fd *: Replace sizeof something to sizeof(something)
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-08 21:44:53 +02:00
Quentin Young
5d2724ec25
Merge pull request #5916 from mjstapp/fix_gmtime
*: use gmtime_r exclusively
2020-03-05 17:38:13 -05:00
Mark Stapp
a2700b5071 *: use gmtime_r, localtime_r exclusively
Stop using gmtime() or localtime() everywhere.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-05 13:26:16 -05:00
Mark Stapp
c5babc8c60 zebra: clean up an SA warning in show_ip_route_all
SA reports a redundant NULL check; remove it.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-05 08:35:55 -05:00
Mark Stapp
890b3450ea
Merge pull request #5859 from donaldsharp/clang_latest
Clean up clang latest SA warnings
2020-02-28 07:51:52 -05:00
Stephen Worley
f16e992d37
Merge pull request #5857 from mjstapp/embed_nhg_in_nhe
zebra,lib: Embed lib nexthop-group in zebra hash entry
2020-02-27 18:43:59 -05:00
Mark Stapp
c415d89528 zebra: Embed lib nexthop-group in zebra hash entry
Embed nexthop-group, which is just a pointer, in the zebra
nexthop-hash-entry object, rather than mallocing one.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-27 15:49:31 -05:00
Donald Sharp
2acf1ad1dd zebra: Cleanup set but unused variables
There existed some variables set but never used.  Clean this up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-27 09:41:58 -05:00
Thibaut Collet
7e0f48c75d vty: add command to get route with table, vrf and protocol
Today vtysh can show the ip/ip6 routes through several commands:
- show_route_cmd
- show_route_detail_cmd
- show_route_summary_cmd
- show_route_table_cmd
- show_route_table_vrf_cmd
- show_route_all_table_vrf_cmd

Each command has its own set of filter rules:
- show_route_cmd can filter by vrf, protocol, tag, ... but not by table
- show_route_table_cmd always filter by table
- show_route_table_vrf_cmd always filter by table and can filter by vrf
too
- show_route_all_table_vrf_cmd show all route in any table for a vrf (or
all)

To reduce the number of commands and provide a possibility to filter by
any key add possibility for the show_route_cmd to filter by table with a
specific value or all to get route in all tables.

Then the show_route_table_cmd, show_route_table_vrf_cmd and
show_route_all_table_vrf_cmd functions can be removed as they are covered
by the generic show_route_cmd function.

It is to be noted that when zebra is started by default, it is possible
to execute show ip route command with both vrf and table parameters,
whereas before the command was not displayed. This is due to the fact
that this combination is only permitted when zebra is launched with vrf
network namespace mode. There, if zebra is configured with vrf-lite
backend, then a vty error message informs the user that the combination
of both table and vrf is not possible.

Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
2020-02-11 17:07:47 +01:00
Renato Westphal
b2ce558967
Merge pull request #5739 from mjstapp/nhg_show_ordered
zebra: show zebra nexthop-groups without copying
2020-02-04 13:37:24 -03:00
Mark Stapp
b5e02d19dc zebra: show zebra nexthop-groups without copying
Use a hash walker/iterator instead of a temporary list to
show zebra's nexthop-groups/nexthop-hash-entries.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-04 08:39:41 -05:00
Russ White
05d0c66d8f
Merge pull request #5737 from mjstapp/zebra_disable_kern_nhs
zebra: add config to disable use of kernel nexthops
2020-02-04 08:12:34 -05:00
Donald Sharp
88cafda739 zebra: nexthop groups vrf's are only a function of namespaces
Nexthop groups as a whole do not make sense to have a vrf'ness
As that you can have a arbitrary number of nexthops that point
to separate vrf's.

Modify the code to make this distinction, by clearly delineating
the line between the nhg and the nexthop a bit better.
Nexthop groups having a vrf_id only make sense if you are using
network namespaces to represent them.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-31 08:45:51 -05:00
Donald Sharp
417f01b751 zebra: Modify 'show nexthop-group rib ip|ipv6'
The zebra implementation of nexthop groups has
two types of nexthops groups currently.  Singleton
objects which have afi's and combined nexthop groups
that do not.  Specifically call this out in the code
to make this distinction.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-31 08:26:39 -05:00
Mark Stapp
7c99d51beb zebra: add config to disable use of kernel nexthops
Add a config that disables use of kernel-level nexthop ids.
Currently, zebra always uses nexthop ids if the kernel supports
them.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-01-28 11:00:42 -05:00
Mark Stapp
2553fde18d zebra: make current show nexthop-group cli zebra-specific
There's confusion between the nexthop-group configuration and a
zebra-specific show command. For now, make the zebra show
command string RIB-specific until we're able to unify these
paths.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-01-08 09:01:19 -05:00
Quentin Young
6498fc458d
Merge pull request #5508 from ton31337/feature/show_ip_route_summary_json
zebra: Print json output for show_route_summary_cmd
2019-12-17 10:05:13 -05:00
Donatas Abraitis
e7deb7e791 zebra: Print json output for show_route_summary_cmd
```
spine1-debian-9# sh ip route summary json
{
  "routes":[
    {
      "fib":1,
      "rib":1,
      "type":"kernel"
    },
    {
      "fib":11,
      "rib":11,
      "type":"connected"
    },
    {
      "fib":2,
      "rib":2,
      "type":"ebgp"
    },
    {
      "fib":1,
      "rib":1,
      "type":"ibgp"
    }
  ],
  "routesTotal":15,
  "routesTotalFib":15
}
spine1-debian-9# sh ipv6 route summary json
{
  "routes":[
    {
      "fib":7,
      "rib":7,
      "type":"connected"
    }
  ],
  "routesTotal":7,
  "routesTotalFib":7
}
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-12 17:20:11 +02:00
Donald Sharp
bd054c1aa2 lib, zebra: Allow for encode/decode of nexthop weight in pass down
Add code to encode/decode the nexthop weight when we pass it down
into zebra.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-09 13:37:37 -05:00
Donald Sharp
e302caaa81
Merge pull request #5416 from mjstapp/re_nhe_pointer
lib,zebra: use shared nexthop-group in route_entry
2019-12-04 14:11:04 -05:00
Mark Stapp
0eb97b860d lib,zebra: use nhg_hash_entry pointer in route_entry
Replace the existing list of nexthops (via a nexthop_group
struct) in the route_entry with a direct pointer to zebra's
new shared group (from zebra_nhg.h). This allows more
direct access to that shared group and the info it carries.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-04 08:13:52 -05:00
Lakshman Krishnamoorthy
06931fdb12 zebra: "show evpn vni details json" prints incorrect JSON format
edge-2> show evpn vni detail json
{
  "vni":79031,
  "type":"L3",
  ...,
  ...
}                                       <<<<<< no comma

{
  "vni":79021,
  "type":"L3",
  ...,
  ...
}                                       <<<<<< no comma

{
}                                       <<<<<< blank
edge-2>

The fix is to pack json info into json_array before printing it.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-11-21 16:18:04 -08:00
Stephen Worley
c7c0b007a4 zebra: separate zebra_vrf_lookup_table_with_id()
We were creating `other` tables in rib_del(), vty commands, and
dataplane return callback via the zebra_vrf_table_with_table_id()
API.

Seperate the API into only a lookup, never create
and added another with `get` in the name (following the standard
we use in other table APIs).

Then changed the rib_del(), rib_find_rn_from_ctx(), and show route
summary vty command to use the lookup API instead.

This was found via a crash where two different vrfs though they owned
the table. On delete, one free'd all the nodes, and then the other tried
to use them. It required specific timing of a VRF existing, going away,
and coming back again to cause the crash.

=23464== Invalid read of size 8
==23464==    at 0x179EA4: rib_dest_from_rnode (rib.h:433)
==23464==    by 0x17ACB1: zebra_vrf_delete (zebra_vrf.c:253)
==23464==    by 0x48F3D45: vrf_delete (vrf.c:243)
==23464==    by 0x48F4468: vrf_terminate (vrf.c:532)
==23464==    by 0x13D8C5: sigint (main.c:172)
==23464==    by 0x48DD25C: quagga_sigevent_process (sigevent.c:105)
==23464==    by 0x48F0502: thread_fetch (thread.c:1417)
==23464==    by 0x48AC82B: frr_run (libfrr.c:1023)
==23464==    by 0x13DD02: main (main.c:483)
==23464==  Address 0x5152788 is 104 bytes inside a block of size 112 free'd
==23464==    at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==23464==    by 0x48B25B8: qfree (memory.c:129)
==23464==    by 0x48EA335: route_node_destroy (table.c:500)
==23464==    by 0x48E967F: route_node_free (table.c:90)
==23464==    by 0x48E9742: route_table_free (table.c:124)
==23464==    by 0x48E9599: route_table_finish (table.c:60)
==23464==    by 0x170CEA: zebra_router_free_table (zebra_router.c:165)
==23464==    by 0x170DB4: zebra_router_release_table (zebra_router.c:188)
==23464==    by 0x17AAD2: zebra_vrf_disable (zebra_vrf.c:222)
==23464==    by 0x48F3F0C: vrf_disable (vrf.c:313)
==23464==    by 0x48F3CCF: vrf_delete (vrf.c:223)
==23464==    by 0x48F4468: vrf_terminate (vrf.c:532)
==23464==  Block was alloc'd at
==23464==    at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==23464==    by 0x48B24A2: qcalloc (memory.c:110)
==23464==    by 0x48EA2FE: route_node_create (table.c:488)
==23464==    by 0x48E95C7: route_node_new (table.c:66)
==23464==    by 0x48E95E5: route_node_set (table.c:75)
==23464==    by 0x48E9EA9: route_node_get (table.c:326)
==23464==    by 0x48E1EDB: srcdest_rnode_get (srcdest_table.c:244)
==23464==    by 0x16EA4B: rib_add_multipath (zebra_rib.c:2730)
==23464==    by 0x1A5310: zread_route_add (zapi_msg.c:1592)
==23464==    by 0x1A7B8E: zserv_handle_commands (zapi_msg.c:2579)
==23464==    by 0x19D689: zserv_process_messages (zserv.c:523)
==23464==    by 0x48F09F8: thread_call (thread.c:1599)

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-11-01 16:06:19 -04:00
Stephen Worley
c1da832a94 zebra: Change wording of duplicate kernel nhg flag
Change the wording of the flag indicating we have received
a nexthop group from the kernel with a different ID but
is fundamentally identical to one we already have.

It was colliding with a flag of similar name in the nexthop struct.

Change it from NEXTHOP_GROUP_DUPLICATE -> NEXTHOP_GROUP_UNHASHABLE
since it is in fact unhashable.

Also change the wording of functions and comments referencing the same
problem.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:44 -04:00
Stephen Worley
fec211ad95 zebra: Zebra nexthop group re-work checkpatch fixes
Checkpatch fixes for the zebra nexthop group re-work.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:43 -04:00
Stephen Worley
d7b5921c58 zebra: Update ip route show with nexthop_num API
Switch the nexthop_num dereferences to use the nexthop_group
API in `vty_show_ip_route()`.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:43 -04:00
Stephen Worley
61d9ffe168 zebra: Only show route nexthop group ID when asked
In lieu of the fact that we probably shouldn't change show
command output too much, changing this to only give nhe_id
output when the user explicitly asks for it. Probably only
going to be used for debugging for now anyway.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:43 -04:00
Stephen Worley
0ad40d1615 zebra: Add nhe_id to show ip route detailed
When querying for detailed route information, show the nexthop
group id for its nh_hash_entry in the output before listing the
nexthops.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:42 -04:00
Stephen Worley
df9069cd18 zebra: Add some more output to show nexthop-group
Add some more detailed output to `show nexthop-group`.
It closely resembles the output of `show ip routes`.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:42 -04:00
Stephen Worley
37c6708b93 zebra: Switch nhg_connected to use new RB tree
Switch the nhg_connected tree structures to use the new
RB tree API in `lib/typerb.h`. We were using the openbsd-tree
implementation before.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:41 -04:00
Stephen Worley
1e9aad82ba zebra: Add cli show NHE by ID and interface groups
Add cli to show nhg_hash_entry's by ID.

Add cli to show nhg_hash_entry info for interfaces and remove
just listing ID's in `show interface *`

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:40 -04:00
Stephen Worley
2d3c57e671 zebra: NHG checkpatch fixes
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:40 -04:00
Stephen Worley
a15d4c0089 zebra: Abstract the RB nodes/add dependents tree
Create a nhg_depenents tree that will function as a way
to get back pointers for NHE's depending on it.

Abstract the RB nodes into nhg_connected for both depends and
dependents. This same struct is used for both.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00
Stephen Worley
0c8215cbab zebra,lib: Refactor depends to RB tree
Refactor the depends to use an RB tree instead of a list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:39 -04:00