From: Martin Willi Date: Thu, 19 May 2016 09:13:24 +0000 (+0200) Subject: af-alg: Silently skip probing algorithms if AF_ALG is not supported X-Git-Tag: 5.5.0dr1~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=294ac097d65f34251754ead4ed720b7b3a9ad4c3;p=thirdparty%2Fstrongswan.git af-alg: Silently skip probing algorithms if AF_ALG is not supported If the af-alg plugin is enabled, but kernel support is missing, we get an error line during startup for each probed algorithm. This is way too verbose, so just skip probing if AF_ALG is unsupported. --- diff --git a/src/libstrongswan/plugins/af_alg/af_alg_plugin.c b/src/libstrongswan/plugins/af_alg/af_alg_plugin.c index 445667507a..571882cec8 100644 --- a/src/libstrongswan/plugins/af_alg/af_alg_plugin.c +++ b/src/libstrongswan/plugins/af_alg/af_alg_plugin.c @@ -22,6 +22,8 @@ #include "af_alg_prf.h" #include "af_alg_crypter.h" +#include + typedef struct private_af_alg_plugin_t private_af_alg_plugin_t; /** @@ -41,6 +43,19 @@ METHOD(plugin_t, get_name, char*, return "af-alg"; } +static bool af_alg_supported() +{ + int fd; + + fd = socket(AF_ALG, SOCK_SEQPACKET, 0); + if (fd != -1) + { + close(fd); + return true; + } + return false; +} + METHOD(plugin_t, get_features, int, private_af_alg_plugin_t *this, plugin_feature_t *features[]) { @@ -50,6 +65,10 @@ METHOD(plugin_t, get_features, int, if (!count) { /* initialize only once */ + if (!af_alg_supported()) + { + return 0; + } f[count++] = PLUGIN_REGISTER(HASHER, af_alg_hasher_create); af_alg_hasher_probe(f, &count); f[count++] = PLUGIN_REGISTER(SIGNER, af_alg_signer_create);