Page MenuHomeFreeBSD

pf: also apply dummynet to route-to/dup-to packets
ClosedPublic

Authored by kp on May 10 2022, 8:53 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 10:22 PM
Unknown Object (File)
Thu, Apr 11, 10:22 PM
Unknown Object (File)
Thu, Apr 11, 2:12 PM
Unknown Object (File)
Thu, Apr 11, 6:33 AM
Unknown Object (File)
Wed, Apr 10, 4:40 PM
Unknown Object (File)
Wed, Apr 10, 2:38 AM
Unknown Object (File)
Mon, Apr 8, 8:16 AM
Unknown Object (File)
Feb 8 2024, 1:02 PM

Details

Summary

If packets are processed by a route-to/dup-to/reply-to rule (i.e. they
pass through pf_route(6)) dummynet was not applied to them.
This is because pf_route(6) passes packets directly to ifp->if_output(),
so the dummynet functions were never called.

Factor out the dummynet code and call dummynet prior to
ifp->if_output(). This has a secondary benefit of reducing some code
duplication between the IPv4 and IPv6 paths.

Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 45525
Build 42413: arc lint + arc unit

Event Timeline

The new function is bool, to tell if the packet was consumed. Let's call this modern FreeBSD style. You also pass a pointer to pointer, so function can NULL-ify to express same fact of consumed mbuf. This matches classic OpenBSD/pf style. In one case you use FreeBSD style and in two cases OpenBSD.

IMHO, the new function should be used consistently using either return value or the pointer. Personally I prefer FreeBSD style over OpenBSD/pf.

The new function is bool, to tell if the packet was consumed. Let's call this modern FreeBSD style. You also pass a pointer to pointer, so function can NULL-ify to express same fact of consumed mbuf. This matches classic OpenBSD/pf style. In one case you use FreeBSD style and in two cases OpenBSD.

IMHO, the new function should be used consistently using either return value or the pointer. Personally I prefer FreeBSD style over OpenBSD/pf.

That's not quite right. The return value indicates an error. For example when we fail to allocate the tag, or if we're configured to shape the packet (i.e. dnpipe/dnrpipe != 0) but dummynet is not loaded.

We can return 'true' and yet not have eaten the mbuf. I'll change the return type to an int (and return ENOMEM on error) to make it a bit clearer.

Change return type to int, to clarify that this is an error return.

This revision was not accepted when it landed; it landed in state Needs Review.May 12 2022, 7:58 PM
This revision was automatically updated to reflect the committed changes.