Page MenuHomeFreeBSD

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

Authored by kp on Tue, May 10, 8:53 AM.

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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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.Thu, May 12, 7:58 PM
This revision was automatically updated to reflect the committed changes.