summaryrefslogtreecommitdiff
path: root/proto-shell.c
Commit message (Collapse)AuthorAgeFilesLines
* proto-shell.c: add a explicit "fall through" comment to make the compiler happyAlexander Couzens2018-07-111-1/+2
| | | | | Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Acked-by: Hans Dedecker <dedeckeh@gmail.com>
* interface: Fix triggering of interface update eventHans Dedecker2016-11-041-4/+3
| | | | | | | | | | | | | | | | | In case the keep flag is set in proto_shell_update_link no interface update event is triggered when IPv4/6 addresses/routes/... are updated as the proto_event callback is not called due to keep being set. Unconditionally call the proto_event callback handler in proto_shell_update_link but let the proto_event callback handler; in this case interface_proto_event_cb, decide which actions need to be taken dependant on the interface state. In case the interface is already in the up state trigger an update event only if the interface updated flag actually indicates either an IP address/ route/data change; before interface update events were actually sent wihtout any parameter change. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* proto-shell: Model config parameter "no-proto-task" as a proto flagHans Dedecker2016-08-111-3/+3
| | | | | | | 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>
* proto-shell: Support teardown on layer 3 link lossHans Dedecker2016-08-111-0/+4
| | | | | | | | | | | | | 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>
* proto-shell: Fix possible segfaultHans Dedecker2016-02-011-0/+5
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* proto-shell: add checkup timeout to restart interface.Yousong Zhou2015-08-251-0/+60
| | | | | | | | | | | | | 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>
* proto-shell: add support for generic host-dependencies to interfacesSteven Barth2015-06-101-13/+19
| | | | Signed-off-by: Steven Barth <steven@midlink.org>
* proto-shell: simplify no_proto_task assignmentFelix Fietkau2015-05-231-4/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: allow running protocols without proto_task.Yousong Zhou2015-05-231-2/+10
| | | | | | | | | | | | | | | 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>
* proto-shell: retry setup if the proto handler script quits without changing ↵Felix Fietkau2015-04-211-3/+10
| | | | | | the state or starting a process Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* netifd: Interface last error supportHans Dedecker2015-04-031-0/+4
| | | | | | | | | | | | | | 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>
* netifd: Make possible state transitions more clear when handling teardown eventHans Dedecker2014-12-081-13/+20
| | | | | | Improve code readibility regarding state transitions when handling teardown event Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* netifd: Fix proto shell setup/teardwon race conditionHans Dedecker2014-12-081-4/+16
| | | | | | | | | | 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>
* proto-shell: fix for not handling switch from DHCP to static raceMichel Stam2014-10-161-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* proto-shell: also set proto_task_killed for SIGKILLFelix Fietkau2014-08-311-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: set proto_task_killed for SIGTERM onlyUlrich Weber2014-08-311-1/+2
| | | | | | | | 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>
* netifd: More fine grained handling of unwanted proto shell actionsHans Dedecker2014-08-071-9/+16
| | | | | | | | | 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>
* netifd: Accept notify errors in proto_shell teardown or abort stateHans Dedecker2014-08-051-2/+6
| | | | | | | | | | | | 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>
* proto-shell: extend race condition avoidanceSteven Barth2014-07-291-1/+4
| | | | | | | | 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>
* proto-shell: fix renew_pending handlingFelix Fietkau2014-07-261-0/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: fix setup/renew race conditionFelix Fietkau2014-07-261-0/+11
| | | | | | | 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>
* proto-shell: don't accept up-notifications in teardown stateSteven Barth2014-07-241-1/+1
| | | | Signed-off-by: Steven Barth <steven@midlink.org>
* proto-shell: add debug msg for calling handlersFelix Fietkau2014-06-261-0/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* netifd: Check device_claim return code in all casesHans Dedecker2014-06-181-1/+3
| | | | | | Fixes observed issue a tunnel interface is reported as up although device_claim failed Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* proto-shell: fix a regression with handling multiple proto updates for the ↵Felix Fietkau2014-04-101-16/+17
| | | | | | | | same interface Preserve the device when keep == true Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: ensure that l3_dev is always setFelix Fietkau2014-04-071-17/+15
| | | | | | | 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>
* netifd: Reload proto on topology changeHelmut Schaa2014-03-211-0/+8
| | | | | | | | | | 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>
* proto-shell: defer init until after command line option processingFelix Fietkau2014-03-071-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* netifd: Link layer state awareness support on interface levelHans Dedecker2014-02-271-0/+1
| | | | | | | | 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>
* Add indicator-flags to ubus and hotplug update-eventsSteven Barth2014-01-171-3/+3
|
* Revert "netifd: Link layer state support on interface level"Felix Fietkau2013-12-141-1/+0
| | | | This reverts commit 7335c3e19ea09674245dda3653d3f40705e68d6b.
* netifd: Link layer state support on interface levelHans Dedecker2013-12-081-0/+1
| | | | | | | | | | | 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>
* proto-shell: replace variable length name char arrays with pointers, using ↵Felix Fietkau2013-10-291-17/+15
| | | | | | calloc_a Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* utils: add a function for checking if a process given by pid is still aliveFelix Fietkau2013-10-221-1/+0
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: move more core to handler.cFelix Fietkau2013-10-221-20/+4
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: move script handler config parse code to handler.cFelix Fietkau2013-10-221-72/+3
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: move script handler dump code to handler.cFelix Fietkau2013-10-221-103/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: make handler dump code more genericFelix Fietkau2013-10-221-26/+57
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Reevaluate target routes also on interface updateSteven Barth2013-10-181-1/+1
|
* Add protocol update notifications and hotplug legacy callsSteven Barth2013-10-171-1/+1
|
* config: use the new uci_blob library codeFelix Fietkau2013-06-101-2/+2
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Add support for IPv6 and interface target-routes & dependenciesSteven Barth2013-05-131-6/+22
| | | | Signed-off-by: Steven Barth <steven@midlink.org>
* proto-shell: use calloc_aFelix Fietkau2013-01-051-5/+2
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* proto-shell: ensure that the teardown timeout gets killedFelix Fietkau2012-10-301-0/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* use FD_CLOEXEC instead of tracking lists of fdsFelix Fietkau2012-10-291-6/+7
|
* proto-shell.c: mark device present after reclaiming it, fixes ubus ↵Jo-Philipp Wich2012-06-191-0/+1
| | | | network.device status call after the protocol has been reconnected
* move dns server/search list parsing to interface core to support peerdns=0 + ↵Felix Fietkau2012-05-191-0/+10
| | | | static entries
* add a command for allowing the setup task to schedule a restartFelix Fietkau2012-05-141-0/+18
|
* proto-shell: clear dependencies on freeFelix Fietkau2012-05-141-0/+1
|
* proto-shell: implement host route dependenciesFelix Fietkau2012-05-051-0/+136
|