mgmtd: Fixed bug,In daemon mode, this stream points to /dev/null and is read-only, which caused an error. As a result, the buffer vty->buf was closed, leading to the crash.

clashlog:
MGMTD: Received signal 11 at 1745121262 (si_addr 0x0, PC 0x7b13a09988f9); aborting...
MGMTD: zlog_signal+0xf9 7b13a0cd2ec9 7ffce3846830 /usr/lib/frr/libfrr.so.0 (mapped at 0x7b13a0c00000)
MGMTD: core_handler+0xb5 7b13a0d13715 7ffce3846970 /usr/lib/frr/libfrr.so.0 (mapped at 0x7b13a0c00000)
MGMTD: __sigaction+0x50 7b13a0845330 7ffce3846ac0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7b13a0800000)
MGMTD: ---- signal ----
MGMTD: __nss_database_lookup+0x10919 7b13a09988f9 7ffce38477c8 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7b13a0800000)
MGMTD: _IO_getline_info+0x124 7b13a0886ff4 7ffce38477d0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7b13a0800000)
MGMTD: fgets+0xa4 7b13a0885bd4 7ffce3847830 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7b13a0800000)
MGMTD: config_from_file+0x45 7b13a0c9f6d5 7ffce3847860 /usr/lib/frr/libfrr.so.0 (mapped at 0x7b13a0c00000)
MGMTD: mgmt_vty_read_configs+0x16c 7b13a0d3263c 7ffce38478a0 /usr/lib/frr/libfrr.so.0 (mapped at 0x7b13a0c00000)
MGMTD: event_call+0xae 7b13a0d269be 7ffce3848910 /usr/lib/frr/libfrr.so.0 (mapped at 0x7b13a0c00000)
MGMTD: frr_run+0xc8 7b13a0cc9bd8 7ffce3848a40 /usr/lib/frr/libfrr.so.0 (mapped at 0x7b13a0c00000)
MGMTD: main+0x157 597895ef2b57 7ffce3848b60 /usr/lib/frr/mgmtd (mapped at 0x597895edd000)
MGMTD: __libc_init_first+0x8a 7b13a082a1ca 7ffce3848ba0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7b13a0800000)
MGMTD: __libc_start_main+0x8b 7b13a082a28b 7ffce3848c40 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7b13a0800000)
MGMTD: _start+0x25 597895ef3045 7ffce3848ca0 /usr/lib/frr/mgmtd (mapped at 0x597895edd000)
MGMTD: in thread mgmt_config_read_in scheduled from mgmtd/mgmt_vty.c:655 mgmt_vty_init()

Signed-off-by: huachao01 <huachao01@corp.netease.com>
This commit is contained in:
huachao01 2025-04-20 12:39:25 +08:00
parent 004c6c0260
commit 31191e61c2

View file

@ -1217,7 +1217,7 @@ void frr_run(struct event_loop *loop)
daemon_ctl_sock, &daemon_ctl_thread);
}
} else if (di->daemon_mode) {
int nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
int nullfd = open("/dev/null", O_RDWR | O_NOCTTY);
if (nullfd == -1) {
flog_err_sys(EC_LIB_SYSTEM_CALL,
"%s: failed to open /dev/null: %s",