Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Check error of rt_setgate and rt_settag



details:   https://anonhg.NetBSD.org/src/rev/423270ac2914
branches:  trunk
changeset: 815012:423270ac2914
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Apr 25 14:38:08 2016 +0000

description:
Check error of rt_setgate and rt_settag

diffstat:

 sys/net/route.c      |  20 +++++++++++++-------
 sys/net/rtsock.c     |  12 ++++++++----
 sys/netinet/if_arp.c |   8 ++++++--
 sys/netinet6/nd6.c   |  10 ++++++++--
 4 files changed, 35 insertions(+), 15 deletions(-)

diffs (142 lines):

diff -r f8adcf1ea732 -r 423270ac2914 sys/net/route.c
--- a/sys/net/route.c   Mon Apr 25 14:30:42 2016 +0000
+++ b/sys/net/route.c   Mon Apr 25 14:38:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.163 2016/04/25 14:30:42 ozaki-r Exp $      */
+/*     $NetBSD: route.c,v 1.164 2016/04/25 14:38:08 ozaki-r Exp $      */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.163 2016/04/25 14:30:42 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.164 2016/04/25 14:38:08 ozaki-r Exp $");
 
 #include <sys/param.h>
 #ifdef RTFLUSH_DEBUG
@@ -549,10 +549,12 @@
                         * Smash the current notion of the gateway to
                         * this destination.  Should check about netmask!!!
                         */
-                       rt->rt_flags |= RTF_MODIFIED;
-                       flags |= RTF_MODIFIED;
+                       error = rt_setgate(rt, gateway);
+                       if (error == 0) {
+                               rt->rt_flags |= RTF_MODIFIED;
+                               flags |= RTF_MODIFIED;
+                       }
                        stat = &rtstat.rts_newgateway;
-                       rt_setgate(rt, gateway);
                }
        } else
                error = EHOSTUNREACH;
@@ -825,8 +827,12 @@
                }
 
                rt_set_ifa(rt, ifa);
-               if (info->rti_info[RTAX_TAG] != NULL)
-                       rt_settag(rt, info->rti_info[RTAX_TAG]);
+               if (info->rti_info[RTAX_TAG] != NULL) {
+                       const struct sockaddr *tag;
+                       tag = rt_settag(rt, info->rti_info[RTAX_TAG]);
+                       if (tag == NULL)
+                               senderr(ENOBUFS);
+               }
                RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key);
                if (info->rti_info[RTAX_IFP] != NULL &&
                    (ifa2 = ifa_ifwithnet(info->rti_info[RTAX_IFP])) != NULL &&
diff -r f8adcf1ea732 -r 423270ac2914 sys/net/rtsock.c
--- a/sys/net/rtsock.c  Mon Apr 25 14:30:42 2016 +0000
+++ b/sys/net/rtsock.c  Mon Apr 25 14:38:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.183 2016/04/25 10:55:01 ozaki-r Exp $     */
+/*     $NetBSD: rtsock.c,v 1.184 2016/04/25 14:38:08 ozaki-r Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.183 2016/04/25 10:55:01 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.184 2016/04/25 14:38:08 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -745,8 +745,12 @@
                                if (error != 0)
                                        senderr(error);
                        }
-                       if (info.rti_info[RTAX_TAG])
-                               rt_settag(rt, info.rti_info[RTAX_TAG]);
+                       if (info.rti_info[RTAX_TAG]) {
+                               const struct sockaddr *tag;
+                               tag = rt_settag(rt, info.rti_info[RTAX_TAG]);
+                               if (tag == NULL)
+                                       senderr(ENOBUFS);
+                       }
                        /* new gateway could require new ifaddr, ifp;
                           flags may also be different; ifp may be specified
                           by ll sockaddr when protocol address is ambiguous */
diff -r f8adcf1ea732 -r 423270ac2914 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Mon Apr 25 14:30:42 2016 +0000
+++ b/sys/netinet/if_arp.c      Mon Apr 25 14:38:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.208 2016/04/19 04:13:56 ozaki-r Exp $     */
+/*     $NetBSD: if_arp.c,v 1.209 2016/04/25 14:38:08 ozaki-r Exp $     */
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.208 2016/04/19 04:13:56 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.209 2016/04/25 14:38:08 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -506,6 +506,10 @@
                break;
        case RTM_ADD:
                gate = arp_setgate(rt, gate, info->rti_info[RTAX_NETMASK]);
+               if (gate == NULL) {
+                       log(LOG_ERR, "%s: arp_setgate failed\n", __func__);
+                       break;
+               }
                if ((rt->rt_flags & RTF_CONNECTED) ||
                    (rt->rt_flags & RTF_LOCAL)) {
                        /*
diff -r f8adcf1ea732 -r 423270ac2914 sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Mon Apr 25 14:30:42 2016 +0000
+++ b/sys/netinet6/nd6.c        Mon Apr 25 14:38:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6.c,v 1.191 2016/04/21 05:07:50 ozaki-r Exp $        */
+/*     $NetBSD: nd6.c,v 1.192 2016/04/25 14:38:08 ozaki-r Exp $        */
 /*     $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $   */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.191 2016/04/21 05:07:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.192 2016/04/25 14:38:08 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1389,6 +1389,12 @@
                        rt_setgate(rt, &u.sa);
                        gate = rt->rt_gateway;
                        RT_DPRINTF("rt_getkey(rt) = %p\n", rt_getkey(rt));
+                       if (gate == NULL) {
+                               log(LOG_ERR,
+                                   "%s: rt_setgate failed on %s\n", __func__,
+                                   if_name(ifp));
+                               break;
+                       }
 
                        RT_DPRINTF("rt_getkey(rt) = %p\n", rt_getkey(rt));
                        if ((rt->rt_flags & RTF_CONNECTED) != 0)



Home | Main Index | Thread Index | Old Index