2 $QuaggaId: Format:%an, %ai, %h$ $
6 * GUIDELINES FOR HACKING ON QUAGGA
7 * COMPILE-TIME CONDITIONAL CODE
9 * HACKING THE BUILD SYSTEM
11 * SHARED LIBRARY VERSIONING
14 * SHARED LIBRARY VERSIONING
17 * STABLE PLATFORMS AND DAEMONS
18 * IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
20 GUIDELINES FOR HACKING ON QUAGGA
22 [this is a draft in progress]
24 GNU coding standards apply. Indentation follows the result of
25 invoking GNU indent (as of 2.2.8a) with no arguments. Note that this
26 uses tabs instead of spaces where possible for leading whitespace, and
27 assumes that tabs are every 8 columns. Do not attempt to redefine the
28 location of tab stops. Note also that some indentation does not
29 follow GNU style. This is a historical accident, and we generally
30 only clean up whitespace when code is unmaintainable due to whitespace
31 issues, as fewer changes from zebra lead to easier merges.
33 For GNU emacs, use indentation style "gnu".
35 For Vim, use the following lines (note that tabs are at 8, and that
36 softtabstop sets the indentation level):
43 Be particularly careful not to break platforms/protocols that you
46 New code should have good comments, and changes to existing code
47 should in many cases upgrade the comments when necessary for a
48 reviewer to conclude that the change has no unintended consequences.
50 Each file in the Git repository should have a git format-placeholder (like
51 an RCS Id keyword), somewhere very near the top, commented out appropriately
52 for the file type. The placeholder used for Quagga (replacing <dollar> with
55 $QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $
57 See line 2 of HACKING for an example;
59 This placeholder string will be expanded out by the 'git archive' commands,
60 wihch is used to generate the tar archives for snapshots and releases.
62 Please document fully the proper use of a new function in the header file
63 in which it is declared. And please consult existing headers for
64 documentation on how to use existing functions. In particular, please consult
67 lib/log.h logging levels and usage guidance
70 If changing an exported interface, please try to deprecate the interface in
71 an orderly manner. If at all possible, try to retain the old deprecated
72 interface as is, or functionally equivalent. Make a note of when the
73 interface was deprecated and guard the deprecated interface definitions in
76 /* Deprecated: 20050406 */
77 #if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
78 #warning "Using deprecated <libname> (interface(s)|function(s))"
80 #endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
82 To ensure that the core Quagga sources do not use the deprecated interfaces
83 (you should update Quagga sources to use new interfaces, if applicable)
84 while allowing external sources to continue to build. Deprecated interfaces
85 should be excised in the next unstable cycle.
87 Note: If you wish, you can test for GCC and use a function
88 marked with the 'deprecated' attribute. However, you must provide the
89 #warning for other compilers.
91 If changing or removing a command definition, *ensure* that you properly
92 deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
93 is *critical*. Even if the command can no longer function, you *must* still
94 implement it as a do-nothing stub. Failure to follow this causes grief for
95 systems administrators. Deprecated commands should be excised in the next
96 unstable cycle. A list of deprecated commands should be collated for each
99 See also below regarding SHARED LIBRARY VERSIONING.
101 COMPILE-TIME CONDITIONAL CODE
103 Please think very carefully before making code conditional at compile time,
104 as it increases maintenance burdens and user confusion. In particular,
105 please avoid gratuitious --enable-.... switches to the configure script -
106 typically code should be good enough to be in Quagga, or it shouldn't be
109 When code must be compile-time conditional, try have the compiler make it
110 conditional rather than the C pre-processor. I.e. this:
119 #endif /* SOME_SYMBOL */
121 Note that the former approach requires ensuring that SOME_SYMBOL will be
122 defined (watch your AC_DEFINEs).
126 The commit message should provide:
128 * A suitable one-line summary as the very first line of the message, in the
131 topic: high-level, one line summary
133 Where topic would tend to be name of a subdirectory, and/or daemon, unless
134 there's a more suitable topic (e.g. 'build'). This topic is used to
135 organise change summaries in release announcements.
137 * An optional introduction, discussing the general intent of the change.
138 * A short description of each change made, preferably:
140 * function by function (use of "ditto", or globs is allowed)
142 to provide a short description of the general intent of the patch, in terms
143 of the problem it solves and how it achieves it, to help reviewers
147 The reason for such itemised commit messages is to encourage the author to
148 self-review every line of the patch, as well as provide reviewers an index
149 of which changes are intended, along with a short description for each.
150 Some discretion is obviously required. A C-to-english description is not
151 desireable. For short patches, a per-function/file break-down may be
152 redundant. For longer patches, such a break-down may be essential.
154 An example (where the general discussion is obviously somewhat redundant,
155 given the one-line summary):
157 zebra: Enhance frob FSM to detect loss of frob
159 * (general) Add a new DOWN state to the frob state machine
160 to allow the barinator to detect loss of frob.
161 * frob.h: (struct frob) Add DOWN state flag.
162 * frob.c: (frob_change) set/clear DOWN appropriately on state change.
163 * bar.c: (barinate) Check frob for DOWN state.
166 HACKING THE BUILD SYSTEM
168 If you change or add to the build system (configure.ac, any Makefile.am,
169 etc.), try to check that the following things still work:
172 - resulting dist tarball builds
175 The quagga.net site relies on make dist to work to generate snapshots. It
176 must work. Common problems are to forget to have some additional file
177 included in the dist, or to have a make rule refer to a source file without
178 using the srcdir variable.
182 * Tag the apppropriate commit with a release tag (follow existing
184 [This enables recreating the release, and is just good CM practice.]
186 * Create a fresh tar archive of the quagga.net repository, and do a test
189 git-clone git:///code.quagga.net/quagga.git quagga
190 git-archive --remote=git://code.quagga.net/quagga.git \
191 --prefix=quagga-release/ master | tar -xf -
199 The tarball which 'make dist' creates is the tarball to be released! The
200 git-archive step ensures you're working with code corresponding to that in
201 the official repository, and also carries out keyword expansion. If any
202 errors occur, move tags as needed and start over from the fresh checkouts.
203 Do not append to tarballs, as this has produced non-standards-conforming
204 tarballs in the past.
206 See also: http://wiki.quagga.net/index.php/Main/Processes
208 [TODO: collation of a list of deprecated commands. Possibly can be scripted
209 to extract from vtysh/vtysh_cmd.c]
214 Require versions of support tools are listed in INSTALL.quagga.txt.
215 Required versions should only be done with due deliberation, as it can
216 cause environments to no longer be able to compile quagga.
219 SHARED LIBRARY VERSIONING
221 [this section is at the moment just gdt's opinion]
223 Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
224 ospfclient/libsopfapiclient). These may be used by external programs,
225 e.g. a new routing protocol that works with the zebra daemon, or
226 ospfapi clients. The libtool info pages (node Versioning) explain
227 when major and minor version numbers should be changed. These values
228 are set in Makefile.am near the definition of the library. If you
229 make a change that requires changing the shared library version,
230 please update Makefile.am.
232 libospf exports far more than it should, and is needed by ospfapi
233 clients. Only bump libospf for changes to functions for which it is
234 reasonable for a user of ospfapi to call, and please err on the side
237 There is no support intended for installing part of zebra. The core
238 library libzebra and the included daemons should always be built and
244 * Send a clean diff against the 'master' branch of the quagga.git
245 repository, in unified diff format, preferably with the '-p' argument to
246 show C function affected by any chunk, and with the -w and -b arguments to
247 minimise changes. E.g:
249 git diff -up mybranch..remotes/quagga.net/master
251 Or by using git-format-patch.
253 * Not doing so is a definite hindrance to patch application.
255 * Include NEWS entries as appropriate.
257 * Please, please include an appropriate commit message with any emailed
258 patches. Doing so makes it easier to review a patch, and apply it.
260 * Include only one semantic change or group of changes per patch.
262 * Do not make gratuitous changes to whitespace. See the w and b arguments
265 * State on which platforms and with what daemons the patch has been
266 tested. Understand that if the set of testing locations is small,
267 and the patch might have unforeseen or hard to fix consequences that
268 there may be a call for testers on quagga-dev, and that the patch
269 may be blocked until test results appear.
271 If there are no users for a platform on quagga-dev who are able and
272 willing to verify -current occasionally, that platform may be
273 dropped from the "should be checked" list.
278 * Only apply patches that meet the submission guidelines.
280 * If the patch might break something, issue a call for testing on the
283 * Give an appropriate commit message (see above), and use the --author
284 argument to git-commit, if required, to ensure proper attribution (you
285 should still be listed as committer)
287 * Immediately after commiting, double-check (with git-log and/or gitk). If
288 there's a small mistake you can easily fix it with 'git commit --amend ..'
290 * By committing a patch, you are responsible for fixing problems
291 resulting from it (or backing it out).
294 STABLE PLATFORMS AND DAEMONS
296 The list of platforms that should be tested follow. This is a list
297 derived from what quagga is thought to run on and for which
298 maintainers can test or there are people on quagga-dev who are able
299 and willing to verify that -current does or does not work correctly.
301 BSD (Free, Net or Open, any platform) # without capabilities
302 GNU/Linux (any distribution, i386)
303 Solaris (strict alignment, any platform)
304 [future: NetBSD/sparc64]
306 The list of daemons that are thought to be stable and that should be
315 Daemons which are in a testing phase are
322 IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
324 The source code of Quagga is based on two vendors:
326 zebra_org (http://www.zebra.org/)
327 isisd_sf (http://isisd.sf.net/)
329 To import code from further sources, e.g. for archival purposes without
330 necessarily having to review and/or fix some changeset, create a branch from
333 git checkout -b archive/foo master
335 git commit -a "Joe Bar <joe@example.com>"
336 git push quagga archive/foo
338 presuming 'quagga' corresponds to a file in your .git/remotes with
339 configuration for the appropriate Quagga.net repository.