oweals/netifd.git
9 years agonetifd: Fix proto shell setup/teardwon race condition
Hans Dedecker [Thu, 4 Dec 2014 12:07:16 +0000 (12:07 +0000)]
netifd: Fix proto shell setup/teardwon race condition

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>
9 years agonetifd: Fix restore of original device settings
Hans Dedecker [Thu, 4 Dec 2014 12:07:15 +0000 (12:07 +0000)]
netifd: Fix restore of original device settings

Don't restore original device settings based on the device settings flags in system_if_down
as device flags are already reset when the device config is deleted.
Therefore move the masking of the relevant original device settings to system_if_up.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd v2: Fix source routing for IPv4
Kristian Evensen [Wed, 26 Nov 2014 10:16:05 +0000 (10:16 +0000)]
netifd v2: Fix source routing for IPv4

According to the OpenWRT Network documentation for route, the 'source' option is
"The preferred source address when sending to destinations covered by the
target". However, netifd currently stores this value in RTA_SRC on
NEWROUTE/DELROUTE.

RTA_SRC is not used by kernel when handling NEWROUTE nor DELROUTE for IPv4
routes. When adding a new IPv4 route, the source is stored in RTA_PREFSRC and
the option works as specified in documentation. For IPv6, the address is still
stored in RTA_SRC as to not break source-destination routing for IPv6.

v2: Limit patch to IPv4, to prevent breaking IPv6 configurations (thanks Steven
Barth)

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
10 years agoFix setting blackhole-routes to kernel
Steven Barth [Tue, 25 Nov 2014 22:56:39 +0000 (23:56 +0100)]
Fix setting blackhole-routes to kernel

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agobridge: retry adding members after config reload / device start
Felix Fietkau [Sun, 23 Nov 2014 16:05:54 +0000 (17:05 +0100)]
bridge: retry adding members after config reload / device start

The kernel will refuse to add a vlan device to a bridge when the base
device of that vlan is already a member. This can happen on config
reload.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agonetifd: Add acceptlocal config support
Hans Dedecker [Thu, 13 Nov 2014 15:57:59 +0000 (15:57 +0000)]
netifd: Add acceptlocal config support

Adds support to accept packets with local source address.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Add rpfilter config support
Hans Dedecker [Thu, 13 Nov 2014 15:57:58 +0000 (15:57 +0000)]
netifd: Add rpfilter config support

Reverse path filtering config support; possible values are:
    0: no source validation
    1|strict: strict mode as packet will be dropped if the
    incoming interface is not the best reverse path
    2|loose: loose mode as packet will be dropped if the
    source address is not reachable via any interface

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Remove superfluous system_if_resolve calls
Hans Dedecker [Thu, 13 Nov 2014 15:57:57 +0000 (15:57 +0000)]
netifd: Remove superfluous system_if_resolve calls

Don't resolve the ifindex of the parent device again
when adding vlandev and macvlan devices as the ifindex
has already been resolved.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Fix device ifindex overwrite when processing netlink event messages
Hans Dedecker [Thu, 13 Nov 2014 15:57:56 +0000 (15:57 +0000)]
netifd: Fix device ifindex overwrite when processing netlink event messages

When a device with the same name is deleted and created again in the kernel
the ifindex changes.
A race condition will occur when netlink event messages linked to the old device
are processed and will thus overwrite the correct ifindex of the new device.
Further make sure a valid ifindex is in place for both external and internal
devices when setting the state to enabled.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd : Apply interface metric on subnet routes when reloading ip
Hans Dedecker [Thu, 23 Oct 2014 09:12:54 +0000 (11:12 +0200)]
netifd : Apply interface metric on subnet routes when reloading ip

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd : Reinsert ip parameters (addresses/routes) based on old interface config...
Hans Dedecker [Thu, 23 Oct 2014 09:12:53 +0000 (11:12 +0200)]
netifd : Reinsert ip parameters (addresses/routes) based on old interface config state

Reinserts the config IP parameters as the config_ip
parameter of the new interface is set to false in
interface_alloc and thus not loading the config ip
options of the old interface

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Read current link state when processing netlink event
Hans Dedecker [Thu, 23 Oct 2014 09:13:44 +0000 (11:13 +0200)]
netifd: Read current link state when processing netlink event

Netifd commit b2dcb02570939d98b92c7c55db1c328693a5d52a introduces
a race condition resulting into infinite toggling interfaces
(eg static interfaces with linksensing enabled, vlan interfaces
with proto none (#18106)) when linksensing is enabled resulting into
a crash.
As netlink event messages will be queued on the netlink event socket
the included lower up interface flag will not always represent the
current link state when netifd processes the netlink messages;
by reading the current link state when a netlink event message is
parsed the correct info is passed to the device layer.
This will avoid continuous interface toggling (down/up) triggered
by link state changes based on outdated netlink interface info.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agowireless: use strdup for vif sections
Felix Fietkau [Fri, 24 Oct 2014 13:00:12 +0000 (15:00 +0200)]
wireless: use strdup for vif sections

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agosystem-linux: fix a glob related memleak
Felix Fietkau [Fri, 24 Oct 2014 12:44:34 +0000 (14:44 +0200)]
system-linux: fix a glob related memleak

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoconfig: use sprintf instead of asprintf
Felix Fietkau [Fri, 24 Oct 2014 11:35:30 +0000 (13:35 +0200)]
config: use sprintf instead of asprintf

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agodevice: make link status detection optional for vlan devices
Felix Fietkau [Mon, 20 Oct 2014 20:07:18 +0000 (22:07 +0200)]
device: make link status detection optional for vlan devices

Fixes a race condition that triggers endless link loss / detect calls
when VLAN devices are created.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoproto-shell: fix for not handling switch from DHCP to static race
Michel Stam [Thu, 2 Oct 2014 11:39:16 +0000 (11:39 +0000)]
proto-shell: fix for not handling switch from DHCP to static race

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>
10 years agonetifd: Fix lost interface device config for devices having default config
Hans Dedecker [Fri, 10 Oct 2014 13:35:08 +0000 (13:35 +0000)]
netifd: Fix lost interface device config for devices having default config

As the PPP main device (either a simple or old style vlan device) is freed when PPP interfaces are reloaded; interface device specific config (eg mtu/macaddr/...) is lost as the interface config is not re-applied on the newly created device.
Patch fixes the issue by re-applying the interface device config after the main device is claimed and is having default config.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd : Line up device.h include guard
Hans Dedecker [Fri, 10 Oct 2014 13:35:07 +0000 (13:35 +0000)]
netifd : Line up device.h include guard

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agoconfig: define _GNU_SOURCE for asprintf
Felix Fietkau [Tue, 7 Oct 2014 12:10:06 +0000 (14:10 +0200)]
config: define _GNU_SOURCE for asprintf

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agowireless: print the active configuration in status info
Felix Fietkau [Sat, 4 Oct 2014 18:30:58 +0000 (20:30 +0200)]
wireless: print the active configuration in status info

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agowireless: fix blob buf in put_container()
Felix Fietkau [Sat, 4 Oct 2014 18:30:24 +0000 (20:30 +0200)]
wireless: fix blob buf in put_container()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agowireless: display anonymous interface section names using index based extended syntax
Felix Fietkau [Wed, 1 Oct 2014 13:05:00 +0000 (15:05 +0200)]
wireless: display anonymous interface section names using index based extended syntax

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agowireless: copy the vif section name instead of keeping a reference that might go...
Felix Fietkau [Wed, 1 Oct 2014 13:03:30 +0000 (15:03 +0200)]
wireless: copy the vif section name instead of keeping a reference that might go stale

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agonetifd: IPIP tunnel support
Hans Dedecker [Thu, 2 Oct 2014 13:37:20 +0000 (13:37 +0000)]
netifd: IPIP tunnel support

Adds IPIP tunnel support to netifd.
Following IPIP tunnel parameters can be configured :
   -peeraddr (IPv4 remote address)
   -ipaddr (IPv4 local address)
   -mtu (IPIP tunnel mtu)
   -ttl (time to live of encapsulting packets)
   -tos (type of service either inherit (outer header inherits the value of the inner header) or hex value)
   -df (don't fragment flag of encapsulating packets)
   -tunlink (bind tunnel to this interface)

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: GRE Tos support
Hans Dedecker [Mon, 29 Sep 2014 15:36:04 +0000 (15:36 +0000)]
netifd: GRE Tos support

Tos support is added as a generic gre parameter which can have the following values :
     -inherit (outer header inherits the tos value of the inner header)
     -hex value

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd-device: add support for promisc setting
Martin Hundebøll [Mon, 15 Sep 2014 09:57:50 +0000 (11:57 +0200)]
netifd-device: add support for promisc setting

Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
10 years agoipv6: work around kernel on-link handling issue
Steven Barth [Mon, 8 Sep 2014 14:40:50 +0000 (16:40 +0200)]
ipv6: work around kernel on-link handling issue

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agointerface: call proto teardown before marking the interface as down
Felix Fietkau [Sun, 31 Aug 2014 13:06:42 +0000 (15:06 +0200)]
interface: call proto teardown before marking the interface as down

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: do not try to bring up an unavailable interface
Felix Fietkau [Sun, 31 Aug 2014 13:03:20 +0000 (15:03 +0200)]
interface: do not try to bring up an unavailable interface

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: cancel the remove timer on cleanup
Felix Fietkau [Sun, 31 Aug 2014 12:57:34 +0000 (14:57 +0200)]
interface: cancel the remove timer on cleanup

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoproto-shell: also set proto_task_killed for SIGKILL
Felix Fietkau [Sun, 31 Aug 2014 12:22:52 +0000 (14:22 +0200)]
proto-shell: also set proto_task_killed for SIGKILL

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoproto-shell: set proto_task_killed for SIGTERM only
Ulrich Weber [Tue, 10 Jun 2014 10:51:06 +0000 (10:51 +0000)]
proto-shell: set proto_task_killed for SIGTERM only

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>
10 years agohandler: explicitly include json.h
Felix Fietkau [Wed, 13 Aug 2014 21:07:24 +0000 (23:07 +0200)]
handler: explicitly include json.h

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoipv6: assign prefixes with length <64 with /64 on-link routes
Steven Barth [Wed, 13 Aug 2014 14:35:28 +0000 (16:35 +0200)]
ipv6: assign prefixes with length <64 with /64 on-link routes

on-link routes for prefixes bigger than /64 make no sense and
might confuse some users

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agonetifd: More fine grained handling of unwanted proto shell actions
Hans Dedecker [Thu, 7 Aug 2014 08:44:31 +0000 (08:44 +0000)]
netifd: More fine grained handling of unwanted proto shell actions

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>
10 years agoDisable new-style tunnel creation for older kernels
Steven Barth [Wed, 6 Aug 2014 11:23:12 +0000 (13:23 +0200)]
Disable new-style tunnel creation for older kernels

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agonetifd: Accept notify errors in proto_shell teardown or abort state
Hans Dedecker [Tue, 5 Aug 2014 08:22:27 +0000 (08:22 +0000)]
netifd: Accept notify errors in proto_shell teardown or abort state

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>
10 years agonetifd: fix incorrect number of bytes memset in clear_if_addr
Hans Dedecker [Tue, 5 Aug 2014 08:22:26 +0000 (08:22 +0000)]
netifd: fix incorrect number of bytes memset in clear_if_addr

Fix clear_if_addr for IPv6 addresses as an incorrect number of bytes were memset due to wrong sizeof argument

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: GRE tunnel support
Hans Dedecker [Wed, 30 Jul 2014 10:56:31 +0000 (10:56 +0000)]
netifd: GRE tunnel support

Adds support for gre, gretap, grev6 and grev6tap tunnels

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Allow to add link devices which can be marked as non external
Hans Dedecker [Wed, 30 Jul 2014 10:56:30 +0000 (10:56 +0000)]
netifd: Allow to add link devices which can be marked as non external

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Set device down based on being a non external device in device_release
Hans Dedecker [Wed, 30 Jul 2014 10:56:29 +0000 (10:56 +0000)]
netifd: Set device down based on being a non external device in device_release

Line up the device state manipulation by checking the external device parameter consistent and not the hotplug device parameter

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agoadd_dynamic: remove redundant code
Steven Barth [Tue, 29 Jul 2014 16:43:45 +0000 (18:43 +0200)]
add_dynamic: remove redundant code

device_config is unneeded since add_dynamic is used to create aliases
checking of setup state is unneeded because of race condition fixes

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agoproto-shell: extend race condition avoidance
Steven Barth [Tue, 29 Jul 2014 16:41:51 +0000 (18:41 +0200)]
proto-shell: extend race condition avoidance

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>
10 years agoubus: add del_dynamic as complement to add_dynamic
Steven Barth [Mon, 28 Jul 2014 19:48:26 +0000 (21:48 +0200)]
ubus: add del_dynamic as complement to add_dynamic

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agointerface: enable force_link by default for proto=static
Felix Fietkau [Sun, 27 Jul 2014 11:21:22 +0000 (13:21 +0200)]
interface: enable force_link by default for proto=static

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoproto-shell: fix renew_pending handling
Felix Fietkau [Sat, 26 Jul 2014 14:35:49 +0000 (16:35 +0200)]
proto-shell: fix renew_pending handling

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoproto-shell: fix setup/renew race condition
Felix Fietkau [Sat, 26 Jul 2014 01:46:39 +0000 (03:46 +0200)]
proto-shell: fix setup/renew race condition

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>
10 years agoOnly add dynamic interfaces if the underlying interface is ready
Steven Barth [Thu, 24 Jul 2014 22:01:50 +0000 (00:01 +0200)]
Only add dynamic interfaces if the underlying interface is ready

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agoproto-shell: don't accept up-notifications in teardown state
Steven Barth [Thu, 24 Jul 2014 19:18:00 +0000 (21:18 +0200)]
proto-shell: don't accept up-notifications in teardown state

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agointerface: fix restart after reload with external devices
Felix Fietkau [Thu, 24 Jul 2014 09:12:48 +0000 (11:12 +0200)]
interface: fix restart after reload with external devices

When an interface goes down, the main_dev is reset to NULL.
Track an externally added device separately to be able to bring it back
up.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agobridge: enable multicast querier functionality by default
Felix Fietkau [Thu, 24 Jul 2014 08:54:14 +0000 (10:54 +0200)]
bridge: enable multicast querier functionality by default

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoSet DEVICE for legacy ifupdate event as well
Steven Barth [Wed, 23 Jul 2014 16:06:47 +0000 (18:06 +0200)]
Set DEVICE for legacy ifupdate event as well

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agoMake dynamic interfaces always autostart
Steven Barth [Wed, 23 Jul 2014 16:04:47 +0000 (18:04 +0200)]
Make dynamic interfaces always autostart

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agoscripts: set type for the "key" attribute
Felix Fietkau [Fri, 18 Jul 2014 11:37:08 +0000 (13:37 +0200)]
scripts: set type for the "key" attribute

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agobridge: enable IGMP snooping by default
Felix Fietkau [Thu, 17 Jul 2014 14:56:14 +0000 (16:56 +0200)]
bridge: enable IGMP snooping by default

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: clean up l3 device reference on remove/reload
Felix Fietkau [Sun, 29 Jun 2014 21:27:29 +0000 (23:27 +0200)]
interface: clean up l3 device reference on remove/reload

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agobridge: enable multicast_to_unicast on all wireless bridge ports
Felix Fietkau [Sun, 29 Jun 2014 18:31:26 +0000 (20:31 +0200)]
bridge: enable multicast_to_unicast on all wireless bridge ports

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agodevice: fall back to simple interface status check if not provided by the device...
Felix Fietkau [Thu, 26 Jun 2014 10:17:46 +0000 (12:17 +0200)]
device: fall back to simple interface status check if not provided by the device type

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: fix indentation
Felix Fietkau [Thu, 26 Jun 2014 10:09:21 +0000 (12:09 +0200)]
interface: fix indentation

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoproto-shell: add debug msg for calling handlers
Felix Fietkau [Thu, 26 Jun 2014 10:07:24 +0000 (12:07 +0200)]
proto-shell: add debug msg for calling handlers

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agosystem-dummy: set present flags on all devices
Felix Fietkau [Thu, 26 Jun 2014 10:04:15 +0000 (12:04 +0200)]
system-dummy: set present flags on all devices

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: don't store table id in route if the default table is used
Steven Barth [Fri, 20 Jun 2014 17:50:13 +0000 (19:50 +0200)]
interface: don't store table id in route if the default table is used

Use system_is_default_rt_table() to test whether the resolved routing table
is the default one, in this case do not apply the table attribute to the
route object.

This is needed for backwards compatibility - only routes using a non-default
table shall report it in the ifstatus output.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agosystem: fix treatment of RT_TABLE_MAIN
Steven Barth [Fri, 20 Jun 2014 17:48:32 +0000 (19:48 +0200)]
system: fix treatment of RT_TABLE_MAIN

Do not treat RT_TABLE_MAIN as RT_TABLE_UNSPEC in system_resolve_rt_table() in
order to allow ip rules with lookup main to work as expected.

Provide a new function system_is_default_rt_table() to allow calling code to
specifically test for RT_TABLE_MAIN, this is going to be needed for the
backwards compatible handling of the table attribute in route objects.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agolinux: unify functions to delete links
Steven Barth [Wed, 18 Jun 2014 11:28:39 +0000 (13:28 +0200)]
linux: unify functions to delete links

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agonetifd: Route type support
Hans Dedecker [Wed, 18 Jun 2014 05:55:48 +0000 (05:55 +0000)]
netifd: Route type support

Patch adds route type support in netifd by means of the route parameter type.
By default the route type was unicast; the parameter adss support for local/broadcast/multicast/unicast routes which will be put into the appropriate routing table.
If route type parameter is unset the route type will be unicast as before.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Check device_claim return code in all cases
Hans Dedecker [Wed, 18 Jun 2014 05:55:47 +0000 (05:55 +0000)]
netifd: Check device_claim return code in all cases

Fixes observed issue a tunnel interface is reported as up although device_claim failed

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Fix ipip6 tunnel memleak in case of tunnel creation failure
Hans Dedecker [Wed, 18 Jun 2014 05:55:46 +0000 (05:55 +0000)]
netifd: Fix ipip6 tunnel memleak in case of tunnel creation failure

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Fix macvlan delete via netlink
Hans Dedecker [Wed, 18 Jun 2014 07:41:14 +0000 (07:41 +0000)]
netifd: Fix macvlan delete via netlink

Fix macvlan delete via netlink as netlink attribute IFLA_IFNAME data size was incorrect (size reject by the kernel) and NLM_F_REQUEST flag was missing.
In addition some minor improvements (attribute IFLA_INFO_KIND can be left out as RTM_DELLINK does not require the attribute)

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Fix vlan delete via netlink
Hans Dedecker [Wed, 18 Jun 2014 05:55:44 +0000 (05:55 +0000)]
netifd: Fix vlan delete via netlink

Fix vlan delete via netlink as netlink attribute IFLA_IFNAME data size was incorrect.
In addition some minor improvements.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agoReorder alfabetically device type matching as they are growing in number
Gioacchino Mazzurco [Tue, 10 Jun 2014 17:29:14 +0000 (19:29 +0200)]
Reorder alfabetically device type matching as they are growing in number

Signed-off-by: Gioacchino Mazzurco <gmazzurco89@gmail.com>
10 years agoAdd vlan 802.1q/802.1ad support as netifd devices
Gioacchino Mazzurco [Tue, 10 Jun 2014 17:29:13 +0000 (19:29 +0200)]
Add vlan 802.1q/802.1ad support as netifd devices

At moment netifd supports just 802.1q vlan, you can configure them using a concise but "hacky"
syntax using an interface config section, with this patch netifd acquire the capability
of configuring 802.1ad and 802.1q vlan using config device sections, so you can define a vlan device
plus interface with something like this:

config device 'test'
        option type '8021ad'
        option name 'test'
        option ifname 'eth0'
        option vid '1000'

config interface 'testif'
        option ifname 'test'
        option proto 'none'
        option auto '1'

old syntax for 802.1q keeps working so no retrocompatibility problems,
to keep retrocompatibility means also that user must not use name/ifname like eth0.2
for devices declared with the new style because this would trigger the "old style"
when interface config section is parsed

Signed-off-by: Gioacchino Mazzurco <gmazzurco89@gmail.com>
10 years agoAdd qtcreator and kdevelop4 project files to .gitignore
Gioacchino Mazzurco [Tue, 10 Jun 2014 17:29:12 +0000 (19:29 +0200)]
Add qtcreator and kdevelop4 project files to .gitignore

Signed-off-by: Gioacchino Mazzurco <gmazzurco89@gmail.com>
10 years agonetifd: process reload calls immediately instead of going through a timer
Felix Fietkau [Wed, 11 Jun 2014 10:18:46 +0000 (12:18 +0200)]
netifd: process reload calls immediately instead of going through a timer

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoAdd support for onlink-flags for IPv4 routes
Steven Barth [Tue, 10 Jun 2014 15:59:16 +0000 (17:59 +0200)]
Add support for onlink-flags for IPv4 routes

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agoadd a interface. prefix to ubus_notify calls
John Crispin [Wed, 4 Jun 2014 17:57:16 +0000 (18:57 +0100)]
add a interface. prefix to ubus_notify calls

Signed-off-by: John Crispin <blogic@openwrt.org>
10 years agomacvlan: fix missing reference to device_attr_list
Gioacchino Mazzurco [Wed, 28 May 2014 20:44:21 +0000 (22:44 +0200)]
macvlan: fix missing reference to device_attr_list

At moment macvlan devices ignore options inherited as device like mtu.

Thanks to suggestions provided by Felix i have done this patch that fix this
iussue by adding the missing reference to device_attr_list in
macvlan_attr_list

Signed-off-by: Gioacchino Mazzurco <gmazzurco89@gmail.com>
10 years agoRewrite ipip6-tunnel setup to use netlink and add support for FMRs
Steven Barth [Wed, 21 May 2014 19:25:50 +0000 (21:25 +0200)]
Rewrite ipip6-tunnel setup to use netlink and add support for FMRs

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agoFix a spurious segfault when tearing down interfaces
Steven Barth [Wed, 21 May 2014 19:24:41 +0000 (21:24 +0200)]
Fix a spurious segfault when tearing down interfaces

Signed-off-by: Steven Barth <steven@midlink.org>
10 years agowireless: fix cancelling setup
Felix Fietkau [Thu, 15 May 2014 19:08:18 +0000 (21:08 +0200)]
wireless: fix cancelling setup

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agosystem-linux: always set the ifindex for hotplug devices on init
Felix Fietkau [Sat, 10 May 2014 18:03:22 +0000 (20:03 +0200)]
system-linux: always set the ifindex for hotplug devices on init

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agonetifd: Fix node version set after free
Hans Dedecker [Wed, 7 May 2014 09:19:09 +0000 (09:19 +0000)]
netifd: Fix node version set after free

Fixes an issue where a bridge member will be removed from the bridge
upon an interface ifup as the bridge node version -1 is overwritten
by vlist_add while the new created bridge member pointer is freed in
bridge_member_update

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Check interface state only when main device is set during interface_change_config
Hans Dedecker [Wed, 7 May 2014 09:19:08 +0000 (09:19 +0000)]
netifd: Check interface state only when main device is set during interface_change_config

Fixes a regression issue introduced by commit d2a33f3f0fe704e4396fa2ada08401cb955ba7cb for device less protocol handlers.
An active interface using a deviceless protocol handler will be be teared down when the interface config is checked upon
an update as the interface link and enabled parameters are unset as no underlying device is present (eg tunnel interfaces)

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Effectively apply configured route mtu
Hans Dedecker [Wed, 7 May 2014 09:19:07 +0000 (09:19 +0000)]
netifd: Effectively apply configured route mtu

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Remove useless route table parameter check in update_proto_route
Hans Dedecker [Wed, 7 May 2014 09:19:06 +0000 (09:19 +0000)]
netifd: Remove useless route table parameter check in update_proto_route

Not necessary since route table parameter is used as key element in route_cmp

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Don't assume routes are always applied in all cases
Hans Dedecker [Wed, 7 May 2014 09:19:05 +0000 (09:19 +0000)]
netifd: Don't assume routes are always applied in all cases

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Apply interface metric on configured interface gateway parameters
Hans Dedecker [Wed, 7 May 2014 09:19:04 +0000 (09:19 +0000)]
netifd: Apply interface metric on configured interface gateway parameters

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agodevice: prevent interface up/down calls for external devices
Felix Fietkau [Tue, 6 May 2014 18:02:00 +0000 (20:02 +0200)]
device: prevent interface up/down calls for external devices

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: clear iface->available before changing main_dev
Felix Fietkau [Fri, 2 May 2014 17:04:42 +0000 (19:04 +0200)]
interface: clear iface->available before changing main_dev

Fixes bogus interface restart loop on interface_remove_link

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: use interface_set_main_dev() from interface_remove_link
Felix Fietkau [Fri, 2 May 2014 17:07:18 +0000 (19:07 +0200)]
interface: use interface_set_main_dev() from interface_remove_link

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface: do not set l3_dev along with main_dev anymore
Felix Fietkau [Fri, 2 May 2014 17:03:48 +0000 (19:03 +0200)]
interface: do not set l3_dev along with main_dev anymore

Made unnecessary by recent fixes to l3_dev handling

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agointerface-ip: fix misuse of IN6_IS_ADDR_LINKLOCAL on a netifd specific union
Felix Fietkau [Tue, 29 Apr 2014 13:24:48 +0000 (15:24 +0200)]
interface-ip: fix misuse of IN6_IS_ADDR_LINKLOCAL on a netifd specific union

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agonetifd: fix a use-after-free issue on wireless config update
Felix Fietkau [Tue, 29 Apr 2014 13:16:21 +0000 (15:16 +0200)]
netifd: fix a use-after-free issue on wireless config update

After vlist_add() the device could have been freed

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agonetifd: Add interface config support to enable/disable IPv6 in the kernel per device
Hans Dedecker [Mon, 7 Apr 2014 11:30:52 +0000 (13:30 +0200)]
netifd: Add interface config support to enable/disable IPv6 in the kernel per device

Main use case is being able to disable IPv6 on (a) WAN interface(s) when only IPv4 connectivity is offered or 6rd is used.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agointerface-event: make eventnames static and const
Felix Fietkau [Wed, 23 Apr 2014 09:44:09 +0000 (11:44 +0200)]
interface-event: make eventnames static and const

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agonetifd: Rework hotplug event queueing in case of congestion
Hans Dedecker [Mon, 7 Apr 2014 11:30:51 +0000 (13:30 +0200)]
netifd: Rework hotplug event queueing in case of congestion

In case of event congestion (e.g. when several interfaces become active in a short notice) :
-hotplug events will be handled on a first come first served basis (before it was lifo)
-drop a new ifupdate event in favour of an already queued ifup event (before the ifup event was overwritten by the ifupdate event resulting in some hotplug scripts "missing" the ifup event)

Additonal the event flow has been documented

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Signed-off-by: Joeri Barbarien <joeri.barbarien@gmail.com>
10 years agonetifd: Check rt_table parameter when comparing routes
Hans Dedecker [Mon, 7 Apr 2014 11:30:50 +0000 (13:30 +0200)]
netifd: Check rt_table parameter when comparing routes

Allows to add identical routes in different routing tables

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Set prefix assignment enabled if the prefix adress can be installed
Hans Dedecker [Thu, 24 Apr 2014 07:51:16 +0000 (07:51 +0000)]
netifd: Set prefix assignment enabled if the prefix adress can be installed

No need to install policy routes if the prefix address cannot be installed; clean up of the policy routes
and the prefix address only needs to happen when the prefix assignment was active.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: Mark interface as dynamic after it has been added in the interface list
Hans Dedecker [Thu, 24 Apr 2014 07:51:15 +0000 (07:51 +0000)]
netifd: Mark interface as dynamic after it has been added in the interface list

Adding an interface in the interface list in case of a config update will override the node version of the old interface and thus overriding the dynamic interface marker.
In case of config update interface_set_dynamic is done on an invalid interface pointer as the new interface pointer has been freed.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
10 years agonetifd: fix IPv6 Link-local DNS server
Ulrich Weber [Wed, 23 Apr 2014 12:33:04 +0000 (12:33 +0000)]
netifd: fix IPv6 Link-local DNS server

interface name must be added to Link-local IPv6
DNS servers, otherwise they are unusable.

Signed-off-by: Ulrich Weber <uw@ocedo.com>