1. %% -*- mode: text; -*-
  2. %% $QuaggaId: Format:%an, %ai, %h$ $
  3. \documentclass[oneside]{article}
  4. \usepackage{parskip}
  5. \usepackage[bookmarks,colorlinks=true]{hyperref}
  6. \title{Conventions for working on Quagga}
  7. \begin{document}
  8. \maketitle
  9. This is a living document. Suggestions for updates, via the
  10. \href{http://lists.quagga.net/mailman/listinfo/quagga-dev}{quagga-dev list},
  11. are welcome.
  12. \tableofcontents
  14. \label{sec:guidelines}
  15. GNU coding standards apply. Indentation follows the result of
  16. invoking GNU indent (as of 2.2.8a) with no arguments. Note that this
  17. uses tabs instead of spaces where possible for leading whitespace, and
  18. assumes that tabs are every 8 columns. Do not attempt to redefine the
  19. location of tab stops. Note also that some indentation does not
  20. follow GNU style. This is a historical accident, and we generally
  21. only clean up whitespace when code is unmaintainable due to whitespace
  22. issues, to minimise merging conflicts.
  23. For GNU emacs, use indentation style ``gnu''.
  24. For Vim, use the following lines (note that tabs are at 8, and that
  25. softtabstop sets the indentation level):
  26. set tabstop=8
  27. set softtabstop=2
  28. set shiftwidth=2
  29. set noexpandtab
  30. Be particularly careful not to break platforms/protocols that you
  31. cannot test.
  32. New code should have good comments, which explain why the code is correct.
  33. Changes to existing code should in many cases upgrade the comments when
  34. necessary for a reviewer to conclude that the change has no unintended
  35. consequences.
  36. Each file in the Git repository should have a git format-placeholder (like
  37. an RCS Id keyword), somewhere very near the top, commented out appropriately
  38. for the file type. The placeholder used for Quagga (replacing <dollar> with
  39. \$) is:
  40. \verb|$QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $|
  41. See line 2 of HACKING.tex, the source for this document, for an example.
  42. This placeholder string will be expanded out by the `git archive' commands,
  43. wihch is used to generate the tar archives for snapshots and releases.
  44. Please document fully the proper use of a new function in the header file
  45. in which it is declared. And please consult existing headers for
  46. documentation on how to use existing functions. In particular, please consult
  47. these header files:
  48. \begin{description}
  49. \item{lib/log.h} logging levels and usage guidance
  50. \item{[more to be added]}
  51. \end{description}
  52. If changing an exported interface, please try to deprecate the interface in
  53. an orderly manner. If at all possible, try to retain the old deprecated
  54. interface as is, or functionally equivalent. Make a note of when the
  55. interface was deprecated and guard the deprecated interface definitions in
  56. the header file, ie:
  57. \begin{verbatim}
  58. /* Deprecated: 20050406 */
  60. #warning "Using deprecated <libname> (interface(s)|function(s))"
  61. ...
  63. \end{verbatim}
  64. This is to ensure that the core Quagga sources do not use the deprecated
  65. interfaces (you should update Quagga sources to use new interfaces, if
  66. applicable), while allowing external sources to continue to build.
  67. Deprecated interfaces should be excised in the next unstable cycle.
  68. Note: If you wish, you can test for GCC and use a function
  69. marked with the 'deprecated' attribute. However, you must provide the
  70. warning for other compilers.
  71. If changing or removing a command definition, \emph{ensure} that you
  72. properly deprecate it - use the \_DEPRECATED form of the appropriate DEFUN
  73. macro. This is \emph{critical}. Even if the command can no longer
  74. function, you \emph{MUST} still implement it as a do-nothing stub.
  75. Failure to follow this causes grief for systems administrators, as an
  76. upgrade may cause daemons to fail to start because of unrecognised commands.
  77. Deprecated commands should be excised in the next unstable cycle. A list of
  78. deprecated commands should be collated for each release.
  79. See also section~\ref{sec:dll-versioning} below regarding SHARED LIBRARY
  82. Please think very carefully before making code conditional at compile time,
  83. as it increases maintenance burdens and user confusion. In particular,
  84. please avoid gratuitious --enable-\ldots switches to the configure script -
  85. typically code should be good enough to be in Quagga, or it shouldn't be
  86. there at all.
  87. When code must be compile-time conditional, try have the compiler make it
  88. conditional rather than the C pre-processor - so that it will still be
  89. checked by the compiler, even if disabled. I.e. this:
  90. \begin{verbatim}
  91. if (SOME_SYMBOL)
  92. frobnicate();
  93. \end{verbatim}
  94. rather than:
  95. \begin{verbatim}
  96. #ifdef SOME_SYMBOL
  97. frobnicate ();
  98. #endif /* SOME_SYMBOL */
  99. \end{verbatim}
  100. Note that the former approach requires ensuring that SOME\_SYMBOL will be
  101. defined (watch your AC\_DEFINEs).
  102. \section{COMMIT MESSAGES}
  103. The commit message requirements are:
  104. \begin{itemize}
  105. \item The message \emph{MUST} provide a suitable one-line summary followed
  106. by a blank line as the very first line of the message, in the form:
  107. \verb|topic: high-level, one line summary|
  108. Where topic would tend to be name of a subdirectory, and/or daemon, unless
  109. there's a more suitable topic (e.g. 'build'). This topic is used to
  110. organise change summaries in release announcements.
  111. \item It should have a suitable "body", which tries to address the
  112. following areas, so as to help reviewers and future browsers of the
  113. code-base understand why the change is correct (note also the code
  114. comment requirements):
  115. \begin{itemize}
  116. \item The motivation for the change (does it fix a bug, if so which?
  117. add a feature?)
  118. \item The general approach taken, and trade-offs versus any other
  119. approaches.
  120. \item Any testing undertaken or other information affecting the confidence
  121. that can be had in the change.
  122. \item Information to allow reviewers to be able to tell which specific
  123. changes to the code are intended (and hence be able to spot any accidental
  124. unintended changes).
  125. \end{itemize}
  126. \end{itemize}
  127. The one-line summary must be limited to 54 characters, and all other
  128. lines to 72 characters.
  129. Commit message bodies in the Quagga project have typically taken the
  130. following form:
  131. \begin{itemize}
  132. \item An optional introduction, describing the change generally.
  133. \item A short description of each specific change made, preferably:
  134. \begin{itemize} \item file by file
  135. \begin{itemize} \item function by function (use of "ditto", or globs is
  136. allowed)
  137. \end{itemize}
  138. \end{itemize}
  139. \end{itemize}
  140. Contributors are strongly encouraged to follow this form.
  141. This itemised commit messages allows reviewers to have confidence that the
  142. author has self-reviewed every line of the patch, as well as providing
  143. reviewers a clear index of which changes are intended, and descriptions for
  144. them (C-to-english descriptions are not desireable - some discretion is
  145. useful). For short patches, a per-function/file break-down may be
  146. redundant. For longer patches, such a break-down may be essential. A
  147. contrived example (where the general discussion is obviously somewhat
  148. redundant, given the one-line summary):
  149. \begin{quote}\begin{verbatim}
  150. zebra: Enhance frob FSM to detect loss of frob
  151. Add a new DOWN state to the frob state machine to allow the barinator to
  152. detect loss of frob.
  153. * frob.h: (struct frob) Add DOWN state flag.
  154. * frob.c: (frob\_change) set/clear DOWN appropriately on state change.
  155. * bar.c: (barinate) Check frob for DOWN state.
  156. \end{verbatim}\end{quote}
  157. Please have a look at the git commit logs to get a feel for what the norms
  158. are.
  159. Note that the commit message format follows git norms, so that ``git
  160. log --oneline'' will have useful output.
  162. If you change or add to the build system (configure.ac, any Makefile.am,
  163. etc.), try to check that the following things still work:
  164. \begin{itemize}
  165. \item make dist
  166. \item resulting dist tarball builds
  167. \item out-of-tree builds
  168. \end{itemize}
  169. The quagga.net site relies on make dist to work to generate snapshots. It
  170. must work. Common problems are to forget to have some additional file
  171. included in the dist, or to have a make rule refer to a source file without
  172. using the srcdir variable.
  173. \section{RELEASE PROCEDURE}
  174. \begin{itemize}
  175. \item Tag the apppropriate commit with a release tag (follow existing
  176. conventions).
  177. [This enables recreating the release, and is just good CM practice.]
  178. \item Create a fresh tar archive of the quagga.net repository, and do a test
  179. build:
  180. \begin{verbatim}
  181. git-clone git:///code.quagga.net/quagga.git quagga
  182. git-archive --remote=git://code.quagga.net/quagga.git \
  183. --prefix=quagga-release/ master | tar -xf -
  184. cd quagga-release
  185. autoreconf -i
  186. ./configure
  187. make
  188. make dist
  189. \end{verbatim}
  190. \end{itemize}
  191. The tarball which `make dist' creates is the tarball to be released! The
  192. git-archive step ensures you're working with code corresponding to that in
  193. the official repository, and also carries out keyword expansion. If any
  194. errors occur, move tags as needed and start over from the fresh checkouts.
  195. Do not append to tarballs, as this has produced non-standards-conforming
  196. tarballs in the past.
  197. See also: \url{http://wiki.quagga.net/index.php/Main/Processes}
  198. [TODO: collation of a list of deprecated commands. Possibly can be scripted
  199. to extract from vtysh/vtysh\_cmd.c]
  200. \section{TOOL VERSIONS}
  201. Require versions of support tools are listed in INSTALL.quagga.txt.
  202. Required versions should only be done with due deliberation, as it can
  203. cause environments to no longer be able to compile quagga.
  205. \label{sec:dll-versioning}
  206. [this section is at the moment just gdt's opinion]
  207. Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
  208. ospfclient/libsopfapiclient). These may be used by external programs,
  209. e.g. a new routing protocol that works with the zebra daemon, or
  210. ospfapi clients. The libtool info pages (node Versioning) explain
  211. when major and minor version numbers should be changed. These values
  212. are set in Makefile.am near the definition of the library. If you
  213. make a change that requires changing the shared library version,
  214. please update Makefile.am.
  215. libospf exports far more than it should, and is needed by ospfapi
  216. clients. Only bump libospf for changes to functions for which it is
  217. reasonable for a user of ospfapi to call, and please err on the side
  218. of not bumping.
  219. There is no support intended for installing part of zebra. The core
  220. library libzebra and the included daemons should always be built and
  221. installed together.
  222. \section{GIT COMMIT SUBMISSION}
  223. \label{sec:git-submission}
  224. The preferred method for submitting changes is to provide git commits via a
  225. publically-accessible git repository, which the maintainers can easily pull.
  226. The commits should be in a branch based off the Quagga.net master - a
  227. "feature branch". Ideally there should be no commits to this branch other
  228. than those in master, and those intended to be submitted. However, merge
  229. commits to this branch from the Quagga master are permitted, though strongly
  230. discouraged - use another (potentially local and throw-away) branch to test
  231. merge with the latest Quagga master.
  232. Recommended practice is to keep different logical sets of changes on
  233. separate branches - "topic" or "feature" branches. This allows you to still
  234. merge them together to one branch (potentially local and/or "throw-away")
  235. for testing or use, while retaining smaller, independent branches that are
  236. easier to merge.
  237. All content guidelines in section \ref{sec:patch-submission}, PATCH
  238. SUBMISSION apply.
  239. \section{PATCH SUBMISSION}
  240. \label{sec:patch-submission}
  241. \begin{itemize}
  242. \item For complex changes, contributors are strongly encouraged to first
  243. start a design discussion on the quagga-dev list \emph{before}
  244. starting any coding.
  245. \item Send a clean diff against the 'master' branch of the quagga.git
  246. repository, in unified diff format, preferably with the '-p' argument to
  247. show C function affected by any chunk, and with the -w and -b arguments to
  248. minimise changes. E.g:
  249. git diff -up mybranch..remotes/quagga.net/master
  250. It is preferable to use git format-patch, and even more preferred to
  251. publish a git repository (see GIT COMMIT SUBMISSION, section
  252. \ref{sec:git-submission}).
  253. If not using git format-patch, Include the commit message in the email.
  254. \item After a commit, code should have comments explaining to the reviewer
  255. why it is correct, without reference to history. The commit message
  256. should explain why the change is correct.
  257. \item Include NEWS entries as appropriate.
  258. \item Include only one semantic change or group of changes per patch.
  259. \item Do not make gratuitous changes to whitespace. See the w and b arguments
  260. to diff.
  261. \item Changes should be arranged so that the least contraversial and most
  262. trivial are first, and the most complex or more contraversial are
  263. last. This will maximise how many the Quagga maintainers can merge,
  264. even if some other commits need further work.
  265. \item Providing a unit-test is strongly encouraged. Doing so will make it
  266. much easier for maintainers to have confidence that they will be able
  267. to support your change.
  268. \item New code should be arranged so that it easy to verify and test. E.g.
  269. stateful logic should be separated out from functional logic as much as
  270. possible: wherever possible, move complex logic out to smaller helper
  271. functions which access no state other than their arguments.
  272. \item State on which platforms and with what daemons the patch has been
  273. tested. Understand that if the set of testing locations is small,
  274. and the patch might have unforeseen or hard to fix consequences that
  275. there may be a call for testers on quagga-dev, and that the patch
  276. may be blocked until test results appear.
  277. If there are no users for a platform on quagga-dev who are able and
  278. willing to verify -current occasionally, that platform may be
  279. dropped from the "should be checked" list.
  280. \end{itemize}
  281. \section{PATCH APPLICATION}
  282. \begin{itemize}
  283. \item Only apply patches that meet the submission guidelines.
  284. \item If the patch might break something, issue a call for testing on the
  285. mailinglist.
  286. \item Give an appropriate commit message (see above), and use the --author
  287. argument to git-commit, if required, to ensure proper attribution (you
  288. should still be listed as committer)
  289. \item Immediately after commiting, double-check (with git-log and/or gitk).
  290. If there's a small mistake you can easily fix it with `git commit
  291. --amend ..'
  292. \item When merging a branch, always use an explicit merge commit. Giving
  293. --no-ff ensures a merge commit is created which documents ``this human
  294. decided to merge this branch at this time''.
  295. \end{itemize}
  297. The list of platforms that should be tested follow. This is a list
  298. derived from what quagga is thought to run on and for which
  299. maintainers can test or there are people on quagga-dev who are able
  300. and willing to verify that -current does or does not work correctly.
  301. \begin{itemize}
  302. \item BSD (Free, Net or Open, any platform)
  303. \item GNU/Linux (any distribution, i386)
  304. \item Solaris (strict alignment, any platform)
  305. \item future: NetBSD/sparc64
  306. \end{itemize}
  307. The list of daemons that are thought to be stable and that should be
  308. tested are:
  309. \begin{itemize}
  310. \item zebra
  311. \item bgpd
  312. \item ripd
  313. \item ospfd
  314. \item ripngd
  315. \end{itemize}
  316. Daemons which are in a testing phase are
  317. \begin{itemize}
  318. \item ospf6d
  319. \item isisd
  320. \item watchquagga
  321. \end{itemize}
  323. The source code of Quagga is based on two vendors:
  324. \verb|zebra_org| (\url{http://www.zebra.org/})
  325. \verb|isisd_sf| (\url{http://isisd.sf.net/})
  326. To import code from further sources, e.g. for archival purposes without
  327. necessarily having to review and/or fix some changeset, create a branch from
  328. `master':
  329. \begin{verbatim}
  330. git checkout -b archive/foo master
  331. <apply changes>
  332. git commit -a "Joe Bar <joe@example.com>"
  333. git push quagga archive/foo
  334. \end{verbatim}
  335. presuming `quagga' corresponds to a file in your .git/remotes with
  336. configuration for the appropriate Quagga.net repository.
  337. \end{document}