summaryrefslogtreecommitdiffstats
path: root/lib/route/link/bridge.c
Commit message (Collapse)AuthorAgeFilesLines
* lib/route: add support for bridge mstiRonan Dalton2024-10-101-27/+494
| | | | https://github.com/thom311/libnl/pull/409
* lib/route: extend bridge flagsRonan Dalton2024-09-121-22/+120
| | | | | | | | | | | | | | | | | | Add support for the following bridge flags: IFLA_BRPORT_PROXYARP IFLA_BRPORT_PROXYARP_WIFI IFLA_BRPORT_MCAST_FLOOD IFLA_BRPORT_MCAST_TO_UCAST IFLA_BRPORT_VLAN_TUNNEL IFLA_BRPORT_BCAST_FLOOD IFLA_BRPORT_NEIGH_SUPPRESS IFLA_BRPORT_ISOLATED IFLA_BRPORT_LOCKED IFLA_BRPORT_MAB IFLA_BRPORT_NEIGH_VLAN_SUPPRESS https://github.com/thom311/libnl/pull/403
* tests: add test for bridge vlan attributes.Cordell O'Leary2024-02-291-4/+4
|
* route: add support for vlan filtering on bridge ports.Cordell O'Leary2024-02-291-8/+323
|
* include: use <linux/$file> instead of <linux-private/linux/$file>Thomas Haller2023-08-081-1/+1
| | | | | | As we now copy all linux headers, and we have include/linux-private in our include search path, just include the linux headers as we commonly do.
* include: include private linux headers with explicit pathThomas Haller2023-08-031-1/+1
| | | | | | | We have copies of the linux headers in include/linux-private. For those files, include the copies explicitly. No practice there is no difference, since we build with :-Ilinux-private".
* include: drop "netlink-private/netlink.h" and move declarationsThomas Haller2023-08-021-2/+0
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-021-2/+6
|
* include: split and drop "netlink-private/types.h"Thomas Haller2023-08-021-0/+2
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* include: move "include/netlink-private/route/link/api.h" to lib/routeThomas Haller2023-07-311-1/+2
| | | | | This header is entirely private to compiling libnl-route-3 under lib/route. Move the header there.
* lib: use _nl_{init,exit} instead of __{init,exit}Thomas Haller2023-07-281-2/+2
| | | | | We should have things with "nl" prefix in our headers. Also, netlink-private/netlink.h is not header-only, preferably header-only stuff is in netlink-private/utils.h
* all: rework ATTR_DIFF() macros to not generate attribute namesThomas Haller2023-07-281-12/+14
| | | | | | | | | | I find macros that stitch together names like "FAMILY_ATTR_##ATTR" very confusing, because we no longer see where a certain name is used. It breaks grepping for symbols, and it breaks cscope. Yes, it's more verbose to not do that. If you really think that those names are too verbose, then maybe they should get a shorter name. And not use macros to make them palatable.
* bridge: fix bridge info parsingStanislav Zaikin2023-07-241-0/+1
| | | | | | Fixes: 1a4031d6db73 ('lib/route: Support IFLA_BRIDGE_MODE') https://github.com/thom311/libnl/pull/339
* all: avoid coverity warnings about assigning variable but not using itThomas Haller2022-04-221-2/+1
| | | | | | | | | | | | Workaround coverity warnings like: Error: CLANG_WARNING: libnl-3.6.0/lib/netfilter/exp.c:428:7: warning[deadcode.DeadStores]: Although the value stored to 'err' is used in the enclosing expression, the value is never actually read from 'err' # 426| } # 427|··· # 428|-> if ((err = nfnl_exp_build_tuple(msg, exp, CTA_EXPECT_NAT)) < 0) # 429| goto nla_put_failure; # 430|···
* license: fix and add SPDX license identifiers and drop license commentsThomas Haller2020-04-161-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also fixes a few wrong SPDX license identifiers, where the original license comment indicates GPL-2.0-only. This is not done manually, but by running the following script: --- #!/bin/bash # Tool to drop license comments, adding SPDX license identifiers, while preserving # copyright comments. The point is not to manually do this task, but perform some # hacked up string replacement. _cp() { /bin/cp "$@" } _cat() { /bin/cat "$@" } in_file() { local T=$(mktemp) _cp -f "$1" "$T" _cat "$T" rm -f "$T" } out_file() { local T=$(mktemp) _cat - > "$T" _cp -f "$T" "$1" rm -f "$T" } join() { _cat "$@" | awk '{ printf("%s#x#", $0)}' } unjoin() { _cat - | sed 's/#x#/\n/g' } files_all() { git ls-files | grep -v '\.png$' | grep -v '^include/linux-private/' } adjust() { NEWLINES='\(#x#\)\+' COPYRIGHTS='\(\( \* Copyright (c) 20..\(-20..\|, 20..\)\? [^#]\+#x#\)\+\( \*#x# \* \(Stolen[^#]*\|Based on [^#]*\)#x#\)\?\)' _cat - | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x##x#%' | \ sed '1s%^\(\)/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU General Public License as#x# \*[ ]\+published by the Free Software Foundation version 2 of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: GPL-2.0-only \*/#x#/*#x#\2 */#x##x#%' } FILES=( $(files_all) ) for f in "${FILES[@]}"; do echo "processing \"$f\"..." in_file "$f" | join | adjust | unjoin | out_file "$f" done
* Change rtnl_link_af_ops.ao_override_rtm behaviorJef Oliver2017-11-291-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rtnl_link_af_ops.ao_override_rtm allows for a link module to override the change request type being sent to the kernel. More specifically, the default change request type is RTM_NEWLINK. Some link change requests require the reqeust type to be set to RTM_SETLINK. This is the case for IFLA_PROTINFO specific attributes for a link that is slave to a bridge. Currently, ao_override_rtm is static to the address family type. So, all changes submitted to AF_BRIDGE override the link change request type. The override only needs to happen if IFLA_PROTINFO attributes are appended to the link change request. This patch changes ao_override_rtm from a const integer to a function pointer that allows for a link module to determine if the override needs to actually happen. Currently, only the bridge module uses this functionality. If bridge flags are applied to a link (bdpu blocking, learning, fast leave, etc...), these flags are nested in IFLA_PROTINFO. If the flags are present, the link change request type will be overridden as RTM_SETLINK. This fixes the ability to set a bridge link up or down by using the correct RTM_NEWLINK link change request type. $ sudo src/nl-link-set -n br2 --state=down Changed bridge br2 ether a6:e6:94:8c:61:ec <broadcast,multicast,up,running,lowerup> group 0 $ ip link show br2: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000 $ sudo src/nl-link-set -n br2 --state=up Changed bridge br2 ether a6:e6:94:8c:61:ec <broadcast,multicast> group 0 $ ip link show br2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 Signed-off-by: Jef Oliver <jef.oliver@intel.com> Fixes: 55bc931a7272e6ac8f555bcc2a373eb2b6b58377 http://lists.infradead.org/pipermail/libnl/2017-November/002382.html http://lists.infradead.org/pipermail/libnl/2017-November/002385.html
* bridge: change return values for rtnl_link_bridge_get_hwmode()Thomas Haller2016-09-241-8/+9
| | | | | | | | | | | | | | | | Unfortunately, libnl3 is rather inconsistent about the getters. - some return the value directly, and don't have a dedicated error return value. - some don't check whether the attribute was set and just return the default value - some fail with -NLE_INVAL or -NLE_NOATTR if the value is unset. I think the best pattern is to fail if the attribue is unset. However, the return value should be negative to indicate an error, while 0 should mean success. Signed-off-by: Thomas Haller <thaller@redhat.com>
* trivial: whitespaceThomas Haller2016-09-241-14/+14
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/route: Support IFLA_BRIDGE_MODEJef Oliver2016-09-241-1/+142
| | | | | | | | | | | | | | | | | | | | | | | This patch adds support for hardware assisted bridge modes stored in IFLA_AF_SPEC[IFLA_BRIDGE_MODE]. This patch adds rtnl_link_[g/s]et_hwmode() functions, allowing for getting and setting the hardware mode for a bridged link. This patch adds the convenience functions for translating between integer and string names for hardware modes. This patch adds rtnl_link_bridge_set_self(), a function that stores flags in IFLA_AF_SPEC[IFLA_BRIDGE_FLAGS], an attribute that tells the kernel whether it should apply settings to the virtual bridge device or the hardware device itself. This requires hardware that supports the hardware flags. This patch adds bridge_fill_af(), a function to fill IFLA_AF_SPEC with AF_BRIDGE specific information. Signed-off-by: Jef Oliver <jef.oliver@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/route: Extend Bridge FlagsJef Oliver2016-09-241-0/+26
| | | | | | | | | | | This patch adds support for the following bridge port flags: IFLA_BRPORT_UNICAST_FLOOD IFLA_BRPORT_LEARNING IFLA_BRPORT_LEARNING_SYNC Signed-off-by: Jef Oliver <jef.oliver@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/route: Add port state translation functionsJef Oliver2016-09-241-0/+25
| | | | | | | | This patch adds translation functions for translating the port state between integers and strings. Signed-off-by: Jef Oliver <jef.oliver@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/route: Fix appending IFLA_BRPORT_FASTLEAVEJef Oliver2016-09-241-1/+1
| | | | | | | | | | This patch fixes IFLA_BRPORT_FASTLEAVE to append to the correct netlink attribute. (Turned up in automated testing.) Fixes: 55bc931a7272e6ac8f555bcc2a373eb2b6b58377 Signed-off-by: Jef Oliver <jef.oliver@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/route: modify link/bridge to set attributesJef Oliver2016-08-291-0/+42
| | | | | | | | | | | | | | | | | This patch modifies link/bridge to set link attributes in a request message. It adds set support for currently implemented functionality. This patch adds bridge_fill_pi, a function to fill in the IFLA_PROTINFO nested attribute. This patch modifies the bridge_ops structure to support modifications made to properly set RTM_SETLINK during modifcation of a link, append the NLA_F_NESTED flag to IFLA_PROTINFO, and to call the newly added bridge_fill_pi. Signed-off-by: Jef Oliver <jef.oliver@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: allow overwriting IFLA_EXT_MASK flag in ao_get_af() functionThomas Haller2016-06-241-4/+3
| | | | | | | Instead of setting it twice, once during link_request_update() and later in bridge_get_af(), pass ext_filter_mask to ao_get_af(). Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: handle RTEXT_FILTER_BRVLAN_COMPRESSEDTobias Jungel2015-12-071-9/+28
| | | | | | | notifications from the kernel regarding vlan ids are now handled [thaller@redhat.com: split ao_parse_af_full() to previous patch] Signed-off-by: Thomas Haller <thaller@redhat.com>
* bridge: add support for VLANsDavid Ahern2015-12-071-0/+199
| | | | | | | | | | | | | | | | | | | | | | | | Add operation for requesting VLAN data for AF_BRIDGE and parsing of IFLA_AF_SPEC for AF_BRIDGE. VLANs are saved in a bitmap. Also add dumping of vlan info to link list and neigh list. For example: $ nl-link-list --details --family=bridge br1 ether 8e:6e:0e:86:e5:86 master br1 <broadcast,multicast,up,running,lowerup> mtu 1500 txqlen 0 weight 0 index 18 mode default carrier down bridge: pvid 1 all vlans: 1 301-400 601-610 untagged vlans: 1 bond1 ether 46:ef:e1:c9:46:fe <broadcast,multicast,master> mtu 1500 txqlen 0 weight 0 index 20 state down mode default carrier down bridge: Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> [thaller@redhat.com: modified original patch to use ao_parse_af_full(). Also renaming new API and drop some #defines] Signed-off-by: Thomas Haller <thaller@redhat.com>
* style: require comma after __ADD() macroThomas Haller2014-07-271-4/+4
| | | | | | | $ sed -i 's/^\([\t ]\+\<__ADD\> \?([^)]\+)\) *$/\1,/' `git grep -w -l __ADD` Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* doc: fix wrong name in documentation for rtnl_link_bridge_alloc()Thomas Haller2014-05-011-1/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* bridge: add rtnl_link_add_bridge() functionHongweiBi2014-01-141-0/+28
| | | | | Signed-off-by: HongweiBi <hwbi2008@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* python: add bridge flags APINicolas PLANEL2013-10-221-0/+24
| | | | | | | | | | | Add flags set/get methods aim to change bridge flags : o hairpin_mode o bpdu_guard o root_block o fast_leave Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bridge: Provide rtnl_link_bridge_alloc()Thomas Graf2013-02-141-0/+21
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bridge: Support the new bridging attributesThomas Graf2013-02-071-12/+362
| | | | | | | | | | | | | This provides support for the new bridging attributes provided in IFLA_PROTINFO while maintaining backwards compatibility with older kernels. A set of new API functions are exported to access the bridging information. rtnl_link_bridge_has_ext_info() can be used to check whether a bridge object has been constructed based on the newly available attributes or the old message format. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Move private header files to <netlink-private/*>Thomas Graf2013-01-241-2/+2
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add ao_compare support to bridge family af_dataroopa2013-01-121-1/+21
| | | | | | | | | | | | | This patch adds support for ao_compare operation to bridge link af data operations. Adds field ce_mask to struct bridge_data to work with the ATTR attributes. I can submit separate patches to introduce mask field to ATTR macros. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link/api: Improve API documentation.Thomas Graf2010-11-111-10/+0
|
* link: Support for AF_BRIDGE address familyThomas Graf2010-11-111-0/+93
Supports parsing of IFLA_PROTINFO returned when dumping with PF_BRIDGE