mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Clean up comments, white space, and style in pfil.c (especially new VNET
bits). MFC after: 3 days (not VNET bits)
This commit is contained in:
parent
07ba0ec4ff
commit
cee8119875
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=198233
@ -86,14 +86,13 @@ pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PFIL_RUNLOCK(ph, &rmpt);
|
PFIL_RUNLOCK(ph, &rmpt);
|
||||||
|
|
||||||
*mp = m;
|
*mp = m;
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pfil_head_register() registers a pfil_head with the packet filter
|
* pfil_head_register() registers a pfil_head with the packet filter hook
|
||||||
* hook mechanism.
|
* mechanism.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pfil_head_register(struct pfil_head *ph)
|
pfil_head_register(struct pfil_head *ph)
|
||||||
@ -105,7 +104,7 @@ pfil_head_register(struct pfil_head *ph)
|
|||||||
if (ph->ph_type == lph->ph_type &&
|
if (ph->ph_type == lph->ph_type &&
|
||||||
ph->ph_un.phu_val == lph->ph_un.phu_val) {
|
ph->ph_un.phu_val == lph->ph_un.phu_val) {
|
||||||
PFIL_LIST_UNLOCK();
|
PFIL_LIST_UNLOCK();
|
||||||
return EEXIST;
|
return (EEXIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PFIL_LOCK_INIT(ph);
|
PFIL_LOCK_INIT(ph);
|
||||||
@ -151,7 +150,6 @@ pfil_head_get(int type, u_long val)
|
|||||||
if (ph->ph_type == type && ph->ph_un.phu_val == val)
|
if (ph->ph_type == type && ph->ph_un.phu_val == val)
|
||||||
break;
|
break;
|
||||||
PFIL_LIST_UNLOCK();
|
PFIL_LIST_UNLOCK();
|
||||||
|
|
||||||
return (ph);
|
return (ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +206,7 @@ pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
|
|||||||
ph->ph_nhooks++;
|
ph->ph_nhooks++;
|
||||||
}
|
}
|
||||||
PFIL_WUNLOCK(ph);
|
PFIL_WUNLOCK(ph);
|
||||||
return 0;
|
return (0);
|
||||||
locked_error:
|
locked_error:
|
||||||
PFIL_WUNLOCK(ph);
|
PFIL_WUNLOCK(ph);
|
||||||
error:
|
error:
|
||||||
@ -216,12 +214,12 @@ pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
|
|||||||
free(pfh1, M_IFADDR);
|
free(pfh1, M_IFADDR);
|
||||||
if (pfh2 != NULL)
|
if (pfh2 != NULL)
|
||||||
free(pfh2, M_IFADDR);
|
free(pfh2, M_IFADDR);
|
||||||
return err;
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pfil_remove_hook removes a specific function from the packet filter
|
* pfil_remove_hook removes a specific function from the packet filter hook
|
||||||
* hook list.
|
* list.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
|
pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
|
||||||
@ -230,7 +228,6 @@ pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
PFIL_WLOCK(ph);
|
PFIL_WLOCK(ph);
|
||||||
|
|
||||||
if (flags & PFIL_IN) {
|
if (flags & PFIL_IN) {
|
||||||
err = pfil_list_remove(&ph->ph_in, func, arg);
|
err = pfil_list_remove(&ph->ph_in, func, arg);
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
@ -242,8 +239,7 @@ pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
|
|||||||
ph->ph_nhooks--;
|
ph->ph_nhooks--;
|
||||||
}
|
}
|
||||||
PFIL_WUNLOCK(ph);
|
PFIL_WUNLOCK(ph);
|
||||||
|
return (err);
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -257,17 +253,17 @@ pfil_list_add(pfil_list_t *list, struct packet_filter_hook *pfh1, int flags)
|
|||||||
TAILQ_FOREACH(pfh, list, pfil_link)
|
TAILQ_FOREACH(pfh, list, pfil_link)
|
||||||
if (pfh->pfil_func == pfh1->pfil_func &&
|
if (pfh->pfil_func == pfh1->pfil_func &&
|
||||||
pfh->pfil_arg == pfh1->pfil_arg)
|
pfh->pfil_arg == pfh1->pfil_arg)
|
||||||
return EEXIST;
|
return (EEXIST);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* insert the input list in reverse order of the output list
|
* Insert the input list in reverse order of the output list so that
|
||||||
* so that the same path is followed in or out of the kernel.
|
* the same path is followed in or out of the kernel.
|
||||||
*/
|
*/
|
||||||
if (flags & PFIL_IN)
|
if (flags & PFIL_IN)
|
||||||
TAILQ_INSERT_HEAD(list, pfh1, pfil_link);
|
TAILQ_INSERT_HEAD(list, pfh1, pfil_link);
|
||||||
else
|
else
|
||||||
TAILQ_INSERT_TAIL(list, pfh1, pfil_link);
|
TAILQ_INSERT_TAIL(list, pfh1, pfil_link);
|
||||||
|
return (0);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -285,30 +281,32 @@ pfil_list_remove(pfil_list_t *list,
|
|||||||
if (pfh->pfil_func == func && pfh->pfil_arg == arg) {
|
if (pfh->pfil_func == func && pfh->pfil_arg == arg) {
|
||||||
TAILQ_REMOVE(list, pfh, pfil_link);
|
TAILQ_REMOVE(list, pfh, pfil_link);
|
||||||
free(pfh, M_IFADDR);
|
free(pfh, M_IFADDR);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
return ENOENT;
|
return (ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/*
|
||||||
* Stuff that must be initialized for every instance
|
* Stuff that must be initialized for every instance (including the first of
|
||||||
* (including the first of course).
|
* course).
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
vnet_pfil_init(const void *unused)
|
vnet_pfil_init(const void *unused)
|
||||||
{
|
{
|
||||||
|
|
||||||
LIST_INIT(&V_pfil_head_list);
|
LIST_INIT(&V_pfil_head_list);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************
|
/*
|
||||||
* Called for the removal of each instance.
|
* Called for the removal of each instance.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
vnet_pfil_uninit(const void *unused)
|
vnet_pfil_uninit(const void *unused)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* XXX should panic if list is not empty */
|
/* XXX should panic if list is not empty */
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define startup order. */
|
/* Define startup order. */
|
||||||
@ -317,17 +315,17 @@ vnet_pfil_uninit(const void *unused)
|
|||||||
#define PFIL_VNET_ORDER (PFIL_MODEVENT_ORDER + 2) /* Later still. */
|
#define PFIL_VNET_ORDER (PFIL_MODEVENT_ORDER + 2) /* Later still. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starting up.
|
* Starting up.
|
||||||
|
*
|
||||||
* VNET_SYSINIT is called for each existing vnet and each new vnet.
|
* VNET_SYSINIT is called for each existing vnet and each new vnet.
|
||||||
*/
|
*/
|
||||||
VNET_SYSINIT(vnet_pfil_init, PFIL_SYSINIT_ORDER, PFIL_VNET_ORDER,
|
VNET_SYSINIT(vnet_pfil_init, PFIL_SYSINIT_ORDER, PFIL_VNET_ORDER,
|
||||||
vnet_pfil_init, NULL);
|
vnet_pfil_init, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Closing up shop. These are done in REVERSE ORDER,
|
* Closing up shop. These are done in REVERSE ORDER. Not called on reboot.
|
||||||
* Not called on reboot.
|
*
|
||||||
* VNET_SYSUNINIT is called for each exiting vnet as it exits.
|
* VNET_SYSUNINIT is called for each exiting vnet as it exits.
|
||||||
*/
|
*/
|
||||||
VNET_SYSUNINIT(vnet_pfil_uninit, PFIL_SYSINIT_ORDER, PFIL_VNET_ORDER,
|
VNET_SYSUNINIT(vnet_pfil_uninit, PFIL_SYSINIT_ORDER, PFIL_VNET_ORDER,
|
||||||
vnet_pfil_uninit, NULL);
|
vnet_pfil_uninit, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user