git: a31a4ddd39bb - stable/13 - if_enc(4): Make enc_add_hhooks() void
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 08 Oct 2024 10:09:22 UTC
The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=a31a4ddd39bbdf0a5f860f980a3f7b1a97edc9a7 commit a31a4ddd39bbdf0a5f860f980a3f7b1a97edc9a7 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2024-10-01 15:28:37 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2024-10-08 10:07:18 +0000 if_enc(4): Make enc_add_hhooks() void As for the consumer `enc_add_hhooks()`, `hhook_add_hook()` will never fail for the given parameters. Meanwhile, to build the module if_enc(4), at least option INET or INET6 is required, so no need for the error EPFNOSUPPORT. No functional change intended. Reviewed by: ae MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46770 (cherry picked from commit 7643141e9314f1eac0d9ac08457410509e6829ad) (cherry picked from commit d6374ee0517f8d991eafe022e2027dd1e64a2ad1) --- sys/net/if_enc.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index acf62b1b9fcc..ba8b07c1848b 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -95,7 +95,7 @@ static int enc_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); static int enc_clone_create(struct if_clone *, int, caddr_t); static void enc_clone_destroy(struct ifnet *); -static int enc_add_hhooks(struct enc_softc *); +static void enc_add_hhooks(struct enc_softc *); static void enc_remove_hhooks(struct enc_softc *); static const char encname[] = "enc"; @@ -310,13 +310,12 @@ enc_hhook(int32_t hhook_type, int32_t hhook_id, void *udata, void *ctx_data, return (0); } -static int +static void enc_add_hhooks(struct enc_softc *sc) { struct hookinfo hki; - int error; + int error __diagused; - error = EPFNOSUPPORT; hki.hook_func = enc_hhook; hki.hook_helper = NULL; hki.hook_udata = sc; @@ -325,28 +324,23 @@ enc_add_hhooks(struct enc_softc *sc) hki.hook_type = HHOOK_TYPE_IPSEC_IN; error = hhook_add_hook(V_ipsec_hhh_in[HHOOK_IPSEC_INET], &hki, HHOOK_WAITOK); - if (error != 0) - return (error); + MPASS(error == 0); hki.hook_type = HHOOK_TYPE_IPSEC_OUT; error = hhook_add_hook(V_ipsec_hhh_out[HHOOK_IPSEC_INET], &hki, HHOOK_WAITOK); - if (error != 0) - return (error); + MPASS(error == 0); #endif #ifdef INET6 hki.hook_id = AF_INET6; hki.hook_type = HHOOK_TYPE_IPSEC_IN; error = hhook_add_hook(V_ipsec_hhh_in[HHOOK_IPSEC_INET6], &hki, HHOOK_WAITOK); - if (error != 0) - return (error); + MPASS(error == 0); hki.hook_type = HHOOK_TYPE_IPSEC_OUT; error = hhook_add_hook(V_ipsec_hhh_out[HHOOK_IPSEC_INET6], &hki, HHOOK_WAITOK); - if (error != 0) - return (error); + MPASS(error == 0); #endif - return (error); } static void @@ -389,8 +383,7 @@ vnet_enc_init_proto(void *unused __unused) { KASSERT(V_enc_sc != NULL, ("%s: V_enc_sc is %p\n", __func__, V_enc_sc)); - if (enc_add_hhooks(V_enc_sc) != 0) - enc_clone_destroy(V_enc_sc->sc_ifp); + enc_add_hhooks(V_enc_sc); } VNET_SYSINIT(vnet_enc_init_proto, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, vnet_enc_init_proto, NULL);