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