]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use a shared function for setting port authorization changes
authorJouni Malinen <quic_jouni@quicinc.com>
Mon, 12 Jun 2023 12:42:52 +0000 (15:42 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 12 Jun 2023 12:42:52 +0000 (15:42 +0300)
Get rid of the duplicated code for setting IEEE 802.1X port
authorization for MLD and non-MLD cases.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/ieee802_1x.c

index cf8ae81a98369b3022c9a513c47349c7972270ce..bc1f47d2b86d072d340d1d4ec570504a48320fb3 100644 (file)
@@ -104,10 +104,9 @@ static void ieee802_1x_send(struct hostapd_data *hapd, struct sta_info *sta,
 }
 
 
-#ifdef CONFIG_IEEE80211BE
-static void ieee802_1x_ml_set_link_sta_auth(struct hostapd_data *hapd,
-                                           struct sta_info *sta,
-                                           bool authorized)
+static void ieee802_1x_set_authorized(struct hostapd_data *hapd,
+                                     struct sta_info *sta,
+                                     bool authorized, bool mld)
 {
        int res;
 
@@ -120,7 +119,11 @@ static void ieee802_1x_ml_set_link_sta_auth(struct hostapd_data *hapd,
                       HOSTAPD_LEVEL_DEBUG, "%sauthorizing port",
                       authorized ? "" : "un");
 
-       if (res) {
+       if (!mld && res && errno != ENOENT) {
+               wpa_printf(MSG_DEBUG, "Could not set station " MACSTR
+                          " flags for kernel driver (errno=%d).",
+                          MAC2STR(sta->addr), errno);
+       } else if (mld && res) {
                wpa_printf(MSG_DEBUG,
                           "MLD: Could not set station " MACSTR " flags",
                           MAC2STR(sta->addr));
@@ -131,7 +134,6 @@ static void ieee802_1x_ml_set_link_sta_auth(struct hostapd_data *hapd,
                accounting_sta_start(hapd, sta);
        }
 }
-#endif /* CONFIG_IEEE80211BE */
 
 
 static void ieee802_1x_ml_set_sta_authorized(struct hostapd_data *hapd,
@@ -174,9 +176,8 @@ static void ieee802_1x_ml_set_sta_authorized(struct hostapd_data *hapd,
                                    tmp_sta->aid != sta->aid)
                                        continue;
 
-                               ieee802_1x_ml_set_link_sta_auth(tmp_hapd,
-                                                               tmp_sta,
-                                                               authorized);
+                               ieee802_1x_set_authorized(tmp_hapd, tmp_sta,
+                                                         authorized, true);
                                break;
                        }
                }
@@ -189,34 +190,7 @@ static void ieee802_1x_ml_set_sta_authorized(struct hostapd_data *hapd,
 void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
                                   struct sta_info *sta, int authorized)
 {
-       int res;
-
-       if (sta->flags & WLAN_STA_PREAUTH)
-               return;
-
-       if (authorized) {
-               ap_sta_set_authorized(hapd, sta, 1);
-               res = hostapd_set_authorized(hapd, sta, 1);
-               hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
-                              HOSTAPD_LEVEL_DEBUG, "authorizing port");
-       } else {
-               ap_sta_set_authorized(hapd, sta, 0);
-               res = hostapd_set_authorized(hapd, sta, 0);
-               hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
-                              HOSTAPD_LEVEL_DEBUG, "unauthorizing port");
-       }
-
-       if (res && errno != ENOENT) {
-               wpa_printf(MSG_DEBUG, "Could not set station " MACSTR
-                          " flags for kernel driver (errno=%d).",
-                          MAC2STR(sta->addr), errno);
-       }
-
-       if (authorized) {
-               os_get_reltime(&sta->connected_time);
-               accounting_sta_start(hapd, sta);
-       }
-
+       ieee802_1x_set_authorized(hapd, sta, authorized, false);
        ieee802_1x_ml_set_sta_authorized(hapd, sta, !!authorized);
 }