git: 8a439f324e90 - main - pf: Remove unused return value from (de)hook_pf()
Kristof Provost
kp at FreeBSD.org
Wed Feb 17 09:29:28 UTC 2021
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=8a439f324e9010a122fa4c00426bde70dc373c2f
commit 8a439f324e9010a122fa4c00426bde70dc373c2f
Author: Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-02-16 11:40:51 +0000
Commit: Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-02-17 08:15:40 +0000
pf: Remove unused return value from (de)hook_pf()
These functions always return 0, which is good, because the code calling
them doesn't handle this error gracefully.
As the functions always succeed remove their return value, and the code
handling their errors (because it was never executed anyway).
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC (“Netgate”’)
---
sys/netpfil/pf/pf_ioctl.c | 40 +++++++++-------------------------------
1 file changed, 9 insertions(+), 31 deletions(-)
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index edc8443dcc0a..028938b9aea0 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -213,8 +213,8 @@ static pfil_return_t pf_check6_out(struct mbuf **m, struct ifnet *ifp,
int flags, void *ruleset __unused, struct inpcb *inp);
#endif
-static int hook_pf(void);
-static int dehook_pf(void);
+static void hook_pf(void);
+static void dehook_pf(void);
static int shutdown_pf(void);
static int pf_load(void);
static void pf_unload(void);
@@ -1814,12 +1814,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td
else {
int cpu;
- error = hook_pf();
- if (error) {
- DPFPRINTF(PF_DEBUG_MISC,
- ("pf: pfil registration failed\n"));
- break;
- }
+ hook_pf();
V_pf_status.running = 1;
V_pf_status.since = time_second;
@@ -1836,12 +1831,7 @@ pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td
error = ENOENT;
else {
V_pf_status.running = 0;
- error = dehook_pf();
- if (error) {
- V_pf_status.running = 1;
- DPFPRINTF(PF_DEBUG_MISC,
- ("pf: pfil unregistration failed\n"));
- }
+ dehook_pf();
V_pf_status.since = time_second;
DPFPRINTF(PF_DEBUG_MISC, ("pf: stopped\n"));
}
@@ -4565,14 +4555,14 @@ VNET_DEFINE_STATIC(pfil_hook_t, pf_ip6_out_hook);
#define V_pf_ip6_out_hook VNET(pf_ip6_out_hook)
#endif
-static int
+static void
hook_pf(void)
{
struct pfil_hook_args pha;
struct pfil_link_args pla;
if (V_pf_pfil_hooked)
- return (0);
+ return;
pha.pa_version = PFIL_VERSION;
pha.pa_modname = "pf";
@@ -4620,15 +4610,14 @@ hook_pf(void)
#endif
V_pf_pfil_hooked = 1;
- return (0);
}
-static int
+static void
dehook_pf(void)
{
if (V_pf_pfil_hooked == 0)
- return (0);
+ return;
#ifdef INET
pfil_remove_hook(V_pf_ip4_in_hook);
@@ -4640,7 +4629,6 @@ dehook_pf(void)
#endif
V_pf_pfil_hooked = 0;
- return (0);
}
static void
@@ -4688,20 +4676,10 @@ pf_load(void)
static void
pf_unload_vnet(void)
{
- int error;
V_pf_vnet_active = 0;
V_pf_status.running = 0;
- error = dehook_pf();
- if (error) {
- /*
- * Should not happen!
- * XXX Due to error code ESRCH, kldunload will show
- * a message like 'No such process'.
- */
- printf("%s : pfil unregisteration fail\n", __FUNCTION__);
- return;
- }
+ dehook_pf();
PF_RULES_WLOCK();
shutdown_pf();
More information about the dev-commits-src-all
mailing list