Writing a new (socket ) system call

Terry Lambert tlambert2 at mindspring.com
Wed Jul 2 08:56:16 PDT 2003


Sandeep Kumar Davu wrote:
> I am scanning throug the freeBSD source code and wanted to know somethin about
> the bind system call. I could follow through the code till sobind and after
> that pru_bind routine is called in uipc_socket.c. Then suddenly in
> tcp_usrreq.c there is tcp_usr_bind. I am wondering how these 2 can be related.
> I think i am missing something. i wanted it because I am writing a new system
> call that has to navigate to the tcp_usrreq.c. Can anyone help me out with
> this. It would be of great help if u can do so.

Most likely you can accomplish what you want to accomplish without
adding a new system call.

If you insist on adding a system call, the code to do so will be
rather complex, and involve not only extending a number of data
structures, which will require recompiling everything to add another
pru_* entry, it will involve adding stub functions in uipc_*, and,
possibly, a default implementation for all protocols that have to
deal with it.  Add to that you will need to allocate a system call
slot and (potentially) a struct fileops entry, and you can see that
you will not only be touching a lot of the system, you will be
making your implementation binarily incompatible with third party
code.

If you can do it as a socket option (search for "SOPT" in tcp_usrreq.c)
then I'd really advise you to do that, instead.

-- Terry


More information about the freebsd-hackers mailing list