1. -*- mode: text; -*-
  2. $QuaggaId: Format:%an, %ai, %h$ $
  3. Contents:
  17. [this is a draft in progress]
  18. GNU coding standards apply. Indentation follows the result of
  19. invoking GNU indent (as of 2.2.8a) with no arguments. Note that this
  20. uses tabs instead of spaces where possible for leading whitespace, and
  21. assumes that tabs are every 8 columns. Do not attempt to redefine the
  22. location of tab stops. Note also that some indentation does not
  23. follow GNU style. This is a historical accident, and we generally
  24. only clean up whitespace when code is unmaintainable due to whitespace
  25. issues, to minimise merging conflicts.
  26. For GNU emacs, use indentation style "gnu".
  27. For Vim, use the following lines (note that tabs are at 8, and that
  28. softtabstop sets the indentation level):
  29. set tabstop=8
  30. set softtabstop=2
  31. set shiftwidth=2
  32. set noexpandtab
  33. Be particularly careful not to break platforms/protocols that you
  34. cannot test.
  35. New code should have good comments, which explain why the code is correct.
  36. Changes to existing code should in many cases upgrade the comments when
  37. necessary for a reviewer to conclude that the change has no unintended
  38. 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 */
  60. #warning "Using deprecated <libname> (interface(s)|function(s))"
  61. ...
  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.
  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 - so that it will still be
  86. checked by the compiler, even if disabled. I.e. this:
  87. if (SOME_SYMBOL)
  88. frobnicate();
  89. rather than:
  90. #ifdef SOME_SYMBOL
  91. frobnicate ();
  92. #endif /* SOME_SYMBOL */
  93. Note that the former approach requires ensuring that SOME_SYMBOL will be
  94. defined (watch your AC_DEFINEs).
  96. The commit message MUST provide:
  97. * A suitable one-line summary followed by a blank line as the very
  98. first line of the message, in the form:
  99. topic: high-level, one line summary
  100. Where topic would tend to be name of a subdirectory, and/or daemon, unless
  101. there's a more suitable topic (e.g. 'build'). This topic is used to
  102. organise change summaries in release announcements.
  103. The remainder of the commit message - its "body" - should ideally try to
  104. address the following areas, so as to help reviewers and future browsers of
  105. the code-base understand why the change is correct (note also the code
  106. comment requirements):
  107. * The motivation for the change (does it fix a bug, if so which?
  108. add a feature?)
  109. * The general approach taken, and trade-offs versus any other approaches.
  110. * Any testing undertaken or other information affecting the confidence
  111. that can be had in the change.
  112. * Information to allow reviewers to be able to tell which specific changes
  113. to the code are intended (and hence be able to spot any accidental
  114. unintended changes).
  115. The one-line summary must be limited to 54 characters, and all other
  116. lines to 72 characters.
  117. Commit message bodies in the Quagga project have typically taken the
  118. following form:
  119. * An optional introduction, describing the change generally.
  120. * A short description of each specific change made, preferably:
  121. * file by file
  122. * function by function (use of "ditto", or globs is allowed)
  123. Contributors are strongly encouraged to follow this form.
  124. This itemised commit messages allows reviewers to have confidence that the
  125. author has self-reviewed every line of the patch, as well as providing
  126. reviewers a clear index of which changes are intended, and descriptions for
  127. them (C-to-english descriptions are not desireable - some discretion is
  128. useful). For short patches, a per-function/file break-down may be
  129. redundant. For longer patches, such a break-down may be essential. A
  130. contrived example (where the general discussion is obviously somewhat
  131. redundant, given the one-line summary):
  132. zebra: Enhance frob FSM to detect loss of frob
  133. Add a new DOWN state to the frob state machine to allow the barinator to
  134. detect loss of frob.
  135. * frob.h: (struct frob) Add DOWN state flag.
  136. * frob.c: (frob_change) set/clear DOWN appropriately on state change.
  137. * bar.c: (barinate) Check frob for DOWN state.
  138. Please have a look at the git commit logs to get a feel for what the norms
  139. are.
  140. Note that the commit message format follows git norms, so that "git
  141. log --oneline" will have useful output.
  143. If you change or add to the build system (configure.ac, any Makefile.am,
  144. etc.), try to check that the following things still work:
  145. - make dist
  146. - resulting dist tarball builds
  147. - out-of-tree builds
  148. The quagga.net site relies on make dist to work to generate snapshots. It
  149. must work. Common problems are to forget to have some additional file
  150. included in the dist, or to have a make rule refer to a source file without
  151. using the srcdir variable.
  153. * Tag the apppropriate commit with a release tag (follow existing
  154. conventions).
  155. [This enables recreating the release, and is just good CM practice.]
  156. * Create a fresh tar archive of the quagga.net repository, and do a test
  157. build:
  158. git-clone git:///code.quagga.net/quagga.git quagga
  159. git-archive --remote=git://code.quagga.net/quagga.git \
  160. --prefix=quagga-release/ master | tar -xf -
  161. cd quagga-release
  162. autoreconf -i
  163. ./configure
  164. make
  165. make dist
  166. The tarball which 'make dist' creates is the tarball to be released! The
  167. git-archive step ensures you're working with code corresponding to that in
  168. the official repository, and also carries out keyword expansion. If any
  169. errors occur, move tags as needed and start over from the fresh checkouts.
  170. Do not append to tarballs, as this has produced non-standards-conforming
  171. tarballs in the past.
  172. See also: http://wiki.quagga.net/index.php/Main/Processes
  173. [TODO: collation of a list of deprecated commands. Possibly can be scripted
  174. to extract from vtysh/vtysh_cmd.c]
  176. Require versions of support tools are listed in INSTALL.quagga.txt.
  177. Required versions should only be done with due deliberation, as it can
  178. cause environments to no longer be able to compile quagga.
  180. [this section is at the moment just gdt's opinion]
  181. Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
  182. ospfclient/libsopfapiclient). These may be used by external programs,
  183. e.g. a new routing protocol that works with the zebra daemon, or
  184. ospfapi clients. The libtool info pages (node Versioning) explain
  185. when major and minor version numbers should be changed. These values
  186. are set in Makefile.am near the definition of the library. If you
  187. make a change that requires changing the shared library version,
  188. please update Makefile.am.
  189. libospf exports far more than it should, and is needed by ospfapi
  190. clients. Only bump libospf for changes to functions for which it is
  191. reasonable for a user of ospfapi to call, and please err on the side
  192. of not bumping.
  193. There is no support intended for installing part of zebra. The core
  194. library libzebra and the included daemons should always be built and
  195. installed together.
  197. The preferred method for submitting changes is to provide git commits via a
  198. publically-accessible git repository, which the maintainers can easily pull.
  199. The commits should be in a branch based off the Quagga.net master - a
  200. "feature branch". Ideally there should be no commits to this branch other
  201. than those in master, and those intended to be submitted. However, merge
  202. commits to this branch from the Quagga master are permitted, though strongly
  203. discouraged - use another (potentially local and throw-away) branch to test
  204. merge with the latest Quagga master.
  205. Recommended practice is to keep different logical sets of changes on
  206. separate branches - "topic" or "feature" branches. This allows you to still
  207. merge them together to one branch (potentially local and/or "throw-away")
  208. for testing or use, while retaining smaller, independent branches that are
  209. easier to merge.
  210. All content guidelines in PATCH SUBMISSION apply.
  212. * For complex changes, contributors are strongly encouraged to first start a
  213. design discussion on the quagga-dev list before starting any coding.
  214. * Send a clean diff against the 'master' branch of the quagga.git
  215. repository, in unified diff format, preferably with the '-p' argument to
  216. show C function affected by any chunk, and with the -w and -b arguments to
  217. minimise changes. E.g:
  218. git diff -up mybranch..remotes/quagga.net/master
  219. It is preferable to use git format-patch, and even more preferred to
  220. publish a git repository (see GIT COMMIT SUBMISSION).
  221. If not using git format-patch, Include the commit message in the email.
  222. * After a commit, code should have comments explaining to the reviewer
  223. why it is correct, without reference to history. The commit message
  224. should explain why the change is correct.
  225. * Include NEWS entries as appropriate.
  226. * Include only one semantic change or group of changes per patch.
  227. * Do not make gratuitous changes to whitespace. See the w and b arguments
  228. to diff.
  229. * Changes should be arranged so that the least contraversial and most
  230. trivial are first, and the most complex or more contraversial are last.
  231. This will maximise how many the Quagga maintainers can merge, even if some
  232. other commits need further work.
  233. * Providing a unit-test is strongly encouraged. Doing so will make it
  234. much easier for maintainers to have confidence that they will be able
  235. to support your change.
  236. * New code should be arranged so that it easy to verify and test. E.g.
  237. stateful logic should be separated out from functional logic as much as
  238. possible: wherever possible, move complex logic out to smaller helper
  239. functions which access no state other than their arguments.
  240. * State on which platforms and with what daemons the patch has been
  241. tested. Understand that if the set of testing locations is small,
  242. and the patch might have unforeseen or hard to fix consequences that
  243. there may be a call for testers on quagga-dev, and that the patch
  244. may be blocked until test results appear.
  245. If there are no users for a platform on quagga-dev who are able and
  246. willing to verify -current occasionally, that platform may be
  247. dropped from the "should be checked" list.
  249. * Only apply patches that meet the submission guidelines.
  250. * If the patch might break something, issue a call for testing on the
  251. mailinglist.
  252. * Give an appropriate commit message (see above), and use the --author
  253. argument to git-commit, if required, to ensure proper attribution (you
  254. should still be listed as committer)
  255. * Immediately after commiting, double-check (with git-log and/or gitk). If
  256. there's a small mistake you can easily fix it with 'git commit --amend ..'
  257. * When merging a branch, always use an explicit merge commit. Giving --no-ff
  258. ensures a merge commit is created which documents "this human decided to
  259. merge this branch at this time".
  261. The list of platforms that should be tested follow. This is a list
  262. derived from what quagga is thought to run on and for which
  263. maintainers can test or there are people on quagga-dev who are able
  264. and willing to verify that -current does or does not work correctly.
  265. BSD (Free, Net or Open, any platform) # without capabilities
  266. GNU/Linux (any distribution, i386)
  267. Solaris (strict alignment, any platform)
  268. [future: NetBSD/sparc64]
  269. The list of daemons that are thought to be stable and that should be
  270. tested are:
  271. zebra
  272. bgpd
  273. ripd
  274. ospfd
  275. ripngd
  276. Daemons which are in a testing phase are
  277. ospf6d
  278. isisd
  279. watchquagga
  281. The source code of Quagga is based on two vendors:
  282. zebra_org (http://www.zebra.org/)
  283. isisd_sf (http://isisd.sf.net/)
  284. To import code from further sources, e.g. for archival purposes without
  285. necessarily having to review and/or fix some changeset, create a branch from
  286. 'master':
  287. git checkout -b archive/foo master
  288. <apply changes>
  289. git commit -a "Joe Bar <joe@example.com>"
  290. git push quagga archive/foo
  291. presuming 'quagga' corresponds to a file in your .git/remotes with
  292. configuration for the appropriate Quagga.net repository.