]> git.proxmox.com Git - mirror_frr.git/blame - COMMUNITY.md
- Solve the Coverity Scan PW.ASSIGN_WHERE_COMPARE_MEANT
[mirror_frr.git] / COMMUNITY.md
CommitLineData
f6ee5b52
DL
1# Developing for PROJECT (DRAFT)
2
4765f35e 3[TOC]
f6ee5b52 4
02fe6f86
DL
5## General note on this document
6
7This document is "descriptive/post-factual" in that it documents pratices that
8are in use; it is not "definitive/pre-factual" in prescribing practices.
9
10This means that when a procedure changes, it is agreed upon, then put into
11practice, and then documented here. If this document doesn't match reality,
12it's the document that needs to be updated, not reality.
13
14
f6ee5b52
DL
15## Git Structure
16
17The master Git for PROJECT resides on Github at
4765f35e 18[https://github.com/PROJECT/XXX](https://github.com/PROJECT/XXX)
f6ee5b52 19
9b7939d9
DL
20![git branches continually merging to the left from 3 lanes; float-right](doc/git_branches.svg
21"git branch mechanics")
22
02fe6f86 23There is one main branch for development and a release branch for each
f6ee5b52
DL
24major release.
25
02fe6f86 26New contributions are done against the head of the master branch. The CI
f6ee5b52 27systems will pick up the Github Pull Requests or the new patch from
02fe6f86 28Patchwork, run some basic build and functional tests.
f6ee5b52
DL
29
30For each major release (1.0, 1.1 etc) a new release branch is created based
31on the master.
32
02fe6f86
DL
33There was an attempt to use a "develop" branch automatically maintained by
34the CI system. This is not currently in active use, though the system is
35operational. If the "develop" branch is in active use and this paragraph
36is still here, this document obviously wasn't updated.
37
f6ee5b52
DL
38
39## Programming language, Tools and Libraries
40
41The core of PROJECT is written in C (gcc or clang supported). A few
42non-essential scripts are implemented in Perl and Python. PROJECT requires
43the following tools to build distribution packages: automake, autoconf,
44texinfo, libtool and gawk and various libraries (i.e. libpam and libjson-c).
45
46If your contribution requires a new library or other tool, then please
47highlight this in your description of the change. Also make sure it’s
48supported by all PROJECT platform OSes or provide a way to build without the
49library (potentially without the new feature) on the other platforms.
50
51Documentation should be written in Tex (.texi) or Markdown (.md) format with
52preference on Markdown.
53
54
55## Before Submitting your changes
56
4765f35e
DL
57* Format code (see [Code Styling requirements](#code-styling-requirements))
58* Verify and acknowledge license (see [License for contributions](#license-for-contributions))
f6ee5b52 59* Test building with various configurations:
4765f35e 60 * `buildtest.sh`
f6ee5b52 61* Verify building source distribution:
4765f35e 62 * `make dist` (and try rebuilding from the resulting tar file)
f6ee5b52 63* Run DejaGNU unit tests:
4765f35e 64 * `make test`
f6ee5b52
DL
65* Document Regression Runs and plans for continued maintenance of the feature
66
67### Changelog
68
69The changelog will be the base for the release notes. A changelog entry for
70your changes is usually not required and will be added based on your commit
71messages by the maintainers. However, you are free to include an update to
72the changelog with some better description. The changelog will be the base
73for the release notes.
74
75
76## Submitting Patches and Enhancements
77
78### License for contributions
79
80PROJECT is under a “GPLv2 or later” license. Any code submitted must be
81released under the same license (preferred) or any license which allows
82redistribution under this GPLv2 license (eg MIT License).
83
84### Signed-off required
85
86Submissions to PROJECT require a “Signed-off” in the patch or git commit.
87We follow the same standard as the Linux Kernel Development.
88
89> Developer's Certificate of Origin 1.1
90>
91> By making a contribution to this project, I certify that:
92>
93> (a) The contribution was created in whole or in part by me and I
94> have the right to submit it under the open source license
95> indicated in the file; or
96>
97> (b) The contribution is based upon previous work that, to the best
98> of my knowledge, is covered under an appropriate open source
99> license and I have the right under that license to submit that
100> work with modifications, whether created in whole or in part
101> by me, under the same open source license (unless I am
102> permitted to submit under a different license), as indicated
103> in the file; or
104>
105> (c) The contribution was provided directly to me by some other
106> person who certified (a), (b) or (c) and I have not modified
107> it.
108>
109> (d) I understand and agree that this project and the contribution
110> are public and that a record of the contribution (including all
111> personal information I submit with it, including my sign-off) is
112> maintained indefinitely and may be redistributed consistent with
113> this project or the open source license(s) involved.
114
115#### Using this Process
116
117We have the same requirements for using the signed-off-by process as the Linux
118kernel. In short, you need to include a signed-off-by tag in every patch:
119
120* `Signed-off-by:` this is a developer's certification that he or she has the
121right to submit the patch for inclusion into the project. It is an agreement to
122the Developer's Certificate of Origin (above). Code without a proper signoff
123cannot be merged into the mainline.
124
125Please make sure to have a `Signed-off-by:` in each commit/patch or the patches
126will be rejected until this is added.
127
128If you are unfamiliar with this process, you should read the [official policy
129at kernel.org](http://www.kernel.org/doc/Documentation/SubmittingPatches) and
130you might find this article about [participating in the Linux community on the
131Linux Foundation
132website](http://www.linuxfoundation.org/content/how-participate-linux-community-0)
133to be a helpful resource.
134
e0ba80e2
DS
135### Code submission - What do I submit my changes against?
136
137We've documented where we would like to have the different fixes applied at
138https://github.com/FRRouting/frr/wiki/Where-Do-I-create-a-Pull-Request-against%3F
139If you are unsure where your submission goes, look at that document or ask
140the question of a maintainer.
f6ee5b52 141
4765f35e 142### Code submission - Github Pull Request (Strongly Preferred)
f6ee5b52
DL
143
144Preferred submission of code is by using a Github Pull Request against the
145Develop branch. Code submitted by Pull Request will have an email generated to
146the PROJECT-devel mailing list for review and the submission will be
147automatically tested by one or more CI systems. Only after this test succeeds
148(and the submission is based on the head of the develop branch), then it will
149be automatically merged into the develop branch. In case of failed tests, it is
150up to the submitter to either amend the request with further commits or close,
151fix and create a new pull request.
152
153Further (manual) code review and discussion happens after the merge into the
154develop branch.
155
156
4765f35e 157### Code submission - Mailing Patch to PROJECT-Devel list
f6ee5b52
DL
158
159As an alternative submission, a patch can be mailed to the PROJECT-Devel
160mailing list. Preferred way to send the patch is using git send-mail. Patches
161received on the mailing list will be picked up by Patchwork and tested against
162the latest develop branch. After a further ACK by someone on the mailing list,
163the patch is then merged into the develop branch.
164
165Further (manual) code review and discussion happens after the merge into the
166develop branch.
167
4765f35e 168#### Sending patch to mailing list
f6ee5b52
DL
169
170The recommended way to send the patch (or series of NN patches) to the list is
171by using ‘git send-email’ as follows (assuming they are the most recent NN
172commit(s) in your git history:
173
174```
175git send-email -NN --annotate --to=XXX-Devel@XXX.org
176```
177
178If your commits do not already contain a `Signed-off-by` line, then use the
179following version to add it (after making sure to be able to agree to the
180Developer Certificate of Origin as outlined above):
181
182```
183git send-email -NN --annotate --signoff --to=XXX-Devel@XXX.org
184```
185
186Submitting multi-commit patches as a Github Pull Request is strongly encouraged
187and will allow your changes to merge faster
188
189
190## After submitting your changes
191
192* Watch for Continuous Integration (CI) Test results
193 * You should automatically receive an email with the test results within
194 less than 2 hrs of the submission. If you don’t get the email, then check
195 status on the github pull request (if submitted by pull request) or on
4765f35e
DL
196 Patchwork at
197 [https://patchwork.PROJECT.org](https://patchwork.PROJECT.org) (if
198 submitted as patch to mailing list).
f6ee5b52 199 * Please notify PROJECT-Devel mailing list if you think something doesn’t
4765f35e 200 work
f6ee5b52
DL
201* If the tests failed:
202 * In general, expect the community to ignore the submission until the tests
203 pass.
204 * It is up to you to fix and resubmit.
205 * This includes fixing existing dejagnu (“make test”) tests if your
206 changes broke or changed them.
207 * It also includes fixing distribution packages for the failing
208 platforms (ie if new libraries are required)
209 * Feel free to ask for help on PROJECT-Devel list
210 * Go back to the submission process and repeat until the tests pass.
211* If the tests pass:
212 * If the changes are done as a pull request, then they should be
213 automatically merged to the develop branch.
214 * Changes sent to mailing list require a manual ACK to be merged and should
215 be merged within 2 weeks. If you don’t see the merge or any
216 reason/discussion on PROJECT-Devel, then please ask.
217* Watch out for questions on the mailing list. At this time there will be a
218 manual code review and further (longer) tests by various community members.
219* Your submission is done once it is merged to the master branch. (which should
220 happen every few weeks from the develop branch)
221
222
223## Code Styling requirements
224
225### File header required for new files added
226
4765f35e
DL
227New files need to have a Copyright header (see [License for
228contributions](#license-for-contributions) above) added to the file. Preferred
229form of the header is as follows:
f6ee5b52
DL
230
231```
232/*
233 Title/Function of file
234 Copyright (C) 2016 Author’s Name
235
236 This program is free software; you can redistribute it and/or modify
237 it under the terms of the GNU General Public License as published by
238 the Free Software Foundation; either version 2 of the License, or
239 (at your option) any later version.
240
241 This program is distributed in the hope that it will be useful, but
242 WITHOUT ANY WARRANTY; without even the implied warranty of
243 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
244 General Public License for more details.
245
246 You should have received a copy of the GNU General Public License
247 along with this program; see the file COPYING; if not, write to the
248 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
249 MA 02110-1301 USA
250 */
4765f35e
DL
251
252#include <zebra.h>
f6ee5b52
DL
253```
254
255### Adding Copyright claims to already existing file
256
257When adding copyright claims for modifications to an existing file, please
258preface the claim with "Portions: " on a line before it and indent the
259"Copyright ..." string. If such a case already exists, add your indented claim
260immediately after. E.g.:
261
262```
263Portions:
264 Copyright (C) 2010 Entity A ....
265 Copyright (C) 2016 Your name [optional brief change description]
266```
267
268### Code styling / format
269
02fe6f86
DL
270Coding style standards in FRR vary depending on location. Pre-existing
271code uses GNU coding standards. New code may use Linux kernel coding style.
272
273GNU coding style apply to the following parts:
274
275* lib/
276* zebra/
277* bgpd/
278* ospfd/
279* ospf6d/
280* isisd/
281* ripd/
282* ripngd/
283* vtysh/
284
285Linux kernel coding style applies to:
286
287* nhrpd/
288* watchfrr/
289* pimd/
290* lib/{checksum,hook,imsg-buffer,imsg,libfrr,md5,module,monotime,queue}.[ch]
291
292BSD coding style applies to:
293
294* ldpd/
295
296**Whitespace changes in untouched parts of the code are not acceptable in
297patches that change actual code.** To change/fix formatting issues, please
298create a separate patch that only does formatting changes and nothing else.
299
300It is acceptable to rewrap entire files to Linux kernel style, but this
301**MUST** come as a separate patch that does nothing other than this
302reformatting.
303
304
305#### GNU style
306
307For GNU coding style, Indentation follows the result of invoking GNU indent:
f6ee5b52
DL
308
309```
310indent -nut -nfc1 file_for_submission.c
311```
312
02fe6f86
DL
313Originally, tabs were used instead of spaces, with tabs are every 8 columns.
314However, tab interoperability issues mean space characters are now preferred for
315new changes. We generally only clean up whitespace when code is unmaintainable
316due to whitespace issues, to minimise merging conflicts.
317
318
319#### Linux kernel & BSD style
320
321These styles are documented externally:
322
323* [https://www.kernel.org/doc/Documentation/CodingStyle](https://www.kernel.org/doc/Documentation/CodingStyle).
324* [http://man.openbsd.org/style](http://man.openbsd.org/style)
325
326They are relatively similar but differ in details.
327
328pimd deviates from Linux kernel style in using 2 spaces for indentation, with
329Tabs replacing 8 spaces, as well as adding a line break between `}` and `else`.
330It is acceptable to convert indentation in pimd/ to Linux kernel style, but
331please convert an entire file at a time. (Rationale: apart from 2-space
332indentation, the styles are sufficiently close to not upset when mixed.)
333
334Unlike GNU style, these styles use tabs, not spaces.
335
f6ee5b52 336
f6ee5b52
DL
337### Compile-Time conditional code
338
339Many users access PROJECT via binary packages from 3rd party sources;
340compile-time code puts inclusion/exclusion in the hands of the package
341maintainer. Please think very carefully before making code conditional at
342compile time, as it increases regression testing, maintenance burdens, and user
343confusion. In particular, please avoid gratuitous --enable-… switches to the
344configure script - typically code should be good enough to be in PROJECT, or it
345shouldn’t be there at all.
346
347When code must be compile-time conditional, try have the compiler make it
348conditional rather than the C pre-processor - so that it will still be checked
349by the compiler, even if disabled. I.e. this:
350
351```
352if (SOME_SYMBOL)
353 frobnicate();
354```
355
356rather than
357
358```
359#ifdef SOME_SYMBOL
360frobnicate ();
361#endif /* SOME_SYMBOL */
362```
363
364Note that the former approach requires ensuring that `SOME_SYMBOL` will be
365defined (watch your `AC_DEFINE`s).
7ce0cb3c
DS
366
367### Debug-Guards in code
368
369Debugs are an important methodology to allow developers to fix issues
370found in the code after it has been released. The caveat here is
371that the developer must remember that people will be using the code
372at scale and in ways that can be unexpected for the original implementor.
373As such debugs MUST be guarded in such a way that they can be turned off.
374This PROJECT has the ability to turn on/off debugs from the CLI and it is
375expected that the developer will use this convention to allow control
19c7f43f
DS
376of their debugs.
377
378### CLI-Changes
379
380CLI's are a complicated ugly beast. Additions or changes to the CLI
381should use a DEFUN to encapsulate one setting as much as is possible.
382Additionally as new DEFUN's are added to the system, documentation
02fe6f86 383should be provided for the new commands.