X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-netlink%2Fnetlink-types.c;h=d22194ad717f7a06d7861716e46e69c62875695f;hp=4ee0e6148e7c59ab6e9f43c24f0733d3ba54dec8;hb=84e862614a39d6e1d5d2317472175ec79bbc769f;hpb=53cb490ec6c1ebe1e19d28fdf504d0d6d57e9425 diff --git a/src/libsystemd/sd-netlink/netlink-types.c b/src/libsystemd/sd-netlink/netlink-types.c index 4ee0e6148..d22194ad7 100644 --- a/src/libsystemd/sd-netlink/netlink-types.c +++ b/src/libsystemd/sd-netlink/netlink-types.c @@ -53,6 +53,15 @@ struct NLTypeSystem { static const NLTypeSystem rtnl_link_type_system; +static const NLType empty_types[1] = { + /* fake array to avoid .types==NULL, which denotes invalid type-systems */ +}; + +static const NLTypeSystem empty_type_system = { + .count = 0, + .types = empty_types, +}; + static const NLType rtnl_link_info_data_veth_types[VETH_INFO_MAX + 1] = { [VETH_INFO_PEER] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, }; @@ -450,8 +459,8 @@ static const NLTypeSystem rtnl_neigh_type_system = { }; static const NLType rtnl_types[RTM_MAX + 1] = { - [NLMSG_DONE] = { .type = NETLINK_TYPE_META, .size = 0 }, - [NLMSG_ERROR] = { .type = NETLINK_TYPE_META, .size = sizeof(struct nlmsgerr) }, + [NLMSG_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = 0 }, + [NLMSG_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = sizeof(struct nlmsgerr) }, [RTM_NEWLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, [RTM_DELLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, [RTM_GETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, @@ -589,7 +598,7 @@ int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_sys return -EOPNOTSUPP; type_system = &type_system_union->type_systems[protocol]; - if (type_system->count == 0) + if (!type_system->types) return -EOPNOTSUPP; *ret = type_system;