From 26fde72265073b26498ce55596c0eda1bc3113b4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 16 Sep 2024 20:27:56 +0200 Subject: Adding upstream version 256.6. Signed-off-by: Daniel Baumann --- src/libsystemd/sd-netlink/test-netlink.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/libsystemd') diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c index cf19c48..c58cfc0 100644 --- a/src/libsystemd/sd-netlink/test-netlink.c +++ b/src/libsystemd/sd-netlink/test-netlink.c @@ -92,18 +92,24 @@ TEST(message_address) { struct in_addr in_data; struct ifa_cacheinfo cache; const char *label; + int r; assert_se(sd_netlink_open(&rtnl) >= 0); ifindex = (int) if_nametoindex("lo"); assert_se(sd_rtnl_message_new_addr(rtnl, &message, RTM_GETADDR, ifindex, AF_INET) >= 0); assert_se(sd_netlink_message_set_request_dump(message, true) >= 0); - assert_se(sd_netlink_call(rtnl, message, 0, &reply) == 1); - assert_se(sd_netlink_message_read_in_addr(reply, IFA_LOCAL, &in_data) >= 0); - assert_se(sd_netlink_message_read_in_addr(reply, IFA_ADDRESS, &in_data) >= 0); - assert_se(sd_netlink_message_read_string(reply, IFA_LABEL, &label) >= 0); - assert_se(sd_netlink_message_read_cache_info(reply, IFA_CACHEINFO, &cache) == 0); + r = sd_netlink_call(rtnl, message, 0, &reply); + assert_se(r >= 0); + + /* If the loopback device is down we won't get any results. */ + if (r > 0) { + assert_se(sd_netlink_message_read_in_addr(reply, IFA_LOCAL, &in_data) >= 0); + assert_se(sd_netlink_message_read_in_addr(reply, IFA_ADDRESS, &in_data) >= 0); + assert_se(sd_netlink_message_read_string(reply, IFA_LABEL, &label) >= 0); + assert_se(sd_netlink_message_read_cache_info(reply, IFA_CACHEINFO, &cache) == 0); + } } TEST(message_route) { -- cgit v1.2.3