# how to rebuild sockstat and netstat



## ivand58 (May 18, 2009)

Hi list, 

after freebsd-update 7.0 -> 7.2 i have a problem with sockstat:

```
# sockstat
sockstat: struct xtcpcb size mismatch
sockstat: struct xinpcb size mismatch
sockstat: struct xunpcb size mismatch
sockstat: struct xunpcb size mismatch
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
```
According 
	
	



```
http://lists.freebsd.org/pipermail/freebsd-current/2007-December/081112.html
```
i have to rebuild sockstat and netstat:


> Yes, I managed to build sockstat and netstat by adding a line
> "CFLAGS+=-DLOCK_PROFILING" to apropriate Makefiles, then make clean,
> make and make install did the trick.


My question is: how to do this? Where are these Makefiles and what exactly i have to do ?


----------



## DutchDaemon (May 18, 2009)

If you're using freebsd-update, I assume you have the GENERIC kernel, which does not contain the LOCK_PROFILING option. Is your kernel in sync with the world? Is uname -r actually the same as your world's OS version/patch level (in /var/db/freebsd-update/tag)?

P.S.: comparing uname and the tag may not heed any results. The tag is only updated by the 'freebsd-update fetch' command. So if you don't install what you fetch, the tag file will be 'off-by-one', so to speak.


----------



## SirDice (May 18, 2009)

It looks like you only updated the kernel and forgot to update world.


----------



## ivand58 (May 18, 2009)

Thanks, 
I just followed the instructions here: http://www.freebsd.org/releases/7.2R/announce.html

```
freebsd-update upgrade -r 7.2-RELEASE
freebsd-update install
shutdown -r now
freebsd-update install
shutdown -r now
```
and my kernel is (was) untouched, GENERIC.
	
	



```
uname -a
FreeBSD aux.hobbylab.org 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May  1 08:49:13 UTC 2009     root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

#cat /var/db/freebsd-update/tag
freebsd-update|i386|7.2-RELEASE|0|b6d6837d3363e50b4f04b250667e856227d40bfff6224698ac4591b12637de4f|1275350400
```



> It looks like you only updated the kernel and forgot to update world.


Sorry but can you help me how to do this? In the Handbook, chapter 24 we can read 


> Do not use make world: A lot of older documentation recommends using make world for this. Doing that skips some important steps and should only be used if you are sure of what you are doing. For almost all circumstances make world is the wrong thing to do, and the procedure described here should be used instead.


 but maybe this is something else?


----------



## DutchDaemon (May 18, 2009)

Something else. The first [cmd=]freebsd-update install[/cmd] installs the new kernel, the second [cmd=]freebsd-update install[/cmd] installs the world and triggers a mergemaster-like config comparison tool. 

I have no idea how a binary only system can produce the error you're seeing. I've not heard of this issue anywhere. I could tell you to roll-back the update and wait a while before trying again (maybe it's something that needs patching), but that's up to you.

I advise against 'polluting' the binary system with edited Makefiles and rebuilt/adjusted binaries (the sources are probably not even on your system -- I assume you have nothing in /usr/src/), because it will likely break the next run of freebsd-update.


----------



## SirDice (May 18, 2009)

ivand58 said:
			
		

> Sorry but can you help me how to do this? In the Handbook, chapter 24 we can read
> but maybe this is something else?



Sorry, old school bsd user :e Updating world actually consists of several steps these days.

I never use freebsd-update. I build everything from source.


```
# make buildworld
# make buildkernel
# make installkernel
# reboot # to single usermode
# make installworld
# mergemaster
```


----------



## ivand58 (May 18, 2009)

DutchDaemon said:
			
		

> ...
> I advise against 'polluting' the binary system with edited Makefiles and rebuilt/adjusted binaries ...


Edited by who? Do I have to modify some Makefiles (like in build custom kernel) or these Makefiles are modified by freebsd-update?


			
				DutchDaemon said:
			
		

> ... I assume you have nothing in /usr/src/...


No, /usr/src is not empty (i had to rebuild senmail with sasl).


----------



## DutchDaemon (May 18, 2009)

You'd have to edit the Makefiles, like you stated in the first post. 

The freebsd-update app doesn't use Makefiles, simply because it doesn't compile anything. That's the whole point of freebsd-update: installing already compiled binaries. 

You compiling your own and replacing the ones installed by freebsd-update will probably lead to the failure of the next freebsd-update run, because it doesn't recognise your binaries. However, I do not know how freebsd-update handles such a case, because I compile everything myself. You may get away with it.


----------



## vivek (May 19, 2009)

Try as follows (it may or may not work). You need to have src distribution installed.

```
cd /usr/src/usr.bin/sockstat/
vi Makefile
```
Add CFLAGS+=-DLOCK_PROFILING. 

```
make install clean
```
If this failed, just rebuild everything.


----------



## ivand58 (May 20, 2009)

Thanks you guys, 
now i am back to freebsd 70 and everything looks fine. Is there some integration tests or some scripts that checks the integrity and functionality of the system? Because after these rebuilds, how can I be sure that everything is OK ?


----------



## richardpl (May 20, 2009)

ident(1) is utility to check if version of files you have installed are same one as available from freebsd cvs repo.


----------

