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