# SYNcache do I need to compile?



## mcapri (Jul 25, 2016)

I am running an experiment to compare performance of SYNcache & SYNcookies (tcp_syncache.c) across different releases of FreeBSD on a Raspberry Pi.

I setup the Pi with RaspBSD and deployed subversion (svn) to populate /usr/src/sys:
`svn checkout [URL]https://svn.freebsd.org/base/release/10.3.0/sys[/URL] /usr/src/sys`

Will the setup above allow me to by changing the release from 10.3 to 4.4 to have the corresponding working version (4.4) of tcp_syncache.c? Or should I recompile the kernel?

Cheers


----------



## SirDice (Jul 25, 2016)

mcapri said:


> I setup the Pi with RaspBSD and deployed subversion (svn) to populate /usr/src/sys:
> `svn checkout [URL]https://svn.freebsd.org/base/release/10.3.0/sys[/URL] /usr/src/sys`


The source tree is meant to be checked out in its entirety, not just a small section of it. Besides that, you have the wrong repository. You should use /base/releng/10.3/ if you need the 10.3-RELEASE sources.


----------



## mcapri (Jul 25, 2016)

OK, so to compare RELENG 10.3 and 4.4 implementation of tcp_syncookies.c should I do respectively:

svn checkout https://svn.freebsd.org/base/releng/10.3/ /usr/src/

svn checkout https://svn.freebsd.org/base/releng/4.4/ /usr/src/


----------



## kpa (Jul 25, 2016)

No need to checkout the second copy at all. This how you diff your current sys/conf/newvers.sh (releng/10.3 in my case) against the version from releng/4.4:

`svnlite diff /usr/src/sys/conf/newvers.sh ^/releng/4.4/sys/conf/newvers.sh`

Same method can be used with any other file in the tree or any branch that is under https://svn.freebsd.org/base

Note, the caret sign ^ is a relative "URL" in SVN, it expands to the repository root when used.


----------



## mcapri (Jul 29, 2016)

Thank you again for the support.

The issue now is that subversion seem to be timing out every single time. I tried for the last two days: `svn checkout https://svn.freebsd.org/base/releng/10.3/ /usr/src/` and I always get svn: E000060: Operation timed out sooner or later.

I tried different boxes and network connections, is there anyway to change the time out value? Cheers


----------



## ab2k (Jul 30, 2016)

Hi, can you successfully `ping svn.freebsd.org` ? If yes - try to change url method from `https://` to `svn://` like this - `svn checkout svn://svn.freebsd.org/base/releng/10.3/ /usr/src/` and try again. Probably you miss new certificates..


----------



## mcapri (Jul 30, 2016)

The issue was due to the speed (or lack of it) of the Raspberry Pi 2. In the end the only thing that worked has been: after each _timeout_, do a `svn cleanup` followed by a `svn update`.

Now that the subversion is in place I've got a last burning question.

is the content of /usr/src/ the repository of code used currently by the kernel, or is it exclusively used to rebuild the kernel?

My final goal is to get SYNcache and SYNcookies working, and my assumption was that the default Raspberry Pi did not ship with this feature. This is because the tcp_syncache.c file is missing from the path I was expecting to find it in /usr/src/sys/netinet as well from anywhere else on the system.


----------



## ab2k (Jul 30, 2016)

Hi, /usr/src directory contains full source code that build FreeBSD to any supported platform, it's not only kernel - it's a whole system. If you build your kernel - you must build system too. Please consider reading corresponding makeworld handbook page. Also there is a very nice short form page for this process by wblock@.


----------



## mcapri (Jul 30, 2016)

That made an interesting reading thanks ab2k. So I guess in order to swap from one version of tcp_syscache.c (let's say 4.4) to another (10.3) I need get the relevant subversion in /usr/src and makeworld. That makes a lot of sense considering at what level tcp_syncache.c works.


----------



## ab2k (Jul 30, 2016)

You are welcome! yeah, seems you have to build 2 different systems to test performance. But before you will start please check compatibility list - probably Raspberry Pi is not supported... I bet on FreeBSD 4.4 Raspberry Pi is not supprted. Also if you use FreeBSD >=10 you can use `svnlite` command to get source tree, it's already built in system.


----------



## mcapri (Jul 30, 2016)

Great tips ! In other words I won't be able to makeworld using the source tree with just a modified (4.4) version of tcp_syncache.c ? 
Sorry to keep nagging you mate, but this is a bit of deal breaker for my experiment. Cheers


----------



## ab2k (Jul 31, 2016)

Hi again, no probs at all. You may try to get old version of it and replace new one; after that you may try to build system, but i think something will not work or it even will not compile.. New version may have some calls from/to other libraries, but older version will not know how to do it; also compiler may differ (new versions of FreeBSD use clang, older gcc)... But who knows - you may always try! and please note tcp_syncache.c arrived to FreeBSD 4.5.0 (don't see that file in 4.4.0 source).

Also seems that Raspberry PI 2 is only supported by FreeBSD 11 CURRENT.. there are few images of it here.


----------



## mcapri (Aug 1, 2016)

I am getting there, thank to you. Now I've got my RPi2 up and running with FreeBSD 11.0-ALPHA3 #0 r301873. 
My idea would be synching the source and change the (famous) tcp_syncache.c to the one found in RELENG_9 - hoping that it will work.
The issue is locating the source of 11.0-ALPHA3 r301873, I dig deep but I could not find the appropriate subversion.


----------



## SirDice (Aug 2, 2016)

mcapri said:


> The issue is locating the source of 11.0-ALPHA3 r301873, I dig deep but I could not find the appropriate subversion.


That would be base/stable/11.


----------



## mcapri (Aug 7, 2016)

I've downloaded tcp_syncache.c and tcp_syncache.h from base/stable/9 but as anticipated the kernel won't compile  under /base/stable/11 conf=RPI2







Considering that I just need to swap the hashing algorithm from SipHash to MD5 .. I was wondering if someone fancies a Sunday challenge 

I'll try it myself but I am not too confident of getting anywhere with my very basic programming skills.  to the winner !


----------

