Skip to contentSkip to conversation

ipvsadm: check if a virtual service exists before attempting removal

PATCH In review Emanuele Rocca 2 participants 2 messages Jul 31, 2017 – Aug 5, 2017 IPVS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipvsadm: check if a virtual service exists before attempting removal

Removing a non-existing service results in a confusing "Memory allocation problem" error message:

        # ipvsadm -D -t example.org:80
        Memory allocation problem

Check if the given service exists before attempting removal. Inform the user if the service is not defined.

---
 ipvsadm.c | 5 +++++
 1 file changed, 5 insertions(+)
ipvsadm.c +5 -0
index 1a28d72..f958b11 100644
@@ -942,6 +942,11 @@ static int process_options(int argc, char **argv, int reading_stdin)
 		break;
 
 	case CMD_DEL:
+		if (!(ipvs_get_service(ce.svc.fwmark, ce.svc.af, ce.svc.protocol,
+						   ce.svc.addr, ce.svc.port))) {
+			fprintf(stderr, "No such service\n");
+			exit(1);
+		}
 		result = ipvs_del_service(&ce.svc);
 		break;
 
Signature · 1 line
2.13.3
maintainer
#1 lore raw

Hello,

Quoted 19 lines · Emanuele Rocca

Removing a non-existing service results in a confusing "Memory allocation problem" error message:

        # ipvsadm -D -t example.org:80
        Memory allocation problem

Check if the given service exists before attempting removal. Inform the user if the service is not defined.

---
 ipvsadm.c | 5 +++++
 1 file changed, 5 insertions(+)
ipvsadm.c +0 -0
index 1a28d72..f958b11 100644

ipvsadm.c static int process_options(int argc, char **argv, int reading_stdin) · line 950

Quoted 9 lines
ipvsadm.c +5 -0
@@ -942,6 +942,11 @@ static int process_options(int argc, char **argv, int reading_stdin)
 		break;
 
 	case CMD_DEL:
+		if (!(ipvs_get_service(ce.svc.fwmark, ce.svc.af, ce.svc.protocol,
+						   ce.svc.addr, ce.svc.port))) {
+			fprintf(stderr, "No such service\n");
+			exit(1);
+		}
 		result = ipvs_del_service(&ce.svc);

After some debugging, I think I found the cause for
this problem. It affects all command failures when ipvsadm is compiled to use libnl, so I'm providing more general patch to fix this problem. I'll post it soon...

Regards

--
Julian Anastasov <[email protected]>