From: Yu Watanabe Date: Wed, 22 May 2024 15:38:38 +0000 (+0900) Subject: sd-ndisc: do not print "(null)" in the log message X-Git-Tag: v256-rc3~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a925620f5fc906bfdbef5fb83f852fe355ef1ad2;p=thirdparty%2Fsystemd.git sd-ndisc: do not print "(null)" in the log message If we received RA with no flags set, or with an invalid preference, previously "(null)" was printed. Follow-up for 238ed432c347ddf7dde7825feb2672b089583103. Fixes https://github.com/systemd/systemd/pull/32308#discussion_r1600940289. --- diff --git a/src/libsystemd-network/sd-ndisc-router.c b/src/libsystemd-network/sd-ndisc-router.c index b2ad41434e5..9ca737d4939 100644 --- a/src/libsystemd-network/sd-ndisc-router.c +++ b/src/libsystemd-network/sd-ndisc-router.c @@ -203,9 +203,10 @@ int sd_ndisc_router_get_preference(sd_ndisc_router *rt, uint8_t *ret) { } static const char* const ndisc_router_preference_table[] = { - [SD_NDISC_PREFERENCE_LOW] = "low", - [SD_NDISC_PREFERENCE_MEDIUM] = "medium", - [SD_NDISC_PREFERENCE_HIGH] = "high", + [SD_NDISC_PREFERENCE_LOW] = "low", + [SD_NDISC_PREFERENCE_MEDIUM] = "medium", + [SD_NDISC_PREFERENCE_HIGH] = "high", + [SD_NDISC_PREFERENCE_RESERVED] = "reserved", }; DEFINE_STRING_TABLE_LOOKUP_TO_STRING(ndisc_router_preference, int); diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c index 2e303965f89..ca15f942f56 100644 --- a/src/libsystemd-network/sd-ndisc.c +++ b/src/libsystemd-network/sd-ndisc.c @@ -248,10 +248,10 @@ static int ndisc_handle_router(sd_ndisc *nd, ICMP6Packet *packet) { if (r < 0) return r; - log_ndisc(nd, "Received Router Advertisement from %s: flags=0x%0*"PRIx64"%s%s%s, preference=%s, lifetime=%s", + log_ndisc(nd, "Received Router Advertisement from %s: flags=0x%0*"PRIx64"(%s), preference=%s, lifetime=%s", IN6_ADDR_TO_STRING(&a), flags & UINT64_C(0x00ffffffffffff00) ? 14 : 2, flags, /* suppress too many zeros if no extension */ - s ? " (" : "", s, s ? ")" : "", + s ?: "none", ndisc_router_preference_to_string(pref), FORMAT_TIMESPAN(lifetime, USEC_PER_SEC)); }