summaryrefslogtreecommitdiff
path: root/sys/net/if_vlan.c
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2021-06-16 00:21:17 +0000
committerriastradh <riastradh@NetBSD.org>2021-06-16 00:21:17 +0000
commitbbdda93be2f0bfefe91466b398fe42700a6ea284 (patch)
treee75e77046575209dbb21f73d0bc44c61ec0ec6c0 /sys/net/if_vlan.c
parent5a96957fa793651c8e7093a5a4c2fcae87232af2 (diff)
if_attach and if_initialize cannot fail, don't test return value
These were originally made failable back in 2017 when if_initialize allocated a softint in every interface for link state changes, so that it could fail gracefully instead of panicking: https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html However, this spawned many seldom- or never-tested error branches, which are risky to have around. And that softint in every interface has since been replaced by a single global workqueue, because link state changes require thread context but not low latency or high throughput: https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html So there is no longer any reason for if_initialize to fail. (The subroutine if_stats_init can't fail because percpu_alloc can't fail either.) There is a snag: the softint_establish in if_percpuq_create could fail, potentially leading to bad consequences later on trying to use the softint. This change doesn't introduce any new bugs because of the snag -- if_percpuq_attach was already broken. However, the snag can be better addressed without spawning error branches, either by using a single softint or making softints less scarce. (Separate commit will change the signatures of if_attach and if_initialize to return void, scheduled to ride whatever is the next convenient kernel bump.) Patch and testing on amd64 and evbmips64-eb by maya@; commit message soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
Diffstat (limited to 'sys/net/if_vlan.c')
-rw-r--r--sys/net/if_vlan.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 7901267f805..33eabe4a6f4 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.153 2020/09/26 18:38:09 roy Exp $ */
+/* $NetBSD: if_vlan.c,v 1.154 2021/06/16 00:21:19 riastradh Exp $ */
/*
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.153 2020/09/26 18:38:09 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.154 2021/06/16 00:21:19 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -333,7 +333,6 @@ vlan_clone_create(struct if_clone *ifc, int unit)
struct ifvlan *ifv;
struct ifnet *ifp;
struct ifvlan_linkmib *mib;
- int rv;
ifv = malloc(sizeof(struct ifvlan), M_DEVBUF, M_WAITOK | M_ZERO);
mib = kmem_zalloc(sizeof(struct ifvlan_linkmib), KM_SLEEP);
@@ -362,14 +361,7 @@ vlan_clone_create(struct if_clone *ifc, int unit)
ifp->if_transmit = vlan_transmit;
ifp->if_ioctl = vlan_ioctl;
IFQ_SET_READY(&ifp->if_snd);
-
- rv = if_initialize(ifp);
- if (rv != 0) {
- aprint_error("%s: if_initialize failed(%d)\n", ifp->if_xname,
- rv);
- goto fail;
- }
-
+ if_initialize(ifp);
/*
* Set the link state to down.
* When the parent interface attaches we will use that link state.
@@ -380,18 +372,6 @@ vlan_clone_create(struct if_clone *ifc, int unit)
vlan_reset_linkname(ifp);
if_register(ifp);
return 0;
-
-fail:
- mutex_enter(&ifv_list.lock);
- LIST_REMOVE(ifv, ifv_list);
- mutex_exit(&ifv_list.lock);
-
- mutex_destroy(&ifv->ifv_lock);
- psref_target_destroy(&ifv->ifv_mib->ifvm_psref, ifvm_psref_class);
- kmem_free(ifv->ifv_mib, sizeof(struct ifvlan_linkmib));
- free(ifv, M_DEVBUF);
-
- return rv;
}
static int