Commit Graph

463 Commits

Author SHA1 Message Date
Renato Westphal
338b8e914a *: setting the socket send/recv buffer sizes doesn't need elevated privs
The less code running under elevated privileges the better.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-08 13:11:28 -03:00
Donald Sharp
416745628e zebra: When shutting down actually close the socket
When shutting down and we have a very large table to shutdown
and after we've intentionally closed all the client connections
close the zebra zserv client socket.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Donald Sharp
494247b58c zebra: Update zserv debug messages to give a bit more useful info
When we schedule a packet for future handling, list the packet
type so that we can see what we are getting with debugs.

Also note which client and how many packets we received from that
client.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-10 11:48:14 -05:00
Donald Sharp
a8a20c4e3c zebra: Remove zclient->idinfo restrictions
The restricting of data about interfaces was both inconsistent
in application and allowed protocol developers to get into states where
they did not have the expected data about an interface that they
thought that they would.  These restrictions and inconsistencies
keep causing bugs that have to be sorted through.

The latest iteration of this bug was that commit:
f20b478ef3

Has caused pim to not receive interface up notifications( but
it knows the interface is back in the vrf and it knows the
relevant ip addresses on the interface as they were changed
as part of an ifdown/ifup cycle ).

Remove this restriction and allow the interface events to
be propagated to all clients.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-05 09:13:30 -05:00
Donald Sharp
2561d12e5d zebra: Remove struct zebra_t
This structure is unused anymore and does not belong in zserv.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05: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
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
cc3d883445 zebra: Make zebrad.sock zserv.c private data
The zebra.sock data is the listener socket for the zapi protocol.
The rest of the zebra router does not need to see this data.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
161e9ab7e2 zebra: Move client_list to the zebra_router data structure
The client_list should be owned by the zebra_router data structure
as that it is part of global state information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Donald Sharp
3801e7646c zebra: Move the master thread handler to the zrouter structure
The master thread handler is really part of the zrouter structure.
So let's move it over to that.  Eventually zserv.h will only be
used for zapi messages.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-31 09:20:46 -05:00
Renato Westphal
bb6b7f79be zebra, lib: send VRF backend to the client daemons
Add a new field in the ZEBRA_CAPABILITIES zapi message specifying
the VRF backend in use.

For simplicity, make the zclient code call vrf_configure_backend()
to apply the received value automatically instead of requiring
the daemons to do that themselves in their zebra_capabilities()
callbacks.

Additionally, call zebra_vrf_update_all() only after sending the
capabilities message to the client, so that it will know which VRF
backend is in use when processing the VRF messages.

This commit fixes a couple of bugs in the "interface" CLI command and
associated northbound callbacks, which behave differently depending
on the VRF backend in use. Before this commit, the vrf_backend
variable would always be set to VRF_BACKEND_NETNS in the client
daemons, even when zebra was started without the --vrfwnetns option.
This could lead to inconsistent behavior and subtle bugs under
specific circumstances.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-19 22:46:37 -02:00
Renato Westphal
49db7a7b05 lib, zebra: add AFI parameter to the ZEBRA_REDISTRIBUTE_DEFAULT_* messages
Some daemons like ospfd and isisd have the ability to advertise a
default route to their peers only if one exists in the RIB. This
is what the "default-information originate" commands do when used
without the "always" parameter.

For that to work, these daemons use the ZEBRA_REDISTRIBUTE_DEFAULT_ADD
message to request default route information to zebra. The problem
is that this message didn't have an AFI parameter, so a default route
from any address-family would satisfy the requests from both daemons
(e.g. ::/0 would trigger ospfd to advertise a default route to its
peers, and 0.0.0.0/0 would trigger isisd to advertise a default route
to its IPv6 peers).

Fix this by adding an AFI parameter to the
ZEBRA_REDISTRIBUTE_DEFAULT_{ADD,DELETE} messages and making the
corresponding code changes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-14 11:41:33 -02:00
Mark Stapp
dded2aba4a zebra: make incoming zserv message-processing a singleton event
Stop creating individual, one-time events as each batch of
incoming zserv/zapi messages is processed - use a singleton
event so that the incoming message activity is more fair if
the zebra main pthread has other events to run.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-12-13 04:56:00 -05:00
Quentin Young
0545c37384 *: only use 32-bit atomics
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-11-19 18:44:35 +00:00
Donald Sharp
ab5990d8b9 zebra: Add counting to nexthop register/unregister events
Add a bit of code to note how many register/unregister nht
events we have had.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-31 06:25:51 -04:00
David Lamparter
1ac267a2d9 lib: remove frr_pthread->id
All I can see is an unneccessary complication.  If there's some purpose
here it needs to be documented...

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-19 22:01:46 +02:00
Quentin Young
1c50c1c0d6 *: style for EC replacements
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:38:57 +00:00
Quentin Young
450971aa99 *: LIB_[ERR|WARN] -> EC_LIB
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:34:28 +00:00
Quentin Young
e914ccbe9c zebra: ZEBRA_[ERR|WARN] -> EC_ZEBRA
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 19:23:29 +00:00
Quentin Young
364fed6b07 zebra: fix includes
Add and remove error related includes as necessary.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:41 +00:00
Quentin Young
9df414feeb zebra: flog_warn conversion
Convert Zebra to user error subsystem.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:38 +00:00
Chirag Shah
57019528a0 *: pthread set name abstraction
Testing Done:

 TOR#cat /proc/2670/task/2672/comm
 bgpd_ka

TOR# ps H -C bgpd -o 'pid tid cmd comm'
  PID   TID CMD                         COMMAND
  2670  2670 /usr/lib/frr/bgpd -M snmp - bgpd
  2670  2671 /usr/lib/frr/bgpd -M snmp - bgpd
  2670  2672 /usr/lib/frr/bgpd -M snmp - bgpd_ka

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-08-29 15:41:54 -07:00
David Lamparter
6bb30c2cba *: use frr_elevate_privs() (2/2: manual)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
Quentin Young
af4c27286d *: rename zlog_fer -> flog_err
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Donald Sharp
174482ef37 bgpd, lib, zebra: Convert LIB_ERR_PRIVILEGES
For all the places we zlog_err about raising/lowering privileges, use
zlog_ferr.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14 20:02:05 +00:00
Quentin Young
c022637847 zebra: don't close client socket from I/O pthread
The client socket value can only be modified by the main thread.
Modifying the client socket from within the client I/O pthread
introduces race conditions.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-01 19:41:47 +00:00
Quentin Young
a580357a87 zebra: ensure cleanup of rib on client close
Socket should be closed in zserv_client_free() and nowhere else.

Credit to Mark Stapp for catching this one.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-01 19:41:47 +00:00
Quentin Young
f3e33b690b zebra: dont delete pthreads from under themselves
* Rename some things to be less confusing
* Convert client close function to take a client struct rather than a
  task
* Extern client close function and use it when handling SIGTERM

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-07-30 23:06:27 +00:00
Quentin Young
29cb1b24d1 zebra: remove unused var in zserv.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-07-24 21:01:29 +00:00
Quentin Young
2875801fa3 zebra: fix zapi fuzzing infra
Some of this stuff got broken with the introduction of pthreads.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-07-18 16:32:07 +00:00
Stephen Worley
24f8f9791e zebra: Fix function call in fuzzing code
The fuzzing code was calling zebra_client_create which was refactored to zserv_client_create.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2018-07-12 12:39:13 -04:00
Quentin Young
7012f1a38c zebra: remove asserts on task nullity
While ZAPI I/O threads make a best effort to kill any scheduled tasks on
their threadmasters, after death another pthread can continue to
schedule onto the threadmaster. This isn't a problem per se since the
tasks will never run, but it also means that asserting that it hasn't
happened is pointless.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-07-02 18:07:28 +00:00
Jafar Al-Gharaibeh
20e5fd7ab5
Merge pull request #2532 from donaldsharp/various_stuff
Redistribution and some extra developer debug code
2018-06-29 12:41:02 -05:00
Donald Sharp
ce4f1050ca zebra: Fix use of uninited variable
Allow compiler to think the value is actually set to
something useful in an impossible case.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-28 21:06:23 -04:00
Donald Sharp
03ed85a6c0 lib, zebra: Add a bit of code to look at fifo
When in a dev build add a bit of code to track max
depth of a fifo and to allow zebra to report on it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-27 20:01:22 -04:00
Donald Sharp
03f290185b zebra: Cleanup code to test for failure once
Cleanup the zebra code to test for failure for reading
from stream once instead of once to see if we should
debug and once for the actual failure.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-13 09:19:37 -04:00
Quentin Young
c2ca5ee66d zebra: fix race condition in i/o pthread shutdown
I mistakenly used an external mechanism to cause a pthread to shut
itself down instead of using the one built into frr_pthread.[ch]. This
created a race condition whereby a pthread could schedule work onto a
dead pthread and cause it to reanimate.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:46 +00: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
Quentin Young
ae6670d013 zebra: don't send data after closing connection
Cancelling threads is nice but they can potentially be scheduled again
after cancellation without an explicit check.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
43ea2c7609 zebra: fix zserv_read rescheduling
Incorrect decrement operation resulted in always rescheduling instead of
only when needed.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
29bed51b74 zebra: fix write task collision
Only one I/O task can be scheduled per file descriptor. Having two
separate tasks for buffer filling and buffer flushing was breaking that
invariant and causing messages to never be written.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
1f312c843d zebra: style
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
822167e704 zebra: some more i/o optimizations
* Separate flush task from write task, so we can continue adding to the
  write buffer while it's waiting to flush
* Handle write errors sooner rather than later
* Only schedule a process job if we have packets to process
* Tweak zserv_process_messages to not reschedule itself and rely on
  zserv_read() to do so in all proper cases

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
e1de21d760 zebra: fix uninitialized value
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
727c9b9961 zebra: handle label manager & fuzzing growths
Label manager reaches its hands into session / IO code for zserv for
whatever reason, gotta handle that.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
904e0d8830 zebra: optimize zserv_process_messages
* Simplify zapi_msg <-> zserv interaction
* Remove header validity checks, as they're already performed before the
  packet ever makes it here
* Perform the same kind of batch processing done in zserv_write by
  copying multiple inbound packets under lock instead of doing serial
  locking
* Perform self-scheduling under the same lock

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
370d8dad79 zebra: optimize zserv_write
Dequeue all pending messages when writing and push them all into the
write buffer. This removes the necessity to self-schedule, avoiding a
mutex lock, and should also maximize throughput by not writing 1 packet
per job.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
1572d9aff0 zserv: optimize zserv_read
* Increase the maximum number of packets to read per read job
* Store read packets in a local cached buffer to avoid mutex overhead
* Only update last-read time / last-command if we actually read a packet
* Add missing log line for corrupt header case

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
21ccc0cf24 zebra: refactor zserv names, consolidate events
* Add centralized thread scheduling dispatchers for client threads and
  the main thread

* Rename everything in zserv.c to stop using a combination of:
  - zebra_server_*
  - zebra_*
  - zserv_*

  Everything in zserv.c now begins with zserv_*.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
f2efe6a3eb zebra: reorganize zserv.c by pthread affinity
Since it is already quite difficult to understand the various pieces
going on here, I reorganized the file to make it much cleaner and easier
to understand. The organization is now:

zserv.c:
 ,---------------------------------.
/ include statements               |
| ...                              |
| ...                              |
| -------------------------------- |
| Client pthread server functions  |
| ...                              |
| ...                              |
| -------------------------------- |
| Main pthread server functions    |
| ...                              |
| ...                              |
| -------------------------------- |
| CLI commands, other              |
| ...                              |
| ...                              |
\_________________________________/

No code has been changed; the functions have merely been moved around.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
52f6868dd4 zebra: fix session stats data race, memory leak
* Time counters need to use atomic access between threads
* After a client disconnects, we properly kill the thread but need to
  free its frr_pthread as well

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
92be6487a4 zebra: fix some memory errors, scheduling bugs
* Add doc comments explaining hairy bits of thread lifecycle
* Remove t_suicide as it no longer makes sense
* Remove client double-free
* Remove unnecessary THREAD_OFF being used in incorrect pthread context
* Eliminate unnecessary racey access to client's obuf_fifo
* Ensure zserv_process_messages() reschedules itself if it has not
  finished its work

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
329e35dab8 zebra: multithreaded zserv
Handle each zclient in its own thread.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-29 19:06:16 +00:00
Quentin Young
8b1766b148 zebra: style last 3 changes
Fixup latent style issues in copied code.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:25 -04:00
Quentin Young
d864709552 zebra: cleanup for zapi_msg.c split
* Rename client_connect and client_close hooks to zapi_client_connect
  and zapi_client_close
* Remove some more unnecessary headers
* Fix a copy-paste error in zapi_msg.[ch] header comments
* Fix an inclusion comment in zserv.c

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:25 -04:00
Quentin Young
453844abd7 zebra: use hooks for client lifecycle callbacks
zserv.c was using hardcoded callbacks to clean up various components
when a client disconnected. Ergo zserv.c had to know about all these
unrelated components that it should not care about. We have hooks now,
let's use the proper thing instead.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:24 -04:00
Quentin Young
bf094f6975 zebra: clean up zapi organization
zserv.c has become something of a dumping ground for everything vaguely
related to ZAPI and really needs some love. This change splits out the
code fo building and consuming ZAPI messages into a separate source
file, leaving the actual session and client lifecycle code in zserv.c.

Unfortunately since the #include situation in Zebra has not been paid
much attention I was forced to fix the headers in a lot of other source
files. This is a net improvement overall though.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 22:50:24 -04:00
Donald Sharp
09924cffad zebra: Add pass up through zapi what zebra is capable of handling
Zebra is starting to have some run-time capabilites that would be
useful to pass up to the higher level protocols so that they
can act in an appropriate manner when needed.

Send the ecmp value zebra is being run with and whether or not
we believe mpls is enabled in the kernel or not.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-18 11:10:27 -04:00
Philippe Guibert
5dd0722dcf zebra: adapt zebra_pbr_rule based with pbr_rule
In order to avoid duplicates functions, the zebra_pbr_rule structure
used by zebra to decode the zapi message, and send netlink messages, is
slightly modified. the structure is derived from pbr_rule, but it also
includes sock identifier that is used to send back information to the
daemon that did the request. Also, the ifp pointer is stored in that
structure.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
7abd6c4fa0 zebra: add IPTABLE_ADD and IPTABLE_DEL commands in zapi
Those messages permit a remote daemon to configure an iptable entry. A
structure is defined that maps to an iptable entry. More specifically,
this structure proposes to associate fwmark, and a table ID.
Adding to the configuration, the initialisation of iptables hash list is
done into zebra netnamespace. Also a hook for notifying the sender that
the iptables has been correctly set is done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
1907e4b80b zebra: pbr rule structure is being added fwmark tag
PBR rule is being added a 32 bit value that can be used to record a rule
in the kernel, by using a fwmark information.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
425bdd6bf1 zebra: handling notifications upon ipset creation/destruction done
Once ipset entries are injected in the kernel, the relevant daemon is
informed with a zebra message sent back.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:43 +02:00
Philippe Guibert
d59c13af5c lib: add ZEBRA IPSET defines
ZEBRA IPSET defines are added for creating/deleting ipset contexts.
Ans also create ipset hash sets.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-04-16 14:40:16 +02:00
Russ White
fdbbf02a05
Merge pull request #1987 from donaldsharp/zserv_read_fix
two zebra changes
2018-03-30 09:37:51 -04:00
Donald Sharp
c0079fc9ce zebra: Subtract header length in the right spot
The header length needs to be subtracted from the handling
side of the zapi in zebra.  This is because we refigure the
header data structure.  The receive side doesn't care
about the total header length so no need to subtract there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-29 08:52:39 -04:00
Philippe Guibert
b98f77282b bgpd: add API to allocate a range of table identifiers
In BGP, doing policy-routing  requires to use table identifiers.
Flowspec protocol will need to have that. 1 API from bgp zebra has been
done to get the table chunk.
Internally, onec flowspec is enabled, the BGP engine will try to
connect smoothly to the table manager. If zebra is not connected, it
will try to connect 10 seconds later. If zebra is connected, and it is
success, then a polling mechanism each 60 seconds is put in place. All
the internal mechanism has no impact on the BGP process.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-29 09:20:01 +02:00
Philippe Guibert
8288a24fc1 zebra: add the handling of table ids from remote daemons
This commit is connecting the table manager with remote daemons by
handling the queries.
As the function is similar in many points with label allocator, a
function has been renamed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-29 09:19:58 +02: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
Donald Sharp
0528d946d5 zebra: Allow deletions from arbitrary tables
When a route_delete is received allow the deletion
to occur in the passed in tableid if the vrf is VRF_DEFAULT.

This now matches route_add behavior in rib_add_multipath

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-21 13:49:51 -04:00
Donald Sharp
98a217f0d0 zebra: Ensure that we properly decode the zapi_route sent to us
Ensure that we have properly decoded the zapi_route sent to us
and if we cannot decode, log and move on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-20 18:48:12 -04:00
Renato Westphal
b49dc9f301
Merge pull request #1909 from donaldsharp/zebra_rule
Zebra rule
2018-03-20 09:45:57 -03:00
Donald Sharp
978caa0c88 zebra: Free memory leak
Free the memory leaked stream in failure cases.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-19 09:18:10 -04:00
Donald Sharp
149a38a313 zebra: Compare to the number of elements not size of array
When figuring out whom to call and if we actually can legally
call into the handler array actually use the number of elements
in the array instead of the size of the array.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-19 09:18:10 -04:00
Donald Sharp
e69aa08419 zebra: Allow for deletion of rules when the originator goes away
When zebra detects that the originator has dissapeared
delete all rules associated with that client.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-16 10:17:41 -04:00
Donald Sharp
010c5efac0
Merge pull request #1739 from LabNConsulting/working/master/bgp-vpn-vrf-leaking
bgpd: vpn - vrf route leaking
2018-03-15 09:01:27 -04:00
paulzlabn
9891fa4cb1
zserv.c: delete unused zsend_write_nexthop 2018-03-14 22:17:53 -07:00
paulzlabn
4ea6c38bf4
zserv.c: zebra_server_send_message() second parameter 2018-03-14 21:42:09 -07:00
Donald Sharp
32391affcc zebra: Add some additional vrf info to debugs
There were several places where when I am attempting
to debug zebra functionality that I would really
like to have the ability to know what vrf I think
I am operating on.

Add the vrf_id to a bunch of zlog_debug messages
to help figure out issues when they happen.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-14 20:14:36 -04:00
paulzlabn
3f1224cd1a
Merge branch 'master' into working/master/bgp-vpn-vrf-leaking 2018-03-14 13:31:58 -07:00
Philippe Guibert
c1a0038782
Merge pull request #1806 from vivek-cumulus/evpn-ipv6-tenant-routing
*: EVPN symmetric routing for IPv6 tenant routes
2018-03-13 10:20:29 +01:00
Quentin Young
41903a4074
lib, zebra: slight cleanup after rebase
Rebased zapi-cleanup, needs a bit of poking.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 14:57:06 -04:00
Quentin Young
107afcd10b
lib, zebra: clean up zapi nits
* Get correct data size when parsing VRF ids
* Move some vars into smaller scope

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 14:57:06 -04:00
Quentin Young
1002497af5
zebra: reorganize zserv, batch i/o
Group send and receive functions together, change handlers to take a
message instead of looking at ->ibuf and ->obuf, allow zebra to read
multiple packets off the wire at a time.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 14:57:05 -04:00
Quentin Young
89f4e5077b
zebra: standardize ZAPI message handler args
A lot of the handler functions that are called directly from the ZAPI
input processing code take different argument sets where they don't need
to. These functions are called from only one place and all have the same
fundamental information available to them to do their work. There is no
need to specialize what information is passed to them; it is cleaner and
easier to understand when they all accept the same base set of
information and extract what they need inline.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 14:57:05 -04:00
Quentin Young
9bcbcae2e4
zebra: add struct zmsghdr
Formalize the ZAPI header by documenting it in code and providing it to
message handlers free of charge to reduce complexity.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 14:57:05 -04:00
Quentin Young
8068a649a7
zebra: dont return a status code in zapi handlers
All of the ZAPI message handlers return an integer that means different
things to each of them, but nobody ever reads these integers, so this is
technical debt that we can just eliminate outright.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 14:57:05 -04:00
vivek
4e262455a2 Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
	bgpd/bgp_evpn.c
2018-03-10 04:03:41 +00:00
G. Paul Ziemba
1b6e575b2a zebra: debug additional detail for route announce/redist
alos add a comment

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:42:40 -05:00
Donald Sharp
b6c5d34354 lib, zebra: Add Rule insertion success/failure messages
Add code to allow rule insertion notifications to be
sent back up the stack.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:11:40 -05:00
Donald Sharp
a03219780f zebra: Make the ifp part of the rule structure
Every place we need to pass around the rule structure
we need to pass around the ifp as well.  Move it into
the structure.  This will also allow us to notify up
to higher level protocols that this worked properly
or not better too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
43fe6a2a73 zebra: Keep track of rules written
Keep track of rules written into the kernel.  This will
allow us to delete them on shutdown if we are not cleaned
up properly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
1fbfe5a572 zebra: Cleanup api
Allow the add/delete to go through a intermediary function in
zebra_pbr.c instead of directly to the underlying os call.  This
will allow future refinements to track the data a bit better
so that on shutdown we can delete the rules.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
fd71d73eb3 zebra: Cleanup a couple of api issues
1) use uint32_t instead of u_int32_t as we are supposed to
2) Consolidate priority into the rule.
3) Cleanup the api from this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Donald Sharp
e16abbb303 lib, zebra: Add rule encoding
Add some code to pass the rule we want installed into
the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05: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
ba1849ef8c lib, zebra: Allow zapi to send down the tableid
Allow the calling daemon to pass down what table-id we
want to use to install the route.  Useful for PBR.

The vrf id passed must be the VRF_DEFAULT else this
value is ignored.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
vivek
bfd498f0da Merge branch 'master' of https://github.com/frrouting/frr into evpn-ipv6-tenant-routing
Conflicts:
	zebra/zserv.c
2018-03-06 22:19:24 +00: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
vivek
558283638b lib, zebra: Fix warnings
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2018-03-01 19:50:46 +00:00
Donald Sharp
c7bacffe46 zebra: Use the passed in nexthops vrf
When decoding and creating the appropriate data structures
for a nexthop, use the passed in vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-02-28 18:55:10 -05:00