summaryrefslogtreecommitdiff
path: root/config.c
Commit message (Collapse)AuthorAgeFilesLines
* netifd: rework/fix device free handlingFelix Fietkau2021-09-271-3/+0
| | | | | | | | | Instead of explicitly preventing free in specific code sections using device_lock/device_unlock, defer all device free handling via uloop timeout This avoids an entire class of lurking use-after-free bugs triggered by device event processing and simplifies the code Signed-off-by: Felix Fietkau <nbd@nbd.name>
* config: fix ifname->ports compat renameFelix Fietkau2021-05-201-4/+11
| | | | | | | Instead of looking it up as a string, use uci_rename. That way it works both on list and string options Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge: rename "ifname" attribute to "ports"Rafał Miłecki2021-05-181-1/+22
| | | | | | | | | | | | | | Bridge aggregates multiple ports so use a more accurate name ("ports"). For backward compatibility add a temporary config translation. Config example: config interface 'lan' option type 'bridge' list ports 'lan1' list ports 'lan2' Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* config: parse default mac address from board.jsonFelix Fietkau2020-11-301-0/+56
| | | | | | | | | | | | | Example: { "network-device": { "eth0": { "macaddr": "bc:a5:11:16:76:d7" } } } Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge-vlan: add support for defining aliases for vlan idsFelix Fietkau2020-11-201-0/+6
| | | | | | | | | | | | | | | When defining a bridge-vlan like this: config bridge-vlan option device 'switch0' option vlan '1' option ports 'lan1 lan2 lan3 lan4' option alias 'lan' You can use switch0.lan instead of switch0.1 to refer to the VLAN. This ensures that the VLAN ID can be kept in a single place in the config Signed-off-by: Felix Fietkau <nbd@nbd.name>
* config: initialize bridge and bridge vlans before other devicesFelix Fietkau2020-11-181-3/+7
| | | | | | | This allows vlan devices to access bridge vlan data safely, regardless of the order in which sections appear in the config Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge: only overwrite implicit vlan assignment if vlans are configuredFelix Fietkau2020-11-051-6/+16
| | | | | | | | | When VLAN filtering is enabled, but no vlans are defined, the implicit VLANs should stay, so that forwarding between ports still works. This is useful for setups where VLANs are assigned by external scripts instead of being configured via netifd Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge: add support for defining port member vlans via hotplug opsFelix Fietkau2020-10-281-0/+1
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* config: enable bridge vlan filtering by default for bridges that define VLANsFelix Fietkau2020-07-191-0/+47
| | | | | | Only enables it if the config option is not present. It can still be disabled. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge: add support for VLAN filteringFelix Fietkau2020-07-191-0/+122
| | | | | | | | | | | | | | | | | VLANs can be defined using bridge-vlan sections, like the following example: config bridge-vlan option device 'switch0' option vlan '1' option ports "lan1 lan2 lan3 lan4:t*" Each member port can be confgured with optional attributes after ':' - t: member port is tagged - *: This is the primary VLAN for the port (PVID) VLAN member interfaces are automatically added as bridge members Signed-off-by: Felix Fietkau <nbd@nbd.name>
* netifd: wireless: add support for tracking wifi-station sectionsJohn Crispin2020-06-041-0/+29
| | | | | | | This new section allows us to assign mac specific key/vid settings to a station. Signed-off-by: John Crispin <john@phrozen.org>
* netifd: wireless: add support for tracking wifi-vlan sectionsJohn Crispin2020-06-041-4/+38
| | | | | | This new section allows us to create apvlan settings for hostapd. Signed-off-by: John Crispin <john@phrozen.org>
* interface: add neighbor config supportmeurisa2019-04-151-2/+17
| | | | | | | | | | | | | | | | | | The neighbor or neighbor6 network section makes neighbours configurable via UCI or proto shell handlers. It allows to install neighbor proxy entries or static neighbor entries The neighbor or neighbor6 section has the following types: interface : declares the logical OpenWrt interface ipaddr : the ip address of the neighbor mac : the mac address of the neighbor proxy : specifies whether the neighbor ia a proxy entry (can be 1 or 0) router : specifies whether the neighbor is a router (can be 1 or 0) Signed-off-by: Alexander Meuris <meurisalexander@gmail.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* config: fix resource leaks on error in config_parse_interface()Hans Dedecker2018-11-261-1/+2
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* interface: rework code to get rid of interface_set_dynamicHans Dedecker2018-11-131-1/+1
| | | | | | | Integrate dynamic interface creation code into interface_alloc and __interface_add so we can get rid of interface_set_dynamic Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* remove rps/xps configuration supportFelix Fietkau2018-02-261-21/+0
| | | | | | | | It is overly complex, yet does not cover common scenarios very well. It will be replaced with a simpler shell script that provides a better default policy Signed-off-by: Felix Fietkau <nbd@nbd.name>
* config: suppress error if no wireless config present (FS#1030)Hans Dedecker2017-10-061-2/+9
| | | | | | | | | | Wireless config is optional as not all targets have a wireless interface; therefore don't report an error if the wireless config is missing so network reload is not reporting an error to the user. While at it use netifd_log_message to print an error if the config cannot be loaded. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* allow setting rps/xps defualt values via uciJohn Crispin2017-08-221-1/+16
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* netifd: propagate error code on netifd_reload()Alexandru Ardelean2017-04-051-2/+8
| | | | | | | | | | | | | | | The context is that we generate some of the UCI config for netifd via scripts/programs. Every once in a while, there's a goof when doing that UCI generation, and netifd prints out the error at stderr, but returns 0 (success) err-code. This change will fail the ubus call if UCI config is invalid or missing for /etc/config/network. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com> Acked-by: Hans Dedecker <dedeckeh@gmail.com>
* device: add device handler listArne Kappen2016-08-261-21/+16
| | | | | | | | Device handlers now also declare if they have bridge capabilities and include a string to prefix device names for their types. Signed-off-by: Arne Kappen <akappen@inet.tu-berlin.de> Signed-off-by: Felix Fietkau <nbd@nbd.name> [cleanup/fixes]
* device: prepare for adding device handlers dynamicallyArne Kappen2016-08-261-1/+1
| | | | | | | | - remove const from device handler struct - pass device handler type to create function Signed-off-by: Arne Kappen <akappen@inet.tu-berlin.de> Signed-off-by: Felix Fietkau <nbd@nbd.name> [cleanup]
* netifd: Support for configurable default packet steering behaviorHans Dedecker2015-05-121-0/+6
| | | | | | | | | | | | 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>
* interface: remove obsolete device config apply codeFelix Fietkau2015-04-191-21/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* netifd:Make sure interface device config is also cachedHans Dedecker2015-03-191-1/+1
| | | | | | | | | | 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>
* netifd: Set interface device config when device has old settingsHans Dedecker2015-02-171-1/+1
| | | | | | | | 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>
* Revert "interface: do not set device_config where only the ifname option ↵Felix Fietkau2015-02-161-1/+1
| | | | | | | | | | 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>
* netifd: Remove unnecessary default_config check in config_parse_interfaceHans Dedecker2015-02-091-1/+1
| | | | | | No need to check default_config twice as it's already checked in config_parse_interface Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* netifd: set current_config for simple devices when parsing device configHans Dedecker2015-02-091-0/+1
| | | | | | | 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>
* interface: suppress unnecessary device config overridesFelix Fietkau2015-01-241-1/+2
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* device: simplify config blob memory allocation handlingFelix Fietkau2015-01-241-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* interface: do not set device_config where only the ifname option matchesFelix Fietkau2015-01-241-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* device: apply config changes from device sectionsFelix Fietkau2015-01-241-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* device: set dev->default_config to false for devices parsed from configFelix Fietkau2015-01-231-1/+4
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* device: add support for specifying a configuration for simple vlan devicesFelix Fietkau2015-01-231-4/+16
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* config: use sprintf instead of asprintfFelix Fietkau2014-10-241-6/+4
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* config: define _GNU_SOURCE for asprintfFelix Fietkau2014-10-071-0/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* wireless: display anonymous interface section names using index based ↵Felix Fietkau2014-10-041-1/+27
| | | | | | extended syntax Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Reorder alfabetically device type matching as they are growing in numberGioacchino Mazzurco2014-06-111-7/+7
| | | | Signed-off-by: Gioacchino Mazzurco <gmazzurco89@gmail.com>
* Add vlan 802.1q/802.1ad support as netifd devicesGioacchino Mazzurco2014-06-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* config: add support for disabling interfacesFelix Fietkau2014-04-211-1/+5
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* config: ignore config parser errorsFelix Fietkau2014-03-311-0/+1
| | | | | | | This helps with keeping routers reachable when there are typos in the network config. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* uci: Allow setting the UCI config path on the command lineMatthias Schiffer2014-03-191-1/+3
| | | | | | | Add a -c switch which allows setting an alternative UCI path instead of using the libuci default. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
* wireless: show the virtual interface section name in wireless statusFelix Fietkau2013-11-301-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* add initial support for handling wireless devices via scriptsFelix Fietkau2013-11-291-0/+85
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* interface: rework code to get rid of arbitrary IFNAMSIZ limitation for ↵Felix Fietkau2013-10-191-3/+2
| | | | | | interface names Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* interface: remove "dynamic" argument for interface_init, add the ↵Felix Fietkau2013-10-191-1/+1
| | | | | | interface_set_dynamic function instead Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Add ubus function to create nested interfacesSteven Barth2013-10-171-1/+1
|
* device: add macvlan supportFelix Fietkau2013-10-031-0/+2
| | | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* config: use the new uci_blob library codeFelix Fietkau2013-06-101-190/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* config: replace config_memdup with blob_memdup from libuboxFelix Fietkau2013-06-101-14/+0
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>