Source-Changes-HG archive

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

[src/trunk]: src/sys/net Make if_stats_init, if_attach, if_initialize return ...



details:   https://anonhg.NetBSD.org/src/rev/4898abaaeceb
branches:  trunk
changeset: 379981:4898abaaeceb
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jun 29 21:19:58 2021 +0000

description:
Make if_stats_init, if_attach, if_initialize return void.

percpu_alloc can't fail.


Author: Maya Rashish <maya%NetBSD.org@localhost>
Committer: Taylor R Campbell <riastradh%NetBSD.org@localhost>

diffstat:

 sys/net/if.c       |  35 +++++++----------------------------
 sys/net/if.h       |   6 +++---
 sys/net/if_stats.c |   9 +++------
 sys/net/if_stats.h |   4 ++--
 4 files changed, 15 insertions(+), 39 deletions(-)

diffs (152 lines):

diff -r fe35277e8052 -r 4898abaaeceb sys/net/if.c
--- a/sys/net/if.c      Tue Jun 29 21:16:54 2021 +0000
+++ b/sys/net/if.c      Tue Jun 29 21:19:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.485 2021/05/17 04:07:43 yamaguchi Exp $       */
+/*     $NetBSD: if.c,v 1.486 2021/06/29 21:19:58 riastradh Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.485 2021/05/17 04:07:43 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.486 2021/06/29 21:19:58 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -702,10 +702,9 @@ skip:
  *     ether_ifattach(ifp, enaddr);
  *     if_register(ifp);
  */
-int
+void
 if_initialize(ifnet_t *ifp)
 {
-       int rv = 0;
 
        KASSERT(if_indexlim > 0);
        TAILQ_INIT(&ifp->if_addrlist);
@@ -748,25 +747,11 @@ if_initialize(ifnet_t *ifp)
        psref_target_init(&ifp->if_psref, ifnet_psref_class);
        ifp->if_ioctl_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
        LIST_INIT(&ifp->if_multiaddrs);
-       if ((rv = if_stats_init(ifp)) != 0) {
-               goto fail;
-       }
+       if_stats_init(ifp);
 
        IFNET_GLOBAL_LOCK();
        if_getindex(ifp);
        IFNET_GLOBAL_UNLOCK();
-
-       return 0;
-
-fail:
-       IF_AFDATA_LOCK_DESTROY(ifp);
-
-       pfil_run_ifhooks(if_pfil, PFIL_IFNET_DETACH, ifp);
-       (void)pfil_head_destroy(ifp->if_pfil);
-
-       IFQ_LOCK_DESTROY(&ifp->if_snd);
-
-       return rv;
 }
 
 /*
@@ -1142,19 +1127,13 @@ if_input(struct ifnet *ifp, struct mbuf 
  * migrate softint-based if_input without much changes. If you don't
  * want to enable it, use if_initialize instead.
  */
-int
+void
 if_attach(ifnet_t *ifp)
 {
-       int rv;
-
-       rv = if_initialize(ifp);
-       if (rv != 0)
-               return rv;
-
+
+       if_initialize(ifp);
        ifp->if_percpuq = if_percpuq_create(ifp);
        if_register(ifp);
-
-       return 0;
 }
 
 void
diff -r fe35277e8052 -r 4898abaaeceb sys/net/if.h
--- a/sys/net/if.h      Tue Jun 29 21:16:54 2021 +0000
+++ b/sys/net/if.h      Tue Jun 29 21:19:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.290 2021/05/17 04:07:43 yamaguchi Exp $       */
+/*     $NetBSD: if.h,v 1.291 2021/06/29 21:19:58 riastradh Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1115,9 +1115,9 @@ void if_activate_sadl(struct ifnet *, st
 void   if_set_sadl(struct ifnet *, const void *, u_char, bool);
 void   if_alloc_sadl(struct ifnet *);
 void   if_free_sadl(struct ifnet *, int);
-int    if_initialize(struct ifnet *);
+void   if_initialize(struct ifnet *);
 void   if_register(struct ifnet *);
-int    if_attach(struct ifnet *); /* Deprecated. Use if_initialize and if_register */
+void   if_attach(struct ifnet *); /* Deprecated. Use if_initialize and if_register */
 void   if_attachdomain(void);
 void   if_deactivate(struct ifnet *);
 bool   if_is_deactivated(const struct ifnet *);
diff -r fe35277e8052 -r 4898abaaeceb sys/net/if_stats.c
--- a/sys/net/if_stats.c        Tue Jun 29 21:16:54 2021 +0000
+++ b/sys/net/if_stats.c        Tue Jun 29 21:19:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stats.c,v 1.3 2020/02/14 22:04:12 thorpej Exp $     */
+/*     $NetBSD: if_stats.c,v 1.4 2021/06/29 21:19:58 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stats.c,v 1.3 2020/02/14 22:04:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stats.c,v 1.4 2021/06/29 21:19:58 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -45,13 +45,10 @@
  * if_stats_init --
  *     Initialize statistics storage for a network interface.
  */
-int
+void
 if_stats_init(ifnet_t * const ifp)
 {
        ifp->if_stats = percpu_alloc(IF_STATS_SIZE);
-       if (ifp->if_stats == NULL)
-               return ENOMEM;
-       return 0;
 }
 
 /*
diff -r fe35277e8052 -r 4898abaaeceb sys/net/if_stats.h
--- a/sys/net/if_stats.h        Tue Jun 29 21:16:54 2021 +0000
+++ b/sys/net/if_stats.h        Tue Jun 29 21:19:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stats.h,v 1.2 2020/02/14 22:04:12 thorpej Exp $     */
+/*     $NetBSD: if_stats.h,v 1.3 2021/06/29 21:19:58 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -115,7 +115,7 @@ if_statsub_ref(net_stat_ref_t nsr, if_st
        _NET_STATSUB_REF(nsr, x, v);
 }
 
-int    if_stats_init(ifnet_t *);
+void   if_stats_init(ifnet_t *);
 void   if_stats_fini(ifnet_t *);
 void   if_stats_to_if_data(ifnet_t *, struct if_data *, bool);
 



Home | Main Index | Thread Index | Old Index