summaryrefslogtreecommitdiffhomepage
path: root/bridge.c
AgeCommit message (Collapse)Author
2020-11-05bridge: only overwrite implicit vlan assignment if vlans are configuredHEADmasterFelix Fietkau
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>
2020-11-05bridge: fix use-after-free bug on bridge member freeFelix Fietkau
When removing the device reference, the core might free the device. Use device_lock/unlock to keep the reference valid until it is no longer needed Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-11-05bridge: preserve hotplug ports on vlan update if config is unchangedFelix Fietkau
Fixes cleanup of port state Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-10-28bridge: show vlans in device statusFelix Fietkau
List vlans with member ports, VLAN IDs and flags Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-10-28bridge: add support for defining port member vlans via hotplug opsFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-08-07bridge: flush vlan list on bridge freeFelix Fietkau
Fixes a potential memory leak Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-07-19bridge: add support for VLAN filteringFelix Fietkau
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>
2020-07-18bridge: add support for turning on vlan_filteringJohn Crispin
If we want a bridge to be vlan aware we need to be able to turn on filtering. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2018-11-19treewide: switch to C-code style commentsHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-11-19treewide: make some functions staticHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-08-14device: gracefully handle device names exceeding IFNAMESIZHans Dedecker
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>
2017-05-09bridge: reset primary only after marking the member not presentAlex Oprea
Run the bridge_reset_primary function only after the member being removed has been marked as not present. This change prevents the bridge_reset_primary function from choosing the member being removed as the new primary member. Signed-off-by: Alex Oprea <alex.oprea@inteno.se>
2017-01-13bridge: disable IGMP snooping by defaultFelix Fietkau
Lots of configurations have triggered various issues in this feature, any many people don't even need this. Let's disable it by default until it has become more stable Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-11-22bridge: fix MAC address override on config reloadFelix Fietkau
When no MAC address option is given, the MAC address of bst->primary_port is used to override the bridge device address. When the config changes and a new MAC address is provided in the config, bridge_reset_primary needs to stop overriding it Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-11-04bridge: Don't use device name as bridge member nameHans Dedecker
The bridge name is a copy of the device name; but the device name can change which is the case when an aliased interface is used as bridge member. This will result into unwanted side effects like bridge reload triggering a topology change effect after doing network reload; therefore use the configured ifname as fixed bridge member name. Also don't display bridge member devices which are hidden Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-09-26bridge: Make bridge_device_type staticHans Dedecker
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-09-26device: Move the different device type registrations to the device type fileHans Dedecker
While at it; make device_types static if only used in the device type file Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2016-08-26device: add device handler listArne Kappen
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]
2016-08-26device: prepare for adding device handlers dynamicallyArne Kappen
- 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]
2016-03-07bridge: multicast: Export some parameters RFCs suggest to be tunableLinus Lüssing
RFCs suggest some parameters of IGMP and MLD to be configurable by the administrator. With this patch the following parameters are configurable: * robustness (default: 2) * query_interval (default: 12500 [125s]) * query_response_interval (default: 1000 [10s]) * last_member_interval (default: 100 [1s]) Depending on the size and nature of the network topology administrators might want to increase or decrease these parameters. netifd will take care of configuring any other parameters which are dependant on the ones above and set them according to the formulas provided in the RFCs. These parameters of the bridge are membership_interval, querier_interval, startup_query_interval, startup_query_count and last_member_count. RFCs allow setting three more parameters to be configurable: startup_query_interval, startup_query_count and last_member_count. However this patch does not export them, as they can be indirectly tuned via the given, exported four parameters, too. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
2015-06-24Add mtu6 option to override IPv6 MTUSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-27bridge: allow setting hash_max valueLinus Lüssing
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>
2015-04-17device: remove DEV_ATTR_IFNAME, it is unusedFelix Fietkau
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>
2015-03-23bridge: allow enabling or disabling the multicast querier independently of ↵Matthias Schiffer
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>
2015-02-17netifd: Keep reference to a config copy in device type specific reload ↵Hans Dedecker
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>
2015-01-23bridge: fix retrying member enable when the bridge is otherwise emptyFelix Fietkau
Ensure that the bridge gets created before retrying Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-01-23bridge: mark tested members as present during enable retryFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-01-23bridge: release failed member devicesFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23bridge: retry adding members after config reload / device startFelix Fietkau
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>
2014-07-17bridge: enable IGMP snooping by defaultFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-05-09netifd: Fix node version set after freeHans Dedecker
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>
2014-04-26netifd: Add interface config support to enable/disable IPv6 in the kernel ↵Hans Dedecker
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>
2014-03-21netifd: Reload proto on topology changeHelmut Schaa
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>
2014-03-11netifd: Fix bridge MTU setting when a bridge member is addedHans Dedecker
Reapply bridge mtu setting as adding a bridge member will override the bridge mtu in the kernel Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2014-03-07netifd: fix bridge reloading issueEmanuel Taube
Check in the right order to decide if the bridge have to be set up. Additionally we are consistent with setting it down. Signed-off-by: Emanuel Taube <emanuel.taube@gmail.com>
2013-11-29netifd: Fix possible segfault in bridge codeHelmut Schaa
Need to check calloc result. In case of failure the bridge member will be missing. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-10-29bridge: fix stray semicolon, fixes a bug in bridge primary port resetFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-08-29bridge: fix corner case with network reloadLuka Perkov
After removing all ifname options from bridge interface and executing network reload the configuration was not applied properly on the system. With this change that is no longer a issue. Signed-off-by: Luka Perkov <luka@openwrt.org>
2013-07-13bridge: add bridge_empty option which allows creation of empty bridgesLuka Perkov
Signed-off-by: Luka Perkov <luka@openwrt.org>
2013-06-10config: use the new uci_blob library codeFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-04-27bridge: disable multicast snooping by defaultJo-Philipp Wich
2013-04-23set default bridge priority to 0x7FFFJo-Philipp Wich
2013-04-23add bridge priority optionNiels Boehm
[netifd] add bridge priority option Using the bridge priority (lower numbers are higher in the hierarchy), one can ensure that the router is chosen as root bridge in a setup with spanning tree protocol. For instance, one can set the priority of network lan to 32767, causing the router to win over all directly and indirectly connected nodes that have a default priority of 32768. The reason for doing that is that otherwise it has a default priority 32768 as well and any other connected node could win and get root bridge. In a home setup, those nodes are often desktop or laptop boxes and get switched off from time to time. As a consequence, root bridges vanish or new root bridges get chosen relatively often, resulting in frequent topology changes to the STP network. While the new topology has not settled, packets can get lost, causing noticeable interruptions of network traffic. Setting the router's bridge on a lower numbered priority (and thus higher in the selection hierarchy) solves the problem in the vast majority of the cases by ensuring that the device that is most likely powered on 24/7 gets chosen as root and prevents topology changes. Signed-off-by: Niels Boehm <blubberdiblub@gmail.com>
2012-10-19bridge: toggle device present state after freeing a bridge member to ensure ↵Felix Fietkau
that it can be reassigned to a different bridge
2012-06-27bridge: fix getting the mac address from the first member deviceFelix Fietkau
2012-05-24bridge: keep existing mac address if specified in the configFelix Fietkau
2012-05-23bridge: set the mac address based on the first active memberFelix Fietkau
2012-05-04add copyright headersFelix Fietkau
2012-03-19move device cleanup to common code, fixes use-after-free in tunnel codeFelix Fietkau
2012-03-05bridge: turn stp off by defaultFelix Fietkau