diff options
author | Tom Gundersen <teg@jklm.no> | 2014-03-05 11:47:38 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-03-05 11:52:32 +0100 |
commit | 3b35ade3fd015482a450fe20edb7c7b7ccbbb803 (patch) | |
tree | c09982fc0d31cb89a828972da313fc5609c2c5a2 | |
parent | 02ec5cd78a148c2c05c0d6e5016ae04570a9ef97 (diff) |
sd-rtnl: do not blindly enter containers in message_read()
We need a separate container_enter() function, which will be part of a largerg
API change. For now, just fix message_read().
-rw-r--r-- | src/libsystemd/sd-rtnl/rtnl-message.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/test-rtnl.c | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c index 95dccc2f81..41a6e4ea85 100644 --- a/src/libsystemd/sd-rtnl/rtnl-message.c +++ b/src/libsystemd/sd-rtnl/rtnl-message.c @@ -778,7 +778,7 @@ int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data) if (!RTA_OK(NEXT_RTA(m), remaining_size)) return 0; - /* if we read a container, enter it and return its type */ + /* if we read a container, return its type, but do not enter it*/ r = sd_rtnl_message_get_type(m, &rtm_type); if (r < 0) return r; @@ -790,14 +790,12 @@ int sd_rtnl_message_read(sd_rtnl_message *m, unsigned short *type, void **data) NEXT_RTA(m)->rta_type == IFLA_LINKINFO) || (m->n_containers == 1 && GET_CONTAINER(m, 0)->rta_type == IFLA_LINKINFO && - NEXT_RTA(m)->rta_type == IFLA_INFO_DATA))) { + NEXT_RTA(m)->rta_type == IFLA_INFO_DATA))) *data = NULL; - PUSH_CONTAINER(m, NEXT_RTA(m)); - UPDATE_RTA(m, RTA_DATA(NEXT_RTA(m))); - } else { + else *data = RTA_DATA(NEXT_RTA(m)); - UPDATE_RTA(m, RTA_NEXT(NEXT_RTA(m), remaining_size)); - } + + UPDATE_RTA(m, RTA_NEXT(NEXT_RTA(m), remaining_size)); return 1; } diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c index dd74e76ed4..1016bb6d4e 100644 --- a/src/libsystemd/sd-rtnl/test-rtnl.c +++ b/src/libsystemd/sd-rtnl/test-rtnl.c @@ -302,6 +302,7 @@ static void test_container(void) { assert_se(sd_rtnl_message_read(m, &type, &data) >= 0); assert_se(type == IFLA_LINKINFO); assert_se(data == NULL); +/* assert_se(sd_rtnl_message_read(m, &type, &data) >= 0); assert_se(type == IFLA_INFO_KIND); assert_se(streq("kind", (char *)data)); @@ -318,6 +319,7 @@ static void test_container(void) { assert_se(streq("kind", (char *)data)); assert_se(sd_rtnl_message_read(m, &type, &data) == 0); assert_se(sd_rtnl_message_exit_container(m) >= 0); +*/ assert_se(sd_rtnl_message_exit_container(m) == -EINVAL); } |