]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
af-alg: Silently skip probing algorithms if AF_ALG is not supported
authorMartin Willi <martin@strongswan.org>
Thu, 19 May 2016 09:13:24 +0000 (11:13 +0200)
committerMartin Willi <martin@strongswan.org>
Thu, 19 May 2016 09:13:24 +0000 (11:13 +0200)
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.

src/libstrongswan/plugins/af_alg/af_alg_plugin.c

index 445667507ab10818dacfda16e0a4cdbb0526bff4..571882cec86754dfc1f61e76aa1419aaf7316fb0 100644 (file)
@@ -22,6 +22,8 @@
 #include "af_alg_prf.h"
 #include "af_alg_crypter.h"
 
+#include <unistd.h>
+
 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);