blob: ca3ad52eb7309ff364835691844ad68476a0b2ff [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
11* SHARED LIBRARY VERSIONING
12* RELEASE PROCEDURE
13* TOOL VERSIONS
14* SHARED LIBRARY VERSIONING
15* PATCH SUBMISSION
16* PATCH APPLICATION
17* STABLE PLATFORMS AND DAEMONS
18* IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
gdtd9fd04c2003-12-19 19:20:25 +000019
20GUIDELINES 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
31issues, as fewer changes from zebra lead to easier merges.
32
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
46New code should have good comments, and changes to existing code
47should in many cases upgrade the comments when necessary for a
48reviewer to conclude that the change has no unintended consequences.
49
Paul Jakmad6bb5aa2008-08-26 22:15:03 +010050Each 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 $QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $
56
57See line 2 of HACKING 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.
gdt697877e2004-11-15 19:23:47 +000061
ajs5e764772004-12-03 19:03:33 +000062Please 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 lib/log.h logging levels and usage guidance
68 [more to be added]
69
paul1eb8ef22005-04-07 07:30:20 +000070If changing an exported interface, please try to deprecate the interface in
71an orderly manner. If at all possible, try to retain the old deprecated
72interface as is, or functionally equivalent. Make a note of when the
73interface was deprecated and guard the deprecated interface definitions in
74the header file, ie:
75
76/* Deprecated: 20050406 */
77#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
78#warning "Using deprecated <libname> (interface(s)|function(s))"
79...
80#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
81
82To ensure that the core Quagga sources do not use the deprecated interfaces
83(you should update Quagga sources to use new interfaces, if applicable)
84while allowing external sources to continue to build. Deprecated interfaces
85should be excised in the next unstable cycle.
86
paul74a2dd72005-04-25 00:37:03 +000087Note: If you wish, you can test for GCC and use a function
88marked with the 'deprecated' attribute. However, you must provide the
89#warning for other compilers.
90
paul1eb8ef22005-04-07 07:30:20 +000091If changing or removing a command definition, *ensure* that you properly
92deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
93is *critical*. Even if the command can no longer function, you *must* still
94implement it as a do-nothing stub. Failure to follow this causes grief for
95systems administrators. Deprecated commands should be excised in the next
96unstable cycle. A list of deprecated commands should be collated for each
97release.
98
99See also below regarding SHARED LIBRARY VERSIONING.
ajs5e764772004-12-03 19:03:33 +0000100
Paul Jakma750e8142008-07-22 21:11:48 +0000101COMPILE-TIME CONDITIONAL CODE
102
103Please think very carefully before making code conditional at compile time,
104as it increases maintenance burdens and user confusion. In particular,
105please avoid gratuitious --enable-.... switches to the configure script -
106typically code should be good enough to be in Quagga, or it shouldn't be
107there at all.
108
109When code must be compile-time conditional, try have the compiler make it
110conditional rather than the C pre-processor. I.e. this:
111
112 if (SOME_SYMBOL)
113 frobnicate();
114
115rather than:
116
117 #ifdef SOME_SYMBOL
118 frobnicate ();
119 #endif /* SOME_SYMBOL */
120
121Note that the former approach requires ensuring that SOME_SYMBOL will be
122defined (watch your AC_DEFINEs).
paul74a2dd72005-04-25 00:37:03 +0000123
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100124COMMIT MESSAGES
gdt2934f282004-01-05 20:09:00 +0000125
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100126The commit message should provide:
gdt2934f282004-01-05 20:09:00 +0000127
Greg Troxeld7a97792010-11-03 07:20:38 -0400128* A suitable one-line summary followed by a blank line as the very
129 first line of the message, in the form:
gdt2934f282004-01-05 20:09:00 +0000130
Paul Jakma3de42772009-07-28 16:04:35 +0100131 topic: high-level, one line summary
paulca6383b2005-11-10 10:21:19 +0000132
Paul Jakma3de42772009-07-28 16:04:35 +0100133 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.
paulca6383b2005-11-10 10:21:19 +0000136
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100137* An optional introduction, discussing the general intent of the change.
Paul Jakma3de42772009-07-28 16:04:35 +0100138* A short description of each change made, preferably:
paulca6383b2005-11-10 10:21:19 +0000139 * file by file
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100140 * function by function (use of "ditto", or globs is allowed)
paulca6383b2005-11-10 10:21:19 +0000141
Paul Jakma3de42772009-07-28 16:04:35 +0100142to provide a short description of the general intent of the patch, in terms
143of the problem it solves and how it achieves it, to help reviewers
144understand.
145
Greg Troxeld7a97792010-11-03 07:20:38 -0400146The one-line summary must be limited to 54 characters, and all other
147lines to 72 characters.
paulca6383b2005-11-10 10:21:19 +0000148
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100149The reason for such itemised commit messages is to encourage the author to
150self-review every line of the patch, as well as provide reviewers an index
Paul Jakma3de42772009-07-28 16:04:35 +0100151of which changes are intended, along with a short description for each.
152Some discretion is obviously required. A C-to-english description is not
153desireable. For short patches, a per-function/file break-down may be
154redundant. For longer patches, such a break-down may be essential.
155
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100156An example (where the general discussion is obviously somewhat redundant,
157given the one-line summary):
158
Paul Jakma3de42772009-07-28 16:04:35 +0100159zebra: Enhance frob FSM to detect loss of frob
paulca6383b2005-11-10 10:21:19 +0000160
Paul Jakma3de42772009-07-28 16:04:35 +0100161* (general) Add a new DOWN state to the frob state machine
162 to allow the barinator to detect loss of frob.
163* frob.h: (struct frob) Add DOWN state flag.
164* frob.c: (frob_change) set/clear DOWN appropriately on state change.
165* bar.c: (barinate) Check frob for DOWN state.
paul1f8f61a2004-11-05 23:38:20 +0000166
Greg Troxeld7a97792010-11-03 07:20:38 -0400167Note that the commit message format follows git norms, so that "git
168log --oneline" will have useful output.
paul74a2dd72005-04-25 00:37:03 +0000169
170HACKING THE BUILD SYSTEM
171
172If you change or add to the build system (configure.ac, any Makefile.am,
173etc.), try to check that the following things still work:
174
175 - make dist
176 - resulting dist tarball builds
177 - out-of-tree builds
178
179The quagga.net site relies on make dist to work to generate snapshots. It
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100180must work. Common problems are to forget to have some additional file
paul74a2dd72005-04-25 00:37:03 +0000181included in the dist, or to have a make rule refer to a source file without
182using the srcdir variable.
183
gdt0d7e9132005-02-23 16:20:07 +0000184RELEASE PROCEDURE
185
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100186* Tag the apppropriate commit with a release tag (follow existing
187 conventions).
gdt0d7e9132005-02-23 16:20:07 +0000188 [This enables recreating the release, and is just good CM practice.]
189
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100190* Create a fresh tar archive of the quagga.net repository, and do a test
191 build:
gdt0d7e9132005-02-23 16:20:07 +0000192
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100193 git-clone git:///code.quagga.net/quagga.git quagga
194 git-archive --remote=git://code.quagga.net/quagga.git \
195 --prefix=quagga-release/ master | tar -xf -
196 cd quagga-release
gdt0d7e9132005-02-23 16:20:07 +0000197
Paul Jakma3de42772009-07-28 16:04:35 +0100198 autoreconf -i
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100199 ./configure
200 make
201 make dist
gdt0d7e9132005-02-23 16:20:07 +0000202
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100203The tarball which 'make dist' creates is the tarball to be released! The
204git-archive step ensures you're working with code corresponding to that in
205the official repository, and also carries out keyword expansion. If any
206errors occur, move tags as needed and start over from the fresh checkouts.
207Do not append to tarballs, as this has produced non-standards-conforming
208tarballs in the past.
gdt0d7e9132005-02-23 16:20:07 +0000209
Paul Jakma3de42772009-07-28 16:04:35 +0100210See also: http://wiki.quagga.net/index.php/Main/Processes
211
paul1eb8ef22005-04-07 07:30:20 +0000212[TODO: collation of a list of deprecated commands. Possibly can be scripted
213to extract from vtysh/vtysh_cmd.c]
214
paul74a2dd72005-04-25 00:37:03 +0000215
gdtfbb67092004-11-15 17:29:11 +0000216TOOL VERSIONS
217
218Require versions of support tools are listed in INSTALL.quagga.txt.
219Required versions should only be done with due deliberation, as it can
220cause environments to no longer be able to compile quagga.
221
paul74a2dd72005-04-25 00:37:03 +0000222
gdtb7a97f82004-07-23 16:23:56 +0000223SHARED LIBRARY VERSIONING
224
225[this section is at the moment just gdt's opinion]
226
227Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
228ospfclient/libsopfapiclient). These may be used by external programs,
229e.g. a new routing protocol that works with the zebra daemon, or
230ospfapi clients. The libtool info pages (node Versioning) explain
231when major and minor version numbers should be changed. These values
232are set in Makefile.am near the definition of the library. If you
233make a change that requires changing the shared library version,
234please update Makefile.am.
235
236libospf exports far more than it should, and is needed by ospfapi
237clients. Only bump libospf for changes to functions for which it is
238reasonable for a user of ospfapi to call, and please err on the side
239of not bumping.
240
241There is no support intended for installing part of zebra. The core
242library libzebra and the included daemons should always be built and
243installed together.
244
paul74a2dd72005-04-25 00:37:03 +0000245
gdtd9fd04c2003-12-19 19:20:25 +0000246PATCH SUBMISSION
247
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100248* Send a clean diff against the 'master' branch of the quagga.git
249 repository, in unified diff format, preferably with the '-p' argument to
250 show C function affected by any chunk, and with the -w and -b arguments to
251 minimise changes. E.g:
gdtd9fd04c2003-12-19 19:20:25 +0000252
Paul Jakma3de42772009-07-28 16:04:35 +0100253 git diff -up mybranch..remotes/quagga.net/master
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100254
255 Or by using git-format-patch.
256
257* Not doing so is a definite hindrance to patch application.
258
259* Include NEWS entries as appropriate.
260
261* Please, please include an appropriate commit message with any emailed
262 patches. Doing so makes it easier to review a patch, and apply it.
gdtd9fd04c2003-12-19 19:20:25 +0000263
gdt18323bb2004-11-05 13:17:20 +0000264* Include only one semantic change or group of changes per patch.
gdtd9fd04c2003-12-19 19:20:25 +0000265
paul85cf0a02004-01-09 16:34:54 +0000266* Do not make gratuitous changes to whitespace. See the w and b arguments
267 to diff.
gdtd9fd04c2003-12-19 19:20:25 +0000268
269* State on which platforms and with what daemons the patch has been
270 tested. Understand that if the set of testing locations is small,
271 and the patch might have unforeseen or hard to fix consequences that
272 there may be a call for testers on quagga-dev, and that the patch
273 may be blocked until test results appear.
274
275 If there are no users for a platform on quagga-dev who are able and
276 willing to verify -current occasionally, that platform may be
277 dropped from the "should be checked" list.
278
paul74a2dd72005-04-25 00:37:03 +0000279
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100280PATCH APPLICATION
gdtd9fd04c2003-12-19 19:20:25 +0000281
282* Only apply patches that meet the submission guidelines.
283
gdtd9fd04c2003-12-19 19:20:25 +0000284* If the patch might break something, issue a call for testing on the
285 mailinglist.
286
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100287* Give an appropriate commit message (see above), and use the --author
288 argument to git-commit, if required, to ensure proper attribution (you
289 should still be listed as committer)
290
291* Immediately after commiting, double-check (with git-log and/or gitk). If
292 there's a small mistake you can easily fix it with 'git commit --amend ..'
paul4134ceb2004-05-13 13:38:06 +0000293
gdtd9fd04c2003-12-19 19:20:25 +0000294* By committing a patch, you are responsible for fixing problems
295 resulting from it (or backing it out).
296
paul74a2dd72005-04-25 00:37:03 +0000297
gdtd9fd04c2003-12-19 19:20:25 +0000298STABLE PLATFORMS AND DAEMONS
299
300The list of platforms that should be tested follow. This is a list
301derived from what quagga is thought to run on and for which
302maintainers can test or there are people on quagga-dev who are able
303and willing to verify that -current does or does not work correctly.
304
305 BSD (Free, Net or Open, any platform) # without capabilities
306 GNU/Linux (any distribution, i386)
paul1f8f61a2004-11-05 23:38:20 +0000307 Solaris (strict alignment, any platform)
gdt18323bb2004-11-05 13:17:20 +0000308 [future: NetBSD/sparc64]
gdtd9fd04c2003-12-19 19:20:25 +0000309
310The list of daemons that are thought to be stable and that should be
311tested are:
312
313 zebra
314 bgpd
315 ripd
316 ospfd
317 ripngd
gdt1f431d22003-12-22 15:45:01 +0000318
gdt18323bb2004-11-05 13:17:20 +0000319Daemons which are in a testing phase are
320
321 ospf6d
322 isisd
ajs8035e9f2004-12-22 03:16:59 +0000323 watchquagga
gdt18323bb2004-11-05 13:17:20 +0000324
paul74a2dd72005-04-25 00:37:03 +0000325
jardin9e867fe2003-12-23 08:56:18 +0000326IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
327
328The source code of Quagga is based on two vendors:
329
330 zebra_org (http://www.zebra.org/)
331 isisd_sf (http://isisd.sf.net/)
332
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100333To import code from further sources, e.g. for archival purposes without
334necessarily having to review and/or fix some changeset, create a branch from
335'master':
gdt18323bb2004-11-05 13:17:20 +0000336
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100337 git checkout -b archive/foo master
338 <apply changes>
339 git commit -a "Joe Bar <joe@example.com>"
340 git push quagga archive/foo
jardin9e867fe2003-12-23 08:56:18 +0000341
Paul Jakmad6bb5aa2008-08-26 22:15:03 +0100342presuming 'quagga' corresponds to a file in your .git/remotes with
343configuration for the appropriate Quagga.net repository.