Commit Graph

375 Commits

Author SHA1 Message Date
Hung-Weic Chiu
9bc221113c - Solve the Coverity Scan PW.ASSIGN_WHERE_COMPARE_MEANT
- Minor refactoring

Signed-off-by: Hung-Weic Chiu <sppsorrg@gmail.com>
2017-05-10 16:02:48 -04:00
David Lamparter
92fd8a7d59 Merge pull request #468 from qlyoung/fix-list-perm
lib: fix 'list permutations'
2017-05-09 17:54:22 +02:00
Quentin Young
e4e63cb6eb lib: fix 'list permutations'
Cyclic graphs ftw

Also remove graph pretty printer from permutations.c 'cause it's not
really needed anymore

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-05 00:19:00 +00:00
Donald Sharp
b46be72b4a Merge branch 'master' into EIGRP 2017-05-02 11:38:06 -04:00
Don Slice
f51bae9cf9 bgpd: labeled unicast config
Implement support for activating the labeled-unicast address family in
BGP and relevant configuration for this address family.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-04-06 10:30:03 -04:00
Donald Sharp
97133f7915 Merge remote-tracking branch 'origin/master' into EIGRP 2017-04-05 20:52:32 -04:00
David Lamparter
3e7c8d040c Merge branch 'stable/2.0'
Fixed minor conflicts from "defaults" change on stable.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-04-04 19:01:47 +02:00
Lou Berger
447a8fe92e Rename: FreeRangeRouting FRRouting
Signed-off-by: Lou Berger <lberger@labn.net>
2017-03-30 14:22:35 -04:00
David Lamparter
8efe88eacf *: track version & "defaults" in configs
[CF]: Move default name to autoconf and update tests

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-03-28 19:18:42 +02:00
David Lamparter
4dcee34bd6 Revert "lib: Fix tab completions memleak, memory stats corruption"
This reverts commit 039dc61292.

The patch actually made the situation worse since the return value from
cmd_complete_command_real() was now inconsistently allocated from
different memory stat pools.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-09 19:23:00 +01:00
Donald Sharp
7f57883ee6 eigrp: Initial Commit
Please Note, I will be redoing this commit message with
more information.

Additionally I will rework the lib/* changes into their
own commits.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-08 23:07:46 -05:00
David Lamparter
deaa50db47 lib: hide away logging internals
... no need to have struct zlog generally-exposed.

A few files get to include log_int.h because they use zlog/vzlog.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:40 +01:00
David Lamparter
dd8376febd lib: remove remaining struct zlog * args
These don't serve any purpose either.

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

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:40 +01:00
David Lamparter
bb85d700d5 lib: ditch struct zlog * argument on zlog/vzlog()
It's completely useless...

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

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

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-07 23:07:20 +01:00
Donald Sharp
5a1945e4e8 lib: Cleanup missing help strings for 'show commandtree..'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-03 10:54:10 -05:00
Philippe Guibert
9e6df0b7ac lib: define BGP_EVPN_NODE
This define introduces bgp sub node address-family evpn.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-02-14 13:58:57 +01:00
Donald Sharp
757abe78d8 Merge pull request #195 from opensourcerouting/cli_merge
CLI: independent merge step
2017-02-11 07:00:00 -05:00
David Lamparter
de8f7a3983 lib: parser: rewrite token deduplication
Merge the parsed graph into the existing one as a separate step.  This
makes it possible to merge identical subgraphs, which is used e.g. in
bgpd for <A.B.C.D|X:X::X:X|WORD> neighbor names.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10 15:39:04 +01:00
David Lamparter
148781210f lib: fix remaining coverity issues
Reported-by: Coverity
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10 15:04:06 +01:00
Donald Sharp
b9aa3abbbe Merge pull request #189 from opensourcerouting/config-write-sync
lib: use fsync() for config writes, plug fd leak
2017-02-09 09:52:58 -05:00
David Lamparter
1520d0aca9 lib: use fsync() for config writes, plug fd leak
sync() has a HUGE impact on systems that perform actual I/O, i.e. real
servers...

Also, we were leaking a fd on each config write ever since
c5e69a0 "lib/vty: add separate output fd support to VTYs"
(by myself :( ...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-09 14:25:55 +01:00
David Lamparter
056cfe496e lib: use fsync() for config writes, plug fd leak
sync() has a HUGE impact on systems that perform actual I/O, i.e. real
servers...

Also, we were leaking a fd on each config write ever since
c5e69a0 "lib/vty: add separate output fd support to VTYs"
(by myself :( ...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-09 12:54:25 +01:00
David Lamparter
a31ff449a0 lib: fix some coverity NULL check warnings
Reported-by: Coverity Scan
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-08 16:34:59 +01:00
David Lamparter
caeb0a4f65 lib: remove unused cmd_concat_strvec()
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-08 16:33:25 +01:00
David Lamparter
bff9c3e9d3 lib/tests: add cmd_hostname_set()
To make it possible for testcli to get a clean memory management bill.
(Note: XFREE() is NULL-safe, just like free().)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:39 +01:00
Donald Sharp
6dfe1c38d7 Merge pull request #101 from LabNConsulting/working/master/patch-set/3-vrf
Master version of basic vrf commands & some other missed fixes
2017-01-25 18:26:15 -05:00
Donald Sharp
d2ce19c9b5 Merge pull request #105 from opensourcerouting/cli_merge_step_prep
Prepare for split-off cli parser "merge" step
2017-01-25 07:49:21 -05:00
David Lamparter
83364d20d5 lib: parser: fix memory management
command.c had:
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc")
while command_match.c had:
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens")

... which means that there are 2 distinct MTYPE_CMD_TOKENS.
(The description text being different does not matter, even with the
same text it'd be 2 distinct types.)

command_match.c allocates token->arg in command_match_r() while
command.c frees it in del_cmd_token().  Therefore with each command
being executed, the allocation count goes up on one, down on the other.

=> clean up parser allocation counting.  Also, use separate MTYPEs for
the different fields in struct cmd_token.

Fixes: #108 / ee9216cf ("lib, ripngd: clean up merge leftovers")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Quentin Young <qlyoung@cumulusnetworks.com>
2017-01-25 02:27:29 +01:00
David Lamparter
af2567b646 grammar_sandbox: add into daemons if DEV_BUILD
Also adds "grammar access <node>" to test/dump an existing command node
(e.g. BGP_NODE).

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-23 21:52:44 +01:00
David Lamparter
0bf5b1cbe3 lib: parser: simplify OPTION_TKN & SELECTOR_TKN
These are functionally identical as "fork" tokens.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-23 21:52:43 +01:00
Lou Berger
5ff06872e9 bgpd: add vrf-policy config using existing vnc code
add add/clear vrf prefix
      + Modified for FRR master parser

Signed-off-by: Lou Berger <lberger@labn.net>
2017-01-22 20:54:57 -05:00
Quentin Young
5320569435 lib: guard strict cli completions
Completions are checked for token and docstring equality before
deduplicating. Put an ifdef guard around checking docstrings because
many of them are inconsistent and may confuse users in a release build.

It is a good idea to enable VTYSH_DEBUG when adding new CLI in the
future to help check docstrings.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-01-19 17:15:45 +00:00
Donald Sharp
46c323a66b Merge pull request #27 from qlyoung/fix-derefs2
bgpd, lib: fix a few scan-build catches
2017-01-06 19:36:59 -05:00
Donald Sharp
15667da96d Merge pull request #24 from qlyoung/fix-uninitialized-jump
lib: Initialize ->allowrepeat
2017-01-06 19:34:09 -05:00
Donald Sharp
3b14d86eed Merge remote-tracking branch 'origin/stable/2.0' 2017-01-06 09:58:21 -05:00
Donald Sharp
9473e34052 watchfrr: Rename watchquagga -> watchfrr
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-03 20:13:02 -05:00
David Lamparter
9b532e09f9 Merge pull request #37 from LabNConsulting/working/2.0/patch-set-170102a
Working/2.0/patch set 170102a
2017-01-03 16:44:44 +01:00
Lou Berger
271a0c2548 lib/command.c: fix leak id'ed by valgrind
Signed-off-by: Lou Berger <lberger@labn.net>
2017-01-02 15:04:47 -05:00
David Lamparter
b2f361571b build: rename (1 of ?): configure.ac + preproc
This replaces Quagga -> FRR in most configure.ac settings as well as
a handful of preprocessor macros in the source code.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-20 17:57:47 +01:00
Quentin Young
c01d03a658 bgpd, lib: fix a few scan-build catches
Fixes a couple null pointer derefs and uninit'd values.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-20 03:26:47 +00:00
Quentin Young
a8e4ddd408 lib: Initialize ->allowrepeat
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-18 05:39:21 +00:00
Quentin Young
55d403c9b2 lib: fix crash when tab-completing do ... commands
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-18 05:14:55 +00:00
David Lamparter
53d5ec3678 lib: parser: fix SEGV when Tab hits non-WORD_TKN
If <Tab> processing finds that there is only 1 candidate, but that
candidate is not a WORD_TKN that we can tab-complete on, the status
would remain at CMD_COMPLETE_FULL_MATCH, but the resulting list of
possible completions is empty.

This then SEGVs in lib/vty.c where it tries to access the first element
of the list, assuming FULL_MATCH always has 1 element there...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-16 20:42:01 +01:00
David Lamparter
04cb240868 Merge branch 'fixes/command'
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-08 15:07:24 +01:00
David Lamparter
d7d73ffc8f *: fix up DEFUNs without install_element calls
These now generate warnings which will break the build with -Werror.

Note this may have enabled commands that should be disabled, or the
other way around...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05 20:28:24 +01:00
David Lamparter
7ddcfca4fb Merge branch 'queue/osr/vtysh-generic'
WARNING: Merge contains nontrivial fixups in vrf_cmd handling.

Conflicts:
	lib/if.c
	zebra/interface.c
2016-12-05 20:04:08 +01:00
Christian Franke
74d57f5a1f lib: "write mem" should write to persistent configuration
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-12-05 19:52:50 +01:00
David Lamparter
53dc2b05c7 Merge branch 'stable/2.0'
Conflicts:
	bgpd/bgp_route.c
	lib/if.c
	ripd/rip_interface.c
	zebra/interface.c
	zebra/zebra_vty.c
2016-12-05 19:48:38 +01:00
David Lamparter
8ab22cd4be Merge branch '-renato' into stable/2.0
This contains bgp memory leak fixes as well as cleanups to VRF/namespace
handling and has been run through extended testing in Cumulus' testbed:

Tested-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-05 16:23:28 +01:00
David Lamparter
b5a1e9ef5c lib: remove misleading copy/del_cmd_element
struct cmd_element items are static global variables, they are never
allocated, copied or freed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01 18:45:30 +01:00
David Lamparter
2ab402707f lib: move command_parse_format prototype
The function prototype for command_parse_format() is better left in
command.h, so that the bison-generated header file doesn't need to be
included for that.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01 18:45:22 +01:00
David Lamparter
0b84f29490 *: make DEFUN installations file-local
This moves all install_element calls into the file where the DEFUNs are
located.  This fixes several small related bugs:

- ospf6d wasn't installing a "no interface FOO" command
- zebra had a useless copy of "interface FOO"
- pimd's copy of "interface FOO" was not setting qobj_index, which means
  "description LINE" commands would fail with an error

The next commit will do the actual act of making "foo_cmd" static.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01 17:25:56 +01:00
David Lamparter
ef736f12ba *: fix "uninitialized" warnings
reported by clang for:
- cmd_complete_command()
- show_ip_bgp_ipv4()

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-29 14:15:05 +01:00
Renato Westphal
58ac32e2d5 zebra/lib: plug several memleaks
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:15:27 -02:00
David Lamparter
45ef430000 build: fix -Wmaybe-uninitialized warnings
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15 11:17:50 +09:00
Quentin Young
07321a065d Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	lib/command.c
	lib/vty.c
2016-11-12 05:17:37 +00:00
Quentin Young
17aca20bfb lib, vtysh: Fix memory leaks, change cmd_element to const
Fix a few memory issues:

* Not freeing tab-completions upon input match failure
* Invalid write when null-terminating tab-completions
* Not freeing argv[] itself in additinon to elements
* Use XFREE() instead of free() as appropriate
* Not freeing final token of an [option] during parsing

Make a few minor changes to CLI internals:

* Improve documentation on matching & completion functions
* Only make one copy of cmd_token's when building argv,
  instead of three
* Don't make a copy of the matching cmd_element

Make one major(ish) change to CLI internals:

* Change all pointers to struct cmd_element to const

Code outside of the core CLI units should never have an
occasion to modify the internal state of the command system.
Doing so could easily amount to having a CLI interface that
changes during runtime, and could conceivably lead to security
issues. Explicitly disallowing this removes any chance of
confusion.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-12 01:06:32 +00:00
Quentin Young
7a4662b4a9 lib: Update list [permutations]
Don't show hidden or deprecated commands.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-10 23:30:20 +00:00
Quentin Young
ce882f8168 lib: Implement hidden and deprecated commands
Each token now knows whether it is part of a hidden
or deprecated command. Command completion logic hides
such tokens when generating completions. Command
matching logic works as before and will still match on
hidden and deprecated commands.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-10 23:17:07 +00:00
David Lamparter
87f44e2f0b lib: add minimal no-config VTY mode
This silences the following warning from watchquagga:
"Can't save to configuration file, using vtysh."
which otherwise appears when doing a "write file" in vtysh when no
integrated-config is in use.

Also make "show memory" available in watchquagga.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-10 10:15:27 +01:00
Quentin Young
34f1f6dc78 lib: Remove node debug message on list output
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-03 19:18:02 +00:00
Quentin Young
5b5231b091 lib: Fix segfault on erroneous command
Command completion vector should only be copied if it is
non-null.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-31 03:34:27 +00:00
Quentin Young
ebacb4edce lib: Various minor improvements & bugfixes to CLI backend
- Do not allow tab-completion on anything except words
- Rewrite cmd_make_strvec to use strsep
- Remove a few trailing whitespaces
- Remove cmd_complete_command_lib

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-29 04:43:04 +00:00
Quentin Young
39e92c066f Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	bgpd/bgp_encap.c
	bgpd/bgp_route.c
	lib/command.c
	lib/command.h
	ospf6d/ospf6d.c
	vtysh/vtysh.c
2016-10-21 19:27:49 +00:00
Quentin Young
ae19d7dd48 lib: Add helper function for working with argv, update bgpd to use it
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-20 20:31:24 +00:00
Quentin Young
0a538fc98f Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	isisd/isis_routemap.c
	zebra/rt_netlink.c
2016-10-20 16:31:49 +00:00
Paul Jakma
274f29b2f4 lib: keep hash of node's commands to detect duplicate installs
* command.h: (struct cmd_node) Add a hash, so duplicate installs of
  a cmd_element to a command node can be detected.  To help catch
  strays from the VIEW/ENABLE node consolidation particularly
  (installs to VIEW automatically install to ENABLE too now).
* command.c: (cmd_hash_{key,cmp}) helpers for the hash - just directly
  on the pointer value is sufficient to catch the main problem.
  (install_node) setup the hash for the command node.
  (install_element) check for duplicate installs.
  The assert on the cmd_parse_format seems misplaced.
  (install_default_basic) separate the basic, VIEW, node default commands
  to here.
  (cmd_init) get rid of dupes, given consolidation.
  (cmd_terminate) clean up the node command hash.

Not done: The (struct cmd_node)'s vector could be replaced with the
cmd hash, however much of the command parser depends heavily on the
vector and it's a lot of work to change.  A vector_lookup_value could
also work, particularly if vector could be backed by a hash.

The duplicate check could be disabled in releases - but useful in
development.  It's a little extra overhead at startup.  The command
initialisation overhead is already something that bites in
micro-benchmarks - makes it easy for other implementations to show
how much faster they are with benchmarks where other load is low
enough that startup time is a factor.
2016-10-19 22:28:45 -04:00
Christian Franke
57387fb2cd lib: add api method to read current config path
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-18 08:39:23 -04:00
Quentin Young
e52702f29d Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	bgpd/bgp_route.c
	bgpd/bgp_routemap.c
	bgpd/bgp_vty.c
	isisd/isis_redist.c
	isisd/isis_routemap.c
	isisd/isis_vty.c
	isisd/isisd.c
	lib/command.c
	lib/distribute.c
	lib/if.c
	lib/keychain.c
	lib/routemap.c
	lib/routemap.h
	ospf6d/ospf6_asbr.c
	ospf6d/ospf6_interface.c
	ospf6d/ospf6_neighbor.c
	ospf6d/ospf6_top.c
	ospf6d/ospf6_zebra.c
	ospf6d/ospf6d.c
	ospfd/ospf_routemap.c
	ospfd/ospf_vty.c
	ripd/rip_routemap.c
	ripngd/ripng_routemap.c
	vtysh/extract.pl.in
	vtysh/vtysh.c
	zebra/interface.c
	zebra/irdp_interface.c
	zebra/rt_netlink.c
	zebra/rtadv.c
	zebra/test_main.c
	zebra/zebra_routemap.c
	zebra/zebra_vty.c
2016-10-17 23:36:21 +00:00
Renato Westphal
6694f68c3f lib/vtysh: fix duplicate installation of some vty commands
This is a followup to commits 735e62 and 0b1442, where we forgot to apply
the same VIEW/ENABLE consolidation logic to vtysh. Also, we can't call
install_default() for the ENABLE node because some of the vty commands
installed by this function were already installed in the VIEW node before.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-10-12 19:33:56 -04:00
Donald Sharp
0b1442e37b *: Consolidate all double VIEW_NODE and ENABLE_NODE's
If a command is put into the VIEW_NODE, it is going into the
ENABLE_NODE as well.  This is especially true for show commands.
As such if a command is in both consolidate it down to VIEW_NODE.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07 21:05:06 -04:00
Donald Sharp
735e62a0f2 lib: Consolidate VIEW_NODE to be ENABLE_NODE as well
If you are in VIEW_NODE, the command should exist in ENABLE_NODE
as well.  This is being done to reduce chances of code being
added to one but not the other NODE.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07 21:05:06 -04:00
Donald Sharp
3c8ab49fd1 bgpd, lib: Remove RESTRICTED_NODE from code base
The RESTRICTED_NODE command is not used, introduces code
complexity and provides no additional levels of security.

The only way to get into RESTRICTED_NODE is to add, under
vty configuration the command 'anonymous restricted', and
then telnet to a daemon, provide a password, then type
'enable' and fail to enter the password three times.
Then the user can enter a very limited set of commands to
monitor bgp and only bgp behavior.

This commit removes both the RESTRICTED_NODE usage as well
as the lib/* usage of the code

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07 21:05:06 -04:00
Quentin Young
a2454870d6 lib: Remove show commandtree, add list permutations
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-07 21:44:10 +00:00
Quentin Young
c0f9771dcc lib: Add naive deduplication checks when installing commands
Since not all duplicate commands can be caught during graph
construction, do a linear search over all commands before
installing.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-07 18:41:41 +00:00
David Lamparter
1bf9f0270c lib: add "qobj" object-ID infrastructure
This adds 64-bit random identifiers as "safe pointers" which are also
type-tracked / can have type-specific extension methods.

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

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-07 09:09:51 -04:00
Quentin Young
cbd7259d95 lib: Log invalid/unknown commands to log file
Ticket: CM-6855

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-06 18:39:31 +00:00
Quentin Young
6011c1b213 lib: Make <cr> appear first in completions
When a command is complete and <cr> appears in tab- or
?-completions, make sure it appears first

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-06 01:15:48 +00:00
Quentin Young
3871154b72 lib: Invalid commands are errors, fix msg formatting
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-05 23:50:49 +00:00
Quentin Young
42debbb43d lib: Add logging for invalid commands
Ticket: CM-6855

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-04 20:41:52 +00:00
Quentin Young
98463e0ab7 lib: fix password and enable password syntax
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-04 18:47:17 +00:00
Quentin Young
268316d185 lib: Clean up completions code, fix segfault on no match
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-03 23:21:11 +00:00
Lou Berger
65efcfce42 bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN
and Encap SAFIs.  This code is currently used to support IETF NVO3 style
operation.  In NVO3 terminology it provides the Network Virtualization
Authority (NVA) and the ability to import/export IP prefixes and MAC
addresses from Network Virtualization Edges (NVEs).  The code supports
per-NVE tables.

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

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

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

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

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

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

Now includes changes needed to merge with cmaster-next.
2016-10-03 08:17:02 -04:00
Quentin Young
51d41d759b lib: Null-terminate tab completions char*[]
vtysh expects the result of a tab completion to
have a null pointer as the last element

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-02 03:27:58 +00:00
Quentin Young
c5bd4620b0 lib: Fix command execution npe
Caller may pass NULL if it does not care about what
command was matched.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-01 20:05:10 +00:00
Quentin Young
a98d33ab20 lib, vtysh: refactor vtysh.c, allow parser continuance
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-30 23:03:05 +00:00
Quentin Young
76b6abb95a lib: initialize cmd_vector and add a root node to graph
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-30 19:33:11 +00:00
Daniel Walton
6de69f8305 all: added some missing <>s within []s
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-30 15:31:48 +00:00
Daniel Walton
58749582a9 all: scrubbed some argc CHECK MEs
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-30 00:16:31 +00:00
Daniel Walton
67656e9b65 all: added CHECK ME for DEFUNs that look at argc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-29 17:48:57 +00:00
Daniel Walton
199d90a10e Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-25 16:49:39 +00:00
Daniel Walton
3ce54f7812 Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Sam Tannous <stannous@cumulusnetworks.com>

Ticket:
2016-09-25 14:22:48 +00:00
Daniel Walton
9ccf14f739 Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-25 14:10:48 +00:00
Quentin Young
d862bffbda lib: lib compiles
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-23 21:34:33 +00:00
Daniel Walton
c349116d7c lib: add 'int idx_foo' argv index variables
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 20:17:29 +00:00
Quentin Young
f667a580b7 lib: Implement removed ALIAS into DEFUN
N.B.: some of these are de-facto ALIAS resurrections
that are necessary due to some parser limitations; these
are marked with ALIAS_FIXME so I can go back and add
capability to the parser to handle these special cases.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-23 20:08:47 +00:00
Daniel Walton
6147e2c694 convert <1-255> to (1-255), ()s to <>s, etc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 13:47:20 +00:00
Renato Westphal
eac6e3f027 ldpd: adapt the code for Quagga
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23 09:31:09 -04:00
Daniel Walton
f412b39a33 ALIAS removal for bgp, ospf, pim, isis, rip, ripng, lib and zebra
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 03:55:26 +00:00
Quentin Young
97e5b7c0b3 lib: argv fixes, XFREE -> free, rm decl in matcher
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-22 20:26:07 +00:00
Daniel Walton
e4123a9bb5 Revert "lib: Fixup more files"
This reverts commit f68cec764a.
2016-09-22 18:22:50 +00:00
Donald Sharp
f68cec764a lib: Fixup more files 2016-09-20 22:26:30 -04:00
Quentin Young
9547b5d072 lib: Update copyright headers
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-21 23:55:29 +00:00
Donald Sharp
460a768914 Merge remote-tracking branch 'origin/cmaster-next' into vtysh-grammar 2016-09-20 21:17:34 -04:00
Quentin Young
844ec28cee Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	lib/.gitignore
	lib/command.c
	lib/command.h
2016-09-21 22:11:53 +00:00
Quentin Young
d0bfb22c22 lib: Initial refactor pass on CLI backend
Shotgun commit:
* Remove shim sources from Makefile.am
* Move new types to command.c / command.h
* Rewrite command.c / command.h
* Refactor shim types to real types in matcher
  and parser
* Initial refactor pass on vty.c

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-19 23:46:51 +00:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.

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

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

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-19 16:31:04 -04:00
Quentin Young
039dc61292 lib: Fix tab completions memleak, memory stats corruption
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-09 21:58:33 +00:00
Feng Lu
13460c44a2 lib, vtysh: support multiple VRFs by using linux netns
We realize VRFs with linux netns by default. The main job is
to associate a VRF with a netns. Currently this is done by
the configuration:

  [no] vrf N netns <netns-name>

This command is also available in vtysh and goes to only
zebra, because presently only zebra supports multiple VRF.

A file descriptor is added to "struct vrf". This is for the
associated netns file. Once the command "vrf N netns NAME"
is executed, the specified file is opened and the file
descriptor is stored in the VRF N. In this way the
association is formed.

In vrf_socket(), we first switch to the specified VRF by
using the stored file descriptor, and then can allocate
a socket which is working in the associated netns.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
(cherry picked from commit 55cfa2f190620f7c711944637659bc208970324d)
2016-09-09 12:15:14 -04:00
Quentin Young
1eb5e8dcd1 lib: Continue matching system refactor
Most things back to working, all CLI units refactored
to use improved graph implementation.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-07 04:05:07 +00:00
Olivier Dugeon
16f1b9ee29 Update Traffic Engineering Support for OSPFD
NOTE: I am squashing several commits together because they
do not independently compile and we need this ability to
do any type of sane testing on the patches.  Since this
series builds together I am doing this. -DBS

This new structure is the basis to get new link parameters for
Traffic Engineering from Zebra/interface layer to OSPFD and ISISD
for the support of Traffic Engineering

* lib/if.[c,h]: link parameters struture and get/set functions
* lib/command.[c,h]: creation of a new link-node
* lib/zclient.[c,h]: modification to the ZBUS message to convey the
link parameters structure
* lib/zebra.h: New ZBUS message

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support for IEEE 754 format

* lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to
  safely convert between big-endian IEEE-754 single and double binary
  format, as used in IETF RFCs, and C99.  Implementation depends on host
  using __STDC_IEC_559__, which should be everything we care about.  Should
  correctly error out otherwise.
* lib/network.[c,h]: Add ntohf and htonf converter
* lib/memtypes.c: Add new memeory type for Traffic Engineering support

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add link parameters support to Zebra

* zebra/interface.c:
   - Add new link-params CLI commands
   - Add new functions to set/get link parameters for interface
* zebra/redistribute.[c,h]: Add new function to propagate link parameters
to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering.
* zebra/redistribute_null.c: Add new function
zebra_interface_parameters_update()
* zebra/zserv.[c,h]: Add new functions to send link parameters

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support of new link-params CLI to vtysh

In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue
to use the ordered version for adding line i.e. config_add_line_uniq() to print
Interface CLI commands as it completely break the new LINK_PARAMS_NODE.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Update Traffic Engineering support for OSPFD

These patches update original code to RFC3630 (OSPF-TE) and add support of
RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support
of RFC6827 (ASON - GMPLS).

* ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering
* ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392
* ospfd/ospf_packet.c: Update checking of OSPF_OPTION
* ospfd/ospf_vty.[c,h]: Update ospf_str2area_id
* ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get
Link Parameters information from the interface to populate Traffic Engineering
metrics
* ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN)
* ospfd/ospf_te.[c,h]: Major modifications to update the code to new
link parameters structure and new RFCs

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

tmp
2016-09-03 11:05:50 -04:00
Sid Khot
c05795b16b Fix for CM-12450 Ensure quagga logs at startup are sent to syslog (until log configuration is processed)
Ticket: CM-12450
Reviewed By: CCR-5112
Testing Done: Manual
2016-08-17 19:36:54 -07:00
Quentin Young
9b887497e8 lib: Remove debug fprintf for cmd_element copy
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-10 19:11:31 +00:00
Quentin Young
de9d7e4f3c lib: Cleanup some memory issues in CLI
Various memory leaks have been fixed and the quagga
memory macros are in use. Also consolidated the argv
and matching code into one graph traversal.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-29 15:54:03 +00:00
Donald Sharp
daa2bc7068 lib: 'show commandtree' is not a CLI command
The 'show commandtree' command was added to the CONFIG_NODE.

We have a basic assumption that CONFIG_NODE commands actually
change state.  'show commandtree' doesn't meet this requirement.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-07-28 14:02:52 -04:00
David Lamparter
fbfa889168 Revert "lib: Rewrite ipv4 address and prefix validator"
This reverts commit d4dc41b6a2.

The rewritten parser fails to recognise "1.2." as partial input for an
IPv4 address, which causes "make check" to fail.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-07-24 03:47:04 -04:00
Don Slice
c9a42b3d91 lib: Free memory correctly when braces used in parser
When braces (optional parameters) are used in the quagga parser, there
was a small leak on every iteration.  Since this construct is primarily
used in the configuation process rather than show commands, it was not
readily apparent.  With the addition of the "show ip bgp {json}" form of
the commands, each time one was run, memory was leaked.

Ticket: CM-11435
Signed-off-by: Don Slice
Reviewed By: Donald Sharp
Testing Done: Manual testing, bgp-min and bgp-smoke successful
2016-07-26 12:32:53 -07:00
Donald Sharp
1ee08155da lib: Modify 'banner motd file <X>'
Modify the banner motd file X command to do these things
differently:

1)  Only allow the file <X> to be in SYSCONFDIR
2)  Only allow the user to use a file that exists.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2016-07-22 19:50:51 -04:00
Quentin Young
9d0662e009 lib: Break up functions, begin matcher
Moved test hook out of command.c into vtysh.c,
renamed graph modules, added matching code

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-19 21:14:27 +00:00
Quentin Young
04e6406218 lib: Cleanup cmd_execute_command
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-12 15:05:05 +00:00
Quentin Young
51e156b303 Add grammar sandbox framework 2016-07-12 15:05:05 +00:00
Quentin Young
d4dc41b6a2 lib: Rewrite ipv4 address and prefix validator
Simplify ipv4 prefix and address matcher / validator to use standard
Linux networking functions instead of a state machine.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-07-12 13:41:27 +00:00
Quentin Young
4d91343a45 lib: Disallow % in IPv6 addresses and prefixes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-12 13:37:34 +00:00
Quentin Young
4c58c70dcb lib: Rewrite ipv6 prefix matcher
Simplify ipv6 prefix matcher / validator to use standard Linux
networking functions instead of a state machine.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-07-12 13:33:56 +00:00
Quentin Young
490b281c00 lib: Add documentation to internal command format parser functions
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-06-23 20:00:17 +00:00
Quentin Young
c4ae17398c lib: Clean command.c
Removed dead code paths and fixed a typo.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-06-16 11:59:16 -04:00
Lou Berger
8b1fb8be22 bgpd, lib, vtysh: hook up bgp ENCAP CLI node
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit a3fda886cdd48b6d8c421ebb1401142fa9ee93b0)

Conflicts:
	bgpd/bgp_vty.c
	bgpd/bgpd.c
	vtysh/vtysh_config.c
2016-06-11 15:52:05 -07:00
David Lamparter
c5e69a025f lib/vty: add separate output fd support to VTYs
to be used with stdin/stdout terminals, this adds support for writing to
a different FD than we're reading from.  Also fixes error messages from
config load being written to stdin.

[v2: fixed config write]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

(cherry picked from commit 4715a53b4d390e72a06c864a6a505971841e3dc9)
2016-06-08 15:08:05 -04:00
David Lamparter
dc1b72dca3 lib: assert(0) still needs a return
assert(0) is not guaranteed to not return since assert() in general can
be optimised out when building without debug / with optimisation.  This
breaks the build in clang, which warns/errors about the missing return.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit f1fc327c7eb00634d2c2b08c2a6f6e44a626ef04)
2016-06-08 15:03:13 -04:00
David Lamparter
27e7f29029 lib: fix "reduce strcmp in CLI" fallout (10bac801)
In "lib/cli: reduce strcmp in CLI hot paths", I failed to notice that
CMD_VARIABLE as a boolean test covers a superset of the other types of
variables.  Thus, the patch broke processing of IP/IPv6/Integer range
parameters in the CLI.

Fix by some reordering and introducing TERMINAL_RECORD macro (which
marks whether a given terminal type is a parameter) to be used in places
where the check is really for all kinds of variables.

Reported-by: Timo Teräs <timo.teras@iki.fi>
Tested-by: Martin Winter <mwinter@netdef.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-06-08 14:58:36 -04:00
David Lamparter
c117e02796 lib/cli: reduce strcmp in CLI hot paths
Er, no idea how anyone could ever have thought that it would be a good
idea to have a zillion of strcmp() calls in the CLI's active paths, just
to compare against things like "A.B.C.D".

Reduces 40k prefix list load time from 1.65s to 1.23s (1.34:1).

Acked-by: Paul Jakma <paul@jakma.org>
[v2: killed CMDS_* macros]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

(cherry picked from commit 10bac80195cf5a781da6e4415e6580fd7080f734)
2016-06-08 14:35:38 -04:00
David Lamparter
c5e0075f8b *: add/cleanup initialisers
There were some (inconsequential) warnings about uninitialised use of
variables.  Also, in one case, sub-structs were mixed in initialisation,
which doesn't quite work as intended.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-06-07 08:51:46 -04:00
vivek
8ecd326693 bgpd, lib, vtysh: hook up bgp VPNv6 CLI node
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 13c378d96a57017f5995b2e0df46cfc31123f0e8)

Conflicts:
	bgpd/bgp_vty.c
	bgpd/bgpd.c
	vtysh/vtysh_config.c
2016-06-06 19:29:05 -07:00
Lou Berger
bcd9fa7ff2 lib: add "show commandtree" CLI command
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit f9ec4190f1eaf2dba355a9808bca8d7148bc8a55)
2016-06-06 14:57:00 -07:00
Lou Berger
cde9f10117 lib: fix bookkeeping for libreadline malloc()s
When libreadline is used, we mistakenly mix in strdup() done in
libreadline with Quagga's lib/memory bookkeeping/counting, leading to
counter underflows on MTYPE_TMP.

Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 672900382d47137638086bd8351b2678f589a546)

Conflicts:
	lib/command.c
2016-06-06 14:34:42 -07:00
Donald Sharp
b06fd12526 Quagga: Fix code to use srandom/random
Quagga was using a mix of srand/rand and srandom/random.
Consolidate to use srandom/random which are the POSIX
versions of random number generators

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-29 20:24:55 -04:00
David Lamparter
80db5ac178 build: track config args
Record the ./configure arguments used and make them user-visible.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Paul Jakma <paul@jakma.org>
2016-06-03 15:53:42 -04:00
David Lamparter
12e41d03bd pimd: merge pimd as of 2015-01-19
Welcome pimd to the Quagga daemon zoo!

This is a merge of commit 77ae369 ("pimd: Log ifindex found for an
interface when zebra lib reports a new connected address."), with
the intermediate "reconnect" changes removed (c9adf00...d274381).
d274381 is replaced with b162ab7, which includes some changes.  In
addition, 4 reconnect-related changes and 1 cosmetic one have been
bumped out.

The rebase command used to produce the branch that is merged here is:
  git rebase --onto b162ab7 c9adf00 77ae369

Note that 3 patches had their author rewritten from
    "Anonymous SR#108542 <>" (which is not a valid git author ID)
to: "Savannah SR#108542 <nbahr@atcorp.com>" (which is the e-mail address
                               listed in the associated Savannah ticket)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:32 -04:00
Donald Sharp
1db63918b2 lib, vtysh: Return actual problem further up
When we encounter a problem loading a config file
quantify to the end user what has gone wrong,
with a combination of err output as well as
return codes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dave Olson <olson@cumulusnetworks.com>
2016-04-06 20:07:27 -04:00
Donald Sharp
73d2dad0bd lib: Fix assert in node_parent()
With this sequence of commands in a conf file:
router bgp X
address-family ipv4
exit
address-family ipv6
exit

When the bgp AS # is currently configured as !X and the
'vtysh -b -f <conf file above>' command run, vtysh will
crash with an assert.

This commit fixes that issue.

Ticket: CM-9852
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-17 16:12:55 -04:00
Daniel Walton
abaaab4e2d vtysh: make HIDDEN commands work
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-9646
2016-03-02 19:55:32 +00:00
Donald Sharp
4d833e556a lib, vtysh: Fix 'banner motd file' command
the File to specify was inadvertently a optional parameter.
Dissallow this.

Ticket: CM-9431
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-01 13:12:36 -05:00
Donald Sharp
7cfc61d32e lib, vtysh: Rehook the motd command back into vtysh
Code was already in place to read and display a motd, but
no cli was present to make it happen.  Add the cli
back to vtysh.conf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-02-18 10:23:45 -05:00
Daniel Walton
41d9cc6a65 quagga: remove babel
Ticket: CM-9274
Reviewed By: sharpd@cumulusnetworks.com
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2016-02-11 08:55:24 -08:00
Donald Sharp
19dc275e1f lib, vtysh, zebra: Better VRF debug handling
Fixup the debug handling of vrf's to be a bit
more explicit how we create a vrf internally.

Add code to turn on/off debugging of vrf's.

Ticket: CM-9063
Testing: Manual

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-03 09:00:25 -05:00
Donald Sharp
f93e3f696c lib: Allow vrf under the cli
Add the infrastructure to allow the vrf keyword.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-01 09:38:33 -08:00
Daniel Walton
fd715b78d9 quagga errors parsing a valid config
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-16 20:51:38 +00:00
Donald Sharp
bed578b8b9 vtysh: Fix Quagga.conf file read in.
There exists a sequence of cli commands that are successfully read in by bgpd.conf, but
not by a consolidated Quagga.conf.

This issue stems from the fact that the consolidated config file attempts to match the
current node + 1 node up the tree, while the individual config file searches for matches
all the way up the tree.

Quagga.conf read-in relies on vtysh_cmd.c command parsing which puts all nodes
at CONFIG_NODE and if a match is found CMD_SUCCESS_DAEMON is returned.  This signals to
the parser to call the appropriate daemon with the comamnd.

bgp as an example has three levels of config node's.  If you are reading in a config node
at the 3rd level(say address-family ipv6) then transition to another node under bgp it will
not work in Quagga.conf because the code only looked up one node and was at CONFIG_BGP when it failed
to find a match.

Ticket: CM-7625
Reviewed by: CCR-3591
Testing: See Bug

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2015-09-28 13:17:36 -07:00
Steve Hill
13fbc82d86 lib: Improve error reporting from broken config files
* command.h: (config_from_file) Add variable to interface for line
      number reporting.
    * command.c: (config_from_file) Set & increment 'line_num' while parsing.
    * vty.c: (vty_read_file) Report parse errors in the correct order to
      stderr, with added line numbers.

Conflicts:
	lib/command.c
	lib/vty.c

Integrated in changes made to continue loading code even after failure
to read a line in properly as part of this cherry-pick
2015-09-01 12:44:10 -07:00
Donald Sharp
16cf945a50 Fix optional arguments with description interactions
Ticket: CM-6659
Reviewed by: CCR-3203
Testing: See bug

If you have a cli like this:
"neighbor WORD interface {v6only}"

When in the cli you hit ? after entering v6only you get this:

tor-11(config-router)# neighbor swp1 interface v6only
% There is no matched command.
tor-11(config-router)# neighbor swp1 interface v6only

With this fix we now see:
tor-22(config-router)# neighbor swp1 interface v6only
<cr>
tor-22(config-router)# neighbor swp1 interface v6only

This behavior is now consistent with non-optional last
arguments.
2015-08-26 09:01:31 -07:00
Daniel Walton
5689fe5fef Quagga processes should not die if they read an unrecognized line in
their config file

Ticket: CM-6738
Reviewed By: Donald and Dinesh
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2015-07-27 20:30:22 -07:00
Donald Sharp
e442116524 vtysh-integrated-fix.patch
Lost config when switching back and forth between 'service integrated-vtysh-config'.
Also it was possible to have config files not be read in if they were not generated.

Ticket: CM-6011, CM-6033
Reviewed By: Daniel Walton <dwalton@cumulusnetworks.com>
Testing Done: See bugs
2015-05-20 16:55:57 -07:00
Donald Sharp
c0e8c16f84 vtysh: vtysh-warnings.patch
Remove compile warnings for the vtysh directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:29:15 -07:00
Donald Sharp
24873f0c06 lib: lib-warnings.patch
Remove compile warnings for the lib directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:04:26 -07:00
Donald Sharp
f702c39f46 "set metric -10" is not accepted by the parser on 64-bit x86 platforms 2015-05-19 17:58:11 -07:00
David Lamparter
6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

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

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

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

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 20:21:41 +02:00
David Lamparter
0be793e674 build: include git info
If enabled with --with-pkg-gitversion on ./configure, this will append
git version strings and branch information at the following places:
 - overall version number: 0.99.21-g0123456
 - login motd and show version: tag information + git id + branches

Sample output:
  Hello, this is Quagga (version 0.99.21-g14b49ad-dirty).
  Copyright 1996-2005 Kunihiro Ishiguro, et al.

  This is a git build of quagga_0_99_21_release-106-g14b49ad-dirty
  Associated branch(es):
	local:master

[v2]: fix build without gitinfo (add "else" branch)
[v2]: fix for repos without any tags (different git describe output)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-12-12 15:34:37 +01:00
David Lamparter
aa5cf24b9d lib: make IPv6 prefix parser slightly more strict
This makes it possible to have both "show babel route A.B.C.D/M"
and "show babel route X:X::X:X/M" commands at the same time without
the parser complaining about ambiguity.

* lib/command.c: only accept STATE_DOT after : was seen.

Reported-by: Juliusz Chroboczek <jch@pps.jussieu.fr>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-07-19 16:15:50 +02:00
Roman Hoog Antink
7c9c6aebe8 lib: drop heuristic IPv6 address recognition
* command.c: (cmd_ipv6_match) Drop IPv6 address recognition
  heuristics and solely rely on inet_pton, because strings
  like "abcd" were mistaken for IPv6 addresses.
  This affects e.g. the command "neighbour WORD peer-group",
  which won't work with words consisting of up to 4 characters
  between 'a' and 'f' and digits.

From: Roman Hoog Antink <rha@open.ch>
[full delete instead of #if 0]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-05-21 15:41:14 +02:00
Paul Jakma
5734509c05 babeld: Initial import, for Babel routing protocol.
* Initial import of the Babel routing protocol, ported to Quagga.
* LICENCE: Update the original LICENCE file to include all known potentially
  applicable copyright claims.  Ask that any future contributors to babeld/
  grant MIT/X11 licence to their work.
* *.{c,h}: Add GPL headers, in according with the SFLC guidance on
  dealing with potentially mixed GPL/other licensed work, at:

  https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
2012-03-25 17:06:51 +01:00
Denis Ovsienko
b82cdeb18f delete CVS keywords 2011-09-27 21:34:26 +04:00
Christian Hammers
fc95186c30 lib: fix more format warnings (#637)
The following patch was also neccessary to compile.

* command.c: (config_logmsg_cmd) use "%s" format spec
* if.c: (connected_log) ditto
2011-03-23 13:07:55 +03:00
Paul Jakma
e276eb8282 lib: Add a command to clear the thread CPU history data
* (general) this can be useful when investigating thread latency problems,
  when you don't want to have to restart a daemon between tests.
* thread.c: (cpu_record_(hash_)clear) wipe the stored thread cpu history
  data, according to the filter, similar to the vty print code.
  (clear_thread_cpu_cmd) new command to clear data.
* thread.h: export new command
* command.c: install it
2010-12-08 16:53:09 +00:00
Stephen Hemminger
2d362d1099 lib: make some structures constant
* isisd/isis_pdu.c
  * maskbit: this pre-initialized array is not modified
* lib/prefix.c
  * maskbit: idem
* lib/command.c
  * facility_map: idem
  * itoa64: idem
  * default_motd: make local var static
  * facility_name(): update local var accordingly
  * facility_match(): idem
2009-12-21 13:03:51 +03:00
Chris Caputo
228da42898 [bgpd] Stability fixes including bugs 397, 492
I've spent the last several weeks working on stability fixes to bgpd.
These patches fix all of the numerous crashes, assertion failures, memory
leaks and memory stomping I could find.  Valgrind was used extensively.

Added new function bgp_exit() to help catch problems.  If "debug bgp" is
configured and bgpd exits with status of 0, statistics on remaining
lib/memory.c allocations are printed to stderr.  It is my hope that other
developers will use this to stay on top of memory issues.

Example questionable exit:

  bgpd: memstats: Current memory utilization in module LIB:
  bgpd: memstats:  Link List                     :          6
  bgpd: memstats:  Link Node                     :          5
  bgpd: memstats:  Hash                          :          8
  bgpd: memstats:  Hash Bucket                   :          2
  bgpd: memstats:  Hash Index                    :          8
  bgpd: memstats:  Work queue                    :          3
  bgpd: memstats:  Work queue item               :          2
  bgpd: memstats:  Work queue name string        :          3
  bgpd: memstats: Current memory utilization in module BGP:
  bgpd: memstats:  BGP instance                  :          1
  bgpd: memstats:  BGP peer                      :          1
  bgpd: memstats:  BGP peer hostname             :          1
  bgpd: memstats:  BGP attribute                 :          1
  bgpd: memstats:  BGP extra attributes          :          1
  bgpd: memstats:  BGP aspath                    :          1
  bgpd: memstats:  BGP aspath str                :          1
  bgpd: memstats:  BGP table                     :         24
  bgpd: memstats:  BGP node                      :          1
  bgpd: memstats:  BGP route                     :          1
  bgpd: memstats:  BGP synchronise               :          8
  bgpd: memstats:  BGP Process queue             :          1
  bgpd: memstats:  BGP node clear queue          :          1
  bgpd: memstats: NOTE: If configuration exists, utilization may be expected.

Example clean exit:

  bgpd: memstats: No remaining tracked memory utilization.

This patch fixes bug #397: "Invalid free in bgp_announce_check()".

This patch fixes bug #492: "SIGBUS in bgpd/bgp_route.c:
bgp_clear_route_node()".

My apologies for not separating out these changes into individual patches.
The complexity of doing so boggled what is left of my brain.  I hope this
is all still useful to the community.

This code has been production tested, in non-route-server-client mode, on
a linux 32-bit box and a 64-bit box.

Release/reset functions, used by bgp_exit(), added to:

  bgpd/bgp_attr.c,h
  bgpd/bgp_community.c,h
  bgpd/bgp_dump.c,h
  bgpd/bgp_ecommunity.c,h
  bgpd/bgp_filter.c,h
  bgpd/bgp_nexthop.c,h
  bgpd/bgp_route.c,h
  lib/routemap.c,h

File by file analysis:

* bgpd/bgp_aspath.c: Prevent re-use of ashash after it is released.

* bgpd/bgp_attr.c: #if removed uncalled cluster_dup().

* bgpd/bgp_clist.c,h: Allow community_list_terminate() to be called from
  bgp_exit().

* bgpd/bgp_filter.c: Fix aslist->name use without allocation check, and
  also fix memory leak.

* bgpd/bgp_main.c: Created bgp_exit() exit routine.  This function frees
  allocations made as part of bgpd initialization and, to some extent,
  configuration.  If "debug bgp" is configured, memory stats are printed
  as described above.

* bgpd/bgp_nexthop.c: zclient_new() already allocates stream for
  ibuf/obuf, so bgp_scan_init() shouldn't do it too.  Also, made it so
  zlookup is global so bgp_exit() can use it.

* bgpd/bgp_packet.c: bgp_capability_msg_parse() call to bgp_clear_route()
  adjusted to use new BGP_CLEAR_ROUTE_NORMAL flag.

* bgpd/bgp_route.h: Correct reference counter "lock" to be signed.
  bgp_clear_route() now accepts a bgp_clear_route_type of either
  BGP_CLEAR_ROUTE_NORMAL or BGP_CLEAR_ROUTE_MY_RSCLIENT.

* bgpd/bgp_route.c:
  - bgp_process_rsclient(): attr was being zero'ed and then
    bgp_attr_extra_free() was being called with it, even though it was
    never filled with valid data.

  - bgp_process_rsclient(): Make sure rsclient->group is not NULL before
    use.

  - bgp_processq_del(): Add call to bgp_table_unlock().

  - bgp_process(): Add call to bgp_table_lock().

  - bgp_update_rsclient(): memset clearing of new_attr not needed since
    declarationw with "= { 0 }" does it.  memset was already commented
    out.

  - bgp_update_rsclient(): Fix screwed up misleading indentation.

  - bgp_withdraw_rsclient(): Fix screwed up misleading indentation.

  - bgp_clear_route_node(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT.

  - bgp_clear_node_queue_del(): Add call to bgp_table_unlock() and also
    free struct bgp_clear_node_queue used for work item.

  - bgp_clear_node_complete(): Do peer_unlock() after BGP_EVENT_ADD() in
    case peer is released by peer_unlock() call.

  - bgp_clear_route_table(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT.  Use
    struct bgp_clear_node_queue to supply data to worker.  Add call to
    bgp_table_lock().

  - bgp_clear_route(): Add support for BGP_CLEAR_ROUTE_NORMAL or
    BGP_CLEAR_ROUTE_MY_RSCLIENT.

  - bgp_clear_route_all(): Use BGP_CLEAR_ROUTE_NORMAL.

  Bug 397 fixes:

    - bgp_default_originate()
    - bgp_announce_table()

* bgpd/bgp_table.h:
  - struct bgp_table: Added reference count.  Changed type of owner to be
    "struct peer *" rather than "void *".

  - struct bgp_node: Correct reference counter "lock" to be signed.

* bgpd/bgp_table.c:
  - Added bgp_table reference counting.

  - bgp_table_free(): Fixed cleanup code.  Call peer_unlock() on owner if
    set.

  - bgp_unlock_node(): Added assertion.

  - bgp_node_get(): Added call to bgp_lock_node() to code path that it was
    missing from.

* bgpd/bgp_vty.c:
  - peer_rsclient_set_vty(): Call peer_lock() as part of peer assignment
    to owner.  Handle failure gracefully.

  - peer_rsclient_unset_vty(): Add call to bgp_clear_route() with
    BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.

* bgpd/bgp_zebra.c: Made it so zclient is global so bgp_exit() can use it.

* bgpd/bgpd.c:
  - peer_lock(): Allow to be called when status is "Deleted".

  - peer_deactivate(): Supply BGP_CLEAR_ROUTE_NORMAL purpose to
    bgp_clear_route() call.

  - peer_delete(): Common variable listnode pn.  Fix bug in which rsclient
    was only dealt with if not part of a peer group.  Call
    bgp_clear_route() for rsclient, if appropriate, and do so with
    BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.

  - peer_group_get(): Use XSTRDUP() instead of strdup() for conf->host.

  - peer_group_bind(): Call bgp_clear_route() for rsclient, and do so with
    BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.

  - bgp_create(): Use XSTRDUP() instead of strdup() for peer_self->host.

  - bgp_delete(): Delete peers before groups, rather than after.  And then
    rather than deleting rsclients, verify that there are none at this
    point.

  - bgp_unlock(): Add assertion.

  - bgp_free(): Call bgp_table_finish() rather than doing XFREE() itself.

* lib/command.c,h: Compiler warning fixes.  Add cmd_terminate().  Fixed
  massive leak in install_element() in which cmd_make_descvec() was being
  called more than once for the same cmd->strvec/string/doc.

* lib/log.c: Make closezlog() check fp before calling fclose().

* lib/memory.c: Catch when alloc count goes negative by using signed
  counts.  Correct #endif comment.  Add log_memstats_stderr().

* lib/memory.h: Add log_memstats_stderr().

* lib/thread.c: thread->funcname was being accessed in thread_call() after
  it had been freed.  Rearranged things so that thread_call() frees
  funcname.  Also made it so thread_master_free() cleans up cpu_record.

* lib/vty.c,h: Use global command_cr.  Add vty_terminate().

* lib/zclient.c,h: Re-enable zclient_free().
2009-07-19 18:28:08 +01:00
Stephen Hemminger
7fc626de5f [cleanup] Make command nodes static
The cmd_nodes used to configure vty, can mostly be static so
(basic data hiding 101).
2009-06-12 17:10:29 +01:00
Paul Jakma
62687ff1cd [vty] Add support for a 'restricted mode' with anonymous vty connections
* lib/command.h: Add a RESTRICTED_NODE, intended for use with
	  anonymous, 'no login' vtys, to provide a subset of 'view' mode
	  commands.
	* lib/command.c: Add RESTRICTED_NODE bits, nothing special, just
	  following VIEW_NODE.
	* lib/vty.c: (vty_auth) enable authentication should fall back to
	  restricted/view node as appropriate.
	  (vty_create) init vty's to restricted/view node as appropriate,
	  for the 'no login' case.
	  (vty_{no_,}restricted_mode_cmd) config commands to enable
	  'anonymous restricted' in vty configuration.
	  (vty_config_write) 'anonymous restricted' config.
	  (vty_init) Install some commands to restricted mode, and the
	  'anonymous restricted' config commands into VTY_NODE.
	* bgpd/*.c: Install some of the safe(r) BGP commands into
	  'restricted mode', i.e. lookup commands of non-sensitive data.
	  Useful with looking-glass route-servers.
2008-08-23 14:27:06 +01:00
Andrew J. Schorr
1ed72e0b3a [logging] Add new "log timestamp precision" command for subsecond timestamps
2007-04-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* command.c: (config_write_host) Save "log timestamp precision"
	  if not default value.
	  (show_logging) Show configured timestamp precision.
	  (config_log_timestamp_precision) Enable configuration of timestamp
	  precision.
	  (no_config_log_timestamp_precision) Restore default timestamp
	  precision.
	  (cmd_init) Install new timestamp precision commands.
	* log.h: (struct zlog) New timestamp_precision field.
	  (quagga_timestamp) New function to generate a timestamp with the
	  desired precision.
	  (struct timestamp_control) Declare a structure for use in avoiding
	  repeated duplicate calls to quagga_timestamp.
	* log.c: (quagga_timestamp) New function to generate a timestamp
	  of the desired precision.
	  (time_print) Call quagga_timestamp if the time hasn't already been
	  calculated.
	  (vzlog) Initialize a timestamp_control structure and pass it to
	  time_print and vty_log.
	  (zlog_backtrace) Fix 64-bit problem: cannot print size_t with %u.
	* vty.h: Must now include "log.h".
	  (vty_log) Takes an additional struct timestamp_control argument.
	* vty.c: (vty_log_out) Use new struct timestamp_control and new
	  quagga_timestamp function to print timestamps of the desired
	  precision.
	  (vty_time_print) Use new quagga_timestamp function.
	  (vty_log) Accept new struct timestamp_control argument and pass it
	  down to vty_log_out.
2007-04-28 22:14:10 +00:00
Paul Jakma
e5cd706c1a [lib] Fix vector leak in error path in command.c, CID #38
2006-06-15 Paul Jakma <paul.jakma@sun.com>

	* command.c: (cmd_describe_command_real) Fix leak, CID #38.
2006-06-15 12:25:55 +00:00
Paul Jakma
5fc60519ed [lib] CID #55, fix return of freed pointer, cmd_describe_command_real
2006-05-12 Paul Jakma <paul.jakma@sun.com>

	* command.c: (cmd_describe_command_real) Fix return of freed
	  pointer when no-match, CID #55.
2006-05-12 23:24:09 +00:00
Paul Jakma
d2519962b7 [lib] CID #37, fix error case leak, cmd_complete_command_real
2006-05-12 Paul Jakma <paul.jakma@sun.com>

	* command.c: (cmd_complete_command_real) Fix leak of cmd_vector
	  in error case, Coverity CID #37.
2006-05-12 23:19:37 +00:00
paul
05865c90ab 2005-10-26 Paul Jakma <paul.jakma@sun.com>
* command.c: Use MTYPE_HOST, MTYPE_STRVEC. Some other fixups,
	  including fixing some likely leaks in config_write_file.
	* vty.c: memory macro usage fixes.
	  (vty_read_config) fix leak where relative config file is
	  specified.
2005-10-26 05:49:54 +00:00
paul
eb820afe3b 2005-09-05 Paul Jakma <paul.jakma@sun.com>
* command.c: (install_element) be more robust. Eg, cmd_init
	  need not have been called, some applications may use other
	  library subsystems, which call install_element, without the
          application wanting commands and hence not calling cmd_init.
2005-09-05 11:54:13 +00:00
paul
1e83659026 2005-08-22 Hugo Santos <hsantos@av.it.pt>
* command.h: (enum node_type) Add BGP_IPV6M_NODE
	* command.c: (node_parent) Handle BGP_IPV6M_NODE node
	  (config_exit, config_end) ditto
	* vty.c: (vty_end_config) Handle BGP_IPV6M_NODE node
2005-08-22 22:39:56 +00:00
paul
8cc4198f9f 2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
	  header.
	  Cleanup any definitions with unspecified arguments.
	  Add casts for callback assignments where the callback is defined,
	  typically, as passing void *, but the function being assigned has
	  some other pointer type defined as its argument, as gcc complains
	  about casts from void * to X* via function arguments.
	  Fix some old K&R style function argument definitions.
	  Add noreturn gcc attribute to some functions, as appropriate.
	  Add unused gcc attribute to some functions (eg ones meant to help
	  while debugging)
	  Add guard defines to headers which were missing them.
	* command.c: (install_node) add const qualifier, still doesnt shut
	  up the warning though, because of the double pointer.
	  (cmp_node) ditto
	* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
	  fromn vty.h ones to fix some of the (long) < 0 warnings.
	* thread.c: (various) use thread_empty
	  (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
	* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
	  removed from ospfd/ospf_vty.h
	* zebra.h: Move definition of ZEBRA_PORT to here, to remove
	  dependence of lib on zebra/zserv.h
2005-05-06 21:25:49 +00:00
paul
354d119a65 2005-04-25 Paul Jakma <paul.jakma@sun.com>
* workqueue.{c,h}: Helper API for setting up and running queues via
	  background threads.
	* command.c: install the 'show workqueues' command
	* memtypes.c: Add work queue mtypes, and a rib-queue type for
	  a zebra rib work queue.
	* memtypes.h: Updated to match memtypes.c
	* Makefile.am: Add new workqueue files to build.
2005-04-25 16:26:42 +00:00
paul
55468c8604 2005-03-14 Paul Jakma <paul.jakma@sun.com>
* (global) update all c files to match the lib/vector.h rename of
	  (struct vector).active to max, and vector_max macro to
	  vector_active.
	* lib/vector.h: Rename to (struct vector).max to slightly less
	  confusing active, for the number of active slots, distinct from
	  allocated or active-and-not-empty. Rename vector_max to
	  vector_active for same reason.
2005-03-14 20:19:01 +00:00
paul
909a215508 2005-03-14 Paul Jakma <paul.jakma@sun.com>
* command.c: (various) Fix indentation and other whitespace.
2005-03-14 17:41:45 +00:00
paul
b89614766b 2005-03-14 Paul Jakma <paul.jakma@sun.com>
* command.c: (sort_node) use vector_max instead of referencing
	  (struct vector *)->max directly. Test that vector_max is > 0
	  before using it to calculate an index.
	  Fixup vector loop to make main body conditional on vector slot
	  not being empty.
	  (cmd_cmdsize) Fixup vector loop to make main body conditional on
	  vector slot not being empty.
	  (cmd_filter_by_completion) ditto
	  (cmd_filter_by_string) ditto
	  (is_cmd_ambiguous) ditto
	  (cmd_describe_command_real) Change index integers to unsigned.
	  Test that vector_max is > 0 before using it to calculate an index.
	  Return immediately with CMD_ERR_NO_MATCH if vline has no
	  active slots.
	  Fixup vector loop to make main body conditional on vector slot
	  not being empty.
	  (cmd_complete_command_real) ditto.
	  (cmd_execute_command_strict) Fixup vector loop to be conditional
	  on non-null slot.
2005-03-14 17:35:52 +00:00
paul
4275b1de3a 2005-03-09 Paul Jakma <paul.jakma@sun.com>
* command.c: (config_list_cmd) Don't list hidden or deprecated
	  commands, hiding these from tab completion is still to be done.
2005-03-09 13:42:23 +00:00
paul
9e92eeab6c 2005-03-09 Paul Jakma <paul.jakma@sun.com>
* command.c: Undo commit of sign warning fix and hidden command
	  in list_cmd. Sign warning is more subtle. list_cmd on its own
	  will be committed after.
2005-03-09 13:39:26 +00:00
paul
220851816a 2005-03-08 Paul Jakma <paul.jakma@sun.com>
* command.c: (no_banner_motd_cmd) use XFREE.
	* vty.c: (vty_hello) fix the indentation and comment.
2005-03-08 16:00:12 +00:00
paul
9c5d8562f8 2005-03-08 Paul Jakma <paul.jakma@sun.com>
* command.c: (cmd_describe_command_real) sign compile warning fix
	  (cmd_complete_command_real) ditto.
	  (config_list_cmd) Don't list hidden or deprecated commands,
	  hiding these from tab completion is still to be done.
	* command.h: cmd attr enum should start at 1.
2005-03-08 15:56:42 +00:00
paul
b45da6f016 2005-03-08 Paul Jakma <paul.jakma@sun.com>
* command.c: (banner_motd_file_cmd) use XSTRDUP/XFREE
	* vty.c: (vty_hello) suggestions from Andrew, read by line and
	  stub out trailling non-printable characters on each line thus
	  allowing us to specify VTY_NEWLINE to vty_out.
2005-03-08 15:16:57 +00:00
paul
3b0c5d9a56 2005-03-08 Jeroen Massar <jeroen@unfix.org>
* vty.c: (vty_hello) display motd file, if set
	* command.h: add char *motdfile to struct host
	* command.c: (config_write_host) write out motdfile config
	  (banner_motd_file_cmd) new command, allow motd to be read from
	  file.
	  (no_banner_motd_cmd) free motdfile string, if needs be.
	  (cmd_init) init (struct host).motdfile. Add new motd file
	  commands.
2005-03-08 10:43:43 +00:00
hasso
12f6ea2300 * command.c: host.name might be NULL.
* vty.c: Fix fd leak.

	[backport candidate]
2005-03-07 08:35:39 +00:00
ajs
f6834d4c40 2005-01-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* lib/command.h: Document behavior of argv_concat function.
	* lib/command.c: (argv_concat) Calculate total string length first so
	  we can call malloc just once (instead of realloc'ing to add each
	  string element).
	  (do_echo,config_logmsg) Allow for possible NULL return value from
	  argv_concat.
2005-01-28 20:28:35 +00:00
hasso
13bfca7a10 * lib/command.[ch]: Make node_parent() function nonstatic. vtyh.c will
use it as well.
        * vtysh/vtysh.c: Implement walkup in node tree for vtysh as it already
          works in vty.
2005-01-23 21:42:25 +00:00
hasso
87d683b071 * command.[ch], vty.c: cmd_execute_command() function must not attempt
to walk up in the node tree if called from vtysh. Different daemons
	  might have commands with same syntax in different nodes (for example
	  "router-id x.x.x.x" commands in zebra/ospfd/ospf6d daemons).

	* vtysh.c: Reflect changes in lib. cmd_execute_command() should know
	  now that it's called from vtysh and must not attempt to walk up in
	  the node tree.

	[pullup candidate]
2005-01-16 23:31:54 +00:00
ajs
cb585b65d1 2005-01-14 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* command.c (print_version): Do not bother even to examine host.name,
	  since it is always NULL when this function is called from main.
2005-01-14 17:09:38 +00:00
gdt
f867d32c4a 2005-01-14 Greg Troxel <gdt@fnord.ir.bbn.com>
* command.c (print_version): Don't print host.name if it is NULL.
        Fixes segfault on Solaris reported by Goetz von Escher <goetz@open.ch>

(pullup candidate)
2005-01-14 15:47:33 +00:00
hasso
cba8a60639 Reverting some int -> unsigned int fixes in command.c for now. Fixes crash
described in [quagga-dev 2292].
2005-01-02 18:51:01 +00:00
ajs
2885f72d54 2004-12-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* command.c: (do_echo) Added new "echo" command, useful for
	  watchdog pinging to make sure the daemon is responsive.
2004-12-17 23:16:33 +00:00
ajs
82146b8891 2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* command.c: (config_write_host) Note that "log trap" is deprecated
	  when writing out the config.
2004-12-07 17:15:55 +00:00
ajs
274a4a4447 2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* bgp_main.c: (main) The 2nd argument to openzlog has been removed.
	* isis_main.c: (main) The 2nd argument to openzlog has been removed.
	* ospf6_main.c: (main) The 2nd argument to openzlog has been removed.
	  Note that stdout logging will no longer be enabled by default when
	  not running as a daemon.
	* ospf_main.c: (main) The 2nd argument to openzlog has been removed.
	* rip_main.c: (main) The 2nd argument to openzlog has been removed.
	* ripng_main.c: (main) The 2nd argument to openzlog has been removed.
	* main.c: (main) The 2nd argument to openzlog has been removed.
	  So stdout logging will no longer be enabled by default.
	* irdp_main.c: (irdp_finish) Reduce severity of shutdown message
	  from LOG_WARNING to LOG_INFO.
	* vtysh.c: Make several functions static instead of global.
	  Added several commands to support destination-specific logging levels.
	  (vtysh_completion) This function is unused, so comment it out.
	* basic.texi: Document new logging features.  Separate basic config
	  commands from basic VTY commands.
	* log.h: Replace struct zlog flags and maskpri fields with maxlvl
	  array to support individual logging levels for each destination.
	  Remove the 2nd argument to openzlog since the default logging config
	  should be standardized inside the library.  Replaced the
	  zlog_set_flag and zlog_reset_flag functions with zlog_set_level.
	  And zlog_set_file now requires an additional log_level argument.
	  Declare zlog_proto_names for use inside command.c in the
	  "show logging" command.  Added defines useful for command
	  construction.
	* log.c: (vzlog) Decide where to send the message based on the
	  individual logging levels configured for each destination.
	  Remove support for ZLOG_STDERR since it was never actually used.
	  Support record-priority for terminal monitors.
	  (zlog_signal,zlog_backtrace_sigsafe) Support destination-specific
	  logging levels.  Remove stderr support (was never used).  Added
	  support for terminal monitor logging.
	  (_zlog_assert_failed) Increase message severity to LOG_EMERG.
	  (openzlog) Remove 2nd argument since default config should be
	  standardized in library.  By default, terminal monitoring
	  is set to debug, and all other logging is disabled.
	  (zlog_set_flag,zlog_reset_flag) Removed.
	  (zlog_set_level) New function to replace zlog_set_flag and
	  zlog_reset_flag.  Supports destination-specific logging levels.
	  (zlog_set_file,zlog_reset_file) Support file-specific logging level.
	  (zlog_rotate) Log an error message if fopen fails, and support
	  new file-specific logging level.
	* command.h: Change DEFUN_CMD_FUNC_DECL and DEFUN_CMD_FUNC_TEXT so that
	  command functions will be static instead of global.  Remove
	  declarations for config_exit and config_help.  Define new macros
	  DEFUNSH_ATTR, DEFUNSH_HIDDEN, and DEFUNSH_DEPRECATED so we can
	  have deprecated commands in vtysh.  Similarly, for completeness,
	  define macros ALIAS_SH, ALIAS_SH_HIDDEN, and ALIAS_SH_DEPRECATED.
	  Also, fix bug in ALIAS_ATTR macro (didn't matter because it
	  was never used).
	* command.c: Make many functions static instead of global.
	  (facility_name,facility_match,level_match) New functions
	  to support enhanced destination-specific logging levels.
	  (config_write_host) Support new destination-specific logging levels.
	  (config_logmsg) Added new "logmsg" command to help test logging
	  system.
	  (show_logging) Added "show logging" command to show the current
	  configuration of the logging system.
	  (config_log_stdout_level) Support explicit stdout logging level.
	  (no_config_log_stdout) Now takes optional LEVEL arg.
	  (config_log_monitor,config_log_monitor_level,no_config_log_monitor)
	  New commands creating new "log monitor" commands to set terminal
	  monitoring log level.
	  (config_log_file_level) Support explicit file logging level.
	  (config_log_syslog_level) Support explicit syslog logging level.
	  (config_log_facility,no_config_log_facility) Implement new
	  "log facility" command.
	  (cmd_init) Add hooks for new commands: "show logging", "logmsg",
	  "log stdout <level>", "log monitor", "log monitor <level>",
	  "no log monitor", "log file <filename> <level>",
	  "no log file <filename> <level>", "log syslog <level>",
	  "log facility", and "no log facility".
	* vty.h: Added a "level" argument to vty_log so it can support
	  "log record-priority".  Declare new function vty_log_fixed for
	  use in signal handlers.
	* vty.c: (vty_log,vty_log_out) Added a "level" argument to support
	  "log record-priority" for vty terminal monitors.
	  (vty_down_level) Use config_exit_cmd.func instead of calling
	  config_exit directly (since command functions will now be static
	  instead of global).
	  (vty_log_fixed) New function to send terminal monitor messages
	  from inside a signal handler.
2004-12-07 15:39:31 +00:00
ajs
56f2069a03 2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* command.h: Remove fields log_stdout and log_syslog from struct host,
	  since they are just trying to duplicate information in the
	  zlog_default structure.  Note that this fixes a bug since those
	  fields were not registering any logging that was established
	  in the initial call to openzlog (this affects only the zebra and
	  ospf6d daemons).  It is probably a bug to turn on any logging by
	  default in the call to openzlog.
	* command.c: (config_write_host) Get logging info from zlog_default
	  instead of now-removed fields host.log_stdout and host.log_syslog.
	  (config_log_stdout,no_config_log_stdout) Do not set now-removed field
	  host.log_stdout, since this info is recorded in zlog_default.
	  (config_log_file) Use XSTRDUP (instead of strdup) to set host.logfile.
	  (config_log_syslog,config_log_syslog_facility,no_config_log_syslog)
	  Do not set now-removed field host.log_syslog, since this info is
	  recorded in zlog_default.
2004-12-03 17:40:31 +00:00
ajs
d246bd9658 2004-11-23 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* log.c: (vzlog) Take a single va_list argument and use va_copy
	  as necessary for multiple traversals.
	  (zlog) Pass only one va_list to vzlog.
	  (zlog_*,plog_*) Use a macro for boilerplate code; pass only one
	  va_list to vzlog.
	  (zlog_set_file) Remove unused 2nd argument (flags).
	  (zlog_save_cwd,zlog_get_cwd,zlog_free_cwd) Remove unused functions.
	* log.h: Remove ZLOG_*_INDEX defines (no longer used).
	  Remove unused 2nd argument from zlog_set_file prototype.
	  Fix prototype for zlog_rotate.
	* command.c: (config_log_file) Remove unused 2nd arg to zlog_set_file.
	* vty.c: (vty_out) Fix stdarg usage to perform multiple traversals
	  properly.
	  (vty_log) Must use va_copy for multiple traversals of va_list arg.
2004-11-23 17:35:08 +00:00