oweals/netifd.git
9 years agoiprule: Insert network and address ip rules before main table lookup rule
Hans Dedecker [Wed, 9 Sep 2015 13:45:48 +0000 (15:45 +0200)]
iprule: Insert network and address ip rules before main table lookup rule

Specific IP address and network rules are now checked before the main table lookup as the main table
often holds a default route. As a result the IP address and network rules pointing to a specific
routing table will not be checked anymore; by reversing the order the specific routing tables
are checked first if the ip rule matches.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agodevice: Resolve ifindex for external claimed devices
Hans Dedecker [Wed, 9 Sep 2015 13:45:47 +0000 (15:45 +0200)]
device: Resolve ifindex for external claimed devices

Fixes regression issues introduced by commit 3224b80 as external (PPP)
device ifindex was not in sync with kernel device ifindex due to re-creation
of the device by the PPP daemon

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agodevice: Don't call set_state for external device in device_claim
Hans Dedecker [Tue, 1 Sep 2015 12:43:58 +0000 (14:43 +0200)]
device: Don't call set_state for external device in device_claim

The function set_state disable is not called for external devices in device_release
which means for external vlan/macvlan devices they won't be deleted.
As a result of this the set_state enable call for external devices by device_claim fails
as vlan/macvlan devices cannot be created since the device already exists in the kernel.
Therefore move the external device check from device_set_state to device_claim so
external vlan/macvlan devices are not created again and can also be external.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agodevice: apply settings when existing device becomes external
Hans Dedecker [Tue, 1 Sep 2015 12:43:57 +0000 (14:43 +0200)]
device: apply settings when existing device becomes external

Make sure device settings are applied when existing device becomes external

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agobridge: Allow setting multicast_router option
Linus Lüssing [Sun, 23 Aug 2015 15:19:28 +0000 (17:19 +0200)]
bridge: Allow setting multicast_router option

The multicast_router option of a bridge allows to control the forwarding
behaviour of multicast packets independant of the listener state:

* 0: Only forward if specific listener is present
* 1 (default): Forward if specific listener or a multicast router
  was detected (currently only learned via query messages, no MRD
  support yet)
* 2: Always forward any multicast traffic on this port

Since MRD is not mandated you might end up with silent multicast routers
(e.g. if your link has more than one multicast router; only one can
become the selected, "noisy" querier). Here you might need a manual
configuration option like the "multicast_router" option.

Other scenarios where this can be useful are for instance:
* Segmentation of IGMP/MLD domains together with ebtables
* Dedicated bridge port for monitoring/debugging purposes

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
9 years agobridge: Allow setting multicast_to_unicast option
Linus Lüssing [Sun, 23 Aug 2015 15:19:27 +0000 (17:19 +0200)]
bridge: Allow setting multicast_to_unicast option

With this patch the multicast_to_unicast feature can be disabled for all
wireless interfaces via an according option on the uci bridge interface.

This patch also exports the setting information to wireless handler
scripts. The hostapd script will need that information to determine
whether to enable or disable ap-isolation, for instance.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
9 years agobridge: Fix multicast_to_unicast feature by hairpin+isolate
Linus Lüssing [Sun, 23 Aug 2015 15:19:26 +0000 (17:19 +0200)]
bridge: Fix multicast_to_unicast feature by hairpin+isolate

All IGMP and MLD versions suffer from a specific limitation (from a
snooping switch perspective): Report suppression.

Once a listener hears an IGMPv2/3 or MLDv1 report for the same group
itself participates in then it might (if this listener is an IGMPv3 or
MLDv2 listener) or will (if this is an IGMPv1/2 or MLDv1 listener)
refrain from sending its own report.

Therefore we might currently miss such surpressing listeners as they
won't receive the multicast packet with the mangled, unicasted
destination.

Fixing this by first isolating the STAs and giving the bridge more
control over traffic forwarding. E.g. refraining to forward listener
reports to other STAs.

For broadcast and unicast traffic to an STA on the same AP, the hairpin
feature of the bridge will reflect such traffic back to the AP
interface. However, if the AP interface is actually configured to
isolate STAs, then hairpin is kept disabled.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
9 years agoproto-shell: add checkup timeout to restart interface.
Yousong Zhou [Fri, 21 Aug 2015 02:11:57 +0000 (10:11 +0800)]
proto-shell: add checkup timeout to restart interface.

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>
9 years agoChanges for more readability.
Yousong Zhou [Fri, 21 Aug 2015 02:11:56 +0000 (10:11 +0800)]
Changes for more readability.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agonetifd: Spawn device events when registering dependency in device_replace
Hans Dedecker [Tue, 4 Aug 2015 14:22:45 +0000 (16:22 +0200)]
netifd: Spawn device events when registering dependency in device_replace

Spawn device events when adding dependency in device_replace so the dependency installer gets
the actual device status

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: Remove obsolete device_set_present in device_replace
Hans Dedecker [Tue, 4 Aug 2015 14:22:44 +0000 (16:22 +0200)]
netifd: Remove obsolete device_set_present in device_replace

New device does not need to be set present as device_check_state called via device_init
sets the device present after probing the kernel device

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: Fix device usage after free
Hans Dedecker [Tue, 4 Aug 2015 14:22:43 +0000 (16:22 +0200)]
netifd: Fix device usage after free

Prevent new device from being freed in device_replace when
device_unlock is called along the function chain triggered
by setting the old device as not present

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: Fix SEG fault when device cannot be allocated
Hans Dedecker [Tue, 4 Aug 2015 14:22:42 +0000 (16:22 +0200)]
netifd: Fix SEG fault when device cannot be allocated

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agodevice: apply initial settings when creating an external device
Felix Fietkau [Sat, 18 Jul 2015 23:09:56 +0000 (01:09 +0200)]
device: apply initial settings when creating an external device

Fixes RPS/XPS settings for wlan devices

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agonetifd: Add dadtransmits config option
Hans Dedecker [Thu, 25 Jun 2015 10:38:52 +0000 (12:38 +0200)]
netifd: Add dadtransmits config option

Config option dadtransmits allows to configure the amount of
Duplicate Address Detection probes to be sent

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agoAdd mtu6 option to override IPv6 MTU
Steven Barth [Wed, 24 Jun 2015 11:02:37 +0000 (13:02 +0200)]
Add mtu6 option to override IPv6 MTU

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agoproto-shell: add support for generic host-dependencies to interfaces
Steven Barth [Wed, 10 Jun 2015 18:36:17 +0000 (20:36 +0200)]
proto-shell: add support for generic host-dependencies to interfaces

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agoFix removal of dynamic interfaces
Steven Barth [Mon, 8 Jun 2015 11:02:00 +0000 (13:02 +0200)]
Fix removal of dynamic interfaces

Also remove obsolete "del_dynamic" call (use "down" instead)

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: Add old style vlan devices to device list
Hans Dedecker [Tue, 26 May 2015 12:41:47 +0000 (14:41 +0200)]
netifd: Add old style vlan devices to device list

Just like other device types old vlan style devices are added to
the device list which means they're displayed when the device list
is displayed via ubus.
Additionally global device setting config like default packet
steering behavior is now also applied for old style vlan devices
when doing a network reload.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agobridge: allow setting hash_max value
Linus Lüssing [Tue, 26 May 2015 19:49:11 +0000 (21:49 +0200)]
bridge: allow setting hash_max value

If the number of entries in the MDB exceeds hash_max then the
multicast snooping capabilities of the bridge are disabled
automatically.

The default value for hash_max is 512 which is already exceeded by some
wireless community mesh networks. They need to be able to set a higher
value.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
9 years agouclibc: backwards-compatibility fixes
Steven Barth [Tue, 26 May 2015 11:59:02 +0000 (13:59 +0200)]
uclibc: backwards-compatibility fixes

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agolinux: more IPv6 onlink-route handling fixes / improvements
Steven Barth [Tue, 26 May 2015 11:51:52 +0000 (13:51 +0200)]
linux: more IPv6 onlink-route handling fixes / improvements

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agointerface: teardown on l3_dev link lost.
Yousong Zhou [Tue, 19 May 2015 12:38:33 +0000 (20:38 +0800)]
interface: teardown on l3_dev link lost.

This is mainly for shell protocols that has no_proto_task so that we can
still teardown and setup the interface on l3_dev link lost instead of
depending on running state of proto_task.

Also rename related callbacks for better clarification.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoproto-shell: simplify no_proto_task assignment
Felix Fietkau [Sat, 23 May 2015 14:42:20 +0000 (16:42 +0200)]
proto-shell: simplify no_proto_task assignment

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoproto-shell: allow running protocols without proto_task.
Yousong Zhou [Tue, 19 May 2015 12:38:32 +0000 (20:38 +0800)]
proto-shell: allow running protocols without proto_task.

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>
9 years agointerface: minor fix for unnecessary ++ operation.
Yousong Zhou [Tue, 19 May 2015 12:38:31 +0000 (20:38 +0800)]
interface: minor fix for unnecessary ++ operation.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agointerface: remove redundant iface_attr_info.
Yousong Zhou [Tue, 19 May 2015 12:38:30 +0000 (20:38 +0800)]
interface: remove redundant iface_attr_info.

BLOBMSG_TYPE_STRING is the default type for elements of
BLOBMSG_TYPE_ARRAY.  Array type IFACE_ATTR_DNS_SEARCH was already
missing there, so drop the whole part anyway.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agosystem: fix typo in returning address length.
Yousong Zhou [Tue, 19 May 2015 12:38:29 +0000 (20:38 +0800)]
system: fix typo in returning address length.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agolinux: add compat-define for IFA_F_NOPREFIXROUTE
Steven Barth [Tue, 19 May 2015 09:01:27 +0000 (11:01 +0200)]
linux: add compat-define for IFA_F_NOPREFIXROUTE

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agoipv6: use kernel >= 3.14 handling of offlink-addresses
Steven Barth [Tue, 19 May 2015 08:58:34 +0000 (10:58 +0200)]
ipv6: use kernel >= 3.14 handling of offlink-addresses

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: Support for configurable default packet steering behavior
Hans Dedecker [Tue, 12 May 2015 11:11:52 +0000 (13:11 +0200)]
netifd: Support for configurable default packet steering behavior

The default packet steering behavior can be configured via the parameter
default_ps in the global section; the default value is true to keep
backwards compatibility.
Device packet steering (rps/xps) config can still be used to override the
default behavior.
This allows you to disable packet steering for all devices without the need
to define a device config list which disables receive/transmit packet steering

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agoproto-shell: retry setup if the proto handler script quits without changing the state...
Felix Fietkau [Tue, 21 Apr 2015 12:09:48 +0000 (14:09 +0200)]
proto-shell: retry setup if the proto handler script quits without changing the state or starting a process

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agointerface: remove obsolete device config apply code
Felix Fietkau [Sun, 19 Apr 2015 09:50:19 +0000 (11:50 +0200)]
interface: remove obsolete device config apply code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agointerface: allow an interface to specify device configs even when there are other...
Felix Fietkau [Sun, 19 Apr 2015 09:49:51 +0000 (11:49 +0200)]
interface: allow an interface to specify device configs even when there are other interfaces attached to the same device

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agonetifd: fix an uninitialized variable
Felix Fietkau [Sun, 19 Apr 2015 09:32:27 +0000 (11:32 +0200)]
netifd: fix an uninitialized variable

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: add support for removing interface config on reload
Felix Fietkau [Sat, 18 Apr 2015 21:27:15 +0000 (23:27 +0200)]
device: add support for removing interface config on reload

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agointerface: detect and handle changes in device config
Felix Fietkau [Sat, 18 Apr 2015 21:26:51 +0000 (23:26 +0200)]
interface: detect and handle changes in device config

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoutils.h: remove leftover commented out code
Felix Fietkau [Fri, 17 Apr 2015 19:25:36 +0000 (21:25 +0200)]
utils.h: remove leftover commented out code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: remove DEV_ATTR_IFNAME, it is unused
Felix Fietkau [Fri, 17 Apr 2015 19:24:29 +0000 (21:24 +0200)]
device: remove DEV_ATTR_IFNAME, it is unused

Ensures that interfaces with only 'ifname' matching the device config
don't cause iface->device_config to be set

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoCleanup issues reported by scan-build
Steven Barth [Tue, 14 Apr 2015 06:45:26 +0000 (08:45 +0200)]
Cleanup issues reported by scan-build

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: Interface last error support
Hans Dedecker [Wed, 8 Apr 2015 14:20:22 +0000 (16:20 +0200)]
netifd: Interface last error support

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>
9 years agoRevert "linux: adjust default policy rules"
Steven Barth [Tue, 31 Mar 2015 13:12:53 +0000 (15:12 +0200)]
Revert "linux: adjust default policy rules"

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: add metric argument for proto_add_ipv4_route
Steven Barth [Tue, 31 Mar 2015 11:32:31 +0000 (13:32 +0200)]
netifd: add metric argument for proto_add_ipv4_route

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agolinux: adjust default policy rules
Steven Barth [Fri, 27 Mar 2015 14:15:59 +0000 (15:15 +0100)]
linux: adjust default policy rules

9 years agobridge: allow enabling or disabling the multicast querier independently of IGMP snooping
Matthias Schiffer [Tue, 27 Jan 2015 02:49:52 +0000 (03:49 +0100)]
bridge: allow enabling or disabling the multicast querier independently of IGMP snooping

In larger networks, especially big batman-adv meshes, it may be desirable to
enable IGMP snooping on every bridge without enabling the multicast querier
to specifically put the querier on a well-connected node.

This patch adds a new UCI option 'multicast_querier' for bridges which allows
this. The default is still the value of the 'igmp_snooping' option to maintain
backwards compatiblity.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
9 years agodevice: fix default initialization for RPS/XPS
Felix Fietkau [Sun, 22 Mar 2015 17:09:49 +0000 (18:09 +0100)]
device: fix default initialization for RPS/XPS

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: add support for configuring RPS/XPS (enabled by default if available)
Felix Fietkau [Sun, 22 Mar 2015 16:41:26 +0000 (17:41 +0100)]
device: add support for configuring RPS/XPS (enabled by default if available)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoFix regression with IPv6 source-dest-routes
Steven Barth [Sat, 21 Mar 2015 18:20:24 +0000 (19:20 +0100)]
Fix regression with IPv6 source-dest-routes

9 years agoadd missing argument for ipv4 routes
Steven Barth [Thu, 19 Mar 2015 17:30:02 +0000 (18:30 +0100)]
add missing argument for ipv4 routes

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agoAdd table argument to shell API for routes
Steven Barth [Thu, 19 Mar 2015 17:28:30 +0000 (18:28 +0100)]
Add table argument to shell API for routes

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agoadd prelocal table to manipulate locally destinated traffic
Steven Barth [Thu, 19 Mar 2015 17:13:33 +0000 (18:13 +0100)]
add prelocal table to manipulate locally destinated traffic

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd:Make sure interface device config is also cached
Hans Dedecker [Wed, 18 Mar 2015 15:54:48 +0000 (16:54 +0100)]
netifd:Make sure interface device config is also cached

Fixes issue interface device config is not applied in some cases.
As the interface device config was applied but not always cached;
an interface device config diff was not always detected.

Simplify device config setting by exposing as api only device_apply_config

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: fixes for json-c 0.12
John Crispin [Thu, 5 Mar 2015 18:44:31 +0000 (19:44 +0100)]
netifd: fixes for json-c 0.12

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agowireless: fix teardown, always pass the previous config to the teardown handler inste...
Felix Fietkau [Sat, 28 Feb 2015 07:36:08 +0000 (20:36 +1300)]
wireless: fix teardown, always pass the previous config to the teardown handler instead of the new one

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agonetifd: Set interface device config when device has old settings
Hans Dedecker [Thu, 12 Feb 2015 16:41:17 +0000 (17:41 +0100)]
netifd: Set interface device config when device has old settings

If interface device settings are removed in UCI they were not removed in the
device settings; calling device_set_config when device settings are present
solves this.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: Keep reference to a config copy in device type specific reload handler as...
Hans Dedecker [Thu, 12 Feb 2015 16:41:16 +0000 (17:41 +0100)]
netifd: Keep reference to a config copy in device type specific reload handler as the original config pointer might go stale

Fixes random observed crashes in blobmsg_parse when device type specific
config data is parsed.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: Fix possible hotplug race conditions
Hans Dedecker [Thu, 12 Feb 2015 16:41:15 +0000 (17:41 +0100)]
netifd: Fix possible hotplug race conditions

Don't drop ifup/ifdown events in case an interface event is cached
as it leads to possible race conditions (eg firewall not being
reloaded as ifup is dropped) when multiple interface events are fired
in a short timeframe (eg multiple PPP link flaps).
Always overwrite the cached interface event except for the
interface update event so the hotplug scripts are launched
with the last known status.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agoutils.c: add missing include
Felix Fietkau [Mon, 16 Feb 2015 09:05:01 +0000 (20:05 +1100)]
utils.c: add missing include

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoRevert "interface: do not set device_config where only the ifname option matches"
Felix Fietkau [Mon, 16 Feb 2015 09:00:58 +0000 (20:00 +1100)]
Revert "interface: do not set device_config where only the ifname option matches"

This reverts commit 8dd2eedafccc9f898d391b93a59efb1412c5b5e9.
This commit was reported to cause a regression with setting MTU on
interfaces.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agonetifd: Add option to configure base_reachable_time_ms for each device
Hans Dedecker [Mon, 2 Feb 2015 15:11:24 +0000 (16:11 +0100)]
netifd: Add option to configure base_reachable_time_ms for each device

The UCI parameter neighreachabletime allows to control the hardware address
to IP mapping lifetime in the neighbour table for both IPv4 and IPv6

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Signed-off-by: Jean-Francois Remy <jeff@melix.org>
9 years agonetifd: Remove unnecessary default_config check in config_parse_interface
Hans Dedecker [Mon, 2 Feb 2015 15:11:23 +0000 (16:11 +0100)]
netifd: Remove unnecessary default_config check in config_parse_interface

No need to check default_config twice as it's already checked in config_parse_interface

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: set current_config for simple devices when parsing device config
Hans Dedecker [Mon, 2 Feb 2015 15:11:22 +0000 (16:11 +0100)]
netifd: set current_config for simple devices when parsing device config

If currrent_config is not set when the simple device config is applied the
device will be deleted in device_reset_old

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agoRevert "vlan: reset device state on init"
Felix Fietkau [Sat, 24 Jan 2015 14:17:02 +0000 (15:17 +0100)]
Revert "vlan: reset device state on init"

This is causing a regression with some VLAN configurations

This reverts commit a4445215e06ee3056427effbef617f4525ee1836.

9 years agodevice: force changes to be applied via state change if necessary
Felix Fietkau [Sat, 24 Jan 2015 00:28:39 +0000 (01:28 +0100)]
device: force changes to be applied via state change if necessary

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agointerface: suppress unnecessary device config overrides
Felix Fietkau [Sat, 24 Jan 2015 00:16:25 +0000 (01:16 +0100)]
interface: suppress unnecessary device config overrides

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agointerface: apply device config passed through interface config
Felix Fietkau [Sat, 24 Jan 2015 00:02:57 +0000 (01:02 +0100)]
interface: apply device config passed through interface config

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: simplify config blob memory allocation handling
Felix Fietkau [Sat, 24 Jan 2015 00:09:23 +0000 (01:09 +0100)]
device: simplify config blob memory allocation handling

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agointerface: do not set device_config where only the ifname option matches
Felix Fietkau [Fri, 23 Jan 2015 23:53:28 +0000 (00:53 +0100)]
interface: do not set device_config where only the ifname option matches

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agovlan: reset device state on init
Felix Fietkau [Fri, 23 Jan 2015 23:47:13 +0000 (00:47 +0100)]
vlan: reset device state on init

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: apply config changes from device sections
Felix Fietkau [Fri, 23 Jan 2015 23:42:20 +0000 (00:42 +0100)]
device: apply config changes from device sections

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: move config apply handling to a helper function
Felix Fietkau [Fri, 23 Jan 2015 23:36:55 +0000 (00:36 +0100)]
device: move config apply handling to a helper function

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: set dev->default_config to false for devices parsed from config
Felix Fietkau [Fri, 23 Jan 2015 22:54:19 +0000 (23:54 +0100)]
device: set dev->default_config to false for devices parsed from config

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agodevice: add support for specifying a configuration for simple vlan devices
Felix Fietkau [Fri, 23 Jan 2015 22:20:29 +0000 (23:20 +0100)]
device: add support for specifying a configuration for simple vlan devices

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agobridge: fix retrying member enable when the bridge is otherwise empty
Felix Fietkau [Fri, 23 Jan 2015 11:41:56 +0000 (12:41 +0100)]
bridge: fix retrying member enable when the bridge is otherwise empty

Ensure that the bridge gets created before retrying

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agobridge: mark tested members as present during enable retry
Felix Fietkau [Fri, 23 Jan 2015 11:41:07 +0000 (12:41 +0100)]
bridge: mark tested members as present during enable retry

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agobridge: release failed member devices
Felix Fietkau [Fri, 23 Jan 2015 11:34:12 +0000 (12:34 +0100)]
bridge: release failed member devices

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agonetifd: Make interface identifier of delegated IPv6 address configurable
Hans Dedecker [Mon, 12 Jan 2015 19:07:55 +0000 (20:07 +0100)]
netifd: Make interface identifier of delegated IPv6 address configurable

The ip6ifaceid UCI interface parameter makes the interface identifier of the delegated IPv6 address configurable.
The parameter can have the following values:
    eui64 : Interface identifier is generated from the interface's MAC address
    random : Interface identifier is generated randomly
    fixed value : Interface identifier is a fixed value (eg ::1:2)

The latter is the default value with a fixed value of ::1 for backwards compatibility

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Signed-off-by: Joeri Barbarien <joeri.barbarien@gmail.com>
9 years agohandler: replace calls to deprecated json_object_object_get
Steven Barth [Tue, 23 Dec 2014 13:29:47 +0000 (14:29 +0100)]
handler: replace calls to deprecated json_object_object_get

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: Add mldversion config support
Steven Barth [Tue, 23 Dec 2014 13:12:32 +0000 (14:12 +0100)]
netifd: Add mldversion config support

Config support to set the MLD host version on device level; possible values are :
    1 : MLDv1
    2 : MLDv2

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Cleaned up and simplified.

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: Handle link down event in interface setup state as well
Hans Dedecker [Mon, 22 Dec 2014 14:46:16 +0000 (15:46 +0100)]
netifd: Handle link down event in interface setup state as well

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agoEnable callers to pass the source IP of an IPv4 route when using
Kristian Evensen [Mon, 8 Dec 2014 17:42:21 +0000 (18:42 +0100)]
Enable callers to pass the source IP of an IPv4 route when using
proto_add_ipv4_route(). This is useful with for example DHCP in a multihomed
scenario, as it provides an easy way to match default routes with the correct IP
address. One use case for this are applications that monitor the state of the
WAN port, and the WAN port is assigned multiple addresses.

Signed-off-by: Kristian Evensen <kristian.evensen at gmail.com>
9 years agonetifd: Add igmpversion config support
Hans Dedecker [Thu, 4 Dec 2014 12:07:18 +0000 (12:07 +0000)]
netifd: Add igmpversion config support

Config support to set the IGMP host version on device level; possible values are :
    1 : IGMPv1
    2 : IGMPv2
    3 : IGMPv3

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Cleand up and simplified

Signed-off-by: Steven Barth <steven@midlink.org>
9 years agonetifd: Fix interface auto disable when doing network reload
Hans Dedecker [Thu, 4 Dec 2014 12:07:19 +0000 (12:07 +0000)]
netifd: Fix interface auto disable when doing network reload

Keep interface down when interface auto parameter is set to 0 when doing network reload

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agonetifd: Make possible state transitions more clear when handling teardown event
Hans Dedecker [Thu, 4 Dec 2014 12:07:17 +0000 (12:07 +0000)]
netifd: Make possible state transitions more clear when handling teardown event

Improve code readibility regarding state transitions when handling teardown event

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
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>
9 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>
9 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>