Skip to content

Commit

Permalink
ovs-monitor-ipsec: Fix active connection regex.
Browse files Browse the repository at this point in the history
Connections are added to IPsec using a connection name
that is determined from the OVS port name and the tunnel
type.

GRE connections take the form:
  <iface>-<ver>
Other connections take the form:
  <iface>-in-<ver>
  <iface>-out-<ver>

The regex '|' operator parses strings left to right looking
for the first match that it can find. '.*' is also greedy. This
causes incorrect interface names to be parsed from active
connections as other tunnel types are parsed as type
GRE. This gives unexpected "is outdated" warnings and the
connection is torn down.

For example,

'ovn-424242-in-1' will produce an incorrect interface name of
'ovn-424242-in' instead of 'ovn-424242'.

There are a number of ways this could be resolved including
a cleverer regular expression, or re.findall(). However, this
approach was taken as it simplifies the code easing maintainability.

Fixes: 22c5eaf ("ipsec: reintroduce IPsec support for tunneling")
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1908789
Signed-off-by: Mark Gray <[email protected]>
Acked-by: Eelco Chaudron <[email protected]>
Acked-by: Flavio Leitner <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
markdgray authored and igsilya committed Jan 5, 2021
1 parent 6d2a5be commit 2ee0f44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ipsec/ovs-monitor-ipsec.in
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,10 @@ conn prevent_unencrypted_vxlan
continue

conn = m.group(1)
m = re.match(r"(.*)(-in-\d+|-out-\d+|-\d+)", conn)
m = re.match(r"(.*)(-in-\d+|-out-\d+)", conn)
if not m:
# GRE connections have format <iface>-<ver>
m = re.match(r"(.*)(-\d+)", conn)
if not m:
continue

Expand Down

0 comments on commit 2ee0f44

Please sign in to comment.