Commit Graph

3994 Commits

Author SHA1 Message Date
Renato Westphal
1821018078
Merge pull request #6542 from mjstapp/zebra_opaque_unicast
Zebra opaque unicast messages
2020-06-10 19:06:16 -03:00
David Lamparter
e2be26436a lib: set up TLS log buffer after forking
... it contains our pid, so doing it before fork leads to littering
buffers since we try to clean up with the forked pid...

Fixes: #6541
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-10 20:30:02 +02:00
Santosh P K
57dd2f0097
Merge pull request #6414 from opensourcerouting/nb-error-handling
NB context + enhanced error handling
2020-06-10 22:47:07 +05:30
Mark Stapp
478ff17be6 lib,sharpd: add a SHARP_STR alias
Add a vty-friendly protocol name alias for sharpd.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:26:27 -04:00
Mark Stapp
387831ffc3 lib,zebra,sharpd: modify opaque zapi message to support unicast
Start modifying the OPAQUE zapi message to include optional
unicast destination zapi client info. Add a 'decode' api and
opaque msg struct to encapsulate that optional info.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:26:27 -04:00
Mark Stapp
d2ddc1416b lib,zebra: rename opaque decode api
Change name of an opaque zapi api to 'decode' to align with the
other zapi message parsing apis. Missed that in the original
opaque commits.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-10 08:16:10 -04:00
Donald Sharp
2d8c1bc235
Merge pull request #5323 from opensourcerouting/filter-nb
lib: migrate FRR filter to northbound
2020-06-10 06:59:32 -04:00
Donatas Abraitis
c415a4dcd4 lib: Make sure route_map_dep_data is not NULL before decrementing refcount
```
2  0x00007fb9adb07a10 in core_handler (signo=11, siginfo=0x7ffe1414a630, context=<optimized out>) at lib/sigevent.c:228
        sa_default = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
        sigset = {__val = {8192, 0 <repeats 15 times>}}
3  <signal handler called>
No locals.
4  route_map_dep_update (type=RMAP_EVENT_CLIST_DELETED, rmap_name=0x55d807ddd410 "export4-as49917", dep_name=<optimized out>, dephash=0x55d807adf170) at lib/routemap.c:2750
        dep = 0x55d807d35b00
        dname = 0x55d8081ba560 "123:124"
        rname = 0x55d8081ba540 "export4-as49917"
        ret = 0
        dep_data = 0x0
        ret_dep_data = 0x0
        tmp_dep_data = {rname = 0x55d8081ba540 "export4-as49917", refcnt = 0}
5  route_map_upd8_dependency (type=RMAP_EVENT_CLIST_DELETED, arg=<optimized out>, rmap_name=0x55d807ddd410 "export4-as49917") at lib/routemap.c:2865
        upd8_hash = 0x55d807adf170
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-06-08 16:15:43 +03:00
Renato Westphal
7f4985f6e3
Merge pull request #6516 from qlyoung/fix-northbound-userdata-disappearance
lib: move all userdata when changing node xpath
2020-06-05 20:00:38 -03:00
Rafael Zalamena
49e3e49d72 lib: use relative XPath to filter entry attributes
We can avoid a big amount of `snprintf` by using relative XPath in
`nb_cli_apply_changes`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
84fdeb2015 lib: filter remove extra CLI transaction
`acl_get_seq` should be able to get the sequence number from candidate
configuration without needing to commit anything midway.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
664ae7953a lib: filter remove unused variable
Remove variable that is not being used.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
a247b2b738 lib: remove filter northbound wrapper functions
Lets just use them directly to avoid extra code and to be extra clear
that we are using those callbacks.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
5ba66296f7 lib: don't set NULL after an XFREE
Avoid two assignment operations by just letting XFREE do its thing.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:16 -03:00
Rafael Zalamena
be96651c93 lib: add YANG model enumerations for filter
Avoid magic numbers by using enumerations.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 16:42:11 -03:00
Rafael Zalamena
019f8325a5 lib: implement legacy prefix list behaviour
Some tests expect that a prefix list structure is gone after all its
entries are removed, so lets keep that behaviour.

NOTE: users using YANG/northbound directly without CLI won't be
affected.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena
cf4472c4f7 lib: implement additional CLI prefix list check
Changes:
- Move the `TODO` to the appropriated place and hint how to resolve
  it.
- Apply mask to prefix when storing it in the data structures. We
  can't just add a validation for it otherwise it will break old
  CLIs.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena
81b5042285 lib: fix route map crash on prefix list removal
Changes:
- Refactor list entry deletion to use a function that properly notifies
  route map on deletion (fixes a heap-use-after-free).
- Prefix list entry wild card sets `le` to maximum IP mask value and
  `any` is a boolean.
- Fix prefix list trie removal order (in `prefix_list_entry_update_start`).
- Let only the `any` callback change the value of field `any`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena
88b8bfdc8a lib: fix two filter cli problems
- Show the correct cisco style access list extended information.
- `assert` action so static analyzer doesn't complain about possible
  NULL usage.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:54 -03:00
Rafael Zalamena
744ad1afb4 lib: properly apply prefix list entries
After the commands started working I noticed that prefix lists were
still not working and displaying incorrect information in
`show ip prefix-list`.

Turns out `any` must be set to `0` when a prefix is set and the prefix
entry **must** be installed in the prefix list head.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
a7b2821884 lib: fix prefix list installation
Based on the function `prefix_list_entry_add` and
`prefix_list_entry_delete` it was created two functions to replicate
its functionality without the assumption we are always alocating a new
prefix list entry.

Since the prefix list entry is stored in the YANG private data
structures, we want to avoid the allocation/free of memory that is
hold by the schema.

Every time a prefix list entry values change we must call
`prefix_list_entry_update_start` to uninstall the entry from prefix
list internal structures and then call
`prefix_list_entry_update_finish` to put them back.

The variable `installed` in the prefix list entry tracks the
installation status of the internal structure. It is possible that a
user unconfigures or forgets to add a `prefix` value and so we can't
install the entry until then.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
25ceb5d807 lib: fix access list mac removal command
Copy & paste mistake: MAC commands need `X:X:X:X:X:X` and not
`X:X::X:X/M` types. Also, MAC access-list don't use `exact-match`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
c7d3de9ff2 lib: add 'no ... remark LINE' commands
Implement the commands `no ... remark LINE` for cisco and zebra style
access lists to match `ipX prefix-list description LINE` command set.

It useful when you just want to go through the command history and
prepend a `no` to a `remark` or `description` command. Example:

```
access-list foo remark just another acl
!
! ...
!
! Suddenly we decide we no longer think that remark is useful,
! lets press up key to find that line in history and append `no`:
no access-list foo remark just another acl
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
1d7b156e7e lib: bump filter CLI XPath buffers size
Bump the size of the buffers so the new compilers don't complain about
possible truncation:
```
lib/filter_cli.c: In function ‘ipv6_prefix_list_magic.isra.0’:
lib/filter_cli.c:1336:5: error: ‘%lld’ directive output may be truncated writing between 1 and 20 bytes into a region of size between 16 and 527 [-Werror=format-truncation=]
 1336 |     "%s/entry[sequence='%" PRId64 "']", xpath, sseq);
      |     ^~~~~~~~~~~~~~~~~~~~~~
lib/filter_cli.c:1336:25: note: format string is defined here
 1336 |     "%s/entry[sequence='%" PRId64 "']", xpath, sseq);
lib/filter_cli.c:1336:5: note: directive argument in the range [-9223372036854775803, 9223372036854775807]
 1336 |     "%s/entry[sequence='%" PRId64 "']", xpath, sseq);
      |     ^~~~~~~~~~~~~~~~~~~~~~
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
4362a7681d lib: fix prefix list mask length check
Implement the restriction from the old CLI to northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
cc82bcc161 lib: fix prefix list description command
Changes:
- Use `description` on CLI but `remark` on YANG like access-list (also
  because `description` is a reserved word).
- Rename YANG model field and northbound code.
- Fix wrong sequence type get.
- Fix wrong action XPath in action callback.
- Fix wrong concat in (ipv6|mac) access-list.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
1d3c4b664d lib: migrate filter configuration writer
Use northbound to write the configuration from now on. While here, fix
how `exact-match` configuration is being created.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:53 -03:00
Rafael Zalamena
63895e83cb lib: fix filter northbound crash when batching
Look up next sequence number by checking XPath instead of trying to
access unallocated context data structures.

This only applies for creation, on destroy the data structures must be
there.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Renato Westphal
7b611145c8 lib: introduce the yang_dnode_iterate helper
Implement helper function that iterates over data nodes that satisfy
XPath query.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena
ff94358e54 lib: fix rebase conflicts
Changes:
- Remove unused variable.
- Make prototypes static like the declaration.
- Fix new compilers complaint about uninitialized values.
- Fix new compilers complaint about small buffer for `snprintf` concatenation.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena
fb8884f355 lib: fix northbound conflicts
Changes:
- Use the northbound callback prototypes.
- Re-implement the removed function: `ipv4_network_addr` (more
  information: https://github.com/FRRouting/frr/pull/5535 )

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena
89b7c834a5 lib: migrate prefix-list to use northbound
Implement all northbound CLI commands for prefix lists.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena
e0caeadd48 lib: fix filter northbound double removal
Don't auto remove filter main access list data structure, it has to be
done manually (or via northbound).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:52 -03:00
Rafael Zalamena
b62578bd9b lib: migrate filter CLI to use northbound
Migrate all filter commands to use the newly implemented northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:36:45 -03:00
Rafael Zalamena
c2aab69336 *: add filter northbound support
Allow all daemons to work with filter northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Rafael Zalamena
4470143be0 lib: implement filter northbound
Implement all access-list and prefix-list northbound callbacks.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Rafael Zalamena
2fb7179888 lib: export prefix-lists functions
Export all functions that are going to be used by the northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Rafael Zalamena
4cf2450162 lib: export access-lists shared functions
These functions are going to be used by the new filter northbound
implementation.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Quentin Young
f7c20aa1fd lib: move all userdata when changing node xpath
All userdata pointers need to be rekeyed to their new xpaths, not just
the one associated with the dnode being moved.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-06-04 20:24:52 -04:00
Donald Sharp
4eeb00b020 lib: Allow deletion of some access-lists
Recent rework of access lists to allow sequence numbers
accidently introduced the inability to delete some
access lists.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-06-03 20:01:48 -04:00
Renato Westphal
edfdfe201a
Merge pull request #6506 from volta-networks/ldp_pwstatus_cleanup
ldpd: remove unused 'pwstatus' field from message zapi_pw_status
2020-06-02 21:34:05 -03:00
Karen Schoener
d0e0a52719 ldpd: remove unused 'pwstatus' field from message zapi_pw_status.
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-06-02 18:10:23 -04:00
Mark Stapp
ff49114095 lib: add OPAQUE zapi message
Add a zapi message type designed to carry opaque data. Add
'send' api, and prototype for client handler function. Also
add registration/unreg messages, so that clients can 'subscribe'
to receive these messages as they're passing through zebra.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02 08:20:54 -04:00
Mark Stapp
f8c511cddb lib: add stream_fifo_init, more const
Add utilities that init and deinit a stream_fifo - this lets us
use an on-stack fifo in some places, avoiding malloc'ing. Also
add const to some apis (no functional changes there).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-02 08:20:54 -04:00
Renato Westphal
30712725a0
Merge pull request #6480 from volta-networks/feat_pwstatus
ldpd: Relay data plane pseudowire status in LDP notification
2020-06-01 21:00:51 -03:00
Renato Westphal
c5b9016eeb
Merge pull request #6266 from mjstapp/backup_nhgs
zebra: backup nexthops/nhlfes for LSPs
2020-06-01 20:54:51 -03:00
Mark Stapp
ae076fc276 lib: add zapi_nexthop2str()
Add a handy 2str api for zapi nexthop debugging.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:32 -04:00
Mark Stapp
34f86754a2 lib: add backup nexthop/nhlfe to zapi label messages
Add backup nexthops/nhlfes to the zapi messages used
to convey LSPs to zebra.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01 14:46:12 -04:00
Karen Schoener
fd563cc7f3 ldpd: Relay data plane pseudowire status in LDP notification
Provide a way for the data plane to indicate pseudowire
status (such as: not forwarding, AC failure).

On a data plane pseudowire install failure, data plane
sets the pseudowire status.
Zebra relays the pseudowire status to LDP.
LDP includes the pseudowire status in the LDP notification
to the LDP peer.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-06-01 13:21:37 -04:00
Russ White
b12b5d2097
Merge pull request #6442 from wesleycoakley/pbrd-showjson
pbrd: Optional JSON output for all `show pbr` directives
2020-06-01 07:44:36 -04:00
Rafael Zalamena
18322efd13 bfdd,lib: implement protocol profile selection
Implement the infrastructure for other protocols daemon (e.g. `bgpd`,
`ospfd`, `isisd` etc...) to communicate to BFD daemon which profile
they want to use with their peers.

It was also added the ability for protocols to change profile while
running (no need to remove the registration and then register again).

The protocols message building function was rewritten to support
multiple arguments through `struct bfd_session_arg`, so we can
implement new features without the need of changing function
prototypes. The old function was also rewritten to keep
compatibility.

The profile message part is only available for BFD daemon at the
moment.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-29 17:48:14 -03:00
Renato Westphal
1abe6c535e lib: detect and log unexpected return values from northbound callbacks
Each northbound callback has a set of valid return values, some of
which might depend on the transaction phase. The valid return values
for each callback are documented in the northbound main header.

Add some code to detect when a callback returns an unexpected value
and log the occurrence. This should help us to identify and fix
such problems.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
0e10aeeb18 lib: fix issue were a few gRPC RPCs were being logged twice
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
0b3eed388c lib: raise VTY_MAXCFGCHANGES to accommodate more complex commands
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
789193362b lib: silence -Wformat-truncation warnings in the confd plugin
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
10bdc68f0c *: convert northbound callbacks to new error handling model
The northbound configuration callbacks should now print error
messages to the provided buffer (args->errmsg) instead of logging
them directly.  This will allow the northbound layer to forward the
error messages to the northbound clients in addition to logging them.

NOTE: many callbacks are returning errors without providing any
error message. This needs to be fixed long term.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
df5eda3d87 lib: return human-readable error messages to the northbound clients
Instead of returning only error codes (e.g. NB_ERR_VALIDATION)
to the northbound clients, do better than that and also return
a human-readable error message. This should make FRR more
automation-friendly since operators won't need to dig into system
logs to find out what went wrong in the case of an error.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
13d6b9c134 lib: introduce the northbound context structure
The new northbound context structure contains information about
the client performing a configuration transaction. This information
will be made available to all configuration callbacks through the
args->context parameter.

The usefulness of this structure comes from the fact that it can be
used as a communication channel (both input and output) between the
northbound callbacks and the northbound clients. This can be done
through its "client_data" field which contains client-specific data.

This should cover some very specific scenarios where a northbound
callback should perform an action only if the configuration change
is coming from a given client. An example would be sending a PCEP
response to a PCE when an SR-TE policy is created or modified
through the PCEP northbound client (for that to happen, the
northbound callbacks need to have access to the PCEP request ID,
which needs to be available).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
1be4decb04 lib: northbound style fixes
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:53 -03:00
Wesley Coakley
f1bc75dac6 lib: stream_hexdump takes const struct
Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-28 11:18:11 -04:00
Wesley Coakley
9d72660d67 zebra, lib: bugfix on zebra packet debugging
`debug zebra packet detail` dumps the full message whereas
it had been dropping exactly 10 bytes, the size of the zebra header

Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-28 10:48:56 -04:00
Wesley Coakley
3e81618d0c pbrd, lib, doc: fix new show json key semantics
Revise new `show pbr` keys to be consistent with existing
json in other daemons

target->nexthop
id->tableId (where relevant)
isValid->valid
isInstalled->installed

Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27 10:28:02 -04:00
Wesley Coakley
81c0078ef4 pbrd, lib: verbosity++ for json show directives
Increased the verbosity of the json keys and flattened the returned
structure by removing superfluous keys.

Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27 10:28:02 -04:00
Wesley Coakley
010dd8edcb pbrd, lib: opt. json for show pbr nexthop-group
Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27 10:28:02 -04:00
Naveen Thanikachalam
3eca871582 lib: Fix erroneous r-map behavior
The route-map optimization is not equipped to match IPv6 next-hop
criteria while evaluating IPv4 routes with IPv6 next-hops.
Similary, it is also not equipped to match IPv4 next-hop criteria
while evaluating IPv6 routes with IPv4 next-hops.
This change addresses these issues.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-05-26 06:01:54 -07:00
vivek
9be782ff9f lib: Minor update to EVPN type-5 prefix display
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 22:40:44 -07:00
Rafael Zalamena
d40d6c2274 bfdd,lib,vtysh: new command node for BFD profiles
Add the necessary code to implement the BFD profile command node.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-20 10:39:34 -03:00
Stephen Worley
3dab0aea06
Merge pull request #6426 from pguibert6WIND/update_ifname_before_hook
Update ifname before hook
2020-05-19 13:58:48 -04:00
Quentin Young
55add95cd7
Merge pull request #6428 from volta-networks/fix_mpls_te_bw
lib: fix bandwidth multiplier for link param
2020-05-19 13:29:00 -04:00
Mark Stapp
3f2e6c01fa
Merge pull request #6339 from opensourcerouting/ds-const-redux
redux lists/datastructure const
2020-05-19 13:27:47 -04:00
Emanuele Di Pascale
5eb567edc8 lib: fix bandwidth multiplier for link param
in the CLI we state that the bandwidth of a link is
in Megabits per second, but when converting it to
Bytes per second for TE purposes we were treating
it as Kilobits. Fix the conversion error.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-05-19 17:08:04 +02:00
Philippe Guibert
1f7a68a2ff lib, zebra: update interface name at netlink creation
the interface name was not present in the hook in charge of updating the
interface context to the registered hook service. For that, update the
name before informing it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-19 16:02:12 +02:00
Philippe Guibert
c4d466c830 lib, zebra: reuse and adapt ns_list walk functionality
the walk routine is used by vxlan service to identify some contexts in
each specific network namespace, when vrf netns backend is used. that
walk mechanism is extended with some additional paramters to the walk
routine.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
Philippe Guibert
b6ebab34f6 zebra, lib: new API to get absolute netns val from relative netns val
when receiving a netlink API for an interface in a namespace, this
interface may come with LINK_NSID value, which means that the interface
has its link in an other namespace. Unfortunately, the link_nsid value
is self to that namespace, and there is a need to know what is its
associated nsid value from the default namespace point of view.
The information collected previously on each namespace, can then be
compared with that value to check if the link belongs to the default
namespace or not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
Philippe Guibert
9d3555e06c zebra, lib: store relative default ns id in each namespace
to be able to retrieve the network namespace identifier for each
namespace, the ns id is stored in each ns context. For default
namespace, the netns id is the same as that value.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
Philippe Guibert
97c9e7533b zebra, lib: add an internal API to get relative default nsid in other ns
as remind, the netns identifiers are local to a namespace. that is to
say that for instance, a vrf <vrfx> will have a netns id value in one
netns, and have an other netns id value in one other netns.
There is a need for zebra daemon to collect some cross information, like
the LINK_NETNSID information from interfaces having link layer in an
other network namespace. For that, it is needed to have a global
overview instead of a relative overview per namespace.
The first brick of this change is an API that sticks to netlink API,
that uses NETNSA_TARGET_NSID. from a given vrf vrfX, and a new vrf
created vrfY, the API returns the value of nsID from vrfX, inside the
new vrf vrfY.
The brick also gets the ns id value of default namespace in each other
namespace. An additional value in ns.h is offered, that permits to
retrieve the default namespace context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
Philippe Guibert
28254125d0 zebra: importation of bgp evpn rt5 from vni with other netns
With vrf-lite mechanisms, it is possible to create layer 3 vnis by
creating a bridge interface in default vr, by creating a vxlan interface
that is attached to that bridge interface, then by moving the vxlan
interface to the wished vrf.
With vrf-netns mechanism, it is slightly different since bridged
interfaces can not be separated in different network namespaces. To make
it work, the setup consists in :
- creating a vxlan interface on default vrf.
- move the vxlan interface to the wished vrf ( with an other netns)
- create a bridge interface in the wished vrf
- attach the vxlan interface to that bridged interface

from that point, if BGP is enabled to advertise vnis in default vrf,
then vxlan interfaces are discovered appropriately in other vrfs,
provided that the link interface still resides in the vrf where l2vpn is
advertised.
to import ipv4 entries from a separate vrf, into the l2vpn, the
configuration of vni in the dedicated vrf + the advertisement of ipv4
entries in bgp vrf will import the entries in the bgp l2vpn.

the modification consists in parsing the vxlan interfaces in all network
namespaces, where the link resides in the same network namespace as the
bgp core instance where bgp l2vpn is enabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-05-18 14:11:03 +02:00
Donald Sharp
36caef199a
Merge pull request #6404 from FRRouting/dev_isis_sr
isisd: IS-IS Segment Routing support
2020-05-15 08:38:06 -04:00
Quentin Young
f6239dc799 lib: remove unnecessary rpc request in grpc
Bit of leftover copypaste code there.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-05-11 12:52:17 -04:00
Renato Westphal
69ec583289 lib: fix undue warning during gRPC module initialization
This warning only shows up when a daemon is started with --log=stdout.
Fix it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-09 00:50:45 -03:00
Quentin Young
ecf9fb30b7 lib: convert GRPC plugin to async
Synchronous GRPC services are called from arbitrary threads. This makes
access to anything outside the GRPC module unsafe. We need to convert
the plugin to use the async model that allows us to control our own
threads.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-05-08 15:50:11 -04:00
Chirag Shah
0edcb505a3 lib: use frr_pthread to spawn grpc pthread
start grpc thread with frr_pthread library
callbacks to integrate with rcu infrastructure.

If a thread is created using native pthread callbacks
and if zlog is used then it leads to crash.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-05-08 15:50:11 -04:00
Quentin Young
6f2f2e6172
Merge pull request #6347 from opensourcerouting/llvm-callgraph
tools: LLVM-based call graphs
2020-05-05 17:40:21 -04:00
Quentin Young
e01a788c44 lib: make hook.h cpp-compatible
Some CPP compilers don't support these designated initializers, since
we're just zero initializing don't need em

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-05-05 14:05:03 -04:00
David Lamparter
8fb40377de build: add LLVM bitcode targets
Just an easy way to produce LLVM .bc (bitcode) files.  Not used during
normal builds.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-05-05 14:39:12 +02:00
David Lamparter
daf3441d2b lib: add const iteration & find to typesafe lists
Based on work originally by Mark Stapp <mjs@voltanet.io>.

Make it possible to iterate the typesafe lists in a const
context, as well as find items from them.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
[above signoff was for the original version before modification]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-05-04 22:13:28 +02:00
Renato Westphal
26f6acafc3 isisd: add support for segment routing
This is an implementation of the IS-IS SR draft [1] for FRR.

The following features are supported:
* IPv4 and IPv6 Prefix-SIDs;
* IPv4 and IPv6 Adj-SIDs and LAN-Adj-SIDs;
* Index and absolute labels;
* The no-php and explicit-null Prefix-SID flags;
* Full integration with the Label Manager.

Known limitations:
* No support for Anycast-SIDs;
* No support for the SID/Label Binding TLV (required for LDP interop).
* No support for persistent Adj-SIDs;
* No support for multiple SRGBs.

[1] draft-ietf-isis-segment-routing-extensions-25

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-30 12:15:47 +02:00
Renato Westphal
0b7005375f lib: constify a few parameters of helper functions
Parameters should be const whenever possible to improve code
readability and remove the need to cast away the constness of
const arguments.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-30 11:27:20 +02:00
Renato Westphal
799a81df9d lib: update the CLI xpath index when exiting from the VRF node
All custom "exit-*" commands that exit from a YANG-modeled
CLI node need to use cmd_exit() to ensure the CLI xpath index
(vty->xpath_index) will be updated accordingly.

Fixes #6316.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-29 18:49:29 -03:00
Donald Sharp
cd8e0b88e3
Merge pull request #6299 from ton31337/fix/access-list_deletion
lib: Delete the entire access-list only if there are no more entries
2020-04-29 08:31:31 -04:00
Donald Sharp
c1d203ca73 Revert "vtysh: fix searching commands in parent nodes"
This reverts commit d741915ecd.

This is because it breaks this behavior:

router ospf6
  <commands>
!
int enp39s0
  <more commands>
!

This is a very legal set of commands and completely destroys the
ability to do this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-28 10:46:28 -04:00
Donatas Abraitis
7d16d76f4c lib: Delete the entire access-list only if there are no more entries
When you enter the access-list with the same sequence number but with a
different prefix AND access-list has only a single entry, then the entry
is deleted and the whole access-list is deleted.

That means that "replace entry" never be re-inserted.

With fix:
```
~# vtysh -c 'c' -c 'access-list 1 seq 10 permit 127.0.0.10/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 10 permit 127.0.0.10/32
~# vtysh -c 'c' -c 'access-list 1 seq 10 permit 127.0.0.20/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 10 permit 127.0.0.20/32
~# vtysh -c 'c' -c 'access-list 1 seq 11 permit 127.0.0.11/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 10 permit 127.0.0.20/32
access-list 1 seq 11 permit 127.0.0.11/32
~# vtysh -c 'c' -c 'no access-list 1 seq 10 permit 127.0.0.20/32'
~# vtysh -c 'sh run' | grep access-list
access-list 1 seq 11 permit 127.0.0.11/32
~#
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-27 12:13:48 +03:00
Donatas Abraitis
7351b95754 lib: Convert access_list_empty to bool
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-27 12:13:04 +03:00
David Lamparter
c2527ed21b lib/zlog: fix printfrr format attribute
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02:00
David Lamparter
7309092bf4 *: fix first header
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02:00
David Lamparter
94cfb0692e build: make clippy Makefile rules nicer
These are easy to get subtly wrong, and doing so can cause
nondeterministic failures when racing in parallel builds.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02:00
David Lamparter
2768748b88 build: use VPATH for vtysh_scan
No need to put $(top_srcdir) everywhere.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:30:01 +02:00
Rafael Zalamena
98dc08cdda
Merge pull request #6249 from chiragshah6/yang_nb5
lib: yang wrapper for date-and-time
2020-04-24 10:17:55 -03:00
Donald Sharp
967ebd2431
Merge pull request #6279 from opensourcerouting/nb-cb-args
*: change the signature of the northbound callbacks to be  more flexible
2020-04-24 08:09:16 -04:00
David Lamparter
c334a16ef1
Merge pull request #6262 from qlyoung/remove-sprintf 2020-04-23 20:27:26 +02:00
Renato Westphal
60ee8be107 *: change the signature of the northbound callbacks to be more flexible
Having a fixed set of parameters for each northbound callback isn't a
good idea since it makes it difficult to add new parameters whenever
that becomes necessary, as several hundreds or thousands of existing
callbacks need to be updated accordingly.

To remediate this issue, this commit changes the signature of all
northbound callbacks to have a single parameter: a pointer to a
'nb_cb_x_args' structure (where x is different for each type
of callback). These structures encapsulate all real parameters
(both input and output) the callbacks need to have access to. And
adding a new parameter to a given callback is as simple as adding
a new field to the corresponding 'nb_cb_x_args' structure, without
needing to update any instance of that callback in any daemon.

This commit includes a .cocci semantic patch that can be used to
update old code to the new format automatically.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-23 10:14:32 -03:00
Renato Westphal
97cd849362 lib: create a wrapper function for all northbound callbacks
The intention here is to keep the code more organized. These wrappers
should be used by the northbound clients only, and never directly
by any YANG backend code.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-23 01:21:46 -03:00
Renato Westphal
17e38209a5 lib, zebra: add missing extern "C" {} blocks to new header files
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-22 23:49:22 -03:00
Quentin Young
cd3b8cdf0a
Merge pull request #6265 from patrasar/pim-yang
yang: Defining yang files for pim
2020-04-22 12:43:02 -04:00
Sarita Patra
da787004cc yang: Defining yang files for pim
Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-04-22 09:21:28 -07:00
Chirag Shah
8d0c8ff55a lib: yang wrapper for date-and-time
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-22 08:55:07 -07:00
David Lamparter
6127ec9752 lib/frrcu: make C++ compatible
... by dropping seqlock.h from the header's includes;  it's only needed
in the C code in frrcu.c.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-21 21:38:07 +02:00
David Lamparter
5d6299d7da lib/atomlist: make C++ compatible
... by using `atomic_atomptr_t`.  Other ideas seemed worse.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-21 21:38:07 +02:00
Quentin Young
0880854185 pimd, lib: suppress compiler warnings on snprintf
truncation warnings on old compilers

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-21 13:13:06 -04:00
Quentin Young
2b7165e76f *: use appropriate buffer sizes, specifiers
- Fix 1 byte overflow when showing GR info in bgpd
- Use PATH_MAX for path buffers
- Use unsigned specifiers for uint16_t's in zebra pbr

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Quentin Young
fc746f1c01 *: manually remove some more sprintf
Take care of some more complicated cases by hand

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
David Lamparter
41051697a9 lib/zlog: fix coverity warning
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-20 23:17:17 +02:00
Donald Sharp
2d3d652178
Merge pull request #6251 from opensourcerouting/cs-ignore
*: make coverity scan ignore random() calls
2020-04-20 16:08:37 -04:00
David Lamparter
034cb57fd2
Merge pull request #6256 from qlyoung/pimd-no-strcpy 2020-04-18 20:47:32 +02:00
Quentin Young
1ac10b15b1 lib: dont null check bitfield pointer before free
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-17 20:19:38 -04:00
Quentin Young
1120b9596a lib: don't use strcpy
>:(

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-17 20:05:34 -04:00
Rafael Zalamena
5920b3eb38 *: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.

Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-17 20:57:43 -03:00
Mark Stapp
193848fff6 lib: clear data pointer in bf_free
Help avoid double-free by clearing data pointer.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-17 16:53:37 -04:00
Donald Sharp
50cf5243c1 lib: prefix must be a valid pointer at this point
Coverity does not understand how our CLI works.  Make it
happy that we have tested it's existence

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-16 20:17:22 -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
Donald Sharp
2ff99507ad
Merge pull request #6135 from opensourcerouting/cli-node-cleanup
*: clean up the mess that is CLI command nodes
2020-04-16 19:24:56 -04:00
Quentin Young
edf7eff077
Merge pull request #6239 from ton31337/fix/uint8_t_to_bool_for_any
bgpd, lib: Use bool instead of uint8_t for community/prefix-list "any"
2020-04-16 15:40:03 -04:00
Quentin Young
40664f16e3 lib: suppress formatting on yang.c module array
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-16 15:38:11 -04:00
Olivier Dugeon
c2c3db58a4
Merge pull request #6224 from mjstapp/zclient_session_id
lib,zebra: add a session id for zapi sessions
2020-04-16 21:12:30 +02:00
Quentin Young
bec74cc8a3 lib: fix style nit in yang_wrappers.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-16 15:10:19 -04:00
Mark Stapp
4e0b5b31b7 lib,zebra: add a session id for zapi sessions
Distinguish zapi sessions, for daemons who use more than one,
by adding a session id. The tuple of proto + instance is not
adequate to support clients who use multiple zapi sessions.
Include the id in the client show output if it's present. Add
a bit of info about this to the developer doc.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-16 12:07:54 -04:00
Chirag Shah
8f86689091 lib: increase xpath maxlen
Certain xpath are well 256 characters, increasing
to 512.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:51:41 -07:00
Chirag Shah
83ed00f1df lib: remove gcc 4.x workaround for nb structure
Remove gcc 4.x workaround for variable size array as gcc
check moved to header file.

In lib/northbound.h : struct frr_yang_module_info made
size 1000 for gcc 4.x, where maximum 1000 nodes can fit.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:48:57 -07:00
Chirag Shah
4e0a7355c2 lib: add interface operational northbound callback
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:26:36 -07:00
Chirag Shah
b0f502c521 yang: add ietf interface yang model
Add ietf interface yant model.
Also include it in the makefile.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:26:36 -07:00
Sarita Patra
7fd139b523 yang: igmp yang definition
Defined frr-igmp.yang file for IGMP protocol.

Co-authored-by: Sarita Patra <saritap@vmware.com>
Co-authored-by: Santosh P K <sapk@vmware.com>

Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-04-16 08:26:29 -07:00
Chirag Shah
cad46cfdc9 lib: yang wrapper nexthop type to str
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:24:02 -07:00
Chirag Shah
b71df6891c lib: add yang wrapper for type empty
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:18:00 -07:00
Chirag Shah
dd9ef518bf lib:api to convert mac to yang object
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:13:15 -07:00
Chirag Shah
0d2e2bd138 yang: add zebra model in makefile
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:11:51 -07:00
Chirag Shah
e7ecd0a657 *: frr nexthop yang in makefile
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:09:11 -07:00
Chirag Shah
8b4cb7a64b lib: convert vrf cmd to northbound config callback
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:00:18 -07:00
Chirag Shah
bc867a5d30 lib: vrf northbound callbacks
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 07:55:56 -07:00
vdhingra
8b04316627 lib: yang defination for basic frr-routing
Yang files for basic frr-routing used by other
daemons like staticd and pim

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: vishaldhingra <vdhingra@vmware.com>
Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2020-04-16 07:55:53 -07:00
Santosh P K
09133ff4f7
Merge pull request #5451 from opensourcerouting/rcu-log
logging subsystem rewrite
2020-04-16 20:23:44 +05:30
Chirag Shah
3a7262b6a9 *: add frr-vrf yang module in makefile
lib: Adding frr-vrf yang module to common place
so it can be accessed from all frr modules.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 07:49:06 -07:00
Donatas Abraitis
d3f6c580a8 bgpd, lib: Use bool instead of uint8_t for community/prefix-list "any"
That's only 0/1, useful to use just a bool for that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-16 15:27:51 +03:00
David Lamparter
d1b221f696 lib: #define FRR_CMD_NODE_20200416
... requested by Lou.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-16 12:55:59 +02:00
David Lamparter
791ded4a62 *: add ->node_exit to struct cmd_node
Rather than doing a f*gly hack for the RPKI code, let's do an on-exit
hook in cmd_node.  Also allows replacing some special-casing in the vty
code.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:54:03 +02:00
David Lamparter
893d8beb4d zebra: fix FPM node reusing VTY_NODE
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-16 12:54:03 +02: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
243895805a *: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can
just put the parent node in cmd_node.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +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
Mark Stapp
f3f054c701
Merge pull request #5510 from opensourcerouting/dplane-fpm-netlink
zebra: netlink FPM interface using zebra data plane
2020-04-14 16:40:05 -04:00
Donald Sharp
b9ba7ed533
Merge pull request #5812 from pguibert6WIND/bgp_stats_all
Bgp stats all
2020-04-14 14:36:21 -04:00
Rafael Zalamena
f2a0ba3a50 zebra: data plane FPM add support RMAC VNI
Store VNI information in the data plane context so we can use it to
build the FPM netlink update with that information later.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 13:45:39 -03:00
Donatas Abraitis
0b60953ed4
Merge pull request #6221 from opensourcerouting/defaults-fix-version-cmp
lib/defaults: fix version number comparison
2020-04-14 16:01:21 +03:00
David Lamparter
d29c01db81 lib/defaults: don't use "static" in a weird way
This didn't break anything but it's not really correct either.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-14 13:25:25 +02:00
David Lamparter
7b8c2b3d66 lib/defaults: more bool confusion
Sigh.  Initializing a bool to -1 gives 1.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-14 13:25:25 +02:00
David Lamparter
feaabe472d
Merge pull request #5988 from xThaid/zebra_vrf_logs
zebra: Add vrf name and id to debugs
2020-04-14 12:52:31 +02:00
Quentin Young
cff0de128d lib: fix SA warning in vrf creation zapi handler
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 17:03:48 -04:00
Quentin Young
41ce53847b lib: fix if_set_value
Something in there is wrong and causing test failures. Moving it back to
how it was; we'll stil assert if the message was wrong, just in a
different place now.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 17:03:48 -04:00
Quentin Young
f7d4592509 lib: work around enum issue in old gcc
I'd like to keep the explicit check here, but since underlying type of
enum is implementation defined, theres some inconsistency using -Wall
-Werror in older compilers here

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 17:03:42 -04:00
Quentin Young
e4f5680d6e lib: re-add accidentally deleted pfx family set
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
6063ede092 lib: improve sanity check on vrf backend value
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
67f8158620 lib: handle failure to change ifindex
This fixes a theoretical bug that could occur when trying to change an
ifindex on an interface to that of an existing interface. We would
remove the interface from the ifindex tree, and change the ifindex, but
when we tried to reinsert the interface, the insert would fail. It was
impossible to know if this failed due to the insertion / deletion macros
capturing the result value of the underlying BSD tree macros. So we
would effectively delete the interface.

Instead of failing on insert, we just check if the prospective ifindex
already exists and return -1 if it does.

Macros have been changed to statement expressions so the result can be
checked, and bubbled up.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
f17a9d0a07 lib: more zclient fixes; str termination, vrfs...
* Don't crash if we get a request to create an existing VRF
* Ensure interface & vrf names are null terminated...again

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
229d0d4edc lib: don't crash on iface add for unknown vrf
If Zebra sends us an interface add notification with a garbage VRF we
crash on an assert(vrf_get(vrf_id, NULL)); let's not

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
b98edbccf8 lib: ensure iface name is null terminated
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
7239d3d9e6 lib: handle bogus VRF backend type
And use an enum...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
efc7191bbe lib: make all zclient.[ch] stream funcs safe
Use STREAM_GET* variants of stream getters, which all have non-assert
error paths.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
c2b5a4e5ff lib: add STREAM_GETQ, STREAM_GETF
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Quentin Young
3b55aba195 lib: remove unnecessary null checks
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-13 13:25:25 -04:00
Jakub Urbańczyk
bd47f3a3b4 zebra: Add vrf name and id to debugs
In some places we log the interface but not the vfr the
interface is in. In others we only output the vrf id, which
can be difficult for human to read. This commit makes zebra
debugs more vrf aware.

Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-04-12 21:03:29 +02:00
Donatas Abraitis
c4efd0f423 *: Do not cast to the same type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 17:15:06 +03:00
Mark Stapp
4fda105e44 lib: support replacement in the nexthop-group cli
Use more limited matching logic so that nexthops within a
nexthop-group are unique based only on vrf, type, and gateway.
Treat configuration of a nexthop that matches an existing
nexthop as a replace operation.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-07 09:31:32 -04:00
Renato Westphal
dc397e4c0a lib: consolidate flexible array hack in a single place
Old gcc versions (< 5.x) have a bug that prevents C99 flexible
arrays from working properly on shared libraries.

We already have a hack in place to work around this problem, but it
needs to be replicated in every declaration of a frr_yang_module_info
variable within libfrr. This clearly isn't a good solution if we
consider that many more libfrr YANG modules are about to come in
the future.

This commit introduces a different workaround that operates within
the northbound layer itself, such that implementers of libfrr YANG
modules won't need to worry about this problem anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-03 22:34:55 -03:00
Renato Westphal
b90204a8e9 lib, tools: silence harmless warnings in the northbound tools
Our two northbound tools don't have embedded YANG modules like the
other FRR binaries. As such, ly_ctx_set_module_imp_clb() shouldn't be
called when the YANG subsystem it being initialized by a northbound
tool. To make that possible, add a new "embedded_modules" parameter
to the yang_init() function to control whether libyang should look
for embedded modules or not.

With this fix, "gen_northbound_callbacks" and "gen_yang_deviations"
won't emit "YANG model X not embedded, trying external file"
warnings anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-03 22:34:55 -03:00
David Lamparter
8d0a2918e8 lib/hook: use static hook entry when possible
hook_register() invocations generally are in some initialization
function and not looped over or similar.  We can use a static struct
hookent variable for the hook list entry in 99.999% of cases, so let's
do that and not malloc() memory.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
David Lamparter
1c4086281f lib/log: re-add log filtering
This is most of the old code bolted on top of the new "backend"
infrastructure.  It just wraps around zlog_fd() with the string search.

Originally-by: Stephen Worley <sworley@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
David Lamparter
767439c558 lib: mark some allocations as "active at exit"
In some cases we really don't want to clean up things even when exiting
(i.e. to keep the logging subsystem going.)  This adds a flag on MGROUPs
to indicate that.

[v2: add "(active at exit)" marker text to debug memstats-at-exit]
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
David Lamparter
0bdeb5e58d lib: rewrite zlog lock-free & TLS-buffered
This is a full rewrite of the "back end" logging code.  It now uses a
lock-free list to iterate over logging targets, and the targets
themselves are as lock-free as possible.  (syslog() may have a hidden
internal mutex in the C library;  the file/fd targets use a single
write() call which should ensure atomicity kernel-side.)

Note that some functionality is lost in this patch:
- Solaris printstack() backtraces are ditched (unlikely to come back)
- the `log-filter` machinery is gone (re-added in followup commit)
- `terminal monitor` is temporarily stubbed out.  The old code had a
  race condition with VTYs going away.  It'll likely come back rewritten
  and with vtysh support.
- The `zebra_ext_log` hook is gone.  Instead, it's now much easier to
  add a "proper" logging target.

v2: TLS buffer to get some actual performance

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
Quentin Young
e0bf2057b4
Merge pull request #5183 from opensourcerouting/zebra-route-map-nb
yang/zebra: migrate route map to northbound
2020-03-31 14:21:20 -04:00
David Lamparter
83b27fdaab
Merge pull request #6093 from LabNConsulting/working/lb/no-birds
*: use the current project name (FRRouting)
2020-03-31 15:10:17 +02:00
Philippe Guibert
799cc00286 lib: add json api to encode double values
this api can be used to encode double values.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-03-31 14:38:15 +02:00
Quentin Young
20b0a2ed3e lib: defer grpc plugin initialization to post fork
When using the GRPC northbound plugin, initialization occurs at the
frr_late_init hook. This is called before fork() when daemonizing (using
-d). Because the GRPC library internally creates threads, this means our
threads go away in the child process, so GRPC doesn't work when used
with -d. Rectify this situation by deferring plugin init to after fork
by scheduling a task on the threadmaster, since those are executed by
the child.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-30 14:28:10 -04:00
Stephen Worley
ff82bbbb91
Merge pull request #5901 from mjstapp/backup_nh_prep
zebra, lib: Backup nexthop (path) prep work
2020-03-30 10:26:17 -04:00
David Lamparter
fb84c629b8 tests: use printfrr-based printf()
Just a small hack to use printfrr() in tests, since otherwise the
redefined PRId64 trips some warnings.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter
566bdaf68c *: fix format string warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter
07ef3e34ae lib: prepare for plugin-based frr_format check
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter
47466c571f
Merge pull request #6101 from sarav511/vty_crash
vtysh: Crash during show running-config
2020-03-29 06:08:29 +02:00
Mark Stapp
1df3b1dc65 sharpd: support backup nexthops
Add cli and zapi support for backup nexthops for sharpd routes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:39:14 -04:00
Mark Stapp
0a8881b4b5 lib: support backup nexthops in nexthop-groups and zapi
Add vty support for backup nexthops in nexthop groups. Capture
backup nexthop info in zapi route messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:39:14 -04:00
Mark Stapp
018c648864 lib: add backup nexthops to zapi routes
Add backup nexthop info to zapi route messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Mark Stapp
defd2ea4a1 lib: add backup-nexthop value to nexthop
Add a field supporting a backup nexthop.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Mark Stapp
e4a1ec7454 zebra,lib: use const in more apis
Use const with some args to ipaddr, zebra vxlan, mpls
lsp, and nexthop apis; add some extra checks to some
nexthop-related apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Sri Mohana Singamsetty
0298bb01bb
Merge pull request #6085 from donaldsharp/bgp_node_get_prefix
Bgp node get prefix
2020-03-26 19:07:36 -07:00
saravanank
9934e1c9b8 vtysh: Crash during show running-config
RCA:
when client is killed, show running-config command crashes vtysh.
vtysh_client_config function temporarily makes vty->of which is standard output file
pointer to null inorder to suppress output to user.
This call further tries to communicate with each client and when the client
is terminated, socket call fails and hits the exception path to print the
connection has failed using vty_out.
vty_out crashes because vtysh_client_config has temporarily made vty->of
pointer to NULL to supress o/p to user.

Fix:
vty_out function should check for the sanity of vty->of pointer.
If it doesn't exist, this must have hit exception path, so use the
vty->saved_of if exists.

Signed-off-by: Saravanan K <saravanank@vmware.com>
2020-03-26 17:36:37 -07:00
Renato Westphal
4e9d40b8a1
Merge pull request #5925 from volta-networks/synchronous_client
zebra: synchronous client queues accumulate messages from zebra
2020-03-26 17:32:37 -03:00
Donald Sharp
5f040085ba lib, bgpd: Another round of struct const prefix cleanup
Cleanup another set of functions that need to respect the
const'ness of a prefix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:22:00 -04:00
Donald Sharp
4ce217af91 lib: make oid_copy_addr respect my constness
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:22:00 -04:00
Lou Berger
8678d6387c *: use the current project name (FRRouting)
Signed-off-by: Lou Berger <lberger@labn.net>
2020-03-25 17:38:56 -04:00
Donald Sharp
42984e1bd4
Merge pull request #6087 from opensourcerouting/log-kill-tabs
*: remove tabs and linefeeds from log messages
2020-03-25 06:30:38 -04:00
David Lamparter
46171e257c lib: rewrite zlog_hexdump()
The old version was creating a multi-line log message, which we can't
properly handle right now.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-24 19:43:18 +01:00
Santosh P K
aa50bf0618
Merge pull request #6035 from qlyoung/fix-nexthop-label-nullity-before-free
lib: remove null check before free nh_labels
2020-03-24 21:29:06 +05:30
Rafael Zalamena
f42cc96552 lib: show zebra route map configuration in tcli
Adapt the zebra route map code to use the transaction CLI output (e.g.
the CLI show callbacks) instead of the fallback compatibility.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-03-24 10:16:15 -03:00
Donald Sharp
26a3ffd60e bgpd, lib, ripngd: Add agg_node_get_prefix
Modify code to use lookup function agg_node_get_prefix()
as the abstraction layer.  When we rework bgp_node to
bgp_dest this will allow us to greatly limit the amount
of work needed to do that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:51:41 -04:00
Donald Sharp
1a4189d4a1 bgpd, isisd, lib: Make key values const for skiplist
Make some key values const for the skiplist code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:33:13 -04:00
Sri Mohana Singamsetty
865a8f8611
Merge pull request #6073 from donaldsharp/is_default
More `const struct prefix` work
2020-03-23 10:54:33 -07:00
Karen Schoener
17da84a49d zebra: Synchronous client queues accumulate messages from zebra.
Zebra is currently sending messages on interface add/delete/update,
VRF add/delete, and interface address change - regardless of whether
its clients had requested them.  This is problematic for lde and isis,
which only listens to label chunk messages, and only when it is
waiting for one (synchronous client). The effect is the that messages
accumulate on the lde synchronous message queue.

With this change:
  - Zebra does not send unsolicited messages to synchronous clients.
  - Synchronous clients send a ZEBRA_HELLO to zebra.
    The ZEBRA_HELLO contains a new boolean field: sychronous.
  - LDP and PIM have been updated to send a ZEBRA_HELLO for their
    synchronous clients.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-03-23 09:17:17 -04:00
Donald Sharp
1be1693edf bgpd, lib: More constification of various code
More second order effects of cleaning up rn usage
in bgp.  Sprinkle the fairy const's all over the place.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-23 08:41:17 -04:00
Donald Sharp
46f56dadd4 lib: Modify zclient_send_rnh to use const struct prefix
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-22 18:38:56 -04:00
Donald Sharp
35518f5419 lib: make is_default_host_route use a const struct prefix
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-22 17:14:32 -04:00
Donald Sharp
8150a500bc lib: Modify agg_XX calls to use const struct prefix
Tell the compiler that the prefix is being used for lookups
and it will never change.

Setup for future work.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-21 21:44:48 -04:00
Donald Sharp
d1ba1814bc lib: Ensure pointer exists before using in mlag
Ensure that the s pointer is valid and usable before
grabbing data off of it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-20 18:17:40 -04:00
Sri Mohana Singamsetty
c133ddca17
Merge pull request #5977 from rubenk/treewide-add-noreturn
treewide: add attribute to functions that do not return
2020-03-20 14:55:49 -07:00
David Lamparter
4e8ea9ede9
Merge pull request #6033 from rubenk/lib-do-not-use-aliased-inet-ntop-on-apple
lib: cannot use aliased function on Darwin
2020-03-20 20:52:28 +01:00
Stephen Worley
a0c5e446a6 lib: include any mem ever allocd in show memory
Include memory types that were ever allocated when doing
a `show memory`.

Before, we were only including memory that existed currently
in the system, so we lost memory that was alloc'd/dealloc'd.

With this patch, we check max number rather than current number.

Ex) dataplane context objects

Old:
==============================================================================
Type                          : Current#   Size       Total     Max#  MaxBytes
--- qmem zebra ---
Type                          : Current#   Size       Total     Max#  MaxBytes
Zebra Interface Information   :       48    360       17280       48     17280
Router Advertisement Prefix   :        3     48         168        3       168
Route Entry                   :      128     80       11264      128     11264
RIB destination               :       64     88        5632       64      5632
Zebra DPlane Provider         :        1    232         232        1       232
Nexthop Group Entry           :       78     80        6928      114     10032
Nexthop Group Connected       :       78     40        3168      114      4560
Zebra Name Space              :       13 variable      1000       13      1000
RIB table info                :       12     16         288       12       288
ZEBRA VRF                     :        3   4744       14232        3     14232

New:
==============================================================================
Type                          : Current#   Size       Total     Max#  MaxBytes
--- qmem zebra ---
Type                          : Current#   Size       Total     Max#  MaxBytes
Zebra Interface Information   :       48    360       17280       48     17280
Router Advertisement Prefix   :        3     48         168        3       168
Route Entry                   :      128     80       11264      128     11264
RIB destination               :       64     88        5632       64      5632
Zebra DPlane Ctx              :        0   2424           0       87    210888
Zebra DPlane Provider         :        1    232         232        1       232
Nexthop Group Entry           :       78     80        6928      114     10032
Nexthop Group Connected       :       78     40        3168      114      4560
Zebra Name Space              :       13 variable      1000       13      1000
RIB table info                :       12     16         288       12       288
ZEBRA VRF                     :        3   4744       14232        3     14232

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-03-20 10:36:18 -04:00
Ruben Kerkhof
8d80a84220 lib: cannot use aliased function on Darwin
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-19 18:47:48 +01:00
Ruben Kerkhof
b25b292538 treewide: add attribute to functions that do not return
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-19 18:33:48 +01:00
Quentin Young
fe86c6b3b1 lib: remove null check before free nh_labels
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-18 12:02:19 -04:00
Donald Sharp
218326d04a
Merge pull request #5927 from mjstapp/interval_string_api
lib, *: add a common time interval formatting api
2020-03-17 06:47:15 -04:00
Sri Mohana Singamsetty
9766604161
Merge pull request #5827 from donaldsharp/missed_upstreaming
Missed upstreaming
2020-03-12 09:27:26 -07:00
Mark Stapp
864aa5a1cc
Merge pull request #5981 from ton31337/fix/not_necessary_checks
*: Remove tests for some XFREE-family functions
2020-03-12 09:45:55 -04:00
Donatas Abraitis
8fa77bc6f4 *: Remove tests for some XFREE-family functions
XFREE() covers that.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-11 18:16:23 +02:00
Ruben Kerkhof
83e7e1d774 isisd: fix a bunch of build warnings with GCC 10
GCC 10 thinks we memcpy into a 0-sized array (which we're not).
Use a C99 flexible array member instead.

Fixes:

  CC       lib/stream.lo
lib/stream.c: In function ‘stream_put_in_addr’:
lib/stream.c:824:2: warning: writing 4 bytes into a region of size 0 [-Wstringop-overflow=]
  824 |  memcpy(s->data + s->endp, addr, sizeof(uint32_t));
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

isisd/isis_tlvs.c: In function ‘auth_validator_hmac_md5’:
isisd/isis_tlvs.c:4279:2: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
 4279 |  memcpy(STREAM_DATA(stream) + auth->offset, auth->value, 16);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘update_auth_hmac_md5’,
    inlined from ‘update_auth’ at isisd/isis_tlvs.c:3734:4,
    inlined from ‘isis_pack_tlvs’ at isisd/isis_tlvs.c:3897:2:
isisd/isis_tlvs.c:3722:2: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
 3722 |  memcpy(STREAM_DATA(s) + auth->offset, digest, 16);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
isisd/isis_tlvs.c:3722:2: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]

Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-11 10:39:35 +01:00
Ruben Kerkhof
1e20238af5 treewide: fix some issues found with -Werror=undef
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-10 16:53:13 +01:00
Quentin Young
fae5f3c125 lib: immediately ping systemd when started
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-10 09:59:56 -04:00
Quentin Young
5567e8010d lib, zebra: remove nullity check before XFREE...
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-03-09 18:16:32 -04:00
Russ White
7f6c322d50
Merge pull request #5839 from donaldsharp/upstream_merge
Upstream merge of missed MLAG code
2020-03-09 15:34:18 -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
Satheesh Kumar K
83f8a12b8e lib, pimd, zebra: Provide some insurance against reading bad stream data
This patch does two things:

1) Ensure the decoding of stream data between pim <-> zebra is properly
decoded and we don't read beyond the end of the stream.

2) In zebra when we are freeing memory alloced ensure that we
actually have memory to delete before we do so.

Ticket: CM-27055
Signed-off-by: Satheesh Kumar K <sathk@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06 16:03:59 -05:00
Donald Sharp
5e81f5dd1a *: Finish off the __PRETTY_FUNCTION__ to __func__
FINISH IT

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-06 09:23:22 -05: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
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donatas Abraitis
08c2d52ae1 *: Use true/false instead of 1/0 when assigning variable for bool type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 18:49:36 +02:00
Donatas Abraitis
f06c4576b7 *: Return bool type for bool functions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 15:05:22 +02:00
Donatas Abraitis
a8f58eb6a5 *: Use short version of bool expressions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 15:04:23 +02:00
Donald Sharp
7f5818fbd6 *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-28 13:59:13 -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
Jafar Al-Gharaibeh
4d67e75282 Revert "*: change hash_backet to hash_bucket"
This reverts commit 3895c42a2e.

LabN CI update needs to be coordinated before merging this

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-02-27 09:52:02 -06:00
Donald Sharp
5037cc3eb4 lib: 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
Donald Sharp
3895c42a2e *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-26 20:03:34 -05:00
Mark Stapp
7a7cd6e9b2
Merge pull request #5866 from qlyoung/fix-ipaddr-isset
lib: fix ipaddr_isset
2020-02-26 15:34:50 -05:00
Quentin Young
f2d72fcdc5 lib: fix ipaddr_isset
Meaning inverted by mistake

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-26 12:14:21 -05:00
Donald Sharp
64c0f439d2
Merge pull request #5270 from NaveenThanikachalam/rmap
lib: Optimizing route-maps
2020-02-25 09:15:49 -05:00
Mark Stapp
c13bfa7435 lib: use const in nexthop_group copy api
Add some const to the nhg copy api.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-25 08:26:38 -05:00
Donatas Abraitis
f294fac22d
Merge pull request #5842 from qlyoung/fix-test-then-xfree-again
lib: do not test before XFREE
2020-02-20 14:40:02 +02:00
Quentin Young
ff51421e80 lib: do not test before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-19 17:06:44 -05:00
Rafael Zalamena
2f95da3284 lib: don't allow to recurse inside route-map node
vtysh should handle going back up one level to try the command, there is
no need to be able to recurse inside route-map.

This also fixes a problem with northbound hitting the XPath queue limit
of 8 nodes.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-19 17:54:08 -03:00
Donald Sharp
49eddc738f
Merge pull request #5834 from opensourcerouting/route-map-fix-crash
lib: fix route-map coverity scan issue
2020-02-19 15:03:12 -05:00
Rafael Zalamena
1c4eca648c lib: fix route-map coverity scan issue
Use better TAILQ free idiom to avoid coverity scan warnings. This fixes
the coverity scan issue 1491240 .

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-19 10:35:28 -03:00
Donatas Abraitis
0bdcc3e3ef
Merge pull request #5809 from donaldsharp/vrf_name
Print out vrf name as well as id
2020-02-19 14:23:32 +01:00
Philippe Guibert
3c5f39e76d
Merge pull request #5651 from AnuradhaKaruppiah/evpn-pim-fixes
EVPN-PIM: complete anycast (MLAG) VTEP support
2020-02-18 18:21:16 +01:00
Donald Sharp
0d60f61f18
Merge pull request #5813 from mjstapp/zapi_labels_use_nh
*: encode zapi labels message using nexthops
2020-02-18 09:57:22 -05:00
Naveen Thanikachalam
2d26f094c1 lib: Optimizing route-maps - Part-3
* This commit implements the code style suggestions from Polychaeta.
* This commit also introduces a CLI to toggle the optimization and, a hidden
  CLI to display the contents of the constructed prefix tree.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18 02:08:29 -08:00
Naveen Thanikachalam
819a23f9fc lib: Optimizing route-maps - Part-2
This commit introduces the logic that computes the best-match route-map index
for a given prefix.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18 02:08:29 -08:00
Naveen Thanikachalam
49a08bb091 lib: Optimizing route-maps - Part-1
* This commit introduces the building blocks.
    A per-route-map prefix tree is introduced.
    This tree will consist of the prefixes defined within the prefix-lists
    that are added to the match clause of that route-map.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2020-02-18 02:08:14 -08:00
Donald Sharp
beee9b4a26 lib: Fix so that --enable-pcreposix actually compiles
The `--enable-pcreposix` configure option was not actually compiling
properly.  Follow pre-existing pattern for inclusion of regex.h
or the pcreposix.h header.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-16 14:14:04 -05:00
Mark Stapp
4945002d71 *: encode zapi labels message using nexthops
Use the zapi_nexthop struct with the mpls_labels
zapi messages instead of the special-purpose (and
more limited) nexthop struct that was being used.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-14 16:16:21 -05:00
Anuradha Karuppiah
d1a3e8df42 lib: add missing command DESC for MLAG messages
This string is used in some logging for e.g. in zclient_read -
>>>>>>>>>>>>>>>>>>>>>>>>>>
    if (zclient_debug)
        zlog_debug("zclient 0x%p command %s VRF %u",
               (void *)zclient, zserv_command_string(command),
               vrf_id);
>>>>>>>>>>>>>>>>>>>>>>>>>>

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-02-14 09:18:30 -08:00
Donald Sharp
a94fbcca24 lib: Add vrf name to outputs/debugs
Add some additional output/debug to code to allow
us to see the vrf name instead of just the vrf id.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:41:42 -05:00
Donald Sharp
b7e48f2147 lib: Add a macro to allow for quick/easy display of vrf name
Add a quick macro to allow for safe dereference of the vrf
since it may or may not exist in all cases.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:15:40 -05:00
Donald Sharp
ac2914d326 lib: Format according to our standard
A couple of functions needed to be reformated.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-14 08:15:33 -05:00
Mark Stapp
9df7724949
Merge pull request #5806 from ton31337/fix/remove_break_after_return
*: Remove break after return
2020-02-13 11:32:27 -05:00
Donatas Abraitis
a01bc07e1e
Merge pull request #5787 from karamalla0406/rmac_check
bgpd: RFC compliance wrt invalid RMAC, GWIP, ESI and VNI
2020-02-13 17:50:16 +02:00
Donatas Abraitis
752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Quentin Young
efa618369a
Merge pull request #5794 from mjstapp/remove_nexthop_matched_flag
lib,zebra: remove unused MATCHED nexthop flag
2020-02-12 11:29:22 -05:00
Mark Stapp
0641a955d7 lib,zebra: remove unused MATCHED nexthop flag
Remove an unused flag value from the nexthop struct.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-11 15:56:35 -05:00
Kishore Aramalla
c6ec0c745a bgpd: RFC compliance wrt invalid RMAC, GWIP, ESI and VNI
A route where ESI, GW IP, MAC and Label are all zero at the same time SHOULD
be treat-as-withdraw.
Invalid MAC addresses are broadcast or multicast MAC addresses. The route
MUST be treat-as-withdraw in case of an invalid MAC address.

As FRR support Ethernet NVO Tunnels only.
Route will be withdrawn when ESI, GW IP and MAC are zero or Invalid MAC

Test cases:
1) ET-5 route with valid RMAC extended community
2) ET-5 route no RMAC extended community
3) ET-5 route with Multicast MAC in RMAC extended community
4) ET-5 route with Broadcast MAC in RMAC extended community

Signed-off-by: Kishore Aramalla <karamalla@vmware.com>
2020-02-11 12:36:50 -08:00
Renato Westphal
4b08a72ed1
Merge pull request #5763 from ton31337/fix/return_without_parent
*: Remove parenthesis on return for constants
2020-02-10 18:49:06 -03:00
Donatas Abraitis
95f7965d09 *: Remove parenthesis on return for constants
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-09 14:21:56 +02:00
Donatas Abraitis
975a328e2e *: Replace s_addr 0 => INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-06 09:00:12 +02:00
Donald Sharp
792465c09f
Merge pull request #5104 from opensourcerouting/route-map-nbv2
lib: migrate route map to use northbound
2020-02-05 11:54:21 -05:00
Rafael Zalamena
7966110676 lib: fix route-map YANG module on old gcc versions
Copy the fix made in 'lib/if.c' to 'lib/routemap_northbound.c' so we can
have a working YANG model when compiled with GCC version less than 5.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-05 11:09:31 -03:00
Renato Westphal
ecaeb3b697
Merge pull request #5750 from qlyoung/fix-null-after-xfree
*: don't null after XFREE; XFREE does this itself
2020-02-05 01:49:08 -03:00
Quentin Young
e1b36e132b *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-04 13:19:37 -05:00
Donatas Abraitis
5ee080f00a zebra, lib: Remove return from void functions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-04 20:05:21 +02:00
Rafael Zalamena
54a35ff48b lib: fix route map northbound memory leak
Keep a list of hook contexts used by northbound so we don't lose the
pointer when free()ing the route map index entry data.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
e324ef433c lib: add backward compatibility for route map
Allow old CLI users to still print their configuration without migrating
to northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
a162869ef0 lib: fix route map generic error output
Two fixes here:

*   Don't attempt to use `vty` pointer in vty;
*   When `vty` is unavailable output to log;

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
a513824c34 yang/lib: add filter model to code
This fixes a warning on daemons that use route map about filter yang
model not being included in the binary.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
2b3e4807ec lib: implement new route map CLI
Use the northbound back-end instead of the old route map CLI.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
686d244f00 lib: implement route map northbound
Based on the route map old CLI, implement the route map handling using
the exported functions.

Use a curry-like programming pattern avoid code repetition when
destroying match/set entries. This is needed by other daemons that
implement custom route map functions and need to pass to lib their
specific destroy functions.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Rafael Zalamena
a7282663ef lib: export route map structures and functions
These exported items are going to be used by the new northbound CLI.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-02-04 14:05:43 -03:00
Donald Sharp
7f1ace03c7
Merge pull request #5653 from slankdev/slankdev-bgpd-support-prefix-sid-srv6-l3vpn
bgpd: additional Prefix-SID sub-types for supporting SRv6 l3vpn
2020-02-04 11:37:10 -05:00
Russ White
c7a754408e
Merge pull request #5746 from donaldsharp/bgp_sa
Coverioty sa stuff
2020-02-04 11:24:08 -05:00
Donald Sharp
19d95d40c0 lib: Test return of fcntl in agentx.c
The agentx.c code was calling fcntl but not testing return
code and handling it, thus making SA unhappy.

Fix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-04 08:10:52 -05:00
Quentin Young
b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
Santosh P K
be7bbe529d lib: Adding GR capabilites encode and decode.
For Graceful restart clients have to send GR capabilities
library functions are added to encode capabilities and
also for zebra to decode client capabilities.

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: Soman K S <somanks@vmware.com>
Signed-off-by: Santosh P K <sapk@vmware.com>
2020-01-30 10:25:52 -08:00
Russ White
64d50ba4c4
Merge pull request #5210 from bisdhdh/master
bgpd:BGP Graceful Restart Per Neighbor(BGPN) Feature.
2020-01-28 11:47:09 -05:00
Russ White
b27b58be24
Merge pull request #4773 from thozza/31-prefix-bcast-addr
ipv4_broadcast_addr() didn't comply with RFC3021
2020-01-28 11:42:45 -05:00
bisdhdh
2ba1fe6951 bgpd: BGP Garaceful Restart debug logs.
Reorganizing bgp gr debug logs and code review comments.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
eb451ee589 bgpd: Zebra lib for Graceful Restart.
These changes are for Zebra lib in order to supportGraceful Restart
feature. These changes are addedtemporarily, until Zebra Graceful
Restart lib Pr is merged.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
Signed-off-by: Soman K S <somanks@vmware.com>
2020-01-23 09:36:33 +05:30
bisdhdh
794b37d521 bgpd: Adding BGP GR Global & Per Neighbour FSM changes
* Added FSM for peer and global configuration for graceful restart
 * Added debug option BGP_GRACEFUL_RESTART for logs specific to
 graceful restart processing

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
bisdhdh
b0965c44e9 bgpd: BGP Graceful Restart Per Neighbor(BGPN), DS & header files.
This pr contains all the header files changes for BGP GR per Neighbour(BGPN)
feature.

Signed-off-by: Biswajit Sadhu <sadhub@vmware.com>
2020-01-23 09:34:25 +05:30
Quentin Young
d35e556c84 lib: add macro to check if value is valid afi
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-22 14:12:15 -05:00
Martin Winter
beec2cfe57 lib: Fix missing __be16 typedef on CentOS6
Need to include linux/types.h on older Linux

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2020-01-20 15:40:49 +01:00
Donatas Abraitis
9e1ecdbaa4
Merge pull request #5707 from donaldsharp/nexthop_encoding
Nexthop encoding
2020-01-18 23:25:56 +02:00