Revert "bridge: Track inter-BSS usage"

This reverts commit 4345fe963e. That
introduced number of memory leaks and since the rest of the VLAN changes
did not yet go in, it is easier to revert this for now and bring back
the changes after fixes if there is sufficient interest for them in the
future.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-03-08 10:54:26 +02:00
parent 48ef12e75f
commit 226e3579f9
2 changed files with 8 additions and 154 deletions

View File

@ -24,7 +24,6 @@ enum wps_event;
union wps_event_data;
struct hostapd_iface;
struct hostapd_dynamic_iface;
struct hapd_interfaces {
int (*reload_config)(struct hostapd_iface *iface);
@ -37,7 +36,6 @@ struct hapd_interfaces {
int (*driver_init)(struct hostapd_iface *iface);
size_t count;
size_t count_dynamic;
int global_ctrl_sock;
char *global_iface_path;
char *global_iface_name;
@ -45,7 +43,6 @@ struct hapd_interfaces {
gid_t ctrl_iface_group;
#endif /* CONFIG_NATIVE_WINDOWS */
struct hostapd_iface **iface;
struct hostapd_dynamic_iface **dynamic_iface;
size_t terminate_on_error;
};
@ -358,16 +355,6 @@ struct hostapd_iface {
void (*scan_cb)(struct hostapd_iface *iface);
};
/**
* struct hostapd_dynamic_iface - hostapd per dynamically allocated
* or added interface data structure
*/
struct hostapd_dynamic_iface {
char parent[IFNAMSIZ + 1];
char iface[IFNAMSIZ + 1];
unsigned int usage;
};
/* hostapd.c */
int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
int (*cb)(struct hostapd_iface *iface,

View File

@ -474,123 +474,6 @@ static int vlan_set_name_type(unsigned int name_type)
#endif /* CONFIG_VLAN_NETLINK */
/**
* Increase the usage counter for given parent/ifname combination.
* If create is set, then this iface is added to the global list.
* Returns
* -1 on error
* 0 if iface is not in list
* 1 if iface is in list (was there or has been added)
*/
static int hapd_get_dynamic_iface(const char *parent, const char *ifname,
int create, struct hostapd_data *hapd)
{
size_t i;
struct hostapd_dynamic_iface *j = NULL, **tmp;
struct hapd_interfaces *hapd_global = hapd->iface->interfaces;
if (!parent)
parent = "";
for (i = 0; i < hapd_global->count_dynamic; i++) {
j = hapd_global->dynamic_iface[i];
if (os_strncmp(j->iface, ifname, sizeof(j->iface)) == 0 &&
os_strncmp(j->parent, parent, sizeof(j->parent)) == 0)
break;
}
if (i < hapd_global->count_dynamic) {
j->usage++;
return 1;
}
/* new entry required */
if (!create)
return 0;
j = os_zalloc(sizeof(*j));
if (!j)
return -1;
os_strlcpy(j->iface, ifname, sizeof(j->iface));
os_strlcpy(j->parent, parent, sizeof(j->parent));
tmp = os_realloc_array(hapd_global->dynamic_iface, i + 1,
sizeof(*hapd_global->dynamic_iface));
if (!tmp) {
wpa_printf(MSG_ERROR, "VLAN: Failed to allocate memory in %s",
__func__);
return -1;
}
hapd_global->count_dynamic++;
hapd_global->dynamic_iface = tmp;
hapd_global->dynamic_iface[i] = j;
return 1;
}
/**
* Decrease the usage counter for given ifname.
* Returns
* -1 on error or if iface was not found
* 0 if iface was found and is still present
* 1 if iface was removed from global list
*/
static int hapd_put_dynamic_iface(const char *parent, const char *ifname,
struct hostapd_data *hapd)
{
size_t i;
struct hostapd_dynamic_iface *j = NULL, **tmp;
struct hapd_interfaces *hapd_glob = hapd->iface->interfaces;
if (!parent)
parent = "";
for (i = 0; i < hapd_glob->count_dynamic; i++) {
j = hapd_glob->dynamic_iface[i];
if (os_strncmp(j->iface, ifname, sizeof(j->iface)) == 0 &&
os_strncmp(j->parent, parent, sizeof(j->parent)) == 0)
break;
}
if (i == hapd_glob->count_dynamic) {
/*
* Interface not in global list. This can happen if alloc in
* _get_ failed.
*/
return -1;
}
if (j->usage > 0) {
j->usage--;
return 0;
}
os_free(j);
for (; i < hapd_glob->count_dynamic - 1; i++)
hapd_glob->dynamic_iface[i] = hapd_glob->dynamic_iface[i + 1];
hapd_glob->dynamic_iface[hapd_glob->count_dynamic - 1] = NULL;
hapd_glob->count_dynamic--;
if (hapd_glob->count_dynamic == 0) {
os_free(hapd_glob->dynamic_iface);
hapd_glob->dynamic_iface = NULL;
return 1;
}
tmp = os_realloc_array(hapd_glob->dynamic_iface,
hapd_glob->count_dynamic,
sizeof(*hapd_glob->dynamic_iface));
if (!tmp) {
wpa_printf(MSG_ERROR, "VLAN: Failed to release memory in %s",
__func__);
return -1;
}
hapd_glob->dynamic_iface = tmp;
return 1;
}
static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
{
char vlan_ifname[IFNAMSIZ];
@ -598,7 +481,6 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
struct hostapd_vlan *vlan = hapd->conf->vlan;
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
int vlan_naming = hapd->conf->ssid.vlan_naming;
int ret;
wpa_printf(MSG_DEBUG, "VLAN: vlan_newlink(%s)", ifname);
@ -618,9 +500,7 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
"brvlan%d", vlan->vlan_id);
}
ret = br_addbr(br_name);
if (hapd_get_dynamic_iface(NULL, br_name, ret == 0,
hapd))
if (!br_addbr(br_name))
vlan->clean |= DVLAN_CLEAN_BR;
ifconfig_up(br_name);
@ -638,24 +518,17 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
"vlan%d", vlan->vlan_id);
ifconfig_up(tagged_interface);
ret = vlan_add(tagged_interface, vlan->vlan_id,
vlan_ifname);
if (hapd_get_dynamic_iface(NULL, vlan_ifname,
ret == 0, hapd))
if (!vlan_add(tagged_interface, vlan->vlan_id,
vlan_ifname))
vlan->clean |= DVLAN_CLEAN_VLAN;
ret = br_addif(br_name, vlan_ifname);
if (hapd_get_dynamic_iface(br_name,
vlan_ifname,
ret == 0, hapd))
if (!br_addif(br_name, vlan_ifname))
vlan->clean |= DVLAN_CLEAN_VLAN_PORT;
ifconfig_up(vlan_ifname);
}
ret = br_addif(br_name, ifname);
if (hapd_get_dynamic_iface(br_name, ifname, ret == 0,
hapd))
if (!br_addif(br_name, ifname))
vlan->clean |= DVLAN_CLEAN_WLAN_PORT;
ifconfig_up(ifname);
@ -694,8 +567,7 @@ static void vlan_dellink(char *ifname, struct hostapd_data *hapd)
"brvlan%d", vlan->vlan_id);
}
if ((vlan->clean & DVLAN_CLEAN_WLAN_PORT) &&
hapd_put_dynamic_iface(br_name, vlan->ifname, hapd))
if (vlan->clean & DVLAN_CLEAN_WLAN_PORT)
br_delif(br_name, vlan->ifname);
if (tagged_interface) {
@ -709,20 +581,15 @@ static void vlan_dellink(char *ifname, struct hostapd_data *hapd)
os_snprintf(vlan_ifname,
sizeof(vlan_ifname),
"vlan%d", vlan->vlan_id);
if ((vlan->clean & DVLAN_CLEAN_VLAN_PORT) &&
hapd_put_dynamic_iface(br_name, vlan_ifname,
hapd))
if (vlan->clean & DVLAN_CLEAN_VLAN_PORT)
br_delif(br_name, vlan_ifname);
ifconfig_down(vlan_ifname);
if ((vlan->clean & DVLAN_CLEAN_VLAN) &&
hapd_put_dynamic_iface(NULL, vlan_ifname,
hapd))
if (vlan->clean & DVLAN_CLEAN_VLAN)
vlan_rem(vlan_ifname);
}
if ((vlan->clean & DVLAN_CLEAN_BR) &&
hapd_put_dynamic_iface(NULL, br_name, hapd) &&
br_getnumports(br_name) == 0) {
ifconfig_down(br_name);
br_delbr(br_name);