Commit Graph

3440 Commits

Author SHA1 Message Date
Donatas Abraitis
240c41c821
Merge pull request #4908 from qlyoung/vtysh-find-regexp
vtysh, lib: allow regexp in `find` command
2019-09-04 14:47:34 +03:00
Donald Sharp
4e279d01b7
Merge pull request #4918 from brchiu/fix_values_cnt_error
lib: Fix erroneously setting pointer values_cnt as NULL
2019-09-04 06:53:33 -04:00
Bi-Ruei, Chiu
dd9a956ee6 lib: Fix erroneously setting pointer values_cnt as NULL
It should be :

  *values_cnt = 0;

not

  values_cnt = 0;

Signed-off-by: Bi-Ruei, Chiu <biruei.chiu@gmail.com>
2019-09-04 08:27:43 +08:00
Quentin Young
68912a2066 vtysh, lib: allow regexp in find command
¯\_(ツ)_/¯

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-09-03 16:09:52 +00:00
David Lamparter
0cf6db21ec *: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:18:35 +02:00
David Lamparter
00dffa8cde lib: add frr_with_mutex() block-wrapper
frr_with_mutex(...) { ... } locks and automatically unlocks the listed
mutex(es) when the block is exited.  This adds a bit of safety against
forgetting the unlock in error paths & co. and makes the code a slight
bit more readable.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:15:17 +02:00
David Lamparter
48373d46f1 lib: add some macro helpers
Macro soup, now with 50% more macros.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:15:17 +02:00
Donald Sharp
cda7187d27 *: Convert some route map functions to return the enum
Conver these functions:
route_map_add_match
route_map_delete_match
route_map_add_set
route_map_delete_set

To return the `enum rmap_compile_rets` and ensure all functions
that use this code handle all the enumerated possible returns.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-03 08:19:22 -04:00
Donald Sharp
e5b4b49e80 lib: Cleanup return codes to use enum values
A couple functions in routemap.c were returning
0/1 that were being mapped into the appropriate
enum values on the calling functions to check return
values.  This matches the return values to the actual
enum for future readability.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-03 08:19:22 -04:00
David Lamparter
ed18356f1f bgpd/bmp: BMP implementation
This implements BMP.  There's no fine-grained history here, the non-BMP
preparations are already split out from here so all that remains is BMP
proper.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-08-30 19:22:23 +02:00
David Lamparter
8defc5be52 lib: add monotime_to_realtime()
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-08-30 19:00:45 +02:00
David Lamparter
5c52c06c5c lib: add pull-driven data write handler
This - mostly intended for BMP - implements a pull-driven write buffer
filled on demand by a callback with some reasonable buffering logic.

I don't expect it to be that useful in other places, but it's not BMP
specific so it's properly split off in its own place.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-08-30 19:00:45 +02:00
Donald Sharp
11375c5274 lib: Stop arm crash on shutdown
Arm platforms are crashing in our topotests with this callstack;

50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0xffffabb591d0 (LWP 18947))]
(gdb) bt
    file=file@entry=0xaaaadfed1e48 "lib/memory.c", line=line@entry=80,
    function=function@entry=0xaaaadfed1db8 <__func__.10514> "mt_count_free") at lib/log.c:837
(gdb)

So we are crashing because we are attempting to free a mtype that has no allocations
associated with it.

I added this debug code:
@@ -227,7 +230,9 @@ static void rcu_bump(void)
     struct rcu_next *rn;

     rn = XMALLOC(MTYPE_RCU_NEXT, sizeof(*rn));
-
+    zlog_debug("RCU_BUMP");
+    mtype_dump(MTYPE_RCU_THREAD);
+    mtype_dump(MTYPE_RCU_NEXT);
     /* note: each RCUA_NEXT item corresponds to exactly one seqno bump.
      * This means we don't need to communicate which seqno is which
      * RCUA_NEXT, since we really don't care.

and added a mtype_dump function:
+void mtype_dump(struct memtype *mt)
+{
+    zlog_debug("%s: %d", mt->name, (int)mt->n_alloc);
+}

Which resulted in this output:

2019/08/28 15:41:11 BGP: RCU_BUMP
2019/08/28 15:41:11 BGP: RCU thread: 3
2019/08/28 15:41:11 BGP: RCU thread: 3

If we look at the defintion of the two static memory types:

DEFINE_MTYPE_STATIC(LIB, RCU_THREAD,    "RCU thread")
DEFINE_MTYPE_STATIC(LIB, RCU_NEXT,      "RCU sequence barrier")

I would have expected the output to be:
RCU_BUMP
RCU thread: 3
RCU sequence barrier: X

instead.

As a thought experiment I reduced the number of static memory types
to 1 in the file and the crash stopped happening.

I suspect we have a systematic error on arm in lib/memory.h
due to the asm code.  I am going to leave that alone for the
moment ( and leave the crash issue open ), but see if we
can get this code change into the system so that our CI
system becomes happy again.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-28 12:09:41 -04:00
Donald Sharp
fd00c97cfa *: Start process of possibly deprecating Solaris
The FRR community has run into an issue where keeping up our
CI system to work with solaris has become a fairly large burden.
We have also sent emails and asked around and have not found
anyone standing up saying that they are using Solaris.

Given the fact that we do not have any comprehensive testing
being done w/ solaris and the fact that we are getting a steady
stream of new features that will never work on solaris and
we cannot find anyone to say that they are using it.  Let's
start the drawn out process of deprecating the code.

If in the mean-time someone comes forward with the fact that
they are using it we can then not deprecate it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-27 14:55:48 -04:00
Philippe Guibert
87272aff32 lib: call vrf update hook when default vrf name changes
this is a call done whenever vrf name changes. This is useful on remote
daemons.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 15:08:50 +02:00
Donald Sharp
dd7c916952
Merge pull request #4880 from ddutt/master
lib: Make if_lookup_by_index understand if VRF is backed by netns or not
2019-08-26 14:08:08 -04:00
Donald Sharp
dec2a1469f
Merge pull request #4812 from pogojotz/fix-destination-multi-use
zebra: Do not use connection dest for bcast
2019-08-26 09:25:17 -04:00
Dinesh G Dutt
47b474b57e lib: Make if_lookup_by_index understand if VRF is backed by netns or not
FRR has two implementations of VRF, one backed by netns and the other by
the proper VRF implementation in the Linux kernel. In certain places, the
code assumes that a VRF is netns and so lookups fail. One example of this
is in IPv6 RA code. This causes functionality such as Unnumbered BGP to
fail. To fix this, this patch makes if_lookup_by_index handle the
behavior based on the backend, similar to if_get_by_index. For the two
places in if.c that were calling if_lookup_by_index to be specific to
the VRF, I renamed the existing code, if_lookup_by_ifindex and made it a
static function that is never exposed or called by any routine outside of
if.c.

Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
2019-08-26 12:38:28 +00:00
Donald Sharp
9c24774d7a
Merge pull request #4795 from opensourcerouting/assorted-fixes
Minor assorted fixes
2019-08-26 08:32:31 -04:00
Mark Stapp
a9e08ebce1 lib: use const in prefix_mac2str
Use const for mac pointer.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-23 10:09:38 -04:00
Mark Stapp
13afe82b5b lib: remove deprecated stream_resize api
Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-22 08:52:25 -04:00
Renato Westphal
3923b6e309 lib: fix a couple more doc comments
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 11:41:14 -03:00
Renato Westphal
ef231ac76c lib: switch str2prefix_ipv4() to use inet_pton()
This is the second part of commit 8d92004979, which converted
only one of the two calls to inet_aton().

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 11:41:10 -03:00
Renato Westphal
681b22affa lib: fix doc comment of the "cli_show_end" northbound callback
The 'show_defaults' parameter is present on the "cli_show" callback
only.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 00:53:00 -03:00
Renato Westphal
20054cb4b1 lib: fix uint32_t overflow in a couple of CLI commands
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 00:53:00 -03:00
Renato Westphal
6a2b0d9a7a lib: don't ignore stream errors in some zapi decode functions
Some other ZAPI decode functions still use void return values and
can't propagate stream errors to their callers. They need to be fixed
as well in the future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 00:53:00 -03:00
Don Slice
dc91261567 bgpd: make clear bgp * clear all peers in all afi/safis
Problem reported that "clear bgp *" only cleared ipv6 peers.
Changed the logic to clear all afi/safis of all peers in
that case.  Also improved the operation of clearing
individual afi/safi using soft/in/out to do the right thing.

Ticket: CM-25887
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-08-20 13:50:58 +00:00
Stephen Worley
3c6e0bd472 lib: Sort zapi_nexthops on the encode
Sort nexthops before we push them to zebra. This offloads
the nexthop sorting zebra is doing onto the upper level protocols
so that when it gets to zebra and we construct a group, it just has
to append them to the tail for every nexthop.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-08-19 15:56:45 -04:00
Stephen Worley
8c15fa95a8 lib: Add tail check before nexthop insertion
Add a tail check to see if we can just put the nexthop
at the end of the already sorted list before iteration.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-08-19 13:55:50 -04:00
Donald Sharp
f79f7a7bb2 *: Fix spelling errors pointed out by debian packaging
Debian packaging when run finds a bunch of spelling errors:

I: frr: spelling-error-in-binary usr/bin/vtysh occurences occurrences
I: frr: spelling-error-in-binary usr/lib/frr/bfdd Amount of times Number of times
I: frr: spelling-error-in-binary usr/lib/frr/bgpd occurences occurrences
I: frr: spelling-error-in-binary usr/lib/frr/bgpd recieved received
I: frr: spelling-error-in-binary usr/lib/frr/isisd betweeen between
I: frr: spelling-error-in-binary usr/lib/frr/ospf6d Infomation Information
I: frr: spelling-error-in-binary usr/lib/frr/ospfd missmatch mismatch
I: frr: spelling-error-in-binary usr/lib/frr/pimd bootsrap bootstrap
I: frr: spelling-error-in-binary usr/lib/frr/pimd Unknwon Unknown
I: frr: spelling-error-in-binary usr/lib/frr/zebra Requsted Requested
I: frr: spelling-error-in-binary usr/lib/frr/zebra uknown unknown
I: frr: spelling-error-in-binary usr/lib/x86_64-linux-gnu/frr/libfrr.so.0.0.0 overriden overridden

This commit fixes all of them except the bgp `recieved` issue due to
it being part of json output.  That one will need to go through
a deprecation cycle.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-08-19 10:36:53 -04:00
Juergen Werner
0f3af7386e zebra: Do not use connection dest for bcast
The `destination` field of the connection structure was used to store
the broadcast address, if the connection was not p2p. This multipurpose
is not very evident and the benefits over calculating the bcast address
on the fly minimal.

Signed-off-by: Juergen Werner <juergen@opensourcerouting.org>
2019-08-18 18:54:46 +02:00
Donald Sharp
f067bdf8e2
Merge pull request #4832 from ddutt/master
Clean up zebra's show interface display
2019-08-17 09:00:47 -04:00
Dinesh G Dutt
ea7ec26162 zebra: Ensure master's ifname is known, even if slave comes up first
In if_netlink.c, when an interface structure, ifp, is first created,
its possible for the master to come up after the slave interface does.
This means, the slave interface has no way to display the master's ifname
in show outputs. To fix this, we need to allow creation by ifindex instead
of by ifname so that this issue is handled.

Signed-off-by: Dinesh G Dutt<5016467+ddutt@users.noreply.github.com>
2019-08-13 16:29:40 +00:00
David Lamparter
bb5fd82d90
Merge pull request #4677 from mruprich/master
ospfd,ripd: Enabling openssl library for md5 authentication in RIP and OSPF
2019-08-12 17:09:14 +02:00
Mark Stapp
595ad74b77
Merge pull request #4793 from qlyoung/fix-bgp-labeled-unicast-addpath
bgpd: tx addpath info for labeled unicast
2019-08-12 08:51:36 -04:00
Michal Ruprich
0513a27153 ospfd,ripd: Enabling build with openssl
Enabling openssl library for md5 authentication in RIP and OSPF

Signed-off-by: Michal Ruprich <michalruprich@gmail.com>
2019-08-08 16:03:20 +02:00
Donald Sharp
76eb017923
Merge pull request #4497 from opensourcerouting/rcu
RCU support
2019-08-08 08:41:07 -04:00
Donald Sharp
3a738964ec
Merge pull request #4763 from opensourcerouting/ds-work
lib: get rid of pqueue_*, use DECLARE_HEAP in thread.c
2019-08-07 16:45:02 -04:00
Quentin Young
ec15e1b588 bgpd: tx addpath info for labeled unicast
Labeled unicast needs path IDs too!

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-08-06 21:46:46 +00:00
Quentin Young
3c1c172f02
Merge pull request #4790 from opensourcerouting/ctype-cast
*: fix ctype casts
2019-08-06 13:21:13 -04:00
David Lamparter
fefa5e0ff5 *: fix ctype (isalpha & co.) casts
The correct cast for these is (unsigned char), because "char" could be
signed and thus have some negative value.  isalpha & co. expect an int
arg that is positive, i.e. 0-255.  So we need to cast to (unsigned char)
when calling any of these.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-06 16:54:52 +02:00
David Lamparter
c8ec87df6e
all: remove logical-router functionality (#4774)
all: remove logical-router functionality
2019-08-06 16:45:56 +02:00
Stephen Worley
00a7f422c3 lib: Remove double log mutex unlock
Coverity report caught this log mutex being unlocked twice.
Removing the extra one before the goto statement.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-08-02 11:15:10 -04:00
Igor Ryzhov
c7975431e6 all: remove logical-router functionality
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-08-02 17:10:11 +03:00
David Lamparter
77faa5bd79 lib: remove pqueue_* (again)
All users of the pqueue_* implementations have been migrated to use
some new data structure (TYPEDSKIP for ospf, HEAP for thread.c).

Remove.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-08-01 17:02:53 +02:00
David Lamparter
27d29ced68 lib: use DECLARE_HEAP for timers instead of pqueue
Replaces the use of pqueue_* for the thread_master's timer list with an
instance of DECLARE_HEAP_*.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-08-01 16:59:29 +02:00
Stephen Worley
0ca16c58a8 lib: Add const to _count() in new list APIs
Add const to the datastructure being passed to the new list APIs
for the `_count()` calls.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-07-31 11:35:21 -04:00
Stephen Worley
571a045bdf lib: Add identifiers to RB declarations
Checkpatch was complaining about the lack of identifiers here, so
added some.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-07-31 11:35:21 -04:00
Stephen Worley
da098d78bb lib: Impelement the *_del list API.
The new list api did not implement the `*_del` endpoint as
it was described in the docs here:

http://docs.frrouting.org/projects/dev-guide/en/latest/lists.html#c.Z_del

This patch implements the endpoints to return the object deleted if
found, otherwise NULL for all but the atomic lists.

The atomic list `*_del` code is marked as TODO and will remain undefined
for now.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-07-31 11:35:21 -04:00
David Lamparter
3e41733f1b lib: RCU
Please refer to doc/developer/rcu.rst for documentation.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-31 03:34:09 +02:00
David Lamparter
30ef834ab3 lib/seqlock: add a few more comments
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-31 03:33:41 +02:00
David Lamparter
2a5e62359f lib/seqlock: add timed-wait operation
seqlock_timedwait() puts an (absolute, CLOCK_MONOTONIC) deadline on how
long we wait.  The RCU code uses this for its watchdog implementation.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-31 03:33:41 +02:00
David Lamparter
6046b690b5 lib/seqlock: avoid syscalls in no-waiter cases
When we have no contention on the seqlock, we shouldn't incur the cost
of syscalls.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-31 03:33:41 +02:00
David Lamparter
5e4f10b1e0 lib: make SA_SIGINFO use unconditional
This has been in POSIX for ages & there's no OS left that doesn't
support this.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-31 03:33:41 +02:00
Russ White
65c52bd33d
Merge pull request #4732 from qlyoung/ercode-oncec
vtysh: only show error codes once
2019-07-30 10:58:45 -04:00
Russ White
997d9b60cd
Merge pull request #4649 from ton31337/feature/access-list_sequence
filter: Introduce sequence number for access-list
2019-07-30 10:40:42 -04:00
Donald Sharp
e24e573519
Merge pull request #4560 from lkrishnamoor/filter_vni_changes_jun
bgp: Route-map VNI in-filter filters out all the routes for EVPN
2019-07-30 09:41:22 -04:00
Quentin Young
1f9128d69f vtysh: only show error codes once
When using `show error` commands, show errors shared between multiple
daemons only once.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-07-29 17:18:18 +00:00
David Lamparter
4937287fb9 lib: fix prefix_copy() for clang-SA
https://bugs.llvm.org/show_bug.cgi?id=42811

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-29 15:49:49 +02:00
David Lamparter
4d5cf6bc46 lib: fix misplaced brace in typesafe lists
OMGWTFBBQ no. 2...

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-28 09:27:03 +02:00
David Lamparter
9c3a217137 lib: use some more transparent unions for prefixes
... so we can pass prefix_ipv4/prefix_ipv6 in.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-28 09:26:21 +02:00
David Lamparter
1315d74de9 lib: fix prefix_cmp() return values
OMGWTFBBQ

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-28 09:25:58 +02:00
Lakshman Krishnamoorthy
b68885f9b7 lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP

Traditionally route map MATCH rule apis  were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:

State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away

State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH

We require a 3rd state because of the following situation:

The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.

Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"

With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.

As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-07-22 08:08:13 -07:00
Donald Sharp
a85de978b6
Merge pull request #4704 from mjstapp/fix_ip2str_const
lib: use const in ipaddr2str
2019-07-17 18:59:08 -04:00
Mark Stapp
24774285ed lib: use const in ipaddr2str
Use const more

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-07-17 16:59:41 -04:00
Jafar Al-Gharaibeh
5f7faeb041
Merge pull request #4635 from AnuradhaKaruppiah/evpn-pim-replay
pimd, zebra: request for replay of VxLAN SG entries on pimd startup
2019-07-15 15:40:12 -05:00
Renato Westphal
07a4ddf2b6
Merge pull request #4660 from manuhalo/label_manager_fixes
Label manager improvements + refactor
2019-07-12 17:09:33 -03:00
Quentin Young
11dbb76eeb
Merge pull request #4674 from mjstapp/fix_mono_ctime
lib,zebra: avoid use of ctime in monotime api
2019-07-11 16:05:03 -04:00
Mark Stapp
c9049b920f lib,zebra: avoid use of ctime in monotime api
Replace a call to ctime with ctime_r in the monotime module;
update the callers of the monotime api.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-07-10 10:16:59 -04:00
Emanuele Di Pascale
f004f7c3ce lib, zebra: handle failure in get chunk
when requesting a specific label chunk (e.g. for the SRGB),
it might happen that we cannot get what we want. In this
event, we must be prepared to receive a response with no
label chunk. Without this fix, if the remote label manager
was not able to alloate the chunk we requested, we would
hang indefinitely trying to read data from the stream which
was not there.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-07-10 15:20:27 +02:00
Emanuele Di Pascale
0e3b6a926a lib, zebra: support label chunk requests for SRGB
For SRGB, we need to support chunk requests starting at a
specific point in the label space, rather than just asking
for any sufficiently large chunk. To this purpose, we extend
the label manager api to request a chunk with a base value;
if the base is set to 0, the label manager will behave as it
currently does, i.e. fetching the first free chunk big enough
to satisfy the request.

update all the existing calls to get chunks from the label
manager so that they use MPLS_LABEL_BASE_ANY as the base
for the requested chunk

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-07-10 15:20:27 +02:00
Russ White
af13de0af6
Merge pull request #4437 from opensourcerouting/bfdd-northbound
bfdd: migrate to northbound
2019-07-09 11:15:51 -04:00
Jafar Al-Gharaibeh
7bc33bcc19
Merge pull request #4088 from opensourcerouting/bump-libyang-requirement-vers
build, lib: bump libyang requirement version to >= 0.16.105 (-r3)
2019-07-09 17:59:17 +03:00
Donatas Abraitis
358189ad83 filter: Introduce sequence number for access-list
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-07-08 11:05:31 +03:00
Philippe Guibert
f449d22396 bgp, zebra, lib: add protocol support for iptables
in addition to support for tcpflags, it is possible to filter on any
protocol. the filtering can then be based with iptables.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-07-08 08:36:45 +02:00
Anuradha Karuppiah
ecbbc3a750 pimd, zebra: request for replay of SG entries on startup
zvni setup in zebra is controlled via bgpd i.e. advertise_all_vni
from bgpd triggers this setup. As a part of zvni creation we may need
to setup BUM mcast SG entries which are propagated to pimd for MDT setup.

Now pimd may not be present at the time of zvni creation or may restart
post zvni creation so we need a mechanism to replay (on pimd startup) and
to cleanup (on pimd stop). This is addressed via zebra_vxlan_sg_replay and
zebra_evpn_pim_cfg_clean_up.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-07-03 10:11:53 -07:00
David Lamparter
50cdb6cf95 lib/resolver: NULL out callback before call
The callback itself might want to reschedule the resolver, so it is
useful to clear out the callback field before making the call instead of
after.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-03 17:15:38 +02:00
David Lamparter
fe9e7b71cf lib: split off c-ares code from nhrpd
This is useful in other places too, e.g. for BMP outbound connections.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-03 17:15:34 +02:00
David Lamparter
a5ddc34dc7
lib: Add a couple functions to nexthop_group.c (#4323)
lib: Add a couple functions to nexthop_group.c

Co-authored-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-03 14:42:35 +02:00
David Lamparter
1df0492687
Run-time log filtering via vtysh commands (#4524)
Run-time log filtering via vtysh commands
2019-07-03 14:39:59 +02:00
Quentin Young
db9f2ddde2
Merge pull request #4634 from mjstapp/vty_report_pids
lib: add process pids to 'show modules'
2019-07-02 16:39:28 -04:00
Mark Stapp
bfae97a6fa lib: add process pids to 'show modules'
Add the process pids to the output produced by 'show modules'.
At least in a development setting, where there may be multiple
instances of frr running, it can be handy to be able to id
the exact pids, for debugging e.g.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-07-02 15:15:13 -04:00
David Lamparter
e846ec9806
Merge pull request #4624 from qlyoung/use-standard-bools
*: s/TRUE/true/, s/FALSE/false/
2019-07-02 17:51:09 +02:00
Renato Westphal
dfe2273849 lib: use flag from new libyang version to simplify the code
When using the LYD_PATH_OPT_NOPARENTRET flag, lyd_new_path() returns
the path-referenced node instead of the first created node. This
flag wasn't available in libyang 0.16-r1 so we couldn't use it
before. Use it now to simplify the code where possible.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-07-02 11:32:06 -03:00
Renato Westphal
cd327983bd lib: fix a couple of yang validation issues
libyang-0.16-r3 contains a commit[1] that changed the autodelete
behavior of subtrees when validating data. A few FRR commands were
affected by this change since they relied on the old autodelete
behavior.

To fix these commands, use the LYD_OPT_WHENAUTODEL flag when
validating data to restore the old autodelete behavior (which adds
a lot of convenience for us).

[1] https://github.com/CESNET/libyang/commit/bbc43b1b4

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-07-01 22:56:52 -03:00
Quentin Young
2951a7a4c2 *: s/TRUE/true/, s/FALSE/false/
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-07-01 17:26:05 +00:00
Stephen Worley
50d8965075 lib: Private api for nexthop_group manipulation
Add a file that exposes functions which modify nexthop groups.
Nexthop groups are techincally immutable but there are a
few special cases where we need direct access to add/remove
nexthops after the group has been made. This file provides a
way to expose those functions in a way that makes it clear
this is a private/hidden api.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:48 -04:00
Stephen Worley
504d0a4096 lib: Add a nexthop_dup() that allocates and copies
Add a nexthop_dup() api that both allocates and copies
a new nexthop from an old one. Still retain the old exposed
function nexthop_copy() so we can copy without allocation.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:47 -04:00
Stephen Worley
e7addf02a1 lib: Put single nexthop copy into its own function
Put the code to copy a single nexthop into a function
of its own.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:47 -04:00
Donald Sharp
6c8b51e172 lib: Add a couple functions to nexthop_group.c
Add nexthop_group_copy and nexthop_group_add_sorted functions.

nexthop_group_copy -> Copy src nexthop_group into dst nexthop_group
nexthop_group_add_sorted -> Adds a new nexthop to the nexthop group
in a sorted manner.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-25 22:58:47 -04:00
Rafael Zalamena
9b2d87406a
Merge pull request #4525 from donaldsharp/some_cleanups
Some cleanups
2019-06-25 16:06:57 -03:00
Sri Mohana Singamsetty
4b7269c42f
Merge pull request #4570 from donaldsharp/route_map_clear
lib: Add `clear route-map counters [WORD]` command
2019-06-25 10:34:11 -07:00
David Lamparter
eb44e1aac0 lib: add a check for {[...]} in DEFUNs
Our command matcher doesn't handle {[...]} correctly;  let's warn about
it so the DEFUN can be changed to [{...}] (which does work as expected.)

Fixes: #4594
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-25 13:35:21 +02:00
Donald Sharp
a36898e755
Revert "Ospf missing interface handling 2" 2019-06-23 19:46:39 -04:00
Donald Sharp
a12bb225a6
Merge pull request #3775 from pguibert6WIND/ospf_missing_interface_handling_2
Ospf missing interface handling 2
2019-06-22 13:35:45 -04:00
Rafael Zalamena
020a390649 lib: fix northbound static analyzer warning
Make the function parameter `const` so the analyzer doesn't suspect we
are trying to change its value.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena
a4d3c1d41d lib: northbound cli support to end config nodes
Some more complex CLI usages will require northbound to support
signalizing a custom configuration node end.

For an example:

```
router bgp 100
 bgp router-id 10.254.254.1
 neighbor 10.0.0.100 remote-as 200
 !
 address-family ipv4 unicast
  network 10.0.1.0/24
  network 10.0.2.0/24
  network 10.0.3.0/24
 exit-address-family
 !
 address-family ipv6 unicast
  neighbor 10.0.0.100 activate
 exit-address-family
!
```

This commit implements a new callback called `cli_show_end` which
complements `cli_show` and is only called at the end of processing the
yang configuration node. It will be used to write the configuration
node termination like: "!" or "exit-address-family".

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:08:33 -03:00
Donatas Abraitis
f554fda700 rmap: Minor changes in comments regarding match ip[v6] next-hop type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-06-22 09:49:33 +03:00
Donatas Abraitis
d8524fbef4 rmap: Modify cli helper text for match_ipv6_next_hop_type_cmd
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-06-22 09:29:19 +03:00
David Lamparter
5a98820303
Prefix list count (#4578)
Prefix list count

Co-authored-by: null <visakha.erina@broadcom.com>
2019-06-21 16:40:30 +02:00
David Lamparter
57d898f3eb lib: fix MTYPE alias on clang
This is probably a compiler bug :/

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-21 14:51:50 +02:00
David Lamparter
eaf58ba906 lib: use MTYPE_STATIC
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-21 08:54:25 +02:00
David Lamparter
056830ba69 lib: improve MTYPE definitions
The "static struct mtype * const MTYPE_FOO" doesn't quite make a
"constant" that is usable for initializers.  An 1-element array works
better.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-21 08:54:25 +02:00
Donald Sharp
55858394f2 lib: Order show run route-map order to be alphabetical
When running `show run` of route-maps the order is basically
the order read in some fashion.  Convert the display to
always be the alphabetically sorted order.

Suggested-by: Manuel Schweizer <manuel@cloudscale.ch>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-20 15:03:05 -04:00
Donald Sharp
1fa305095a lib: Add clear route-map counters [WORD] command
This will allow the end-user to clear the counters associated
with the route-map.  Subsuquent `show route-map ..` commands
will display counters since the last clear.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-20 14:10:44 -04:00
Visakha Erina
0277936a2c lib: Keep proper count of prefix-list hit-count when used
When a prefix-list is applied to a BGP neighbor to deny the learning
of specific routes, the hit count is showing 0 for BGP even though
the routes are being filtered correctly due
to the configured prefix-list.

Before fix:

c1# show ip prefix-list nag seq 10
ZEBRA: seq 10 permit any (hit count: 0, refcount: 0)
BGP: seq 10 permit any (hit count: 0, refcount: 0)
c1# show ip prefix-list nag seq 5
ZEBRA: seq 5 deny 1.0.1.0/24 (hit count: 0, refcount: 0)
BGP: seq 5 deny 1.0.1.0/24 (hit count: 0, refcount: 0)

Fix: Increment the prefix-list's hit count whenever a rule match occurs.

After Fix:

c1# show ip prefix-list nag seq 10
ZEBRA: seq 10 permit any (hit count: 0, refcount: 0)
BGP: seq 10 permit any (hit count: 6, refcount: 0)
c1# show ip prefix-list nag seq 5
ZEBRA: seq 5 deny 1.0.1.0/24 (hit count: 0, refcount: 0)
BGP: seq 5 deny 1.0.1.0/24 (hit count: 1, refcount: 0)

Signed-off-by: Visakha Erina visakha.erina@broadcom.com
2019-06-20 01:51:38 -04:00
Donald Sharp
43b8ca995b lib: Do not blindly set the _read and _write pointers to NULL
Adding a read with the address of the thread pointer we want to
use will allow lib/thread.c to properly handle your thread pointers.
Instead we were setting the pointer to NULL before we passed
into the _read and _write thread functions.  Remove the NULL
pointer set and just let thread.c handle everything.

vty_stdio_resume and vty_read would blindly add read and write
which would cause vty_event() to drop the thread pointer.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-19 19:04:53 -04:00
Stephen Worley
8ad7c5c2e7 lib: Remove extraneous spacing/output filter cmds
Use %% style for errors in log commands and switch
tabs to a single space in output. Also, remove un-needed
output for success.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
ec1d97751e lib: Use gotos in filter control functions
Use gotos to reduce return paths in the log filter
add/del/dump functions.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
3b96430b72 lib: Add vrrpd,sharpd to DAEMONS_* strings
Add vrrpd and sharpd to the DAEMONS_* list so they
can be dispatched daemons independent commands
such as `show work-queues` and `log-filter`.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
fc2a67dd25 lib: Filter logs as they come in via macros
As logging functions are called, if filters are stored,
look for the filter substring in the logs. If it is not
found, do not output the log to a file or stdout.

If the filter is matched, handle the log call per usual.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
f73126c31a lib,vtysh: Add vtysh commands for log-filter
Add vtysh commands to add/del/clear/show filters across
all daemons and independently on each one. Add automake and
clippy boilerplate for those commands as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
bd1058c0af lib: Use memmove to adjust filters after del
Simplify the code in deleting a filter by using memmove rather
than iterating. Memmove handles overlapping strings safely so
this is fine here.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
c0dc23460b lib: Add log filter manipulation code
Add code for manipulation/creation of log filters
and their table. Specifically, add lookup,clear,add,del,dump
functionality.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Stephen Worley
db9a7cf7c0 lib: Add some all daemon command strings
Add some strings for defining vty commands that target
all daemons.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-19 17:20:24 -04:00
Donald Sharp
2e4c561bf8
Merge pull request #4300 from adharkar/frr-master-rmap_debug
Lib: Debugs for route-map code in FRR
2019-06-18 11:24:10 -04:00
Donald Sharp
7ec5e2bf70
Merge pull request #4514 from opensourcerouting/warnings-20190612
*: kill more warnings
2019-06-17 15:19:42 -04:00
David Lamparter
ce746edebb
lib: Prevent infinite loop in fd handling (#4516)
lib: Prevent infinite loop in fd handling
2019-06-14 23:48:36 +02:00
David Lamparter
277aee6fc9
eliminate snprintf from AF_INET/AF_INET6 prefix2str, add prefix2str test (#4521)
eliminate snprintf from AF_INET/AF_INET6 prefix2str, add prefix2str test
2019-06-14 21:48:34 +02:00
David Lamparter
0688fd81d0
bgpd, lib: Add iana_afi2str and iana_safi2str for eye pleasing strings (#4439)
bgpd, lib: Add iana_afi2str and iana_safi2str for eye pleasing strings
2019-06-13 22:06:49 +02:00
Donald Sharp
a0b36ae673 lib: Add function name to show thread poll
When displaying `show thread poll` data add the
function we are supposed to call when the poll
event happens.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-13 15:14:04 -04:00
Donald Sharp
1ef14bee7a lib: Add check for non-preexisting thread
When adding a read/write poll event and we are using a developmental
build add a bit of code to ensure that we do not already have an read
or write event scheduled.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-13 15:14:04 -04:00
Donald Sharp
45f3d59084 lib: Prevent infinite loop in fd handling
If we have a case where have created a fd for i/o and we have
removed the handling thread but still have the fd in the poll
data structure, there existed a case where we would get
the handle this fd return from poll but we would immediately
do nothing with it because we didn't have a thread to hand
the event to.

This leads to an infinite loop.  Prevent the infinite loop
from happening and log the problem.

We still need to find the cause of this happening.  But
let's prevent the system from melting down in the mean time.

Fixes: #2796
Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-13 15:14:04 -04:00
Quentin Young
42aac9b2ab
Merge pull request #4500 from opensourcerouting/clippy-improve
clippy: batch of improvements
2019-06-13 15:06:24 -04:00
Quentin Young
096873bd46
Merge pull request #4509 from opensourcerouting/spanish-intquisition
lib: make printfrr int64_t usable
2019-06-13 14:00:50 -04:00
Quentin Young
ec466f6546 lib: remove snprintf from prefix2str
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-13 17:08:05 +00:00
Mark Stapp
a8baba69ae
Merge pull request #4448 from opensourcerouting/cxx-container-of
lib: const-unaware container_of for C++
2019-06-13 08:38:05 -04:00
David Lamparter
2618a52ed3 *: config.h or zebra.h is the first #include
This is mostly relevant for Solaris, where config.h sets up some #define
that affect overall header behaviour, so it needs to be before anything
else.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 13:35:33 +02:00
David Lamparter
f54dd468ec lib/clippy: ignore -Wstrict-aliasing
This warning is both meaningless and unfixable, just ignore it.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 00:05:03 +02:00
David Lamparter
866f6e4008 lib: drop DSO_SELF on inet_ntop
NetBSD doesn't seem to like this.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 00:05:03 +02:00
David Lamparter
53280f9327 *: fix northbound initializer warning on OpenBSD
For some reason, the compiler on OpenBSD on our CI boxes doesn't like
struct initializers with ".a.b = x, .a.c = y", generating a warning
about overwritten initializers...

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 00:05:03 +02:00
David Lamparter
afb35622ef lib: make "%Ld" work for int64_t
... without compiler plugins.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:35:43 +02:00
David Lamparter
c7179009cf lib: use snprintfrr() in "hidden" printfs
We need to be calling snprintfrr() instead of snprintf() in places that
wrap snprintf in some user-exposed way; otherwise the extensions won't
be available for those functions.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:35:43 +02:00
David Lamparter
3779776a39 lib/clippy: error out on unsupported bits
clippy can't process #ifdef or similar bits inside of an argument list
(e.g. within the braces of a DEFUN or DEFPY statement.)  Improve error
reporting to catch these cases instead of generating broken C code.

Fixes: #3840
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:22:59 +02:00
David Lamparter
a71c5039ad build: improve clippy options
* adds a `--with-clippy=...` option to use a prebuilt clippy binary
* limits the autoconf tests done for `--enable-clippy-only`
  (e.g. no libyang)

Fixes: #3921
Fixes: #4006
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:22:59 +02:00
David Lamparter
2655e41fa2 build: slim down configure.ac
Quite a few tests are deprecated/unnecessary at this point.  Remove
everything that is pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12 19:22:55 +02:00
Renato Westphal
eaf6705d7a lib: fix outdated candidate configuration issue
Even when using the classic CLI mode (i.e. when --tcli is not
used), the northbound code still uses vty->candidate_config
to perform configuration changes. From the perspective of the
user, the running configuration is being edited directly, but
under the hood the northbound layer does a full configuration
transaction for each command.  When the running configuration is
edited by a northbound client other than the CLI (e.g. kernel,
gRPC), vty->candidate_config might become outdated, and this can
lead to lots of weird problems. To fix this, always regenerate
vty->candidate_config before each configuration command when
using the classic CLI mode. When using the transactional CLI,
the user needs to update the candidate manually using the "update"
command, otherwise the "commit" command will fail with this error:
"% Candidate configuration needs to be updated before commit".

Fixes some problems reported by Don after moving an interface from
one VRF to another one while zebra is running.

Reported-by: Don Slice <dslice@cumulusnetworks.com>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-06-12 11:17:03 -03:00
Philippe Guibert
a41c4e1b1f *: change interface structure, from vrf_id to vrf
Field vrf_id is replaced by the pointer of the struct vrf *.
For that all other code referencing to (interface)->vrf_id is replaced.
This work should not change the behaviour.
It is just a continuation work toward having an interface API handling
vrf pointer only.

some new generic functions are created in vrf:
vrf_to_id, vrf_to_name,

a zebra function is also created:
zvrf_info_lookup

an ospf function is also created:
ospf_lookup_by_vrf

it is to be noted that now that interface has a vrf pointer, some more
optimisations could be thought through all the rest of the code. as
example, many structure store the vrf_id. those structures could get
the exact vrf structure if inherited from an interface vrf context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 14:10:28 +02:00
Philippe Guibert
da85f5e038 lib, bgpd, ospfd, pimd, zebra, rip, ripng, bfd: change if_update_to_new_vrf() api
vrf_id parameter is replaced with struct vrf * parameter. It is
needed to create vrf structure before entering in the fuction.
an error is generated in case the vrf parameter is missing.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
921a85ba8c zebra, ifp: on netlink discovery, anticipate the vrf creation
there may be cases where the vrf is yet allocated from the vty, and the
discovery process did not make the relationship between the vrf_id and
the name of the vrf. For instance, by parsing an interface belonging to
vrf-id X, it is not sure that vrf-id X and vrfname XX are talking about
the same vrf. For that, lets allocate the vrf, and lets try to detect
there is a duplicate case in vrf, so that the merge can be done without
any impact for the user.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
8205b1b455 zebra, lib: upon entering interface, create vrf context
the interface search is based on vrfs. As at startup, some interfaces
may be configured, there is need to have vrfs contexts present. A macro
is being appended with an extra parameter that permits create a vrf and
return the context. This macro is also used by some show routines, but
will not create vrfs, because that extra parameter will be set to false,
on that case.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
ac6c2a11a6 lib: create interface upon accessing interface NB API.
Upon accessing interface NB API, the interface is created, if the vrf
is available. the commit does not change the behaviour, since at this
commit, this is not yet possible to have vrf contexts, while zebra did
not connect to daemons. However, that commit adds some work, so that it
will be possible to work on a vrf context, without having the vrf_id
completely resolved. for instance, if we suppose a vrf is created by
command 'vrf TOTO' in the starting configuration of a daemon, then 'interface
TITI vrf TOTO' will permit to create interface TITI within vrf TOTO.

the macro VRF_GET_INSTANCE will return the vrf context, if available or
not.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:58 +02:00
Philippe Guibert
f11e98eca3 *: change if_lookup_by_name() api with vrf
the vrf_id parameter is replaced by struct vrf * parameter.
this impacts most of the daemons that look for an interface based on the
name and the vrf identifier.
Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was
ignored until now.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12 08:37:54 +02:00
Ameya Dharkar
e3ab8170bd Lib: Debugs for route-map code in FRR
Added a CLI "debug route-map" to enble route-map debugs

Added debugs for following triggers
1. Add/delete a route-map
2. Add/delete a sequence in route-map
3. Add/delete a match statement(dependency)
4. Update a dependency
5. Apply a route-map

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2019-06-11 16:17:15 -07:00
David Lamparter
a7f20d4328 lib: const-unaware container_of for C++
This version of container_of() should work on C++, by ditching the
unavailable builtins (at the cost of no longer checking for "const"
violations.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-11 18:45:38 +02:00
Philippe Guibert
e9c199a6c1 lib, ospfd, pimd, zebra: change if_create() api with vrf
if_create() takes as input a vrf poiter instead of the vrf_id parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
Philippe Guibert
4c634658a6 ospf, ospf6d, zebra, lib: change if_get_by_name prototype with vrf
vrf pointer is used as reference when calling if_get_by_name() function.
this will permit to create interfaces with an unknown vrf_id, since it
is only necessary to get the vrf structure to store the interfaces.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-11 17:10:47 +02:00
David Lamparter
051a0be4b2 *: fix some dumb printf format warnings
Some types like `time_t` vary across platforms and always need to be
cast when printed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-11 13:34:57 +02:00
David Lamparter
e787685f86
More compiler cleanup (#4487)
More compiler cleanup
2019-06-11 13:31:52 +02:00
David Lamparter
0afc154435
Zebra.h header cleanup (#4444)
Zebra.h header cleanup
2019-06-11 11:36:17 +02:00
Renato Westphal
9fd5497f30
Merge pull request #4484 from donaldsharp/pbr_tab_complete
Pbr tab complete
2019-06-07 21:48:53 -03:00
Quentin Young
9f9307c953
Merge pull request #4480 from opensourcerouting/inet_ntop
inet_ntop but faster
2019-06-07 11:23:16 -04:00
Donald Sharp
adc109b5a2 lib: On some platforms function did not return anything
On some compiler platforms the md5 setup function was
not returning anything.  Place failure case on the bottom
to properly handle this situation.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-07 09:29:45 -04:00
Donald Sharp
3711fdb77c lib: Include proper header
bcopy is being used in the new printf code.  Let's actually
include the proper header for it.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-07 09:29:45 -04:00
Donald Sharp
9a8a7b0ed1 lib, pimd, sharpd: Various output string cleanups
Various compilers in our CI system were complaining about various
auto-conversions.  Let's get these cleaned up a bit more.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-07 09:29:45 -04:00
David Lamparter
874035be4e tests: exercise frr_inet_ntop()
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-06 20:59:54 +02:00
David Lamparter
e128c00226 lib: add optimized inet_ntop()
This commit is brought to you by: "Manuel - Gas Gas Gas" (Initial D)

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-06 20:59:50 +02:00
David Lamparter
111a04f740 lib: add OPTIMIZE + assume() to compiler.h
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-06 20:58:20 +02:00
Mark Stapp
fa3bf3a21b lib,bgpd,babeld,ripngd,nhrpd,bfdd: clean up SA warnings
Clean up several SA warnings.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-06-06 13:13:15 -04:00
Donald Sharp
695a52fd5e
Merge pull request #4333 from opensourcerouting/printfrr
printfrr() world domination tour
2019-06-05 13:30:42 -04:00
Donald Sharp
868ee86cec lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group'
Add some auto-completion for the nexthop-group command

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-05 06:33:00 -04:00
Donald Sharp
43e587c1d1 *: Convert over to all -N namespace to change DAEMON_VTY_DIR
When the user specifies -N namespace allow it to influence the
frr_vtydir(DAEMON_VTY_DIR) to have namespace in it's path
like so: $frrstate_dir/<namespace>

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-04 19:52:46 -04:00
Donald Sharp
4e99f30932 lib: Allow -N to modify the zapi domain socket
When using -z, allow that to override the zapi domain socket
path.  If using -N add the namespace name to the path to
$frr_statedir/<namespace>/zserv.api.  If you don't specify
the -N or -z option then it is $frr_statedir/zserv.api

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-04 10:37:19 -04:00
Lakshman Krishnamoorthy
2789041a46 Revert of PR 4078 and PR 4315
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-03 15:43:02 -07:00
David Lamparter
c22f6d8cde lib: simplify SEGV handler
printfrr is AS-Safe, let's simplify the SEGV handler quite a bit by
relying on that.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 18:57:31 +02:00
David Lamparter
3cd9490d0b lib/printf: ditch reallocarray
reallocarray() is walled behind stupid feature macros on various
platforms and doesn't quite gain us much in that particular use case.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 18:57:31 +02:00
David Lamparter
d52ec5720f lib: add some printfrr specifiers
More to come - these are just the most obvious and easy.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 18:57:31 +02:00
David Lamparter
807f5b9842 lib: use printfrr for log & vty
This makes printfrr extensions available in most of our format strings.
snprintf() is the obvious exception.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 18:57:28 +02:00
David Lamparter
bf4d3d8021 lib/printf: add extension support
Inspired by the Linux kernel, this allows us to do %pI4 and similar
things.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:45:01 +02:00
David Lamparter
60f1101d29 lib/printf: fix some random warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:58 +02:00
David Lamparter
5c25bd87b5 lib/printf: integrate
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:51 +02:00
David Lamparter
8be3678a23 lib/printf: rename & private __find_arguments
These are internal to printf(), and symbols starting with __ are
reserved for the compiler/libc.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:32 +02:00
David Lamparter
e8c672ea81 lib/printf: disable wchar_t support
... we just don't use wchar_t in FRR, no point in having this enabled.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:29 +02:00
David Lamparter
32b67a0aeb lib/printf: add %Ld/%Lu for int64_t/uint64_t
[u]int64_t is the only type in the intX_t family that needs
special-casing for printf since the calling convention may differ
between 32-bit and 64-bit systems.

Adding the L specifier allows us to eschew the gnarly-looking PRIu64.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:24 +02:00
Donald Sharp
f232dd29c1 lib: Cleanup recent commit warn->werror issues in lib/routemap.c
The get_route_map_delete_event function should return a value
even if we never get to that part of the function.  Make sure
we know why we are here so it can be fixed appropriately in
the future.

Signed-off-by: Donald Sharp <sharpd@cumulusnetwork.com>
2019-06-03 10:44:23 -04:00
David Lamparter
7fa480984e lib/printf: use system printf for floats
We're not libc, we can just fall back to snprintf() to avoid all this
low-level float mangling.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:18 +02:00
David Lamparter
86bfbddf6e lib/printf: cut down to size
remove various FreeBSD specific bits, as well as the entirety of locale
support.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:44:05 +02:00
David Lamparter
ea0b6afe2b lib: import FreeBSD's printf
... from current SVN HEAD (not that it has been touched in the past 2
years ...)

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03 16:43:11 +02:00
David Lamparter
5a4ac9df0f
No log commands (#3581)
No log commands
2019-06-03 15:52:32 +02:00
Donald Sharp
b2eea7a00e
Merge pull request #4345 from NaveenThanikachalam/route_map_dep
lib: Changes made to dependencies of a route-map do not take effect dynamically.
2019-06-03 09:19:59 -04:00
Donald Sharp
03edc41d51 lib: Move zebra_size_t to zclient.h who should own it
The zebra_size_t type needs to be owned by zclient.h since
it is part of the zapi protocol.  Move it to where the
structure belongs.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 16:07:48 -04:00
Donald Sharp
64cbb7c5b7 lib: Remove unused zebra_command_t type
The zebra_command_t type was never being used, remove from
the system.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 16:07:48 -04:00
Donald Sharp
26ee1525e6 lib: Remove unused INT8_MAX and UINT8_MAX values
We are not using these in the system, remove.

Signed-off-by: Donald Sharp <sharpd2cumulusnetworks.com>
2019-06-02 16:07:48 -04:00
Donald Sharp
8ee06b2c46 lib: Move ZEBRA_HEADER_MARKER to header it belongs in
The ZEBRA_HEADER_MARKER is part of the zapi protocol
Move it to the zclient.h header.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 16:07:48 -04:00
Donald Sharp
da01a37a1b lib: Move zclient flags to zclient.h
zebra.h had some defined flags that were being used
as part of the route encode/decode functionality.  These
belong in the zclient.h code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 16:07:48 -04:00
Donald Sharp
7708357131 lib: Move some log.c functions declarations to log.h
We have some functions that are owned by log.c, so
move their declarations from zebra.h to log.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 16:07:48 -04:00
Donald Sharp
17136bf23e lib, bgpd: Create iana_afi.h for storing iana_afi/safi enums
The iana_afi_t and iana_safi_t were being created in zebra.h
and zebra.h is a bit of a dumping ground.  When the iana_afi2str and
iana_safi2str functions were created, it was correctly pointed out
that we should just use the internal afi_t and safi_t 2str functions
but to do that we would need to include prefix.h in zebra.h.  Which
really is not the right thing to do.  This tells us that we need
to break out this code into it's own header.

Move to iana_afi.h the enums and specific functions and remove
from zebra.  Convert to using the afi2str and safi2str functions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 15:02:07 -04:00
Donald Sharp
748a041f09 bgpd, lib: Add iana_afi2str and iana_safi2str for eye pleasing strings
Modify the code such that we can auto turn the iana values of afi
and safi to pleasant to read strings.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 14:51:52 -04:00
Donald Sharp
d92050a607 lib: Remove some iana_afi_t values that are not really afi's
The IPMR and IP6MR values have no actual legal representation
and we do not sue them at all.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-02 14:48:19 -04:00
Mark Stapp
32e4ce5fd5
Merge pull request #4435 from donaldsharp/zclient_buffer_sizing
lib, zebra: Ensure route encoding has enough space
2019-05-31 16:20:38 -04:00
Donald Sharp
ce231fbc87
Merge pull request #4430 from lkrishnamoor/hostname_crash
lib: crash when FRR hostname length > 80 chars
2019-05-31 15:02:10 -04:00
Lakshman Krishnamoorthy
63e653a21f lib: crash when FRR hostname length > 80 chars
Although the RFC states hostname length should be < 255 chars,
FRR allows infinite length technically. However, when you try
to set a hostname > 80 chars, you would immediately notice a crash.

RCA: Crash due to buffer overflow. Large buffer sprintf'd into smaller
buffer. Usage of sprintf function instead of snprintf which is safer.

Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-31 10:52:33 -07:00
Naveen Thanikachalam
e2c8d6ce90 lib: Changes made to dependencies of a r-map do not take effect.
Say, more than one sequence of a route-map uses the same named entity
in its match clause. After that entity is removed from any one of the
route-map sequences, any further changes made to that entity doesn't
dynamically take effect.
A reference counter, that allows the named entity to keep a count of
the route-maps dependent on it,  has been introduced to address this issue.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
2019-05-31 10:05:19 -07:00
Donald Sharp
f3f4562612 lib, zebra: Ensure route encoding has enough space
When you have compiled FRR with a large multipath number
then encoding large ecmp routes between zebra and the
routing daemons.  There exists a theoritical size
of multipath that will cause the encoding to be larger
than the ZEBRA_MAX_PACKET_SIZ.  In the cases where
we have allocated streams that will encode routes
then let's ensure that whatever size we have will
auto-fit what we say we can send.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31 10:25:18 -04:00
Donald Sharp
2950f5da55 lib: Add '--command-log-always` to all daemons startup
Add 'no log commands' cli and at the same time add a
--command-log-always to the daemon startup cli.

If --command-log-always is specified then all commands are
auto-logged and the 'no log commands' form of the command
is now ignored.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31 10:06:42 -04:00
Donald Sharp
1b3f6ff1f6 lib: Fix gcc 9 warning -> error issue
gcc is complaing about this with --enable-dev and --enable-werror:

In function 'nb_log_callback',
    inlined from 'nb_transaction_apply_finish' at lib/northbound.c:1106:4:
lib/northbound.c:777:2: error: '%s' directive argument is null [-Werror=format-overflow=]
  777 |  zlog_debug(
      |  ^~~~~~~~~~~
  778 |   "northbound callback: event [%s] op [%s] xpath [%s] value [%s]",
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  779 |   nb_event_name(event), nb_operation_name(operation), xpath,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  780 |   value);
      |   ~~~~~~
  CC       lib/ringbuf.lo

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31 08:37:34 -04:00
Donald Sharp
918537e240 lib: vtypath_default could be overwritten
The vtypath_default variable had a possibility of being overwritten
due to size constraints.  This fixes this issue.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-31 08:18:55 -04:00
Donald Sharp
9c61cec7e3
Merge pull request #4315 from lkrishnamoor/route_map_3rd_state
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
2019-05-30 21:25:18 -04:00
Mark Stapp
85a6806dce lib, vtysh: make debug memstats work in vtysh
Allow vtysh to send the 'debug memstats-on-exit' command
to the running daemons.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-05-30 16:14:25 -04:00
Lakshman Krishnamoorthy
eadd168781 lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP

Traditionally route map MATCH rule apis  were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:

Action: Apply route-map match and return the result (RMAP_MATCH/RMAP_NOMATCH)
State1: Receveived RMAP_MATCH
THEN: If Routemap type is PERMIT, execute other rules if applicable,
otherwise we PERMIT!
Else: If Routemap type is DENY, we DENYMATCH right away

State2: Received RMAP_NOMATCH, continue on to next route-map, otherwise,
return DENYMATCH by default if nothing matched.

With reference to PR 4078 (https://github.com/FRRouting/frr/pull/4078),
we require a 3rd state because of the following situation:

The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.

Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"

With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP (or another enum) to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.

Question: Do we repurpose an existing enum RMAP_OKAY or RMAP_ERROR
as the 3rd state (or create a new enum like RMAP_NOOP)?
RMAP_OKAY and RMAP_ERROR are used to return the result of set cmd.

We chose to go with RMAP_NOOP (but open to ideas),
as a way to bypass the rmap filter

As a result we have a 3rd state:
State3: Received RMAP_NOOP
Then, proceed to other route-map, otherwise return RMAP_PERMITMATCH by default.

Signed-off-by:Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-05-30 11:21:28 -07:00
Renato Westphal
4eb4afa3b6
Merge pull request #4393 from donaldsharp/debug_all
Debug all
2019-05-29 23:55:50 -03:00
Quentin Young
67c726a10d lib: fix helpstring truncation
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:03:26 +00:00
Quentin Young
daeb97e980 lib: use static storage for vty_cwd
Why are we allocating this

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:03:26 +00:00
Quentin Young
fcb072cdbf lib, zebra: remove uses of strncpy
This removes the last removable uses of strncpy in FRR.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:03:26 +00:00
Quentin Young
9f73d2c9b6 lib: remove some strcpy, strcat
Replace with strlcpy, strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:02:57 +00:00
Quentin Young
53a394720e lib: fix false compiler warning
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:02:57 +00:00
Quentin Young
aa0e96ed1c lib: fix uninitialized variable in backtrace output
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-29 18:02:57 +00:00
Mark Stapp
5c6188221f
Merge pull request #4404 from qlyoung/const-linklist
lib: const a couple linklist apis
2019-05-29 11:28:08 -04:00
Donald Sharp
ae0994f6eb lib: Separate out the debug_init api
Separate out the debug_init api to have 2 functions:

1) Function to register a callback
2) Function to initiate the cli.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-28 17:16:16 -04:00
Donald Sharp
f756a869ae lib: Make the debug callbacks a list of callbacks
Allow multiple callers to initialize themselves to receive
callbacks for debug on/off operations.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-28 17:07:04 -04:00
Quentin Young
396cd6366d lib: const a couple linklist apis
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-28 20:23:04 +00:00
Donald Sharp
dcdc27095a
Merge pull request #4391 from ton31337/feature/delete_prefix_list_by_sequence_number
plist: Delete prefix-list by sequence number
2019-05-28 16:14:52 -04:00
Jafar Al-Gharaibeh
bda0241599
Merge pull request #4239 from sarav511/rp
pimd: PIM Bootstrap Message Processing
2019-05-28 10:26:28 -05:00
Renato Westphal
f6fd430e44
Merge pull request #4322 from sworleys/Nexthop-Cmp
lib: Add nexthop_cmp
2019-05-28 11:32:44 -03:00
Renato Westphal
a26bd54e86
Merge pull request #4390 from qlyoung/frrstr-beginswith-endswith
lib: rename begins_with, add frrstr_endswith
2019-05-27 20:55:14 -03:00
Donatas Abraitis
7e200e8645 plist: Delete prefix-list by sequence number
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-05-25 13:02:38 +03:00
Donald Sharp
51da389626 bgpd, lib: Remove SO_MARK
The SO_MARK socket option was being used pre vrf to allow for the
separation of the front panel -vs- the management port.  This
was facilitated by a ip rule.  Since this is undocumented anywhere
in our system( other than old commits see
ed40466af8 ).  We should remove this
because this will cause interference with people using rules
and are not aware of this offshoot of functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-24 08:35:35 -04:00
Donald Sharp
6c19478a3b lib: Display to end user the MAX_FDS allowed
Upon startup FRR reads in the MAX_FDS variable from
it's control files via the getrlimit call.  We then
setup code to limit the poll data structure size to
that value.  The OS also limits our FD's to that value
because that is what is set.  Provide a methodology
that a interested end user can figure this data out.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-24 08:24:18 -04:00
Donald Sharp
61fa0b976a lib: 'show thread cpu' help strings referenced a weird option
The 'show thread cpu' command referenced a 'b' option.  Which
is not parsed at all in the parse_filter function.  As such
I do not know what this was referencing as that it has been
removed.  Update the help strings to reflect this reality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-24 08:24:18 -04:00
Quentin Young
90cf59eccf lib: replace begins_with, add frrstr_endswith
* Change 'begins_with' to 'frrstr_startswith' for consistency
* Add suffix checker, frrstr_endswith()
* Update vtysh to use the new function

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-23 20:52:01 +00:00
Stephen Worley
a5a2d802d7 lib,zebra,bgpd,pbrd: Compare nexthops without labels
Allow label ignoring when comparing nexthops. Specifically,
add another functon nexthop_same_no_labels() that shares
a path with nexthop_same() but doesn't check labels.

rib_delete() needs to ignore labels in this case.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
24cfec8418 lib: Explicitly cmp gateway and source based on AF
Refactor the gatway and source nexthop comparision into a
common code path that compares them explicitly based on
their address family.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
78fba41bd8 lib,zebra,bgpd: Remove nexthop_same_no_recurse()
The functions nexthop_same() does not check the resolved
nexthops so I don't think this function is even needed
anymore.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
2ed74b933d lib: Update nexthop_same to use nexthop_cmp
Simplify the code a bit by making nexthop_same()
just use nexthop_cmp() internally.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
ff0e16daf9 lib: Add labels_cmp to nexthop_cmp
Add labels comparison to nexthop_cmp() as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
f932ce865f lib: nexthop-cmp return if gateways don't match
Fix the cmp check the so that it returns the result
if the gateways don't match.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
89dc316029 lib: Make labels_match function use labels_cmp
Update the nexthop_labels_match() function to use
nexthop_labels_cmp().

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Stephen Worley
ebc403dda5 lib: Add nexthop labels cmp functions
Add a function to compare nexthop labels.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Donald Sharp
776c3e90c1 lib: Add nexthop_cmp
Add function to allow us to have a sorted order
of nexthops.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Renato Westphal
81fddbe7ae *: rename new ForEach macros from the typesafe API
This is necessary to avoid a name collision with std::for_each
from C++.

Fixes the compilation of the gRPC northbound module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-05-21 15:59:08 -03:00
Renato Westphal
eea3c899cd lib: add missing extern "C" {} blocks to new headers
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-05-21 15:56:18 -03:00
David Lamparter
791ac7c7e7 Revert "lib: Make _find functions treat the head as const"
This reverts commit 98d28ef55d.

No longer needed with previous commit.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:42:13 +02:00
David Lamparter
3b18b6c03d lib/table: remove nonsensical const, add pure
Passing the struct route_table *ptr as const doesn't really help; if
anything it semantically would imply that the returned route_node is
const too since constness should propagate (but it doesn't in C.)

The right thing to do here - which actually helps the compiler optimize
the code too - is to tag functions with __attribute__((pure)).  The
compiler does this automatically if it has the function body (and the
body of all called functions) available.  That should cover most "static
inline" functions in headers, as well as functions in the same file.

However, this doesn't work (at least without LTO) for extern functions.
Hence, add "ext_pure" for this case.  (Built-in "extern" to make lines
shorter.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:42:13 +02:00
David Lamparter
0734f93b8e lib/table: remove odd casts
Working with a proper struct route_node gets us around a bunch of weird
casts here and makes the code slightly more robust.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:42:13 +02:00
David Lamparter
9680a2af1c lib: add missing atomlist_init/fini
Only noticed this when trying to add atomlists to the typesafe
datastructure tests...  the atomic-specific test_atomlist doesn't use
init/fini :/

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:42:13 +02:00
David Lamparter
5cb4277dfe lib: add DECLARE_HEAP datastructure
This is an 8-ary heap (cacheline optimized.)  It works as a semi-sorted
kind of middle ground between unsorted and sorted datastructures;  pop()
always returns the lowest item but ordering is only loosely enforced.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:42:13 +02:00
David Lamparter
fdad523b54 lib: add DECLARE_DLIST (double-linked list)
Turns out we need one of these.  Same API as DECLARE_LIST, but deleting
random items is much faster.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:18:16 +02:00
David Lamparter
01734da376 lib: add dedicated pop() to DECLARE_SKIPLIST
The skiplist code was previously falling back to the del() code path for
a pop() on a skiplist.  This is unneeded complexity, a pop() can be done
more efficiently.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21 05:18:16 +02:00
Quentin Young
303b93cdee zebra: update zebra_rib for vrrp
VRRP doesn't install any routes, but should still have an array entry.
Also add a help string for VRRP to route_types.txt

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
4f576e7575 lib, vrrpd: define & use ZEBRA_ROUTE_VRRP
Allow Zebra to know our protocol name.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
2fff50ec01 vrrpd, lib: style fixes
Fixup:
* Blank lines after declarations
* Trailing whitespace
* Braces and parentheses

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
e91c9247eb lib: add more convenient boolean adder for json
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
f828842a69 vrrpd: add support for configuration writing
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
53e60e5c58 vrrpd: autoconfig support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
c3bd894e4d vrrpd: protodown macvlan in backup state
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
4f838de420 lib: add sizing macro to ipaddr.h
Useful for getting the size of the relevant data in the `ip` field of
struct ipaddr.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
667179cae4 lib: add function to get iface link-local
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
17b48d7d11 lib: add internet checksum with pseudoheaders
Add convenience functions to compute the Internet checksum of a data
block, including a pseudoheader.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
dad18a2fd7 vrrpd: add initial macvlan support
* Search for macvlan interfaces with the appropriate name and MAC
  address when starting up a new VRRP instance
* Split VRRP socket into two; one for Tx, one for Rx
* Bind Tx socket to the macvlan subinterface so our VRRP advertisements
  go out with the correct MAC address
* Send ARP requests from this macvlan subinterface
* Improve error messaging

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Quentin Young
862f2f374f vrrpd: ipv6 support
Add initial support for IPv6.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00