Skip to content

Commit

Permalink
Add fixes for DHCP modes 'client' and 'none' to ensure proper udhcpc …
Browse files Browse the repository at this point in the history
…execution and removal from bridges. Also remove unused 'lease' state parameter.
  • Loading branch information
jheretic committed Mar 6, 2014
1 parent d4fb914 commit bb49b46
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions openwrt/lib/netifd/proto/commotion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,20 @@ proto_commotion_setup() {
unset_bridge "$client_bridge" "$iface"
logger -t "commotion.proto" -s "Removing $iface from bridge $client_bridge"
export DHCP_INTERFACE="$config"
udhcpc -q -i ${iface} -t 2 -T "$dhcp_timeout" -n -s /lib/netifd/commotion.dhcp.script
udhcpc -q -i ${iface} -p /var/run/udhcpc-${iface}.pid -t 2 -T "$dhcp_timeout" -n -s /lib/netifd/commotion.dhcp.script
dhcp_status=$?
export DHCP_INTERFACE=""
if [ $dhcp_status -eq 0 ]; then
# we got an IP
# see commotion.dhcp.script for the rest of
# the setup code.
have_ip=1
uci_set_state network "$config" lease 2

# get out of here early.
return
else
unset_fwzone "$config"
uci_commit firewall
uci_set_state network "$config" lease 1
set_bridge "$client_bridge" "$iface"
logger -t "commotion.proto" -s "Adding $iface to bridge $client_bridge"

Expand Down Expand Up @@ -142,7 +140,6 @@ proto_commotion_setup() {
"server")
unset_fwzone "$config"
uci_commit firewall
uci_set_state network "$config" lease 1
set_bridge "$client_bridge" "$iface"
logger -t "commotion.proto" -s "Adding $iface to bridge $client_bridge"

Expand All @@ -165,9 +162,13 @@ proto_commotion_setup() {

unset_bridge "$client_bridge" "$iface"
logger -t "commotion.proto" -s "Removing $iface from bridge $client_bridge"
export DHCP_INTERFACE="$config"
proto_run_command "$config" udhcpc -i ${iface} -t 2 -T "$dhcp_timeout" -n -s /lib/netifd/commotion.dhcp.script
proto_export "DHCP_INTERFACE=$config"
proto_run_command "$config" udhcpc -i ${iface} -f -T "$dhcp_timeout" -t 0 -p /var/run/udhcpc-"$iface".pid -s /lib/netifd/commotion.dhcp.script
have_ip=1
;;
"none")
unset_bridge "$client_bridge" "$iface"
;;
esac
;;
esac
Expand All @@ -176,8 +177,13 @@ proto_commotion_setup() {

if [ $have_ip -eq 0 ]; then
if [ "$class" != "mesh" ]; then
local ip=${ipaddr:-$(commotion_gen_ip $DEFAULT_CLIENT_SUBNET $DEFAULT_CLIENT_IPGENMASK gw)}
local netmask=${netmask:-$DEFAULT_CLIENT_NETMASK}
if [ "$class" == "wired" -a "$dhcp" == "none" ]; then
local ip="$ipaddr"
local netmask="$netmask"
else
local ip=${ipaddr:-$(commotion_gen_ip $DEFAULT_CLIENT_SUBNET $DEFAULT_CLIENT_IPGENMASK gw)}
local netmask=${netmask:-$DEFAULT_CLIENT_NETMASK}
fi
proto_add_ipv4_address $ip $netmask
logger -t "commotion.proto" -s "proto_add_ipv4_address: $ip $netmask"
uci_set_state network "$config" ipaddr "$ip"
Expand Down

0 comments on commit bb49b46

Please sign in to comment.