]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
macsec_linux: Exit early when missing macsec kernel module
authorMichael Braun <michael-dev@fami-braun.de>
Tue, 22 Aug 2017 15:02:48 +0000 (17:02 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 10 Sep 2017 19:26:36 +0000 (22:26 +0300)
Using driver macsec_linux makes no sense without macsec kernel module
loaded.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
src/drivers/driver_macsec_linux.c

index 0694e60884274a9ef3bac17e11cc16b445d05142..e89b3ba14c67e7523cb00b4b7f12b81004cceacd 100644 (file)
@@ -234,10 +234,44 @@ static void macsec_drv_wpa_deinit(void *priv)
 }
 
 
+static int macsec_check_macsec(void)
+{
+       struct nl_sock *sk;
+       int err = -1;
+
+       sk = nl_socket_alloc();
+       if (!sk) {
+               wpa_printf(MSG_ERROR, DRV_PREFIX "failed to alloc genl socket");
+               return -1;
+       }
+
+       if (genl_connect(sk) < 0) {
+               wpa_printf(MSG_ERROR,
+                          DRV_PREFIX "connection to genl socket failed");
+               goto out_free;
+       }
+
+       if (genl_ctrl_resolve(sk, "macsec") < 0) {
+               wpa_printf(MSG_ERROR,
+                          DRV_PREFIX "genl resolve failed - macsec kernel module not present?");
+               goto out_free;
+       }
+
+       err = 0;
+
+out_free:
+       nl_socket_free(sk);
+       return err;
+}
+
+
 static void * macsec_drv_wpa_init(void *ctx, const char *ifname)
 {
        struct macsec_drv_data *drv;
 
+       if (macsec_check_macsec() < 0)
+               return NULL;
+
        drv = os_zalloc(sizeof(*drv));
        if (!drv)
                return NULL;