hostapd: backport current version from trunk as of r27021
[openwrt-10.03/.git] / package / hostapd / patches / 320-nl80211_multicall_fixes.patch
1 --- a/src/drivers/driver_nl80211.c
2 +++ b/src/drivers/driver_nl80211.c
3 @@ -1890,6 +1890,7 @@ static void * wpa_driver_nl80211_init(vo
4         drv->monitor_ifidx = -1;
5         drv->monitor_sock = -1;
6         drv->ioctl_sock = -1;
7 +       drv->nlmode = NL80211_IFTYPE_STATION;
8  
9         if (wpa_driver_nl80211_init_nl(drv)) {
10                 os_free(drv);
11 @@ -2056,29 +2057,29 @@ wpa_driver_nl80211_finish_drv_init(struc
12         drv->ifindex = if_nametoindex(bss->ifname);
13         drv->first_bss.ifindex = drv->ifindex;
14  
15 -#ifndef HOSTAPD
16 -       if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
17 -               wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
18 -                          "use managed mode");
19 -       }
20 +       if (drv->nlmode == NL80211_IFTYPE_STATION) {
21 +               if (wpa_driver_nl80211_set_mode(bss, IEEE80211_MODE_INFRA) < 0) {
22 +                       wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
23 +                                  "use managed mode");
24 +               }
25  
26 -       if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
27 -               if (rfkill_is_blocked(drv->rfkill)) {
28 -                       wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
29 -                                  "interface '%s' due to rfkill",
30 -                                  bss->ifname);
31 -                       drv->if_disabled = 1;
32 -                       send_rfkill_event = 1;
33 -               } else {
34 -                       wpa_printf(MSG_ERROR, "nl80211: Could not set "
35 -                                  "interface '%s' UP", bss->ifname);
36 -                       return -1;
37 +               if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
38 +                       if (rfkill_is_blocked(drv->rfkill)) {
39 +                               wpa_printf(MSG_DEBUG, "nl80211: Could not yet enable "
40 +                                          "interface '%s' due to rfkill",
41 +                                          bss->ifname);
42 +                               drv->if_disabled = 1;
43 +                               send_rfkill_event = 1;
44 +                       } else {
45 +                               wpa_printf(MSG_ERROR, "nl80211: Could not set "
46 +                                          "interface '%s' UP", bss->ifname);
47 +                               return -1;
48 +                       }
49                 }
50 -       }
51  
52 -       netlink_send_oper_ifla(drv->netlink, drv->ifindex,
53 -                              1, IF_OPER_DORMANT);
54 -#endif /* HOSTAPD */
55 +               netlink_send_oper_ifla(drv->netlink, drv->ifindex,
56 +                                      1, IF_OPER_DORMANT);
57 +       }
58  
59         if (wpa_driver_nl80211_capa(drv))
60                 return -1;
61 @@ -3849,7 +3850,8 @@ static void nl80211_remove_iface(struct 
62  
63  #ifdef HOSTAPD
64         /* stop listening for EAPOL on this interface */
65 -       del_ifidx(drv, ifidx);
66 +       if (drv->nlmode == NL80211_IFTYPE_AP)
67 +               del_ifidx(drv, ifidx);
68  #endif /* HOSTAPD */
69  
70         msg = nlmsg_alloc();
71 @@ -3922,7 +3924,8 @@ static int nl80211_create_iface_once(str
72  
73  #ifdef HOSTAPD
74         /* start listening for EAPOL on this interface */
75 -       add_ifidx(drv, ifidx);
76 +       if (drv->nlmode == NL80211_IFTYPE_AP)
77 +               add_ifidx(drv, ifidx);
78  #endif /* HOSTAPD */
79  
80         if (addr && iftype != NL80211_IFTYPE_MONITOR &&