Page MenuHomeFreeBSD

ypbind: IPv6 clean by adding version 3 of ypbind
Needs ReviewPublic

Authored by on Thu, Jun 6, 5:08 PM.
Referenced Files
Unknown Object (File)
Wed, Jun 12, 1:37 AM
Unknown Object (File)
Tue, Jun 11, 4:43 AM
Unknown Object (File)
Sat, Jun 8, 4:47 PM



Diff Detail

rG FreeBSD src repository
Lint Passed
No Test Coverage
Build Status
Buildable 58143
Build 55031: arc lint + arc unit

Event Timeline

This patch attempts to implement version 3 of YP from Sun ( into FreeBSD. It is part of my Google Summer of Code 2024 project ( I believe uploading the ongoing work for discussion with my mentor (Hiroki) is efficient. If this is not a good approach, please let me know, and I will cancel the patch immediately and seek another way to discuss it.

Version 2 of YP uses TS-RPC and supports only IPv4 addresses. I am revising version 2 to use TI-RPC and adding support for IPv4/6 in version 3.


  1. In the main function, I use getnetconfig, svc_tp_create, and svc_reg within a while loop to replace the original functions svcudp_create and svctcp_create. I attempt to bind version 3 of ypbind on every netconfig and bind version 2 of ypbind only on IPv4 over UDP/TCP.
  1. Use clnt_dg_create to replace clntudp_bufcreate function. And use the clnt_control function to add a timeout.
  1. Use clnt_create function to replace clntudp_create.
  1. Use rpc_broadcast function to replace clnt_broadcast.

Version 3 ypbind

  1. I have included some version 3 data structures in "yp.x".
    1. Use new _dom_binding. It is very similar to the old one, except for the address. Version 3 uses a new data structure, ypbind_binding_3, to represent addresses.
    2. Use ypbind_setdom_3 to replace ypbind_setdom. The difference is that version 3 uses the new ypbind_binding_3 structure.
    3. Use ypbind_resp_3 to replace ypbind_resp, with the main difference still being ypbind_binding_3.

      This is problem 1 because I am not sure if I included the data structure correctly. For example, I am not sure why there are two members, rpcvers_t ypbind_hi_vers and rpcvers_t ypbind_lo_vers, in ypbind_binding_3. In Sun's code, they seem the same.
  1. I have added version 3 functions like ypbindprog_3, ypbindproc_domain_3_yp, and ypbindproc_setdom_3_yp, following Sun's implementation. In their code, version 2 structures are converted to version 3 structures before calling version 3 functions.
  1. I also revised the "yp_ping.c" function to support struct sockaddr *.

The code compiles and I have run it without any error messages. However, I couldn't fully test it as my test environment does not have a YP server.

  • Restore "ypset.c" which add accidentally
hrs requested changes to this revision.Thu, Jun 6, 7:21 PM
hrs added inline comments.

See comments for L.313 in ypbind.c


When you want to use struct sockaddr_storage, use #include <netdb.h>.


The reason why two members for the version number is that hi_vers means the highest version number the service accepts, and the lo_vers means the lowest. So if these two are the same, the ypbind service will accept the specified version only.


memcpy() for the size of (struct netbuf) is not enough if you want to copy the buffer contents (netbuf->buf).


For a pointer access, use (struct sockaddr *) instead of (struct sockaddr_storage *) because the sockaddr is already address-family-independent and the sockaddr_storage is usually required only when the struct size that can hold any address families matters.


If fromsin is in (struct sockaddr *), you will not need two type-castings here.


If getnameinfo() is used, simply checking "::1" or "" might be enough without checking sa_family. The same appears in L.1082.


The port number should be obtained from fromsin using ((struct sockaddr_in *)fromsin)->sin_port or ((struct sockaddr_in6 *)fromsin)->sin6_port, depending on sa_family.


Move typedefs outside the function.


Same as L.313 in ypbind.c

This revision now requires changes to proceed.Thu, Jun 6, 7:21 PM

I did not test the functionality yet, but I will give it a try with IPv4 and IPv6 configurations.

  • Move variable to "yp.x" file and fix variable name
  • Revise according the advice from Hiroki added inline comments.

I add a utility function copy_netbuf to handle the situation while need to memcpy for struct netbuf.