Commit Graph

2119 Commits

Author SHA1 Message Date
Quentin Young
74e4a329a3
lib: fix a few bugs in ring buffers
* Fix rare failure caused when end pointer is at end of buffer memory
  and a call to ringbuf_get() is made that reads all of the data in the
  buffer; start pointer was advanced past end pointer, causing some
  special handling to be skipped
* Fix ringbuf_peek() moving start pointer
* Fix use after free
* Remove extraneous assignment
* Update relevant tests

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-01-03 14:04:43 -05:00
Quentin Young
cb94eaebff
lib: add ringbuf_copy()
Quick 'n easy way to copy the contents of one ringbuf to another.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-01-03 14:04:43 -05:00
Russ White
82b9bf3145
Merge pull request #1569 from qlyoung/ringbuf
lib: add ring buffer
2018-01-02 09:21:37 -05:00
mitesh
523cafc418 bgpd, lib, zebra: fix style problems
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-27 11:47:10 -08:00
Quentin Young
a5080622b2
lib: add ringbuf_peek()
Peek functionality for ring buffers and associated tests.

Also:
* Slight optimization to avoid 0-byte memcpy() by changing > to >=
* Add rv checks for some ringbuf_[put|get] calls that were missing them
  in the test

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-26 18:50:56 -05:00
Quentin Young
5318d89638
lib: add ring buffer
Simple ring buffer implementation useful for fixed size FIFO queues.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-19 17:12:43 -05:00
Renato Westphal
fb6f7c2c25
Merge pull request #1515 from donaldsharp/selected_to_front1
Store selected_fib as a pointer off of rib_dest_t
2017-12-19 14:09:03 -02:00
Mitesh Kanjariya
90264d64ef bgpd: process evpn type-5 routes received from peers
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:08 -08:00
Mitesh Kanjariya
408b00c4d7 bgpd: only advertise valid subnet routes as evpn type-5 routes
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:08 -08:00
Mitesh Kanjariya
053905d2e3 bgpd: follow AFI/SAFI style for advertising/withdrawing type-5 routes
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:08 -08:00
mitesh
342dd0c623 bgpd: advertise/withdraw type-5 routes upon user config
CLI config for enabling/disabling type-5 routes

router bgp <as> vrf <vrf>
  address-family l2vpn evpn
    [no] advertise <ipv4|ipv6|both>

loop through all the routes in VRF instance and advertise/withdraw
all ip routes as type-5 routes in default instance.

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:07 -08:00
Mitesh Kanjariya
181c08c6fc bgpd: json support for show bgp l2vpn evpn vrf-import-rt
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:06 -08:00
Mitesh Kanjariya
19a847a9cd bgpd: set evpn rvtep nexthops as active by default
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
mitesh
2dbad57fc6 bgpd: program nh/rmac entries
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
mitesh
d3135ba31d bgpd: program mac-ip routes in matching vrfs
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:57:05 -08:00
Mitesh Kanjariya
b7cfce934f zebra, lib: zebra changes for symmetric routing support
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-12-14 10:56:44 -08:00
Donald Sharp
db33b83b1d
Merge pull request #1478 from bingen/zeromq4
lib: Address ZMQ lib TODOs
2017-12-13 07:36:57 -05:00
Rafael Zalamena
a457559e18
Merge pull request #1519 from donaldsharp/ptm
Ptm
2017-12-07 12:37:10 -02:00
Donald Sharp
a7ea39668d *: Remove cvs control points
The $Id: lines would allow code kept in cvs to substitute
the file version upon checkout.  Since we are not using
cvs there is no need to keep these lines anymore.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-05 17:28:12 -05:00
Martin Winter
79e68c7c5b lib: Fix gcc 7 warning 'error: ‘fld’ may be used uninitialized in this function'
Warning breaks Debian Package build with gcc 7 which uses -Werror=maybe-uninitialized

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2017-12-05 00:30:29 -08:00
Donald Sharp
b5f270ad09 lib: Allow memory to be cleaned up for error cases in ptm
ptm_lib.c had no way to cleanup after itself when an
error was detected.  This adds a function to cleanup
context in such a case.

A followup commit will use this new functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-12-04 18:59:47 -05:00
Renato Westphal
2e4c229616 *: make clippy usage more consistent
Fixes #1511.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-12-04 19:46:38 -02:00
Quentin Young
2d34fb80b8
*: don't use deprecated stream.h macros
Some of the deprecated stream.h macros see such little use that we may
as well just remove them and use the non-deprecated macros.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-12-01 13:51:06 -05:00
Donald Sharp
522f7f9923 lib: Fix thread removal from a pqueue
When we remove a thread from a pqueue, use the saved
index to go to the correct spot immediately instead of
having to search the whole queue for it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-29 14:53:59 -05:00
Rafael Zalamena
69df82f3b5
Merge pull request #1493 from donaldsharp/plist_stuff
lib: Fix prefix-list where le is == prefixlen
2017-11-29 14:03:56 -02:00
Russ White
1d04ad057d
Merge pull request #1482 from chiragshah6/mdev1
ospfd:  Running-config display ospf (non active) vrf config, OSPF Route json support
2017-11-29 07:44:39 -05:00
Donald Sharp
4015e91850 lib: Fix prefix-list where le is == prefixlen
This should be allowed:

robot(config)# ip prefix-list outbound_asp_routes seq 33 permit 1.1.1.0/24 le 24
% Invalid prefix range for 1.1.1.0/24, make sure: len < ge-value <= le-value

This commit fixes the issue:

robot(config)# ip prefix-list outbound_asp_routes seq 33 permit 1.1.1.0/24 le 23
% Invalid prefix range for 1.1.1.0/24, make sure: len < ge-value <= le-value
robot(config)# ip prefix-list outbound_asp_routes seq 33 permit 1.1.1.0/24 le 24
robot(config)# ip prefix-list outbound_asp_routes seq 33 permit 1.1.1.0/24 le 25
robot(config)#

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-28 19:55:07 -05:00
Donald Sharp
8a71d93d85 sharpd: Add Super Happy Advanced Routing Protocol
Add a daemon that will allow us to test the zapi
as well as test route install/removal times from
the kernel.

The current commands are:

install route <starting ip address> nexthop <nexthop> (1-1000000)

This command starts installing at <starting ip address>/32
(1-100000) routes that it auto-increments by 1
Installation start time is noted in the log and finish
time is noted as well.

remove routes <starting ip address> (1-1000000)

This command removes routes at <starting ip address>/32
and removes (1-100000) routes created by the install route
command.

This code can be considered experimental and *is not*
something that should be run in a production environment.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:16:30 -05:00
Donald Sharp
e1a1880de3 *: Make zapi route install Notifications optional
Allow the higher level protocol to specify if it would
like to receive notifications about it's routes that
it has installed.

I've purposely made it part of zclient_new_notify because
we need to track the routes on a per daemon basis only.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:09:35 -05:00
Donald Sharp
7ea7b86e2b lib, zebra: Add ability to notify to Routing Protocols Success/Failure
Provide ZAPI code that can pass to an upper level protocol
what happened to it's route on install.

There are these notifications:
1) ZAPI_ROUTE_FAIL_INSTALL - The route attempted to be
   installed did not work.
2) ZAPI_ROUTE_BETTER_ADMIN_WON - A route that was installed
   has become un-installed due to another routing protocol
   installing a better admin distance
3) ZAPI_ROUTE_INSTALLED - The route specified has been installed

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-27 09:09:32 -05:00
Chirag Shah
0f478e3050 ospfd: show ip ospf route json support
Define JSON_C_TO_STRING_NOSLASHESCAPE used for
escaping forward slash.

Disply json output for
'show ip ospf route [vrf all] json'

Ticket:CM-18659
Reviewed By:
Testing Done:
Configure multiple non-default VRF, inject external routes
via redistribute to ospf area.
checked show ip ospf route vrf all /json based output.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-11-26 09:18:19 -08:00
ßingen
afd0f10d63 lib: Address ZMQ lib TODOs
Add write callback.
Add error callback.
Add frrzmq_check_events() function to check for edge triggered things
that may have happened after a zmq_send() call or so.
Update ZMQ tests.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-11-23 12:50:27 +01:00
Donald Sharp
832d0f566f lib: Pass the safi as a uint8_t
The safi encode/decode is using 2 bytes, which
may cause problems on some platforms.  Let's assume
that a safi is a uint8_t and work accordingly.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13 14:18:43 -05:00
Donald Sharp
ec93aa120e lib, zebra: Modify zebra to use STREAM_GET for zapi
This code modifies zebra to use the STREAM_GET functionality.
This will allow zebra to continue functioning in the case of
bad input data from higher level protocols instead of crashing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13 14:16:13 -05:00
Donald Sharp
051cc28c8f lib: Add STREAM_GETX functions
Currently when stream reads fail, for any reason, we assert.
While a *great* debugging tool, Asserting on production code
is not a good thing.  So this is the start of a conversion over
to a series of STREAM_GETX functions that do not assert and
allow the developer a way to program this gracefully and still
clean up.

Current code is something like this( taken from redistribute.c
because this is dead simple ):

	afi = stream_getc(client->ibuf);
	type = stream_getc(client->ibuf);
	instance = stream_getw(client->ibuf);

This code has several issues:

1) There is no failure mode for the stream read other than assert.
if afi fails to be read the code stops.
2) stream_getX functions cannot be converted to a failure mode
because it is impossible to tell a failure from good data
with this api.

So this new code will convert to this:

	STREAM_GETC(client->ibuf, afi);
	STREAM_GETC(client->ibuf, type);
	STREAM_GETW(client->ibuf, instance);

	....

stream_failure:
	return;

We've created a stream_getc2( which does not assert ),
but we need a way to allow clean failure mode handling.
This is done by macro'ing stream_getX2 functions with
the equivalent all uppercase STREAM_GETX functions that
include a goto.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-13 14:15:24 -05:00
Donald Sharp
4df759fecf
Merge pull request #1436 from rtrlib/rpki
bgpd: Add RPKI/RTR support
2017-11-13 13:35:22 -05:00
pogojotz
f806f29c49 lib: Fix command copy running-config startup-config to alias write file
Fixes: #1412
Signed-off-by: Juergen Werner <pogojotz@gmx.net>
2017-11-12 13:09:29 -05:00
Jafar Al-Gharaibeh
1757d71693
Merge pull request #1426 from donaldsharp/prefixlistafi
lib: Only apply prefix's to the same family
2017-11-10 09:11:53 -06:00
Marcel Röthke
dabecd7c63 bgpd: Add RPKI/RTR support
This commit adds support for the RTR protocol to receive ROA
information from a RPKI cache server. That information can than be used
to validate the BGP origin AS of IP prefixes.
Both features are implemented using [rtrlib](http://rtrlib.realmv6.org/).

Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
2017-11-10 14:37:52 +01:00
Donald Sharp
4f3749854a lib: Only apply prefix's to the same family
When we have a v4 or v6 prefix list, only
apply it via a match when the address families
are the same.

Fixes: #1339
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-07 10:54:03 -05:00
Donald Sharp
ae2158fecf lib: Fix nexthop reading to work better
Fixes: #1404
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-06 11:20:40 -05:00
Russ White
453a5340a8
Merge pull request #1363 from donaldsharp/z_improvements
Z improvements
2017-10-31 20:27:19 -04:00
Lou Berger
820e1d547b
Merge pull request #1366 from donaldsharp/bgp_non_integrated_zebra_redistribution
Bgp non integrated zebra redistribution
2017-10-31 10:53:59 -04:00
Donald Sharp
e2e7a81d58 Merge pull request #1174 from opensourcerouting/show_route_defpy
Refactor the 'show ip route' commands using DEFPY
2017-10-27 10:00:57 -04:00
Donald Sharp
c539c38944 lib: Fix non-integrated config error display
When using a non-integrated config and starting up
of a protocol daemon, we were not properly handling
all possible cases and as such when an user hit
an actual error they were getting (null) listed
for the message string.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 22:35:35 -04:00
Donald Sharp
2a82635882 lib: Remove strange line
Remove a line that only has a semi-colon on it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 22:34:45 -04:00
Donald Sharp
41e7fb8030 lib, ospf6d, ospfd, zebra: Add ZEBRA_STR
Allow us to use a ZEBRA_STR for commands

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25 10:57:00 -04:00
Renato Westphal
b11b57723b lib: optimize sockunion_connect()
This function is only called with non-blocking sockets [1], so there's
no need to worry about setting O_NONBLOCK and unsetting it later if the
given fd was a blocking socket. This saves us 4 syscalls per connect,
which is not much but is something.

Also, remove an outdated comment about the return values of this
function. It returns a 'connect_result' enum now, whose values are
self-explanatory (connect_error, connect_success and connect_in_progress).

This also fixes a coverity scan warning where we weren't checking the
return value of the fcntl() syscall.

[1] bgp_connect() and pim_msdp_sock_connect().

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 19:30:31 -02:00
Renato Westphal
44f12f209f *: fix coverity warnings - resource leaks
These are mostly trivial fixes for leaks in the error path of some functions.

The changes in bgpd/bgp_mpath.c deserves a bit of explanation though. In
the bgp_info_mpath_aggregate_update() function, we were allocating memory
for the lcomm variable but doing nothing with it. Since the code for
communities, extended communities and large communities is pretty much
the same in this function, it's clear that this was a copy and paste
error where most of the ext. community code was copied but not all of
it as it should have been.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 19:30:30 -02:00
Renato Westphal
efd7904eab *: add missing \n in some help strings
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 19:30:30 -02:00
Renato Westphal
5b8524f5c2 lib: fix coverity warnings introduced by the iface rb-tree conversion
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 18:26:02 -02:00
Renato Westphal
ecffa493c0 zebra: unify the ipv4/ipv6 'show ip route' commands - part 1/2
Note: I had to remove one assert in clidef.py in order to fix a build
error when using a preprocessor string (FRR_IP_REDIST_STR_ZEBRA) inside
a DEFPY command. This should be revisited later.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 10:12:40 -02:00
Donald Sharp
342213eac0 *: Modify zclient_init to require privs data
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23 18:12:29 -04:00
Donald Sharp
bf2394f08b lib: Cleanup some missed reformat
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23 18:09:23 -04:00
Renato Westphal
9d4542919f Merge pull request #1331 from donaldsharp/hash_speedup
lib: Allow hash_get to sidestep expensive hash key generation in some…
2017-10-18 23:52:41 -02:00
Jafar Al-Gharaibeh
5e3dd606da Merge pull request #1333 from donaldsharp/command_py_leak
lib: Fix small memory leak when using command_py.c
2017-10-17 23:03:43 -05:00
Donald Sharp
d1667f531f lib: Display unsigned instead of signed
When displaying thread cpu data, display unsigned instead
of signed data when we get really really really large
numbers of invocations.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-17 20:49:15 -04:00
Donald Sharp
e871b669e1 lib: Fix small memory leak when using command_py.c
When free'ing memory associated with the wgraph, also
free memory malloced during the initialization.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-17 09:22:41 -04:00
Donald Sharp
1ab21a40eb lib: No need to call apply_mask 2 times
route_node_set is only called by route_node_get
which calls apply_mask.  There is no need to do
this again.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-16 14:47:08 -04:00
Donald Sharp
efb149d95b lib: Allow hash_get to sidestep expensive hash key generation in some cases
There is no need to generate a hash key *if* the hash_alloc_function
is NULL and the hash is empty.

This changed showed a measurable increase in performance for
table hash lookup for tables that were meant to be empty in
bgp( the distance commands ).

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-16 13:56:01 -04:00
Donald Sharp
5b8d8894f8 Merge pull request #1298 from opensourcerouting/iface-rb-tree
Use rb-trees to store interfaces instead of linked-lists
2017-10-16 12:00:38 -04:00
Donald Sharp
da7f979a07 lib: Free workqueue memory leak on free
When free'ing the workqueue if you have items
on the workqueue you should free the memory associated
with it.

Additionally move the work_queue_item_remove function
to allow for static to be awesome

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-11 10:00:54 -04:00
Donald Sharp
b286ddb07a lib: Add some documentation about argv_find
We expect that the index value passed in for argv_find
should be initially set to 0.  This way if the cli
ever changes there is no need to modify the initial
value.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-10 12:31:36 -04:00
Donald Sharp
d06542d566 lib: Fix missing va_end
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-10 12:31:36 -04:00
Renato Westphal
451fda4f9a *: use the FOR_ALL_INTERFACES abstraction from babeld
This improves code readability and also future-proofs our codebase
against new changes in the data structure used to store interfaces.

The FOR_ALL_INTERFACES_ADDRESSES macro was also moved to lib/ but
for now only babeld is using it.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:46 -03:00
Renato Westphal
c9cbbb4054 lib: fix bug in if_cmp_name_func()
If the p1 and p2 arguments pointed to identical strings ending with
a non-numeric character (e.g. "lo"), this function would return -1
instead of 0 as one would expect. This inconsistency didn't matter
for sorted linked-lists but for red-black trees it's a major source
of problems.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
ff880b78ef *: introduce new rb-tree to optimize interface lookup by ifindex
Performance tests showed that, when running on a system with a large
number of interfaces, some daemons would spend a considerable amount
of time in the if_lookup_by_index() function. Introduce a new rb-tree
to solve this problem.

With this change, we need to use the if_set_index() function whenever
we want to change the ifindex of an interface. This is necessary to
ensure that the 'ifaces_by_index' rb-tree is updated accordingly. The
return value of all insert/remove operations in the interface rb-trees
is checked to ensure that an error is logged if a corruption is
detected.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
8928a08f65 *: eliminate IFINDEX_DELETED in favor of IFINDEX_INTERNAL
IFINDEX_DELETED is not necessary anymore as we moved from a global
list of interfaces to a list of interfaces per VRF.

This reverts commit 84361d615.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
f4e14fdba7 *: use rb-trees to store interfaces instead of sorted linked-lists
This is an important optimization for users running FRR on systems with
a large number of interfaces (e.g. thousands of tunnels). Red-black
trees scale much better than sorted linked-lists and also store the
elements in an ordered way (contrary to hash tables).

This is a big patch but the interesting bits are all in lib/if.[ch].

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:05:02 -03:00
Renato Westphal
5d56066e46 lib: register 'if_var_handlers' only once
There's no need to register 'if_var_handlers' for every VRF, we need
to do it only once.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:01:24 -03:00
Renato Westphal
bcc245799b lib: nuke the if_*_by_name_len() functions
Make use of strnlen() and strlcpy() so we can get rid of these
convoluted if_*_by_name_len() functions.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-10 09:01:24 -03:00
Donald Sharp
613aa4ddb2 Merge pull request #1310 from vjardin6WIND/null_references
lib: linklist avoid access NULL->data
2017-10-09 08:16:04 -04:00
Vincent JARDIN
d9ced40ab7 lib: fix wrong warning from clang
The compiler cannot guess that rise() will not return here.
One should help.

Warning:
  Access to field 'file' results in a dereference of a null pointer
  (loaded from variable 'error')
aka error->file while error is NULL.

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09 13:07:50 +02:00
Vincent JARDIN
c7bba448d8 lib: csv unit tests
Fix csv unit tests.

To be run using,
  gcc -o csv csv.c -DTEST_CSV
  ./csv

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09 12:58:14 +02:00
Vincent JARDIN
43b798b7dd lib: fix NULL->field_len access
Currenlty, this function is used only by:
  - unit test of csv.c (see its main() section)
  - ptm_lib.c

In case of ptm, it is safe to return NULL because:
  csv_encode_record() -> return NULL
     _ptm_lib_encode_header() -> return NULL
        the only consumer of the return value is: ptm_lib_init_msg()
        that checks the NULL return.

Warning:
  Access to field 'field_len' results in a dereference of a null
  pointer (loaded from variable 'fld')

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09 12:42:11 +02:00
Vincent JARDIN
3f58e1b3e7 lib: fix a64448ba, invalid NULL->num_labels
We should assume match OK only when neither nhl1
and neither nhl2 are NULL.
If both are NULL, it means match NOK.

Clang Warning:
  Access to field 'num_labels' results in a dereference of a null
  pointer (loaded from variable 'nhl1')

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09 12:32:05 +02:00
Vincent JARDIN
67533c11d2 lib: linklist avoid access NULL->data
Let's assert(NULL) if the datastructure is not set.
The code assumes that the pointer is always non NULL. So, let's enforce
this semantic.

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-09 10:51:03 +02:00
Vincent JARDIN
649579afb3 lib: fix clang warning
Properly initialize to avoid "Branch condition evaluates to a garbage value"
warning.

Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-10-08 23:46:24 +02:00
Renato Westphal
993bab898d lib, ldpd: fix "argument cannot be negative" coverity warnings
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-05 22:51:23 -03:00
Donald Sharp
acdf5e2510 *: Convert list_free usage to list_delete
list_free is occassionally being used to delete the
list and accidently not deleting all the nodes.
We keep running across this usage pattern.  Let's
remove the temptation and only allow list_delete
to handle list deletion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:17 -04:00
Donald Sharp
affe9e9983 *: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **.  This is to allow the list pointer to be nulled.

I keep running into uses of this list_delete function where we
forget to set the returned pointer to NULL and attempt to use
it and then experience a crash, usually after the developer
has long since left the building.

Let's make the api explicit in it setting the list pointer
to null.

Cynical Prediction:  This code will expose a attempt
to use the NULL'ed list pointer in some obscure bit
of code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:13 -04:00
Donald Sharp
7faf667af6 lib: Fix memset usage
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-03 12:03:56 -04:00
Vincent JARDIN
c31a793b48 scan-build: cleanup some warnings
Current cleanup is for unset values or variables that are not used anymore.

Regarding ospfd/ospf_vty.c: argv_find()
  we'll never get it NULL, so get coststr = argv[idx]->arg;
2017-10-02 09:14:03 +02:00
Vincent JARDIN
80a5a11bb1 sha256: fix clang warning
t0 and t1 are not used, but want do really want them to be reset to secure
the stack.
Suggested by Quentin: let's use memset() to be consistent.
2017-10-02 09:14:03 +02:00
Jafar Al-Gharaibeh
bc5dcce7da Merge pull request #1271 from donaldsharp/multiplier
lib: Fix abbreviation
2017-09-30 22:47:43 -05:00
Renato Westphal
867be27151 Merge pull request #1255 from qlyoung/vtysh-remove-double-slash
vtysh: remove extra / in config path
2017-09-29 14:47:48 -03:00
Donald Sharp
b077b2e658 lib: Fix abbreviation
The word Multiplier has been abbreviated to 'Mul' in
the output.  This apparently is causing people
angst.  Write word out.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-29 11:53:53 -04:00
Quentin Young
3607783335
lib: remove extra / in other paths
Non-integrated config paths need the treatment as well.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-09-29 11:26:11 -04:00
Renato Westphal
67c0a9206c Merge pull request #1180 from dwalton76/ipv6-static-route-null0
Ipv6 static route null0
2017-09-27 13:42:53 -03:00
Daniel Walton
66b8ce1a17 Merge branch 'master' into bgpd-debug-updates-prefix 2017-09-27 09:21:26 -04:00
Renato Westphal
f5129394ec Merge pull request #1242 from donaldsharp/eigrp_tm
Eigrp tm
2017-09-27 09:20:51 -03:00
Renato Westphal
63e4c24f2c Merge pull request #1243 from qlyoung/tm-destroy-cond
lib: destroy threadmaster condition variable
2017-09-26 21:58:39 -03:00
Philippe Guibert
5c4dc90307 Merge pull request #1069 from donaldsharp/rfc_plist
PIM: allow overlapping group ranges for prefix-list and static RP's
2017-09-26 17:33:29 +02:00
Quentin Young
33844bbe43
lib: destroy threadmaster condition variable
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-09-25 16:01:08 -04:00
Donald Sharp
e5716b1677 lib: Free thread_master pointer after free
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 15:43:03 -04:00
Donald Sharp
1a0a92ea3b lib: Set pointer to NULL after free
list_delete does not set the list pointer to NULL
Thus when we accidently use it later we happily write
off into lala land instead of crashing imediately

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-25 15:41:28 -04:00
Donald Sharp
5176f7b713 Merge pull request #1213 from opensourcerouting/zebra-netlink
Misc RIB/Netlink fixes
2017-09-25 14:33:14 -04:00
Renato Westphal
e4e451ce15 lib: log error details if F_SETLK fails
Somehow F_SETLK was failing for me a couple of days ago, and not being
able to see the errno value was frustrating.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 13:27:50 -03:00
Renato Westphal
a74e593b35 *: fix segfault when sending more than MULTIPATH_NUM nexthops
This is a fallout from PR #1022 (zapi consolidation). In the early days,
the client daemons would allocate enough memory to send all nexthops
to zebra.  Then zebra would add all nexthops to the RIB and respect
MULTIPATH_NUM only when installing the routes in the kernel. Now things
are different and the client daemons can send at most MULTIPATH_NUM
nexthops to zebra, and failure to respect that will result in a buffer
overflow. The MULTIPATH_NUM limit in the new zebra API is a small price
we pay to avoid allocating memory for each route sent to zebra.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-09-21 11:21:09 -03:00
Mitesh Kanjariya
8367c32764 bgpd: Intialize all the variables used in argv_find.
Ticket: CM-17706
Review: CCR-6639
Testing: Manual (test failing in min test for ARM)

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-09-20 14:56:23 -07:00