[systemd-commits] 3 commits - src/libsystemd TODO
Tom Gundersen
tomegun at kemper.freedesktop.org
Sat May 3 09:17:36 PDT 2014
TODO | 4 +--
src/libsystemd/sd-rtnl/rtnl-message.c | 45 +++++++++++++++++++++-------------
2 files changed, 30 insertions(+), 19 deletions(-)
New commits:
commit 7ca1d31964a2553f7bd011bc10ac42e0ebc1f975
Author: Tom Gundersen <teg at jklm.no>
Date: Fri May 2 22:29:18 2014 +0200
sd-rtnl-message: append - fix uninitialized memory
We were not properly clearing the padding at the front of some containers.
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 150b46f..9043c67 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -452,24 +452,28 @@ int sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags) {
/* If successful the updated message will be correctly aligned, if
unsuccessful the old message is untouched. */
static int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data, size_t data_length) {
- uint32_t rta_length, message_length;
+ uint32_t rta_length;
+ size_t message_length, padding_length;
struct nlmsghdr *new_hdr;
struct rtattr *rta;
char *padding;
unsigned i;
+ int offset;
assert(m);
assert(m->hdr);
assert(!m->sealed);
assert(NLMSG_ALIGN(m->hdr->nlmsg_len) == m->hdr->nlmsg_len);
- assert(!data || data_length > 0);
- assert(data || m->n_containers < RTNL_CONTAINER_DEPTH);
+ assert(!data || data_length);
+
+ /* get offset of the new attribute */
+ offset = m->hdr->nlmsg_len;
/* get the size of the new rta attribute (with padding at the end) */
rta_length = RTA_LENGTH(data_length);
/* get the new message size (with padding at the end) */
- message_length = m->hdr->nlmsg_len + RTA_ALIGN(rta_length);
+ message_length = offset + RTA_ALIGN(rta_length);
/* realloc to fit the new attribute */
new_hdr = realloc(m->hdr, message_length);
@@ -478,33 +482,35 @@ static int add_rtattr(sd_rtnl_message *m, unsigned short type, const void *data,
m->hdr = new_hdr;
/* get pointer to the attribute we are about to add */
- rta = (struct rtattr *) ((uint8_t *) m->hdr + m->hdr->nlmsg_len);
+ rta = (struct rtattr *) ((uint8_t *) m->hdr + offset);
/* if we are inside containers, extend them */
for (i = 0; i < m->n_containers; i++)
- GET_CONTAINER(m, i)->rta_len += message_length - m->hdr->nlmsg_len;
+ GET_CONTAINER(m, i)->rta_len += message_length - offset;
/* fill in the attribute */
rta->rta_type = type;
rta->rta_len = rta_length;
- if (!data) {
- //TODO: simply return this value rather than check for !data
- /* this is the start of a new container */
- m->container_offsets[m->n_containers ++] = m->hdr->nlmsg_len;
- } else {
+ if (data)
/* we don't deal with the case where the user lies about the type
* and gives us too little data (so don't do that)
- */
+ */
padding = mempcpy(RTA_DATA(rta), data, data_length);
- /* make sure also the padding at the end of the message is initialized */
- memzero(padding,
- (uint8_t *) m->hdr + message_length - (uint8_t *) padding);
+ else {
+ /* if no data was passed, make sure we still initialize the padding
+ note that we can have data_length > 0 (used by some containers) */
+ padding = RTA_DATA(rta);
+ data_length = 0;
}
+ /* make sure also the padding at the end of the message is initialized */
+ padding_length = (uint8_t*)m->hdr + message_length - (uint8_t*)padding;
+ memzero(padding, padding_length);
+
/* update message size */
m->hdr->nlmsg_len = message_length;
- return 0;
+ return offset;
}
static int message_attribute_has_type(sd_rtnl_message *m, uint16_t attribute_type, uint16_t data_type) {
@@ -679,6 +685,7 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
+ assert_return(m->n_containers < RTNL_CONTAINER_DEPTH, -ERANGE);
r = message_attribute_has_type(m, type, NLA_NESTED);
if (r < 0)
@@ -696,6 +703,8 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
if (r < 0)
return r;
+ m->container_offsets[m->n_containers ++] = r;
+
return 0;
}
@@ -725,6 +734,8 @@ int sd_rtnl_message_open_container_union(sd_rtnl_message *m, unsigned short type
if (r < 0)
return r;
+ m->container_offsets[m->n_containers ++] = r;
+
return 0;
}
commit 3f781aa8a0b4490e00975ebc7d4a7b729c7dd9e8
Author: Tom Gundersen <teg at jklm.no>
Date: Fri May 2 15:49:40 2014 +0200
sd-rtnl: route - allow setting multiple matching routes
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 3576274..150b46f 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -146,7 +146,7 @@ int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
return r;
if (nlmsg_type == RTM_NEWROUTE)
- (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
+ (*ret)->hdr->nlmsg_flags |= NLM_F_CREATE | NLM_F_APPEND;
rtm = NLMSG_DATA((*ret)->hdr);
commit 8faf88e5eb5495bd54b2b2ad376e836a530de603
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Apr 30 10:37:13 2014 +0200
TODO
diff --git a/TODO b/TODO
index 5cef3be..6126e91 100644
--- a/TODO
+++ b/TODO
@@ -678,6 +678,7 @@ Features:
- Make sure ID_PATH is always exported and complete for
network devices where possible, so we can safely rely
on Path= matching
+ - check MTUBytes parsing (expecting size_t but we are using unsigned)
* sd-rtnl:
- add support for more attribute types
@@ -686,13 +687,12 @@ Features:
* networkd:
- add more keys to [Route] and [Address] sections
- add support for more DHCPv4 options (and, longer term, other kinds of dynamic config)
+ - send hostname to DHCP server
- add proper initrd support (in particular generate .network/.link files based on /proc/cmdline)
- add reduced [Link] support to .network files
- add Scope= parsing option for [Network]
- properly handle routerless dhcp leases
- set lifetime on the address acquired from dhcp
-
-* sd-network:
- add veth netdev support (c.f. http://shorewall.net/bridge-Shorewall-perl.html#veth)
External:
More information about the systemd-commits
mailing list