blob: be86ae18d2341a9c63ce9fdbfbf4f122a7f1f594 [file] [log] [blame]
Paul Jakmafa482832012-03-08 13:51:21 +00001%% -*- mode: text; -*-
2%% $QuaggaId: Format:%an, %ai, %h$ $
3
4\documentclass[oneside]{article}
5\usepackage{parskip}
6\usepackage[bookmarks,colorlinks=true]{hyperref}
7
8\title{Conventions for working on Quagga}
9
10\begin{document}
11\maketitle
12
13This is a living document. Suggestions for updates, via the
14\href{http://lists.quagga.net/mailman/listinfo/quagga-dev}{quagga-dev list},
15are welcome.
16
17\tableofcontents
18
19\section{GUIDELINES FOR HACKING ON QUAGGA}
20\label{sec:guidelines}
21
22
23GNU coding standards apply. Indentation follows the result of
Paul Jakma4da670b2014-10-27 15:14:06 +000024invoking GNU indent (as of 2.2.8a) with the --nut argument.
Paul Jakmafa482832012-03-08 13:51:21 +000025
Paul Jakma4da670b2014-10-27 15:14:06 +000026Originally, tabs were used instead of spaces, with tabs are every 8 columns.
27However, tab's interoperability issues mean space characters are now preferred for
28new changes. We generally only clean up whitespace when code is unmaintainable
29due to whitespace issues, to minimise merging conflicts.
Paul Jakmafa482832012-03-08 13:51:21 +000030
31Be particularly careful not to break platforms/protocols that you
32cannot test.
33
34New code should have good comments, which explain why the code is correct.
35Changes to existing code should in many cases upgrade the comments when
36necessary for a reviewer to conclude that the change has no unintended
37consequences.
38
39Each file in the Git repository should have a git format-placeholder (like
40an RCS Id keyword), somewhere very near the top, commented out appropriately
41for the file type. The placeholder used for Quagga (replacing <dollar> with
42\$) is:
43
44 \verb|$QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $|
45
46See line 2 of HACKING.tex, the source for this document, for an example.
47
48This placeholder string will be expanded out by the `git archive' commands,
Paul Jakmaf0996122014-10-27 15:09:38 +000049which is used to generate the tar archives for snapshots and releases.
Paul Jakmafa482832012-03-08 13:51:21 +000050
51Please document fully the proper use of a new function in the header file
52in which it is declared. And please consult existing headers for
53documentation on how to use existing functions. In particular, please consult
54these header files:
55
56\begin{description}
57 \item{lib/log.h} logging levels and usage guidance
58 \item{[more to be added]}
59\end{description}
60
61If changing an exported interface, please try to deprecate the interface in
62an orderly manner. If at all possible, try to retain the old deprecated
63interface as is, or functionally equivalent. Make a note of when the
64interface was deprecated and guard the deprecated interface definitions in
Paul Jakmaf0996122014-10-27 15:09:38 +000065the header file, i.e.:
Paul Jakmafa482832012-03-08 13:51:21 +000066
67\begin{verbatim}
68/* Deprecated: 20050406 */
69#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
70#warning "Using deprecated <libname> (interface(s)|function(s))"
71...
72#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
73\end{verbatim}
74
75This is to ensure that the core Quagga sources do not use the deprecated
76interfaces (you should update Quagga sources to use new interfaces, if
77applicable), while allowing external sources to continue to build.
78Deprecated interfaces should be excised in the next unstable cycle.
79
80Note: If you wish, you can test for GCC and use a function
81marked with the 'deprecated' attribute. However, you must provide the
82warning for other compilers.
83
84If changing or removing a command definition, \emph{ensure} that you
85properly deprecate it - use the \_DEPRECATED form of the appropriate DEFUN
86macro. This is \emph{critical}. Even if the command can no longer
87function, you \emph{MUST} still implement it as a do-nothing stub.
88
89Failure to follow this causes grief for systems administrators, as an
90upgrade may cause daemons to fail to start because of unrecognised commands.
91Deprecated commands should be excised in the next unstable cycle. A list of
92deprecated commands should be collated for each release.
93
94See also section~\ref{sec:dll-versioning} below regarding SHARED LIBRARY
95VERSIONING.
96
Vincent JARDINf80ba042014-10-27 13:03:14 +000097\section{YOUR FIRST CONTRIBUTIONS}
98
99Routing protocols can be very complex sometimes. Then, working with an
100Opensource community can be complex too, but usually friendly with
101anyone who is ready to be willing to do it properly.
102
103\begin{itemize}
104
105 \item First, start doing simple tasks. Quagga's patchwork is a good place
106 to start with. Pickup some patches, apply them on your git trie,
107 review them and send your ack't or review comments. Then, a
108 maintainer will apply the patch if ack't or the author will
109 have to provide a new update. It help a lot to drain the
110 patchwork queues.
111 See \url{http://patchwork.quagga.net/project/quagga/list/}
112
113 \item The more you'll review patches from patchwork, the more the
114 Quagga's maintainers will be willing to consider some patches you will
115 be sending.
116
117 \item start using git clone, pwclient \url{http://patchwork.quagga.net/help/pwclient/}
118
119\begin{verbatim}
120$ pwclient list -s new
121ID State Name
122-- ----- ----
123179 New [quagga-dev,6648] Re: quagga on FreeBSD 4.11 (gcc-2.95)
124181 New [quagga-dev,6660] proxy-arp patch
125[...]
126
127$ pwclient git-am 1046
128\end{verbatim}
129
130\end{itemize}
131
132\section{HANDY GUIDELINES FOR MAINTAINERS}
133
134Get your cloned trie:
135\begin{verbatim}
136 git clone vjardin@git.sv.gnu.org:/srv/git/quagga.git
137\end{verbatim}
138
139Apply some ack't patches:
140\begin{verbatim}
141 pwclient git-am 1046
142 Applying patch #1046 using 'git am'
143 Description: [quagga-dev,11595] zebra: route_unlock_node is missing in "show ip[v6] route <prefix>" commands
144 Applying: zebra: route_unlock_node is missing in "show ip[v6] route <prefix>" commands
145\end{verbatim}
146
147Run a quick review. If the ack't was not done properly, you know who you have
148to blame.
149
150Push the patches:
151\begin{verbatim}
152 git push
153\end{verbatim}
154
155Set the patch to accepted on patchwork
156\begin{verbatim}
157 pwclient update -s Accepted 1046
158\end{verbatim}
Paul Jakmafa482832012-03-08 13:51:21 +0000159
160\section{COMPILE-TIME CONDITIONAL CODE}
161
162Please think very carefully before making code conditional at compile time,
163as it increases maintenance burdens and user confusion. In particular,
Paul Jakmaf0996122014-10-27 15:09:38 +0000164please avoid gratuitous --enable-\ldots switches to the configure script -
Paul Jakmafa482832012-03-08 13:51:21 +0000165typically code should be good enough to be in Quagga, or it shouldn't be
Paul Jakmaf0996122014-10-27 15:09:38 +0000166there at all.
Paul Jakmafa482832012-03-08 13:51:21 +0000167
168When code must be compile-time conditional, try have the compiler make it
169conditional rather than the C pre-processor - so that it will still be
170checked by the compiler, even if disabled. I.e. this:
171
172\begin{verbatim}
173 if (SOME_SYMBOL)
174 frobnicate();
175\end{verbatim}
176
177rather than:
178
179\begin{verbatim}
180 #ifdef SOME_SYMBOL
181 frobnicate ();
182 #endif /* SOME_SYMBOL */
183\end{verbatim}
184
185Note that the former approach requires ensuring that SOME\_SYMBOL will be
186defined (watch your AC\_DEFINEs).
187
188
189\section{COMMIT MESSAGES}
190
191The commit message requirements are:
192
193\begin{itemize}
194
195\item The message \emph{MUST} provide a suitable one-line summary followed
196 by a blank line as the very first line of the message, in the form:
197
198 \verb|topic: high-level, one line summary|
199
200 Where topic would tend to be name of a subdirectory, and/or daemon, unless
201 there's a more suitable topic (e.g. 'build'). This topic is used to
202 organise change summaries in release announcements.
203
204\item It should have a suitable "body", which tries to address the
205 following areas, so as to help reviewers and future browsers of the
206 code-base understand why the change is correct (note also the code
207 comment requirements):
208
209 \begin{itemize}
210
211 \item The motivation for the change (does it fix a bug, if so which?
212 add a feature?)
213
214 \item The general approach taken, and trade-offs versus any other
215 approaches.
216
217 \item Any testing undertaken or other information affecting the confidence
218 that can be had in the change.
219
220 \item Information to allow reviewers to be able to tell which specific
221 changes to the code are intended (and hence be able to spot any accidental
222 unintended changes).
223
224 \end{itemize}
225\end{itemize}
226
227The one-line summary must be limited to 54 characters, and all other
228lines to 72 characters.
229
230Commit message bodies in the Quagga project have typically taken the
231following form:
232
233\begin{itemize}
234\item An optional introduction, describing the change generally.
235\item A short description of each specific change made, preferably:
236 \begin{itemize} \item file by file
237 \begin{itemize} \item function by function (use of "ditto", or globs is
238 allowed)
239 \end{itemize}
240 \end{itemize}
241\end{itemize}
242
243Contributors are strongly encouraged to follow this form.
244
245This itemised commit messages allows reviewers to have confidence that the
246author has self-reviewed every line of the patch, as well as providing
247reviewers a clear index of which changes are intended, and descriptions for
Paul Jakmaf0996122014-10-27 15:09:38 +0000248them (C-to-english descriptions are not desirable - some discretion is
Paul Jakmafa482832012-03-08 13:51:21 +0000249useful). For short patches, a per-function/file break-down may be
250redundant. For longer patches, such a break-down may be essential. A
251contrived example (where the general discussion is obviously somewhat
252redundant, given the one-line summary):
253
254\begin{quote}\begin{verbatim}
255zebra: Enhance frob FSM to detect loss of frob
256
257Add a new DOWN state to the frob state machine to allow the barinator to
258detect loss of frob.
259
260* frob.h: (struct frob) Add DOWN state flag.
Paul Jakmad4a86072012-10-19 12:02:42 +0100261* frob.c: (frob_change) set/clear DOWN appropriately on state change.
Paul Jakmafa482832012-03-08 13:51:21 +0000262* bar.c: (barinate) Check frob for DOWN state.
263\end{verbatim}\end{quote}
264
265Please have a look at the git commit logs to get a feel for what the norms
266are.
267
268Note that the commit message format follows git norms, so that ``git
269log --oneline'' will have useful output.
270
271\section{HACKING THE BUILD SYSTEM}
272
273If you change or add to the build system (configure.ac, any Makefile.am,
274etc.), try to check that the following things still work:
275
276\begin{itemize}
277\item make dist
278\item resulting dist tarball builds
279\item out-of-tree builds
280\end{itemize}
281
282The quagga.net site relies on make dist to work to generate snapshots. It
283must work. Common problems are to forget to have some additional file
284included in the dist, or to have a make rule refer to a source file without
285using the srcdir variable.
286
287
288\section{RELEASE PROCEDURE}
289
290\begin{itemize}
Paul Jakmaf0996122014-10-27 15:09:38 +0000291\item Tag the appropriate commit with a release tag (follow existing
Paul Jakmafa482832012-03-08 13:51:21 +0000292 conventions).
293
294 [This enables recreating the release, and is just good CM practice.]
295
296\item Create a fresh tar archive of the quagga.net repository, and do a test
297 build:
298
299 \begin{verbatim}
David Lamparterec62e142015-03-07 08:40:56 +0100300 vim configure.ac
301 git commit -m "release: 0.99.99.99"
302 git tag -u 54CD2E60 quagga-0.99.99.99
303 git push savannah tag quagga-0.99.99.99
304
305 git archive --prefix=quagga-release/ quagga-0.99.99.99 | tar xC /tmp
306 git log quagga-0.99.99.98..quagga-0.99.99.99 > \
307 /tmp/quagga-release/quagga-0.99.99.99.changelog.txt
308 cd /tmp/quagga-release
Paul Jakmafa482832012-03-08 13:51:21 +0000309
310 autoreconf -i
311 ./configure
312 make
David Lamparterec62e142015-03-07 08:40:56 +0100313 make dist-gzip
314
315 gunzip < quagga-0.99.99.99.tar.gz > quagga-0.99.99.99.tar
316 xz -6e < quagga-0.99.99.99.tar > quagga-0.99.99.99.tar.xz
317 gpg -u 54CD2E60 -a --detach-sign quagga-0.99.99.99.tar
318
319 scp quagga-0.99.99.99.* username@dl.sv.nongnu.org:/releases/quagga
Paul Jakmafa482832012-03-08 13:51:21 +0000320 \end{verbatim}
David Lamparterec62e142015-03-07 08:40:56 +0100321
322 Do NOT do this in a subdirectory of the Quagga sources, autoconf will think
323 it's a sub-package and fail to include neccessary files.
324
325\item Add the version number on https://bugzilla.quagga.net/, under
326 Administration, Products, "Quagga", Edit versions, Add a version.
327\item Edit the wiki on https://wiki.quagga.net/wiki/index.php/Release\_status
328\item Post a news entry on Savannah
329\item Send a mail to quagga-dev and quagga-users
Paul Jakmafa482832012-03-08 13:51:21 +0000330\end{itemize}
331
332The tarball which `make dist' creates is the tarball to be released! The
333git-archive step ensures you're working with code corresponding to that in
334the official repository, and also carries out keyword expansion. If any
335errors occur, move tags as needed and start over from the fresh checkouts.
336Do not append to tarballs, as this has produced non-standards-conforming
337tarballs in the past.
338
339See also: \url{http://wiki.quagga.net/index.php/Main/Processes}
340
341[TODO: collation of a list of deprecated commands. Possibly can be scripted
342to extract from vtysh/vtysh\_cmd.c]
343
344
345\section{TOOL VERSIONS}
346
347Require versions of support tools are listed in INSTALL.quagga.txt.
348Required versions should only be done with due deliberation, as it can
349cause environments to no longer be able to compile quagga.
350
351
352\section{SHARED LIBRARY VERSIONING}
353\label{sec:dll-versioning}
354
355[this section is at the moment just gdt's opinion]
356
357Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
358ospfclient/libsopfapiclient). These may be used by external programs,
359e.g. a new routing protocol that works with the zebra daemon, or
360ospfapi clients. The libtool info pages (node Versioning) explain
361when major and minor version numbers should be changed. These values
362are set in Makefile.am near the definition of the library. If you
363make a change that requires changing the shared library version,
364please update Makefile.am.
365
366libospf exports far more than it should, and is needed by ospfapi
367clients. Only bump libospf for changes to functions for which it is
368reasonable for a user of ospfapi to call, and please err on the side
369of not bumping.
370
371There is no support intended for installing part of zebra. The core
372library libzebra and the included daemons should always be built and
373installed together.
374
375
376\section{GIT COMMIT SUBMISSION}
377\label{sec:git-submission}
378
379The preferred method for submitting changes is to provide git commits via a
Paul Jakmaf0996122014-10-27 15:09:38 +0000380publicly-accessible git repository, which the maintainers can easily pull.
Paul Jakmafa482832012-03-08 13:51:21 +0000381
382The commits should be in a branch based off the Quagga.net master - a
383"feature branch". Ideally there should be no commits to this branch other
384than those in master, and those intended to be submitted. However, merge
385commits to this branch from the Quagga master are permitted, though strongly
386discouraged - use another (potentially local and throw-away) branch to test
387merge with the latest Quagga master.
388
389Recommended practice is to keep different logical sets of changes on
390separate branches - "topic" or "feature" branches. This allows you to still
391merge them together to one branch (potentially local and/or "throw-away")
392for testing or use, while retaining smaller, independent branches that are
393easier to merge.
394
395All content guidelines in section \ref{sec:patch-submission}, PATCH
396SUBMISSION apply.
397
398
399\section{PATCH SUBMISSION}
400\label{sec:patch-submission}
401
402\begin{itemize}
403
404\item For complex changes, contributors are strongly encouraged to first
405 start a design discussion on the quagga-dev list \emph{before}
406 starting any coding.
407
408\item Send a clean diff against the 'master' branch of the quagga.git
409 repository, in unified diff format, preferably with the '-p' argument to
410 show C function affected by any chunk, and with the -w and -b arguments to
411 minimise changes. E.g:
412
413 git diff -up mybranch..remotes/quagga.net/master
414
415 It is preferable to use git format-patch, and even more preferred to
416 publish a git repository (see GIT COMMIT SUBMISSION, section
417 \ref{sec:git-submission}).
418
419 If not using git format-patch, Include the commit message in the email.
420
421\item After a commit, code should have comments explaining to the reviewer
422 why it is correct, without reference to history. The commit message
423 should explain why the change is correct.
424
425\item Include NEWS entries as appropriate.
426
427\item Include only one semantic change or group of changes per patch.
428
429\item Do not make gratuitous changes to whitespace. See the w and b arguments
430 to diff.
431
Paul Jakmaf0996122014-10-27 15:09:38 +0000432\item Changes should be arranged so that the least controversial and most
433 trivial are first, and the most complex or more controversial are
Paul Jakmafa482832012-03-08 13:51:21 +0000434 last. This will maximise how many the Quagga maintainers can merge,
435 even if some other commits need further work.
436
437\item Providing a unit-test is strongly encouraged. Doing so will make it
438 much easier for maintainers to have confidence that they will be able
439 to support your change.
440
441\item New code should be arranged so that it easy to verify and test. E.g.
442 stateful logic should be separated out from functional logic as much as
443 possible: wherever possible, move complex logic out to smaller helper
444 functions which access no state other than their arguments.
445
446\item State on which platforms and with what daemons the patch has been
447 tested. Understand that if the set of testing locations is small,
448 and the patch might have unforeseen or hard to fix consequences that
449 there may be a call for testers on quagga-dev, and that the patch
450 may be blocked until test results appear.
451
452 If there are no users for a platform on quagga-dev who are able and
453 willing to verify -current occasionally, that platform may be
454 dropped from the "should be checked" list.
455
456\end{itemize}
457
458\section{PATCH APPLICATION}
459
460\begin{itemize}
461
462\item Only apply patches that meet the submission guidelines.
463
464\item If the patch might break something, issue a call for testing on the
Paul Jakmaf0996122014-10-27 15:09:38 +0000465 mailing-list.
Paul Jakmafa482832012-03-08 13:51:21 +0000466
467\item Give an appropriate commit message (see above), and use the --author
468 argument to git-commit, if required, to ensure proper attribution (you
469 should still be listed as committer)
470
471\item Immediately after commiting, double-check (with git-log and/or gitk).
472 If there's a small mistake you can easily fix it with `git commit
473 --amend ..'
474
475\item When merging a branch, always use an explicit merge commit. Giving
476 --no-ff ensures a merge commit is created which documents ``this human
477 decided to merge this branch at this time''.
478\end{itemize}
479
480\section{STABLE PLATFORMS AND DAEMONS}
481
482The list of platforms that should be tested follow. This is a list
483derived from what quagga is thought to run on and for which
484maintainers can test or there are people on quagga-dev who are able
485and willing to verify that -current does or does not work correctly.
486
487\begin{itemize}
488 \item BSD (Free, Net or Open, any platform)
489 \item GNU/Linux (any distribution, i386)
490 \item Solaris (strict alignment, any platform)
491 \item future: NetBSD/sparc64
492\end{itemize}
493
494The list of daemons that are thought to be stable and that should be
495tested are:
496
497\begin{itemize}
498 \item zebra
499 \item bgpd
500 \item ripd
501 \item ospfd
502 \item ripngd
503\end{itemize}
504Daemons which are in a testing phase are
505
506\begin{itemize}
507 \item ospf6d
508 \item isisd
509 \item watchquagga
510\end{itemize}
511
512\section{IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS}
513
514The source code of Quagga is based on two vendors:
515
516 \verb|zebra_org| (\url{http://www.zebra.org/})
517 \verb|isisd_sf| (\url{http://isisd.sf.net/})
518
519To import code from further sources, e.g. for archival purposes without
520necessarily having to review and/or fix some changeset, create a branch from
521`master':
522
523\begin{verbatim}
524 git checkout -b archive/foo master
525 <apply changes>
526 git commit -a "Joe Bar <joe@example.com>"
527 git push quagga archive/foo
528\end{verbatim}
529
530presuming `quagga' corresponds to a file in your .git/remotes with
531configuration for the appropriate Quagga.net repository.
532
533\end{document}