summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COMMUNITY.md446
-rw-r--r--babeld/babel_main.c2
-rw-r--r--babeld/babel_zebra.c92
-rw-r--r--babeld/babeld.c17
-rw-r--r--babeld/babeld.h1
-rw-r--r--bgpd/bgp_aspath.c20
-rw-r--r--bgpd/bgp_attr.c155
-rw-r--r--bgpd/bgp_attr.h2
-rw-r--r--bgpd/bgp_bfd.c5
-rw-r--r--bgpd/bgp_btoa.c4
-rw-r--r--bgpd/bgp_damp.c15
-rw-r--r--bgpd/bgp_dump.c5
-rw-r--r--bgpd/bgp_evpn.c14
-rw-r--r--bgpd/bgp_evpn_vty.c9
-rw-r--r--bgpd/bgp_fsm.c5
-rw-r--r--bgpd/bgp_label.c2
-rw-r--r--bgpd/bgp_main.c4
-rw-r--r--bgpd/bgp_mpath.c23
-rw-r--r--bgpd/bgp_mplsvpn.c7
-rw-r--r--bgpd/bgp_network.c15
-rw-r--r--bgpd/bgp_open.c47
-rw-r--r--bgpd/bgp_packet.c5
-rw-r--r--bgpd/bgp_route.c112
-rw-r--r--bgpd/bgp_route.h6
-rw-r--r--bgpd/bgp_routemap.c95
-rw-r--r--bgpd/bgp_snmp.c2
-rw-r--r--bgpd/bgp_updgrp.c4
-rw-r--r--bgpd/bgp_updgrp.h1
-rw-r--r--bgpd/bgp_updgrp_adv.c7
-rw-r--r--bgpd/bgp_updgrp_packet.c17
-rw-r--r--bgpd/bgp_vpn.c7
-rw-r--r--bgpd/bgp_vty.c145
-rw-r--r--bgpd/bgp_zebra.c49
-rw-r--r--bgpd/bgpd.c58
-rw-r--r--bgpd/bgpd.h9
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c63
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.h4
-rw-r--r--bgpd/rfapi/rfapi.c13
-rw-r--r--bgpd/rfapi/rfapi_import.c83
-rw-r--r--bgpd/rfapi/rfapi_monitor.c9
-rw-r--r--bgpd/rfapi/rfapi_private.h2
-rw-r--r--bgpd/rfapi/rfapi_rib.c22
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c2
-rw-r--r--bgpd/rfapi/vnc_zebra.c10
-rw-r--r--doc/Building_FRR_on_CentOS6.md3
-rw-r--r--eigrpd/eigrp_interface.c5
-rw-r--r--eigrpd/eigrp_main.c11
-rw-r--r--eigrpd/eigrp_packet.c16
-rw-r--r--eigrpd/eigrp_routemap.c31
-rw-r--r--eigrpd/eigrp_structs.h5
-rw-r--r--eigrpd/eigrp_update.c12
-rw-r--r--eigrpd/eigrp_vty.c17
-rw-r--r--git-reindent-branch.py72
-rw-r--r--isisd/dict.c2
-rw-r--r--isisd/isis_adjacency.c7
-rw-r--r--isisd/isis_circuit.c4
-rw-r--r--isisd/isis_lsp.c57
-rw-r--r--isisd/isis_pdu.c9
-rw-r--r--isisd/isis_pfpacket.c21
-rw-r--r--isisd/isis_redist.c6
-rw-r--r--isisd/isis_spf.c27
-rw-r--r--isisd/isis_tlv.h2
-rw-r--r--isisd/isisd.h2
-rw-r--r--ldpd/.gitignore1
-rw-r--r--ldpd/Makefile.am4
-rw-r--r--ldpd/lde.c6
-rw-r--r--ldpd/ldp_debug.c18
-rw-r--r--ldpd/ldp_vty.h78
-rw-r--r--ldpd/ldp_vty_cmds.c745
-rw-r--r--ldpd/ldp_vty_conf.c217
-rw-r--r--ldpd/ldp_vty_exec.c34
-rw-r--r--lib/checksum.c2
-rw-r--r--lib/command.c133
-rw-r--r--lib/command.h6
-rw-r--r--lib/command_py.c2
-rw-r--r--lib/getopt.c5
-rw-r--r--lib/hash.c21
-rw-r--r--lib/hash.h3
-rw-r--r--lib/hook.h3
-rw-r--r--lib/if.h2
-rw-r--r--lib/imsg-buffer.c105
-rw-r--r--lib/imsg.c117
-rw-r--r--lib/imsg.h110
-rw-r--r--lib/log.c11
-rw-r--r--lib/log.h4
-rw-r--r--lib/md5.c8
-rw-r--r--lib/mpls.h2
-rw-r--r--lib/nexthop.c20
-rw-r--r--lib/openbsd-tree.c150
-rw-r--r--lib/openbsd-tree.h811
-rw-r--r--lib/plist.c5
-rw-r--r--lib/prefix.c5
-rw-r--r--lib/prefix.h6
-rw-r--r--lib/privs.c222
-rw-r--r--lib/routemap.c10
-rw-r--r--lib/sigevent.c10
-rw-r--r--lib/smux.c77
-rw-r--r--lib/sockopt.c10
-rw-r--r--lib/vty.c4
-rw-r--r--lib/zassert.h7
-rw-r--r--lib/zclient.c5
-rw-r--r--ospf6d/ospf6_asbr.c17
-rw-r--r--ospf6d/ospf6_interface.c7
-rw-r--r--ospf6d/ospf6_intra.c7
-rw-r--r--ospf6d/ospf6_lsa.c2
-rw-r--r--ospf6d/ospf6_message.c8
-rw-r--r--ospf6d/ospf6_neighbor.c6
-rw-r--r--ospf6d/ospf6_route.c4
-rw-r--r--ospf6d/ospf6_zebra.c3
-rw-r--r--ospfd/ospf_abr.c25
-rw-r--r--ospfd/ospf_api.c72
-rw-r--r--ospfd/ospf_apiserver.c8
-rw-r--r--ospfd/ospf_flood.c4
-rw-r--r--ospfd/ospf_ia.c8
-rw-r--r--ospfd/ospf_interface.c5
-rw-r--r--ospfd/ospf_lsa.c11
-rw-r--r--ospfd/ospf_main.c4
-rw-r--r--ospfd/ospf_neighbor.c5
-rw-r--r--ospfd/ospf_opaque.c33
-rw-r--r--ospfd/ospf_packet.c37
-rw-r--r--ospfd/ospf_route.c10
-rw-r--r--ospfd/ospf_routemap.c16
-rw-r--r--ospfd/ospf_snmp.c7
-rw-r--r--ospfd/ospf_vty.c77
-rw-r--r--pimd/pim_assert.c6
-rw-r--r--pimd/pim_cmd.c148
-rw-r--r--pimd/pim_iface.h7
-rw-r--r--pimd/pim_ifchannel.c5
-rw-r--r--pimd/pim_main.c5
-rw-r--r--pimd/pim_msdp.c8
-rw-r--r--pimd/pim_msdp.h12
-rw-r--r--pimd/pim_register.c5
-rw-r--r--pimd/pim_rp.c5
-rw-r--r--pimd/pim_zlookup.c5
-rw-r--r--qpb/qpb_allocator.h1
-rwxr-xr-xredhat/frr.init12
-rw-r--r--ripd/rip_debug.c6
-rw-r--r--ripd/rip_interface.c4
-rw-r--r--ripd/rip_routemap.c8
-rw-r--r--ripd/rip_zebra.c3
-rw-r--r--ripd/ripd.c5
-rw-r--r--ripngd/ripng_debug.c6
-rw-r--r--ripngd/ripng_routemap.c8
-rw-r--r--ripngd/ripng_zebra.c3
-rw-r--r--ripngd/ripngd.c9
-rw-r--r--tests/bgpd/test_aspath.c136
-rw-r--r--tests/bgpd/test_capability.c762
-rw-r--r--tests/bgpd/test_mp_attr.c158
-rw-r--r--tests/bgpd/test_mpath.c3
-rw-r--r--tests/lib/cli/test_commands.c12
-rw-r--r--tests/lib/test_checksum.c4
-rw-r--r--tests/lib/test_privs.c5
-rw-r--r--tests/lib/test_timer_correctness.c4
-rw-r--r--tools/start-stop-daemon.c13
-rw-r--r--vtysh/vtysh.c194
-rw-r--r--vtysh/vtysh.h2
-rw-r--r--zebra/.gitignore1
-rw-r--r--zebra/Makefile.am2
-rw-r--r--zebra/debug.c135
-rw-r--r--zebra/if_ioctl_solaris.c2
-rw-r--r--zebra/interface.c6
-rw-r--r--zebra/interface.h9
-rw-r--r--zebra/kernel_netlink.c3
-rw-r--r--zebra/kernel_socket.c7
-rw-r--r--zebra/main.c32
-rw-r--r--zebra/rtadv.c7
-rw-r--r--zebra/zebra_l2.h1
-rw-r--r--zebra/zebra_mpls.c12
-rw-r--r--zebra/zebra_mpls_vty.c599
-rw-r--r--zebra/zebra_ptm.c5
-rw-r--r--zebra/zebra_rib.c77
-rw-r--r--zebra/zebra_rnh.h8
-rw-r--r--zebra/zebra_routemap.c9
-rw-r--r--zebra/zebra_static.c42
-rw-r--r--zebra/zebra_static.h18
-rw-r--r--zebra/zebra_vty.c1006
-rw-r--r--zebra/zebra_vxlan.c16
-rw-r--r--zebra/zserv.c10
178 files changed, 3574 insertions, 5276 deletions
diff --git a/COMMUNITY.md b/COMMUNITY.md
index 8ab6a624ee..bbc5bb6d10 100644
--- a/COMMUNITY.md
+++ b/COMMUNITY.md
@@ -1,4 +1,7 @@
-# Developing for PROJECT (DRAFT)
+Developing for FRRouting
+=========================
+
+## Table of Contents
[TOC]
@@ -14,55 +17,57 @@ it's the document that needs to be updated, not reality.
## Git Structure
-The master Git for PROJECT resides on Github at
-[https://github.com/PROJECT/XXX](https://github.com/PROJECT/XXX)
+The master Git for FRRouting resides on Github at
+[https://github.com/frrouting/frr](https://github.com/FRRouting/frr)
![git branches continually merging to the left from 3 lanes; float-right](doc/git_branches.svg
"git branch mechanics")
-There is one main branch for development and a release branch for each
-major release.
+There is one main branch for development and a release branch for each major
+release.
New contributions are done against the head of the master branch. The CI
-systems will pick up the Github Pull Requests or the new patch from
-Patchwork, run some basic build and functional tests.
+systems will pick up the Github Pull Requests or the new patch from Patchwork,
+run some basic build and functional tests.
-For each major release (1.0, 1.1 etc) a new release branch is created based
-on the master.
+For each major release (1.0, 1.1 etc) a new release branch is created based on
+the master.
-There was an attempt to use a "develop" branch automatically maintained by
-the CI system. This is not currently in active use, though the system is
-operational. If the "develop" branch is in active use and this paragraph
-is still here, this document obviously wasn't updated.
+There was an attempt to use a "develop" branch automatically maintained by the
+CI system. This is not currently in active use, though the system is
+operational. If the "develop" branch is in active use and this paragraph is
+still here, this document obviously wasn't updated.
## Programming language, Tools and Libraries
-The core of PROJECT is written in C (gcc or clang supported). A few
-non-essential scripts are implemented in Perl and Python. PROJECT requires
-the following tools to build distribution packages: automake, autoconf,
-texinfo, libtool and gawk and various libraries (i.e. libpam and libjson-c).
+The core of FRRouting is written in C (gcc or clang supported) and makes use of
+GNU compiler extensions. A few non-essential scripts are implemented in Perl
+and Python. FRRouting requires the following tools to build distribution
+packages: automake, autoconf, texinfo, libtool and gawk and various libraries
+(i.e. libpam and libjson-c).
If your contribution requires a new library or other tool, then please
-highlight this in your description of the change. Also make sure it’s
-supported by all PROJECT platform OSes or provide a way to build without the
-library (potentially without the new feature) on the other platforms.
+highlight this in your description of the change. Also make sure it’s supported
+by all FRRouting platform OSes or provide a way to build without the library
+(potentially without the new feature) on the other platforms.
-Documentation should be written in Tex (.texi) or Markdown (.md) format with
-preference on Markdown.
+Documentation should be written in Tex (.texi) or Markdown (.md) format with a
+preference for Markdown.
-## Before Submitting your changes
+## Mailing lists
+
+Italicized lists are private.
+
+| Topic | List |
+|--------------------------------|------------------------------|
+| Development | dev@lists.frrouting.org |
+| Users & Operators | frog@lists.frrouting.org |
+| Announcements | announce@lists.frrouting.org |
+| _Security_ | security@lists.frrouting.org |
+| _Technical Steering Committee_ | tsc@lists.frrouting.org |
-* Format code (see [Code Styling requirements](#code-styling-requirements))
-* Verify and acknowledge license (see [License for contributions](#license-for-contributions))
-* Test building with various configurations:
- * `buildtest.sh`
-* Verify building source distribution:
- * `make dist` (and try rebuilding from the resulting tar file)
-* Run DejaGNU unit tests:
- * `make test`
-* Document Regression Runs and plans for continued maintenance of the feature
### Changelog
@@ -75,16 +80,45 @@ for the release notes.
## Submitting Patches and Enhancements
+### Pre-submission Checklist
+
+* Format code (see [Coding style requirements](#coding-style-requirements))
+* Verify and acknowledge license (see [License for contributions](#license-for-contributions))
+* Ensure you have properly signed off (see [Signing Off](#signing-off))
+* Test building with various configurations:
+ * `buildtest.sh`
+* Verify building source distribution:
+ * `make dist` (and try rebuilding from the resulting tar file)
+* Run unit tests:
+ * `make test`
+* Document Regression Runs and plans for continued maintenance of the feature
+
### License for contributions
-PROJECT is under a “GPLv2 or later” license. Any code submitted must be
+FRRouting is under a “GPLv2 or later” license. Any code submitted must be
released under the same license (preferred) or any license which allows
redistribution under this GPLv2 license (eg MIT License).
-### Signed-off required
+### Signing Off
-Submissions to PROJECT require a “Signed-off” in the patch or git commit.
-We follow the same standard as the Linux Kernel Development.
+Code submitted to FRRouting must be signed off. We have the same requirements
+for using the signed-off-by process as the Linux kernel. In short, you must
+include a signed-off-by tag in every patch.
+
+`Signed-off-by:` this is a developer's certification that he or she has the
+right to submit the patch for inclusion into the project. It is an agreement to
+the Developer's Certificate of Origin (below). Code without a proper signoff
+can not and will not be merged.
+
+If you are unfamiliar with this process, you should read the [official policy
+at kernel.org](http://www.kernel.org/doc/Documentation/SubmittingPatches) and
+you might find this article about [participating in the Linux community on the
+Linux Foundation
+website](http://www.linuxfoundation.org/content/how-participate-linux-community-0)
+to be a helpful resource.
+
+In short, when you sign off on a commit, you assert your agreement to all of
+the following:
> Developer's Certificate of Origin 1.1
>
@@ -112,79 +146,46 @@ We follow the same standard as the Linux Kernel Development.
> maintained indefinitely and may be redistributed consistent with
> this project or the open source license(s) involved.
-#### Using this Process
-
-We have the same requirements for using the signed-off-by process as the Linux
-kernel. In short, you need to include a signed-off-by tag in every patch:
-
-* `Signed-off-by:` this is a developer's certification that he or she has the
-right to submit the patch for inclusion into the project. It is an agreement to
-the Developer's Certificate of Origin (above). Code without a proper signoff
-cannot be merged into the mainline.
-
-Please make sure to have a `Signed-off-by:` in each commit/patch or the patches
-will be rejected until this is added.
-
-If you are unfamiliar with this process, you should read the [official policy
-at kernel.org](http://www.kernel.org/doc/Documentation/SubmittingPatches) and
-you might find this article about [participating in the Linux community on the
-Linux Foundation
-website](http://www.linuxfoundation.org/content/how-participate-linux-community-0)
-to be a helpful resource.
-
-### Code submission - What do I submit my changes against?
+### What do I submit my changes against?
We've documented where we would like to have the different fixes applied at
https://github.com/FRRouting/frr/wiki/Where-Do-I-create-a-Pull-Request-against%3F
-If you are unsure where your submission goes, look at that document or ask
-the question of a maintainer.
+If you are unsure where your submission goes, look at that document or ask a
+project maintainer.
-### Code submission - Github Pull Request (Strongly Preferred)
+### Github pull requests
-Preferred submission of code is by using a Github Pull Request against the
-Develop branch. Code submitted by Pull Request will have an email generated to
-the PROJECT-devel mailing list for review and the submission will be
-automatically tested by one or more CI systems. Only after this test succeeds
-(and the submission is based on the head of the develop branch), then it will
-be automatically merged into the develop branch. In case of failed tests, it is
-up to the submitter to either amend the request with further commits or close,
-fix and create a new pull request.
+The preferred method of submitting changes is a Github pull request. Code
+submitted by pull request will be automatically tested by one or more CI
+systems. Once the automated tests succeed, other developers will review your
+code for quality and correctness. After any concerns are resolved, your code
+will be merged into the branch it was submitted against.
-Further (manual) code review and discussion happens after the merge into the
-develop branch.
+### Patch submission via mailing list
-
-### Code submission - Mailing Patch to PROJECT-Devel list
-
-As an alternative submission, a patch can be mailed to the PROJECT-Devel
-mailing list. Preferred way to send the patch is using git send-mail. Patches
-received on the mailing list will be picked up by Patchwork and tested against
-the latest develop branch. After a further ACK by someone on the mailing list,
-the patch is then merged into the develop branch.
-
-Further (manual) code review and discussion happens after the merge into the
-develop branch.
-
-#### Sending patch to mailing list
+As an alternative submission method, a patch can be mailed to the development
+mailing list. Patches received on the mailing list will be picked up by
+Patchwork and tested against the latest development branch.
The recommended way to send the patch (or series of NN patches) to the list is
-by using ‘git send-email’ as follows (assuming they are the most recent NN
+by using `git send-email` as follows (assuming they are the N most recent
commit(s) in your git history:
```
-git send-email -NN --annotate --to=XXX-Devel@XXX.org
+git send-email -NN --annotate --to=dev@lists.frrouting.org
```
If your commits do not already contain a `Signed-off-by` line, then use the
-following version to add it (after making sure to be able to agree to the
-Developer Certificate of Origin as outlined above):
+following command to add it (after making sure you agree to the Developer
+Certificate of Origin as outlined above):
```
-git send-email -NN --annotate --signoff --to=XXX-Devel@XXX.org
+git send-email -NN --annotate --signoff --to=dev@lists.frrouting.org
```
-Submitting multi-commit patches as a Github Pull Request is strongly encouraged
-and will allow your changes to merge faster
+Submitting multi-commit patches as a Github pull request is **strongly
+encouraged** and increases the probability of your patch getting reviewed and
+merged in a timely manner.
## After submitting your changes
@@ -194,35 +195,34 @@ and will allow your changes to merge faster
less than 2 hrs of the submission. If you don’t get the email, then check
status on the github pull request (if submitted by pull request) or on
Patchwork at
- [https://patchwork.PROJECT.org](https://patchwork.PROJECT.org) (if
+ [https://patchwork.frrouting.org](https://patchwork.frrouting.org) (if
submitted as patch to mailing list).
- * Please notify PROJECT-Devel mailing list if you think something doesn’t
- work
+ * Please notify the development mailing list if you think something doesn’t
+ work.
* If the tests failed:
* In general, expect the community to ignore the submission until the tests
pass.
* It is up to you to fix and resubmit.
- * This includes fixing existing dejagnu (“make test”) tests if your
+ * This includes fixing existing unit (“make test”) tests if your
changes broke or changed them.
* It also includes fixing distribution packages for the failing
- platforms (ie if new libraries are required)
- * Feel free to ask for help on PROJECT-Devel list
+ platforms (ie if new libraries are required).
+ * Feel free to ask for help on the development list.
* Go back to the submission process and repeat until the tests pass.
* If the tests pass:
- * If the changes are done as a pull request, then they should be
- automatically merged to the develop branch.
- * Changes sent to mailing list require a manual ACK to be merged and should
- be merged within 2 weeks. If you don’t see the merge or any
- reason/discussion on PROJECT-Devel, then please ask.
+ * Wait for reviewers. Someone will review your code or be assigned to
+ review your code.
+ * Respond to any comments or concerns the reviewer has.
+ * After all comments and concerns are addressed, expect your patch to be
+ merged.
* Watch out for questions on the mailing list. At this time there will be a
manual code review and further (longer) tests by various community members.
-* Your submission is done once it is merged to the master branch. (which should
- happen every few weeks from the develop branch)
+* Your submission is done once it is merged to the master branch.
-## Code Styling requirements
+## Developer's Guidelines
-### File header required for new files added
+### Source file header
New files need to have a Copyright header (see [License for
contributions](#license-for-contributions) above) added to the file. Preferred
@@ -251,7 +251,7 @@ form of the header is as follows:
#include <zebra.h>
```
-### Adding Copyright claims to already existing file
+### Adding copyright claims to existing files
When adding copyright claims for modifications to an existing file, please
preface the claim with "Portions: " on a line before it and indent the
@@ -264,95 +264,147 @@ Portions:
Copyright (C) 2016 Your name [optional brief change description]
```
-### Code styling / format
+### Code formatting
-Coding style standards in FRR vary depending on location. Pre-existing
-code uses GNU coding standards. New code may use Linux kernel coding style.
+FRR uses Linux kernel style except where noted below. Code which does not
+comply with these style guidelines will not be accepted.
-GNU coding style apply to the following parts:
+To assist with compliance, in the project root there is a .clang-format
+configuration file which can be used with the `clang-format` tool from the LLVM
+project. In the `tools/` directory there is a Python script named `indent.py`
+that wraps clang-format and handles some edge cases specific to FRR. If you are
+submitting a new file, it is recommended to run that script over the new file
+after ensuring that the latest stable release of `clang-format` is in your
+PATH.
-* lib/
-* zebra/
-* bgpd/
-* ospfd/
-* ospf6d/
-* isisd/
-* ripd/
-* ripngd/
-* vtysh/
+**Whitespace changes in untouched parts of the code are not acceptable in
+patches that change actual code.** To change/fix formatting issues, please
+create a separate patch that only does formatting changes and nothing else.
-Linux kernel coding style applies to:
+#### Style documentation
+Kernel and BSD styles are documented externally:
-* nhrpd/
-* watchfrr/
-* pimd/
-* lib/{checksum,hook,imsg-buffer,imsg,libfrr,md5,module,monotime,queue}.[ch]
+* [https://www.kernel.org/doc/html/latest/process/coding-style.html](https://www.kernel.org/doc/html/latest/process/coding-style.html)
+* [http://man.openbsd.org/style](http://man.openbsd.org/style)
+
+For GNU coding style, use `indent` with the following invocation:
+
+```
+indent -nut -nfc1 file_for_submission.c
+```
+
+#### Exceptions
+
+FRR project code comes from a variety of sources, so there are some stylistic
+exceptions in place. They are organized here by branch.
+
+**For `master`:**
BSD coding style applies to:
-* ldpd/
+* `ldpd/`
-**Whitespace changes in untouched parts of the code are not acceptable in
-patches that change actual code.** To change/fix formatting issues, please
-create a separate patch that only does formatting changes and nothing else.
+`babeld` uses, approximately, the following style:
-It is acceptable to rewrap entire files to Linux kernel style, but this
-**MUST** come as a separate patch that does nothing other than this
-reformatting.
+* K&R style braces
+* Indents are 4 spaces
+* Function return types are on their own line
-#### GNU style
+**For `stable/3.0` and `stable/2.0`:**
-For GNU coding style, Indentation follows the result of invoking GNU indent:
+GNU coding style apply to the following parts:
-```
-indent -nut -nfc1 file_for_submission.c
-```
+* `lib/`
+* `zebra/`
+* `bgpd/`
+* `ospfd/`
+* `ospf6d/`
+* `isisd/`
+* `ripd/`
+* `ripngd/`
+* `vtysh/`
-Originally, tabs were used instead of spaces, with tabs are every 8 columns.
-However, tab interoperability issues mean space characters are now preferred for
-new changes. We generally only clean up whitespace when code is unmaintainable
-due to whitespace issues, to minimise merging conflicts.
+BSD coding style applies to:
+* `ldpd/`
-#### Linux kernel & BSD style
-These styles are documented externally:
+### Documentation
-* [https://www.kernel.org/doc/Documentation/CodingStyle](https://www.kernel.org/doc/Documentation/CodingStyle).
-* [http://man.openbsd.org/style](http://man.openbsd.org/style)
+FRRouting is a large and complex software project developed by many different
+people over a long period of time. Without adequate documentation, it can be
+exceedingly difficult to understand code segments, APIs and other interfaces.
+In the interest of keeping the project healthy and maintainable, you should
+make every effort to document your code so that other people can understand
+what it does without needing to closely read the code itself.
+
+Some specific guidelines that contributors should follow are:
+
+* Functions exposed in header files should have descriptive comments above
+ their signatures in the header file. At a minimum, a function comment should
+ contain information about the return value, parameters, and a general summary
+ of the function's purpose. Documentation on parameter values can be omitted
+ if it is (very) obvious what they are used for.
+
+ Function comments must follow the style for multiline comments laid out in
+ the kernel style guide.
+
+Example:
+
+```
+/*
+ * Determines whether or not a string is cool.
+ *
+ * @param text - the string to check for coolness
+ * @param is_clccfc - whether capslock is cruise control for cool
+ * @return 7 if the text is cool, 0 otherwise
+ */
+int check_coolness(const char *text, bool is_clccfc);
+```
-They are relatively similar but differ in details.
+The Javadoc-style annotations are not required, but you should still strive to
+make it equally clear what parameters and return values are used for.
-pimd deviates from Linux kernel style in using 2 spaces for indentation, with
-Tabs replacing 8 spaces, as well as adding a line break between `}` and `else`.
-It is acceptable to convert indentation in pimd/ to Linux kernel style, but
-please convert an entire file at a time. (Rationale: apart from 2-space
-indentation, the styles are sufficiently close to not upset when mixed.)
+* Static functions should have descriptive comments in the same form as above
+ if what they do is not immediately obvious. Use good engineering judgement
+ when deciding whether a comment is necessary. If you are unsure, document
+ your code.
-Unlike GNU style, these styles use tabs, not spaces.
+* Global variables, static or not, should have a comment describing their use.
+* **For new code in `lib/`, these guidelines are hard requirements.**
-### Compile-Time conditional code
-Many users access PROJECT via binary packages from 3rd party sources;
-compile-time code puts inclusion/exclusion in the hands of the package
-maintainer. Please think very carefully before making code conditional at
-compile time, as it increases regression testing, maintenance burdens, and user
-confusion. In particular, please avoid gratuitous --enable-… switches to the
-configure script - typically code should be good enough to be in PROJECT, or it
-shouldn’t be there at all.
+If you are contributing code that adds significant user-visible functionality
+or introduces a new API, please document it in `doc/`. Markdown and LaTeX are
+acceptable formats, although Markdown is currently preferred for new
+documentation. This may change in the near future.
+
+Finally, if you come across some code that is undocumented and feel like going
+above and beyond, document it! We absolutely appreciate and accept patches that
+document previously undocumented code.
+
+### Compile-time conditional code
+
+Many users access FRR via binary packages from 3rd party sources; compile-time
+code puts inclusion/exclusion in the hands of the package maintainer. Please
+think very carefully before making code conditional at compile time, as it
+increases regression testing, maintenance burdens, and user confusion. In
+particular, please avoid gratuitous `--enable-…` switches to the configure
+script - in general, code should be of high quality and in working condition,
+or it shouldn’t be in FRR at all.
When code must be compile-time conditional, try have the compiler make it
-conditional rather than the C pre-processor - so that it will still be checked
-by the compiler, even if disabled. I.e. this:
+conditional rather than the C pre-processor so that it will still be checked by
+the compiler, even if disabled. For example,
```
if (SOME_SYMBOL)
frobnicate();
```
-rather than
+is preferred to
```
#ifdef SOME_SYMBOL
@@ -363,53 +415,55 @@ frobnicate ();
Note that the former approach requires ensuring that `SOME_SYMBOL` will be
defined (watch your `AC_DEFINE`s).
-### Debug-Guards in code
+### Debug-guards in code
-Debugs are an important methodology to allow developers to fix issues
-found in the code after it has been released. The caveat here is
-that the developer must remember that people will be using the code
-at scale and in ways that can be unexpected for the original implementor.
-As such debugs MUST be guarded in such a way that they can be turned off.
-This PROJECT has the ability to turn on/off debugs from the CLI and it is
-expected that the developer will use this convention to allow control
-of their debugs.
+Debugging statements are an important methodology to allow developers to fix
+issues found in the code after it has been released. The caveat here is that
+the developer must remember that people will be using the code at scale and in
+ways that can be unexpected for the original implementor. As such debugs
+**MUST** be guarded in such a way that they can be turned off. FRR has the
+ability to turn on/off debugs from the CLI and it is expected that the
+developer will use this convention to allow control of their debugs.
-### CLI-Changes
+### CLI changes
-CLI's are a complicated ugly beast. Additions or changes to the CLI
-should use a DEFUN to encapsulate one setting as much as is possible.
-Additionally as new DEFUN's are added to the system, documentation
-should be provided for the new commands.
+CLI's are a complicated ugly beast. Additions or changes to the CLI should use
+a DEFUN to encapsulate one setting as much as is possible. Additionally as new
+DEFUN's are added to the system, documentation should be provided for the new
+commands.
### Backwards Compatibility
-As a general principle, changes to CLI and code in the lib/ directory
-should be made in a backwards compatible fashion. This means that
-changes that are purely stylistic in nature should be avoided, e.g.,
-renaming an existing macro or library function name without any
-functional change. When adding new parameters to common functions, it is
-also good to consider if this too should be done in a backward
-compatible fashion, e.g., by preserving the old form in addition to
+As a general principle, changes to CLI and code in the lib/ directory should be
+made in a backwards compatible fashion. This means that changes that are purely
+stylistic in nature should be avoided, e.g., renaming an existing macro or
+library function name without any functional change. When adding new parameters
+to common functions, it is also good to consider if this too should be done in
+a backward compatible fashion, e.g., by preserving the old form in addition to
adding the new form.
-This is not to say that minor or even major functional changes to CLI
-and common code should be avoided, but rather that the benefit gained
-from a change should be weighed against the added cost/complexity to
-existing code. Also, that when making such changes, it is good to
-preserve compatibility when possible to do so without introducing
-maintenance overhead/cost. It is also important to keep in mind,
-existing code includes code that may reside in private repositories (and
-is yet to be submitted) or code that has yet to be migrated from Quagga
-to FRR.
+This is not to say that minor or even major functional changes to CLI and
+common code should be avoided, but rather that the benefit gained from a change
+should be weighed against the added cost/complexity to existing code. Also,
+that when making such changes, it is good to preserve compatibility when
+possible to do so without introducing maintenance overhead/cost. It is also
+important to keep in mind, existing code includes code that may reside in
+private repositories (and is yet to be submitted) or code that has yet to be
+migrated from Quagga to FRR.
That said, compatibility measures can (and should) be removed when either:
-* they become a significant burden, e.g. when data structures change and
- the compatibility measure would need a complex adaptation layer or becomes
+* they become a significant burden, e.g. when data structures change and the
+ compatibility measure would need a complex adaptation layer or becomes
flat-out impossible
-* some measure of time (dependent on the specific case) has passed, so that
- the compatibility grace period is considered expired.
+* some measure of time (dependent on the specific case) has passed, so that the
+ compatibility grace period is considered expired.
In all cases, compatibility pieces should be marked with compiler/preprocessor
annotations to print warnings at compile time, pointing to the appropriate
update path. A `-Werror` build should fail if compatibility bits are used.
+
+### Miscellaneous
+
+When in doubt, follow the guidelines in the Linux kernel style guide, or ask on
+the development mailing list / public Slack instance.
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index 517489f15f..54626a4aeb 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -207,8 +207,6 @@ main(int argc, char **argv)
schedule_neighbours_check(5000, 1);
- zlog_notice ("BABELd %s starting: vty@%d", BABEL_VERSION, babel_vty_port);
-
frr_config_fork();
frr_run(master);
diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c
index 52d7eaee83..11b9c5956c 100644
--- a/babeld/babel_zebra.c
+++ b/babeld/babel_zebra.c
@@ -55,25 +55,6 @@ static struct {
{0, 0, NULL}
};
-static struct {
- int str_min_len;
- const char *str;
-} proto_redistnum_type[ZEBRA_ROUTE_MAX] = {
- [ZEBRA_ROUTE_BABEL] = {2, "babel"},
- [ZEBRA_ROUTE_BGP] = {2, "bgp"},
- [ZEBRA_ROUTE_CONNECT] = {1, "connected"},
- [ZEBRA_ROUTE_HSLS] = {1, "hsls"},
- [ZEBRA_ROUTE_ISIS] = {1, "isis"},
- [ZEBRA_ROUTE_KERNEL] = {1, "kernel"},
- [ZEBRA_ROUTE_OLSR] = {2, "olsr"},
- [ZEBRA_ROUTE_OSPF] = {2, "ospf"},
- [ZEBRA_ROUTE_OSPF6] = {5, "ospf6"},
- [ZEBRA_ROUTE_RIP] = {1, "rip"},
- [ZEBRA_ROUTE_RIPNG] = {4, "ripng"},
- [ZEBRA_ROUTE_STATIC] = {2, "static"},
- [ZEBRA_ROUTE_SYSTEM] = {2, "system"},
-};
-
/* Zebra node structure. */
struct cmd_node zebra_node =
{
@@ -191,66 +172,46 @@ babel_zebra_read_ipv4 (int command, struct zclient *zclient,
return 0;
}
-static int
-babel_proto_redistnum(const char *s)
-{
- int i;
- if (! s)
- return -1;
- int len = strlen(s);
-
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
- if (len <= (int)strlen(proto_redistnum_type[i].str) &&
- strncmp(proto_redistnum_type[i].str, s,
- proto_redistnum_type[i].str_min_len) == 0) {
- return i;
- }
- }
-
- return -1;
-}
-
/* [Babel Command] */
DEFUN (babel_redistribute_type,
babel_redistribute_type_cmd,
- "redistribute " FRR_REDIST_STR_BABELD,
+ "[no] redistribute <ipv4 " FRR_IP_REDIST_STR_BABELD "|ipv6 " FRR_IP6_REDIST_STR_BABELD ">",
+ NO_STR
"Redistribute\n"
- FRR_REDIST_HELP_STR_BABELD)
+ "Redistribute IPv4 routes\n"
+ FRR_IP_REDIST_HELP_STR_BABELD
+ "Redistribute IPv6 routes\n"
+ FRR_IP6_REDIST_HELP_STR_BABELD)
{
+ int negate = 0;
+ int family;
+ int afi;
int type;
+ int idx = 0;
- type = babel_proto_redistnum(argv[1]->arg);
-
- if (type < 0) {
- vty_out (vty, "Invalid type %s\n", argv[1]->arg);
+ if (argv_find(argv, argc, "no", &idx))
+ negate = 1;
+ argv_find(argv, argc, "redistribute", &idx);
+ family = str2family(argv[idx + 1]->text);
+ if (family < 0)
return CMD_WARNING_CONFIG_FAILED;
- }
-
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
- return CMD_SUCCESS;
-}
-
-/* [Babel Command] */
-DEFUN (no_babel_redistribute_type,
- no_babel_redistribute_type_cmd,
- "no redistribute " FRR_REDIST_STR_BABELD,
- NO_STR
- "Redistribute\n"
- FRR_REDIST_HELP_STR_BABELD)
-{
- int type;
- type = babel_proto_redistnum(argv[2]->arg);
+ afi = family2afi(family);
+ if (!afi)
+ return CMD_WARNING_CONFIG_FAILED;
+ type = proto_redistnum(afi, argv[idx + 2]->text);
if (type < 0) {
- vty_out (vty, "Invalid type %s\n", argv[2]->arg);
+ vty_out (vty, "Invalid type %s\n", argv[idx + 2]->arg);
return CMD_WARNING_CONFIG_FAILED;
}
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
- zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
- /* perhaps should we remove xroutes having the same type... */
+ if (!negate)
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0, VRF_DEFAULT);
+ else {
+ zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0, VRF_DEFAULT);
+ /* perhaps should we remove xroutes having the same type... */
+ }
return CMD_SUCCESS;
}
@@ -374,7 +335,6 @@ void babelz_zebra_init(void)
install_node (&zebra_node, zebra_config_write);
install_element(BABEL_NODE, &babel_redistribute_type_cmd);
- install_element(BABEL_NODE, &no_babel_redistribute_type_cmd);
install_element(ENABLE_NODE, &debug_babel_cmd);
install_element(ENABLE_NODE, &no_debug_babel_cmd);
install_element(CONFIG_NODE, &debug_babel_cmd);
diff --git a/babeld/babeld.c b/babeld/babeld.c
index b2f8176aab..f995745e41 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -76,6 +76,7 @@ static int
babel_config_write (struct vty *vty)
{
int lines = 0;
+ int afi;
int i;
/* list enabled debug modes */
@@ -108,13 +109,17 @@ babel_config_write (struct vty *vty)
/* list enabled interfaces */
lines = 1 + babel_enable_if_config_write (vty);
/* list redistributed protocols */
- for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
- if (i != zclient->redist_default &&
- vrf_bitmap_check (zclient->redist[AFI_IP][i], VRF_DEFAULT))
- {
- vty_out (vty, " redistribute %s\n", zebra_route_string(i));
- lines++;
+ for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
+ for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
+ if (i != zclient->redist_default &&
+ vrf_bitmap_check (zclient->redist[afi][i], VRF_DEFAULT)) {
+ vty_out (vty, " redistribute %s %s\n",
+ (afi == AFI_IP) ? "ipv4" : "ipv6",
+ zebra_route_string(i));
+ lines++;
+ }
}
+ }
lines += config_write_distribute (vty);
diff --git a/babeld/babeld.h b/babeld/babeld.h
index d933f18805..899b4f175c 100644
--- a/babeld/babeld.h
+++ b/babeld/babeld.h
@@ -90,7 +90,6 @@ THE SOFTWARE.
#define BABEL_VTY_PORT 2609
#define BABEL_DEFAULT_CONFIG "babeld.conf"
-#define BABEL_VERSION "0.1 for quagga"
/* Values in milliseconds */
#define BABEL_DEFAULT_HELLO_INTERVAL 4000
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 1e68c7d53b..4e55c5f264 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -878,9 +878,8 @@ size_t aspath_put(struct stream *s, struct aspath *as, int use32bit)
* The general assumption here is that many things tested will
* never happen. And, in real live, up to now, they have not.
*/
- while (seg
- && (ASSEGMENT_LEN(seg, use32bit)
- <= STREAM_WRITEABLE(s))) {
+ while (seg && (ASSEGMENT_LEN(seg, use32bit)
+ <= STREAM_WRITEABLE(s))) {
struct assegment *next = seg->next;
int written = 0;
int asns_packed = 0;
@@ -1585,14 +1584,12 @@ int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
return 1;
/* find first non-confed segments for each */
- while (seg1
- && ((seg1->type == AS_CONFED_SEQUENCE)
- || (seg1->type == AS_CONFED_SET)))
+ while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
+ || (seg1->type == AS_CONFED_SET)))
seg1 = seg1->next;
- while (seg2
- && ((seg2->type == AS_CONFED_SEQUENCE)
- || (seg2->type == AS_CONFED_SET)))
+ while (seg2 && ((seg2->type == AS_CONFED_SEQUENCE)
+ || (seg2->type == AS_CONFED_SET)))
seg2 = seg2->next;
/* Check as1's */
@@ -2069,8 +2066,7 @@ static void aspath_show_all_iterator(struct hash_backet *backet,
`show [ip] bgp paths' command. */
void aspath_print_all_vty(struct vty *vty)
{
- hash_iterate(ashash,
- (void (*)(struct hash_backet *,
- void *))aspath_show_all_iterator,
+ hash_iterate(ashash, (void (*)(struct hash_backet *,
+ void *))aspath_show_all_iterator,
vty);
}
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 508deb1d34..ef32b9cf92 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -82,14 +82,15 @@ static const struct message attr_str[] = {
{BGP_ATTR_PREFIX_SID, "PREFIX_SID"},
{0}};
-static const struct message attr_flag_str[] = {
- {BGP_ATTR_FLAG_OPTIONAL, "Optional"},
- {BGP_ATTR_FLAG_TRANS, "Transitive"},
- {BGP_ATTR_FLAG_PARTIAL, "Partial"},
- /* bgp_attr_flags_diagnose() relies on this bit being last in
- this list */
- {BGP_ATTR_FLAG_EXTLEN, "Extended Length"},
- {0}};
+static const struct message attr_flag_str[] =
+ {
+ {BGP_ATTR_FLAG_OPTIONAL, "Optional"},
+ {BGP_ATTR_FLAG_TRANS, "Transitive"},
+ {BGP_ATTR_FLAG_PARTIAL, "Partial"},
+ /* bgp_attr_flags_diagnose() relies on this bit being last in
+ this list */
+ {BGP_ATTR_FLAG_EXTLEN, "Extended Length"},
+ {0}};
static struct hash *cluster_hash;
@@ -679,10 +680,9 @@ static void attr_show_all_iterator(struct hash_backet *backet, struct vty *vty)
void attr_show_all(struct vty *vty)
{
- hash_iterate(
- attrhash,
- (void (*)(struct hash_backet *, void *))attr_show_all_iterator,
- vty);
+ hash_iterate(attrhash, (void (*)(struct hash_backet *,
+ void *))attr_show_all_iterator,
+ vty);
}
static void *bgp_attr_hash_alloc(void *p)
@@ -1055,7 +1055,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, u_char subcode,
static void
bgp_attr_flags_diagnose(struct bgp_attr_parser_args *args,
u_int8_t desired_flags /* how RFC says it must be */
-)
+ )
{
u_char seen = 0, i;
u_char real_flags = args->flags;
@@ -1087,26 +1087,30 @@ bgp_attr_flags_diagnose(struct bgp_attr_parser_args *args,
* as will PARTIAL for optional+transitive attributes.
*/
const u_int8_t attr_flags_values[] = {
- [BGP_ATTR_ORIGIN] = BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_AS_PATH] = BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_NEXT_HOP] = BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_MULTI_EXIT_DISC] = BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_LOCAL_PREF] = BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_ATOMIC_AGGREGATE] = BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_AGGREGATOR] = BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_COMMUNITIES] = BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_ORIGINATOR_ID] = BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_CLUSTER_LIST] = BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_MP_REACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_MP_UNREACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
- [BGP_ATTR_EXT_COMMUNITIES] =
- BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_AS4_PATH] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_AS4_AGGREGATOR] =
- BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_LARGE_COMMUNITIES] =
- BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
- [BGP_ATTR_PREFIX_SID] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_ORIGIN] = BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_AS_PATH] = BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_NEXT_HOP] = BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_MULTI_EXIT_DISC] = BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_LOCAL_PREF] = BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_ATOMIC_AGGREGATE] = BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_AGGREGATOR] =
+ BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_COMMUNITIES] =
+ BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_ORIGINATOR_ID] = BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_CLUSTER_LIST] = BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_MP_REACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_MP_UNREACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
+ [BGP_ATTR_EXT_COMMUNITIES] =
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_AS4_PATH] =
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_AS4_AGGREGATOR] =
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_LARGE_COMMUNITIES] =
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
+ [BGP_ATTR_PREFIX_SID] =
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
};
static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1;
@@ -2035,7 +2039,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
}
#endif
}
- stlv_last->next = tlv;
+ stlv_last = tlv;
}
if (BGP_ATTR_ENCAP == type) {
@@ -2751,10 +2755,9 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,
struct bgp_attr_encap_subtlv *st;
const char *attrname;
- if (!attr
- || (attrtype == BGP_ATTR_ENCAP
- && (!attr->encap_tunneltype
- || attr->encap_tunneltype == BGP_ENCAP_TYPE_MPLS)))
+ if (!attr || (attrtype == BGP_ATTR_ENCAP
+ && (!attr->encap_tunneltype
+ || attr->encap_tunneltype == BGP_ENCAP_TYPE_MPLS)))
return;
switch (attrtype) {
@@ -2801,8 +2804,9 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,
if (attrlenfield > 0xff) {
/* 2-octet length field */
- stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, attrtype);
stream_putw(s, attrlenfield & 0xffff);
} else {
@@ -3040,14 +3044,15 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) {
if (attr->community->size * 4 > 255) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putw(s, attr->community->size * 4);
} else {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putc(s, attr->community->size * 4);
}
@@ -3061,14 +3066,15 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
PEER_FLAG_SEND_LARGE_COMMUNITY)
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {
if (attr->lcommunity->size * 12 > 255) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putw(s, attr->lcommunity->size * 12);
} else {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putc(s, attr->lcommunity->size * 12);
}
@@ -3120,14 +3126,16 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
if (peer->sort == BGP_PEER_IBGP
|| peer->sort == BGP_PEER_CONFED) {
if (attr->ecommunity->size * 8 > 255) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
stream_putw(s, attr->ecommunity->size * 8);
} else {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
stream_putc(s, attr->ecommunity->size * 8);
}
@@ -3193,8 +3201,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
label_index = attr->label_index;
if (label_index != BGP_INVALID_LABEL_INDEX) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_PREFIX_SID);
stream_putc(s, 10);
stream_putc(s, BGP_PREFIX_SID_LABEL_INDEX);
@@ -3222,8 +3231,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
*/
aspath = aspath_delete_confed_seq(aspath);
- stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_AS4_PATH);
aspath_sizep = stream_get_endp(s);
stream_putw(s, 0);
@@ -3408,14 +3418,15 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
/* Community attribute. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) {
if (attr->community->size * 4 > 255) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putw(s, attr->community->size * 4);
} else {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putc(s, attr->community->size * 4);
}
@@ -3425,14 +3436,15 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
/* Large Community attribute. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {
if (attr->lcommunity->size * 12 > 255) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS
- | BGP_ATTR_FLAG_EXTLEN);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
+ | BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putw(s, attr->lcommunity->size * 12);
} else {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putc(s, attr->lcommunity->size * 12);
}
@@ -3477,8 +3489,9 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
/* Prefix SID */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID)) {
if (attr->label_index != BGP_INVALID_LABEL_INDEX) {
- stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
- | BGP_ATTR_FLAG_TRANS);
+ stream_putc(s,
+ BGP_ATTR_FLAG_OPTIONAL
+ | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_PREFIX_SID);
stream_putc(s, 10);
stream_putc(s, BGP_PREFIX_SID_LABEL_INDEX);
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index c9f0d6f4eb..324813c085 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -220,7 +220,7 @@ typedef enum {
BGP_ATTR_PARSE_WITHDRAW = -2,
/* only used internally, send notify + convert to BGP_ATTR_PARSE_ERROR
- */
+ */
BGP_ATTR_PARSE_ERROR_NOTIFYPLS = -3,
} bgp_attr_parse_ret_t;
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
index 9b5202ff91..2e277bfa5f 100644
--- a/bgpd/bgp_bfd.c
+++ b/bgpd/bgp_bfd.c
@@ -212,9 +212,8 @@ static void bgp_bfd_update_type(struct peer *peer)
if ((multihop
&& !CHECK_FLAG(bfd_info->flags,
BFD_FLAG_BFD_TYPE_MULTIHOP))
- || (!multihop
- && CHECK_FLAG(bfd_info->flags,
- BFD_FLAG_BFD_TYPE_MULTIHOP))) {
+ || (!multihop && CHECK_FLAG(bfd_info->flags,
+ BFD_FLAG_BFD_TYPE_MULTIHOP))) {
bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_DEREGISTER);
bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_REGISTER);
}
diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c
index e29f72b747..4faebb538e 100644
--- a/bgpd/bgp_btoa.c
+++ b/bgpd/bgp_btoa.c
@@ -36,9 +36,7 @@
/* privileges */
static zebra_capabilities_t _caps_p[] = {
- ZCAP_BIND,
- ZCAP_NET_RAW,
- ZCAP_NET_ADMIN,
+ ZCAP_BIND, ZCAP_NET_RAW, ZCAP_NET_ADMIN,
};
struct zebra_privs_t bgpd_privs = {
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index e3ab943792..bd3ae27c05 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -369,9 +369,10 @@ static void bgp_damp_parameter_set(int hlife, int reuse, int sup, int maxsup)
/* Initialize params per bgp_damp_config. */
damp->reuse_index_size = REUSE_ARRAY_SIZE;
- damp->ceiling = (int)(damp->reuse_limit
- * (pow(2, (double)damp->max_suppress_time
- / damp->half_life)));
+ damp->ceiling =
+ (int)(damp->reuse_limit * (pow(2,
+ (double)damp->max_suppress_time
+ / damp->half_life)));
/* Decay-array computations */
damp->decay_array_size =
@@ -413,11 +414,9 @@ static void bgp_damp_parameter_set(int hlife, int reuse, int sup, int maxsup)
for (i = 0; i < damp->reuse_index_size; i++) {
damp->reuse_index[i] =
(int)(((double)damp->half_life / DELTA_REUSE)
- * log10(1.0
- / (damp->reuse_limit
- * (1.0
- + ((double)i
- / damp->scale_factor))))
+ * log10(1.0 / (damp->reuse_limit
+ * (1.0 + ((double)i
+ / damp->scale_factor))))
/ log10(0.5));
}
}
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index d1d06f36ba..0831369062 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -244,8 +244,9 @@ static void bgp_dump_routes_index_table(struct bgp *bgp)
/* Populate fake peer at index 0, for locally originated routes */
/* Peer type (IPv4) */
- stream_putc(obuf, TABLE_DUMP_V2_PEER_INDEX_TABLE_AS4
- + TABLE_DUMP_V2_PEER_INDEX_TABLE_IP);
+ stream_putc(obuf,
+ TABLE_DUMP_V2_PEER_INDEX_TABLE_AS4
+ + TABLE_DUMP_V2_PEER_INDEX_TABLE_IP);
/* Peer BGP ID (0.0.0.0) */
stream_putl(obuf, 0);
/* Peer IP address (0.0.0.0) */
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 4d1e690f9c..f0081e6d02 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -2718,10 +2718,9 @@ int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni,
*/
void bgp_evpn_cleanup_on_disable(struct bgp *bgp)
{
- hash_iterate(
- bgp->vnihash,
- (void (*)(struct hash_backet *, void *))cleanup_vni_on_disable,
- bgp);
+ hash_iterate(bgp->vnihash, (void (*)(struct hash_backet *,
+ void *))cleanup_vni_on_disable,
+ bgp);
}
/*
@@ -2731,10 +2730,9 @@ void bgp_evpn_cleanup_on_disable(struct bgp *bgp)
void bgp_evpn_cleanup(struct bgp *bgp)
{
if (bgp->vnihash)
- hash_iterate(
- bgp->vnihash,
- (void (*)(struct hash_backet *, void *))free_vni_entry,
- bgp);
+ hash_iterate(bgp->vnihash, (void (*)(struct hash_backet *,
+ void *))free_vni_entry,
+ bgp);
if (bgp->import_rt_hash)
hash_free(bgp->import_rt_hash);
bgp->import_rt_hash = NULL;
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index 0e16fa2eae..1225354c0a 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -347,6 +347,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (bgp == NULL) {
if (!use_json)
vty_out(vty, "No BGP process is configured\n");
+ else
+ vty_out(vty, "{}\n");
return CMD_WARNING;
}
@@ -1301,10 +1303,9 @@ static void evpn_show_routes_vni_all(struct vty *vty, struct bgp *bgp,
wctx.bgp = bgp;
wctx.vty = vty;
wctx.vtep_ip = vtep_ip;
- hash_iterate(
- bgp->vnihash,
- (void (*)(struct hash_backet *, void *))show_vni_routes_hash,
- &wctx);
+ hash_iterate(bgp->vnihash, (void (*)(struct hash_backet *,
+ void *))show_vni_routes_hash,
+ &wctx);
}
/*
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 8275f3e89c..cf1cb18689 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -1394,8 +1394,9 @@ static int bgp_establish(struct peer *peer)
}
if (other == peer)
- ret = 1; /* bgp_establish specific code when xfer_conn
- happens. */
+ ret =
+ 1; /* bgp_establish specific code when xfer_conn
+ happens. */
/* Reset capability open status flag. */
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN))
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index 88c77d978c..ad7411990e 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -283,7 +283,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
* an error SHOULD
* be logged locally, and the prefix SHOULD be
* ignored.
- */
+ */
zlog_err(
"%s: IPv4 labeled-unicast NLRI is multicast address %s, ignoring",
peer->host, inet_ntoa(p.u.prefix4));
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 319d28f3fb..25a562ed68 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -101,9 +101,7 @@ static int retain_mode = 0;
/* privileges */
static zebra_capabilities_t _caps_p[] = {
- ZCAP_BIND,
- ZCAP_NET_RAW,
- ZCAP_NET_ADMIN,
+ ZCAP_BIND, ZCAP_NET_RAW, ZCAP_NET_ADMIN,
};
struct zebra_privs_t bgpd_privs = {
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index a9346582ba..d3ee140bb4 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -102,6 +102,7 @@ int bgp_maximum_paths_unset(struct bgp *bgp, afi_t afi, safi_t safi,
int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2)
{
int compare;
+ struct in6_addr addr1, addr2;
compare = IPV4_ADDR_CMP(&bi1->attr->nexthop, &bi2->attr->nexthop);
if (!compare) {
@@ -120,13 +121,18 @@ int bgp_info_nexthop_cmp(struct bgp_info *bi1, struct bgp_info *bi2)
&bi2->attr->mp_nexthop_global);
break;
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
- compare = IPV6_ADDR_CMP(
- &bi1->attr->mp_nexthop_global,
- &bi2->attr->mp_nexthop_global);
+ addr1 = (bi1->attr->mp_nexthop_prefer_global) ?
+ bi1->attr->mp_nexthop_global
+ : bi1->attr->mp_nexthop_local;
+ addr2 = (bi2->attr->mp_nexthop_prefer_global) ?
+ bi2->attr->mp_nexthop_global
+ : bi2->attr->mp_nexthop_local;
+
+ if (!bi1->attr->mp_nexthop_prefer_global &&
+ !bi2->attr->mp_nexthop_prefer_global)
+ compare = !(bi1->peer->ifindex == bi2->peer->ifindex);
if (!compare)
- compare = IPV6_ADDR_CMP(
- &bi1->attr->mp_nexthop_local,
- &bi2->attr->mp_nexthop_local);
+ compare = IPV6_ADDR_CMP(&addr1, &addr2);
break;
}
}
@@ -675,9 +681,8 @@ void bgp_info_mpath_aggregate_update(struct bgp_info *new_best,
bgp_attr_dup(&attr, new_best->attr);
- if (new_best->peer
- && bgp_flag_check(new_best->peer->bgp,
- BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
+ if (new_best->peer && bgp_flag_check(new_best->peer->bgp,
+ BGP_FLAG_MULTIPATH_RELAX_AS_SET)) {
/* aggregate attribute from multipath constituents */
aspath = aspath_dup(attr.aspath);
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index d56d62e6b9..baf081c815 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -374,6 +374,8 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
if (bgp == NULL) {
if (!use_json)
vty_out(vty, "No BGP process is configured\n");
+ else
+ vty_out(vty, "{}\n");
return CMD_WARNING;
}
@@ -612,9 +614,8 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
if (use_json) {
json_object_object_add(json, "routes", json_nroute);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (output_count == 0)
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index 9c13869206..70299ea456 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -158,9 +158,8 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
if (ret) {
zlog_err(
"%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d",
- __func__,
- inet_ntop(AF_INET, &peer->remote_id, buf,
- sizeof(buf)),
+ __func__, inet_ntop(AF_INET, &peer->remote_id,
+ buf, sizeof(buf)),
errno);
return ret;
}
@@ -173,9 +172,8 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
if (ret) {
zlog_err(
"%s: Can't set TxTTL on peer (rtrid %s) socket, err = %d",
- __func__,
- inet_ntop(AF_INET, &peer->remote_id, buf,
- sizeof(buf)),
+ __func__, inet_ntop(AF_INET, &peer->remote_id,
+ buf, sizeof(buf)),
errno);
return ret;
}
@@ -184,9 +182,8 @@ int bgp_set_socket_ttl(struct peer *peer, int bgp_sock)
if (ret) {
zlog_err(
"%s: Can't set MinTTL on peer (rtrid %s) socket, err = %d",
- __func__,
- inet_ntop(AF_INET, &peer->remote_id, buf,
- sizeof(buf)),
+ __func__, inet_ntop(AF_INET, &peer->remote_id,
+ buf, sizeof(buf)),
errno);
return ret;
}
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index d31e54c672..b18a4b7c46 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -744,18 +744,18 @@ static const struct message capcode_str[] = {
/* Minimum sizes for length field of each cap (so not inc. the header) */
static const size_t cap_minsizes[] = {
- [CAPABILITY_CODE_MP] = CAPABILITY_CODE_MP_LEN,
- [CAPABILITY_CODE_REFRESH] = CAPABILITY_CODE_REFRESH_LEN,
- [CAPABILITY_CODE_ORF] = CAPABILITY_CODE_ORF_LEN,
- [CAPABILITY_CODE_RESTART] = CAPABILITY_CODE_RESTART_LEN,
- [CAPABILITY_CODE_AS4] = CAPABILITY_CODE_AS4_LEN,
- [CAPABILITY_CODE_ADDPATH] = CAPABILITY_CODE_ADDPATH_LEN,
- [CAPABILITY_CODE_DYNAMIC] = CAPABILITY_CODE_DYNAMIC_LEN,
- [CAPABILITY_CODE_DYNAMIC_OLD] = CAPABILITY_CODE_DYNAMIC_LEN,
- [CAPABILITY_CODE_ENHE] = CAPABILITY_CODE_ENHE_LEN,
- [CAPABILITY_CODE_REFRESH_OLD] = CAPABILITY_CODE_REFRESH_LEN,
- [CAPABILITY_CODE_ORF_OLD] = CAPABILITY_CODE_ORF_LEN,
- [CAPABILITY_CODE_FQDN] = CAPABILITY_CODE_MIN_FQDN_LEN,
+ [CAPABILITY_CODE_MP] = CAPABILITY_CODE_MP_LEN,
+ [CAPABILITY_CODE_REFRESH] = CAPABILITY_CODE_REFRESH_LEN,
+ [CAPABILITY_CODE_ORF] = CAPABILITY_CODE_ORF_LEN,
+ [CAPABILITY_CODE_RESTART] = CAPABILITY_CODE_RESTART_LEN,
+ [CAPABILITY_CODE_AS4] = CAPABILITY_CODE_AS4_LEN,
+ [CAPABILITY_CODE_ADDPATH] = CAPABILITY_CODE_ADDPATH_LEN,
+ [CAPABILITY_CODE_DYNAMIC] = CAPABILITY_CODE_DYNAMIC_LEN,
+ [CAPABILITY_CODE_DYNAMIC_OLD] = CAPABILITY_CODE_DYNAMIC_LEN,
+ [CAPABILITY_CODE_ENHE] = CAPABILITY_CODE_ENHE_LEN,
+ [CAPABILITY_CODE_REFRESH_OLD] = CAPABILITY_CODE_REFRESH_LEN,
+ [CAPABILITY_CODE_ORF_OLD] = CAPABILITY_CODE_ORF_LEN,
+ [CAPABILITY_CODE_FQDN] = CAPABILITY_CODE_MIN_FQDN_LEN,
};
/* value the capability must be a multiple of.
@@ -764,12 +764,18 @@ static const size_t cap_minsizes[] = {
* table should be set to 1.
*/
static const size_t cap_modsizes[] = {
- [CAPABILITY_CODE_MP] = 4, [CAPABILITY_CODE_REFRESH] = 1,
- [CAPABILITY_CODE_ORF] = 1, [CAPABILITY_CODE_RESTART] = 1,
- [CAPABILITY_CODE_AS4] = 4, [CAPABILITY_CODE_ADDPATH] = 4,
- [CAPABILITY_CODE_DYNAMIC] = 1, [CAPABILITY_CODE_DYNAMIC_OLD] = 1,
- [CAPABILITY_CODE_ENHE] = 6, [CAPABILITY_CODE_REFRESH_OLD] = 1,
- [CAPABILITY_CODE_ORF_OLD] = 1, [CAPABILITY_CODE_FQDN] = 1,
+ [CAPABILITY_CODE_MP] = 4,
+ [CAPABILITY_CODE_REFRESH] = 1,
+ [CAPABILITY_CODE_ORF] = 1,
+ [CAPABILITY_CODE_RESTART] = 1,
+ [CAPABILITY_CODE_AS4] = 4,
+ [CAPABILITY_CODE_ADDPATH] = 4,
+ [CAPABILITY_CODE_DYNAMIC] = 1,
+ [CAPABILITY_CODE_DYNAMIC_OLD] = 1,
+ [CAPABILITY_CODE_ENHE] = 6,
+ [CAPABILITY_CODE_REFRESH_OLD] = 1,
+ [CAPABILITY_CODE_ORF_OLD] = 1,
+ [CAPABILITY_CODE_FQDN] = 1,
};
/**
@@ -1309,8 +1315,9 @@ void bgp_open_capability(struct stream *s, struct peer *peer)
*/
SET_FLAG(peer->cap, PEER_CAP_ENHE_ADV);
stream_putc(s, BGP_OPEN_OPT_CAP);
- stream_putc(s, CAPABILITY_CODE_ENHE_LEN
- + 2);
+ stream_putc(s,
+ CAPABILITY_CODE_ENHE_LEN
+ + 2);
stream_putc(s, CAPABILITY_CODE_ENHE);
stream_putc(s,
CAPABILITY_CODE_ENHE_LEN);
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index b0d6a9388a..e92f2d6977 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -547,8 +547,9 @@ void bgp_open_send(struct peer *peer)
/* Set open packet values. */
stream_putc(s, BGP_VERSION_4); /* BGP version */
- stream_putw(s, (local_as <= BGP_AS_MAX) ? (u_int16_t)local_as
- : BGP_AS_TRANS);
+ stream_putw(s,
+ (local_as <= BGP_AS_MAX) ? (u_int16_t)local_as
+ : BGP_AS_TRANS);
stream_putw(s, send_holdtime); /* Hold Time */
stream_put_in_addr(s, &peer->local_id); /* BGP Identifier */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 1c1c95525c..b554aeb32b 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1916,9 +1916,8 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp,
: NULL);
/* First update is deferred until ORF or ROUTE-REFRESH is received */
- if (onlypeer
- && CHECK_FLAG(onlypeer->af_sflags[afi][safi],
- PEER_STATUS_ORF_WAIT_REFRESH))
+ if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi],
+ PEER_STATUS_ORF_WAIT_REFRESH))
return 0;
memset(&attr, 0, sizeof(struct attr));
@@ -3869,7 +3868,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
* an error SHOULD
* be logged locally, and the prefix SHOULD be
* ignored.
- */
+ */
zlog_err(
"%s: IPv4 unicast NLRI is multicast address %s, ignoring",
peer->host, inet_ntoa(p.u.prefix4));
@@ -5210,16 +5209,14 @@ DEFUN (no_bgp_network_mask_natural,
}
ALIAS(no_bgp_network, no_bgp_network_label_index_cmd,
- "no network A.B.C.D/M label-index (0-1048560)",
- NO_STR
+ "no network A.B.C.D/M label-index (0-1048560)", NO_STR
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Label index to associate with the prefix\n"
"Label index value\n")
ALIAS(no_bgp_network, no_bgp_network_label_index_route_map_cmd,
- "no network A.B.C.D/M label-index (0-1048560) route-map WORD",
- NO_STR
+ "no network A.B.C.D/M label-index (0-1048560) route-map WORD", NO_STR
"Specify a network to announce via BGP\n"
"IP prefix\n"
"Label index to associate with the prefix\n"
@@ -5301,16 +5298,14 @@ DEFUN (no_ipv6_bgp_network,
}
ALIAS(no_ipv6_bgp_network, no_ipv6_bgp_network_label_index_cmd,
- "no network X:X::X:X/M label-index (0-1048560)",
- NO_STR
+ "no network X:X::X:X/M label-index (0-1048560)", NO_STR
"Specify a network to announce via BGP\n"
"IPv6 prefix <network>/<length>\n"
"Label index to associate with the prefix\n"
"Label index value\n")
ALIAS(no_ipv6_bgp_network, no_ipv6_bgp_network_label_index_route_map_cmd,
- "no network X:X::X:X/M label-index (0-1048560) route-map WORD",
- NO_STR
+ "no network X:X::X:X/M label-index (0-1048560) route-map WORD", NO_STR
"Specify a network to announce via BGP\n"
"IPv6 prefix\n"
"Label index to associate with the prefix\n"
@@ -6510,10 +6505,11 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo,
len = vty_out(
vty, "%s",
binfo->peer->conf_if);
- len = 7 - len; /* len of IPv6
- addr + max
- len of def
- ifname */
+ len =
+ 7 - len; /* len of IPv6
+ addr + max
+ len of def
+ ifname */
if (len < 1)
vty_out(vty, "\n%*s",
@@ -7000,10 +6996,9 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p,
bgp_damp_reuse_time_vty(vty, binfo, timebuf, BGP_UPTIME_LEN,
use_json, json);
else
- vty_out(vty, "%s ",
- bgp_damp_reuse_time_vty(vty, binfo, timebuf,
- BGP_UPTIME_LEN, use_json,
- json));
+ vty_out(vty, "%s ", bgp_damp_reuse_time_vty(vty, binfo, timebuf,
+ BGP_UPTIME_LEN,
+ use_json, json));
/* Print attribute */
attr = binfo->attr;
@@ -7082,9 +7077,8 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p,
peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, use_json,
json);
else
- vty_out(vty, "%s ",
- peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 0,
- NULL));
+ vty_out(vty, "%s ", peer_uptime(bdi->start_time, timebuf,
+ BGP_UPTIME_LEN, 0, NULL));
if (CHECK_FLAG(binfo->flags, BGP_INFO_DAMPED)
&& !CHECK_FLAG(binfo->flags, BGP_INFO_HISTORY)) {
@@ -8263,6 +8257,8 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (bgp == NULL) {
if (!use_json)
vty_out(vty, "No BGP process is configured\n");
+ else
+ vty_out(vty, "{}\n");
return CMD_WARNING;
}
@@ -8604,9 +8600,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
if (display)
json_object_object_add(json, "paths", json_paths);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (!display) {
@@ -8624,8 +8619,16 @@ static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str,
int prefix_check, enum bgp_path_type pathtype,
u_char use_json)
{
- if (!bgp)
+ if (!bgp) {
bgp = bgp_get_default();
+ if (!bgp) {
+ if (!use_json)
+ vty_out(vty, "No BGP process is configured\n");
+ else
+ vty_out(vty, "{}\n");
+ return CMD_WARNING;
+ }
+ }
/* labeled-unicast routes live in the unicast table */
if (safi == SAFI_LABELED_UNICAST)
@@ -9276,20 +9279,21 @@ enum bgp_stats {
};
static const char *table_stats_strs[] = {
- [BGP_STATS_PREFIXES] = "Total Prefixes",
- [BGP_STATS_TOTPLEN] = "Average prefix length",
- [BGP_STATS_RIB] = "Total Advertisements",
- [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
- [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
- [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
- [BGP_STATS_SPACE] = "Address space advertised",
- [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
- [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
- [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
- [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
- [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
- [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
- [BGP_STATS_MAX] = NULL,
+ [BGP_STATS_PREFIXES] = "Total Prefixes",
+ [BGP_STATS_TOTPLEN] = "Average prefix length",
+ [BGP_STATS_RIB] = "Total Advertisements",
+ [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
+ [BGP_STATS_MAX_AGGREGATEABLE] =
+ "Maximum aggregateable prefixes",
+ [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
+ [BGP_STATS_SPACE] = "Address space advertised",
+ [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
+ [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
+ [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
+ [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
+ [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
+ [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
+ [BGP_STATS_MAX] = NULL,
};
struct bgp_table_stats {
@@ -9524,11 +9528,16 @@ enum bgp_pcounts {
};
static const char *pcount_strs[] = {
- [PCOUNT_ADJ_IN] = "Adj-in", [PCOUNT_DAMPED] = "Damped",
- [PCOUNT_REMOVED] = "Removed", [PCOUNT_HISTORY] = "History",
- [PCOUNT_STALE] = "Stale", [PCOUNT_VALID] = "Valid",
- [PCOUNT_ALL] = "All RIB", [PCOUNT_COUNTED] = "PfxCt counted",
- [PCOUNT_PFCNT] = "Useable", [PCOUNT_MAX] = NULL,
+ [PCOUNT_ADJ_IN] = "Adj-in",
+ [PCOUNT_DAMPED] = "Damped",
+ [PCOUNT_REMOVED] = "Removed",
+ [PCOUNT_HISTORY] = "History",
+ [PCOUNT_STALE] = "Stale",
+ [PCOUNT_VALID] = "Valid",
+ [PCOUNT_ALL] = "All RIB",
+ [PCOUNT_COUNTED] = "PfxCt counted",
+ [PCOUNT_PFCNT] = "Useable",
+ [PCOUNT_MAX] = NULL,
};
struct peer_pcounts {
@@ -9629,9 +9638,9 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi,
pcounts.table = peer->bgp->rib[afi][safi];
/* in-place call via thread subsystem so as to record execution time
- * * stats for the thread-walk (i.e. ensure this can't be blamed on
- * * on just vty_read()).
- * */
+ * * stats for the thread-walk (i.e. ensure this can't be blamed on
+ * * on just vty_read()).
+ * */
thread_execute(bm->master, bgp_peer_count_walker, &pcounts, 0);
if (use_json) {
@@ -9888,9 +9897,8 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
"bgpOriginatingDefaultNetwork",
"0.0.0.0");
} else {
- vty_out(vty,
- "BGP table version is %" PRIu64
- ", local router ID is %s\n",
+ vty_out(vty, "BGP table version is %" PRIu64
+ ", local router ID is %s\n",
table->version, inet_ntoa(bgp->router_id));
vty_out(vty, BGP_SHOW_SCODE_HEADER);
vty_out(vty, BGP_SHOW_OCODE_HEADER);
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index cb4c9a21ee..1a1817bad3 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -97,8 +97,10 @@ struct bgp_info_extra {
struct in6_addr addr6;
} un; /* cached un address */
time_t create_time;
- struct prefix aux_prefix; /* AFI_L2VPN: the IP addr,
- if family set */
+ struct
+ prefix
+ aux_prefix; /* AFI_L2VPN: the IP addr,
+ if family set */
} import;
} vnc;
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 8a9bd764ee..285bb9a80c 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -652,10 +652,7 @@ static route_map_result_t route_match_metric(void *rule, struct prefix *prefix,
/* Route map commands for metric matching. */
struct route_map_rule_cmd route_match_metric_cmd = {
- "metric",
- route_match_metric,
- route_value_compile,
- route_value_free,
+ "metric", route_match_metric, route_value_compile, route_value_free,
};
/* `match as-path ASPATH' */
@@ -1050,9 +1047,7 @@ static route_map_result_t route_match_tag(void *rule, struct prefix *prefix,
/* Route map commands for tag matching. */
static struct route_map_rule_cmd route_match_tag_cmd = {
- "tag",
- route_match_tag,
- route_map_rule_tag_compile,
+ "tag", route_match_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -1197,9 +1192,7 @@ static route_map_result_t route_set_local_pref(void *rule,
/* Set local preference rule structure. */
struct route_map_rule_cmd route_set_local_pref_cmd = {
- "local-preference",
- route_set_local_pref,
- route_value_compile,
+ "local-preference", route_set_local_pref, route_value_compile,
route_value_free,
};
@@ -1228,10 +1221,7 @@ static route_map_result_t route_set_weight(void *rule, struct prefix *prefix,
/* Set local preference rule structure. */
struct route_map_rule_cmd route_set_weight_cmd = {
- "weight",
- route_set_weight,
- route_value_compile,
- route_value_free,
+ "weight", route_set_weight, route_value_compile, route_value_free,
};
/* `set metric METRIC' */
@@ -1263,10 +1253,7 @@ static route_map_result_t route_set_metric(void *rule, struct prefix *prefix,
/* Set metric rule structure. */
struct route_map_rule_cmd route_set_metric_cmd = {
- "metric",
- route_set_metric,
- route_value_compile,
- route_value_free,
+ "metric", route_set_metric, route_value_compile, route_value_free,
};
/* `set as-path prepend ASPATH' */
@@ -1324,10 +1311,8 @@ static void route_set_aspath_prepend_free(void *rule)
/* Set as-path prepend rule structure. */
struct route_map_rule_cmd route_set_aspath_prepend_cmd = {
- "as-path prepend",
- route_set_aspath_prepend,
- route_set_aspath_prepend_compile,
- route_set_aspath_prepend_free,
+ "as-path prepend", route_set_aspath_prepend,
+ route_set_aspath_prepend_compile, route_set_aspath_prepend_free,
};
/* `set as-path exclude ASn' */
@@ -1360,9 +1345,7 @@ static route_map_result_t route_set_aspath_exclude(void *rule,
/* Set ASn exlude rule structure. */
struct route_map_rule_cmd route_set_aspath_exclude_cmd = {
- "as-path exclude",
- route_set_aspath_exclude,
- route_aspath_compile,
+ "as-path exclude", route_set_aspath_exclude, route_aspath_compile,
route_aspath_free,
};
@@ -1475,9 +1458,7 @@ static void route_set_community_free(void *rule)
/* Set community rule structure. */
struct route_map_rule_cmd route_set_community_cmd = {
- "community",
- route_set_community,
- route_set_community_compile,
+ "community", route_set_community, route_set_community_compile,
route_set_community_free,
};
@@ -1595,9 +1576,7 @@ static void route_set_lcommunity_free(void *rule)
/* Set community rule structure. */
struct route_map_rule_cmd route_set_lcommunity_cmd = {
- "large-community",
- route_set_lcommunity,
- route_set_lcommunity_compile,
+ "large-community", route_set_lcommunity, route_set_lcommunity_compile,
route_set_lcommunity_free,
};
@@ -1680,10 +1659,8 @@ static void route_set_lcommunity_delete_free(void *rule)
/* Set lcommunity rule structure. */
struct route_map_rule_cmd route_set_lcommunity_delete_cmd = {
- "large-comm-list",
- route_set_lcommunity_delete,
- route_set_lcommunity_delete_compile,
- route_set_lcommunity_delete_free,
+ "large-comm-list", route_set_lcommunity_delete,
+ route_set_lcommunity_delete_compile, route_set_lcommunity_delete_free,
};
@@ -1766,10 +1743,8 @@ static void route_set_community_delete_free(void *rule)
/* Set community rule structure. */
struct route_map_rule_cmd route_set_community_delete_cmd = {
- "comm-list",
- route_set_community_delete,
- route_set_community_delete_compile,
- route_set_community_delete_free,
+ "comm-list", route_set_community_delete,
+ route_set_community_delete_compile, route_set_community_delete_free,
};
/* `set extcommunity rt COMMUNITY' */
@@ -1836,10 +1811,8 @@ static void route_set_ecommunity_free(void *rule)
/* Set community rule structure. */
struct route_map_rule_cmd route_set_ecommunity_rt_cmd = {
- "extcommunity rt",
- route_set_ecommunity,
- route_set_ecommunity_rt_compile,
- route_set_ecommunity_free,
+ "extcommunity rt", route_set_ecommunity,
+ route_set_ecommunity_rt_compile, route_set_ecommunity_free,
};
/* `set extcommunity soo COMMUNITY' */
@@ -1858,10 +1831,8 @@ static void *route_set_ecommunity_soo_compile(const char *arg)
/* Set community rule structure. */
struct route_map_rule_cmd route_set_ecommunity_soo_cmd = {
- "extcommunity soo",
- route_set_ecommunity,
- route_set_ecommunity_soo_compile,
- route_set_ecommunity_free,
+ "extcommunity soo", route_set_ecommunity,
+ route_set_ecommunity_soo_compile, route_set_ecommunity_free,
};
/* `set origin ORIGIN' */
@@ -1909,9 +1880,7 @@ static void route_set_origin_free(void *rule)
/* Set origin rule structure. */
struct route_map_rule_cmd route_set_origin_cmd = {
- "origin",
- route_set_origin,
- route_set_origin_compile,
+ "origin", route_set_origin, route_set_origin_compile,
route_set_origin_free,
};
@@ -1948,10 +1917,8 @@ static void route_set_atomic_aggregate_free(void *rule)
/* Set atomic aggregate rule structure. */
struct route_map_rule_cmd route_set_atomic_aggregate_cmd = {
- "atomic-aggregate",
- route_set_atomic_aggregate,
- route_set_atomic_aggregate_compile,
- route_set_atomic_aggregate_free,
+ "atomic-aggregate", route_set_atomic_aggregate,
+ route_set_atomic_aggregate_compile, route_set_atomic_aggregate_free,
};
/* `set aggregator as AS A.B.C.D' */
@@ -2006,10 +1973,8 @@ static void route_set_aggregator_as_free(void *rule)
}
struct route_map_rule_cmd route_set_aggregator_as_cmd = {
- "aggregator as",
- route_set_aggregator_as,
- route_set_aggregator_as_compile,
- route_set_aggregator_as_free,
+ "aggregator as", route_set_aggregator_as,
+ route_set_aggregator_as_compile, route_set_aggregator_as_free,
};
/* Set tag to object. object must be pointer to struct bgp_info */
@@ -2032,9 +1997,7 @@ static route_map_result_t route_set_tag(void *rule, struct prefix *prefix,
/* Route map commands for tag set. */
static struct route_map_rule_cmd route_set_tag_cmd = {
- "tag",
- route_set_tag,
- route_map_rule_tag_compile,
+ "tag", route_set_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -2067,9 +2030,7 @@ static route_map_result_t route_set_label_index(void *rule,
/* Route map commands for label-index set. */
static struct route_map_rule_cmd route_set_label_index_cmd = {
- "label-index",
- route_set_label_index,
- route_value_compile,
+ "label-index", route_set_label_index, route_value_compile,
route_value_free,
};
@@ -2596,10 +2557,8 @@ static void route_set_originator_id_free(void *rule)
/* Set originator-id rule structure. */
struct route_map_rule_cmd route_set_originator_id_cmd = {
- "originator-id",
- route_set_originator_id,
- route_set_originator_id_compile,
- route_set_originator_id_free,
+ "originator-id", route_set_originator_id,
+ route_set_originator_id_compile, route_set_originator_id_free,
};
/* Add bgp route map rule. */
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index 50ced81644..8a9d61f305 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -864,6 +864,8 @@ static u_char *bgp4PathAttrTable(struct variable *v, oid name[], size_t *length,
return SNMP_INTEGER(-1);
break;
case BGP4PATHATTRBEST: /* 13 */
+ /* $FRR indent$ */
+ /* clang-format off */
#define BGP4_PathAttrBest_false 1
#define BGP4_PathAttrBest_true 2
if (CHECK_FLAG(binfo->flags, BGP_INFO_SELECTED))
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index b791bc1a1c..77e6157150 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -1121,8 +1121,8 @@ int update_subgroup_check_merge(struct update_subgroup *subgrp,
}
/*
- * update_subgroup_merge_check_thread_cb
- */
+* update_subgroup_merge_check_thread_cb
+*/
static int update_subgroup_merge_check_thread_cb(struct thread *thread)
{
struct update_subgroup *subgrp;
diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h
index d6c8055b64..52a21679b8 100644
--- a/bgpd/bgp_updgrp.h
+++ b/bgpd/bgp_updgrp.h
@@ -267,6 +267,7 @@ struct update_subgroup {
*/
#define SUBGRP_DECR_STAT(subgrp, stat) SUBGRP_INCR_STAT_BY(subgrp, stat, -1)
+
typedef int (*updgrp_walkcb)(struct update_group *updgrp, void *ctx);
/* really a private structure */
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index a0961d8cee..0a33fa5ed4 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -646,10 +646,9 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
*/
onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? (SUBGRP_PFIRST(subgrp))->peer
: NULL);
- if (onlypeer
- && CHECK_FLAG(onlypeer->af_sflags[SUBGRP_AFI(subgrp)]
- [SUBGRP_SAFI(subgrp)],
- PEER_STATUS_ORF_WAIT_REFRESH))
+ if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[SUBGRP_AFI(subgrp)]
+ [SUBGRP_SAFI(subgrp)],
+ PEER_STATUS_ORF_WAIT_REFRESH))
return;
if (SUBGRP_SAFI(subgrp) != SAFI_MPLS_VPN
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 53d695167f..1a23a36e91 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -700,6 +700,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
int send_attr_printed = 0;
int num_pfx = 0;
int addpath_encode = 0;
+ int addpath_overhead = 0;
u_int32_t addpath_tx_id = 0;
struct prefix_rd *prd = NULL;
mpls_label_t label = MPLS_INVALID_LABEL;
@@ -721,6 +722,7 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
bpacket_attr_vec_arr_reset(&vecarr);
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
+ addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
adv = BGP_ADV_FIFO_HEAD(&subgrp->sync->update);
while (adv) {
@@ -732,9 +734,8 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
space_remaining = STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW;
- space_needed =
- BGP_NLRI_LENGTH
- + bgp_packet_mpattr_prefix_size(afi, safi, &rn->p);
+ space_needed = BGP_NLRI_LENGTH + addpath_overhead +
+ bgp_packet_mpattr_prefix_size(afi, safi, &rn->p);
/* When remaining space can't include NLRI and it's length. */
if (space_remaining < space_needed)
@@ -778,9 +779,9 @@ struct bpacket *subgroup_update_packet(struct update_subgroup *subgrp)
space_remaining =
STREAM_CONCAT_REMAIN(s, snlri, STREAM_SIZE(s))
- BGP_MAX_PACKET_SIZE_OVERFLOW;
- space_needed = BGP_NLRI_LENGTH
- + bgp_packet_mpattr_prefix_size(
- afi, safi, &rn->p);
+ space_needed = BGP_NLRI_LENGTH + addpath_overhead +
+ bgp_packet_mpattr_prefix_size(afi, safi,
+ &rn->p);
/* If the attributes alone do not leave any room for
* NLRI then
@@ -937,6 +938,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
int space_needed = 0;
int num_pfx = 0;
int addpath_encode = 0;
+ int addpath_overhead = 0;
u_int32_t addpath_tx_id = 0;
struct prefix_rd *prd = NULL;
@@ -953,6 +955,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
s = subgrp->work;
stream_reset(s);
addpath_encode = bgp_addpath_encode_tx(peer, afi, safi);
+ addpath_overhead = addpath_encode ? BGP_ADDPATH_ID_LEN : 0;
while ((adv = BGP_ADV_FIFO_HEAD(&subgrp->sync->withdraw)) != NULL) {
assert(adv->rn);
@@ -963,7 +966,7 @@ struct bpacket *subgroup_withdraw_packet(struct update_subgroup *subgrp)
space_remaining =
STREAM_REMAIN(s) - BGP_MAX_PACKET_SIZE_OVERFLOW;
space_needed =
- BGP_NLRI_LENGTH + BGP_TOTAL_ATTR_LEN
+ BGP_NLRI_LENGTH + addpath_overhead + BGP_TOTAL_ATTR_LEN
+ bgp_packet_mpattr_prefix_size(afi, safi, &rn->p);
if (space_remaining < space_needed)
diff --git a/bgpd/bgp_vpn.c b/bgpd/bgp_vpn.c
index c9baf5af34..4661e195a2 100644
--- a/bgpd/bgp_vpn.c
+++ b/bgpd/bgp_vpn.c
@@ -51,6 +51,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
if (bgp == NULL) {
if (!use_json)
vty_out(vty, "No BGP process is configured\n");
+ else
+ vty_out(vty, "{}\n");
return CMD_WARNING;
}
@@ -242,9 +244,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
}
if (use_json) {
json_object_object_add(json, "routes", json_routes);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
return CMD_SUCCESS;
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 353a3425a2..65a1473f75 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -1470,8 +1470,7 @@ DEFUN (no_bgp_maxpaths,
}
ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd,
- "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]",
- NO_STR
+ "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR
"Forward packets over multiple paths\n"
"Number of paths\n")
@@ -4202,8 +4201,15 @@ DEFUN (neighbor_attr_unchanged,
"Med attribute\n")
{
int idx = 0;
- char *peer = argv[1]->arg;
+ char *peer_str = argv[1]->arg;
+ struct peer *peer;
u_int16_t flags = 0;
+ afi_t afi = bgp_node_afi(vty);
+ safi_t safi = bgp_node_safi(vty);
+
+ peer = peer_and_group_lookup_vty(vty, peer_str);
+ if (!peer)
+ return CMD_WARNING_CONFIG_FAILED;
if (argv_find(argv, argc, "as-path", &idx))
SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED);
@@ -4214,15 +4220,35 @@ DEFUN (neighbor_attr_unchanged,
if (argv_find(argv, argc, "med", &idx))
SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED);
- if (!flags) // no flags means all of them!
- {
+ /* no flags means all of them! */
+ if (!flags) {
SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED);
SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED);
SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED);
+ } else {
+ if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) &&
+ peer_af_flag_check(peer, afi, safi,
+ PEER_FLAG_AS_PATH_UNCHANGED)) {
+ peer_af_flag_unset_vty(vty, peer_str, afi, safi,
+ PEER_FLAG_AS_PATH_UNCHANGED);
+ }
+
+ if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) &&
+ peer_af_flag_check(peer, afi, safi,
+ PEER_FLAG_NEXTHOP_UNCHANGED)) {
+ peer_af_flag_unset_vty(vty, peer_str, afi, safi,
+ PEER_FLAG_NEXTHOP_UNCHANGED);
+ }
+
+ if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) &&
+ peer_af_flag_check(peer, afi, safi,
+ PEER_FLAG_MED_UNCHANGED)) {
+ peer_af_flag_unset_vty(vty, peer_str, afi, safi,
+ PEER_FLAG_MED_UNCHANGED);
+ }
}
- return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty),
- bgp_node_safi(vty), flags);
+ return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags);
}
ALIAS_HIDDEN(
@@ -6377,9 +6403,8 @@ DEFUN (show_bgp_vrfs,
json_object_int_add(json, "totalVrfs", count);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (count)
@@ -6473,20 +6498,17 @@ DEFUN (show_bgp_memory,
/* Other attributes */
if ((count = community_count()))
vty_out(vty, "%ld BGP community entries, using %s of memory\n",
- count,
- mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(struct community)));
+ count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
+ count * sizeof(struct community)));
if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY)))
vty_out(vty, "%ld BGP community entries, using %s of memory\n",
- count,
- mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(struct ecommunity)));
+ count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
+ count * sizeof(struct ecommunity)));
if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY)))
vty_out(vty,
"%ld BGP large-community entries, using %s of memory\n",
- count,
- mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(struct lcommunity)));
+ count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
+ count * sizeof(struct lcommunity)));
if ((count = mtype_stats_alloc(MTYPE_CLUSTER)))
vty_out(vty, "%ld Cluster lists, using %s of memory\n", count,
@@ -6515,9 +6537,8 @@ DEFUN (show_bgp_memory,
count * sizeof(struct hash_backet)));
if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP)))
vty_out(vty, "%ld compiled regexes, using %s of memory\n",
- count,
- mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(regex_t)));
+ count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
+ count * sizeof(regex_t)));
return CMD_SUCCESS;
}
@@ -6742,9 +6763,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
ents);
json_object_int_add(
json, "peerGroupMemory",
- ents
- * sizeof(struct
- peer_group));
+ ents * sizeof(struct
+ peer_group));
}
if (CHECK_FLAG(bgp->af_flags[afi][safi],
@@ -6775,9 +6795,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
mtype_memstr(
memstrbuf,
sizeof(memstrbuf),
- ents
- * sizeof(struct
- bgp_node)));
+ ents * sizeof(struct
+ bgp_node)));
/* Peer related usage */
ents = listcount(bgp->peer);
@@ -6787,9 +6806,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
mtype_memstr(
memstrbuf,
sizeof(memstrbuf),
- ents
- * sizeof(struct
- peer)));
+ ents * sizeof(struct
+ peer)));
if ((ents = listcount(bgp->group)))
vty_out(vty,
@@ -6798,9 +6816,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
mtype_memstr(
memstrbuf,
sizeof(memstrbuf),
- ents
- * sizeof(struct
- peer_group)));
+ ents * sizeof(struct
+ peer_group)));
if (CHECK_FLAG(bgp->af_flags[afi][safi],
BGP_CONFIG_DAMPENING))
@@ -6918,9 +6935,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
vty_out(vty, "%*s",
max_neighbor_width - len, " ");
- vty_out(vty,
- "4 %10u %7d %7d %8" PRIu64
- " %4d %4zd %8s",
+ vty_out(vty, "4 %10u %7d %7d %8" PRIu64
+ " %4d %4zd %8s",
peer->as,
peer->open_in + peer->update_in
+ peer->keepalive_in
@@ -6968,9 +6984,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
json_object_int_add(json, "totalPeers", count);
json_object_int_add(json, "dynamicPeers", dn_count);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (count)
@@ -7065,9 +7080,10 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi,
}
safi++;
if (safi == SAFI_RESERVED_4
- || safi == SAFI_RESERVED_5) /* handle special
- cases to match
- zebra.h */
+ || safi
+ == SAFI_RESERVED_5) /* handle special
+ cases to match
+ zebra.h */
safi++;
if (!safi_wildcard)
safi = SAFI_MAX;
@@ -7626,9 +7642,8 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi,
paf = peer_af_find(p, afi, safi);
if (paf && PAF_SUBGRP(paf)) {
- vty_out(vty,
- " Update group %" PRIu64 ", subgroup %" PRIu64
- "\n",
+ vty_out(vty, " Update group %" PRIu64
+ ", subgroup %" PRIu64 "\n",
PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id);
vty_out(vty, " Packet Queue length %d\n",
bpacket_queue_virtual_length(paf));
@@ -9394,9 +9409,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json,
} else
vty_out(vty,
" Reduce the no. of prefix from %s, will restart in %ld seconds\n",
- p->host,
- thread_timer_remain_second(
- p->t_pmax_restart));
+ p->host, thread_timer_remain_second(
+ p->t_pmax_restart));
} else {
if (use_json)
json_object_boolean_true_add(
@@ -9636,9 +9650,8 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
vty_out(vty, "\n");
@@ -11093,45 +11106,31 @@ int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi,
/* BGP node structure. */
static struct cmd_node bgp_node = {
- BGP_NODE,
- "%s(config-router)# ",
- 1,
+ BGP_NODE, "%s(config-router)# ", 1,
};
static struct cmd_node bgp_ipv4_unicast_node = {
- BGP_IPV4_NODE,
- "%s(config-router-af)# ",
- 1,
+ BGP_IPV4_NODE, "%s(config-router-af)# ", 1,
};
static struct cmd_node bgp_ipv4_multicast_node = {
- BGP_IPV4M_NODE,
- "%s(config-router-af)# ",
- 1,
+ BGP_IPV4M_NODE, "%s(config-router-af)# ", 1,
};
static struct cmd_node bgp_ipv4_labeled_unicast_node = {
- BGP_IPV4L_NODE,
- "%s(config-router-af)# ",
- 1,
+ BGP_IPV4L_NODE, "%s(config-router-af)# ", 1,
};
static struct cmd_node bgp_ipv6_unicast_node = {
- BGP_IPV6_NODE,
- "%s(config-router-af)# ",
- 1,
+ BGP_IPV6_NODE, "%s(config-router-af)# ", 1,
};
static struct cmd_node bgp_ipv6_multicast_node = {
- BGP_IPV6M_NODE,
- "%s(config-router-af)# ",
- 1,
+ BGP_IPV6M_NODE, "%s(config-router-af)# ", 1,
};
static struct cmd_node bgp_ipv6_labeled_unicast_node = {
- BGP_IPV6L_NODE,
- "%s(config-router-af)# ",
- 1,
+ BGP_IPV6L_NODE, "%s(config-router-af)# ", 1,
};
static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE,
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index be3c6eea3a..4870e54aec 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -269,8 +269,6 @@ static int bgp_interface_delete(int command, struct zclient *zclient,
if (!ifp) /* This may happen if we've just unregistered for a VRF. */
return 0;
- ifp->ifindex = IFINDEX_DELETED;
-
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx Intf del VRF %u IF %s", vrf_id, ifp->name);
@@ -279,6 +277,8 @@ static int bgp_interface_delete(int command, struct zclient *zclient,
return 0;
bgp_update_interface_nbrs(bgp, ifp, NULL);
+
+ ifp->ifindex = IFINDEX_DELETED;
return 0;
}
@@ -621,12 +621,10 @@ static int zebra_read_ipv4(int command, struct zclient *zclient,
zlog_debug(
"Rx IPv4 route add VRF %u %s[%d] %s/%d nexthop %s metric %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
- api.instance,
- inet_ntop(AF_INET, &p.prefix, buf[0],
- sizeof(buf[0])),
- p.prefixlen,
- inet_ntop(AF_INET, &nexthop, buf[1],
- sizeof(buf[1])),
+ api.instance, inet_ntop(AF_INET, &p.prefix,
+ buf[0], sizeof(buf[0])),
+ p.prefixlen, inet_ntop(AF_INET, &nexthop,
+ buf[1], sizeof(buf[1])),
api.metric, api.tag);
}
@@ -657,12 +655,10 @@ static int zebra_read_ipv4(int command, struct zclient *zclient,
"Rx IPv4 route delete VRF %u %s[%d] %s/%d "
"nexthop %s metric %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
- api.instance,
- inet_ntop(AF_INET, &p.prefix, buf[0],
- sizeof(buf[0])),
- p.prefixlen,
- inet_ntop(AF_INET, &nexthop, buf[1],
- sizeof(buf[1])),
+ api.instance, inet_ntop(AF_INET, &p.prefix,
+ buf[0], sizeof(buf[0])),
+ p.prefixlen, inet_ntop(AF_INET, &nexthop,
+ buf[1], sizeof(buf[1])),
api.metric, api.tag);
}
bgp_redistribute_delete(bgp, (struct prefix *)&p, api.type,
@@ -752,12 +748,10 @@ static int zebra_read_ipv6(int command, struct zclient *zclient,
zlog_debug(
"Rx IPv6 route add VRF %u %s[%d] %s/%d nexthop %s metric %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
- api.instance,
- inet_ntop(AF_INET6, &p.prefix, buf[0],
- sizeof(buf[0])),
- p.prefixlen,
- inet_ntop(AF_INET, &nexthop, buf[1],
- sizeof(buf[1])),
+ api.instance, inet_ntop(AF_INET6, &p.prefix,
+ buf[0], sizeof(buf[0])),
+ p.prefixlen, inet_ntop(AF_INET, &nexthop,
+ buf[1], sizeof(buf[1])),
api.metric, api.tag);
}
@@ -787,12 +781,10 @@ static int zebra_read_ipv6(int command, struct zclient *zclient,
"Rx IPv6 route delete VRF %u %s[%d] %s/%d "
"nexthop %s metric %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
- api.instance,
- inet_ntop(AF_INET6, &p.prefix, buf[0],
- sizeof(buf[0])),
- p.prefixlen,
- inet_ntop(AF_INET6, &nexthop, buf[1],
- sizeof(buf[1])),
+ api.instance, inet_ntop(AF_INET6, &p.prefix,
+ buf[0], sizeof(buf[0])),
+ p.prefixlen, inet_ntop(AF_INET6, &nexthop,
+ buf[1], sizeof(buf[1])),
api.metric, api.tag);
}
bgp_redistribute_delete(bgp, (struct prefix *)&p, api.type,
@@ -1324,9 +1316,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
"Tx IPv4 route %s VRF %u %s/%d metric %u tag %" ROUTE_TAG_PRI
" count %d",
(valid_nh_count ? "add" : "delete"),
- bgp->vrf_id,
- inet_ntop(AF_INET, &p->u.prefix4, buf[0],
- sizeof(buf[0])),
+ bgp->vrf_id, inet_ntop(AF_INET, &p->u.prefix4,
+ buf[0], sizeof(buf[0])),
p->prefixlen, api.metric, api.tag,
api.nexthop_num);
for (i = 0; i < api.nexthop_num; i++) {
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 0c5b88d74d..a0e2d6749a 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3886,9 +3886,8 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi,
}
/* Track if addpath TX is in use */
- if (flag
- & (PEER_FLAG_ADDPATH_TX_ALL_PATHS
- | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) {
+ if (flag & (PEER_FLAG_ADDPATH_TX_ALL_PATHS
+ | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) {
bgp = peer->bgp;
addpath_tx_used = 0;
@@ -6758,9 +6757,8 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
} else {
if (!peer_af_flag_check(peer, afi, safi,
PEER_FLAG_SEND_COMMUNITY)
- && (!g_peer
- || peer_af_flag_check(g_peer, afi, safi,
- PEER_FLAG_SEND_COMMUNITY))
+ && (!g_peer || peer_af_flag_check(g_peer, afi, safi,
+ PEER_FLAG_SEND_COMMUNITY))
&& !peer_af_flag_check(peer, afi, safi,
PEER_FLAG_SEND_EXT_COMMUNITY)
&& (!g_peer
@@ -6768,10 +6766,9 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
PEER_FLAG_SEND_EXT_COMMUNITY))
&& !peer_af_flag_check(peer, afi, safi,
PEER_FLAG_SEND_LARGE_COMMUNITY)
- && (!g_peer
- || peer_af_flag_check(
- g_peer, afi, safi,
- PEER_FLAG_SEND_LARGE_COMMUNITY))) {
+ && (!g_peer || peer_af_flag_check(
+ g_peer, afi, safi,
+ PEER_FLAG_SEND_LARGE_COMMUNITY))) {
afi_header_vty_out(
vty, afi, safi, write,
" no neighbor %s send-community all\n", addr);
@@ -6802,10 +6799,9 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
if (!peer_af_flag_check(peer, afi, safi,
PEER_FLAG_SEND_COMMUNITY)
- && (!g_peer
- || peer_af_flag_check(
- g_peer, afi, safi,
- PEER_FLAG_SEND_COMMUNITY))) {
+ && (!g_peer || peer_af_flag_check(
+ g_peer, afi, safi,
+ PEER_FLAG_SEND_COMMUNITY))) {
afi_header_vty_out(
vty, afi, safi, write,
" no neighbor %s send-community\n",
@@ -6930,36 +6926,34 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp,
bgp_config_write_filter(vty, peer, afi, safi, write);
/* atribute-unchanged. */
- if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)
- || CHECK_FLAG(peer->af_flags[afi][safi],
- PEER_FLAG_NEXTHOP_UNCHANGED)
- || CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) {
- if (peergroup_af_flag_check(peer, afi, safi,
- PEER_FLAG_AS_PATH_UNCHANGED)
- && peergroup_af_flag_check(peer, afi, safi,
- PEER_FLAG_NEXTHOP_UNCHANGED)
- && peergroup_af_flag_check(peer, afi, safi,
- PEER_FLAG_MED_UNCHANGED)) {
- afi_header_vty_out(
- vty, afi, safi, write,
- " neighbor %s attribute-unchanged\n", addr);
- } else {
+ if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) ||
+ peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) ||
+ peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) {
+
+ if (!peer_group_active(peer) ||
+ peergroup_af_flag_check(peer, afi, safi,
+ PEER_FLAG_AS_PATH_UNCHANGED) ||
+ peergroup_af_flag_check(peer, afi, safi,
+ PEER_FLAG_NEXTHOP_UNCHANGED) ||
+ peergroup_af_flag_check(peer, afi, safi,
+ PEER_FLAG_MED_UNCHANGED)) {
+
afi_header_vty_out(
vty, afi, safi, write,
" neighbor %s attribute-unchanged%s%s%s\n",
addr,
- peergroup_af_flag_check(
+ peer_af_flag_check(
peer, afi, safi,
PEER_FLAG_AS_PATH_UNCHANGED)
? " as-path"
: "",
- peergroup_af_flag_check(
+ peer_af_flag_check(
peer, afi, safi,
PEER_FLAG_NEXTHOP_UNCHANGED)
? " next-hop"
: "",
- peergroup_af_flag_check(peer, afi, safi,
- PEER_FLAG_MED_UNCHANGED)
+ peer_af_flag_check(peer, afi, safi,
+ PEER_FLAG_MED_UNCHANGED)
? " med"
: "");
}
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index c6c14420e6..67b8289c70 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -251,14 +251,13 @@ struct bgp {
/* $FRR indent$ */
/* clang-format off */
#define BGP_MAXMED_ADMIN_UNCONFIGURED 0 /* Off by default */
- u_int32_t maxmed_admin_value; /* Max-med value when administrative in on
+ u_int32_t
+ maxmed_admin_value; /* Max-med value when administrative in on
*/
- /* $FRR indent$ */
- /* clang-format off */
#define BGP_MAXMED_VALUE_DEFAULT 4294967294 /* Maximum by default */
- u_char maxmed_active; /* 1/0 if max-med is active or not */
- u_int32_t maxmed_value; /* Max-med value when its active */
+ u_char maxmed_active; /* 1/0 if max-med is active or not */
+ u_int32_t maxmed_value; /* Max-med value when its active */
/* BGP update delay on startup */
struct thread *t_update_delay;
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index ba4c703e96..c8e2dd9525 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -135,10 +135,10 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
switch (vn->family) {
case AF_INET:
- rt_vn = &(hc->nve_groups_vn[AFI_IP]);
+ rt_vn = hc->nve_groups_vn[AFI_IP];
break;
case AF_INET6:
- rt_vn = &(hc->nve_groups_vn[AFI_IP6]);
+ rt_vn = hc->nve_groups_vn[AFI_IP6];
break;
default:
return NULL;
@@ -146,10 +146,10 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
switch (un->family) {
case AF_INET:
- rt_un = &(hc->nve_groups_un[AFI_IP]);
+ rt_un = hc->nve_groups_un[AFI_IP];
break;
case AF_INET6:
- rt_un = &(hc->nve_groups_un[AFI_IP6]);
+ rt_un = hc->nve_groups_un[AFI_IP6];
break;
default:
return NULL;
@@ -503,8 +503,9 @@ DEFUN (vnc_defaults_responselifetime,
} else {
rspint = strtoul(argv[1]->arg, NULL, 10);
if (rspint > INT32_MAX)
- rspint = INT32_MAX; /* is really an int, not an unsigned
- int */
+ rspint =
+ INT32_MAX; /* is really an int, not an unsigned
+ int */
}
bgp->rfapi_cfg->default_response_lifetime = rspint;
@@ -1673,9 +1674,8 @@ DEFUN (vnc_nve_group_export_no_prefixlist,
}
if (argv[2]->arg[0] == 'b') {
- if (((argc > 5)
- && strmatch(argv[5]->text,
- rfg->plist_export_bgp_name[afi]))
+ if (((argc > 5) && strmatch(argv[5]->text,
+ rfg->plist_export_bgp_name[afi]))
|| (argc <= 5)) {
if (rfg->plist_export_bgp_name[afi])
@@ -1686,9 +1686,8 @@ DEFUN (vnc_nve_group_export_no_prefixlist,
vnc_direct_bgp_reexport_group_afi(bgp, rfg, afi);
}
} else {
- if (((argc > 5)
- && strmatch(argv[5]->text,
- rfg->plist_export_zebra_name[afi]))
+ if (((argc > 5) && strmatch(argv[5]->text,
+ rfg->plist_export_zebra_name[afi]))
|| (argc <= 5)) {
if (rfg->plist_export_zebra_name[afi])
free(rfg->plist_export_zebra_name[afi]);
@@ -1792,9 +1791,8 @@ DEFUN (vnc_nve_group_export_no_routemap,
vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP6);
}
} else {
- if (((argc > 4)
- && strmatch(argv[4]->text,
- rfg->routemap_export_zebra_name))
+ if (((argc > 4) && strmatch(argv[4]->text,
+ rfg->routemap_export_zebra_name))
|| (argc <= 4)) {
if (rfg->routemap_export_zebra_name)
free(rfg->routemap_export_zebra_name);
@@ -2447,9 +2445,8 @@ bgp_rfapi_delete_named_nve_group(struct vty *vty, /* NULL = no output */
*/
for (ALL_LIST_ELEMENTS_RO(bgp->rfapi_cfg->rfg_export_direct_bgp_l, node,
rfgn)) {
- if (rfg_name == NULL
- || (type == RFAPI_GROUP_CFG_NVE
- && !strcmp(rfgn->name, rfg_name))) {
+ if (rfg_name == NULL || (type == RFAPI_GROUP_CFG_NVE
+ && !strcmp(rfgn->name, rfg_name))) {
rfgn->rfg = NULL;
/* remove exported routes from this group */
vnc_direct_bgp_del_group(bgp, rfg);
@@ -2463,9 +2460,8 @@ bgp_rfapi_delete_named_nve_group(struct vty *vty, /* NULL = no output */
for (ALL_LIST_ELEMENTS_RO(bgp->rfapi_cfg->rfg_export_zebra_l, node,
rfgn)) {
- if (rfg_name == NULL
- || (type == RFAPI_GROUP_CFG_NVE
- && !strcmp(rfgn->name, rfg_name))) {
+ if (rfg_name == NULL || (type == RFAPI_GROUP_CFG_NVE
+ && !strcmp(rfgn->name, rfg_name))) {
rfgn->rfg = NULL;
/* remove exported routes from this group */
vnc_zebra_del_group(bgp, rfg);
@@ -2507,7 +2503,7 @@ DEFUN (vnc_nve_group_prefix,
VTY_DECLVAR_CONTEXT(bgp, bgp);
VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg);
struct prefix p;
- int afi;
+ afi_t afi;
struct route_table *rt;
struct route_node *rn;
int is_un_prefix = 0;
@@ -2531,10 +2527,10 @@ DEFUN (vnc_nve_group_prefix,
}
if (argv[1]->arg[0] == 'u') {
- rt = &(bgp->rfapi_cfg->nve_groups_un[afi]);
+ rt = bgp->rfapi_cfg->nve_groups_un[afi];
is_un_prefix = 1;
} else {
- rt = &(bgp->rfapi_cfg->nve_groups_vn[afi]);
+ rt = bgp->rfapi_cfg->nve_groups_vn[afi];
}
rn = route_node_get(rt, &p); /* NB locks node */
@@ -3834,7 +3830,7 @@ void bgp_rfapi_cfg_init(void)
struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
{
struct rfapi_cfg *h;
- int afi;
+ afi_t afi;
h = (struct rfapi_cfg *)XCALLOC(MTYPE_RFAPI_CFG,
sizeof(struct rfapi_cfg));
@@ -3842,14 +3838,9 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
h->nve_groups_sequential = list_new();
assert(h->nve_groups_sequential);
-
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
- /* ugly, to deal with addition of delegates, part of 0.99.24.1
- * merge */
- h->nve_groups_vn[afi].delegate =
- route_table_get_default_delegate();
- h->nve_groups_un[afi].delegate =
- route_table_get_default_delegate();
+ h->nve_groups_vn[afi] = route_table_init();
+ h->nve_groups_un[afi] = route_table_init();
}
h->default_response_lifetime =
BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT;
@@ -3889,6 +3880,7 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
{
+ afi_t afi;
if (h == NULL)
return;
@@ -3905,6 +3897,10 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
ecommunity_free(&h->default_rt_import_list);
if (h->default_rfp_cfg)
XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
+ for (afi = AFI_IP; afi < AFI_MAX; afi++) {
+ route_table_finish(h->nve_groups_vn[afi]);
+ route_table_finish(h->nve_groups_un[afi]);
+ }
XFREE(MTYPE_RFAPI_CFG, h);
}
@@ -4575,7 +4571,8 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
void bgp_rfapi_show_summary(struct bgp *bgp, struct vty *vty)
{
struct rfapi_cfg *hc = bgp->rfapi_cfg;
- int afi, type, redist = 0;
+ afi_t afi;
+ int type, redist = 0;
char tmp[40];
if (hc == NULL)
return;
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.h b/bgpd/rfapi/bgp_rfapi_cfg.h
index d99aefa60d..a11b0992fa 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.h
+++ b/bgpd/rfapi/bgp_rfapi_cfg.h
@@ -135,8 +135,8 @@ struct rfapi_cfg {
struct list *l2_groups; /* rfapi_l2_group_cfg list */
/* three views into the same collection of rfapi_nve_group_cfg */
struct list *nve_groups_sequential;
- struct route_table nve_groups_vn[AFI_MAX];
- struct route_table nve_groups_un[AFI_MAX];
+ struct route_table *nve_groups_vn[AFI_MAX];
+ struct route_table *nve_groups_un[AFI_MAX];
/*
* For Single VRF export to ordinary routing protocols. This is
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index f809621123..ab71eda126 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -205,7 +205,7 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
struct prefix p;
struct route_node *rn;
int rc;
- int afi;
+ afi_t afi;
if (!bgp) {
return ENXIO;
@@ -224,7 +224,7 @@ static int rfapi_find_node(struct bgp *bgp, struct rfapi_ip_addr *vn_addr,
if ((rc = rfapiRaddr2Qprefix(un_addr, &p)))
return rc;
- rn = route_node_lookup(&h->un[afi], &p);
+ rn = route_node_lookup(h->un[afi], &p);
if (!rn)
return ENOENT;
@@ -1415,7 +1415,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd,
assert(afi_vn && afi_un);
assert(!rfapiRaddr2Qprefix(&rfd->un_addr, &pfx_un));
- rn = route_node_get(&(h->un[afi_un]), &pfx_un);
+ rn = route_node_get(h->un[afi_un], &pfx_un);
assert(rn);
rfd->next = rn->info;
rn->info = rfd;
@@ -2367,7 +2367,7 @@ int rfapi_register(void *handle, struct rfapi_ip_prefix *prefix,
struct prefix p;
struct prefix *pfx_ip = NULL;
struct prefix_rd prd;
- int afi;
+ afi_t afi;
struct prefix pfx_mac_buf;
struct prefix *pfx_mac = NULL;
struct prefix pfx_vn_buf;
@@ -2603,9 +2603,8 @@ int rfapi_register(void *handle, struct rfapi_ip_prefix *prefix,
ZEBRA_ROUTE_BGP, BGP_ROUTE_RFP, NULL,
action == RFAPI_REGISTER_KILL);
- if (0
- == rfapiApDelete(bgp, rfd, &p, pfx_mac, &prd,
- &adv_tunnel)) {
+ if (0 == rfapiApDelete(bgp, rfd, &p, pfx_mac, &prd,
+ &adv_tunnel)) {
if (adv_tunnel)
rfapiTunnelRouteAnnounce(
bgp, rfd, &rfd->max_prefix_lifetime);
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index d16d578ac8..0bbbe12cce 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -1,22 +1,22 @@
/*
- *
- * Copyright 2009-2016, LabN Consulting, L.L.C.
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
+*
+* Copyright 2009-2016, LabN Consulting, L.L.C.
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; see the file COPYING; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
/*
* File: rfapi_import.c
@@ -1086,8 +1086,9 @@ int rfapiEcommunityGetEthernetTag(struct ecommunity *ecom, uint16_t *tag_id)
} else if (encode == ECOMMUNITY_ENCODE_AS) {
as = (*p++ << 8);
as |= (*p++);
- p += 2; /* skip next two, tag/vid
- always in lowest bytes */
+ p +=
+ 2; /* skip next two, tag/vid
+ always in lowest bytes */
}
if (as == bgp->as) {
*tag_id = *p++ << 8;
@@ -2010,9 +2011,8 @@ static void rfapiBgpInfoAttachSorted(struct route_node *rn,
for (prev = NULL, next = rn->info; next;
prev = next, next = next->next) {
- if (!bgp
- || (!CHECK_FLAG(info_new->flags, BGP_INFO_REMOVED)
- && CHECK_FLAG(next->flags, BGP_INFO_REMOVED))
+ if (!bgp || (!CHECK_FLAG(info_new->flags, BGP_INFO_REMOVED)
+ && CHECK_FLAG(next->flags, BGP_INFO_REMOVED))
|| bgp_info_cmp_compatible(bgp, info_new, next, pfx_buf,
afi, safi)
== -1) { /* -1 if 1st is better */
@@ -3554,10 +3554,9 @@ void rfapiBgpInfoFilteredImportVPN(
vnc_zlog_debug_verbose(
"%s: withdrawing at prefix %s/%d%s",
- __func__,
- rfapi_ntop(rn->p.family,
- &rn->p.u.prefix, buf,
- BUFSIZ),
+ __func__, rfapi_ntop(rn->p.family,
+ &rn->p.u.prefix,
+ buf, BUFSIZ),
rn->p.prefixlen,
(washolddown
? " (already being withdrawn)"
@@ -4024,7 +4023,7 @@ void rfapiProcessWithdraw(struct peer *peer, void *rfd, struct prefix *p,
p, /* aux_prefix: IP */
AFI_L2VPN, prd, attr, type, 0,
NULL); /* sub_type & label unused for withdraw
- */
+ */
}
}
@@ -4249,7 +4248,7 @@ static void rfapiBgpTableFilteredImport(struct bgp *bgp,
struct rfapi *bgp_rfapi_new(struct bgp *bgp)
{
struct rfapi *h;
- int afi;
+ afi_t afi;
struct rfapi_rfp_cfg *cfg = NULL;
struct rfapi_rfp_cb_methods *cbm = NULL;
@@ -4258,9 +4257,7 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp)
h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi));
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
- /* ugly, to deal with addition of delegates, part of 0.99.24.1
- * merge */
- h->un[afi].delegate = route_table_get_default_delegate();
+ h->un[afi] = route_table_init();
}
/*
@@ -4293,6 +4290,8 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp)
void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h)
{
+ afi_t afi;
+
if (bgp == NULL || h == NULL)
return;
@@ -4311,8 +4310,9 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h)
void *cursor;
int rc;
- for (cursor = NULL, rc = skiplist_next(h->import_mac, NULL,
- (void **)&it, &cursor);
+ for (cursor = NULL,
+ rc = skiplist_next(h->import_mac, NULL, (void **)&it,
+ &cursor);
!rc; rc = skiplist_next(h->import_mac, NULL, (void **)&it,
&cursor)) {
@@ -4327,6 +4327,11 @@ void bgp_rfapi_destroy(struct bgp *bgp, struct rfapi *h)
if (h->rfp != NULL)
rfp_stop(h->rfp);
+
+ for (afi = AFI_IP; afi < AFI_MAX; afi++) {
+ route_table_finish(h->un[afi]);
+ }
+
XFREE(MTYPE_RFAPI_IMPORTTABLE, h->it_ce);
XFREE(MTYPE_RFAPI, h);
}
@@ -4711,8 +4716,9 @@ void rfapiDeleteRemotePrefixes(struct prefix *un, struct prefix *vn,
void *cursor = NULL;
int rc;
- for (cursor = NULL, rc = skiplist_next(h->import_mac, NULL,
- (void **)&it, &cursor);
+ for (cursor = NULL,
+ rc = skiplist_next(h->import_mac, NULL, (void **)&it,
+ &cursor);
!rc; rc = skiplist_next(h->import_mac, NULL, (void **)&it,
&cursor)) {
@@ -4805,8 +4811,9 @@ void rfapiCountAllItRoutes(int *pALRcount, /* active local routes */
int rc;
if (h->import_mac) {
- for (cursor = NULL, rc = skiplist_next(h->import_mac, NULL,
- (void **)&it, &cursor);
+ for (cursor = NULL,
+ rc = skiplist_next(h->import_mac, NULL, (void **)&it,
+ &cursor);
!rc; rc = skiplist_next(h->import_mac, NULL, (void **)&it,
&cursor)) {
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index 5a1b29e598..9c0d9da6ff 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -1339,11 +1339,10 @@ struct route_node *rfapiMonitorEthAdd(struct bgp *bgp,
{
char buf[BUFSIZ];
- vnc_zlog_debug_verbose("%s: LNI=%d: rfd=%p, pfx=%s", __func__,
- logical_net_id, rfd,
- rfapi_ntop(pfx_mac_buf.family,
- pfx_mac_buf.u.val, buf,
- BUFSIZ));
+ vnc_zlog_debug_verbose(
+ "%s: LNI=%d: rfd=%p, pfx=%s", __func__, logical_net_id,
+ rfd, rfapi_ntop(pfx_mac_buf.family, pfx_mac_buf.u.val,
+ buf, BUFSIZ));
}
diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h
index e7a3e5aae3..73c9312a64 100644
--- a/bgpd/rfapi/rfapi_private.h
+++ b/bgpd/rfapi/rfapi_private.h
@@ -171,7 +171,7 @@ struct rfapi_global_stats {
* check vn address to get exact match.
*/
struct rfapi {
- struct route_table un[AFI_MAX];
+ struct route_table *un[AFI_MAX];
struct rfapi_import_table *imports; /* IPv4, IPv6 */
struct list descriptors; /* debug & resolve-nve imports */
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index 58da84ea32..791eb4c916 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -527,11 +527,11 @@ void rfapiRibClear(struct rfapi_descriptor *rfd)
struct rfapi_info *ri;
- while (0
- == skiplist_first(
- (struct skiplist *)
- rn->info,
- NULL, (void **)&ri)) {
+ while (0 == skiplist_first(
+ (struct skiplist *)
+ rn->info,
+ NULL,
+ (void **)&ri)) {
rfapi_info_free(ri);
skiplist_delete_first(
@@ -2236,9 +2236,12 @@ void rfapiRibShowResponsesSummary(void *stream)
struct rfapi_descriptor *rfd;
struct listnode *node;
-
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
return;
+ if (!bgp) {
+ fp(out, "Unable to find default BGP instance\n");
+ return;
+ }
fp(out, "%-24s ", "Responses: (Prefixes)");
fp(out, "%-8s %-8u ", "Active:", bgp->rfapi->rib_prefix_count_total);
@@ -2388,6 +2391,11 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
return;
+ if (!bgp) {
+ fp(out, "Unable to find default BGP instance\n");
+ return;
+ }
+
/*
* loop over NVEs
*/
@@ -2449,7 +2457,7 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
#else
"Remaining"
#endif
- );
+ );
}
if (!printednve) {
char str_vn[BUFSIZ];
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 0fab2e7005..117d4fbfd4 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -2009,7 +2009,7 @@ void vnc_import_bgp_exterior_del_route(
bgp_info_unlock(info);
route_unlock_node(
rn); /* sl entry
- */
+ */
}
if (skiplist_empty(
RFAPI_MONITOR_EXTERIOR(
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 69529c722e..3075d4109f 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -375,9 +375,8 @@ static int vnc_zebra_read_ipv4(int command, struct zclient *zclient,
__func__, zebra_route_string(api.type),
inet_ntop(AF_INET, &p.prefix, buf[0],
sizeof(buf[0])),
- p.prefixlen,
- inet_ntop(AF_INET, &nexthop, buf[1],
- sizeof(buf[1])),
+ p.prefixlen, inet_ntop(AF_INET, &nexthop,
+ buf[1], sizeof(buf[1])),
api.metric);
}
vnc_redistribute_add((struct prefix *)&p, &nexthop, api.metric,
@@ -391,9 +390,8 @@ static int vnc_zebra_read_ipv4(int command, struct zclient *zclient,
__func__, zebra_route_string(api.type),
inet_ntop(AF_INET, &p.prefix, buf[0],
sizeof(buf[0])),
- p.prefixlen,
- inet_ntop(AF_INET, &nexthop, buf[1],
- sizeof(buf[1])),
+ p.prefixlen, inet_ntop(AF_INET, &nexthop,
+ buf[1], sizeof(buf[1])),
api.metric);
}
vnc_redistribute_delete((struct prefix *)&p, api.type);
diff --git a/doc/Building_FRR_on_CentOS6.md b/doc/Building_FRR_on_CentOS6.md
index 4139daf316..b25845c38a 100644
--- a/doc/Building_FRR_on_CentOS6.md
+++ b/doc/Building_FRR_on_CentOS6.md
@@ -17,6 +17,9 @@ CentOS 6 restrictions:
- Zebra is unable to detect what bridge/vrf an interface is associcated
with (IFLA_INFO_SLAVE_KIND does not exist in the kernel headers, you
can use a newer kernel + headers to get this functionality)
+- frr_reload.py will not work, as this requires Python 2.7, and CentOS 6
+ only has 2.6. You can install Python 2.7 via IUS, but it won't work
+ properly unless you compile and install the ipaddr package for it.
Install required packages
-------------------------
diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c
index 7f312d9808..2312cc6edd 100644
--- a/eigrpd/eigrp_interface.c
+++ b/eigrpd/eigrp_interface.c
@@ -552,9 +552,8 @@ struct eigrp_interface *eigrp_if_lookup_recv_if(struct eigrp *eigrp,
if (prefix_match(CONNECTED_PREFIX(ei->connected),
(struct prefix *)&addr)) {
- if ((match == NULL)
- || (match->address->prefixlen
- < ei->address->prefixlen))
+ if ((match == NULL) || (match->address->prefixlen
+ < ei->address->prefixlen))
match = ei;
}
}
diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c
index d593f5ceea..4c99821d3c 100644
--- a/eigrpd/eigrp_main.c
+++ b/eigrpd/eigrp_main.c
@@ -50,7 +50,7 @@
#include "keychain.h"
#include "distribute.h"
#include "libfrr.h"
-//#include "routemap.h"
+#include "routemap.h"
//#include "if_rmap.h"
#include "eigrpd/eigrp_structs.h"
@@ -68,9 +68,7 @@
/* eigprd privileges */
zebra_capabilities_t _caps_p[] = {
- ZCAP_NET_RAW,
- ZCAP_BIND,
- ZCAP_NET_ADMIN,
+ ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
};
struct zebra_privs_t eigrpd_privs = {
@@ -194,6 +192,11 @@ int main(int argc, char **argv, char **envp)
prefix_list_add_hook(eigrp_distribute_update_all);
prefix_list_delete_hook(eigrp_distribute_update_all);
+ /*
+ * XXX: This is just to get the CLI installed to suppress VTYSH errors.
+ * Routemaps in EIGRP are not yet functional.
+ */
+ route_map_init();
/*eigrp_route_map_init();
route_map_add_hook (eigrp_rmap_update);
route_map_delete_hook (eigrp_rmap_update);*/
diff --git a/eigrpd/eigrp_packet.c b/eigrpd/eigrp_packet.c
index 1cbd06df6c..f20ec0ad12 100644
--- a/eigrpd/eigrp_packet.c
+++ b/eigrpd/eigrp_packet.c
@@ -134,9 +134,8 @@ int eigrp_make_md5_digest(struct eigrp_interface *ei, struct stream *s,
MD5Update(&ctx, zeropad, 16 - strlen(key->string));
if (backup_end > (EIGRP_HEADER_LEN + EIGRP_AUTH_MD5_TLV_SIZE)) {
MD5Update(&ctx,
- ibuf
- + (EIGRP_HEADER_LEN
- + EIGRP_AUTH_MD5_TLV_SIZE),
+ ibuf + (EIGRP_HEADER_LEN
+ + EIGRP_AUTH_MD5_TLV_SIZE),
backup_end - 20
- (EIGRP_HEADER_LEN
+ EIGRP_AUTH_MD5_TLV_SIZE));
@@ -209,9 +208,8 @@ int eigrp_check_md5_digest(struct stream *s,
MD5Update(&ctx, zeropad, 16 - strlen(key->string));
if (backup_end > (EIGRP_HEADER_LEN + EIGRP_AUTH_MD5_TLV_SIZE)) {
MD5Update(&ctx,
- ibuf
- + (EIGRP_HEADER_LEN
- + EIGRP_AUTH_MD5_TLV_SIZE),
+ ibuf + (EIGRP_HEADER_LEN
+ + EIGRP_AUTH_MD5_TLV_SIZE),
backup_end - 20
- (EIGRP_HEADER_LEN
+ EIGRP_AUTH_MD5_TLV_SIZE));
@@ -328,9 +326,9 @@ int eigrp_write(struct thread *thread)
struct listnode *node;
#ifdef WANT_EIGRP_WRITE_FRAGMENT
static u_int16_t ipid = 0;
-#endif /* WANT_EIGRP_WRITE_FRAGMENT */
- /* $FRR indent$ */
- /* clang-format off */
+#endif /* WANT_EIGRP_WRITE_FRAGMENT */
+ /* $FRR indent$ */
+/* clang-format off */
#define EIGRP_WRITE_IPHL_SHIFT 2
eigrp->t_write = NULL;
diff --git a/eigrpd/eigrp_routemap.c b/eigrpd/eigrp_routemap.c
index 0823201fec..b645ed1987 100644
--- a/eigrpd/eigrp_routemap.c
+++ b/eigrpd/eigrp_routemap.c
@@ -644,9 +644,7 @@ static void route_set_metric_free(void *rule)
/* Set metric rule structure. */
static struct route_map_rule_cmd route_set_metric_cmd = {
- "metric",
- route_set_metric,
- route_set_metric_compile,
+ "metric", route_set_metric, route_set_metric_compile,
route_set_metric_free,
};
@@ -778,8 +776,7 @@ DEFUN (no_match_metric,
}
ALIAS(no_match_metric, no_match_metric_val_cmd,
- "no match metric <0-4294967295>",
- NO_STR MATCH_STR
+ "no match metric <0-4294967295>", NO_STR MATCH_STR
"Match metric of route\n"
"Metric value\n")
@@ -842,8 +839,7 @@ DEFUN (no_match_ip_next_hop,
}
ALIAS(no_match_ip_next_hop, no_match_ip_next_hop_val_cmd,
- "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
- NO_STR MATCH_STR IP_STR
+ "no match ip next-hop (<1-199>|<1300-2699>|WORD)", NO_STR MATCH_STR IP_STR
"Match next-hop address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
@@ -881,8 +877,7 @@ DEFUN (no_match_ip_next_hop_prefix_list,
ALIAS(no_match_ip_next_hop_prefix_list,
no_match_ip_next_hop_prefix_list_val_cmd,
- "no match ip next-hop prefix-list WORD",
- NO_STR MATCH_STR IP_STR
+ "no match ip next-hop prefix-list WORD", NO_STR MATCH_STR IP_STR
"Match next-hop address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
@@ -916,8 +911,7 @@ DEFUN (no_match_ip_address,
}
ALIAS(no_match_ip_address, no_match_ip_address_val_cmd,
- "no match ip address (<1-199>|<1300-2699>|WORD)",
- NO_STR MATCH_STR IP_STR
+ "no match ip address (<1-199>|<1300-2699>|WORD)", NO_STR MATCH_STR IP_STR
"Match address of route\n"
"IP access-list number\n"
"IP access-list number (expanded range)\n"
@@ -954,8 +948,7 @@ DEFUN (no_match_ip_address_prefix_list,
}
ALIAS(no_match_ip_address_prefix_list, no_match_ip_address_prefix_list_val_cmd,
- "no match ip address prefix-list WORD",
- NO_STR MATCH_STR IP_STR
+ "no match ip address prefix-list WORD", NO_STR MATCH_STR IP_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
@@ -1000,8 +993,7 @@ DEFUN (set_metric,
return eigrp_route_set_add(vty, vty->index, "metric", argv[0]);
}
-ALIAS(set_metric, set_metric_addsub_cmd, "set metric <+/-metric>",
- SET_STR
+ALIAS(set_metric, set_metric_addsub_cmd, "set metric <+/-metric>", SET_STR
"Metric value for destination routing protocol\n"
"Add or subtract metric\n")
@@ -1019,8 +1011,7 @@ DEFUN (no_set_metric,
}
ALIAS(no_set_metric, no_set_metric_val_cmd,
- "no set metric (<0-4294967295>|<+/-metric>)",
- NO_STR SET_STR
+ "no set metric (<0-4294967295>|<+/-metric>)", NO_STR SET_STR
"Metric value for destination routing protocol\n"
"Metric value\n"
"Add or subtract metric\n")
@@ -1061,8 +1052,7 @@ DEFUN (no_set_ip_nexthop,
}
ALIAS(no_set_ip_nexthop, no_set_ip_nexthop_val_cmd,
- "no set ip next-hop A.B.C.D",
- NO_STR SET_STR IP_STR
+ "no set ip next-hop A.B.C.D", NO_STR SET_STR IP_STR
"Next hop address\n"
"IP address of next hop\n")
@@ -1089,8 +1079,7 @@ DEFUN (no_set_tag,
return eigrp_route_set_delete(vty, vty->index, "tag", argv[0]);
}
-ALIAS(no_set_tag, no_set_tag_val_cmd, "no set tag <0-65535>",
- NO_STR SET_STR
+ALIAS(no_set_tag, no_set_tag_val_cmd, "no set tag <0-65535>", NO_STR SET_STR
"Tag value for routing protocol\n"
"Tag value\n")
diff --git a/eigrpd/eigrp_structs.h b/eigrpd/eigrp_structs.h
index bc87b076bb..6b3a14abc5 100644
--- a/eigrpd/eigrp_structs.h
+++ b/eigrpd/eigrp_structs.h
@@ -104,8 +104,9 @@ struct eigrp {
uint64_t serno; /* Global serial number counter for topology entry
changes*/
- uint64_t serno_last_update; /* Highest serial number of information send
- by last update*/
+ uint64_t
+ serno_last_update; /* Highest serial number of information send
+ by last update*/
struct list *topology_changes_internalIPV4;
struct list *topology_changes_externalIPV4;
diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c
index 88a6ccf2a8..3c2ce6ce42 100644
--- a/eigrpd/eigrp_update.c
+++ b/eigrpd/eigrp_update.c
@@ -771,8 +771,8 @@ void eigrp_update_send_all(struct eigrp *eigrp,
/**
* @fn eigrp_update_send_GR_part
*
- * @param[in] nbr contains neighbor who would receive
- * Graceful restart
+ * @param[in] nbr contains neighbor who would receive Graceful
+ * restart
*
* @return void
*
@@ -1034,8 +1034,8 @@ int eigrp_update_send_GR_thread(struct thread *thread)
/**
* @fn eigrp_update_send_GR
*
- * @param[in] nbr Neighbor who would receive
- * Graceful restart
+ * @param[in] nbr Neighbor who would receive Graceful
+ * restart
* @param[in] gr_type Who executed Graceful restart
* @param[in] vty Virtual terminal for log output
*
@@ -1094,8 +1094,8 @@ void eigrp_update_send_GR(struct eigrp_neighbor *nbr, enum GR_type gr_type,
/**
* @fn eigrp_update_send_interface_GR
*
- * @param[in] ei Interface to neighbors of which the
- * GR is sent
+ * @param[in] ei Interface to neighbors of which the GR
+ * is sent
* @param[in] gr_type Who executed Graceful restart
* @param[in] vty Virtual terminal for log output
*
diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c
index d416183f52..465007478d 100644
--- a/eigrpd/eigrp_vty.c
+++ b/eigrpd/eigrp_vty.c
@@ -237,6 +237,11 @@ DEFUN (no_router_eigrp,
struct eigrp *eigrp;
eigrp = eigrp_lookup();
+ if (eigrp == NULL) {
+ vty_out(vty, " EIGRP Routing Process not enabled\n");
+ return CMD_SUCCESS;
+ }
+
if (eigrp->AS != atoi(argv[3]->arg)) {
vty_out(vty, "%% Attempting to deconfigure non-existent AS\n");
return CMD_WARNING_CONFIG_FAILED;
@@ -1000,9 +1005,11 @@ DEFUN (eigrp_redistribute_source_metric,
/* Get distribute source. */
argv_find(argv, argc, "redistribute", &idx);
- source = proto_redistnum(AFI_IP, argv[idx + 1]->arg);
- if (source < 0)
+ source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
+ if (source < 0) {
+ vty_out(vty, "%% Invalid route type\n");
return CMD_WARNING_CONFIG_FAILED;
+ }
/* Get metrics values */
@@ -1029,9 +1036,11 @@ DEFUN (no_eigrp_redistribute_source_metric,
/* Get distribute source. */
argv_find(argv, argc, "redistribute", &idx);
- source = proto_redistnum(AFI_IP, argv[idx + 1]->arg);
- if (source < 0)
+ source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
+ if (source < 0) {
+ vty_out(vty, "%% Invalid route type\n");
return CMD_WARNING_CONFIG_FAILED;
+ }
/* Get metrics values */
diff --git a/git-reindent-branch.py b/git-reindent-branch.py
new file mode 100644
index 0000000000..b0dd8db6de
--- /dev/null
+++ b/git-reindent-branch.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import sys, os
+import subprocess, argparse, tempfile
+import indent
+
+def run(cmd):
+ proc = subprocess.Popen(cmd, stdout = subprocess.PIPE)
+ rv = proc.communicate('')[0].decode('UTF-8')
+ proc.wait()
+ return rv
+
+argp = argparse.ArgumentParser(description = 'git whitespace-fixing tool')
+argp.add_argument('branch', metavar='BRANCH', type = str, nargs = '?', default = 'HEAD')
+args = argp.parse_args()
+
+branch = args.branch
+commit = run(['git', 'rev-list', '-n', '1', branch, '--']).strip()
+beforeid = run(['git', 'rev-list', '-n', '1', 'reindent-master-before', '--']).strip()
+afterid = run(['git', 'rev-list', '-n', '1', 'reindent-master-after', '--']).strip()
+
+beforebase = run(['git', 'merge-base', commit, beforeid]).strip()
+afterbase = run(['git', 'merge-base', commit, afterid]).strip()
+
+if afterbase == afterid:
+ sys.stderr.write('this branch was already rebased\n')
+ sys.exit(1)
+
+if beforebase != beforeid:
+ sys.stderr.write('you need to rebase your branch onto the tag "reindent-master-before"\n')
+ sys.exit(1)
+
+revs = run(['git', 'rev-list', 'reindent-master-before..%s' % commit]).strip().split('\n')
+revs.reverse()
+
+srcdir = os.getcwd()
+tmpdir = tempfile.mkdtemp('frrindent')
+os.chdir(tmpdir)
+
+sys.stderr.write('using temporary directory %s; %d revisions\n' % (tmpdir, len(revs)))
+run(['git', 'clone', '-s', '-b', 'reindent-master-after', srcdir, 'repo'])
+os.chdir('repo')
+
+prev = beforeid
+for rev in revs:
+ filestat = run(['git', 'diff', '-z', '--name-status', prev, rev]).rstrip('\0').split('\0')
+ changes = zip(filestat[0::2], filestat[1::2])
+ sys.stderr.write('%s: %d files\n' % (rev, len(changes)))
+
+ for typ, name in changes:
+ if typ == 'D':
+ run(['git', 'rm', name])
+ elif typ in ['A', 'M']:
+ run(['git', 'checkout', rev, '--', name])
+ if name.endswith('.c') or name.endswith('.h'):
+ for d in ['babeld/', 'ldpd/', 'nhrpd/']:
+ if name.startswith(d):
+ break
+ else:
+ sys.stderr.write('\t%s\n' % name)
+ indent.wrap_file(name)
+ run(['git', 'add', name])
+
+ run(['git', 'commit', '-C', rev])
+ prev = rev
+
+run(['git', 'push', 'origin', 'HEAD:refs/heads/reindented-branch'])
+sys.stderr.write('\n\n"reindented-branch" should now be OK.\n')
+sys.stderr.write('you could use "git reset --hard reindented-branch" to set your current branch to the reindented output\n')
+sys.stderr.write('\033[31;1mplease always double-check the output\033[m\n')
+
diff --git a/isisd/dict.c b/isisd/dict.c
index 5da2a741a7..f09a8152a8 100644
--- a/isisd/dict.c
+++ b/isisd/dict.c
@@ -441,7 +441,7 @@ dnode_t *dict_lookup(dict_t *dict, const void *key)
root = root->right;
else {
if (!dict->dupes) { /* no duplicates, return match
- */
+ */
return root;
} else { /* could be dupes, find leftmost one */
do {
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c
index 7214f31093..d8cb32375b 100644
--- a/isisd/isis_adjacency.c
+++ b/isisd/isis_adjacency.c
@@ -446,10 +446,9 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty,
adj->dis_record[ISIS_LEVELS + level - 1]
.dis),
adj->dischanges[level - 1],
- time2string(now
- - (adj->dis_record[ISIS_LEVELS
- + level - 1]
- .last_dis_change)));
+ time2string(now - (adj->dis_record[ISIS_LEVELS
+ + level - 1]
+ .last_dis_change)));
}
vty_out(vty, "\n");
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index de2c453aee..72810532b0 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -1270,9 +1270,7 @@ int isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit,
passwd);
}
struct cmd_node interface_node = {
- INTERFACE_NODE,
- "%s(config-if)# ",
- 1,
+ INTERFACE_NODE, "%s(config-if)# ", 1,
};
int isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type)
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index e86b9d93e4..40c6141ab8 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -838,30 +838,26 @@ static void lsp_print_mt_ipv6_reach(struct list *list, struct vty *vty,
if (mtid == ISIS_MT_IPV4_UNICAST) {
if ((ipv6_reach->control_info & CTRL_INFO_DISTRIBUTION)
== DISTRIBUTION_INTERNAL)
- vty_out(vty,
- " Metric : %-8" PRIu32
- " IPv6-Internal : %s/%d\n",
+ vty_out(vty, " Metric : %-8" PRIu32
+ " IPv6-Internal : %s/%d\n",
ntohl(ipv6_reach->metric), buff,
ipv6_reach->prefix_len);
else
- vty_out(vty,
- " Metric : %-8" PRIu32
- " IPv6-External : %s/%d\n",
+ vty_out(vty, " Metric : %-8" PRIu32
+ " IPv6-External : %s/%d\n",
ntohl(ipv6_reach->metric), buff,
ipv6_reach->prefix_len);
} else {
if ((ipv6_reach->control_info & CTRL_INFO_DISTRIBUTION)
== DISTRIBUTION_INTERNAL)
- vty_out(vty,
- " Metric : %-8" PRIu32
- " IPv6-MT-Int : %s/%d %s\n",
+ vty_out(vty, " Metric : %-8" PRIu32
+ " IPv6-MT-Int : %s/%d %s\n",
ntohl(ipv6_reach->metric), buff,
ipv6_reach->prefix_len,
isis_mtid2str(mtid));
else
- vty_out(vty,
- " Metric : %-8" PRIu32
- " IPv6-MT-Ext : %s/%d %s\n",
+ vty_out(vty, " Metric : %-8" PRIu32
+ " IPv6-MT-Ext : %s/%d %s\n",
ntohl(ipv6_reach->metric), buff,
ipv6_reach->prefix_len,
isis_mtid2str(mtid));
@@ -879,9 +875,8 @@ static void lsp_print_mt_ipv4_reach(struct list *list, struct vty *vty,
if (mtid == ISIS_MT_IPV4_UNICAST) {
/* FIXME: There should be better way to output this
* stuff. */
- vty_out(vty,
- " Metric : %-8" PRIu32
- " IPv4-Extended : %s/%d\n",
+ vty_out(vty, " Metric : %-8" PRIu32
+ " IPv4-Extended : %s/%d\n",
ntohl(te_ipv4_reach->te_metric),
inet_ntoa(newprefix2inaddr(
&te_ipv4_reach->prefix_start,
@@ -890,9 +885,8 @@ static void lsp_print_mt_ipv4_reach(struct list *list, struct vty *vty,
} else {
/* FIXME: There should be better way to output this
* stuff. */
- vty_out(vty,
- " Metric : %-8" PRIu32
- " IPv4-MT : %s/%d %s\n",
+ vty_out(vty, " Metric : %-8" PRIu32
+ " IPv4-MT : %s/%d %s\n",
ntohl(te_ipv4_reach->te_metric),
inet_ntoa(newprefix2inaddr(
&te_ipv4_reach->prefix_start,
@@ -993,9 +987,8 @@ void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost)
for (ALL_LIST_ELEMENTS_RO(lsp->tlv_data.is_neighs, lnode,
is_neigh)) {
lspid_print(is_neigh->neigh_id, LSPid, dynhost, 0);
- vty_out(vty,
- " Metric : %-8" PRIu8
- " IS : %s\n",
+ vty_out(vty, " Metric : %-8" PRIu8
+ " IS : %s\n",
is_neigh->metrics.metric_default, LSPid);
}
@@ -1007,9 +1000,8 @@ void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost)
sizeof(ipv4_reach_prefix));
memcpy(ipv4_reach_mask, inet_ntoa(ipv4_reach->mask),
sizeof(ipv4_reach_mask));
- vty_out(vty,
- " Metric : %-8" PRIu8
- " IPv4-Internal : %s %s\n",
+ vty_out(vty, " Metric : %-8" PRIu8
+ " IPv4-Internal : %s %s\n",
ipv4_reach->metrics.metric_default,
ipv4_reach_prefix, ipv4_reach_mask);
}
@@ -1022,9 +1014,8 @@ void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost)
sizeof(ipv4_reach_prefix));
memcpy(ipv4_reach_mask, inet_ntoa(ipv4_reach->mask),
sizeof(ipv4_reach_mask));
- vty_out(vty,
- " Metric : %-8" PRIu8
- " IPv4-External : %s %s\n",
+ vty_out(vty, " Metric : %-8" PRIu8
+ " IPv4-External : %s %s\n",
ipv4_reach->metrics.metric_default,
ipv4_reach_prefix, ipv4_reach_mask);
}
@@ -2763,9 +2754,9 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level)
THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]);
diff = now - lsp->last_generated;
if (diff < circuit->area->lsp_gen_interval[lvl - 1]) {
- timeout = 1000
- * (circuit->area->lsp_gen_interval[lvl - 1]
- - diff);
+ timeout =
+ 1000 * (circuit->area->lsp_gen_interval[lvl - 1]
+ - diff);
sched_debug(
"ISIS (%s): Sechduling in %ld ms to match configured lsp_gen_interval",
area->area_tag, timeout);
@@ -2990,9 +2981,9 @@ void lsp_purge_non_exist(int level, struct isis_link_state_hdr *lsp_hdr,
lsp->level = level;
lsp->pdu = stream_new(LLC_LEN + area->lsp_mtu);
lsp->isis_header = (struct isis_fixed_hdr *)STREAM_DATA(lsp->pdu);
- fill_fixed_hdr(lsp->isis_header, (lsp->level == IS_LEVEL_1)
- ? L1_LINK_STATE
- : L2_LINK_STATE);
+ fill_fixed_hdr(lsp->isis_header,
+ (lsp->level == IS_LEVEL_1) ? L1_LINK_STATE
+ : L2_LINK_STATE);
lsp->lsp_header = (struct isis_link_state_hdr *)(STREAM_DATA(lsp->pdu)
+ ISIS_FIXED_HDR_LEN);
memcpy(lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN);
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index c107c2e347..a3706179a6 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1391,10 +1391,11 @@ dontcheckadj:
lsp_set_all_srmflags(lsp);
/* v */
ISIS_FLAGS_CLEAR_ALL(
- lsp->SSNflags); /* FIXME:
- OTHER
- than c
- */
+ lsp
+ ->SSNflags); /* FIXME:
+ OTHER
+ than c
+ */
/* For the case of lsp confusion, flood
* the purge back to its
diff --git a/isisd/isis_pfpacket.c b/isisd/isis_pfpacket.c
index e5752e31f6..e24901b0de 100644
--- a/isisd/isis_pfpacket.c
+++ b/isisd/isis_pfpacket.c
@@ -47,16 +47,17 @@
extern struct zebra_privs_t isisd_privs;
/* tcpdump -i eth0 'isis' -dd */
-static struct sock_filter isisfilter[] = {
- /* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped
- * off!
- * (OTOH it's a bit more lower-layer agnostic and might work
- * over GRE?) */
- /* { 0x28, 0, 0, 0x0000000c - 14 }, */
- /* { 0x25, 5, 0, 0x000005dc }, */
- {0x28, 0, 0, 0x0000000e - 14}, {0x15, 0, 3, 0x0000fefe},
- {0x30, 0, 0, 0x00000011 - 14}, {0x15, 0, 1, 0x00000083},
- {0x6, 0, 0, 0x00040000}, {0x6, 0, 0, 0x00000000},
+static struct sock_filter isisfilter[] =
+ {
+ /* NB: we're in SOCK_DGRAM, so src/dst mac + length are stripped
+ * off!
+ * (OTOH it's a bit more lower-layer agnostic and might work
+ * over GRE?) */
+ /* { 0x28, 0, 0, 0x0000000c - 14 }, */
+ /* { 0x25, 5, 0, 0x000005dc }, */
+ {0x28, 0, 0, 0x0000000e - 14}, {0x15, 0, 3, 0x0000fefe},
+ {0x30, 0, 0, 0x00000011 - 14}, {0x15, 0, 1, 0x00000083},
+ {0x6, 0, 0, 0x00040000}, {0x6, 0, 0, 0x00000000},
};
static struct sock_fprog bpf = {
diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c
index 9f27d780a4..8e329494dd 100644
--- a/isisd/isis_redist.c
+++ b/isisd/isis_redist.c
@@ -389,9 +389,9 @@ static void isis_redist_update_zebra_subscriptions(struct isis *isis)
for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++)
for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++)
for (level = 0; level < ISIS_LEVELS; level++)
- if (area->redist_settings
- [protocol][type][level]
- .redist)
+ if (area->redist_settings[protocol]
+ [type]
+ [level].redist)
do_subscribe[protocol][type] =
1;
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 620b19391d..615c2eeaa2 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -366,9 +366,10 @@ static struct isis_vertex *isis_spf_add_root(struct isis_spftree *spftree,
zlog_warn("ISIS-Spf: could not find own l%d LSP!",
spftree->level);
- vertex = isis_vertex_new(id, spftree->area->oldmetric
- ? VTYPE_NONPSEUDO_IS
- : VTYPE_NONPSEUDO_TE_IS);
+ vertex = isis_vertex_new(id,
+ spftree->area->oldmetric
+ ? VTYPE_NONPSEUDO_IS
+ : VTYPE_NONPSEUDO_TE_IS);
listnode_add(spftree->paths, vertex);
#ifdef EXTREME_DEBUG
@@ -507,13 +508,11 @@ static void isis_spf_add_local(struct isis_spftree *spftree,
/* d) */
if (listcount(vertex->Adj_N) > ISIS_MAX_PATH_SPLITS)
remove_excess_adjs(vertex->Adj_N);
- if (parent
- && (listnode_lookup(vertex->parents, parent)
- == NULL))
+ if (parent && (listnode_lookup(vertex->parents, parent)
+ == NULL))
listnode_add(vertex->parents, parent);
- if (parent
- && (listnode_lookup(parent->children, vertex)
- == NULL))
+ if (parent && (listnode_lookup(parent->children, vertex)
+ == NULL))
listnode_add(parent->children, vertex);
return;
} else if (vertex->d_N < cost) {
@@ -650,9 +649,8 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree,
mt_router_info = tlvs_lookup_mt_router_info(&lsp->tlv_data,
spftree->mtid);
- if (!pseudo_lsp
- && (spftree->mtid == ISIS_MT_IPV4_UNICAST
- && !speaks(lsp->tlv_data.nlpids, spftree->family))
+ if (!pseudo_lsp && (spftree->mtid == ISIS_MT_IPV4_UNICAST
+ && !speaks(lsp->tlv_data.nlpids, spftree->family))
&& !mt_router_info)
return ISIS_OK;
@@ -669,9 +667,8 @@ lspfragloop:
#endif /* EXTREME_DEBUG */
/* RFC3787 section 4 SHOULD ignore overload bit in pseudo LSPs */
- if (pseudo_lsp
- || (spftree->mtid == ISIS_MT_IPV4_UNICAST
- && !ISIS_MASK_LSP_OL_BIT(lsp->lsp_header->lsp_bits))
+ if (pseudo_lsp || (spftree->mtid == ISIS_MT_IPV4_UNICAST
+ && !ISIS_MASK_LSP_OL_BIT(lsp->lsp_header->lsp_bits))
|| (mt_router_info && !mt_router_info->overload))
{
diff --git a/isisd/isis_tlv.h b/isisd/isis_tlv.h
index dea44f5f23..d06548519f 100644
--- a/isisd/isis_tlv.h
+++ b/isisd/isis_tlv.h
@@ -217,7 +217,7 @@ struct te_ipv4_reachability {
u_int32_t te_metric;
u_char control;
u_char prefix_start; /* since this is variable length by nature it only
- */
+ */
}; /* points to an approximate location */
#define TE_IPV4_HAS_SUBTLV (0x40)
diff --git a/isisd/isisd.h b/isisd/isisd.h
index 007d48f33d..1aacea881f 100644
--- a/isisd/isisd.h
+++ b/isisd/isisd.h
@@ -70,7 +70,7 @@ struct isis_area {
struct isis_spftree *spftree6[ISIS_LEVELS]; /* The v6 SPTs */
struct route_table *route_table6[ISIS_LEVELS]; /* IPv6 routes */
/* $FRR indent$ */
- /* clang-format off */
+/* clang-format off */
#define DEFAULT_LSP_MTU 1497
unsigned int lsp_mtu; /* Size of LSPs to generate */
struct list *circuit_list; /* IS-IS circuits */
diff --git a/ldpd/.gitignore b/ldpd/.gitignore
index 35f7740d11..f52b227cb1 100644
--- a/ldpd/.gitignore
+++ b/ldpd/.gitignore
@@ -15,3 +15,4 @@ TAGS
.arch-ids
*~
*.loT
+ldp_vty_cmds_clippy.c
diff --git a/ldpd/Makefile.am b/ldpd/Makefile.am
index 6074b53a33..de9b07ed4c 100644
--- a/ldpd/Makefile.am
+++ b/ldpd/Makefile.am
@@ -1,5 +1,7 @@
## Process this file with automake to produce Makefile.in.
+include ../common.am
+
AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600
@@ -16,6 +18,8 @@ libldp_a_SOURCES = \
socket.c util.c ldp_vty_cmds.c ldp_vty_conf.c ldp_vty_exec.c \
ldp_debug.c ldp_zebra.c
+ldp_vty_cmds.o: ldp_vty_cmds_clippy.c
+
noinst_HEADERS = \
control.h lde.h ldpd.h ldpe.h ldp.h log.h ldp_debug.h ldp_vty.h
diff --git a/ldpd/lde.c b/ldpd/lde.c
index 602dc8805e..77643ff48b 100644
--- a/ldpd/lde.c
+++ b/ldpd/lde.c
@@ -1328,7 +1328,6 @@ lde_nbr_addr_update(struct lde_nbr *ln, struct lde_addr *lde_addr, int removed)
struct lde_map *me;
RB_FOREACH(fec, fec_tree, &ln->recv_map) {
- fn = (struct fec_node *)fec_find(&ft, fec);
switch (fec->type) {
case FEC_TYPE_IPV4:
if (lde_addr->af != AF_INET)
@@ -1342,6 +1341,11 @@ lde_nbr_addr_update(struct lde_nbr *ln, struct lde_addr *lde_addr, int removed)
continue;
}
+ fn = (struct fec_node *)fec_find(&ft, fec);
+ if (fn == NULL)
+ /* shouldn't happen */
+ continue;
+
LIST_FOREACH(fnh, &fn->nexthops, entry) {
if (ldp_addrcmp(fnh->af, &fnh->nexthop,
&lde_addr->addr))
diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c
index c9c7160aed..d80ec8dfbc 100644
--- a/ldpd/ldp_debug.c
+++ b/ldpd/ldp_debug.c
@@ -38,31 +38,31 @@ struct cmd_node ldp_debug_node =
};
int
-ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
- const char *dir_str, int all)
+ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
+ const char *dir_str, const char *all)
{
if (strcmp(type_str, "discovery") == 0) {
if (dir_str == NULL)
return (CMD_WARNING_CONFIG_FAILED);
if (dir_str[0] == 'r') {
- if (disable)
+ if (negate)
DEBUG_OFF(hello, HELLO_RECV);
else
DEBUG_ON(hello, HELLO_RECV);
} else {
- if (disable)
+ if (negate)
DEBUG_OFF(hello, HELLO_SEND);
else
DEBUG_ON(hello, HELLO_SEND);
}
} else if (strcmp(type_str, "errors") == 0) {
- if (disable)
+ if (negate)
DEBUG_OFF(errors, ERRORS);
else
DEBUG_ON(errors, ERRORS);
} else if (strcmp(type_str, "event") == 0) {
- if (disable)
+ if (negate)
DEBUG_OFF(event, EVENT);
else
DEBUG_ON(event, EVENT);
@@ -71,7 +71,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
return (CMD_WARNING_CONFIG_FAILED);
if (dir_str[0] == 'r') {
- if (disable) {
+ if (negate) {
DEBUG_OFF(msg, MSG_RECV);
DEBUG_OFF(msg, MSG_RECV_ALL);
} else {
@@ -80,7 +80,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
DEBUG_ON(msg, MSG_RECV_ALL);
}
} else {
- if (disable) {
+ if (negate) {
DEBUG_OFF(msg, MSG_SEND);
DEBUG_OFF(msg, MSG_SEND_ALL);
} else {
@@ -90,7 +90,7 @@ ldp_vty_debug(struct vty *vty, int disable, const char *type_str,
}
}
} else if (strcmp(type_str, "zebra") == 0) {
- if (disable)
+ if (negate)
DEBUG_OFF(zebra, ZEBRA);
else
DEBUG_ON(zebra, ZEBRA);
diff --git a/ldpd/ldp_vty.h b/ldpd/ldp_vty.h
index 93713166f4..3d2072f1e5 100644
--- a/ldpd/ldp_vty.h
+++ b/ldpd/ldp_vty.h
@@ -36,46 +36,46 @@ int ldp_get_address(const char *, int *, union ldpd_addr *);
int ldp_config_write(struct vty *);
int ldp_l2vpn_config_write(struct vty *);
int ldp_debug_config_write(struct vty *);
-int ldp_vty_mpls_ldp (struct vty *, int);
-int ldp_vty_address_family (struct vty *, int, const char *);
-int ldp_vty_disc_holdtime(struct vty *, int, const char *, const char *);
-int ldp_vty_disc_interval(struct vty *, int, const char *, const char *);
-int ldp_vty_targeted_hello_accept(struct vty *, int, const char *);
-int ldp_vty_nbr_session_holdtime(struct vty *, int, const char *, const char *);
-int ldp_vty_af_session_holdtime(struct vty *, int, const char *);
-int ldp_vty_interface(struct vty *, int, const char *);
-int ldp_vty_trans_addr(struct vty *, int, const char *);
-int ldp_vty_neighbor_targeted(struct vty *, int, const char *);
-int ldp_vty_label_advertise(struct vty *, int, const char *, const char *);
-int ldp_vty_label_allocate(struct vty *, int, int, const char *);
-int ldp_vty_label_expnull(struct vty *, int, const char *);
-int ldp_vty_label_accept(struct vty *, int, const char *, const char *);
-int ldp_vty_ttl_security(struct vty *, int);
-int ldp_vty_router_id(struct vty *, int, const char *);
-int ldp_vty_ds_cisco_interop(struct vty *, int);
-int ldp_vty_trans_pref_ipv4(struct vty *, int);
-int ldp_vty_neighbor_password(struct vty *, int, const char *, const char *);
-int ldp_vty_neighbor_ttl_security(struct vty *, int, const char *, const char *);
-int ldp_vty_l2vpn(struct vty *, int, const char *);
-int ldp_vty_l2vpn_bridge(struct vty *, int, const char *);
-int ldp_vty_l2vpn_mtu(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pwtype(struct vty *, int, const char *);
-int ldp_vty_l2vpn_interface(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pseudowire(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pw_cword(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pw_nbr_addr(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pw_nbr_id(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pw_pwid(struct vty *, int, const char *);
-int ldp_vty_l2vpn_pw_pwstatus(struct vty *, int);
+int ldp_vty_mpls_ldp (struct vty *, const char *);
+int ldp_vty_address_family (struct vty *, const char *, const char *);
+int ldp_vty_disc_holdtime(struct vty *, const char *, const char *, long);
+int ldp_vty_disc_interval(struct vty *, const char *, const char *, long);
+int ldp_vty_targeted_hello_accept(struct vty *, const char *, const char *);
+int ldp_vty_nbr_session_holdtime(struct vty *, const char *, struct in_addr, long);
+int ldp_vty_af_session_holdtime(struct vty *, const char *, long);
+int ldp_vty_interface(struct vty *, const char *, const char *);
+int ldp_vty_trans_addr(struct vty *, const char *, const char *);
+int ldp_vty_neighbor_targeted(struct vty *, const char *, const char *);
+int ldp_vty_label_advertise(struct vty *, const char *, const char *, const char *);
+int ldp_vty_label_allocate(struct vty *, const char *, const char *, const char *);
+int ldp_vty_label_expnull(struct vty *, const char *, const char *);
+int ldp_vty_label_accept(struct vty *, const char *, const char *, const char *);
+int ldp_vty_ttl_security(struct vty *, const char *);
+int ldp_vty_router_id(struct vty *, const char *, struct in_addr);
+int ldp_vty_ds_cisco_interop(struct vty *, const char *);
+int ldp_vty_trans_pref_ipv4(struct vty *, const char *);
+int ldp_vty_neighbor_password(struct vty *, const char *, struct in_addr, const char *);
+int ldp_vty_neighbor_ttl_security(struct vty *, const char *, struct in_addr, const char *);
+int ldp_vty_l2vpn(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_bridge(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_mtu(struct vty *, const char *, long);
+int ldp_vty_l2vpn_pwtype(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_interface(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_pseudowire(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_pw_cword(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_pw_nbr_addr(struct vty *, const char *, const char *);
+int ldp_vty_l2vpn_pw_nbr_id(struct vty *, const char *, struct in_addr);
+int ldp_vty_l2vpn_pw_pwid(struct vty *, const char *, long);
+int ldp_vty_l2vpn_pw_pwstatus(struct vty *, const char *);
int ldp_vty_clear_nbr(struct vty *, const char *);
-int ldp_vty_debug(struct vty *, int, const char *, const char *, int);
-int ldp_vty_show_binding(struct vty *, const char *, int, int);
-int ldp_vty_show_discovery(struct vty *, const char *, int, int);
-int ldp_vty_show_interface(struct vty *, const char *, int);
-int ldp_vty_show_capabilities(struct vty *, int);
-int ldp_vty_show_neighbor(struct vty *, int, int, int);
-int ldp_vty_show_atom_binding(struct vty *, int);
-int ldp_vty_show_atom_vc(struct vty *, int);
+int ldp_vty_debug(struct vty *, const char *, const char *, const char *, const char *);
+int ldp_vty_show_binding(struct vty *, const char *, const char *, const char *);
+int ldp_vty_show_discovery(struct vty *, const char *, const char *, const char *);
+int ldp_vty_show_interface(struct vty *, const char *, const char *);
+int ldp_vty_show_capabilities(struct vty *, const char *);
+int ldp_vty_show_neighbor(struct vty *, int, const char *, const char *);
+int ldp_vty_show_atom_binding(struct vty *, const char *);
+int ldp_vty_show_atom_vc(struct vty *, const char *);
int ldp_vty_show_debugging(struct vty *);
void ldp_vty_init(void);
diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c
index d28424cbb7..7da76185c6 100644
--- a/ldpd/ldp_vty_cmds.c
+++ b/ldpd/ldp_vty_cmds.c
@@ -21,68 +21,98 @@
#include "command.h"
#include "vty.h"
+#include "ldpd/ldpd.h"
#include "ldpd/ldp_vty.h"
+#include "ldpd/ldp_vty_cmds_clippy.c"
DEFUN_NOSH(ldp_mpls_ldp,
ldp_mpls_ldp_cmd,
- "[no] mpls ldp",
- "Negate a command or set its defaults\n"
+ "mpls ldp",
"Global MPLS configuration subcommands\n"
"Label Distribution Protocol\n")
{
- int idx = 0;
- int negate = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
+ return (ldp_vty_mpls_ldp(vty, NULL));
+}
- return (ldp_vty_mpls_ldp(vty, negate));
+DEFPY (no_ldp_mpls_ldp,
+ no_ldp_mpls_ldp_cmd,
+ "no mpls ldp",
+ "Negate a command or set its defaults\n"
+ "Global MPLS configuration subcommands\n"
+ "Label Distribution Protocol\n")
+{
+ return (ldp_vty_mpls_ldp(vty, "no"));
}
DEFUN_NOSH(ldp_l2vpn,
ldp_l2vpn_cmd,
- "[no] l2vpn WORD type vpls",
- "Negate a command or set its defaults\n"
+ "l2vpn WORD type vpls",
"Configure l2vpn commands\n"
"L2VPN name\n"
"L2VPN type\n"
"Virtual Private LAN Service\n")
{
int idx = 0;
- int negate = 0;
const char *name;
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
argv_find(argv, argc, "WORD", &idx);
name = argv[idx]->arg;
- return (ldp_vty_l2vpn(vty, negate, name));
+ return (ldp_vty_l2vpn(vty, 0, name));
+}
+
+DEFPY (no_ldp_l2vpn,
+ no_ldp_l2vpn_cmd,
+ "no l2vpn WORD$l2vpn_name type vpls",
+ "Negate a command or set its defaults\n"
+ "Configure l2vpn commands\n"
+ "L2VPN name\n"
+ "L2VPN type\n"
+ "Virtual Private LAN Service\n")
+{
+ return (ldp_vty_l2vpn(vty, "no", l2vpn_name));
}
DEFUN_NOSH(ldp_address_family,
ldp_address_family_cmd,
- "[no] address-family <ipv4|ipv6>",
- "Negate a command or set its defaults\n"
+ "address-family <ipv4|ipv6>",
"Configure Address Family and its parameters\n"
"IPv4\n"
"IPv6\n")
{
int idx = 0;
- int negate = 0;
const char *af;
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
argv_find(argv, argc, "address-family", &idx);
af = argv[idx + 1]->text;
- return (ldp_vty_address_family(vty, negate, af));
+ return (ldp_vty_address_family(vty, 0, af));
}
-DEFUN (ldp_discovery_holdtime,
+DEFPY (no_ldp_address_family,
+ no_ldp_address_family_cmd,
+ "no address-family <ipv4|ipv6>$af",
+ "Negate a command or set its defaults\n"
+ "Configure Address Family and its parameters\n"
+ "IPv4\n"
+ "IPv6\n")
+{
+ return (ldp_vty_address_family(vty, "no", af));
+}
+
+DEFUN_NOSH(ldp_exit_address_family,
+ ldp_exit_address_family_cmd,
+ "exit-address-family",
+ "Exit from Address Family configuration mode\n")
+{
+ if (vty->node == LDP_IPV4_NODE || vty->node == LDP_IPV6_NODE)
+ vty->node = LDP_NODE;
+ return CMD_SUCCESS;
+}
+
+DEFPY (ldp_discovery_holdtime,
ldp_discovery_holdtime_cmd,
- "[no] discovery <hello|targeted-hello> holdtime (1-65535)",
+ "[no] discovery <hello|targeted-hello>$hello_type holdtime (1-65535)$holdtime",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Link Hellos\n"
@@ -90,24 +120,12 @@ DEFUN (ldp_discovery_holdtime,
"Hello holdtime\n"
"Time (seconds) - 65535 implies infinite\n")
{
- int idx = 0;
- int negate = 0;
- const char *hello_type;
- const char *holdtime;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "discovery", &idx);
- hello_type = argv[idx + 1]->text;
- argv_find(argv, argc, "(1-65535)", &idx);
- holdtime = argv[idx]->arg;
-
- return (ldp_vty_disc_holdtime(vty, negate, hello_type, holdtime));
+ return (ldp_vty_disc_holdtime(vty, no, hello_type, holdtime));
}
-DEFUN (ldp_discovery_interval,
+DEFPY (ldp_discovery_interval,
ldp_discovery_interval_cmd,
- "[no] discovery <hello|targeted-hello> interval (1-65535)",
+ "[no] discovery <hello|targeted-hello>$hello_type interval (1-65535)$interval",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Link Hellos\n"
@@ -115,22 +133,10 @@ DEFUN (ldp_discovery_interval,
"Hello interval\n"
"Time (seconds)\n")
{
- int idx = 0;
- int negate = 0;
- const char *hello_type;
- const char *interval;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "discovery", &idx);
- hello_type = argv[idx + 1]->text;
- argv_find(argv, argc, "(1-65535)", &idx);
- interval = argv[idx]->arg;
-
- return (ldp_vty_disc_interval(vty, negate, hello_type, interval));
+ return (ldp_vty_disc_interval(vty, no, hello_type, interval));
}
-DEFUN (ldp_dual_stack_transport_connection_prefer_ipv4,
+DEFPY (ldp_dual_stack_transport_connection_prefer_ipv4,
ldp_dual_stack_transport_connection_prefer_ipv4_cmd,
"[no] dual-stack transport-connection prefer ipv4",
"Negate a command or set its defaults\n"
@@ -139,58 +145,34 @@ DEFUN (ldp_dual_stack_transport_connection_prefer_ipv4,
"Configure prefered address family for TCP transport connection with neighbor\n"
"IPv4\n")
{
- int idx = 0;
- int negate = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- return (ldp_vty_trans_pref_ipv4(vty, negate));
+ return (ldp_vty_trans_pref_ipv4(vty, no));
}
-DEFUN (ldp_dual_stack_cisco_interop,
+DEFPY (ldp_dual_stack_cisco_interop,
ldp_dual_stack_cisco_interop_cmd,
"[no] dual-stack cisco-interop",
"Negate a command or set its defaults\n"
"Configure dual stack parameters\n"
"Use Cisco non-compliant format to send and interpret the Dual-Stack capability TLV\n")
{
- int idx = 0;
- int negate = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- return (ldp_vty_ds_cisco_interop(vty, negate));
+ return (ldp_vty_ds_cisco_interop(vty, no));
}
-DEFUN (ldp_neighbor_password,
+DEFPY (ldp_neighbor_password,
ldp_neighbor_password_cmd,
- "[no] neighbor A.B.C.D password WORD",
+ "[no] neighbor A.B.C.D$neighbor password WORD$password",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
"Configure password for MD5 authentication\n"
"The password\n")
{
- int idx = 0;
- int negate = 0;
- const char *neighbor;
- const char *password;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- neighbor = argv[idx]->arg;
- argv_find(argv, argc, "WORD", &idx);
- password = argv[idx]->arg;
-
- return (ldp_vty_neighbor_password(vty, negate, neighbor, password));
+ return (ldp_vty_neighbor_password(vty, no, neighbor, password));
}
-DEFUN (ldp_neighbor_session_holdtime,
+DEFPY (ldp_neighbor_session_holdtime,
ldp_neighbor_session_holdtime_cmd,
- "[no] neighbor A.B.C.D session holdtime (15-65535)",
+ "[no] neighbor A.B.C.D$neighbor session holdtime (15-65535)$holdtime",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
@@ -198,24 +180,12 @@ DEFUN (ldp_neighbor_session_holdtime,
"Configure session holdtime\n"
"Time (seconds)\n")
{
- int idx = 0;
- int negate = 0;
- const char *neighbor;
- const char *holdtime;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- neighbor = argv[idx]->arg;
- argv_find(argv, argc, "(15-65535)", &idx);
- holdtime = argv[idx]->arg;
-
- return (ldp_vty_nbr_session_holdtime(vty, negate, neighbor, holdtime));
+ return (ldp_vty_nbr_session_holdtime(vty, no, neighbor, holdtime));
}
-DEFUN (ldp_neighbor_ttl_security,
+DEFPY (ldp_neighbor_ttl_security,
ldp_neighbor_ttl_security_cmd,
- "[no] neighbor A.B.C.D ttl-security <disable|hops (1-254)>",
+ "[no] neighbor A.B.C.D$neighbor ttl-security <disable|hops (1-254)$hops>",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"LDP Id of neighbor\n"
@@ -224,43 +194,22 @@ DEFUN (ldp_neighbor_ttl_security,
"IP hops\n"
"maximum number of hops\n")
{
- int idx = 0;
- int negate = 0;
- const char *neighbor;
- const char *hops = NULL;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- neighbor = argv[idx]->arg;
- if (argv_find(argv, argc, "(1-254)", &idx))
- hops = argv[idx]->arg;
-
- return (ldp_vty_neighbor_ttl_security(vty, negate, neighbor, hops));
+ return (ldp_vty_neighbor_ttl_security(vty, no, neighbor, hops_str));
}
-DEFUN (ldp_router_id,
+DEFPY (ldp_router_id,
ldp_router_id_cmd,
- "[no] router-id A.B.C.D",
+ "[no] router-id A.B.C.D$address",
"Negate a command or set its defaults\n"
"Configure router Id\n"
"LSR Id (in form of an IPv4 address)\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- address = argv[idx]->arg;
-
- return (ldp_vty_router_id(vty, negate, address));
+ return (ldp_vty_router_id(vty, no, address));
}
-DEFUN (ldp_discovery_targeted_hello_accept,
+DEFPY (ldp_discovery_targeted_hello_accept,
ldp_discovery_targeted_hello_accept_cmd,
- "[no] discovery targeted-hello accept [from <(1-199)|(1300-2699)|WORD>]",
+ "[no] discovery targeted-hello accept [from <(1-199)|(1300-2699)|WORD>$from_acl]",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"LDP Targeted Hellos\n"
@@ -270,61 +219,34 @@ DEFUN (ldp_discovery_targeted_hello_accept,
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
- int idx = 0;
- int negate = 0;
- const char *from_acl = NULL;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- if (argv_find(argv, argc, "from", &idx))
- from_acl = argv[idx + 1]->arg;
-
- return (ldp_vty_targeted_hello_accept(vty, negate, from_acl));
+ return (ldp_vty_targeted_hello_accept(vty, no, from_acl));
}
-DEFUN (ldp_discovery_transport_address_ipv4,
+DEFPY (ldp_discovery_transport_address_ipv4,
ldp_discovery_transport_address_ipv4_cmd,
- "[no] discovery transport-address A.B.C.D",
+ "[no] discovery transport-address A.B.C.D$address",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"Specify transport address for TCP connection\n"
"IP address to be used as transport address\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- address = argv[idx]->arg;
-
- return (ldp_vty_trans_addr(vty, negate, address));
+ return (ldp_vty_trans_addr(vty, no, address_str));
}
-DEFUN (ldp_discovery_transport_address_ipv6,
+DEFPY (ldp_discovery_transport_address_ipv6,
ldp_discovery_transport_address_ipv6_cmd,
- "[no] discovery transport-address X:X::X:X",
+ "[no] discovery transport-address X:X::X:X$address",
"Negate a command or set its defaults\n"
"Configure discovery parameters\n"
"Specify transport address for TCP connection\n"
"IPv6 address to be used as transport address\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "X:X::X:X", &idx);
- address = argv[idx]->arg;
-
- return (ldp_vty_trans_addr(vty, negate, address));
+ return (ldp_vty_trans_addr(vty, no, address_str));
}
-DEFUN (ldp_label_local_advertise,
+DEFPY (ldp_label_local_advertise,
ldp_label_local_advertise_cmd,
- "[no] label local advertise [{to <(1-199)|(1300-2699)|WORD>|for <(1-199)|(1300-2699)|WORD>}]",
+ "[no] label local advertise [{to <(1-199)|(1300-2699)|WORD>$to_acl|for <(1-199)|(1300-2699)|WORD>$for_acl}]",
"Negate a command or set its defaults\n"
"Configure label control and policies\n"
"Configure local label control and policies\n"
@@ -338,27 +260,12 @@ DEFUN (ldp_label_local_advertise,
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
- int idx = 0;
- int negate = 0;
- const char *to_acl = NULL;
- const char *for_acl = NULL;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- /* arguments within curly braces may be provided in any order */
- if (argv_find(argv, argc, "to", &idx))
- to_acl = argv[idx + 1]->arg;
- idx = 0;
- if (argv_find(argv, argc, "for", &idx))
- for_acl = argv[idx + 1]->arg;
-
- return (ldp_vty_label_advertise(vty, negate, to_acl, for_acl));
+ return (ldp_vty_label_advertise(vty, no, to_acl, for_acl));
}
-DEFUN (ldp_label_local_advertise_explicit_null,
+DEFPY (ldp_label_local_advertise_explicit_null,
ldp_label_local_advertise_explicit_null_cmd,
- "[no] label local advertise explicit-null [for <(1-199)|(1300-2699)|WORD>]",
+ "[no] label local advertise explicit-null [for <(1-199)|(1300-2699)|WORD>$for_acl]",
"Negate a command or set its defaults\n"
"Configure label control and policies\n"
"Configure local label control and policies\n"
@@ -369,21 +276,12 @@ DEFUN (ldp_label_local_advertise_explicit_null,
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
- int idx = 0;
- int negate = 0;
- const char *for_acl = NULL;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- if (argv_find(argv, argc, "for", &idx))
- for_acl = argv[idx + 1]->arg;
-
- return (ldp_vty_label_expnull(vty, negate, for_acl));
+ return (ldp_vty_label_expnull(vty, no, for_acl));
}
-DEFUN (ldp_label_local_allocate,
+DEFPY (ldp_label_local_allocate,
ldp_label_local_allocate_cmd,
- "[no] label local allocate <host-routes|for <(1-199)|(1300-2699)|WORD>>",
+ "[no] label local allocate <host-routes$host_routes|for <(1-199)|(1300-2699)|WORD>$for_acl>",
"Negate a command or set its defaults\n"
"Configure label control and policies\n"
"Configure local label control and policies\n"
@@ -394,27 +292,12 @@ DEFUN (ldp_label_local_allocate,
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
- int idx = 0;
- int negate = 0;
- int host_routes = 0;
- const char *for_acl = NULL;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- /* arguments within curly braces may be provided in any order */
- if (argv_find(argv, argc, "host-routes", &idx))
- host_routes = 1;
- idx = 0;
- if (argv_find(argv, argc, "for", &idx))
- for_acl = argv[idx + 1]->arg;
-
- return (ldp_vty_label_allocate(vty, negate, host_routes, for_acl));
+ return (ldp_vty_label_allocate(vty, no, host_routes, for_acl));
}
-DEFUN (ldp_label_remote_accept,
+DEFPY (ldp_label_remote_accept,
ldp_label_remote_accept_cmd,
- "[no] label remote accept {from <(1-199)|(1300-2699)|WORD>|for <(1-199)|(1300-2699)|WORD>}",
+ "[no] label remote accept {from <(1-199)|(1300-2699)|WORD>$from_acl|for <(1-199)|(1300-2699)|WORD>$for_acl}",
"Negate a command or set its defaults\n"
"Configure label control and policies\n"
"Configure remote/peer label control and policies\n"
@@ -428,317 +311,204 @@ DEFUN (ldp_label_remote_accept,
"IP access-list number (expanded range)\n"
"IP access-list name\n")
{
- int idx = 0;
- int negate = 0;
- const char *from_acl = NULL;
- const char *for_acl = NULL;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- /* arguments within curly braces may be provided in any order */
- if (argv_find(argv, argc, "from", &idx))
- from_acl = argv[idx + 1]->arg;
- idx = 0;
- if (argv_find(argv, argc, "for", &idx))
- for_acl = argv[idx + 1]->arg;
-
- return (ldp_vty_label_accept(vty, negate, from_acl, for_acl));
+ return (ldp_vty_label_accept(vty, no, from_acl, for_acl));
}
-DEFUN (ldp_ttl_security_disable,
+DEFPY (ldp_ttl_security_disable,
ldp_ttl_security_disable_cmd,
"[no] ttl-security disable",
"Negate a command or set its defaults\n"
"LDP ttl security check\n"
"Disable ttl security\n")
{
- int idx = 0;
- int negate = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- return (ldp_vty_ttl_security(vty, negate));
+ return (ldp_vty_ttl_security(vty, no));
}
-DEFUN (ldp_session_holdtime,
+DEFPY (ldp_session_holdtime,
ldp_session_holdtime_cmd,
- "[no] session holdtime (15-65535)",
+ "[no] session holdtime (15-65535)$holdtime",
"Negate a command or set its defaults\n"
"Configure session parameters\n"
"Configure session holdtime\n"
"Time (seconds)\n")
{
- int idx = 0;
- int negate = 0;
- const char *holdtime;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "(15-65535)", &idx);
- holdtime = argv[idx]->arg;
-
- return (ldp_vty_af_session_holdtime(vty, negate, holdtime));
+ return (ldp_vty_af_session_holdtime(vty, no, holdtime));
}
DEFUN_NOSH(ldp_interface,
ldp_interface_cmd,
- "[no] interface IFNAME",
- "Negate a command or set its defaults\n"
+ "interface IFNAME",
"Enable LDP on an interface and enter interface submode\n"
"Interface's name\n")
{
int idx = 0;
- int negate = 0;
const char *ifname;
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
argv_find(argv, argc, "IFNAME", &idx);
ifname = argv[idx]->arg;
- return (ldp_vty_interface(vty, negate, ifname));
+ return (ldp_vty_interface(vty, 0, ifname));
}
-DEFUN (ldp_neighbor_ipv4_targeted,
+DEFPY (no_ldp_interface,
+ no_ldp_interface_cmd,
+ "no interface IFNAME$ifname",
+ "Negate a command or set its defaults\n"
+ "Enable LDP on an interface and enter interface submode\n"
+ "Interface's name\n")
+{
+ return (ldp_vty_interface(vty, "no", ifname));
+}
+
+DEFPY (ldp_neighbor_ipv4_targeted,
ldp_neighbor_ipv4_targeted_cmd,
- "[no] neighbor A.B.C.D targeted",
+ "[no] neighbor A.B.C.D$address targeted",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"IP address of neighbor\n"
"Establish targeted session\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- address = argv[idx]->arg;
-
- return (ldp_vty_neighbor_targeted(vty, negate, address));
+ return (ldp_vty_neighbor_targeted(vty, no, address_str));
}
-DEFUN (ldp_neighbor_ipv6_targeted,
+DEFPY (ldp_neighbor_ipv6_targeted,
ldp_neighbor_ipv6_targeted_cmd,
- "[no] neighbor X:X::X:X targeted",
+ "[no] neighbor X:X::X:X$address targeted",
"Negate a command or set its defaults\n"
"Configure neighbor parameters\n"
"IPv6 address of neighbor\n"
"Establish targeted session\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "X:X::X:X", &idx);
- address = argv[idx]->arg;
-
- return (ldp_vty_neighbor_targeted(vty, negate, address));
+ return (ldp_vty_neighbor_targeted(vty, no, address_str));
}
-DEFUN (ldp_bridge,
+DEFPY (ldp_bridge,
ldp_bridge_cmd,
- "[no] bridge IFNAME",
+ "[no] bridge IFNAME$ifname",
"Negate a command or set its defaults\n"
"Bridge interface\n"
"Interface's name\n")
{
- int idx = 0;
- int negate = 0;
- const char *ifname;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "IFNAME", &idx);
- ifname = argv[idx]->arg;
-
- return (ldp_vty_l2vpn_bridge(vty, negate, ifname));
+ return (ldp_vty_l2vpn_bridge(vty, no, ifname));
}
-DEFUN (ldp_mtu,
+DEFPY (ldp_mtu,
ldp_mtu_cmd,
- "[no] mtu (1500-9180)",
+ "[no] mtu (1500-9180)$mtu",
"Negate a command or set its defaults\n"
"Set Maximum Transmission Unit\n"
"Maximum Transmission Unit value\n")
{
- int idx = 0;
- int negate = 0;
- const char *mtu;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "(1500-9180)", &idx);
- mtu = argv[idx]->arg;
-
- return (ldp_vty_l2vpn_mtu(vty, negate, mtu));
+ return (ldp_vty_l2vpn_mtu(vty, no, mtu));
}
-DEFUN (ldp_member_interface,
+DEFPY (ldp_member_interface,
ldp_member_interface_cmd,
- "[no] member interface IFNAME",
+ "[no] member interface IFNAME$ifname",
"Negate a command or set its defaults\n"
"L2VPN member configuration\n"
"Local interface\n"
"Interface's name\n")
{
- int idx = 0;
- int negate = 0;
- const char *ifname;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "IFNAME", &idx);
- ifname = argv[idx]->arg;
-
- return (ldp_vty_l2vpn_interface(vty, negate, ifname));
+ return (ldp_vty_l2vpn_interface(vty, no, ifname));
}
DEFUN_NOSH(ldp_member_pseudowire,
ldp_member_pseudowire_cmd,
- "[no] member pseudowire IFNAME",
- "Negate a command or set its defaults\n"
+ "member pseudowire IFNAME",
"L2VPN member configuration\n"
"Pseudowire interface\n"
"Interface's name\n")
{
int idx = 0;
- int negate = 0;
const char *ifname;
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
argv_find(argv, argc, "IFNAME", &idx);
ifname = argv[idx]->arg;
- return (ldp_vty_l2vpn_pseudowire(vty, negate, ifname));
+ return (ldp_vty_l2vpn_pseudowire(vty, 0, ifname));
}
-DEFUN (ldp_vc_type,
+DEFPY (no_ldp_member_pseudowire,
+ no_ldp_member_pseudowire_cmd,
+ "no member pseudowire IFNAME$ifname",
+ "Negate a command or set its defaults\n"
+ "L2VPN member configuration\n"
+ "Pseudowire interface\n"
+ "Interface's name\n")
+{
+ return (ldp_vty_l2vpn_pseudowire(vty, "no", ifname));
+}
+
+DEFPY (ldp_vc_type,
ldp_vc_type_cmd,
- "[no] vc type <ethernet|ethernet-tagged>",
+ "[no] vc type <ethernet|ethernet-tagged>$vc_type",
"Negate a command or set its defaults\n"
"Virtual Circuit options\n"
"Virtual Circuit type to use\n"
"Ethernet (type 5)\n"
"Ethernet-tagged (type 4)\n")
{
- int idx = 0;
- int negate = 0;
- const char *vc_type;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "type", &idx);
- vc_type = argv[idx + 1]->text;
-
- return (ldp_vty_l2vpn_pwtype(vty, negate, vc_type));
+ return (ldp_vty_l2vpn_pwtype(vty, no, vc_type));
}
-DEFUN (ldp_control_word,
+DEFPY (ldp_control_word,
ldp_control_word_cmd,
- "[no] control-word <exclude|include>",
+ "[no] control-word <exclude|include>$preference",
"Negate a command or set its defaults\n"
"Control-word options\n"
"Exclude control-word in pseudowire packets\n"
"Include control-word in pseudowire packets\n")
{
- int idx = 0;
- int negate = 0;
- const char *preference;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "control-word", &idx);
- preference = argv[idx + 1]->text;
-
- return (ldp_vty_l2vpn_pw_cword(vty, negate, preference));
+ return (ldp_vty_l2vpn_pw_cword(vty, no, preference));
}
-DEFUN (ldp_neighbor_address,
+DEFPY (ldp_neighbor_address,
ldp_neighbor_address_cmd,
- "[no] neighbor address <A.B.C.D|X:X::X:X>",
+ "[no] neighbor address <A.B.C.D|X:X::X:X>$pw_address",
"Negate a command or set its defaults\n"
"Remote endpoint configuration\n"
"Specify the IPv4 or IPv6 address of the remote endpoint\n"
"IPv4 address\n"
"IPv6 address\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "address", &idx);
- address = argv[idx + 1]->arg;
-
- return (ldp_vty_l2vpn_pw_nbr_addr(vty, negate, address));
+ return (ldp_vty_l2vpn_pw_nbr_addr(vty, no, pw_address_str));
}
-DEFUN (ldp_neighbor_lsr_id,
+DEFPY (ldp_neighbor_lsr_id,
ldp_neighbor_lsr_id_cmd,
- "[no] neighbor lsr-id A.B.C.D",
+ "[no] neighbor lsr-id A.B.C.D$address",
"Negate a command or set its defaults\n"
"Remote endpoint configuration\n"
"Specify the LSR-ID of the remote endpoint\n"
"IPv4 address\n")
{
- int idx = 0;
- int negate = 0;
- const char *address;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "A.B.C.D", &idx);
- address = argv[idx]->arg;
-
- return (ldp_vty_l2vpn_pw_nbr_id(vty, negate, address));
+ return (ldp_vty_l2vpn_pw_nbr_id(vty, no, address));
}
-DEFUN (ldp_pw_id,
+DEFPY (ldp_pw_id,
ldp_pw_id_cmd,
- "[no] pw-id (1-4294967295)",
+ "[no] pw-id (1-4294967295)$pwid",
"Negate a command or set its defaults\n"
"Set the Virtual Circuit ID\n"
"Virtual Circuit ID value\n")
{
- int idx = 0;
- int negate = 0;
- const char *pwid;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "(1-4294967295)", &idx);
- pwid = argv[idx]->arg;
-
- return (ldp_vty_l2vpn_pw_pwid(vty, negate, pwid));
+ return (ldp_vty_l2vpn_pw_pwid(vty, no, pwid));
}
-DEFUN (ldp_pw_status_disable,
+DEFPY (ldp_pw_status_disable,
ldp_pw_status_disable_cmd,
"[no] pw-status disable",
"Negate a command or set its defaults\n"
"Configure PW status\n"
"Disable PW status\n")
{
- int idx = 0;
- int negate = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
-
- return (ldp_vty_l2vpn_pw_pwstatus(vty, negate));
+ return (ldp_vty_l2vpn_pw_pwstatus(vty, no));
}
-DEFUN (ldp_clear_mpls_ldp_neighbor,
+DEFPY (ldp_clear_mpls_ldp_neighbor,
ldp_clear_mpls_ldp_neighbor_cmd,
- "clear mpls ldp neighbor [<A.B.C.D|X:X::X:X>]",
+ "clear mpls ldp neighbor [<A.B.C.D|X:X::X:X>]$address",
"Reset functions\n"
"Reset MPLS statistical information\n"
"Clear LDP state\n"
@@ -746,18 +516,12 @@ DEFUN (ldp_clear_mpls_ldp_neighbor,
"IPv4 address\n"
"IPv6 address\n")
{
- int idx = 0;
- const char *address = NULL;
-
- if (argv_find(argv, argc, "neighbor", &idx))
- address = argv[idx + 1]->arg;
-
- return (ldp_vty_clear_nbr(vty, address));
+ return (ldp_vty_clear_nbr(vty, address_str));
}
-DEFUN (ldp_debug_mpls_ldp_discovery_hello,
+DEFPY (ldp_debug_mpls_ldp_discovery_hello,
ldp_debug_mpls_ldp_discovery_hello_cmd,
- "[no] debug mpls ldp discovery hello <recv|sent>",
+ "[no] debug mpls ldp discovery hello <recv|sent>$dir",
"Negate a command or set its defaults\n"
"Debugging functions\n"
"MPLS information\n"
@@ -767,21 +531,12 @@ DEFUN (ldp_debug_mpls_ldp_discovery_hello,
"Received messages\n"
"Sent messages\n")
{
- int idx = 0;
- int negate = 0;
- const char *dir;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "hello", &idx);
- dir = argv[idx + 1]->text;
-
- return (ldp_vty_debug(vty, negate, "discovery", dir, 0));
+ return (ldp_vty_debug(vty, no, "discovery", dir, NULL));
}
-DEFUN (ldp_debug_mpls_ldp_type,
+DEFPY (ldp_debug_mpls_ldp_type,
ldp_debug_mpls_ldp_type_cmd,
- "[no] debug mpls ldp <errors|event|zebra>",
+ "[no] debug mpls ldp <errors|event|zebra>$type",
"Negate a command or set its defaults\n"
"Debugging functions\n"
"MPLS information\n"
@@ -790,21 +545,12 @@ DEFUN (ldp_debug_mpls_ldp_type,
"LDP event information\n"
"LDP zebra information\n")
{
- int idx = 0;
- int negate = 0;
- const char *type;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- argv_find(argv, argc, "ldp", &idx);
- type = argv[idx + 1]->text;
-
- return (ldp_vty_debug(vty, negate, type, NULL, 0));
+ return (ldp_vty_debug(vty, no, type, NULL, NULL));
}
-DEFUN (ldp_debug_mpls_ldp_messages_recv,
+DEFPY (ldp_debug_mpls_ldp_messages_recv,
ldp_debug_mpls_ldp_messages_recv_cmd,
- "[no] debug mpls ldp messages recv [all]",
+ "[no] debug mpls ldp messages recv [all]$all",
"Negate a command or set its defaults\n"
"Debugging functions\n"
"MPLS information\n"
@@ -813,21 +559,12 @@ DEFUN (ldp_debug_mpls_ldp_messages_recv,
"Received messages, excluding periodic Keep Alives\n"
"Received messages, including periodic Keep Alives\n")
{
- int idx = 0;
- int negate = 0;
- int all = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- if (argv_find(argv, argc, "all", &idx))
- all = 1;
-
- return (ldp_vty_debug(vty, negate, "messages", "recv", all));
+ return (ldp_vty_debug(vty, no, "messages", "recv", all));
}
-DEFUN (ldp_debug_mpls_ldp_messages_sent,
+DEFPY (ldp_debug_mpls_ldp_messages_sent,
ldp_debug_mpls_ldp_messages_sent_cmd,
- "[no] debug mpls ldp messages sent [all]",
+ "[no] debug mpls ldp messages sent [all]$all",
"Negate a command or set its defaults\n"
"Debugging functions\n"
"MPLS information\n"
@@ -836,21 +573,12 @@ DEFUN (ldp_debug_mpls_ldp_messages_sent,
"Sent messages, excluding periodic Keep Alives\n"
"Sent messages, including periodic Keep Alives\n")
{
- int idx = 0;
- int negate = 0;
- int all = 0;
-
- if (argv_find(argv, argc, "no", &idx))
- negate = 1;
- if (argv_find(argv, argc, "all", &idx))
- all = 1;
-
- return (ldp_vty_debug(vty, negate, "messages", "sent", all));
+ return (ldp_vty_debug(vty, no, "messages", "sent", all));
}
-DEFUN (ldp_show_mpls_ldp_binding,
+DEFPY (ldp_show_mpls_ldp_binding,
ldp_show_mpls_ldp_binding_cmd,
- "show mpls ldp [<ipv4|ipv6>] binding [detail] [json]",
+ "show mpls ldp [<ipv4|ipv6>]$af binding [detail]$detail [json]$json",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@@ -860,25 +588,12 @@ DEFUN (ldp_show_mpls_ldp_binding,
"Show detailed information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- const char *af = NULL;
- int detail = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "ipv4", &idx) ||
- argv_find(argv, argc, "ipv6", &idx))
- af = argv[idx]->text;
- if (argv_find(argv, argc, "detail", &idx))
- detail = 1;
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_binding(vty, af, detail, json));
}
-DEFUN (ldp_show_mpls_ldp_discovery,
+DEFPY (ldp_show_mpls_ldp_discovery,
ldp_show_mpls_ldp_discovery_cmd,
- "show mpls ldp [<ipv4|ipv6>] discovery [detail] [json]",
+ "show mpls ldp [<ipv4|ipv6>]$af discovery [detail]$detail [json]$json",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@@ -888,25 +603,12 @@ DEFUN (ldp_show_mpls_ldp_discovery,
"Show detailed information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- const char *af = NULL;
- int detail = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "ipv4", &idx) ||
- argv_find(argv, argc, "ipv6", &idx))
- af = argv[idx]->text;
- if (argv_find(argv, argc, "detail", &idx))
- detail = 1;
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_discovery(vty, af, detail, json));
}
-DEFUN (ldp_show_mpls_ldp_interface,
+DEFPY (ldp_show_mpls_ldp_interface,
ldp_show_mpls_ldp_interface_cmd,
- "show mpls ldp [<ipv4|ipv6>] interface [json]",
+ "show mpls ldp [<ipv4|ipv6>]$af interface [json]$json",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@@ -915,40 +617,24 @@ DEFUN (ldp_show_mpls_ldp_interface,
"interface information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- const char *af = NULL;
- int json = 0;
-
- if (argv_find(argv, argc, "ipv4", &idx) ||
- argv_find(argv, argc, "ipv6", &idx))
- af = argv[idx]->text;
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_interface(vty, af, json));
}
-DEFUN (ldp_show_mpls_ldp_capabilities,
+DEFPY (ldp_show_mpls_ldp_capabilities,
ldp_show_mpls_ldp_capabilities_cmd,
- "show mpls ldp capabilities [json]",
+ "show mpls ldp capabilities [json]$json",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
"Display LDP Capabilities information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_capabilities(vty, json));
}
-DEFUN (ldp_show_mpls_ldp_neighbor,
+DEFPY (ldp_show_mpls_ldp_neighbor,
ldp_show_mpls_ldp_neighbor_cmd,
- "show mpls ldp neighbor [detail] [json]",
+ "show mpls ldp neighbor [detail]$detail [json]$json",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@@ -956,21 +642,12 @@ DEFUN (ldp_show_mpls_ldp_neighbor,
"Show detailed information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- int detail = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "detail", &idx))
- detail = 1;
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_neighbor(vty, 0, detail, json));
}
-DEFUN (ldp_show_mpls_ldp_neighbor_capabilities,
+DEFPY (ldp_show_mpls_ldp_neighbor_capabilities,
ldp_show_mpls_ldp_neighbor_capabilities_cmd,
- "show mpls ldp neighbor capabilities [json]",
+ "show mpls ldp neighbor capabilities [json]$json",
"Show running system information\n"
"MPLS information\n"
"Label Distribution Protocol\n"
@@ -978,52 +655,34 @@ DEFUN (ldp_show_mpls_ldp_neighbor_capabilities,
"Display neighbor capability information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
- return (ldp_vty_show_neighbor(vty, 1, 0, json));
+ return (ldp_vty_show_neighbor(vty, 1, NULL, json));
}
-DEFUN (ldp_show_l2vpn_atom_binding,
+DEFPY (ldp_show_l2vpn_atom_binding,
ldp_show_l2vpn_atom_binding_cmd,
- "show l2vpn atom binding [json]",
+ "show l2vpn atom binding [json]$json",
"Show running system information\n"
"Show information about Layer2 VPN\n"
"Show Any Transport over MPLS information\n"
"Show AToM label binding information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_atom_binding(vty, json));
}
-DEFUN (ldp_show_l2vpn_atom_vc,
+DEFPY (ldp_show_l2vpn_atom_vc,
ldp_show_l2vpn_atom_vc_cmd,
- "show l2vpn atom vc [json]",
+ "show l2vpn atom vc [json]$json",
"Show running system information\n"
"Show information about Layer2 VPN\n"
"Show Any Transport over MPLS information\n"
"Show AToM virtual circuit information\n"
"JavaScript Object Notation\n")
{
- int idx = 0;
- int json = 0;
-
- if (argv_find(argv, argc, "json", &idx))
- json = 1;
-
return (ldp_vty_show_atom_vc(vty, json));
}
-DEFUN (ldp_show_debugging_mpls_ldp,
+DEFPY (ldp_show_debugging_mpls_ldp,
ldp_show_debugging_mpls_ldp_cmd,
"show debugging mpls ldp",
"Show running system information\n"
@@ -1034,9 +693,30 @@ DEFUN (ldp_show_debugging_mpls_ldp,
return (ldp_vty_show_debugging(vty));
}
+static void
+l2vpn_autocomplete(vector comps, struct cmd_token *token)
+{
+ struct l2vpn *l2vpn;
+
+ RB_FOREACH(l2vpn, l2vpn_head, &vty_conf->l2vpn_tree)
+ vector_set(comps, XSTRDUP(MTYPE_COMPLETION, l2vpn->name));
+}
+
+static const struct cmd_variable_handler l2vpn_var_handlers[] = {
+ {
+ .varname = "l2vpn_name",
+ .completions = l2vpn_autocomplete
+ },
+ {
+ .completions = NULL
+ }
+};
+
void
ldp_vty_init (void)
{
+ cmd_variable_handler_register(l2vpn_var_handlers);
+
install_node(&ldp_node, ldp_config_write);
install_node(&ldp_ipv4_node, NULL);
install_node(&ldp_ipv6_node, NULL);
@@ -1054,13 +734,16 @@ ldp_vty_init (void)
install_default(LDP_PSEUDOWIRE_NODE);
install_element(CONFIG_NODE, &ldp_mpls_ldp_cmd);
+ install_element(CONFIG_NODE, &no_ldp_mpls_ldp_cmd);
install_element(CONFIG_NODE, &ldp_l2vpn_cmd);
+ install_element(CONFIG_NODE, &no_ldp_l2vpn_cmd);
install_element(CONFIG_NODE, &ldp_debug_mpls_ldp_discovery_hello_cmd);
install_element(CONFIG_NODE, &ldp_debug_mpls_ldp_type_cmd);
install_element(CONFIG_NODE, &ldp_debug_mpls_ldp_messages_recv_cmd);
install_element(CONFIG_NODE, &ldp_debug_mpls_ldp_messages_sent_cmd);
install_element(LDP_NODE, &ldp_address_family_cmd);
+ install_element(LDP_NODE, &no_ldp_address_family_cmd);
install_element(LDP_NODE, &ldp_discovery_holdtime_cmd);
install_element(LDP_NODE, &ldp_discovery_interval_cmd);
install_element(LDP_NODE, &ldp_dual_stack_transport_connection_prefer_ipv4_cmd);
@@ -1080,8 +763,10 @@ ldp_vty_init (void)
install_element(LDP_IPV4_NODE, &ldp_label_remote_accept_cmd);
install_element(LDP_IPV4_NODE, &ldp_ttl_security_disable_cmd);
install_element(LDP_IPV4_NODE, &ldp_interface_cmd);
+ install_element(LDP_IPV4_NODE, &no_ldp_interface_cmd);
install_element(LDP_IPV4_NODE, &ldp_session_holdtime_cmd);
install_element(LDP_IPV4_NODE, &ldp_neighbor_ipv4_targeted_cmd);
+ install_element(LDP_IPV4_NODE, &ldp_exit_address_family_cmd);
install_element(LDP_IPV6_NODE, &ldp_discovery_holdtime_cmd);
install_element(LDP_IPV6_NODE, &ldp_discovery_interval_cmd);
@@ -1095,6 +780,7 @@ ldp_vty_init (void)
install_element(LDP_IPV6_NODE, &ldp_interface_cmd);
install_element(LDP_IPV6_NODE, &ldp_session_holdtime_cmd);
install_element(LDP_IPV6_NODE, &ldp_neighbor_ipv6_targeted_cmd);
+ install_element(LDP_IPV6_NODE, &ldp_exit_address_family_cmd);
install_element(LDP_IPV4_IFACE_NODE, &ldp_discovery_holdtime_cmd);
install_element(LDP_IPV4_IFACE_NODE, &ldp_discovery_interval_cmd);
@@ -1106,6 +792,7 @@ ldp_vty_init (void)
install_element(LDP_L2VPN_NODE, &ldp_mtu_cmd);
install_element(LDP_L2VPN_NODE, &ldp_member_interface_cmd);
install_element(LDP_L2VPN_NODE, &ldp_member_pseudowire_cmd);
+ install_element(LDP_L2VPN_NODE, &no_ldp_member_pseudowire_cmd);
install_element(LDP_L2VPN_NODE, &ldp_vc_type_cmd);
install_element(LDP_PSEUDOWIRE_NODE, &ldp_control_word_cmd);
diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c
index 4e900ca93e..e938582d0d 100644
--- a/ldpd/ldp_vty_conf.c
+++ b/ldpd/ldp_vty_conf.c
@@ -233,7 +233,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf,
ldp_af_iface_config_write(vty, af);
- vty_out (vty, " !\n");
+ vty_out(vty, " exit-address-family\n");
}
int
@@ -407,9 +407,9 @@ ldp_iface_is_configured(struct ldpd_conf *xconf, const char *ifname)
}
int
-ldp_vty_mpls_ldp(struct vty *vty, int disable)
+ldp_vty_mpls_ldp(struct vty *vty, const char *negate)
{
- if (disable)
+ if (negate)
vty_conf->flags &= ~F_LDPD_ENABLED;
else {
vty->node = LDP_NODE;
@@ -422,7 +422,7 @@ ldp_vty_mpls_ldp(struct vty *vty, int disable)
}
int
-ldp_vty_address_family(struct vty *vty, int disable, const char *af_str)
+ldp_vty_address_family(struct vty *vty, const char *negate, const char *af_str)
{
struct ldpd_af_conf *af_conf;
int af;
@@ -436,7 +436,7 @@ ldp_vty_address_family(struct vty *vty, int disable, const char *af_str)
} else
return (CMD_WARNING_CONFIG_FAILED);
- if (disable) {
+ if (negate) {
af_conf->flags &= ~F_LDPD_AF_ENABLED;
ldp_config_apply(vty, vty_conf);
return (CMD_SUCCESS);
@@ -460,23 +460,15 @@ ldp_vty_address_family(struct vty *vty, int disable, const char *af_str)
}
int
-ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
- const char *seconds_str)
+ldp_vty_disc_holdtime(struct vty *vty, const char *negate,
+ const char *hello_type_str, long secs)
{
struct ldpd_af_conf *af_conf;
struct iface *iface;
struct iface_af *ia;
int af;
- char *ep;
- long int secs;
enum hello_type hello_type;
- secs = strtol(seconds_str, &ep, 10);
- if (*ep != '\0' || secs < MIN_HOLDTIME || secs > MAX_HOLDTIME) {
- vty_out (vty, "%% Invalid holdtime\n");
- return (CMD_WARNING_CONFIG_FAILED);
- }
-
if (hello_type_str[0] == 'h')
hello_type = HELLO_LINK;
else
@@ -484,7 +476,7 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
switch (vty->node) {
case LDP_NODE:
- if (disable) {
+ if (negate) {
switch (hello_type) {
case HELLO_LINK:
vty_conf->lhello_holdtime = LINK_DFLT_HOLDTIME;
@@ -511,7 +503,7 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable) {
+ if (negate) {
switch (hello_type) {
case HELLO_LINK:
af_conf->lhello_holdtime = 0;
@@ -539,7 +531,7 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
VTY_CHECK_CONTEXT(iface);
ia = iface_af_get(iface, af);
- if (disable)
+ if (negate)
ia->hello_holdtime = 0;
else
ia->hello_holdtime = secs;
@@ -554,24 +546,15 @@ ldp_vty_disc_holdtime(struct vty *vty, int disable, const char *hello_type_str,
}
int
-ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
- const char *seconds_str)
+ldp_vty_disc_interval(struct vty *vty, const char *negate,
+ const char *hello_type_str, long secs)
{
struct ldpd_af_conf *af_conf;
struct iface *iface;
struct iface_af *ia;
int af;
- char *ep;
- long int secs;
enum hello_type hello_type;
- secs = strtol(seconds_str, &ep, 10);
- if (*ep != '\0' || secs < MIN_HELLO_INTERVAL ||
- secs > MAX_HELLO_INTERVAL) {
- vty_out (vty, "%% Invalid interval\n");
- return (CMD_WARNING_CONFIG_FAILED);
- }
-
if (hello_type_str[0] == 'h')
hello_type = HELLO_LINK;
else
@@ -579,14 +562,15 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
switch (vty->node) {
case LDP_NODE:
- if (disable) {
+ if (negate) {
switch (hello_type) {
case HELLO_LINK:
- vty_conf->lhello_interval = LINK_DFLT_HOLDTIME;
+ vty_conf->lhello_interval =
+ DEFAULT_HELLO_INTERVAL;
break;
case HELLO_TARGETED:
vty_conf->thello_interval =
- TARGETED_DFLT_HOLDTIME;
+ DEFAULT_HELLO_INTERVAL;
break;
}
} else {
@@ -606,7 +590,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable) {
+ if (negate) {
switch (hello_type) {
case HELLO_LINK:
af_conf->lhello_interval = 0;
@@ -634,7 +618,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
VTY_CHECK_CONTEXT(iface);
ia = iface_af_get(iface, af);
- if (disable)
+ if (negate)
ia->hello_interval = 0;
else
ia->hello_interval = secs;
@@ -649,7 +633,7 @@ ldp_vty_disc_interval(struct vty *vty, int disable, const char *hello_type_str,
}
int
-ldp_vty_targeted_hello_accept(struct vty *vty, int disable,
+ldp_vty_targeted_hello_accept(struct vty *vty, const char *negate,
const char *acl_from_str)
{
struct ldpd_af_conf *af_conf;
@@ -658,7 +642,7 @@ ldp_vty_targeted_hello_accept(struct vty *vty, int disable,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable) {
+ if (negate) {
af_conf->flags &= ~F_LDPD_AF_THELLO_ACCEPT;
af_conf->acl_thello_accept_from[0] = '\0';
} else {
@@ -676,29 +660,19 @@ ldp_vty_targeted_hello_accept(struct vty *vty, int disable,
}
int
-ldp_vty_nbr_session_holdtime(struct vty *vty, int disable,
- const char *lsr_id_str, const char *seconds_str)
+ldp_vty_nbr_session_holdtime(struct vty *vty, const char *negate,
+ struct in_addr lsr_id, long secs)
{
- char *ep;
- long int secs;
- struct in_addr lsr_id;
struct nbr_params *nbrp;
- if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
- bad_addr_v4(lsr_id)) {
+ if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
- secs = strtol(seconds_str, &ep, 10);
- if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) {
- vty_out (vty, "%% Invalid holdtime\n");
- return (CMD_SUCCESS);
- }
-
nbrp = nbr_params_find(vty_conf, lsr_id);
- if (disable) {
+ if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
@@ -722,24 +696,15 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, int disable,
}
int
-ldp_vty_af_session_holdtime(struct vty *vty, int disable,
- const char *seconds_str)
+ldp_vty_af_session_holdtime(struct vty *vty, const char *negate, long secs)
{
struct ldpd_af_conf *af_conf;
int af;
- char *ep;
- long int secs;
-
- secs = strtol(seconds_str, &ep, 10);
- if (*ep != '\0' || secs < MIN_KEEPALIVE || secs > MAX_KEEPALIVE) {
- vty_out (vty, "%% Invalid holdtime\n");
- return (CMD_SUCCESS);
- }
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable)
+ if (negate)
af_conf->keepalive = DEFAULT_KEEPALIVE;
else
af_conf->keepalive = secs;
@@ -750,7 +715,7 @@ ldp_vty_af_session_holdtime(struct vty *vty, int disable,
}
int
-ldp_vty_interface(struct vty *vty, int disable, const char *ifname)
+ldp_vty_interface(struct vty *vty, const char *negate, const char *ifname)
{
int af;
struct iface *iface;
@@ -759,7 +724,7 @@ ldp_vty_interface(struct vty *vty, int disable, const char *ifname)
af = ldp_vty_get_af(vty);
iface = if_lookup_name(vty_conf, ifname);
- if (disable) {
+ if (negate) {
if (iface == NULL)
return (CMD_SUCCESS);
@@ -812,7 +777,7 @@ ldp_vty_interface(struct vty *vty, int disable, const char *ifname)
}
int
-ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str)
+ldp_vty_trans_addr(struct vty *vty, const char *negate, const char *addr_str)
{
struct ldpd_af_conf *af_conf;
int af;
@@ -820,7 +785,7 @@ ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str)
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable)
+ if (negate)
memset(&af_conf->trans_addr, 0, sizeof(af_conf->trans_addr));
else {
if (inet_pton(af, addr_str, &af_conf->trans_addr) != 1 ||
@@ -836,7 +801,7 @@ ldp_vty_trans_addr(struct vty *vty, int disable, const char *addr_str)
}
int
-ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str)
+ldp_vty_neighbor_targeted(struct vty *vty, const char *negate, const char *addr_str)
{
int af;
union ldpd_addr addr;
@@ -856,7 +821,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str)
tnbr = tnbr_find(vty_conf, af, &addr);
- if (disable) {
+ if (negate) {
if (tnbr == NULL)
return (CMD_SUCCESS);
@@ -883,7 +848,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, int disable, const char *addr_str)
}
int
-ldp_vty_label_advertise(struct vty *vty, int disable, const char *acl_to_str,
+ldp_vty_label_advertise(struct vty *vty, const char *negate, const char *acl_to_str,
const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
@@ -892,7 +857,7 @@ ldp_vty_label_advertise(struct vty *vty, int disable, const char *acl_to_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable) {
+ if (negate) {
af_conf->acl_label_advertise_to[0] = '\0';
af_conf->acl_label_advertise_for[0] = '\0';
} else {
@@ -914,7 +879,7 @@ ldp_vty_label_advertise(struct vty *vty, int disable, const char *acl_to_str,
}
int
-ldp_vty_label_allocate(struct vty *vty, int disable, int host_routes,
+ldp_vty_label_allocate(struct vty *vty, const char *negate, const char *host_routes,
const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
@@ -925,7 +890,7 @@ ldp_vty_label_allocate(struct vty *vty, int disable, int host_routes,
af_conf->flags &= ~F_LDPD_AF_ALLOCHOSTONLY;
af_conf->acl_label_allocate_for[0] = '\0';
- if (!disable) {
+ if (!negate) {
if (host_routes)
af_conf->flags |= F_LDPD_AF_ALLOCHOSTONLY;
else
@@ -939,7 +904,7 @@ ldp_vty_label_allocate(struct vty *vty, int disable, int host_routes,
}
int
-ldp_vty_label_expnull(struct vty *vty, int disable, const char *acl_for_str)
+ldp_vty_label_expnull(struct vty *vty, const char *negate, const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
int af;
@@ -947,7 +912,7 @@ ldp_vty_label_expnull(struct vty *vty, int disable, const char *acl_for_str)
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable) {
+ if (negate) {
af_conf->flags &= ~F_LDPD_AF_EXPNULL;
af_conf->acl_label_expnull_for[0] = '\0';
} else {
@@ -965,7 +930,7 @@ ldp_vty_label_expnull(struct vty *vty, int disable, const char *acl_for_str)
}
int
-ldp_vty_label_accept(struct vty *vty, int disable, const char *acl_from_str,
+ldp_vty_label_accept(struct vty *vty, const char *negate, const char *acl_from_str,
const char *acl_for_str)
{
struct ldpd_af_conf *af_conf;
@@ -974,7 +939,7 @@ ldp_vty_label_accept(struct vty *vty, int disable, const char *acl_from_str,
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable) {
+ if (negate) {
af_conf->acl_label_accept_from[0] = '\0';
af_conf->acl_label_accept_for[0] = '\0';
} else {
@@ -996,7 +961,7 @@ ldp_vty_label_accept(struct vty *vty, int disable, const char *acl_from_str,
}
int
-ldp_vty_ttl_security(struct vty *vty, int disable)
+ldp_vty_ttl_security(struct vty *vty, const char *negate)
{
struct ldpd_af_conf *af_conf;
int af;
@@ -1004,7 +969,7 @@ ldp_vty_ttl_security(struct vty *vty, int disable)
af = ldp_vty_get_af(vty);
af_conf = ldp_af_conf_get(vty_conf, af);
- if (disable)
+ if (negate)
af_conf->flags &= ~F_LDPD_AF_NO_GTSM;
else
af_conf->flags |= F_LDPD_AF_NO_GTSM;
@@ -1015,16 +980,16 @@ ldp_vty_ttl_security(struct vty *vty, int disable)
}
int
-ldp_vty_router_id(struct vty *vty, int disable, const char *addr_str)
+ldp_vty_router_id(struct vty *vty, const char *negate, struct in_addr address)
{
- if (disable)
+ if (negate)
vty_conf->rtr_id.s_addr = INADDR_ANY;
else {
- if (inet_pton(AF_INET, addr_str, &vty_conf->rtr_id) != 1 ||
- bad_addr_v4(vty_conf->rtr_id)) {
+ if (bad_addr_v4(address)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_SUCCESS);
}
+ vty_conf->rtr_id = address;
}
ldp_config_apply(vty, vty_conf);
@@ -1033,9 +998,9 @@ ldp_vty_router_id(struct vty *vty, int disable, const char *addr_str)
}
int
-ldp_vty_ds_cisco_interop(struct vty *vty, int disable)
+ldp_vty_ds_cisco_interop(struct vty *vty, const char * negate)
{
- if (disable)
+ if (negate)
vty_conf->flags &= ~F_LDPD_DS_CISCO_INTEROP;
else
vty_conf->flags |= F_LDPD_DS_CISCO_INTEROP;
@@ -1046,9 +1011,9 @@ ldp_vty_ds_cisco_interop(struct vty *vty, int disable)
}
int
-ldp_vty_trans_pref_ipv4(struct vty *vty, int disable)
+ldp_vty_trans_pref_ipv4(struct vty *vty, const char *negate)
{
- if (disable)
+ if (negate)
vty_conf->trans_pref = DUAL_STACK_LDPOV6;
else
vty_conf->trans_pref = DUAL_STACK_LDPOV4;
@@ -1059,22 +1024,20 @@ ldp_vty_trans_pref_ipv4(struct vty *vty, int disable)
}
int
-ldp_vty_neighbor_password(struct vty *vty, int disable, const char *lsr_id_str,
+ldp_vty_neighbor_password(struct vty *vty, const char *negate, struct in_addr lsr_id,
const char *password_str)
{
- struct in_addr lsr_id;
size_t password_len;
struct nbr_params *nbrp;
- if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
- bad_addr_v4(lsr_id)) {
+ if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
nbrp = nbr_params_find(vty_conf, lsr_id);
- if (disable) {
+ if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
@@ -1104,16 +1067,14 @@ ldp_vty_neighbor_password(struct vty *vty, int disable, const char *lsr_id_str,
}
int
-ldp_vty_neighbor_ttl_security(struct vty *vty, int disable,
- const char *lsr_id_str, const char *hops_str)
+ldp_vty_neighbor_ttl_security(struct vty *vty, const char *negate,
+ struct in_addr lsr_id, const char *hops_str)
{
- struct in_addr lsr_id;
struct nbr_params *nbrp;
long int hops = 0;
char *ep;
- if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
- bad_addr_v4(lsr_id)) {
+ if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
@@ -1128,7 +1089,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, int disable,
nbrp = nbr_params_find(vty_conf, lsr_id);
- if (disable) {
+ if (negate) {
if (nbrp == NULL)
return (CMD_SUCCESS);
@@ -1158,7 +1119,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, int disable,
}
int
-ldp_vty_l2vpn(struct vty *vty, int disable, const char *name_str)
+ldp_vty_l2vpn(struct vty *vty, const char *negate, const char *name_str)
{
struct l2vpn *l2vpn;
struct l2vpn_if *lif;
@@ -1166,7 +1127,7 @@ ldp_vty_l2vpn(struct vty *vty, int disable, const char *name_str)
l2vpn = l2vpn_find(vty_conf, name_str);
- if (disable) {
+ if (negate) {
if (l2vpn == NULL)
return (CMD_SUCCESS);
@@ -1203,11 +1164,11 @@ ldp_vty_l2vpn(struct vty *vty, int disable, const char *name_str)
}
int
-ldp_vty_l2vpn_bridge(struct vty *vty, int disable, const char *ifname)
+ldp_vty_l2vpn_bridge(struct vty *vty, const char *negate, const char *ifname)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
- if (disable)
+ if (negate)
memset(l2vpn->br_ifname, 0, sizeof(l2vpn->br_ifname));
else
strlcpy(l2vpn->br_ifname, ifname, sizeof(l2vpn->br_ifname));
@@ -1218,19 +1179,11 @@ ldp_vty_l2vpn_bridge(struct vty *vty, int disable, const char *ifname)
}
int
-ldp_vty_l2vpn_mtu(struct vty *vty, int disable, const char *mtu_str)
+ldp_vty_l2vpn_mtu(struct vty *vty, const char *negate, long mtu)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
- char *ep;
- int mtu;
-
- mtu = strtol(mtu_str, &ep, 10);
- if (*ep != '\0' || mtu < MIN_L2VPN_MTU || mtu > MAX_L2VPN_MTU) {
- vty_out (vty, "%% Invalid MTU\n");
- return (CMD_WARNING_CONFIG_FAILED);
- }
- if (disable)
+ if (negate)
l2vpn->mtu = DEFAULT_L2VPN_MTU;
else
l2vpn->mtu = mtu;
@@ -1241,7 +1194,7 @@ ldp_vty_l2vpn_mtu(struct vty *vty, int disable, const char *mtu_str)
}
int
-ldp_vty_l2vpn_pwtype(struct vty *vty, int disable, const char *type_str)
+ldp_vty_l2vpn_pwtype(struct vty *vty, const char *negate, const char *type_str)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
int pw_type;
@@ -1251,7 +1204,7 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, int disable, const char *type_str)
else
pw_type = PW_TYPE_ETHERNET_TAGGED;
- if (disable)
+ if (negate)
l2vpn->pw_type = DEFAULT_PW_TYPE;
else
l2vpn->pw_type = pw_type;
@@ -1262,14 +1215,14 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, int disable, const char *type_str)
}
int
-ldp_vty_l2vpn_interface(struct vty *vty, int disable, const char *ifname)
+ldp_vty_l2vpn_interface(struct vty *vty, const char *negate, const char *ifname)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
struct l2vpn_if *lif;
lif = l2vpn_if_find(l2vpn, ifname);
- if (disable) {
+ if (negate) {
if (lif == NULL)
return (CMD_SUCCESS);
@@ -1300,14 +1253,14 @@ ldp_vty_l2vpn_interface(struct vty *vty, int disable, const char *ifname)
}
int
-ldp_vty_l2vpn_pseudowire(struct vty *vty, int disable, const char *ifname)
+ldp_vty_l2vpn_pseudowire(struct vty *vty, const char *negate, const char *ifname)
{
VTY_DECLVAR_CONTEXT(l2vpn, l2vpn);
struct l2vpn_pw *pw;
pw = l2vpn_pw_find(l2vpn, ifname);
- if (disable) {
+ if (negate) {
if (pw == NULL)
return (CMD_SUCCESS);
@@ -1346,11 +1299,11 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, int disable, const char *ifname)
}
int
-ldp_vty_l2vpn_pw_cword(struct vty *vty, int disable, const char *preference_str)
+ldp_vty_l2vpn_pw_cword(struct vty *vty, const char *negate, const char *preference_str)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
- if (disable)
+ if (negate)
pw->flags |= F_PW_CWORD_CONF;
else {
if (preference_str[0] == 'e')
@@ -1365,7 +1318,7 @@ ldp_vty_l2vpn_pw_cword(struct vty *vty, int disable, const char *preference_str)
}
int
-ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str)
+ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, const char *negate, const char *addr_str)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
int af;
@@ -1377,7 +1330,7 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str)
return (CMD_WARNING_CONFIG_FAILED);
}
- if (disable) {
+ if (negate) {
pw->af = AF_UNSPEC;
memset(&pw->addr, 0, sizeof(pw->addr));
pw->flags &= ~F_PW_STATIC_NBR_ADDR;
@@ -1393,18 +1346,16 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, int disable, const char *addr_str)
}
int
-ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, int disable, const char *lsr_id_str)
+ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, const char *negate, struct in_addr lsr_id)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
- struct in_addr lsr_id;
- if (inet_pton(AF_INET, lsr_id_str, &lsr_id) != 1 ||
- bad_addr_v4(lsr_id)) {
+ if (bad_addr_v4(lsr_id)) {
vty_out (vty, "%% Malformed address\n");
return (CMD_WARNING_CONFIG_FAILED);
}
- if (disable)
+ if (negate)
pw->lsr_id.s_addr = INADDR_ANY;
else
pw->lsr_id = lsr_id;
@@ -1415,19 +1366,11 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, int disable, const char *lsr_id_str)
}
int
-ldp_vty_l2vpn_pw_pwid(struct vty *vty, int disable, const char *pwid_str)
+ldp_vty_l2vpn_pw_pwid(struct vty *vty, const char *negate, long pwid)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
- char *ep;
- uint32_t pwid;
-
- pwid = strtol(pwid_str, &ep, 10);
- if (*ep != '\0' || pwid < MIN_PWID_ID || pwid > MAX_PWID_ID) {
- vty_out (vty, "%% Invalid pw-id\n");
- return (CMD_WARNING_CONFIG_FAILED);
- }
- if (disable)
+ if (negate)
pw->pwid = 0;
else
pw->pwid = pwid;
@@ -1438,11 +1381,11 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, int disable, const char *pwid_str)
}
int
-ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, int disable)
+ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, const char *negate)
{
VTY_DECLVAR_CONTEXT_SUB(l2vpn_pw, pw);
- if (disable)
+ if (negate)
pw->flags |= F_PW_STATUSTLV_CONF;
else
pw->flags &= ~F_PW_STATUSTLV_CONF;
diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c
index bec1375bd2..ad5e79c721 100644
--- a/ldpd/ldp_vty_exec.c
+++ b/ldpd/ldp_vty_exec.c
@@ -1565,7 +1565,7 @@ ldp_vty_get_af(const char *str, int *af)
}
int
-ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
+ldp_vty_show_binding(struct vty *vty, const char *af_str, const char *detail, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1579,8 +1579,8 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
memset(&params, 0, sizeof(params));
params.family = af;
- params.detail = detail;
- params.json = json;
+ params.detail = (detail) ? 1 : 0;
+ params.json = (json) ? 1 : 0;
if (!params.detail && !params.json)
vty_out (vty, "%-4s %-20s %-15s %-11s %-13s %6s\n", "AF",
@@ -1592,8 +1592,8 @@ ldp_vty_show_binding(struct vty *vty, const char *af_str, int detail, int json)
}
int
-ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
- int json)
+ldp_vty_show_discovery(struct vty *vty, const char *af_str, const char *detail,
+ const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1607,8 +1607,8 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
memset(&params, 0, sizeof(params));
params.family = af;
- params.detail = detail;
- params.json = json;
+ params.detail = (detail) ? 1 : 0;
+ params.json = (json) ? 1 : 0;
if (!params.detail && !params.json)
vty_out (vty, "%-4s %-15s %-8s %-15s %9s\n",
@@ -1623,7 +1623,7 @@ ldp_vty_show_discovery(struct vty *vty, const char *af_str, int detail,
}
int
-ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
+ldp_vty_show_interface(struct vty *vty, const char *af_str, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1638,7 +1638,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
memset(&params, 0, sizeof(params));
params.family = af;
- params.json = json;
+ params.json = (json) ? 1 : 0;
/* header */
if (!params.json) {
@@ -1652,7 +1652,7 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, int json)
}
int
-ldp_vty_show_capabilities(struct vty *vty, int json)
+ldp_vty_show_capabilities(struct vty *vty, const char *json)
{
if (json) {
json_object *json;
@@ -1703,7 +1703,7 @@ ldp_vty_show_capabilities(struct vty *vty, int json)
}
int
-ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
+ldp_vty_show_neighbor(struct vty *vty, int capabilities, const char *detail, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1713,8 +1713,8 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
memset(&params, 0, sizeof(params));
params.capabilities = capabilities;
- params.detail = detail;
- params.json = json;
+ params.detail = (detail) ? 1 : 0;
+ params.json = (json) ? 1 : 0;
if (params.capabilities)
params.detail = 1;
@@ -1728,7 +1728,7 @@ ldp_vty_show_neighbor(struct vty *vty, int capabilities, int detail, int json)
}
int
-ldp_vty_show_atom_binding(struct vty *vty, int json)
+ldp_vty_show_atom_binding(struct vty *vty, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1737,14 +1737,14 @@ ldp_vty_show_atom_binding(struct vty *vty, int json)
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
- params.json = json;
+ params.json = (json) ? 1 : 0;
imsg_compose(&ibuf, IMSG_CTL_SHOW_L2VPN_BINDING, 0, 0, -1, NULL, 0);
return (ldp_vty_dispatch(vty, &ibuf, SHOW_L2VPN_BINDING, &params));
}
int
-ldp_vty_show_atom_vc(struct vty *vty, int json)
+ldp_vty_show_atom_vc(struct vty *vty, const char *json)
{
struct imsgbuf ibuf;
struct show_params params;
@@ -1753,7 +1753,7 @@ ldp_vty_show_atom_vc(struct vty *vty, int json)
return (CMD_WARNING);
memset(&params, 0, sizeof(params));
- params.json = json;
+ params.json = (json) ? 1 : 0;
if (!params.json) {
/* header */
diff --git a/lib/checksum.c b/lib/checksum.c
index 7666c58a31..8eef73e243 100644
--- a/lib/checksum.c
+++ b/lib/checksum.c
@@ -10,7 +10,7 @@
#include "checksum.h"
int /* return checksum in low-order 16 bits */
-in_cksum(void *parg, int nbytes)
+ in_cksum(void *parg, int nbytes)
{
u_short *ptr = parg;
register long sum; /* assumes long == 32 bits */
diff --git a/lib/command.c b/lib/command.c
index d4b628ab02..f28a55ec6d 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -47,6 +47,74 @@ DEFINE_MTYPE(LIB, HOST, "Host config")
DEFINE_MTYPE(LIB, STRVEC, "String vector")
DEFINE_MTYPE(LIB, COMPLETION, "Completion item")
+const char *node_names[] = {
+ "auth", // AUTH_NODE,
+ "view", // VIEW_NODE,
+ "auth enable", // AUTH_ENABLE_NODE,
+ "enable", // ENABLE_NODE,
+ "config", // CONFIG_NODE,
+ "service", // SERVICE_NODE,
+ "debug", // DEBUG_NODE,
+ "vrf debug", // VRF_DEBUG_NODE,
+ "vnc debug", // DEBUG_VNC_NODE,
+ "aaa", // AAA_NODE,
+ "keychain", // KEYCHAIN_NODE,
+ "keychain key", // KEYCHAIN_KEY_NODE,
+ "logical-router", // NS_NODE,
+ "vrf", // VRF_NODE,
+ "interface", // INTERFACE_NODE,
+ "zebra", // ZEBRA_NODE,
+ "table", // TABLE_NODE,
+ "rip", // RIP_NODE,
+ "ripng", // RIPNG_NODE,
+ "babel", // BABEL_NODE,
+ "eigrp", // EIGRP_NODE,
+ "bgp", // BGP_NODE,
+ "bgp vpnv4", // BGP_VPNV4_NODE,
+ "bgp vpnv6", // BGP_VPNV6_NODE,
+ "bgp ipv4 unicast", // BGP_IPV4_NODE,
+ "bgp ipv4 multicast", // BGP_IPV4M_NODE,
+ "bgp ipv4 labeled unicast", // BGP_IPV4L_NODE,
+ "bgp ipv6", // BGP_IPV6_NODE,
+ "bgp ipv6 multicast", // BGP_IPV6M_NODE,
+ "bgp ipv6 labeled unicast", // BGP_IPV6L_NODE,
+ "bgp vrf policy", // BGP_VRF_POLICY_NODE,
+ "bgp vnc defaults", // BGP_VNC_DEFAULTS_NODE,
+ "bgp vnc nve", // BGP_VNC_NVE_GROUP_NODE,
+ "bgp vnc l2", // BGP_VNC_L2_GROUP_NODE,
+ "rfp defaults", // RFP_DEFAULTS_NODE,
+ "bgp evpn", // BGP_EVPN_NODE,
+ "ospf", // OSPF_NODE,
+ "ospf6", // OSPF6_NODE,
+ "ldp", // LDP_NODE,
+ "ldp ipv4", // LDP_IPV4_NODE,
+ "ldp ipv6", // LDP_IPV6_NODE,
+ "ldp ipv4 interface", // LDP_IPV4_IFACE_NODE,
+ "ldp ipv6 interface", // LDP_IPV6_IFACE_NODE,
+ "ldp l2vpn", // LDP_L2VPN_NODE,
+ "ldp", // LDP_PSEUDOWIRE_NODE,
+ "isis", // ISIS_NODE,
+ "pim", // PIM_NODE,
+ "masc", // MASC_NODE,
+ "irdp", // IRDP_NODE,
+ "static ip", // IP_NODE,
+ "ipv4 access list", // ACCESS_NODE,
+ "ipv4 prefix list", // PREFIX_NODE,
+ "ipv6 access list", // ACCESS_IPV6_NODE,
+ "ipv6 prefix list", // PREFIX_IPV6_NODE,
+ "as list", // AS_LIST_NODE,
+ "community list", // COMMUNITY_LIST_NODE,
+ "routemap", // RMAP_NODE,
+ "smux", // SMUX_NODE,
+ "dump", // DUMP_NODE,
+ "forwarding", // FORWARDING_NODE,
+ "protocol", // PROTOCOL_NODE,
+ "mpls", // MPLS_NODE,
+ "vty", // VTY_NODE,
+ "link-params", // LINK_PARAMS_NODE,
+ "bgp evpn vni", // BGP_EVPN_VNI_NODE,
+};
+
/* Command vector which includes some level of command lists. Normally
each daemon maintains each own cmdvec. */
vector cmdvec = NULL;
@@ -56,23 +124,19 @@ struct host host;
/* Standard command node structures. */
static struct cmd_node auth_node = {
- AUTH_NODE,
- "Password: ",
+ AUTH_NODE, "Password: ",
};
static struct cmd_node view_node = {
- VIEW_NODE,
- "%s> ",
+ VIEW_NODE, "%s> ",
};
static struct cmd_node auth_enable_node = {
- AUTH_ENABLE_NODE,
- "Password: ",
+ AUTH_ENABLE_NODE, "Password: ",
};
static struct cmd_node enable_node = {
- ENABLE_NODE,
- "%s# ",
+ ENABLE_NODE, "%s# ",
};
static struct cmd_node config_node = {CONFIG_NODE, "%s(config)# ", 1};
@@ -653,9 +717,8 @@ void cmd_variable_complete(struct cmd_token *token, const char *arg,
for (ALL_LIST_ELEMENTS_RO(varhandlers, ln, cvh)) {
if (cvh->tokenname && strcmp(cvh->tokenname, token->text))
continue;
- if (cvh->varname
- && (!token->varname
- || strcmp(cvh->varname, token->varname)))
+ if (cvh->varname && (!token->varname
+ || strcmp(cvh->varname, token->varname)))
continue;
cvh->completions(tmpcomps, token);
break;
@@ -1500,9 +1563,8 @@ DEFUN (config_write,
struct stat conf_stat;
// if command was 'write terminal' or 'show running-config'
- if (argc == 2
- && (strmatch(argv[idx_type]->text, "terminal")
- || strmatch(argv[0]->text, "show"))) {
+ if (argc == 2 && (strmatch(argv[idx_type]->text, "terminal")
+ || strmatch(argv[0]->text, "show"))) {
vty_write_config(vty);
return CMD_SUCCESS;
}
@@ -2361,6 +2423,35 @@ DEFUN (no_banner_motd,
return CMD_SUCCESS;
}
+DEFUN(find,
+ find_cmd,
+ "find COMMAND...",
+ "Find CLI command containing text\n"
+ "Text to search for\n")
+{
+ char *text = argv_concat(argv, argc, 1);
+ const struct cmd_node *node;
+ const struct cmd_element *cli;
+ vector clis;
+
+ for (unsigned int i = 0; i < vector_active(cmdvec); i++) {
+ node = vector_slot(cmdvec, i);
+ if (!node)
+ continue;
+ clis = node->cmd_vector;
+ for (unsigned int j = 0; j < vector_active(clis); j++) {
+ cli = vector_slot(clis, j);
+ if (strcasestr(cli->string, text))
+ vty_out(vty, " (%s) %s\n",
+ node_names[node->node], cli->string);
+ }
+ }
+
+ XFREE(MTYPE_TMP, text);
+
+ return CMD_SUCCESS;
+}
+
/* Set config filename. Called from vty.c */
void host_config_set(const char *filename)
{
@@ -2381,6 +2472,7 @@ void install_default(enum node_type node)
install_element(node, &config_end_cmd);
install_element(node, &config_help_cmd);
install_element(node, &config_list_cmd);
+ install_element(node, &find_cmd);
install_element(node, &config_write_cmd);
install_element(node, &show_running_config_cmd);
@@ -2395,6 +2487,9 @@ void install_default(enum node_type node)
* terminal = -1 -- watchfrr / no logging, but minimal config control */
void cmd_init(int terminal)
{
+ if (array_size(node_names) != NODE_TYPE_MAX)
+ assert(!"Update the CLI node description array!");
+
qobj_init();
varhandlers = list_new();
@@ -2422,6 +2517,8 @@ void cmd_init(int terminal)
/* Each node's basic commands. */
install_element(VIEW_NODE, &show_version_cmd);
+ install_element(ENABLE_NODE, &show_startup_config_cmd);
+
if (terminal) {
install_element(VIEW_NODE, &config_list_cmd);
install_element(VIEW_NODE, &config_exit_cmd);
@@ -2434,20 +2531,16 @@ void cmd_init(int terminal)
install_element(VIEW_NODE, &show_commandtree_cmd);
install_element(VIEW_NODE, &echo_cmd);
install_element(VIEW_NODE, &autocomplete_cmd);
- }
+ install_element(VIEW_NODE, &find_cmd);
- if (terminal) {
install_element(ENABLE_NODE, &config_end_cmd);
install_element(ENABLE_NODE, &config_disable_cmd);
install_element(ENABLE_NODE, &config_terminal_cmd);
install_element(ENABLE_NODE, &copy_runningconf_startupconf_cmd);
install_element(ENABLE_NODE, &config_write_cmd);
install_element(ENABLE_NODE, &show_running_config_cmd);
- }
- install_element(ENABLE_NODE, &show_startup_config_cmd);
-
- if (terminal) {
install_element(ENABLE_NODE, &config_logmsg_cmd);
+
install_default(CONFIG_NODE);
thread_cmd_init();
diff --git a/lib/command.h b/lib/command.h
index 5d52fe3fc3..533b4b3289 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -68,7 +68,7 @@ struct host {
char *motdfile;
};
-/* There are some command levels which called from command node. */
+/* List of CLI nodes. Please remember to update the name array in command.c. */
enum node_type {
AUTH_NODE, /* Authentication mode of vty interface. */
VIEW_NODE, /* View node. Default mode of vty interface. */
@@ -135,8 +135,12 @@ enum node_type {
VTY_NODE, /* Vty node. */
LINK_PARAMS_NODE, /* Link-parameters node */
BGP_EVPN_VNI_NODE, /* BGP EVPN VNI */
+ NODE_TYPE_MAX, /* maximum */
};
+extern vector cmdvec;
+extern const char *node_names[];
+
/* Node which has some commands and prompt string and configuration
function pointer . */
struct cmd_node {
diff --git a/lib/command_py.c b/lib/command_py.c
index be4c39a361..785d2ffa70 100644
--- a/lib/command_py.c
+++ b/lib/command_py.c
@@ -203,7 +203,7 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph,
/* plumbing types */
item(FORK_TKN) item(JOIN_TKN) item(START_TKN)
item(END_TKN) default
- : wrap->type = "???";
+ : wrap->type = "???";
}
wrap->deprecated = (tok->attr == CMD_ATTR_DEPRECATED);
diff --git a/lib/getopt.c b/lib/getopt.c
index 3f52c6f06b..71799c9b6d 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -619,9 +619,8 @@ int long_only;
if (longopts != NULL
&& (argv[optind][1] == '-'
- || (long_only
- && (argv[optind][2]
- || !my_index(optstring, argv[optind][1]))))) {
+ || (long_only && (argv[optind][2]
+ || !my_index(optstring, argv[optind][1]))))) {
char *nameend;
const struct option *p;
const struct option *pfound = NULL;
diff --git a/lib/hash.c b/lib/hash.c
index 7adbd908d8..a7714f1569 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -49,7 +49,6 @@ struct hash *hash_create_size(unsigned int size,
hash->index =
XCALLOC(MTYPE_HASH_INDEX, sizeof(struct hash_backet *) * size);
hash->size = size;
- hash->no_expand = 0;
hash->hash_key = hash_key;
hash->hash_cmp = hash_cmp;
hash->count = 0;
@@ -91,7 +90,7 @@ void *hash_alloc_intern(void *arg)
/* Expand hash if the chain length exceeds the threshold. */
static void hash_expand(struct hash *hash)
{
- unsigned int i, new_size, losers;
+ unsigned int i, new_size;
struct hash_backet *hb, *hbnext, **new_index;
new_size = hash->size * 2;
@@ -128,22 +127,6 @@ static void hash_expand(struct hash *hash)
XFREE(MTYPE_HASH_INDEX, hash->index);
hash->size = new_size;
hash->index = new_index;
-
- /* Ideally, new index should have chains half as long as the original.
- * If expansion didn't help, then not worth expanding again,
- * the problem is the hash function. */
- losers = 0;
- for (i = 0; i < hash->size; i++) {
- unsigned int len = hash->index[i] ? hash->index[i]->len : 0;
-
- if (len > HASH_THRESHOLD / 2)
- ++losers;
- if (len >= HASH_THRESHOLD)
- hash->no_expand = 1;
- }
-
- if (losers > hash->count / 2)
- hash->no_expand = 1;
}
/* Lookup and return hash backet in hash. If there is no
@@ -173,7 +156,7 @@ void *hash_get(struct hash *hash, void *data, void *(*alloc_func)(void *))
if (newdata == NULL)
return NULL;
- if (len > HASH_THRESHOLD && !hash->no_expand) {
+ if (len > HASH_THRESHOLD) {
hash_expand(hash);
index = key & (hash->size - 1);
}
diff --git a/lib/hash.h b/lib/hash.h
index ec3766eaaa..6ce29f0426 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -64,9 +64,6 @@ struct hash {
/* Hash table size. Must be power of 2 */
unsigned int size;
- /* If expansion failed. */
- int no_expand;
-
/* Key make function. */
unsigned int (*hash_key)(void *);
diff --git a/lib/hook.h b/lib/hook.h
index da3419bd27..4a5cee2fd3 100644
--- a/lib/hook.h
+++ b/lib/hook.h
@@ -161,8 +161,7 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg,
*/
#define DEFINE_HOOK(hookname, arglist, passlist) \
struct hook _hook_##hookname = { \
- .name = #hookname, \
- .entries = NULL, \
+ .name = #hookname, .entries = NULL, \
}; \
static int hook_call_##hookname arglist \
{ \
diff --git a/lib/if.h b/lib/if.h
index 0204d325b7..f80ac19179 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -236,7 +236,7 @@ struct interface {
unsigned int mtu; /* IPv4 MTU */
unsigned int
mtu6; /* IPv6 MTU - probably, but not neccessarily same as mtu
- */
+ */
/* Link-layer information and hardware address */
enum zebra_link_type ll_type;
diff --git a/lib/imsg-buffer.c b/lib/imsg-buffer.c
index 4068e31c51..a486fc17c1 100644
--- a/lib/imsg-buffer.c
+++ b/lib/imsg-buffer.c
@@ -21,13 +21,14 @@
#include "openbsd-queue.h"
#include "imsg.h"
-int ibuf_realloc(struct ibuf *, size_t);
-void ibuf_enqueue(struct msgbuf *, struct ibuf *);
-void ibuf_dequeue(struct msgbuf *, struct ibuf *);
+int ibuf_realloc(struct ibuf *, size_t);
+void ibuf_enqueue(struct msgbuf *, struct ibuf *);
+void ibuf_dequeue(struct msgbuf *, struct ibuf *);
-struct ibuf *ibuf_open(size_t len)
+struct ibuf *
+ibuf_open(size_t len)
{
- struct ibuf *buf;
+ struct ibuf *buf;
if ((buf = calloc(1, sizeof(struct ibuf))) == NULL)
return (NULL);
@@ -41,9 +42,10 @@ struct ibuf *ibuf_open(size_t len)
return (buf);
}
-struct ibuf *ibuf_dynamic(size_t len, size_t max)
+struct ibuf *
+ibuf_dynamic(size_t len, size_t max)
{
- struct ibuf *buf;
+ struct ibuf *buf;
if (max < len)
return (NULL);
@@ -57,9 +59,10 @@ struct ibuf *ibuf_dynamic(size_t len, size_t max)
return (buf);
}
-int ibuf_realloc(struct ibuf *buf, size_t len)
+int
+ibuf_realloc(struct ibuf *buf, size_t len)
{
- u_char *b;
+ u_char *b;
/* on static buffers max is eq size and so the following fails */
if (buf->wpos + len > buf->max) {
@@ -76,7 +79,8 @@ int ibuf_realloc(struct ibuf *buf, size_t len)
return (0);
}
-int ibuf_add(struct ibuf *buf, const void *data, size_t len)
+int
+ibuf_add(struct ibuf *buf, const void *data, size_t len)
{
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
@@ -87,9 +91,10 @@ int ibuf_add(struct ibuf *buf, const void *data, size_t len)
return (0);
}
-void *ibuf_reserve(struct ibuf *buf, size_t len)
+void *
+ibuf_reserve(struct ibuf *buf, size_t len)
{
- void *b;
+ void *b;
if (buf->wpos + len > buf->size)
if (ibuf_realloc(buf, len) == -1)
@@ -100,7 +105,8 @@ void *ibuf_reserve(struct ibuf *buf, size_t len)
return (b);
}
-void *ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
+void *
+ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
{
/* only allowed to seek in already written parts */
if (pos + len > buf->wpos)
@@ -109,31 +115,34 @@ void *ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
return (buf->buf + pos);
}
-size_t ibuf_size(struct ibuf *buf)
+size_t
+ibuf_size(struct ibuf *buf)
{
return (buf->wpos);
}
-size_t ibuf_left(struct ibuf *buf)
+size_t
+ibuf_left(struct ibuf *buf)
{
return (buf->max - buf->wpos);
}
-void ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
+void
+ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
{
ibuf_enqueue(msgbuf, buf);
}
-int ibuf_write(struct msgbuf *msgbuf)
+int
+ibuf_write(struct msgbuf *msgbuf)
{
- struct iovec iov[IOV_MAX];
- struct ibuf *buf;
- unsigned int i = 0;
- ssize_t n;
+ struct iovec iov[IOV_MAX];
+ struct ibuf *buf;
+ unsigned int i = 0;
+ ssize_t n;
memset(&iov, 0, sizeof(iov));
- TAILQ_FOREACH(buf, &msgbuf->bufs, entry)
- {
+ TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = buf->buf + buf->rpos;
@@ -150,7 +159,7 @@ again:
return (-1);
}
- if (n == 0) { /* connection closed */
+ if (n == 0) { /* connection closed */
errno = 0;
return (0);
}
@@ -160,7 +169,8 @@ again:
return (1);
}
-void ibuf_free(struct ibuf *buf)
+void
+ibuf_free(struct ibuf *buf)
{
if (buf == NULL)
return;
@@ -168,19 +178,21 @@ void ibuf_free(struct ibuf *buf)
free(buf);
}
-void msgbuf_init(struct msgbuf *msgbuf)
+void
+msgbuf_init(struct msgbuf *msgbuf)
{
msgbuf->queued = 0;
msgbuf->fd = -1;
TAILQ_INIT(&msgbuf->bufs);
}
-void msgbuf_drain(struct msgbuf *msgbuf, size_t n)
+void
+msgbuf_drain(struct msgbuf *msgbuf, size_t n)
{
- struct ibuf *buf, *next;
+ struct ibuf *buf, *next;
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
- buf = next) {
+ buf = next) {
next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->wpos) {
n -= buf->wpos - buf->rpos;
@@ -192,32 +204,33 @@ void msgbuf_drain(struct msgbuf *msgbuf, size_t n)
}
}
-void msgbuf_clear(struct msgbuf *msgbuf)
+void
+msgbuf_clear(struct msgbuf *msgbuf)
{
- struct ibuf *buf;
+ struct ibuf *buf;
while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL)
ibuf_dequeue(msgbuf, buf);
}
-int msgbuf_write(struct msgbuf *msgbuf)
+int
+msgbuf_write(struct msgbuf *msgbuf)
{
- struct iovec iov[IOV_MAX];
- struct ibuf *buf;
- unsigned int i = 0;
- ssize_t n;
- struct msghdr msg;
- struct cmsghdr *cmsg;
+ struct iovec iov[IOV_MAX];
+ struct ibuf *buf;
+ unsigned int i = 0;
+ ssize_t n;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
union {
- struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(int))];
+ struct cmsghdr hdr;
+ char buf[CMSG_SPACE(sizeof(int))];
} cmsgbuf;
memset(&iov, 0, sizeof(iov));
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
- TAILQ_FOREACH(buf, &msgbuf->bufs, entry)
- {
+ TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
if (i >= IOV_MAX)
break;
iov[i].iov_base = buf->buf + buf->rpos;
@@ -249,7 +262,7 @@ again:
return (-1);
}
- if (n == 0) { /* connection closed */
+ if (n == 0) { /* connection closed */
errno = 0;
return (0);
}
@@ -268,13 +281,15 @@ again:
return (1);
}
-void ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
+void
+ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++;
}
-void ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
+void
+ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
diff --git a/lib/imsg.c b/lib/imsg.c
index 10650f648a..fc62c13734 100644
--- a/lib/imsg.c
+++ b/lib/imsg.c
@@ -21,21 +21,22 @@
#include "openbsd-queue.h"
#include "imsg.h"
-int imsg_fd_overhead = 0;
+int imsg_fd_overhead = 0;
-int imsg_get_fd(struct imsgbuf *);
+int imsg_get_fd(struct imsgbuf *);
#ifndef __OpenBSD__
/*
* The original code calls getdtablecount() which is OpenBSD specific. Use
* available_fds() from OpenSMTPD instead.
*/
-static int available_fds(unsigned int n)
+static int
+available_fds(unsigned int n)
{
- unsigned int i;
- int ret, fds[256];
+ unsigned int i;
+ int ret, fds[256];
- if (n > (sizeof(fds) / sizeof(fds[0])))
+ if (n > (sizeof(fds)/sizeof(fds[0])))
return (1);
ret = 0;
@@ -58,7 +59,8 @@ static int available_fds(unsigned int n)
}
#endif
-void imsg_init(struct imsgbuf *ibuf, int fd)
+void
+imsg_init(struct imsgbuf *ibuf, int fd)
{
msgbuf_init(&ibuf->w);
memset(&ibuf->r, 0, sizeof(ibuf->r));
@@ -68,18 +70,19 @@ void imsg_init(struct imsgbuf *ibuf, int fd)
TAILQ_INIT(&ibuf->fds);
}
-ssize_t imsg_read(struct imsgbuf *ibuf)
+ssize_t
+imsg_read(struct imsgbuf *ibuf)
{
- struct msghdr msg;
- struct cmsghdr *cmsg;
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
union {
struct cmsghdr hdr;
- char buf[CMSG_SPACE(sizeof(int) * 1)];
+ char buf[CMSG_SPACE(sizeof(int) * 1)];
} cmsgbuf;
- struct iovec iov;
- ssize_t n = -1;
- int fd;
- struct imsg_fd *ifd;
+ struct iovec iov;
+ ssize_t n = -1;
+ int fd;
+ struct imsg_fd *ifd;
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
@@ -96,14 +99,12 @@ ssize_t imsg_read(struct imsgbuf *ibuf)
again:
#ifdef __OpenBSD__
- if (getdtablecount() + imsg_fd_overhead
- + (int)((CMSG_SPACE(sizeof(int)) - CMSG_SPACE(0))
- / sizeof(int))
+ if (getdtablecount() + imsg_fd_overhead +
+ (int)((CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int))
>= getdtablesize()) {
#else
- if (available_fds(imsg_fd_overhead
- + (CMSG_SPACE(sizeof(int)) - CMSG_SPACE(0))
- / sizeof(int))) {
+ if (available_fds(imsg_fd_overhead +
+ (CMSG_SPACE(sizeof(int))-CMSG_SPACE(0))/sizeof(int))) {
#endif
errno = EAGAIN;
free(ifd);
@@ -119,9 +120,9 @@ again:
ibuf->r.wpos += n;
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
- cmsg = CMSG_NXTHDR(&msg, cmsg)) {
- if (cmsg->cmsg_level == SOL_SOCKET
- && cmsg->cmsg_type == SCM_RIGHTS) {
+ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level == SOL_SOCKET &&
+ cmsg->cmsg_type == SCM_RIGHTS) {
int i;
int j;
@@ -130,15 +131,14 @@ again:
* padding rules, our control buffer might contain
* more than one fd, and we must close them.
*/
- j = ((char *)cmsg + cmsg->cmsg_len
- - (char *)CMSG_DATA(cmsg))
- / sizeof(int);
+ j = ((char *)cmsg + cmsg->cmsg_len -
+ (char *)CMSG_DATA(cmsg)) / sizeof(int);
for (i = 0; i < j; i++) {
fd = ((int *)CMSG_DATA(cmsg))[i];
if (ifd != NULL) {
ifd->fd = fd;
TAILQ_INSERT_TAIL(&ibuf->fds, ifd,
- entry);
+ entry);
ifd = NULL;
} else
close(fd);
@@ -152,9 +152,10 @@ fail:
return (n);
}
-ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
+ssize_t
+imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
{
- size_t av, left, datalen;
+ size_t av, left, datalen;
av = ibuf->r.wpos;
@@ -162,7 +163,8 @@ ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
return (0);
memcpy(&imsg->hdr, ibuf->r.buf, sizeof(imsg->hdr));
- if (imsg->hdr.len < IMSG_HEADER_SIZE || imsg->hdr.len > MAX_IMSGSIZE) {
+ if (imsg->hdr.len < IMSG_HEADER_SIZE ||
+ imsg->hdr.len > MAX_IMSGSIZE) {
errno = ERANGE;
return (-1);
}
@@ -181,7 +183,7 @@ ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
imsg->fd = -1;
if (imsg->data)
- memcpy(imsg->data, ibuf->r.rptr, datalen);
+ memcpy(imsg->data, ibuf->r.rptr, datalen);
if (imsg->hdr.len < av) {
left = av - imsg->hdr.len;
@@ -193,10 +195,11 @@ ssize_t imsg_get(struct imsgbuf *ibuf, struct imsg *imsg)
return (datalen + IMSG_HEADER_SIZE);
}
-int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, int fd, const void *data, u_int16_t datalen)
+int
+imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+ pid_t pid, int fd, const void *data, u_int16_t datalen)
{
- struct ibuf *wbuf;
+ struct ibuf *wbuf;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
return (-1);
@@ -211,11 +214,12 @@ int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
return (1);
}
-int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, int fd, const struct iovec *iov, int iovcnt)
+int
+imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+ pid_t pid, int fd, const struct iovec *iov, int iovcnt)
{
- struct ibuf *wbuf;
- int i, datalen = 0;
+ struct ibuf *wbuf;
+ int i, datalen = 0;
for (i = 0; i < iovcnt; i++)
datalen += iov[i].iov_len;
@@ -235,11 +239,12 @@ int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
}
/* ARGSUSED */
-struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, u_int16_t datalen)
+struct ibuf *
+imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+ pid_t pid, u_int16_t datalen)
{
- struct ibuf *wbuf;
- struct imsg_hdr hdr;
+ struct ibuf *wbuf;
+ struct imsg_hdr hdr;
datalen += IMSG_HEADER_SIZE;
if (datalen > MAX_IMSGSIZE) {
@@ -261,7 +266,8 @@ struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
return (wbuf);
}
-int imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
+int
+imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
{
if (datalen)
if (ibuf_add(msg, data, datalen) == -1) {
@@ -271,9 +277,10 @@ int imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
return (datalen);
}
-void imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
+void
+imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
{
- struct imsg_hdr *hdr;
+ struct imsg_hdr *hdr;
hdr = (struct imsg_hdr *)msg->buf;
@@ -286,15 +293,17 @@ void imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
ibuf_close(&ibuf->w, msg);
}
-void imsg_free(struct imsg *imsg)
+void
+imsg_free(struct imsg *imsg)
{
free(imsg->data);
}
-int imsg_get_fd(struct imsgbuf *ibuf)
+int
+imsg_get_fd(struct imsgbuf *ibuf)
{
- int fd;
- struct imsg_fd *ifd;
+ int fd;
+ struct imsg_fd *ifd;
if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL)
return (-1);
@@ -306,7 +315,8 @@ int imsg_get_fd(struct imsgbuf *ibuf)
return (fd);
}
-int imsg_flush(struct imsgbuf *ibuf)
+int
+imsg_flush(struct imsgbuf *ibuf)
{
while (ibuf->w.queued)
if (msgbuf_write(&ibuf->w) <= 0)
@@ -314,9 +324,10 @@ int imsg_flush(struct imsgbuf *ibuf)
return (0);
}
-void imsg_clear(struct imsgbuf *ibuf)
+void
+imsg_clear(struct imsgbuf *ibuf)
{
- int fd;
+ int fd;
msgbuf_clear(&ibuf->w);
while ((fd = imsg_get_fd(ibuf)) != -1)
diff --git a/lib/imsg.h b/lib/imsg.h
index ddaf71344e..d053d01956 100644
--- a/lib/imsg.h
+++ b/lib/imsg.h
@@ -26,87 +26,87 @@
#define MAX_IMSGSIZE 16384
struct ibuf {
- TAILQ_ENTRY(ibuf) entry;
- u_char *buf;
- size_t size;
- size_t max;
- size_t wpos;
- size_t rpos;
- int fd;
+ TAILQ_ENTRY(ibuf) entry;
+ u_char *buf;
+ size_t size;
+ size_t max;
+ size_t wpos;
+ size_t rpos;
+ int fd;
};
struct msgbuf {
- TAILQ_HEAD(, ibuf) bufs;
- u_int32_t queued;
- int fd;
+ TAILQ_HEAD(, ibuf) bufs;
+ u_int32_t queued;
+ int fd;
};
struct ibuf_read {
- u_char buf[IBUF_READ_SIZE];
- u_char *rptr;
- size_t wpos;
+ u_char buf[IBUF_READ_SIZE];
+ u_char *rptr;
+ size_t wpos;
};
struct imsg_fd {
- TAILQ_ENTRY(imsg_fd) entry;
- int fd;
+ TAILQ_ENTRY(imsg_fd) entry;
+ int fd;
};
struct imsgbuf {
- TAILQ_HEAD(, imsg_fd) fds;
- struct ibuf_read r;
- struct msgbuf w;
- int fd;
- pid_t pid;
+ TAILQ_HEAD(, imsg_fd) fds;
+ struct ibuf_read r;
+ struct msgbuf w;
+ int fd;
+ pid_t pid;
};
#define IMSGF_HASFD 1
struct imsg_hdr {
- u_int32_t type;
- u_int16_t len;
- u_int16_t flags;
- u_int32_t peerid;
- u_int32_t pid;
+ u_int32_t type;
+ u_int16_t len;
+ u_int16_t flags;
+ u_int32_t peerid;
+ u_int32_t pid;
};
struct imsg {
- struct imsg_hdr hdr;
- int fd;
- void *data;
+ struct imsg_hdr hdr;
+ int fd;
+ void *data;
};
/* buffer.c */
-struct ibuf *ibuf_open(size_t);
-struct ibuf *ibuf_dynamic(size_t, size_t);
-int ibuf_add(struct ibuf *, const void *, size_t);
-void *ibuf_reserve(struct ibuf *, size_t);
-void *ibuf_seek(struct ibuf *, size_t, size_t);
-size_t ibuf_size(struct ibuf *);
-size_t ibuf_left(struct ibuf *);
-void ibuf_close(struct msgbuf *, struct ibuf *);
-int ibuf_write(struct msgbuf *);
-void ibuf_free(struct ibuf *);
-void msgbuf_init(struct msgbuf *);
-void msgbuf_clear(struct msgbuf *);
-int msgbuf_write(struct msgbuf *);
-void msgbuf_drain(struct msgbuf *, size_t);
+struct ibuf *ibuf_open(size_t);
+struct ibuf *ibuf_dynamic(size_t, size_t);
+int ibuf_add(struct ibuf *, const void *, size_t);
+void *ibuf_reserve(struct ibuf *, size_t);
+void *ibuf_seek(struct ibuf *, size_t, size_t);
+size_t ibuf_size(struct ibuf *);
+size_t ibuf_left(struct ibuf *);
+void ibuf_close(struct msgbuf *, struct ibuf *);
+int ibuf_write(struct msgbuf *);
+void ibuf_free(struct ibuf *);
+void msgbuf_init(struct msgbuf *);
+void msgbuf_clear(struct msgbuf *);
+int msgbuf_write(struct msgbuf *);
+void msgbuf_drain(struct msgbuf *, size_t);
/* imsg.c */
-void imsg_init(struct imsgbuf *, int);
-ssize_t imsg_read(struct imsgbuf *);
-ssize_t imsg_get(struct imsgbuf *, struct imsg *);
-int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int,
- const void *, u_int16_t);
-int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t, int,
- const struct iovec *, int);
+void imsg_init(struct imsgbuf *, int);
+ssize_t imsg_read(struct imsgbuf *);
+ssize_t imsg_get(struct imsgbuf *, struct imsg *);
+int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
+ int, const void *, u_int16_t);
+int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
+ int, const struct iovec *, int);
struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
- u_int16_t);
-int imsg_add(struct ibuf *, const void *, u_int16_t);
-void imsg_close(struct imsgbuf *, struct ibuf *);
-void imsg_free(struct imsg *);
-int imsg_flush(struct imsgbuf *);
-void imsg_clear(struct imsgbuf *);
+ u_int16_t);
+int imsg_add(struct ibuf *, const void *, u_int16_t);
+void imsg_close(struct imsgbuf *, struct ibuf *);
+void imsg_free(struct imsg *);
+int imsg_flush(struct imsgbuf *);
+void imsg_clear(struct imsgbuf *);
#endif
diff --git a/lib/log.c b/lib/log.c
index 68f172cdf9..28e0865354 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -411,7 +411,7 @@ void zlog_signal(int signo, const char *action
,
siginfo_t *siginfo, void *program_counter
#endif
-)
+ )
{
time_t now;
char buf[sizeof("DEFAULT: Received signal S at T (si_addr 0xP, PC 0xP); aborting...")
@@ -474,7 +474,7 @@ void zlog_signal(int signo, const char *action
#else
NULL
#endif
- );
+ );
s = buf;
struct thread *tc;
@@ -1063,9 +1063,10 @@ void zlog_hexdump(const void *mem, unsigned int len)
printing */
s += sprintf(s, " ");
- else if (isprint((int)((const char *)mem)
- [j])) /* printable char
- */
+ else if (
+ isprint((int)((const char *)mem)
+ [j])) /* printable char
+ */
s += sprintf(
s, "%c",
0xFF & ((const char *)mem)[j]);
diff --git a/lib/log.h b/lib/log.h
index 711308a476..d872ce56d6 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -109,7 +109,7 @@ extern void zlog_signal(int signo, const char *action
,
siginfo_t *siginfo, void *program_counter
#endif
-);
+ );
/* Log a backtrace. */
extern void zlog_backtrace(int priority);
@@ -143,7 +143,7 @@ struct timestamp_control {
int precision; /* configuration parameter */
int already_rendered; /* should be initialized to 0 */
char buf[QUAGGA_TIMESTAMP_LEN]; /* will contain the rendered timestamp
- */
+ */
};
/* Defines for use in command construction: */
diff --git a/lib/md5.c b/lib/md5.c
index 633256b77b..cce67d7ec1 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -389,11 +389,11 @@ uint8_t *digest; /* caller digest to be filled in */
{
MD5_CTX context;
unsigned char k_ipad[65]; /* inner padding -
- * key XORd with ipad
- */
+ * key XORd with ipad
+ */
unsigned char k_opad[65]; /* outer padding -
- * key XORd with opad
- */
+ * key XORd with opad
+ */
unsigned char tk[16];
int i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */
diff --git a/lib/mpls.h b/lib/mpls.h
index 38482e2f92..025770d479 100644
--- a/lib/mpls.h
+++ b/lib/mpls.h
@@ -173,7 +173,7 @@ static inline char *label2str(mpls_label_t label, char *buf, size_t len)
#define MPLS_LABEL_RTALERT 1 /* Router Alert Label */
#define MPLS_LABEL_IPV6NULL 2 /* IPv6 Explicit NULL Label */
#define MPLS_LABEL_IMPLNULL 3 /* Implicit NULL Label */
-/* MPLS_LABEL_RESERVED 4-15 */ /* Values 4-15 are reserved */
+ /* MPLS_LABEL_RESERVED 4-15 */ /* Values 4-15 are reserved */
#define MPLS_LABEL_RESERVED_MAX 15
#define MPLS_LABEL_MAX ((1 << 20) - 1)
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 9b0c2d73f4..7180be33dd 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -133,17 +133,17 @@ void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
for (nh1 = nh; nh1; nh1 = nh1->next) {
nexthop = nexthop_new();
- nexthop->ifindex = nh->ifindex;
- nexthop->type = nh->type;
- nexthop->flags = nh->flags;
- memcpy(&nexthop->gate, &nh->gate, sizeof(nh->gate));
- memcpy(&nexthop->src, &nh->src, sizeof(nh->src));
- memcpy(&nexthop->rmap_src, &nh->rmap_src, sizeof(nh->rmap_src));
+ nexthop->ifindex = nh1->ifindex;
+ nexthop->type = nh1->type;
+ nexthop->flags = nh1->flags;
+ memcpy(&nexthop->gate, &nh1->gate, sizeof(nh1->gate));
+ memcpy(&nexthop->src, &nh1->src, sizeof(nh1->src));
+ memcpy(&nexthop->rmap_src, &nh1->rmap_src, sizeof(nh1->rmap_src));
nexthop->rparent = rparent;
- if (nh->nh_label)
- nexthop_add_labels(nexthop, nh->nh_label_type,
- nh->nh_label->num_labels,
- &nh->nh_label->label[0]);
+ if (nh1->nh_label)
+ nexthop_add_labels(nexthop, nh1->nh_label_type,
+ nh1->nh_label->num_labels,
+ &nh1->nh_label->label[0]);
nexthop_add(tnh, nexthop);
if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE))
diff --git a/lib/openbsd-tree.c b/lib/openbsd-tree.c
index 5d77ac2a47..d171e14d25 100644
--- a/lib/openbsd-tree.c
+++ b/lib/openbsd-tree.c
@@ -45,14 +45,16 @@
#include <lib/openbsd-tree.h>
-static inline struct rb_entry *rb_n2e(const struct rb_type *t, void *node)
+static inline struct rb_entry *
+rb_n2e(const struct rb_type *t, void *node)
{
unsigned long addr = (unsigned long)node;
return ((struct rb_entry *)(addr + t->t_offset));
}
-static inline void *rb_e2n(const struct rb_type *t, struct rb_entry *rbe)
+static inline void *
+rb_e2n(const struct rb_type *t, struct rb_entry *rbe)
{
unsigned long addr = (unsigned long)rbe;
@@ -66,33 +68,37 @@ static inline void *rb_e2n(const struct rb_type *t, struct rb_entry *rbe)
#define RBH_ROOT(_rbt) (_rbt)->rbt_root
-static inline void rbe_set(struct rb_entry *rbe, struct rb_entry *parent)
+static inline void
+rbe_set(struct rb_entry *rbe, struct rb_entry *parent)
{
RBE_PARENT(rbe) = parent;
RBE_LEFT(rbe) = RBE_RIGHT(rbe) = NULL;
RBE_COLOR(rbe) = RB_RED;
}
-static inline void rbe_set_blackred(struct rb_entry *black,
- struct rb_entry *red)
+static inline void
+rbe_set_blackred(struct rb_entry *black, struct rb_entry *red)
{
RBE_COLOR(black) = RB_BLACK;
RBE_COLOR(red) = RB_RED;
}
-static inline void rbe_augment(const struct rb_type *t, struct rb_entry *rbe)
+static inline void
+rbe_augment(const struct rb_type *t, struct rb_entry *rbe)
{
(*t->t_augment)(rb_e2n(t, rbe));
}
-static inline void rbe_if_augment(const struct rb_type *t, struct rb_entry *rbe)
+static inline void
+rbe_if_augment(const struct rb_type *t, struct rb_entry *rbe)
{
if (t->t_augment != NULL)
rbe_augment(t, rbe);
}
-static inline void rbe_rotate_left(const struct rb_type *t,
- struct rbt_tree *rbt, struct rb_entry *rbe)
+static inline void
+rbe_rotate_left(const struct rb_type *t, struct rbt_tree *rbt,
+ struct rb_entry *rbe)
{
struct rb_entry *parent;
struct rb_entry *tmp;
@@ -124,8 +130,9 @@ static inline void rbe_rotate_left(const struct rb_type *t,
}
}
-static inline void rbe_rotate_right(const struct rb_type *t,
- struct rbt_tree *rbt, struct rb_entry *rbe)
+static inline void
+rbe_rotate_right(const struct rb_type *t, struct rbt_tree *rbt,
+ struct rb_entry *rbe)
{
struct rb_entry *parent;
struct rb_entry *tmp;
@@ -157,13 +164,14 @@ static inline void rbe_rotate_right(const struct rb_type *t,
}
}
-static inline void rbe_insert_color(const struct rb_type *t,
- struct rbt_tree *rbt, struct rb_entry *rbe)
+static inline void
+rbe_insert_color(const struct rb_type *t, struct rbt_tree *rbt,
+ struct rb_entry *rbe)
{
struct rb_entry *parent, *gparent, *tmp;
- while ((parent = RBE_PARENT(rbe)) != NULL
- && RBE_COLOR(parent) == RB_RED) {
+ while ((parent = RBE_PARENT(rbe)) != NULL &&
+ RBE_COLOR(parent) == RB_RED) {
gparent = RBE_PARENT(parent);
if (parent == RBE_LEFT(gparent)) {
@@ -208,19 +216,14 @@ static inline void rbe_insert_color(const struct rb_type *t,
RBE_COLOR(RBH_ROOT(rbt)) = RB_BLACK;
}
-static inline void rbe_remove_color(const struct rb_type *t,
- struct rbt_tree *rbt,
- struct rb_entry *parent,
- struct rb_entry *rbe)
+static inline void
+rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,
+ struct rb_entry *parent, struct rb_entry *rbe)
{
struct rb_entry *tmp;
- /* Silence clang possible NULL deference warning. */
- if (parent == NULL)
- return;
-
- while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK)
- && rbe != RBH_ROOT(rbt)) {
+ while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK) &&
+ rbe != RBH_ROOT(rbt) && parent) {
if (RBE_LEFT(parent) == rbe) {
tmp = RBE_RIGHT(parent);
if (RBE_COLOR(tmp) == RB_RED) {
@@ -228,16 +231,16 @@ static inline void rbe_remove_color(const struct rb_type *t,
rbe_rotate_left(t, rbt, parent);
tmp = RBE_RIGHT(parent);
}
- if ((RBE_LEFT(tmp) == NULL
- || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK)
- && (RBE_RIGHT(tmp) == NULL
- || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
+ if ((RBE_LEFT(tmp) == NULL ||
+ RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) &&
+ (RBE_RIGHT(tmp) == NULL ||
+ RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
RBE_COLOR(tmp) = RB_RED;
rbe = parent;
parent = RBE_PARENT(rbe);
} else {
- if (RBE_RIGHT(tmp) == NULL
- || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) {
+ if (RBE_RIGHT(tmp) == NULL ||
+ RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK) {
struct rb_entry *oleft;
oleft = RBE_LEFT(tmp);
@@ -266,16 +269,16 @@ static inline void rbe_remove_color(const struct rb_type *t,
tmp = RBE_LEFT(parent);
}
- if ((RBE_LEFT(tmp) == NULL
- || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK)
- && (RBE_RIGHT(tmp) == NULL
- || RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
+ if ((RBE_LEFT(tmp) == NULL ||
+ RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) &&
+ (RBE_RIGHT(tmp) == NULL ||
+ RBE_COLOR(RBE_RIGHT(tmp)) == RB_BLACK)) {
RBE_COLOR(tmp) = RB_RED;
rbe = parent;
parent = RBE_PARENT(rbe);
} else {
- if (RBE_LEFT(tmp) == NULL
- || RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) {
+ if (RBE_LEFT(tmp) == NULL ||
+ RBE_COLOR(RBE_LEFT(tmp)) == RB_BLACK) {
struct rb_entry *oright;
oright = RBE_RIGHT(tmp);
@@ -385,7 +388,8 @@ color:
return (old);
}
-void *_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
+void *
+_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
struct rb_entry *old;
@@ -395,7 +399,8 @@ void *_rb_remove(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
return (old == NULL ? NULL : rb_e2n(t, old));
}
-void *_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
+void *
+_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
struct rb_entry *tmp;
@@ -435,7 +440,8 @@ void *_rb_insert(const struct rb_type *t, struct rbt_tree *rbt, void *elm)
}
/* Finds the node with the same key as elm */
-void *_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
+void *
+_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
{
struct rb_entry *tmp = RBH_ROOT(rbt);
void *node;
@@ -456,7 +462,8 @@ void *_rb_find(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
}
/* Finds the first node greater than or equal to the search key */
-void *_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
+void *
+_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
{
struct rb_entry *tmp = RBH_ROOT(rbt);
void *node;
@@ -478,7 +485,8 @@ void *_rb_nfind(const struct rb_type *t, struct rbt_tree *rbt, const void *key)
return (res);
}
-void *_rb_next(const struct rb_type *t, void *elm)
+void *
+_rb_next(const struct rb_type *t, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
@@ -487,11 +495,12 @@ void *_rb_next(const struct rb_type *t, void *elm)
while (RBE_LEFT(rbe) != NULL)
rbe = RBE_LEFT(rbe);
} else {
- if (RBE_PARENT(rbe) && (rbe == RBE_LEFT(RBE_PARENT(rbe))))
+ if (RBE_PARENT(rbe) &&
+ (rbe == RBE_LEFT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
else {
- while (RBE_PARENT(rbe)
- && (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
+ while (RBE_PARENT(rbe) &&
+ (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
rbe = RBE_PARENT(rbe);
}
@@ -500,7 +509,8 @@ void *_rb_next(const struct rb_type *t, void *elm)
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *_rb_prev(const struct rb_type *t, void *elm)
+void *
+_rb_prev(const struct rb_type *t, void *elm)
{
struct rb_entry *rbe = rb_n2e(t, elm);
@@ -509,11 +519,12 @@ void *_rb_prev(const struct rb_type *t, void *elm)
while (RBE_RIGHT(rbe))
rbe = RBE_RIGHT(rbe);
} else {
- if (RBE_PARENT(rbe) && (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
+ if (RBE_PARENT(rbe) &&
+ (rbe == RBE_RIGHT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
else {
- while (RBE_PARENT(rbe)
- && (rbe == RBE_LEFT(RBE_PARENT(rbe))))
+ while (RBE_PARENT(rbe) &&
+ (rbe == RBE_LEFT(RBE_PARENT(rbe))))
rbe = RBE_PARENT(rbe);
rbe = RBE_PARENT(rbe);
}
@@ -522,14 +533,16 @@ void *_rb_prev(const struct rb_type *t, void *elm)
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *_rb_root(const struct rb_type *t, struct rbt_tree *rbt)
+void *
+_rb_root(const struct rb_type *t, struct rbt_tree *rbt)
{
struct rb_entry *rbe = RBH_ROOT(rbt);
return (rbe == NULL ? rbe : rb_e2n(t, rbe));
}
-void *_rb_min(const struct rb_type *t, struct rbt_tree *rbt)
+void *
+_rb_min(const struct rb_type *t, struct rbt_tree *rbt)
{
struct rb_entry *rbe = RBH_ROOT(rbt);
struct rb_entry *parent = NULL;
@@ -542,7 +555,8 @@ void *_rb_min(const struct rb_type *t, struct rbt_tree *rbt)
return (parent == NULL ? NULL : rb_e2n(t, parent));
}
-void *_rb_max(const struct rb_type *t, struct rbt_tree *rbt)
+void *
+_rb_max(const struct rb_type *t, struct rbt_tree *rbt)
{
struct rb_entry *rbe = RBH_ROOT(rbt);
struct rb_entry *parent = NULL;
@@ -555,28 +569,32 @@ void *_rb_max(const struct rb_type *t, struct rbt_tree *rbt)
return (parent == NULL ? NULL : rb_e2n(t, parent));
}
-void *_rb_left(const struct rb_type *t, void *node)
+void *
+_rb_left(const struct rb_type *t, void *node)
{
struct rb_entry *rbe = rb_n2e(t, node);
rbe = RBE_LEFT(rbe);
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *_rb_right(const struct rb_type *t, void *node)
+void *
+_rb_right(const struct rb_type *t, void *node)
{
struct rb_entry *rbe = rb_n2e(t, node);
rbe = RBE_RIGHT(rbe);
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void *_rb_parent(const struct rb_type *t, void *node)
+void *
+_rb_parent(const struct rb_type *t, void *node)
{
struct rb_entry *rbe = rb_n2e(t, node);
rbe = RBE_PARENT(rbe);
return (rbe == NULL ? NULL : rb_e2n(t, rbe));
}
-void _rb_set_left(const struct rb_type *t, void *node, void *left)
+void
+_rb_set_left(const struct rb_type *t, void *node, void *left)
{
struct rb_entry *rbe = rb_n2e(t, node);
struct rb_entry *rbl = (left == NULL) ? NULL : rb_n2e(t, left);
@@ -584,7 +602,8 @@ void _rb_set_left(const struct rb_type *t, void *node, void *left)
RBE_LEFT(rbe) = rbl;
}
-void _rb_set_right(const struct rb_type *t, void *node, void *right)
+void
+_rb_set_right(const struct rb_type *t, void *node, void *right)
{
struct rb_entry *rbe = rb_n2e(t, node);
struct rb_entry *rbr = (right == NULL) ? NULL : rb_n2e(t, right);
@@ -592,7 +611,8 @@ void _rb_set_right(const struct rb_type *t, void *node, void *right)
RBE_RIGHT(rbe) = rbr;
}
-void _rb_set_parent(const struct rb_type *t, void *node, void *parent)
+void
+_rb_set_parent(const struct rb_type *t, void *node, void *parent)
{
struct rb_entry *rbe = rb_n2e(t, node);
struct rb_entry *rbp = (parent == NULL) ? NULL : rb_n2e(t, parent);
@@ -600,19 +620,21 @@ void _rb_set_parent(const struct rb_type *t, void *node, void *parent)
RBE_PARENT(rbe) = rbp;
}
-void _rb_poison(const struct rb_type *t, void *node, unsigned long poison)
+void
+_rb_poison(const struct rb_type *t, void *node, unsigned long poison)
{
struct rb_entry *rbe = rb_n2e(t, node);
RBE_PARENT(rbe) = RBE_LEFT(rbe) = RBE_RIGHT(rbe) =
- (struct rb_entry *)poison;
+ (struct rb_entry *)poison;
}
-int _rb_check(const struct rb_type *t, void *node, unsigned long poison)
+int
+_rb_check(const struct rb_type *t, void *node, unsigned long poison)
{
struct rb_entry *rbe = rb_n2e(t, node);
- return ((unsigned long)RBE_PARENT(rbe) == poison
- && (unsigned long)RBE_LEFT(rbe) == poison
- && (unsigned long)RBE_RIGHT(rbe) == poison);
+ return ((unsigned long)RBE_PARENT(rbe) == poison &&
+ (unsigned long)RBE_LEFT(rbe) == poison &&
+ (unsigned long)RBE_RIGHT(rbe) == poison);
}
diff --git a/lib/openbsd-tree.h b/lib/openbsd-tree.h
index bfa695fcdc..22cb9252f5 100644
--- a/lib/openbsd-tree.h
+++ b/lib/openbsd-tree.h
@@ -24,7 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _SYS_TREE_H_
+#ifndef _SYS_TREE_H_
#define _SYS_TREE_H_
/*
@@ -54,26 +54,23 @@
* The maximum height of a red-black tree is 2lg (n+1).
*/
-#define SPLAY_HEAD(name, type) \
- struct name { \
- struct type *sph_root; /* root of the tree */ \
- }
+#define SPLAY_HEAD(name, type) \
+struct name { \
+ struct type *sph_root; /* root of the tree */ \
+}
-#define SPLAY_INITIALIZER(root) \
- { \
- NULL \
- }
+#define SPLAY_INITIALIZER(root) \
+ { NULL }
-#define SPLAY_INIT(root) \
- do { \
- (root)->sph_root = NULL; \
- } while (0)
+#define SPLAY_INIT(root) do { \
+ (root)->sph_root = NULL; \
+} while (0)
-#define SPLAY_ENTRY(type) \
- struct { \
- struct type *spe_left; /* left element */ \
- struct type *spe_right; /* right element */ \
- }
+#define SPLAY_ENTRY(type) \
+struct { \
+ struct type *spe_left; /* left element */ \
+ struct type *spe_right; /* right element */ \
+}
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
@@ -81,220 +78,197 @@
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
-#define SPLAY_ROTATE_RIGHT(head, tmp, field) \
- do { \
- SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
- SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
- (head)->sph_root = tmp; \
- } while (0)
-
-#define SPLAY_ROTATE_LEFT(head, tmp, field) \
- do { \
- SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
- SPLAY_LEFT(tmp, field) = (head)->sph_root; \
- (head)->sph_root = tmp; \
- } while (0)
-
-#define SPLAY_LINKLEFT(head, tmp, field) \
- do { \
- SPLAY_LEFT(tmp, field) = (head)->sph_root; \
- tmp = (head)->sph_root; \
- (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
- } while (0)
-
-#define SPLAY_LINKRIGHT(head, tmp, field) \
- do { \
- SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
- tmp = (head)->sph_root; \
- (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
- } while (0)
-
-#define SPLAY_ASSEMBLE(head, node, left, right, field) \
- do { \
- SPLAY_RIGHT(left, field) = \
- SPLAY_LEFT((head)->sph_root, field); \
- SPLAY_LEFT(right, field) = \
- SPLAY_RIGHT((head)->sph_root, field); \
- SPLAY_LEFT((head)->sph_root, field) = \
- SPLAY_RIGHT(node, field); \
- SPLAY_RIGHT((head)->sph_root, field) = \
- SPLAY_LEFT(node, field); \
- } while (0)
+#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
+ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
+ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
+ (head)->sph_root = tmp; \
+} while (0)
+
+#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
+ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
+ SPLAY_LEFT(tmp, field) = (head)->sph_root; \
+ (head)->sph_root = tmp; \
+} while (0)
+
+#define SPLAY_LINKLEFT(head, tmp, field) do { \
+ SPLAY_LEFT(tmp, field) = (head)->sph_root; \
+ tmp = (head)->sph_root; \
+ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
+} while (0)
+
+#define SPLAY_LINKRIGHT(head, tmp, field) do { \
+ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
+ tmp = (head)->sph_root; \
+ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
+} while (0)
+
+#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
+ SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
+ SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
+ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
+ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
+} while (0)
/* Generates prototypes and inline functions */
-#define SPLAY_PROTOTYPE(name, type, field, cmp) \
- void name##_SPLAY(struct name *, struct type *); \
- void name##_SPLAY_MINMAX(struct name *, int); \
- struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
- struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
- \
- /* Finds the node with the same key as elm */ \
- static __inline struct type *name##_SPLAY_FIND(struct name *head, \
- struct type *elm) \
- { \
- if (SPLAY_EMPTY(head)) \
- return (NULL); \
- name##_SPLAY(head, elm); \
- if ((cmp)(elm, (head)->sph_root) == 0) \
- return (head->sph_root); \
- return (NULL); \
- } \
- \
- static __inline struct type *name##_SPLAY_NEXT(struct name *head, \
- struct type *elm) \
- { \
- name##_SPLAY(head, elm); \
- if (SPLAY_RIGHT(elm, field) != NULL) { \
- elm = SPLAY_RIGHT(elm, field); \
- while (SPLAY_LEFT(elm, field) != NULL) { \
- elm = SPLAY_LEFT(elm, field); \
- } \
- } else \
- elm = NULL; \
- return (elm); \
- } \
- \
- static __inline struct type *name##_SPLAY_MIN_MAX(struct name *head, \
- int val) \
- { \
- name##_SPLAY_MINMAX(head, val); \
- return (SPLAY_ROOT(head)); \
- }
+#define SPLAY_PROTOTYPE(name, type, field, cmp) \
+void name##_SPLAY(struct name *, struct type *); \
+void name##_SPLAY_MINMAX(struct name *, int); \
+struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
+struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
+ \
+/* Finds the node with the same key as elm */ \
+static __inline struct type * \
+name##_SPLAY_FIND(struct name *head, struct type *elm) \
+{ \
+ if (SPLAY_EMPTY(head)) \
+ return(NULL); \
+ name##_SPLAY(head, elm); \
+ if ((cmp)(elm, (head)->sph_root) == 0) \
+ return (head->sph_root); \
+ return (NULL); \
+} \
+ \
+static __inline struct type * \
+name##_SPLAY_NEXT(struct name *head, struct type *elm) \
+{ \
+ name##_SPLAY(head, elm); \
+ if (SPLAY_RIGHT(elm, field) != NULL) { \
+ elm = SPLAY_RIGHT(elm, field); \
+ while (SPLAY_LEFT(elm, field) != NULL) { \
+ elm = SPLAY_LEFT(elm, field); \
+ } \
+ } else \
+ elm = NULL; \
+ return (elm); \
+} \
+ \
+static __inline struct type * \
+name##_SPLAY_MIN_MAX(struct name *head, int val) \
+{ \
+ name##_SPLAY_MINMAX(head, val); \
+ return (SPLAY_ROOT(head)); \
+}
/* Main splay operation.
* Moves node close to the key of elm to top
*/
-#define SPLAY_GENERATE(name, type, field, cmp) \
- struct type *name##_SPLAY_INSERT(struct name *head, struct type *elm) \
- { \
- if (SPLAY_EMPTY(head)) { \
- SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = \
- NULL; \
- } else { \
- int __comp; \
- name##_SPLAY(head, elm); \
- __comp = (cmp)(elm, (head)->sph_root); \
- if (__comp < 0) { \
- SPLAY_LEFT(elm, field) = \
- SPLAY_LEFT((head)->sph_root, field); \
- SPLAY_RIGHT(elm, field) = (head)->sph_root; \
- SPLAY_LEFT((head)->sph_root, field) = NULL; \
- } else if (__comp > 0) { \
- SPLAY_RIGHT(elm, field) = \
- SPLAY_RIGHT((head)->sph_root, field); \
- SPLAY_LEFT(elm, field) = (head)->sph_root; \
- SPLAY_RIGHT((head)->sph_root, field) = NULL; \
- } else \
- return ((head)->sph_root); \
- } \
- (head)->sph_root = (elm); \
- return (NULL); \
- } \
- \
- struct type *name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
- { \
- struct type *__tmp; \
- if (SPLAY_EMPTY(head)) \
- return (NULL); \
- name##_SPLAY(head, elm); \
- if ((cmp)(elm, (head)->sph_root) == 0) { \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
- (head)->sph_root = \
- SPLAY_RIGHT((head)->sph_root, field); \
- } else { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- (head)->sph_root = \
- SPLAY_LEFT((head)->sph_root, field); \
- name##_SPLAY(head, elm); \
- SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
- } \
- return (elm); \
- } \
- return (NULL); \
- } \
- \
- void name##_SPLAY(struct name *head, struct type *elm) \
- { \
- struct type __node, *__left, *__right, *__tmp; \
- int __comp; \
- \
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = \
- NULL; \
- __left = __right = &__node; \
- \
- while ((__comp = (cmp)(elm, (head)->sph_root))) { \
- if (__comp < 0) { \
- __tmp = SPLAY_LEFT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if ((cmp)(elm, __tmp) < 0) { \
- SPLAY_ROTATE_RIGHT(head, __tmp, \
- field); \
- if (SPLAY_LEFT((head)->sph_root, \
- field) \
- == NULL) \
- break; \
- } \
- SPLAY_LINKLEFT(head, __right, field); \
- } else if (__comp > 0) { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if ((cmp)(elm, __tmp) > 0) { \
- SPLAY_ROTATE_LEFT(head, __tmp, field); \
- if (SPLAY_RIGHT((head)->sph_root, \
- field) \
- == NULL) \
- break; \
- } \
- SPLAY_LINKRIGHT(head, __left, field); \
- } \
- } \
- SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
- } \
- \
- /* Splay with either the minimum or the maximum element \
- * Used to find minimum or maximum element in tree. \
- */ \
- void name##_SPLAY_MINMAX(struct name *head, int __comp) \
- { \
- struct type __node, *__left, *__right, *__tmp; \
- \
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = \
- NULL; \
- __left = __right = &__node; \
- \
- while (1) { \
- if (__comp < 0) { \
- __tmp = SPLAY_LEFT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if (__comp < 0) { \
- SPLAY_ROTATE_RIGHT(head, __tmp, \
- field); \
- if (SPLAY_LEFT((head)->sph_root, \
- field) \
- == NULL) \
- break; \
- } \
- SPLAY_LINKLEFT(head, __right, field); \
- } else if (__comp > 0) { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if (__comp > 0) { \
- SPLAY_ROTATE_LEFT(head, __tmp, field); \
- if (SPLAY_RIGHT((head)->sph_root, \
- field) \
- == NULL) \
- break; \
- } \
- SPLAY_LINKRIGHT(head, __left, field); \
- } \
- } \
- SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
- }
+#define SPLAY_GENERATE(name, type, field, cmp) \
+struct type * \
+name##_SPLAY_INSERT(struct name *head, struct type *elm) \
+{ \
+ if (SPLAY_EMPTY(head)) { \
+ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
+ } else { \
+ int __comp; \
+ name##_SPLAY(head, elm); \
+ __comp = (cmp)(elm, (head)->sph_root); \
+ if(__comp < 0) { \
+ SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
+ SPLAY_RIGHT(elm, field) = (head)->sph_root; \
+ SPLAY_LEFT((head)->sph_root, field) = NULL; \
+ } else if (__comp > 0) { \
+ SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
+ SPLAY_LEFT(elm, field) = (head)->sph_root; \
+ SPLAY_RIGHT((head)->sph_root, field) = NULL; \
+ } else \
+ return ((head)->sph_root); \
+ } \
+ (head)->sph_root = (elm); \
+ return (NULL); \
+} \
+ \
+struct type * \
+name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
+{ \
+ struct type *__tmp; \
+ if (SPLAY_EMPTY(head)) \
+ return (NULL); \
+ name##_SPLAY(head, elm); \
+ if ((cmp)(elm, (head)->sph_root) == 0) { \
+ if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
+ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
+ } else { \
+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
+ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
+ name##_SPLAY(head, elm); \
+ SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
+ } \
+ return (elm); \
+ } \
+ return (NULL); \
+} \
+ \
+void \
+name##_SPLAY(struct name *head, struct type *elm) \
+{ \
+ struct type __node, *__left, *__right, *__tmp; \
+ int __comp; \
+\
+ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
+ __left = __right = &__node; \
+\
+ while ((__comp = (cmp)(elm, (head)->sph_root))) { \
+ if (__comp < 0) { \
+ __tmp = SPLAY_LEFT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if ((cmp)(elm, __tmp) < 0){ \
+ SPLAY_ROTATE_RIGHT(head, __tmp, field); \
+ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
+ break; \
+ } \
+ SPLAY_LINKLEFT(head, __right, field); \
+ } else if (__comp > 0) { \
+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if ((cmp)(elm, __tmp) > 0){ \
+ SPLAY_ROTATE_LEFT(head, __tmp, field); \
+ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
+ break; \
+ } \
+ SPLAY_LINKRIGHT(head, __left, field); \
+ } \
+ } \
+ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
+} \
+ \
+/* Splay with either the minimum or the maximum element \
+ * Used to find minimum or maximum element in tree. \
+ */ \
+void name##_SPLAY_MINMAX(struct name *head, int __comp) \
+{ \
+ struct type __node, *__left, *__right, *__tmp; \
+\
+ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
+ __left = __right = &__node; \
+\
+ while (1) { \
+ if (__comp < 0) { \
+ __tmp = SPLAY_LEFT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if (__comp < 0){ \
+ SPLAY_ROTATE_RIGHT(head, __tmp, field); \
+ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
+ break; \
+ } \
+ SPLAY_LINKLEFT(head, __right, field); \
+ } else if (__comp > 0) { \
+ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
+ if (__tmp == NULL) \
+ break; \
+ if (__comp > 0) { \
+ SPLAY_ROTATE_LEFT(head, __tmp, field); \
+ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
+ break; \
+ } \
+ SPLAY_LINKRIGHT(head, __left, field); \
+ } \
+ } \
+ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
+}
#define SPLAY_NEGINF -1
#define SPLAY_INF 1
@@ -303,13 +277,14 @@
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
-#define SPLAY_MIN(name, x) \
- (SPLAY_EMPTY(x) ? NULL : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
-#define SPLAY_MAX(name, x) \
- (SPLAY_EMPTY(x) ? NULL : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
-
-#define SPLAY_FOREACH(x, name, head) \
- for ((x) = SPLAY_MIN(name, head); (x) != NULL; \
+#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
+ : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
+#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
+ : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
+
+#define SPLAY_FOREACH(x, name, head) \
+ for ((x) = SPLAY_MIN(name, head); \
+ (x) != NULL; \
(x) = SPLAY_NEXT(name, head, x))
/*
@@ -332,199 +307,203 @@
#define RB_RED 1
struct rb_type {
- int (*t_compare)(const void *, const void *);
- void (*t_augment)(void *);
- unsigned int t_offset; /* offset of rb_entry in type */
+ int (*t_compare)(const void *, const void *);
+ void (*t_augment)(void *);
+ unsigned int t_offset; /* offset of rb_entry in type */
};
struct rbt_tree {
- struct rb_entry *rbt_root;
+ struct rb_entry *rbt_root;
};
struct rb_entry {
- struct rb_entry *rbt_parent;
- struct rb_entry *rbt_left;
- struct rb_entry *rbt_right;
- unsigned int rbt_color;
+ struct rb_entry *rbt_parent;
+ struct rb_entry *rbt_left;
+ struct rb_entry *rbt_right;
+ unsigned int rbt_color;
};
-#define RB_HEAD(_name, _type) \
- struct _name { \
- struct rbt_tree rbh_root; \
- }
+#define RB_HEAD(_name, _type) \
+struct _name { \
+ struct rbt_tree rbh_root; \
+}
#define RB_ENTRY(_type) struct rb_entry
-static inline void _rb_init(struct rbt_tree *rbt)
+static inline void
+_rb_init(struct rbt_tree *rbt)
{
rbt->rbt_root = NULL;
}
-static inline int _rb_empty(struct rbt_tree *rbt)
+static inline int
+_rb_empty(struct rbt_tree *rbt)
{
return (rbt->rbt_root == NULL);
}
-void *_rb_insert(const struct rb_type *, struct rbt_tree *, void *);
-void *_rb_remove(const struct rb_type *, struct rbt_tree *, void *);
-void *_rb_find(const struct rb_type *, struct rbt_tree *, const void *);
-void *_rb_nfind(const struct rb_type *, struct rbt_tree *, const void *);
-void *_rb_root(const struct rb_type *, struct rbt_tree *);
-void *_rb_min(const struct rb_type *, struct rbt_tree *);
-void *_rb_max(const struct rb_type *, struct rbt_tree *);
-void *_rb_next(const struct rb_type *, void *);
-void *_rb_prev(const struct rb_type *, void *);
-void *_rb_left(const struct rb_type *, void *);
-void *_rb_right(const struct rb_type *, void *);
-void *_rb_parent(const struct rb_type *, void *);
-void _rb_set_left(const struct rb_type *, void *, void *);
-void _rb_set_right(const struct rb_type *, void *, void *);
-void _rb_set_parent(const struct rb_type *, void *, void *);
-void _rb_poison(const struct rb_type *, void *, unsigned long);
-int _rb_check(const struct rb_type *, void *, unsigned long);
+void *_rb_insert(const struct rb_type *, struct rbt_tree *, void *);
+void *_rb_remove(const struct rb_type *, struct rbt_tree *, void *);
+void *_rb_find(const struct rb_type *, struct rbt_tree *, const void *);
+void *_rb_nfind(const struct rb_type *, struct rbt_tree *, const void *);
+void *_rb_root(const struct rb_type *, struct rbt_tree *);
+void *_rb_min(const struct rb_type *, struct rbt_tree *);
+void *_rb_max(const struct rb_type *, struct rbt_tree *);
+void *_rb_next(const struct rb_type *, void *);
+void *_rb_prev(const struct rb_type *, void *);
+void *_rb_left(const struct rb_type *, void *);
+void *_rb_right(const struct rb_type *, void *);
+void *_rb_parent(const struct rb_type *, void *);
+void _rb_set_left(const struct rb_type *, void *, void *);
+void _rb_set_right(const struct rb_type *, void *, void *);
+void _rb_set_parent(const struct rb_type *, void *, void *);
+void _rb_poison(const struct rb_type *, void *, unsigned long);
+int _rb_check(const struct rb_type *, void *, unsigned long);
#define RB_INITIALIZER(_head) { { NULL } }
-#define RB_PROTOTYPE(_name, _type, _field, _cmp) \
- extern const struct rb_type *const _name##_RB_TYPE; \
- \
- __attribute__((__unused__)) static inline void _name##_RB_INIT( \
- struct _name *head) \
- { \
- _rb_init(&head->rbh_root); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_INSERT(struct _name *head, struct _type *elm) \
- { \
- return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_REMOVE(struct _name *head, struct _type *elm) \
- { \
- return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_FIND(struct _name *head, const struct _type *key) \
- { \
- return _rb_find(_name##_RB_TYPE, &head->rbh_root, key); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_NFIND(struct _name *head, const struct _type *key) \
- { \
- return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_ROOT(struct _name *head) \
- { \
- return _rb_root(_name##_RB_TYPE, &head->rbh_root); \
- } \
- \
- __attribute__((__unused__)) static inline int _name##_RB_EMPTY( \
- struct _name *head) \
- { \
- return _rb_empty(&head->rbh_root); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_MIN(struct _name *head) \
- { \
- return _rb_min(_name##_RB_TYPE, &head->rbh_root); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_MAX(struct _name *head) \
- { \
- return _rb_max(_name##_RB_TYPE, &head->rbh_root); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_NEXT(struct _type *elm) \
- { \
- return _rb_next(_name##_RB_TYPE, elm); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_PREV(struct _type *elm) \
- { \
- return _rb_prev(_name##_RB_TYPE, elm); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_LEFT(struct _type *elm) \
- { \
- return _rb_left(_name##_RB_TYPE, elm); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_RIGHT(struct _type *elm) \
- { \
- return _rb_right(_name##_RB_TYPE, elm); \
- } \
- \
- __attribute__((__unused__)) static inline struct _type \
- *_name##_RB_PARENT(struct _type *elm) \
- { \
- return _rb_parent(_name##_RB_TYPE, elm); \
- } \
- \
- __attribute__((__unused__)) static inline void _name##_RB_SET_LEFT( \
- struct _type *elm, struct _type *left) \
- { \
- return _rb_set_left(_name##_RB_TYPE, elm, left); \
- } \
- \
- __attribute__((__unused__)) static inline void _name##_RB_SET_RIGHT( \
- struct _type *elm, struct _type *right) \
- { \
- return _rb_set_right(_name##_RB_TYPE, elm, right); \
- } \
- \
- __attribute__((__unused__)) static inline void _name##_RB_SET_PARENT( \
- struct _type *elm, struct _type *parent) \
- { \
- return _rb_set_parent(_name##_RB_TYPE, elm, parent); \
- } \
- \
- __attribute__((__unused__)) static inline void _name##_RB_POISON( \
- struct _type *elm, unsigned long poison) \
- { \
- return _rb_poison(_name##_RB_TYPE, elm, poison); \
- } \
- \
- __attribute__((__unused__)) static inline int _name##_RB_CHECK( \
- struct _type *elm, unsigned long poison) \
- { \
- return _rb_check(_name##_RB_TYPE, elm, poison); \
- }
-
-#define RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \
- static int _name##_RB_COMPARE(const void *lptr, const void *rptr) \
- { \
- const struct _type *l = lptr, *r = rptr; \
- return _cmp(l, r); \
- } \
- static const struct rb_type _name##_RB_INFO = { \
- _name##_RB_COMPARE, \
- _aug, \
- offsetof(struct _type, _field), \
- }; \
- const struct rb_type *const _name##_RB_TYPE = &_name##_RB_INFO;
-
-#define RB_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \
- static void _name##_RB_AUGMENT(void *ptr) \
- { \
- struct _type *p = ptr; \
- return _aug(p); \
- } \
- RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT)
-
-#define RB_GENERATE(_name, _type, _field, _cmp) \
- RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL)
+#define RB_PROTOTYPE(_name, _type, _field, _cmp) \
+extern const struct rb_type *const _name##_RB_TYPE; \
+ \
+__attribute__((__unused__)) static inline void \
+_name##_RB_INIT(struct _name *head) \
+{ \
+ _rb_init(&head->rbh_root); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_INSERT(struct _name *head, struct _type *elm) \
+{ \
+ return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_REMOVE(struct _name *head, struct _type *elm) \
+{ \
+ return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_FIND(struct _name *head, const struct _type *key) \
+{ \
+ return _rb_find(_name##_RB_TYPE, &head->rbh_root, key); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_NFIND(struct _name *head, const struct _type *key) \
+{ \
+ return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_ROOT(struct _name *head) \
+{ \
+ return _rb_root(_name##_RB_TYPE, &head->rbh_root); \
+} \
+ \
+__attribute__((__unused__)) static inline int \
+_name##_RB_EMPTY(struct _name *head) \
+{ \
+ return _rb_empty(&head->rbh_root); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_MIN(struct _name *head) \
+{ \
+ return _rb_min(_name##_RB_TYPE, &head->rbh_root); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_MAX(struct _name *head) \
+{ \
+ return _rb_max(_name##_RB_TYPE, &head->rbh_root); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_NEXT(struct _type *elm) \
+{ \
+ return _rb_next(_name##_RB_TYPE, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_PREV(struct _type *elm) \
+{ \
+ return _rb_prev(_name##_RB_TYPE, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_LEFT(struct _type *elm) \
+{ \
+ return _rb_left(_name##_RB_TYPE, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_RIGHT(struct _type *elm) \
+{ \
+ return _rb_right(_name##_RB_TYPE, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline struct _type * \
+_name##_RB_PARENT(struct _type *elm) \
+{ \
+ return _rb_parent(_name##_RB_TYPE, elm); \
+} \
+ \
+__attribute__((__unused__)) static inline void \
+_name##_RB_SET_LEFT(struct _type *elm, struct _type *left) \
+{ \
+ return _rb_set_left(_name##_RB_TYPE, elm, left); \
+} \
+ \
+__attribute__((__unused__)) static inline void \
+_name##_RB_SET_RIGHT(struct _type *elm, struct _type *right) \
+{ \
+ return _rb_set_right(_name##_RB_TYPE, elm, right); \
+} \
+ \
+__attribute__((__unused__)) static inline void \
+_name##_RB_SET_PARENT(struct _type *elm, struct _type *parent) \
+{ \
+ return _rb_set_parent(_name##_RB_TYPE, elm, parent); \
+} \
+ \
+__attribute__((__unused__)) static inline void \
+_name##_RB_POISON(struct _type *elm, unsigned long poison) \
+{ \
+ return _rb_poison(_name##_RB_TYPE, elm, poison); \
+} \
+ \
+__attribute__((__unused__)) static inline int \
+_name##_RB_CHECK(struct _type *elm, unsigned long poison) \
+{ \
+ return _rb_check(_name##_RB_TYPE, elm, poison); \
+}
+
+#define RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _aug) \
+static int \
+_name##_RB_COMPARE(const void *lptr, const void *rptr) \
+{ \
+ const struct _type *l = lptr, *r = rptr; \
+ return _cmp(l, r); \
+} \
+static const struct rb_type _name##_RB_INFO = { \
+ _name##_RB_COMPARE, \
+ _aug, \
+ offsetof(struct _type, _field), \
+}; \
+const struct rb_type *const _name##_RB_TYPE = &_name##_RB_INFO;
+
+#define RB_GENERATE_AUGMENT(_name, _type, _field, _cmp, _aug) \
+static void \
+_name##_RB_AUGMENT(void *ptr) \
+{ \
+ struct _type *p = ptr; \
+ return _aug(p); \
+} \
+RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, _name##_RB_AUGMENT)
+
+#define RB_GENERATE(_name, _type, _field, _cmp) \
+ RB_GENERATE_INTERNAL(_name, _type, _field, _cmp, NULL)
#define RB_INIT(_name, _head) _name##_RB_INIT(_head)
#define RB_INSERT(_name, _head, _elm) _name##_RB_INSERT(_head, _elm)
@@ -546,20 +525,24 @@ int _rb_check(const struct rb_type *, void *, unsigned long);
#define RB_POISON(_name, _elm, _p) _name##_RB_POISON(_elm, _p)
#define RB_CHECK(_name, _elm, _p) _name##_RB_CHECK(_elm, _p)
-#define RB_FOREACH(_e, _name, _head) \
- for ((_e) = RB_MIN(_name, (_head)); (_e) != NULL; \
+#define RB_FOREACH(_e, _name, _head) \
+ for ((_e) = RB_MIN(_name, (_head)); \
+ (_e) != NULL; \
(_e) = RB_NEXT(_name, (_e)))
-#define RB_FOREACH_SAFE(_e, _name, _head, _n) \
- for ((_e) = RB_MIN(_name, (_head)); \
- (_e) != NULL && ((_n) = RB_NEXT(_name, (_e)), 1); (_e) = (_n))
+#define RB_FOREACH_SAFE(_e, _name, _head, _n) \
+ for ((_e) = RB_MIN(_name, (_head)); \
+ (_e) != NULL && ((_n) = RB_NEXT(_name, (_e)), 1); \
+ (_e) = (_n))
-#define RB_FOREACH_REVERSE(_e, _name, _head) \
- for ((_e) = RB_MAX(_name, (_head)); (_e) != NULL; \
+#define RB_FOREACH_REVERSE(_e, _name, _head) \
+ for ((_e) = RB_MAX(_name, (_head)); \
+ (_e) != NULL; \
(_e) = RB_PREV(_name, (_e)))
-#define RB_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \
- for ((_e) = RB_MAX(_name, (_head)); \
- (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); (_e) = (_n))
+#define RB_FOREACH_REVERSE_SAFE(_e, _name, _head, _n) \
+ for ((_e) = RB_MAX(_name, (_head)); \
+ (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); \
+ (_e) = (_n))
-#endif /* _SYS_TREE_H_ */
+#endif /* _SYS_TREE_H_ */
diff --git a/lib/plist.c b/lib/plist.c
index a598548c68..d7a0db6807 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -1918,9 +1918,8 @@ int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
json_object_object_add(json, "ipv6PrefixList",
json_prefix);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
vty_out(vty, "ip%s prefix-list %s: %d entries\n",
diff --git a/lib/prefix.c b/lib/prefix.c
index 6a37d7de36..88b13cd99f 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -1151,9 +1151,8 @@ const char *prefix2str(union prefixconstptr pu, char *str, int size)
switch (p->family) {
case AF_INET:
case AF_INET6:
- snprintf(str, size, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
- PREFIX2STR_BUFFER),
+ snprintf(str, size, "%s/%d", inet_ntop(p->family, &p->u.prefix,
+ buf, PREFIX2STR_BUFFER),
p->prefixlen);
break;
diff --git a/lib/prefix.h b/lib/prefix.h
index ab9e49f7af..ce13dcfa0a 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -53,9 +53,9 @@ struct ethaddr {
/* length is the number of valuable bits of prefix structure
- * 18 bytes is current length in structure, if address is ipv4
- * 30 bytes is in case of ipv6
- */
+* 18 bytes is current length in structure, if address is ipv4
+* 30 bytes is in case of ipv6
+*/
#define PREFIX_LEN_ROUTE_TYPE_5_IPV4 (18*8)
#define PREFIX_LEN_ROUTE_TYPE_5_IPV6 (30*8)
diff --git a/lib/privs.c b/lib/privs.c
index 81673f84a1..c971596117 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -99,131 +99,113 @@ static struct {
pvalue_t *system_caps;
} cap_map[ZCAP_MAX] = {
#ifdef HAVE_LCAPS /* Quagga -> Linux capabilities mappings */
- [ZCAP_SETID] =
- {
- 2,
- (pvalue_t[]){CAP_SETGID, CAP_SETUID},
- },
- [ZCAP_BIND] =
- {
- 1,
- (pvalue_t[]){CAP_NET_BIND_SERVICE},
- },
- [ZCAP_NET_ADMIN] =
- {
- 1,
- (pvalue_t[]){CAP_NET_ADMIN},
- },
- [ZCAP_NET_RAW] =
- {
- 1,
- (pvalue_t[]){CAP_NET_RAW},
- },
- [ZCAP_CHROOT] =
- {
- 1,
- (pvalue_t[]){
- CAP_SYS_CHROOT,
+ [ZCAP_SETID] =
+ {
+ 2, (pvalue_t[]){CAP_SETGID, CAP_SETUID},
+ },
+ [ZCAP_BIND] =
+ {
+ 1, (pvalue_t[]){CAP_NET_BIND_SERVICE},
+ },
+ [ZCAP_NET_ADMIN] =
+ {
+ 1, (pvalue_t[]){CAP_NET_ADMIN},
+ },
+ [ZCAP_NET_RAW] =
+ {
+ 1, (pvalue_t[]){CAP_NET_RAW},
+ },
+ [ZCAP_CHROOT] =
+ {
+ 1,
+ (pvalue_t[]){
+ CAP_SYS_CHROOT,
+ },
+ },
+ [ZCAP_NICE] =
+ {
+ 1, (pvalue_t[]){CAP_SYS_NICE},
+ },
+ [ZCAP_PTRACE] =
+ {
+ 1, (pvalue_t[]){CAP_SYS_PTRACE},
+ },
+ [ZCAP_DAC_OVERRIDE] =
+ {
+ 1, (pvalue_t[]){CAP_DAC_OVERRIDE},
+ },
+ [ZCAP_READ_SEARCH] =
+ {
+ 1, (pvalue_t[]){CAP_DAC_READ_SEARCH},
+ },
+ [ZCAP_SYS_ADMIN] =
+ {
+ 1, (pvalue_t[]){CAP_SYS_ADMIN},
+ },
+ [ZCAP_FOWNER] =
+ {
+ 1, (pvalue_t[]){CAP_FOWNER},
},
- },
- [ZCAP_NICE] =
- {
- 1,
- (pvalue_t[]){CAP_SYS_NICE},
- },
- [ZCAP_PTRACE] =
- {
- 1,
- (pvalue_t[]){CAP_SYS_PTRACE},
- },
- [ZCAP_DAC_OVERRIDE] =
- {
- 1,
- (pvalue_t[]){CAP_DAC_OVERRIDE},
- },
- [ZCAP_READ_SEARCH] =
- {
- 1,
- (pvalue_t[]){CAP_DAC_READ_SEARCH},
- },
- [ZCAP_SYS_ADMIN] =
- {
- 1,
- (pvalue_t[]){CAP_SYS_ADMIN},
- },
- [ZCAP_FOWNER] =
- {
- 1,
- (pvalue_t[]){CAP_FOWNER},
- },
#elif defined(HAVE_SOLARIS_CAPABILITIES) /* HAVE_LCAPS */
- /* Quagga -> Solaris privilege mappings */
- [ZCAP_SETID] =
- {
- 1,
- (pvalue_t[]){PRIV_PROC_SETID},
- },
- [ZCAP_BIND] =
- {
- 1,
- (pvalue_t[]){PRIV_NET_PRIVADDR},
- },
+ /* Quagga -> Solaris privilege mappings */
+ [ZCAP_SETID] =
+ {
+ 1, (pvalue_t[]){PRIV_PROC_SETID},
+ },
+ [ZCAP_BIND] =
+ {
+ 1, (pvalue_t[]){PRIV_NET_PRIVADDR},
+ },
/* IP_CONFIG is a subset of NET_CONFIG and is allowed in zones */
#ifdef PRIV_SYS_IP_CONFIG
- [ZCAP_NET_ADMIN] =
- {
- 1,
- (pvalue_t[]){PRIV_SYS_IP_CONFIG},
- },
+ [ZCAP_NET_ADMIN] =
+ {
+ 1, (pvalue_t[]){PRIV_SYS_IP_CONFIG},
+ },
#else
- [ZCAP_NET_ADMIN] =
- {
- 1,
- (pvalue_t[]){PRIV_SYS_NET_CONFIG},
- },
+ [ZCAP_NET_ADMIN] =
+ {
+ 1, (pvalue_t[]){PRIV_SYS_NET_CONFIG},
+ },
#endif
- [ZCAP_NET_RAW] =
- {
- 2,
- (pvalue_t[]){PRIV_NET_RAWACCESS, PRIV_NET_ICMPACCESS},
- },
- [ZCAP_CHROOT] =
- {
- 1,
- (pvalue_t[]){PRIV_PROC_CHROOT},
- },
- [ZCAP_NICE] =
- {
- 1,
- (pvalue_t[]){PRIV_PROC_PRIOCNTL},
- },
- [ZCAP_PTRACE] =
- {
- 1,
- (pvalue_t[]){PRIV_PROC_SESSION},
- },
- [ZCAP_DAC_OVERRIDE] =
- {
- 5,
- (pvalue_t[]){PRIV_FILE_DAC_EXECUTE, PRIV_FILE_DAC_READ,
- PRIV_FILE_DAC_SEARCH, PRIV_FILE_DAC_WRITE,
- PRIV_FILE_DAC_SEARCH},
- },
- [ZCAP_READ_SEARCH] =
- {
- 2,
- (pvalue_t[]){PRIV_FILE_DAC_SEARCH, PRIV_FILE_DAC_READ},
- },
- [ZCAP_SYS_ADMIN] =
- {
- 1,
- (pvalue_t[]){PRIV_SYS_ADMIN},
- },
- [ZCAP_FOWNER] =
- {
- 1,
- (pvalue_t[]){PRIV_FILE_OWNER},
- },
+ [ZCAP_NET_RAW] =
+ {
+ 2, (pvalue_t[]){PRIV_NET_RAWACCESS,
+ PRIV_NET_ICMPACCESS},
+ },
+ [ZCAP_CHROOT] =
+ {
+ 1, (pvalue_t[]){PRIV_PROC_CHROOT},
+ },
+ [ZCAP_NICE] =
+ {
+ 1, (pvalue_t[]){PRIV_PROC_PRIOCNTL},
+ },
+ [ZCAP_PTRACE] =
+ {
+ 1, (pvalue_t[]){PRIV_PROC_SESSION},
+ },
+ [ZCAP_DAC_OVERRIDE] =
+ {
+ 5, (pvalue_t[]){PRIV_FILE_DAC_EXECUTE,
+ PRIV_FILE_DAC_READ,
+ PRIV_FILE_DAC_SEARCH,
+ PRIV_FILE_DAC_WRITE,
+ PRIV_FILE_DAC_SEARCH},
+ },
+ [ZCAP_READ_SEARCH] =
+ {
+ 2, (pvalue_t[]){PRIV_FILE_DAC_SEARCH,
+ PRIV_FILE_DAC_READ},
+ },
+ [ZCAP_SYS_ADMIN] =
+ {
+ 1, (pvalue_t[]){PRIV_SYS_ADMIN},
+ },
+ [ZCAP_FOWNER] =
+ {
+ 1, (pvalue_t[]){PRIV_FILE_OWNER},
+ },
#endif /* HAVE_SOLARIS_CAPABILITIES */
};
@@ -785,7 +767,7 @@ void zprivs_init(struct zebra_privs_t *zprivs)
if (zprivs->vty_group)
/* Add the vty_group to the supplementary groups so it can be chowned to
- */
+ */
{
if (zprivs_state.vtygrp == (gid_t)-1) {
fprintf(stderr,
diff --git a/lib/routemap.c b/lib/routemap.c
index 40daeae41c..3d1add25dc 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -1232,9 +1232,8 @@ int route_map_delete_match(struct route_map_index *index,
return 1;
for (rule = index->match_list.head; rule; rule = rule->next)
- if (rule->cmd == cmd
- && (rulecmp(rule->rule_str, match_arg) == 0
- || match_arg == NULL)) {
+ if (rule->cmd == cmd && (rulecmp(rule->rule_str, match_arg) == 0
+ || match_arg == NULL)) {
route_map_rule_delete(&index->match_list, rule);
/* Execute event hook. */
if (route_map_master.event_hook) {
@@ -1320,9 +1319,8 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
return 1;
for (rule = index->set_list.head; rule; rule = rule->next)
- if ((rule->cmd == cmd)
- && (rulecmp(rule->rule_str, set_arg) == 0
- || set_arg == NULL)) {
+ if ((rule->cmd == cmd) && (rulecmp(rule->rule_str, set_arg) == 0
+ || set_arg == NULL)) {
route_map_rule_delete(&index->set_list, rule);
/* Execute event hook. */
if (route_map_master.event_hook) {
diff --git a/lib/sigevent.c b/lib/sigevent.c
index 2eebb47d6c..2a04fa23cb 100644
--- a/lib/sigevent.c
+++ b/lib/sigevent.c
@@ -207,14 +207,14 @@ exit_handler(int signo
,
siginfo_t *siginfo, void *context
#endif
-)
+ )
{
zlog_signal(signo, "exiting..."
#ifdef SA_SIGINFO
,
siginfo, program_counter(context)
#endif
- );
+ );
_exit(128 + signo);
}
@@ -224,7 +224,7 @@ core_handler(int signo
,
siginfo_t *siginfo, void *context
#endif
-)
+ )
{
/* make sure we don't hang in here. default for SIGALRM is terminate.
* - if we're in backtrace for more than a second, abort. */
@@ -243,7 +243,7 @@ core_handler(int signo
,
siginfo, program_counter(context)
#endif
- );
+ );
/* dump memory stats on core */
log_memstats_stderr("core_handler");
abort();
@@ -290,7 +290,7 @@ static void trap_default_signals(void)
,
siginfo_t *info, void *context
#endif
- );
+ );
} sigmap[] = {
{core_signals, array_size(core_signals), core_handler},
{exit_signals, array_size(exit_signals), exit_handler},
diff --git a/lib/smux.c b/lib/smux.c
index 56c2e874a2..9a0063df21 100644
--- a/lib/smux.c
+++ b/lib/smux.c
@@ -210,25 +210,22 @@ static void smux_getresp_send(oid objid[], size_t objid_len, long reqid,
ptr = asn_build_sequence(ptr, &len, (u_char)SMUX_GETRSP, 0);
h1e = ptr;
- ptr = asn_build_int(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), &reqid,
- sizeof(reqid));
+ ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_INTEGER),
+ &reqid, sizeof(reqid));
if (debug_smux)
zlog_debug("SMUX GETRSP errstat: %ld", errstat);
- ptr = asn_build_int(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), &errstat,
- sizeof(errstat));
+ ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_INTEGER),
+ &errstat, sizeof(errstat));
if (debug_smux)
zlog_debug("SMUX GETRSP errindex: %ld", errindex);
- ptr = asn_build_int(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- &errindex, sizeof(errindex));
+ ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_INTEGER),
+ &errindex, sizeof(errindex));
h2 = ptr;
/* Place holder h2 for one variable */
@@ -887,28 +884,24 @@ static int smux_open(int sock)
/* SMUX Open. */
version = 0;
- ptr = asn_build_int(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER), &version,
- sizeof(version));
+ ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_INTEGER),
+ &version, sizeof(version));
/* SMUX connection oid. */
- ptr = asn_build_objid(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
- smux_oid, smux_oid_len);
+ ptr = asn_build_objid(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_OBJECT_ID),
+ smux_oid, smux_oid_len);
/* SMUX connection description. */
- ptr = asn_build_string(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- (const u_char *)progname, strlen(progname));
+ ptr = asn_build_string(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_OCTET_STR),
+ (const u_char *)progname, strlen(progname));
/* SMUX connection password. */
- ptr = asn_build_string(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- (u_char *)smux_passwd, strlen(smux_passwd));
+ ptr = asn_build_string(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_OCTET_STR),
+ (u_char *)smux_passwd, strlen(smux_passwd));
/* Fill in real SMUX header. We exclude ASN header size (2). */
len = BUFSIZ;
@@ -948,31 +941,27 @@ int smux_trap(struct variable *vp, size_t vp_len, const oid *ename,
ptr = asn_build_header(ptr, &len, (u_char)SMUX_TRAP, 0);
/* Sub agent enterprise oid. */
- ptr = asn_build_objid(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
- smux_oid, smux_oid_len);
+ ptr = asn_build_objid(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_OBJECT_ID),
+ smux_oid, smux_oid_len);
/* IP address. */
addr.s_addr = 0;
- ptr = asn_build_string(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_IPADDRESS),
- (u_char *)&addr, sizeof(addr));
+ ptr = asn_build_string(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_IPADDRESS),
+ (u_char *)&addr, sizeof(addr));
/* Generic trap integer. */
val = SNMP_TRAP_ENTERPRISESPECIFIC;
- ptr = asn_build_int(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&val, sizeof(val));
+ ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_INTEGER),
+ (long *)&val, sizeof(val));
/* Specific trap integer. */
val = sptrap;
- ptr = asn_build_int(
- ptr, &len,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&val, sizeof(val));
+ ptr = asn_build_int(ptr, &len, (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE
+ | ASN_INTEGER),
+ (long *)&val, sizeof(val));
/* Timeticks timestamp. */
val = 0;
diff --git a/lib/sockopt.c b/lib/sockopt.c
index a1bde13a9c..d100991a33 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -261,9 +261,8 @@ int setsockopt_ipv4_multicast(int sock, int optname, struct in_addr if_addr,
zlog_info(
"setsockopt_ipv4_multicast attempting to drop and "
"re-add (fd %d, mcast %s, ifindex %u)",
- sock,
- inet_ntop(AF_INET, &mreqn.imr_multiaddr, buf[0],
- sizeof(buf[0])),
+ sock, inet_ntop(AF_INET, &mreqn.imr_multiaddr, buf[0],
+ sizeof(buf[0])),
ifindex);
setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, (void *)&mreqn,
sizeof(mreqn));
@@ -304,9 +303,8 @@ int setsockopt_ipv4_multicast(int sock, int optname, struct in_addr if_addr,
zlog_info(
"setsockopt_ipv4_multicast attempting to drop and "
"re-add (fd %d, mcast %s, ifindex %u)",
- sock,
- inet_ntop(AF_INET, &mreq.imr_multiaddr, buf[0],
- sizeof(buf[0])),
+ sock, inet_ntop(AF_INET, &mreq.imr_multiaddr, buf[0],
+ sizeof(buf[0])),
ifindex);
setsockopt(sock, IPPROTO_IP, IP_DROP_MEMBERSHIP, (void *)&mreq,
sizeof(mreq));
diff --git a/lib/vty.c b/lib/vty.c
index 494fad7c38..00579550e4 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2822,9 +2822,7 @@ static int vty_config_write(struct vty *vty)
}
struct cmd_node vty_node = {
- VTY_NODE,
- "%s(config-line)# ",
- 1,
+ VTY_NODE, "%s(config-line)# ", 1,
};
/* Reset all VTY status. */
diff --git a/lib/zassert.h b/lib/zassert.h
index 3adaf4f98c..5c06d933e6 100644
--- a/lib/zassert.h
+++ b/lib/zassert.h
@@ -34,10 +34,9 @@ extern void _zlog_assert_failed(const char *assertion, const char *file,
#endif
#define zassert(EX) \
- ((void)((EX) ? 0 \
- : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
- __ASSERT_FUNCTION), \
- 0)))
+ ((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
+ __ASSERT_FUNCTION), \
+ 0)))
#undef assert
#define assert(EX) zassert(EX)
diff --git a/lib/zclient.c b/lib/zclient.c
index b4511ed2cb..a54d8749a3 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -1480,9 +1480,8 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
zlog_warn(
"warning: interface %s address %s "
"with peer flag set, but no peer address!",
- ifp->name,
- prefix2str(ifc->address, buf,
- sizeof buf));
+ ifp->name, prefix2str(ifc->address, buf,
+ sizeof buf));
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
}
}
diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c
index 5d344aca71..7f8341d0e4 100644
--- a/ospf6d/ospf6_asbr.c
+++ b/ospf6d/ospf6_asbr.c
@@ -848,9 +848,7 @@ static route_map_result_t ospf6_routemap_rule_match_tag(void *rule,
}
static struct route_map_rule_cmd ospf6_routemap_rule_match_tag_cmd = {
- "tag",
- ospf6_routemap_rule_match_tag,
- route_map_rule_tag_compile,
+ "tag", ospf6_routemap_rule_match_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -885,8 +883,7 @@ static void ospf6_routemap_rule_set_metric_type_free(void *rule)
}
struct route_map_rule_cmd ospf6_routemap_rule_set_metric_type_cmd = {
- "metric-type",
- ospf6_routemap_rule_set_metric_type,
+ "metric-type", ospf6_routemap_rule_set_metric_type,
ospf6_routemap_rule_set_metric_type_compile,
ospf6_routemap_rule_set_metric_type_free,
};
@@ -921,8 +918,7 @@ static void ospf6_routemap_rule_set_metric_free(void *rule)
}
struct route_map_rule_cmd ospf6_routemap_rule_set_metric_cmd = {
- "metric",
- ospf6_routemap_rule_set_metric,
+ "metric", ospf6_routemap_rule_set_metric,
ospf6_routemap_rule_set_metric_compile,
ospf6_routemap_rule_set_metric_free,
};
@@ -960,8 +956,7 @@ static void ospf6_routemap_rule_set_forwarding_free(void *rule)
}
struct route_map_rule_cmd ospf6_routemap_rule_set_forwarding_cmd = {
- "forwarding-address",
- ospf6_routemap_rule_set_forwarding,
+ "forwarding-address", ospf6_routemap_rule_set_forwarding,
ospf6_routemap_rule_set_forwarding_compile,
ospf6_routemap_rule_set_forwarding_free,
};
@@ -983,9 +978,7 @@ static route_map_result_t ospf6_routemap_rule_set_tag(void *rule,
}
static struct route_map_rule_cmd ospf6_routemap_rule_set_tag_cmd = {
- "tag",
- ospf6_routemap_rule_set_tag,
- route_map_rule_tag_compile,
+ "tag", ospf6_routemap_rule_set_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 7921df884e..1d17a1c233 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -1402,10 +1402,9 @@ DEFUN (ipv6_ospf6_priority,
oi->priority = strtol(argv[idx_number]->arg, NULL, 10);
- if (oi->area
- && (oi->state == OSPF6_INTERFACE_DROTHER
- || oi->state == OSPF6_INTERFACE_BDR
- || oi->state == OSPF6_INTERFACE_DR))
+ if (oi->area && (oi->state == OSPF6_INTERFACE_DROTHER
+ || oi->state == OSPF6_INTERFACE_BDR
+ || oi->state == OSPF6_INTERFACE_DR))
ospf6_interface_state_change(dr_election(oi), oi);
return CMD_SUCCESS;
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index 66e5714d07..015776a174 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -73,9 +73,8 @@ static char *ospf6_router_lsa_get_nbr_id(struct ospf6_lsa *lsa, char *buf,
lsdesc = (struct ospf6_router_lsdesc
*)(start
- + pos
- * (sizeof(struct
- ospf6_router_lsdesc)));
+ + pos * (sizeof(struct
+ ospf6_router_lsdesc)));
if ((char *)lsdesc < end) {
if (buf && (buflen > INET_ADDRSTRLEN * 2)) {
inet_ntop(AF_INET,
@@ -1438,7 +1437,7 @@ static void ospf6_brouter_debug_print(struct ospf6_route *brouter)
char brouter_name[16];
char area_name[16];
char destination[64];
- char installed[16], changed[16];
+ char installed[64], changed[64];
struct timeval now, res;
char id[16], adv_router[16];
char capa[16], options[16];
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index 329060a16f..e1a431ea07 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -467,7 +467,7 @@ void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa)
char adv_router[64], id[64];
struct ospf6_lsa_handler *handler;
struct timeval now, res;
- char duration[16];
+ char duration[64];
assert(lsa && lsa->header);
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 78f1148243..aa5f05ce17 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -869,7 +869,7 @@ static unsigned ospf6_prefixes_examin(
unsigned length,
const u_int32_t req_num_pfxs /* always compared with the actual number
of prefixes */
-)
+ )
{
u_char requested_pfx_bytes;
u_int32_t real_num_pfxs = 0;
@@ -1066,7 +1066,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah,
lsalen - OSPF6_LSA_HEADER_SIZE
- OSPF6_LINK_LSA_MIN_SIZE,
ntohl(link_lsa->prefix_num) /* 32 bits */
- );
+ );
case OSPF6_LSTYPE_INTRA_PREFIX:
/* RFC5340 A.4.10, LSA header + OSPF6_INTRA_PREFIX_LSA_MIN_SIZE
bytes
@@ -1084,7 +1084,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah,
lsalen - OSPF6_LSA_HEADER_SIZE
- OSPF6_INTRA_PREFIX_LSA_MIN_SIZE,
ntohs(intra_prefix_lsa->prefix_num) /* 16 bits */
- );
+ );
}
/* No additional validation is possible for unknown LSA types, which are
themselves valid in OPSFv3, hence the default decision is to accept.
@@ -1270,7 +1270,7 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh,
+ OSPF6_LS_UPD_MIN_SIZE),
bytesonwire - OSPF6_HEADER_SIZE - OSPF6_LS_UPD_MIN_SIZE,
0, ntohl(lsupd->lsa_number) /* 32 bits */
- );
+ );
break;
case OSPF6_MESSAGE_TYPE_LSACK:
/* RFC5340 A.3.6, packet header + N>=0 header-only LSAs. */
diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c
index a21da07483..bde89f54a6 100644
--- a/ospf6d/ospf6_neighbor.c
+++ b/ospf6d/ospf6_neighbor.c
@@ -582,10 +582,10 @@ int inactivity_timer(struct thread *thread)
static void ospf6_neighbor_show(struct vty *vty, struct ospf6_neighbor *on)
{
char router_id[16];
- char duration[16];
+ char duration[64];
struct timeval res;
char nstate[16];
- char deadtime[16];
+ char deadtime[64];
long h, m, s;
/* Router-ID (Name) */
@@ -640,7 +640,7 @@ static void ospf6_neighbor_show_drchoice(struct vty *vty,
{
char router_id[16];
char drouter[16], bdrouter[16];
- char duration[16];
+ char duration[64];
struct timeval now, res;
/*
diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c
index 5e8fd0e15d..e0e9fc9449 100644
--- a/ospf6d/ospf6_route.c
+++ b/ospf6d/ospf6_route.c
@@ -945,7 +945,7 @@ void ospf6_route_show(struct vty *vty, struct ospf6_route *route)
{
int i;
char destination[PREFIX2STR_BUFFER], nexthop[64];
- char duration[16];
+ char duration[64];
const char *ifname;
struct timeval now, res;
struct listnode *node;
@@ -991,7 +991,7 @@ void ospf6_route_show_detail(struct vty *vty, struct ospf6_route *route)
char destination[PREFIX2STR_BUFFER], nexthop[64];
char area_id[16], id[16], adv_router[16], capa[16], options[16];
struct timeval now, res;
- char duration[16];
+ char duration[64];
struct listnode *node;
struct ospf6_nexthop *nh;
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 84993f0b4c..d33f41730e 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -347,8 +347,7 @@ static int config_write_ospf6_zebra(struct vty *vty)
/* Zebra node structure. */
static struct cmd_node zebra_node = {
- ZEBRA_NODE,
- "%s(config-zebra)# ",
+ ZEBRA_NODE, "%s(config-zebra)# ",
};
#define ADD 0
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 41c21ee9b6..c6d4364fa3 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -1034,20 +1034,22 @@ static void ospf_abr_process_network_rt(struct ospf *ospf,
continue;
}
- if (or->path_type == OSPF_PATH_INTRA_AREA
- && !ospf_abr_should_announce(
- ospf, (struct prefix_ipv4 *)&rn->p,
- or)) {
+ if (
+ or->path_type == OSPF_PATH_INTRA_AREA
+ && !ospf_abr_should_announce(
+ ospf, (struct prefix_ipv4 *)&rn->p,
+ or)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_abr_process_network_rt(): denied by export-list");
continue;
}
- if (or->path_type == OSPF_PATH_INTRA_AREA
- && !ospf_abr_plist_out_check(
- area, or,
- (struct prefix_ipv4 *)&rn->p)) {
+ if (
+ or->path_type == OSPF_PATH_INTRA_AREA
+ && !ospf_abr_plist_out_check(
+ area, or,
+ (struct prefix_ipv4 *)&rn->p)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_abr_process_network_rt(): denied by prefix-list");
@@ -1269,9 +1271,10 @@ static void ospf_abr_process_router_rt(struct ospf *ospf,
continue;
}
- if (or->path_type == OSPF_PATH_INTER_AREA
- && !OSPF_IS_AREA_ID_BACKBONE(
- or->u.std.area_id)) {
+ if (
+ or->path_type == OSPF_PATH_INTER_AREA
+ && !OSPF_IS_AREA_ID_BACKBONE(
+ or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_abr_process_router_rt(): "
diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c
index 10570f4e62..f1a7433760 100644
--- a/ospfd/ospf_api.c
+++ b/ospfd/ospf_api.c
@@ -131,60 +131,46 @@ const char *ospf_api_typename(int msgtype)
{
struct nametab NameTab[] = {
{
- MSG_REGISTER_OPAQUETYPE,
- "Register opaque-type",
+ MSG_REGISTER_OPAQUETYPE, "Register opaque-type",
},
{
- MSG_UNREGISTER_OPAQUETYPE,
- "Unregister opaque-type",
+ MSG_UNREGISTER_OPAQUETYPE, "Unregister opaque-type",
},
{
- MSG_REGISTER_EVENT,
- "Register event",
+ MSG_REGISTER_EVENT, "Register event",
},
{
- MSG_SYNC_LSDB,
- "Sync LSDB",
+ MSG_SYNC_LSDB, "Sync LSDB",
},
{
- MSG_ORIGINATE_REQUEST,
- "Originate request",
+ MSG_ORIGINATE_REQUEST, "Originate request",
},
{
- MSG_DELETE_REQUEST,
- "Delete request",
+ MSG_DELETE_REQUEST, "Delete request",
},
{
- MSG_REPLY,
- "Reply",
+ MSG_REPLY, "Reply",
},
{
- MSG_READY_NOTIFY,
- "Ready notify",
+ MSG_READY_NOTIFY, "Ready notify",
},
{
- MSG_LSA_UPDATE_NOTIFY,
- "LSA update notify",
+ MSG_LSA_UPDATE_NOTIFY, "LSA update notify",
},
{
- MSG_LSA_DELETE_NOTIFY,
- "LSA delete notify",
+ MSG_LSA_DELETE_NOTIFY, "LSA delete notify",
},
{
- MSG_NEW_IF,
- "New interface",
+ MSG_NEW_IF, "New interface",
},
{
- MSG_DEL_IF,
- "Del interface",
+ MSG_DEL_IF, "Del interface",
},
{
- MSG_ISM_CHANGE,
- "ISM change",
+ MSG_ISM_CHANGE, "ISM change",
},
{
- MSG_NSM_CHANGE,
- "NSM change",
+ MSG_NSM_CHANGE, "NSM change",
},
};
@@ -205,48 +191,38 @@ const char *ospf_api_errname(int errcode)
{
struct nametab NameTab[] = {
{
- OSPF_API_OK,
- "OK",
+ OSPF_API_OK, "OK",
},
{
- OSPF_API_NOSUCHINTERFACE,
- "No such interface",
+ OSPF_API_NOSUCHINTERFACE, "No such interface",
},
{
- OSPF_API_NOSUCHAREA,
- "No such area",
+ OSPF_API_NOSUCHAREA, "No such area",
},
{
- OSPF_API_NOSUCHLSA,
- "No such LSA",
+ OSPF_API_NOSUCHLSA, "No such LSA",
},
{
- OSPF_API_ILLEGALLSATYPE,
- "Illegal LSA type",
+ OSPF_API_ILLEGALLSATYPE, "Illegal LSA type",
},
{
- OSPF_API_OPAQUETYPEINUSE,
- "Opaque type in use",
+ OSPF_API_OPAQUETYPEINUSE, "Opaque type in use",
},
{
OSPF_API_OPAQUETYPENOTREGISTERED,
"Opaque type not registered",
},
{
- OSPF_API_NOTREADY,
- "Not ready",
+ OSPF_API_NOTREADY, "Not ready",
},
{
- OSPF_API_NOMEMORY,
- "No memory",
+ OSPF_API_NOMEMORY, "No memory",
},
{
- OSPF_API_ERROR,
- "Other error",
+ OSPF_API_ERROR, "Other error",
},
{
- OSPF_API_UNDEF,
- "Undefined",
+ OSPF_API_UNDEF, "Undefined",
},
};
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 2a178a684e..a5f5971ac0 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -1236,10 +1236,10 @@ static int apiserver_sync_callback(struct ospf_lsa *lsa, void *p_arg,
zlog_warn(
"apiserver_sync_callback: new_msg_update failed");
#ifdef NOTYET
-/* Cannot allocate new message. What should we do? */
-/* ospf_apiserver_free (apiserv);*/ /* Do nothing
- here XXX
- */
+ /* Cannot allocate new message. What should we do? */
+ /* ospf_apiserver_free (apiserv);*/ /* Do nothing
+ here XXX
+ */
#endif
goto out;
}
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c
index f00973d64a..c775f2ea2e 100644
--- a/ospfd/ospf_flood.c
+++ b/ospfd/ospf_flood.c
@@ -217,7 +217,7 @@ static void ospf_process_self_originated_lsa(struct ospf *ospf,
break;
case OSPF_OPAQUE_AS_LSA:
ospf_opaque_lsa_refresh(new);
- /* Reconsideration may needed. */ /* XXX */
+ /* Reconsideration may needed. */ /* XXX */
break;
default:
break;
@@ -281,7 +281,7 @@ int ospf_flood(struct ospf *ospf, struct ospf_neighbor *nbr,
"LSA[Flooding]: Got a self-originated LSA, "
"while local one is initial instance.");
; /* Accept this LSA for quick LSDB resynchronization.
- */
+ */
} else if (monotime_since(&current->tv_recv, NULL)
< ospf->min_ls_arrival * 1000LL) {
if (IS_DEBUG_OSPF_EVENT)
diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c
index 38ce71293b..c65d8b8743 100644
--- a/ospfd/ospf_ia.c
+++ b/ospfd/ospf_ia.c
@@ -361,8 +361,10 @@ static void ospf_update_network_route(struct ospf *ospf, struct route_table *rt,
}
if (ospf->abr_type == OSPF_ABR_SHORTCUT) {
- if (or->path_type == OSPF_PATH_INTRA_AREA
- && !OSPF_IS_AREA_ID_BACKBONE(or->u.std.area_id)) {
+ if (
+ or->path_type == OSPF_PATH_INTRA_AREA
+ && !OSPF_IS_AREA_ID_BACKBONE(
+ or->u.std.area_id)) {
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_update_network_route(): Shortcut: "
@@ -648,7 +650,7 @@ void ospf_ia_routing(struct ospf *ospf, struct route_table *rt,
OSPF_EXAMINE_TRANSIT_SUMMARIES_ALL(
area, rt, rtrs);
} else { /* No active BB connection--consider all areas
- */
+ */
if (IS_DEBUG_OSPF_EVENT)
zlog_debug(
"ospf_ia_routing(): "
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index b4624f400f..4ea8ec26f2 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -428,9 +428,8 @@ struct ospf_interface *ospf_if_lookup_recv_if(struct ospf *ospf,
match = oi;
else if (prefix_match(CONNECTED_PREFIX(oi->connected),
(struct prefix *)&addr)) {
- if ((match == NULL)
- || (match->address->prefixlen
- < oi->address->prefixlen))
+ if ((match == NULL) || (match->address->prefixlen
+ < oi->address->prefixlen))
match = oi;
}
}
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 38a17710cd..68adf2e10b 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -429,8 +429,8 @@ static char link_info_set(struct stream *s, struct in_addr id,
*
* Simpler just to subtract OSPF_MAX_LSA_SIZE though.
*/
- ret = stream_resize(s, OSPF_MAX_PACKET_SIZE
- - OSPF_MAX_LSA_SIZE);
+ ret = stream_resize(
+ s, OSPF_MAX_PACKET_SIZE - OSPF_MAX_LSA_SIZE);
}
if (ret == OSPF_MAX_LSA_SIZE) {
@@ -519,9 +519,8 @@ static int lsa_link_broadcast_set(struct stream *s, struct ospf_interface *oi)
dr = ospf_nbr_lookup_by_addr(oi->nbrs, &DR(oi));
/* Describe Type 2 link. */
- if (dr
- && (dr->state == NSM_Full
- || IPV4_ADDR_SAME(&oi->address->u.prefix4, &DR(oi)))
+ if (dr && (dr->state == NSM_Full
+ || IPV4_ADDR_SAME(&oi->address->u.prefix4, &DR(oi)))
&& ospf_nbr_count(oi, NSM_Full) > 0) {
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
zlog_debug(
@@ -3418,7 +3417,7 @@ struct in_addr ospf_lsa_unique_id(struct ospf *ospf, struct ospf_lsdb *lsdb,
return id;
}
/* Masklen differs, then apply wildcard mask to Link State ID.
- */
+ */
else {
masklen2ip(p->prefixlen, &mask);
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index d1cc00b913..f284a04cbe 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -55,9 +55,7 @@
/* ospfd privileges */
zebra_capabilities_t _caps_p[] = {
- ZCAP_NET_RAW,
- ZCAP_BIND,
- ZCAP_NET_ADMIN,
+ ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN,
};
struct zebra_privs_t ospfd_privs = {
diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c
index a1e9533dba..33492cf7c9 100644
--- a/ospfd/ospf_neighbor.c
+++ b/ospfd/ospf_neighbor.c
@@ -460,8 +460,9 @@ struct ospf_neighbor *ospf_nbr_get(struct ospf_interface *oi,
if (oi->type == OSPF_IFTYPE_VIRTUALLINK
|| oi->type == OSPF_IFTYPE_POINTOPOINT)
- key.u.prefix4 = ospfh->router_id; /* index vlink and ptp nbrs by
- router-id */
+ key.u.prefix4 =
+ ospfh->router_id; /* index vlink and ptp nbrs by
+ router-id */
else
key.u.prefix4 = iph->ip_src;
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 97f06afd66..a2c40923b1 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -1358,11 +1358,12 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
* list_isempty (oipt->id_list)
* not being empty.
*/
- if (oipt->t_opaque_lsa_self
- != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot
- originate
- now. */
+ if (
+ oipt->t_opaque_lsa_self
+ != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot
+ originate
+ now. */
continue;
ospf_opaque_lsa_reoriginate_schedule(
@@ -1383,11 +1384,12 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
* list_isempty (oipt->id_list)
* not being empty.
*/
- if (oipt->t_opaque_lsa_self
- != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot
- originate
- now. */
+ if (
+ oipt->t_opaque_lsa_self
+ != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot
+ originate
+ now. */
continue;
ospf_opaque_lsa_reoriginate_schedule(
@@ -1408,11 +1410,12 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0)
* list_isempty (oipt->id_list)
* not being empty.
*/
- if (oipt->t_opaque_lsa_self
- != NULL /* Waiting for a thread call. */
- || oipt->status == PROC_SUSPEND) /* Cannot
- originate
- now. */
+ if (
+ oipt->t_opaque_lsa_self
+ != NULL /* Waiting for a thread call. */
+ || oipt->status == PROC_SUSPEND) /* Cannot
+ originate
+ now. */
continue;
ospf_opaque_lsa_reoriginate_schedule((void *)top,
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index ee6623a057..ac2406ec2d 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -643,9 +643,9 @@ static int ospf_write(struct thread *thread)
#ifdef WANT_OSPF_WRITE_FRAGMENT
static u_int16_t ipid = 0;
u_int16_t maxdatasize;
-#endif /* WANT_OSPF_WRITE_FRAGMENT */
- /* $FRR indent$ */
- /* clang-format off */
+#endif /* WANT_OSPF_WRITE_FRAGMENT */
+ /* $FRR indent$ */
+ /* clang-format off */
#define OSPF_WRITE_IPHL_SHIFT 2
int pkt_count = 0;
@@ -2436,15 +2436,15 @@ static int ospf_check_auth(struct ospf_interface *oi, struct ospf_header *ospfh)
return 0;
}
/* only MD5 crypto method can pass ospf_packet_examin() */
- if (NULL
- == (ck = listgetdata(listtail(
- OSPF_IF_PARAM(oi, auth_crypt))))
- || ospfh->u.crypt.key_id != ck->key_id ||
- /* Condition above uses the last key ID on the list,
- which is
- different from what ospf_crypt_key_lookup() does. A
- bug? */
- !ospf_check_md5_digest(oi, ospfh)) {
+ if (
+ NULL == (ck = listgetdata(listtail(
+ OSPF_IF_PARAM(oi, auth_crypt))))
+ || ospfh->u.crypt.key_id != ck->key_id ||
+ /* Condition above uses the last key ID on the list,
+ which is
+ different from what ospf_crypt_key_lookup() does. A
+ bug? */
+ !ospf_check_md5_digest(oi, ospfh)) {
if (IS_DEBUG_OSPF_PACKET(ospfh->type - 1, RECV))
zlog_warn("interface %s: MD5 auth failed",
IF_NAME(oi));
@@ -2548,7 +2548,7 @@ static unsigned ospf_lsa_examin(struct lsa_header *lsah, const u_int16_t lsalen,
header, "flags",
0, "# links" */
ntohs(rlsa->links) /* 16 bits */
- );
+ );
break;
case OSPF_AS_EXTERNAL_LSA:
/* RFC2328 A.4.5, LSA header + 4 bytes followed by N>=1 12-bytes long
@@ -2772,7 +2772,7 @@ static unsigned ospf_packet_examin(struct ospf_header *oh,
bytesdeclared - OSPF_HEADER_SIZE - OSPF_LS_UPD_MIN_SIZE,
0, /* full LSAs */
ntohl(lsupd->num_lsas) /* 32 bits */
- );
+ );
break;
case OSPF_MSG_LS_ACK:
/* RFC2328 A.3.6, packet header followed by N>=0 header-only
@@ -2888,8 +2888,8 @@ int ospf_read(struct thread *thread)
ospfh = (struct ospf_header *)STREAM_PNT(ibuf);
if (MSG_OK
- != ospf_packet_examin(ospfh, stream_get_endp(ibuf)
- - stream_get_getp(ibuf)))
+ != ospf_packet_examin(
+ ospfh, stream_get_endp(ibuf) - stream_get_getp(ibuf)))
return -1;
/* Now it is safe to access all fields of OSPF packet header. */
@@ -2935,9 +2935,8 @@ int ospf_read(struct thread *thread)
* or header area is backbone but ospf_interface is not
* check for VLINK interface
*/
- if ((oi == NULL)
- || (OSPF_IS_AREA_ID_BACKBONE(ospfh->area_id)
- && !OSPF_IS_AREA_ID_BACKBONE(oi->area->area_id))) {
+ if ((oi == NULL) || (OSPF_IS_AREA_ID_BACKBONE(ospfh->area_id)
+ && !OSPF_IS_AREA_ID_BACKBONE(oi->area->area_id))) {
if ((oi = ospf_associate_packet_vl(ospf, ifp, iph, ospfh))
== NULL) {
if (!ospf->instance && IS_DEBUG_OSPF_EVENT)
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index 020dfe9d4d..9c4dca2e2f 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -229,16 +229,18 @@ static void ospf_route_delete_uniq(struct route_table *rt,
or->path_type == OSPF_PATH_INTER_AREA) {
if (or->type == OSPF_DESTINATION_NETWORK) {
if (!ospf_route_exist_new_table(
- cmprt, (struct prefix_ipv4
- *)&rn->p))
+ cmprt,
+ (struct prefix_ipv4 *)&rn
+ ->p))
ospf_zebra_delete(
(struct prefix_ipv4
*)&rn->p,
or);
} else if (or->type == OSPF_DESTINATION_DISCARD)
if (!ospf_route_exist_new_table(
- cmprt, (struct prefix_ipv4
- *)&rn->p))
+ cmprt,
+ (struct prefix_ipv4 *)&rn
+ ->p))
ospf_zebra_delete_discard(
(struct prefix_ipv4
*)&rn->p);
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index 80fdbf2158..547e1e8f53 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -332,9 +332,7 @@ static route_map_result_t route_match_tag(void *rule, struct prefix *prefix,
/* Route map commands for tag matching. */
static struct route_map_rule_cmd route_match_tag_cmd = {
- "tag",
- route_match_tag,
- route_map_rule_tag_compile,
+ "tag", route_match_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -392,9 +390,7 @@ static void route_set_metric_free(void *rule)
/* Set metric rule structure. */
struct route_map_rule_cmd route_set_metric_cmd = {
- "metric",
- route_set_metric,
- route_set_metric_compile,
+ "metric", route_set_metric, route_set_metric_compile,
route_set_metric_free,
};
@@ -446,9 +442,7 @@ static void route_set_metric_type_free(void *rule)
/* Set metric rule structure. */
struct route_map_rule_cmd route_set_metric_type_cmd = {
- "metric-type",
- route_set_metric_type,
- route_set_metric_type_compile,
+ "metric-type", route_set_metric_type, route_set_metric_type_compile,
route_set_metric_type_free,
};
@@ -471,9 +465,7 @@ static route_map_result_t route_set_tag(void *rule, struct prefix *prefix,
/* Route map commands for tag set. */
static struct route_map_rule_cmd route_set_tag_cmd = {
- "tag",
- route_set_tag,
- route_map_rule_tag_compile,
+ "tag", route_set_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index a8b7027194..6a352380b8 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -872,9 +872,7 @@ static u_char *ospfStubAreaEntry(struct variable *v, oid *name, size_t *length,
return SNMP_INTEGER(SNMP_VALID);
break;
case OSPFSTUBMETRICTYPE: /* 5 */
- /* OSPF Metric type. */
- /* $FRR indent$ */
- /* clang-format off */
+/* OSPF Metric type. */
#define OSPF_ospfMetric 1
#define OSPF_comparableCost 2
#define OSPF_nonComparable 3
@@ -2102,8 +2100,7 @@ static struct ospf_neighbor *ospf_snmp_nbr_lookup(struct ospf *ospf,
for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi)) {
for (rn = route_top(oi->nbrs); rn; rn = route_next(rn))
- if ((nbr = rn->info) != NULL
- && nbr != oi->nbr_self
+ if ((nbr = rn->info) != NULL && nbr != oi->nbr_self
/* If EXACT match is needed, provide ALL entry found
&& nbr->state != NSM_Down
*/
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index b644c94ca4..a8bfb669af 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -290,9 +290,8 @@ static void ospf_passive_interface_default(struct ospf *ospf, u_char newval)
ospf->passive_interface_default = newval;
for (ALL_LIST_ELEMENTS_RO(om->iflist, ln, ifp)) {
- if (ifp
- && OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
- passive_interface))
+ if (ifp && OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp),
+ passive_interface))
UNSET_IF_PARAM(IF_DEF_PARAMS(ifp), passive_interface);
}
for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, ln, oi)) {
@@ -395,9 +394,8 @@ DEFUN (ospf_passive_interface,
for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
struct ospf_interface *oi = rn->info;
- if (oi
- && (OSPF_IF_PARAM(oi, passive_interface)
- == OSPF_IF_PASSIVE))
+ if (oi && (OSPF_IF_PARAM(oi, passive_interface)
+ == OSPF_IF_PASSIVE))
ospf_if_set_multicast(oi);
}
/*
@@ -2127,8 +2125,7 @@ ALIAS(ospf_compatible_rfc1583, ospf_rfc1583_flag_cmd,
"Enable the RFC1583Compatibility flag\n")
ALIAS(no_ospf_compatible_rfc1583, no_ospf_rfc1583_flag_cmd,
- "no ospf rfc1583compatibility",
- NO_STR
+ "no ospf rfc1583compatibility", NO_STR
"OSPF specific commands\n"
"Disable the RFC1583Compatibility flag\n")
@@ -2582,8 +2579,7 @@ DEFUN (no_ospf_write_multiplier,
}
ALIAS(no_ospf_write_multiplier, no_write_multiplier_cmd,
- "no write-multiplier (1-100)",
- NO_STR
+ "no write-multiplier (1-100)", NO_STR
"Write multiplier\n"
"Maximum number of interface serviced per write\n")
@@ -3181,9 +3177,8 @@ static int show_ip_ospf_common(struct vty *vty, struct ospf *ospf,
if (use_json) {
json_object_object_add(json, "areas", json_areas);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -3327,10 +3322,10 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
dstr = "Broadcast";
/* For Vlinks, showing the peer address is
- * probably more
- * * * * * informative than
- * the local interface that is being used
- * * * * */
+ * probably more
+ * * * * * informative than the local
+ * interface that is being used
+ * * * * */
if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
dest = &oi->vl_data->peer_addr;
else
@@ -3611,9 +3606,8 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -3823,9 +3817,8 @@ static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf,
show_ip_ospf_neighbor_sub(vty, oi, json, use_json);
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -3944,9 +3937,8 @@ static int show_ip_ospf_neighbor_all_common(struct vty *vty, struct ospf *ospf,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -4038,9 +4030,8 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -4411,6 +4402,10 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
if (!ret) {
if (!use_json)
vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n");
+ else {
+ vty_out(vty, "{}\n");
+ json_object_free(json);
+ }
return CMD_WARNING;
}
@@ -4422,9 +4417,8 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -4512,9 +4506,8 @@ static int show_ip_ospf_neighbor_detail_common(struct vty *vty,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
@@ -4611,9 +4604,8 @@ static int show_ip_ospf_neighbor_detail_all_common(struct vty *vty,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
vty_out(vty, "\n");
@@ -4694,6 +4686,10 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
if (!ifp) {
if (!use_json)
vty_out(vty, "No such interface.\n");
+ else {
+ vty_out(vty, "{}\n");
+ json_object_free(json);
+ }
return CMD_WARNING;
}
@@ -4714,9 +4710,8 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "\n");
diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c
index e1c961491f..f68c252a35 100644
--- a/pimd/pim_assert.c
+++ b/pimd/pim_assert.c
@@ -404,9 +404,9 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp,
}
/* Metric preference */
- pim_write_uint32(pim_msg_curr, rpt_bit_flag
- ? metric_preference | 0x80000000
- : metric_preference);
+ pim_write_uint32(pim_msg_curr,
+ rpt_bit_flag ? metric_preference | 0x80000000
+ : metric_preference);
pim_msg_curr += 4;
/* Route metric */
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 07678159d0..1c9fe40c29 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -423,9 +423,8 @@ static void pim_show_membership(struct vty *vty, u_char uj)
} /* scan interface channels */
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
} else {
vty_out(vty,
"Interface Address Source Group Membership\n");
@@ -589,9 +588,8 @@ static void igmp_show_interfaces(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -786,9 +784,8 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (!found_ifname)
@@ -1168,8 +1165,9 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname,
print_header = 1;
for (ALL_LIST_ELEMENTS_RO(pim_upstream_list, upnode,
up)) {
- if (strcmp(ifp->name, up->rpf.source_nexthop
- .interface->name)
+ if (strcmp(ifp->name,
+ up->rpf.source_nexthop
+ .interface->name)
== 0) {
if (up->flags
& PIM_UPSTREAM_FLAG_MASK_FHR) {
@@ -1256,9 +1254,8 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (!found_ifname)
@@ -1317,9 +1314,8 @@ static void pim_show_interfaces(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
} else {
vty_out(vty,
"Interface State Address PIM Nbrs PIM DR FHR IfChannels\n");
@@ -1436,9 +1432,8 @@ static void pim_show_interface_traffic(struct vty *vty, u_char uj)
}
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -1523,9 +1518,8 @@ static void pim_show_interface_traffic_single(struct vty *vty,
}
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
if (!found_ifname)
@@ -1628,9 +1622,8 @@ static void pim_show_join(struct vty *vty, u_char uj)
} /* scan interface channels */
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -1833,9 +1826,8 @@ static void pim_show_neighbors_single(struct vty *vty, const char *neighbor,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
{
@@ -2039,9 +2031,8 @@ static void pim_show_state(struct vty *vty, const char *src_or_group,
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
vty_out(vty, "\n");
@@ -2124,9 +2115,8 @@ static void pim_show_neighbors(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -2356,9 +2346,8 @@ static void pim_show_upstream(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -2442,9 +2431,8 @@ static void pim_show_join_desired(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -2481,10 +2469,7 @@ static void pim_show_upstream_rpf(struct vty *vty, u_char uj)
pim_addr_dump("<rpf?>", &rpf->rpf_addr, rpf_addr_str,
sizeof(rpf_addr_str));
- rpf_ifname =
- rpf->source_nexthop.interface ? rpf->source_nexthop
- .interface->name
- : "<ifname?>";
+ rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
if (uj) {
json_object_object_get_ex(json, grp_str, &json_group);
@@ -2514,9 +2499,8 @@ static void pim_show_upstream_rpf(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -2620,10 +2604,7 @@ static void pim_show_rpf(struct vty *vty, u_char uj)
&rpf->source_nexthop.mrib_nexthop_addr,
rib_nexthop_str, sizeof(rib_nexthop_str));
- rpf_ifname =
- rpf->source_nexthop.interface ? rpf->source_nexthop
- .interface->name
- : "<ifname?>";
+ rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
if (uj) {
json_object_object_get_ex(json, grp_str, &json_group);
@@ -2661,9 +2642,8 @@ static void pim_show_rpf(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -2822,9 +2802,8 @@ static void igmp_show_groups(struct vty *vty, u_char uj)
} /* scan interfaces */
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -4060,9 +4039,8 @@ static void show_mroute(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -4655,9 +4633,8 @@ static void ip_pim_ssm_show_group_range(struct vty *vty, u_char uj)
json_object *json;
json = json_object_new_object();
json_object_string_add(json, "ssmGroups", range_str);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "SSM group range : %s\n", range_str);
@@ -4699,9 +4676,8 @@ static void ip_pim_ssm_show_group_type(struct vty *vty, u_char uj,
json_object *json;
json = json_object_new_object();
json_object_string_add(json, "groupType", type_str);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
vty_out(vty, "Group type : %s\n", type_str);
@@ -6453,8 +6429,7 @@ DEFUN (ip_pim_bfd_param,
}
ALIAS(no_ip_pim_bfd, no_ip_pim_bfd_param_cmd,
- "no ip pim bfd (2-255) (50-60000) (50-60000)",
- NO_STR IP_STR PIM_STR
+ "no ip pim bfd (2-255) (50-60000) (50-60000)", NO_STR IP_STR PIM_STR
"Enables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
@@ -6815,9 +6790,8 @@ static void ip_msdp_show_mesh_group(struct vty *vty, u_char uj)
if (uj) {
json_object_object_add(json, mg->mesh_group_name, json_mg_row);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -6884,9 +6858,8 @@ static void ip_msdp_show_peers(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -6990,9 +6963,8 @@ static void ip_msdp_show_peers_detail(struct vty *vty, const char *peer,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -7089,9 +7061,8 @@ static void ip_msdp_show_sa(struct vty *vty, u_char uj)
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -7182,9 +7153,8 @@ static void ip_msdp_show_sa_detail(struct vty *vty, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -7227,9 +7197,8 @@ static void ip_msdp_show_sa_addr(struct vty *vty, const char *addr, u_char uj)
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
@@ -7257,9 +7226,8 @@ static void ip_msdp_show_sa_sg(struct vty *vty, const char *src,
}
if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h
index 5165f78906..e742e68f67 100644
--- a/pimd/pim_iface.h
+++ b/pimd/pim_iface.h
@@ -78,9 +78,10 @@ struct pim_interface {
struct in_addr update_source; /* user can statically set the primary
* address of the interface */
- int igmp_version; /* IGMP version */
- int igmp_default_robustness_variable; /* IGMPv3 QRV */
- int igmp_default_query_interval; /* IGMPv3 secs between general
+ int igmp_version; /* IGMP version */
+ int igmp_default_robustness_variable; /* IGMPv3 QRV */
+ int
+ igmp_default_query_interval; /* IGMPv3 secs between general
queries */
int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in
dsecs for general queries */
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index cd9da1f536..d4916518e7 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -814,9 +814,8 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,
/*
* If we are going to be a LHR, we need to note it
*/
- if (ch->upstream->parent
- && (ch->upstream->parent->flags
- & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
+ if (ch->upstream->parent && (ch->upstream->parent->flags
+ & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
&& !(ch->upstream->flags
& PIM_UPSTREAM_FLAG_MASK_SRC_LHR)) {
pim_upstream_ref(ch->upstream,
diff --git a/pimd/pim_main.c b/pimd/pim_main.c
index ecaafaa587..b8e6d8ad3d 100644
--- a/pimd/pim_main.c
+++ b/pimd/pim_main.c
@@ -53,10 +53,7 @@ struct option longopts[] = {{0}};
/* pimd privileges */
zebra_capabilities_t _caps_p[] = {
- ZCAP_NET_ADMIN,
- ZCAP_SYS_ADMIN,
- ZCAP_NET_RAW,
- ZCAP_BIND,
+ ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, ZCAP_NET_RAW, ZCAP_BIND,
};
/* pimd privileges to run with */
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 648bc1d5b5..0f653e70a4 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -793,10 +793,10 @@ static void pim_msdp_peer_listen(struct pim_msdp_peer *mp)
}
/* this is interntionally asymmetric i.e. we set up listen-socket when
- * the
- * first listening peer is configured; but don't bother tearing it down
- * when
- * all the peers go down */
+ * the
+ * first listening peer is configured; but don't bother tearing it down
+ * when
+ * all the peers go down */
pim_msdp_sock_listen();
}
diff --git a/pimd/pim_msdp.h b/pimd/pim_msdp.h
index 9719941362..66e5457df4 100644
--- a/pimd/pim_msdp.h
+++ b/pimd/pim_msdp.h
@@ -69,7 +69,7 @@ enum pim_msdp_sa_flags {
PIM_MSDP_SAF_PEER = (1 << 1),
PIM_MSDP_SAF_REF = (PIM_MSDP_SAF_LOCAL | PIM_MSDP_SAF_PEER),
PIM_MSDP_SAF_STALE = (1 << 2), /* local entries can get kicked out on
- * misc pim events such as RP change */
+ * misc pim events such as RP change */
PIM_MSDP_SAF_UP_DEL_IN_PROG = (1 << 3)
};
@@ -116,13 +116,13 @@ struct pim_msdp_peer {
#define PIM_MSDP_PEER_HOLD_TIME 75
struct thread *hold_timer; // 5.4
/* $FRR indent$ */
- /* clang-format off */
+/* clang-format off */
#define PIM_MSDP_PEER_KA_TIME 60
- struct thread *ka_timer; // 5.5
- /* $FRR indent$ */
- /* clang-format off */
+ struct thread *ka_timer; // 5.5
+ /* $FRR indent$ */
+ /* clang-format off */
#define PIM_MSDP_PEER_CONNECT_RETRY_TIME 30
- struct thread *cr_timer; // 5.6
+ struct thread *cr_timer; // 5.6
/* packet thread and buffers */
uint32_t packet_size;
diff --git a/pimd/pim_register.c b/pimd/pim_register.c
index 2210a91f98..1cbe1dcf7f 100644
--- a/pimd/pim_register.c
+++ b/pimd/pim_register.c
@@ -330,9 +330,8 @@ int pim_register_recv(struct interface *ifp, struct in_addr dest_addr,
pim_str_sg_dump(&sg), src_str, ifp->name, i_am_rp);
}
- if (i_am_rp
- && (dest_addr.s_addr
- == ((RP(sg.grp))->rpf_addr.u.prefix4.s_addr))) {
+ if (i_am_rp && (dest_addr.s_addr
+ == ((RP(sg.grp))->rpf_addr.u.prefix4.s_addr))) {
sentRegisterStop = 0;
if (*bits & PIM_REGISTER_BORDER_BIT) {
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 4c5722e353..2fe0143a87 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -948,9 +948,8 @@ void pim_rp_show_information(struct vty *vty, u_char uj)
inet_ntoa(prev_rp_info->rp.rpf_addr.u.prefix4),
json_rp_rows);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
}
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 5258377cca..027b18e123 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -435,8 +435,9 @@ int zclient_lookup_nexthop(struct pim_zlookup_nexthop nexthop_tab[],
nexthop_tab[0].route_metric);
}
- addr = nexthop_addr.u.prefix4; /* use nexthop addr for
- recursive lookup */
+ addr =
+ nexthop_addr.u.prefix4; /* use nexthop addr for
+ recursive lookup */
} /* for (max_lookup) */
diff --git a/qpb/qpb_allocator.h b/qpb/qpb_allocator.h
index fd55592f88..c9022af713 100644
--- a/qpb/qpb_allocator.h
+++ b/qpb/qpb_allocator.h
@@ -74,6 +74,7 @@ static inline void qpb_free(qpb_allocator_t *allocator, void *ptr)
*/
#define QPB_ALLOC(allocator, type) (type *)qpb_alloc(allocator, sizeof(type))
+
/*
* Externs.
*/
diff --git a/redhat/frr.init b/redhat/frr.init
index cf01e4c6e3..a62647b258 100755
--- a/redhat/frr.init
+++ b/redhat/frr.init
@@ -515,6 +515,18 @@ case "$1" in
if [ -z "$dmn" -o "$dmn" = "zebra" ]; then
echo "Removing all routes made by zebra."
ip route flush proto zebra
+ # At least in CentOS/RHEL 6, iproute2 doesn't know
+ # about the new protocol names, so we have to flush them
+ # by number (it also doesn't support rt_protos.d
+ ip route flush proto 186
+ ip route flush proto 187
+ ip route flush proto 188
+ ip route flush proto 189
+ ip route flush proto 190
+ ip route flush proto 191
+ ip route flush proto 192
+ ip route flush proto 193
+ ip route flush proto 194
else
[ -n "$dmn" ] && eval "${dmn/-/_}=0"
start_watchfrr
diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c
index b2c80817dd..492d036991 100644
--- a/ripd/rip_debug.c
+++ b/ripd/rip_debug.c
@@ -66,7 +66,7 @@ DEFUN (debug_rip_events,
"RIP events\n")
{
rip_debug_event = RIP_DEBUG_EVENT;
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_SUCCESS;
}
DEFUN (debug_rip_packet,
@@ -112,7 +112,7 @@ DEFUN (debug_rip_zebra,
"RIP and ZEBRA communication\n")
{
rip_debug_zebra = RIP_DEBUG_ZEBRA;
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_SUCCESS;
}
DEFUN (no_debug_rip_events,
@@ -177,7 +177,7 @@ DEFUN (no_debug_rip_zebra,
"RIP and ZEBRA communication\n")
{
rip_debug_zebra = 0;
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_SUCCESS;
}
/* Debug node. */
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 3dc54a6617..a170471123 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -1855,9 +1855,7 @@ int config_write_rip_network(struct vty *vty, int config_mode)
}
static struct cmd_node interface_node = {
- INTERFACE_NODE,
- "%s(config-if)# ",
- 1,
+ INTERFACE_NODE, "%s(config-if)# ", 1,
};
/* Called when interface structure allocated. */
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index 546efb2dad..7255df5e67 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -347,9 +347,7 @@ static route_map_result_t route_match_tag(void *rule, struct prefix *prefix,
/* Route map commands for tag matching. */
static struct route_map_rule_cmd route_match_tag_cmd = {
- "tag",
- route_match_tag,
- route_map_rule_tag_compile,
+ "tag", route_match_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -438,9 +436,7 @@ static void route_set_metric_free(void *rule)
/* Set metric rule structure. */
static struct route_map_rule_cmd route_set_metric_cmd = {
- "metric",
- route_set_metric,
- route_set_metric_compile,
+ "metric", route_set_metric, route_set_metric_compile,
route_set_metric_free,
};
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index 79d4324ea1..961a846db2 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -661,8 +661,7 @@ int config_write_rip_redistribute(struct vty *vty, int config_mode)
/* Zebra node structure. */
static struct cmd_node zebra_node = {
- ZEBRA_NODE,
- "%s(config-router)# ",
+ ZEBRA_NODE, "%s(config-router)# ",
};
static void rip_zebra_connected(struct zclient *zclient)
diff --git a/ripd/ripd.c b/ripd/ripd.c
index eb6c8f743a..d9b38bba89 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -454,8 +454,9 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* Get back the object */
rte->nexthop = newinfo.nexthop_out;
rte->tag = htons(newinfo.tag_out); /* XXX */
- rte->metric = newinfo.metric_out; /* XXX: the routemap uses the
- metric_out field */
+ rte->metric =
+ newinfo.metric_out; /* XXX: the routemap uses the
+ metric_out field */
}
/* Once the entry has been validated, update the metric by
diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c
index 5d7a2cf9ff..d56161d39e 100644
--- a/ripngd/ripng_debug.c
+++ b/ripngd/ripng_debug.c
@@ -67,7 +67,7 @@ DEFUN (debug_ripng_events,
"Debug option set for ripng events\n")
{
ripng_debug_event = RIPNG_DEBUG_EVENT;
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_SUCCESS;
}
DEFUN (debug_ripng_packet,
@@ -114,7 +114,7 @@ DEFUN (debug_ripng_zebra,
"Debug option set for ripng and zebra communication\n")
{
ripng_debug_zebra = RIPNG_DEBUG_ZEBRA;
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_SUCCESS;
}
DEFUN (no_debug_ripng_events,
@@ -179,7 +179,7 @@ DEFUN (no_debug_ripng_zebra,
"Debug option set for ripng and zebra communication\n")
{
ripng_debug_zebra = 0;
- return CMD_WARNING_CONFIG_FAILED;
+ return CMD_SUCCESS;
}
/* Debug node. */
diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c
index 0696d61ac0..3080801fb3 100644
--- a/ripngd/ripng_routemap.c
+++ b/ripngd/ripng_routemap.c
@@ -150,9 +150,7 @@ static route_map_result_t route_match_tag(void *rule, struct prefix *prefix,
}
static struct route_map_rule_cmd route_match_tag_cmd = {
- "tag",
- route_match_tag,
- route_map_rule_tag_compile,
+ "tag", route_match_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -242,9 +240,7 @@ static void route_set_metric_free(void *rule)
}
static struct route_map_rule_cmd route_set_metric_cmd = {
- "metric",
- route_set_metric,
- route_set_metric_compile,
+ "metric", route_set_metric, route_set_metric_compile,
route_set_metric_free,
};
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index 709a285ab5..386bee43b8 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -507,8 +507,7 @@ static int zebra_config_write(struct vty *vty)
/* Zebra node structure. */
static struct cmd_node zebra_node = {
- ZEBRA_NODE,
- "%s(config-router)# ",
+ ZEBRA_NODE, "%s(config-router)# ",
};
static void ripng_zebra_connected(struct zclient *zclient)
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 874c42e7e8..2883698f47 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -742,8 +742,9 @@ static void ripng_route_process(struct rte *rte, struct sockaddr_in6 *from,
}
}
rte->tag = htons(newinfo.tag_out); /* XXX */
- rte->metric = newinfo.metric_out; /* XXX: the routemap uses the
- metric_out field */
+ rte->metric =
+ newinfo.metric_out; /* XXX: the routemap uses the
+ metric_out field */
}
/* Once the entry has been validated, update the metric by
@@ -2717,9 +2718,7 @@ static int ripng_config_write(struct vty *vty)
/* RIPng node structure. */
static struct cmd_node cmd_ripng_node = {
- RIPNG_NODE,
- "%s(config-router)# ",
- 1,
+ RIPNG_NODE, "%s(config-router)# ", 1,
};
static void ripng_distribute_update(struct distribute *dist)
diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c
index 706825681b..46462d79c4 100644
--- a/tests/bgpd/test_aspath.c
+++ b/tests/bgpd/test_aspath.c
@@ -50,10 +50,8 @@ struct test_spec {
deleted */
const unsigned int hops; /* aspath_count_hops result */
const unsigned int confeds; /* aspath_count_confeds */
- const int private_as; /* whether the private_as check should pass or
- fail */
- /* $FRR indent$ */
- /* clang-format off */
+ const int private_as; /* whether the private_as check should pass or
+ fail */
#define NOT_ALL_PRIVATE 0
#define ALL_PRIVATE 1
const as_t does_loop; /* an ASN which should trigger loop-check */
@@ -87,14 +85,7 @@ static struct test_segment {
{0x2, 0x1, 0x22, 0x12, 0x2, 0x1, 0x00, 0x04},
8,
{
- "8722 4",
- "8722 4",
- 2,
- 0,
- NOT_ALL_PRIVATE,
- 4,
- 5,
- 8722,
+ "8722 4", "8722 4", 2, 0, NOT_ALL_PRIVATE, 4, 5, 8722,
},
},
{
@@ -407,22 +398,8 @@ static struct test_segment {
"reconcile_start_trans",
"seq(23456,23456,23456) seq(6435,59408,21665)",
{
- 0x2,
- 0x3,
- 0x5b,
- 0xa0,
- 0x5b,
- 0xa0,
- 0x5b,
- 0xa0,
- 0x2,
- 0x3,
- 0x19,
- 0x23,
- 0xe8,
- 0x10,
- 0x54,
- 0xa1,
+ 0x2, 0x3, 0x5b, 0xa0, 0x5b, 0xa0, 0x5b, 0xa0, 0x2, 0x3,
+ 0x19, 0x23, 0xe8, 0x10, 0x54, 0xa1,
},
16,
{"23456 23456 23456 6435 59408 21665",
@@ -434,22 +411,8 @@ static struct test_segment {
"reconcile_start_trans4",
"seq(1842,41591,51793) seq(6435,59408,21665)",
{
- 0x2,
- 0x3,
- 0x07,
- 0x32,
- 0xa2,
- 0x77,
- 0xca,
- 0x51,
- 0x2,
- 0x3,
- 0x19,
- 0x23,
- 0xe8,
- 0x10,
- 0x54,
- 0xa1,
+ 0x2, 0x3, 0x07, 0x32, 0xa2, 0x77, 0xca, 0x51, 0x2, 0x3,
+ 0x19, 0x23, 0xe8, 0x10, 0x54, 0xa1,
},
16,
{"1842 41591 51793 6435 59408 21665",
@@ -461,20 +424,8 @@ static struct test_segment {
"reconcile_start_trans_error",
"seq(23456,23456,23456) seq(6435,59408)",
{
- 0x2,
- 0x3,
- 0x5b,
- 0xa0,
- 0x5b,
- 0xa0,
- 0x5b,
- 0xa0,
- 0x2,
- 0x2,
- 0x19,
- 0x23,
- 0xe8,
- 0x10,
+ 0x2, 0x3, 0x5b, 0xa0, 0x5b, 0xa0, 0x5b, 0xa0, 0x2, 0x2,
+ 0x19, 0x23, 0xe8, 0x10,
},
14,
{"23456 23456 23456 6435 59408", "23456 23456 23456 6435 59408",
@@ -552,10 +503,7 @@ static struct aspath_tests {
0,
0,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 10,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 10,
},
COMMON_ATTR_SIZE + 3,
},
@@ -568,10 +516,7 @@ static struct aspath_tests {
-1,
0,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 8,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 8,
},
COMMON_ATTR_SIZE + 3,
},
@@ -584,10 +529,7 @@ static struct aspath_tests {
-1,
0,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 12,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 12,
},
COMMON_ATTR_SIZE + 3,
},
@@ -602,8 +544,7 @@ static struct aspath_tests {
{
COMMON_ATTRS,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- BGP_ATTR_AS_PATH,
- 10,
+ BGP_ATTR_AS_PATH, 10,
},
COMMON_ATTR_SIZE + 3,
},
@@ -618,8 +559,7 @@ static struct aspath_tests {
{
COMMON_ATTRS,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- BGP_ATTR_AS4_PATH,
- 10,
+ BGP_ATTR_AS4_PATH, 10,
},
COMMON_ATTR_SIZE + 3,
},
@@ -634,8 +574,7 @@ static struct aspath_tests {
{
COMMON_ATTRS,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- BGP_ATTR_AS4_PATH,
- 10,
+ BGP_ATTR_AS4_PATH, 10,
},
COMMON_ATTR_SIZE + 3,
},
@@ -648,10 +587,7 @@ static struct aspath_tests {
0,
PEER_CAP_AS4_RCV | PEER_CAP_AS4_ADV,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 18,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 18,
},
COMMON_ATTR_SIZE + 3,
},
@@ -664,10 +600,7 @@ static struct aspath_tests {
-1,
PEER_CAP_AS4_RCV | PEER_CAP_AS4_ADV,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 16,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 16,
},
COMMON_ATTR_SIZE + 3,
},
@@ -680,10 +613,7 @@ static struct aspath_tests {
-1,
PEER_CAP_AS4_RCV | PEER_CAP_AS4_ADV,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 20,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 20,
},
COMMON_ATTR_SIZE + 3,
},
@@ -696,10 +626,7 @@ static struct aspath_tests {
-1,
PEER_CAP_AS4_RCV | PEER_CAP_AS4_ADV,
{
- COMMON_ATTRS,
- BGP_ATTR_FLAG_TRANS,
- BGP_ATTR_AS_PATH,
- 22,
+ COMMON_ATTRS, BGP_ATTR_FLAG_TRANS, BGP_ATTR_AS_PATH, 22,
},
COMMON_ATTR_SIZE + 3,
},
@@ -714,8 +641,7 @@ static struct aspath_tests {
{
COMMON_ATTRS,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- BGP_ATTR_AS_PATH,
- 18,
+ BGP_ATTR_AS_PATH, 18,
},
COMMON_ATTR_SIZE + 3,
},
@@ -730,8 +656,7 @@ static struct aspath_tests {
{
COMMON_ATTRS,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- BGP_ATTR_AS4_PATH,
- 14,
+ BGP_ATTR_AS4_PATH, 14,
},
COMMON_ATTR_SIZE + 3,
},
@@ -746,8 +671,7 @@ static struct aspath_tests {
{
COMMON_ATTRS,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
- BGP_ATTR_AS4_PATH,
- 14,
+ BGP_ATTR_AS4_PATH, 14,
},
COMMON_ATTR_SIZE + 3,
&test_segments[0],
@@ -880,13 +804,7 @@ static struct tests {
{NULL,
NULL,
{
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
+ NULL, 0, 0, 0, 0, 0, 0,
}},
};
@@ -934,13 +852,7 @@ struct tests reconcile_tests[] = {
{NULL,
NULL,
{
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
+ NULL, 0, 0, 0, 0, 0, 0,
}},
};
diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c
index 2b515b0f78..9ec2b5df19 100644
--- a/tests/bgpd/test_capability.c
+++ b/tests/bgpd/test_capability.c
@@ -216,387 +216,439 @@ static struct test_segment mp_segments[] = {
},
{NULL, NULL, {0}, 0, 0}};
-static struct test_segment misc_segments[] = {
- /* 13 */
+static struct test_segment misc_segments[] =
{
- "ORF",
- "ORF, simple, single entry, single tuple",
- {/* hdr */ CAPABILITY_CODE_ORF, 0x7,
- /* mpc */ 0x0, 0x1, 0x0, 0x1,
- /* num */ 0x1,
- /* tuples */ 0x40, 0x3},
- 9,
- SHOULD_PARSE,
- },
- /* 14 */
- {
- "ORF-many",
- "ORF, multi entry/tuple",
+ /* 13 */
{
- /* hdr */ CAPABILITY_CODE_ORF,
- 0x21,
- /* mpc */ 0x0,
- 0x1,
- 0x0,
- 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40,
- ORF_MODE_BOTH,
- 0x80,
- ORF_MODE_RECEIVE,
- 0x80,
- ORF_MODE_SEND,
- /* mpc */ 0x0,
- 0x2,
- 0x0,
- 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40,
- ORF_MODE_BOTH,
- 0x80,
- ORF_MODE_RECEIVE,
- 0x80,
- ORF_MODE_SEND,
- /* mpc */ 0x0,
- 0x2,
- 0x0,
- 0x2,
- /* num */ 0x3,
- /* tuples */ 0x40,
- ORF_MODE_RECEIVE,
- 0x80,
- ORF_MODE_SEND,
- 0x80,
- ORF_MODE_BOTH,
+ "ORF",
+ "ORF, simple, single entry, single tuple",
+ {/* hdr */ CAPABILITY_CODE_ORF, 0x7,
+ /* mpc */ 0x0, 0x1, 0x0, 0x1,
+ /* num */ 0x1,
+ /* tuples */ 0x40, 0x3},
+ 9,
+ SHOULD_PARSE,
},
- 35,
- SHOULD_PARSE,
- },
- /* 15 */
- {
- "ORFlo",
- "ORF, multi entry/tuple, hdr length too short",
+ /* 14 */
{
- /* hdr */ CAPABILITY_CODE_ORF,
- 0x15,
- /* mpc */ 0x0,
- 0x1,
- 0x0,
- 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40,
- 0x3,
- 0x80,
- 0x1,
- 0x80,
- 0x2,
- /* mpc */ 0x0,
- 0x1,
- 0x0,
- 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40,
- 0x3,
- 0x80,
- 0x1,
- 0x80,
- 0x2,
- /* mpc */ 0x0,
- 0x2,
- 0x0,
- 0x2,
- /* num */ 0x3,
- /* tuples */ 0x40,
- 0x3,
- 0x80,
- 0x1,
- 0x80,
- 0x2,
+ "ORF-many",
+ "ORF, multi entry/tuple",
+ {
+ /* hdr */ CAPABILITY_CODE_ORF,
+ 0x21,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ ORF_MODE_BOTH,
+ 0x80,
+ ORF_MODE_RECEIVE,
+ 0x80,
+ ORF_MODE_SEND,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ ORF_MODE_BOTH,
+ 0x80,
+ ORF_MODE_RECEIVE,
+ 0x80,
+ ORF_MODE_SEND,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x2,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ ORF_MODE_RECEIVE,
+ 0x80,
+ ORF_MODE_SEND,
+ 0x80,
+ ORF_MODE_BOTH,
+ },
+ 35,
+ SHOULD_PARSE,
},
- 35,
- SHOULD_ERR, /* It should error on invalid
- Route-Refresh.. */
- },
- /* 16 */
- {"ORFlu",
- "ORF, multi entry/tuple, length too long",
- {
- /* hdr */ 0x3, 0x22,
- /* mpc */ 0x0, 0x1, 0x0, 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- /* mpc */ 0x0, 0x2, 0x0, 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- /* mpc */ 0x0, 0x2, 0x0, 0x2,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- },
- 35,
- SHOULD_ERR},
- /* 17 */
- {
- "ORFnu",
- "ORF, multi entry/tuple, entry number too long",
+ /* 15 */
{
- /* hdr */ 0x3, 0x21,
- /* mpc */ 0x0, 0x1, 0x0, 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- /* mpc */ 0x0, 0x2, 0x0, 0x1,
- /* num */ 0x4,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- /* mpc */ 0x0, 0x2, 0x0, 0x2,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
+ "ORFlo",
+ "ORF, multi entry/tuple, hdr length too short",
+ {
+ /* hdr */ CAPABILITY_CODE_ORF,
+ 0x15,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x2,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ },
+ 35,
+ SHOULD_ERR, /* It should error on invalid
+ Route-Refresh.. */
},
- 35,
- SHOULD_PARSE, /* parses, but last few tuples should be
- gibberish */
- },
- /* 18 */
- {
- "ORFno",
- "ORF, multi entry/tuple, entry number too short",
+ /* 16 */
+ {"ORFlu",
+ "ORF, multi entry/tuple, length too long",
+ {
+ /* hdr */ 0x3,
+ 0x22,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x2,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ },
+ 35,
+ SHOULD_ERR},
+ /* 17 */
{
- /* hdr */ 0x3, 0x21,
- /* mpc */ 0x0, 0x1, 0x0, 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- /* mpc */ 0x0, 0x2, 0x0, 0x1,
- /* num */ 0x1,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
- /* mpc */ 0x0, 0x2, 0x0, 0x2,
- /* num */ 0x3,
- /* tuples */ 0x40, 0x3, 0x80, 0x1, 0x80, 0x2,
+ "ORFnu",
+ "ORF, multi entry/tuple, entry number too long",
+ {
+ /* hdr */ 0x3,
+ 0x21,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x1,
+ /* num */ 0x4,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x2,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ },
+ 35,
+ SHOULD_PARSE, /* parses, but last few tuples should be
+ gibberish */
},
- 35,
- SHOULD_PARSE, /* Parses, but should get gibberish
- afi/safis */
- },
- /* 17 */
- {
- "ORFpad",
- "ORF, multi entry/tuple, padded to align",
+ /* 18 */
{
- /* hdr */ 0x3,
- 0x22,
- /* mpc */ 0x0,
- 0x1,
- 0x0,
- 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40,
- 0x3,
- 0x80,
- 0x1,
- 0x80,
- 0x2,
- /* mpc */ 0x0,
- 0x2,
- 0x0,
- 0x1,
- /* num */ 0x3,
- /* tuples */ 0x40,
- 0x3,
- 0x80,
- 0x1,
- 0x80,
- 0x2,
- /* mpc */ 0x0,
- 0x2,
- 0x0,
- 0x2,
- /* num */ 0x3,
- /* tuples */ 0x40,
- 0x3,
- 0x80,
- 0x1,
- 0x80,
- 0x2,
- 0x00,
+ "ORFno",
+ "ORF, multi entry/tuple, entry number too short",
+ {
+ /* hdr */ 0x3,
+ 0x21,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x1,
+ /* num */ 0x1,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x2,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ },
+ 35,
+ SHOULD_PARSE, /* Parses, but should get gibberish
+ afi/safis */
},
- 36,
- SHOULD_PARSE,
- },
- /* 19 */
- {
- "AS4",
- "AS4 capability",
- {0x41, 0x4, 0xab, 0xcd, 0xef, 0x12}, /* AS: 2882400018 */
- 6,
- SHOULD_PARSE,
- 2882400018,
- },
- {
- "AS4",
- "AS4 capability: short",
- {0x41, 0x4, 0xab, 0xcd, 0xef}, /* AS: 2882400018 */
- 5,
- SHOULD_ERR,
- },
- {
- "AS4",
- "AS4 capability: long",
- {0x41, 0x4, 0xab, 0xcd, 0xef, 0x12, 0x12},
- 7,
- SHOULD_ERR,
- 2882400018,
- },
- {
- "GR",
- "GR capability",
+ /* 17 */
{
- /* hdr */ CAPABILITY_CODE_RESTART,
- 0xe,
- /* R-bit, time */ 0xf1,
- 0x12,
- /* afi */ 0x0,
- 0x1,
- /* safi */ 0x1,
- /* flags */ 0xf,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x1,
- /* flags */ 0x0,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x2,
- /* flags */ 0x1,
+ "ORFpad",
+ "ORF, multi entry/tuple, padded to align",
+ {
+ /* hdr */ 0x3,
+ 0x22,
+ /* mpc */ 0x0,
+ 0x1,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x1,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ /* mpc */ 0x0,
+ 0x2,
+ 0x0,
+ 0x2,
+ /* num */ 0x3,
+ /* tuples */ 0x40,
+ 0x3,
+ 0x80,
+ 0x1,
+ 0x80,
+ 0x2,
+ 0x00,
+ },
+ 36,
+ SHOULD_PARSE,
},
- 16,
- SHOULD_PARSE,
- },
- {
- "GR-short",
- "GR capability, but header length too short",
+ /* 19 */
{
- /* hdr */ 0x40,
- 0xa,
- /* R-bit, time */ 0xf1,
- 0x12,
- /* afi */ 0x0,
- 0x1,
- /* safi */ 0x1,
- /* flags */ 0xf,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x1,
- /* flags */ 0x0,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x2,
- /* flags */ 0x1,
+ "AS4",
+ "AS4 capability",
+ {0x41, 0x4, 0xab, 0xcd, 0xef,
+ 0x12}, /* AS: 2882400018 */
+ 6,
+ SHOULD_PARSE,
+ 2882400018,
},
- 15 /* array is 16 though */,
- SHOULD_ERR,
- },
- {
- "GR-long",
- "GR capability, but header length too long",
{
- /* hdr */ 0x40,
- 0xf,
- /* R-bit, time */ 0xf1,
- 0x12,
- /* afi */ 0x0,
- 0x1,
- /* safi */ 0x1,
- /* flags */ 0xf,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x1,
- /* flags */ 0x0,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x2,
- /* flags */ 0x01,
+ "AS4",
+ "AS4 capability: short",
+ {0x41, 0x4, 0xab, 0xcd, 0xef}, /* AS: 2882400018 */
+ 5,
+ SHOULD_ERR,
},
- 16,
- SHOULD_ERR,
- },
- {
- "GR-trunc",
- "GR capability, but truncated",
{
- /* hdr */ 0x40,
- 0xf,
- /* R-bit, time */ 0xf1,
- 0x12,
- /* afi */ 0x0,
- 0x1,
- /* safi */ 0x1,
- /* flags */ 0xf,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x1,
- /* flags */ 0x0,
- /* afi */ 0x0,
- 0x2,
- /* safi */ 0x2,
- /* flags */ 0x1,
+ "AS4",
+ "AS4 capability: long",
+ {0x41, 0x4, 0xab, 0xcd, 0xef, 0x12, 0x12},
+ 7,
+ SHOULD_ERR,
+ 2882400018,
},
- 15,
- SHOULD_ERR,
- },
- {
- "GR-empty",
- "GR capability, but empty.",
{
- /* hdr */ 0x40,
- 0x0,
+ "GR",
+ "GR capability",
+ {
+ /* hdr */ CAPABILITY_CODE_RESTART, 0xe,
+ /* R-bit, time */ 0xf1, 0x12,
+ /* afi */ 0x0, 0x1,
+ /* safi */ 0x1,
+ /* flags */ 0xf,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x1,
+ /* flags */ 0x0,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x2,
+ /* flags */ 0x1,
+ },
+ 16,
+ SHOULD_PARSE,
},
- 2,
- SHOULD_ERR,
- },
- {
- "MP-empty",
- "MP capability, but empty.",
{
- /* hdr */ 0x1,
- 0x0,
+ "GR-short",
+ "GR capability, but header length too short",
+ {
+ /* hdr */ 0x40, 0xa,
+ /* R-bit, time */ 0xf1, 0x12,
+ /* afi */ 0x0, 0x1,
+ /* safi */ 0x1,
+ /* flags */ 0xf,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x1,
+ /* flags */ 0x0,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x2,
+ /* flags */ 0x1,
+ },
+ 15 /* array is 16 though */,
+ SHOULD_ERR,
},
- 2,
- SHOULD_ERR,
- },
- {
- "ORF-empty",
- "ORF capability, but empty.",
{
- /* hdr */ 0x3,
- 0x0,
+ "GR-long",
+ "GR capability, but header length too long",
+ {
+ /* hdr */ 0x40, 0xf,
+ /* R-bit, time */ 0xf1, 0x12,
+ /* afi */ 0x0, 0x1,
+ /* safi */ 0x1,
+ /* flags */ 0xf,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x1,
+ /* flags */ 0x0,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x2,
+ /* flags */ 0x01,
+ },
+ 16,
+ SHOULD_ERR,
},
- 2,
- SHOULD_ERR,
- },
- {
- "AS4-empty",
- "AS4 capability, but empty.",
{
- /* hdr */ 0x41,
- 0x0,
+ "GR-trunc",
+ "GR capability, but truncated",
+ {
+ /* hdr */ 0x40, 0xf,
+ /* R-bit, time */ 0xf1, 0x12,
+ /* afi */ 0x0, 0x1,
+ /* safi */ 0x1,
+ /* flags */ 0xf,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x1,
+ /* flags */ 0x0,
+ /* afi */ 0x0, 0x2,
+ /* safi */ 0x2,
+ /* flags */ 0x1,
+ },
+ 15,
+ SHOULD_ERR,
},
- 2,
- SHOULD_ERR,
- },
- {
- "dyn-empty",
- "Dynamic capability, but empty.",
{
- /* hdr */ 0x42,
- 0x0,
+ "GR-empty",
+ "GR capability, but empty.",
+ {
+ /* hdr */ 0x40, 0x0,
+ },
+ 2,
+ SHOULD_ERR,
},
- 2,
- SHOULD_PARSE,
- },
- {
- "dyn-old",
- "Dynamic capability (deprecated version)",
- {CAPABILITY_CODE_DYNAMIC, 0x0},
- 2,
- SHOULD_PARSE,
- },
- {NULL, NULL, {0}, 0, 0}};
+ {
+ "MP-empty",
+ "MP capability, but empty.",
+ {
+ /* hdr */ 0x1, 0x0,
+ },
+ 2,
+ SHOULD_ERR,
+ },
+ {
+ "ORF-empty",
+ "ORF capability, but empty.",
+ {
+ /* hdr */ 0x3, 0x0,
+ },
+ 2,
+ SHOULD_ERR,
+ },
+ {
+ "AS4-empty",
+ "AS4 capability, but empty.",
+ {
+ /* hdr */ 0x41, 0x0,
+ },
+ 2,
+ SHOULD_ERR,
+ },
+ {
+ "dyn-empty",
+ "Dynamic capability, but empty.",
+ {
+ /* hdr */ 0x42, 0x0,
+ },
+ 2,
+ SHOULD_PARSE,
+ },
+ {
+ "dyn-old",
+ "Dynamic capability (deprecated version)",
+ {CAPABILITY_CODE_DYNAMIC, 0x0},
+ 2,
+ SHOULD_PARSE,
+ },
+ {NULL, NULL, {0}, 0, 0}};
/* DYNAMIC message */
struct test_segment dynamic_cap_msgs[] = {
@@ -819,9 +871,9 @@ static void parse_test(struct peer *peer, struct test_segment *t, int type)
failed++;
if (tty)
- printf("%s", (failed > oldfailed)
- ? VT100_RED "failed!" VT100_RESET
- : VT100_GREEN "OK" VT100_RESET);
+ printf("%s",
+ (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET
+ : VT100_GREEN "OK" VT100_RESET);
else
printf("%s", (failed > oldfailed) ? "failed!" : "OK");
diff --git a/tests/bgpd/test_mp_attr.c b/tests/bgpd/test_mp_attr.c
index 2dbde0dbdd..7c0afa1b92 100644
--- a/tests/bgpd/test_mp_attr.c
+++ b/tests/bgpd/test_mp_attr.c
@@ -610,15 +610,15 @@ static struct test_segment {
/* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_AS */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 17, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_AS */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 17, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
},
(4 + 12 + 1 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3)),
SHOULD_PARSE,
@@ -700,15 +700,15 @@ static struct test_segment {
/* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 88 + 32, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_AS */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 17, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_AS */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 17, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
},
(4 + 12 + 1 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3)),
SHOULD_ERR,
@@ -727,16 +727,16 @@ static struct test_segment {
/* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_AS */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 17, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
- 88 + 1, /* bogus */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_AS */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 17, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
+ 88 + 1, /* bogus */
},
(4 + 12 + 1 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3) + 1),
SHOULD_ERR,
@@ -755,15 +755,15 @@ static struct test_segment {
/* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_AS */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 2, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_AS */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 2, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
},
(4 + 12 + 1 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3)),
SHOULD_ERR,
@@ -782,15 +782,15 @@ static struct test_segment {
/* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0xff, 0, /* Bogus RD */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 17, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
+ /* rd, 8 octets */
+ 0xff, 0, /* Bogus RD */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 17, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
},
(4 + 12 + 1 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3)),
SHOULD_PARSE,
@@ -809,16 +809,16 @@ static struct test_segment {
/* Nexthop */ 192, 168, 0, 1,
/* SNPA (defunct, MBZ) */ 0x0,
/* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_AS */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 17, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
- 0 /* 0/0, bogus for vpnv4 ?? */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_AS */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 17, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
+ 0 /* 0/0, bogus for vpnv4 ?? */
},
(4 + 12 + 1 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3) + 1),
SHOULD_ERR,
@@ -901,23 +901,11 @@ static struct test_segment mp_unreach_segments[] = {
"IPv6-unreach2",
"IPV6 MP Unreach, 2 NLRIs",
{
- /* AFI / SAFI */ 0x0,
- AFI_IP6,
- SAFI_UNICAST,
- /* NLRI tuples */ 32,
- 0xff,
- 0xfe,
- 0x1,
- 0x2, /* fffe:102::/32 */
- 64,
- 0xff,
- 0xfe,
- 0x0,
- 0x1, /* fffe:1:2:3::/64 */
- 0x0,
- 0x2,
- 0x0,
- 0x3,
+ /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST,
+ /* NLRI tuples */ 32, 0xff, 0xfe, 0x1,
+ 0x2, /* fffe:102::/32 */
+ 64, 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */
+ 0x0, 0x2, 0x0, 0x3,
},
(3 + 5 + 9),
SHOULD_PARSE,
@@ -992,15 +980,15 @@ static struct test_segment mp_unreach_segments[] = {
{
/* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN,
/* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_AS */
- 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
- 10, 1, /* 10.1/16 */
- 88 + 17, 0xff, 0, 0, /* tag */
- /* rd, 8 octets */
- 0, 0, /* RD_TYPE_IP */
- 192, 168, 0, 1, /* IPv4 */
- 10, 2, 3, /* 10.2.3/17 */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_AS */
+ 0, 2, 0, 0xff, 3, 4, /* AS(2):val(4) */
+ 10, 1, /* 10.1/16 */
+ 88 + 17, 0xff, 0, 0, /* tag */
+ /* rd, 8 octets */
+ 0, 0, /* RD_TYPE_IP */
+ 192, 168, 0, 1, /* IPv4 */
+ 10, 2, 3, /* 10.2.3/17 */
},
(3 + (1 + 3 + 8 + 2) + (1 + 3 + 8 + 3)),
SHOULD_PARSE,
@@ -1029,9 +1017,9 @@ static void handle_result(struct peer *peer, struct test_segment *t,
if (tty)
- printf("%s", (failed > oldfailed)
- ? VT100_RED "failed!" VT100_RESET
- : VT100_GREEN "OK" VT100_RESET);
+ printf("%s",
+ (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET
+ : VT100_GREEN "OK" VT100_RESET);
else
printf("%s", (failed > oldfailed) ? "failed!" : "OK");
diff --git a/tests/bgpd/test_mpath.c b/tests/bgpd/test_mpath.c
index 72fe2d821c..ccd3b6f4c2 100644
--- a/tests/bgpd/test_mpath.c
+++ b/tests/bgpd/test_mpath.c
@@ -361,8 +361,7 @@ testcase_t test_bgp_info_mpath_update = {
* Set up testcase vector
*/
testcase_t *all_tests[] = {
- &test_bgp_cfg_maximum_paths,
- &test_bgp_mp_list,
+ &test_bgp_cfg_maximum_paths, &test_bgp_mp_list,
&test_bgp_info_mpath_update,
};
diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c
index e149487c5d..48dd99d28a 100644
--- a/tests/lib/cli/test_commands.c
+++ b/tests/lib/cli/test_commands.c
@@ -49,23 +49,19 @@ static vector test_cmds;
static char test_buf[32768];
static struct cmd_node bgp_node = {
- BGP_NODE,
- "%s(config-router)# ",
+ BGP_NODE, "%s(config-router)# ",
};
static struct cmd_node rip_node = {
- RIP_NODE,
- "%s(config-router)# ",
+ RIP_NODE, "%s(config-router)# ",
};
static struct cmd_node isis_node = {
- ISIS_NODE,
- "%s(config-router)# ",
+ ISIS_NODE, "%s(config-router)# ",
};
static struct cmd_node interface_node = {
- INTERFACE_NODE,
- "%s(config-if)# ",
+ INTERFACE_NODE, "%s(config-if)# ",
};
static struct cmd_node rmap_node = {RMAP_NODE, "%s(config-route-map)# "};
diff --git a/tests/lib/test_checksum.c b/tests/lib/test_checksum.c
index 87ea3039ec..c265e164eb 100644
--- a/tests/lib/test_checksum.c
+++ b/tests/lib/test_checksum.c
@@ -401,7 +401,7 @@ static int verify(u_char *buffer, testsz_t len)
}
static int /* return checksum in low-order 16 bits */
-in_cksum_optimized(void *parg, int nbytes)
+ in_cksum_optimized(void *parg, int nbytes)
{
u_short *ptr = parg;
register long sum; /* assumes long == 32 bits */
@@ -433,7 +433,7 @@ in_cksum_optimized(void *parg, int nbytes)
static int /* return checksum in low-order 16 bits */
-in_cksum_rfc(void *parg, int count)
+ in_cksum_rfc(void *parg, int count)
/* from RFC 1071 */
{
u_short *addr = parg;
diff --git a/tests/lib/test_privs.c b/tests/lib/test_privs.c
index 8438334377..c2cb5c2ea5 100644
--- a/tests/lib/test_privs.c
+++ b/tests/lib/test_privs.c
@@ -27,10 +27,7 @@
#include "memory_vty.h"
zebra_capabilities_t _caps_p[] = {
- ZCAP_NET_RAW,
- ZCAP_BIND,
- ZCAP_NET_ADMIN,
- ZCAP_DAC_OVERRIDE,
+ ZCAP_NET_RAW, ZCAP_BIND, ZCAP_NET_ADMIN, ZCAP_DAC_OVERRIDE,
};
struct zebra_privs_t test_privs = {
diff --git a/tests/lib/test_timer_correctness.c b/tests/lib/test_timer_correctness.c
index eb9bca71d7..43e79ba9d0 100644
--- a/tests/lib/test_timer_correctness.c
+++ b/tests/lib/test_timer_correctness.c
@@ -97,8 +97,8 @@ static int timer_func(struct thread *thread)
static int cmp_timeval(const void *a, const void *b)
{
- const struct timeval *ta = *(struct timeval *const *)a;
- const struct timeval *tb = *(struct timeval *const *)b;
+ const struct timeval *ta = *(struct timeval * const *)a;
+ const struct timeval *tb = *(struct timeval * const *)b;
if (timercmp(ta, tb, <))
return -1;
diff --git a/tools/start-stop-daemon.c b/tools/start-stop-daemon.c
index 7372cc8449..39527eca77 100644
--- a/tools/start-stop-daemon.c
+++ b/tools/start-stop-daemon.c
@@ -869,13 +869,12 @@ static int run_stop_schedule(void)
if (ratio < 10)
ratio++;
- TVCALC(interval, ratio
- * (TVELEM(&after)
- - TVELEM(&before)
- + TVADJUST));
- TVCALC(maxinterval, TVELEM(&stopat)
- - TVELEM(&after)
- + TVADJUST);
+ TVCALC(interval,
+ ratio * (TVELEM(&after) - TVELEM(&before)
+ + TVADJUST));
+ TVCALC(maxinterval,
+ TVELEM(&stopat) - TVELEM(&after)
+ + TVADJUST);
if (timercmp(&interval, &maxinterval, >))
interval = maxinterval;
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index bca582d628..f6a2c92586 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -303,7 +303,9 @@ static int vtysh_execute_func(const char *line, int pager)
|| saved_node == BGP_IPV4L_NODE
|| saved_node == BGP_IPV6L_NODE
|| saved_node == BGP_IPV6M_NODE
- || saved_node == BGP_EVPN_NODE)
+ || saved_node == BGP_EVPN_NODE
+ || saved_node == LDP_IPV4_NODE
+ || saved_node == LDP_IPV6_NODE)
&& (tried == 1)) {
vtysh_execute("exit-address-family");
} else if ((saved_node == BGP_EVPN_VNI_NODE) && (tried == 1)) {
@@ -496,6 +498,29 @@ int vtysh_mark_file(const char *filename)
strcpy(vty_buf_copy, vty->buf);
vty_buf_trimmed = trim(vty_buf_copy);
+ switch (vty->node) {
+ case LDP_IPV4_IFACE_NODE:
+ if (strncmp(vty_buf_copy, " ", 3)) {
+ fprintf(stdout, " end\n");
+ vty->node = LDP_IPV4_NODE;
+ }
+ break;
+ case LDP_IPV6_IFACE_NODE:
+ if (strncmp(vty_buf_copy, " ", 3)) {
+ fprintf(stdout, " end\n");
+ vty->node = LDP_IPV6_NODE;
+ }
+ break;
+ case LDP_PSEUDOWIRE_NODE:
+ if (strncmp(vty_buf_copy, " ", 2)) {
+ fprintf(stdout, " end\n");
+ vty->node = LDP_L2VPN_NODE;
+ }
+ break;
+ default:
+ break;
+ }
+
if (vty_buf_trimmed[0] == '!' || vty_buf_trimmed[0] == '#') {
fprintf(stdout, "%s", vty->buf);
continue;
@@ -667,8 +692,9 @@ int vtysh_config_from_file(struct vty *vty, FILE *fp)
case CMD_ERR_NO_MATCH:
fprintf(stderr, "line %d: %% Unknown command[%d]: %s",
lineno, vty->node, vty->buf);
- retcode = CMD_ERR_NO_MATCH; /* once we have an error, we
- remember & return that */
+ retcode =
+ CMD_ERR_NO_MATCH; /* once we have an error, we
+ remember & return that */
break;
case CMD_ERR_INCOMPLETE:
fprintf(stderr,
@@ -870,33 +896,27 @@ static char **new_completion(char *text, int start, int end)
/* Vty node structures. */
static struct cmd_node bgp_node = {
- BGP_NODE,
- "%s(config-router)# ",
+ BGP_NODE, "%s(config-router)# ",
};
static struct cmd_node rip_node = {
- RIP_NODE,
- "%s(config-router)# ",
+ RIP_NODE, "%s(config-router)# ",
};
static struct cmd_node isis_node = {
- ISIS_NODE,
- "%s(config-router)# ",
+ ISIS_NODE, "%s(config-router)# ",
};
static struct cmd_node interface_node = {
- INTERFACE_NODE,
- "%s(config-if)# ",
+ INTERFACE_NODE, "%s(config-if)# ",
};
static struct cmd_node ns_node = {
- NS_NODE,
- "%s(config-logical-router)# ",
+ NS_NODE, "%s(config-logical-router)# ",
};
static struct cmd_node vrf_node = {
- VRF_NODE,
- "%s(config-vrf)# ",
+ VRF_NODE, "%s(config-vrf)# ",
};
static struct cmd_node rmap_node = {RMAP_NODE, "%s(config-route-map)# "};
@@ -978,8 +998,7 @@ static struct cmd_node keychain_key_node = {KEYCHAIN_KEY_NODE,
"%s(config-keychain-key)# "};
struct cmd_node link_params_node = {
- LINK_PARAMS_NODE,
- "%s(config-link-params)# ",
+ LINK_PARAMS_NODE, "%s(config-link-params)# ",
};
/* Defined in lib/vty.c */
@@ -1274,6 +1293,14 @@ DEFUNSH(VTYSH_LDPD, ldp_address_family_ipv6, ldp_address_family_ipv6_cmd,
return CMD_SUCCESS;
}
+DEFUNSH(VTYSH_LDPD, ldp_exit_address_family, ldp_exit_address_family_cmd,
+ "exit-address-family", "Exit from Address Family configuration mode\n")
+{
+ if (vty->node == LDP_IPV4_NODE || vty->node == LDP_IPV6_NODE)
+ vty->node = LDP_NODE;
+ return CMD_SUCCESS;
+}
+
DEFUNSH(VTYSH_LDPD, ldp_interface_ifname, ldp_interface_ifname_cmd,
"interface IFNAME",
"Enable LDP on an interface and enter interface submode\n"
@@ -1635,8 +1662,7 @@ DEFUNSH(VTYSH_INTERFACE, vtysh_interface, vtysh_interface_cmd,
/* TODO Implement "no interface command in isisd. */
DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D
| VTYSH_EIGRPD,
- vtysh_no_interface_cmd, "no interface IFNAME",
- NO_STR
+ vtysh_no_interface_cmd, "no interface IFNAME", NO_STR
"Delete a pseudo interface's configuration\n"
"Interface's name\n")
@@ -1663,8 +1689,7 @@ DEFUNSH(VTYSH_VRF, vtysh_vrf, vtysh_vrf_cmd, "vrf NAME",
return CMD_SUCCESS;
}
-DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_cmd, "no vrf NAME",
- NO_STR
+DEFSH(VTYSH_ZEBRA, vtysh_no_vrf_cmd, "no vrf NAME", NO_STR
"Delete a pseudo vrf's configuration\n"
"VRF's name\n")
@@ -1915,8 +1940,7 @@ DEFUNSH(VTYSH_ALL, vtysh_log_stdout_level, vtysh_log_stdout_level_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_log_stdout, no_vtysh_log_stdout_cmd,
- "no log stdout [LEVEL]",
- NO_STR
+ "no log stdout [LEVEL]", NO_STR
"Logging control\n"
"Cancel logging to stdout\n"
"Logging level\n")
@@ -1942,8 +1966,7 @@ DEFUNSH(VTYSH_ALL, vtysh_log_file_level, vtysh_log_file_level_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_log_file, no_vtysh_log_file_cmd,
- "no log file [FILENAME [LEVEL]]",
- NO_STR
+ "no log file [FILENAME [LEVEL]]", NO_STR
"Logging control\n"
"Cancel logging to file\n"
"Logging file name\n"
@@ -1961,8 +1984,7 @@ DEFUNSH(VTYSH_ALL, vtysh_log_monitor, vtysh_log_monitor_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_log_monitor, no_vtysh_log_monitor_cmd,
- "no log monitor [LEVEL]",
- NO_STR
+ "no log monitor [LEVEL]", NO_STR
"Logging control\n"
"Disable terminal line (monitor) logging\n"
"Logging level\n")
@@ -1979,8 +2001,7 @@ DEFUNSH(VTYSH_ALL, vtysh_log_syslog, vtysh_log_syslog_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_log_syslog, no_vtysh_log_syslog_cmd,
- "no log syslog [LEVEL]",
- NO_STR
+ "no log syslog [LEVEL]", NO_STR
"Logging control\n"
"Cancel logging to syslog\n"
"Logging level\n")
@@ -1998,8 +2019,7 @@ DEFUNSH(VTYSH_ALL, vtysh_log_facility, vtysh_log_facility_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_log_facility, no_vtysh_log_facility_cmd,
- "no log facility [FACILITY]",
- NO_STR
+ "no log facility [FACILITY]", NO_STR
"Logging control\n"
"Reset syslog facility to default (daemon)\n"
"Syslog facility\n")
@@ -2019,8 +2039,7 @@ DEFUNSH_DEPRECATED(
}
DEFUNSH_DEPRECATED(VTYSH_ALL, no_vtysh_log_trap, no_vtysh_log_trap_cmd,
- "no log trap [LEVEL]",
- NO_STR
+ "no log trap [LEVEL]", NO_STR
"Logging control\n"
"Permit all logging information\n"
"Logging level\n")
@@ -2037,8 +2056,7 @@ DEFUNSH(VTYSH_ALL, vtysh_log_record_priority, vtysh_log_record_priority_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_log_record_priority,
- no_vtysh_log_record_priority_cmd, "no log record-priority",
- NO_STR
+ no_vtysh_log_record_priority_cmd, "no log record-priority", NO_STR
"Logging control\n"
"Do not log the priority of the message within the message\n")
{
@@ -2102,8 +2120,7 @@ DEFUNSH(VTYSH_ALL, vtysh_config_enable_password, vtysh_enable_password_cmd,
}
DEFUNSH(VTYSH_ALL, no_vtysh_config_enable_password,
- no_vtysh_enable_password_cmd, "no enable password",
- NO_STR
+ no_vtysh_enable_password_cmd, "no enable password", NO_STR
"Modify enable password parameters\n"
"Assign the privileged level password\n")
{
@@ -2436,7 +2453,7 @@ DEFUN (vtysh_show_daemons,
/* Execute command in child process. */
static void execute_command(const char *command, int argc,
- struct cmd_token *arg1, const char *arg2)
+ const char *arg1, const char *arg2)
{
pid_t pid;
int status;
@@ -2481,7 +2498,10 @@ DEFUN (vtysh_ping,
"Send echo messages\n"
"Ping destination address or hostname\n")
{
- execute_command("ping", 1, argv[0], NULL);
+ int idx = 1;
+
+ argv_find(argv, argc, "WORD", &idx);
+ execute_command("ping", 1, argv[idx]->arg, NULL);
return CMD_SUCCESS;
}
@@ -2496,7 +2516,10 @@ DEFUN (vtysh_traceroute,
"Trace route to destination\n"
"Trace route to destination address or hostname\n")
{
- execute_command("traceroute", 1, argv[0], NULL);
+ int idx = 1;
+
+ argv_find(argv, argc, "WORD", &idx);
+ execute_command("traceroute", 1, argv[idx]->arg, NULL);
return CMD_SUCCESS;
}
@@ -2512,7 +2535,7 @@ DEFUN (vtysh_ping6,
"IPv6 echo\n"
"Ping destination address or hostname\n")
{
- execute_command("ping6", 1, argv[0], NULL);
+ execute_command("ping6", 1, argv[2]->arg, NULL);
return CMD_SUCCESS;
}
@@ -2523,7 +2546,7 @@ DEFUN (vtysh_traceroute6,
"IPv6 trace\n"
"Trace route to destination address or hostname\n")
{
- execute_command("traceroute6", 1, argv[0], NULL);
+ execute_command("traceroute6", 1, argv[2]->arg, NULL);
return CMD_SUCCESS;
}
@@ -2534,7 +2557,7 @@ DEFUN (vtysh_telnet,
"Open a telnet connection\n"
"IP address or hostname of a remote system\n")
{
- execute_command("telnet", 1, argv[0], NULL);
+ execute_command("telnet", 1, argv[1]->arg, NULL);
return CMD_SUCCESS;
}
@@ -2545,7 +2568,7 @@ DEFUN (vtysh_telnet_port,
"IP address or hostname of a remote system\n"
"TCP Port number\n")
{
- execute_command("telnet", 2, argv[0], argv[1]);
+ execute_command("telnet", 2, argv[1]->arg, argv[2]->arg);
return CMD_SUCCESS;
}
@@ -2555,7 +2578,7 @@ DEFUN (vtysh_ssh,
"Open an ssh connection\n"
"[user@]host\n")
{
- execute_command("ssh", 1, argv[0], NULL);
+ execute_command("ssh", 1, argv[1]->arg, NULL);
return CMD_SUCCESS;
}
@@ -2598,9 +2621,39 @@ DEFUN (config_list,
return cmd_list_cmds(vty, argc == 2);
}
+DEFUN(find,
+ find_cmd,
+ "find COMMAND...",
+ "Find CLI command containing text\n"
+ "Text to search for\n")
+{
+ char *text = argv_concat(argv, argc, 1);
+ const struct cmd_node *node;
+ const struct cmd_element *cli;
+ vector clis;
+
+ for (unsigned int i = 0; i < vector_active(cmdvec); i++) {
+ node = vector_slot(cmdvec, i);
+ if (!node)
+ continue;
+ clis = node->cmd_vector;
+ for (unsigned int j = 0; j < vector_active(clis); j++) {
+ cli = vector_slot(clis, j);
+ if (strcasestr(cli->string, text))
+ fprintf(stdout, " (%s) %s\n",
+ node_names[node->node], cli->string);
+ }
+ }
+
+ XFREE(MTYPE_TMP, text);
+
+ return CMD_SUCCESS;
+}
+
static void vtysh_install_default(enum node_type node)
{
install_element(node, &config_list_cmd);
+ install_element(node, &find_cmd);
}
/* Making connection to protocol daemon. */
@@ -2892,48 +2945,13 @@ void vtysh_init_vty(void)
install_node(&isis_node, NULL);
install_node(&vty_node, NULL);
- vtysh_install_default(VIEW_NODE);
- vtysh_install_default(CONFIG_NODE);
- vtysh_install_default(BGP_NODE);
- vtysh_install_default(RIP_NODE);
- vtysh_install_default(INTERFACE_NODE);
- vtysh_install_default(LINK_PARAMS_NODE);
- vtysh_install_default(NS_NODE);
- vtysh_install_default(VRF_NODE);
- vtysh_install_default(RMAP_NODE);
- vtysh_install_default(ZEBRA_NODE);
- vtysh_install_default(BGP_VPNV4_NODE);
- vtysh_install_default(BGP_VPNV6_NODE);
- vtysh_install_default(BGP_IPV4_NODE);
- vtysh_install_default(BGP_IPV4M_NODE);
- vtysh_install_default(BGP_IPV4L_NODE);
- vtysh_install_default(BGP_IPV6_NODE);
- vtysh_install_default(BGP_IPV6M_NODE);
- vtysh_install_default(BGP_EVPN_NODE);
- vtysh_install_default(BGP_EVPN_VNI_NODE);
- vtysh_install_default(BGP_IPV6L_NODE);
-#if ENABLE_BGP_VNC
- vtysh_install_default(BGP_VRF_POLICY_NODE);
- vtysh_install_default(BGP_VNC_DEFAULTS_NODE);
- vtysh_install_default(BGP_VNC_NVE_GROUP_NODE);
- vtysh_install_default(BGP_VNC_L2_GROUP_NODE);
-#endif
- vtysh_install_default(OSPF_NODE);
- vtysh_install_default(EIGRP_NODE);
- vtysh_install_default(BABEL_NODE);
- vtysh_install_default(RIPNG_NODE);
- vtysh_install_default(OSPF6_NODE);
- vtysh_install_default(LDP_NODE);
- vtysh_install_default(LDP_IPV4_NODE);
- vtysh_install_default(LDP_IPV6_NODE);
- vtysh_install_default(LDP_IPV4_IFACE_NODE);
- vtysh_install_default(LDP_IPV6_IFACE_NODE);
- vtysh_install_default(LDP_L2VPN_NODE);
- vtysh_install_default(LDP_PSEUDOWIRE_NODE);
- vtysh_install_default(ISIS_NODE);
- vtysh_install_default(KEYCHAIN_NODE);
- vtysh_install_default(KEYCHAIN_KEY_NODE);
- vtysh_install_default(VTY_NODE);
+ struct cmd_node *node;
+ for (unsigned int i = 0; i < vector_active(cmdvec); i++) {
+ node = vector_slot(cmdvec, i);
+ if (!node || node->node == VIEW_NODE)
+ continue;
+ vtysh_install_default(node->node);
+ }
install_element(VIEW_NODE, &vtysh_enable_cmd);
install_element(ENABLE_NODE, &vtysh_config_terminal_cmd);
@@ -2961,8 +2979,10 @@ void vtysh_init_vty(void)
install_element(LDP_NODE, &vtysh_quit_ldpd_cmd);
install_element(LDP_IPV4_NODE, &vtysh_exit_ldpd_cmd);
install_element(LDP_IPV4_NODE, &vtysh_quit_ldpd_cmd);
+ install_element(LDP_IPV4_NODE, &ldp_exit_address_family_cmd);
install_element(LDP_IPV6_NODE, &vtysh_exit_ldpd_cmd);
install_element(LDP_IPV6_NODE, &vtysh_quit_ldpd_cmd);
+ install_element(LDP_IPV6_NODE, &ldp_exit_address_family_cmd);
install_element(LDP_IPV4_IFACE_NODE, &vtysh_exit_ldpd_cmd);
install_element(LDP_IPV4_IFACE_NODE, &vtysh_quit_ldpd_cmd);
install_element(LDP_IPV6_IFACE_NODE, &vtysh_exit_ldpd_cmd);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index 67ee8898c9..bef4b82d3f 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -44,7 +44,7 @@ DECLARE_MGROUP(MVTYSH)
* run on it (logging & co. should stay in a fixed/frozen config, and
* things like prefix lists are not even initialised) */
#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD
-#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_PIMD
+#define VTYSH_RMAP VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_PIMD|VTYSH_EIGRPD
#define VTYSH_INTERFACE VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_PIMD|VTYSH_NHRPD|VTYSH_EIGRPD|VTYSH_BABELD
#define VTYSH_NS VTYSH_ZEBRA
#define VTYSH_VRF VTYSH_ZEBRA
diff --git a/zebra/.gitignore b/zebra/.gitignore
index 145df05689..d0a7528539 100644
--- a/zebra/.gitignore
+++ b/zebra/.gitignore
@@ -13,3 +13,4 @@ TAGS
.arch-ids
*~
*.loT
+zebra_vty_clippy.c
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
index 46ecad5e4c..67031ea361 100644
--- a/zebra/Makefile.am
+++ b/zebra/Makefile.am
@@ -37,6 +37,8 @@ zebra_SOURCES = \
zebra_vxlan.c \
# end
+zebra_vty.o: zebra_vty_clippy.c
+
noinst_HEADERS = \
zebra_memory.h \
connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
diff --git a/zebra/debug.c b/zebra/debug.c
index dfee6b74c0..6aedea1e39 100644
--- a/zebra/debug.c
+++ b/zebra/debug.c
@@ -71,10 +71,10 @@ DEFUN (show_debugging_zebra,
" Zebra kernel netlink message dumps (recv) are on\n");
/* Check here using flags as the 'macro' does an OR */
- if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
- vty_out(vty, " Zebra RIB debugging is on\n");
if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
vty_out(vty, " Zebra RIB detailed debugging is on\n");
+ else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB))
+ vty_out(vty, " Zebra RIB debugging is on\n");
if (IS_ZEBRA_DEBUG_FPM)
vty_out(vty, " Zebra FPM debugging is on\n");
@@ -145,17 +145,16 @@ DEFUN (debug_zebra_packet,
if (argv_find(argv, argc, "send", &idx))
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
- idx = 0;
- if (argv_find(argv, argc, "recv", &idx))
+ else if (argv_find(argv, argc, "recv", &idx))
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
- idx = 0;
- if (argv_find(argv, argc, "detail", &idx))
- SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
-
- if (!(zebra_debug_packet & ZEBRA_DEBUG_SEND & ZEBRA_DEBUG_RECV)) {
+ else {
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
}
+
+ if (argv_find(argv, argc, "detail", &idx))
+ SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
+
return CMD_SUCCESS;
}
@@ -167,6 +166,13 @@ DEFUN (debug_zebra_kernel,
"Debug option set for zebra between kernel interface\n")
{
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
+
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+
return CMD_SUCCESS;
}
@@ -181,34 +187,41 @@ DEFUN (debug_zebra_kernel_msgdump,
"Dump raw netlink messages sent\n")
{
int idx = 0;
- if (argc == 4 || argv_find(argv, argc, "recv", &idx))
+
+ if (argv_find(argv, argc, "recv", &idx)) {
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
- if (argc == 4 || argv_find(argv, argc, "send", &idx))
+
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+
+ } else if (argv_find(argv, argc, "send", &idx)) {
SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+
+ } else {
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+ }
+
return CMD_SUCCESS;
}
DEFUN (debug_zebra_rib,
debug_zebra_rib_cmd,
- "debug zebra rib",
- DEBUG_STR
- "Zebra configuration\n"
- "Debug RIB events\n")
-{
- SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB);
- return CMD_SUCCESS;
-}
-
-DEFUN (debug_zebra_rib_detailed,
- debug_zebra_rib_detailed_cmd,
- "debug zebra rib detailed",
+ "debug zebra rib [detailed]",
DEBUG_STR
"Zebra configuration\n"
"Debug RIB events\n"
"Detailed debugs\n")
{
- SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+ int idx = 0;
+ SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB);
+
+ if (argv_find(argv, argc, "detailed", &idx))
+ SET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+
return CMD_SUCCESS;
}
@@ -273,19 +286,16 @@ DEFUN (no_debug_zebra_vxlan,
DEFUN (no_debug_zebra_packet,
no_debug_zebra_packet_cmd,
- "no debug zebra packet [<recv|send>]",
+ "no debug zebra packet [<recv|send>] [detail]",
NO_STR
DEBUG_STR
"Zebra configuration\n"
"Debug option set for zebra packet\n"
"Debug option set for receive packet\n"
- "Debug option set for send packet\n")
+ "Debug option set for send packet\n"
+ "Debug option set for detailed info\n")
{
- int idx = 0;
- if (argc == 4 || argv_find(argv, argc, "send", &idx))
- UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
- if (argc == 4 || argv_find(argv, argc, "recv", &idx))
- UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
+ zebra_debug_packet = 0;
return CMD_SUCCESS;
}
@@ -297,7 +307,7 @@ DEFUN (no_debug_zebra_kernel,
"Zebra configuration\n"
"Debug option set for zebra between kernel interface\n")
{
- UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
+ zebra_debug_kernel = 0;
return CMD_SUCCESS;
}
@@ -312,37 +322,20 @@ DEFUN (no_debug_zebra_kernel_msgdump,
"Dump raw netlink messages received\n"
"Dump raw netlink messages sent\n")
{
- int idx = 0;
- if (argc == 5 || argv_find(argv, argc, "recv", &idx))
- UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
- if (argc == 5 || argv_find(argv, argc, "send", &idx))
- UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
-
+ zebra_debug_kernel = 0;
return CMD_SUCCESS;
}
DEFUN (no_debug_zebra_rib,
no_debug_zebra_rib_cmd,
- "no debug zebra rib",
- NO_STR
- DEBUG_STR
- "Zebra configuration\n"
- "Debug zebra RIB\n")
-{
- zebra_debug_rib = 0;
- return CMD_SUCCESS;
-}
-
-DEFUN (no_debug_zebra_rib_detailed,
- no_debug_zebra_rib_detailed_cmd,
- "no debug zebra rib detailed",
+ "no debug zebra rib [detailed]",
NO_STR
DEBUG_STR
"Zebra configuration\n"
"Debug zebra RIB\n"
"Detailed debugs\n")
{
- UNSET_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+ zebra_debug_rib = 0;
return CMD_SUCCESS;
}
@@ -385,27 +378,31 @@ static int config_write_debug(struct vty *vty)
write++;
}
}
+
if (IS_ZEBRA_DEBUG_KERNEL) {
- vty_out(vty, "debug zebra kernel\n");
- write++;
- }
- if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
- vty_out(vty, "debug zebra kernel msgdump recv\n");
- write++;
- }
- if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
- vty_out(vty, "debug zebra kernel msgdump send\n");
- write++;
- }
- /* Check here using flags as the 'macro' does an OR */
- if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
- vty_out(vty, "debug zebra rib\n");
- write++;
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND && IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
+ vty_out(vty, "debug zebra kernel msgdump\n");
+ write++;
+ } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) {
+ vty_out(vty, "debug zebra kernel msgdump recv\n");
+ write++;
+ } else if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) {
+ vty_out(vty, "debug zebra kernel msgdump send\n");
+ write++;
+ } else {
+ vty_out(vty, "debug zebra kernel\n");
+ write++;
+ }
}
+
if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED)) {
vty_out(vty, "debug zebra rib detailed\n");
write++;
+ } else if (CHECK_FLAG(zebra_debug_rib, ZEBRA_DEBUG_RIB)) {
+ vty_out(vty, "debug zebra rib\n");
+ write++;
}
+
if (IS_ZEBRA_DEBUG_FPM) {
vty_out(vty, "debug zebra fpm\n");
write++;
@@ -447,7 +444,6 @@ void zebra_debug_init(void)
install_element(ENABLE_NODE, &debug_zebra_kernel_cmd);
install_element(ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
install_element(ENABLE_NODE, &debug_zebra_rib_cmd);
- install_element(ENABLE_NODE, &debug_zebra_rib_detailed_cmd);
install_element(ENABLE_NODE, &debug_zebra_fpm_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_events_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_nht_cmd);
@@ -457,7 +453,6 @@ void zebra_debug_init(void)
install_element(ENABLE_NODE, &no_debug_zebra_kernel_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_rib_cmd);
- install_element(ENABLE_NODE, &no_debug_zebra_rib_detailed_cmd);
install_element(ENABLE_NODE, &no_debug_zebra_fpm_cmd);
install_element(CONFIG_NODE, &debug_zebra_events_cmd);
@@ -468,7 +463,6 @@ void zebra_debug_init(void)
install_element(CONFIG_NODE, &debug_zebra_kernel_cmd);
install_element(CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
install_element(CONFIG_NODE, &debug_zebra_rib_cmd);
- install_element(CONFIG_NODE, &debug_zebra_rib_detailed_cmd);
install_element(CONFIG_NODE, &debug_zebra_fpm_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_events_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_nht_cmd);
@@ -478,6 +472,5 @@ void zebra_debug_init(void)
install_element(CONFIG_NODE, &no_debug_zebra_kernel_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_rib_cmd);
- install_element(CONFIG_NODE, &no_debug_zebra_rib_detailed_cmd);
install_element(CONFIG_NODE, &no_debug_zebra_fpm_cmd);
}
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index d38fe7c306..fce36ebc1d 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -119,7 +119,7 @@ calculate_lifc_len: /* must hold privileges to enter here */
if (ret < 0) {
if (errno == EINVAL)
goto calculate_lifc_len; /* deliberately hold privileges
- */
+ */
zlog_warn("SIOCGLIFCONF: %s", safe_strerror(errno));
diff --git a/zebra/interface.c b/zebra/interface.c
index 4bce42f22b..03ddf8d386 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -429,7 +429,7 @@ static void if_addr_wakeup(struct interface *ifp)
* XXX: RUNNING is not a settable flag
* on any system
* I (paulj) am aware of.
- */
+ */
if_set_flags(ifp, IFF_UP | IFF_RUNNING);
if_refresh(ifp);
}
@@ -1757,9 +1757,7 @@ DEFUN (no_bandwidth_if,
struct cmd_node link_params_node = {
- LINK_PARAMS_NODE,
- "%s(config-link-params)# ",
- 1,
+ LINK_PARAMS_NODE, "%s(config-link-params)# ", 1,
};
static void link_param_cmd_set_uint32(struct interface *ifp, uint32_t *field,
diff --git a/zebra/interface.h b/zebra/interface.h
index 58c61c2c11..ea72264696 100644
--- a/zebra/interface.h
+++ b/zebra/interface.h
@@ -172,10 +172,11 @@ struct rtadvconf {
int DefaultPreference;
#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
- u_char inFastRexmit; /* True if we're rexmits faster than usual */
- u_char configured; /* Has operator configured RA? */
- int NumFastReXmitsRemain; /* Loaded first with number of fast
- rexmits to do */
+ u_char inFastRexmit; /* True if we're rexmits faster than usual */
+ u_char configured; /* Has operator configured RA? */
+ int
+ NumFastReXmitsRemain; /* Loaded first with number of fast
+ rexmits to do */
#define RTADV_FAST_REXMIT_PERIOD 1 /* 1 sec */
#define RTADV_NUM_FAST_REXMITS 4 /* Fast Rexmit RA 4 times on certain events */
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 8a5bc69521..7fc2d61332 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -307,8 +307,7 @@ static void netlink_install_filter(int sock, __u32 pid)
};
struct sock_fprog prog = {
- .len = array_size(filter),
- .filter = filter,
+ .len = array_size(filter), .filter = filter,
};
if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog))
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 2484d81832..4b63a3eb04 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -315,9 +315,8 @@ static int ifan_read(struct if_announcemsghdr *ifan)
assert((ifp->ifindex == ifan->ifan_index)
|| (ifp->ifindex == IFINDEX_INTERNAL));
- if ((ifp == NULL)
- || ((ifp->ifindex == IFINDEX_INTERNAL)
- && (ifan->ifan_what == IFAN_ARRIVAL))) {
+ if ((ifp == NULL) || ((ifp->ifindex == IFINDEX_INTERNAL)
+ && (ifan->ifan_what == IFAN_ARRIVAL))) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
"%s: creating interface for ifindex %d, name %s",
@@ -945,7 +944,7 @@ void rtm_read(struct rt_msghdr *rtm)
buf, gate_buf);
break;
case ZEBRA_RIB_FOUND_EXACT: /* RIB RR == FIB RR
- */
+ */
zlog_debug(
"%s: %s %s: done Ok", __func__,
lookup_msg(rtm_type_str,
diff --git a/zebra/main.c b/zebra/main.c
index b9a3bf881a..27a6f3e027 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -89,9 +89,7 @@ struct option longopts[] = {{"batch", no_argument, NULL, 'b'},
{0}};
zebra_capabilities_t _caps_p[] = {
- ZCAP_NET_ADMIN,
- ZCAP_SYS_ADMIN,
- ZCAP_NET_RAW,
+ ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, ZCAP_NET_RAW,
};
/* zebra privileges to run with */
@@ -226,7 +224,7 @@ int main(int argc, char **argv)
#ifdef HAVE_NETLINK
" -s, --nl-bufsize Set netlink receive buffer size\n"
#endif /* HAVE_NETLINK */
- );
+ );
while (1) {
int opt = frr_getopt(argc, argv, NULL);
@@ -310,25 +308,25 @@ int main(int argc, char **argv)
zebra_ns_init();
/* Process the configuration file. Among other configuration
- * directives we can meet those installing static routes. Such
- * requests will not be executed immediately, but queued in
- * zebra->ribq structure until we enter the main execution loop.
- * The notifications from kernel will show originating PID equal
- * to that after daemon() completes (if ever called).
- */
+ * directives we can meet those installing static routes. Such
+ * requests will not be executed immediately, but queued in
+ * zebra->ribq structure until we enter the main execution loop.
+ * The notifications from kernel will show originating PID equal
+ * to that after daemon() completes (if ever called).
+ */
frr_config_fork();
/* Clean up rib -- before fork (?) */
/* rib_weed_tables (); */
/* After we have successfully acquired the pidfile, we can be sure
- * about being the only copy of zebra process, which is submitting
- * changes to the FIB.
- * Clean up zebra-originated routes. The requests will be sent to OS
- * immediately, so originating PID in notifications from kernel
- * will be equal to the current getpid(). To know about such routes,
- * we have to have route_read() called before.
- */
+ * about being the only copy of zebra process, which is submitting
+ * changes to the FIB.
+ * Clean up zebra-originated routes. The requests will be sent to OS
+ * immediately, so originating PID in notifications from kernel
+ * will be equal to the current getpid(). To know about such routes,
+ * we have to have route_read() called before.
+ */
if (!keep_kernel_mode)
rib_sweep_route();
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index a7679cb830..b8cf2d490a 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -263,7 +263,7 @@ static void rtadv_send_packet(int sock, struct interface *ifp)
for RL,
but not
for HAL*/
- );
+ );
len += sizeof(struct nd_opt_homeagent_info);
}
@@ -1274,9 +1274,8 @@ DEFUN (ipv6_nd_prefix,
{
/* prelude */
char *prefix = argv[3]->arg;
- int lifetimes = (argc > 4)
- && (argv[4]->type == RANGE_TKN
- || strmatch(argv[4]->text, "infinite"));
+ int lifetimes = (argc > 4) && (argv[4]->type == RANGE_TKN
+ || strmatch(argv[4]->text, "infinite"));
int routeropts = lifetimes ? argc > 6 : argc > 4;
int idx_routeropts = routeropts ? (lifetimes ? 6 : 4) : 0;
diff --git a/zebra/zebra_l2.h b/zebra/zebra_l2.h
index 0d0c5aaf22..d9bbcfed6f 100644
--- a/zebra/zebra_l2.h
+++ b/zebra/zebra_l2.h
@@ -67,6 +67,7 @@ union zebra_l2if_info {
#define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) ((zif)->l2info.br.vlan_aware == 1)
+
extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave);
extern void
zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave);
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index cb1c80923d..e44e5d2e6b 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -1965,7 +1965,7 @@ int zebra_mpls_label_already_bound(struct zebra_vrf *zvrf, mpls_label_t label)
* Add static FEC to label binding. If there are clients registered for this
* FEC, notify them. If there are labeled routes for this FEC, install the
* label forwarding entry.
- */
+*/
int zebra_mpls_static_fec_add(struct zebra_vrf *zvrf, struct prefix *p,
mpls_label_t in_label)
{
@@ -2639,9 +2639,8 @@ void zebra_mpls_print_lsp(struct vty *vty, struct zebra_vrf *zvrf,
if (use_json) {
json = lsp_json(lsp);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else
lsp_print(lsp, (void *)vty);
@@ -2669,9 +2668,8 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
json, label2str(lsp->ile.in_label, buf, BUFSIZ),
lsp_json(lsp));
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
} else {
vty_out(vty, " Inbound Outbound\n");
diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c
index ed34831f8f..9d100bb7d0 100644
--- a/zebra/zebra_mpls_vty.c
+++ b/zebra/zebra_mpls_vty.c
@@ -283,570 +283,6 @@ DEFUN (no_mpls_label_bind,
return zebra_mpls_bind(vty, 0, argv[4]->arg, NULL);
}
-/* Static route configuration. */
-DEFUN (ip_route_label,
- ip_route_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, NULL, NULL, NULL,
- argv[5]->arg);
-}
-
-DEFUN (ip_route_tag_label,
- ip_route_tag_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, argv[5]->arg, NULL, NULL,
- argv[7]->arg);
-}
-
-/* Mask as A.B.C.D format. */
-DEFUN (ip_route_mask_label,
- ip_route_mask_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, NULL, NULL,
- NULL, argv[6]->arg);
-}
-
-DEFUN (ip_route_mask_tag_label,
- ip_route_mask_tag_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg,
- NULL, NULL, argv[8]->arg);
-}
-
-/* Distance option value. */
-DEFUN (ip_route_distance_label,
- ip_route_distance_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, NULL, argv[4]->arg, NULL,
- argv[6]->arg);
-}
-
-DEFUN (ip_route_tag_distance_label,
- ip_route_tag_distance_label_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg, NULL,
- argv[3]->arg, NULL, argv[5]->arg, argv[6]->arg,
- NULL, argv[8]->arg);
-}
-
-DEFUN (ip_route_mask_distance_label,
- ip_route_mask_distance_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, NULL,
- argv[5]->arg, NULL, argv[7]->arg);
-}
-
-DEFUN (ip_route_mask_tag_distance_label,
- ip_route_mask_tag_distance_label_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[2]->arg,
- argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg,
- argv[7]->arg, NULL, argv[9]->arg);
-}
-
-DEFUN (no_ip_route_label,
- no_ip_route_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, NULL, NULL, NULL,
- argv[6]->arg);
-}
-
-DEFUN (no_ip_route_tag_label,
- no_ip_route_tag_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, argv[6]->arg, NULL, NULL,
- argv[8]->arg);
-}
-
-DEFUN (no_ip_route_mask_label,
- no_ip_route_mask_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, NULL, NULL,
- NULL, argv[7]->arg);
-}
-
-DEFUN (no_ip_route_mask_tag_label,
- no_ip_route_mask_tag_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg,
- NULL, NULL, argv[9]->arg);
-}
-
-DEFUN (no_ip_route_distance_label,
- no_ip_route_distance_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, NULL, argv[5]->arg, NULL,
- argv[7]->arg);
-}
-
-DEFUN (no_ip_route_tag_distance_label,
- no_ip_route_tag_distance_label_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg, NULL,
- argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg,
- NULL, argv[9]->arg);
-}
-
-DEFUN (no_ip_route_mask_distance_label,
- no_ip_route_mask_distance_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, NULL,
- argv[6]->arg, NULL, argv[8]->arg);
-}
-
-DEFUN (no_ip_route_mask_tag_distance_label,
- no_ip_route_mask_tag_distance_label_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- MPLS_LABEL_HELPSTR)
-{
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[3]->arg,
- argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg,
- argv[8]->arg, NULL, argv[10]->arg);
-}
-
-DEFUN (ipv6_route_label,
- ipv6_route_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, NULL, NULL, NULL, argv[5]->arg);
-}
-
-DEFUN (ipv6_route_tag_label,
- ipv6_route_tag_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, argv[5]->arg, NULL, NULL, argv[7]->arg);
-}
-
-DEFUN (ipv6_route_ifname_label,
- ipv6_route_ifname_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, NULL, NULL, NULL,
- argv[6]->arg);
-}
-DEFUN (ipv6_route_ifname_tag_label,
- ipv6_route_ifname_tag_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, argv[6]->arg, NULL, NULL,
- argv[8]->arg);
-}
-
-DEFUN (ipv6_route_pref_label,
- ipv6_route_pref_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, NULL, argv[4]->arg, NULL, argv[6]->arg);
-}
-
-DEFUN (ipv6_route_pref_tag_label,
- ipv6_route_pref_tag_label_cmd,
- "ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL,
- NULL, argv[5]->arg, argv[6]->arg, NULL,
- argv[8]->arg);
-}
-
-DEFUN (ipv6_route_ifname_pref_label,
- ipv6_route_ifname_pref_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, NULL, argv[5]->arg, NULL,
- argv[7]->arg);
-}
-
-DEFUN (ipv6_route_ifname_pref_tag_label,
- ipv6_route_ifname_pref_tag_label_cmd,
- "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 1, argv[2]->arg, NULL, argv[3]->arg,
- argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg,
- NULL, argv[9]->arg);
-}
-
-DEFUN (no_ipv6_route_label,
- no_ipv6_route_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, NULL, NULL, NULL, argv[6]->arg);
-}
-
-DEFUN (no_ipv6_route_tag_label,
- no_ipv6_route_tag_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, argv[6]->arg, NULL, NULL, argv[8]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_label,
- no_ipv6_route_ifname_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, NULL, NULL, NULL,
- argv[7]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_tag_label,
- no_ipv6_route_ifname_tag_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, argv[7]->arg, NULL, NULL,
- argv[9]->arg);
-}
-
-DEFUN (no_ipv6_route_pref_label,
- no_ipv6_route_pref_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, NULL, argv[5]->arg, NULL, argv[7]->arg);
-}
-
-DEFUN (no_ipv6_route_pref_tag_label,
- no_ipv6_route_pref_tag_label_cmd,
- "no ipv6 route X:X::X:X/M <X:X::X:X|INTERFACE> tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL,
- NULL, argv[6]->arg, argv[7]->arg, NULL,
- argv[9]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_pref_label,
- no_ipv6_route_ifname_pref_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, NULL, argv[6]->arg, NULL,
- argv[8]->arg);
-}
-
-DEFUN (no_ipv6_route_ifname_pref_tag_label,
- no_ipv6_route_ifname_pref_tag_label_cmd,
- "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag (1-4294967295) (1-255) label WORD",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- MPLS_LABEL_HELPSTR)
-{
- return static_ipv6_func(vty, 0, argv[3]->arg, NULL, argv[4]->arg,
- argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg,
- NULL, argv[10]->arg);
-}
-
/* MPLS LSP configuration write function. */
static int zebra_mpls_config(struct vty *vty)
{
@@ -1024,44 +460,11 @@ void zebra_mpls_vty_init(void)
install_node(&mpls_node, zebra_mpls_config);
- install_element(CONFIG_NODE, &ip_route_label_cmd);
- install_element(CONFIG_NODE, &ip_route_tag_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_tag_label_cmd);
- install_element(CONFIG_NODE, &ip_route_distance_label_cmd);
- install_element(CONFIG_NODE, &ip_route_tag_distance_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_distance_label_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_tag_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_tag_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_distance_label_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_tag_distance_label_cmd);
-
- install_element(CONFIG_NODE, &ipv6_route_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_pref_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_pref_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_pref_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_tag_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_tag_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_pref_tag_label_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_pref_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_pref_tag_label_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_label_cmd);
-
install_element(CONFIG_NODE, &mpls_transit_lsp_cmd);
install_element(CONFIG_NODE, &no_mpls_transit_lsp_cmd);
install_element(CONFIG_NODE, &no_mpls_transit_lsp_out_label_cmd);
install_element(CONFIG_NODE, &no_mpls_transit_lsp_all_cmd);
+
install_element(CONFIG_NODE, &mpls_label_bind_cmd);
install_element(CONFIG_NODE, &no_mpls_label_bind_cmd);
diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c
index 0c79d773a8..1bf672d4a1 100644
--- a/zebra/zebra_ptm.c
+++ b/zebra/zebra_ptm.c
@@ -267,9 +267,8 @@ DEFUN (zebra_ptm_enable,
for (ALL_LIST_ELEMENTS_RO(vrf->iflist, i, ifp))
if (!ifp->ptm_enable) {
if_data = (struct zebra_if *)ifp->info;
- if (if_data
- && (if_data->ptm_enable
- == ZEBRA_IF_PTM_ENABLE_UNSPEC)) {
+ if (if_data && (if_data->ptm_enable
+ == ZEBRA_IF_PTM_ENABLE_UNSPEC)) {
ifp->ptm_enable = ZEBRA_IF_PTM_ENABLE_ON;
}
/* Assign a default unknown status */
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index c72e290032..98508aaa89 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -68,17 +68,17 @@ static const struct {
int key;
int distance;
} route_info[ZEBRA_ROUTE_MAX] = {
- [ZEBRA_ROUTE_SYSTEM] = {ZEBRA_ROUTE_SYSTEM, 0},
- [ZEBRA_ROUTE_KERNEL] = {ZEBRA_ROUTE_KERNEL, 0},
- [ZEBRA_ROUTE_CONNECT] = {ZEBRA_ROUTE_CONNECT, 0},
- [ZEBRA_ROUTE_STATIC] = {ZEBRA_ROUTE_STATIC, 1},
- [ZEBRA_ROUTE_RIP] = {ZEBRA_ROUTE_RIP, 120},
- [ZEBRA_ROUTE_RIPNG] = {ZEBRA_ROUTE_RIPNG, 120},
- [ZEBRA_ROUTE_OSPF] = {ZEBRA_ROUTE_OSPF, 110},
- [ZEBRA_ROUTE_OSPF6] = {ZEBRA_ROUTE_OSPF6, 110},
- [ZEBRA_ROUTE_ISIS] = {ZEBRA_ROUTE_ISIS, 115},
- [ZEBRA_ROUTE_BGP] = {ZEBRA_ROUTE_BGP, 20 /* IBGP is 200. */},
- [ZEBRA_ROUTE_NHRP] = {ZEBRA_ROUTE_NHRP, 10},
+ [ZEBRA_ROUTE_SYSTEM] = {ZEBRA_ROUTE_SYSTEM, 0},
+ [ZEBRA_ROUTE_KERNEL] = {ZEBRA_ROUTE_KERNEL, 0},
+ [ZEBRA_ROUTE_CONNECT] = {ZEBRA_ROUTE_CONNECT, 0},
+ [ZEBRA_ROUTE_STATIC] = {ZEBRA_ROUTE_STATIC, 1},
+ [ZEBRA_ROUTE_RIP] = {ZEBRA_ROUTE_RIP, 120},
+ [ZEBRA_ROUTE_RIPNG] = {ZEBRA_ROUTE_RIPNG, 120},
+ [ZEBRA_ROUTE_OSPF] = {ZEBRA_ROUTE_OSPF, 110},
+ [ZEBRA_ROUTE_OSPF6] = {ZEBRA_ROUTE_OSPF6, 110},
+ [ZEBRA_ROUTE_ISIS] = {ZEBRA_ROUTE_ISIS, 115},
+ [ZEBRA_ROUTE_BGP] = {ZEBRA_ROUTE_BGP, 20 /* IBGP is 200. */},
+ [ZEBRA_ROUTE_NHRP] = {ZEBRA_ROUTE_NHRP, 10},
/* no entry/default: 150 */
};
@@ -1551,9 +1551,8 @@ static void rib_process(struct route_node *rn)
/* Buffer ROUTE_ENTRY_CHANGED here, because it will get cleared if
* fib == selected */
- bool selected_changed =
- new_selected
- && CHECK_FLAG(new_selected->status, ROUTE_ENTRY_CHANGED);
+ bool selected_changed = new_selected && CHECK_FLAG(new_selected->status,
+ ROUTE_ENTRY_CHANGED);
/* Update fib according to selection results */
if (new_fib && old_fib)
@@ -1726,30 +1725,30 @@ static wq_item_status meta_queue_process(struct work_queue *dummy, void *data)
* Map from rib types to queue type (priority) in meta queue
*/
static const u_char meta_queue_map[ZEBRA_ROUTE_MAX] = {
- [ZEBRA_ROUTE_SYSTEM] = 4,
- [ZEBRA_ROUTE_KERNEL] = 0,
- [ZEBRA_ROUTE_CONNECT] = 0,
- [ZEBRA_ROUTE_STATIC] = 1,
- [ZEBRA_ROUTE_RIP] = 2,
- [ZEBRA_ROUTE_RIPNG] = 2,
- [ZEBRA_ROUTE_OSPF] = 2,
- [ZEBRA_ROUTE_OSPF6] = 2,
- [ZEBRA_ROUTE_ISIS] = 2,
- [ZEBRA_ROUTE_BGP] = 3,
- [ZEBRA_ROUTE_PIM] = 4, // Shouldn't happen but for safety
- [ZEBRA_ROUTE_EIGRP] = 2,
- [ZEBRA_ROUTE_NHRP] = 2,
- [ZEBRA_ROUTE_HSLS] = 4,
- [ZEBRA_ROUTE_OLSR] = 4,
- [ZEBRA_ROUTE_TABLE] = 1,
- [ZEBRA_ROUTE_LDP] = 4,
- [ZEBRA_ROUTE_VNC] = 3,
- [ZEBRA_ROUTE_VNC_DIRECT] = 3,
- [ZEBRA_ROUTE_VNC_DIRECT_RH] = 3,
- [ZEBRA_ROUTE_BGP_DIRECT] = 3,
- [ZEBRA_ROUTE_BGP_DIRECT_EXT] = 3,
- [ZEBRA_ROUTE_BABEL] = 2,
- [ZEBRA_ROUTE_ALL] = 4, // Shouldn't happen but for safety
+ [ZEBRA_ROUTE_SYSTEM] = 4,
+ [ZEBRA_ROUTE_KERNEL] = 0,
+ [ZEBRA_ROUTE_CONNECT] = 0,
+ [ZEBRA_ROUTE_STATIC] = 1,
+ [ZEBRA_ROUTE_RIP] = 2,
+ [ZEBRA_ROUTE_RIPNG] = 2,
+ [ZEBRA_ROUTE_OSPF] = 2,
+ [ZEBRA_ROUTE_OSPF6] = 2,
+ [ZEBRA_ROUTE_ISIS] = 2,
+ [ZEBRA_ROUTE_BGP] = 3,
+ [ZEBRA_ROUTE_PIM] = 4, // Shouldn't happen but for safety
+ [ZEBRA_ROUTE_EIGRP] = 2,
+ [ZEBRA_ROUTE_NHRP] = 2,
+ [ZEBRA_ROUTE_HSLS] = 4,
+ [ZEBRA_ROUTE_OLSR] = 4,
+ [ZEBRA_ROUTE_TABLE] = 1,
+ [ZEBRA_ROUTE_LDP] = 4,
+ [ZEBRA_ROUTE_VNC] = 3,
+ [ZEBRA_ROUTE_VNC_DIRECT] = 3,
+ [ZEBRA_ROUTE_VNC_DIRECT_RH] = 3,
+ [ZEBRA_ROUTE_BGP_DIRECT] = 3,
+ [ZEBRA_ROUTE_BGP_DIRECT_EXT] = 3,
+ [ZEBRA_ROUTE_BABEL] = 2,
+ [ZEBRA_ROUTE_ALL] = 4, // Shouldn't happen but for safety
};
/* Look into the RN and queue it into one or more priority queues,
@@ -2396,7 +2395,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
family2afi(afi), gate,
buf2,
INET_ADDRSTRLEN), /* FIXME
- */
+ */
ifindex, type);
else
rnode_debug(
diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h
index f769a273eb..f8d89ec8ca 100644
--- a/zebra/zebra_rnh.h
+++ b/zebra/zebra_rnh.h
@@ -39,12 +39,12 @@ struct rnh {
struct route_entry *state;
struct prefix resolved_route;
struct list *client_list;
- struct list
- *zebra_static_route_list; /* static routes dependent on this NH
- */
+ struct list *
+ zebra_static_route_list; /* static routes dependent on this NH
+ */
struct route_node *node;
int filtered[ZEBRA_ROUTE_MAX]; /* if this has been filtered for client
- */
+ */
};
typedef enum { RNH_NEXTHOP_TYPE, RNH_IMPORT_CHECK_TYPE } rnh_type_t;
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 2b209613d4..0176b36840 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -148,9 +148,7 @@ static route_map_result_t route_match_tag(void *rule, struct prefix *prefix,
/* Route map commands for tag matching */
static struct route_map_rule_cmd route_match_tag_cmd = {
- "tag",
- route_match_tag,
- route_map_rule_tag_compile,
+ "tag", route_match_tag, route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -1169,10 +1167,7 @@ static void route_set_src_free(void *rule)
/* Set src rule structure. */
static struct route_map_rule_cmd route_set_src_cmd = {
- "src",
- route_set_src,
- route_set_src_compile,
- route_set_src_free,
+ "src", route_set_src, route_set_src_compile, route_set_src_free,
};
static int zebra_route_map_update_timer(struct thread *thread)
diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c
index 84b2c14dbe..6cebae997c 100644
--- a/zebra/zebra_static.c
+++ b/zebra/zebra_static.c
@@ -81,6 +81,10 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
+ case STATIC_IPV4_GATEWAY_IFINDEX:
+ nexthop = route_entry_nexthop_ipv4_ifindex_add(
+ re, &si->addr.ipv4, NULL, si->ifindex);
+ break;
case STATIC_IFINDEX:
nexthop = route_entry_nexthop_ifindex_add(re,
si->ifindex);
@@ -152,6 +156,10 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
nh_p.u.prefix4 = si->addr.ipv4;
zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn);
break;
+ case STATIC_IPV4_GATEWAY_IFINDEX:
+ nexthop = route_entry_nexthop_ipv4_ifindex_add(
+ re, &si->addr.ipv4, NULL, si->ifindex);
+ break;
case STATIC_IFINDEX:
nexthop = route_entry_nexthop_ifindex_add(re,
si->ifindex);
@@ -216,6 +224,11 @@ static int static_nexthop_same(struct nexthop *nexthop, struct static_route *si)
&& si->type == STATIC_IPV4_GATEWAY
&& IPV4_ADDR_SAME(&nexthop->gate.ipv4, &si->addr.ipv4))
return 1;
+ else if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
+ && si->type == STATIC_IPV4_GATEWAY_IFINDEX
+ && IPV4_ADDR_SAME(&nexthop->gate.ipv4, &si->addr.ipv4)
+ && nexthop->ifindex == si->ifindex)
+ return 1;
else if (nexthop->type == NEXTHOP_TYPE_IFINDEX
&& si->type == STATIC_IFINDEX
&& nexthop->ifindex == si->ifindex)
@@ -362,12 +375,16 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
return -1;
if (!gate
- && (type == STATIC_IPV4_GATEWAY || type == STATIC_IPV6_GATEWAY
+ && (type == STATIC_IPV4_GATEWAY
+ || type == STATIC_IPV4_GATEWAY_IFINDEX
+ || type == STATIC_IPV6_GATEWAY
|| type == STATIC_IPV6_GATEWAY_IFINDEX))
return -1;
if (!ifindex
- && (type == STATIC_IFINDEX || type == STATIC_IPV6_GATEWAY_IFINDEX))
+ && (type == STATIC_IFINDEX
+ || type == STATIC_IPV4_GATEWAY_IFINDEX
+ || type == STATIC_IPV6_GATEWAY_IFINDEX))
return -1;
/* Lookup static route prefix. */
@@ -376,11 +393,10 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
/* Do nothing if there is a same static route. */
for (si = rn->info; si; si = si->next) {
if (type == si->type
- && (!gate
- || ((afi == AFI_IP
- && IPV4_ADDR_SAME(gate, &si->addr.ipv4))
- || (afi == AFI_IP6
- && IPV6_ADDR_SAME(gate, &si->addr.ipv6))))
+ && (!gate || ((afi == AFI_IP
+ && IPV4_ADDR_SAME(gate, &si->addr.ipv4))
+ || (afi == AFI_IP6
+ && IPV6_ADDR_SAME(gate, &si->addr.ipv6))))
&& (!ifindex || ifindex == si->ifindex)) {
if ((distance == si->distance) && (tag == si->tag)
&& !memcmp(&si->snh_label, snh_label,
@@ -413,11 +429,10 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
switch (type) {
case STATIC_IPV4_GATEWAY:
+ case STATIC_IPV4_GATEWAY_IFINDEX:
si->addr.ipv4 = gate->ipv4;
break;
case STATIC_IPV6_GATEWAY:
- si->addr.ipv6 = gate->ipv6;
- break;
case STATIC_IPV6_GATEWAY_IFINDEX:
si->addr.ipv6 = gate->ipv6;
break;
@@ -485,11 +500,10 @@ int static_delete_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
/* Find same static route is the tree */
for (si = rn->info; si; si = si->next)
if (type == si->type
- && (!gate
- || ((afi == AFI_IP
- && IPV4_ADDR_SAME(gate, &si->addr.ipv4))
- || (afi == AFI_IP6
- && IPV6_ADDR_SAME(gate, &si->addr.ipv6))))
+ && (!gate || ((afi == AFI_IP
+ && IPV4_ADDR_SAME(gate, &si->addr.ipv4))
+ || (afi == AFI_IP6
+ && IPV6_ADDR_SAME(gate, &si->addr.ipv6))))
&& (!ifindex || ifindex == si->ifindex)
&& (!tag || (tag == si->tag))
&& (!snh_label->num_labels
diff --git a/zebra/zebra_static.h b/zebra/zebra_static.h
index 91ac0a33c2..885774895f 100644
--- a/zebra/zebra_static.h
+++ b/zebra/zebra_static.h
@@ -32,6 +32,7 @@ struct static_nh_label {
typedef enum {
STATIC_IFINDEX,
STATIC_IPV4_GATEWAY,
+ STATIC_IPV4_GATEWAY_IFINDEX,
STATIC_BLACKHOLE,
STATIC_IPV6_GATEWAY,
STATIC_IPV6_GATEWAY_IFINDEX,
@@ -57,11 +58,6 @@ struct static_route {
/*
* Nexthop value.
- *
- * Under IPv4 addr and ifindex are
- * used independentyly.
- * STATIC_IPV4_GATEWAY uses addr
- * STATIC_IFINDEX uses ifindex
*/
union g_addr addr;
ifindex_t ifindex;
@@ -100,16 +96,4 @@ extern int static_delete_route(afi_t, safi_t safi, u_char type,
struct zebra_vrf *zvrf,
struct static_nh_label *snh_label);
-int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
- const char *dest_str, const char *mask_str,
- const char *gate_str, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str);
-
-int static_ipv6_func(struct vty *vty, int add_cmd, const char *dest_str,
- const char *src_str, const char *gate_str,
- const char *ifname, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str);
-
#endif
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index a97672599d..e8b82ecf90 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -43,6 +43,7 @@
#include "zebra/zebra_static.h"
#include "lib/json.h"
#include "zebra/zebra_vxlan.h"
+#include "zebra/zebra_vty_clippy.c"
extern int allow_delete;
@@ -61,40 +62,59 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
#define CMD_VNI_RANGE "(1-16777215)"
/* General function for static route. */
-int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
- const char *dest_str, const char *mask_str,
- const char *gate_str, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str)
+static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
+ const char *negate, const char *dest_str,
+ const char *mask_str, const char *src_str,
+ const char *gate_str, const char *ifname,
+ const char *flag_str, const char *tag_str,
+ const char *distance_str, const char *vrf_id_str,
+ const char *label_str)
{
int ret;
u_char distance;
- struct prefix p;
- struct in_addr gate;
+ struct prefix p, src;
+ struct prefix_ipv6 *src_p = NULL;
+ union g_addr gate;
+ union g_addr *gatep = NULL;
struct in_addr mask;
u_char flag = 0;
route_tag_t tag = 0;
- struct zebra_vrf *zvrf = NULL;
+ struct zebra_vrf *zvrf;
unsigned int ifindex = 0;
- const char *ifname = NULL;
- u_char type = STATIC_BLACKHOLE;
+ u_char type;
struct static_nh_label snh_label;
- memset(&snh_label, 0, sizeof(struct static_nh_label));
ret = str2prefix(dest_str, &p);
if (ret <= 0) {
vty_out(vty, "%% Malformed address\n");
return CMD_WARNING_CONFIG_FAILED;
}
- /* Cisco like mask notation. */
- if (mask_str) {
- ret = inet_aton(mask_str, &mask);
- if (ret == 0) {
- vty_out(vty, "%% Malformed address\n");
- return CMD_WARNING_CONFIG_FAILED;
+ switch (afi) {
+ case AFI_IP:
+ /* Cisco like mask notation. */
+ if (mask_str) {
+ ret = inet_aton(mask_str, &mask);
+ if (ret == 0) {
+ vty_out(vty, "%% Malformed address\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ p.prefixlen = ip_masklen(mask);
+ }
+ break;
+ case AFI_IP6:
+ /* srcdest routing */
+ if (src_str) {
+ ret = str2prefix(src_str, &src);
+ if (ret <= 0 || src.family != AF_INET6) {
+ vty_out(vty, "%% Malformed source address\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ src_p = (struct prefix_ipv6 *)&src;
}
- p.prefixlen = ip_masklen(mask);
+ break;
+ default:
+ break;
}
/* Apply mask for given prefix. */
@@ -119,6 +139,7 @@ int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
}
/* Labels */
+ memset(&snh_label, 0, sizeof(struct static_nh_label));
if (label_str) {
if (!mpls_enabled) {
vty_out(vty,
@@ -149,22 +170,15 @@ int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
}
/* Null0 static route. */
- if ((gate_str != NULL)
- && (strncasecmp(gate_str, "Null0", strlen(gate_str)) == 0)) {
+ if ((ifname != NULL)
+ && (strncasecmp(ifname, "Null0", strlen(ifname)) == 0)) {
if (flag_str) {
vty_out(vty, "%% can not have flag %s with Null0\n",
flag_str);
return CMD_WARNING_CONFIG_FAILED;
}
- if (add_cmd)
- static_add_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, ifname, ZEBRA_FLAG_BLACKHOLE,
- tag, distance, zvrf, &snh_label);
- else
- static_delete_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, tag, distance, zvrf,
- &snh_label);
- return CMD_SUCCESS;
+ SET_FLAG(flag, ZEBRA_FLAG_BLACKHOLE);
+ ifname = NULL;
}
/* Route flags */
@@ -184,70 +198,56 @@ int zebra_static_ipv4(struct vty *vty, safi_t safi, int add_cmd,
}
}
- if (gate_str == NULL) {
- if (add_cmd)
- static_add_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, ifname, flag, tag, distance,
- zvrf, &snh_label);
- else
- static_delete_route(AFI_IP, safi, type, &p, NULL, NULL,
- ifindex, tag, distance, zvrf,
- &snh_label);
-
- return CMD_SUCCESS;
+ if (gate_str) {
+ if (inet_pton(afi2family(afi), gate_str, &gate) != 1) {
+ vty_out(vty, "%% Malformed nexthop address %s\n",
+ gate_str);
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ gatep = &gate;
}
- /* When gateway is A.B.C.D format, gate is treated as nexthop
- address other case gate is treated as interface name. */
- ret = inet_aton(gate_str, &gate);
- if (!ret) {
- struct interface *ifp =
- if_lookup_by_name(gate_str, zvrf_id(zvrf));
+ if (ifname) {
+ struct interface *ifp;
+ ifp = if_lookup_by_name(ifname, zvrf_id(zvrf));
if (!ifp) {
- vty_out(vty, "%% Unknown interface: %s\n", gate_str);
+ vty_out(vty, "%% Malformed Interface name %s\n",
+ ifname);
ifindex = IFINDEX_DELETED;
} else
ifindex = ifp->ifindex;
- ifname = gate_str;
+ }
+
+ if (gate_str == NULL && ifname == NULL)
+ type = STATIC_BLACKHOLE;
+ else if (gate_str && ifname) {
+ if (afi == AFI_IP)
+ type = STATIC_IPV4_GATEWAY_IFINDEX;
+ else
+ type = STATIC_IPV6_GATEWAY_IFINDEX;
+ } else if (ifname)
type = STATIC_IFINDEX;
- } else
- type = STATIC_IPV4_GATEWAY;
+ else {
+ if (afi == AFI_IP)
+ type = STATIC_IPV4_GATEWAY;
+ else
+ type = STATIC_IPV6_GATEWAY;
+ }
- if (add_cmd)
- static_add_route(AFI_IP, safi, type, &p, NULL,
- ifindex ? NULL : (union g_addr *)&gate,
- ifindex, ifname, flag, tag, distance, zvrf,
- &snh_label);
+ if (!negate)
+ static_add_route(afi, safi, type, &p, src_p, gatep, ifindex,
+ ifname, flag, tag, distance, zvrf, &snh_label);
else
- static_delete_route(AFI_IP, safi, type, &p, NULL,
- ifindex ? NULL : (union g_addr *)&gate,
- ifindex, tag, distance, zvrf, &snh_label);
+ static_delete_route(afi, safi, type, &p, src_p, gatep, ifindex,
+ tag, distance, zvrf, &snh_label);
return CMD_SUCCESS;
}
/* Static unicast routes for multicast RPF lookup. */
-DEFUN (ip_mroute_dist,
+DEFPY (ip_mroute_dist,
ip_mroute_dist_cmd,
- "ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
- IP_STR
- "Configure static unicast route into MRIB for multicast RPF lookup\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "Nexthop address\n"
- "Nexthop interface name\n"
- "Distance\n")
-{
- char *destprefix = argv[2]->arg;
- char *nexthop = argv[3]->arg;
- char *distance = (argc == 5) ? argv[4]->arg : NULL;
-
- return zebra_static_ipv4(vty, SAFI_MULTICAST, 1, destprefix, NULL,
- nexthop, NULL, NULL, distance, NULL, NULL);
-}
-
-DEFUN (no_ip_mroute_dist,
- no_ip_mroute_dist_cmd,
- "no ip mroute A.B.C.D/M <A.B.C.D|INTERFACE> [(1-255)]",
+ "[no] ip mroute A.B.C.D/M$prefix <A.B.C.D$gate|INTERFACE$ifname> [(1-255)$distance]",
NO_STR
IP_STR
"Configure static unicast route into MRIB for multicast RPF lookup\n"
@@ -256,12 +256,9 @@ DEFUN (no_ip_mroute_dist,
"Nexthop interface name\n"
"Distance\n")
{
- char *destprefix = argv[3]->arg;
- char *nexthop = argv[4]->arg;
- char *distance = (argc == 6) ? argv[5]->arg : NULL;
-
- return zebra_static_ipv4(vty, SAFI_MULTICAST, 0, destprefix, NULL,
- nexthop, NULL, NULL, distance, NULL, NULL);
+ return zebra_static_route(vty, AFI_IP, SAFI_MULTICAST, no, prefix_str,
+ NULL, NULL, gate_str, ifname, NULL, NULL,
+ distance_str, NULL, NULL);
}
DEFUN (ip_multicast_mode,
@@ -357,270 +354,43 @@ DEFUN (show_ip_rpf_addr,
return CMD_SUCCESS;
}
-static void zebra_vty_ip_route_tdv_helper(int argc, struct cmd_token *argv[],
- int idx_curr, char **tag,
- char **distance, char **vrf,
- char **labels)
-{
- *distance = NULL;
- while (idx_curr < argc) {
- if (strmatch(argv[idx_curr]->text, "tag")) {
- if (tag)
- *tag = argv[idx_curr + 1]->arg;
- idx_curr += 2;
- } else if (strmatch(argv[idx_curr]->text, "vrf")) {
- if (vrf)
- *vrf = argv[idx_curr + 1]->arg;
- idx_curr += 2;
- } else if (strmatch(argv[idx_curr]->text, "label")) {
- if (labels)
- *labels = argv[idx_curr + 1]->arg;
- idx_curr += 2;
- } else {
- if (distance)
- *distance = argv[idx_curr]->arg;
- idx_curr++;
- }
- }
-
- return;
-}
-
/* Static route configuration. */
-DEFUN (ip_route,
+DEFPY (ip_route,
ip_route_cmd,
- "ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 2;
- int idx_ipv4_ifname_null = 3;
- int idx_curr = 4;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1,
- argv[idx_ipv4_prefixlen]->arg, NULL,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (ip_route_flags,
- ip_route_flags_cmd,
- "ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 2;
- int idx_reject_blackhole = 3;
- int idx_curr = 4;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(
- vty, SAFI_UNICAST, 1, argv[idx_ipv4_prefixlen]->arg, NULL, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance, vrf, NULL);
-}
-
-/* Mask as A.B.C.D format. */
-DEFUN (ip_route_mask,
- ip_route_mask_cmd,
- "ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4 = 2;
- int idx_ipv4_2 = 3;
- int idx_ipv4_ifname_null = 4;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (ip_route_mask_flags,
- ip_route_mask_flags_cmd,
- "ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4 = 2;
- int idx_ipv4_2 = 3;
- int idx_reject_blackhole = 4;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 1, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (no_ip_route,
- no_ip_route_cmd,
- "no ip route A.B.C.D/M <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
+ "[no] ip route\
+ <A.B.C.D/M$prefix|A.B.C.D$prefix A.B.C.D$mask>\
+ <\
+ {A.B.C.D$gate|INTERFACE$ifname}\
+ |null0$ifname\
+ |<reject|blackhole>$flag\
+ >\
+ [{\
+ tag (1-4294967295)\
+ |(1-255)$distance\
+ |vrf NAME\
+ |label WORD\
+ }]",
NO_STR
IP_STR
"Establish static routes\n"
"IP destination prefix (e.g. 10.0.0.0/8)\n"
- "IP gateway address\n"
- "IP gateway interface name\n"
- "Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 3;
- int idx_ipv4_ifname_null = 4;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0,
- argv[idx_ipv4_prefixlen]->arg, NULL,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (no_ip_route_flags,
- no_ip_route_flags_cmd,
- "no ip route A.B.C.D/M <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix (e.g. 10.0.0.0/8)\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4_prefixlen = 3;
- int idx_curr = 5;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0,
- argv[idx_ipv4_prefixlen]->arg, NULL, NULL,
- NULL, tag, distance, vrf, NULL);
-}
-
-DEFUN (no_ip_route_mask,
- no_ip_route_mask_cmd,
- "no ip route A.B.C.D A.B.C.D <A.B.C.D|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
"IP destination prefix\n"
"IP destination prefix mask\n"
"IP gateway address\n"
"IP gateway interface name\n"
"Null interface\n"
- "Tag of this route\n"
- "Tag value\n"
- "Distance value for this route\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv4 = 3;
- int idx_ipv4_2 = 4;
- int idx_ipv4_ifname_null = 5;
- int idx_curr = 6;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg,
- argv[idx_ipv4_ifname_null]->arg, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (no_ip_route_mask_flags,
- no_ip_route_mask_flags_cmd,
- "no ip route A.B.C.D A.B.C.D <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IP destination prefix\n"
- "IP destination prefix mask\n"
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n"
- "Tag of this route\n"
+ "Set tag for this route\n"
"Tag value\n"
"Distance value for this route\n"
- VRF_CMD_HELP_STR)
+ VRF_CMD_HELP_STR
+ MPLS_LABEL_HELPSTR)
{
- int idx_ipv4 = 3;
- int idx_ipv4_2 = 4;
- int idx_curr = 6;
- char *tag, *distance, *vrf;
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return zebra_static_ipv4(vty, SAFI_UNICAST, 0, argv[idx_ipv4]->arg,
- argv[idx_ipv4_2]->arg, NULL, NULL, tag,
- distance, vrf, NULL);
+ return zebra_static_route(vty, AFI_IP, SAFI_UNICAST, no, prefix,
+ mask_str, NULL, gate_str, ifname, flag,
+ tag_str, distance_str, vrf, label);
+ return 0;
}
/* New RIB. Detailed information for IPv4 route. */
@@ -1231,9 +1001,8 @@ static int do_show_ip_route(struct vty *vty, const char *vrf_name, afi_t afi,
}
if (use_json) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
+ vty_out(vty, "%s\n", json_object_to_json_string_ext(
+ json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
}
@@ -1621,9 +1390,8 @@ static void vty_show_ip_route_summary(struct vty *vty,
"FIB", zvrf_name(((rib_table_info_t *)table->info)->zvrf));
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
- if ((rib_cnt[i] > 0)
- || (i == ZEBRA_ROUTE_BGP
- && rib_cnt[ZEBRA_ROUTE_IBGP] > 0)) {
+ if ((rib_cnt[i] > 0) || (i == ZEBRA_ROUTE_BGP
+ && rib_cnt[ZEBRA_ROUTE_IBGP] > 0)) {
if (i == ZEBRA_ROUTE_BGP) {
vty_out(vty, "%-20s %-20d %-20d \n", "ebgp",
rib_cnt[ZEBRA_ROUTE_BGP],
@@ -1939,8 +1707,20 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
case STATIC_IFINDEX:
vty_out(vty, " %s", si->ifname);
break;
+ /* blackhole and Null0 mean the same thing */
case STATIC_BLACKHOLE:
- vty_out(vty, " Null0");
+ if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
+ vty_out(vty, " reject");
+ else
+ vty_out(vty, " Null0");
+ break;
+ case STATIC_IPV4_GATEWAY_IFINDEX:
+ vty_out(vty, " %s %s",
+ inet_ntop(AF_INET,
+ &si->addr.ipv4, buf,
+ sizeof buf),
+ ifindex2ifname(si->ifindex,
+ si->vrf_id));
break;
case STATIC_IPV6_GATEWAY_IFINDEX:
vty_out(vty, " %s %s",
@@ -1994,360 +1774,22 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
return write;
}
-/* General fucntion for IPv6 static route. */
-int static_ipv6_func(struct vty *vty, int add_cmd, const char *dest_str,
- const char *src_str, const char *gate_str,
- const char *ifname, const char *flag_str,
- const char *tag_str, const char *distance_str,
- const char *vrf_id_str, const char *label_str)
-{
- int ret;
- u_char distance;
- struct prefix p, src;
- struct prefix_ipv6 *src_p = NULL;
- struct in6_addr *gate = NULL;
- struct in6_addr gate_addr;
- u_char type = STATIC_BLACKHOLE;
- u_char flag = 0;
- route_tag_t tag = 0;
- unsigned int ifindex = 0;
- struct interface *ifp = NULL;
- struct zebra_vrf *zvrf;
- struct static_nh_label snh_label;
-
- ret = str2prefix(dest_str, &p);
- if (ret <= 0) {
- vty_out(vty, "%% Malformed address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- if (src_str) {
- ret = str2prefix(src_str, &src);
- if (ret <= 0 || src.family != AF_INET6) {
- vty_out(vty, "%% Malformed source address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- src_p = (struct prefix_ipv6 *)&src;
- }
-
- /* Apply mask for given prefix. */
- apply_mask(&p);
-
- /* Administrative distance. */
- if (distance_str)
- distance = atoi(distance_str);
- else
- distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
-
- /* tag */
- if (tag_str)
- tag = strtoul(tag_str, NULL, 10);
-
- /* When gateway is valid IPv6 addrees, then gate is treated as
- nexthop address other case gate is treated as interface name. */
- ret = inet_pton(AF_INET6, gate_str, &gate_addr);
-
- /* VRF id */
- zvrf = zebra_vrf_lookup_by_name(vrf_id_str);
-
- if (!zvrf) {
- vty_out(vty, "%% vrf %s is not defined\n", vrf_id_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- /* Labels */
- memset(&snh_label, 0, sizeof(struct static_nh_label));
- if (label_str) {
- if (!mpls_enabled) {
- vty_out(vty,
- "%% MPLS not turned on in kernel, ignoring command\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- int rc = mpls_str2label(label_str, &snh_label.num_labels,
- snh_label.label);
- if (rc < 0) {
- switch (rc) {
- case -1:
- vty_out(vty, "%% Malformed label(s)\n");
- break;
- case -2:
- vty_out(vty,
- "%% Cannot use reserved label(s) (%d-%d)\n",
- MPLS_MIN_RESERVED_LABEL,
- MPLS_MAX_RESERVED_LABEL);
- break;
- case -3:
- vty_out(vty,
- "%% Too many labels. Enter %d or fewer\n",
- MPLS_MAX_LABELS);
- break;
- }
- return CMD_WARNING_CONFIG_FAILED;
- }
- }
-
- /* Null0 static route. */
- if ((gate_str != NULL)
- && (strncasecmp(gate_str, "Null0", strlen(gate_str)) == 0)) {
- if (flag_str) {
- vty_out(vty, "%% can not have flag %s with Null0\n",
- flag_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
- if (add_cmd)
- static_add_route(AFI_IP6, SAFI_UNICAST, type, &p, src_p,
- NULL, ifindex, ifname,
- ZEBRA_FLAG_BLACKHOLE, tag, distance,
- zvrf, &snh_label);
- else
- static_delete_route(AFI_IP6, SAFI_UNICAST, type, &p,
- src_p, NULL, ifindex, tag, distance,
- zvrf, &snh_label);
- return CMD_SUCCESS;
- }
-
- /* Route flags */
- if (flag_str) {
- switch (flag_str[0]) {
- case 'r':
- case 'R': /* XXX */
- SET_FLAG(flag, ZEBRA_FLAG_REJECT);
- break;
- case 'b':
- case 'B': /* XXX */
- SET_FLAG(flag, ZEBRA_FLAG_BLACKHOLE);
- break;
- default:
- vty_out(vty, "%% Malformed flag %s \n", flag_str);
- return CMD_WARNING_CONFIG_FAILED;
- }
- }
-
- if (ifname) {
- /* When ifname is specified. It must be come with gateway
- address. */
- if (ret != 1) {
- vty_out(vty, "%% Malformed address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- type = STATIC_IPV6_GATEWAY_IFINDEX;
- gate = &gate_addr;
- ifp = if_lookup_by_name(ifname, zvrf_id(zvrf));
- if (!ifp) {
- vty_out(vty, "%% Malformed Interface name %s\n",
- ifname);
- return CMD_WARNING_CONFIG_FAILED;
- }
- ifindex = ifp->ifindex;
- } else {
- if (ret == 1) {
- type = STATIC_IPV6_GATEWAY;
- gate = &gate_addr;
- } else {
- type = STATIC_IFINDEX;
- ifp = if_lookup_by_name(gate_str, zvrf_id(zvrf));
- if (!ifp) {
- vty_out(vty, "%% Malformed Interface name %s\n",
- gate_str);
- ifindex = IFINDEX_DELETED;
- } else
- ifindex = ifp->ifindex;
- ifname = gate_str;
- }
- }
-
- if (add_cmd)
- static_add_route(AFI_IP6, SAFI_UNICAST, type, &p, src_p,
- (union g_addr *)gate, ifindex, ifname, flag,
- tag, distance, zvrf, &snh_label);
- else
- static_delete_route(AFI_IP6, SAFI_UNICAST, type, &p, src_p,
- (union g_addr *)gate, ifindex, tag,
- distance, zvrf, &snh_label);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (ipv6_route,
+DEFPY (ipv6_route,
ipv6_route_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6_ifname;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6_ifname = 5;
- idx_curr = 6;
- } else {
- src = NULL;
- idx_ipv6_ifname = 3;
- idx_curr = 4;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (ipv6_route_flags,
- ipv6_route_flags_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6_ifname;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6_ifname = 5;
- idx_reject_blackhole = 6;
- idx_curr = 7;
- } else {
- src = NULL;
- idx_ipv6_ifname = 3;
- idx_reject_blackhole = 4;
- idx_curr = 5;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (ipv6_route_ifname,
- ipv6_route_ifname_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6 = 3;
- int idx_interface = 4;
- int idx_curr = 5;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6 = 5;
- idx_interface = 6;
- idx_curr = 7;
- } else {
- src = NULL;
- idx_ipv6 = 3;
- idx_interface = 4;
- idx_curr = 5;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- NULL, tag, distance, vrf, NULL);
-}
-
-DEFUN (ipv6_route_ifname_flags,
- ipv6_route_ifname_flags_cmd,
- "ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 2;
- int idx_ipv6;
- int idx_interface;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[3]->text, "from")) {
- src = argv[4]->arg;
- idx_ipv6 = 5;
- idx_interface = 6;
- idx_reject_blackhole = 7;
- idx_curr = 8;
- } else {
- src = NULL;
- idx_ipv6 = 3;
- idx_interface = 4;
- idx_reject_blackhole = 5;
- idx_curr = 6;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 1, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (no_ipv6_route,
- no_ipv6_route_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE|null0> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
+ "[no] ipv6 route X:X::X:X/M$prefix [from X:X::X:X/M]\
+ <\
+ {X:X::X:X$gate|INTERFACE$ifname}\
+ |null0$ifname\
+ |<reject|blackhole>$flag\
+ >\
+ [{\
+ tag (1-4294967295)\
+ |(1-255)$distance\
+ |vrf NAME\
+ |label WORD\
+ }]",
NO_STR
- IP_STR
+ IPV6_STR
"Establish static routes\n"
"IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
"IPv6 source-dest route\n"
@@ -2355,171 +1797,17 @@ DEFUN (no_ipv6_route,
"IPv6 gateway address\n"
"IPv6 gateway interface name\n"
"Null interface\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6_ifname;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6_ifname = 6;
- idx_curr = 7;
- } else {
- src = NULL;
- idx_ipv6_ifname = 4;
- idx_curr = 5;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL, NULL, tag,
- distance, vrf, NULL);
-}
-
-DEFUN (no_ipv6_route_flags,
- no_ipv6_route_flags_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] <X:X::X:X|INTERFACE> <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Emit an ICMP unreachable when matched\n"
- "Silently discard pkts when matched\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6_ifname;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6_ifname = 6;
- idx_reject_blackhole = 7;
- idx_curr = 8;
- } else {
- src = NULL;
- idx_ipv6_ifname = 4;
- idx_reject_blackhole = 5;
- idx_curr = 6;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6_ifname]->arg, NULL,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
-}
-
-DEFUN (no_ipv6_route_ifname,
- no_ipv6_route_ifname_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
- "Set tag for this route\n"
- "Tag value\n"
- "Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
-{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6;
- int idx_interface;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6 = 6;
- idx_interface = 7;
- idx_curr = 8;
- } else {
- src = NULL;
- idx_ipv6 = 4;
- idx_interface = 5;
- idx_curr = 6;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- NULL, tag, distance, vrf, NULL);
-}
-
-DEFUN (no_ipv6_route_ifname_flags,
- no_ipv6_route_ifname_flags_cmd,
- "no ipv6 route X:X::X:X/M [from X:X::X:X/M] X:X::X:X INTERFACE <reject|blackhole> [tag (1-4294967295)] [(1-255)] [vrf NAME]",
- NO_STR
- IP_STR
- "Establish static routes\n"
- "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
- "IPv6 source-dest route\n"
- "IPv6 source prefix\n"
- "IPv6 gateway address\n"
- "IPv6 gateway interface name\n"
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n"
"Set tag for this route\n"
"Tag value\n"
"Distance value for this prefix\n"
- VRF_CMD_HELP_STR)
+ VRF_CMD_HELP_STR
+ MPLS_LABEL_HELPSTR)
{
- int idx_ipv6_prefixlen = 3;
- int idx_ipv6;
- int idx_interface;
- int idx_reject_blackhole;
- int idx_curr;
- char *src, *tag, *distance, *vrf;
-
- if (strmatch(argv[4]->text, "from")) {
- src = argv[5]->arg;
- idx_ipv6 = 6;
- idx_interface = 7;
- idx_reject_blackhole = 8;
- idx_curr = 9;
- } else {
- src = NULL;
- idx_ipv6 = 4;
- idx_interface = 5;
- idx_reject_blackhole = 6;
- idx_curr = 7;
- }
-
- tag = distance = vrf = NULL;
- zebra_vty_ip_route_tdv_helper(argc, argv, idx_curr, &tag, &distance,
- &vrf, NULL);
-
- return static_ipv6_func(vty, 0, argv[idx_ipv6_prefixlen]->arg, src,
- argv[idx_ipv6]->arg, argv[idx_interface]->arg,
- argv[idx_reject_blackhole]->arg, tag, distance,
- vrf, NULL);
+ return zebra_static_route(vty, AFI_IP6, SAFI_UNICAST, no, prefix_str,
+ NULL, from_str, gate_str, ifname, flag,
+ tag_str, distance_str, vrf, label);
}
DEFUN (show_ipv6_route,
@@ -3372,15 +2660,9 @@ void zebra_vty_init(void)
install_element(CONFIG_NODE, &allow_external_route_update_cmd);
install_element(CONFIG_NODE, &no_allow_external_route_update_cmd);
install_element(CONFIG_NODE, &ip_mroute_dist_cmd);
- install_element(CONFIG_NODE, &no_ip_mroute_dist_cmd);
install_element(CONFIG_NODE, &ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd);
install_element(CONFIG_NODE, &ip_route_cmd);
- install_element(CONFIG_NODE, &ip_route_flags_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_cmd);
- install_element(CONFIG_NODE, &ip_route_mask_flags_cmd);
- install_element(CONFIG_NODE, &no_ip_route_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_cmd);
install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd);
install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd);
@@ -3398,24 +2680,12 @@ void zebra_vty_init(void)
install_element(VIEW_NODE, &show_ip_rpf_cmd);
install_element(VIEW_NODE, &show_ip_rpf_addr_cmd);
- /* Commands for VRF */
-
- install_element(CONFIG_NODE, &no_ip_route_flags_cmd);
- install_element(CONFIG_NODE, &no_ip_route_mask_flags_cmd);
-
install_element(VIEW_NODE, &show_ip_route_vrf_all_addr_cmd);
install_element(VIEW_NODE, &show_ip_route_vrf_all_prefix_cmd);
install_element(VIEW_NODE, &show_ip_route_vrf_all_summary_cmd);
install_element(VIEW_NODE, &show_ip_route_vrf_all_summary_prefix_cmd);
install_element(CONFIG_NODE, &ipv6_route_cmd);
- install_element(CONFIG_NODE, &ipv6_route_flags_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_cmd);
- install_element(CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_flags_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_cmd);
- install_element(CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
install_element(CONFIG_NODE, &ip_nht_default_route_cmd);
install_element(CONFIG_NODE, &no_ip_nht_default_route_cmd);
install_element(CONFIG_NODE, &ipv6_nht_default_route_cmd);
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index d03caabfa6..c96f073064 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -903,10 +903,9 @@ static void zvni_mac_del_from_vtep(zebra_vni_t *zvni, int uninstall,
wctx.flags = DEL_REMOTE_MAC_FROM_VTEP;
wctx.r_vtep_ip = *r_vtep_ip;
- hash_iterate(
- zvni->mac_table,
- (void (*)(struct hash_backet *, void *))zvni_mac_del_hash_entry,
- &wctx);
+ hash_iterate(zvni->mac_table, (void (*)(struct hash_backet *,
+ void *))zvni_mac_del_hash_entry,
+ &wctx);
}
/*
@@ -927,10 +926,9 @@ static void zvni_mac_del_all(struct zebra_vrf *zvrf, zebra_vni_t *zvni,
wctx.upd_client = upd_client;
wctx.flags = flags;
- hash_iterate(
- zvni->mac_table,
- (void (*)(struct hash_backet *, void *))zvni_mac_del_hash_entry,
- &wctx);
+ hash_iterate(zvni->mac_table, (void (*)(struct hash_backet *,
+ void *))zvni_mac_del_hash_entry,
+ &wctx);
}
/*
@@ -1995,7 +1993,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp,
send_del = 1;
} else if (ext_learned)
/* The neighbor is remote and that is the notification we got.
- */
+ */
{
/* TODO: Evaluate if we need to do anything here. */
return 0;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index fb1ff74c28..3bc5f83f64 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -854,9 +854,8 @@ static int zserv_rnh_register(struct zserv *client, int sock, u_short length,
if (flags
&& !CHECK_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH))
SET_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH);
- else if (!flags
- && CHECK_FLAG(rnh->flags,
- ZEBRA_NHT_EXACT_MATCH))
+ else if (!flags && CHECK_FLAG(rnh->flags,
+ ZEBRA_NHT_EXACT_MATCH))
UNSET_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH);
}
@@ -2820,9 +2819,8 @@ DEFUN (show_zebra,
RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
{
struct zebra_vrf *zvrf = vrf->info;
- vty_out(vty,
- "%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64
- " %10" PRIu64 " %10" PRIu64 "\n",
+ vty_out(vty, "%-25s %10" PRIu64 " %10" PRIu64 " %10" PRIu64
+ " %10" PRIu64 " %10" PRIu64 "\n",
vrf->name, zvrf->installs, zvrf->removals,
zvrf->neigh_updates, zvrf->lsp_installs,
zvrf->lsp_removals);