History

net: bridge: add support for user-controlled bool options

We have been adding many new bridge options, a big number of which are boolean but still take up netlink attribute ids and waste space in the skb. Recently we discussed learning from link-local packets[1] and decided yet another new boolean option will be needed, thus introducing this API to save some bridge nl space. The API supports changing the value of multiple boolean options at once via the br_boolopt_multi struct which has an optmask (which options to set, bit per opt) and optval (options' new values). Future boolean options will only be added to the br_boolopt_id enum and then will have to be handled in br_boolopt_toggle/get. The API will automatically add the ability to change and export them via netlink, sysfs can use the single boolopt function versions to do the same. The behaviour with failing/succeeding is the same as with normal netlink option changing. If an option requires mapping to internal kernel flag or needs special configuration to be enabled then it should be handled in br_boolopt_toggle. It should also be able to retrieve an option's current state via br_boolopt_get. v2: WARN_ON() on unsupported option as that shouldn't be possible and also will help catch people who add new options without handling them for both set and get. Pass down extack so if an option desires it could set it on error and be more user-friendly. [1] https://www.spinics.net/lists/netdev/msg532698.html

Nikolay Aleksandrov committed 7 years ago

Commit a428afe1 parent 02c72d56 files · +115 −2Browse files

Showing the changes to include/uapi/linux (2 of 6 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/if_bridge.h +18 −0
  2. include/uapi/linux/if_link.h +1 −0
include/uapi/linux/if_bridge.h+18−0
@@ -292,4 +292,22 @@ struct br_mcast_stats { · 291 unmodified lines
292 __u64 mcast_bytes[BR_MCAST_DIR_SIZE];292 __u64 mcast_bytes[BR_MCAST_DIR_SIZE];
293 __u64 mcast_packets[BR_MCAST_DIR_SIZE];293 __u64 mcast_packets[BR_MCAST_DIR_SIZE];
294};294};
295
296/* bridge boolean options
297 * IMPORTANT: if adding a new option do not forget to handle
298 * it in br_boolopt_toggle/get and bridge sysfs
299 */
300enum br_boolopt_id {
301 BR_BOOLOPT_MAX
302};
303
304/* struct br_boolopt_multi - change multiple bridge boolean options
305 *
306 * @optval: new option values (bit per option)
307 * @optmask: options to change (bit per option)
308 */
309struct br_boolopt_multi {
310 __u32 optval;
311 __u32 optmask;
312};
295#endif /* _UAPI_LINUX_IF_BRIDGE_H */313#endif /* _UAPI_LINUX_IF_BRIDGE_H */
include/uapi/linux/if_link.h+1−0
@@ -288,6 +288,7 @@ enum { · 287 unmodified lines
288 IFLA_BR_MCAST_IGMP_VERSION,288 IFLA_BR_MCAST_IGMP_VERSION,
289 IFLA_BR_MCAST_MLD_VERSION,289 IFLA_BR_MCAST_MLD_VERSION,
290 IFLA_BR_VLAN_STATS_PER_PORT,290 IFLA_BR_VLAN_STATS_PER_PORT,
291 IFLA_BR_MULTI_BOOLOPT,
291 __IFLA_BR_MAX,292 __IFLA_BR_MAX,
292};293};
293 294