2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 13:58:14 +00:00

22 Commits

Author SHA1 Message Date
Pengfei Sun
ac7a10721f table: Fix freeing global variable.
In function shash_replace_nocopy, argument to free() is the address
of a global variable (argument passed by function table_print_json__),
which is not memory allocated by malloc().

ovsdb-client -f json monitor Open_vSwitch --timestamp

ASan reports:

 =================================================================
 ==1443083==ERROR: AddressSanitizer: attempting free on address
 which was not malloc()-ed: 0x000000535980 in thread T0
    0 0xfc9eac in __interceptor_free (/usr/lib64/libasan.so.6)
    1 0x4826e4 in json_destroy_object lib/json.c:445
    2 0x4826e4 in json_destroy__ lib/json.c:403
    3 0x4cc4e4 in table_print lib/table.c:633
    4 0x410650 in monitor_print_table ovsdb/ovsdb-client.c:1019
    5 0x410650 in monitor_print ovsdb/ovsdb-client.c:1040
    6 0x4110cc in monitor_print ovsdb/ovsdb-client.c:1030
    7 0x4110cc in do_monitor__ ovsdb/ovsdb-client.c:1503
    8 0x40743c in main ovsdb/ovsdb-client.c:283
    9 0xf50038  (/usr/lib64/libc.so.6+0x2b038)
   10 0xf50110 in __libc_start_main (/usr/lib64/libc.so.6)
   11 0x40906c in _start (/usr/local/bin/ovsdb-client)

Fixes: cb139fa8b3a1 ("table: New function table_format() for formatting a table as a string.")
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Pengfei Sun <sunpengfei16@huawei.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2024-05-17 13:25:25 +02:00
Mark Michelson
d9cf9b2d8b table: Create method for resetting table formatting.
Table formatting has a local static integer that is intended to insert
line breaks between tables. This works exactly as intended, as long as
each call to table_format() is done as a single unit within the run of a
process.

When ovn-nbctl is run in daemon mode, it is a long-running process that
makes multiple calls to table_format() throughout its lifetime. After
the first call, this results in an unexpected newline prepended to table
output on each subsequent ovn-nbctl invocation.

The solution is to introduce a function to reset table formatting. This
way, the first time after resetting table formatting, no newline is
prepended.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-10-08 12:38:03 -07:00
Aaron Conole
c3cc694b93 table: fix html buffer output
Prior to this commit, html output exhibits a doppler effect for
content by continually printing strings passed from
table_print_html_cell.

Fixes: cb139fa8b3a1 ("table: New function table_format() for formatting a table as a string.")
Cc: Ben Pfaff <blp@ovn.org>
Cc: Jakub Sitnicki <jsitnicki@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2018-08-08 11:18:07 -07:00
Aaron Conole
3562353e0e table: append newline when printing tables
With commit cb139fa8b3a1 ("table: New function table_format() for
formatting a table as a string.") a new mechanism for formatting
tables was introduced, and the table_print method was refactored to
use this.

During that refactor, calls to 'puts' were replaced with
'ds_put_cstr', and table print was changed to use 'fputs(...,
stdout)'.  Unfortunately, fputs() does not append a newline to the
string provided, and changes the output strings of, for example,
ovsdb-client dump to print all on one line.  This means
post-processing scripts that are chained after ovsdb-client would
either block indefinitely (if they don't detect EOF), or process the
entire bundle at once (rather than seeing each table on a separate
line).

Fixes: cb139fa8b3a1 ("table: New function table_format() for formatting a table as a string.")
Cc: Ben Pfaff <blp@ovn.org>
Cc: Jakub Sitnicki <jsitnicki@gmail.com>
Reported-by: Terry Wilson <twilson@redhat.com>
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1608508
Signed-off-by: Aaron Conole <aconole@redhat.com>
Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Terry Wilson <twilson@redhat.com>
Tested-by: Terry Wilson <twilson@redhat.com>
2018-08-08 11:17:00 -07:00
Ben Pfaff
cb139fa8b3 table: New function table_format() for formatting a table as a string.
This will be useful for daemonized ovn-nbctl.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jakub Sitnicki <jkbs@redhat.com>
2018-07-10 09:30:58 -07:00
Ben Pfaff
80f66ee041 table: Add --max-column-width option.
This can make it easier to read tables that contain wide data in some
columns.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
2017-12-22 11:50:33 -08:00
Ben Pfaff
e51d0a1d5a table: Avoid trailing white space in tables.
Commands that use the table library, such as ovs-vsctl and  "ovsdb-client
dump", print trailing white space in tabular output, to fill out the entire
width of their tabular columns.  This is annoying whenever we use these
commands in the test infrastructure, since we have to specially mark the
trailing white space in Autotest with a "@&t@" marker at the end of the
line.  This commit gets rid of the trailing white space and the annoying
"@&t@" markers.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
2017-10-06 20:52:24 -07:00
Ben Pfaff
71f21279f6 Eliminate most shadowing for local variable names.
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>
2017-08-02 15:03:35 -07:00
Lance Richardson
bcb58ce069 table: provide table formatting option help at runtime
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>
2017-04-06 08:04:55 -07:00
Terry Wilson
ee89ea7b47 json: Move from lib to include/openvswitch.
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>
2016-07-22 17:09:17 -07:00
Ben Warren
3e8a2ad145 Move lib/dynamic-string.h to include/openvswitch directory
Signed-off-by: Ben Warren <ben@skyportsystems.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2016-03-19 10:02:12 -07:00
Paul Ingram
2b31d8e713 vlog: Report timestamps in millisecond resolution in log messages.
To make debugging easier.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Paul Ingram <pingram@nicira.com>
2013-09-13 09:11:46 -07:00
Ben Pfaff
3e78870d0b Always check return value of strftime().
strftime() returns 0 and leaves the contents of the output buffer
unspecified if the output buffer is not big enough.  Thus, one should
check strftime()'s return value.  Until now, OVS has had a few invocations
of strftime() that did not check the return value.  This commit fixes
those.  I believe that the buffers were always large enough in each case,
but it's better to be safe.

Reported-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-08 10:53:07 -07:00
Ben Pfaff
9b6937eb1f Use gmtime_r() and localtime_r() instead of non-thread-safe versions.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2013-05-02 15:49:36 -07:00
Ben Pfaff
cb22974d77 Replace most uses of assert by ovs_assert.
This is a straight search-and-replace, except that I also removed #include
<assert.h> from each file where there were no assert calls left.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
2013-01-16 16:03:37 -08:00
Ben Pfaff
3123c8fda5 Use UTC consistently instead of local timezone.
Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-07-02 09:12:13 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc.

Feature #10593
Signed-off-by: Raju Subramanian <rsubramanian@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-02 17:08:02 -07:00
Ben Pfaff
8f46c9bb84 ovsdb-client: Add optional timestamps to "monitor" command output.
Suggestion #9347.
Suggested-by: Alan Shieh <ashieh@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-02-02 16:24:51 -08:00
Ben Pfaff
8d56fd267c table: Avoid segmentation fault when printing an empty cell in JSON format.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-01-30 09:11:08 -08:00
Justin Pettit
84ba64b964 table: Free "error" in cell_to_text().
Coverity #10722
2011-02-23 11:08:20 -08:00
Ben Pfaff
c6a4125250 table: Add new "bare" output formatting options.
--format=list corresponds to the output format that "ovs-vsctl list" has
always used.

--bare is easier for scripts to parse.
2011-02-08 16:10:05 -08:00
Ben Pfaff
3a3eb9daef ovsdb-client: Break table formatting into new library.
This makes the table formatting functions available to other programs.
ovs-vsctl will start using it soon on the "list" and "find" commands.
2011-02-08 16:09:45 -08:00