From a461e9b09ee4cd8340315539bde3892c97ac14da Mon Sep 17 00:00:00 2001 From: Augusto Bott Date: Wed, 7 Dec 2011 13:06:31 +0700 Subject: [PATCH] Fix issues with 'disappearing' WL ifaces (when not assigned as part of any LAN bridges) * related to assignments of VLANs, LAN bridges and WL interfaces on Advanced/VLAN (advanced-vlan.asp) * any existing WL interfaces not assigned as part of any LAN bridges would simply 'disappear' from any/all web admin/UI pages (after saving settings on advanced-vlan.asp and rebooting) * try to ensure any/all previously configured WL interfaces are still properly detected, even when not a member/part of a LAN bridge (therefore, available to be selected and/or re-assigned via the web UI) --- release/src/router/httpd/wl.c | 24 +++++++++++++++++- release/src/router/shared/misc.c | 13 ++++++++-- release/src/router/www/status-data.jsx | 15 +++++++++++- release/src/router/www/status-overview.asp | 39 +++++++++++++++--------------- 4 files changed, 67 insertions(+), 24 deletions(-) diff --git a/release/src/router/httpd/wl.c b/release/src/router/httpd/wl.c index 3e7969b3b2..a25ac3e125 100644 --- a/release/src/router/httpd/wl.c +++ b/release/src/router/httpd/wl.c @@ -9,6 +9,7 @@ #include #include +#include #ifndef WL_BSS_INFO_VERSION #error WL_BSS_INFO_VERSION @@ -638,9 +639,30 @@ static int print_wif(int idx, int unit, int subunit, void *param) else snprintf(unit_str, sizeof(unit_str), "%d", unit); + int up = 0; + int sfd; + struct ifreq ifr; + + if ((sfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) { + _dprintf("[%s %d]: error opening socket %m\n", __FUNCTION__, __LINE__); + } + + up = 0; + if (sfd >= 0) { + strcpy(ifr.ifr_name, nvram_safe_get(wl_nvname("ifname", unit, subunit))); + if (ioctl(sfd, SIOCGIFFLAGS, &ifr) == 0) + up = (ifr.ifr_flags & IFF_UP); + } + + + + + + + // [ifname, unitstr, unit, subunit, ssid, hwaddr] ssidj = js_string(nvram_safe_get(wl_nvname("ssid", unit, subunit))); - web_printf("%c['%s','%s',%d,%d,'%s','%s']", (idx == 0) ? ' ' : ',', + web_printf("%c['%s','%s',%d,%d,'%s','%s',%d]", (idx == 0) ? ' ' : ',', nvram_safe_get(wl_nvname("ifname", unit, subunit)), unit_str, unit, subunit, ssidj, // assume the slave inteface MAC address is the same as the primary interface diff --git a/release/src/router/shared/misc.c b/release/src/router/shared/misc.c index 6420bfa7db..8147f716ac 100644 --- a/release/src/router/shared/misc.c +++ b/release/src/router/shared/misc.c @@ -126,8 +126,17 @@ int foreach_wif(int include_vifs, void *param, int i; int ret = 0; - snprintf(ifnames, sizeof(ifnames), "%s %s %s %s %s", - nvram_safe_get("lan_ifnames"), nvram_safe_get("lan1_ifnames"), nvram_safe_get("lan2_ifnames"), nvram_safe_get("lan3_ifnames"), nvram_safe_get("wan_ifnames")); + snprintf(ifnames, sizeof(ifnames), "%s %s %s %s %s %s %s %s %s %s", + nvram_safe_get("lan_ifnames"), + nvram_safe_get("lan1_ifnames"), + nvram_safe_get("lan2_ifnames"), + nvram_safe_get("lan3_ifnames"), + nvram_safe_get("wan_ifnames"), + nvram_safe_get("wl_ifname"), + nvram_safe_get("wl0_ifname"), + nvram_safe_get("wl0_vifs"), + nvram_safe_get("wl1_ifname"), + nvram_safe_get("wl1_vifs")); remove_dups(ifnames, sizeof(ifnames)); i = 0; diff --git a/release/src/router/www/status-data.jsx b/release/src/router/www/status-data.jsx index 2cdc05d4a6..0f9d5e323d 100644 --- a/release/src/router/www/status-data.jsx +++ b/release/src/router/www/status-data.jsx @@ -7,8 +7,8 @@ No part of this file may be used without permission. */ +//<% nvram("ppp_get_ip,pptp_server_ip,router_name,wan_domain,wan_gateway,wan_gateway_get,wan_get_domain,wan_hostname,wan_hwaddr,wan_ipaddr,wan_netmask,wan_proto,wan_run_mtu,et0macaddr,lan_proto,lan_ipaddr,dhcp_start,dhcp_num,dhcpd_startip,dhcpd_endip,lan_netmask,wl_security_mode,wl_crypto,wl_mode,wl_wds_enable,wl_hwaddr,wl_net_mode,wl_radio,wl_channel,lan_gateway,wl_ssid,t_model_name,t_features,pptp_dhcp,dhcp1_start,dhcp1_num,dhcpd1_startip,dhcpd1_endip,dhcp2_start,dhcp2_num,dhcpd2_startip,dhcpd2_endip,dhcp3_start,dhcp3_num,dhcpd3_startip,dhcpd3_endip,lan1_proto,lan1_ipaddr,lan1_netmask,lan2_proto,lan2_ipaddr,lan2_netmask,lan3_proto,lan3_ipaddr,lan3_netmask,lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname,clkfreq,wan_ipaddr_buf,wl_closed,lan_ifnames,lan1_ifnames,lan2_ifnames,lan3_ifnames,wan_ifnames"); %> -//<% nvram("ppp_get_ip,pptp_server_ip,router_name,wan_domain,wan_gateway,wan_gateway_get,wan_get_domain,wan_hostname,wan_hwaddr,wan_ipaddr,wan_netmask,wan_proto,wan_run_mtu,et0macaddr,lan_proto,lan_ipaddr,dhcp_start,dhcp_num,dhcpd_startip,dhcpd_endip,lan_netmask,wl_security_mode,wl_crypto,wl_mode,wl_wds_enable,wl_hwaddr,wl_net_mode,wl_radio,wl_channel,lan_gateway,wl_ssid,t_model_name,t_features,pptp_dhcp,dhcp1_start,dhcp1_num,dhcpd1_startip,dhcpd1_endip,dhcp2_start,dhcp2_num,dhcpd2_startip,dhcpd2_endip,dhcp3_start,dhcp3_num,dhcpd3_startip,dhcpd3_endip,lan1_proto,lan1_ipaddr,lan1_netmask,lan2_proto,lan2_ipaddr,lan2_netmask,lan3_proto,lan3_ipaddr,lan3_netmask,lan_ifname,lan1_ifname,lan2_ifname,lan3_ifname,clkfreq,wan_ipaddr_buf,wl_closed"); %> //<% uptime(); %> //<% sysinfo(); %> //<% wlstats(1); %> @@ -17,6 +17,7 @@ stats = { }; do { var a, b, i; + var xifs = ['wan', 'lan', 'lan1', 'lan2', 'lan3']; if (typeof(last_wan_proto) == 'undefined') { last_wan_proto = nvram.wan_proto; @@ -149,5 +150,17 @@ do { wlstats[uidx].rssi = ''; stats.qual.push(''); } + + if (wl_ifaces[uidx][6] != 1) { + wlstats[uidx].ifstatus = 'Down'; + } else { + wlstats[uidx].ifstatus = 'Up'; + for (i = 0; i < xifs.length ; ++i) { + if ((nvram[xifs[i] + '_ifnames']).indexOf(wl_ifaces[uidx][0]) >= 0) { + wlstats[uidx].ifstatus = wlstats[uidx].ifstatus + ' (' + xifs[i].toUpperCase() + ')'; + break; + } + } + } } } while (0); diff --git a/release/src/router/www/status-overview.asp b/release/src/router/www/status-overview.asp index 8a79e773ad..0235db8760 100644 --- a/release/src/router/www/status-overview.asp +++ b/release/src/router/www/status-overview.asp @@ -160,6 +160,7 @@ function show() c('qual'+uidx, stats.qual[uidx] || ''); } } + c('ifstatus'+uidx, wlstats[uidx].ifstatus || ''); } } @@ -316,26 +317,24 @@ createFieldTable('', [