blob: 54931d121efbeac8f21f310553309681a416a594 [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}
311 git-clone git:///code.quagga.net/quagga.git quagga
312 git-archive --remote=git://code.quagga.net/quagga.git \
313 --prefix=quagga-release/ master | tar -xf -
314 cd quagga-release
315
316 autoreconf -i
317 ./configure
318 make
319 make dist
320 \end{verbatim}
321\end{itemize}
322
323The tarball which `make dist' creates is the tarball to be released! The
324git-archive step ensures you're working with code corresponding to that in
325the official repository, and also carries out keyword expansion. If any
326errors occur, move tags as needed and start over from the fresh checkouts.
327Do not append to tarballs, as this has produced non-standards-conforming
328tarballs in the past.
329
330See also: \url{http://wiki.quagga.net/index.php/Main/Processes}
331
332[TODO: collation of a list of deprecated commands. Possibly can be scripted
333to extract from vtysh/vtysh\_cmd.c]
334
335
336\section{TOOL VERSIONS}
337
338Require versions of support tools are listed in INSTALL.quagga.txt.
339Required versions should only be done with due deliberation, as it can
340cause environments to no longer be able to compile quagga.
341
342
343\section{SHARED LIBRARY VERSIONING}
344\label{sec:dll-versioning}
345
346[this section is at the moment just gdt's opinion]
347
348Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
349ospfclient/libsopfapiclient). These may be used by external programs,
350e.g. a new routing protocol that works with the zebra daemon, or
351ospfapi clients. The libtool info pages (node Versioning) explain
352when major and minor version numbers should be changed. These values
353are set in Makefile.am near the definition of the library. If you
354make a change that requires changing the shared library version,
355please update Makefile.am.
356
357libospf exports far more than it should, and is needed by ospfapi
358clients. Only bump libospf for changes to functions for which it is
359reasonable for a user of ospfapi to call, and please err on the side
360of not bumping.
361
362There is no support intended for installing part of zebra. The core
363library libzebra and the included daemons should always be built and
364installed together.
365
366
367\section{GIT COMMIT SUBMISSION}
368\label{sec:git-submission}
369
370The preferred method for submitting changes is to provide git commits via a
371publically-accessible git repository, which the maintainers can easily pull.
372
373The commits should be in a branch based off the Quagga.net master - a
374"feature branch". Ideally there should be no commits to this branch other
375than those in master, and those intended to be submitted. However, merge
376commits to this branch from the Quagga master are permitted, though strongly
377discouraged - use another (potentially local and throw-away) branch to test
378merge with the latest Quagga master.
379
380Recommended practice is to keep different logical sets of changes on
381separate branches - "topic" or "feature" branches. This allows you to still
382merge them together to one branch (potentially local and/or "throw-away")
383for testing or use, while retaining smaller, independent branches that are
384easier to merge.
385
386All content guidelines in section \ref{sec:patch-submission}, PATCH
387SUBMISSION apply.
388
389
390\section{PATCH SUBMISSION}
391\label{sec:patch-submission}
392
393\begin{itemize}
394
395\item For complex changes, contributors are strongly encouraged to first
396 start a design discussion on the quagga-dev list \emph{before}
397 starting any coding.
398
399\item Send a clean diff against the 'master' branch of the quagga.git
400 repository, in unified diff format, preferably with the '-p' argument to
401 show C function affected by any chunk, and with the -w and -b arguments to
402 minimise changes. E.g:
403
404 git diff -up mybranch..remotes/quagga.net/master
405
406 It is preferable to use git format-patch, and even more preferred to
407 publish a git repository (see GIT COMMIT SUBMISSION, section
408 \ref{sec:git-submission}).
409
410 If not using git format-patch, Include the commit message in the email.
411
412\item After a commit, code should have comments explaining to the reviewer
413 why it is correct, without reference to history. The commit message
414 should explain why the change is correct.
415
416\item Include NEWS entries as appropriate.
417
418\item Include only one semantic change or group of changes per patch.
419
420\item Do not make gratuitous changes to whitespace. See the w and b arguments
421 to diff.
422
423\item Changes should be arranged so that the least contraversial and most
424 trivial are first, and the most complex or more contraversial are
425 last. This will maximise how many the Quagga maintainers can merge,
426 even if some other commits need further work.
427
428\item Providing a unit-test is strongly encouraged. Doing so will make it
429 much easier for maintainers to have confidence that they will be able
430 to support your change.
431
432\item New code should be arranged so that it easy to verify and test. E.g.
433 stateful logic should be separated out from functional logic as much as
434 possible: wherever possible, move complex logic out to smaller helper
435 functions which access no state other than their arguments.
436
437\item State on which platforms and with what daemons the patch has been
438 tested. Understand that if the set of testing locations is small,
439 and the patch might have unforeseen or hard to fix consequences that
440 there may be a call for testers on quagga-dev, and that the patch
441 may be blocked until test results appear.
442
443 If there are no users for a platform on quagga-dev who are able and
444 willing to verify -current occasionally, that platform may be
445 dropped from the "should be checked" list.
446
447\end{itemize}
448
449\section{PATCH APPLICATION}
450
451\begin{itemize}
452
453\item Only apply patches that meet the submission guidelines.
454
455\item If the patch might break something, issue a call for testing on the
456 mailinglist.
457
458\item Give an appropriate commit message (see above), and use the --author
459 argument to git-commit, if required, to ensure proper attribution (you
460 should still be listed as committer)
461
462\item Immediately after commiting, double-check (with git-log and/or gitk).
463 If there's a small mistake you can easily fix it with `git commit
464 --amend ..'
465
466\item When merging a branch, always use an explicit merge commit. Giving
467 --no-ff ensures a merge commit is created which documents ``this human
468 decided to merge this branch at this time''.
469\end{itemize}
470
471\section{STABLE PLATFORMS AND DAEMONS}
472
473The list of platforms that should be tested follow. This is a list
474derived from what quagga is thought to run on and for which
475maintainers can test or there are people on quagga-dev who are able
476and willing to verify that -current does or does not work correctly.
477
478\begin{itemize}
479 \item BSD (Free, Net or Open, any platform)
480 \item GNU/Linux (any distribution, i386)
481 \item Solaris (strict alignment, any platform)
482 \item future: NetBSD/sparc64
483\end{itemize}
484
485The list of daemons that are thought to be stable and that should be
486tested are:
487
488\begin{itemize}
489 \item zebra
490 \item bgpd
491 \item ripd
492 \item ospfd
493 \item ripngd
494\end{itemize}
495Daemons which are in a testing phase are
496
497\begin{itemize}
498 \item ospf6d
499 \item isisd
500 \item watchquagga
501\end{itemize}
502
503\section{IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS}
504
505The source code of Quagga is based on two vendors:
506
507 \verb|zebra_org| (\url{http://www.zebra.org/})
508 \verb|isisd_sf| (\url{http://isisd.sf.net/})
509
510To import code from further sources, e.g. for archival purposes without
511necessarily having to review and/or fix some changeset, create a branch from
512`master':
513
514\begin{verbatim}
515 git checkout -b archive/foo master
516 <apply changes>
517 git commit -a "Joe Bar <joe@example.com>"
518 git push quagga archive/foo
519\end{verbatim}
520
521presuming `quagga' corresponds to a file in your .git/remotes with
522configuration for the appropriate Quagga.net repository.
523
524\end{document}