summaryrefslogtreecommitdiff
path: root/lib/vty.c
AgeCommit message (Collapse)Author
2017-05-23lib: remove BGP_ENCAP(V6)_NODELou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2017-05-18lib: detangle protocol name/instance from loggingDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-17Merge pull request #538 from qlyoung/fix-stack-access-2Lou Berger
lib: return thread * from thread_add*
2017-05-16lib: let vty.c manage its own pointersQuentin Young
vty.c doesn't require back refs for a couple threads Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15Merge pull request #531 from qlyoung/fix-stack-refLou Berger
lib: fix access to stack value
2017-05-15lib: cli: autocomplete variablesDavid Lamparter
Shows known values in the appropriate naming domain when the user hits <?> or <Tab>. This patch only works in the telnet CLI, the next patch adds vtysh support. Included completions: - interface names - route-map names - prefix-list names Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15lib: fix access to stack valueQuentin Young
Passing stack value to thread_add_* causes thread->ref to become an invalid pointer when the value goes out of scope Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09*: update thread_add_* callsQuentin Young
Pass pointer to pointer instead of assigning by return value. See previous commit message. To ensure that the behavior stays functionally correct, any assignments with the result of a thread_add* function have been transformed to set the pointer to null before passing it. These can be removed wherever the pointer is known to already be null. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09*: remove THREAD_ON macros, add nullity checkQuentin Young
The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-02Merge branch 'master' into EIGRPDonald Sharp
2017-04-06bgpd: labeled unicast configDon Slice
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-05Merge remote-tracking branch 'origin/master' into EIGRPDonald Sharp
2017-03-28*: apply DEFUN_NOSH for node-switch CLI commandsDavid Lamparter
These have copies in vtysh that do the node-switch locally and are listed in extract.pl's ignore list. The ignore list however is redundant since DEFUN_NOSH does the same thing... ldpd is a bit hacky, but Renato is reworking this anyway. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-17Merge remote-tracking branch 'origin/master' into EIGRPDonald Sharp
2017-03-10Merge branch 'stable/2.0'David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-09lib: handle case specifc types, protect against double free (issue #144)Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net> [DL: dropped changes except the two NULL assignments] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08eigrp: Initial CommitDonald Sharp
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-08lib: hide away logging internalsDavid Lamparter
... 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-08lib: simplify protocol/log namingDavid Lamparter
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*: get rid of zlog(*, LOG_LEVEL, ...)David Lamparter
Result of running the following Coccinelle patch + fixups: <<EOF /* long-forms: zlog(NULL, <level>, ...) * => zlog_level(...) */ @@ expression list args; @@ - zlog(NULL, LOG_DEBUG, args) + zlog_debug(args) @@ expression list args; @@ - zlog(NULL, LOG_NOTICE, args) + zlog_notice(args) @@ expression list args; @@ - zlog(NULL, LOG_INFO, args) + zlog_info(args) @@ expression list args; @@ - zlog(NULL, LOG_WARNING, args) + zlog_warn(args) @@ expression list args; @@ - zlog(NULL, LOG_ERR, args) + zlog_err(args) /* long-forms: zlog(base->log, <level>, ...) * => zlog_level(...) */ @@ expression base; expression list args; @@ - zlog(base->log, LOG_DEBUG, args) + zlog_debug(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_NOTICE, args) + zlog_notice(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_INFO, args) + zlog_info(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_WARNING, args) + zlog_warn(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_ERR, args) + zlog_err(args) EOF Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08*: add frr_config_fork()David Lamparter
Centralise read_config/daemonize/dryrun/pidfile/vty_serv into libfrr. This also makes multi-instance pid/config handling available as part of the library. It's only wired up in ospfd, but the code is in lib/. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-14lib: define BGP_EVPN_NODEPhilippe Guibert
This define introduces bgp sub node address-family evpn. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-02-10lib: rework vty_use_backup_config()David Lamparter
Like config_write(), this should use rename(), even though atomicity is not a real issue here. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10lib: fix remaining coverity issuesDavid Lamparter
Reported-by: Coverity Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-09lib: use fsync() for config writes, plug fd leakDavid Lamparter
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-09lib: use fsync() for config writes, plug fd leakDavid Lamparter
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-07Merge branch 'frr/pull/152' ("Lib fixes")David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-02Merge remote-tracking branch 'origin/stable/2.0'Donald Sharp
2017-02-01lib: Properly Initialize codeDonald Sharp
was_stdio was never set up with a 'correct' initial value, leading to cases where we would choose what to do based upon what was in the stack. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-31lib: move at_close call in vty_stdio to endDavid Lamparter
Since the at_close call for the stdio vty might exit() the process, move it to the end of the function, after freeing all memory. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31lib: clean up tab-completion memory countingDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-26lib: Don't change uid/gid if we are already the correct uid/gidMartin Winter
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2017-01-22bgpd: add vrf-policy config using existing vnc codeLou Berger
add add/clear vrf prefix + Modified for FRR master parser Signed-off-by: Lou Berger <lberger@labn.net>
2017-01-18lib: additional patch for 496e83aQuentin Young
Fixes a couple off-by-ones introduced in previous commit. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> [cherry-picked from master d1e4a518e6f55ccf80c67b58d16eeb1cbf5923e3] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-18lib: additional patch for 496e83aQuentin Young
Fixes a couple off-by-ones introduced in previous commit. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-01-13Merge branch 'master' into cleanupDonald Sharp
2017-01-13lib: limit size of vty buffer to 4096 bytesQuentin Young
This removes the automatic resizing of the vty input buffer and places a hard size cap of 4096 bytes. It also fixes a potentially unsafe strcpy. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> [cherry-picked from master 2af38873d89e20bd039255418366c1601aa99e64]
2017-01-13frr: Remove HAVE_IPV6 from code baseDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-10lib: limit size of vty buffer to 4096 bytesQuentin Young
This removes the automatic resizing of the vty input buffer and places a hard size cap of 4096 bytes. It also fixes a potentially unsafe strcpy. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-01-06Merge remote-tracking branch 'origin/stable/2.0'Donald Sharp
2017-01-03watchfrr: Rename watchquagga -> watchfrrDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-01*: make DEFUN installations file-localDavid Lamparter
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-11-28lib: temporary-catch a SEGV in command completionDavid Lamparter
Getting FULL_MATCH with matched[0] == NULL in tests/testcli. Catch and print error for now. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28Merge branch 'vtysh-grammar'David Lamparter
Conflicts: isisd/isisd.c lib/Makefile.am lib/thread.c Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15lib: replace strlcpy & strlcat with glibc versionsDavid Lamparter
It seems these two were at some point copied in from rsync; replace with more recent versions that will hopefully become available in glibc as well. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-12Merge branch 'cmaster-next' into vtysh-grammarQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: lib/command.c lib/vty.c
2016-11-09watchquagga: add "write integrated"David Lamparter
This new command - available for internal use by vtysh and explicit usage by users - calls "vtysh -w" from watchquagga. This ensures vtysh is run with privileges to actually write the integrated-config file. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09lib: add and use set_cloexec()David Lamparter
watchquagga is already leaking an open file descriptor on its pid file on fork+exec() invocations; next up is adding vtysh support with even more fds. Mark things CLOEXEC before going there. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-29lib: Various minor improvements & bugfixes to CLI backendQuentin Young
- 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>