blob: 7c92604ac9e0ba8dab33b23e940c5fae1a456f37 [file] [log] [blame]
gdtd9fd04c2003-12-19 19:20:25 +00001-*- mode: text; -*-
paulca6383b2005-11-10 10:21:19 +00002$Id: HACKING,v 1.21 2005/11/10 10:21:19 paul Exp $
gdtd9fd04c2003-12-19 19:20:25 +00003
4GUIDELINES FOR HACKING ON QUAGGA
5
gdtd9fd04c2003-12-19 19:20:25 +00006[this is a draft in progress]
7
hasso863076d2004-09-01 20:13:23 +00008GNU coding standards apply. Indentation follows the result of
9invoking GNU indent (as of 2.2.8a) with no arguments. Note that this
10uses tabs instead of spaces where possible for leading whitespace, and
11assumes that tabs are every 8 columns. Do not attempt to redefine the
12location of tab stops. Note also that some indentation does not
13follow GNU style. This is a historical accident, and we generally
14only clean up whitespace when code is unmaintainable due to whitespace
15issues, as fewer changes from zebra lead to easier merges.
16
17For GNU emacs, use indentation style "gnu".
18
19For Vim, use the following lines (note that tabs are at 8, and that
20softtabstop sets the indentation level):
21
22set tabstop=8
23set softtabstop=2
24set shiftwidth=2
25set noexpandtab
gdtd9fd04c2003-12-19 19:20:25 +000026
gdt2934f282004-01-05 20:09:00 +000027Be particularly careful not to break platforms/protocols that you
28cannot test.
29
30New code should have good comments, and changes to existing code
31should in many cases upgrade the comments when necessary for a
32reviewer to conclude that the change has no unintended consequences.
33
gdt697877e2004-11-15 19:23:47 +000034Each file in CVS should have the RCS keyword Id, somewhere very near
35the top, commented out appropriately for the file type. Just add
36<dollar>Id:<dollar>, replacing <dollar> with $. See line 2 of HACKING
37for an example; on checkout :$ is expanded to include the value.
38
ajs5e764772004-12-03 19:03:33 +000039Please document fully the proper use of a new function in the header file
40in which it is declared. And please consult existing headers for
41documentation on how to use existing functions. In particular, please consult
42these header files:
43
44 lib/log.h logging levels and usage guidance
45 [more to be added]
46
paul1eb8ef22005-04-07 07:30:20 +000047If changing an exported interface, please try to deprecate the interface in
48an orderly manner. If at all possible, try to retain the old deprecated
49interface as is, or functionally equivalent. Make a note of when the
50interface was deprecated and guard the deprecated interface definitions in
51the header file, ie:
52
53/* Deprecated: 20050406 */
54#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
55#warning "Using deprecated <libname> (interface(s)|function(s))"
56...
57#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
58
59To ensure that the core Quagga sources do not use the deprecated interfaces
60(you should update Quagga sources to use new interfaces, if applicable)
61while allowing external sources to continue to build. Deprecated interfaces
62should be excised in the next unstable cycle.
63
paul74a2dd72005-04-25 00:37:03 +000064Note: If you wish, you can test for GCC and use a function
65marked with the 'deprecated' attribute. However, you must provide the
66#warning for other compilers.
67
paul1eb8ef22005-04-07 07:30:20 +000068If changing or removing a command definition, *ensure* that you properly
69deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
70is *critical*. Even if the command can no longer function, you *must* still
71implement it as a do-nothing stub. Failure to follow this causes grief for
72systems administrators. Deprecated commands should be excised in the next
73unstable cycle. A list of deprecated commands should be collated for each
74release.
75
76See also below regarding SHARED LIBRARY VERSIONING.
ajs5e764772004-12-03 19:03:33 +000077
paul74a2dd72005-04-25 00:37:03 +000078
gdt2934f282004-01-05 20:09:00 +000079CHANGELOG
80
81Add a ChangeLog entry whenever changing code, except for minor fixes
82to a commit (with a ChangeLog entry) within the last few days.
83
gdt18323bb2004-11-05 13:17:20 +000084Most directories have a ChangeLog file; changes to code in that
85directory should go in the per-directory ChangeLog. Global or
86structural changes should also be mentioned in the top-level
87ChangeLog.
gdt2934f282004-01-05 20:09:00 +000088
paul1f8f61a2004-11-05 23:38:20 +000089Certain directories do not contain project code, but contain project
paulca6383b2005-11-10 10:21:19 +000090meta-data, eg packaging information, changes to files in these
91directory may not require the global ChangeLog to be updated (at the
92discretion of the maintainer who usually maintains that meta-data).
93Also, CVS meta-data such as cvsignore files do not require ChangeLog
94updates, just a sane commit message.
95
96The ChangeLog should provide:
97
98* The date, in YYYY-MM-DD format
99* The author's name and email.
100* a short description of each change made
101 * file by file
102 * function by function (use of "ditto" is allowed)
103
104(detailed discussion of non-obvious reasoning behind and/or
105implications of a change should be made in comments in the code
106concerned). The changelog optionally may have a (general) description,
107to provide a short description of the general intent of the patch. The
108reason for such itemised ChangeLogs is to encourage the author to
109self-review every line of the patch, as well as provide reviewers an
110index of which changes are intended, along with a short description for
111each. E.g.:
112
1132012-05-29 Joe Bar <joe@example.com>
114
115 * (general) Add a new DOWN state to the frob state machine
116 to allow the barinator to detect loss of frob.
117 * frob.h: (struct frob) Add DOWN state flag.
118 * frob.c: (frob_change) set/clear DOWN appropriately on state
119 change.
120 * bar.c: (barinate) Check frob for DOWN state.
paul1f8f61a2004-11-05 23:38:20 +0000121
paul74a2dd72005-04-25 00:37:03 +0000122
123HACKING THE BUILD SYSTEM
124
125If you change or add to the build system (configure.ac, any Makefile.am,
126etc.), try to check that the following things still work:
127
128 - make dist
129 - resulting dist tarball builds
130 - out-of-tree builds
131
132The quagga.net site relies on make dist to work to generate snapshots. It
133must work. Commong problems are to forget to have some additional file
134included in the dist, or to have a make rule refer to a source file without
135using the srcdir variable.
136
gdt0d7e9132005-02-23 16:20:07 +0000137RELEASE PROCEDURE
138
139 Tag the repository with release tag (follow existing conventions).
140 [This enables recreating the release, and is just good CM practice.]
141
142 Check out the tag, and do a test build.
143
144 In an empty directory, do a fresh checkout with -r <release-tag>
145 [This makes the dates in the tarball be the modified dates in CVS.]
146
gdt0d7e9132005-02-23 16:20:07 +0000147 ./configure
148 make dist
149
150If any errors occur, move tags as needed and start over from the fresh
151checkouts. Do not append to tarballs, as this has produced
152non-standards-conforming tarballs in the past.
153
paul1eb8ef22005-04-07 07:30:20 +0000154[TODO: collation of a list of deprecated commands. Possibly can be scripted
155to extract from vtysh/vtysh_cmd.c]
156
paul74a2dd72005-04-25 00:37:03 +0000157
gdtfbb67092004-11-15 17:29:11 +0000158TOOL VERSIONS
159
160Require versions of support tools are listed in INSTALL.quagga.txt.
161Required versions should only be done with due deliberation, as it can
162cause environments to no longer be able to compile quagga.
163
paul74a2dd72005-04-25 00:37:03 +0000164
gdtb7a97f82004-07-23 16:23:56 +0000165SHARED LIBRARY VERSIONING
166
167[this section is at the moment just gdt's opinion]
168
169Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
170ospfclient/libsopfapiclient). These may be used by external programs,
171e.g. a new routing protocol that works with the zebra daemon, or
172ospfapi clients. The libtool info pages (node Versioning) explain
173when major and minor version numbers should be changed. These values
174are set in Makefile.am near the definition of the library. If you
175make a change that requires changing the shared library version,
176please update Makefile.am.
177
178libospf exports far more than it should, and is needed by ospfapi
179clients. Only bump libospf for changes to functions for which it is
180reasonable for a user of ospfapi to call, and please err on the side
181of not bumping.
182
183There is no support intended for installing part of zebra. The core
184library libzebra and the included daemons should always be built and
185installed together.
186
paul74a2dd72005-04-25 00:37:03 +0000187
gdtd9fd04c2003-12-19 19:20:25 +0000188PATCH SUBMISSION
189
paul85cf0a02004-01-09 16:34:54 +0000190* Send a clean diff against the head of CVS in unified diff format, eg by:
hassoe69b9e42005-02-23 11:54:12 +0000191 cvs <cvs opts> diff -upwb ....
gdtd9fd04c2003-12-19 19:20:25 +0000192
193* Include ChangeLog and NEWS entries as appropriate before the patch
paul6a524702005-04-05 10:14:50 +0000194 (or in it if you are 100% up to date). A good ChangeLog makes it easier to
195 review a patch, hence failure to include a good ChangeLog is prejudicial
196 to proper review of the patch, and hence the possibility of inclusion.
gdtd9fd04c2003-12-19 19:20:25 +0000197
gdt18323bb2004-11-05 13:17:20 +0000198* Include only one semantic change or group of changes per patch.
gdtd9fd04c2003-12-19 19:20:25 +0000199
paul85cf0a02004-01-09 16:34:54 +0000200* Do not make gratuitous changes to whitespace. See the w and b arguments
201 to diff.
gdtd9fd04c2003-12-19 19:20:25 +0000202
203* State on which platforms and with what daemons the patch has been
204 tested. Understand that if the set of testing locations is small,
205 and the patch might have unforeseen or hard to fix consequences that
206 there may be a call for testers on quagga-dev, and that the patch
207 may be blocked until test results appear.
208
209 If there are no users for a platform on quagga-dev who are able and
210 willing to verify -current occasionally, that platform may be
211 dropped from the "should be checked" list.
212
paul74a2dd72005-04-25 00:37:03 +0000213
gdtd9fd04c2003-12-19 19:20:25 +0000214PATCH APPLICATION TO CVS
215
216* Only apply patches that meet the submission guidelines.
217
218* If a patch is large (perhaps more than 100 new/changed lines), tag
219 the repository before and after the change with e.g. before-foo-fix
220 and after-foo-fix.
221
222* If the patch might break something, issue a call for testing on the
223 mailinglist.
224
paulca6383b2005-11-10 10:21:19 +0000225* Give an appropriate commit message, prefixed with a category name
226 (either the name of the daemon, the library component or the general
227 topic) and a one-line short summary of the change as the first line,
228 suitable for use as a Subject in an email. The ChangeLog entry should
229 suffice as the body of the commit message, if it does not, then the
230 ChangeLog entry itself needs to be corrected. The commit message text
231 should be identical to that added to the ChangeLog message. (One
232 suggestion: when commiting, use your editor to read in the ChangeLog
233 and delete all previous ChangeLogs.) An example:
234
235 ----------------------------------------------------------------
236 [frob] Defangulator needs to specify frob
237
238 2012-05-12 Joe Bar <joe@example.com>
239
240 * frobinate.c: (frob_lookup) fix NULL dereference
241 (defangulate) check whether frob is in state FROB_VALID
242 before defangulating.
243 ----------------------------------------------------------------
paul4134ceb2004-05-13 13:38:06 +0000244
gdtd9fd04c2003-12-19 19:20:25 +0000245* By committing a patch, you are responsible for fixing problems
246 resulting from it (or backing it out).
247
paul74a2dd72005-04-25 00:37:03 +0000248
gdtd9fd04c2003-12-19 19:20:25 +0000249STABLE PLATFORMS AND DAEMONS
250
251The list of platforms that should be tested follow. This is a list
252derived from what quagga is thought to run on and for which
253maintainers can test or there are people on quagga-dev who are able
254and willing to verify that -current does or does not work correctly.
255
256 BSD (Free, Net or Open, any platform) # without capabilities
257 GNU/Linux (any distribution, i386)
paul1f8f61a2004-11-05 23:38:20 +0000258 Solaris (strict alignment, any platform)
gdt18323bb2004-11-05 13:17:20 +0000259 [future: NetBSD/sparc64]
gdtd9fd04c2003-12-19 19:20:25 +0000260
261The list of daemons that are thought to be stable and that should be
262tested are:
263
264 zebra
265 bgpd
266 ripd
267 ospfd
268 ripngd
gdt1f431d22003-12-22 15:45:01 +0000269
gdt18323bb2004-11-05 13:17:20 +0000270Daemons which are in a testing phase are
271
272 ospf6d
273 isisd
ajs8035e9f2004-12-22 03:16:59 +0000274 watchquagga
gdt18323bb2004-11-05 13:17:20 +0000275
paul74a2dd72005-04-25 00:37:03 +0000276
jardin9e867fe2003-12-23 08:56:18 +0000277IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
278
279The source code of Quagga is based on two vendors:
280
281 zebra_org (http://www.zebra.org/)
282 isisd_sf (http://isisd.sf.net/)
283
gdt18323bb2004-11-05 13:17:20 +0000284[20041105: Is isisd.sf.netf still where isisd word is happening, or is
285the quagga repo now the canonical place? The last tarball on sf is
286two years old. --gdt]
287
jardin9e867fe2003-12-23 08:56:18 +0000288In order to import source code, the following procedure should be used:
289
290* Tag the Current Quagga CVS repository:
291
292 cvs tag import_isisd_sf_20031223
293
294* Import the source code into the Quagga's framework. You must not modified
295 this source code. It will be merged later.
296
297 cd dir_isisd
298 export CVSROOT=:pserver:LOGIN@anoncvs.quagga.net:/var/cvsroot
299 cvs import quagga/isisd isisd_sf isisd_sf_20031223
300 ---COMMENTS---
301 Vendor: [isisd_sf] Sampo's ISISd from Sourceforge
302 Tag: [isisd_sf_20031217] Current CVS release
303 ---
304
305* Update your Quagga's directory:
306
307 cd dir_quagga
308 cvs update -dP
309
310 or
311
312 cvs co -d quagga_isisd quagga
313
314* Merge the code, then commit:
315
316 cvs commit
317