Do not report an EDQUOT "Disk quota exceeded" error from the routing
authorbluhm <bluhm@openbsd.org>
Fri, 19 Dec 2014 18:57:17 +0000 (18:57 +0000)
committerbluhm <bluhm@openbsd.org>
Fri, 19 Dec 2014 18:57:17 +0000 (18:57 +0000)
code.  Instead generate an ENOBUFS "No buffer space available" error
at the malloc(9) failure in rt_setgate(9) and propagate it.
OK mpi@

share/man/man9/route.9
sys/net/route.c
sys/net/rtsock.c

index 51d11a8..e68b099 100644 (file)
@@ -1,4 +1,4 @@
-.\"     $OpenBSD: route.9,v 1.13 2014/11/01 21:45:54 mpi Exp $
+.\"     $OpenBSD: route.9,v 1.14 2014/12/19 18:57:17 bluhm Exp $
 .\"
 .\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org>
 .\" All rights reserved.
@@ -15,7 +15,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: November 1 2014 $
+.Dd $Mdocdate: December 19 2014 $
 .Dt ROUTE 9
 .Os
 .Sh NAME
@@ -81,7 +81,12 @@ sockets.
 .El
 .Sh RETURN VALUES
 .Fn rt_setgate
-returns non-0 if it cannot allocate memory.
+may fail with:
+.Pp
+.Bl -tag -width Er -compact
+.It Bq Er ENOBUFS
+Memory could not be allocated for the gateway.
+.El
 .Pp
 .Fn rtdeletemsg
 may fail with:
index b933dd0..d6b616b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: route.c,v 1.194 2014/12/08 10:46:14 mpi Exp $ */
+/*     $OpenBSD: route.c,v 1.195 2014/12/19 18:57:17 bluhm Exp $       */
 /*     $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $      */
 
 /*
@@ -834,10 +834,10 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio,
                        prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
                rt->rt_priority = prio; /* init routing priority */
                LIST_INIT(&rt->rt_timer);
-               if (rt_setgate(rt, info->rti_info[RTAX_DST],
-                   info->rti_info[RTAX_GATEWAY], tableid)) {
+               if ((error = rt_setgate(rt, info->rti_info[RTAX_DST],
+                   info->rti_info[RTAX_GATEWAY], tableid))) {
                        pool_put(&rtentry_pool, rt);
-                       senderr(ENOBUFS);
+                       senderr(error);
                }
                ndst = rt_key(rt);
                if (info->rti_info[RTAX_NETMASK] != NULL) {
@@ -997,7 +997,7 @@ rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate,
                old = (caddr_t)rt_key(rt);
                new = malloc(dlen + glen, M_RTABLE, M_NOWAIT);
                if (new == NULL)
-                       return 1;
+                       return (ENOBUFS);
                rt->rt_nodes->rn_key = new;
        } else {
                new = rt->rt_nodes->rn_key;
index 52f2ac3..80c53bc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rtsock.c,v 1.154 2014/12/11 08:55:10 mpi Exp $        */
+/*     $OpenBSD: rtsock.c,v 1.155 2014/12/19 18:57:17 bluhm Exp $      */
 /*     $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $  */
 
 /*
@@ -750,11 +750,9 @@ report:
                                        newgate = 1;
                                }
                        if (info.rti_info[RTAX_GATEWAY] != NULL &&
-                           rt_setgate(rt, rt_key(rt),
-                           info.rti_info[RTAX_GATEWAY], tableid)) {
-                               error = EDQUOT;
+                           (error = rt_setgate(rt, rt_key(rt),
+                           info.rti_info[RTAX_GATEWAY], tableid)))
                                goto flush;
-                       }
                        /*
                         * new gateway could require new ifaddr, ifp;
                         * flags may also be different; ifp may be specified