summaryrefslogtreecommitdiffhomepage
path: root/proto-shell.c
AgeCommit message (Collapse)Author
2014-12-08netifd: Make possible state transitions more clear when handling teardown eventHans Dedecker
Improve code readibility regarding state transitions when handling teardown event Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2014-12-08netifd: Fix proto shell setup/teardwon race conditionHans Dedecker
Fix setup race condition when proto shell is in teardown or setup_abort state when setup cmd is received. Don't change the proto shell state and launch no setup in these conditions so the proto shell teardown timeout handler does not kill the wrong processes and proto_shell_task_finish takes action on the correct teardown state. Don't launch a new setup action when already in setup state. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2014-10-16proto-shell: fix for not handling switch from DHCP to static raceMichel Stam
When a shell script call is finished, proto_shell_task_finish( ) is called to monitor processes, and determine the next interface state. When the interface is brought up after a reconfiguration from dhcp to static, it will first try to (erroneously?) reconfigure the interface for DHCP. Upon doing this, it realises the mistake and kills off the script by setting the state to S_SETUP_ABORT. This is done by the proto_shell_handler. When this happens. the scripts have 1 second to finish. When this happens, S_SETUP_ABORT in proto_shell_task_finish( ) should issue a 'teardown' event to the shell script to deconfigure the interface. It is here that things go wrong. Shell scripts do not execute commands themselves, they should finish as quick as possible. This is very race condition sensitive, though; Instead of executing commands, they post messages to execute commands. It is therefore possible that when the script finishes, there's still commands to execute. The dhcp protocol handler script, one of the scripts involved, notifies netifd of changes by (indirectly) calling proto_shell_update_link( ). Once every so often, the dhcp script will not be finished in time, and proto_shell_task_finish( ) cannot immediately continue, because (in this case) the proto_task is still pending. If this happens, the proto_shell_task_finish( ) will wait, but if the proto_shell_update_link( ) notification is then received, it will set the statemachine to idle, thus breaking the S_SETUP_ABORT. Furthermore, an event is generated to indicate that the network interface should be set to UP, rather than DOWN. This confuses netifd, and the result is a stuck process that does not respond to UCI calls anymore. Note that a similar situation happens in the S_TEARDOWN state in proto_shell_task_finish( ). The fix, although a bit ugly, is to prevent the UP event from being sent, and not to reset the state machine to idle in proto_shell_update_link( ). Signed-off-by: Michel Stam <m.stam@fugro.nl>
2014-08-31proto-shell: also set proto_task_killed for SIGKILLFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-08-31proto-shell: set proto_task_killed for SIGTERM onlyUlrich Weber
otherwise teardown will not kill the process if the interface was renewed before, which set proto_task_killed Signed-off-by: Ulrich Weber <uw@ocedo.com>
2014-08-07netifd: More fine grained handling of unwanted proto shell actionsHans Dedecker
In commit e1ec2d2b9e7f7692a4ff88a0361bbcdbe34f0d99 (proto-shell: extend race condition avoidance), changes were made to prevent notifications from the proto handler during the proto shell states teardown and abort. These changes unfortunately also prevent netifd from being notified of a number of proto handler events like notify_error, blok_restart and kill during the teardown state. This introduces issues when the protocol is ppp, the authfail UCI parameter is set and authentication fails; the interface autostart parameter cannot be set to disabled while the ppp daemon keeps running as these proto handler notifications are dropped in the teardown state. The attached patch blocks the notifications in the individual notification handlers which should not get notifications during teardown/abort state and allows notify_error/blok_restart/kill notifications during these states. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2014-08-05netifd: Accept notify errors in proto_shell teardown or abort stateHans Dedecker
In commit e1ec2d2b9e7f7692a4ff88a0361bbcdbe34f0d99 (proto-shell: extend race condition avoidance), changes were made to prevent notifications from the proto handler during teardown. According to the comments, this was done to avoid the shell proto state being reset to S_IDLE and the interface hanging in IFS_TEARDOWN state. These changes unfortunately also prevent netifd from being notified of the errors (proto_shell_notify_error) that actually caused the teardown. This is for instance an issue when the protocol is ppp and e.g. PAP/CHAP authentication fails. Since proto_shell_notify_error does not touch the proto state, it seems like a good idea to at least allow these notifications in teardown state. The attached patch accomplishes this. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Signed-off-by: Joeri Barbarien <joeri.barbarien@gmail.com>
2014-07-29proto-shell: extend race condition avoidanceSteven Barth
Disallow all notifications from the proto handler during teardown to avoid the shell proto state being reset to S_IDLE and the interface hanging in IFS_TEARDOWN state. Signed-off-by: Steven Barth <steven@midlink.org>
2014-07-26proto-shell: fix renew_pending handlingFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-26proto-shell: fix setup/renew race conditionFelix Fietkau
If a renew event arrives before the setup event has been processed, the renew event needs to be deferred, otherwise interfaces can get stuck Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-07-24proto-shell: don't accept up-notifications in teardown stateSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>
2014-06-26proto-shell: add debug msg for calling handlersFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-06-18netifd: Check device_claim return code in all casesHans Dedecker
Fixes observed issue a tunnel interface is reported as up although device_claim failed Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2014-04-10proto-shell: fix a regression with handling multiple proto updates for the ↵Felix Fietkau
same interface Preserve the device when keep == true Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-07proto-shell: ensure that l3_dev is always setFelix Fietkau
A link-down event clears l3_dev, so even if the proto handler does not provide a new ifname, it still needs to be set explicitly Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-03-21netifd: Reload proto on topology changeHelmut Schaa
Introduce a new device event "topology change" that gets signaled by bridges on adding/removing members. On "topology changes" the proto handlers are requested to "renew" which is most useful for DHCP. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2014-03-07proto-shell: defer init until after command line option processingFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-27netifd: Link layer state awareness support on interface levelHans Dedecker
The link layer state is monitored for a given interface; an interface will be setup when both enabled and link layer active. Likewise an interface will be teared down when either disabled or link layer down. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2014-01-17Add indicator-flags to ubus and hotplug update-eventsSteven Barth
2013-12-14Revert "netifd: Link layer state support on interface level"Felix Fietkau
This reverts commit 7335c3e19ea09674245dda3653d3f40705e68d6b.
2013-12-08netifd: Link layer state support on interface levelHans Dedecker
Patch implements handling of link layer support on interface level. An interface will go into the setup state when it's enabled and the underlying link state is enabled. Vice versa an interface will go to the down state when it's either disabled or underlying link state is disabled. Testing has been done with PPP, IPoE, tunnel and static interfaces Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2013-10-29proto-shell: replace variable length name char arrays with pointers, using ↵Felix Fietkau
calloc_a Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-22utils: add a function for checking if a process given by pid is still aliveFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-22proto-shell: move more core to handler.cFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-22proto-shell: move script handler config parse code to handler.cFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-22proto-shell: move script handler dump code to handler.cFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-22proto-shell: make handler dump code more genericFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-18Reevaluate target routes also on interface updateSteven Barth
2013-10-17Add protocol update notifications and hotplug legacy callsSteven Barth
2013-06-10config: use the new uci_blob library codeFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-13Add support for IPv6 and interface target-routes & dependenciesSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>
2013-01-05proto-shell: use calloc_aFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-10-30proto-shell: ensure that the teardown timeout gets killedFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-10-29use FD_CLOEXEC instead of tracking lists of fdsFelix Fietkau
2012-06-19proto-shell.c: mark device present after reclaiming it, fixes ubus ↵Jo-Philipp Wich
network.device status call after the protocol has been reconnected
2012-05-19move dns server/search list parsing to interface core to support peerdns=0 + ↵Felix Fietkau
static entries
2012-05-14add a command for allowing the setup task to schedule a restartFelix Fietkau
2012-05-14proto-shell: clear dependencies on freeFelix Fietkau
2012-05-05proto-shell: implement host route dependenciesFelix Fietkau
2012-05-04add copyright headersFelix Fietkau
2012-04-29proto-shell: add support for appending configuration data over multiple ↵Felix Fietkau
update_link notifications
2012-04-12proto-shell: set sm to S_IDLE once the interface is upFelix Fietkau
2012-03-23allow proto handlers to attach data items in notifyFelix Fietkau
2012-03-23move l3 device tracking to interface core to enforce proper order of ↵Felix Fietkau
address/route removal on device or interface state changes
2012-03-19properly flush routes and l3 devices when tearing down interfacesFelix Fietkau
2012-03-19proto-shell: fix potential use-after-freeFelix Fietkau
2012-03-15shell: add tunnel supportFelix Fietkau
2012-02-26proto: move the dns search option handling to the coreFelix Fietkau
2012-02-26proto-shell: process some common notify options using proto_apply_ip_settings()Felix Fietkau
2012-01-22proto-shell: merge setup/teardown task into oneFelix Fietkau