Commit Graph

326 Commits

Author SHA1 Message Date
Donald Sharp
f8507817cf lib: Add new cli to specify where to output logs on startup
When we are starting a daemon, allow the user to specify:

--log <stdout|syslog|file:file_name>

This can be used on early startup to put the log files
where the end user wants them to show up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-06-19 08:43:59 -04:00
paco
9f227e4c91
lib: null return value check (Coverity 1469894)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-12 16:37:36 +02:00
Quentin Young
0b42d81ab8 lib: fix output mangling with | include
Sometimes output would be mangled when filtering with include as a
result of the following bugs:

* Filters were applied per each call to vty_out() instead of buffering
  until a line break and then applying
* Long output would sometimes be cut due to using the wrong buffer
  pointer

Also remove the trailing \n as it should no longer be necessary to
ensure the vty prompt ends up on a new line.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 19:09:44 +00:00
Quentin Young
f428cb8a3a lib: add vector_compact(), use after str splits
* Add function to move all data to the start of a vector by shifting
  over contiguous empty slots
* Use this function to remove empty slots leftover after
  frrstr_filter_vec

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:16:12 +00:00
Quentin Young
5d806ec6e0 lib: fix static analysis issues, use regfree()
* Fix potential NULL dereference
* Fix use of uninitialized value
* Fix leaking memory by not freeing regex_t
* Fix extra \n when using empty regex filter
* Clean up still-reachable hook memory
* Handle nonexistent pager

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:16:12 +00:00
Quentin Young
62bece4449 lib: add vector_remove() to vector.[ch]
An optimized version of this has already been implemented within graph.c
that assumes some specialized constraints for that code. It's generally
useful so this change implements a general purpose version of it.

This fixes cmd_make_strvec() that was broken by some code shuffling in
previous commits.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:16:12 +00:00
Quentin Young
0a334343d1 *: style for | support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:16:12 +00:00
Quentin Young
2cddf2fff7 vtysh: add | support
* Rewrite pager implementation
* Replace fprintf() with vty_out()
* Modify vty_out() for better vtysh support
* Remove static global outputfile var
* Remove fp argument from many vtysh functions
* Add some docs for stuff along the way

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:16:10 +00:00
Quentin Young
fe6b47b9e9 lib: add cli preprocessor for | actions
This patch adds a CLI preprocessor function that activates when `|` is
found in the command. This is the start of adding support for some text
processing utilities intended for inline use. The first one implemented
here is `| include`, which provides grep-like filtering of command
output.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:15:34 +00:00
Quentin Young
01e24c4a69 lib: add hook for preprocessing commands
This patch adds a hook point intended to allow subscribers to modify the
raw text of a CLI command before it is passed to the rest of the CLI
pipeline. To give access to the raw text of the command, a new function
for executing CLI has been defined whose only difference from
`cmd_execute_command` is that it accepts the command to execute as a
string rather than as a string vector.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:15:34 +00:00
Quentin Young
fe011935cd lib: add string utilities
I see lots of the same code being copy-pasted and slightly tweaked for
string processing all over the codebase. Time to start aggregating these
pieces into something consistent and correct.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06 16:15:34 +00:00
Pascal Mathis
4911ca9cab
lib: Moved no-password warnings into header file
The warning string which appears when the users executes 'no (enable)
password' was moved into command.h and declared as a constant named
'NO_PASSWD_CMD_WARNING'.

This avoids duplicate code and makes it easy to change the warning
message in all places at once.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-13 19:11:43 +02:00
Pascal Mathis
eb83f7ce84
lib: Improved warnings for 'no (enable) password'
When the user executes one of the commands 'no password' or 'no enable
password', a warning message gets shown to inform the user of the
security implications.

While the current implementation works, a warning message gets printed
once for each daemon, which can lead to seeing the same message many
times. This does not affect functionality, but looks like an error to
the user as it can be seen within issue #1432.

This commit only prints the warning message inside lib when vtysh
dispatch is not being used. Additionally, the warning message was copied
into the vtysh command handlers, so that they get printed exactly once.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-12 22:22:09 +02:00
Russ White
71ef4ee49a
Merge pull request #2132 from donaldsharp/missed_stuff
Missed stuff
2018-05-12 06:18:15 -04:00
Pascal Mathis
322e2d5c69
lib: Ported 'no (enable) password' from stable/3.0
The pull request #1545 from @donaldsharp introduced the command 'no
password' to remove an existing terminal connection password.
Additionally, warnings have been added to both 'no password' and 'no
enable password' to make the user aware of any security implications.

It seems that this specific pull request was never merged against master
and got lost. This commit is a cherry-pick of d4961273cb with fixed
conflicts and updated documentation.

Thanks to @donaldsharp and @pogojotz for the original PR.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
2018-05-11 02:54:30 +02:00
Donald Sharp
914432b5eb lib: Fix bad function
Fix the decleration of a function to be better.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-08 19:33:07 -04:00
Donald Sharp
3518f35264 bgpd, lib, zebra: Cleanup formatting issues found
Cleanup the formating issues found.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Daniel Walton
0204baa876 watchfrr always writes 'log syslog informational' to the config
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Dave Olson <olson@cumulusnetworks.com>

Ticket: CM-16501
2018-05-08 19:24:15 -04:00
Quentin Young
9f46cc36aa lib: move ip node above vrf node for config order
VRF static route commands adopt global static config if static config is
placed after a vrf context with no separator, workaround by always
writing static route config before vrf config

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-08 19:24:15 -04:00
Don Slice
d4f368e15a lib: allow hostname to begin with a letter or number
Customers have requested the ability to name their devices starting
with a number instead of a letter.  This fix changes the check for
hostname to allow either a letter or a number.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-05-01 21:13:51 +00:00
Quentin Young
26fbe47294 lib: add ability to dump cli mode graph
The grammar sandbox has had the ability to dump individual commands as
DOT graphs, but now that generalized DOT support is present it's trivial
to extend this to entire submodes. This is quite useful for visualizing
the CLI space when debugging CLI errors.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 17:14:55 -04:00
Donald Sharp
e5c83d9b31 pbrd: Add PBR to FRR
This is an implementation of PBR for FRR.

This implemenation uses a combination of rules and
tables to determine how packets will flow.

PBR introduces a new concept of 'nexthop-groups' to
specify a group of nexthops that will be used for
ecmp.  Nexthop-groups are specified on the cli via:

nexthop-group DONNA
  nexthop 192.168.208.1
  nexthop 192.168.209.1
  nexthop 192.168.210.1
!

PBR sees the nexthop-group and installs these as a default
route with these nexthops starting at table 10000
robot# show pbr nexthop-groups
Nexthop-Group: DONNA Table: 10001 Valid: 1 Installed: 1
	Valid: 1  nexthop 192.168.209.1
	Valid: 1  nexthop 192.168.210.1
	Valid: 1  nexthop 192.168.208.1

I have also introduced the ability to specify a table
in a 'show ip route table XXX' to see the specified tables.

robot# show ip route table 10001
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR,
       > - selected route, * - FIB route

F>* 0.0.0.0/0 [0/0] via 192.168.208.1, enp0s8, 00:14:25
  *                 via 192.168.209.1, enp0s9, 00:14:25
  *                 via 192.168.210.1, enp0s10, 00:14:25

PBR tracks PBR-MAPS via the pbr-map command:

!
pbr-map EVA seq 10
  match src-ip 4.3.4.0/24
  set nexthop-group DONNA
!
pbr-map EVA seq 20
  match dst-ip 4.3.5.0/24
  set nexthop-group DONNA
!

pbr-maps can have 'match src-ip <prefix>' and 'match dst-ip <prefix>'
to affect decisions about incoming packets.  Additionally if you
only have one nexthop to use for a pbr-map you do not need
to setup a nexthop-group and can specify 'set nexthop XXXX'.

To apply the pbr-map to an incoming interface you do this:

interface enp0s10
 pbr-policy EVA
!

When a pbr-map is applied to interfaces it can be installed
into the kernel as a rule:

[sharpd@robot frr1]$ ip rule show
0:	from all lookup local
309:	from 4.3.4.0/24 iif enp0s10 lookup 10001
319:	from all to 4.3.5.0/24 iif enp0s10 lookup 10001
1000:	from all lookup [l3mdev-table]
32766:	from all lookup main
32767:	from all lookup default

[sharpd@robot frr1]$ ip route show table 10001
default proto pbr metric 20
	nexthop via 192.168.208.1 dev enp0s8 weight 1
	nexthop via 192.168.209.1 dev enp0s9 weight 1
	nexthop via 192.168.210.1 dev enp0s10 weight 1

The linux kernel now will use the rules and tables to properly
apply these policies.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-06 13:22:43 -04:00
Quentin Young
aec1641e52
lib: remove IRDP_NODE
Unused

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-03 10:50:58 -04:00
Rafael Zalamena
5012c1b6ee
Merge pull request #2005 from qlyoung/remove-masc-node
lib: remove MASC_NODE
2018-04-02 17:55:44 -03:00
Quentin Young
7d3ffd35ea
lib: remove MASC_NODE
Unused

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-30 17:45:41 -04:00
Quentin Young
f108d4873d
lib: remove SERVICE_NODE
Unused

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-30 16:29:51 -04:00
jaydom
7c40bf391c bgpd: add flowspec feature
This work is derived from a work done by China-Telecom.
That initial work can be found in [0].
As the gap between frr and quagga is important, a reworks has been
done in the meantime.
The initial work consists of bringing the following:
- Bringing the client side of flowspec.
- the enhancement of address-family ipv4/ipv6 flowspec
- partial data path handling at reception has been prepared
- the support for ipv4 flowspec or ipv6 flowspec in BGP open messages,
  and the internals of BGP has been done.
- the memory contexts necessary for flowspec has been provisioned

In addition to this work, the following has been done:
- the complement of adaptation for FS safi in bgp code
- the code checkstyle has been reworked so as to match frr checkstyle
- the processing of IPv6 FS NLRI is prevented
- the processing of FS NLRI is stopped ( temporary)

[0] https://github.com/chinatelecom-sdn-group/quagga_flowspec/

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: jaydom <chinatelecom-sdn-group@github.com>
2018-03-30 14:00:47 +02:00
G. Paul Ziemba
b9c7bc5ab0 bgpd: new vpn-policy CLI
PR #1739 added code to leak routes between (default VRF) VPN safi and unicast RIBs in any VRF. That set of changes included temporary CLI including vpn-policy blocks to specify RD/RT/label/&c. After considerable discussion, we arrived at a consensus CLI shown below.

The code of this PR implements the vpn-specific parts of this syntax:

router bgp <as> [vrf <FOO>]
    address-family <afi> unicast
        rd (vpn|evpn) export (AS:NN | IP:nn)
        label (vpn|evpn) export (0..1048575)
        rt (vpn|evpn) (import|export|both) RTLIST...
        nexthop vpn (import|export) (A.B.C.D | X:X::X:X)
        route-map (vpn|evpn|vrf NAME) (import|export) MAP

        [no] import|export [vpn|evpn|evpn8]
        [no] import|export vrf NAME

User documentation of the vpn-specific parts of the above syntax is in PR #1937

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-19 22:13:43 -07:00
G. Paul Ziemba
c8ff868c1a lib: add new BGP VPN policy command node
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-03-09 16:40:37 -05:00
Donald Sharp
dba32923eb lib, vtysh: Start cli for nexthop-group
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09 11:07:41 -05:00
Lou Berger
996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Philippe Guibert
6dfe83b8f7
Merge pull request #1728 from mkanjari/evpn-bug-fixes
Evpn bug fixes
2018-03-06 17:27:10 +01:00
Philippe Guibert
e26aedbe0b lib: split logicalrouter and vrf netns feature
This split is introducing logicalrouter.[ch] as the file that contains
the vty commands to configure logical router feature. The split has as
consequence that the backend of logical router is linux_netns.c formerly
called ns.c. The same relationship exists between VRF and its backend
which may be linux_netns.c file.
The split is adapting ns and vrf fiels so as to :
- clarify header
- ensure that the daemon persepctive, the feature VRF or logical router
  is called instead of calling directly ns.
- this implies that VRF will call NS apis, as logical router does.

Also, like it is done for default NS and default VRF, the associated VRF
is enabled first, before NETNS is enabled, so that zvrf->zns pointer is
valid when NETNS discovery applies.

Also, other_netns.c file is a stub handler that will be used for non
linux systems. As NETNS feature is only used by Linux, some BSD systems
may want to use the same backend API to benefit from NETNS. This is what
that file has been done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-02-27 11:11:24 +01:00
Mitesh Kanjariya
3b103fec6b vtysh/lib: write domainname to config file
Ticket: CM-19626
Review: CCR-7170
Testing: Manual

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2018-02-08 23:04:05 -08:00
Renato Westphal
a7ce0ad1da *: silence '-Wchar-subscripts' warnings on NetBSD
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-02-02 16:31:20 -02:00
Donald Sharp
57dac17c57 lib, pimd: Remove PIM_NODE as it is not needed
The PIM_NODE command is only being used to display
default vrf configuration.  Move this into the
vrf display and remove PIM_NODE.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-30 03:21:42 -05:00
Donald Sharp
4df759fecf
Merge pull request #1436 from rtrlib/rpki
bgpd: Add RPKI/RTR support
2017-11-13 13:35:22 -05:00
pogojotz
f806f29c49 lib: Fix command copy running-config startup-config to alias write file
Fixes: #1412
Signed-off-by: Juergen Werner <pogojotz@gmx.net>
2017-11-12 13:09:29 -05:00
Marcel Röthke
dabecd7c63 bgpd: Add RPKI/RTR support
This commit adds support for the RTR protocol to receive ROA
information from a RPKI cache server. That information can than be used
to validate the BGP origin AS of IP prefixes.
Both features are implemented using [rtrlib](http://rtrlib.realmv6.org/).

Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
2017-11-10 14:37:52 +01:00
Renato Westphal
efd7904eab *: add missing \n in some help strings
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-10-24 19:30:30 -02:00
Donald Sharp
affe9e9983 *: Convert list_delete(struct list *) to ** to allow nulling
Convert the list_delete(struct list *) function to use
struct list **.  This is to allow the list pointer to be nulled.

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

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

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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05 10:53:13 -04:00
Donald Sharp
bd74dc610a lib: Hash creation cleanup
1) Some hash key functions where converting pointers
directly to a 32 bit value via downcasting.  Pointers
are 64 bit on a majority of our platforms.

2) Some hashes were being created with 256 entries,
downsize the hash creation size to more appropriate
values.

3) Add hash names to hash creation so we can watch
the hash via 'show debugging hashtable'

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-09-05 14:33:01 -04:00
Quentin Young
60466a63f2
*: fix style
Fixes style nits introduced by recent pull requests.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-30 11:27:11 -04:00
Mitesh Kanjariya
09fdc88c8c Merge branch 'master' into dev-master 2017-08-28 18:19:03 -07:00
Mitesh Kanjariya
6b3ee3a0b0 lib: new APIs for get/set system hostname/domainname
1. Change hostname_get to cmd_hostname_get
2. Change domainname_get to cmd_domainname_get
3. New API to set domainname
3. Provide a CLI command to set domainname

Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-28 17:16:52 -07:00
Mitesh Kanjariya
0802e118dd Handle hostname/domainname properly for FreeBSD
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-25 16:36:31 -07:00
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
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
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