Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating ALTQ in NPF #42

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions sys/altq/altq_cbq.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.41 2024/09/26 02:39:09 ozaki-r Exp $"
#ifdef _KERNEL_OPT
#include "opt_altq.h"
#include "opt_inet.h"
#include "pf.h"
#include "npf.h"
#endif

#ifdef ALTQ_CBQ /* cbq is enabled by ALTQ_CBQ option in opt_altq.h */
Expand All @@ -59,8 +59,8 @@ __KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.41 2024/09/26 02:39:09 ozaki-r Exp $"
#include <net/if.h>
#include <netinet/in.h>

#if NPF > 0
#include <net/pfvar.h>
#if NNPF > 0
#include <net/npf_altq.h>
#endif
#include <altq/altq.h>
#include <altq/altq_cbq.h>
Expand Down Expand Up @@ -242,9 +242,9 @@ get_class_stats(class_stats_t *statsp, struct rm_class *cl)
#endif
}

#if NPF > 0
#if NNPF > 0
int
cbq_pfattach(struct pf_altq *a)
cbq_pfattach(struct npf_altq *a)
{
struct ifnet *ifp;
int s, error;
Expand All @@ -259,7 +259,7 @@ cbq_pfattach(struct pf_altq *a)
}

int
cbq_add_altq(struct pf_altq *a)
cbq_add_altq(struct npf_altq *a)
{
cbq_state_t *cbqp;
struct ifnet *ifp;
Expand All @@ -285,7 +285,7 @@ cbq_add_altq(struct pf_altq *a)
}

int
cbq_remove_altq(struct pf_altq *a)
cbq_remove_altq(struct npf_altq *a)
{
cbq_state_t *cbqp;

Expand All @@ -308,7 +308,7 @@ cbq_remove_altq(struct pf_altq *a)

#define NSEC_TO_PSEC(s) ((uint64_t)(s) * 1000)
int
cbq_add_queue(struct pf_altq *a)
cbq_add_queue(struct npf_altq *a)
{
struct rm_class *borrow, *parent;
cbq_state_t *cbqp;
Expand Down Expand Up @@ -415,7 +415,7 @@ cbq_add_queue(struct pf_altq *a)
}

int
cbq_remove_queue(struct pf_altq *a)
cbq_remove_queue(struct npf_altq *a)
{
struct rm_class *cl;
cbq_state_t *cbqp;
Expand Down Expand Up @@ -451,7 +451,7 @@ cbq_remove_queue(struct pf_altq *a)
}

int
cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
cbq_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
{
cbq_state_t *cbqp;
struct rm_class *cl;
Expand All @@ -475,7 +475,7 @@ cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
*nbytes = sizeof(stats);
return (0);
}
#endif /* NPF > 0 */
#endif /* NNPF > 0 */

/*
* int
Expand Down
22 changes: 11 additions & 11 deletions sys/altq/altq_hfsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.30 2021/09/21 14:30:15 christos Exp
#ifdef _KERNEL_OPT
#include "opt_altq.h"
#include "opt_inet.h"
#include "pf.h"
#include "npf.h"
#endif

#ifdef ALTQ_HFSC /* hfsc is enabled by ALTQ_HFSC option in opt_altq.h */
Expand All @@ -70,8 +70,8 @@ __KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.30 2021/09/21 14:30:15 christos Exp
#include <net/if.h>
#include <netinet/in.h>

#if NPF > 0
#include <net/pfvar.h>
#if NNPF > 0
#include <net/npf_altq.h>
#endif
#include <altq/altq.h>
#include <altq/altq_hfsc.h>
Expand Down Expand Up @@ -173,9 +173,9 @@ altqdev_decl(hfsc);
static struct hfsc_if *hif_list = NULL;
#endif /* ALTQ3_COMPAT */

#if NPF > 0
#if NNPF > 0
int
hfsc_pfattach(struct pf_altq *a)
hfsc_pfattach(struct npf_altq *a)
{
struct ifnet *ifp;
int s, error;
Expand All @@ -190,7 +190,7 @@ hfsc_pfattach(struct pf_altq *a)
}

int
hfsc_add_altq(struct pf_altq *a)
hfsc_add_altq(struct npf_altq *a)
{
struct hfsc_if *hif;
struct ifnet *ifp;
Expand Down Expand Up @@ -219,7 +219,7 @@ hfsc_add_altq(struct pf_altq *a)
}

int
hfsc_remove_altq(struct pf_altq *a)
hfsc_remove_altq(struct npf_altq *a)
{
struct hfsc_if *hif;

Expand All @@ -238,7 +238,7 @@ hfsc_remove_altq(struct pf_altq *a)
}

int
hfsc_add_queue(struct pf_altq *a)
hfsc_add_queue(struct npf_altq *a)
{
struct hfsc_if *hif;
struct hfsc_class *cl, *parent;
Expand Down Expand Up @@ -281,7 +281,7 @@ hfsc_add_queue(struct pf_altq *a)
}

int
hfsc_remove_queue(struct pf_altq *a)
hfsc_remove_queue(struct npf_altq *a)
{
struct hfsc_if *hif;
struct hfsc_class *cl;
Expand All @@ -296,7 +296,7 @@ hfsc_remove_queue(struct pf_altq *a)
}

int
hfsc_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
hfsc_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
{
struct hfsc_if *hif;
struct hfsc_class *cl;
Expand All @@ -320,7 +320,7 @@ hfsc_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
*nbytes = sizeof(stats);
return (0);
}
#endif /* NPF > 0 */
#endif /* NNPF > 0 */

/*
* bring the interface back to the initial state by discarding
Expand Down
22 changes: 11 additions & 11 deletions sys/altq/altq_priq.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.28 2021/09/21 14:30:15 christos Exp
#ifdef _KERNEL_OPT
#include "opt_altq.h"
#include "opt_inet.h"
#include "pf.h"
#include "npf.h"
#endif

#ifdef ALTQ_PRIQ /* priq is enabled by ALTQ_PRIQ option in opt_altq.h */
Expand All @@ -56,8 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.28 2021/09/21 14:30:15 christos Exp
#include <net/if.h>
#include <netinet/in.h>

#if NPF > 0
#include <net/pfvar.h>
#if NNPF > 0
#include <net/npf_altq.h>
#endif
#include <altq/altq.h>
#include <altq/altq_conf.h>
Expand Down Expand Up @@ -105,9 +105,9 @@ altqdev_decl(priq);
static struct priq_if *pif_list = NULL;
#endif /* ALTQ3_COMPAT */

#if NPF > 0
#if NNPF > 0
int
priq_pfattach(struct pf_altq *a)
priq_pfattach(struct npf_altq *a)
{
struct ifnet *ifp;
int s, error;
Expand All @@ -122,7 +122,7 @@ priq_pfattach(struct pf_altq *a)
}

int
priq_add_altq(struct pf_altq *a)
priq_add_altq(struct npf_altq *a)
{
struct priq_if *pif;
struct ifnet *ifp;
Expand All @@ -146,7 +146,7 @@ priq_add_altq(struct pf_altq *a)
}

int
priq_remove_altq(struct pf_altq *a)
priq_remove_altq(struct npf_altq *a)
{
struct priq_if *pif;

Expand All @@ -161,7 +161,7 @@ priq_remove_altq(struct pf_altq *a)
}

int
priq_add_queue(struct pf_altq *a)
priq_add_queue(struct npf_altq *a)
{
struct priq_if *pif;
struct priq_class *cl;
Expand All @@ -188,7 +188,7 @@ priq_add_queue(struct pf_altq *a)
}

int
priq_remove_queue(struct pf_altq *a)
priq_remove_queue(struct npf_altq *a)
{
struct priq_if *pif;
struct priq_class *cl;
Expand All @@ -203,7 +203,7 @@ priq_remove_queue(struct pf_altq *a)
}

int
priq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
priq_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
{
struct priq_if *pif;
struct priq_class *cl;
Expand All @@ -227,7 +227,7 @@ priq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
*nbytes = sizeof(stats);
return (0);
}
#endif /* NPF > 0 */
#endif /* NNPF > 0 */

/*
* bring the interface back to the initial state by discarding
Expand Down
24 changes: 12 additions & 12 deletions sys/altq/altq_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $
#ifdef _KERNEL_OPT
#include "opt_altq.h"
#include "opt_inet.h"
#include "pf.h"
#include "npf.h"
#endif

#include <sys/param.h>
Expand Down Expand Up @@ -62,8 +62,8 @@ __KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $
#include <netinet/tcp.h>
#include <netinet/udp.h>

#if NPF > 0
#include <net/pfvar.h>
#if NNPF > 0
#include <net/npf_altq.h>
#endif
#include <altq/altq.h>
#ifdef ALTQ3_COMPAT
Expand Down Expand Up @@ -400,13 +400,13 @@ tbr_get(struct ifaltq *ifq, struct tb_profile *profile)
return (0);
}

#if NPF > 0
#if NNPF > 0
/*
* attach a discipline to the interface. if one already exists, it is
* overridden.
*/
int
altq_pfattach(struct pf_altq *a)
altq_pfattach(struct npf_altq *a)
{
int error = 0;

Expand Down Expand Up @@ -441,7 +441,7 @@ altq_pfattach(struct pf_altq *a)
* discipline.
*/
int
altq_pfdetach(struct pf_altq *a)
altq_pfdetach(struct npf_altq *a)
{
struct ifnet *ifp;
int s, error = 0;
Expand All @@ -467,7 +467,7 @@ altq_pfdetach(struct pf_altq *a)
* add a discipline or a queue
*/
int
altq_add(struct pf_altq *a)
altq_add(struct npf_altq *a)
{
int error = 0;

Expand Down Expand Up @@ -506,7 +506,7 @@ altq_add(struct pf_altq *a)
* remove a discipline or a queue
*/
int
altq_remove(struct pf_altq *a)
altq_remove(struct npf_altq *a)
{
int error = 0;

Expand Down Expand Up @@ -540,7 +540,7 @@ altq_remove(struct pf_altq *a)
* add a queue to the discipline
*/
int
altq_add_queue(struct pf_altq *a)
altq_add_queue(struct npf_altq *a)
{
int error = 0;

Expand Down Expand Up @@ -571,7 +571,7 @@ altq_add_queue(struct pf_altq *a)
* remove a queue from the discipline
*/
int
altq_remove_queue(struct pf_altq *a)
altq_remove_queue(struct npf_altq *a)
{
int error = 0;

Expand Down Expand Up @@ -602,7 +602,7 @@ altq_remove_queue(struct pf_altq *a)
* get queue statistics
*/
int
altq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
altq_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
{
int error = 0;

Expand All @@ -628,7 +628,7 @@ altq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)

return (error);
}
#endif /* NPF > 0 */
#endif /* NNPF > 0 */

/*
* read and write diffserv field in IPv4 or IPv6 header
Expand Down
1 change: 1 addition & 0 deletions sys/modules/npf/npf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define NNPF 1
2 changes: 1 addition & 1 deletion sys/net/npf/files.npf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defpseudo npf: ifnet, libnv

# Core
file net/npf/npf.c npf
file net/npf/npf.c npf needs-flag
file net/npf/npf_conf.c npf
file net/npf/npf_ctl.c npf
file net/npf/npf_handler.c npf
Expand Down
Loading