ctrl: Fix fd leak in ctrl_listen()
Subsystems (2)
PATCH 1/3 ctrl: Fix fd leak in ctrl_listen()
From: Maks Mishin <[email protected]>
Use the same pattern for handling rtnl_listen() errors that is used across other iproute2 commands. All other commands exit with status of 2 if rtnl_listen fails.
--- genl/ctrl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
genl/ctrl.c +3 -2
@@ -334,8 +334,9 @@ static int ctrl_listen(int argc, char **argv) }if (rtnl_listen (&rth, print_ctrl, (void *) stdout) <0 ) -return -1 ; - +exit (2 ); + +rtnl_close (&rth);return 0 ; }
Signature · 1 line
2.43.0
PATCH 2/3 ip: detect errors in netconf monitor mode
If rtnl_listen() returns error while looking for netconf events, then exit with status of 2 as other iproute2 monitor actions do.
--- ip/ipnetconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ip/ipnetconf.c +2 -1
@@ -193,7 +193,8 @@ static int do_show(int argc, char **argv)perror ("Can not send request" );exit (1 ); } -rtnl_listen (&rth, print_netconf, stdout); +if (rtnl_listen (&rth, print_netconf, stdout) <0 ) +exit (2 ); }else { rth.flags =RTNL_HANDLE_F_SUPPRESS_NLERR ; dump:
Signature · 1 line
2.43.0
PATCH 3/3 ip: detect rtnl_listen errors while monitoring netns
In reply to Stephen HemmingerIf rtnl_listen detects error (such as netlink socket EOF), then exit with status 2 like other iproute2 monitor commands.
--- ip/ipnetns.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ip/ipnetns.c +2 -1
@@ -96,7 +96,8 @@ static int ipnetns_have_nsid(void)close (fd);return 0 ; } -rtnl_listen (&rth, ipnetns_accept_msg,NULL ); +if (rtnl_listen (&rth, ipnetns_accept_msg,NULL ) <0 ) +exit (2 );close (fd); }
Signature · 1 line
2.43.0
This series was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Hello:
This series was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Quoted 10 lines · On Thu, 8 Feb 2024 09:26:27 -0800 you wrote:
From: Maks Mishin <[email protected]>
Use the same pattern for handling
rtnl_listen()errors that is used across other iproute2 commands. All other commands exit with status of 2 ifrtnl_listenfails.Reported-off-by Maks Mishin <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>[...]
Here is the summary with links:
- [iproute2,1/3] ctrl: Fix fd leak in ctrl_listen()
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f4dc6a784f6e - [iproute2,2/3] ip: detect errors in netconf monitor mode https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=00e8a64dac3b - [iproute2,3/3] ip: detect rtnl_listen errors while monitoring netns https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=8f340a075138
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html