HACKING 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. -*- mode: text; -*-
  2. $QuaggaId: Format:%an, %ai, %h$ $
  3. Contents:
  4. * GUIDELINES FOR HACKING ON QUAGGA
  5. * COMPILE-TIME CONDITIONAL CODE
  6. * COMMIT MESSAGE
  7. * HACKING THE BUILD SYSTEM
  8. * RELEASE PROCEDURE
  9. * SHARED LIBRARY VERSIONING
  10. * RELEASE PROCEDURE
  11. * TOOL VERSIONS
  12. * SHARED LIBRARY VERSIONING
  13. * PATCH SUBMISSION
  14. * PATCH APPLICATION
  15. * STABLE PLATFORMS AND DAEMONS
  16. * IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
  17. GUIDELINES FOR HACKING ON QUAGGA
  18. [this is a draft in progress]
  19. GNU coding standards apply. Indentation follows the result of
  20. invoking GNU indent (as of 2.2.8a) with no arguments. Note that this
  21. uses tabs instead of spaces where possible for leading whitespace, and
  22. assumes that tabs are every 8 columns. Do not attempt to redefine the
  23. location of tab stops. Note also that some indentation does not
  24. follow GNU style. This is a historical accident, and we generally
  25. only clean up whitespace when code is unmaintainable due to whitespace
  26. issues, as fewer changes from zebra lead to easier merges.
  27. For GNU emacs, use indentation style "gnu".
  28. For Vim, use the following lines (note that tabs are at 8, and that
  29. softtabstop sets the indentation level):
  30. set tabstop=8
  31. set softtabstop=2
  32. set shiftwidth=2
  33. set noexpandtab
  34. Be particularly careful not to break platforms/protocols that you
  35. cannot test.
  36. New code should have good comments, and changes to existing code
  37. should in many cases upgrade the comments when necessary for a
  38. reviewer to conclude that the change has no unintended consequences.
  39. Each file in the Git repository should have a git format-placeholder (like
  40. an RCS Id keyword), somewhere very near the top, commented out appropriately
  41. for the file type. The placeholder used for Quagga (replacing <dollar> with
  42. $) is:
  43. $QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $
  44. See line 2 of HACKING for an example;
  45. This placeholder string will be expanded out by the 'git archive' commands,
  46. wihch is used to generate the tar archives for snapshots and releases.
  47. Please document fully the proper use of a new function in the header file
  48. in which it is declared. And please consult existing headers for
  49. documentation on how to use existing functions. In particular, please consult
  50. these header files:
  51. lib/log.h logging levels and usage guidance
  52. [more to be added]
  53. If changing an exported interface, please try to deprecate the interface in
  54. an orderly manner. If at all possible, try to retain the old deprecated
  55. interface as is, or functionally equivalent. Make a note of when the
  56. interface was deprecated and guard the deprecated interface definitions in
  57. the header file, ie:
  58. /* Deprecated: 20050406 */
  59. #if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
  60. #warning "Using deprecated <libname> (interface(s)|function(s))"
  61. ...
  62. #endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
  63. To ensure that the core Quagga sources do not use the deprecated interfaces
  64. (you should update Quagga sources to use new interfaces, if applicable)
  65. while allowing external sources to continue to build. Deprecated interfaces
  66. should be excised in the next unstable cycle.
  67. Note: If you wish, you can test for GCC and use a function
  68. marked with the 'deprecated' attribute. However, you must provide the
  69. #warning for other compilers.
  70. If changing or removing a command definition, *ensure* that you properly
  71. deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
  72. is *critical*. Even if the command can no longer function, you *must* still
  73. implement it as a do-nothing stub. Failure to follow this causes grief for
  74. systems administrators. Deprecated commands should be excised in the next
  75. unstable cycle. A list of deprecated commands should be collated for each
  76. release.
  77. See also below regarding SHARED LIBRARY VERSIONING.
  78. COMPILE-TIME CONDITIONAL CODE
  79. Please think very carefully before making code conditional at compile time,
  80. as it increases maintenance burdens and user confusion. In particular,
  81. please avoid gratuitious --enable-.... switches to the configure script -
  82. typically code should be good enough to be in Quagga, or it shouldn't be
  83. there at all.
  84. When code must be compile-time conditional, try have the compiler make it
  85. conditional rather than the C pre-processor. I.e. this:
  86. if (SOME_SYMBOL)
  87. frobnicate();
  88. rather than:
  89. #ifdef SOME_SYMBOL
  90. frobnicate ();
  91. #endif /* SOME_SYMBOL */
  92. Note that the former approach requires ensuring that SOME_SYMBOL will be
  93. defined (watch your AC_DEFINEs).
  94. COMMIT MESSAGES
  95. The commit message should provide:
  96. * A suitable one-line summary followed by a blank line as the very
  97. first line of the message, in the form:
  98. topic: high-level, one line summary
  99. Where topic would tend to be name of a subdirectory, and/or daemon, unless
  100. there's a more suitable topic (e.g. 'build'). This topic is used to
  101. organise change summaries in release announcements.
  102. * An optional introduction, discussing the general intent of the change.
  103. * A short description of each change made, preferably:
  104. * file by file
  105. * function by function (use of "ditto", or globs is allowed)
  106. to provide a short description of the general intent of the patch, in terms
  107. of the problem it solves and how it achieves it, to help reviewers
  108. understand.
  109. The one-line summary must be limited to 54 characters, and all other
  110. lines to 72 characters.
  111. The reason for such itemised commit messages is to encourage the author to
  112. self-review every line of the patch, as well as provide reviewers an index
  113. of which changes are intended, along with a short description for each.
  114. Some discretion is obviously required. A C-to-english description is not
  115. desireable. For short patches, a per-function/file break-down may be
  116. redundant. For longer patches, such a break-down may be essential.
  117. An example (where the general discussion is obviously somewhat redundant,
  118. given the one-line summary):
  119. zebra: Enhance frob FSM to detect loss of frob
  120. * (general) Add a new DOWN state to the frob state machine
  121. to allow the barinator to detect loss of frob.
  122. * frob.h: (struct frob) Add DOWN state flag.
  123. * frob.c: (frob_change) set/clear DOWN appropriately on state change.
  124. * bar.c: (barinate) Check frob for DOWN state.
  125. Note that the commit message format follows git norms, so that "git
  126. log --oneline" will have useful output.
  127. HACKING THE BUILD SYSTEM
  128. If you change or add to the build system (configure.ac, any Makefile.am,
  129. etc.), try to check that the following things still work:
  130. - make dist
  131. - resulting dist tarball builds
  132. - out-of-tree builds
  133. The quagga.net site relies on make dist to work to generate snapshots. It
  134. must work. Common problems are to forget to have some additional file
  135. included in the dist, or to have a make rule refer to a source file without
  136. using the srcdir variable.
  137. RELEASE PROCEDURE
  138. * Tag the apppropriate commit with a release tag (follow existing
  139. conventions).
  140. [This enables recreating the release, and is just good CM practice.]
  141. * Create a fresh tar archive of the quagga.net repository, and do a test
  142. build:
  143. git-clone git:///code.quagga.net/quagga.git quagga
  144. git-archive --remote=git://code.quagga.net/quagga.git \
  145. --prefix=quagga-release/ master | tar -xf -
  146. cd quagga-release
  147. autoreconf -i
  148. ./configure
  149. make
  150. make dist
  151. The tarball which 'make dist' creates is the tarball to be released! The
  152. git-archive step ensures you're working with code corresponding to that in
  153. the official repository, and also carries out keyword expansion. If any
  154. errors occur, move tags as needed and start over from the fresh checkouts.
  155. Do not append to tarballs, as this has produced non-standards-conforming
  156. tarballs in the past.
  157. See also: http://wiki.quagga.net/index.php/Main/Processes
  158. [TODO: collation of a list of deprecated commands. Possibly can be scripted
  159. to extract from vtysh/vtysh_cmd.c]
  160. TOOL VERSIONS
  161. Require versions of support tools are listed in INSTALL.quagga.txt.
  162. Required versions should only be done with due deliberation, as it can
  163. cause environments to no longer be able to compile quagga.
  164. SHARED LIBRARY VERSIONING
  165. [this section is at the moment just gdt's opinion]
  166. Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
  167. ospfclient/libsopfapiclient). These may be used by external programs,
  168. e.g. a new routing protocol that works with the zebra daemon, or
  169. ospfapi clients. The libtool info pages (node Versioning) explain
  170. when major and minor version numbers should be changed. These values
  171. are set in Makefile.am near the definition of the library. If you
  172. make a change that requires changing the shared library version,
  173. please update Makefile.am.
  174. libospf exports far more than it should, and is needed by ospfapi
  175. clients. Only bump libospf for changes to functions for which it is
  176. reasonable for a user of ospfapi to call, and please err on the side
  177. of not bumping.
  178. There is no support intended for installing part of zebra. The core
  179. library libzebra and the included daemons should always be built and
  180. installed together.
  181. GIT COMMIT SUBSMISSION
  182. The preferred method for changes is to provide git commits via a
  183. publically-accessible git repository.
  184. All content guidelines in PATCH SUBMISSION apply.
  185. PATCH SUBMISSION
  186. * Send a clean diff against the 'master' branch of the quagga.git
  187. repository, in unified diff format, preferably with the '-p' argument to
  188. show C function affected by any chunk, and with the -w and -b arguments to
  189. minimise changes. E.g:
  190. git diff -up mybranch..remotes/quagga.net/master
  191. It is preferable to use git format-patch, and even more preferred to
  192. publish a git repostory.
  193. If not using git format-patch, Include the commit message in the email.
  194. * After a commit, code should have comments explaining to the reviewer
  195. why it is correct, without reference to history. The commit message
  196. should explain why the change is correct.
  197. * Include NEWS entries as appropriate.
  198. * Include only one semantic change or group of changes per patch.
  199. * Do not make gratuitous changes to whitespace. See the w and b arguments
  200. to diff.
  201. * State on which platforms and with what daemons the patch has been
  202. tested. Understand that if the set of testing locations is small,
  203. and the patch might have unforeseen or hard to fix consequences that
  204. there may be a call for testers on quagga-dev, and that the patch
  205. may be blocked until test results appear.
  206. If there are no users for a platform on quagga-dev who are able and
  207. willing to verify -current occasionally, that platform may be
  208. dropped from the "should be checked" list.
  209. PATCH APPLICATION
  210. * Only apply patches that meet the submission guidelines.
  211. * If the patch might break something, issue a call for testing on the
  212. mailinglist.
  213. * Give an appropriate commit message (see above), and use the --author
  214. argument to git-commit, if required, to ensure proper attribution (you
  215. should still be listed as committer)
  216. * Immediately after commiting, double-check (with git-log and/or gitk). If
  217. there's a small mistake you can easily fix it with 'git commit --amend ..'
  218. * By committing a patch, you are responsible for fixing problems
  219. resulting from it (or backing it out).
  220. STABLE PLATFORMS AND DAEMONS
  221. The list of platforms that should be tested follow. This is a list
  222. derived from what quagga is thought to run on and for which
  223. maintainers can test or there are people on quagga-dev who are able
  224. and willing to verify that -current does or does not work correctly.
  225. BSD (Free, Net or Open, any platform) # without capabilities
  226. GNU/Linux (any distribution, i386)
  227. Solaris (strict alignment, any platform)
  228. [future: NetBSD/sparc64]
  229. The list of daemons that are thought to be stable and that should be
  230. tested are:
  231. zebra
  232. bgpd
  233. ripd
  234. ospfd
  235. ripngd
  236. Daemons which are in a testing phase are
  237. ospf6d
  238. isisd
  239. watchquagga
  240. IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
  241. The source code of Quagga is based on two vendors:
  242. zebra_org (http://www.zebra.org/)
  243. isisd_sf (http://isisd.sf.net/)
  244. To import code from further sources, e.g. for archival purposes without
  245. necessarily having to review and/or fix some changeset, create a branch from
  246. 'master':
  247. git checkout -b archive/foo master
  248. <apply changes>
  249. git commit -a "Joe Bar <joe@example.com>"
  250. git push quagga archive/foo
  251. presuming 'quagga' corresponds to a file in your .git/remotes with
  252. configuration for the appropriate Quagga.net repository.