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. Routing protocols can be very complex sometimes. Then, working with an
  83. Opensource community can be complex too, but usually friendly with
  84. anyone who is ready to be willing to do it properly.
  85. \begin{itemize}
  86. \item First, start doing simple tasks. Quagga's patchwork is a good place
  87. to start with. Pickup some patches, apply them on your git trie,
  88. review them and send your ack't or review comments. Then, a
  89. maintainer will apply the patch if ack't or the author will
  90. have to provide a new update. It help a lot to drain the
  91. patchwork queues.
  92. See \url{http://patchwork.quagga.net/project/quagga/list/}
  93. \item The more you'll review patches from patchwork, the more the
  94. Quagga's maintainers will be willing to consider some patches you will
  95. be sending.
  96. \item start using git clone, pwclient \url{http://patchwork.quagga.net/help/pwclient/}
  97. \begin{verbatim}
  98. $ pwclient list -s new
  99. ID State Name
  100. -- ----- ----
  101. 179 New [quagga-dev,6648] Re: quagga on FreeBSD 4.11 (gcc-2.95)
  102. 181 New [quagga-dev,6660] proxy-arp patch
  103. [...]
  104. $ pwclient git-am 1046
  105. \end{verbatim}
  106. \end{itemize}
  108. Get your cloned trie:
  109. \begin{verbatim}
  110. git clone vjardin@git.sv.gnu.org:/srv/git/quagga.git
  111. \end{verbatim}
  112. Apply some ack't patches:
  113. \begin{verbatim}
  114. pwclient git-am 1046
  115. Applying patch #1046 using 'git am'
  116. Description: [quagga-dev,11595] zebra: route_unlock_node is missing in "show ip[v6] route <prefix>" commands
  117. Applying: zebra: route_unlock_node is missing in "show ip[v6] route <prefix>" commands
  118. \end{verbatim}
  119. Run a quick review. If the ack't was not done properly, you know who you have
  120. to blame.
  121. Push the patches:
  122. \begin{verbatim}
  123. git push
  124. \end{verbatim}
  125. Set the patch to accepted on patchwork
  126. \begin{verbatim}
  127. pwclient update -s Accepted 1046
  128. \end{verbatim}
  130. Please think very carefully before making code conditional at compile time,
  131. as it increases maintenance burdens and user confusion. In particular,
  132. please avoid gratuitious --enable-\ldots switches to the configure script -
  133. typically code should be good enough to be in Quagga, or it shouldn't be
  134. there at all.
  135. When code must be compile-time conditional, try have the compiler make it
  136. conditional rather than the C pre-processor - so that it will still be
  137. checked by the compiler, even if disabled. I.e. this:
  138. \begin{verbatim}
  139. if (SOME_SYMBOL)
  140. frobnicate();
  141. \end{verbatim}
  142. rather than:
  143. \begin{verbatim}
  144. #ifdef SOME_SYMBOL
  145. frobnicate ();
  146. #endif /* SOME_SYMBOL */
  147. \end{verbatim}
  148. Note that the former approach requires ensuring that SOME\_SYMBOL will be
  149. defined (watch your AC\_DEFINEs).
  150. \section{COMMIT MESSAGES}
  151. The commit message requirements are:
  152. \begin{itemize}
  153. \item The message \emph{MUST} provide a suitable one-line summary followed
  154. by a blank line as the very first line of the message, in the form:
  155. \verb|topic: high-level, one line summary|
  156. Where topic would tend to be name of a subdirectory, and/or daemon, unless
  157. there's a more suitable topic (e.g. 'build'). This topic is used to
  158. organise change summaries in release announcements.
  159. \item It should have a suitable "body", which tries to address the
  160. following areas, so as to help reviewers and future browsers of the
  161. code-base understand why the change is correct (note also the code
  162. comment requirements):
  163. \begin{itemize}
  164. \item The motivation for the change (does it fix a bug, if so which?
  165. add a feature?)
  166. \item The general approach taken, and trade-offs versus any other
  167. approaches.
  168. \item Any testing undertaken or other information affecting the confidence
  169. that can be had in the change.
  170. \item Information to allow reviewers to be able to tell which specific
  171. changes to the code are intended (and hence be able to spot any accidental
  172. unintended changes).
  173. \end{itemize}
  174. \end{itemize}
  175. The one-line summary must be limited to 54 characters, and all other
  176. lines to 72 characters.
  177. Commit message bodies in the Quagga project have typically taken the
  178. following form:
  179. \begin{itemize}
  180. \item An optional introduction, describing the change generally.
  181. \item A short description of each specific change made, preferably:
  182. \begin{itemize} \item file by file
  183. \begin{itemize} \item function by function (use of "ditto", or globs is
  184. allowed)
  185. \end{itemize}
  186. \end{itemize}
  187. \end{itemize}
  188. Contributors are strongly encouraged to follow this form.
  189. This itemised commit messages allows reviewers to have confidence that the
  190. author has self-reviewed every line of the patch, as well as providing
  191. reviewers a clear index of which changes are intended, and descriptions for
  192. them (C-to-english descriptions are not desireable - some discretion is
  193. useful). For short patches, a per-function/file break-down may be
  194. redundant. For longer patches, such a break-down may be essential. A
  195. contrived example (where the general discussion is obviously somewhat
  196. redundant, given the one-line summary):
  197. \begin{quote}\begin{verbatim}
  198. zebra: Enhance frob FSM to detect loss of frob
  199. Add a new DOWN state to the frob state machine to allow the barinator to
  200. detect loss of frob.
  201. * frob.h: (struct frob) Add DOWN state flag.
  202. * frob.c: (frob_change) set/clear DOWN appropriately on state change.
  203. * bar.c: (barinate) Check frob for DOWN state.
  204. \end{verbatim}\end{quote}
  205. Please have a look at the git commit logs to get a feel for what the norms
  206. are.
  207. Note that the commit message format follows git norms, so that ``git
  208. log --oneline'' will have useful output.
  210. If you change or add to the build system (configure.ac, any Makefile.am,
  211. etc.), try to check that the following things still work:
  212. \begin{itemize}
  213. \item make dist
  214. \item resulting dist tarball builds
  215. \item out-of-tree builds
  216. \end{itemize}
  217. The quagga.net site relies on make dist to work to generate snapshots. It
  218. must work. Common problems are to forget to have some additional file
  219. included in the dist, or to have a make rule refer to a source file without
  220. using the srcdir variable.
  221. \section{RELEASE PROCEDURE}
  222. \begin{itemize}
  223. \item Tag the apppropriate commit with a release tag (follow existing
  224. conventions).
  225. [This enables recreating the release, and is just good CM practice.]
  226. \item Create a fresh tar archive of the quagga.net repository, and do a test
  227. build:
  228. \begin{verbatim}
  229. git-clone git:///code.quagga.net/quagga.git quagga
  230. git-archive --remote=git://code.quagga.net/quagga.git \
  231. --prefix=quagga-release/ master | tar -xf -
  232. cd quagga-release
  233. autoreconf -i
  234. ./configure
  235. make
  236. make dist
  237. \end{verbatim}
  238. \end{itemize}
  239. The tarball which `make dist' creates is the tarball to be released! The
  240. git-archive step ensures you're working with code corresponding to that in
  241. the official repository, and also carries out keyword expansion. If any
  242. errors occur, move tags as needed and start over from the fresh checkouts.
  243. Do not append to tarballs, as this has produced non-standards-conforming
  244. tarballs in the past.
  245. See also: \url{http://wiki.quagga.net/index.php/Main/Processes}
  246. [TODO: collation of a list of deprecated commands. Possibly can be scripted
  247. to extract from vtysh/vtysh\_cmd.c]
  248. \section{TOOL VERSIONS}
  249. Require versions of support tools are listed in INSTALL.quagga.txt.
  250. Required versions should only be done with due deliberation, as it can
  251. cause environments to no longer be able to compile quagga.
  253. \label{sec:dll-versioning}
  254. [this section is at the moment just gdt's opinion]
  255. Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
  256. ospfclient/libsopfapiclient). These may be used by external programs,
  257. e.g. a new routing protocol that works with the zebra daemon, or
  258. ospfapi clients. The libtool info pages (node Versioning) explain
  259. when major and minor version numbers should be changed. These values
  260. are set in Makefile.am near the definition of the library. If you
  261. make a change that requires changing the shared library version,
  262. please update Makefile.am.
  263. libospf exports far more than it should, and is needed by ospfapi
  264. clients. Only bump libospf for changes to functions for which it is
  265. reasonable for a user of ospfapi to call, and please err on the side
  266. of not bumping.
  267. There is no support intended for installing part of zebra. The core
  268. library libzebra and the included daemons should always be built and
  269. installed together.
  270. \section{GIT COMMIT SUBMISSION}
  271. \label{sec:git-submission}
  272. The preferred method for submitting changes is to provide git commits via a
  273. publically-accessible git repository, which the maintainers can easily pull.
  274. The commits should be in a branch based off the Quagga.net master - a
  275. "feature branch". Ideally there should be no commits to this branch other
  276. than those in master, and those intended to be submitted. However, merge
  277. commits to this branch from the Quagga master are permitted, though strongly
  278. discouraged - use another (potentially local and throw-away) branch to test
  279. merge with the latest Quagga master.
  280. Recommended practice is to keep different logical sets of changes on
  281. separate branches - "topic" or "feature" branches. This allows you to still
  282. merge them together to one branch (potentially local and/or "throw-away")
  283. for testing or use, while retaining smaller, independent branches that are
  284. easier to merge.
  285. All content guidelines in section \ref{sec:patch-submission}, PATCH
  286. SUBMISSION apply.
  287. \section{PATCH SUBMISSION}
  288. \label{sec:patch-submission}
  289. \begin{itemize}
  290. \item For complex changes, contributors are strongly encouraged to first
  291. start a design discussion on the quagga-dev list \emph{before}
  292. starting any coding.
  293. \item Send a clean diff against the 'master' branch of the quagga.git
  294. repository, in unified diff format, preferably with the '-p' argument to
  295. show C function affected by any chunk, and with the -w and -b arguments to
  296. minimise changes. E.g:
  297. git diff -up mybranch..remotes/quagga.net/master
  298. It is preferable to use git format-patch, and even more preferred to
  299. publish a git repository (see GIT COMMIT SUBMISSION, section
  300. \ref{sec:git-submission}).
  301. If not using git format-patch, Include the commit message in the email.
  302. \item After a commit, code should have comments explaining to the reviewer
  303. why it is correct, without reference to history. The commit message
  304. should explain why the change is correct.
  305. \item Include NEWS entries as appropriate.
  306. \item Include only one semantic change or group of changes per patch.
  307. \item Do not make gratuitous changes to whitespace. See the w and b arguments
  308. to diff.
  309. \item Changes should be arranged so that the least contraversial and most
  310. trivial are first, and the most complex or more contraversial are
  311. last. This will maximise how many the Quagga maintainers can merge,
  312. even if some other commits need further work.
  313. \item Providing a unit-test is strongly encouraged. Doing so will make it
  314. much easier for maintainers to have confidence that they will be able
  315. to support your change.
  316. \item New code should be arranged so that it easy to verify and test. E.g.
  317. stateful logic should be separated out from functional logic as much as
  318. possible: wherever possible, move complex logic out to smaller helper
  319. functions which access no state other than their arguments.
  320. \item State on which platforms and with what daemons the patch has been
  321. tested. Understand that if the set of testing locations is small,
  322. and the patch might have unforeseen or hard to fix consequences that
  323. there may be a call for testers on quagga-dev, and that the patch
  324. may be blocked until test results appear.
  325. If there are no users for a platform on quagga-dev who are able and
  326. willing to verify -current occasionally, that platform may be
  327. dropped from the "should be checked" list.
  328. \end{itemize}
  329. \section{PATCH APPLICATION}
  330. \begin{itemize}
  331. \item Only apply patches that meet the submission guidelines.
  332. \item If the patch might break something, issue a call for testing on the
  333. mailinglist.
  334. \item Give an appropriate commit message (see above), and use the --author
  335. argument to git-commit, if required, to ensure proper attribution (you
  336. should still be listed as committer)
  337. \item Immediately after commiting, double-check (with git-log and/or gitk).
  338. If there's a small mistake you can easily fix it with `git commit
  339. --amend ..'
  340. \item When merging a branch, always use an explicit merge commit. Giving
  341. --no-ff ensures a merge commit is created which documents ``this human
  342. decided to merge this branch at this time''.
  343. \end{itemize}
  345. The list of platforms that should be tested follow. This is a list
  346. derived from what quagga is thought to run on and for which
  347. maintainers can test or there are people on quagga-dev who are able
  348. and willing to verify that -current does or does not work correctly.
  349. \begin{itemize}
  350. \item BSD (Free, Net or Open, any platform)
  351. \item GNU/Linux (any distribution, i386)
  352. \item Solaris (strict alignment, any platform)
  353. \item future: NetBSD/sparc64
  354. \end{itemize}
  355. The list of daemons that are thought to be stable and that should be
  356. tested are:
  357. \begin{itemize}
  358. \item zebra
  359. \item bgpd
  360. \item ripd
  361. \item ospfd
  362. \item ripngd
  363. \end{itemize}
  364. Daemons which are in a testing phase are
  365. \begin{itemize}
  366. \item ospf6d
  367. \item isisd
  368. \item watchquagga
  369. \end{itemize}
  371. The source code of Quagga is based on two vendors:
  372. \verb|zebra_org| (\url{http://www.zebra.org/})
  373. \verb|isisd_sf| (\url{http://isisd.sf.net/})
  374. To import code from further sources, e.g. for archival purposes without
  375. necessarily having to review and/or fix some changeset, create a branch from
  376. `master':
  377. \begin{verbatim}
  378. git checkout -b archive/foo master
  379. <apply changes>
  380. git commit -a "Joe Bar <joe@example.com>"
  381. git push quagga archive/foo
  382. \end{verbatim}
  383. presuming `quagga' corresponds to a file in your .git/remotes with
  384. configuration for the appropriate Quagga.net repository.
  385. \end{document}