summaryrefslogtreecommitdiffhomepage
path: root/proto-shell.c
AgeCommit message (Collapse)Author
2016-08-11proto-shell: Model config parameter "no-proto-task" as a proto flagHans Dedecker
Export the config parameter "no-proto-task" as a proto flag so it's available for other other netifd modules Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-08-11proto-shell: Support teardown on layer 3 link lossHans Dedecker
Commit c6858766 added interface teardown support on layer 3 device link loss mainly for shell protocols who have no proto task like xl2tp. However for shell protocols having a proto task it is not always the correct action to teardown the interface; as an example the PPP daemon can be put into persist state trying to re-establish the link via a hold-off mechanism if layer 3 link loss is detected. Therefore shell handlers can enable via TEARDOWN_ON_L3_LINK_DOWN a proto flag which will teardown the interface when layer 3 link loss is detected Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-02-01proto-shell: Fix possible segfaultHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-08-25proto-shell: add checkup timeout to restart interface.Yousong Zhou
This is mainly for protocols with no_proto_task set. L2TP with xl2tpd is such a case and the issue this commit tries to address is that xl2tpd could fail redialing the connection (segfault or abort) without the notice of netifd causing the concerned interface being left down. This patch solves it by allowing users to configure an timeout value instructing netifd to check if the interface is in up state after its last attempt to setup it and try again if that is not the case. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2015-06-10proto-shell: add support for generic host-dependencies to interfacesSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-23proto-shell: simplify no_proto_task assignmentFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-23proto-shell: allow running protocols without proto_task.Yousong Zhou
Adds a new config parameter "no-proto-task" for noting that no proto_task will be running for this protocol type. This is required since then change in commit "d0dcf74 proto-shell: retry setup if the proto handler script quits without changing the state or starting a process". The change is mainly for protocols like xl2tpd in which control commands are sent to another daemon xl2tpd to start L2TP negotiation and pppd process who is not under netifd's control as proto_task as is the case in other ppp related protocols like pppoe, pptp, etc. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2015-04-21proto-shell: retry setup if the proto handler script quits without changing ↵Felix Fietkau
the state or starting a process Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-04-03netifd: Interface last error supportHans Dedecker
Adds interface last error support which preserves the last reported error reported by the protocol handler till the interface is up; e.g. survives network reload and interface restarts. This is mainly usefull for tracking down why an interface fails to establish; eg auth failure/traffic limit for PPP interfaces Protocol handlers register last error support by setting lasterror=1 in the proto_init function Signed-off-by: Johan Peeters <johan.peeters111@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
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