Page MenuHomePhabricator

Implement a big IPsec off switch
Closed, ResolvedPublic

Description

When we deploy IPsec in production we'll want to have a big fast off switch. When IPsec breaks and thereby blocks all important communication, we need to turn it off quickly, and should not have to wait for a Puppet change to make its way.

Let's implement something faster. This could for example be a Salt command/module specific to the task.

Event Timeline

mark raised the priority of this task from to Needs Triage.
mark updated the task description. (Show Details)
mark added a project: Interdatacenter-IPsec.
mark subscribed.

[OT] Please tell me the ID of the task about creating the project which is associated to this task (it is only displayed as "Restricted Project" to me) and the reasons why it is so supersecret that its existence wasn't documented.

  • Puppet will ensure that Strongswan's IKEv2 daemon (charon) is running at all times.
  • Connections are configured for auto=add, meaning they will be "added" in the running config but not brought up when the daemon starts.
    • (Similar to doing 'ifconfig eth0 192.168.0.2' without doing 'ifconfig eth0 up')
  • The 'ipsec up' and 'ipsec down' commands require the name of a connection to act on, and do not accept wildcard values.
  • Therefore a big off switch implemented as a salt command needs to know the name of each connection, by parsing ipsec.conf and iterating:
for c in `awk '/^conn [^%]/ {print $2}' /etc/ipsec.conf` ; do ipsec down $c ; done
  • (the [^%] part is to ignore "conn %default")
  • I haven't had much success with quoting and escaping in salt commands; this remains to be tested.

Maybe put the off-switch in a puppet-deployed script in /usr/local/ so it's easy to execute?

are you trying to run this via salt command line or do it via the api?

• Gage set Security to None.

Proposed solution: https://gerrit.wikimedia.org/r/#/c/196498/

This script may be run as a salt command. I haven't explored the Salt API.

To clarify the task description: I do not predict a scenario in which a failure of IPsec would "break and thereby block all important communication" because traffic from bastions (particularly SSH) will be unaffected due to lack of SAs between Varnish nodes and bastions, and unencrypted traffic with all nodes will remain possible unless or until T85823 is completed.

To revise an earlier comment on this task: connections are currently configured with auto=start so that they are established when the daemon is started. This does not interfere with the action of the proposed script.

After the proposed solution is revised and merged, I will update Wikitech to complete this task.

If you run the script via salt and you make the script blocking as I saw in a comment on the changeset, you need to check for job returns from all the clients and give up after some period of time, displaying a list of hosts that did not report back. By nature salt frm the command line is async.

faidon renamed this task from Implement a big off switch to Implement a big IPsec off switch.Mar 18 2015, 2:33 PM

Change 196498 had a related patch set uploaded (by Faidon Liambotis):
IPsec: big off switch

https://gerrit.wikimedia.org/r/196498

Change 196498 merged by Faidon Liambotis:
IPsec: big off switch

https://gerrit.wikimedia.org/r/196498

fgiunchedi subscribed.

Change 202975 had a related patch set uploaded (by Gage):
ipsec-global: fix bug in non-verbose mode, exit if not root

https://gerrit.wikimedia.org/r/202975

Change 202975 merged by Gage:
ipsec-global: fix bug in non-verbose mode, exit if not root

https://gerrit.wikimedia.org/r/202975