summaryrefslogtreecommitdiff
path: root/vlan.c
Commit message (Collapse)AuthorAgeFilesLines
* netifd: Fix multiple -Wsign-compare warningsHauke Mehrtens2023-02-191-2/+2
| | | | | | | | | | | | | | | | | | This fixes warnings like this: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare] Mostly this was an int compared to a size_t returned by ARRAY_SIZE(). The easiest fix is to count on the size_t type. The ifindex is sometimes an unsigned int and sometimes a signed int in the kernel interfaces. I think it normally fits into an unsigned 16 bit value, so this should be fine. Do the one comparison where the compiler complains as a long. Casting the result of sizeof() to int should be safe. These values are never out of range of int. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* treewide: correctly apply IFNAMSIZ limitJo-Philipp Wich2022-11-171-2/+2
| | | | | | | | | | | | | | | | The `IFNAMSIZ` macro defines the required buffer size to hold a Linux interface name including the terminating zero byte while netifd currently uses an `IFNAMSIZ + 1` limit for interface name buffers. This causes netifd to use overlong names (16 instead of 15 bytes) in netlink communication with the kernel, leading to netlink failure replies due to policy violations. Fix this issue by applying the correct length, that is `IFNAMSIZ` directly, to the corresponding buffers. Ref: https://github.com/openwrt/openwrt/issues/11259 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* vlan: fix device vlan alias handlingFelix Fietkau2021-07-141-8/+23
| | | | | | | | | | | | A recent commit changed the vlan chain handling to not treat devices with non-digit characters after "." as vlan devices. This broke aliases, which rely on names after the "." component. Fix dealing with both cases by first trying to set up a vlan regardless of the non-digit characters, but for the first component allow falling back to treating the first two parts as a full device name Fixes: 013a1171e9b0 ("device: do not treat devices with non-digit characters after . as vlan devices") Signed-off-by: Felix Fietkau <nbd@nbd.name>
* device: do not treat devices with non-digit characters after . as vlan devicesFelix Fietkau2021-06-191-12/+14
| | | | | | Fixes corner cases related to AP WDS station interfaces Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge: allow adding/removing VLANs to configured member ports via hotplugFelix Fietkau2021-06-041-9/+12
| | | | | | | This is useful for a dynamic VLAN setup, where extra tags need to be created on the trunking port on demand Signed-off-by: Felix Fietkau <nbd@nbd.name>
* bridge-vlan: add support for defining aliases for vlan idsFelix Fietkau2020-11-201-8/+14
| | | | | | | | | | | | | | | 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>
* wireless: fix passing bridge name for vlan hotplug pass-throughFelix Fietkau2020-11-181-2/+2
| | | | | | | When preparing the interface for hotplug add, pass the bridge device back to the caller, since it may not match the original device Signed-off-by: Felix Fietkau <nbd@nbd.name>
* vlan: add pass-through hotplug ops that pass the VLAN info to the bridgeFelix Fietkau2020-10-281-0/+74
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* vlan: initialize device ifname earlier at creation timeFelix Fietkau2020-07-181-16/+12
| | | | | | Avoids attempting to add the device with an empty string as ifname Signed-off-by: Felix Fietkau <nbd@nbd.name>
* device: gracefully handle device names exceeding IFNAMESIZHans Dedecker2018-08-141-8/+14
| | | | | | | | | | | | Instead of truncating the device name when it exceeds IFNAMSIZ length; let device_set_ifname return an error code and do not add the device to the device list. This avoids possible issues with device names becoming identical due the truncation and as a result unexpected behavior. Further let the different device types gracefully handle the error code returned by device_init Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* netifd: make sure the vlan ifname fits into the bufferJohn Crispin2018-07-271-0/+3
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* vlan: use alloca to get rid of IFNAMSIZE in vlan_dev_set_name()Hans Dedecker2018-07-171-2/+4
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* replace fall throughs in switch/cases where possible with simple code changesAlexander Couzens2018-07-111-3/+3
| | | | | | | | fall throughs are usually error-prone, especially when someone else extend it. Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Acked-by: Hans Dedecker <dedeckeh@gmail.com>
* 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]
* device: Fix device find failure in avl list due to device name changeHans Dedecker2016-06-061-4/+7
| | | | | | | | As device name is used as key in avl list a device name change will break the avl find logic. Function device_set_ifname offers api to set the device name and re-inserts the avl node in the list when the avl key value is changed. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* vlan: Fix possible segfaultHans Dedecker2016-02-011-0/+2
| | | | Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* device: Don't process link events anymore in device user specific callback ↵Hans Dedecker2015-11-041-6/+0
| | | | | | | | | | | | | | | handlers Set link_state for all device types via the device_set_link API as all devices are registered in the device tree list making it possible to always get the device via device_get. The decice link state parameter will now actually reflect the corresponding kernel device carrier state in all cases. Before this change a vlan/macvlan device could still have link_state enabled if an interface was brought down; this was the case when the parent vlan/macvlan device was still enabled as the netlink link_state event would be dropped for vlan/macvlan devices due to keep_link_state in the function cb_rtnl_event. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* netifd: Add old style vlan devices to device listHans Dedecker2015-05-271-1/+1
| | | | | | | | | | | 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>
* Revert "vlan: reset device state on init"Felix Fietkau2015-01-241-3/+0
| | | | | | This is causing a regression with some VLAN configurations This reverts commit a4445215e06ee3056427effbef617f4525ee1836.
* vlan: reset device state on initFelix Fietkau2015-01-241-0/+3
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* device: make link status detection optional for vlan devicesFelix Fietkau2014-10-201-0/+1
| | | | | | | Fixes a race condition that triggers endless link loss / detect calls when VLAN devices are created. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* netifd: Check device_claim return code in all casesHans Dedecker2014-06-181-1/+1
| | | | | | Fixes observed issue a tunnel interface is reported as up although device_claim failed Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* netifd: Reload proto on topology changeHelmut Schaa2014-03-211-0/+4
| | | | | | | | | | 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>
* netifd: Link layer state awareness support on interface levelHans Dedecker2014-02-271-3/+10
| | | | | | | | 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>
* Revert "netifd: Link layer state support on device level"Felix Fietkau2013-12-141-10/+3
| | | | This reverts commit c439b52400978dd3799c66e1f632ee68d2c7c9eb.
* netifd: Link layer state support on device levelHans Dedecker2013-12-081-3/+10
| | | | | | | Patch implements link layer state awareness (aka carrier detection) in netifd on device level. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* vlan: set the name of vlan devices earlierNathan Hintz2013-09-251-3/+3
| | | | | | | | Set the device name earlier so that the logging done inside of 'device_init_virtual' can print the name of the device being initialized (instead of an empty string). Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
* device: use safe_list for device event, fixes some hang issuesFelix Fietkau2013-04-151-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* fix ifname for alias+vlan chainsFelix Fietkau2012-07-051-1/+11
|
* make vlan devices virtual to avoid avl tree issues with changing ifnames ↵Felix Fietkau2012-07-051-1/+1
| | | | when bound to alias interfaces
* vlan.c: prevent segfault in get_vlan_device_chain() if the base device does ↵Jo-Philipp Wich2012-07-051-1/+1
| | | | not exist
* add copyright headersFelix Fietkau2012-05-041-0/+13
|
* apply device settings to simple devices with config specified from the ↵Felix Fietkau2011-10-191-0/+1
| | | | interface section (legacy format compatibility), but only if no other config was provided
* always recreate devices by default if the config attribute list is not the ↵Felix Fietkau2011-10-061-0/+1
| | | | default one
* rename a variable for clarityFelix Fietkau2011-10-051-7/+7
|
* make device_claim/device_release operate on the device_user instead of the ↵Felix Fietkau2011-09-041-3/+3
| | | | device to avoid refcount bugs
* s/release_device/device_release/Felix Fietkau2011-07-291-2/+2
|
* s/claim_device/device_claim/Felix Fietkau2011-07-291-1/+1
|
* s/init_device/device_init/Felix Fietkau2011-07-291-1/+1
|
* s/get_device/device_get/Felix Fietkau2011-07-291-1/+1
|
* s/cleanup_device/device_cleanup/Felix Fietkau2011-07-291-1/+1
|
* s/set_device_present/device_set_present/Felix Fietkau2011-07-291-2/+2
|
* s/add_device_user/device_add_user/Felix Fietkau2011-07-291-1/+1
|
* s/remove_device_user/device_remove_user/gFelix Fietkau2011-07-291-1/+1
|
* remove an unnecessary inlineFelix Fietkau2011-03-281-1/+1
|
* Initial importFelix Fietkau2011-03-271-0/+156