<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openvswitch.git/python, branch branch-2.6</title>
<subtitle>github.com: openvswitch/ovs.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/'/>
<entry>
<title>vlog: Better handle syslog handler exceptions.</title>
<updated>2019-03-14T12:21:34+00:00</updated>
<author>
<name>Ilya Maximets</name>
<email>i.maximets@samsung.com</email>
</author>
<published>2019-02-26T13:00:03+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=7fd301b541a10a17b4114eb81f6e2ca07a86be33'/>
<id>7fd301b541a10a17b4114eb81f6e2ca07a86be33</id>
<content type='text'>
'set_levels_from_string' doesn't check for exceptions that could
happen while opening syslog files or connecting to syslog sockets.

For example, if rsyslog stopped on a system:

  $ test-unixctl.py -vFACILITY:daemon --detach
  Traceback (most recent call last):
    File "../../../../tests/test-unixctl.py", line 90, in &lt;module&gt;
      main()
    File "../../../../tests/test-unixctl.py", line 61, in main
      ovs.vlog.handle_args(args)
    File "python/ovs/vlog.py", line 463, in handle_args
      msg = Vlog.set_levels_from_string(verbose)
    File "python/ovs/vlog.py", line 345, in set_levels_from_string
      Vlog.add_syslog_handler(words[1])
    File "python/ovs/vlog.py", line 321, in add_syslog_handler
      facility=syslog_facility)
    File "/python2.7/logging/handlers.py", line 759, in __init__
      self._connect_unixsocket(address)
    File "/python2.7/logging/handlers.py", line 787, in _connect_unixsocket
      self.socket.connect(address)
    File "/python2.7/socket.py", line 224, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 111] Connection refused

In this case "/dev/log" file exists, so the check inside
'add_syslog_handler' doesn't help.

We need to catch the exceptions in 'set_levels_from_string' same way
as it done in 'init' function.
Also, we don't really need to check for '/dev/log' existence, because
exception will be catched on the upper layer and properly handled by
disabling the corresponding logger.

Fixes: d69d61c7c175 ("vlog: Ability to override the default log facility.")
Signed-off-by: Ilya Maximets &lt;i.maximets@samsung.com&gt;
Signed-off-by: Simon Horman &lt;simon.horman@netronome.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'set_levels_from_string' doesn't check for exceptions that could
happen while opening syslog files or connecting to syslog sockets.

For example, if rsyslog stopped on a system:

  $ test-unixctl.py -vFACILITY:daemon --detach
  Traceback (most recent call last):
    File "../../../../tests/test-unixctl.py", line 90, in &lt;module&gt;
      main()
    File "../../../../tests/test-unixctl.py", line 61, in main
      ovs.vlog.handle_args(args)
    File "python/ovs/vlog.py", line 463, in handle_args
      msg = Vlog.set_levels_from_string(verbose)
    File "python/ovs/vlog.py", line 345, in set_levels_from_string
      Vlog.add_syslog_handler(words[1])
    File "python/ovs/vlog.py", line 321, in add_syslog_handler
      facility=syslog_facility)
    File "/python2.7/logging/handlers.py", line 759, in __init__
      self._connect_unixsocket(address)
    File "/python2.7/logging/handlers.py", line 787, in _connect_unixsocket
      self.socket.connect(address)
    File "/python2.7/socket.py", line 224, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 111] Connection refused

In this case "/dev/log" file exists, so the check inside
'add_syslog_handler' doesn't help.

We need to catch the exceptions in 'set_levels_from_string' same way
as it done in 'init' function.
Also, we don't really need to check for '/dev/log' existence, because
exception will be catched on the upper layer and properly handled by
disabling the corresponding logger.

Fixes: d69d61c7c175 ("vlog: Ability to override the default log facility.")
Signed-off-by: Ilya Maximets &lt;i.maximets@samsung.com&gt;
Signed-off-by: Simon Horman &lt;simon.horman@netronome.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python: Escape backslashes while formatting logs.</title>
<updated>2019-01-15T17:12:52+00:00</updated>
<author>
<name>Ilya Maximets</name>
<email>i.maximets@samsung.com</email>
</author>
<published>2019-01-15T14:03:00+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=de36604ccf1ee23f06361adeb2ebb04de1bfd361'/>
<id>de36604ccf1ee23f06361adeb2ebb04de1bfd361</id>
<content type='text'>
Since python version 3.7 (and some 3.6+ versions) regexp engine
changed to treat the wrong escape sequences as errors. Previously,
if the replace string had something like '\u0000', '\u' was
qualified as a bad escape sequence and treated just as a sequence
of characters '\' and 'u'. But know this triggers an error:

  Traceback (most recent call last):
    File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template
      this = chr(ESCAPES[this][1])
  KeyError: '\\u'

From the documentation [1]:

  Unknown escapes consisting of '\' and an ASCII letter in replacement
  templates for re.sub() were deprecated in Python 3.5, and will now
  cause an error.

[1] https://docs.python.org/3/whatsnew/3.7.html#api-and-feature-removals

We need to escape the backslash by another one to keep regexp engine
from errors. In case of '\\u000', '\\' is a valid escape sequence
and the 'u' is a simple character.

To be 100% safe we need to use 're.escape(replace)', but it escapes
too many characters making the logs hard to read.

This change fixes Python 3 tests on systems with python 3.7.
Should be backward compatible.

Reported-by: Ben Pfaff &lt;blp@ovn.org&gt;
Signed-off-by: Ilya Maximets &lt;i.maximets@samsung.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since python version 3.7 (and some 3.6+ versions) regexp engine
changed to treat the wrong escape sequences as errors. Previously,
if the replace string had something like '\u0000', '\u' was
qualified as a bad escape sequence and treated just as a sequence
of characters '\' and 'u'. But know this triggers an error:

  Traceback (most recent call last):
    File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template
      this = chr(ESCAPES[this][1])
  KeyError: '\\u'

From the documentation [1]:

  Unknown escapes consisting of '\' and an ASCII letter in replacement
  templates for re.sub() were deprecated in Python 3.5, and will now
  cause an error.

[1] https://docs.python.org/3/whatsnew/3.7.html#api-and-feature-removals

We need to escape the backslash by another one to keep regexp engine
from errors. In case of '\\u000', '\\' is a valid escape sequence
and the 'u' is a simple character.

To be 100% safe we need to use 're.escape(replace)', but it escapes
too many characters making the logs hard to read.

This change fixes Python 3 tests on systems with python 3.7.
Should be backward compatible.

Reported-by: Ben Pfaff &lt;blp@ovn.org&gt;
Signed-off-by: Ilya Maximets &lt;i.maximets@samsung.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python: Catch setsockopt exceptions for TCP stream.</title>
<updated>2018-12-20T18:12:15+00:00</updated>
<author>
<name>Ilya Maximets</name>
<email>i.maximets@samsung.com</email>
</author>
<published>2018-12-20T17:35:57+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=1c0ce6092c3e3248cdde68a705cc9c4230ca6ba4'/>
<id>1c0ce6092c3e3248cdde68a705cc9c4230ca6ba4</id>
<content type='text'>
'sock.setsockopt' could throw exceptions. For example, if non-blocking
connection failed before the call:

  Traceback (most recent call last):
    File "../.././test-ovsdb.py", line 896, in &lt;module&gt;
      main(sys.argv)
    File "../.././test-ovsdb.py", line 891, in main
      func(*args)
    File "../.././test-ovsdb.py", line 604, in do_idl
      ovs.stream.Stream.open(r))
    File "/root/git_/ovs/python/ovs/stream.py", line 190, in open
      error, sock = cls._open(suffix, dscp)
    File "/root/git_/ovs/python/ovs/stream.py", line 744, in _open
      sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
    File "/usr/local/lib/python2.7/socket.py", line 228, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 54] Connection reset by peer

This fixes tests on FreeBSD.

Signed-off-by: Ilya Maximets &lt;i.maximets@samsung.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'sock.setsockopt' could throw exceptions. For example, if non-blocking
connection failed before the call:

  Traceback (most recent call last):
    File "../.././test-ovsdb.py", line 896, in &lt;module&gt;
      main(sys.argv)
    File "../.././test-ovsdb.py", line 891, in main
      func(*args)
    File "../.././test-ovsdb.py", line 604, in do_idl
      ovs.stream.Stream.open(r))
    File "/root/git_/ovs/python/ovs/stream.py", line 190, in open
      error, sock = cls._open(suffix, dscp)
    File "/root/git_/ovs/python/ovs/stream.py", line 744, in _open
      sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
    File "/usr/local/lib/python2.7/socket.py", line 228, in meth
      return getattr(self._sock,name)(*args)
  socket.error: [Errno 54] Connection reset by peer

This fixes tests on FreeBSD.

Signed-off-by: Ilya Maximets &lt;i.maximets@samsung.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python-c-ext: Fix memory leak in Parser_finish</title>
<updated>2018-10-31T17:35:45+00:00</updated>
<author>
<name>Eric Lapointe</name>
<email>elapointe@corsa.com</email>
</author>
<published>2018-10-31T16:11:42+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=ff7067e076bc0219aba7ab180e8442644d0c1054'/>
<id>ff7067e076bc0219aba7ab180e8442644d0c1054</id>
<content type='text'>
The memory returned by json_parser_finish needs to be freed by the caller.

Signed-off-by: Eric Lapointe &lt;elapointe@corsa.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The memory returned by json_parser_finish needs to be freed by the caller.

Signed-off-by: Eric Lapointe &lt;elapointe@corsa.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Python: Make Row's __getattr__ less error prone</title>
<updated>2018-10-06T00:43:34+00:00</updated>
<author>
<name>Lucas Alvares Gomes</name>
<email>lucasagomes@gmail.com</email>
</author>
<published>2018-10-05T15:31:07+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=09082d253ee1b672a38736a44d697e94f7043876'/>
<id>09082d253ee1b672a38736a44d697e94f7043876</id>
<content type='text'>
Calling getattr() on a Row object after invoking delkey() with a value
that does not exist in the object will cause getattr() to fail with a
KeyError error. For example:

Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovsdbapp/backend/ovs_idl/connection.py",
line 122, in run
Oct 05 14:59:28 neutron-server[28435]:
txn.results.put(txn.do_commit())
Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovsdbapp/backend/ovs_idl/transaction.py",
line 86, in do_commit
Oct 05 14:59:28 neutron-server[28435]:     command.run_idl(txn)
Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovsdbapp/backend/ovs_idl/command.py",
line 299, in run_idl
Oct 05 14:59:28 neutron-server[28435]:     if
isinstance(getattr(record, self.column), dict):
Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovs/db/idl.py", line 843, in
__getattr__
Oct 05 14:59:28 neutron-server[28435]:     del dmap[key]
Oct 05 14:59:28 neutron-server[28435]: KeyError: 'bogusvalue'

This patch is replacing the "del dmap[key]" instruction with a
"dmap.pop(key, None)" instruction instead because a pop() (with a
default value) will not raise an exception in case the key does not
exist in the object in the first place, it will just ignore it.

Signed-off-by: Lucas Alvares Gomes &lt;lucasagomes@gmail.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Calling getattr() on a Row object after invoking delkey() with a value
that does not exist in the object will cause getattr() to fail with a
KeyError error. For example:

Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovsdbapp/backend/ovs_idl/connection.py",
line 122, in run
Oct 05 14:59:28 neutron-server[28435]:
txn.results.put(txn.do_commit())
Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovsdbapp/backend/ovs_idl/transaction.py",
line 86, in do_commit
Oct 05 14:59:28 neutron-server[28435]:     command.run_idl(txn)
Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovsdbapp/backend/ovs_idl/command.py",
line 299, in run_idl
Oct 05 14:59:28 neutron-server[28435]:     if
isinstance(getattr(record, self.column), dict):
Oct 05 14:59:28 neutron-server[28435]:   File
"/usr/local/lib/python2.7/dist-packages/ovs/db/idl.py", line 843, in
__getattr__
Oct 05 14:59:28 neutron-server[28435]:     del dmap[key]
Oct 05 14:59:28 neutron-server[28435]: KeyError: 'bogusvalue'

This patch is replacing the "del dmap[key]" instruction with a
"dmap.pop(key, None)" instruction instead because a pop() (with a
default value) will not raise an exception in case the key does not
exist in the object in the first place, it will just ignore it.

Signed-off-by: Lucas Alvares Gomes &lt;lucasagomes@gmail.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python: Prevent extra unexpected reply debug logs.</title>
<updated>2017-02-17T20:51:17+00:00</updated>
<author>
<name>Terry Wilson</name>
<email>twilson@redhat.com</email>
</author>
<published>2017-02-17T17:27:46+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=214c6bfce554018fd2d3f6b8f9a93a78d2846729'/>
<id>214c6bfce554018fd2d3f6b8f9a93a78d2846729</id>
<content type='text'>
Since __txn_process_reply always returns None, the existing code
will always hit the final else for replies and log a debug message
about receiving an unexpected reply. In the C version,
ovsdb_idl_txn_process_reply returns true any time the txn is found,
so that behavior is duplicated here.

Signed-off-by: Terry Wilson &lt;twilson@redhat.com&gt;
Signed-off-by: Russell Bryant &lt;russell@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since __txn_process_reply always returns None, the existing code
will always hit the final else for replies and log a debug message
about receiving an unexpected reply. In the C version,
ovsdb_idl_txn_process_reply returns true any time the txn is found,
so that behavior is duplicated here.

Signed-off-by: Terry Wilson &lt;twilson@redhat.com&gt;
Signed-off-by: Russell Bryant &lt;russell@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>python: Add TCP/SSL probes for OVSDB python lib</title>
<updated>2017-01-06T05:02:00+00:00</updated>
<author>
<name>Guoshuai Li</name>
<email>ligs@dtdream.com</email>
</author>
<published>2017-01-06T03:25:36+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=048a2dababb13a825e911388a253cc965cda80f9'/>
<id>048a2dababb13a825e911388a253cc965cda80f9</id>
<content type='text'>
stream_or_pstream_needs_probes always return 0. This causes TCP/SSL
connection not be probed, and no reconnect when the connection
is aborted

Signed-off-by: Guoshuai Li &lt;ligs@dtdream.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
stream_or_pstream_needs_probes always return 0. This causes TCP/SSL
connection not be probed, and no reconnect when the connection
is aborted

Signed-off-by: Guoshuai Li &lt;ligs@dtdream.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Python-IDL: getattr after mutate fix</title>
<updated>2016-10-15T02:03:51+00:00</updated>
<author>
<name>Amitabha Biswas</name>
<email>azbiswas@gmail.com</email>
</author>
<published>2016-10-12T21:36:57+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=e681dc6e9bd226ec5cb2560951d91bebfe472084'/>
<id>e681dc6e9bd226ec5cb2560951d91bebfe472084</id>
<content type='text'>
This commit returns the updated column value when getattr is done
after a mutate operation is performed (but before the commit).

Signed-off-by: Amitabha Biswas &lt;azbiswas@gmail.com&gt;
Reported-by: Richard Theis &lt;rtheis@us.ibm.com&gt;
Reported-at: http://openvswitch.org/pipermail/dev/2016-September/080120.html
Fixes: a59912a0ee8e ("python: Add support for partial map and set updates")
Signed-off-by: Russell Bryant &lt;russell@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit returns the updated column value when getattr is done
after a mutate operation is performed (but before the commit).

Signed-off-by: Amitabha Biswas &lt;azbiswas@gmail.com&gt;
Reported-by: Richard Theis &lt;rtheis@us.ibm.com&gt;
Reported-at: http://openvswitch.org/pipermail/dev/2016-September/080120.html
Fixes: a59912a0ee8e ("python: Add support for partial map and set updates")
Signed-off-by: Russell Bryant &lt;russell@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ovsdb-idlc: Make set and map update operations take const arguments.</title>
<updated>2016-09-01T04:42:34+00:00</updated>
<author>
<name>Ben Pfaff</name>
<email>blp@ovn.org</email>
</author>
<published>2016-08-31T21:25:40+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=485383396edd7664245300cba36c61f199a3c88c'/>
<id>485383396edd7664245300cba36c61f199a3c88c</id>
<content type='text'>
In a call like "ovsrec_bridge_update_ports_delvalue(bridge, port)", there's
no reason for the port argument to be nonconst, because the call doesn't
do anything to the port at all--it only searches the list of ports in the
bridge for that particular port and, if it finds it, removes it.

Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
Acked-by: Russell Bryant &lt;russell@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In a call like "ovsrec_bridge_update_ports_delvalue(bridge, port)", there's
no reason for the port argument to be nonconst, because the call doesn't
do anything to the port at all--it only searches the list of ports in the
bridge for that particular port and, if it finds it, removes it.

Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
Acked-by: Russell Bryant &lt;russell@ovn.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ovsdb: Fix reference to table's row on condition_add|remove_clause</title>
<updated>2016-08-30T20:34:40+00:00</updated>
<author>
<name>Liran Schour</name>
<email>lirans@il.ibm.com</email>
</author>
<published>2016-08-16T06:06:58+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openvswitch.git/commit/?id=cc0e634aa4667a55a65630b166adb4540cbbe86e'/>
<id>cc0e634aa4667a55a65630b166adb4540cbbe86e</id>
<content type='text'>
Use struct uuid * on [add|remove]_clause on columns which are references to
tables. That prevents use-after-free errors.

Signed-off-by: Liran Schour &lt;lirans@il.ibm.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use struct uuid * on [add|remove]_clause on columns which are references to
tables. That prevents use-after-free errors.

Signed-off-by: Liran Schour &lt;lirans@il.ibm.com&gt;
Signed-off-by: Ben Pfaff &lt;blp@ovn.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
