sbspace() / sbappendaddr() problem
VANHULLEBUS Yvan
vanhu_bsd at zeninc.net
Thu Sep 1 07:54:51 GMT 2005
Hi all.
I have some reccurent problems with PFKey interafce for a while, whith
ENOBUFS errors.
While tracking down the problem, I found that a test goes wrong in
sbappendaddr(), in kern_uipc_socket2.c, because the "space" variable
(an int) gets "bigger" than the result of sbspace(sb), which shlould
not happen.
After having a deeper look at sbspace() macro, I noticed that there
are some potential cast/sign problems with this macro (this is
specified in the comments of the macro).
So I wrote a new version of the macro, which should avoir all
problems:
#define sbspace(sb) \
(ulmin( ( (sb)->sb_hiwat > (sb)->sb_cc ? (sb)->sb_hiwat - (sb)->sb_cc : 0), \
(sb)->sb_mbmax > (sb)->sb_mbcnt ? (sb)->sb_mbmax - (sb)->sb_mbcnt : 0)))
Then I set up the type of "space" variable in sbappendaddr() as
u_long, and I have no more problems for now.
But as this function and this macro are used on some other parts of
the kernel, I don't know if I solved all problems, or if I generated
new problems elsewhere while solving one.
Does someone have any comments on this new sbspace() ?
Yvan.
--
NETASQ - Secure Internet Connectivity
http://www.netasq.com
More information about the freebsd-net
mailing list