From: Martin Willi Date: Tue, 16 Dec 2014 15:58:17 +0000 (+0100) Subject: charon-xpc: Add a work-around to trigger IP address add events after boot X-Git-Tag: 5.2.2~14^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c6188a0c2cd25604fdcc9b1843298286fb34dfc;p=thirdparty%2Fstrongswan.git charon-xpc: Add a work-around to trigger IP address add events after boot --- diff --git a/src/frontends/osx/charon-xpc/charon-xpc.c b/src/frontends/osx/charon-xpc/charon-xpc.c index 2235be12d4..057bfbd88b 100644 --- a/src/frontends/osx/charon-xpc/charon-xpc.c +++ b/src/frontends/osx/charon-xpc/charon-xpc.c @@ -122,6 +122,29 @@ static void segv_handler(int signal) abort(); } +/** + * PF_ROUTE for some reason does not send an event for the first address + * installed after a fresh boot. Fix this by installing a fake tun address + * just to remove it afterwards. + */ +static void fixup_pf_route() +{ + tun_device_t *tun; + host_t *host; + + tun = tun_device_create(NULL); + if (tun) + { + if (tun->up(tun)) + { + host = host_create_from_string("127.0.0.99", 0); + tun->set_address(tun, host, 32); + host->destroy(host); + } + tun->destroy(tun); + } +} + /** * Main function, starts the daemon. */ @@ -204,5 +227,6 @@ int main(int argc, char *argv[]) atexit(dispatcher_cleanup); charon->start(charon); + fixup_pf_route(); return run(); }