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”’)
This commit is contained in:
Kristof Provost 2021-02-16 12:40:51 +01:00
parent 6b7e592c21
commit 8a439f324e

View File

@ -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();