Skip to content

libreswan get_active_conns() is not looking for Child SA but any SA #374

@The-Mule

Description

@The-Mule

The current version of libreswan check for active connections looks as follows:

    def get_active_conns(self):
        return self.get_conns_from_status(r"#\d+: .*\"(.*)\".*")

It looks for the following in the output of ipsec status:

#1831: "ovn-8cd020-0-out-1":500 ESTABLISHED_CHILD_SA ...                                  
#1831: "ovn-8cd020-0-out-1" esp.c17d497a@10.0.54.91 esp.a1627f5e@10.0.91.148 Traffic: ...
#2308: "ovn-8cd020-0-out-1":500 ESTABLISHED_IKE_SA ...

Any of the aforementioned three lines will mark ovn-8cd020-0-out-1 as active but in reality only the first or second line means that this connection is actice - a Child SA must be established. The following connection will be incorrectly marked as active even though it only contains orphaned IKE SA and no Child SA (ie. there is no IPsec SA in kernel for this connection):

#2308: "ovn-8cd020-0-out-1":500 ESTABLISHED_IKE_SA ...

I suggest to update the check to look for ESTABLISHED_CHILD_SA. Notice that even though there is a difference between libreswan-4 and libreswan-5 output "#\d+: .*\"(.*)\".*ESTABLISHED_CHILD_SA.*" should match correctly using either version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions