From 1e6d5a84b89b58844aee2633831d97985e54844d Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Fri, 18 May 2018 17:47:05 +0200 Subject: [PATCH] rtnl_link: implement IFLA_INFO_DATA for bridges * xlat/rtnl_ifla_info_data_bridge_attrs.in: New file. * rtnl_link.c: Include xlat/rtnl_ifla_info_data_bridge_attrs.h. (ifla_info_data_bridge_nla_decoders): New decoder dispatcher table. (decode_nla_linkinfo_data_bridge, decode_nla_linkinfo_data): New functions. (ifla_linkinfo_nla_decoders) : Use decode_nla_linkinfo_data as a decoder. --- rtnl_link.c | 83 +++++++++++++++++++++++- xlat/rtnl_ifla_info_data_bridge_attrs.in | 46 +++++++++++++ 2 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 xlat/rtnl_ifla_info_data_bridge_attrs.in diff --git a/rtnl_link.c b/rtnl_link.c index 0944ea95..41e9ba42 100644 --- a/rtnl_link.c +++ b/rtnl_link.c @@ -50,6 +50,7 @@ #include "xlat/rtnl_ifla_brport_attrs.h" #include "xlat/rtnl_ifla_events.h" #include "xlat/rtnl_ifla_info_attrs.h" +#include "xlat/rtnl_ifla_info_data_bridge_attrs.h" #include "xlat/rtnl_ifla_port_attrs.h" #include "xlat/rtnl_ifla_vf_port_attrs.h" #include "xlat/rtnl_ifla_xdp_attrs.h" @@ -281,9 +282,89 @@ decode_nla_linkinfo_xstats(struct tcb *const tcp, return false; } +static const nla_decoder_t ifla_info_data_bridge_nla_decoders[] = { + [IFLA_BR_UNSPEC] = NULL, + [IFLA_BR_FORWARD_DELAY] = decode_nla_u32, + [IFLA_BR_HELLO_TIME] = decode_nla_u32, + [IFLA_BR_MAX_AGE] = decode_nla_u32, + [IFLA_BR_AGEING_TIME] = decode_nla_u32, + [IFLA_BR_STP_STATE] = decode_nla_u32, + [IFLA_BR_PRIORITY] = decode_nla_u16, + [IFLA_BR_VLAN_FILTERING] = decode_nla_u8, + [IFLA_BR_VLAN_PROTOCOL] = decode_nla_ether_proto, + [IFLA_BR_GROUP_FWD_MASK] = decode_nla_x16, + [IFLA_BR_ROOT_ID] = decode_ifla_bridge_id, + [IFLA_BR_BRIDGE_ID] = decode_ifla_bridge_id, + [IFLA_BR_ROOT_PORT] = decode_nla_u16, + [IFLA_BR_ROOT_PATH_COST] = decode_nla_u32, + [IFLA_BR_TOPOLOGY_CHANGE] = decode_nla_u8, + [IFLA_BR_TOPOLOGY_CHANGE_DETECTED] = decode_nla_u8, + [IFLA_BR_HELLO_TIMER] = decode_nla_u64, + [IFLA_BR_TCN_TIMER] = decode_nla_u64, + [IFLA_BR_TOPOLOGY_CHANGE_TIMER] = decode_nla_u64, + [IFLA_BR_GC_TIMER] = decode_nla_u64, + [IFLA_BR_GROUP_ADDR] = NULL, /* MAC address */ + [IFLA_BR_FDB_FLUSH] = NULL, /* unspecified */ + [IFLA_BR_MCAST_ROUTER] = decode_nla_u8, + [IFLA_BR_MCAST_SNOOPING] = decode_nla_u8, + [IFLA_BR_MCAST_QUERY_USE_IFADDR] = decode_nla_u8, + [IFLA_BR_MCAST_QUERIER] = decode_nla_u8, + [IFLA_BR_MCAST_HASH_ELASTICITY] = decode_nla_u32, + [IFLA_BR_MCAST_HASH_MAX] = decode_nla_u32, + [IFLA_BR_MCAST_LAST_MEMBER_CNT] = decode_nla_u32, + [IFLA_BR_MCAST_STARTUP_QUERY_CNT] = decode_nla_u32, + [IFLA_BR_MCAST_LAST_MEMBER_INTVL] = decode_nla_u64, + [IFLA_BR_MCAST_MEMBERSHIP_INTVL] = decode_nla_u64, + [IFLA_BR_MCAST_QUERIER_INTVL] = decode_nla_u64, + [IFLA_BR_MCAST_QUERY_INTVL] = decode_nla_u64, + [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL] = decode_nla_u64, + [IFLA_BR_MCAST_STARTUP_QUERY_INTVL] = decode_nla_u64, + [IFLA_BR_NF_CALL_IPTABLES] = decode_nla_u8, + [IFLA_BR_NF_CALL_IP6TABLES] = decode_nla_u8, + [IFLA_BR_NF_CALL_ARPTABLES] = decode_nla_u8, + [IFLA_BR_VLAN_DEFAULT_PVID] = decode_nla_u16, + [IFLA_BR_PAD] = NULL, + [IFLA_BR_VLAN_STATS_ENABLED] = decode_nla_u8, + [IFLA_BR_MCAST_STATS_ENABLED] = decode_nla_u8, + [IFLA_BR_MCAST_IGMP_VERSION] = decode_nla_u8, + [IFLA_BR_MCAST_MLD_VERSION] = decode_nla_u8, +}; + +bool +decode_nla_linkinfo_data_bridge(struct tcb *const tcp, + const kernel_ulong_t addr, + const unsigned int len, + const void *const opaque_data) +{ + decode_nlattr(tcp, addr, len, rtnl_ifla_info_data_bridge_attrs, + "IFLA_BR_???", ifla_info_data_bridge_nla_decoders, + ARRAY_SIZE(rtnl_ifla_info_data_bridge_attrs), + opaque_data); + + return true; +} + +bool +decode_nla_linkinfo_data(struct tcb *const tcp, + const kernel_ulong_t addr, + const unsigned int len, + const void *const opaque_data) +{ + struct ifla_linkinfo_ctx *ctx = (void *) opaque_data; + nla_decoder_t func = NULL; + + if (!strcmp(ctx->kind, "bridge")) + func = decode_nla_linkinfo_data_bridge; + + if (func) + return func(tcp, addr, len, opaque_data); + + return false; +} + static const nla_decoder_t ifla_linkinfo_nla_decoders[] = { [IFLA_INFO_KIND] = decode_nla_linkinfo_kind, - [IFLA_INFO_DATA] = NULL, /* unimplemented */ + [IFLA_INFO_DATA] = decode_nla_linkinfo_data, [IFLA_INFO_XSTATS] = decode_nla_linkinfo_xstats, [IFLA_INFO_SLAVE_KIND] = decode_nla_str, [IFLA_INFO_SLAVE_DATA] = NULL, /* unimplemented */ diff --git a/xlat/rtnl_ifla_info_data_bridge_attrs.in b/xlat/rtnl_ifla_info_data_bridge_attrs.in new file mode 100644 index 00000000..524dc8b5 --- /dev/null +++ b/xlat/rtnl_ifla_info_data_bridge_attrs.in @@ -0,0 +1,46 @@ +#value_indexed +IFLA_BR_UNSPEC 0 +IFLA_BR_FORWARD_DELAY 1 +IFLA_BR_HELLO_TIME 2 +IFLA_BR_MAX_AGE 3 +IFLA_BR_AGEING_TIME 4 +IFLA_BR_STP_STATE 5 +IFLA_BR_PRIORITY 6 +IFLA_BR_VLAN_FILTERING 7 +IFLA_BR_VLAN_PROTOCOL 8 +IFLA_BR_GROUP_FWD_MASK 9 +IFLA_BR_ROOT_ID 10 +IFLA_BR_BRIDGE_ID 11 +IFLA_BR_ROOT_PORT 12 +IFLA_BR_ROOT_PATH_COST 13 +IFLA_BR_TOPOLOGY_CHANGE 14 +IFLA_BR_TOPOLOGY_CHANGE_DETECTED 15 +IFLA_BR_HELLO_TIMER 16 +IFLA_BR_TCN_TIMER 17 +IFLA_BR_TOPOLOGY_CHANGE_TIMER 18 +IFLA_BR_GC_TIMER 19 +IFLA_BR_GROUP_ADDR 20 +IFLA_BR_FDB_FLUSH 21 +IFLA_BR_MCAST_ROUTER 22 +IFLA_BR_MCAST_SNOOPING 23 +IFLA_BR_MCAST_QUERY_USE_IFADDR 24 +IFLA_BR_MCAST_QUERIER 25 +IFLA_BR_MCAST_HASH_ELASTICITY 26 +IFLA_BR_MCAST_HASH_MAX 27 +IFLA_BR_MCAST_LAST_MEMBER_CNT 28 +IFLA_BR_MCAST_STARTUP_QUERY_CNT 29 +IFLA_BR_MCAST_LAST_MEMBER_INTVL 30 +IFLA_BR_MCAST_MEMBERSHIP_INTVL 31 +IFLA_BR_MCAST_QUERIER_INTVL 32 +IFLA_BR_MCAST_QUERY_INTVL 33 +IFLA_BR_MCAST_QUERY_RESPONSE_INTVL 34 +IFLA_BR_MCAST_STARTUP_QUERY_INTVL 35 +IFLA_BR_NF_CALL_IPTABLES 36 +IFLA_BR_NF_CALL_IP6TABLES 37 +IFLA_BR_NF_CALL_ARPTABLES 38 +IFLA_BR_VLAN_DEFAULT_PVID 39 +IFLA_BR_PAD 40 +IFLA_BR_VLAN_STATS_ENABLED 41 +IFLA_BR_MCAST_STATS_ENABLED 42 +IFLA_BR_MCAST_IGMP_VERSION 43 +IFLA_BR_MCAST_MLD_VERSION 44 -- 2.40.0