Commit Graph

546 Commits

Author SHA1 Message Date
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
Stephen Worley
8e401b251f zebra: Refactor nexthop group creation code to use allocated memory
Simplify the code for nexthop hash entry creation. I made nexthop
hash entry creation expect the nexthop group and depends to always
be allocated before lookup. Before, it was only allocated if it had
dependencies. I think it makes the code a bit more readable to go
ahead an allocate even for single nexthops as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
cced3a2d29 zebra: Make show nexthop-group <null> list all nexthop hash entries
Add an option to not specify the afi in the show nexthop-group
command so that it shows all nexthops, including groups. This is
how iproute2 does it. If the afi is given, it will only show single
nexthops since groups are AF_UNSPEC.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
77b76fc900 Revert "zebra: Remove afi field in nexthop hash entry"
This reverts commit be73fe9393aac58c7f4bdb5c8a98c24c6cda6d5d.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:38 -04:00
Stephen Worley
2614bf8764 zebra: Add ifp to zebra-side rib_add
Add an interface pointer for an nexthop group hash entry
when we are getting a rib_add for a new route.

Also, add the interface index to the `show nexthop-group` command.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
a53a11f218 zebra: Make show nexthop-group command more readable
Put some whitespace into the command output so that
we can read it a little bit easier.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:37 -04:00
Stephen Worley
8b5bdc8bdf zebra: Remove afi field in nexthop hash entry
I do not believe we should be hashing based on AFI
in for our upper level nexthop group entries. These
should be ambiguous with regards to  address families since
an ipv4 or ipv6 address can have the same interface
nexthop. This can be seen in NEXTHOP_TYPE_IFINDEX.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
Donald Sharp
6b46851168 zebra: Replace nexthop_group with pointer in route entry
In the route_entry we are keeping a non pointer based
nexthop group, switch the code to use a pointer for all
operations here and ensure we create and delete the memory.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 11:13:36 -04:00
Donald Sharp
c8ee3cdb39 zebra: Add some basic flags to the zebra nexthop group
We need to track if a nexthop group is valid and installed,
so create some basic flags to track this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 11:13:35 -04:00
Donald Sharp
21be136402 zebra: Add show command to dump nexthop-group information for Zebra
Just a simple addition of a command to dump the nexthop group information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 11:13:35 -04:00
Donald Sharp
8f79e2cf65 zebra: zrt->table cannot crash here
If we have a zrt data structure then we have a table pointer
as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-16 13:38:29 -04:00
Donald Sharp
7e933bc159
Merge pull request #5058 from mjstapp/fix_dplane_config_handler
zebra: handle config write for dataplane values
2019-09-25 16:47:47 -04:00
Mark Stapp
f26730e17e zebra: handle config write for dataplane values
Add the (single) dataplane config value to the output of
config write, 'show run' - missed this during dplane development.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-25 14:05:50 -04:00
Kishore Aramalla
c1066ba002 zebra: Added vrfname to route prefix dictionary
Route prefix dictionary contains vrf ID only.
Added vrfName to the route prefix dictionary.

Signed-off-by: Kishore Aramalla <karamalla@vmware.com>
2019-09-19 14:28:11 -07:00
Donald Sharp
ae813e21a6 zebra: Modify show ip route summary to allow you to specify a table
Add a bit of extra command `show ip route summary table XXX`
To allow end user to specify a specific table that they want
summary information on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-11 08:16:18 -04:00
Donald Sharp
9d55926924
Merge pull request #4892 from pguibert6WIND/nhtresolvedefaultvrf
zebra: nht resolution default configurable per vrf
2019-09-03 15:40:43 -04:00
Philippe Guibert
5a0bdc782c zebra: nht resolution default configurable per vrf
even if vty commands were available, the default resolution command was
working only for the first vrf configured. others were ignored. Also,
for nexthop, resolution was working for all vrfs, and not the specific
one.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-28 16:19:34 +02:00
vdhingra
d4c7ac0105 zebra: Added a few more information in route_entry while dumping
re->nexthop_num and re->nexthop_active_num are calculated while rib
processing. Also It helps in encoding the ZAPI message.
It's good to dump these parameters also, when the system is in
abnormal state.

Signed-off-by: vishaldhingra<vdhingra@vmware.com>
2019-08-23 06:02:53 -07:00
Donald Sharp
94a01fb26e zebra: Allow v4 or v6 addresses to be optional after vrf X in show ip nht
The `show ip nht vrf EVA ...` command was not allowing you to only
specify the vrf anymore.  Fix this:

robot# show ip nht vrf EVA
  <cr>
  A.B.C.D   IPv4 Address
  X:X::X:X  IPv6 Address
robot# show ip nht vrf EVA 4.5.6.7
robot# show ip nht vrf EVA
robot#

Ticket: CM-25831
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-07 15:02:43 -04:00
Chirag Shah
155b4398b4 zebra: fix evpn dad clear cmd mac parsing
The changes came as part of PR #4730, checks
only variable mac, which is never null. Even
for ip version of cli hits "mac" case statement
and failing the clear cli.

Testing Done:

Before Fix:

VTEP-03# show evpn arp-cache vni 1002 duplicate
VNI 1002 #ARP (IPv4 and IPv6, local and remote) 1

IP                        Type   State    MAC               Remote VTEP
Seq #'s
11.11.11.11               remote active   aa:22:aa:aa:aa:aa 27.0.0.16
7/8

VTEP-03# clear evpn dup-addr vni 1002 ip 11.11.11.11
% Requested MAC does not exist in VNI 1002

Post fix:

VTEP-03# clear evpn dup-addr vni 1002 ip 11.11.11.11
VTEP-03#

VTEP-03# show evpn mac vni all duplicat
VNI 1002 #MACs (local and remote) 1

MAC               Type   Intf/Remote VTEP      VLAN  Seq #'s
aa:aa:aa:aa:aa:aa remote 27.0.0.16                   7/8

Post fix:

VTEP-03# clear evpn dup-addr vni 1002 mac aa:aa:aa:aa:aa:aa
VTEP-03#

VTEP-03# clear evpn dup-addr vni 1002 ip 11.11.11.11
VTEP-03#

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-07-31 14:09:08 -07:00
Russ White
0cd8c0ff11
Merge pull request #4650 from pguibert6WIND/show_ip_route_table_all
zebra: add show ip route all command to dump all unicast tables
2019-07-30 11:18:10 -04:00
Igor Ryzhov
f65d330cbc lib: fix missing M:A:C to X:X:X:X:X:X changes
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-07-25 17:15:27 +03:00
Philippe Guibert
e2256d2e87 zebra: show ip route all command displays all tables from all vrfs
initially, that command was dumping only tables from default vrfs.
the change here consists in dumping all the tables from all the vrfs.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-07-09 14:32:24 +02:00
Philippe Guibert
234963a589 zebra: display the table identifier along with table and entries
the table identifier is made visible. this permits to easily know which
table identifier is dumped, or which table that entry belongs to, when
one calls 'show ip route all' command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-07-09 14:32:20 +02:00
Philippe Guibert
16c42fba57 zebra: add show ip route all command to dump all unicast tables
this vty command explores the routing tables available, and dumps the
routing entries. there is no need to pass a table identifier, since all
configured tables are dumped.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-07-09 12:16:28 +02:00
Donald Sharp
fe257ae733 zebra: Push VRF_DEFAULT outside of import table code
The import table code assumes that they will only work
in the default vrf.  This is ok, but we should push the
vrf_id and zvrf to be passed in instead of just using
VRF_DEFAULT.

This will allow us to fix a couple of things:

1) A bug in import where we are not creating the
route entry with the appropriate table so the imported
entry is showing up in the wrong spot.

2) In the future allow `ip import-table X` to become
vrf aware very easily.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-25 17:47:41 -04:00
Donald Sharp
a36898e755
Revert "Ospf missing interface handling 2" 2019-06-23 19:46:39 -04:00
Donald Sharp
a12bb225a6
Merge pull request #3775 from pguibert6WIND/ospf_missing_interface_handling_2
Ospf missing interface handling 2
2019-06-22 13:35:45 -04:00
David Lamparter
b41b3f7bf1 lib/clippy: expand some macros
At least the "easy" cases of macros work.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:23:00 +02:00
Philippe Guibert
ac6c2a11a6 lib: create interface upon accessing interface NB API.
Upon accessing interface NB API, the interface is created, if the vrf
is available. the commit does not change the behaviour, since at this
commit, this is not yet possible to have vrf contexts, while zebra did
not connect to daemons. However, that commit adds some work, so that it
will be possible to work on a vrf context, without having the vrf_id
completely resolved. for instance, if we suppose a vrf is created by
command 'vrf TOTO' in the starting configuration of a daemon, then 'interface
TITI vrf TOTO' will permit to create interface TITI within vrf TOTO.

the macro VRF_GET_INSTANCE will return the vrf context, if available or
not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Mark Stapp
941e261c97 zebra: share rib processing of updates and notifications
Use some common handling for both route update results
processing and dataplane notification processing. Use the
fib-specific nexthop-group if the update to a route results
in different nexthop status than the default rib-provided
nexthop-group.

Use the fib-specific nexthop-group, if present, to provide
the output of 'show ip fib'.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-05-28 08:34:21 -04:00
Donald Sharp
543c749625
Merge pull request #4296 from adharkar/frr-master-fib_prefix
Zebra: Add "show ip/ipv6 fib <prefix> [json]" CLI
2019-05-14 21:46:38 -04:00
Donald Sharp
98572489ea zebra: Switch to using monotime(NULL) for re->uptime
The re->uptime usage of time(NULL) leaves it open to
timing changes from outside influence.  Switching
to monotime allows us to ensure that we have a timestamp
that is always increasing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-11 01:44:42 -04:00
Ameya Dharkar
ad2e7233a4 Zebra: "show ip/ipv6 route/fib prefix" prefix not found cases
1. If prefix not found, print "{}" for json
2. Print "Network not in table" for route option
3. Print "Network not in FIB" for fib option
4. Take care of "show ip route/fib vrf all prefix" command.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-10 12:12:44 -07:00
Ameya Dharkar
3a3be633cc Zebra: Add "show ip/ipv6 fib <prefix> [json]" CLI - review comments 1
According to the review comments, added "Network not in FIB" message when we do
not have a FIB route present for given prefix.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-09 14:23:23 -07:00
Ameya Dharkar
6a794a7e83 Zebra: Add "show ip/ipv6 fib <prefix> [json]" CLI
"show ip/ipv6 route <prefix> [json]" uses a different parser chain from
"show ip/ipv6 route [json]".
"show ip/ipv6 route <prefix> [json]" CLI does not support "fib" option.

Fix:
Add "fib" option to the above command.
The new command is: "show ip/ipv6 <route/fib> <prefix> [json]"
If "fib" option is specified, we will show only the selected routes
(Similar to "show ip/ipv6 fib")

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-05-08 14:26:49 -07:00
Donald Sharp
c447ad08b2 doc, zebra: Remove "table X" command
This command is broken and has been broken since the introduction
of vrf's.  Since no-one has complained it is safe to assume that
there is no call for this specialized linux command.  Remove
from the system with extreme prejudice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-06 13:42:23 -04:00
Donald Sharp
d2f5903b84 zebra: Add hidden 'show frr' command
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-12 10:27:52 -04:00
Donald Sharp
dbeca4841b zebra: Allow specification of v[4|6] addrs on some commands
The `show ipv[4|6] <nht|import-check> ...` commands are starting
to produce a bunch of output due to multiple daemons now
using the code.  Allow the specification of a v4 or v6 address
to allow the show command to only display the interesting nht.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-05 11:34:22 -04:00
Tuetuopay
d074383c62
Merge branch 'master' into evpn-session-vrf 2019-03-28 18:41:38 +01:00
Donald Sharp
13551afd80
Merge pull request #4017 from mjstapp/fix_summary_installed_flag
zebra: use the INSTALLED flag consistently in route summary
2019-03-27 08:40:12 -04:00
Mark Stapp
6f875a362a zebra: use the INSTALLED flag consistently in route summary
The 'sho ip route summary' and 'sho ip route summary <prefix>'
paths used different definitions of a 'fib' route. Use
the route-entry 'INSTALLED' flag in both places.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-03-25 13:35:02 -04:00
Philippe Guibert
41533022a2 zebra: remove duplicated json information
the metric information is already present for connected routes. so
remove that line.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-03-25 15:02:52 +01:00
Tuetuopay
8f2ff1b5b0 zebra/vty: Don't hide VNI config for default VRF
Since the EVPN session and underlay can be in a non-default VRF, the
default VRF can be an overlay VRF.

Signed-off-by: Tuetuopay <tuetuopay@me.com>
Sponsored-by: Scaleway
2019-03-19 11:56:25 +01:00
Tuetuopay
530db8dc03 bgpd, zebra: Scope EVPN commands to EVPN VRF
If the EVPN VRF is not the default one (i.e. with advertise-all-vni),
this allows showing its information with `show bgp l2evpn evpn ...`
commands. They do not require adding `vrf VRFNAME` since we only
support a single EVPN VRF. The same is true for zebra-specific commands
(e.g. `show evpn ...`).

Configuration commands are not restricted to the default VRF but to
the EVPN one, that is to the one bearing `advertise-all-vni`.

Signed-off-by: Tuetuopay <tuetuopay@me.com>
Sponsored-by: Scaleway
2019-03-19 11:56:25 +01:00
Donald Sharp
1e03ae0dc7 zebra: Allow json output to give a bit more data
The dest->selected_fib should be reported in json output
so that we can debug subtle conditions a bit better in the
future.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-09 20:28:49 -05:00
Donald Sharp
e625a783ed zebra: Do not display recursive nexthops as installed
Recursive nexthops should not be marked as installed

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-05 15:21:26 -05:00
Renato Westphal
3524352154
Merge pull request #3698 from donaldsharp/netlink_is_serious_business
Netlink is serious business
2019-02-05 11:52:33 -02:00
Donald Sharp
5ec5a7160a zebra: Move packets_to_process to zrouter
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
489a961429 zebra: Move ribq from zebrad to zrouter
The zrouter should own this data structure and it should not
be defined in zserv.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
b3d43ff471 zebra: Move rtm_table_default to zrouter
The zrouter should own this particular piece of data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
b0538fc8b7 lib, zebra: Fix 'show ip route' char collision
Apparently 'f' means both OpenFabric and a Failed kernel
route installation.

Let's switch the 'f' for the failed kernel route installation
to 'r - rejected route'.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-29 20:41:36 -05:00
Donald Sharp
677c1dd5cb zebra: Use ROUTE_ENTRY_INSTALLED as decision for route is installed
zebra is using NEXTHOP_FLAG_FIB as the basis of whether or not
a route_entry is installed.  This is problematic in that we plan
to separate out nexthop handling from route installation.  So modify
the code to keep track of whether or not a route_entry is installed/failed.

This basically means that every place we set/unset NEXTHOP_FLAG_FIB, we
actually also set/unset ROUTE_ENTRY_INSTALLED on the route_entry.
Additionally where we check for route installed via NEXTHOP_FLAG_FIB
switch over to checking if the route think's it is installed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-25 20:16:15 -05:00
Donald Sharp
4a2f796f2e lib, zebra: Abstract character selection for nexthop display
When we are selecting nexthops for disply, abstract the notion
of what character we display to the end user about the status
of the nexthop.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-25 20:14:38 -05:00
Anuradha Karuppiah
059c79ba30 zebra: display metric for connected routes
In a VRR/VRRP setup we can have connected routes with different costs.
So this change eliminates suppressing metric display for connected routes.

Sample output -
root@TORC11:~# vtysh -c "show ipv6 route vrf vrf1"
Codes: K - kernel route, C - connected, S - static, R - RIPng,
       O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table,
       v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR,
       > - selected route, * - FIB route

VRF vrf1:
K * ::/0 [255/8192] unreachable (ICMP unreachable), 00:00:36
C * 2001:aa:1::/64 [0/100] is directly connected, vlan1002-v0, 00:00:36
C>* 2001:aa:1::/64 [0/90] is directly connected, vlan1002, 00:00:36

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-01-25 14:19:26 -05:00
Renato Westphal
7004c67b35 zebra: merge four "show ip nht" commands into a single DEFPY
This is mostly to be consistent with the "show ip import-check"
command, which is very similar.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-21 13:26:54 -02:00
Renato Westphal
73bf60a06b zebra: consolidate how we indentify address-families in the NHT code
Favor usage of the afi_t enumeration to identify address-families
over using the classic AF_INET[6] constants for that. The choice to
use either of the two seems to be mostly arbitrary throughout our
code base, which leads to confusion and bugs like the one fixed by
commit 6f95d11a1. To address this problem, favor usage of the afi_t
enumeration whenever possible, since 1) it's an enumeration (helps
the compilers to catch some bugs), 2) has a safi_t sibling and 3)
can be used to index static arrays. AF_INET[6] should then be used
only when interfacing with the kernel or external libraries like
libc. The family2afi() and afi2family() functions can be used to
convert between the two different representations back and forth.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-21 13:26:36 -02:00
Renato Westphal
6f95d11a17 zebra: fix the "show ip import-check" command
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18 14:21:42 -02:00
Donald Sharp
ac5aa23f93 zebra: Add a dump table information command to zebra
Allow zebra to dump the table information it has from a router perspective.

This table looks like this:
donna.cumulusnetworks.com# show zebra router table summary
VRF             NS ID    VRF ID     AFI            SAFI    Table      Count
---------------------------------------------------------------------------
default             0         0    IPv4         unicast       49          1
default             0         0    IPv4         unicast      254          7
default             0         0    IPv4       multicast      254          9
default             0         0    IPv6         unicast      254          1
default             0         0    IPv6       multicast      254          1
BLUE                0        31    IPv4         unicast     1005          0
BLUE                0        31    IPv4       multicast     1005          0
BLUE                0        31    IPv6         unicast     1005          0
BLUE                0        31    IPv6       multicast     1005          0

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-04 09:48:40 -05:00
Philippe Guibert
b85c827591 zebra: add command show ip/ipv6 import-check table
Add the ability to dump import check nexthop table.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-12-17 12:19:28 +01:00
Donald Sharp
9e7cd6fdca zebra: show ip route A.B.C.D json would only show last route entry
The `show ip route A.B.C.D json` command was only displaying
the last route entry looked at and we would drop the data
associated with other route entries.  This fixes the issue:

robot# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route

K>* 0.0.0.0/0 [0/100] via 192.168.201.1, enp3s0, 00:13:31
C>* 4.50.50.50/32 is directly connected, lo, 00:13:31
D   10.0.0.1/32 [150/0] via 192.168.201.1, enp3s0, 00:09:46
S>* 10.0.0.1/32 [1/0] via 192.168.201.1, enp3s0, 00:10:04
C>* 192.168.201.0/24 is directly connected, enp3s0, 00:13:31
robot# show ip route 10.0.0.1 json
{
  "10.0.0.1\/32":[
    {
      "prefix":"10.0.0.1\/32",
      "protocol":"sharp",
      "distance":150,
      "metric":0,
      "internalStatus":0,
      "internalFlags":1,
      "uptime":"00:09:50",
      "nexthops":[
        {
          "flags":1,
          "ip":"192.168.201.1",
          "afi":"ipv4",
          "interfaceIndex":2,
          "interfaceName":"enp3s0",
          "active":true
        }
      ]
    },
    {
      "prefix":"10.0.0.1\/32",
      "protocol":"static",
      "selected":true,
      "distance":1,
      "metric":0,
      "internalStatus":0,
      "internalFlags":2064,
      "uptime":"00:10:08",
      "nexthops":[
        {
          "flags":3,
          "fib":true,
          "ip":"192.168.201.1",
          "afi":"ipv4",
          "interfaceIndex":2,
          "interfaceName":"enp3s0",
          "active":true
        }
      ]
    }
  ]
}
robot#

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-05 15:12:50 -05:00
Sri Mohana Singamsetty
ad31e8d398
Merge pull request #3372 from nitinsoniism/show_evpn_mac_vni_all_detail
zebra: Add "show evpn mac vni all detail" command
2018-12-04 10:19:18 -08:00
David Lamparter
21e2819dbf
Merge pull request #3340 from nitinsoniism/show_evpn_vni_detail
zebra: Add "show evpn vni detail" command
2018-12-04 17:29:50 +01:00
Chirag Shah
1883de666f zebra: dup addr detect clear cmd non-zero return
Clear dup address vni needs to return non-zero value
in case of command is not successful.

Ticket:CM-23122
Testing Done:
run clear command and check upon failure return code is non-zero.

root@TORS1:~# vtysh -c "clear evpn dup-addr vni 1000 ip 45.0.1.26"
% Requested IP's associated MAC 00:01:02:03:04:05 is still in duplicate
% state
root@TORS1:~# echo $?
1

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-12-03 16:56:00 -08:00
Nitin Soni
e3fac9195d zebra: Add "show evpn arp-cache vni all detail" command
Change helps display detailed output for all possible VNI neighbors
without specifying VNI and ip. It helps in troubleshooting as a single
command can be fired to capture detailed info on all VNIs.

Ticket: CM-22832
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8034
2018-11-27 05:56:56 -08:00
Nitin Soni
cffe7580fd zebra: Add "show evpn mac vni all detail" command
Change helps display detailed output for all possible VNI MACs without
specifying VNI or mac. It helps in troubleshooting - a single
command can be fired to capture detailed info on all VNIs.
Also fixed and existing json related bug where json object is created by
a parent function and freed in child function.

Ticket: CM-22832
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8028
2018-11-27 05:44:48 -08:00
Nitin Soni
09af6961d4 zebra: Add "show evpn vni detail" command
Change helps display detailed output for all possible VNIs without
specifying VNI. It helps in troubleshooting - a single command can
be fired to capture detailed info on all VNIs.

Ticket: CM-22831
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8013
2018-11-21 08:13:01 -08:00
Chirag Shah
09de9258a9 zebra: dup addr detect clear command
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-11-17 19:22:17 -08:00
Chirag Shah
1374d4dbc2 zebra: dup addr detect operation commands
Display duplicate detected list of MACs and VNIs.
- Per VNI
- Across all VNIs

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-11-17 19:22:17 -08:00
Russ White
2379dbecbd
Merge pull request #3202 from donaldsharp/evpn_dump
Evpn dump
2018-11-08 18:13:27 -05:00
Russ White
7c32c1dc10
Merge pull request #3255 from dslicenc/show_evpn_mac_json
zebra: add json support to show evpn mac vni <num> mac <mac>
2018-10-31 21:47:18 -04:00
Donald Sharp
093e3f23f6 bgpd, lib, vtysh, zebra: Convert to using CMD_VNI_RANGE
For the vni range use a macro to keep track of it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 06:23:32 -04:00
Don Slice
24cdbd0d8b zebra: add json support to show evpn mac vni <num> mac <mac>
Added the json output capability in order to improve troubleshooting
capabilities.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-10-29 13:09:31 +00:00
Donald Sharp
69c19e1def
Merge pull request #2946 from mjstapp/dplane_2
Zebra: async dataplane, phase 1
2018-10-28 16:10:45 -04:00
David Lamparter
00b7a9ddfe
Merge pull request #2926 from donaldsharp/router
zebra_ns split up
2018-10-26 22:24:15 +02:00
David Lamparter
0437e10517 *: spelchek
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-25 20:10:57 +02:00
Mark Stapp
91f1681258 zebra: limit queued route updates
Impose a configurable limit on the number of route updates
that can be queued towards the dataplane subsystem.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Mark Stapp
1d11b21f33 zebra: add dplane show commands
Add first pass at show commands for the zebra dplane. Add some stats
counters to show. Start prep for correct shutdown processing, and for
multiple providers.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-10-25 08:57:04 -04:00
Donald Sharp
89272910f7 zebra: Start breakup of zns into zrouter and zns
The `struct zebra_ns` data structure is being used
for both router information as well as support for
the vrf backend( as appropriate ).  This is a confusing
state.  Start the movement of `struct zebra_ns` into
2 things `struct zebra_router` and `struct zebra_ns`.

In this new regime `struct zebra_router` is purely
for handling data about the router.  It has no knowledge
of the underlying representation of the Data Plane.

`struct zebra_ns` becomes a linux specific bit of code
that allows us to handle the vrf backend and is allowed
to have knowledge about underlying data plane constructs.

When someone implements a *bsd backend the zebra_vrf data
structure will need to be abstracted to take advantage of this
instead of relying on zebra_ns.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-24 06:52:07 -04:00
vishaldhingra
7cf16e19c5 zebra: vrf aware routmap is missing in Zebra #2802(Part 4 of 4)
The new cli for show output

Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-10-11 10:49:34 -07:00
vishaldhingra
214e5c2679 zebra: vrf aware routmap is missing in Zebra #2802(Part 3 of 4)
The cli changes to allow this to work.

Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-10-11 10:48:23 -07:00
vishaldhingra
6d53d7b1af zebra: vrf aware routmap is missing in Zebra #2802(Part 2 of 4)
Function parameter replacement of using zvrf instead of vrf_id

Signed-off-by: vishaldhingra vdhingra@vmware.com
2018-10-11 10:46:55 -07:00
Donald Sharp
6ca30e9ec6 bgpd, lib, zebra: Wrapper get/set of table->info pointer
Wrapper the get/set of the table->info pointer so that
people are not directly accessing this data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-23 20:04:39 -04:00
Don Slice
9f049418bc bgpd/ospfd: make bgp and ospf json response a bit more consistent
Problem reported that some bgp and ospf json commands did not return
any json output at all if the bgp/ospf instance did not exist.
Additionally, some bgp and ospf json commands did not return any json
output if the instance existed but no neighbors were defined.  This
fix makes these commands more consistent in returning empty braces for
json output and issue a message if not using json output.  Additionally,
made the flag "use_json" a bool to make it consistent since previously,
it had been defined as an int, char, u_char, and bool at various places.

Ticket: CM-21040
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-30 12:40:18 +00:00
David Lamparter
6de00b4e95
Merge pull request #2799 from adharkar/frr-zebra_cli
Zebra: Changes to "show ip route" json commands
2018-08-08 20:27:49 +02:00
Ameya Dharkar
96d71e3878 1. Added json output to "show ip route <prefix>" command
2. Added tag O/P to "show ip route json" command

Signed-off-by: Ameya Dharkar adharkar@vmware.com
2018-08-07 15:15:34 -07:00
Donald Sharp
9f2982ab69 zebra: Remove zebra_static.c and .h
These are no longer needed so remove.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:37:26 -04:00
Donald Sharp
7e24fdf333 staticd: Start the addition of a staticd
This is the start of separating out the static
handling code from zebra -> staticd.  This will
help simplify the zebra code and isolate static
route handling to it's own code base.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-29 12:37:24 -04:00
Lou Berger
bf7bf2b99c
Merge pull request #2719 from pguibert6WIND/fix_tableno_vrf
zebra: fix missing table identifier passed for ip route vrf commands
2018-07-28 10:42:07 -04:00
Nathan Van Gheem
ec1db5882d lib,zebra: fix json output when vrf1 when not active
When I did a show ip route with `json` on a vrf when it didn't exist,
frr would output invalid json.

Signed-off-by: Nathan Van Gheem <nathan@cumulusnetworks.com>
2018-07-27 10:17:03 -04:00
Philippe Guibert
521191140d zebra: fix missing table identifier passed for ip route vrf commands
The parameter was missing in that vty command. Then it is being added.
Also some documentation is refreshed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-27 08:42:14 +02:00
Philippe Guibert
7929821a81 zebra: show pbr iptable per iptable
Add ability to pass a ip table parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-07-24 12:17:57 +02:00
Renato Westphal
f4f9200dec
Merge pull request #2668 from dslicenc/cm21722-v6-vrf-display
zebra: remove default vrf output for kernel vrf ipv6 blackhole default
2018-07-23 14:56:29 -03:00
Christian Franke
c9591045cc zebra: fix do_show_route_helper to include srcdest routes 2018-07-19 15:16:57 -04:00
Don Slice
bbde7a0f25 zebra: fix nexthop type check for kernel default route display
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-07-18 13:05:50 +00:00
Don Slice
fc132690b4 zebra: remove default vrf output for kernel vrf ipv6 blackhole default
It was reported that "show ipv6 route vrf <vrfname>", "show ipv6 route
vrf <vrfname> ::/0 " or "show ipv6 route vrf <vrfname> json" all
displayed that the nexthop was in the default vrf.  This was because
the kernel netlink messages would supply the RTA_OIF of the loopback
interface for the kernel-created default route for the vrf, where ipv4
did not supply any RTA_OIF.  This fix suppresses the display if the
nexthop and route entry are in different vrfs and the nexthop is
NEXTHOP_TYPE_BLACKHOLE.

Ticket: CM-21722
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-07-17 14:35:33 +00:00
Chirag Shah
62710e2b33 zebra: Hide default vrf instance of l3vni cmd
Hide following l3vni config from DEFAULT_VRF instance
until it is fully supported.

TORS1(config)# vni 2222456 prefix-routes-only

Ticket:CM-20572

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-06-15 15:42:20 -07:00
paco
77e03f0511 zebra: resource leak fix (Coverity 1465679)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-08 18:51:43 +02:00
Russ White
49eeb60a70
Merge pull request #2123 from qlyoung/zserv-mt
Multithreaded Zserv
2018-06-08 06:47:14 -04:00
Philippe Guibert
00384b5fbd zebra: keep one command to handle vty with/without table param
That fix is a workaround from a vtysh limitation.
Because table identifier should be accessible in configuration only for
vrf netns backends, there was a need to differentiate the vty commands.
Unfortunately, vtysh parses the two commands without knowing which
command has really been installed.
Using one single vty command will avoid having this issue in vtysh.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-06-01 15:24:13 +02:00
Philippe Guibert
b73823efa1 zebra: add in show vrf information about vrf backend kind
By default, nothing is displayed. If vrf backend is linux network
namespaces, then "netns-based vrfs" is displayed, before dumping the
list of VRFs.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-06-01 15:24:13 +02:00
Philippe Guibert
87d6ac7a04 zebra: add show ip route table vrf command
It is possible to get table per VRF, provided that vrf backend is
configured with NETNS.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-06-01 15:24:13 +02:00
Philippe Guibert
e9748a8901 zebra: table_id election with the vrf backend
As table_id for VRF with netns backend is main table ( RT_TABLE_MAIN or
zebrad.rtm_table_default), this makes possible to return the table id
that wants to be configured for those cases. ( in addition to default
VRF). In other cases ( VRF Lite presumably), then vrf table_id is
returned.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-06-01 15:24:13 +02:00
Philippe Guibert
b3b086026b zebra: add table keyword to route configuration vty command
Add the table keyword for all ip route/ip mroute/ipv6 route commands
that are available. Also, the main structure is being added a table
identifier.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-06-01 15:24:13 +02:00
Quentin Young
ccd51bd210 zebra: misc fixes, perf improvements
* Coalesce multiple write() syscalls into one
* Write larger chunks
* Decrease default read limit to 1000
* Remove unnecessary operations from hot loop (zserv_write)
* Move cross-schedule out of obuf lock
* Use atomic ops to update atomic variable

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Philippe Guibert
586f4ccf2c zebra: pbr vty show command for ipset and iptables
Two new vty show functions available:
show pbr ipset <NAME>
show pbr iptables <NAME>

Those function dump the underlying "kernel" contexts. It relies on the
zebra pbr contexts. This helps then to know which zebra pbr
context has been configured since those contexts are mainly configured
by BGP Flowspec.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-05-25 15:49:38 +02:00
Mitesh Kanjariya
cf29971433 zebra: vni [prefix-routes-only] should also be provided for the 'no' cmd
We have a command to enable symmetric routing only for type-5 routes.
This command is provided under vrf <> option in zebra as follows:
vrf <VRF>
  vni <VNI> [prefix-routes-only]
We need the corresponding no version of the command as well as follows:
vrf <VRF>
  no vni <VNI> [prefix-routes-only]

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Donald Sharp
f03098f979 zebra: Add a few more breadcrumbs
re->status and re->flags both influence our decision states
for rib processing.  Yet it's impossible to see them.  Add
a tiny bit of code to allow us to look at them when things
are not behaving like we would expect.

Additionally dump the nexthop->flags at the same time for
the same reasons.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-02 16:50:37 -04:00
Donald Sharp
d5ab760b34 zebra: Leave some warning breadcrumbs
When a user specifies static routes, there are a couple of states
where we will store the route and display it as part of the 'show run'
but it will not be installed until such time that the dependant state
is created.  Add some breadcrumbs to the user so that they can figure
out WTF just happened.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17 14:04:47 -04:00
Renato Westphal
15da01e92d
Merge pull request #1973 from donaldsharp/static_nh_vrf
Static nh vrf
2018-04-10 17:27:57 -03:00
Russ White
bb04824d89
Merge pull request #2027 from qlyoung/fix-vrf-static-holdem-display
zebra: display holdem statics correctly
2018-04-06 13:21:49 -04:00
Quentin Young
cd4b15a523
zebra: display holdem statics correctly
Holdem statics display the dest (and mask, if present) string that the
user entered instead of converting to CIDR notation and applying the
mask. They need to do the latter.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-05 11:02:07 -04:00
Quentin Young
d7ca637481
zebra: consistently order static route attributes
Everyone else displays them with nexthop-vrf last.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-04 15:23:36 -04:00
Donald Sharp
4c66767c10 zebra: Prevent crash in the off-chance we make a mistake
Prevent zebra from crashing for when the nexthop vrf has
changed in some manner and the lookup fails.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27 15:52:26 -04:00
Donald Sharp
90f86c0a4d zebra: Fixup enable/disable of static routes in vrfs
When a user enables and disables a vrf, we were not
properly cleaning up the static routes leaving us
in a state where we would crash by looking at anything
in zebra.

On disable of a vrf -> Search through all static routes
and if the nexthop vrf is the disabled vrf uninstall it.
Additionally uninstall all static routes in that zvrf

On enable of a vrf -> Search through all static routes
and if the nexthop vrf is the enabled vrf install it.
Additionally install all the static routes in that zvrf.

Ticket: CM-19768
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-27 15:52:25 -04:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Quentin Young
b88689f2a7
zebra: fix config of vrf static routes
This patch fixes two bugs with respect to static route configuration
inside vrf contexts:

* Entering a negative form of a static route created the static route.
* Once created, static routes could not be deleted.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-21 16:47:46 -04:00
Donald Sharp
6e94d41057 zebra: Fix comparison to not look at itself
The nexthop vrf comparison should not be against itself

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-20 19:16:24 -04:00
Donald Sharp
af5849b662 zebra: Fix memory leak on re-enter case
When we have a case where the user re-enters the same
ip route line, we need to delete the memory we just
malloc'ed.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-20 18:41:00 -04:00
Quentin Young
be627102c0
zebra: fix static route config write
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-19 17:37:00 -04:00
Donald Sharp
6a17b1a0f2 zebra: Extend unknown vrf to vrf part of ip route
When specifying a ip route:

ip route 4.3.2.0/24 192.168.201.1 vrf DONNA

Accept DONNA even if it has not been created yet.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 18:45:29 -04:00
Donald Sharp
ad97d1c10a zebra: Allow duplicate entry of a route
If a user enters a route inside a non kernel existant vrf:

vrf BLOOP
  ip route 4.3.2.0/24 192.168.201.1
!

They should be able to enter it over and over and over and
over and over no matter how futile it is.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 18:38:25 -04:00
Donald Sharp
e7f96f7411 zebra: Auto create the nexthop-vrf if needed.
Currently if I try to use a nexthop-vrf that has
not been specified yet we get a failure from the cli.

Add code to zebra so that if we fail to find the nexthop-vrf
we auto create it, instead of failing the install.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 18:36:10 -04:00
Renato Westphal
f22ab4c3fc
Merge pull request #1819 from donaldsharp/static_stuff
Static stuff
2018-03-14 11:26:20 -03:00
Donald Sharp
7ee30f288e lib: Isolate nexthop_group functions to nexthop_group.c
Also modify `struct route_entry` to use nexthop_groups.
Move ALL_NEXTHOPS loop to nexthop_group.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
4060008bda zebra: Allow for storage of non-configed vrf routes
When zebra is being configed we allow for static routes
to be entered.  This presents a problem for when a vrf
is cli configed but not kernel configed yet.

Modify zebra to notice that when a static route is
entered and either the nexthop vrf or the vrf
is not fully configed, to save that config to the
side.

When vrf's become active( kernel configed ) parse
through the list of saved to the side static routes
and determine if any of them can be installed.

Additionally modify the cli to output the saved
to the side cli, so that we can properly handle
a wr mem.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-07 14:33:59 -05:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Philippe Guibert
81c9005ff6 zebra: enhance show vrf for netns and fixing
Show vrf command displays information on the vrf, if it is related to
vrf kernel or if it is related to netns.
When a vrf from kernel is detected, before creating a new vrf, a check
is done against an already present vrf, and if that vrf is not a vrf
mapped with a netns. If that is that case, then the creation is
rejected.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Philippe Guibert
ac3133a35d
Merge pull request #1736 from mkanjari/type5-with-asymm
zebra, bgp: Support type-5 routes with asymmetric routing
2018-02-27 10:36:57 +01:00
Donald Sharp
ae825b8bf0 zebra: Add code to display interesting tables
With the ability of zebra to handle random tables,
add code to display those tables via the
show <ip|ipv6> route table (1-...) [json] command.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-23 07:08:36 -05:00
Donald Sharp
6447dbb372 zebra: Clean up some SA issues found by new code
1) Add asserts in a couple of spots to show we
never expect prefix to be bad.
2) Fix some bfd code where out_ctxt will
always be NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-13 23:41:31 -05:00
Mitesh Kanjariya
c48d9f5f85 zebra, bgp: Support type-5 routes with asymmetric routing
Asymmetric routing is an ideal choice when all VLANs are cfged on all leafs.
It simplifies the routing configuration and
eliminates potential need for advertising subnet routes.
However, we need to reach the Internet or global destinations
or to do subnet-based routing between PODs or DCs.
This requires EVPN type-5 routes but those routes require L3 VNI configuration.

This task is to support EVPN type-5 routes for prefix-based routing in
conjunction with asymmetric routing within the POD/DC.
It is done by providing an option to use the L3 VNI only for prefix routes,
so that type-2 routes (host routes) will only use the L2 VNI.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-10 00:41:28 -08:00
Renato Westphal
a97e5c1a80
Merge pull request #1722 from donaldsharp/vrf_mc_vrf
zebra: Fix vrf routes from assuming their nh's were in the default
2018-02-09 20:54:17 -02:00
Donald Sharp
70e98a7fe7 *: Make code use a consisten definition of labels
Turns out we had 3 different ways to define labels
all of them overlapping with the same meanings.
Consolidate to 1.  This one choosen is consistent
naming wise with what the *bsd and linux kernels
use.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 20:31:37 -05:00
Donald Sharp
4a7371e9e2 *: Track vrfs per nexthop not per route entry
Track the vfrs on a per nexthop basis instead
of on a per route entry basis.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-08 19:35:53 -05:00
Philippe Guibert
8e71b98f72
Merge pull request #1654 from mkanjari/evpn-symm-routing-enhancements
Evpn symmetric routing enhancements
2018-02-08 11:46:29 +01:00
Donald Sharp
dfce9b257d zebra: Fix vrf routes from assuming their nh's were in the default
Fix the read in of vrf routes on a start or restart that caused
the nexthop_vrf to be assumed to be the default vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-07 18:22:15 -05:00