diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2015-06-23 11:46:48 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2015-06-24 13:45:47 +0200 |
commit | c1df8dee2811e76ec2f7306f13b7559044a88842 (patch) | |
tree | 8c348058b27cca9b24c6f23431da452fcc4bcd34 /src/libsystemd/sd-netlink/netlink-message.c | |
parent | 6c14ad61db68e24932329c4137198ef7f46e35e8 (diff) |
sd-netlink: turn 'max' into 'count' to support empty type-systems
Right now we store the maximum type-ID of a type-system. This prevents us
from creating empty type-systems. Store the "count" instead, which should
be treated as max+1.
Note that type_system_union_protocol_get_type_system() currently has a
nasty hack to treat empty type-systems as invalid. This might need some
modification later on as well.
Diffstat (limited to 'src/libsystemd/sd-netlink/netlink-message.c')
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-message.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c index a41d7f9670..bfbc0e6c95 100644 --- a/src/libsystemd/sd-netlink/netlink-message.c +++ b/src/libsystemd/sd-netlink/netlink-message.c @@ -753,7 +753,7 @@ int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short typ r = rtnl_message_parse(m, &m->rta_offset_tb[m->n_containers], &m->rta_tb_size[m->n_containers], - type_system_get_max(type_system), + type_system_get_count(type_system), container, size); if (r < 0) { @@ -811,17 +811,17 @@ int sd_netlink_message_get_errno(sd_netlink_message *m) { int rtnl_message_parse(sd_netlink_message *m, size_t **rta_offset_tb, unsigned short *rta_tb_size, - int max, + int count, struct rtattr *rta, unsigned int rt_len) { unsigned short type; size_t *tb; - tb = new0(size_t, max + 1); + tb = new0(size_t, count); if(!tb) return -ENOMEM; - *rta_tb_size = max + 1; + *rta_tb_size = count; for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) { type = RTA_TYPE(rta); @@ -829,7 +829,7 @@ int rtnl_message_parse(sd_netlink_message *m, /* if the kernel is newer than the headers we used when building, we ignore out-of-range attributes */ - if (type > max) + if (type >= count) continue; if (tb[type]) @@ -889,7 +889,7 @@ int sd_netlink_message_rewind(sd_netlink_message *m) { r = rtnl_message_parse(m, &m->rta_offset_tb[m->n_containers], &m->rta_tb_size[m->n_containers], - type_system_get_max(type_system), + type_system_get_count(type_system), (struct rtattr*)((uint8_t*)NLMSG_DATA(m->hdr) + NLMSG_ALIGN(size)), NLMSG_PAYLOAD(m->hdr, size)); if (r < 0) |