blob: b90c76afea128301ef0072f719a783df57fc9160 [file] [log] [blame]
gdtd9fd04c2003-12-19 19:20:25 +00001-*- mode: text; -*-
Paul Jakmad6bb5aa2008-08-26 22:15:03 +01002$QuaggaId: Format:%an, %ai, %h$ $
3
4Contents:
5
6* GUIDELINES FOR HACKING ON QUAGGA
7* COMPILE-TIME CONDITIONAL CODE
8* COMMIT MESSAGE
9* HACKING THE BUILD SYSTEM
10* RELEASE PROCEDURE
Paul Jakmad6bb5aa2008-08-26 22:15:03 +010011* TOOL VERSIONS
12* SHARED LIBRARY VERSIONING
Paul Jakma724b3ae2012-03-07 11:02:05 +000013* GIT COMMIT SUBSMISSION
Paul Jakmad6bb5aa2008-08-26 22:15:03 +010014* PATCH SUBMISSION
15* PATCH APPLICATION
16* STABLE PLATFORMS AND DAEMONS
17* IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
gdtd9fd04c2003-12-19 19:20:25 +000018
Greg Troxela8e474a2010-11-03 07:22:00 -040019
gdtd9fd04c2003-12-19 19:20:25 +000020GUIDELINES FOR HACKING ON QUAGGA
21
gdtd9fd04c2003-12-19 19:20:25 +000022[this is a draft in progress]
23
hasso863076d2004-09-01 20:13:23 +000024GNU coding standards apply. Indentation follows the result of
25invoking GNU indent (as of 2.2.8a) with no arguments. Note that this
26uses tabs instead of spaces where possible for leading whitespace, and
27assumes that tabs are every 8 columns. Do not attempt to redefine the
28location of tab stops. Note also that some indentation does not
29follow GNU style. This is a historical accident, and we generally
30only clean up whitespace when code is unmaintainable due to whitespace
Paul Jakma724b3ae2012-03-07 11:02:05 +000031issues, to minimise merging conflicts.
hasso863076d2004-09-01 20:13:23 +000032
33For GNU emacs, use indentation style "gnu".
34
35For Vim, use the following lines (note that tabs are at 8, and that
36softtabstop sets the indentation level):
37
38set tabstop=8
39set softtabstop=2
40set shiftwidth=2
41set noexpandtab
gdtd9fd04c2003-12-19 19:20:25 +000042
gdt2934f282004-01-05 20:09:00 +000043Be particularly careful not to break platforms/protocols that you
44cannot test.
45
Paul Jakma724b3ae2012-03-07 11:02:05 +000046New code should have good comments, which explain why the code is correct.
47Changes to existing code should in many cases upgrade the comments when
48necessary for a reviewer to conclude that the change has no unintended
49consequences.
gdt2934f282004-01-05 20:09:00 +000050
Paul Jakmad6bb5aa2008-08-26 22:15:03 +010051Each file in the Git repository should have a git format-placeholder (like
52an RCS Id keyword), somewhere very near the top, commented out appropriately
53for the file type. The placeholder used for Quagga (replacing <dollar> with
54$) is:
55
56 $QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $
57
58See line 2 of HACKING for an example;
59
60This placeholder string will be expanded out by the 'git archive' commands,
61wihch is used to generate the tar archives for snapshots and releases.
gdt697877e2004-11-15 19:23:47 +000062
ajs5e764772004-12-03 19:03:33 +000063Please document fully the proper use of a new function in the header file
64in which it is declared. And please consult existing headers for
65documentation on how to use existing functions. In particular, please consult
66these header files:
67
68 lib/log.h logging levels and usage guidance
69 [more to be added]
70
paul1eb8ef22005-04-07 07:30:20 +000071If changing an exported interface, please try to deprecate the interface in
72an orderly manner. If at all possible, try to retain the old deprecated
73interface as is, or functionally equivalent. Make a note of when the
74interface was deprecated and guard the deprecated interface definitions in
75the header file, ie:
76
77/* Deprecated: 20050406 */
78#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
79#warning "Using deprecated <libname> (interface(s)|function(s))"
80...
81#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
82
83To ensure that the core Quagga sources do not use the deprecated interfaces
84(you should update Quagga sources to use new interfaces, if applicable)
85while allowing external sources to continue to build. Deprecated interfaces
86should be excised in the next unstable cycle.
87
paul74a2dd72005-04-25 00:37:03 +000088Note: If you wish, you can test for GCC and use a function
89marked with the 'deprecated' attribute. However, you must provide the
90#warning for other compilers.
91
paul1eb8ef22005-04-07 07:30:20 +000092If changing or removing a command definition, *ensure* that you properly
93deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
94is *critical*. Even if the command can no longer function, you *must* still
95implement it as a do-nothing stub. Failure to follow this causes grief for
96systems administrators. Deprecated commands should be excised in the next
97unstable cycle. A list of deprecated commands should be collated for each
98release.
99
100See also below regarding SHARED LIBRARY VERSIONING.
ajs5e764772004-12-03 19:03:33 +0000101
Greg Troxela8e474a2010-11-03 07:22:00 -0400102
Paul Jakma750e8142008-07-22 21:11:48 +0000103COMPILE-TIME CONDITIONAL CODE
104
105Please think very carefully before making code conditional at compile time,
106as it increases maintenance burdens and user confusion. In particular,
107please avoid gratuitious --enable-.... switches to the configure script -
108typically code should be good enough to be in Quagga, or it shouldn't be
109there at all.
110
111When code must be compile-time conditional, try have the compiler make it
Paul Jakma724b3ae2012-03-07 11:02:05 +0000112conditional rather than the C pre-processor - so that it will still be
113checked by the compiler, even if disabled. I.e. this:
Paul Jakma750e8142008-07-22 21:11:48 +0000114
115 if (SOME_SYMBOL)
116 frobnicate();
117
118rather than:
119
120 #ifdef SOME_SYMBOL
121 frobnicate ();
122 #endif /* SOME_SYMBOL */
123
124Note that the former approach requires ensuring that SOME_SYMBOL will be
125defined (watch your AC_DEFINEs).
paul74a2dd72005-04-25 00:37:03 +0000126
Greg Troxela8e474a2010-11-03 07:22:00 -0400127
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100128COMMIT MESSAGES
gdt2934f282004-01-05 20:09:00 +0000129
Paul Jakma724b3ae2012-03-07 11:02:05 +0000130The commit message MUST provide:
gdt2934f282004-01-05 20:09:00 +0000131
Greg Troxeld7a97792010-11-03 07:20:38 -0400132* A suitable one-line summary followed by a blank line as the very
133 first line of the message, in the form:
gdt2934f282004-01-05 20:09:00 +0000134
Paul Jakma3de42772009-07-28 16:04:35 +0100135 topic: high-level, one line summary
paulca6383b2005-11-10 10:21:19 +0000136
Paul Jakma3de42772009-07-28 16:04:35 +0100137 Where topic would tend to be name of a subdirectory, and/or daemon, unless
138 there's a more suitable topic (e.g. 'build'). This topic is used to
139 organise change summaries in release announcements.
paulca6383b2005-11-10 10:21:19 +0000140
Paul Jakma724b3ae2012-03-07 11:02:05 +0000141The remainder of the commit message - its "body" - should ideally try to
142address the following areas, so as to help reviewers and future browsers of
143the code-base understand why the change is correct (note also the code
144comment requirements):
paulca6383b2005-11-10 10:21:19 +0000145
Paul Jakma724b3ae2012-03-07 11:02:05 +0000146* The motivation for the change (does it fix a bug, if so which?
147 add a feature?)
148* The general approach taken, and trade-offs versus any other approaches.
149* Any testing undertaken or other information affecting the confidence
150 that can be had in the change.
151* Information to allow reviewers to be able to tell which specific changes
152 to the code are intended (and hence be able to spot any accidental
153 unintended changes).
Paul Jakma3de42772009-07-28 16:04:35 +0100154
Greg Troxeld7a97792010-11-03 07:20:38 -0400155The one-line summary must be limited to 54 characters, and all other
156lines to 72 characters.
paulca6383b2005-11-10 10:21:19 +0000157
Paul Jakma724b3ae2012-03-07 11:02:05 +0000158Commit message bodies in the Quagga project have typically taken the
159following form:
Paul Jakma3de42772009-07-28 16:04:35 +0100160
Paul Jakma724b3ae2012-03-07 11:02:05 +0000161* An optional introduction, describing the change generally.
162* A short description of each specific change made, preferably:
163 * file by file
164 * function by function (use of "ditto", or globs is allowed)
165
166Contributors are strongly encouraged to follow this form.
167
168This itemised commit messages allows reviewers to have confidence that the
169author has self-reviewed every line of the patch, as well as providing
170reviewers a clear index of which changes are intended, and descriptions for
171them (C-to-english descriptions are not desireable - some discretion is
172useful). For short patches, a per-function/file break-down may be
173redundant. For longer patches, such a break-down may be essential. A
174contrived example (where the general discussion is obviously somewhat
175redundant, given the one-line summary):
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100176
Paul Jakma3de42772009-07-28 16:04:35 +0100177zebra: Enhance frob FSM to detect loss of frob
paulca6383b2005-11-10 10:21:19 +0000178
Paul Jakma724b3ae2012-03-07 11:02:05 +0000179Add a new DOWN state to the frob state machine to allow the barinator to
180detect loss of frob.
181
Paul Jakma3de42772009-07-28 16:04:35 +0100182* frob.h: (struct frob) Add DOWN state flag.
183* frob.c: (frob_change) set/clear DOWN appropriately on state change.
184* bar.c: (barinate) Check frob for DOWN state.
paul1f8f61a2004-11-05 23:38:20 +0000185
Paul Jakma724b3ae2012-03-07 11:02:05 +0000186Please have a look at the git commit logs to get a feel for what the norms
187are.
188
Greg Troxeld7a97792010-11-03 07:20:38 -0400189Note that the commit message format follows git norms, so that "git
190log --oneline" will have useful output.
paul74a2dd72005-04-25 00:37:03 +0000191
192HACKING THE BUILD SYSTEM
193
194If you change or add to the build system (configure.ac, any Makefile.am,
195etc.), try to check that the following things still work:
196
197 - make dist
198 - resulting dist tarball builds
Greg Troxela8e474a2010-11-03 07:22:00 -0400199 - out-of-tree builds
paul74a2dd72005-04-25 00:37:03 +0000200
201The quagga.net site relies on make dist to work to generate snapshots. It
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100202must work. Common problems are to forget to have some additional file
paul74a2dd72005-04-25 00:37:03 +0000203included in the dist, or to have a make rule refer to a source file without
204using the srcdir variable.
205
Greg Troxela8e474a2010-11-03 07:22:00 -0400206
gdt0d7e9132005-02-23 16:20:07 +0000207RELEASE PROCEDURE
208
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100209* Tag the apppropriate commit with a release tag (follow existing
210 conventions).
gdt0d7e9132005-02-23 16:20:07 +0000211 [This enables recreating the release, and is just good CM practice.]
212
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100213* Create a fresh tar archive of the quagga.net repository, and do a test
214 build:
gdt0d7e9132005-02-23 16:20:07 +0000215
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100216 git-clone git:///code.quagga.net/quagga.git quagga
217 git-archive --remote=git://code.quagga.net/quagga.git \
218 --prefix=quagga-release/ master | tar -xf -
219 cd quagga-release
gdt0d7e9132005-02-23 16:20:07 +0000220
Paul Jakma3de42772009-07-28 16:04:35 +0100221 autoreconf -i
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100222 ./configure
223 make
224 make dist
gdt0d7e9132005-02-23 16:20:07 +0000225
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100226The tarball which 'make dist' creates is the tarball to be released! The
227git-archive step ensures you're working with code corresponding to that in
228the official repository, and also carries out keyword expansion. If any
Greg Troxela8e474a2010-11-03 07:22:00 -0400229errors occur, move tags as needed and start over from the fresh checkouts.
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100230Do not append to tarballs, as this has produced non-standards-conforming
231tarballs in the past.
gdt0d7e9132005-02-23 16:20:07 +0000232
Paul Jakma3de42772009-07-28 16:04:35 +0100233See also: http://wiki.quagga.net/index.php/Main/Processes
234
paul1eb8ef22005-04-07 07:30:20 +0000235[TODO: collation of a list of deprecated commands. Possibly can be scripted
236to extract from vtysh/vtysh_cmd.c]
237
paul74a2dd72005-04-25 00:37:03 +0000238
gdtfbb67092004-11-15 17:29:11 +0000239TOOL VERSIONS
240
241Require versions of support tools are listed in INSTALL.quagga.txt.
242Required versions should only be done with due deliberation, as it can
243cause environments to no longer be able to compile quagga.
244
paul74a2dd72005-04-25 00:37:03 +0000245
gdtb7a97f82004-07-23 16:23:56 +0000246SHARED LIBRARY VERSIONING
247
248[this section is at the moment just gdt's opinion]
249
250Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
251ospfclient/libsopfapiclient). These may be used by external programs,
252e.g. a new routing protocol that works with the zebra daemon, or
253ospfapi clients. The libtool info pages (node Versioning) explain
254when major and minor version numbers should be changed. These values
255are set in Makefile.am near the definition of the library. If you
256make a change that requires changing the shared library version,
257please update Makefile.am.
258
259libospf exports far more than it should, and is needed by ospfapi
260clients. Only bump libospf for changes to functions for which it is
261reasonable for a user of ospfapi to call, and please err on the side
262of not bumping.
263
264There is no support intended for installing part of zebra. The core
265library libzebra and the included daemons should always be built and
266installed together.
267
paul74a2dd72005-04-25 00:37:03 +0000268
Greg Troxel5195e172010-11-03 07:37:23 -0400269GIT COMMIT SUBSMISSION
270
Paul Jakma724b3ae2012-03-07 11:02:05 +0000271The preferred method for submitting changes is to provide git commits via a
272publically-accessible git repository, which the maintainers can easily pull.
273
274The 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
276than those in master, and those intended to be submitted. However, merge
277commits to this branch from the Quagga master are permitted, though strongly
278discouraged - use another (potentially local and throw-away) branch to test
279merge with the latest Quagga master.
280
281Recommended practice is to keep different logical sets of changes on
282separate branches - "topic" or "feature" branches. This allows you to still
283merge them together to one branch (potentially local and/or "throw-away")
284for testing or use, while retaining smaller, independent branches that are
285easier to merge.
Greg Troxel5195e172010-11-03 07:37:23 -0400286
287All content guidelines in PATCH SUBMISSION apply.
288
289
gdtd9fd04c2003-12-19 19:20:25 +0000290PATCH SUBMISSION
291
Paul Jakma724b3ae2012-03-07 11:02:05 +0000292* For complex changes, contributors are strongly encouraged to first start a
293 design discussion on the quagga-dev list before starting any coding.
294
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100295* Send a clean diff against the 'master' branch of the quagga.git
Greg Troxela8e474a2010-11-03 07:22:00 -0400296 repository, in unified diff format, preferably with the '-p' argument to
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100297 show C function affected by any chunk, and with the -w and -b arguments to
Greg Troxela8e474a2010-11-03 07:22:00 -0400298 minimise changes. E.g:
gdtd9fd04c2003-12-19 19:20:25 +0000299
Paul Jakma3de42772009-07-28 16:04:35 +0100300 git diff -up mybranch..remotes/quagga.net/master
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100301
Greg Troxel5195e172010-11-03 07:37:23 -0400302 It is preferable to use git format-patch, and even more preferred to
Paul Jakma724b3ae2012-03-07 11:02:05 +0000303 publish a git repostory (see GIT COMMIT SUBSMISSION).
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100304
Greg Troxel5195e172010-11-03 07:37:23 -0400305 If not using git format-patch, Include the commit message in the email.
306
307* After a commit, code should have comments explaining to the reviewer
308 why it is correct, without reference to history. The commit message
309 should explain why the change is correct.
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100310
Greg Troxela8e474a2010-11-03 07:22:00 -0400311* Include NEWS entries as appropriate.
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100312
gdt18323bb2004-11-05 13:17:20 +0000313* Include only one semantic change or group of changes per patch.
gdtd9fd04c2003-12-19 19:20:25 +0000314
paul85cf0a02004-01-09 16:34:54 +0000315* Do not make gratuitous changes to whitespace. See the w and b arguments
316 to diff.
gdtd9fd04c2003-12-19 19:20:25 +0000317
Paul Jakma724b3ae2012-03-07 11:02:05 +0000318* Changes should be arranged so that the least contraversial and most
319 trivial are first, and the most complex or more contraversial are last.
320 This will maximise how many the Quagga maintainers can merge, even if some
321 other commits need further work.
322
323* Providing a unit-test is strongly encouraged. Doing so will make it
324 much easier for maintainers to have confidence that they will be able
325 to support your change.
326
327* New code should be arranged so that it easy to verify and test. E.g.
328 stateful logic should be separated out from functional logic as much as
329 possible: wherever possible, move complex logic out to smaller helper
330 functions which access no state other than their arguments.
331
gdtd9fd04c2003-12-19 19:20:25 +0000332* State on which platforms and with what daemons the patch has been
333 tested. Understand that if the set of testing locations is small,
334 and the patch might have unforeseen or hard to fix consequences that
335 there may be a call for testers on quagga-dev, and that the patch
336 may be blocked until test results appear.
337
338 If there are no users for a platform on quagga-dev who are able and
339 willing to verify -current occasionally, that platform may be
340 dropped from the "should be checked" list.
341
paul74a2dd72005-04-25 00:37:03 +0000342
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100343PATCH APPLICATION
gdtd9fd04c2003-12-19 19:20:25 +0000344
345* Only apply patches that meet the submission guidelines.
346
gdtd9fd04c2003-12-19 19:20:25 +0000347* If the patch might break something, issue a call for testing on the
348 mailinglist.
349
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100350* Give an appropriate commit message (see above), and use the --author
351 argument to git-commit, if required, to ensure proper attribution (you
352 should still be listed as committer)
353
354* Immediately after commiting, double-check (with git-log and/or gitk). If
355 there's a small mistake you can easily fix it with 'git commit --amend ..'
paul4134ceb2004-05-13 13:38:06 +0000356
Paul Jakma724b3ae2012-03-07 11:02:05 +0000357* When merging a branch, always use an explicit merge commit. Giving --no-ff
358 ensures a merge commit is created which documents "this human decided to
359 merge this branch at this time".
paul74a2dd72005-04-25 00:37:03 +0000360
gdtd9fd04c2003-12-19 19:20:25 +0000361STABLE PLATFORMS AND DAEMONS
362
363The list of platforms that should be tested follow. This is a list
364derived from what quagga is thought to run on and for which
365maintainers can test or there are people on quagga-dev who are able
366and willing to verify that -current does or does not work correctly.
367
368 BSD (Free, Net or Open, any platform) # without capabilities
369 GNU/Linux (any distribution, i386)
paul1f8f61a2004-11-05 23:38:20 +0000370 Solaris (strict alignment, any platform)
gdt18323bb2004-11-05 13:17:20 +0000371 [future: NetBSD/sparc64]
gdtd9fd04c2003-12-19 19:20:25 +0000372
373The list of daemons that are thought to be stable and that should be
374tested are:
375
376 zebra
377 bgpd
378 ripd
379 ospfd
380 ripngd
gdt1f431d22003-12-22 15:45:01 +0000381
gdt18323bb2004-11-05 13:17:20 +0000382Daemons which are in a testing phase are
383
384 ospf6d
385 isisd
ajs8035e9f2004-12-22 03:16:59 +0000386 watchquagga
gdt18323bb2004-11-05 13:17:20 +0000387
paul74a2dd72005-04-25 00:37:03 +0000388
jardin9e867fe2003-12-23 08:56:18 +0000389IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
390
391The source code of Quagga is based on two vendors:
392
393 zebra_org (http://www.zebra.org/)
394 isisd_sf (http://isisd.sf.net/)
395
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100396To import code from further sources, e.g. for archival purposes without
397necessarily having to review and/or fix some changeset, create a branch from
398'master':
gdt18323bb2004-11-05 13:17:20 +0000399
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100400 git checkout -b archive/foo master
401 <apply changes>
402 git commit -a "Joe Bar <joe@example.com>"
403 git push quagga archive/foo
jardin9e867fe2003-12-23 08:56:18 +0000404
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100405presuming 'quagga' corresponds to a file in your .git/remotes with
406configuration for the appropriate Quagga.net repository.