Paul Jakma | fa48283 | 2012-03-08 13:51:21 +0000 | [diff] [blame] | 1 | %% -*- mode: text; -*- |
| 2 | %% $QuaggaId: Format:%an, %ai, %h$ $ |
| 3 | |
| 4 | \documentclass[oneside]{article} |
| 5 | \usepackage{parskip} |
| 6 | \usepackage[bookmarks,colorlinks=true]{hyperref} |
| 7 | |
| 8 | \title{Conventions for working on Quagga} |
| 9 | |
| 10 | \begin{document} |
| 11 | \maketitle |
| 12 | |
| 13 | This is a living document. Suggestions for updates, via the |
| 14 | \href{http://lists.quagga.net/mailman/listinfo/quagga-dev}{quagga-dev list}, |
| 15 | are welcome. |
| 16 | |
| 17 | \tableofcontents |
| 18 | |
| 19 | \section{GUIDELINES FOR HACKING ON QUAGGA} |
| 20 | \label{sec:guidelines} |
| 21 | |
| 22 | |
| 23 | GNU coding standards apply. Indentation follows the result of |
| 24 | invoking GNU indent (as of 2.2.8a) with no arguments. Note that this |
| 25 | uses tabs instead of spaces where possible for leading whitespace, and |
| 26 | assumes that tabs are every 8 columns. Do not attempt to redefine the |
| 27 | location of tab stops. Note also that some indentation does not |
| 28 | follow GNU style. This is a historical accident, and we generally |
| 29 | only clean up whitespace when code is unmaintainable due to whitespace |
| 30 | issues, to minimise merging conflicts. |
| 31 | |
| 32 | For GNU emacs, use indentation style ``gnu''. |
| 33 | |
| 34 | For Vim, use the following lines (note that tabs are at 8, and that |
| 35 | softtabstop sets the indentation level): |
| 36 | |
| 37 | set tabstop=8 |
| 38 | set softtabstop=2 |
| 39 | set shiftwidth=2 |
| 40 | set noexpandtab |
| 41 | |
| 42 | Be particularly careful not to break platforms/protocols that you |
| 43 | cannot test. |
| 44 | |
| 45 | New code should have good comments, which explain why the code is correct. |
| 46 | Changes to existing code should in many cases upgrade the comments when |
| 47 | necessary for a reviewer to conclude that the change has no unintended |
| 48 | consequences. |
| 49 | |
| 50 | Each file in the Git repository should have a git format-placeholder (like |
| 51 | an RCS Id keyword), somewhere very near the top, commented out appropriately |
| 52 | for the file type. The placeholder used for Quagga (replacing <dollar> with |
| 53 | \$) is: |
| 54 | |
| 55 | \verb|$QuaggaId: <dollar>Format:%an, %ai, %h<dollar> $| |
| 56 | |
| 57 | See line 2 of HACKING.tex, the source for this document, for an example. |
| 58 | |
| 59 | This placeholder string will be expanded out by the `git archive' commands, |
| 60 | wihch is used to generate the tar archives for snapshots and releases. |
| 61 | |
| 62 | Please document fully the proper use of a new function in the header file |
| 63 | in which it is declared. And please consult existing headers for |
| 64 | documentation on how to use existing functions. In particular, please consult |
| 65 | these header files: |
| 66 | |
| 67 | \begin{description} |
| 68 | \item{lib/log.h} logging levels and usage guidance |
| 69 | \item{[more to be added]} |
| 70 | \end{description} |
| 71 | |
| 72 | If changing an exported interface, please try to deprecate the interface in |
| 73 | an orderly manner. If at all possible, try to retain the old deprecated |
| 74 | interface as is, or functionally equivalent. Make a note of when the |
| 75 | interface was deprecated and guard the deprecated interface definitions in |
| 76 | the header file, ie: |
| 77 | |
| 78 | \begin{verbatim} |
| 79 | /* Deprecated: 20050406 */ |
| 80 | #if !defined(QUAGGA_NO_DEPRECATED_INTERFACES) |
| 81 | #warning "Using deprecated <libname> (interface(s)|function(s))" |
| 82 | ... |
| 83 | #endif /* QUAGGA_NO_DEPRECATED_INTERFACES */ |
| 84 | \end{verbatim} |
| 85 | |
| 86 | This is to ensure that the core Quagga sources do not use the deprecated |
| 87 | interfaces (you should update Quagga sources to use new interfaces, if |
| 88 | applicable), while allowing external sources to continue to build. |
| 89 | Deprecated interfaces should be excised in the next unstable cycle. |
| 90 | |
| 91 | Note: If you wish, you can test for GCC and use a function |
| 92 | marked with the 'deprecated' attribute. However, you must provide the |
| 93 | warning for other compilers. |
| 94 | |
| 95 | If changing or removing a command definition, \emph{ensure} that you |
| 96 | properly deprecate it - use the \_DEPRECATED form of the appropriate DEFUN |
| 97 | macro. This is \emph{critical}. Even if the command can no longer |
| 98 | function, you \emph{MUST} still implement it as a do-nothing stub. |
| 99 | |
| 100 | Failure to follow this causes grief for systems administrators, as an |
| 101 | upgrade may cause daemons to fail to start because of unrecognised commands. |
| 102 | Deprecated commands should be excised in the next unstable cycle. A list of |
| 103 | deprecated commands should be collated for each release. |
| 104 | |
| 105 | See also section~\ref{sec:dll-versioning} below regarding SHARED LIBRARY |
| 106 | VERSIONING. |
| 107 | |
Vincent JARDIN | f80ba04 | 2014-10-27 13:03:14 +0000 | [diff] [blame] | 108 | \section{YOUR FIRST CONTRIBUTIONS} |
| 109 | |
| 110 | Routing protocols can be very complex sometimes. Then, working with an |
| 111 | Opensource community can be complex too, but usually friendly with |
| 112 | anyone who is ready to be willing to do it properly. |
| 113 | |
| 114 | \begin{itemize} |
| 115 | |
| 116 | \item First, start doing simple tasks. Quagga's patchwork is a good place |
| 117 | to start with. Pickup some patches, apply them on your git trie, |
| 118 | review them and send your ack't or review comments. Then, a |
| 119 | maintainer will apply the patch if ack't or the author will |
| 120 | have to provide a new update. It help a lot to drain the |
| 121 | patchwork queues. |
| 122 | See \url{http://patchwork.quagga.net/project/quagga/list/} |
| 123 | |
| 124 | \item The more you'll review patches from patchwork, the more the |
| 125 | Quagga's maintainers will be willing to consider some patches you will |
| 126 | be sending. |
| 127 | |
| 128 | \item start using git clone, pwclient \url{http://patchwork.quagga.net/help/pwclient/} |
| 129 | |
| 130 | \begin{verbatim} |
| 131 | $ pwclient list -s new |
| 132 | ID State Name |
| 133 | -- ----- ---- |
| 134 | 179 New [quagga-dev,6648] Re: quagga on FreeBSD 4.11 (gcc-2.95) |
| 135 | 181 New [quagga-dev,6660] proxy-arp patch |
| 136 | [...] |
| 137 | |
| 138 | $ pwclient git-am 1046 |
| 139 | \end{verbatim} |
| 140 | |
| 141 | \end{itemize} |
| 142 | |
| 143 | \section{HANDY GUIDELINES FOR MAINTAINERS} |
| 144 | |
| 145 | Get your cloned trie: |
| 146 | \begin{verbatim} |
| 147 | git clone vjardin@git.sv.gnu.org:/srv/git/quagga.git |
| 148 | \end{verbatim} |
| 149 | |
| 150 | Apply some ack't patches: |
| 151 | \begin{verbatim} |
| 152 | pwclient git-am 1046 |
| 153 | Applying patch #1046 using 'git am' |
| 154 | Description: [quagga-dev,11595] zebra: route_unlock_node is missing in "show ip[v6] route <prefix>" commands |
| 155 | Applying: zebra: route_unlock_node is missing in "show ip[v6] route <prefix>" commands |
| 156 | \end{verbatim} |
| 157 | |
| 158 | Run a quick review. If the ack't was not done properly, you know who you have |
| 159 | to blame. |
| 160 | |
| 161 | Push the patches: |
| 162 | \begin{verbatim} |
| 163 | git push |
| 164 | \end{verbatim} |
| 165 | |
| 166 | Set the patch to accepted on patchwork |
| 167 | \begin{verbatim} |
| 168 | pwclient update -s Accepted 1046 |
| 169 | \end{verbatim} |
Paul Jakma | fa48283 | 2012-03-08 13:51:21 +0000 | [diff] [blame] | 170 | |
| 171 | \section{COMPILE-TIME CONDITIONAL CODE} |
| 172 | |
| 173 | Please think very carefully before making code conditional at compile time, |
| 174 | as it increases maintenance burdens and user confusion. In particular, |
| 175 | please avoid gratuitious --enable-\ldots switches to the configure script - |
| 176 | typically code should be good enough to be in Quagga, or it shouldn't be |
| 177 | there at all. |
| 178 | |
| 179 | When code must be compile-time conditional, try have the compiler make it |
| 180 | conditional rather than the C pre-processor - so that it will still be |
| 181 | checked by the compiler, even if disabled. I.e. this: |
| 182 | |
| 183 | \begin{verbatim} |
| 184 | if (SOME_SYMBOL) |
| 185 | frobnicate(); |
| 186 | \end{verbatim} |
| 187 | |
| 188 | rather than: |
| 189 | |
| 190 | \begin{verbatim} |
| 191 | #ifdef SOME_SYMBOL |
| 192 | frobnicate (); |
| 193 | #endif /* SOME_SYMBOL */ |
| 194 | \end{verbatim} |
| 195 | |
| 196 | Note that the former approach requires ensuring that SOME\_SYMBOL will be |
| 197 | defined (watch your AC\_DEFINEs). |
| 198 | |
| 199 | |
| 200 | \section{COMMIT MESSAGES} |
| 201 | |
| 202 | The commit message requirements are: |
| 203 | |
| 204 | \begin{itemize} |
| 205 | |
| 206 | \item The message \emph{MUST} provide a suitable one-line summary followed |
| 207 | by a blank line as the very first line of the message, in the form: |
| 208 | |
| 209 | \verb|topic: high-level, one line summary| |
| 210 | |
| 211 | Where topic would tend to be name of a subdirectory, and/or daemon, unless |
| 212 | there's a more suitable topic (e.g. 'build'). This topic is used to |
| 213 | organise change summaries in release announcements. |
| 214 | |
| 215 | \item It should have a suitable "body", which tries to address the |
| 216 | following areas, so as to help reviewers and future browsers of the |
| 217 | code-base understand why the change is correct (note also the code |
| 218 | comment requirements): |
| 219 | |
| 220 | \begin{itemize} |
| 221 | |
| 222 | \item The motivation for the change (does it fix a bug, if so which? |
| 223 | add a feature?) |
| 224 | |
| 225 | \item The general approach taken, and trade-offs versus any other |
| 226 | approaches. |
| 227 | |
| 228 | \item Any testing undertaken or other information affecting the confidence |
| 229 | that can be had in the change. |
| 230 | |
| 231 | \item Information to allow reviewers to be able to tell which specific |
| 232 | changes to the code are intended (and hence be able to spot any accidental |
| 233 | unintended changes). |
| 234 | |
| 235 | \end{itemize} |
| 236 | \end{itemize} |
| 237 | |
| 238 | The one-line summary must be limited to 54 characters, and all other |
| 239 | lines to 72 characters. |
| 240 | |
| 241 | Commit message bodies in the Quagga project have typically taken the |
| 242 | following form: |
| 243 | |
| 244 | \begin{itemize} |
| 245 | \item An optional introduction, describing the change generally. |
| 246 | \item A short description of each specific change made, preferably: |
| 247 | \begin{itemize} \item file by file |
| 248 | \begin{itemize} \item function by function (use of "ditto", or globs is |
| 249 | allowed) |
| 250 | \end{itemize} |
| 251 | \end{itemize} |
| 252 | \end{itemize} |
| 253 | |
| 254 | Contributors are strongly encouraged to follow this form. |
| 255 | |
| 256 | This itemised commit messages allows reviewers to have confidence that the |
| 257 | author has self-reviewed every line of the patch, as well as providing |
| 258 | reviewers a clear index of which changes are intended, and descriptions for |
| 259 | them (C-to-english descriptions are not desireable - some discretion is |
| 260 | useful). For short patches, a per-function/file break-down may be |
| 261 | redundant. For longer patches, such a break-down may be essential. A |
| 262 | contrived example (where the general discussion is obviously somewhat |
| 263 | redundant, given the one-line summary): |
| 264 | |
| 265 | \begin{quote}\begin{verbatim} |
| 266 | zebra: Enhance frob FSM to detect loss of frob |
| 267 | |
| 268 | Add a new DOWN state to the frob state machine to allow the barinator to |
| 269 | detect loss of frob. |
| 270 | |
| 271 | * frob.h: (struct frob) Add DOWN state flag. |
Paul Jakma | d4a8607 | 2012-10-19 12:02:42 +0100 | [diff] [blame] | 272 | * frob.c: (frob_change) set/clear DOWN appropriately on state change. |
Paul Jakma | fa48283 | 2012-03-08 13:51:21 +0000 | [diff] [blame] | 273 | * bar.c: (barinate) Check frob for DOWN state. |
| 274 | \end{verbatim}\end{quote} |
| 275 | |
| 276 | Please have a look at the git commit logs to get a feel for what the norms |
| 277 | are. |
| 278 | |
| 279 | Note that the commit message format follows git norms, so that ``git |
| 280 | log --oneline'' will have useful output. |
| 281 | |
| 282 | \section{HACKING THE BUILD SYSTEM} |
| 283 | |
| 284 | If you change or add to the build system (configure.ac, any Makefile.am, |
| 285 | etc.), try to check that the following things still work: |
| 286 | |
| 287 | \begin{itemize} |
| 288 | \item make dist |
| 289 | \item resulting dist tarball builds |
| 290 | \item out-of-tree builds |
| 291 | \end{itemize} |
| 292 | |
| 293 | The quagga.net site relies on make dist to work to generate snapshots. It |
| 294 | must work. Common problems are to forget to have some additional file |
| 295 | included in the dist, or to have a make rule refer to a source file without |
| 296 | using the srcdir variable. |
| 297 | |
| 298 | |
| 299 | \section{RELEASE PROCEDURE} |
| 300 | |
| 301 | \begin{itemize} |
| 302 | \item Tag the apppropriate commit with a release tag (follow existing |
| 303 | conventions). |
| 304 | |
| 305 | [This enables recreating the release, and is just good CM practice.] |
| 306 | |
| 307 | \item Create a fresh tar archive of the quagga.net repository, and do a test |
| 308 | build: |
| 309 | |
| 310 | \begin{verbatim} |
| 311 | git-clone git:///code.quagga.net/quagga.git quagga |
| 312 | git-archive --remote=git://code.quagga.net/quagga.git \ |
| 313 | --prefix=quagga-release/ master | tar -xf - |
| 314 | cd quagga-release |
| 315 | |
| 316 | autoreconf -i |
| 317 | ./configure |
| 318 | make |
| 319 | make dist |
| 320 | \end{verbatim} |
| 321 | \end{itemize} |
| 322 | |
| 323 | The tarball which `make dist' creates is the tarball to be released! The |
| 324 | git-archive step ensures you're working with code corresponding to that in |
| 325 | the official repository, and also carries out keyword expansion. If any |
| 326 | errors occur, move tags as needed and start over from the fresh checkouts. |
| 327 | Do not append to tarballs, as this has produced non-standards-conforming |
| 328 | tarballs in the past. |
| 329 | |
| 330 | See also: \url{http://wiki.quagga.net/index.php/Main/Processes} |
| 331 | |
| 332 | [TODO: collation of a list of deprecated commands. Possibly can be scripted |
| 333 | to extract from vtysh/vtysh\_cmd.c] |
| 334 | |
| 335 | |
| 336 | \section{TOOL VERSIONS} |
| 337 | |
| 338 | Require versions of support tools are listed in INSTALL.quagga.txt. |
| 339 | Required versions should only be done with due deliberation, as it can |
| 340 | cause environments to no longer be able to compile quagga. |
| 341 | |
| 342 | |
| 343 | \section{SHARED LIBRARY VERSIONING} |
| 344 | \label{sec:dll-versioning} |
| 345 | |
| 346 | [this section is at the moment just gdt's opinion] |
| 347 | |
| 348 | Quagga builds several shared libaries (lib/libzebra, ospfd/libospf, |
| 349 | ospfclient/libsopfapiclient). These may be used by external programs, |
| 350 | e.g. a new routing protocol that works with the zebra daemon, or |
| 351 | ospfapi clients. The libtool info pages (node Versioning) explain |
| 352 | when major and minor version numbers should be changed. These values |
| 353 | are set in Makefile.am near the definition of the library. If you |
| 354 | make a change that requires changing the shared library version, |
| 355 | please update Makefile.am. |
| 356 | |
| 357 | libospf exports far more than it should, and is needed by ospfapi |
| 358 | clients. Only bump libospf for changes to functions for which it is |
| 359 | reasonable for a user of ospfapi to call, and please err on the side |
| 360 | of not bumping. |
| 361 | |
| 362 | There is no support intended for installing part of zebra. The core |
| 363 | library libzebra and the included daemons should always be built and |
| 364 | installed together. |
| 365 | |
| 366 | |
| 367 | \section{GIT COMMIT SUBMISSION} |
| 368 | \label{sec:git-submission} |
| 369 | |
| 370 | The preferred method for submitting changes is to provide git commits via a |
| 371 | publically-accessible git repository, which the maintainers can easily pull. |
| 372 | |
| 373 | The commits should be in a branch based off the Quagga.net master - a |
| 374 | "feature branch". Ideally there should be no commits to this branch other |
| 375 | than those in master, and those intended to be submitted. However, merge |
| 376 | commits to this branch from the Quagga master are permitted, though strongly |
| 377 | discouraged - use another (potentially local and throw-away) branch to test |
| 378 | merge with the latest Quagga master. |
| 379 | |
| 380 | Recommended practice is to keep different logical sets of changes on |
| 381 | separate branches - "topic" or "feature" branches. This allows you to still |
| 382 | merge them together to one branch (potentially local and/or "throw-away") |
| 383 | for testing or use, while retaining smaller, independent branches that are |
| 384 | easier to merge. |
| 385 | |
| 386 | All content guidelines in section \ref{sec:patch-submission}, PATCH |
| 387 | SUBMISSION apply. |
| 388 | |
| 389 | |
| 390 | \section{PATCH SUBMISSION} |
| 391 | \label{sec:patch-submission} |
| 392 | |
| 393 | \begin{itemize} |
| 394 | |
| 395 | \item For complex changes, contributors are strongly encouraged to first |
| 396 | start a design discussion on the quagga-dev list \emph{before} |
| 397 | starting any coding. |
| 398 | |
| 399 | \item Send a clean diff against the 'master' branch of the quagga.git |
| 400 | repository, in unified diff format, preferably with the '-p' argument to |
| 401 | show C function affected by any chunk, and with the -w and -b arguments to |
| 402 | minimise changes. E.g: |
| 403 | |
| 404 | git diff -up mybranch..remotes/quagga.net/master |
| 405 | |
| 406 | It is preferable to use git format-patch, and even more preferred to |
| 407 | publish a git repository (see GIT COMMIT SUBMISSION, section |
| 408 | \ref{sec:git-submission}). |
| 409 | |
| 410 | If not using git format-patch, Include the commit message in the email. |
| 411 | |
| 412 | \item After a commit, code should have comments explaining to the reviewer |
| 413 | why it is correct, without reference to history. The commit message |
| 414 | should explain why the change is correct. |
| 415 | |
| 416 | \item Include NEWS entries as appropriate. |
| 417 | |
| 418 | \item Include only one semantic change or group of changes per patch. |
| 419 | |
| 420 | \item Do not make gratuitous changes to whitespace. See the w and b arguments |
| 421 | to diff. |
| 422 | |
| 423 | \item Changes should be arranged so that the least contraversial and most |
| 424 | trivial are first, and the most complex or more contraversial are |
| 425 | last. This will maximise how many the Quagga maintainers can merge, |
| 426 | even if some other commits need further work. |
| 427 | |
| 428 | \item Providing a unit-test is strongly encouraged. Doing so will make it |
| 429 | much easier for maintainers to have confidence that they will be able |
| 430 | to support your change. |
| 431 | |
| 432 | \item New code should be arranged so that it easy to verify and test. E.g. |
| 433 | stateful logic should be separated out from functional logic as much as |
| 434 | possible: wherever possible, move complex logic out to smaller helper |
| 435 | functions which access no state other than their arguments. |
| 436 | |
| 437 | \item State on which platforms and with what daemons the patch has been |
| 438 | tested. Understand that if the set of testing locations is small, |
| 439 | and the patch might have unforeseen or hard to fix consequences that |
| 440 | there may be a call for testers on quagga-dev, and that the patch |
| 441 | may be blocked until test results appear. |
| 442 | |
| 443 | If there are no users for a platform on quagga-dev who are able and |
| 444 | willing to verify -current occasionally, that platform may be |
| 445 | dropped from the "should be checked" list. |
| 446 | |
| 447 | \end{itemize} |
| 448 | |
| 449 | \section{PATCH APPLICATION} |
| 450 | |
| 451 | \begin{itemize} |
| 452 | |
| 453 | \item Only apply patches that meet the submission guidelines. |
| 454 | |
| 455 | \item If the patch might break something, issue a call for testing on the |
| 456 | mailinglist. |
| 457 | |
| 458 | \item Give an appropriate commit message (see above), and use the --author |
| 459 | argument to git-commit, if required, to ensure proper attribution (you |
| 460 | should still be listed as committer) |
| 461 | |
| 462 | \item Immediately after commiting, double-check (with git-log and/or gitk). |
| 463 | If there's a small mistake you can easily fix it with `git commit |
| 464 | --amend ..' |
| 465 | |
| 466 | \item When merging a branch, always use an explicit merge commit. Giving |
| 467 | --no-ff ensures a merge commit is created which documents ``this human |
| 468 | decided to merge this branch at this time''. |
| 469 | \end{itemize} |
| 470 | |
| 471 | \section{STABLE PLATFORMS AND DAEMONS} |
| 472 | |
| 473 | The list of platforms that should be tested follow. This is a list |
| 474 | derived from what quagga is thought to run on and for which |
| 475 | maintainers can test or there are people on quagga-dev who are able |
| 476 | and willing to verify that -current does or does not work correctly. |
| 477 | |
| 478 | \begin{itemize} |
| 479 | \item BSD (Free, Net or Open, any platform) |
| 480 | \item GNU/Linux (any distribution, i386) |
| 481 | \item Solaris (strict alignment, any platform) |
| 482 | \item future: NetBSD/sparc64 |
| 483 | \end{itemize} |
| 484 | |
| 485 | The list of daemons that are thought to be stable and that should be |
| 486 | tested are: |
| 487 | |
| 488 | \begin{itemize} |
| 489 | \item zebra |
| 490 | \item bgpd |
| 491 | \item ripd |
| 492 | \item ospfd |
| 493 | \item ripngd |
| 494 | \end{itemize} |
| 495 | Daemons which are in a testing phase are |
| 496 | |
| 497 | \begin{itemize} |
| 498 | \item ospf6d |
| 499 | \item isisd |
| 500 | \item watchquagga |
| 501 | \end{itemize} |
| 502 | |
| 503 | \section{IMPORT OR UPDATE VENDOR SPECIFIC ROUTING PROTOCOLS} |
| 504 | |
| 505 | The source code of Quagga is based on two vendors: |
| 506 | |
| 507 | \verb|zebra_org| (\url{http://www.zebra.org/}) |
| 508 | \verb|isisd_sf| (\url{http://isisd.sf.net/}) |
| 509 | |
| 510 | To import code from further sources, e.g. for archival purposes without |
| 511 | necessarily having to review and/or fix some changeset, create a branch from |
| 512 | `master': |
| 513 | |
| 514 | \begin{verbatim} |
| 515 | git checkout -b archive/foo master |
| 516 | <apply changes> |
| 517 | git commit -a "Joe Bar <joe@example.com>" |
| 518 | git push quagga archive/foo |
| 519 | \end{verbatim} |
| 520 | |
| 521 | presuming `quagga' corresponds to a file in your .git/remotes with |
| 522 | configuration for the appropriate Quagga.net repository. |
| 523 | |
| 524 | \end{document} |