summaryrefslogtreecommitdiff
path: root/vtep/vtep-ctl.c
Commit message (Collapse)AuthorAgeFilesLines
* db-ctl-base: Use partial map/set updates for last add/set commands.Ilya Maximets2022-12-061-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, command to add one item into a large set generates the transaction with the full new content of that set plus 'wait' operation for the full old content of that set. So, if we're adding one new load-balancer into a load-balancer group in OVN using ovn-nbctl, transaction will include all the existing load-balancers from that groups twice. IDL supports partial updates for sets and maps. The problem with that is changes are not visible to the IDL user until the transaction is committed. That will cause problems for chained ctl commands. However, we still can optimize the very last command in the list. It makes sense to do, since it's a common case for manual invocations. Updating the 'add' command as well as 'set' for a case where we're actually adding one new element to the map. One downside is that we can't check the set size without examining it and checking for duplicates, so allowing the transaction to be sent and constraints to be checked on the server side in that case. Not touching 'remove' operation for now, since removals may have different type, e.g. if elements from the map are removed by the key. The function will likely need to be fully re-written to accommodate all the corner cases. Acked-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* hmap: use short version of safe loops if possible.Adrian Moreno2022-03-301-3/+3
| | | | | | | | | | | | | | | Using SHORT version of the *_SAFE loops makes the code cleaner and less error prone. So, use the SHORT version and remove the extra variable when possible for hmap and all its derived types. In order to be able to use both long and short versions without changing the name of the macro for all the clients, overload the existing name and select the appropriate version depending on the number of arguments. Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* list: use short version of safe loops if possible.Adrian Moreno2022-03-301-6/+6
| | | | | | | | | | | | | | | Using the SHORT version of the *_SAFE loops makes the code cleaner and less error-prone. So, use the SHORT version and remove the extra variable when possible. In order to be able to use both long and short versions without changing the name of the macro for all the clients, overload the existing name and select the appropriate version depending on the number of arguments. Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* tests: Use environment variable for default timeout.Ilya Maximets2018-08-151-3/+1
| | | | | | | | | | | Introduce new 'OVS_CTL_TIMEOUT' environment variable that, if set, will be used as a default timeout for OVS control utilities. Setting it in 'atlocal.in' will cover all the hangs inside the testsuite, even when utils called in a subshell. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* utilities: Fix and unify parsing of timeout option.Ilya Maximets2018-08-151-5/+3
| | | | | | | | | | | | | | Parsing of the '--timeout' option implemented differently for every single control utility and, which is more important, highly inaccurate. In most cases unsigned result of 'strtoul' stored in signed variable. Parsing failures are not tracked. 'ovs-appctl' even uses just 'atoi' without any checking of the argument or result. This patch unifies the parsing by using 'str_to_uint'. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Propagate errors from the commands parser.Jakub Sitnicki2018-07-231-2/+5
| | | | | | | | Let the caller decide how to handle the error. Prepare for using the parser in ovn-nbctl daemon mode. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Extend ctl_context with an error message.Jakub Sitnicki2018-07-031-0/+9
| | | | | | | | Prepare for the command handlers (pre_cmd_*() cmd_*() functions) to report errors by storing them in the context. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-vsctl, ovn-nbctl, ovn-sbctl, vtep-ctl: Parse options before logging.Ben Pfaff2018-05-251-5/+3
| | | | | | | | | | These utilities logged the command very early, before parsing the options or the command. This meant that logging options (like --log-file or -vsyslog:off) weren't considered for the purpose of logging the command. This fixes the problem. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* ctl-option: add --inactivity-probe= option in set targets commandsGuoshuai Li2018-03-311-4/+13
| | | | | | | | | | | | This patch can set inactivity probe for connection by command: ovs-vsctl --inactivity-probe=30000 set-manager tcp:<CONTROLLER IP>:6640 ovs-vsctl --inactivity-probe=30000 set-controller tcp:<CONTROLLER IP>:6641 vtep-ctl --inactivity-probe=30000 set-manager tcp:<CONTROLLER IP>:6640 ovn-nbctl --inactivity-probe=30000 set-connection ptcp:6641:0.0.0.0 ovn-sbctl --inactivity-probe=30000 set-connection ptcp:6642:0.0.0.0 Signed-off-by: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Refer to database manpages in *ctl manpagesMark Michelson2018-02-261-2/+5
| | | | | | | | | | | | | | The ovn-nbctl, ovn-sbctl, and ovs-vsctl manpages are inconsistent in their "Database Commands" section when it comes to referring to what database tables exist. This commit amends this by making each *ctl manpage reference the corresponding database manpage instead. To aid in having a more handy list, the --help text of ovn-nbctl, ovn-sbctl, and ovs-vsctl have been modified to list the available tables. This is also referenced in the manpages for those applications. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovs-vsctl, vtep-ctl: Free 'args' string on exit.Ben Pfaff2018-01-261-4/+8
| | | | | | | | | This avoids a memory leak warning from valgrind. ovn-sbctl and ovn-nbctl already followed this pattern. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: William Tu <u9012063@gmail.com>
* lib: Move lib/poll-loop.h to include/openvswitchXiao Liang2017-11-031-1/+1
| | | | | | | | Poll-loop is the core to implement main loop. It should be available in libopenvswitch. Signed-off-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Eliminate most shadowing for local variable names.Ben Pfaff2017-08-021-1/+0
| | | | | | | | | | | | | | Shadowing is when a variable with a given name in an inner scope hides a different variable with the same name in a surrounding scope. This is generally undesirable because it can confuse programmers. This commit eliminates most of it. Found with -Wshadow=local in GCC 7. The repo is not really ready to enable this option by default because of a few cases that are harder to fix, and harmless, such as nested use of CMAP_FOR_EACH. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* Free port bindings when deleting cached ports.Mark Michelson2017-07-141-0/+1
| | | | | | | | | | | | Running test "ovn-controller-vtep binding 2" with address sanitizer enabled resulted in a failure due to a memory leak. The cached switch port's bindings were not being freed when the port was freed. The fix is to destroy the bindings hash table when the switch port is freed. Signed-off-by: Mark Michelson <mmichels@redhat.com> Reported-by: Lance Richardson <lrichard@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Add support for identifying a row based on a value in a map.Ben Pfaff2017-05-031-5/+6
| | | | | | | | | This will be used in an upcoming commit to allow Datapath_Binding records in the OVN southbound database to be identified based on external-ids:name and other map values. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* db-ctl-base: Drop redundant 'table' field from struct ctl_row_id.Ben Pfaff2017-05-031-7/+5
| | | | | | | | | | The 'table' field is redundant because the required 'column' field implies the table that the column is a part of. This simplifies the users and makes it harder to get these things wrong. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* table: provide table formatting option help at runtimeLance Richardson2017-04-061-0/+1
| | | | | | | | | Show table formatting options with help output from ovn-nbctl, obn-sbctl, ovs-vsctl, and vtep-ctl commands. Include "--data" option in ovsdb-client help output. Signed-off-by: Lance Richardson <lrichard@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* db-ctl-base: Always support all tables in schema.Ben Pfaff2017-01-131-64/+14
| | | | | | | | | | | | | | | | | When one adds a new table to a database schema, it's easy to forget to add the table to the list of tables in the *ctl.c program. When this happens, the database commands for that program don't work on that table at all, even for commands like "list" and "create" that don't need any special help. This patch fixes that problem, by making sure that db-ctl-base always has the complete list of tables. Previously, each ctl_table_class pointed directly to the corresponding ovsdb_idl_table_class. With this patch, there are instead two parallel arrays, one of ovsdb_idl_table_classes and the other of ctl_table_classes. This change accounts for the bulk of the change to the db-ctl-base code. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Lance Richardson <lrichard@redhat.com>
* table: correct documented default format in man pagesLance Richardson2016-12-221-1/+0
| | | | | | | | | | | | | | | | | There are currently five users of the table formatting library, all of which default to "list" except for ovsdb-client which defaults to "table". The library current default is "table", and the table.man man page fragment only considers ovs-vsctl to use something other than "table" as a default.As a result, the man pages for ovn-sbctl and vtep-ctl are currently incorrect (these options aren't documented in the ovn-nbctl man page, which will need to be addressed in a future patch). Fix by making the library default format "list" and handling ovsdb-client as the exception. Signed-off-by: Lance Richardson <lrichard@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Add support for specifying SSL connection parameters to ovsdbEthan Rahn2016-11-101-1/+2
| | | | | Signed-off-by: Ethan Rahn <erahn@arista.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idlc: Eliminate <prefix>_init() function from generated code.Ben Pfaff2016-10-191-1/+0
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+1
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* util: New function nullable_xstrdup().Ben Pfaff2016-06-261-1/+1
| | | | | | It's a pretty common pattern so create a function for it. Signed-off-by: Ben Pfaff <blp@ovn.org>
* vtep: Add source node replication support.Darrell Ball2016-05-091-0/+41
| | | | | | | | | | | | | | | This patch updates the vtep schema, vtep-ctl commands and vtep simulator to support source node replication in addition to service node replication per logical switch. The default replication mode is service node as that was the only mode previously supported. Source node replication mode is optionally configurable and clearing the replication mode implicitly sets the replication mode back to a default of service node. Signed-off-by: Darrell Ball <dlu998@gmail.com> Acked-by: Bruce Davie <bdavie@vmware.com> Acked-by: Anupam Chanda <achanda@vmware.com> Signed-off-by: Justin Pettit <jpettit@ovn.org>
* list: Rename all functions in list.h with ovs_ prefix.Ben Warren2016-03-301-9/+9
| | | | | | | This attempts to prevent namespace collisions with other list libraries Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* vlog: Make the most common module reference more direct.Ben Pfaff2016-02-101-2/+2
| | | | | | | | | | | | | Most vlog calls are for the log module owned by the translation unit being compiled, but this module was referenced indirectly through a pointer variable. That seems silly, so this commit changes the code so that the local vlog module is referred to directly, as &this_module. We could get rid of the global variables for vlog modules entirely, but I like getting linker errors when there's a duplicate module name. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* vlog: Stop using explicit references to external log modules.Ben Pfaff2016-02-031-2/+1
| | | | | | | | | | | | | | | | | It's always risky to write "extern" declarations outside a header file, since there's no way to ensure the type of what's being referenced is correct. In these cases, we can easily avoid the extern reference, so do so. There is a little tradeoff here, in that referring to the log modules through strings means that we catch an incorrect module name at runtime instead of at link time, but I think that the risk here is minimal because the mistake will be found by every test in "make check" that runs any of the utilities, since they make these calls as one of their first tasks during initialization. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* vtep: add logical router related commands.Wenyu Zhang2016-02-031-0/+155
| | | | | | | | | | | Add logical router related vtep-ctl commands: vtep-ctl add-lr LR vtep-ctl del-lr LR vtep-ctl list-lr vtep-ctl lr-exists LR Signed-off-by: Wenyu Zhang <wenyuz@vmware.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* vtep: make vtep-ctl support L3 tables.Wenyu Zhang2016-01-281-0/+12
| | | | | | | | | | | Add supporting for tables necessary for L3 usage: Logical_Router Arp_Sources_Local Arp_Sources_Remote Signed-off-by: Wenyu Zhang <wenyuz@vmware.com> Acked-by: Shuangmin Zhang <tsingzsm@gmail.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* vtep-ctl: Exit if database connection fails.Daniele Di Proietto2015-10-221-0/+5
| | | | | | | | | | | | | | Before this commit vtep-ctl hung forever if it didn't manage to reach the database. This caused the testcase "ovn -- 3 HVs, 1 VIFs/HV, 1 GW, 1 LS" to hang occasionally, because ovsdb-server could be killed before ovs-vtep called vtep-ctl. This mimics the behaviour of ovs-vsctl, ovn-nbctl and ovn-sbctl. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* Fix typos in comments.Ben Pfaff2015-09-141-1/+1
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <ee07b291@gmail.com>
* db-ctl-base: Allow print rows that weak reference to table inAlex Wang2015-08-131-6/+11
| | | | | | | | | | | | | | | | | | | | 'cmd_show_table'. Sometimes, it is desirable to print the table with weak reference to the table specified in 'struct cmd_show_table'. For example the Port_Binding table rows in OVN_Southbound database that refer to the same Chassis table row can be printed under the same chassis entry in 'ovn-sbctl show' output. To achieve it, this commit adds a new struct in 'struct cmd_show_table' that allows users to print a table with weak reference to 'table' specified in 'struct cmd_show_table'. The 'ovn-sbctl' which now prints the Port_Binding entries with Chassis table, is the first user of this new feature. Requested-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* db-ctl-base: make cmd_show_table privateAndy Zhou2015-07-231-2/+2
| | | | | | | | Instead of requiring user to declare a global variable, pass the value via ctl_init(). Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: remove the recurse member from struct cmd_show_tableAndy Zhou2015-07-231-11/+11
| | | | | | | | | | | | The 'recurse' is used during run time to suppress duplicated prints. It is not essential to describe how show command should work. This patch remove the 'recurse' member. Duplicated prints is now suppressed by maintaining an 'sset' of tables that have been printed at run time. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: make use of user supplied exit functionAndy Zhou2015-07-171-4/+28
| | | | | | | | | The user is required to expose the_idl and the_idl_txn global variables, so that memory can be cleaned up on fatal errors. This patch changes to ask user to supply an exit function via ctl_init(). What user needs to do on exit can now remain private. Signed-off-by: Andy Zhou <azhou@nicira.com>
* vtep-ctl: Remove extraneous NULL pointer check.Joe Stringer2015-07-171-7/+2
| | | | | | | | | | OVS will exit if the allocations in this function fail, so this check is pointless. Found by MIT STACK undefined behaviour checker. Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* db-ctl-base: do not require client to expose the "tables" variableAndy Zhou2015-07-131-2/+2
| | | | | | | Instead, client now pass it via the modified ctl_init() API. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* db-ctl-base: Improve show command.Alex Wang2015-06-231-3/+10
| | | | | | | | | | This commit adds improvement to 'show' command logic and allows it to print key->table_ref maps. The direct effect can be observed from the tests/vtep-ctl.at change. The improvement will also be used in the ovn-sbctl implementation. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* vtep-ctl: Use db-ctl-base.Alex Wang2015-06-231-1977/+372
| | | | | | | | This commit makes vtep-ctl use db-ctl-base to avoid duplicate code. As an addition, a 'show' command is added to vtep-ctl. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* vtep-ctl: Fix a bug.Alex Wang2015-06-111-1/+1
| | | | | | | | | | | add_port_to_cache() uses 'cache_name' as the shash node name for shash_add(). So, the del_cached_port() must also pass 'cache_name' as argument for shash_find_and_delete(). This bug does not cause any issue currently but should be fixed. Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* command-line: add ovs_cmdl_ prefixRussell Bryant2015-03-161-1/+1
| | | | | | | | | | | | | | | | | The coding style guidelines include the following: - Pick a unique name prefix (ending with an underscore) for each module, and apply that prefix to all of that module's externally visible names. Names of macro parameters, struct and union members, and parameters in function prototypes are not considered externally visible for this purpose. This patch adds the new prefix to the externally visible names. This makes it a bit more obvious what code is coming from common command line handling code. Signed-off-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* vtep: Move vtep IDL files into new "libvtep.la".Justin Pettit2015-03-051-1/+1
| | | | | | | | There's no reason to build it in "lib" and include it in "libopenvswitch.la". This commit moves it to "vtep" and includes it in a new "libvtep.la". Signed-off-by: Justin Pettit <jpettit@nicira.com>
* vlog: Rename the currently used term 'facility' as 'destination'.Gurucharan Shetty2015-01-081-1/+1
| | | | | | | | | | | | In OVS, we currently use the term 'facility' to mean the place where we log (syslog, console or file). In Linux's syslog() and rfc5424, the term 'facility' is used to specify what type of program is logging the message (e.g: LOG_DAEMON). This causes confusion while reading vlog's code. This commit changes the term 'facility' to 'destination'. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move vconn.h to <openvswitch/vconn.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | Also moves definitions for struct vconn and pvconn to the public header. The provider interface is kept private. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* list: Rename struct list to struct ovs_listThomas Graf2014-12-151-5/+5
| | | | | | | struct list is a common name and can't be used in public headers. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move compiler.h to <openvswitch/compiler.h>Thomas Graf2014-12-151-4/+4
| | | | | | | | | | The following macros are renamed to avoid conflicts with other headers: * WARN_UNUSED_RESULT to OVS_WARN_UNUSED_RESULT * PRINTF_FORMAT to OVS_PRINTF_FORMAT * NO_RETURN to OVS_NO_RETURN Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* vtep-ctl: Add Tunnel table to vtep_ctl_table_class.Gurucharan Shetty2014-09-251-0/+18
| | | | | | | | | | | | | This is needed to create, get, set records in the Tunnel table. (We need to add the Tunnel table's 'local' and 'remote' columns that point to the Physical_Locator record to cache because vtep-ctl commands like 'add-ucast-local' will try to add an entry in Physical_Locator table based on the contents of the cache.) Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ariel Tubaltsev <atubaltsev@vmware.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* compiler: Define NO_RETURN for MSVC.Gurucharan Shetty2014-09-151-3/+3
| | | | | | | | | | | | | To prevent warnings such as "Not all control paths return a value", we should define NO_RETURN for MSVC. Currently for gcc, we add NO_RETURN at the end of function declaration. But for MSVC, "__declspec(noreturn)" is needed at the beginning of function declaration. So this commit moves NO_RETURN to the beginning of the function declaration as it works with gcc and clang too. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>