Skip to content

Commit 8fc49ba

Browse files
committed
Initiate NPF in ALTQ
altq communicate to pf through pf_altq queue structures. similar is done for npf and being used to replace pf's pf_altq. npf_altq fileds are compatible with struct pf_altq as they represent a complete queue structure. a needs-flag is set on npf to produce a npf.h during config in the kernel directory which will set optional compilation for npf related code in altq. it is also handled at runtime in the npf module.
1 parent 97eb7ca commit 8fc49ba

File tree

7 files changed

+154
-46
lines changed

7 files changed

+154
-46
lines changed

sys/altq/altq_cbq.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.41 2024/09/26 02:39:09 ozaki-r Exp $"
3737
#ifdef _KERNEL_OPT
3838
#include "opt_altq.h"
3939
#include "opt_inet.h"
40-
#include "pf.h"
40+
#include "npf.h"
4141
#endif
4242

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

62-
#if NPF > 0
63-
#include <net/pfvar.h>
62+
#if NNPF > 0
63+
#include <net/npf_altq.h>
6464
#endif
6565
#include <altq/altq.h>
6666
#include <altq/altq_cbq.h>
@@ -242,9 +242,9 @@ get_class_stats(class_stats_t *statsp, struct rm_class *cl)
242242
#endif
243243
}
244244

245-
#if NPF > 0
245+
#if NNPF > 0
246246
int
247-
cbq_pfattach(struct pf_altq *a)
247+
cbq_pfattach(struct npf_altq *a)
248248
{
249249
struct ifnet *ifp;
250250
int s, error;
@@ -259,7 +259,7 @@ cbq_pfattach(struct pf_altq *a)
259259
}
260260

261261
int
262-
cbq_add_altq(struct pf_altq *a)
262+
cbq_add_altq(struct npf_altq *a)
263263
{
264264
cbq_state_t *cbqp;
265265
struct ifnet *ifp;
@@ -285,7 +285,7 @@ cbq_add_altq(struct pf_altq *a)
285285
}
286286

287287
int
288-
cbq_remove_altq(struct pf_altq *a)
288+
cbq_remove_altq(struct npf_altq *a)
289289
{
290290
cbq_state_t *cbqp;
291291

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

309309
#define NSEC_TO_PSEC(s) ((uint64_t)(s) * 1000)
310310
int
311-
cbq_add_queue(struct pf_altq *a)
311+
cbq_add_queue(struct npf_altq *a)
312312
{
313313
struct rm_class *borrow, *parent;
314314
cbq_state_t *cbqp;
@@ -415,7 +415,7 @@ cbq_add_queue(struct pf_altq *a)
415415
}
416416

417417
int
418-
cbq_remove_queue(struct pf_altq *a)
418+
cbq_remove_queue(struct npf_altq *a)
419419
{
420420
struct rm_class *cl;
421421
cbq_state_t *cbqp;
@@ -451,7 +451,7 @@ cbq_remove_queue(struct pf_altq *a)
451451
}
452452

453453
int
454-
cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
454+
cbq_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
455455
{
456456
cbq_state_t *cbqp;
457457
struct rm_class *cl;
@@ -475,7 +475,7 @@ cbq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
475475
*nbytes = sizeof(stats);
476476
return (0);
477477
}
478-
#endif /* NPF > 0 */
478+
#endif /* NNPF > 0 */
479479

480480
/*
481481
* int

sys/altq/altq_hfsc.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_hfsc.c,v 1.30 2021/09/21 14:30:15 christos Exp
4848
#ifdef _KERNEL_OPT
4949
#include "opt_altq.h"
5050
#include "opt_inet.h"
51-
#include "pf.h"
51+
#include "npf.h"
5252
#endif
5353

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

73-
#if NPF > 0
74-
#include <net/pfvar.h>
73+
#if NNPF > 0
74+
#include <net/npf_altq.h>
7575
#endif
7676
#include <altq/altq.h>
7777
#include <altq/altq_hfsc.h>
@@ -173,9 +173,9 @@ altqdev_decl(hfsc);
173173
static struct hfsc_if *hif_list = NULL;
174174
#endif /* ALTQ3_COMPAT */
175175

176-
#if NPF > 0
176+
#if NNPF > 0
177177
int
178-
hfsc_pfattach(struct pf_altq *a)
178+
hfsc_pfattach(struct npf_altq *a)
179179
{
180180
struct ifnet *ifp;
181181
int s, error;
@@ -190,7 +190,7 @@ hfsc_pfattach(struct pf_altq *a)
190190
}
191191

192192
int
193-
hfsc_add_altq(struct pf_altq *a)
193+
hfsc_add_altq(struct npf_altq *a)
194194
{
195195
struct hfsc_if *hif;
196196
struct ifnet *ifp;
@@ -219,7 +219,7 @@ hfsc_add_altq(struct pf_altq *a)
219219
}
220220

221221
int
222-
hfsc_remove_altq(struct pf_altq *a)
222+
hfsc_remove_altq(struct npf_altq *a)
223223
{
224224
struct hfsc_if *hif;
225225

@@ -238,7 +238,7 @@ hfsc_remove_altq(struct pf_altq *a)
238238
}
239239

240240
int
241-
hfsc_add_queue(struct pf_altq *a)
241+
hfsc_add_queue(struct npf_altq *a)
242242
{
243243
struct hfsc_if *hif;
244244
struct hfsc_class *cl, *parent;
@@ -281,7 +281,7 @@ hfsc_add_queue(struct pf_altq *a)
281281
}
282282

283283
int
284-
hfsc_remove_queue(struct pf_altq *a)
284+
hfsc_remove_queue(struct npf_altq *a)
285285
{
286286
struct hfsc_if *hif;
287287
struct hfsc_class *cl;
@@ -296,7 +296,7 @@ hfsc_remove_queue(struct pf_altq *a)
296296
}
297297

298298
int
299-
hfsc_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
299+
hfsc_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
300300
{
301301
struct hfsc_if *hif;
302302
struct hfsc_class *cl;
@@ -320,7 +320,7 @@ hfsc_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
320320
*nbytes = sizeof(stats);
321321
return (0);
322322
}
323-
#endif /* NPF > 0 */
323+
#endif /* NNPF > 0 */
324324

325325
/*
326326
* bring the interface back to the initial state by discarding

sys/altq/altq_priq.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_priq.c,v 1.28 2021/09/21 14:30:15 christos Exp
3636
#ifdef _KERNEL_OPT
3737
#include "opt_altq.h"
3838
#include "opt_inet.h"
39-
#include "pf.h"
39+
#include "npf.h"
4040
#endif
4141

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

59-
#if NPF > 0
60-
#include <net/pfvar.h>
59+
#if NNPF > 0
60+
#include <net/npf_altq.h>
6161
#endif
6262
#include <altq/altq.h>
6363
#include <altq/altq_conf.h>
@@ -105,9 +105,9 @@ altqdev_decl(priq);
105105
static struct priq_if *pif_list = NULL;
106106
#endif /* ALTQ3_COMPAT */
107107

108-
#if NPF > 0
108+
#if NNPF > 0
109109
int
110-
priq_pfattach(struct pf_altq *a)
110+
priq_pfattach(struct npf_altq *a)
111111
{
112112
struct ifnet *ifp;
113113
int s, error;
@@ -122,7 +122,7 @@ priq_pfattach(struct pf_altq *a)
122122
}
123123

124124
int
125-
priq_add_altq(struct pf_altq *a)
125+
priq_add_altq(struct npf_altq *a)
126126
{
127127
struct priq_if *pif;
128128
struct ifnet *ifp;
@@ -146,7 +146,7 @@ priq_add_altq(struct pf_altq *a)
146146
}
147147

148148
int
149-
priq_remove_altq(struct pf_altq *a)
149+
priq_remove_altq(struct npf_altq *a)
150150
{
151151
struct priq_if *pif;
152152

@@ -161,7 +161,7 @@ priq_remove_altq(struct pf_altq *a)
161161
}
162162

163163
int
164-
priq_add_queue(struct pf_altq *a)
164+
priq_add_queue(struct npf_altq *a)
165165
{
166166
struct priq_if *pif;
167167
struct priq_class *cl;
@@ -188,7 +188,7 @@ priq_add_queue(struct pf_altq *a)
188188
}
189189

190190
int
191-
priq_remove_queue(struct pf_altq *a)
191+
priq_remove_queue(struct npf_altq *a)
192192
{
193193
struct priq_if *pif;
194194
struct priq_class *cl;
@@ -203,7 +203,7 @@ priq_remove_queue(struct pf_altq *a)
203203
}
204204

205205
int
206-
priq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
206+
priq_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
207207
{
208208
struct priq_if *pif;
209209
struct priq_class *cl;
@@ -227,7 +227,7 @@ priq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
227227
*nbytes = sizeof(stats);
228228
return (0);
229229
}
230-
#endif /* NPF > 0 */
230+
#endif /* NNPF > 0 */
231231

232232
/*
233233
* bring the interface back to the initial state by discarding

sys/altq/altq_subr.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.33 2017/03/14 09:03:08 ozaki-r Exp $
3333
#ifdef _KERNEL_OPT
3434
#include "opt_altq.h"
3535
#include "opt_inet.h"
36-
#include "pf.h"
36+
#include "npf.h"
3737
#endif
3838

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

65-
#if NPF > 0
66-
#include <net/pfvar.h>
65+
#if NNPF > 0
66+
#include <net/npf_altq.h>
6767
#endif
6868
#include <altq/altq.h>
6969
#ifdef ALTQ3_COMPAT
@@ -400,13 +400,13 @@ tbr_get(struct ifaltq *ifq, struct tb_profile *profile)
400400
return (0);
401401
}
402402

403-
#if NPF > 0
403+
#if NNPF > 0
404404
/*
405405
* attach a discipline to the interface. if one already exists, it is
406406
* overridden.
407407
*/
408408
int
409-
altq_pfattach(struct pf_altq *a)
409+
altq_pfattach(struct npf_altq *a)
410410
{
411411
int error = 0;
412412

@@ -441,7 +441,7 @@ altq_pfattach(struct pf_altq *a)
441441
* discipline.
442442
*/
443443
int
444-
altq_pfdetach(struct pf_altq *a)
444+
altq_pfdetach(struct npf_altq *a)
445445
{
446446
struct ifnet *ifp;
447447
int s, error = 0;
@@ -467,7 +467,7 @@ altq_pfdetach(struct pf_altq *a)
467467
* add a discipline or a queue
468468
*/
469469
int
470-
altq_add(struct pf_altq *a)
470+
altq_add(struct npf_altq *a)
471471
{
472472
int error = 0;
473473

@@ -506,7 +506,7 @@ altq_add(struct pf_altq *a)
506506
* remove a discipline or a queue
507507
*/
508508
int
509-
altq_remove(struct pf_altq *a)
509+
altq_remove(struct npf_altq *a)
510510
{
511511
int error = 0;
512512

@@ -540,7 +540,7 @@ altq_remove(struct pf_altq *a)
540540
* add a queue to the discipline
541541
*/
542542
int
543-
altq_add_queue(struct pf_altq *a)
543+
altq_add_queue(struct npf_altq *a)
544544
{
545545
int error = 0;
546546

@@ -571,7 +571,7 @@ altq_add_queue(struct pf_altq *a)
571571
* remove a queue from the discipline
572572
*/
573573
int
574-
altq_remove_queue(struct pf_altq *a)
574+
altq_remove_queue(struct npf_altq *a)
575575
{
576576
int error = 0;
577577

@@ -602,7 +602,7 @@ altq_remove_queue(struct pf_altq *a)
602602
* get queue statistics
603603
*/
604604
int
605-
altq_getqstats(struct pf_altq *a, void *ubuf, int *nbytes)
605+
altq_getqstats(struct npf_altq *a, void *ubuf, int *nbytes)
606606
{
607607
int error = 0;
608608

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

629629
return (error);
630630
}
631-
#endif /* NPF > 0 */
631+
#endif /* NNPF > 0 */
632632

633633
/*
634634
* read and write diffserv field in IPv4 or IPv6 header

sys/modules/npf/npf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define NNPF 1

sys/net/npf/files.npf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
defpseudo npf: ifnet, libnv
1111

1212
# Core
13-
file net/npf/npf.c npf
13+
file net/npf/npf.c npf needs-flag
1414
file net/npf/npf_conf.c npf
1515
file net/npf/npf_ctl.c npf
1616
file net/npf/npf_handler.c npf

0 commit comments

Comments
 (0)