Module Name: src
Committed By: christos
Date: Thu Sep 12 19:52:50 UTC 2013
Modified Files:
src/etc/rc.d: ipsec
Log Message:
wait until our local address is available before configuring.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/etc/rc.d/ipsec
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/etc/rc.d/ipsec
diff -u src/etc/rc.d/ipsec:1.12 src/etc/rc.d/ipsec:1.13
--- src/etc/rc.d/ipsec:1.12 Fri Jun 14 12:37:55 2013
+++ src/etc/rc.d/ipsec Thu Sep 12 15:52:50 2013
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: ipsec,v 1.12 2013/06/14 16:37:55 christos Exp $
+# $NetBSD: ipsec,v 1.13 2013/09/12 19:52:50 christos Exp $
#
# PROVIDE: ipsec
@@ -37,14 +37,33 @@ ipsec_getip() {
done
}
+ipsec_load() {
+ if [ -z "$1" ]; then
+ /sbin/setkey -f /etc/ipsec.conf
+ else
+ sed -e "s/@LOCAL_ADDR@/$1/" < /etc/ipsec.conf | \
+ /sbin/setkey -f -
+ fi
+}
+
+ipsec_configure() {
+ while true; do
+ local addr="$(ipsec_getip "$ipsec_flags")"
+ case "$addr" in
+ '') sleep 1;;
+ "0.0.0.0") sleep 1;;
+ *) ipsec_load "$addr"; return;;
+ esac
+ done &
+}
+
ipsec_start()
{
echo "Installing ipsec manual keys/policies."
if [ -n "$ipsec_flags" ]; then
- sed -e "s/@LOCAL_ADDR@/$(ipsec_getip "$ipsec_flags")/" \
- < /etc/ipsec.conf | /sbin/setkey -f -
+ ipsec_configure
else
- /sbin/setkey -f /etc/ipsec.conf
+ ipsec_load
fi
}