Page MenuHomeFreeBSD

Enable the ability to load multiple versions of the same TCP stack
ClosedPublic

Authored by jtl on Jun 7 2017, 11:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 21 2024, 3:03 PM
Unknown Object (File)
Jan 21 2024, 1:32 AM
Unknown Object (File)
Jan 5 2024, 2:06 PM
Unknown Object (File)
Dec 22 2023, 8:06 AM
Unknown Object (File)
Dec 20 2023, 5:20 AM
Unknown Object (File)
Dec 12 2023, 2:05 AM
Unknown Object (File)
Nov 13 2023, 10:48 AM
Unknown Object (File)
Oct 31 2023, 2:05 AM
Subscribers

Details

Summary

This patch enables the ability to load multiple versions of the same TCP stack.

It lets us write simple Makefiles like this:

#
# $FreeBSD$
#

STACKNAME=      bbr_17q22
KMOD=   tcp_${STACKNAME}
SRCS=   bbr.c sack_filter.c

#
# Enable full debugging
#
#CFLAGS += -g

CFLAGS+=        -DMODNAME=${KMOD}
CFLAGS+=        -DSTACKNAME=${STACKNAME}
PREFIX_SYMS=    ${KMOD}_

.include <bsd.kmod.mk>

In the code, we can register non-conflicting module names like this:

MODULE_VERSION(MODNAME, 1);
DECLARE_MODULE(MODNAME, tcp_bbr, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY);

We can enable multiple stack names like this:

static const char *my_stack_names[] = {
        __XSTRING(STACKNAME),
#ifdef STACKALIAS
        __XSTRING(STACKALIAS),
#endif
};
...
                num_stacks = nitems(my_stack_names);
                err = register_tcp_functions_as_names(&__tcp_mystack, M_WAITOK,
                    my_stack_names, &num_stacks);

To do this, it:

  • Supports symbol mangling to avoid overlapping symbols between the multiple modules.
  • Lets us use a macro as the module name in the DECLARE_MACRO() and MACRO_VERSION() macros.
  • Lets us register stack aliases (e.g. both a generic name ["default"] and version-specific name ["default_v1"]).

We can then create a new version of the module just by changing the STACKNAME variable.

Test Plan

This is in use in Netflix.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

makefile changes look ok, thought the number of ${OBJCOPY} invocations might be getting out of hand.
Since they all work the same it would be possible to accumulate the output of all the awk commands in one file, and then feed that to xargs -J% ${OBJCOPY} % ${.TARGET}

never mind, objcopy -J% is going to be invoked once per line anyway

This revision is now accepted and ready to land.Jun 8 2017, 12:25 AM
This revision was automatically updated to reflect the committed changes.