Source-Changes-HG archive

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

[src/trunk]: src/sys/net Ensure we only call pfil_run_hooks if if_init succee...



details:   https://anonhg.NetBSD.org/src/rev/cf9c3d6f8d2c
branches:  trunk
changeset: 347996:cf9c3d6f8d2c
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Sep 29 14:08:40 2016 +0000

description:
Ensure we only call pfil_run_hooks if if_init succeeded.
While here, improve improve some logging.

diffstat:

 sys/net/if_spppsubr.c |  28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diffs (82 lines):

diff -r 83e79eda8703 -r cf9c3d6f8d2c sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c     Thu Sep 29 13:36:30 2016 +0000
+++ b/sys/net/if_spppsubr.c     Thu Sep 29 14:08:40 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_spppsubr.c,v 1.152 2016/09/16 14:17:23 roy Exp $     */
+/*     $NetBSD: if_spppsubr.c,v 1.153 2016/09/29 14:08:40 roy Exp $     */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.152 2016/09/16 14:17:23 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.153 2016/09/29 14:08:40 roy Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -4934,8 +4934,8 @@
 
                if (debug && error)
                {
-                       log(LOG_DEBUG, "%s: sppp_set_ip_addrs: in_ifinit "
-                       " failed, error=%d\n", ifp->if_xname, error);
+                       log(LOG_DEBUG, "%s: %s: in_ifinit failed, error=%d\n",
+                           ifp->if_xname, __func__, error);
                }
                if (!error) {
                        (void)pfil_run_hooks(if_pfil,
@@ -4950,7 +4950,7 @@
 static void
 sppp_clear_ip_addrs(struct sppp *sp)
 {
-       struct ifnet *ifp = &sp->pp_if;
+       STDDCL;
        struct ifaddr *ifa;
        struct sockaddr_in *si, *dest;
 
@@ -4977,6 +4977,7 @@
 found:
        {
                struct sockaddr_in new_sin = *si;
+               int error;
 
                in_ifscrub(ifp, ifatoia(ifa));
                if (sp->ipcp.flags & IPCP_MYADDR_DYN)
@@ -4988,14 +4989,21 @@
                LIST_REMOVE(ifatoia(ifa), ia_hash);
                IN_ADDRHASH_WRITER_REMOVE(ifatoia(ifa));
 
-               in_ifinit(ifp, ifatoia(ifa), &new_sin, 0);
+               error = in_ifinit(ifp, ifatoia(ifa), &new_sin, 0);
 
                LIST_INSERT_HEAD(&IN_IFADDR_HASH(ifatoia(ifa)->ia_addr.sin_addr.s_addr),
                    ifatoia(ifa), ia_hash);
                IN_ADDRHASH_WRITER_INSERT_HEAD(ifatoia(ifa));
 
-               (void)pfil_run_hooks(if_pfil,
-                   (struct mbuf **)SIOCDIFADDR, ifp, PFIL_IFADDR);
+               if (debug && error)
+               {
+                       log(LOG_DEBUG, "%s: %s: in_ifinit failed, error=%d\n",
+                           ifp->if_xname, __func__, error);
+               }
+               if (!error) {
+                       (void)pfil_run_hooks(if_pfil,
+                           (struct mbuf **)SIOCAIFADDR, ifp, PFIL_IFADDR);
+               }
        }
 }
 #endif
@@ -5093,8 +5101,8 @@
                error = in6_ifinit(ifp, ifatoia6(ifa), &new_sin6, 1);
                if (debug && error)
                {
-                       log(LOG_DEBUG, "%s: sppp_set_ip6_addr: in6_ifinit "
-                       " failed, error=%d\n", ifp->if_xname, error);
+                       log(LOG_DEBUG, "%s: %s: in6_ifinit failed, error=%d\n",
+                           ifp->if_xname, __func__, error);
                }
                if (!error) {
                        (void)pfil_run_hooks(if_pfil,



Home | Main Index | Thread Index | Old Index