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)
Wed, Dec 4, 5:01 PM
Unknown Object (File)
Nov 10 2024, 5:13 PM
Unknown Object (File)
Nov 8 2024, 12:58 PM
Unknown Object (File)
Oct 2 2024, 5:52 PM
Unknown Object (File)
Oct 2 2024, 11:51 AM
Unknown Object (File)
Oct 1 2024, 9:27 PM
Unknown Object (File)
Sep 30 2024, 12:33 AM
Unknown Object (File)
Sep 27 2024, 8:05 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.