git: 7643141e9314 - main - if_enc(4): Make enc_add_hhooks() void
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 01 Oct 2024 15:30:37 UTC
The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=7643141e9314f1eac0d9ac08457410509e6829ad commit 7643141e9314f1eac0d9ac08457410509e6829ad Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2024-10-01 15:28:37 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2024-10-01 15:28:37 +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 --- 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 18587dc1cb46..3c7ae38324c3 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -96,7 +96,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"; @@ -315,13 +315,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; @@ -330,28 +329,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 @@ -394,8 +388,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);