Skip to content

Commit a925620

Browse files
yuwatabluca
authored andcommitted
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 238ed43. Fixes systemd/systemd#32308 (comment).
1 parent 6840ecb commit a925620

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/libsystemd-network/sd-ndisc-router.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,10 @@ int sd_ndisc_router_get_preference(sd_ndisc_router *rt, uint8_t *ret) {
203203
}
204204

205205
static const char* const ndisc_router_preference_table[] = {
206-
[SD_NDISC_PREFERENCE_LOW] = "low",
207-
[SD_NDISC_PREFERENCE_MEDIUM] = "medium",
208-
[SD_NDISC_PREFERENCE_HIGH] = "high",
206+
[SD_NDISC_PREFERENCE_LOW] = "low",
207+
[SD_NDISC_PREFERENCE_MEDIUM] = "medium",
208+
[SD_NDISC_PREFERENCE_HIGH] = "high",
209+
[SD_NDISC_PREFERENCE_RESERVED] = "reserved",
209210
};
210211

211212
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(ndisc_router_preference, int);

src/libsystemd-network/sd-ndisc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ static int ndisc_handle_router(sd_ndisc *nd, ICMP6Packet *packet) {
248248
if (r < 0)
249249
return r;
250250

251-
log_ndisc(nd, "Received Router Advertisement from %s: flags=0x%0*"PRIx64"%s%s%s, preference=%s, lifetime=%s",
251+
log_ndisc(nd, "Received Router Advertisement from %s: flags=0x%0*"PRIx64"(%s), preference=%s, lifetime=%s",
252252
IN6_ADDR_TO_STRING(&a),
253253
flags & UINT64_C(0x00ffffffffffff00) ? 14 : 2, flags, /* suppress too many zeros if no extension */
254-
s ? " (" : "", s, s ? ")" : "",
254+
s ?: "none",
255255
ndisc_router_preference_to_string(pref),
256256
FORMAT_TIMESPAN(lifetime, USEC_PER_SEC));
257257
}

0 commit comments

Comments
 (0)