802.11s: fix authsae support in netifd
This patch implements support for 802.11s protected mesh wireless networks (using authsae) in the netifd framework. Until meshd-nl80211 implements a proper -P option for the PID file, this uses shell backgrounding in order to be able to get the PID for the process. Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net> SVN-Revision: 40497
This commit is contained in:
		| @@ -449,6 +449,7 @@ mac80211_setup_adhoc() { | |||||||
|  |  | ||||||
| mac80211_setup_vif() { | mac80211_setup_vif() { | ||||||
| 	local name="$1" | 	local name="$1" | ||||||
|  | 	local failed | ||||||
|  |  | ||||||
| 	json_select data | 	json_select data | ||||||
| 	json_get_vars ifname | 	json_get_vars ifname | ||||||
| @@ -473,7 +474,19 @@ mac80211_setup_vif() { | |||||||
| 				json_get_var mp_val "$var" | 				json_get_var mp_val "$var" | ||||||
| 				[ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$var" "$mp_val" | 				[ -n "$mp_val" ] && iw dev "$ifname" set mesh_param "$var" "$mp_val" | ||||||
| 			done | 			done | ||||||
| 			# todo: authsae |  | ||||||
|  | 			# authsae | ||||||
|  | 			json_get_vars key | ||||||
|  | 			if [ -n "$key" ]; then | ||||||
|  | 				if [ -e "/lib/wifi/authsae.sh" ]; then | ||||||
|  | 					. /lib/wifi/authsae.sh | ||||||
|  | 					authsae_start_interface || failed=1 | ||||||
|  | 				else | ||||||
|  | 					wireless_setup_vif_failed AUTHSAE_NOT_INSTALLED | ||||||
|  | 					json_select .. | ||||||
|  | 					return | ||||||
|  | 				fi | ||||||
|  | 			fi | ||||||
| 		;; | 		;; | ||||||
| 		adhoc) | 		adhoc) | ||||||
| 			wireless_vif_parse_encryption | 			wireless_vif_parse_encryption | ||||||
|   | |||||||
| @@ -1,28 +1,24 @@ | |||||||
| authsae_start_interface() { | authsae_start_interface() { | ||||||
| 	local device="$1" # to use the correct channel | 	local mcast_rate | ||||||
| 	local vif="$2" | 	local mesh_htmode | ||||||
| 	local band | 	local mesh_band | ||||||
|  | 	local authsae_conf_file="/var/run/authsae-$ifname.cfg" | ||||||
|  | 	local ret=1 | ||||||
|  |  | ||||||
| 	cfgfile="/var/run/authsae-$vif.cfg" | 	json_get_vars mcast_rate | ||||||
| 	config_get channel "$device" channel | 	set_default mcast_rate "12" | ||||||
| 	config_get hwmode "$device" hwmode |  | ||||||
| 	config_get htmode "$device" htmode |  | ||||||
| 	config_get ifname "$vif" ifname |  | ||||||
| 	config_get key "$vif" key |  | ||||||
| 	config_get mesh_id "$vif" mesh_id |  | ||||||
| 	config_get mcast_rate "$vif" mcast_rate "12" |  | ||||||
|  |  | ||||||
| 	case "$htmode" in | 	case "$htmode" in | ||||||
| 		HT20|HT40+|HT40-) htmode="$htmode";; | 		HT20|HT40+|HT40-) mesh_htmode="$htmode";; | ||||||
| 		NOHT|none|*) htmode="none";; | 		*) mesh_htmode="none";; | ||||||
| 	esac | 	esac | ||||||
|  |  | ||||||
| 	case "$hwmode" in | 	case "$hwmode" in | ||||||
| 		*g*) band=11g;; | 		*g*) mesh_band=11g;; | ||||||
| 		*a*) band=11a;; | 		*a*) mesh_band=11a;; | ||||||
| 	esac | 	esac | ||||||
|  |  | ||||||
| 	cat > "$cfgfile" <<EOF | 	cat > "$authsae_conf_file" <<EOF | ||||||
| authsae: | authsae: | ||||||
| { | { | ||||||
|  sae: |  sae: | ||||||
| @@ -41,13 +37,21 @@ authsae: | |||||||
|     passive = 0; |     passive = 0; | ||||||
|     debug = 0; |     debug = 0; | ||||||
|     mediaopt = 1; |     mediaopt = 1; | ||||||
|     band = "$band"; |     band = "$mesh_band"; | ||||||
|     channel = $channel; |     channel = $channel; | ||||||
|     htmode = "$htmode"; |     htmode = "$mesh_htmode"; | ||||||
|     mcast-rate = $mcast_rate; |     mcast-rate = $mcast_rate; | ||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
| EOF | EOF | ||||||
| 	ifconfig "$ifname" up |  | ||||||
| 	meshd-nl80211 -i "$ifname" -s "$mesh_id" -c "$cfgfile" -B | 	/usr/bin/meshd-nl80211 -i "$ifname" -s "$mesh_id" -c "$authsae_conf_file" </dev/null >/dev/null 2>/dev/null & | ||||||
|  | 	authsae_pid="$!" | ||||||
|  | 	ret="$?" | ||||||
|  |  | ||||||
|  | 	echo $authsae_pid > /var/run/authsae-$ifname.pid | ||||||
|  | 	wireless_add_process "$authsae_pid" "/usr/bin/meshd-nl80211" 1 | ||||||
|  |  | ||||||
|  | 	[ "$ret" != 0 ] && wireless_setup_vif_failed AUTHSAE_FAILED | ||||||
|  | 	return $ret | ||||||
| } | } | ||||||
|   | |||||||
| @@ -586,5 +586,5 @@ wpa_supplicant_run() { | |||||||
| } | } | ||||||
|  |  | ||||||
| hostapd_common_cleanup() { | hostapd_common_cleanup() { | ||||||
| 	killall hostapd wpa_supplicant | 	killall hostapd wpa_supplicant meshd-nl80211 | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 John Crispin
					John Crispin