Commit Graph

1013 Commits

Author SHA1 Message Date
Rafael Zalamena
31bfa9df79 topogen: use shorter names for equipments
After some feedback from mwinter@, the names of equipments are now
shorter to make it easier to type them and to keep consistency with
mininet documentation. While here, update the template and make it use
optional name parameters for clarity.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
3079edf96b topotest: add guidelines
This is the beginning of the guidelines file. It will contain all
necessary instructions to help people write topology tests.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
7326ea11c0 topogen: implement __str__ for TopoGear objects
Print TopoGear name, links and type (currently TopoRouter and Switch
don't have any other useful attributes).
2018-11-27 20:22:11 -05:00
Rafael Zalamena
240e334fca example: add missing __init__.py
Adding the __init__.py file makes python and its linter recognize that
the test makes part of the package, this makes us save a few lines of
code to make the linter and auto complete engines happy.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
38c3993248 topogen: implement memory leak test call
This is a shortcut for the memory leak test, it should be used in the
new tests in order to avoid boilerplate code.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
8c3fdf62a9 topogen: add support for setting link state
This commit changes how topology links are made in order to support
discovering who and what link is the node interface connected to. After
that, the implementation of the link state change functions were trivial
as calling a command in the node shell.

The method run() was moved from TopoRouter to TopoGear so all equipment
types can benefit from this code.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
d9ea1cda81 Topogen: document new options
We can now add routers to the topology using different daemon binaries
path. This will allow us to run tests with different daemon versions and
types.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
2ab8553078 topotest: parameterize daemon's path
This diff is a code cleanup that will allow us more flexibility when
defining and using the daemon binaries path, it also fixes a few pylint
warnings.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
1fca63c1e4 topogen: first code import
Topogen (Topology Generator) is a helper that wraps around Topotest to
simplify some of the boilerplate code. This abstraction will help the
development of new tests and new APIs without breaking the existing
ones. It also makes the relation of objects clearer, since we no longer
touch the Mininet API directly, which in turn also makes us less
vulnerable to external API changes.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
797e8dcf5c lib: assert sysctl values
Implemented two functions to help setting sysctl values:

* set_sysctl: set a sysctl and return an auditable return value
* assert_sysctl: uses the previous function to assert that the sysctl
  was set
2018-11-27 20:22:11 -05:00
Renato Westphal
fa05076643 ldp-topo1: sync with PR#710 in FRR
Now zebra is adding the ldpd implicit-null labels to the RIB as well. We
don't want to hide them in the "show ip route" commands because knowing
that a route is associated with an implicit-null label is an useful
piece of information, specially when troubleshooting L2/L3 VPNs.

Note: preserve the original output for cli version 1 (stable/2.0).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Renato Westphal
0e5ae9cc1d ldp-topo1: add some debug commands to facilitate troubleshooting
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
c8cff3ced1 lib: Fix stopRouter not to fail for case if daemon was never started
Fixes the issue for topotest to fail ot end of skipped LDP test on
a system without MPLS support

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
9e05a644e9 ospf6_topo1: Remove ff00:/8 routes from Linux Table compare
Some Ubuntu VM setups show ff00:/8 kernel routes, not a FRR issue

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
17070436a3 lib: cleanup diff text output formatting issue and move to library
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
4942f29847 lib: Move AddressSanitizer check to separate procedure and add check for errors in vtysh itself as part of checkRouterRunning
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
311dba3332 lib: Send Output error from AddressSanitizer to StdErr
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
28aa9ae658 rip-topo1: Add check to make sure daemons are still running between essential tests
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
7e7fc73b49 (all tests): Add extra check to make sure daemons are still running after each essential stage.
If daemon crashed at a later stage (not startup), then the test scripts didn't properly detect it and report unpredictable errors. This will properly log the daemon crashes

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
84379e8e7f lib: Add different failure comment on processes killed by AddressSanitizer
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
597cabb74d lib: Move updated topotest.py lib with AddressSanitizer to correct directory (fix mistake from 2 commits ago)
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
09bd98fbb7 Doc: Update manual sample build instruction with symlink for vtysh and reference to user creation
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
3a1f8275db Add support for collecting AddressSanitizer output. See README.md for details
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
faf94e5a3a ldp-topo1: Adjust to accept new format in "show ip route" as introduced with PR 495 (extra comma)
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
50c40bdebb Fix memory leak detection and reporting which accidentally was dropped a month ago
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
e9125d9286 lib: Fix another typo on kernel compare
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
c63b6f86f0 lib: Fix version check in previous kernel compare
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Donald Sharp
dd43120e8e Actually fix version comparison
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-27 20:22:11 -05:00
Donald Sharp
b2764f904e Spell Verifying correctly
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-27 20:22:11 -05:00
Donald Sharp
8b2e59e943 Fix tests to handle new output
The show commands for bgp now have a bit more
data associated with labeled unicast routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-27 20:22:11 -05:00
Donald Sharp
dd4eca4d97 lib: Fix kernel version parsing
When we have a kernel sub version > 10 the float conversion
of the kernel version causes 4.10 to be less than 4.5

Get the kernel version in groups on <major>.<minor> and do
comparison that way

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-27 20:22:11 -05:00
Martin Winter
f6c44df78f ospf6-topo1: Update to ignore the proto type in linux kernel table
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
798fb5934d all-protocol-startup: Fix bad assert in case of failed vtysh output test
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
1026c19adb all-protocol-startup: Fix pref commit - bamboo prefix is lower case
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
08fa1af779 all-protocol-startup: Add option to skip currently broken checks and relax BGP check
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
e341b1927d ripng-topo1: Fix duplicate IP (Thanks Renato!) and documentation typos 2018-11-27 20:22:11 -05:00
Martin Winter
4501fbcaa8 all-protocol-startup: Add test suite which runs all protocols at once and verifies startup and spurious errors of each
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
80eeefb7da lib: Add function to check for daemon available (i.e. LDPd) and function to return typ (quagga or frr)
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
598d845766 Update FreeRangeRouting -> FRRouting name
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
d6df723b10 rip_topo1: Adding new test for RIPv2 Topology
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
9f3e0f6493 ripng_topo1: Adding new test for RIPng Topology
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
a93477ec42 topotest library: Fix creation of /etc/XXX/vtysh.conf
- Needs to be created in local filesystem of each router

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
5b7a4ad33a bgp_multiview_topo1: Fix case of tests hanging if convergence is not successful.
- Part of a command was missing which caused a hang in cases when BGP didn't converge

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
3eaafbd95d LDP-Topo1: Update test to accept new format of LDP output
* Added test to check for version
* Adopted all tests to verify against the correct version of output

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
1c909f4248 Fix README incorrect reference to Quagga 2018-11-27 20:22:11 -05:00
Martin Winter
ff0d89dcfd ldp-topo1: Fix ordering of reference output to check against
Ordering of output is now done by LDP and should be consistent

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
37c4800c44 ldp-topo1: Delete accidentally include tar file
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Donald Sharp
3a4f98d587 Update Readme to have correct ordering for frr user
We cannot usermod the frr user until after we
create the user with adduser.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-27 20:22:11 -05:00
Martin Winter
33ae1f751e Update Readme to reflect FreeRangeRouting name
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
d98b7d6359 bgp_multiview_topo1: Mask out BGP Table version in comparison
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
99561211e1 Added optional output for memleaks at the end of test. Enable them by setting the environment variable TOPOTESTS_CHECK_STDERR to some value
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
594b1259f9 Move common function and class to topotest library
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-11-27 20:22:11 -05:00
Martin Winter
f03e38f397 ldp-topo1: Add new LDP Topology Test 2018-11-27 20:22:11 -05:00
Martin Winter
e631b5186f bgp_multiview_topo1: Fix bad check for running daemons
Only one ruter running in the setup
2018-11-27 20:22:11 -05:00
Martin Winter
b36d3e1c85 Add support for FRR in addition to Quagga 2018-11-27 20:22:11 -05:00
Martin Winter
593335d02d change in checkRunning: Check all daemons on all nodes before aborting with an assert 2018-11-27 20:22:11 -05:00
Martin Winter
615f6ba320 ospf6-topo1: Add Markdown doc with testdescription 2018-11-27 20:22:11 -05:00
Martin Winter
6d9d0176e4 bgp_multiview_topo1: Rename test_description.md to README.md for automatic rendering in online git 2018-11-27 20:22:11 -05:00
Martin Winter
d71f367580 bgp_multiview_topo1: Add Markdown doc for test 2018-11-27 20:22:11 -05:00
Martin Winter
024fc0b8bc README: Add example configure statement for building test quagga code 2018-11-27 20:22:11 -05:00
Martin Winter
3b6bac2adf bgp_multiview_topo1: Change from unified to context diff for better readability 2018-11-27 20:22:11 -05:00
Martin Winter
2bdcdbd1b8 ospf6-topo1: Add check for Linux Kernel Routing Table as well and change to better human readable context diff 2018-11-27 20:22:11 -05:00
Martin Winter
a99a6a026e ospf6-topo1: Enable coredumps for Quagga Daemons and add logic to skip remaining test in case of fatal error 2018-11-27 20:22:11 -05:00
Martin Winter
04df53ab5a bgp_multiview_topo1: Added Network Diagram as comment 2018-11-27 20:22:11 -05:00
Martin Winter
5ead87b456 bgp_multiview_topo1: Fix limit to create coredumps on quagga crashes 2018-11-27 20:22:11 -05:00
Martin Winter
64581658b1 bgp_multiview_topo1: Rename received bgp route log with .log for easy clean between runs 2018-11-27 20:22:11 -05:00
Martin Winter
309c9764c5 example-test: Add simple example pytest for documentation (and exclude it from running in pytest.ini) 2018-11-27 20:22:11 -05:00
Martin Winter
6b1be61ad8 Update Documentation 2018-11-27 20:22:11 -05:00
Martin Winter
2cda38e488 bgp_multiview_topo1: Skip remaining on fatal error and try to get more crash info of daemon is not running 2018-11-27 20:22:11 -05:00
Martin Winter
586e15c4fb bgp_multiview_topo1: Add "bgp multiview" simple topology to test. Initial commit 2018-11-27 20:22:10 -05:00
Martin Winter
68a655673f ospf6-topo1: Code cleanup 2018-11-27 20:22:10 -05:00
Martin Winter
50bd94cd20 ospf6-topo1: Less chatty timeout messages during convergence 2018-11-27 20:22:10 -05:00
Martin Winter
806111c083 ospf6-topo1: Cleanup log messages 2018-11-27 20:22:10 -05:00
Martin Winter
a177e146bb Add .gitignore 2018-11-27 20:22:10 -05:00
Martin Winter
b057efe120 test_ospf6_topo1: Restructure to run under pytest 2018-11-27 20:22:10 -05:00
Martin Winter
a92d8407ab Renamed Test Directory: ospf6-test1 -> ospf6_topo1 2018-11-27 20:22:10 -05:00
Martin Winter
52f17ef4aa ospf6-test1: Renamed testscript to have test_ prefix for pytest discovery 2018-11-27 20:22:10 -05:00
Martin Winter
d14615d865 ospf6-test1: Look for test config in directories relative to main script location 2018-11-27 20:22:10 -05:00
Martin Winter
8ab9a37669 Cleanup README and a reference to License 2018-11-27 20:22:10 -05:00
Martin Winter
59d80fffc2 Initial commit with first OSPFv6 Topology Test 2018-11-27 20:22:10 -05:00
Donald Sharp
8b5f676563 tests: Exclude topotests from consideration
When running make check, exclude the topotests directory from considertion.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-27 20:22:10 -05:00
Renato Westphal
1a4bc045de lib, tests: major rework in the operational-data callbacks
The northbound infrastructure for operational data was subpar compared
to the infrastructure for configuration data. This commit addresses most
of the existing problems, making it possible to write operational-data
callbacks for more complex YANG models.

Summary of the changes:
* Add support for nested YANG lists.
* Add support for leaf-lists.
* Add support for leafs of type "empty".
* Introduce the "show yang operational-data XPATH" command, and write an
  unit test for it. The main purpose of this command is to make it
  easier to test the operational-data northbound callbacks.
* Introduce the nb_oper_data_iterate() function, that can be used
  to iterate over operational data. Make the CLI and sysrepo use this
  function.
* Since ConfD has a very peculiar API, it can't reuse the
  nb_oper_data_iterate() like the other northbound clients. In this
  case, adapt the existing ConfD callbacks to support the new features
  (and make some performance improvements in the process).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26 18:28:53 -02:00
Renato Westphal
8017028d6b tests: fix warning related to change in the hash API
The hash_cmp functions need to return bool since commit 74df8d6d9d.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26 17:35:58 -02:00
Donald Sharp
bddea5fdf8
Merge pull request #3051 from mitch-skiba/addpath_change_V1
Addpath - Reuse IDs
2018-11-13 09:20:22 -05:00
Renato Westphal
9f0dc29b03
Merge pull request #3276 from donaldsharp/zclient_update
*: Replace zclient_new with zclient_new_notify
2018-11-12 13:40:47 -02:00
Donald Sharp
26f63a1ec6 *: Replace zclient_new with zclient_new_notify
It's been a year since we added the new optional parameters
to instantiation.  Let's switch over to the new name.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-12 09:16:23 -05:00
Christian Franke
9c0437ecd7 tests: Verify correct operation of lsp_build_list_nonzero_ht
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-11-12 12:24:10 +01:00
Mitch Skiba
dcc68b5e2a bgpd: Re-use TX Addpath IDs where possible
The motivation for this patch is to address a concerning behavior of
tx-addpath-bestpath-per-AS. Prior to this patch, all paths' TX ID was
pre-determined as the path was received from a peer. However, this meant
that any time the path selected as best from an AS changed, bgpd had no
choice but to withdraw the previous best path, and advertise the new
best-path under a new TX ID. This could cause significant network
disruption, especially for the subset of prefixes coming from only one
AS that were also communicated over a bestpath-per-AS session.

The patch's general approach is best illustrated by
txaddpath_update_ids. After a bestpath run (required for best-per-AS to
know what will and will not be sent as addpaths) ID numbers will be
stripped from paths that no longer need to be sent, and held in a pool.
Then, paths that will be sent as addpaths and do not already have ID
numbers will allocate new ID numbers, pulling first from that pool.
Finally, anything left in the pool will be returned to the allocator.

In order for this to work, ID numbers had to be split by strategy. The
tx-addpath-All strategy would keep every ID number "in use" constantly,
preventing IDs from being transferred to different paths. Rather than
create two variables for ID, this patch create a more generic array that
will easily enable more addpath strategies to be implemented. The
previously described ID manipulations will happen per addpath strategy,
and will only be run for strategies that are enabled on at least one
peer.

Finally, the ID numbers are allocated from an allocator that tracks per
AFI/SAFI/Addpath Strategy which IDs are in use. Though it would be very
improbable, there was the possibility with the free-running counter
approach for rollover to cause two paths on the same prefix to get
assigned the same TX ID. As remote as the possibility is, we prefer to
not leave it to chance.

This ID re-use method is not perfect. In some cases you could still get
withdraw-then-add behaviors where not strictly necessary. In the case of
bestpath-per-AS this requires one AS to advertise a prefix for the first
time, then a second AS withdraws that prefix, all within the space of an
already pending MRAI timer. In those situations a withdraw-then-add is
more forgivable, and fixing it would probably require a much more
significant effort, as IDs would need to be moved to ADVs instead of
paths.

Signed-off-by Mitchell Skiba <mskiba@amazon.com>
2018-11-10 00:16:36 +00:00
Mitch Skiba
a94eca0968 lib: Implement an allocator for 32 bit ID numbers
This commit introduces lib/id_alloc, which has facilities for both an ID number
allocator, and less efficient ID holding pools. The pools are meant to be a
temporary holding area for ID numbers meant to be re-used, and are implemented
as a linked-list stack.

The allocator itself is much more efficient with memory. Based on sizeof
values on my 64 bit desktop, the allocator requires around 155 KiB per
million IDs tracked.

IDs are ultimately tracked in a bit-map split into many "pages." The
allocator tracks a list of pages that have free bits, and which sections
of each page have free IDs, so there isn't any scanning required to find
a free ID. (The library utility ffs, or "Find First Set," is generally a
single CPU instruction.) At the moment, totally empty pages will not be
freed, so the memory utilization of this allocator will remain at the
high water mark.

The initial intended use case is for BGP's TX Addpath IDs to be pulled
from an allocator that tracks which IDs are in use, rather than a free
running counter.  The allocator reserves ID #0 as a sentinel value for
an invalid ID numbers, and BGP will want ID #1 reserved as well. To
support this, the allocator allows for IDs to be explicitly reserved,
though be aware this is only practical to use with low numbered IDs
because the allocator must allocate pages in order.

Signed-off-by Mitchell Skiba <mskiba@amazon.com>
2018-11-09 21:50:34 +00:00
Renato Westphal
1c2facd12d lib: introduce new northbound API
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-27 16:16:12 -02:00
David Lamparter
67cf020d17 build: make clean and dist consistent
We weren't cleaning up some files (a whole lot of python foobar) and had
some files in the dist tarball that don't quite belong there.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-24 18:35:15 +02:00
David Lamparter
68b8a15f87 lib: add libunwind support for backtraces
libunwind provides an alternate to backtrace() for printing out the call
stack of a particular location.  It doesn't use the frame pointer, it
goes by the DWARF debug info.  In most cases the traces have exactly the
same information, but there are some situations where libunwind traces
are better.

(On some platforms, the libc backtrace() also uses the DWARF debug info
[e.g.: ARM backtraces are impossible without it] but this is not the
case everywhere, especially not on BSD libexecinfo.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-18 02:51:51 +02:00
Donald Sharp
121e245d4f bgpd: Cleanup warnings issued by CI system from these changes
Modify code to cleanup warnings issued by the CI system from
this series of changes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:26:30 -04:00
Donald Sharp
4b7e606625 bgpd: Convert struct bgp_info to struct bgp_path_info
Do a straight conversion of `struct bgp_info` to `struct bgp_path_info`.
This commit will setup the rename of variables as well.

This is being done because `struct bgp_info` is not descriptive
of what this data actually is.  It is path information for routes
that we keep to build the actual routes nexthops plus some extra
information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
Donald Sharp
1defdda8e8 bgpd: Convert BGP_INFO_XXX to BGP_PATH_XXX
Search and replace all BGP_INFO_XXX to BGP_PATH_XXX

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09 14:14:25 -04:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Lou Berger
d127c61aeb
Merge pull request #3010 from opensourcerouting/no-frr-thread-id
lib: frr_pthread minor simplification
2018-09-22 15:02:09 -04:00
David Lamparter
1ac267a2d9 lib: remove frr_pthread->id
All I can see is an unneccessary complication.  If there's some purpose
here it needs to be documented...

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-19 22:01:46 +02:00
F. Aragon
20ae4acdba
bgpd: fix test (using bgp instance 0)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-18 17:39:23 +02:00
paco
f533be73f6
bgpd, doc, ldpd, lib, tests, zebra: LM fixes
Corrections so that the BGP daemon can work with the label manager properly
through a label-manager proxy. Details:

- Correction so the BGP daemon behind a proxy label manager gets the range
  correctly (-I added to the BGP daemon, to set the daemon instance id)
- For the BGP case, added an asynchronous label manager connect command so
  the labels get recycled in case of a BGP daemon reconnection. With this,
  BGPd and LDPd would behave similarly.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-18 17:39:16 +02:00
F. Aragon
7fe96307ee
bgpd lib ospf6d pbrd tests zebra: shadowing fixes
This fixes all remaining local variable shadowing cases

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-13 17:37:08 +02:00
David Lamparter
b45ac5f5c6 *: fix config.h/zebra.h include order
config.h (or, transitively, zebra.h) must be the first include file
listed for autoconf things like _GNU_SOURCE and _POSIX_C_SOURCE to work
correctly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
David Lamparter
dbac691da6 build: fix & clean up *SAN flags
ASAN/MSAN/TSAN flags need to be in CFLAGS and LDFLAGS; the latter links
the correct compiler-dependent library.  Also, the configure switch was
broken (--disable-... would enable the sanitizer.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
David Lamparter
e7c25325cc *: cleanup .gitignore files
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
David Lamparter
b37ccace1e tests: properly locate files in builddir
test_cli.refout is written by configure into the build directory, thus
we need a little special glue to find it correctly.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:19 +02:00
David Lamparter
a1286a3245 build: non-recursive tests
May SUBDIRS rest in pieces... er, peace.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:26:54 +02:00
Christian Franke
f6ae63ca95 isisd: fix warnings by removing union isis_N and going to void * instead
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:13 +02:00
Christian Franke
5f77d90188 isisd: add TLV 13 Purge Originator Identification
Extend our parser to support the Purge Originator Identifaction
TLV as per RFC 6232.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:13 +02:00
Christian Franke
9d33cf3886 tests/isisd: remove auth when fuzzing
Our "deserialize, reserialize, check-equality" test fails when the
fuzzer produces PDUs with incorrect cryptographic checksums.

While the most realistic solution would be to validate the
cryptographic checksums in the test program, that seems very silly,
given that we don't want to fuzz our cryptographic auth.

Given that, removing auth during fuzzing seems the next best solution.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:13 +02:00
Christian Franke
686afe9f07 fabricd: add field with first and second nexthop to SPF paths
OpenFabric requires knowledge of the first two hops on each path
calculated by spf to implement its flooding optimization. Extend the
hopcount-spf to build such a datastructure.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-09-05 11:38:13 +02:00
Philippe Guibert
ecbc5a3781 *: add a vrf update hook to be informed of the vrf name
The Vrf aliases can be known with a specific hook. That hook will then,
from zebra propagate the information to the relevant zapi clients.
The registration hook function is the same for all daemons.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-28 16:23:50 +02:00
Russ White
0a4ecf2729
Merge pull request #2886 from donaldsharp/stream_resize
Stream resize
2018-08-22 16:04:37 -04:00
Donald Sharp
db3c830afe isisd, ospfd, tests: Switch to using stream_resize_inplace
Switch code and tests to use new stream_resize_inplace functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-22 07:58:54 -04:00
David Lamparter
bd27ea43e9 build: wrap "fallthrough" attr
This generates a warning on gcc versions before 7.0.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-21 20:34:58 +02:00
David Lamparter
6bb30c2cba *: use frr_elevate_privs() (2/2: manual)
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-08-14 20:02:05 +00:00
Donald Sharp
1314370166 tests: Cleanup assumption that ALLOC could fail.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 19:58:23 +02:00
Christian Franke
321c1bbb94 isisd: make spf code dst-src aware
Take the source-prefix sub-TLV into consideration when running SPF
and support creation/deletion of dst-src routes as result.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-08-03 13:25:39 +02:00
Christian Franke
d43d2df5f3 isisd: learn and advertise IPv6 dst-src routes
Receive IPv6 dst-src routes from zebra and advertise them in our LSPs
if so configured.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-08-03 13:25:39 +02:00
Donald Sharp
ccc34deb38 tests: Let compiler know this was an intentionall fallthrough
Let the compiler know that this code intentionally fell
through to the next case statement in a switch.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-25 15:00:52 -04:00
Donald Sharp
9fc8a332b1 tests: Prevent weird type promotion objection in bgp tests
The va_start function cannot take a object that can be type promoted
Looks like a new warning coming in from a new compiler.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-25 14:50:29 -04:00
Donald Sharp
e3c5f7b689 tests: Fix const change
Some of the parameters for lib/srcdest.. have changed to
consts, make the test cases respect that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-25 14:50:29 -04:00
F. Aragon
a2ddc2a67b
tests/isisd: fix warnings
Commit ae9c9aba changed isis_vertex_id_init() and isis_find_vertex()
parameters, so compiler reported warnings in the test (the actual data
passing through is the same because of the union used in the latest changes).
This commit fixes the warnings in the test.

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-07-24 18:26:26 +02:00
Mark Stapp
432eaa5d97 tests: add test_bgp_table to gitignore
Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-07-13 07:56:38 -04:00
Mark Stapp
2861a0deda tests: align with srcdest lib changes, remove bgp binary
Align the srcdest table test with recent api changes that use
'const' more strictly. Remove test_bgp_table binary - looks
as if it was committed by mistake.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2018-07-12 09:51:52 -04:00
Marcel Röthke
a98b00ee3e bgpd: add test for bgp_table_range_lookup
Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
2018-07-05 16:06:37 +02:00
Quentin Young
772b852662
Merge pull request #2408 from ajones-rvbd/ajones-issue-2403
tests: use BUILT_SOURCES in tests/Makefile.am for automake 1.16.1
2018-06-21 14:43:16 -04:00
Russ White
05d7e026c8
Merge pull request #2445 from ppmathis/feature/bgp-pg-overrides
bgpd: Improve peer-group override implementation
2018-06-19 08:20:31 -04:00
Russ White
8fef257611
Merge pull request #2465 from qlyoung/fix-build-am-cppflags-warning
tests: fixup minor autotools nit
2018-06-19 07:31:43 -04:00
paco
6d10727ac1
eigrpd, lib, tests, vtysh: security (cppcheck)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-19 10:40:56 +02:00
paco
2ec42b858c
babeld, lib, ospfd, tests: fmt fixes (cppcheck)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-18 17:52:56 +02:00
Quentin Young
972c2ee9de tests: fixup minor autotools nit
Makes super strict builds fail due to a warning.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-15 17:17:42 +00:00
Pascal Mathis
4c3911425c
bgpd: Finalize group-overrides for peer/AF attrs
This commit finalizes the previous commits which introduced a generic
approach for making all BGP peer and address-family attributes
overrideable by keeping track of the configuration origin in separate
internal structures.

First of all, the test suite was greatly extended to also check the
internal data structures of peer/AF attributes, so that inheritance for
internal values like 'peer->weight' is also being checked in all cases.

This revealed some smaller issues in the implementation, which were also
fixed in this commit. The test suite now fully passes and covers all the
usual situations that should normally occur.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:33 +02:00
Pascal Mathis
a14810f43f
bgpd: Implement group-overrides for peer attrs
This commit introduces BGP peer-group overrides for the last set of
peer-level attrs which did not offer that feature yet. The following
attributes have been implemented: description, local-as, password and
update-source.

Each attribute, with the exception of description because it does not
offer any inheritance between peer-groups and peers, is now also setting
a peer-flag instead of just modifying the internal data structures. This
made it possible to also re-use the same implementation for attribute
overrides as already done for peer flags, AF flags and AF attrs.

The `no neighbor <neigh> description` command has been slightly changed
to support negation for no parameters, one parameter or * parameters
(LINE...). This was needed for the test suite to pass and is a small
change without any bigger impact on the CLI.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:32 +02:00
Pascal Mathis
b90a8e13ee
bgpd: Implement group-overrides for peer timers
This commit implements BGP peer-group overrides for the timer flags,
which control the value of the hold, keepalive, advertisement-interval
and connect connect timers. It was kept separated on purpose as the
whole timer implementation is quite complex and merging this commit
together with with the other flag implementations did not seem right.

Basically three new peer flags were introduced, namely
*PEER_FLAG_ROUTEADV*, *PEER_FLAG_TIMER* and *PEER_FLAG_TIMER_CONNECT*.
The overrides work exactly the same way as they did before, but
introducing these flags made a few conditionals simpler as they no
longer had to compare internal data structures against eachother.

Last but not least, the test suite has been adjusted accordingly to test
the newly implemented flag overrides.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:30 +02:00
Pascal Mathis
598a3d4288
bgpd: Improve test suite for peer-group overrides
This commit introduces the current test suite for BGP peer-group
overrides by adding support for custom check handlers (which can check
internal data structures more thoroughly) and by fixing several small
mistakes and issues that slipped through. Also some parts of the code
have been cleaned up to avoid duplicate and/or hard-to-read code.

Additionally a first experimental check for a BGP peer attribute with
values (advertisement-interval <value>) has been added to the test
suite. As this test suite is currently not passing, it has not been
added to the python test caller.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:28 +02:00
Pascal Mathis
e7103a9644
bgpd: Fix AF-attribute overrides when binding peer
The current implementation of the overrides for peer address-family
attributes suffered a bug, which caused all peer-specific attributes to
be lost when the peer was added to a peer-group which already had that
specific address-family active.

This commit extends the *peer_group2peer_config_copy_af* function to
respect overridden flags properly. Additionally, the arguments of the
macros *PEER_ATTR_INHERIT* and *PEER_STR_ATTR_INHERIT* have been
reordered to be more consistent and easy to read.

This commit also adds further test cases to the BGP peer attributes test
suite, so that this kind of error is being caught in future commits. The
missing AF-attribute *distribute-list* has also been added to the test
suite.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:25 +02:00
Pascal Mathis
9fb964de21
bgpd: Implement group-overrides for peer flags
The current implementation of peer flags (e.g. shutdown, passive, ...)
only has partial support for overriding flags of a peer-group when the
peer is a member. Often settings might get lost if the user toys around
with the peer-group configuration, which can lead to disaster.

This commit introduces the same override implementation which was
previously integrated to support proper peer flag/attribute override on
the address-family level. The code is very similar and the global
attributes now use their separate state-arrays *flags_invert* and
*flags_override*.

The test suite for BGP peer attributes was extended to also check peer
global attributes, so that the newly introduced changes are covered. An
additional feature was added which allows to test an attribute with an
*interface-peer*, which can be configured by running `neighbor IF-TEST
interface`. This was introduced so that the dynamic runtime inversion of
the `extended-nexthop` flag, which is only enabled by default for
interface peers, can also be tested.

Last but not least, two small changes have been made to the current bgpd
implementation:

- The command `strict-capability-match` can now also be set on a
peer-group, it seems like this command slipped through while
implementing peer-groups in the very past.

- The macro `COND_FLAG` was introduced inside lib/zebra.h, which now
allows to either set or unset a flag based on a condition. The syntax
for using this macro is: `COND_FLAG(flag_variable, flag, condition)`

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-06-14 18:55:18 +02:00
Arthur Jones
15ecc92750 tests: use BUILT_SOURCES in tests/Makefile.am for automake 1.16.1
When trying to run make check using automake 1.16.1, we get:

CC isisd/test_fuzz_isis_tlv-test_fuzz_isis_tlv.o
isisd/test_fuzz_isis_tlv.c:1:10: fatal error: test_fuzz_isis_tlv_tests.h: No such file or directory
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:1096: recipe for target 'isisd/test_fuzz_isis_tlv-test_fuzz_isis_tlv.o' failed
make[1]: *** [isisd/test_fuzz_isis_tlv-test_fuzz_isis_tlv.o] Error 1
make[1]: Leaving directory '/src/frr-frr-5.0/tests'
Makefile:1220: recipe for target 'check-am' failed
make: *** [check-am] Error 2

From reading the automake docs, it looks like there may be a more
reliable way to express built files in the Makefile.am using BUILT_SOURCES.
Using this method, we seem to build fine now on 1.16.1 and this
has been tested on Ubuntu 18.04, CentOS 7 and Alpine edge (which uses
automake 1.16.1).

Issue: https://github.com/FRRouting/frr/issues/2403
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
2018-06-12 08:05:00 -07:00
Russ White
9eafc8abd7
Merge pull request #2298 from qlyoung/pipe-actions-vtysh
*: add support for `|` actions
2018-06-08 07:39:36 -04:00
Quentin Young
fe011935cd lib: add string utilities
I see lots of the same code being copy-pasted and slightly tweaked for
string processing all over the codebase. Time to start aggregating these
pieces into something consistent and correct.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:15:34 +00:00
Arthur Jones
1808d46db2 tests/isisd: bypass test_fuzz_isis_tlv when inet_ntop is broken
On Alpine Linux edge, musl does not seem to be RFC 5952 4.2.2
compliant (how to print a single :0: in the IPv6 address).  Let's
skip that test, as we get false negatives when running against
that version of musl.

Credit for the idea for the fix and how to fix it is due to
chris@opensourcerouting.org.

Testing done:

make check on alpine linux passes now

Issue: https://github.com/FRRouting/frr/issues/2375
Signed-off-by: Arthur Jones <arthur.jones@riverbed.com>
2018-06-06 08:08:46 -07:00
Quentin Young
483e5a3aa5
Merge pull request #2304 from ppmathis/enhancement/bgp-pg-overrides
bgpd: Add proper support for overriding peer-group AF-flags/filters
2018-06-05 11:51:57 -04:00
Donald Sharp
1525e99f17 bgpd: Cleanup assumptions in bgp_evpn.c
The bgp data structures:
bgp->vnihash
bgp->vrf_export_rtl
bgp->vrf_import_rtl
bgp->l2vnis

Must always be valid data structures.  So remove the tests
that ensure that they are.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-05 10:43:43 -04:00
Pascal Mathis
f906747961
tests: Improve test suite for peer attributes
This commit improves the previous implementation of the peer attribute
test suite by getting rid of some really ugly macros and replacing them
with sane functions.

Additionally, the macro TEST_ASSERT was changed to TEST_ASSERT_EQ (==
comparison) which now also prints the line where the assertion has been
infringend. This should make it way more clear where a specific issue
has been spotted.

Last but not least, the multicast families for both IPv4 and IPv6 had
been added as they are working without any further changes or special
cases for all currently existing peer attributes. Other AFI/SAFI
references have been removed to keep the code clean.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-28 22:07:53 +02:00
Pascal Mathis
cf9ac8bfb0
bgpd: Fix style issues for peer-group overrides
This commit fixes all outstanding style/formatting issues as detected by
'git clang-format' or 'checkpath' for the new peer-group override
implementation, which spanned across several commits.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-28 19:25:51 +02:00
Pascal Mathis
9d4f56237a
tests: Add tests for overriding BGP peer attrs
This commit introduces unit tests for BGP peer attributes and checks all
three involved components, which are:

- CLI Configuration Input: The appropriate commands to configure the
attribute on either a peer or peer-group are being executed the same way
an end user would do it.

- CLI Configuration Output: The output of 'show running-config' is being
checked for presence/absence of expected configuration strings.

- Internal Data Structures: The internal data structures for maintaining
flag/filter states (value + override + invert) are being checked after
each operation to ensure the override has been implemented properly.

All attributes to be tested must be defined within the 'peer_attrs'
structure, which contains all peer attributes as of today and checks
them with both IPv4 Unicast and IPv6 Unicast. More address families are
supposed to be introduced at a later point in time.

Each attribute is being checked in its own 'clean' BGP environment, so
everything gets reset after each attribute to avoid any weird edge
cases. The 'correct' BGP startup and shutdown routine was taken from
'bgp_main.c' to ensure that we are not leaking any memory or acting
different than the real 'bgpd' would do.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-28 19:20:46 +02:00
Christian Franke
a5558663af tests: add pytest cache to gitignore 2018-05-28 15:09:50 +02:00
Quentin Young
ecbe4344af tests: add missing file to Makefile.am
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-18 19:45:10 +00:00
Donald Sharp
4258abc56c tests: Add a prefix-sid test
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-02 18:51:07 -04:00
Donald Sharp
d0fa84c228 tests: Fix crash in test_mp_attr
Some recent changes in BGP now require that the
peer's nexthop have a valid ifp when we are looking
at:

	case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
	case BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL:

This assumption makes sense for this type of Nexthop Attribute.
So for the test let's jimmy up a `fake` enough interface pointer
so that the actual test we can focus on what we are actually
testing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-25 12:39:17 -04:00
Quentin Young
58f8a9ecde lib: add DFS + DOT dumping to graph datastructure
* Add general-purpose DFS traversal code
* Add ability to dump any graph to DOT language
* Add tests for graph datastructure

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-19 13:04:58 -04:00
Quentin Young
0e9f8d2d86 ospf6d: handle realloc() failure in lsa test
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-17 13:58:24 -04:00
G. Paul Ziemba
960035b2d9 bgpd: nexthop tracking with labels for vrf-vpn leaking
Routes that have labels must be sent via a nexthop that also has labels.
This change notes whether any path in a nexthop update from zebra contains
labels. If so, then the nexthop is valid for routes that have labels.

If a nexthop update has no labeled paths, then any labeled routes
referencing the nexthop are marked not valid.

Add a route flag BGP_INFO_ANNC_NH_SELF that means "advertise myself
as nexthop when announcing" so that we can track our notion of the
nexthop without revealing it to peers.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-04-04 10:00:23 -07:00
Philippe Guibert
3bc593a8f7 tests: add flowspec test with BGP MP_REACH/UNREACH
This commit checks that the reception of MP_REACH and MP_UNREACH
flowspec is handled correctly.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-30 14:01:06 +02:00
Quentin Young
d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

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

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Donald Sharp
4fc797c052
Merge pull request #1830 from opensourcerouting/isis-three-way-adj
IS-IS: implement three-way handshake as per RFC5303
2018-03-14 08:22:18 -04:00
Quentin Young
abccc77544
tests: add unit test for zlog
Just tests zlog_hexdump right now

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-12 15:39:45 -04:00
Christian Franke
9fe2120814 isisd: add support for TLV 240 P2P Three-Way Adjacency
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-03-10 18:38:03 +01:00
Donald Sharp
7ee30f288e lib: Isolate nexthop_group functions to nexthop_group.c
Also modify `struct route_entry` to use nexthop_groups.
Move ALL_NEXTHOPS loop to nexthop_group.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Christian Franke
2d0e9b8026 tests: update gitignore
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-03-05 19:50:21 +01:00
Christian Franke
4cfe547340 tests: fix python test description for test_ringbuf
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-03-05 19:44:41 +01:00
Renato Westphal
6bba65f29f tests: fix warnings related to afi/safi constants
We were improperly mixing constants used to identify AFI/SAFI values
using the IANA and internal representations. Things happened to be
working because the IANA/internal values are the same in some cases
(e.g. AFI_IP and IANA_AFI_IPV4). This commit fixes a few warnings when
running "make check" on FreeBSD 11.1.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-02-02 16:31:07 -02:00
Renato Westphal
a36fbef21a tests: fix warnings by removing dead code
These variables being removed were made obsolete by commit 9cabb64b3. As
of now, the parse_test() function fetches the afi/safi values from
the parsed NLRIs. There's no need to have duplicate information in the
'test_segment' structure anymore.

This fixes several warnings of this kind when running "make check"
on FreeBSD: "implicit conversion from enumeration type 'iana_safi_t'
to different enumeration type 'safi_t'".

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-02-02 16:28:21 -02:00
Quentin Young
cadc5f3377
tests: make tests happy for pthread changes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-01-24 15:53:07 -05:00
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
Russ White
82b9bf3145
Merge pull request #1569 from qlyoung/ringbuf
lib: add ring buffer
2018-01-02 09:21:37 -05: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
Donald Sharp
db33b83b1d
Merge pull request #1478 from bingen/zeromq4
lib: Address ZMQ lib TODOs
2017-12-13 07:36:57 -05: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
Quentin Young
5561f52343
tests: neuter fuzzing frontend for now
Fuzzing hook for BGP packet processing does not map to MT-BGPD. Removing
offending call for now, additional work to fix this in the future.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:07 -05:00
Quentin Young
ca7f0cc7ac
tests: add name to test_mp_attr threadmaster
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:05 -05:00
Quentin Young
becedef6c3
bgpd, tests: comment formatting
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:05 -05:00
Quentin Young
e9aac3a29a
tests: update tests for bgp_packet changes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:18:03 -05:00
Quentin Young
419dfe6a70
bgpd: dynamically allocate synchronization primitives
Changes all synchronization primitives to be dynamically allocated. This
should help catch any subtle errors in pthread lifecycles.

This change also pre-initializes synchronization primitives before
threads begin to run, eliminating a potential race condition that
probably would have caused a segfault on startup on a very fast box.

Also changes mutex and condition variable allocations to use
MTYPE_PTHREAD and updates tests to do the proper initializations.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-30 16:17:58 -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
ß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
faf4cc64f4 tests: Add code to allow us to test packet handling in bgp easier
Fuzzing with tools like afl requires the ability to quickly/easily
call a function to test it's input.  In the case of bgp we
need the ability to test bgp's packet handler quickly.  This
added program bgpd/test_packet takes a file name as input
that it treats as normal bgp communication between itself
and a peer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-11-06 10:53:01 -05:00
Donald Sharp
76e292f994 isisd: Allow struct zebra_privs_t to be available
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-23 18:09:23 -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
Christian Franke
60d3914270 isisd: fix vertex queue comparator
While vertizes should be strictly ordered on insertion, deletion
will of course encouter equality.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-10-02 16:03:11 +02:00
Christian Franke
5d30de83e1 tests: verify isis_vertex_queue correctness
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-09-22 21:19:34 +02:00
Christian Franke
0fb07d51c0 tests: skip isis tlv fuzztest on SunOS 2017-09-02 01:57:32 +02:00
David Lamparter
35b416fde2 tests: fix & run ZeroMQ test
add reference output & run the test with proper libs and such.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 18:00:13 +02:00
David Lamparter
a0b974def7 tests: add ZeroMQ test
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28 18:00:13 +02:00
David Lamparter
9eed278b16 lib: centralized memstats-at-exit
adds a new all-daemon "debug memstats-at-exit" command.  Also saves
memstats to a file in /tmp, useful if a long-running daemon is having
weird issues (e.g. in a user install).

Fixes: #437
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24 00:18:50 +02:00
David Lamparter
279f5e0934 tests: fix clippy include paths / double-build
A mismatch between the make rule and the include path causes dependency
tracking to try to build the clippy.c file twice (at the same time),
which results in spurious build failures.

Fixes: #971
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-15 11:21:07 +02:00
David Lamparter
4e1fd26a5e Merge remote-tracking branch 'frr/master' into tcp-zebra 2017-08-09 20:42:27 +02:00
Donald Sharp
fc73dd4bdf Merge pull request #911 from opensourcerouting/non-recursive-2
more non-recursive build, fix cross-compile, & doc build mangling
2017-08-09 14:38:07 -04:00
Donald Sharp
f790234f2f Merge pull request #892 from opensourcerouting/watchfrr-simplify
simplify watchfrr, add --terminal, improve startup logging
2017-08-09 14:32:44 -04:00
Quentin Young
19c9f07691
*: ignore .dirstamp
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-09 13:48:31 -04:00
David Lamparter
689f5a8c84 *: remove --enable-tcp-zebra, rework ZAPI path
This adds "@tcp" as new choice on the -z option present in zebra and the
protocol daemons.  The --enable-tcp-zebra option on configure is no
longer needed, both UNIX and TCP socket support is always available.

Note that @tcp should not be used by default (e.g. in an init script),
and --enable-tcp-zebra should never have been in any distro package
builds, because

**** TCP-ZEBRA IS A SECURITY PROBLEM ****

It allows arbitrary local users to mess with the routing table and
inject bogus data -- and also ZAPI is not designed to be robust against
attacks.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-08 11:14:05 +02:00
David Lamparter
70d27c5b7d build: clean up BUILT_SOURCES
BUILT_SOURCES doesn't do what the name suggests.  What it actually means
is "these files should be built first when doing a 'make' without
explicit target" (or "make all").

It's pretty much almost always wrong to use BUILT_SOURCES, the only
correct use is when a file is needed by an unspecified / large set of
files.

Also remove version.h and route_types.h from dist tarball while we're at
it.  configure will create them anyway.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-04 11:13:55 +02:00
Christian Franke
841791b65b isisd: rework complete, move "tlvs2" to "tlvs"
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-08-03 11:34:04 +02:00
Christian Franke
7ef5fefc3c isisd: add new tlv parser
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-08-03 11:34:04 +02:00
David Lamparter
37a1f2fbb6 lib: privs: make uid/gid accessible before setuid
This splits off privs_preinit(), which does the lookups for user and
group IDs.  This is so the init code can create state directories while
still running as root.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 23:36:39 +02:00
David Lamparter
154b9e8f9f lib: vty_stdio signal handling
- SIGTSTP appropriately suspends the foreground terminal
- SIGINT causes the daemon to exit, regardless of -d
- SIGQUIT causes the daemon to daemonize, regardless of -d

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 02:59:51 +02:00
Renato Westphal
399aedd637 tests: fix small typo
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31 23:45:03 -03:00
Renato Westphal
5c5255381e lib/bgpd: introduce the iana_safi_t enum
We had afi_t/iana_afi_t for AFIs but only safi_t for SAFIs. Fix this
inconsistency.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31 23:44:42 -03:00
David Lamparter
9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22 14:52:33 +02:00
whitespace / reindent
c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -04:00
whitespace / reindent
d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
David Lamparter
53a37141f9 tests/ospf6d/test_lsdb: remove vty_outln
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 17:32:22 +02:00
David Lamparter
22106bbf68 Merge remote-tracking branch 'frr/master' into table-hash-ospf6-lsdb-refactor
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 17:30:56 +02:00
Russ White
28bd1c1158 Merge pull request #813 from opensourcerouting/newline-redux
newline redux
2017-07-14 08:00:43 -04:00
Donald Sharp
eef83e96f7 Merge pull request #762 from bingen/mutiple_nh_recursive_levels
Allow for more than 1 NH recursion level
2017-07-14 07:44:02 -04:00
David Lamparter
2d8270596a Merge remote-tracking branch 'frr/master' into newline-redux
Lots of conflicts from CMD_WARNING_CONFIG_FAILED...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:07:30 +02:00
David Lamparter
625e016d14 *: remove VTYNL, part 6 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
5c7571d43f *: ditch vty_outln(), part 1 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:22 +02:00
ßingen
97ba3968a0 lib, test: Add test case for ALL_NEXTHOPS_RO
Without it, tests were passing before commit 9fb47c0, so a case was
missing (the one which that commit fixes).

Signed-off-by: ßingen <bingen@voltanet.io>
2017-07-13 15:07:12 +02:00
Christian Franke
6c968614b5 tests: update prng to return better pseudo random numbers
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-07-12 18:44:44 +02:00
David Lamparter
25fbf00118 build: fix ttable test
test_ttable.refout wasn't in the dist package.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 15:23:28 +02:00
David Lamparter
f1c73d1495 tests: ospf6d: basic LSDB tests
Needed these while rewriting LSDB iteration.

NB: this commit fails because of a bug in ospf_lsdb_get_next, which will
SEGV when the LSDB is actually empty.  Whooo...  (this is fixed in the
following commits.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 15:04:12 +02:00
David Lamparter
2e8a2df1fb tests: fix pytest API "surprise" in skipping tests
pytest.mark.skipif apparently iterates through a class's methods,
applying itself onto the various methods.  Now, since we're deriving
from a parent class, the method is actually the same object inherited
from the parent, so the decorator will apply itself on the parent's
testrunning method (test_refout).  The result is that any TestRefout
tests after "test_commands.py" will be skipped...

This only became apparent after adding ospf6d/test_lsdb.py;  before,
test_commands.py was the last test in the list so it didn't matter...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 15:00:26 +02:00
ßingen
8e688dbd58 Rename ALL_NEXTHOPS_RO to ALL_NEXTHOPS 2017-07-10 21:14:59 +02:00
ßingen
97c2fb7cdc Fix tests for NH multiple recursion levels
Tests were no passing. Besides, added cases to test more than 1 level
depth in nexthop recursion.
2017-07-10 14:02:57 +02:00
Quentin Young
dfd19ccc3a
*: update hash_create(), hash_create_size()
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-01 19:18:37 -04:00
Quentin Young
972a411ccc lib: more show thread cpu
Add support for naming pthreads. Also, note that we don't have any
records yet if that's the case.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 23:40:56 +00:00
Quentin Young
8e25c8ce2f *: rebase vty_outln() -> master
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:38:59 +00:00
Quentin Young
1318e7c841 *: s/VTY_NEWLINE/VTYNL/g
Should be able to fit more vty_out onto one line now

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:34:54 +00:00
Quentin Young
96ade3ed77 *: use vty_outln
Saves 400 lines

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:31:28 +00:00
ßingen
f9e1b38e1a Allow for more than 1 NH recursion level
Before, only one level of recursive resolution was supported.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-06-28 21:32:18 +02:00
Donald Sharp
1e84e9a697 Merge pull request #714 from opensourcerouting/cli_magic_defpy
CLI magic: part 1 (DEFPY)
2017-06-28 09:48:33 -04:00
Quentin Young
f051edd156 lib: add table generator
Allows for easy preparation of tabular output.

Supports:
 -- Padding
 -- Alignment
 -- Styling
2017-06-16 02:02:42 +00:00
David Lamparter
169e541c28 tests: cli: unit test DEFPY() + clidef.py
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-14 19:29:26 +02:00
Quentin Young
a587d00bac *: remove THREAD_BACKGROUND
it's just an alias for a millisecond timer used in exactly nine places
and serves only to complicate

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-08 01:53:50 +00:00
David Lamparter
bac7b7b935 Merge pull request #537 from donaldsharp/vrf_stuff
Vrf stuff
2017-05-17 22:06:39 +02:00
Donald Sharp
910a5c0e21 Merge branch 'master' into vrf_stuff 2017-05-16 07:58:55 -04:00
Donald Sharp
cc629aef4a tests: Fix vrf_init to have correct call
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-15 22:30:28 -04:00
David Lamparter
896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
David Lamparter
9a7fc1bd7a lib: cli: fix IPv6 address partial matching
A partially-entered IPv6 address would never return a "partly_match",
meaning some possible completions weren't listed by the matcher.

This specifically breaks autocompleting BGP IPv6 neighbor addresses.
Before:
aegaeon# show ip bg ne 2001:<?>
  WORD      Neighbor on BGP configured interface

After:
aegaeon# show ip bg ne 2001:<?>
  WORD      Neighbor on BGP configured interface
  X:X::X:X  Neighbor to display information about
      2001:db8::2

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 10:27:43 -04:00
Quentin Young
66e78ae64b *: update thread_add_* calls
Pass pointer to pointer instead of assigning by return value. See
previous commit message.

To ensure that the behavior stays functionally correct, any assignments
with the result of a thread_add* function have been transformed to set
the pointer to null before passing it. These can be removed wherever the
pointer is known to already be null.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:22 +00:00
Quentin Young
ffa2c8986d *: remove THREAD_ON macros, add nullity check
The way thread.c is written, a caller who wishes to be able to cancel a
thread or avoid scheduling it twice must keep a reference to the thread.
Typically this is done with a long lived pointer whose value is checked
for null in order to know if the thread is currently scheduled.  The
check-and-schedule idiom is so common that several wrapper macros in
thread.h existed solely to provide it.

This patch removes those macros and adds a new parameter to all
thread_add_* functions which is a pointer to the struct thread * to
store the result of a scheduling call. If the value passed is non-null,
the thread will only be scheduled if the value is null. This helps with
consistency.

A Coccinelle spatch has been used to transform code of the form:

  if (t == NULL)
    t = thread_add_* (...)

to the form

  thread_add_* (..., &t)

The THREAD_ON macros have also been transformed to the underlying
thread.c calls.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:19 +00:00
Christian Franke
9d83fa426c tests: allow to use exit_cleanly as test method
TestMultiOut can now also just check for clean exit

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-05-08 17:24:30 +02:00
David Lamparter
3e7c8d040c Merge branch 'stable/2.0'
Fixed minor conflicts from "defaults" change on stable.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-04-04 19:01:47 +02:00
Lou Berger
447a8fe92e Rename: FreeRangeRouting FRRouting
Signed-off-by: Lou Berger <lberger@labn.net>
2017-03-30 14:22:35 -04:00
Donald Sharp
fdbfd655c1 Merge pull request #299 from opensourcerouting/test-ref-out
tests: format TestRefMismatch more readable
2017-03-30 06:14:21 -05:00
David Lamparter
8efe88eacf *: track version & "defaults" in configs
[CF]: Move default name to autoconf and update tests

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-03-28 19:18:42 +02:00
Christian Franke
1ea8289e2a tests: format TestRefMismatch more readable
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-03-28 18:56:38 +02:00
ßingen
fea12efb86 Implement generic label manager
Label Manager allows to share MPLS label space among different
daemons. Each daemon can request a chunk of consecutive labels and
release it if it doesn't need them anymore. Label Manager stores the
daemon protocol and instance to identify the owner client. It uses them
to perform garbage collection, releasing all label chunks from a client
when it gets disconnected or reconnected.

Additionally, every client can request that the chunk is never garbage
collected. In that case client has the responsibility to release
non-used labels.

Zebra can host the label manager itself (if no -l param is provided) or
connect to an external one using zserv/zclient (providing its address
with -l param).

Client code is in lib/zclient.c, but currently only LDP is using it.

TODO: Allow for custom ranges requests, i.e., specify the start label
besides the chunk.
TODO: Release labels from LDP.

Signed-off-by: Bingen Eguzkitza <bingen@voltanet.io>
2017-03-20 17:10:41 +01:00
David Lamparter
dd8376febd lib: remove remaining struct zlog * args
These don't serve any purpose either.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:40 +01:00
David Lamparter
bf1013e6c4 lib: simplify protocol/log naming
The protocols enum serves no purpose other than adding potential for
bugs and making it complicated to add a new protocol... nuke.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:40 +01:00
David Lamparter
4f04a76b71 *: add frr_init() infrastructure
Start centralising startup & option parsing into the library.

FRR_DAEMON_INFO is a bit weird, but it will become useful later (e.g.
for killing the ZLOG_* enum, and having the daemon name available)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 23:07:20 +01:00
Philippe Guibert
dd3fb4c3ee tests: fix bgp print in tests
This commit is a fix from previous commit: Quagga: AFI/SAFI mappings
IANA to/from internal values. It removes the printf that was used for
troubleshooting the afi/safi change, in respect to testing.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-02-14 13:58:59 +01:00
Philippe Guibert
4fadf88120 tests: update ecommunity_ecom2str call api
Test adaptation using updated API, introducing new ecommunity type.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-02-14 13:58:58 +01:00
Philippe Guibert
b205584753 tests: update bgp_nlri_parse function usage in bgp testing
Because the bgp_nlri_parse function has been extended with one parameter,
when doing bgp testing against some packets, the correct call to
bgp_nlri_parse must be done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-02-14 13:58:57 +01:00
David Lamparter
43dac2baae tests: fix out-of-tree build
Fix pytest with $(top_srcdir) != "."

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-13 17:44:03 +01:00
Christian Franke
cbbf41cbb3 tests: add pytest testrunners
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-02-13 17:43:47 +01:00
Christian Franke
30c4877560 tests: reorganize tests hierarchically
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-02-13 16:54:48 +01:00
Christian Franke
5a1218aa53 tests: remove dejagnu
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-02-13 16:53:00 +01:00
Donald Sharp
757abe78d8 Merge pull request #195 from opensourcerouting/cli_merge
CLI: independent merge step
2017-02-11 07:00:00 -05:00
David Lamparter
a95c3a4917 tests: fix out-of-tree build
Fix pytest with $(top_srcdir) != "."

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-11 01:03:57 +01:00
David Lamparter
fdc3d1ab83 tests: add uninstall_element in testcli
Test uninstall_element().  The commandline-specified counter allows
isolating memleaks more closely, differentiating one-off vs. repeated
leaks.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10 15:40:38 +01:00
Christian Franke
a4b74d05fc tests: add pytest testrunners
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-02-08 19:10:10 +01:00
Christian Franke
ca49a76b02 tests: reorganize tests hierarchically
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-02-08 19:09:35 +01:00
Christian Franke
0b4191c147 tests: remove dejagnu
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-02-08 19:08:25 +01:00
Donald Sharp
03bf19b29b tests: Fix warning in compile
Fix bgp_mp_attr_test.c warning in compile
on fedora 25 and clang.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-07 14:14:17 -05:00
Donald Sharp
7df2e1c379 Merge remote-tracking branch 'origin/stable/2.0' 2017-02-07 13:20:12 -05:00
Donald Sharp
55c7280315 *: Convert libzebra -> libfrr
The library libzebra that is installed with FRR will
conflict with Quagga.  So let's rename it to libfrr.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-03 08:29:13 -05:00
Donald Sharp
e46538e628 Merge pull request #139 from opensourcerouting/cli_merge_prep_final
CLI split merge-step preparations
2017-01-31 13:27:42 -05:00
Christian Franke
e322dbc73a Merge branch 'master' into feature/zebra-srcdest 2017-01-31 16:22:54 +01:00
David Lamparter
3a8b1ac043 tests/testcli: cleanup at exit
Call the proper termination functions so we can see memory leaks.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:39 +01:00
David Lamparter
bff9c3e9d3 lib/tests: add cmd_hostname_set()
To make it possible for testcli to get a clean memory management bill.
(Note: XFREE() is NULL-safe, just like free().)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:39 +01:00
David Lamparter
66d29a54a1 lib: clean up tab-completion memory counting
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:19 +01:00
Donald Sharp
bf21dc0a41 Merge pull request #127 from LabNConsulting/working/master/patch/assert-dup-free
lib: assert on duplicate free (count)
2017-01-30 13:07:44 -05:00
Christian Franke
785025eea0 tests: add a test for the srcdest_table structure
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
[DL: v2: fix missing slash in tests/Makefile.am]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-30 13:54:40 +01:00
Donald Sharp
52e6153210 tests: Fix conversion between iana_t and afi_t
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-27 15:31:47 -05:00
Lou Berger
56c8423f58 tests: use lib memory allocation
Signed-off-by: Lou Berger <lberger@labn.net>
2017-01-27 09:16:43 -05:00
Donald Sharp
d2ce19c9b5 Merge pull request #105 from opensourcerouting/cli_merge_step_prep
Prepare for split-off cli parser "merge" step
2017-01-25 07:49:21 -05:00
David Lamparter
663982cda7 lib: parser: unify subgraphs & simplify even more
This cuts a large piece of complexity from the parser by making the
sequences between | the same, no matter whether it's <> () or [].

This causes some changes in behaviour:
- [foo|bar] is now accepted
- <foo|[bar]> is now accepted (yes it's stupid)
- {a|b} is now means "at least one of these, in any order"; to allow
  zero use [{a|b}] instead.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-23 21:52:44 +01:00
David Lamparter
cf672a8654 *: use monotime()
This is largely a bulk-replace made with coccinelle.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-23 18:26:32 +01:00
David Lamparter
b6f1faf045 Merge branch 'stable/2.0-for-merge'
Conflicts (CLI vs. atol()):
- bgpd/bgp_vty.c
- ospfd/ospf_vty.c
- zebra/zebra_vty.c

NB: pull req #65 (LabNConsulting/working/2.0/afi-safi-vty/c) was
excluded from this merge.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-13 15:24:25 +01:00
David Lamparter
81f28d2624 tests: fix mis-fixed format string
PRIu64 is "u", we need "x", so PRIx64...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Donald Sharp <sharpd@cumulusnetworks.com>
[cherry-picked from master eed831e065]
2017-01-13 11:51:45 +01:00
David Lamparter
9d8927ee1f tests: fix exit <> return mix-up in dejagnu
exit 0 exits the entire testrunner... Oops.
Also, "unresolved" breaks too many things, so make this a pass.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
[cherry-picked from master e988dfd35b]
2017-01-13 11:25:36 +01:00
David Lamparter
2f9a659926 tests: ignore stderr for expect
expect redirects both stdout and stderr to its input.  This causes
serious problems when libzebra prints log messages to stderr, which are
then asynchronously inserted in the middle of lines of stdout test
output.  Ultimately this makes testbgpmpattr fail on FreeBSD.

(The stdio buffering seems to be slightly different on FreeBSD,
triggering the bug.)

Just ignore stderr for expect.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-13 11:23:18 +01:00
vivek
9cabb64b32 Quagga: AFI/SAFI mappings IANA to/from internal values
Introduce internal and IANA defintions for AFI/SAFI and mapping
functions and modify code to use these. This refactoring will
facilitate adding support for other AFI/SAFI whose IANA values
won't be suitable for internal data structure definitions (e.g.,
they are not contiguous).
The commit adds some fixes related to afi/safi testing with 'make check
' command.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>

Ticket: CM-11416
Reviewed By: CCR-3594 (mpls branch)
Testing Done: Not tested now, tested earlier on mpls branch
2017-01-12 09:28:43 +01:00
Donald Sharp
3b14d86eed Merge remote-tracking branch 'origin/stable/2.0' 2017-01-06 09:58:21 -05:00
David Lamparter
b2f361571b build: rename (1 of ?): configure.ac + preproc
This replaces Quagga -> FRR in most configure.ac settings as well as
a handful of preprocessor macros in the source code.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-20 17:57:47 +01:00
David Lamparter
8ef0791cb6 build: remove $Format tags
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-20 17:54:03 +01:00
David Lamparter
eed831e065 tests: fix mis-fixed format string
PRIu64 is "u", we need "x", so PRIx64...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-16 20:42:01 +01:00
David Lamparter
e988dfd35b tests: fix exit <> return mix-up in dejagnu
exit 0 exits the entire testrunner... Oops.
Also, "unresolved" breaks too many things, so make this a pass.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-16 20:42:01 +01:00
David Lamparter
46715ff034 tests: add missing qobj_init() call
This was SEGV'ing the test in bgp_master_init() since QOBJ_REG was used
without qobj_init() being called first.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-16 20:42:01 +01:00
David Lamparter
7ef290efa3 tests: adjust testcli ref output to new argv rules
Now that we have keyword argument support in the matcher again, this
needs to be updated because argv[] will be 1:1 user input without
mangling or reordering.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-16 20:42:01 +01:00
Quentin Young
6fd800be4a Merge remote-tracking branch 'osr/master' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	lib/command_match.c
2016-12-06 19:51:33 +00:00
Quentin Young
3d6e734154 lib, tests: fix failing cli tests
Some tests still failing pending reimplementation of {}
cli definition constructs

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-06 19:27:58 +00:00
David Lamparter
53dc2b05c7 Merge branch 'stable/2.0'
Conflicts:
	bgpd/bgp_route.c
	lib/if.c
	ripd/rip_interface.c
	zebra/interface.c
	zebra/zebra_vty.c
2016-12-05 19:48:38 +01:00
Renato Westphal
37d361e7fd bgpd: plug several memleaks
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:15:27 -02:00
David Lamparter
8a7787e8ac tests: update testcli reference output
These are expected changes in CLI behaviour.  There's still a diff of
unexpected changes that need fixing (or are missing features, e.g.
keyword arguments).

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28 18:40:25 +01:00
David Lamparter
6a23719c75 tests: fixup for vtysh-grammar merge
Tests weren't updated for vtysh-grammar yet...
NB: things still fail since some CLI behaviour changed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28 18:32:45 +01:00
Quentin Young
476e95e3f3 Merge branch 'cmaster-next' into vtysh-grammar 2016-11-03 20:43:41 +00:00
Paul Jakma
96e52474fd bgpd: Regularise bgp_update_receive, add missing notifies and checks
* bgp_packet.c: (bgp_update_receive) Lots of repeated code, doing same
  thing for each AFI/SAFI.  Except when it doesn't, e.g.  the IPv4/VPN
  case was missing the EoR bgp_clear_stale_route call - the only action
  really needed for EoR.

  Make this function a lot more regular, using common, AFI/SAFI
  independent blocks so far as possible.

  Replace the 4 separate bgp_nlris with an array, indexed by an enum.

  The distinct blocks that handle calling bgp_nlri_parse for each
  different AFI/SAFI can now be replaced with a loop.

  Transmogrify the nlri SAFI from the SAFI_MPLS_LABELED_VPN code-point
  used on the wire, to the SAFI_MPLS_VPN safi_t enum we use internally
  as early as possible.

  The existing code was not necessarily sending a NOTIFY for NLRI
  parsing errors, if they arose via bgp_nlri_sanity_check.  Send the
  correct NOTIFY - INVAL_NETWORK for the classic NLRIs and OPT_ATTR_ERR
  for the MP ones.

  EoR can now be handled in one block.  The existing code seemed broken
  for EoR recognition in a number of ways:

  1.  A v4/unicast EoR should be an empty UPDATE.  However, it seemed
     to be treating an UPDATE with attributes, inc.  MP REACH/UNREACH,
     but no classic NLRIs, as a v4/uni EoR.

  2.  For other AFI/SAFIs, it was treating UPDATEs with no classic
     withraw and with a zero-length MP withdraw as EoRs.  However, that
     would mean an UPDATE packet _with_ update NLRIs and a 0-len MP
     withdraw could be classed as an EoR.

  This seems to be loose coding leading to ambiguous protocol
  situations and likely incorrect behaviour, rather than simply being
  liberal.  Be more strict about checking that an UPDATE really is an
  EoR and definitely is not trying to update any NLRIs.

  This same loose EoR parsing was noted by Chris Hall previously on
  list.

  (bgp_nlri_parse) Front end NLRI parse function, to fan-out to the correct
  parser for the AFI/SAFI.

* bgp_route.c: (bgp_nlri_sanity_check) We try convert NLRI safi to
  internal code-point ASAP, adjust switch for that.  Leave the wire
  code point in for defensive coding.

  (bgp_nlri_parse) rename to bgp_nlri_parse_ip.

* tests/bgp_mp_attr_test.c: Can just use bgp_nlri_parse frontend.
2016-10-26 09:36:08 -04:00
Paul Jakma
48a5452b5b bgpd: Regularise BGP NLRI sanity checks a bit
* bgp_route.h: (bgp_nlri_sanity_check) The bulk of the args are equivalent
  to a (struct bgp_nlri), consolidate.
* bgp_route.c: (bgp_nlri_sanity_check) Make this a frontend for all afi/safis.
  Including SAFI_MPLS_LABELED_VPN.
  (bgp_nlri_sanity_check_ip) Regular IP NLRI sanity check based on the
  existing code, and adjusted for (struct bgp_nlri *) arg.
* bgp_attr.c: (bgp_mp_reach_parse) Adjust for passing (struct bgp_nlri *)
  to bgp_nlri_sanity_check.
  Get rid of special-casing to not sanity check VPN.
  (bgp_mp_unreach_parse) Ditto.

* bgp_mplsvpn.c: Use the same VPN parsing code for both the sanity
  check and the actual parse.

  (bgp_nlri_parse_vpn) renamed to bgp_nlri_parse_vpn_body and made
  internal.

  (bgp_nlri_parse_vpn_body) Added (bool) argument to control whether it
  is sanity checking or whether it should update routing state for each
  NLRI.  Send a NOTIFY and reset the session, if there's a parsing
  error, as bgp_nlri_sanity_check_ip does, and as is required by the
  RFC.

  (bgp_nlri_parse_vpn) now a wrapper to call _body with update.

  (bgp_nlri_sanity_check_vpn) wrapper to call parser without
  updating.

* bgp_mplsvpn.h: (bgp_nlri_sanity_check_vpn) export for
  bgp_nlri_sanity_check.

* bgp_packet.c: (bgp_update_receive) Adjust for bgp_nlri_sanity_check
  argument changes.

* test/bgp_mp_attr_test.c: Extend to also test the NLRI parsing functions,
  if the initial MP-attr parsing has succeeded.  Fix the NLRI in the
  VPN cases.  Add further VPN tests.

* tests/bgpd.tests/testbgpmpattr.exp: Add the new test cases.

This commit a joint effort of:

Lou Berger <lberger@labn.net>
Donald Sharp <sharpd@cumulusnetworks.com>
Paul Jakma <paul.jakma@hpe.com> / <paul@jakma.org>
2016-10-26 09:36:08 -04:00
Quentin Young
0a538fc98f Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	isisd/isis_routemap.c
	zebra/rt_netlink.c
2016-10-20 16:31:49 +00:00
David Lamparter
db7d7ba4e1 tests: fix MIN()-related sign warnings
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-18 08:36:25 -04:00
Quentin Young
e52702f29d Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	bgpd/bgp_route.c
	bgpd/bgp_routemap.c
	bgpd/bgp_vty.c
	isisd/isis_redist.c
	isisd/isis_routemap.c
	isisd/isis_vty.c
	isisd/isisd.c
	lib/command.c
	lib/distribute.c
	lib/if.c
	lib/keychain.c
	lib/routemap.c
	lib/routemap.h
	ospf6d/ospf6_asbr.c
	ospf6d/ospf6_interface.c
	ospf6d/ospf6_neighbor.c
	ospf6d/ospf6_top.c
	ospf6d/ospf6_zebra.c
	ospf6d/ospf6d.c
	ospfd/ospf_routemap.c
	ospfd/ospf_vty.c
	ripd/rip_routemap.c
	ripngd/ripng_routemap.c
	vtysh/extract.pl.in
	vtysh/vtysh.c
	zebra/interface.c
	zebra/irdp_interface.c
	zebra/rt_netlink.c
	zebra/rtadv.c
	zebra/test_main.c
	zebra/zebra_routemap.c
	zebra/zebra_vty.c
2016-10-17 23:36:21 +00:00
David Lamparter
1bf9f0270c lib: add "qobj" object-ID infrastructure
This adds 64-bit random identifiers as "safe pointers" which are also
type-tracked / can have type-specific extension methods.

This will be used by both the CLI (to keep safe references while in
config editing mode) as well as the Cap'n Proto code (to hand out
pointers to the user in a safe way and add per-type handlers)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-07 09:09:51 -04:00
Lou Berger
5d370a29a0 vnc: look for librfp.a in builddir 2016-10-03 08:17:30 -04:00
Lou Berger
65efcfce42 bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN
and Encap SAFIs.  This code is currently used to support IETF NVO3 style
operation.  In NVO3 terminology it provides the Network Virtualization
Authority (NVA) and the ability to import/export IP prefixes and MAC
addresses from Network Virtualization Edges (NVEs).  The code supports
per-NVE tables.

The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2
(L2) forwarding information between NVAs and NVEs is referred to as the
Remote Forwarder Protocol (RFP). OpenFlow is an example RFP.  For
general background on NVO3 and RFP concepts see [1].  For information on
Openflow see [2].

RFPs are integrated with BGP via the RF API contained in the new "rfapi"
BGP sub-directory.  Currently, only a simple example RFP is included in
Quagga. Developers may use this example as a starting point to integrate
Quagga with an RFP of their choosing, e.g., OpenFlow.  The RFAPI code
also supports the ability import/export of routing information between
VNC and customer edge routers (CEs) operating within a virtual
network. Import/export may take place between BGP views or to the
default zebera VRF.

BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN
information between NVAs. BGP based IP VPN support is defined in
RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659,
BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use
of both the Encapsulation Subsequent Address Family Identifier (SAFI)
and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation
Subsequent Address Family Identifier (SAFI) and the BGP Tunnel
Encapsulation Attribute, are supported. MAC address distribution does
not follow any standard BGB encoding, although it was inspired by the
early IETF EVPN concepts.

The feature is conditionally compiled and disabled by default.
Use the --enable-bgp-vnc configure option to enable.

The majority of this code was authored by G. Paul Ziemba
<paulz@labn.net>.

[1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req
[2] https://www.opennetworking.org/sdn-resources/technical-library

Now includes changes needed to merge with cmaster-next.
2016-10-03 08:17:02 -04:00
Daniel Walton
e961923c72 bgpd, etc: changed .LINE to LINE...
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-27 00:07:46 +00:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.

The zebra change is slightly annoying because there is no nice place to
put the #include "zebra_memory.h" statement.

bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the
library for its own use.  This is bad practice and would break when the
memtype are made static.

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-19 16:31:04 -04:00
David Lamparter
fc7948fafe lib: migrate to new memory-type handling
Move over to the new allocation counting added in the previous commit.

(This commit is mostly mechanical.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
2016-09-19 18:35:50 +02:00
Donald Sharp
039f3a3495 lib, bgpd, tests: Refactor FILTER_X in zebra.h
lib/zebra.h has FILTER_X #define's.  These do not belong there.
Put them in lib/filter.h where they belong.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 0490729cc033a3483fc6b0ed45085ee249cac779)
2016-08-16 11:00:22 -04:00
David Lamparter
355cf2a71a tests: update testcli reference output
an extra comment line got added somewhere inbetween.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-07-24 03:49:35 -04:00
Quentin Young
34be90949f Fix missing parameter in call to openzlog 2016-06-17 15:59:12 -04:00
David Lamparter
7a2fbbf0ee *: make sure zebra.h is always included first
zebra.h pulls in config.h, which results in fiddling with things like
__FILE_OFFSET_BITS. It must always be included first, in order to set
flags that influence the compiler via <features.h>.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 821df2cf18e5978cc7ab532a8695444380d08270)
2016-06-09 10:45:22 -04:00
Lou Berger
005b6bc0ab bgpd: tests - add null pointer protection to fix bgp test failures
Signed-off-by: Lou Berger <lberger@labn.net>
(cherry picked from commit d5d5e3e04fc41b9a89b7ce9049fd322bdbde2e4d)

Conflicts:
	bgpd/bgp_nexthop.c
2016-06-08 21:49:47 -07:00
David Lamparter
3ac45df164 tests: add testcli reference in/out & do DejaGNU
This adds reference in & output for the previously added testcli tool,
to check basic CLI parsing/help functions.  Unlike "testcommands", this
one doesn't depend on compile-time system details.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit d79668fb440ae2689b54f52c076dbd79a8689135)
2016-06-03 20:35:40 +00:00
David Lamparter
2bb57c682e tests: add CLI dummy command-exec tool
This adds some common CLI testtool code as well as a tool that has a
bunch of commands to be poked for their correct processing.

The tool doesn't work correctly from a script at stdin at this point
because the vty code will throw away all buffered when it sees EOF, so
the tail end of the input file is lost.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit db93eec18d8f1e840b32ba2cdf8baf2510f6e1a5)
2016-06-03 20:34:55 +00:00
David Lamparter
9e8da292d1 build: get rid of INCLUDES, use AM_CPPFLAGS
INCLUDES in configure.ac was not used at all, and INCLUDES in
Makefile.am is supposed to be AM_CPPFLAGS these days.

Reduces warnings spewed during bootstrap/autoreconf.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Greg Troxel <gdt@ir.bbn.com>
Acked-by: Feng Lu <lu.feng@6wind.com>
Acked-by: Paul Jakma <paul@jakma.org>
(cherry picked from commit 237aac56960575f6ad2451ba2796d94bd5ae4b33)
2016-06-03 15:46:59 -04:00
Paul Jakma
3c88dab5b8 tests: add more AS4 capability tests + little fixes for couple of GR test cases.
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 321d4130a615445d0f49f41c909c92d5401fd5ff)
2016-05-26 15:33:33 +00:00
Donald Sharp
6a697154ff tests: Fix warnings from test-stream.c
test-stream is generating some compiler warnings

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 6169559976b33a5bf120c806135c76b1b6d943ee)
2016-05-26 15:33:33 +00:00
David Lamparter
9fc3f9b382 tests: fix warnings
While I don't see -Werror being used on tests anytime soon, there's no
reason to keep the warnings in tests unfixed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit c313895dec3c176584d99f7b8684ddc3f9141d88)
2016-05-26 15:33:29 +00:00
David Lamparter
1407b02237 tests: remove --disable-ipv6
With --disable-ipv6 gone, the IPv6 detection logic in the tests is not
needed anymore either.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Paul Jakma <paul@jakma.org>
(cherry picked from commit 85c63b844df4a295a64f37573e0ba08a7cc63659)
2016-05-26 15:25:13 +00:00
David Lamparter
75ee619cf7 tests: fix tests for 1a211cb (missing well-known)
Fix tests/aspathtest.c again, this time by including a NEXT_HOP
attribute (which is out of correct order with AS_PATH, but that doesn't
matter here.)  This satisfies bgp_attr_check(), which after 1a211cb
refuses updates without nexthop attribute.

Fixes: 1a211cb ("one more fix for tightening of check for missing well-known attributes")
Cc: Paul Jakma <paul@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 143637198e333f0c822766b38f9d8cfe75c04e21)
2016-05-26 15:24:51 +00:00
David Lamparter
0b1e756bbf tests: fix tests for 055086f (well-known attr check)
Fix tests/aspathtest.c by including an ORIGIN attribute in the
testcases.  After 055086f "bgpd: well-known attr check only run for
v4/uni, which could cause a crash," we're now checking for it and tests
are failing due to that.

Note that test #11 ("4b AS4_PATH w/o AS_PATH") is no longer accepted as
OK since the function now checks for the existence of an AS_PATH attr.

Fixes: 055086f ("bgpd: well-known attr check only run for v4/uni"...)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit c68f6d9dbb9f910d3ee82e099655fff7c12ef856)
2016-05-26 01:16:32 +00:00
Paul Jakma
46f4a4d21f Add missing GPL headers, and copyright claims that certainly apply.
* Fix (a subset of)? files with non-trivial code that are missing GPL headers.

* A few copyright claims added which I am certain apply, but which I had
  missed out on the original commits.

NB: Copyright claims are not exclusive and the addition of any copyright
claim should not be read as implying a lack of any further claims, or
denying the validity of any other claims.  All those with claims of
copyright over any portion of Quagga are welcome to submit them, ideally as
patches to update copyright strings in files.

(cherry picked from commit 010ebbbca6396f272cc2d50d147dd922dda68213)
2016-05-26 01:06:59 +00:00
Paul Jakma
95bb83054b build: Remove the old PIC/PIE patch, let libtool sort it out
* Remove the old change from '08 to add in PIE arguments at automake level.
  Versions of libtool since then know how to deal with -fpie and do the right
  thing according to whether its building shared or executable objects.
  So just pass '-fpie' as CFLAG and let libtool do its thing.
2016-05-25 20:38:35 -04:00
Daniel Walton
859d388e90 quagga: "set community x:y" needs bounds checking
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-10002

superm-redxp-05# conf t
superm-redxp-05(config)# route-map FOO permit 10
superm-redxp-05(config-route-map)# set community ?
  AA:NN  Community number in AA:NN format (where AA and NN are <0-65535>) or local-AS|no-advertise|no-export|internet or additive
  none   No community attribute
superm-redxp-05(config-route-map)# set community 2:2
superm-redxp-05(config-route-map)# set community 2:70000
% Malformed communities attribute
superm-redxp-05(config-route-map)# set community 70000:2
% Malformed communities attribute
superm-redxp-05(config-route-map)#
2016-04-14 18:16:43 +00:00
Donald Sharp
ebf004583c tests: Fixup startup of tests so they don't core
Tests were not even compiling due to non updated API changes.
Additionally tests were core'ing after compile issue
because the vrf subsystem is being used now and it
needs to be initialized.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-03-18 09:36:04 -04:00
Daniel Walton
41d9cc6a65 quagga: remove babel
Ticket: CM-9274
Reviewed By: sharpd@cumulusnetworks.com
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2016-02-11 08:55:24 -08:00
Daniel Walton
3ffe142a3a Quagga: make check is broken with addpath changes
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-8472

The first as-path is what the original as-path for the test, the second
is what the as-path should look like once all confed SETs and SEQs have
been removed. At the time the test was written quagga did not correctly
remove confed SETs and SEQs but whoever wrote the test didn't notice
this and assumed that the behavior they were seeing was correct so used
that output to populate the second as-path.

Now that we do correctly remove the confed parts these tests fail. So
the fix is to update the second as-path for these two tests so that they
no longer contain any confed SETs/SEQs.
2015-12-11 21:12:56 +00:00
Donald Sharp
d5b77cc20d bgpd: Use actual MULTIPATH_NUM as the limitor
BGP uses a second #define that is equal to MULTIPATH_NUM.  There
is no point in having a different #define.  Just consolidate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-12-08 10:06:33 -08:00
Donald Sharp
4690c7d74c Quagga: prefix2str fixup
During CR for nexthop upstream it was noticed that usage
of prefix2str was not consistent.  This fixes this problem

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-11-23 13:31:11 -08:00
Donald Sharp
87d4a78163 bgpd: backout change of bm->master and master
Upstream does wanted the reverse of what was done
in this patch.  Back out the patch.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-13 13:00:55 -07:00
Donald Sharp
7dfe5b9499 bgpd: fix using of two pointers for struct thread_master
bgp is using both bm->master and master pointers interchangebly
for thread manipulation.  Since they are the same thing consolidate
to one pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-09-23 18:38:27 -07:00
Donald Sharp
4140ca4d15 lib: zclient.c remove extern struct thread_master *
zclient.c depended upon link time inclusion of a
extern struct thread_master *master.  This is a violation of the
namespace of the calling daemon.  If a library needs the pointer
pass it in and save it for future use.

This code change also makes the zclient code consistent with
the other lib functions that need to schedule work on your behalf

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2015-09-23 13:26:56 -07:00
Donald Sharp
2a3fa5d7c4 AS_PATH comparison is broken if CONFED_AS_SEQ are present 2015-05-19 18:29:18 -07:00
Donald Sharp
3f9c7369f7 BGP: Add dynamic update group support
This patch implements the 'update-groups' functionality in BGP. This is a
function that can significantly improve BGP performance for Update generation
and resultant network convergence. BGP Updates are formed for "groups" of
peers and then replicated and sent out to each peer rather than being formed
for each peer. Thus major BGP operations related to outbound policy
application, adj-out maintenance and actual Update packet formation
are optimized.

BGP update-groups dynamically groups peers together based on configuration
as well as run-time criteria. Thus, it is more flexible than update-formation
based on peer-groups, which relies on operator configuration.

[Note that peer-group based update formation has been introduced into BGP by
Cumulus but is currently intended only for specific releases.]

From 11098af65b2b8f9535484703e7f40330a71cbae4 Mon Sep 17 00:00:00 2001
Subject: [PATCH] updgrp commits
2015-05-19 18:03:47 -07:00
Donald Sharp
7c8ff89e93 Multi-Instance OSPF Summary
——————————————-------------

- etc/init.d/quagga is modified to support creating separate ospf daemon
  process for each instance. Each individual instance is monitored by
  watchquagga just like any protocol daemons.(requires initd-mi.patch).

- Vtysh is modified to able to connect to multiple daemons of the same
  protocol (supported for OSPF only for now).

- ospfd is modified to remember the Instance-ID that its invoked with. For
  the entire life of the process it caters to any command request that
  matches that instance-ID (unless its a non instance specific command).
  Routes/messages to zebra are tagged with instance-ID.

- zebra route/redistribute mechanisms are modified to work with
  [protocol type + instance-id]

- bgpd now has ability to have multiple instance specific redistribution
  for a protocol (OSPF only supported/tested for now).

- zlog ability to display instance-id besides the protocol/daemon name.

- Changes in other daemons are to because of the needed integration with
  some of the modified APIs/routines. (Didn’t prefer replicating too many
  separate instance specific APIs.)

- config/show/debug commands are modified to take instance-id argument
  as appropriate.

Guidelines to start using multi-instance ospf
---------------------------------------------

The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.

To enable multiple instances, do the following:

     1. service quagga stop
     2. Modify /etc/quagga/daemons to add instance-ids of each desired
        instance in the following format:
        ospfd=“yes"
        ospfd_instances="1,2,3"
	assuming you want to enable 3 instances with those instance ids.
     3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
        and ospfd-3.conf.
     4. service quagga start/restart
     5. Verify that the deamons are started as expected. You should see
        ospfd started with -n <instance-id> option.
     	ps –ef | grep quagga
     	With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
	ospfd-<instance-id>/vty to each instance.
     6. vtysh to work with instances as you would with any other deamons.
     7. Overall most quagga semantics are the same working with the instance
     	deamon, like it is for any other daemon.

NOTE:
     To safeguard against errors leading to too many processes getting invoked,
     a hard limit on number of instance-ids is in place, currently its 5.
     Allowed instance-id range is <1-65535>
     Once daemons are up, show running from vtysh should show the instance-id
     of  each daemon as 'router ospf <instance-id>’  (without needing explicit
     configuration)
     Instance-id can not be changed via vtysh, other router ospf configuration
     is allowed as before.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 18:03:42 -07:00
Donald Sharp
16286195e4 Overhual BGP debugs
Summary of changes
- added an option to enable keepalive debugs for a specific peer
- added an option to enable inbound and/or outbound updates debugs for a specific peer
- added an option to enable update debugs for a specific prefix
- added an option to enable zebra debugs for a specific prefix
- combined "deb bgp", "deb bgp events" and "deb bgp fsm" into "deb bgp neighbor-events". "deb bgp neighbor-events" can be enabled for a specific peer.
- merged "deb bgp filters" into "deb bgp update"
- moved the per-peer logging to one central log file. We now have the ability to filter all verbose debugs on a per-peer and per-prefix basis so we no longer need to keep log files per-peer. This simplifies troubleshooting by keeping all BGP logs in one location.  The use
r can then grep for the peer IP they are interested in if they wish to see the logs for a specific peer.
- Changed "show debugging" in isis to "show debugging isis" to be consistent with all other protocols.  This was very confusing for the user because they would type "show debug" and expect to see a list of debugs enabled across all protocols.
- Removed "undebug" from the parser for BGP.  Again this was to be consisten with all other protocols.
- Removed the "all" keyword from the BGP debug parser.  The user can now do "no debug bgp" to disable all BGP debugs, before you had to type "no deb all bgp" which was confusing.

The new parse tree for BGP debugging is:

deb bgp as4
deb bgp as4 segment
deb bgp keepalives [A.B.C.D|WORD|X:X::X:X]
deb bgp neighbor-events [A.B.C.D|WORD|X:X::X:X]
deb bgp nht
deb bgp updates [in|out] [A.B.C.D|WORD|X:X::X:X]
deb bgp updates prefix [A.B.C.D/M|X:X::X:X/M]
deb bgp zebra
deb bgp zebra prefix [A.B.C.D/M|X:X::X:X/M]
2015-05-19 17:58:12 -07:00
Donald Sharp
5e242b0dd3 cluster-id length equality for multipath
A fat tree topology running IBGP gets into two issues with anycast address
routing. Consider the following topology:

        R9   R10
          x x
  R3   R4     R7   R8
     x           x
  R1   R2     R5   R6
  |    |      |    |
 10/8 10/8  10/8   S

Let's remind ourselves of BGP decision process steps:

1. Highest Local Preference
2. Shortest AS Path Length
3. Lowest Origin Type
4. Lowest MED (Multi-Exit Discriminator)
5. Prefer External to Internal
6. Closest Egress (Lowest IGP Distance)
7. Tie Breaking (Lowest-Router-ID)
8. Tie Breaking (Lowest-cluster-list length)
9. Tie Breaking (Lowest-neighbor-address)

Without any policies, steps 1-6 will almost always evaluate identically for
all paths received on any router in the above topology. Let's assume that
the router-ids follow the following inequality: R1 < R2 < R5 < R6. Owing to
the 7th step above, all routers will now choose R1's path as the best. This
is undesirable. As an example, traffic from S to 10/8 will follow the path
S -> R6 -> R7 -> R9 -> R4 -> R2 -> 10/8 instead of S -> R6 -> R7 -> R5 -> 10/8.
Furthermore, once R7 (& R8) chooses R1's path as the best, it would withdraw
its path learned through (R5, R6) from (R9, R10). This leads to inefficient
load balancing - e.g. R9 can't do ECMP across all available egresses -
(R1, R2, R5).

The patch addresses these issues by noting that that cluster list is always
carried along with the routes and its length is a good indicator of IBGP
hops. It thus makes sense to compare that as an extension to metric after
step 6. That automatically ensures correct multipath computation.

Unfortunately a partial deployment of this in a generic topology (note:
fat-tree/clos topologies work fine) may lead to potential loops. It needs
to be looked into.

Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-19 17:40:31 -07:00
David Lamparter
8b16ed74fa tests/bgpd: don't hardcode error number (fix f57000c)
f57000c ("bgpd: don't send NOTIFY twice for malformed attrs") introduces
BGP_ATTR_PARSE_ERROR_NOTIFYPLS as additional error code that implies the
caller should sent a NOTIFY and convert it to BGP_ATTR_PARSE_ERROR.
Sadly, the latter was hardcoded in bgp_mp_attr_test.c, which now didn't
consider the new value to be an error.

Make the testcase treat all nonzero values as error without discern.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-08-18 01:49:17 +02:00
David Lamparter
6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

Patches can be adapted simply by:
	sed -e 's%^L%%' -i filename.patch
(you can type page feeds in some environments with Ctrl-V Ctrl-L)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-04 06:58:02 +02:00
Christian Franke
ba32db1e85 tests: Add tests for timers
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-22 21:15:11 +02:00
Christian Franke
6f2a67031c ospfd/ospf_vty.c: use keyword cmd style
Use the new keyword command style for:

  - default-information originate
  - distance ospf
  - redistribute

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 20:21:42 +02:00
Christian Franke
cd40b329a2 lib/command.c: rewrite command matching/parsing
Add support for keyword commands.

Includes new documentation for DEFUN() in lib/command.h, for preexisting
features as well as new keyword specification.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 20:21:41 +02:00
David Lamparter
e712d0e366 tests: fix build & disable testcommands
The perils of having tests, the test wasn't tested thoroughly enough...
Fixup various automake problems, and then disable it since it depends on
configure parameters in its current version.

For 0.99.24 we can ship a static copy of vtysh_cmd.c and have it
reenabled.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 20:21:19 +02:00
Christian Franke
8f399b0e4f tests: add a test program for lib/command.c
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 17:38:29 +02:00
David Lamparter
4d474fa329 lib: fix backtraces broken by 837d16c...
837d16c ("*: use array_size() helper macro") accidentally changed one of
the expressions in the backtrace code, which afterwards read:

zlog_backtrace_sigsafe():
  if (((size = backtrace(array,array_size(array)) <= 0) ||

which boils down to: (size = backtrace(...)  <= 0).  The braces were
intended to go:      (size = backtrace(...)) <= 0.

All in all, this makes a nice textbook example of the original author
being too clever (trying to save a single line by pulling the assignment
into the condition) and the next person touching the code tripping over
it...

This code occurs another time in zlog_backtrace() where it is actually
correct.  Pulling out the assignment nonetheless.  Also, new test
program.

Cc: Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Cc: Balaji.G <balajig81@gmail.com>
Cc: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-03-21 06:28:48 +01:00
David Lamparter
a83a1e9c2f build: fix tests/prng.h missing from dist
broken by fa713d9... "zebra: rework recursive route resolution", and I
forgot to squash the fix into that.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-10-22 11:35:48 -07:00
Christian Franke
fa713d9ee5 zebra: rework recursive route resolution
Change the datastructure for recursive routes. This brings the following
benefits:

By using struct nexthop also to store nexthops obtained by recursive
resolution, we can get rid of quite a bit of code duplication in the fib
management. (rt_netlink, rt_socket, ...)

With the new datastructure we can make use of all available paths when
recursive routes are resolved with multipath routes.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-09-19 18:04:40 +02:00
Christian Franke
d77102025a tests: don't build tests unless make check is run
Use check_PROGRAMS instead of noinst_PROGRAMS in tests/Makefile.am
to build the tests only when make check is actually run.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2013-07-15 08:50:38 -04:00
Christian Franke
1bf0ca9a07 tests: fix Makefile.am so it works with BSD make
The export statement is specific to GNU make and breaks the build
with BSD make. I couldn't observe any difference in behaviour
between having the export present and absent, therefore, just remove it.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2013-07-09 12:26:46 -04:00
David Lamparter
c69905b673 tests: DejaGNU libzebra
Wrap the few libzebra test programs we have up for DejaGNU.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-04-14 16:01:19 +02:00
David Lamparter
5bb7e4d12b tests: DejaGNU bgpd
this just wraps the existing test programs in expect wrappers that make
their results usable to DejaGNU.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-04-14 16:01:11 +02:00
David Lamparter
f281ab9752 tests: add DejaGNU framework
DejaGNU seems to be the 'standard' GNU test framework (which by itself
doesn't say much), but it seems relatively usable and the "remote
system" capabilities might come in handy for virtualisation-based tests
for kernel interactions or something.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-04-14 16:01:05 +02:00
David Lamparter
c095185c26 tests: make --disable-bgpd kill bgpd tests too
bgpd tests don't compile or run with --disable-bgpd, let's catch this in
the Makefile.

Reported-by: Joachim Nilsson <troglobit@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-04-09 17:05:37 +02:00
David Lamparter
aeef13b0d5 tests: fix missing init in bgp_mp_attr_test.c
turns out, bgp_mp_reach_parse really doesn't like getting garbage
attribute input.  In particular, attr->extra better be NULL or we
merrily go trample random places (like our stack).

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-02-01 17:55:04 +01:00
David Lamparter
1cb9cf062e tests: update & extend AS_PATH tests
NB: these tests test for current implementation state, not for RFC
conformance.  In particular, behaviour with confederations in AS4_PATH
as well as reconcilation of short AS_PATH + AS4_PATH is currently NOT
conforming to RFC 4893/6793.

* tests/aspath_test.c:  add capability to put both AS4_PATH & AS_PATH,
  add test for AS4_PATH w/o AS_PATH, update confederation test

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2013-02-01 17:55:04 +01:00
Leonid Rosenboim
8d083b9ec5 build: update .gitignore for all test programs 2013-01-16 01:10:24 +01:00
David Lamparter
326fe3df2c tests: fix missing array_size() include
* tests/test-sig.c: add #include "lib/memory.h" to get array_size()

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-03 09:13:23 -07:00
Avneesh Sachdev
d1d3ac9bad build: reorder libraries to address linker error
The linker on some systems (for example, Ubuntu 12.04 LTS x86_64)
appears to be sensitive to the order in which libraries are
specified. On these systems, if a library 'A' depends on a library
'B', it has to be specified before 'B' when linking an executable.

  * zebra/Makefile.am: Make sure LIBCAP comes after libzebra.

  * tests/Makefile.am: Ensure libm comes after libbgp.

Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-11-01 23:03:24 -07:00
Balaji.G
837d16ccbe *: use array_size() helper macro
Use the array_size() helper macro.  Replaces several instances of local
macros with the same definition.

Reviewed-by: Scott Feldman <sfeldma@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-10-25 10:15:59 -07:00
Avneesh Sachdev
28971c8cb1 lib/table: add route_table_get_next() and iterator
* lib/table.[ch]

    - Add a function (route_table_get_next()) to get the route_node in
      a tree that succeeds a given prefix in iteration order.

      This allows one to reliably walk nodes in a tree while allowing
      modifications, and is useful for achieving scale and
      performance. Other approaches are also possible -- the main plus
      point of this one is that it does not require any state about
      the walk to be maintained in the table data structures.

    - Add an iterator for walking the nodes in a tree. This introduces
      a new structure (route_table_iter_t) and the following main
      functions.

        route_table_iter_init()
        route_table_iter_pause()
        route_table_iter_next()
        route_table_iter_cleanup()

      The iterator normally uses node pointers and the existing
      route_next() function to walk nodes efficiently. When an
      iteration is 'paused' with route_table_iter_pause(), it stores
      the last prefix processed. The next call to
      route_table_iter_next() transparently invokes
      route_table_get_next() with the prefix to resume iteration.

  * bgpd/bgp_table.[ch]

    Add wrappers for the new table features described above.

  * tests/table_test.c

    Add tests for the new table code.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-09-26 21:50:48 +02:00
Vincent Bernat
9e7a548ce4 build: allow configure and build in a separate directory
Some .h files in lib/ are autogenerated. The search path should
include the build directory and the source directory. They usually
match but sometimes, they may be different. For example:

 $ mkdir build
 $ cd build
 $ ../configure
 $ make
2012-06-25 19:03:23 +02:00
Paul Jakma
c9e4f86236 tests: BGP unit tests to set BGP_OPT_NO_LISTEN so they can run
BGP tests had been broken by auto-creation of listen socket. This allows
them to run at least, though at least 1 test seems to have other breakage,
aspath_test.
2012-06-19 13:40:22 +01:00
Paul Jakma
1dba254e10 tests: Fix some compile errors and warnings
* aspath_test.c: match changes in aspath_unintern. Fix printf size_t warning.
* bgp_capability_test.c: compile warnings.
* bgp_mp_attr_test.c: update for attr parser context struct
* ecommunity_test.c: ecommunity_free/ecommunity
* test-checksum.c: some unused vars and funcs without need of prototypes.
2012-05-02 11:02:10 +01:00
Paul Jakma
6ebeebb506 Revert "tests: disable broken tests/bgp_mp_attr_test.c"
This reverts commit d78e2b8b56. Next 2
commits fix it.
2012-05-02 11:02:10 +01:00
David Lamparter
d78e2b8b56 tests: disable broken tests/bgp_mp_attr_test.c
it doesn't compile currently; it'll be fixed after the 0.99.21 release.

  * tests/bgp_mp_attr_test.c: wrap in #if 0 for now

Signed-off-by: David Lamparter <equinox@diac24.net>
2012-05-01 18:53:16 +02:00
Avneesh Sachdev
3cf6c2b4e4 Merge branch 'quagga' into google-bgp-multipath
Conflicts:
	bgpd/bgp_route.c
2012-04-09 00:25:15 -07:00
Denis Ovsienko
05e54ee3df build: delete .cvsignore files 2011-12-13 14:27:01 +04:00
Denis Ovsienko
565b828dc0 bgpd: add flag checks for MP_(UN)REACH_NLRI
* bgp_attr.[ch]
  * bgp_mp_reach_parse(): add extra arguments and a uniform flag
    check block
  * bgp_mp_unreach_parse(): idem
  * bgp_attr_parse(): provide extra arguments
* bgp_mp_attr_test.c
  * parse_test(): justify respective calls
2011-10-17 19:07:02 +04:00
Denis Ovsienko
42e6d745d1 bgpd: more SAFI fixes
(with resolved conflict in bgpd/bgp_packet.c)

Two macros resolving to the same integer constant broke a case block and
a more thorough merge of BGP_SAFI_VPNV4 and BGP_SAFI_VPNV6 was
performed.

* bgpd.h: MPLS-labeled VPN SAFI is AFI-independent, switch to single
* macro
* bgp_capability_test.c: update test data
* bgp_mp_attr_test.c: idem
* bgp_route.c: (bgp_maximum_prefix_overflow, bgp_table_stats_vty) update
  macro and check conditions (where appropriate)
* bgp_packet.c: (bgp_route_refresh_send, bgp_capability_send,
  bgp_update_receive, bgp_route_refresh_receive): idem
* bgp_open.c: (bgp_capability_vty_out, bgp_afi_safi_valid_indices,
  bgp_open_capability_orf, bgp_open_capability): idem
* bgp_attr.c: (bgp_mp_reach_parse, bgp_packet_attribute,
  bgp_packet_withdraw): idem
2011-09-29 22:14:11 +04:00
Denis Ovsienko
b82cdeb18f delete CVS keywords 2011-09-27 21:34:26 +04:00
Josh Bailey
de8d5dff15 bgpd: Adds support to mark up the BGP rib table entry with multipath
information based on the multipath list (mp_list) generated during
the best path calculation. Display "multipath" for paths that are
multipath and also on bestpath if the route is multipath. Flag a
best path with the BGP_INFO_MULTIPATH_CHG if the multipath
set has changed since the last update. This can be used to trigger
updates to zebra and peers.

The multipath markup is a lazily allocated bgp_info_mpath structure
that is added to the best path and any multipaths. The mpath structures
are linked together with the best path element at the head and the
other elements ordered by nexthop and then by peer address. This
markup scheme is updated by calling bgp_info_mpath_update() and passing
in a new mp_list the the current multipath set. There are additional
API's for walking the multipath set, querying the count of multipaths,
and for cleaning up the multipath markup information when freeing path
information.

* bgpd/bgp_mpath.c
  * bgp_info_mpath_new(): Allocation of new mpath element
  * bgp_info_mpath_free(): Release memory for mpath element
  * bgp_info_mpath_get(): Access mpath element of path. Allocate memory
    on-demand
  * bgp_info_mpath_enqueue(): Enqueue a path onto the multipath list
  * bgp_info_mpath_dequeue(): Remove a path from the multipath list
  * bgp_info_mpath_first(): Return first path on the multipath list
  * bgp_info_mpath_next(): Return next path on the multipath list
  * bgp_info_mpath_count(): Return the number of paths on the multipath list
  * bgp_info_mpath_count_set(): Set the number of paths on the multipath list
  * bgp_info_mpath_update(): Update multipath markup on bgp route table entry
    and flag any changes. Emit 'debug bgp event' output on any multipath
    change.
* bgpd/bgp_mpath.h
  * struct bgp_info_mpath: Information added to a bgp_info path to record
    multipath information
  * External declarations for new functions in bgp_mpath.c
* bgpd/bgp_route.c
  * bgp_info_free(): Free mpath memory when freeing path information
  * bgp_info_reap(): Dequeue path from multipath queue before deleting it
  * bgp_best_selection(): Calls bgp_info_mpath_update() with latest
    mp_list to mark-up rib table entry
  * bgp_vty_out_detail(): Add display of multipath flag for a path. Also
    display 'multipath' for bestpath if it is a multipath route
* bgpd/bgp_route.h
  * struct bgp_info: Add pointer to bgp_info_mpath information
  * Add flags to mark a path as multipath (BGP_INFO_MULTIPATH) and
    to mark bestpath if multipath information has changed
    (BGP_INFO_MULTIPATH_CHG)
* lib/memtypes.c
  * Add MTYPE_BGP_MPATH_INFO for allocating memory for bgp_info_mpath
* tests/bgp_mpath_test.c
  * Add test case for bgp_info_mpath_update() and supporting functions
2011-07-20 20:46:01 -07:00
Josh Bailey
96450faf33 bgpd: Adds equal-paths check to path comparison. Paths that are
equal to the best path are accumulated onto an ordered list (mp_list)
if maximum-paths is configured. A future commit will add the
multipath markup to the BGP rib table based on the mp_list. Add
unit test for the added mp_list functions.

Deterministic MED is not supported in this commit, it will be
added later.

* bgpd/bgp_aspath.c
  * Make aspath_cmp() an external symbol so it can be used in
    equivalent paths check
* bgpd/bgp_aspath.h
  * Add extern declaration of aspath_cmp()
* bgpd/bgp_mpath.c
  * bgp_info_nexthop_cmp(): Compares nexthops of two paths
  * bgp_info_mpath_cmp(): Compare function to order multipaths by
    nexthop and then by peer address
  * bgp_mp_list_init(): Initialize a list with the multipath order function
  * bgp_mp_list_clear(): Clear out the mp_list
  * bgp_mp_list_add(): Add a multipath to mp_list
* bgpd/bgp_mpath.h
  * External declarations for above added functions in bgp_mpath.c
* bgpd/bgp_route.c
  * bgp_info_cmp(): Add equivalent paths result (paths_eq). If eBGP
    paths are equal down to IGP metric check, flag as equal if peer AS
    matches. Similarly for iBGP paths but compare full AS_PATH.
  * bgp_best_selection(): If multipath is enabled, accumulate equivalent paths
    in mp_list. Add debug bgp event output to see result (will be filtered
    later to display only when change occurs)
  * bgp_process_rsclient(): Pass multipath config to bgp_best_selection()
  * bgp_process_main(): Pass multipath config to bgp_best_selection()
* tests/bgp_mpath_test.c
  * Add unit test case for bgp_mp_list functions
2011-07-20 20:45:12 -07:00
Josh Bailey
42ea68512f bgpd: add bgp_mpath_test.c
* tests/bgp_mpath_test.c
  * New file with test framework for testing BGP multipath
  * Add test for CLI support functions
* tests/Makefile.am
  * Add new testbgpmpath target
2011-07-20 20:44:23 -07:00
Paul Jakma
b881c7074b bgpd: Implement revised error handling for partial optional/trans. attributes
* BGP error handling generally boils down to "reset session". This was fine
  when all BGP speakers pretty much understood all BGP messages. However
  the increasing deployment of new attribute types has shown this approach
  to cause problems, in particular where a new attribute type is "tunneled"
  over some speakers which do not understand it, and then arrives at a speaker
  which does but considers it malformed (e.g. corruption along the way, or
  because of early implementation bugs/interop issues).

  To mitigate this drafts before the IDR (likely to be adopted) propose to
  treat errors in partial (i.e.  not understood by neighbour), optional
  transitive attributes, when received from eBGP peers, as withdrawing only
  the NLRIs in the affected UPDATE, rather than causing the entire session
  to be reset.  See:

   http://tools.ietf.org/html/draft-scudder-idr-optional-transitive

* bgp_aspath.c: (assegments_parse) Replace the "NULL means valid, 0-length
  OR an error" return value with an error code - instead taking
  pointer to result structure as arg.
  (aspath_parse) adjust to suit previous change, but here NULL really
  does mean error in the external interface.
* bgp_attr.h (bgp_attr_parse) use an explictly typed and enumerated
  value to indicate return result.
  (bgp_attr_unintern_sub) cleans up just the members of an attr, but not the
  attr itself, for benefit of those who use a stack-local attr.
* bgp_attr.c: (bgp_attr_unintern_sub) split out from bgp_attr_unintern
  (bgp_attr_unintern) as previous.
  (bgp_attr_malformed) helper function to centralise decisions on how to
  handle errors in attributes.
  (bgp_attr_{aspathlimit,origin,etc..}) Use bgp_attr_malformed.
  (bgp_attr_aspathlimit) Subcode for error specifc to this attr should be
  BGP_NOTIFY_UPDATE_OPT_ATTR_ERR.
  (bgp_attr_as4_path) be more rigorous about checks, ala bgp_attr_as_path.
  (bgp_attr_parse) Adjust to deal with the additional error level that
  bgp_attr_ parsers can raise, and also similarly return appropriate
  error back up to (bgp_update_receive). Try to avoid leaking as4_path.
* bgp_packet.c: (bgp_update_receive) Adjust to deal with BGP_ATTR_PARSE_WITHDRAW
  error level from bgp_attr_parse, which should lead to a withdraw, by
  making the attribute parameter in call to (bgp_nlri_parse) conditional
  on the error, so the update case morphs also into a withdraw.
  Use bgp_attr_unintern_sub from above, instead of doing this itself.
  Fix error case returns which were not calling bgp_attr_unintern_sub
  and probably leaking memory.
* tests/aspath_test.c: Fix to work for null return with bad segments
2011-03-21 13:51:14 +00:00
Paul Jakma
50ef565e4e tests: Extend aspath_test.c with cases for invalid segments & attributes
* aspath_test.c: Add more test cases. In particular ones to cover the
  last invalid-segment problem. Also add ability to specify aspath attribute
  headers and test them somewhat.

  NB: It's obvious this test has not been run for a year by anyone, despite
  2 non-trivial commits to bgpd aspath code.
2011-03-21 13:51:14 +00:00
Chris Hall
cddb8112b8 bgpd: fix handling of AS path data
* bgpd/bgp_aspath.c
  * assegments_parse(): add handling of AS4_PATH input, update bounds
    checks, add check for AS segment type
  * aspath_parse(): add handling of AS4_PATH input, expect
    assegments_parse() to do length checking
  * aspath_empty(): update for the new function prototype
* bgpd/bgp_aspath.h: ditto
* tests/aspath_test.c: ditto
* bgpd/bgp_attr.c
  * bgp_attr_aspath(): add handling of AS4_PATH input, update flags
    checks, change returned type
  * bgp_attr_as4_path(): discard, superseded by bgp_attr_aspath()
  * bgp_attr_parse(): update respectively
2010-08-09 22:31:37 +04:00
Stephen Hemminger
065de90380 all: check return value from daemon() call
* */*main.c: (main) Current versions of Gcc warn if the return value for
  daemon() is not checked.  So add a simple test and exit on failure.
2009-08-13 10:21:13 +01:00
Joakim Tjernlund
439c52f190 Add test for Internet checksum.
Add 2 impl. of the Internet Checksum. One new optimized nad
one form RFC 1071. Turns out that the current Quagga in_cksum()
is buggy. On Big Endian routers it miscalculates odd sized buffers.
2009-06-25 15:36:39 +01:00
Paul Jakma
5d4b8cf2fa [lib] Switch Fletcher checksum back to old ospfd version
* lib/checksum.c: (fletcher_checksum) Switch the second phase of the checksum
  back to the old ospfd logic.

  The isisd-derived version:

  a) is very hard to follow
  b) had some kind of subtle bug that caused it be wrong when c0=0 and c1=254
     (potentially fixable by doing the mods before adjusting x and y)

  Additionally:

  - explicitely cast expressions using non-internal variables to int, to ensure
    the result is signed.
  - defensively change the length argument to 'size_t', to ensure the code
    works with that argument being unsigned..

  Thanks to Joakim Tjernlund for the investigative work into this bug.

* tests/test-checksum.c: new file to exercise the checksum code.
2008-11-16 18:47:02 +00:00
Paul Jakma
d68cbf9261 [administrivia] Git should ignore backup files and .loT files 2008-08-22 20:00:46 +01:00
Paul Jakma
3998bfd766 [trivia] Remove ChangeLog files, as this data is now maintained in SCM 2008-08-22 19:57:22 +01:00
Paul P Komkoff Jr
46bc0e432e [build] Test for GNU-style PIE support in toolchain and enable
2008-08-13 Paul P Komkoff Jr <i@stingr.net>

	* configure.ac: add a configure flag and autoconf macro, which will
	  determine if your toolchain supports PIE.
	* */Makefile.am: add corresponding CFLAGS and LDFLAGS into
	  appropriate places.

Signed-off-by: Paul Jakma <paul@quagga.net>
2008-08-22 19:52:12 +01:00
Paul Jakma
3c5a0a4f8f [administrivia] Add .gitignore files, based on .cvsignores. 2008-08-22 19:49:33 +01:00
Paul Jakma
1eab26bbc6 [tests] BGP MP_(UN)REACH_NLRI unit tests (actual file..)
2008-06-07 Paul Jakma <paul@jakma.org

	* bgp_mp_attr_test.c: MP_(UN)REACH_NLRI unit tests
2008-06-07 20:44:30 +00:00
Paul Jakma
343f720b34 [tests] BGP MP_(UN)REACH_NLRI unit tests
2008-06-07 Paul Jakma <paul@jakma.org

	* bgp_mp_attr_test.c: MP_(UN)REACH_NLRI unit tests
2008-06-07 20:32:38 +00:00
Paul Jakma
d38e8d63fd [tests:bgp] Further tests for 0 sized as_path segments
2008-02-23 Paul Jakma <paul.jakma@sun.com>

	* aspath_test.c: Test for 0-ASN sequences that still have data.
2008-02-23 16:57:03 +00:00
Paul Jakma
370b64a2ad [bgpd] Fix number of DoS security issues, restricted to configured peers.
2007-12-22 Paul Jakma <paul.jakma@sun.com>

	* Fix series of vulnerabilities reported by "Mu Security
	  Research Team", where bgpd can be made to crash by sending
	  malformed packets - requires that bgpd be configured with a
	  session to the peer.
	* bgp_attr.c: (bgp_attr_as4_path) aspath_parse may fail, only
	  set the attribute flag indicating AS4_PATH if we actually managed
	  to parse one.
	  (bgp_attr_munge_as4_attrs) Assert was too general, it is possible
	  to receive AS4_AGGREGATOR before AGGREGATOR.
	  (bgp_attr_parse) Check that we have actually received the extra
	  byte of header for Extended-Length attributes.
	* bgp_attr.h: Fix BGP_ATTR_MIN_LEN to account for the length byte.
	* bgp_open.c: (cap_minsizes) Fix size of CAPABILITY_CODE_RESTART,
	  incorrect -2 left in place from a development version of as4-path
	  patch.
	* bgp_packet.c: (bgp_route_refresh_receive) ORF length parameter
	  needs to be properly sanity checked.
	* tests/bgp_capability_test.c: Test for empty capabilities.
2007-12-22 16:49:52 +00:00
Paul Jakma
5b5bfb8c06 [tests] Forgot to commit ecommunity_tests.c 2007-10-18 16:33:08 +00:00
Paul Jakma
0b2aa3a0a8 [bgpd] Merge AS4 support
2007-10-14 Paul Jakma <paul.jakma@sun.com>

	* NEWS: Note that MRT dumps are now version 2
	* (general) Merge in Juergen Kammer's AS4 patch.

2007-09-27 Paul Jakma <paul.jakma@sun.com>

	* bgp_aspath.c: (assegment_normalise) remove duplicates from
	  from sets.
	  (aspath_reconcile_as4) disregard a broken part of the RFC around
	  error handling in path reconciliation.
	* aspath_test.c: Test dupe-weeding from sets.
	  Test that reconciliation merges AS_PATH and AS4_PATH where
	  former is shorter than latter.

2007-09-26 Paul Jakma <paul.jakma@sun.com>

	* aspath_test.c: Test AS4_PATH reconcilation where length
	  of AS_PATH and AS4_PATH is same.

2007-09-25 Paul Jakma <paul.jakma@sun.com>

	* bgp_open.c: (peek_for_as4_capability) Fix to work.
	* bgp_packet.c: (bgp_open_receive) Fix sanity check of as4.
	* tests/bgp_capability_test.c: (general) Extend tests to validate
	  peek_for_as4_capability.
	  Add test of full OPEN Option block, with multiple capabilities,
	  both as a series of Option, and a single option.
	  Add some crap to beginning of stream, to prevent code depending
	  on getp == 0.

2007-09-18 Paul Jakma <paul.jakma@sun.com>

	* bgp_open.c: (bgp_capability_as4) debug printf inline with others.
	  (peek_for_as4_capability) There's no need to signal failure, as
	  failure is better dealt with through full capability parser -
	  just return the AS4, simpler.
	* bgp_packet.c: (bgp_open_receive) Update to match
	  peek_for_as4_capability change.
	  Allow use of BGP_AS_TRANS by 2b speakers.
	  Use NOTIFY_OPEN_ERR rather than CEASE for OPEN parsing errors.
	  (bgp_capability_msg_parse) missing argument to debug print
	  (bgp_capability_receive) missing return values.
	* tests/bgp_capability_test.c: (parse_test) update for changes to
	  peek_for_as4_capability

2007-07-25 Paul Jakma <paul.jakma@sun.com>

	* Remove 2-byte size macros, just make existing macros take
	  argument to indicate which size to use.
	  Adjust all users - typically they want '1'.
	* bgp_aspath.c: (aspath_has_as4) New, return 1 if there are any
	  as4's in a path.
	  (aspath_put) Return the number of bytes actually written, to
	  fix the bug Juergen noted: Splitting of segments will change
	  the number of bytes written from that already written to the
	  AS_PATH header.
	  (aspath_snmp_pathseg) Pass 2-byte flag to aspath_put. SNMP
	  is still defined as 2b.
	  (aspath_aggregate) fix latent bug.
	  (aspath_reconcile_as4) AS_PATH+NEW_AS_PATH reconciliation
	  function.
	  (aspath_key_make) Hash the AS_PATH string, rather than
	  just taking the addition of assegment ASes as the hash value,
	  hopefully sligthly more collision resistant.
	  (bgp_attr_munge_as4_attrs) Collide the NEW_ attributes
	  together with the OLD 2-byte forms, code Juergen
	  had in bgp_attr_parse but re-organised a bit.
	  (bgp_attr_parse) Bunch of code from Juergen moves
	  to previous function.
	  (bgp_packet_attribute) Compact significantly by
	  just /always/ using extended-length attr header.
	  Fix bug Juergen noted, by using aspath_put's
	  (new) returned size value for the attr header rather
	  than the (guesstimate) of aspath_size() - the two could
	  differ when aspath_put had to split large segments, unlikely
	  this bug was ever hit in the 'wild'.
	  (bgp_dump_routes_attr) Always use extended-len and
	  use aspath_put return for header length. Output 4b ASN
	  for AS_PATH and AGGREGATOR.
	* bgp_ecommunity.c: (ecommunity_{hash_make,cmp}) fix
	  hash callback declarations to match prototypes.
	  (ecommunity_gettoken) Updated for ECOMMUNITY_ENCODE_AS4,
	  complete rewrite of Juergen's changes (no asdot support)
	* bgp_open.c: (bgp_capability_as4) New, does what it says
	  on the tin.
	  (peek_for_as4_capability) Rewritten to use streams and
	  bgp_capability_as4.
	* bgp_packet.c: (bgp_open_send) minor edit
	  checked (in the abstract at least) with Juergen.
	  Changes are to be more accepting, e.g, allow AS_TRANS on
	  a 2-byte session.
	* (general) Update all commands to use CMD_AS_RANGE.
	* bgp_vty.c: (bgp_clear) Fix return vals to use CMD_..
	  Remove stuff replicated by VTY_GET_LONG
	  (bgp_clear_vty) Return bgp_clear directly to vty.
	* tests/aspath_test.c: Exercise 32bit parsing. Test reconcile
	  function.
	* tests/ecommunity_test.c: New, test AS4 ecommunity changes,
	  positive test only at this time, error cases not tested yet.

2007-07-25 Juergen Kammer <j.kammer@eurodata.de>

	* (general) AS4 support.
	* bgpd.h: as_t changes to 4-bytes.
	* bgp_aspath.h: Add BGP_AS4_MAX and BGP_AS_TRANS defines.
	* bgp_aspath.c: AS_VALUE_SIZE becomes 4-byte, AS16_VALUE_SIZE
	  added for 2-byte.
	  Add AS16 versions of length calc macros.
	  (aspath_count_numas) New, count number of ASes.
	  (aspath_has_as4) New, return 1 if there are any as4's in a
	  path.
	  (assegments_parse) Interpret assegment as 4 or 2 byte,
	  according to how the caller instructs us, with a new
	  argument.
	  (aspath_parse) Add use32bit argument to pass to
	  assegments_parse. Adjust all its callers to pass 1, unless
	  otherwise noted.
	  (assegment_data_put) Adjust to be able to write 2 or 4 byte
	  AS, according to new use32bit argument.
	  (aspath_put) Adjust to write 2 or 4.
	  (aspath_gettoken) Use a long for passed in asno.
	* bgp_attr.c: (attr_str) Add BGP_ATTR_AS4_PATH and
	  BGP_ATTR_AS4_AGGREGATOR.
	  (bgp_attr_aspath) Call aspath_parse with right 2/4 arg, as
	  determined by received-capability flag.
	  (bgp_attr_aspath_check) New, code previously in attr_aspath
	  but moved to new func so it can be run after NEW_AS_PATH
	  reconciliation.
	  (bgp_attr_as4_path) New, handle NEW_AS_PATH.
	  (bgp_attr_aggregator) Adjust to cope with 2/4 byte ASes.
	  (bgp_attr_as4_aggregator) New, read NEW_AGGREGATOR.
	  (bgp_attr_parse) Add handoffs to previous parsers for the two
	  new AS4 NEW_ attributes.
	  Various checks added for NEW/OLD reconciliation.
	  (bgp_packet_attribute) Support 2/4 for AS_PATH and
	  AGGREGATOR, detect when NEW_ attrs need to be sent.
	* bgp_debug.{c,h}: Add 'debug bgp as4'.
	* bgp_dump.c: MRTv2 support, unconditionally enabled, which
	  supports AS4. Based on patches from Erik (RIPE?).
	* bgp_ecommunity.c: (ecommunity_ecom2str) ECOMMUNITY_ENCODE_AS4
	  support.
	* bgp_open.c: (peek_for_as4_capability) New, peek for AS4
	  capability prior to full capability parsing, so we know which
	  ASN to use for struct peer lookup.
	  (bgp_open_capability) Always send AS4 capability.
	* bgp_packet.c: (bgp_open_send) AS4 handling for AS field
	  (bgp_open_receive) Peek for AS4 capability first, and figure
	  out which AS to believe.
	* bgp_vty.c: (bgp_show_peer) Print AS4 cap
	* tests/aspath_test.c: Support asn32 changes, call aspath_parse
	  with 16 bit.
	* vtysh/extract.pl: AS4 compatibility for router bgp ASNUMBER
	* vtysh/extract.pl.in: AS4 compatibility for router bgp ASNUMBER
	* vtysh/vtysh.c: AS4 compatibility for router bgp ASNUMBER
2007-10-14 22:32:21 +00:00
Paul Jakma
e08286bcf8 [bgpd] Fix typo, which prevented advertisement of MP (non-IPv4) prefixes
2007-09-17 Paul Jakma <paul.jakma@sun.com>

	* bgp_open.c: (bgp_capability_mp) We were setting
	  afc_nego[safi][safi] rather than afc_nego[afi][safi], thus
	  failling to announce any non-IPv4 prefixes. Remove the extra,
	  typo-ed character.
	* bgp_capability_test.c: Test that peer's adv_recv and adv_nego get
	  set correctly for MP capability and given AFI/SAFI.
	  Colour OK/failed result so it's easier to find them.
2007-09-18 12:11:26 +00:00
Paul Jakma
ed6ef902df [tests] Add bgp_capability_test.c, should have been part of earlier commit 2007-08-08 14:13:03 +00:00
Paul Jakma
6d58272b4c [bgpd] cleanup, compact and consolidate capability parsing code
2007-07-26 Paul Jakma <paul.jakma@sun.com>

	* (general) Clean up and compact capability parsing slightly.
	  Consolidate validation of length and logging of generic TLV, and
	  memcpy of capability data, thus removing such from cap specifc
	  code (not always present or correct).
	* bgp_open.h: Add structures for the generic capability TLV header
	  and for the data formats of the various specific capabilities we
	  support.  Hence remove the badly named, or else misdefined, struct
	  capability.
	* bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data.
	  Do the length checks *before* memcpy()'ing based on that length
	  (stored capability - should have been validated anyway on input,
	  but..).
	  (bgp_afi_safi_valid_indices) new function to validate (afi,safi)
	  which is about to be used as index into arrays, consolidates
	  several instances of same, at least one of which appeared to be
	  incomplete..
	  (bgp_capability_mp) Much condensed.
	  (bgp_capability_orf_entry) New, process one ORF entry
	  (bgp_capability_orf) Condensed. Fixed to process all ORF entries.
	  (bgp_capability_restart) Condensed, and fixed to use a
	  cap-specific type, rather than abusing capability_mp.
	  (struct message capcode_str) added to aid generic logging.
	  (size_t cap_minsizes[]) added to aid generic validation of
	  capability length field.
	  (bgp_capability_parse) Generic logging and validation of TLV
	  consolidated here. Code compacted as much as possible.
	* bgp_packet.c: (bgp_open_receive) Capability parsers now use
	  streams, so no more need here to manually fudge the input stream
	  getp.
	  (bgp_capability_msg_parse) use struct capability_mp_data. Validate
	  lengths /before/ memcpy. Use bgp_afi_safi_valid_indices.
	  (bgp_capability_receive) Exported for use by test harness.
	* bgp_vty.c: (bgp_show_summary) fix conversion warning
	  (bgp_show_peer) ditto
	* bgp_debug.h: Fix storage 'extern' after type 'const'.
        * lib/log.c: (mes_lookup) warning about code not being in
          same-number array slot should be debug, not warning. E.g. BGP
          has several discontigious number spaces, allocating from
          different parts of a space is not uncommon (e.g. IANA
          assigned versus vendor-assigned code points in some number
          space).
2007-08-06 15:21:45 +00:00
Paul Jakma
3414bf250a [tests] update heavywq for workqueue api changes
2006-08-26 Paul Jakma <paul.jakma@sun.com>

	* heavy-wq.c: (slow_func_del,slow_func) update to match workqueue
	  changes
2006-08-27 06:53:24 +00:00
Paul Jakma
1f742f21a9 [bgpd] aspath_loop_check was broken, fix it and the aspath unit test code.
2006-08-06 Paul Jakma <paul.jakma@sun.com>

	* bgp_aspath.c: (aspath_loop_check) Fix the typo-bug which
	  essentially had disabled this check. Problem reported by
	  Bartek Kania <mrbk@gnarf.org> in [quagga-users 7388].
	* aspath_test.c: (validate) Fix the sense of the aspath_loop_check,
	  which was the wrong way around and had actually been testing for
	  aspath_loop_check to be buggy.
2006-08-06 15:52:11 +00:00
Paul Jakma
1602a71d7a [tests] Fix stray character in previous commit 2006-05-28 08:32:44 +00:00
Paul Jakma
f783c1d7bc [tests] test-sig.c: configure logging
2006-05-28 Paul Jakma <paul.jakma@sun.com>

	* test-sig.c: (main) configure logging, there's no terminal
	  to write to for one thing, but we do want stdout, and we
	  don't want a test to spam syslog.
2006-05-28 08:31:17 +00:00
Paul Jakma
5d932f6197 [tests] fix heavy-wq, add redundant AS_SET test and statics to aspath_test
2006-03-16 Paul Jakma <paul.jakma@sun.com>

	* heavy-wq.c: (heavy_wq_init) delay is gone from workqueue
	  spec.
	* aspath_test.c: (test_segments) Add an AS_SET with redundant
	  ASNs.
	  ({empty_prepend,prepend,parse}_test) add static qualifiers
2006-03-30 13:42:50 +00:00
paul
590188b67d [cvs] update cvsignore file. 2006-01-19 20:33:47 +00:00
paul
6726f950ad 2006-01-16 Paul Jakma <paul.jakma@sun.com>
* aspath_test.c: (validate) free the temporary aspaths.
	  (empty_get_test) ditto.
2006-01-16 12:06:00 +00:00
paul
067fca8632 [tests] Add small unit test for the new stream functions
2006-01-10 Paul Jakma <paul.jakma@sun.com>

	* test-stream.c: new file, small unit test for new
	  resize and {put,get}-quad stream functions.
	* Makefile.am: build teststream unit test.
2006-01-10 14:49:04 +00:00
paul
5906476bea [tests] Add empty-path and sequence+1ASN test data to aspath_test.c
2005-11-23 Paul Jakma <paul.jakma@sun.com>

	* aspath_test.c: Add an empty aspath to test segments, and to
	  compare tests.
	  Add a segment identical to seq1, but with one extra asn.
	  Fix bogus free of stream in make_aspath for case where
	  no stream was allocated (empty path data).
2005-11-23 02:48:14 +00:00
paul
84771ee0de 2005-10-11 Paul Jakma <paul.jakma@sun.com>
* test-privs.c: Privileges unit test.
	* Makefile.am: build testprivs
	* aspath_test.c: fix a few sign warnings
2005-10-11 03:48:28 +00:00
paul
1f377b0202 2005-09-06 Paul Jakma <paul@dishone.st>
* aspath_test.c: Test bgp_aspath functionality.
	* Makefile.am: build aspathtest
	* ChangeLog: Fix date of previous commit
2005-09-10 18:00:11 +00:00
paul
dff4f5272f 2004-09-06 Paul Jakma <paul@dishone.st>
* test-buffer.c: include memory.h
          (main) call memory_init().
2005-09-06 23:08:01 +00:00
paul
6379b96117 2004-09-05 Paul Jakma <paul@dishone.st>
* heavy-wq.c: (slow_func_del,slow_func_err) make them take
	  void * argument to shut up silly gcc warning.
2005-09-05 14:00:09 +00:00
paul
9f3f7a1145 2004-05-25 Paul Jakma <paul@dishone.st>
* main.c: new file, common 'main' portion which then calls
	  test_init.
	* heavy.c: remove common portions now in 'main.
	* heavy-wq.c: ditto
	* heavy-thread.c: ditto
	* heavy*.c: Set the slow_function iteration number lower, to 300, it
	  was several orders of magnitude too 'slow' to be useful. :)
	* Makefile.am: main is a source of the tests. heavy should link
	  to the math library.
2005-04-25 16:42:24 +00:00
paul
1d2c893b61 2004-05-22 Paul Jakma <paul@dishone.st>
* Makefile.am: Build heavythread
2005-04-22 00:54:44 +00:00
paul
864c364df9 2004-05-22 Paul Jakma <paul@dishone.st>
* heavy-thread.c: Andrew Schorr's adaptation of heavy.c to use a
	  background thread to avoid responsivity problems.
2005-04-22 00:50:08 +00:00
paul
cb0663c41a - bah, commit changelog 2005-04-21 17:23:48 +00:00
paul
f4d062f872 2004-05-21 Paul Jakma <paul@dishone.st>
* heavy.c: Add a timer thread to demonstrate thread interactivity,
	  Add a daemon_exit command to assist with debugging (eg for memory
	  tracers, etc..)
2005-04-21 16:58:44 +00:00
paul
43313d05bc 2004-05-19 Paul Jakma <paul@dishone.st>
* heavy.c: test programme to show how long-running functions
	  kill responsiveness. Demonstrating the most niggly problem
	  left in bgpd.
2005-04-19 21:28:36 +00:00
paul
662a1f25bb - add changelog 2005-04-13 03:32:23 +00:00
paul
4dcadf7efd 2004-05-13 Paul Jakma <paul@dishone.st>
* test-buffer.c: Andrew's buffer tester
	* test-memory.c: basic memory tester
	* Makefile.am: Add new tests
2005-04-13 03:31:35 +00:00
paul
3c035aa871 - Add .arch-ids and .arch-inventory to cvsignore, to allow one to use arch
with CVS trees.
2004-11-02 18:59:49 +00:00
paul
41c14a1fc3 2004-07-26 Paul Jakma <paul@dishone.st>
* configure.ac: reenable tests/Makefile
	* tests/Makefile.am: automake file for tests dir
	* tests/.cvsignore: update
2004-07-26 19:27:51 +00:00
paul
d26ca6a976 CVS ignore Linux NFS silly-delete .nfs* files 2004-06-06 15:25:35 +00:00
paul
c15cfa8329 add appropriate cvsignore 2004-01-19 21:33:17 +00:00
paul
9a76e2ddb6 2004-01-19 Paul Jakma <paul@dishone.st>
* tests/test-sig.c: New file, regression test for sigevents.
2004-01-19 21:25:17 +00:00