Commit Graph

2119 Commits

Author SHA1 Message Date
Mitesh Kanjariya
1f53ef552d Fix compilation errors for domainname
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-25 15:51:16 -07:00
Mitesh Kanjariya
4a48f1b70b lib: Fix make check failures
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-25 15:39:14 -07:00
Quentin Young
935cee3f9b
lib: remove static variable from cli matcher
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-25 15:41:32 -04:00
Quentin Young
8295b504cb
lib: fix rare bug in ambiguous command resolution
In certain situations, the CLI matcher would not handle ambiguous
commands properly. If it found an ambiguous result in a lower subgraph,
the ambiguous result would not correctly propagate up to previous frames
in the resolution DFS as ambiguous; instead it would propagate up as a
non-match, which could subsequently be overridden by a partial match.

Example CLI space:

  show ip route summary
  show ip route supernet-only
  show ipv6 route summary

Entering `show ip route su` would result in an ambiguous resolution for
the `show ip route` subgraph but would propagate up to the `show ip`
subgraph as a no-match, allowing `ip` to partial-match `ipv6` and
execute that command.

In this example entering `show ip route summary` would disambiguate the
`show ip` subgraph. So this bug would only appear when entering input
that caused ambiguities in at least two parallel subgraphs.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-25 15:41:27 -04:00
Donald Sharp
9ca25fedba *: Add RMAP_COMPILE_SUCCESS to enum
Add the RMAP_COMPILE_SUCCESS and switch over to using it.
Refactoring allows a removal of a if statement to just
use the switch statement already in place.  Additionally
the reworking cleans up memory freeing in a couple of spots.
In one spot we no longer will leak memory too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-25 10:48:30 -04:00
Renato Westphal
0af35d90a1 *: fix assorted issues detected by Coverity Scan
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-24 21:49:39 -03:00
Mitesh Kanjariya
6f9d219ae6 provide/use API to get hostname/domainname
Set default hostname in frr to unix hostname.
Provide APIs to get the hostname/domaninanme
Use this APIs where needed

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-24 16:44:31 -07:00
Mitesh Kanjariya
419cd5a03f lib/bgpd: provide/use API to get hostname/domainname
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-24 16:37:16 -07:00
Renato Westphal
40d55b54c6 Merge pull request #1038 from donaldsharp/zserv
zebra: Fix compiler warnings
2017-08-24 10:26:31 -03:00
Donald Sharp
27c5d4de93 Merge pull request #1031 from opensourcerouting/small-bits
small bits
2017-08-24 08:58:46 -04:00
Donald Sharp
b5f7965155 lib: Fix nexthop num
If we assign MULTIPATH_NUM to be 256, this causes issues
for us since 256 is bigger than a u_char.  So let's make
the api's multipath_num to be a u_int16_t and pass it
around as a word.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-24 08:30:08 -04:00
Renato Westphal
f474e08be0 lib: mark the old zebra API for route advertisement as deprecated
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 20:28:34 -03:00
Renato Westphal
744899219f *: use zapi_route to send/receive redistributed routes as well
Some differences compared to the old API:
* Now the redistributed routes are sent using address-family
  independent messages (ZEBRA_REDISTRIBUTE_ROUTE_ADD and
  ZEBRA_REDISTRIBUTE_ROUTE_DEL). This allows us to unify the ipv4/ipv6
  zclient callbacks in the client daemons and thus remove a lot of
  duplicate code;

* Now zebra sends all nexthops of the redistributed routes to the client
  daemons, not only the first one. This shouldn't have any noticeable
  performance implications and will allow us to remove an ugly exception
  we had for ldpd (which needs to know all nexthops of the redistributed
  routes). The other client daemons can simply ignore the nexthops if
  they want or consult just the first one (e.g. ospfd/ospf6d/ripd/ripngd).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 20:25:45 -03:00
David Lamparter
de1a880c4e lib: split off compiler magic into its own file
Also make timed notices available via CONFDATE.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24 00:18:53 +02:00
David Lamparter
c0e29be115 lib: prefix: try harder to not hash garbage
With prefix_ptr or prefix_ls, there can still be stuff in a struct
prefix that we shouldn't hash.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24 00:18:53 +02:00
David Lamparter
3cbb67f229 lib: better warnings for install_element
Also fixes misuse of vector_slot() - that one doesn't check for access
beyond end of vector...

And print node names in grammar sandbox "printall".

Fixes: #543
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24 00:18:53 +02:00
David Lamparter
427f8e61bb ospf6d: properly update prefix list references
Register add/delete hooks with the prefix list code to properly change
ospf6_area's prefix list in/out pointers.

There are 2 other uncached uses of prefix lists in the ASBR route-map
code and the interface code;  these should probably be cached too. (To
be fixed another day...)

Fixes: #453
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24 00:18:53 +02:00
David Lamparter
6bd2b3608d lib: fix cosmetic issue with exit race
if we're using --terminal, the daemon may in some cases exit fast enough
for the parent to see this; this resulted in a confusing/bogus "failed
to start, exited 0" message.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-24 00:18:53 +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
Renato Westphal
52dd3aa483 zapi: add support for routes with multiple labels
This will be necessary for the Segment Routing feature.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 18:58:35 -03:00
Renato Westphal
0e51b4a368 lib/zserv: introduce address-family independent ZAPI message types
As noticed in 657cde1, the zapi_ipv[4|6]_route functions are broken in
many ways and that's the reason that many client daemons (e.g. ospfd,
isisd) need to send handcrafted messages to zebra.

The zapi_route() function introduced by Donald solves the problem
by providing a consistent way to send ipv4/ipv6 routes to zebra with
nexthops of any type, in all possible combinations including IPv4 routes
with IPv6 nexthops (for BGP unnumbered routes).

This patch goes a bit further and creates two new address-family
independent ZAPI message types that the client daemons can
use to advertise route information to zebra: ZEBRA_ROUTE_ADD and
ZEBRA_ROUTE_DELETE. The big advantage of having address-family independent
messages is that it allows us to remove a lot of duplicate code in zebra
and in the client daemons.

This patch also introduces the zapi_route_decode() function. It will be
used by zebra to decode route messages sent by the client daemons using
zclient_route_send(), which calls zapi_route_encode().

Later on we'll use this same pair of encode/decode functions to
send/receive redistributed routes from zebra to the client daemons,
taking the idea of removing code duplication to the next level.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
Renato Westphal
bb1b9c47ca lib: updates to zapi_route
This patch introduces the following changes to the zapi_route structure
and associated code:
* Use a fixed-size array to store the nexthops instead of a pointer. This
  makes the zapi_route() function much easier to use when we have multiple
  nexthops to send. It's also much more efficient to put everything on
  the stack rather than allocating an array in the heap every time we
  need to send a route to zebra;

* Use the new 'zapi_nexthop' structure. This will allow the client daemons
  to send labeled routes without having to allocate memory for the labels
  (the 'nexthop' structure was designed to be memory efficient and doesn't
  have room for MPLS labels, only a pointer). Also, 'zapi_nexthop' is more
  compact and more clean from an API perspective;

* Embed the route prefix inside the zapi_route structure. Since the
  route's prefix is sent along with its nexthops and attributes, it makes
  sense to pack everything inside the same structure.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
Renato Westphal
34b054ba6d *: remove leftovers from "router zebra"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
Renato Westphal
153856bbe9 lib: remove redundant zebra messages
This also fixes a bug of ipv6 routes advertised by the VNC code being
ignored by zebra.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-23 17:45:17 -03:00
David Lamparter
acf3a851b9 lib: fix const-check in route_node
route_node->lock is "const" if --enable-dev-build is used.  This is done
to deter people from messing with internals of the route_table...
unfortunately, the inline'd route_[un]lock_node runs into this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-22 15:27:08 +02:00
Lou Berger
3f54388956 Merge pull request #939 from jbonor/optimization
Optimization
2017-08-22 09:01:20 -04:00
Donald Sharp
cacec09618 Merge pull request #1016 from opensourcerouting/cli-minor
minor cli foo (hashtable stats, pseudowire show)
2017-08-22 08:54:18 -04:00
David Lamparter
4093d47b99 lib: terminate capabilities only if initialized
zprivs_caps_init() is called conditionally, apply the same condition on
terminate.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-21 21:53:46 +02:00
David Lamparter
40818cec85 lib: move hashstats under debug, show per-daemon
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-21 14:41:02 +02:00
Jorge Boncompte
19aad877b7 lib: optimize IPV4_ADDR_[SAME|COPY]()
Change all callers of IPV4_ADDR_SAME() to pass a pointer to a struct in_addr

Use assignment and comparison instead of memcpy() and memcmp(). Avoids function
calls. Faster.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:58:35 +02:00
Jorge Boncompte
f104f6c1a6 lib: cleanup the work queue implementation
Convert the work queue implementation to not use the generic linked list
to mantain the item list and use instead a simple queue from queue.h that
does not allocate memory for each node.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:47:07 +02:00
Jorge Boncompte
cd85bc2e0b lib: standardize use of queue.h
The simple queue implementation in OpenBSD and FreeBSD are called diferently,
standardize in the use of the FreeBSD version and map the missing names only
if we compile on OpenBSD.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:47:05 +02:00
Jorge Boncompte
01dccc0b19 lib: inline route_node_lock()/route_node_unlock()
Avoid function calls.

Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-17 17:46:22 +02:00
David Lamparter
ce19a04aea lib: replace if_add_hook with hook_* logic
This allows modules to register their own additional hooks on interface
creation/deletion.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-15 13:25:44 +02:00
David Lamparter
0395137477 *: centralize some exit cleanup into libfrr
Start creating a counterpart to frr_init and frr_late_init.
Unfortunately, some daemons don't do any exit handling, this doesn't
change that just yet.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-15 13:25:44 +02:00
David Lamparter
08c4c73be6 lib: hooks: support priority ordering & reversing
Allow registering callbacks with a priority value used to order them
relative to each other.  Plus a reverse variant that just flips the
direction on priorities.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-15 13:25:41 +02:00
David Lamparter
bf30e5eaf2 Merge pull request #948 from qlyoung/fix-set-ip-next-hop-peer-address
lib, bgpd: fix `set ip next-hop peer-address`
2017-08-15 11:10:01 +02:00
David Lamparter
24fb3b1873 Merge pull request #934 from qlyoung/mac-parser
lib: add CLI token for 48-bit mac addresses
2017-08-15 11:09:15 +02:00
Quentin Young
473196f613
lib, python: add M:A:C support for clippy
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-14 11:30:08 -04:00
David Lamparter
b4e55fc5e8 lib: fix prefix list trie corruption
The specific code here needs to establish an absolute order of more
specific to less specific possible matches in a prefix list.  This is
indirectly checked by an assert on insertion, because the "next best"
entry is required to be consistent even when joining multiple chains
of candidates.

Unfortunately, trie_install_fn() would insert entries too far ahead in
the chain if another entry with higher sequence number was seen.  This
breaks the trie and (rightfully) triggers the assertion failure on
insert.

Fixes: #937
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-11 19:02:22 +02:00
Quentin Young
9779e3f193
lib: add CLI token for 48-bit mac addresses
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-11 12:42:01 -04:00
David Lamparter
fc4ecb5a5e Merge pull request #957 from chiragshah6/mdev
ospfd: fix crash due to conflicting router-id, fix MI-OSPF cli in lib commands and fix memory leaks
2017-08-11 18:28:04 +02:00
David Lamparter
eef3d03026 lib: don't close stdio when running foreground
c9c8d0d ("lib: close stdin/out/err in non-terminal case") overshot its
goal and closes stdin/stdout/stderr even when a daemon is running in
foreground.  That means stdout logging & exit memory reporting are both
broken.

Reported-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-11 15:45:56 +02:00
Chirag Shah
825d5fbf59 lib: Fix multi instance ospf
ospfd crashes upon configuring multi-instance ospf
i.e 'router ospf x'.
ospfd can return CMD_NOT_MY_INSTANCE which
is not supported in lib/commands

Support two of the error codes
CMD_NOT_MY_INSTANCE and CMD_WARNING_CONFIG_FAILED

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-08-10 14:59:07 -07:00
Quentin Young
89602edb31
lib, bgpd: fix set ip next-hop peer-address
This bgp-specific command had its positive form defined only in bgpd and
its negative form defined only in lib, which broke the whole rule for
other daemons.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-10 12:31:47 -04:00
David Lamparter
695bb8f0d1 Merge branch 'frr/pull/822' ("EVPN fixes")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-09 21:34:10 +02:00
Donald Sharp
3cc2066899 Merge pull request #926 from opensourcerouting/tcp-zebra
remove `--enable-tcp-zebra`
2017-08-09 14:43:48 -04:00
David Lamparter
2c3699c0eb Merge pull request #940 from qlyoung/hashtable-expansion-lf
lib: use load factor as hash expansion trigger
2017-08-09 20:43:40 +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
David Lamparter
3b0f6068a8 lib: some final MAC access-list fixes
- couldn't load back written configs because it was trying to parse
  "any" as MAC address
- don't need special-casing in filter_match_zebra(), exact is going to
  be 0 for AF_ETHERNET anyway
- some vty formatting was slightly different
- is_zero_mac now static to prefix.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-09 20:30:34 +02:00
Quentin Young
bed7ad8387
lib: use load factor as hash expansion trigger
Previous strategy was to resize the hash table when the length of any
one bucket exceeded a certain size, with some logic for intelligently
stopping resizes when the gains from doing so weren't sufficient. While
this was a good idea that attempted to optimize both space and lookup
time, unfortunately under transient degenerate conditions this led to
some issues with the tables not resizing when they should have,
harming performance. The resizing restriction was lifted, but this had
the result of exacerbating degenerate behavior and caused out of memory
conditions.

This patch changes the hash expansion criterion to be based on the
number of elements in the table. Once the # of elements in the table
exceeds the number of buckets, the table size is doubled. While the
space efficiency of this method decreases relative to the perfectness of
the hash function, at least this strategy puts the table performance
squarely in the hands of the hash function.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-09 13:53:11 -04:00
Renato Westphal
2dd0d72624 zebra: add support for static pseudowires
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-09 13:03:36 +02:00
Renato Westphal
87b5f1b77b ldpd: integrate with the pseudowire manager in zebra
If we receive a notification from zebra indicating that the installation
of a pseudowire has failed (e.g. no reachability), send a PW Status
notification to the remote peer (or a Label Withdraw if the remote peer
doesn't support the PW Status TLV).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-09 12:35:16 +02:00
ßingen
6833ae01bc zebra: add pseudowire manager
Base framework for supporting MPLS pseudowires in FRR.

A consistent zserv interface is provided so that any client daemon
(e.g. ldpd, bgpd) can install/uninstall pseudowires in a standard
way. Static pseudowires can also be implemented by using the same
interface.

When zebra receives a request to install a pseudowire and the installation
in the kernel or hardware fails, a notification is sent back to the
client daemon and a new install attempt is made every 60 seconds (until
it succeeds).

Support for external dataplanes is provided by the use of hooks to
install/uninstall pseudowires.

Signed-off-by: ßingen <bingen@voltanet.io>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-09 12:35:15 +02:00
ßingen
ea4ecfb351 ospf: Fix segfault if compiled with DEBUG
If OSPF_LS_REFRESH_TIME is 60, min_delay in ospf_refresher_register_lsa
function (ospf_lsa.c) would be negative, so index (which is unsigned)
would be out of range, causing a segfault.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-08-09 12:07:58 +02:00
David Lamparter
b8c1fde3cb lib: don't mkdir state paths in watchfrr
watchfrr doesn't know if there will be -u/-g options on the individual
daemons, so it doesn't know what the appropriate ownership is.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-09 10:55:03 +02:00
David Lamparter
5d13cd091a lib: thoroughly disable tcp-zebra
Disable this in the code to make it hard for people to shoot themselves
in the foot.  It's only left as a remnant for development use.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-08 20:11:10 +02:00
Donald Sharp
0f6476ccc3 lib, bgpd: Use 'struct prefix *' for filter matching
There is no need for special casing of mac addresses,
since the mac address is it's own type integrated
into `struct prefix` now.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-08 12:55:03 -04:00
Quentin Young
eff09c66a4
lib: fix still reachable linked list in thread.c
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-08 12:54:28 -04:00
Donald Sharp
b03b88986e lib, bgpd: Distinguish between AF_EVPN and AF_ETHERNET
Create AF_EVPN for internal use and start using it.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-08-08 10:34:31 -04:00
Donald Sharp
b34fd35d3a lib, bgpd: Address Review comments.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-08 10:30:14 -04:00
Donald Sharp
1667fc4097 lib: Fix extra doc string
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-08 10:30:13 -04:00
Mitesh Kanjariya
69b61704b8 lib: changes needed for mac access-list any command
Ticket: CM-17074
Review: CCR-6453
Unit-test: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-08 10:28:55 -04:00
Mitesh Kanjariya
1a98c08704 bgpd/zebra/lib: EVPN support for asymmetric VxLan routing
1. Advertise gateway mac-ip in EVPN
2. Advertise VRR mac-ip in EVPN
3. Ignore gateway mac-ip advertisements in case of distributed gateway
4. Config knob to enable/disable gateway mac-ip advertisements

Ticket: CM-16456, CM-16543, CM-16555, CM-16778
Review: CCR-6283
Unit-test: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-08 10:28:46 -04:00
Mitesh Kanjariya
d37ba5499e bgpd, lib, vtysh: Added support for mac filtering in route-maps
1. Added support to create mac filters
2. Enabled route-map commands for EVPN address family
3. Provision to add mac filters under match clause in route-maps

Ticket: CM-16349
Review: CCR-6190
Unit-test: Manual (logs attached to ticket)

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-08 10:09:37 -04:00
Donald Sharp
99a6a31e50 *: Define the number of seconds in a Day, Week and year
The defines:

ONE_DAY_SECOND
ONE_WEEK_SECOND
ONE_YEAR_SECOND

were being defined all over the system, move the
define to a central location.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-08 09:06:22 -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
5225e155d3 lib: cli: don't run off graph "pre-end"
Behind END_TKN, there is another graph node whose data pointer is
actually struct cmd_element instead of struct cmd_token.  Don't try to
interpret that as cmd_token.  This causes very interesting crashes when
ASLR decides to give one of the strings of a command definition a lower
32-bit value that is a valid cmd_token_type (e.g. FORK_TKN).

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-07 15:05:34 +02:00
David Lamparter
9b0a8efa46 Merge pull request #912 from chiragshah6/mdev
Fix Multi-Instance OSPF configurations CLIs
2017-08-06 03:55:10 +02:00
David Lamparter
c053ff8bff Merge pull request #899 from donaldsharp/ETH_ALEN
Fix Crash and Convert to ETH_ALEN
2017-08-05 05:19:01 +02:00
Russ White
6b22ae607f Merge pull request #906 from opensourcerouting/vty-close
lib: vty: fix config-write fd leak
2017-08-04 13:14:43 -04:00
Quentin Young
61b9e9d6b3
lib: remove last powl()
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-04 10:58:00 -04:00
Chirag Shah
a3d826f0ea ospfd: Fix MI-OSPF configuraton clis
Multi-Instance OSPF configuration CLI would fail because
first client return error upon seeing qobj_index being 0.
With new marco generate new error code to return from each
instance (vtysh client) and if the command is intended for given
instance, its qobj_index would be nonzero and process the command
and push correct ospf context. Other instance would return the error.
On vtysh end, check all instance return an error log a message to a
file.

Testing Done:
Verfied various MI-OSPF configuration CLI with multi instances.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-08-04 07:47:45 -07:00
Donald Sharp
7628d862ca lib: Add ETH_ALEN to prefix.h and deprecate ETHER_ADDR_LEN
From discussion we decided that we should use ETH_ALEN instead
of ETHER_ADDR_LEN.  Add ETH_ALEN to prefix.h and make
ETHER_ADDR_LEN generate a warning when used( but still work ).

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-04 09:06:14 -04:00
Donald Sharp
6b36796215 Merge pull request #909 from opensourcerouting/isis-perf
IS-IS: improve spf performance
2017-08-04 09:04:12 -04:00
David Lamparter
10b8a9c007 lib: vty: fix config-write fd leak
Since we were only setting vty->wfd in config_write, vty->fd would
remain 0 and vty_close() wouldn't close vty->wfd.

Clean up the entire fd closing and make it more explicit.  We were even
trying to write to stdin...

Reported-by: Jorge Boncompte <jbonor@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-04 12:15:54 +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
David Lamparter
89727c8d9e build: fix clippy cross-compile
Broke the build-for-host setup for clippy in the non-recursive changes
:/

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-04 11:09:45 +02:00
David Lamparter
3619938e2f Merge pull request #891 from Jafaral/portability
Portability configurations
2017-08-04 08:52:07 +02:00
David Lamparter
e4f48ace5d Merge pull request #900 from qlyoung/apply-mask
lib: add missed apply_mask()
2017-08-04 08:49:20 +02:00
Quentin Young
bca37d172a
lib: minor style fixes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-03 11:25:24 -04:00
Quentin Young
c7fcc67369
lib: add missed apply_mask()
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-03 11:12:14 -04:00
Christian Franke
c7d3895eb1 lib: Reformat comment so my eyes don't fall out while reading it
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-08-03 14:30:01 +02:00
Christian Franke
7a7761d21c lib: move prefix hash key to prefix.c to allow global use
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-08-03 13:37:58 +02:00
Christian Franke
31bfa0624d lib: add sbuf
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-08-03 11:34:01 +02:00
David Lamparter
c9c8d0d189 lib: close stdin/out/err in non-terminal case
Oops, forgot this path... in the --terminal case, stdio is closed when
the user ends the terminal session, but without terminal it was left
open.

(This caused a ssh session hang in the CentOS6 CI because the file
descriptors were still open, so ssh would keep the session alive...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-03 03:37:37 +02:00
David Lamparter
b4fa7c95f9 lib: replace stderr with zlog in vty config load
Now that the logging hole is plugged, we can just print config-loading
errors to the log.  This has 2 hidden advantages:

- vty_read_config calls in SIGHUP don't print errors to /dev/null
- errors are consistently printed to syslog on --enable-cumulus

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 23:36:42 +02:00
David Lamparter
d34cb7f0b7 lib: plug logging hole during startup
zlog_* doesn't work in startup before we've loaded the real logging
configuration.  Add some code to log to stderr for that window of time.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 23:36:42 +02:00
David Lamparter
beaa54706a lib: create pid/vty directories
If the paths for pid or vty don't exist, try creating them.  Failure is
ignored (on EEXIST) or prints a non-fatal warning (other errors).

Fixes: #507
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 23:36:42 +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
Jafar Al-Gharaibeh
dacb17162a Merge pull request #895 from qlyoung/flush-ready
lib: flush ready queue before poll() again
2017-08-02 14:24:41 -05:00
Jafar Al-Gharaibeh
408647964a Merge pull request #894 from donaldsharp/sockopt
lib: Remove sockopt_cork functionality
2017-08-02 14:22:43 -05:00
Quentin Young
d764d2cc50
lib: flush ready queue before poll() again
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-02 14:29:04 -04:00
Jafar Al-Gharaibeh
f9e755241a config: If we don't have crypt but we have ssl crypto, use it
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2017-08-02 10:01:17 -05:00
Donald Sharp
0ecfe5bf38 Merge branch 'master' into PIM_VRF 2017-08-02 09:39:38 -04:00
Renato Westphal
bd402424a4 lib: fix build from git repository on OpenBSD
The OpenBSD's cp(1) command doesn't support the -v option. This will
change in the next releases (starting from v6.2) but this patch fixes
the problem for v6.1 and older releases.

Fixes Issue #875.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-01 22:12:24 -03: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
David Lamparter
cff2b2112e lib: --terminal option for all daemons
This allows, among other things, piping in a configuration from stdin.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 02:59:51 +02:00
David Lamparter
f43fbf837c lib: daemonize more intelligently
Block the parent process until the child has reached the main loop, e.g.
full service is available.

This means it's no longer neccessary to add a "safety sleep" for daemon
cross-dependencies, when using the -d startup option.  This doesn't help
if -d isn't used.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 02:59:51 +02:00
David Lamparter
181d61462b build: make gitversion more useful
Use --first-parent (i.e. mainline side of merge) and restrict to "frr-"
tags.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02 02:59:51 +02:00
Donald Sharp
c62232b4b1 lib: Remove sockopt_cork functionality
Linux -> TCP_CORK is enabled by default
*BSD -> The equivalent is TCP_NOPUSH

As such sockopt_cork is effectively useless
especially since the two places it is used
do it right before TCP writes then disable
it right after the writes are over.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-01 20:36:33 -04:00
Donald Sharp
ab665082fe Merge pull request #882 from opensourcerouting/safi-cleanup
lib/bgpd: cleanup SAFI values
2017-08-01 14:21:26 -04:00
Donald Sharp
c72ec965b9 Merge pull request #860 from opensourcerouting/non-recursive
convert lib & zebra to non-recursive automake
2017-08-01 11:33:43 -04:00
Russ White
f7ba7b3b2b Merge pull request #884 from dwalton76/bgpd-peer-hash-limit
bgpd: peer hash expands until we are out of memory
2017-08-01 08:04:23 -04:00
David Lamparter
f1b32b2e5e build: fix/improve clippy dependencies
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-01 07:09:45 +02:00
Renato Westphal
085347cfad lib: use switch statements in the AFI/SAFI conversion functions
Switch statements are more elegant (and potentially faster... but that's
not the main motivation).

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
Renato Westphal
a08ca0a7e1 lib: remove SAFI_RESERVED_4 and SAFI_RESERVED_5
SAFI values have been a major source of confusion over the last few
years. That's because each SAFI needs to be represented in two different
ways:
* IANA's value used to send/receive packets over the network;
* Internal value used for array indexing.

In the second case, defining reserved values makes no sense because we
don't want to index SAFIs that simply don't exist. The sole purpose of
the internal SAFI values is to remove the gaps we have among the IANA
values, which would represent wasted memory in C arrays. With that said,
remove these reserved SAFIs to avoid further confusion in the future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-31 23:38:38 -03:00
Daniel Walton
40520c3649 bgpd: peer hash expands until we are out of memory
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

swpX peers all start out with the same sockunion so initially they all
go into the same hash bucket. Once IPv6 ND has worked its magic they
will have different sockunions and will go in different buckets...life
is good.

Until then though, we are in a phase where all swpX peers have the same
socknunion. Once we have HASH_THRESHOLD (10) swpX peers and call
hash_get for a new swpX peer the hash code calls hash_expand(). This
happens because there are more than HASH_THRESHOLD entries in a single
bucket so the logic is "expand the hash to spread things out"...in our
case expanding doesn't spread out the swpX peers because all of their
sockunions are the same.

I looked at having peer_hash_make and peer_hash_same consider the ifname
of the swpX peer but that is a large change that we don't want to make
at the moment. So the fix is to put a cap on how large we are
willing to let the hash table get. By default there is no limit but if
max_size is set we will not allow the hash to expand above that.
2017-07-31 21:22:23 +00:00
David Lamparter
4a121f99f7 build: convert lib/ to non-recursive build
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-31 23:03:27 +02:00
David Lamparter
812ff999ca Merge pull request #865 from qlyoung/find
Find
2017-07-31 19:58:20 +02:00
Quentin Young
9d356c939f
lib: s/leychain/keychain
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-31 11:03:32 -04:00
Quentin Young
c652f6f633
lib: correct some node name typos
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-27 15:03:31 -04:00
Donald Sharp
8b2a6222e8 lib: Remove expansion of hash table
The hash code has the idea of stopping expanding
the hash table when certain criteria are set.
With the recent addition of `show hashtable`
we can now see that when we have a full internet
feed we've stopped expanding the table at 1k
buckets.  This results in some serious performance
issues at scale.

Since we now have the ability to see the statistics
on a hash table, let's allow it to expand.  Doing
so on a full feed showed this:

before:
   Hash table          |  Buckets   Entries   Empty   LF        SD      FLF       SD
 ----------------------+----------------------------------------------------------------
   route table hash    |  1024      1187579   0%      1159.75   34.06   1159.75   35.08
   route table hash    |  32768     76208     10%     2.33      2.80    2.58      4.03
   route table hash    |  1024      1187572   0%      1159.74   34.06   1159.74   35.08
   route table hash    |  2048      76205     0%      37.21     6.13    37.21     7.29

Showing hash table statistics for BGP
-------------------------------------

   Hash table         |  Buckets   Entries   Empty   LF       SD      FLF      SD
 ---------------------+--------------------------------------------------------------
   BGP Attributes     |  131072    251229    15%     1.92     2.48    2.25     3.33
   route table hash   |  4096      1187572   0%      289.93   17.03   289.93   17.87
   route table hash   |  32768     76205     10%     2.33     2.90    2.58     4.21

After:

   Hash table          |  Buckets   Entries   Empty   LF     SD     FLF    SD
 ----------------------+--------------------------------------------------------
   route table hash    |  1048576   1187349   32%     1.13   2.57   1.67   3.16
   route table hash    |  32768     76195     10%     2.33   2.81   2.58   4.03
   route table hash    |  1048576   1187342   32%     1.13   2.58   1.67   3.16
   route table hash    |  32768     76192     10%     2.33   2.68   2.58   3.81

Showing hash table statistics for BGP
-------------------------------------

   Hash table         |  Buckets   Entries   Empty   LF     SD     FLF    SD
 ---------------------+--------------------------------------------------------
   BGP Attributes     |  131072    251222    15%     1.92   2.64   2.25   3.58
   route table hash   |  1048576   1187342   32%     1.13   2.52   1.67   3.07
   route table hash   |  32768     76192     10%     2.33   2.86   2.58   4.12

We should see some significant performance improvements across the board
for full feeds.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-27 11:08:40 -04:00
Quentin Young
cf6c83e712
lib, vtysh: add find COMMAND
Substring search through all defined commands in all nodes.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-26 22:58:52 -04:00
Quentin Young
a83a533139
lib: add CLI node names
Adds an array of descriptive names for each CLI node, plus a runtime
check to make sure folks don't forget to update it.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-26 18:19:49 -04:00
Donald Sharp
c6413dd394 Merge pull request #848 from opensourcerouting/rb-tree-fix
Fix corrupted RB trees
2017-07-25 11:11:33 -04:00
David Lamparter
4ff218ac39 Merge pull request #838 from dwalton76/lib-copy-nexthops
lib: copy_nexthops() only copies the first nexthop
2017-07-25 16:20:08 +02:00
Renato Westphal
145b205177 lib: fix corrupted RB trees
Commit 8f942af90 introduced a bug while silencing a clang warning. Silence
the warning in a different way to fix our red-black tree implementation.

Fixes #841.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-24 18:50:45 -03:00
Renato Westphal
52535beec1 lib: revert reindent of files imported from OpenBSD
We should preserve the original indentation to make it easier to keep
these files in sync with the upstream.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-24 18:40:24 -03:00
Donald Sharp
e0ae31b886 lib, pimd, zebra: Allow pim to set pimregX into appropriate vrf
The pimregX devices when created by the kernel are put into
the default vrf.  When pim gets the callback that the device
exists, check to see if it is a pimregX device and if so
move it into the appropriate vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-24 13:51:39 -04: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
Daniel Walton
8744028312 lib: copy_nexthops() only copies the first nexthop
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

Before the fix NHT had each path resolving via swp1

cel-redxp-10# show ip route 20.0.11.253
Routing entry for 20.0.11.0/24
  Known via "bgp", distance 20, metric 0, best
  Last update 00:00:20 ago
  * 169.254.0.1, via swp1
  * 169.254.0.17, via swp2

cel-redxp-10#

cel-redxp-10# show ip nht
[snip]
20.0.11.253
 resolved via bgp
 via 169.254.0.1, swp1
 via 169.254.0.1, swp1
 Client list: pim(fd 19)

After the fix

cel-redxp-10# show ip nht
[snip]
20.0.11.253
 resolved via bgp
 via 169.254.0.1, swp1
 via 169.254.0.17, swp2
 Client list: pim(fd 19)
2017-07-20 17:11:43 +00:00
Daniel Walton
b37aead99b lib: route_node_lookup() needs to apply_mask() to prefix
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   <qlyoung@cumulusnetworks.com>
2017-07-19 16:54:24 +00: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
Donald Sharp
e553b498f1 Merge pull request #820 from opensourcerouting/gcc7
fix new warnings emitted by GCC 7
2017-07-14 12:54:40 -04:00
David Lamparter
33cef91932 lib: parser: remove incorrect assert
A {foo|bar|baz} graph node will have more than 1/2 incoming links even
if no other references are left to it (which is what the assert was
previously trying to ensure.)

I don't see a good way to "fix" the assert so I'm just removing it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 17:53:59 +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
David Lamparter
20a6c6f31f *: fix GCC 7 warnings/issues
The label initializer & nhrpd variable are just to shut up GCC 7,
the other two are actual bugs.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 16:59:44 +02:00
David Lamparter
acd738fc7f *: fix GCC 7 switch/case fallthrough warnings
Need a comment on these.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 16:59:43 +02:00
Donald Sharp
1ea6b3f237 Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attr 2017-07-14 08:24:46 -04:00
Donald Sharp
da571b7a6c Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attr 2017-07-14 08:11:05 -04: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
28b672fcd3 lib, vtysh: remove now-useless newline arg
It's always \n now, hooray.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:18:14 +02:00
David Lamparter
84a98309de Merge remote-tracking branch 'frr/master' into newline-redux
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:15:55 +02:00
Russ White
79af1cb338 Merge pull request #808 from qlyoung/vtysh-termcols
lib, vtysh: pretty-print variable autocompletions
2017-07-14 07:10:13 -04:00
David Lamparter
50790e72fb *: remove vty_outln again
(PRs merged to master added another few vty_outln() calls)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 13:09:47 +02: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
55f70b671f *: remove VTYNL, part 4 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
61b7d449bd *: remove VTYNL, part 3 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:03 +02:00
David Lamparter
26a429fe8e *: remove VTYNL, part 2 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:02 +02:00
David Lamparter
6d3c2ed4ed *: remove VTYNL, part 1 of 6
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:02 +02:00
David Lamparter
6b18e3b2e0 ospf6d: VNL -> VTYNL
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:20:02 +02:00
David Lamparter
181039f3d7 *: ditch vty_outln(), part 2 of 2
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14 10:19:58 +02:00
Daniel Walton
f1a05de982 vtysh: return non-zero for configuration failures
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

This allows frr-reload.py (or anything else that scripts via vtysh)
to know if the vtysh command worked or hit an error.
2017-07-13 19:56:08 +00: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
David Lamparter
83eba583d7 lib: move \n vs. \r\n handling into vty code
Instead of having an ?: expression embedded in every single caller of
vty_out, just expand \n to \r\n in the vty code if neccessary.

(Deprecation warnings will be enabled in the next commits which will do
the search-and-replace over the codebase.)

[This reverts commit 4d5f445 "lib: add vty_outln()"]

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:20 +02:00
David Lamparter
8867927f0e lib: vty: warn when using compatibility macros
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13 20:29:18 +02:00
Quentin Young
1a0f614dd2
lib, vtysh: pretty-print variable autocompletions
Pretty-prints variable autocompletions by breaking them up into multiple
lines, indenting them consistently and respecting the column width of
the terminal.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-13 10:59:13 -04:00
Donald Sharp
4b8197a4f7 Merge pull request #807 from Jafaral/qua2frr
Find/Replace Quagga/FRR
2017-07-13 10:00:19 -04:00
David Lamparter
76ac0fe511 Merge pull request #798 from dwalton76/CMD_RANGE_STR
bgpd: --enable-multipath=256 setting is ignored
2017-07-13 14:58:52 +02:00
David Lamparter
f4b0619dc6 Merge pull request #796 from qlyoung/fix-hash-stats
lib: use 32-bit atomics, s/pow/mul
2017-07-13 14:57:44 +02:00
vivek
90e60aa7c9 bgpd: Additional configuration for EVPN
Implement configuration options for EVPN. The configuration options include
VNI configuration with RD and Import and Export Route Targets. Also, display
the EVPN configuration.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-07-12 15:07:27 -04:00
Jafar Al-Gharaibeh
7c4e6ea920 lib: fix error message to reference FRR
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2017-07-12 11:42:25 -05:00
vivek
5b4168879d lib: Define handlers for VNI and MACIP
Define client handlers for processing add or delete of local VNIs
and local MACIPs.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-07-12 12:39:12 -04:00
Jafar Al-Gharaibeh
ef8a03ccd1 lib: Change comment to reference watchfrr
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2017-07-12 11:36:47 -05:00
vivek
2232a77c2b zebra: MAC and Neighbor (ARP/ND) handling
Implement handling of MACs and Neighbors (ARP/ND entries) in zebra:
- MAC and Neighbor database handlers
- Read MACs and Neighbors from the kernel, when needed and create
entries in zebra's MAC and Neighbor databases.
- Handle add/update/delete notifications from the kernel for MACs and
Neighbors and update zebra's database appropriately
- Inform locally learnt MACs and Neighbors to client
- Handle MACIP add/delete from client and install appriporiate entries
into the kernel
- Since Neighbor entries will be installed on an SVI, implement the
needed mappings

NOTE: kernel interface is only implemented for Linux/netlink

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:29:25 -04:00
Christian Franke
e3054ee94f zebra: prettier format for multilevel-recursive routes
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-07-12 18:28:40 +02:00
Christian Franke
8fad3ca3a0 lib: copy rmap_src too in copy_nexthops
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-07-12 18:28:03 +02:00
Christian Franke
9fb47c0584 lib,zebra: Fix ALL_NEXTHOPS iterator
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-07-12 18:27:55 +02:00
vivek
13d60d351c zebra: VNI and VTEP handling
Implement fundamental handling for VNIs and VTEPs:
- Handle EVPN enable/disable by client (advertise-all-vni)
- Create/update/delete VNIs based on VxLAN interface events and inform
client
- Handle VTEP add/delete from client and install into kernel
- New debug command for VxLAN/EVPN
- kernel interface (Linux/netlink only)

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-12 12:26:02 -04:00
Donald Sharp
4c25598b4e Merge pull request #791 from LabNConsulting/working/master/patch-set/style
A couple of compatibility/style fixes
2017-07-12 12:13:37 -04:00
Donald Sharp
991ae35b17 Merge pull request #793 from opensourcerouting/hash-double-init
lib: init & cleanup fixes
2017-07-12 08:27:24 -04:00
Quentin Young
62c3d0260c
lib: use 32-bit atomics, s/pow/mul
Some platforms don't support 64-bit atomics, missed converting a
floating point pow() to an integral mul when changing SD algo.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-11 14:43:50 -04:00
Lou Berger
c75af349d7 vty: add some more defines for backwards compatibility
Signed-off-by: Lou Berger <lberger@labn.net>
2017-07-11 14:41:44 -04:00
Daniel Walton
6319fd637b bgpd: --enable-multipath=256 setting is ignored
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Restoring some code that was unintentionally removed when we were
migrating to Quentin's parser.
2017-07-11 18:41:08 +00:00
David Lamparter
45082064cb lib: grammar_sandbox: don't pre-setup nodegraph
This shows up as still reachable allocation on exit, which is somewhat
misleading.  Note this only affects --enable-dev-build.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 16:10:30 +02:00
David Lamparter
151d7c3591 lib: drop off "masters" list on master_free()
Don't leave a dangling leaked reference.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 16:10:29 +02:00
David Lamparter
8d8763f407 lib: fix out-of-tree build
"$(top_srcdir)" is not on the include path, but "$(top_srcdir)/lib" is.
This is relevant when building with a separate build directory.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 15:11:21 +02:00
David Lamparter
07181496b7 lib: hash: don't double-init hash list
hash_cmd_init will overwrite _hashes with a new list, while _hashes
already has been initialised from cmd_init(), thread_master_create(), or
any other function that may have created a hash.

Found while valgrind'ing ospf6d/test_lsdb.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 14:58:44 +02:00
Lou Berger
dcc0a0d117 vty: add some defines for backwards compatibility
Signed-off-by: Lou Berger <lberger@labn.net>
2017-07-11 08:48:57 -04:00
David Lamparter
736ac221d1 lib: table: use hash for exact-match lookups
Most read accesses of route_table are actually exact matches where
walking down the tree is wildly inefficient.  Use a parallel hash
structure instead.

This significantly speeds up processes that are performance-bound by
table accesses, e.g. BGP withdraw processing.  In other locations, the
improvement is not seen as strongly, e.g. when filter processing is the
limiting factor.

[includes fix to ignore prefix host bits in hash comparison]

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 13:47:31 +02:00
David Lamparter
bc7a2c035a lib: table: maintain parallel hash for route_table
See next commit for description.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 13:47:31 +02:00
David Lamparter
4cb260c33e lib: add some abstraction guards for table code
route_node->parent and route_node->link shouldn't be touched by user
code since that is a recipe for trouble once we have a hash table in
parallel.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 13:47:31 +02:00
David Lamparter
9dc716d64c lib: use "union prefixconstptr" in table code
This allows passing struct prefix_{ipv4,ipv6,evpn} * in addition to
struct prefix * without an extra cast (since the union uses the gcc
transparent-union extension present in all compilers that we support.)

Also applies some "const" while we're at it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11 13:47:27 +02:00
Donald Sharp
7fb9d20fcf lib: Remove typedef from ipaddr
The ipaddr_t type was conflicting with code on omnios.

Remove the typedef

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-10 22:15:56 +02:00
David Lamparter
21bb7c8774 Merge commit '3d22338f04d9554fa' into evpn-prep
Conflicts:
	lib/Makefile.am

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-10 22:15:19 +02:00
Daniel Walton
dfd8121281 Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-ipv4-plus-label-misc3
Conflicts:
	bgpd/bgp_route.c
	bgpd/bgp_zebra.c
2017-07-10 13:06:19 +00:00
Russ White
ceae5559a5 Merge pull request #778 from qlyoung/fix-excess-docstring
Fix excess docstring
2017-07-07 13:31:08 -04:00
Quentin Young
007b0667e0
lib: fix more docstrings
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-06 16:27:48 -04:00
David Lamparter
ecf3d1b9d5 lib: fix vty_out with >1024 bytes of output
Consuming va_args modifies its internal bits, hence the need to copy
it... but the copying wasn't quite right just yet.

Fixes: 4d5f445 ("lib: add vty_outln()")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-06 17:35:25 +02:00
Daniel Walton
b83c95ce27 Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-ipv4-plus-label-misc3 2017-07-05 19:41:51 +00:00
Quentin Young
7111c1a0cd
*: fix excess docstring
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-05 15:33:00 -04:00
Quentin Young
ebb0813089
lib: warn about too much docstring
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-05 14:30:16 -04:00
Quentin Young
e703a0f3af
lib, vtysh: rebase hashstats
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-01 19:18:39 -04:00
Quentin Young
b3db0a22b7
lib: use doubles instead of long doubles
NetBSD can't take the square root of a long double
and we should be fine just using a double here anyway

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-01 19:18:38 -04: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
6f6f00107e
lib, vtysh: hashtable statistics
Adds the ability to name hash tables, and a new cli command that will
show various summary statistics for named hash tables.

Statistics computed are
  - load factor
  - full load factor (see comments)
  - stddev of full load factor

Standard deviation is computed by storing the sum of squares of bucket
lengths. This is somewhat susceptible to overflow. On platforms where a
double is 32 bits, placing 65535 or more elements into a hash table
opens up the potential for overflow, depending on how they are arranged
in buckets (which depends on the hash function). For example, placing
65535 elements into one hash bucket would cause ssq overflow, but
distributing 40000000 elements evenly among 400000 buckets (100 elements
per bucket) would not.

These cases are extremely degenerate, so the vague possibility of
overflow in an informational command is deemed an acceptable tradeoff
for constant time calculation of variance without locks or compromising
efficiency of actual table operations.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-01 19:18:35 -04:00
Quentin Young
4db0cff16a
lib: add statistics for hash tables
Adds a function that calculates various statistics on our implementation
of a hash table. These are useful for evaluating performance.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-01 19:18:06 -04:00
Daniel Walton
1161690b93 Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-ipv4-plus-label-misc3
Conflicts:
	bgpd/bgp_route.c
2017-06-30 17:52:56 +00:00
Quentin Young
fe232cf819 lib: printf bugfixes & improvement
* Fix bad format specifier in thread.[ch]
* Move PRINTF_ATTRIBUTE macro to zebra.h
* Use PRINTF_ATTRIBUTE on termtable printers

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-30 16:18:20 +00:00
Jafar Al-Gharaibeh
4a19f832b4 Merge pull request #768 from qlyoung/fix-gitignore2
lib, bgpd: fix .gitignore
2017-06-30 10:38:20 -05:00
Jafar Al-Gharaibeh
1d0ca3ebf3 Merge pull request #770 from donaldsharp/zclient
Zclient
2017-06-30 10:35:28 -05:00
Jafar Al-Gharaibeh
b5a46fd2a6 Merge pull request #723 from qlyoung/fix-static-pipe-poker-buf
lib: more multithreading infra work
2017-06-30 10:00:43 -05:00
Russ White
801ec168a4 Merge pull request #769 from qlyoung/fix-json-int
lib: always use 64-bit integers for json
2017-06-30 10:44:03 -04:00
Donald Sharp
85bf0f3237 lib: Fix clang warning
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-30 10:29:14 -04:00
Jafar Al-Gharaibeh
fd576f61bc Merge pull request #767 from donaldsharp/if_update
bgpd, lib, zebra: Fix if_update function to represent what it does
2017-06-29 23:42:21 -05:00
Quentin Young
26eb0e4ff5 lib: fix merge error
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 23:40:57 +00: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
62f4402239 lib: make show thread... commands mt-aware
This patch fixes up show thread commands so that they know about
and operate on all extant thread_masters, since we can now have multiple
running in any given application.

This change also eliminates a heap use after free that appears when
using a single cpu_record shared among multiple threads. Since struct
thread's have pointers to bits of memory that are freed when the global
statistics hash table is freed, later accesses are invalid. By moving
the stats hash to be unique to each thread_master this problem is
sidestepped.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 23:37:08 +00:00
Quentin Young
e0bebc7c22 lib: mt-safe tracebacks
can't be using them statics anymore sonny

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 23:32:15 +00:00
Quentin Young
0693f6fc75 lib: un-static trash buffer for pipe poker
data races

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 23:32:15 +00:00
Quentin Young
d849012d19 lib: always use 64-bit integers for json
json-c does not (yet) offer support for unsigned integer types, and
furthermore, the docs state that all integers are stored internally as
64-bit. So there's never a case in which we would want to limit,
implicitly or otherwise, the range of an integer when adding it to a
json object.

Among other things this fixes the display of ASN values greater than
(1/2) * (2^32 - 1)

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 23:05:36 +00:00
Quentin Young
9478f47801 lib, bgpd: fix .gitignore
gotta ignore clippy stuff

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 19:39:36 +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
e31b6333f4 *: vty_outln (vty, "") --> vty_out (vty, VTYNL)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 17:34:56 +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
Quentin Young
4d5f445750 lib: add vty_outln()
Like *.println() in some other unspeakable languages

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29 16:28:21 +00:00
Russ White
9e3b206d7c Merge pull request #701 from qlyoung/mt-safe-cancel
mt-safe thread_cancel()
2017-06-29 11:09:24 -04:00
Russ White
5bee21f37c Merge pull request #735 from qlyoung/fix-routemap
Fix routemap
2017-06-29 11:06:52 -04:00
Russ White
0bc44f61c9 Merge pull request #754 from qlyoung/fix-argv-arg
use argv->text where appropriate
2017-06-29 11:06:15 -04:00
Jafar Al-Gharaibeh
0eef52fd95 Merge pull request #759 from qlyoung/remove-vty-argparsers
*: remove VTY_GET_*
2017-06-29 09:36:06 -05:00
Donald Sharp
16895dbf73 bgpd, lib, zebra: Fix if_update function to represent what it does
The if_update function was taking the interface name as
input and reapplying it, using strncpy to reapply the name.
This has several issues.  strncpy should not be used
to copy memory in place.  The second issue is that
the interface name is not actually changing when we
update interface to be in the new vrf.

Since every usage of if_update was just reapplying the same
name the interface actually had, just remove that part of
the function and rename it to if_update_to_new_vrf
to represent what it is actually doing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-29 09:09:23 -04: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
Don Slice
3bec29ac95 lib/ospf/eigrp: enable ospf and eigrp to use more specific network statements
Issue reported that a configuration commonly used on other routing implementations
fails in frr.  If under ospf, "network 172.16.1.1/32 area 0" or under eigrp, "network
172.16.1.1/32" is entered, the appropriate interfaces are not included in the routing
protocol.  This was because the code was calling prefix_match, which did not match if
the network statement had a longer mask than the interface being matched.  This fix
takes away that restriction by creating a "lib/prefix_match_network_statement" function
which doesn't care about the mask of the interface.  Manual testing shows both ospf and
eigrp now can be defined with more specific network statements.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-06-28 14:57:36 -04: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
facfee22f5 *: remove VTY_GET_*
CLI validates input tokens, so there's no need to do it in handler
functions anymore.

spatch follows
----------------

@getull@
expression v;
expression str;
@@
<...
- VTY_GET_ULL(..., v, str)
+ v = strtoull (str, NULL, 10)
...>

@getul@
expression v;
expression str;
@@
<...
- VTY_GET_ULONG(..., v, str)
+ v = strtoul (str, NULL, 10)
...>

@getintrange@
expression name;
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER_RANGE(name, v, str, ...)
+ v = strtoul (str, NULL, 10)
...>

@getint@
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER(..., v, str)
+ v = strtoul (str, NULL, 10)
...>

@getv4@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_ADDRESS(..., v, str)
+ inet_aton (str, &v)
...>

@getv4pfx@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_PREFIX(..., v, str)
+ str2prefix_ipv4 (str, &v)
...>

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-27 19:04:41 +00:00
Quentin Young
7e045c3d42 *: use ->text and strmatch where appropriate
Still need to go fix all the places where we do a 1-char strncmp...

spatch follows
------------------

@asdf@
expression idx;
@@
<...
 strcmp (
- argv[idx]->arg,
+ argv[idx]->text,
  ...)
...>

@depends on asdf@
expression idx;
@@
<...
- !strcmp (argv[idx]->text,
+ strmatch (argv[idx]->text,
           ...)
...>

@depends on asdf@
expression idx;
expression arg;
@@
<...
- strcmp (argv[idx]->text, arg) == 0
+ strmatch (argv[idx]->text, arg)
...>

@depends on asdf@
expression idx;
expression arg;
@@
<...
- strcmp (argv[idx]->text, arg) != 0
+ !strmatch (argv[idx]->text, arg)
...>

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-27 17:46:42 +00:00
Jafar Al-Gharaibeh
43d372ece4 Merge pull request #748 from qlyoung/fix-vtysh-exit
lib: actually exit when asked to 'do' so
2017-06-27 10:47:45 -05:00
Daniel Walton
4fbf55e986 Merge branch 'master' of https://github.com/dwalton76/frr into bgpd-ipv4-plus-label-misc3 2017-06-26 17:24:44 +00:00
Quentin Young
5046f07672 lib: look at the correct token for json
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-22 00:19:24 +00:00
Quentin Young
e82a17c61b lib: actually exit when asked to do so
When vtysh sends 'exit' to a daemon, we set the vty->status to
VTY_CLOSE but never actually close the connection. Lovely.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21 20:06:44 +00:00
Olivier Dugeon
8ea37652c7 Merge pull request #745 from qlyoung/fix-lookup
*: simplify log message lookup
2017-06-21 18:22:52 +02:00
Quentin Young
af3346ecd5 lib: some minor cli fixups for routemap
Need to use the appropriate token field

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21 15:41:35 +00:00
Quentin Young
56b4067930 *: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b

The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21 15:22:21 +00:00
Daniel Walton
c1a44e4367 Merge branch 'master' into bgpd-ipv4-plus-label-misc3 2017-06-21 10:30:29 -04:00
Russ White
4ce856eef7 Merge pull request #698 from dslicenc/cm16737-srgb-block
zebra: define default segment routing global block values
2017-06-19 22:00:57 -04:00
Russ White
a88bbcb8a0 Merge pull request #732 from qlyoung/coverity-memes
lib: termtable coverity warnings
2017-06-19 21:52:10 -04:00
Donald Sharp
d368cd48b9 Merge pull request #730 from opensourcerouting/rbtree-improvement
RB tree improvement
2017-06-19 17:27:55 -04:00
Rafael Zalamena
b19ad86195 lib: fix __unused compilation on old platforms
Expand the macro __attribute__ to avoid problem with old platforms that
do not define this.
2017-06-19 13:24:04 -03:00
Rafael Zalamena
5508764270 lib: rename rb_tree to fix NetBSD compilation
Change rb_tree struct name to rbt_tree to avoid conflicts with NetBSD.
2017-06-19 13:17:35 -03:00
Quentin Young
58b0878ac6 ospfd: fix route-map brokenness
ospf redefines the standard route map commands which causes ambiguity
issues in the CLI parser, it also uses a signed integer to hold an
unsigned quantity leading to weirdness when specifying metrics larger
than 2,147,483,647

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-17 00:49:15 +00:00
Quentin Young
98f224ef22 lib: improve routemap error messages
indicate which daemon was the source of the message and that it may be a
question of daemon support rather than a malformed argument

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-16 22:43:09 +00:00
Donald Sharp
6021c8d382 lib: Fix ordering of RB Tree
So the *bsd implementations of RB Tree's for older
platforms use a macro implementation.  New platforms
have converted to a function implementation that uses
a different calling parameter list.  So when
we attempt to build FRR on older *bsd implementations
the macro's and functions do not interact too well.

As a workaround put the openbsd-tree.h #include
inside of zebra.h at a point before the particular
platforms version is included.  Since we use
the same #if guard for the header we should be ok.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-16 17:48:18 -04:00
David Lamparter
2dc1ef552b Merge pull request #725 from donaldsharp/vrf_completion
Vrf completion
2017-06-16 21:59:23 +02:00
Quentin Young
7feb7d7e65 lib: tighten up exit semantics for thread_fetch()
* Account for the pipe poker in poll() by explicitly returning NULL when
  we have no events, timers or file descriptors to work with
* Add a comment explaining exactly what we are doing and why

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-16 19:56:58 +00:00
Quentin Young
8797240ea4 lib: mt-safe cancel, round deux
* Update pollfds copy as well as the original
* Keep array count for copy in thread_master
* Remove last remnants of POLLHUP in .events field
* Remove unused snmpcount (lolwut)
* Improve docs
* Add missing do_thread_cancel() call in thread_cancel_event()
* Change thread_fetch() to always enter poll() to avoid starving i/o
* Remember to free up cancel_req when destroying thread_master
* Fix dereference of null pointer
* Fix dead store to timeval
* Fix missing condition for condition variable :-)

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-16 19:56:58 +00:00
Quentin Young
63ccb9cb12 lib: add mt-safe thread_cancel
This patch implements an MT-safe version of thread_cancel() in
thread_cancel_async(). Behavior as follows:

* Cancellation requests are queued into a list

* Cancellation requests made from the same pthread as the thread_master
  owner are serviced immediately (thread_cancel())

* Cancellation requests made from a separate pthread are queued and the
  call blocks on a condition variable until the owning pthread services
  the request, at which point the condition variable is signaled and
  execution continues (thread_cancel_async())

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-16 19:56:58 +00:00
Daniel Walton
9bedbb1e52 bgpd: Install SAFI_LABELED_UNICAST routes in SAFI_UNICAST table
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

- All ipv4 labeled-unicast routes are now installed in the ipv4 unicast
  table. This allows us to do things like take routes from an ipv4
  unicast peer, allocate a label for them and TX them to a ipv4
  labeled-unicast peer. We can do the opposite where we take routes from
  a labeled-unicast peer, remove the label and advertise them to an ipv4
  unicast peer.

- Multipath over a labeled route and non-labeled route is not allowed.

- You cannot activate a peer for both 'ipv4 unicast' and 'ipv4
  labeled-unicast'

- The 'tag' variable was overloaded for zebra's route tag feature as
  well as the mpls label. I added a 'mpls_label_t mpls' variable to
  avoid this.  This is much cleaner but resulted in touching a lot of
  code.
2017-06-16 19:12:57 +00:00
Quentin Young
94b989402f lib: termtable coverity warnings
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-16 19:04:57 +00:00
Renato Westphal
c740f7d367 ldpd: convert cli and get rid of the xml interface
The xml2cli.pl script was useful years ago when the vty code was very
rudimentary. This is not the case anymore, so convert all ldpd CLI
commands to use DEFUNs directly and get rid of the XML interface.

The benefits are:
* Consistency with the other daemons;
* One less build dependency (the LibXML perl module);
* Easier to add new commands.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-06-16 14:43:42 -03:00
Donald Sharp
d7a75a6ca6 lib, vtysh, zebra: Fix per CR comments
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-16 13:09:37 -04:00
Donald Sharp
d617d5febf *: Add vrf autocompletion for commands
Switch NAME to VRFNAME and add vrf autocompletion
to commands that have them

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-16 13:01:51 -04:00
David Lamparter
62e4232010 Merge pull request #718 from qlyoung/fix-vtysh-shit
lib: allow 'do' commands in ENABLE_NODE
2017-06-16 18:25:48 +02:00