cvs commit: src/sys/sys protosw.h src/sys/kern uipc_domain.c uipc_socket2.c

Andre Oppermann andre at
Tue Oct 19 08:13:30 PDT 2004

andre       2004-10-19 15:13:30 UTC

  FreeBSD src repository

  Modified files:
    sys/sys              protosw.h 
    sys/kern             uipc_domain.c uipc_socket2.c 
  Support for dynamically loadable and unloadable protocols within existing protocol
  The protosw[] array of any particular protocol family ("domain") is of fixed size
  defined at compile time.  This made it impossible to dynamically add or remove any
  protocols to or from it.  We work around this by introducing so called SPACER's
  which are embedded into the protosw[] array at compile time.  The SPACER's have
  a special protocol number (32767) to indicate the fact that they are SPACER's but
  are otherwise NULL.  Only as many protocols can be dynamically loaded as SPACER's
  are provided in the protosw[] structure.
  The pr_usrreqs structure is treated more special and contains pointers to dummy
  functions only returning EOPNOTSUPP.  This is needed because the use of those
  functions pointers is usually not checked within the kernel because until now it
  was assumed to be a valid function pointer.  Instead of fixing all potential
  callers we just return a proper error code.
  Two new functions provide a clean API to register and unregister a protocol.  The
  register function expects a pointer to a valid and complete struct protosw including
  a pointer to struct pru_usrreqs provided by the caller.  Upon successful registration
  the pr_init() function will be called to finish initialization of the protocol.  The
  unregister function restores the SPACER in place of the protocol again.  It is the
  responseability of the caller to ensure proper closing of all sockets and freeing
  of memory allocation by the unloading protocol.
    o Define generic PROTO_SPACER to be 32767
    o Prototypes for all pru_*_notsupp() functions
    o Prototypes for pf_proto_[un]register() functions
    o Global struct pr_usrreqs nousrreqs containing valid pointers to the
      pru_*_notsupp() functions
    o New functions pf_proto_[un]register()
    o New functions bodies for all pru_*_notsupp() functions
  Revision  Changes    Path
  1.37      +136 -2    src/sys/kern/uipc_domain.c
  1.138     +78 -1     src/sys/kern/uipc_socket2.c
  1.44      +33 -0     src/sys/sys/protosw.h

More information about the cvs-src mailing list