]> git.proxmox.com Git - mirror_frr.git/blame - doc/developer/workflow.rst
developer: workflow.rst - add text on how to respond to reviews/comments
[mirror_frr.git] / doc / developer / workflow.rst
CommitLineData
9de103f0
QY
1.. _process-and-workflow:
2
3*******************
b22ba015 4Process & Workflow
9de103f0 5*******************
d1890d04 6
b22ba015
QY
7FRR is a large project developed by many different groups. This section
8documents standards for code style & quality, commit messages, pull requests
9and best practices that all contributors are asked to follow.
d1890d04 10
9de103f0
QY
11This chapter is "descriptive/post-factual" in that it documents pratices that
12are in use; it is not "definitive/pre-factual" in prescribing practices. This
b22ba015
QY
13means that when a procedure changes, it is agreed upon, then put into practice,
14and then documented here. If this document doesn't match reality, it's the
15document that needs to be updated, not reality.
d1890d04 16
9de103f0
QY
17Mailing Lists
18=============
d1890d04 19
b22ba015
QY
20The FRR development group maintains multiple mailing lists for use by the
21community. Italicized lists are private.
d1890d04
QY
22
23+----------------------------------+--------------------------------+
24| Topic | List |
25+==================================+================================+
26| Development | dev@lists.frrouting.org |
27+----------------------------------+--------------------------------+
28| Users & Operators | frog@lists.frrouting.org |
29+----------------------------------+--------------------------------+
30| Announcements | announce@lists.frrouting.org |
31+----------------------------------+--------------------------------+
32| *Security* | security@lists.frrouting.org |
33+----------------------------------+--------------------------------+
34| *Technical Steering Committee* | tsc@lists.frrouting.org |
35+----------------------------------+--------------------------------+
36
9de103f0
QY
37The Development list is used to discuss and document general issues related to
38project development and governance. The public Slack instance,
39frrouting.slack.com, and weekly technical meetings provide a higher bandwidth
40channel for discussions. The results of such discussions must be reflected in
41updates, as appropriate, to code (i.e., merges), `Github issues`_, and for
42governance or process changes, updates to the Development list and either this
43file or information posted at https://frrouting.org/.
8ce7861f 44
c804874a
QY
45Release Process & Schedule
46==========================
47
48FRR employs a <MAJOR>.<MINOR>.<BUGFIX> versioning scheme.
49
50MAJOR
51 Significant new features or multiple minor features. The addition of a new
52 routing protocol or daemon would fall under this class.
53
54MINOR
55 Small features, e.g. options for automatic BGP shutdown.
56
57BUGFIX
58 Fixes for actual bugs and/or security issues.
59
60We will pull a new development branch for the next release every 4 months. The
61current schedule is Feb/June/October 1. The decision for a MAJOR/MINOR release
62is made at the time of branch pull based on what has been received the previous
634 months. The branch name will be dev/MAJOR.MINOR. At this point in time the
64master branch, :file:`configure.ac`, documentation and packaging systems will
65be updated to reflect the next possible release name to allow for easy
66distinguishing. Additionally the new dev branch will have these files updated
67too.
68
69After one month the development branch will be renamed to stable/MAJOR.MINOR.
70This process is not held up unless a crash or security issue has been found and
71needs to be addressed. Issues being fixed will not cause a delay.
72
73Bugfix releases are made as needed at 1 month intervals until the next
74MAJOR.MINOR relese branch is pulled. Depending on the severity of the bugs,
75bugfix releases may occur sooner.
76
77Bugfixes are applied to the two most recent releases. Security fixes are
78backported to all releases less than or equal to one year old. Security fixes
79may also be backported to older releases depending on severity.
8ce7861f 80
d1890d04 81Changelog
9de103f0 82=========
d1890d04 83
b22ba015
QY
84The changelog will be the base for the release notes. A changelog entry for
85your changes is usually not required and will be added based on your commit
86messages by the maintainers. However, you are free to include an update to the
87changelog with some better description.
d1890d04
QY
88
89Submitting Patches and Enhancements
9de103f0 90===================================
d1890d04 91
b22ba015
QY
92FRR accepts patches from two sources:
93
94- Email (git format-patch)
95- Github pull request
96
97Contributors are highly encouraged to use Github's fork-and-pr workflow. It is
98easier for us to review it, test it, try it and discuss it on Github than it is
99via email, thus your patch will get more attention more quickly on Github.
100
101The base branch for new contributions and non-critical bug fixes should be
102``master``. Please ensure your pull request is based on this branch when you
103submit it.
104
d1890d04 105Pre-submission Checklist
9de103f0 106------------------------
d1890d04 107
b22ba015 108- Format code (see `Code Formatting <#developers-guidelines>`__)
d1890d04
QY
109- Verify and acknowledge license (see `License for
110 contributions <#license-for-contributions>`__)
111- Ensure you have properly signed off (see `Signing
112 Off <#signing-off>`__)
113- Test building with various configurations:
114
115 - ``buildtest.sh``
116
117- Verify building source distribution:
118
119 - ``make dist`` (and try rebuilding from the resulting tar file)
120
121- Run unit tests:
122
123 - ``make test``
124
125- Document Regression Runs and plans for continued maintenance of the
126 feature
127
128License for contributions
9de103f0 129-------------------------
d1890d04 130
b22ba015 131FRR is under a “GPLv2 or later” license. Any code submitted must
d1890d04
QY
132be released under the same license (preferred) or any license which
133allows redistribution under this GPLv2 license (eg MIT License).
134
135Signing Off
9de103f0 136-----------
d1890d04 137
b22ba015 138Code submitted to FRR must be signed off. We have the same
d1890d04
QY
139requirements for using the signed-off-by process as the Linux kernel. In
140short, you must include a signed-off-by tag in every patch.
141
142``Signed-off-by:`` this is a developer's certification that he or she
143has the right to submit the patch for inclusion into the project. It is
144an agreement to the Developer's Certificate of Origin (below). Code
145without a proper signoff can not and will not be merged.
146
147If you are unfamiliar with this process, you should read the `official
148policy at
149kernel.org <https://www.kernel.org/doc/html/latest/process/submitting-patches.html>`__
150and you might find this article about `participating in the Linux
151community on the Linux Foundation
152website <http://www.linuxfoundation.org/content/how-participate-linux-community-0>`__
153to be a helpful resource.
154
155In short, when you sign off on a commit, you assert your agreement to
156all of the following:
157
b22ba015
QY
158::
159
d1890d04
QY
160 Developer's Certificate of Origin 1.1
161
162 By making a contribution to this project, I certify that:
163
164 (a) The contribution was created in whole or in part by me and I
165 have the right to submit it under the open source license
166 indicated in the file; or
167
168 (b) The contribution is based upon previous work that, to the best
169 of my knowledge, is covered under an appropriate open source
170 license and I have the right under that license to submit that
171 work with modifications, whether created in whole or in part by
172 me, under the same open source license (unless I am permitted to
173 submit under a different license), as indicated in the file; or
174
175 (c) The contribution was provided directly to me by some other
176 person who certified (a), (b) or (c) and I have not modified it.
177
178 (d) I understand and agree that this project and the contribution
179 are public and that a record of the contribution (including all
180 personal information I submit with it, including my sign-off) is
181 maintained indefinitely and may be redistributed consistent with
182 this project or the open source license(s) involved.
183
184What do I submit my changes against?
9de103f0 185------------------------------------
d1890d04
QY
186
187We've documented where we would like to have the different fixes applied
188at
b22ba015 189https://github.com/FRR/frr/wiki/Where-Do-I-create-a-Pull-Request-against%3F
d1890d04
QY
190If you are unsure where your submission goes, look at that document or
191ask a project maintainer.
192
193Github pull requests
9de103f0 194--------------------
d1890d04
QY
195
196The preferred method of submitting changes is a Github pull request.
197Code submitted by pull request will be automatically tested by one or
198more CI systems. Once the automated tests succeed, other developers will
199review your code for quality and correctness. After any concerns are
200resolved, your code will be merged into the branch it was submitted
201against.
202
203Patch submission via mailing list
9de103f0 204---------------------------------
d1890d04
QY
205
206As an alternative submission method, a patch can be mailed to the
207development mailing list. Patches received on the mailing list will be
208picked up by Patchwork and tested against the latest development branch.
209
210The recommended way to send the patch (or series of NN patches) to the
211list is by using ``git send-email`` as follows (assuming they are the N
212most recent commit(s) in your git history:
213
214::
215
216 git send-email -NN --annotate --to=dev@lists.frrouting.org
217
218If your commits do not already contain a ``Signed-off-by`` line, then
219use the following command to add it (after making sure you agree to the
220Developer Certificate of Origin as outlined above):
221
222::
223
224 git send-email -NN --annotate --signoff --to=dev@lists.frrouting.org
225
226Submitting multi-commit patches as a Github pull request is **strongly
227encouraged** and increases the probability of your patch getting
228reviewed and merged in a timely manner.
229
230After submitting your changes
231-----------------------------
232
233- Watch for Continuous Integration (CI) Test results
234
235 - You should automatically receive an email with the test results
236 within less than 2 hrs of the submission. If you don’t get the
b22ba015 237 email, then check status on the Github pull request.
d1890d04 238 - Please notify the development mailing list if you think something
b22ba015 239 doesn't work.
d1890d04
QY
240
241- If the tests failed:
242
243 - In general, expect the community to ignore the submission until
244 the tests pass.
245 - It is up to you to fix and resubmit.
246
247 - This includes fixing existing unit (“make test”) tests if your
248 changes broke or changed them.
249 - It also includes fixing distribution packages for the failing
250 platforms (ie if new libraries are required).
251 - Feel free to ask for help on the development list.
252
253 - Go back to the submission process and repeat until the tests pass.
254
255- If the tests pass:
256
257 - Wait for reviewers. Someone will review your code or be assigned
258 to review your code.
493e3eed
LB
259 - Respond to any comments or concerns the reviewer has. Use e-mail or
260 add a comment via github to respond or to let the reviewer know how
261 their comment or concern is addressed.
262 - An author must never delete or manually dismiss someone else's comments
263 or review. (A review may be overridden by agreement in the weekly
264 technical meeting.)
265 - Automatically generated comments, e.g., those generated by CI systems,
266 may be deleted by authors and others when such comments are not the most
267 results from that automated comment source.
d1890d04
QY
268 - After all comments and concerns are addressed, expect your patch
269 to be merged.
270
271- Watch out for questions on the mailing list. At this time there will
272 be a manual code review and further (longer) tests by various
273 community members.
274- Your submission is done once it is merged to the master branch.
275
9de103f0
QY
276Git Structure
277=============
278
279.. figure:: ../figures/git_branches.png
280 :align: center
281 :scale: 55%
282 :alt: Merging Git branches into a central trunk
283
284 Rough outline of FRR development workflow
285
286The master Git for FRR resides on `GitHub`_.
287
288There is one main branch for development, ``master``. For each major release
289(2.0, 3.0 etc) a new release branch is created based on the master. Subsequent
290point releases based on a major branch are marked by tagging.
291
292Programming Languages, Tools and Libraries
293==========================================
294
295The core of FRR is written in C (gcc or clang supported) and makes
296use of GNU compiler extensions. A few non-essential scripts are
297implemented in Perl and Python. FRR requires the following tools
298to build distribution packages: automake, autoconf, texinfo, libtool and
299gawk and various libraries (i.e. libpam and libjson-c).
300
301If your contribution requires a new library or other tool, then please
302highlight this in your description of the change. Also make sure it’s
303supported by all FRR platform OSes or provide a way to build
304without the library (potentially without the new feature) on the other
305platforms.
306
307Documentation should be written in reStructuredText. Sphinx extensions may be
308utilized but pure ReST is preferred where possible. See
309:ref:`documentation`.
310
311
b22ba015 312Coding Practices & Style
9de103f0 313========================
d1890d04
QY
314
315Commit messages
9de103f0 316---------------
d1890d04
QY
317
318Commit messages should be formatted in the same way as Linux kernel
319commit messages. The format is roughly
320
321::
322
323 dir: short summary
324
325 extended summary
326
327``dir`` should be the top level source directory under which the change
9de103f0 328was made. For example, a change in bgpd/rfapi would be formatted as:::
d1890d04 329
9de103f0 330 bgpd: short summary
d1890d04
QY
331
332The first line should be no longer than 50 characters. Subsequent lines
333should be wrapped to 72 characters.
334
335Source file header
9de103f0 336------------------
d1890d04
QY
337
338New files need to have a Copyright header (see `License for
339contributions <#license-for-contributions>`__ above) added to the file.
340Preferred form of the header is as follows:
341
342::
343
344 /*
345 * Title/Function of file
346 * Copyright (C) YEAR Author’s Name
347 *
348 * This program is free software; you can redistribute it and/or modify it
349 * under the terms of the GNU General Public License as published by the Free
350 * Software Foundation; either version 2 of the License, or (at your option)
351 * any later version.
352 *
353 * This program is distributed in the hope that it will be useful, but WITHOUT
354 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
355 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
356 * more details.
357 *
358 * You should have received a copy of the GNU General Public License along
359 * with this program; see the file COPYING; if not, write to the Free Software
360 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
361 */
362
363 #include <zebra.h>
364
365Adding copyright claims to existing files
9de103f0 366-----------------------------------------
d1890d04
QY
367
368When adding copyright claims for modifications to an existing file,
369please preface the claim with "Portions: " on a line before it and
370indent the "Copyright ..." string. If such a case already exists, add
371your indented claim immediately after. E.g.:
372
373::
374
375 Portions:
376 Copyright (C) 2010 Entity A ....
377 Copyright (C) 2016 Your name [optional brief change description]
378
379Code formatting
9de103f0 380---------------
d1890d04
QY
381
382FRR uses Linux kernel style except where noted below. Code which does
383not comply with these style guidelines will not be accepted.
384
281ba953
QY
385The project provides multiple tools to allow you to correctly style your code
386as painlessly as possible, primarily built around ``clang-format``.
387
388clang-format
389 In the project root there is a :file:`.clang-format` configuration file
390 which can be used with the ``clang-format`` source formatter tool from the
391 LLVM project. Most of the time, this is the easiest and smartest tool to
392 use. It can be run in a variety of ways. If you point it at a C source file
393 or directory of source files, it will format all of them. In the LLVM source
394 tree there are scripts that allow you to integrate it with ``git``, ``vim``
395 and ``emacs``, and there are third-party plugins for other editors. The
396 ``git`` integration is particularly useful; suppose you have some changes in
397 your git index. Then, with the integration installed, you can do the
398 following:
399
400 ::
401
402 git clang-format
403
404 This will format *only* the changes present in your index. If you have just
405 made a few commits and would like to correctly style only the changes made
406 in those commits, you can use the following syntax:
407
408 ::
409
410 git clang-format HEAD~X
411
412 Where X is one more than the number of commits back from the tip of your
413 branch you would like ``clang-format`` to look at (similar to specifying the
414 target for a rebase).
415
416 The ``vim`` plugin is particularly useful. It allows you to select lines in
417 visual line mode and press a key binding to invoke ``clang-format`` on only
418 those lines.
419
420 When using ``clang-format``, it is recommended to use the latest version.
421 Each consecutive version generally has better handling of various edge
422 cases. You may notice on occasion that two consecutive runs of
423 ``clang-format`` over the same code may result in changes being made on the
424 second run. This is an unfortunate artifact of the tool. Please check with
425 the kernel style guide if in doubt.
426
427 One stylistic problem with the FRR codebase is the use of ``DEFUN`` macros
428 for defining CLI commands. ``clang-format`` will happily format these macro
429 invocations, but the result is often unsightly and difficult to read.
430 Consequently, FRR takes a more relaxed position with how these are
431 formatted. In general you should lean towards using the style exemplified in
432 the section on :ref:`command-line-interface`. Because ``clang-format``
433 mangles this style, there is a Python script named ``tools/indent.py`` that
434 wraps ``clang-format`` and handles ``DEFUN`` macros as well as some other
435 edge cases specific to FRR. If you are submitting a new file, it is
436 recommended to run that script over the new file, preferably after ensuring
437 that the latest stable release of ``clang-format`` is in your ``PATH``.
438
439 Documentation on ``clang-format`` and its various integrations is maintained
440 on the LLVM website.
441
442 https://clang.llvm.org/docs/ClangFormat.html
443
444checkpatch.sh
445 In the Linux kernel source tree there is a Perl script used to check
446 incoming patches for style errors. FRR uses an adapted version of this
447 script for the same purpose. It can be found at
2780ae0c 448 :file:`tools/checkpatch.sh`. This script takes a git-formatted diff or
281ba953
QY
449 patch file, applies it to a clean FRR tree, and inspects the result to catch
450 potential style errors. Running this script on your patches before
451 submission is highly recommended. The CI system runs this script as well and
452 will comment on the PR with the results if style errors are found.
453
454 It is run like this:
455
456 ::
457
458 checkpatch.sh <patch> <tree>
459
460 Reports are generated on ``stderr`` and the exit code indicates whether
461 issues were found (2, 1) or not (0).
462
463 Where ``<patch>`` is the path to the diff or patch file and ``<tree>`` is
464 the path to your FRR source tree. The tree should be on the branch that you
465 intend to submit the patch against. The script will make a best-effort
466 attempt to save the state of your working tree and index before applying the
467 patch, and to restore it when it is done, but it is still recommended that
468 you have a clean working tree as the script does perform a hard reset on
469 your tree during its run.
470
471 The script reports two classes of issues, namely WARNINGs and ERRORs. Please
472 pay attention to both of them. The script will generally report WARNINGs
473 where it cannot be 100% sure that a particular issue is real. In most cases
474 WARNINGs indicate an issue that needs to be fixed. Sometimes the script will
475 report false positives; these will be handled in code review on a
476 case-by-case basis. Since the script only looks at changed lines,
477 occasionally changing one part of a line can cause the script to report a
478 style issue already present on that line that is unrelated to the change.
479 When convenient it is preferred that these be cleaned up inline, but this is
480 not required.
481
482 If the script finds one or more WARNINGs it will exit with 1. If it finds
483 one or more ERRORs it will exit with 2.
484
485
486Please remember that while FRR provides these tools for your convenience,
487responsibility for properly formatting your code ultimately lies on the
488shoulders of the submitter. As such, it is recommended to double-check the
489results of these tools to avoid delays in merging your submission.
d1890d04
QY
490
491**Whitespace changes in untouched parts of the code are not acceptable
492in patches that change actual code.** To change/fix formatting issues,
493please create a separate patch that only does formatting changes and
494nothing else.
495
d1890d04
QY
496Kernel and BSD styles are documented externally:
497
498- https://www.kernel.org/doc/html/latest/process/coding-style.html
499- http://man.openbsd.org/style
500
501For GNU coding style, use ``indent`` with the following invocation:
502
503::
504
505 indent -nut -nfc1 file_for_submission.c
506
507Exceptions
508^^^^^^^^^^
509
510FRR project code comes from a variety of sources, so there are some
511stylistic exceptions in place. They are organized here by branch.
512
9de103f0
QY
513For ``master``
514""""""""""""""
d1890d04
QY
515
516BSD coding style applies to:
517
518- ``ldpd/``
519
520``babeld`` uses, approximately, the following style:
521
522- K&R style braces
523- Indents are 4 spaces
524- Function return types are on their own line
525
9de103f0
QY
526For ``stable/3.0`` and ``stable/2.0``
527"""""""""""""""""""""""""""""""""""""
d1890d04
QY
528
529GNU coding style apply to the following parts:
530
531- ``lib/``
532- ``zebra/``
533- ``bgpd/``
534- ``ospfd/``
535- ``ospf6d/``
536- ``isisd/``
537- ``ripd/``
538- ``ripngd/``
539- ``vtysh/``
540
541BSD coding style applies to:
542
543- ``ldpd/``
544
d1890d04 545Compile-time conditional code
9de103f0 546-----------------------------
d1890d04
QY
547
548Many users access FRR via binary packages from 3rd party sources;
549compile-time code puts inclusion/exclusion in the hands of the package
550maintainer. Please think very carefully before making code conditional
551at compile time, as it increases regression testing, maintenance
552burdens, and user confusion. In particular, please avoid gratuitous
553``--enable-…`` switches to the configure script - in general, code
554should be of high quality and in working condition, or it shouldn’t be
555in FRR at all.
556
557When code must be compile-time conditional, try have the compiler make
558it conditional rather than the C pre-processor so that it will still be
559checked by the compiler, even if disabled. For example,
560
561::
562
563 if (SOME_SYMBOL)
564 frobnicate();
565
566is preferred to
567
568::
569
570 #ifdef SOME_SYMBOL
571 frobnicate ();
572 #endif /* SOME_SYMBOL */
573
574Note that the former approach requires ensuring that ``SOME_SYMBOL``
575will be defined (watch your ``AC_DEFINE``\ s).
576
577Debug-guards in code
9de103f0 578--------------------
d1890d04
QY
579
580Debugging statements are an important methodology to allow developers to
581fix issues found in the code after it has been released. The caveat here
582is that the developer must remember that people will be using the code
583at scale and in ways that can be unexpected for the original
584implementor. As such debugs **MUST** be guarded in such a way that they
585can be turned off. FRR has the ability to turn on/off debugs from the
586CLI and it is expected that the developer will use this convention to
587allow control of their debugs.
588
9e001286
QY
589Static Analysis and Sanitizers
590------------------------------
591Clang/LLVM comes with a variety of tools that can be used to help find bugs in FRR.
592
593clang-analyze
594 This is a static analyzer that scans the source code looking for patterns
595 that are likely to be bugs. The tool is run automatically on pull requests
596 as part of CI and new static analysis warnings will be placed in the CI
597 results. FRR aims for absolutely zero static analysis errors. While the
598 project is not quite there, code that introduces new static analysis errors
599 is very unlikely to be merged.
600
601AddressSanitizer
602 This is an excellent tool that provides runtime instrumentation for
603 detecting memory errors. As part of CI FRR is built with this
604 instrumentation and run through a series of tests to look for any results.
605 Testing your own code with this tool before submission is encouraged. You
606 can enable it by passing::
607
608 --enable-address-sanitizer
609
610 to ``configure``.
611
612ThreadSanitizer
613 Similar to AddressSanitizer, this tool provides runtime instrumentation for
614 detecting data races. If you are working on or around multithreaded code,
615 extensive testing with this instrumtation enabled is *highly* recommended.
616 You can enable it by passing::
617
618 --enable-thread-sanitizer
619
620 to ``configure``.
621
622MemorySanitizer
623 Similar to AddressSanitizer, this tool provides runtime instrumentation for
624 detecting use of uninitialized heap memory. Testing your own code with this
625 tool before submission is encouraged. You can enable it by passing::
626
627 --enable-memory-sanitizer
628
629 to ``configure``.
630
631All of the above tools are available in the Clang/LLVM toolchain since 3.4.
632AddressSanitizer and ThreadSanitizer are available in recent versions of GCC,
633but are no longer actively maintained. MemorySanitizer is not available in GCC.
634
635Additionally, the FRR codebase is regularly scanned with Coverity.
636Unfortunately Coverity does not have the ability to handle scanning pull
637requests, but after code is merged it will send an email notifying project
638members with Coverity access of newly introduced defects.
639
d1890d04 640CLI changes
9de103f0 641-----------
d1890d04
QY
642
643CLI's are a complicated ugly beast. Additions or changes to the CLI
644should use a DEFUN to encapsulate one setting as much as is possible.
645Additionally as new DEFUN's are added to the system, documentation
646should be provided for the new commands.
647
648Backwards Compatibility
9de103f0 649-----------------------
d1890d04
QY
650
651As a general principle, changes to CLI and code in the lib/ directory
652should be made in a backwards compatible fashion. This means that
653changes that are purely stylistic in nature should be avoided, e.g.,
654renaming an existing macro or library function name without any
655functional change. When adding new parameters to common functions, it is
656also good to consider if this too should be done in a backward
657compatible fashion, e.g., by preserving the old form in addition to
658adding the new form.
659
660This is not to say that minor or even major functional changes to CLI
661and common code should be avoided, but rather that the benefit gained
662from a change should be weighed against the added cost/complexity to
663existing code. Also, that when making such changes, it is good to
664preserve compatibility when possible to do so without introducing
665maintenance overhead/cost. It is also important to keep in mind,
666existing code includes code that may reside in private repositories (and
667is yet to be submitted) or code that has yet to be migrated from Quagga
668to FRR.
669
670That said, compatibility measures can (and should) be removed when
671either:
672
673- they become a significant burden, e.g. when data structures change
674 and the compatibility measure would need a complex adaptation layer
675 or becomes flat-out impossible
676- some measure of time (dependent on the specific case) has passed, so
677 that the compatibility grace period is considered expired.
678
679In all cases, compatibility pieces should be marked with
680compiler/preprocessor annotations to print warnings at compile time,
681pointing to the appropriate update path. A ``-Werror`` build should fail
682if compatibility bits are used.
683
684Miscellaneous
9de103f0 685-------------
d1890d04
QY
686
687When in doubt, follow the guidelines in the Linux kernel style guide, or
688ask on the development mailing list / public Slack instance.
9de103f0
QY
689
690
691.. _documentation:
692
693Documentation
694=============
695
696FRR uses Sphinx+RST as its documentation system. The document you are currently
697reading was generated by Sphinx from RST source in
698:file:`doc/developer/workflow.rst`. The documentation is structured as follows:
699
700+-----------------------+--------------------------------------------------------------+
701| Directory | Contents |
702+=======================+==============================================================+
703| :file:`doc/user` | User documentation; configuration guides; protocol overviews |
704+-----------------------+--------------------------------------------------------------+
705| :file:`doc/developer` | Developer's documentation; API specs; datastructures; |
706| | architecture overviews; project management procedure |
707+-----------------------+--------------------------------------------------------------+
708| :file:`doc/manpages` | Source for manpages |
709+-----------------------+--------------------------------------------------------------+
710| :file:`doc/figures` | Images and diagrams |
711+-----------------------+--------------------------------------------------------------+
712
713Each of these directories, with the exception of :file:`doc/figures`, contains
714a Sphinx-generated Makefile and configuration script :file:`conf.py` used to
715set various document parameters. The makefile can be used for a variety of
716targets; invoke `make help` in any of these directories for a listing of
717available output formats. For convenience, there is a top-level
718:file:`Makefile.am` that has targets for PDF and HTML documentation for both
719developer and user documentation, respectively. That makefile is also
720responsible for building manual pages packed with distribution builds.
721
722Indent and styling should follow existing conventions:
723
724- 3 spaces for indents under directives
725- Cross references may contain only lowercase alphanumeric characters and
726 hyphens ('-')
727- Lines wrapped to 80 characters where possible
728
729Characters for header levels should follow Python documentation guide:
730
731- ``#`` with overline, for parts
732- ``*`` with overline, for chapters
733- ``=``, for sections
734- ``-``, for subsections
735- ``^``, for subsubsections
736- ``"``, for paragraphs
737
738After you have made your changes, please make sure that you can invoke
739``make latexpdf`` and ``make html`` with no warnings.
740
741The documentation is currently incomplete and needs love. If you find a broken
742cross-reference, figure, dead hyperlink, style issue or any other nastiness we
743gladly accept documentation patches.
744
c91e9b8f
QY
745To build the docs, please ensure you have installed a recent version of
746`Sphinx <http://www.sphinx-doc.org/en/stable/install.html>`_. If you want to
747build LaTeX or PDF docs, you will also need a full LaTeX distribution
748installed.
749
9de103f0
QY
750Code
751----
752
753FRR is a large and complex software project developed by many different people
754over a long period of time. Without adequate documentation, it can be
755exceedingly difficult to understand code segments, APIs and other interfaces.
756In the interest of keeping the project healthy and maintainable, you should
757make every effort to document your code so that other people can understand
758what it does without needing to closely read the code itself.
759
760Some specific guidelines that contributors should follow are:
761
762- Functions exposed in header files should have descriptive comments above
763 their signatures in the header file. At a minimum, a function comment should
764 contain information about the return value, parameters, and a general summary
765 of the function's purpose. Documentation on parameter values can be omitted
766 if it is (very) obvious what they are used for.
767
768 Function comments must follow the style for multiline comments laid out in
769 the kernel style guide.
770
771 Example:
772
773 .. code-block:: c
774
775 /*
776 * Determines whether or not a string is cool.
777 *
778 * @param text - the string to check for coolness
779 * @param is_clccfc - whether capslock is cruise control for cool
780 * @return 7 if the text is cool, 0 otherwise
781 */
782 int check_coolness(const char *text, bool is_clccfc);
783
784 The Javadoc-style annotations are not required, but you should still strive
785 to make it equally clear what parameters and return values are used for.
786
787- Static functions should have descriptive comments in the same form as above
788 if what they do is not immediately obvious. Use good engineering judgement
789 when deciding whether a comment is necessary. If you are unsure, document
790 your code.
791- Global variables, static or not, should have a comment describing their use.
792- **For new code in lib/, these guidelines are hard requirements.**
793
794If you make significant changes to portions of the codebase covered in the
795Developer's Manual, add a major subsystem or feature, or gain arcane mastery of
796some undocumented or poorly documented part of the codebase, please document
797your work so others can benefit. If you add a major feature or introduce a new
798API, please document the architecture and API to the best of your abilities in
799the Developer's Manual, using good judgement when choosing where to place it.
800
801Finally, if you come across some code that is undocumented and feel like
802going above and beyond, document it! We absolutely appreciate and accept
803patches that document previously undocumented code.
804
805User
806----
807
808If you are contributing code that adds significant user-visible functionality
809please document how to use it in :file:`doc/user`. Use good judgement when
810choosing where to place documentation. For example, instructions on how to use
811your implementation of a new BGP draft should go in the BGP chapter instead of
812being its own chapter. If you are adding a new protocol daemon, please create a
813new chapter.
814
815When documenting CLI please use a combination of the ``.. index::`` and
816``.. clicmd::`` directives. For example, the command :clicmd:`show pony` would
817be documented as follows:
818
819.. code-block:: rest
820
821 .. index:: show pony
822 .. clicmd:: show pony
823
824 Prints an ASCII pony. Example output:::
825
826 >>\.
827 /_ )`.
828 / _)`^)`. _.---. _
829 (_,' \ `^-)"" `.\
830 | | \
831 \ / |
832 / \ /.___.'\ (\ (_
833 < ,"|| \ |`. \`-'
834 \\ () )| )/
835 hjw |_>|> /_] //
836 /_] /_]
837
838When documented this way, CLI commands can be cross referenced with the
839``:clicmd:`` inline markup like so:
840
841.. code-block:: rest
842
843 :clicmd:`show pony`
844
845This is very helpful for users who want to quickly remind themselves what a
846particular command does.
847
848.. _GitHub: https://github.com/frrouting/frr
849.. _GitHub issues: https://github.com/frrouting/frr/issues