]> git.proxmox.com Git - mirror_frr.git/blame - HACKING
Update for git and emphasize asking for good reports.
[mirror_frr.git] / HACKING
CommitLineData
d9fd04c2 1-*- mode: text; -*-
d6bb5aa5
PJ
2$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
d9fd04c2 19
20GUIDELINES FOR HACKING ON QUAGGA
21
d9fd04c2 22[this is a draft in progress]
23
863076db 24GNU 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
d9fd04c2 42
2934f28e 43Be 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
d6bb5aa5
PJ
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 $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.
697877eb 61
5e764774 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 lib/log.h logging levels and usage guidance
68 [more to be added]
69
1eb8ef25 70If 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
74a2dd7b 87Note: 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
1eb8ef25 91If 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.
5e764774 100
750e8146
PJ
101COMPILE-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).
74a2dd7b 123
d6bb5aa5 124COMMIT MESSAGES
2934f28e 125
d6bb5aa5 126The commit message should provide:
2934f28e 127
d6bb5aa5
PJ
128* A suitable one-line summary as the very first line of the message, in the
129 form:
2934f28e 130
3de4277b 131 topic: high-level, one line summary
ca6383ba 132
3de4277b
PJ
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.
ca6383ba 136
d6bb5aa5 137* An optional introduction, discussing the general intent of the change.
3de4277b 138* A short description of each change made, preferably:
ca6383ba 139 * file by file
d6bb5aa5 140 * function by function (use of "ditto", or globs is allowed)
ca6383ba 141
3de4277b
PJ
142to 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
ca6383ba 146
d6bb5aa5
PJ
147The reason for such itemised commit messages is to encourage the author to
148self-review every line of the patch, as well as provide reviewers an index
3de4277b
PJ
149of which changes are intended, along with a short description for each.
150Some discretion is obviously required. A C-to-english description is not
151desireable. For short patches, a per-function/file break-down may be
152redundant. For longer patches, such a break-down may be essential.
153
d6bb5aa5
PJ
154An example (where the general discussion is obviously somewhat redundant,
155given the one-line summary):
156
3de4277b 157zebra: Enhance frob FSM to detect loss of frob
ca6383ba 158
3de4277b
PJ
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.
1f8f61a7 164
74a2dd7b 165
166HACKING THE BUILD SYSTEM
167
168If you change or add to the build system (configure.ac, any Makefile.am,
169etc.), try to check that the following things still work:
170
171 - make dist
172 - resulting dist tarball builds
173 - out-of-tree builds
174
175The quagga.net site relies on make dist to work to generate snapshots. It
d6bb5aa5 176must work. Common problems are to forget to have some additional file
74a2dd7b 177included in the dist, or to have a make rule refer to a source file without
178using the srcdir variable.
179
0d7e9134 180RELEASE PROCEDURE
181
d6bb5aa5
PJ
182* Tag the apppropriate commit with a release tag (follow existing
183 conventions).
0d7e9134 184 [This enables recreating the release, and is just good CM practice.]
185
d6bb5aa5
PJ
186* Create a fresh tar archive of the quagga.net repository, and do a test
187 build:
0d7e9134 188
d6bb5aa5
PJ
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 -
192 cd quagga-release
0d7e9134 193
3de4277b 194 autoreconf -i
d6bb5aa5
PJ
195 ./configure
196 make
197 make dist
0d7e9134 198
d6bb5aa5
PJ
199The tarball which 'make dist' creates is the tarball to be released! The
200git-archive step ensures you're working with code corresponding to that in
201the official repository, and also carries out keyword expansion. If any
202errors occur, move tags as needed and start over from the fresh checkouts.
203Do not append to tarballs, as this has produced non-standards-conforming
204tarballs in the past.
0d7e9134 205
3de4277b
PJ
206See also: http://wiki.quagga.net/index.php/Main/Processes
207
1eb8ef25 208[TODO: collation of a list of deprecated commands. Possibly can be scripted
209to extract from vtysh/vtysh_cmd.c]
210
74a2dd7b 211
fbb67099 212TOOL VERSIONS
213
214Require versions of support tools are listed in INSTALL.quagga.txt.
215Required versions should only be done with due deliberation, as it can
216cause environments to no longer be able to compile quagga.
217
74a2dd7b 218
b7a97f82 219SHARED LIBRARY VERSIONING
220
221[this section is at the moment just gdt's opinion]
222
223Quagga builds several shared libaries (lib/libzebra, ospfd/libospf,
224ospfclient/libsopfapiclient). These may be used by external programs,
225e.g. a new routing protocol that works with the zebra daemon, or
226ospfapi clients. The libtool info pages (node Versioning) explain
227when major and minor version numbers should be changed. These values
228are set in Makefile.am near the definition of the library. If you
229make a change that requires changing the shared library version,
230please update Makefile.am.
231
232libospf exports far more than it should, and is needed by ospfapi
233clients. Only bump libospf for changes to functions for which it is
234reasonable for a user of ospfapi to call, and please err on the side
235of not bumping.
236
237There is no support intended for installing part of zebra. The core
238library libzebra and the included daemons should always be built and
239installed together.
240
74a2dd7b 241
d9fd04c2 242PATCH SUBMISSION
243
d6bb5aa5
PJ
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:
248
3de4277b 249 git diff -up mybranch..remotes/quagga.net/master
d9fd04c2 250
d6bb5aa5
PJ
251 Or by using git-format-patch.
252
253* Not doing so is a definite hindrance to patch application.
254
255* Include NEWS entries as appropriate.
256
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.
d9fd04c2 259
18323bb2 260* Include only one semantic change or group of changes per patch.
d9fd04c2 261
85cf0a0d 262* Do not make gratuitous changes to whitespace. See the w and b arguments
263 to diff.
d9fd04c2 264
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.
270
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.
274
74a2dd7b 275
d6bb5aa5 276PATCH APPLICATION
d9fd04c2 277
278* Only apply patches that meet the submission guidelines.
279
d9fd04c2 280* If the patch might break something, issue a call for testing on the
281 mailinglist.
282
d6bb5aa5
PJ
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)
286
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 ..'
4134ceb7 289
d9fd04c2 290* By committing a patch, you are responsible for fixing problems
291 resulting from it (or backing it out).
292
74a2dd7b 293
d9fd04c2 294STABLE PLATFORMS AND DAEMONS
295
296The list of platforms that should be tested follow. This is a list
297derived from what quagga is thought to run on and for which
298maintainers can test or there are people on quagga-dev who are able
299and willing to verify that -current does or does not work correctly.
300
301 BSD (Free, Net or Open, any platform) # without capabilities
302 GNU/Linux (any distribution, i386)
1f8f61a7 303 Solaris (strict alignment, any platform)
18323bb2 304 [future: NetBSD/sparc64]
d9fd04c2 305
306The list of daemons that are thought to be stable and that should be
307tested are:
308
309 zebra
310 bgpd
311 ripd
312 ospfd
313 ripngd
1f431d2d 314
18323bb2 315Daemons which are in a testing phase are
316
317 ospf6d
318 isisd
8035e9f0 319 watchquagga
18323bb2 320
74a2dd7b 321
9e867fe6 322IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS
323
324The source code of Quagga is based on two vendors:
325
326 zebra_org (http://www.zebra.org/)
327 isisd_sf (http://isisd.sf.net/)
328
d6bb5aa5
PJ
329To import code from further sources, e.g. for archival purposes without
330necessarily having to review and/or fix some changeset, create a branch from
331'master':
9e867fe6 332
d6bb5aa5
PJ
333 git checkout -b archive/foo master
334 <apply changes>
335 git commit -a "Joe Bar <joe@example.com>"
336 git push quagga archive/foo
9e867fe6 337
d6bb5aa5
PJ
338presuming 'quagga' corresponds to a file in your .git/remotes with
339configuration for the appropriate Quagga.net repository.