[lvs-users] [PATCH] ipvsadm: check if a virtual service exists before attempting removal

Emanuele Rocca ema at wikimedia.org
Mon Jul 31 13:35:55 BST 2017

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.

Signed-off-by: Emanuele Rocca <ema at wikimedia.org>
 ipvsadm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ipvsadm.c b/ipvsadm.c
index 1a28d72..f958b11 100644
--- a/ipvsadm.c
+++ b/ipvsadm.c
@@ -942,6 +942,11 @@ static int process_options(int argc, char **argv, int reading_stdin)
 	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);

More information about the lvs-users mailing list