From: Yu Watanabe Date: Wed, 25 Aug 2021 16:29:21 +0000 (+0900) Subject: sd-netlink: specify appropriate netlink attribute type X-Git-Tag: v250-rc1~746^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0df8e99935cc87886b4d700b89c53eb4eee1ca5;p=thirdparty%2Fsystemd.git sd-netlink: specify appropriate netlink attribute type --- diff --git a/src/libsystemd/sd-netlink/netlink-types-genl.c b/src/libsystemd/sd-netlink/netlink-types-genl.c index 0e8783b4983..b2f768181fd 100644 --- a/src/libsystemd/sd-netlink/netlink-types-genl.c +++ b/src/libsystemd/sd-netlink/netlink-types-genl.c @@ -50,18 +50,18 @@ static const NLType genl_batadv_types[] = { [BATADV_ATTR_ALGO_NAME] = { .type = NETLINK_TYPE_STRING }, [BATADV_ATTR_MESH_IFINDEX] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_MESH_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ }, - [BATADV_ATTR_MESH_ADDRESS] = { .size = ETH_ALEN }, + [BATADV_ATTR_MESH_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_HARD_IFINDEX] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_HARD_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ }, - [BATADV_ATTR_HARD_ADDRESS] = { .size = ETH_ALEN }, - [BATADV_ATTR_ORIG_ADDRESS] = { .size = ETH_ALEN }, + [BATADV_ATTR_HARD_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, + [BATADV_ATTR_ORIG_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_TPMETER_RESULT] = { .type = NETLINK_TYPE_U8 }, [BATADV_ATTR_TPMETER_TEST_TIME] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_TPMETER_BYTES] = { .type = NETLINK_TYPE_U64 }, [BATADV_ATTR_TPMETER_COOKIE] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_PAD] = { .type = NETLINK_TYPE_UNSPEC }, [BATADV_ATTR_ACTIVE] = { .type = NETLINK_TYPE_FLAG }, - [BATADV_ATTR_TT_ADDRESS] = { .size = ETH_ALEN }, + [BATADV_ATTR_TT_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_TT_TTVN] = { .type = NETLINK_TYPE_U8 }, [BATADV_ATTR_TT_LAST_TTVN] = { .type = NETLINK_TYPE_U8 }, [BATADV_ATTR_TT_CRC32] = { .type = NETLINK_TYPE_U32 }, @@ -69,19 +69,19 @@ static const NLType genl_batadv_types[] = { [BATADV_ATTR_TT_FLAGS] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_FLAG_BEST] = { .type = NETLINK_TYPE_FLAG }, [BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NETLINK_TYPE_U32 }, - [BATADV_ATTR_NEIGH_ADDRESS] = { .size = ETH_ALEN }, + [BATADV_ATTR_NEIGH_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_TQ] = { .type = NETLINK_TYPE_U8 }, [BATADV_ATTR_THROUGHPUT] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 }, - [BATADV_ATTR_ROUTER] = { .size = ETH_ALEN }, + [BATADV_ATTR_ROUTER] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_BLA_OWN] = { .type = NETLINK_TYPE_FLAG }, - [BATADV_ATTR_BLA_ADDRESS] = { .size = ETH_ALEN }, + [BATADV_ATTR_BLA_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_BLA_VID] = { .type = NETLINK_TYPE_U16 }, - [BATADV_ATTR_BLA_BACKBONE] = { .size = ETH_ALEN }, + [BATADV_ATTR_BLA_BACKBONE] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_BLA_CRC] = { .type = NETLINK_TYPE_U16 }, [BATADV_ATTR_DAT_CACHE_IP4ADDRESS] = { .type = NETLINK_TYPE_U32 }, - [BATADV_ATTR_DAT_CACHE_HWADDRESS] = { .size = ETH_ALEN }, + [BATADV_ATTR_DAT_CACHE_HWADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN }, [BATADV_ATTR_DAT_CACHE_VID] = { .type = NETLINK_TYPE_U16 }, [BATADV_ATTR_MCAST_FLAGS] = { .type = NETLINK_TYPE_U32 }, [BATADV_ATTR_MCAST_FLAGS_PRIV] = { .type = NETLINK_TYPE_U32 }, @@ -118,9 +118,9 @@ static const NLType genl_fou_types[] = { [FOU_ATTR_LOCAL_V4] = { .type = NETLINK_TYPE_IN_ADDR }, [FOU_ATTR_PEER_V4] = { .type = NETLINK_TYPE_IN_ADDR }, [FOU_ATTR_LOCAL_V6] = { .type = NETLINK_TYPE_IN_ADDR }, - [FOU_ATTR_PEER_V6] = { .type = NETLINK_TYPE_IN_ADDR}, - [FOU_ATTR_PEER_PORT] = { .type = NETLINK_TYPE_U16}, - [FOU_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32}, + [FOU_ATTR_PEER_V6] = { .type = NETLINK_TYPE_IN_ADDR }, + [FOU_ATTR_PEER_PORT] = { .type = NETLINK_TYPE_U16 }, + [FOU_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, }; /***************** genl l2tp type systems *****************/ @@ -165,8 +165,8 @@ static const NLType genl_macsec_sa_types[] = { [MACSEC_SA_ATTR_AN] = { .type = NETLINK_TYPE_U8 }, [MACSEC_SA_ATTR_ACTIVE] = { .type = NETLINK_TYPE_U8 }, [MACSEC_SA_ATTR_PN] = { .type = NETLINK_TYPE_U32 }, - [MACSEC_SA_ATTR_KEYID] = { .size = MACSEC_KEYID_LEN }, - [MACSEC_SA_ATTR_KEY] = { .size = MACSEC_MAX_KEY_LEN }, + [MACSEC_SA_ATTR_KEYID] = { .type = NETLINK_TYPE_BINARY, .size = MACSEC_KEYID_LEN }, + [MACSEC_SA_ATTR_KEY] = { .type = NETLINK_TYPE_BINARY, .size = MACSEC_MAX_KEY_LEN }, }; DEFINE_TYPE_SYSTEM(genl_macsec_sa); @@ -195,9 +195,9 @@ static const NLType genl_wireguard_allowedip_types[] = { DEFINE_TYPE_SYSTEM(genl_wireguard_allowedip); static const NLType genl_wireguard_peer_types[] = { - [WGPEER_A_PUBLIC_KEY] = { .size = WG_KEY_LEN }, + [WGPEER_A_PUBLIC_KEY] = { .type = NETLINK_TYPE_BINARY, .size = WG_KEY_LEN }, [WGPEER_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, - [WGPEER_A_PRESHARED_KEY] = { .size = WG_KEY_LEN }, + [WGPEER_A_PRESHARED_KEY] = { .type = NETLINK_TYPE_BINARY, .size = WG_KEY_LEN }, [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U16 }, [WGPEER_A_ENDPOINT] = { .type = NETLINK_TYPE_SOCKADDR }, [WGPEER_A_ALLOWEDIPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_allowedip_type_system }, @@ -209,7 +209,7 @@ static const NLType genl_wireguard_types[] = { [WGDEVICE_A_IFINDEX] = { .type = NETLINK_TYPE_U32 }, [WGDEVICE_A_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ-1 }, [WGDEVICE_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, - [WGDEVICE_A_PRIVATE_KEY] = { .size = WG_KEY_LEN }, + [WGDEVICE_A_PRIVATE_KEY] = { .type = NETLINK_TYPE_BINARY, .size = WG_KEY_LEN }, [WGDEVICE_A_LISTEN_PORT] = { .type = NETLINK_TYPE_U16 }, [WGDEVICE_A_FWMARK] = { .type = NETLINK_TYPE_U32 }, [WGDEVICE_A_PEERS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_peer_type_system }, diff --git a/src/libsystemd/sd-netlink/netlink-types-rtnl.c b/src/libsystemd/sd-netlink/netlink-types-rtnl.c index e2e999711ff..3424bd625a6 100644 --- a/src/libsystemd/sd-netlink/netlink-types-rtnl.c +++ b/src/libsystemd/sd-netlink/netlink-types-rtnl.c @@ -943,10 +943,10 @@ static const NLType rtnl_route_types[] = { [RTA_GATEWAY] = { .type = NETLINK_TYPE_IN_ADDR }, [RTA_PRIORITY] = { .type = NETLINK_TYPE_U32 }, [RTA_PREFSRC] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ - [RTA_METRICS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_metrics_type_system}, - [RTA_MULTIPATH] = { .size = sizeof(struct rtnexthop) }, + [RTA_METRICS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_metrics_type_system }, + [RTA_MULTIPATH] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rtnexthop) }, [RTA_FLOW] = { .type = NETLINK_TYPE_U32 }, /* 6? */ - [RTA_CACHEINFO] = { .size = sizeof(struct rta_cacheinfo) }, + [RTA_CACHEINFO] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rta_cacheinfo) }, [RTA_TABLE] = { .type = NETLINK_TYPE_U32 }, [RTA_MARK] = { .type = NETLINK_TYPE_U32 }, [RTA_MFC_STATS] = { .type = NETLINK_TYPE_U64 }, @@ -1002,11 +1002,11 @@ static const NLType rtnl_routing_policy_rule_types[] = { [FRA_OIFNAME] = { .type = NETLINK_TYPE_STRING }, [FRA_PAD] = { .type = NETLINK_TYPE_U32 }, [FRA_L3MDEV] = { .type = NETLINK_TYPE_U8 }, - [FRA_UID_RANGE] = { .size = sizeof(struct fib_rule_uid_range) }, + [FRA_UID_RANGE] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct fib_rule_uid_range) }, [FRA_PROTOCOL] = { .type = NETLINK_TYPE_U8 }, [FRA_IP_PROTO] = { .type = NETLINK_TYPE_U8 }, - [FRA_SPORT_RANGE] = { .size = sizeof(struct fib_rule_port_range) }, - [FRA_DPORT_RANGE] = { .size = sizeof(struct fib_rule_port_range) }, + [FRA_SPORT_RANGE] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct fib_rule_port_range) }, + [FRA_DPORT_RANGE] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct fib_rule_port_range) }, }; DEFINE_TYPE_SYSTEM(rtnl_routing_policy_rule); @@ -1097,7 +1097,7 @@ static const NLType rtnl_tca_option_data_fq_pie_types[] = { }; static const NLType rtnl_tca_option_data_gred_types[] = { - [TCA_GRED_DPS] = { .size = sizeof(struct tc_gred_sopt) }, + [TCA_GRED_DPS] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_gred_sopt) }, }; static const NLType rtnl_tca_option_data_hhf_types[] = { @@ -1105,10 +1105,10 @@ static const NLType rtnl_tca_option_data_hhf_types[] = { }; static const NLType rtnl_tca_option_data_htb_types[] = { - [TCA_HTB_PARMS] = { .size = sizeof(struct tc_htb_opt) }, - [TCA_HTB_INIT] = { .size = sizeof(struct tc_htb_glob) }, - [TCA_HTB_CTAB] = { .size = TC_RTAB_SIZE }, - [TCA_HTB_RTAB] = { .size = TC_RTAB_SIZE }, + [TCA_HTB_PARMS] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_htb_opt) }, + [TCA_HTB_INIT] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_htb_glob) }, + [TCA_HTB_CTAB] = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE }, + [TCA_HTB_RTAB] = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE }, [TCA_HTB_RATE64] = { .type = NETLINK_TYPE_U64 }, [TCA_HTB_CEIL64] = { .type = NETLINK_TYPE_U64 }, }; @@ -1123,13 +1123,13 @@ static const NLType rtnl_tca_option_data_qfq_types[] = { }; static const NLType rtnl_tca_option_data_sfb_types[] = { - [TCA_SFB_PARMS] = { .size = sizeof(struct tc_sfb_qopt) }, + [TCA_SFB_PARMS] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_sfb_qopt) }, }; static const NLType rtnl_tca_option_data_tbf_types[] = { - [TCA_TBF_PARMS] = { .size = sizeof(struct tc_tbf_qopt) }, - [TCA_TBF_RTAB] = { .size = TC_RTAB_SIZE }, - [TCA_TBF_PTAB] = { .size = TC_RTAB_SIZE }, + [TCA_TBF_PARMS] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_tbf_qopt) }, + [TCA_TBF_RTAB] = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE }, + [TCA_TBF_PTAB] = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE }, [TCA_TBF_RATE64] = { .type = NETLINK_TYPE_U64 }, [TCA_TBF_PRATE64] = { .type = NETLINK_TYPE_U64 }, [TCA_TBF_BURST] = { .type = NETLINK_TYPE_U32 }, @@ -1165,7 +1165,7 @@ static const NLType rtnl_tca_types[] = { DEFINE_TYPE_SYSTEM(rtnl_tca); static const NLType rtnl_mdb_types[] = { - [MDBA_SET_ENTRY] = { .size = sizeof(struct br_port_msg) }, + [MDBA_SET_ENTRY] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct br_port_msg) }, }; DEFINE_TYPE_SYSTEM(rtnl_mdb);