Skip to contentSkip to conversation

kexec/ifdown.c: minimise errors printed

PATCH Applied Mason Rocha 2 participants 5 messages Oct 22, 2025 – Nov 11, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover kexec/ifdown.c: minimise errors printed

On some embedded configurations, kexec generates messages when rebooting to the new kernel. This patch line helps eliminate these messages in the event certain kernel options are set. I'm not too worried about the second patch, but it is along the same line as the first patch and I thought that it should included. Thanks!

Mason Rocha (2):
kexec/ifdown.c: Use AF_NETLINK instead of AF_INET kexec/ifdown.c: Hide error if sockets are disabled

 kexec/ifdown.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--
2.51.0

#1 lore raw

PATCH 1/2 kexec/ifdown.c: Use AF_NETLINK instead of AF_INET

On embedded systems, there is no guarantee that INET support has been built in. However, as long as network support is built into the kernel, we can use the netlink protocol to create a socket to still then use for the ioctl calls since they don't require any certain family. This will help prevent EAFNOSUPPORT from being returned and printed to the console on these systems.

---
 kexec/ifdown.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/ifdown.c +1 -1
index 3ac19c1..6a60bcb 100644
@@ -31,7 +31,7 @@ int ifdown(void)
 	struct ifreq ifr;
 	int fd, shaper;
 
-	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+	if ((fd = socket(AF_NETLINK, SOCK_DGRAM, 0)) < 0) {
 		fprintf(stderr, "ifdown: ");
 		perror("socket");
 		goto error;
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/2 kexec/ifdown.c: Hide error if sockets are disabled

In reply to Mason Rocha

Prevents the message "Function not implemented" from being logged when a system with networking support disabled, as there couldn't possibly be any interfaces to bring down to the point where we need to make sure the user knows that the interfaces were not brought down.

---
 kexec/ifdown.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kexec/ifdown.c +4 -2
index 6a60bcb..e6ea0ae 100644
@@ -32,8 +32,10 @@ int ifdown(void)
 	int fd, shaper;
 
 	if ((fd = socket(AF_NETLINK, SOCK_DGRAM, 0)) < 0) {
-		fprintf(stderr, "ifdown: ");
-		perror("socket");
+		if(errno != ENOSYS) {
+			fprintf(stderr, "ifdown: ");
+			perror("socket");
+		}
 		goto error;
 	}
 
Signature · 1 line
2.51.0
#3 lore raw

Re: [PATCH kexec-tools 2/2] kexec/ifdown.c: Hide error if sockets are disabled

Quoted 15 lines · Mason Rocha

Prevents the message "Function not implemented" from being logged when a system with networking support disabled, as there couldn't possibly be any interfaces to bring down to the point where we need to make sure the user knows that the interfaces were not brought down.

---
 kexec/ifdown.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kexec/ifdown.c +0 -0
index 6a60bcb..e6ea0ae 100644

kexec/ifdown.c int ifdown(void) · line 35

Quoted 6 lines
kexec/ifdown.c +1 -2
@@ -32,8 +32,10 @@ int ifdown(void)
 	int fd, shaper;
 
 	if ((fd = socket(AF_NETLINK, SOCK_DGRAM, 0)) < 0) {
-		fprintf(stderr, "ifdown: ");
-		perror("socket");
+		if(errno != ENOSYS) {

nit: I'd prefer a space between 'if' and '('

I added one when applying this series.

Quoted 9 lines
kexec/ifdown.c +3 -0
+			fprintf(stderr, "ifdown: ");
+			perror("socket");
+		}
 		goto error;
 	}
 
Signature · 1 line
2.51.0
Applied
#4 lore raw
In reply to Mason Rocha
Quoted 5 lines · Mason Rocha

On some embedded configurations, kexec generates messages when rebooting to the new kernel. This patch line helps eliminate these messages in the event certain kernel options are set. I'm not too worried about the second patch, but it is along the same line as the first patch and I thought that it should included. Thanks!

Thanks, applied.

- kexec/ifdown.c: Hide error if sockets are disabled
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=86c3d1f7b646
- kexec/ifdown.c: Use AF_NETLINK instead of AF_INET
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=eb8609a29363