1

I am trying to modify the default congestion control algorithm in FreeBSD (NewReno) by creating a copy of the source file (cc_newreno.c, located in /usr/src/sys/netinet/cc) called cc_newreno_mod.c and making changes to it.

Suppose I have made some modifications. How do I test them? Compiling the cc_newreno_mod.c directly (using the built-in C compiler) results in multiple errors, some of which seem strange (for example netinet/cc/cc_module.h file not found, although the file clearly is there).

Should I build a new Kernel? Will the module from the changed file be created automatically? Or am I totally wrong and I should take a different approach?

2 Answers 2

2

For compiling kernel module you should create Makefile and to include kernel module makefile /usr/src/share/mk/bsd.kmod.mk for example:

# Note: It is important to make sure you include the <bsd.kmod.mk>  makefile after declaring the KMOD and SRCS variables.

# Declare Name of kernel module
KMOD    =  module

# Enumerate Source files for kernel module

SRCS    =  module.c

# Include kernel module makefile
.include <bsd.kmod.mk>

And finally you run make to compile it so you can test it if it compiles properly.
And as it is not presented in kernel modules (/boot/kernel/*.ko), but it is listed in sys/conf/files I think you should recompile your kernel to apply changes. For more info you can see this page. As it is a copy of cc_newreno.c you can rename your original /usr/src/sys/netinet/cc/cc_newreno.c to something else for saving it copy your new one there and recompile.

4
  • Hi, thank you for the tip, with the help of Makefile I was able to compile the cc_newreno_mod.c (a copy of the original cc_newreno.c), no problem, however I ran into a new issue, when loading in the module with kldload cc_newreno_mod.ko I got error 17... Any tips on what went wrong? Is it something related to the Module naming, or is it because newreno is the default congestion control algorithm?
    – KarlisL
    Apr 19, 2015 at 18:03
  • The error is that it is already registered, so you have to try to do the second part of the answer (recompiling kernel).
    – taliezin
    Apr 19, 2015 at 18:04
  • It's strange - I did change the module data to make the system think it's a different module, it's possible that I missed something...Maybe I should change the default CC algorithm, so, on boot, for example cc_vegas is loaded? Would that help to load the cc_newreno_mod ? About the Kernel recompiling - I tried the idea suggested in this forum, by adding the /usr/src/sys/netinet/cc/cc_newreno_mod.c optional inet | inet6 line to the /usr/src/sys/conf/files file, but it seems that the module was not built...Any ideas on that?
    – KarlisL
    Apr 20, 2015 at 4:21
  • Thank you for checking up & your assistance! I am now able to make the module. To make it loadable, I had to change it's ID data, since it did conflict with the cc_newreno.c, which is the default congestion control algorithm that is started upon boot.
    – KarlisL
    Apr 20, 2015 at 13:06
0

netinet is currently not a kernel module, so i suggest to add your modified file to sys/conf/files instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .