Subject: Re: ip route del bug?

From: Jamal Hadi Salim <[email-masked]>
Date: Thu, 05 May 2005 15:15:24 -0400

On Thu, 2005-05-05 at 20:52 +0200, Patrick McHardy wrote:
> Stephen Hemminger wrote:
> > It looks like an accidental behaviour (of the kernel) in response to
> > an ip route delete netlink message with no additional data.
> 
> I don't believe it is accidental, it seems correct to me to delete
> the default route when no more specific selector is given. To avoid
> this, iproute could print an error when dst.bytelen == 0.

Agreed - basically the kernel does what its told.  
I think the check should be on missing dst (default will always give you
bytelen of 0 for example and is legit).
Patchlet attached.

cheers,
jamal
--- a/ip/iproute.c	2005/05/05 18:56:30	1.1
+++ b/ip/iproute.c	2005/05/05 19:10:49
@@ -857,6 +857,11 @@
 		argc--; argv++;
 	}
 
+	if (!dst_ok) {
+		fprintf(stderr,"route must specify destination address \n");
+		return -1;
+	}
+
 	if (rtnl_open(&rth, 0) < 0)
 		exit(1);