Commit graph

79 commits

Author SHA1 Message Date
Louis Scalbert c7895ba320 Revert "ospfd: fix some dicey pointer arith in snmp module"
This reverts commit 438ef98701.

The previous code was correct even if the coverity scanner was
complaining.

Fixes: https://github.com/FRRouting/frr/issues/15680
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-04-23 11:36:14 +02:00
David Lamparter 8b23c0b0bd *: convert struct interface->connected to DLIST
Replace `struct list *` with `DLIST(if_connected, ...)`.

NB: while converting this, I found multiple places using connected
prefixes assuming they were IPv4 without checking:

- vrrpd/vrrp.c: vrrp_socket()
- zebra/irdp_interface.c: irdp_get_prefix(), irdp_if_start(),
  irdp_advert_off()

(these fixes are really hard to split off into separate commits as that
would require going back and reapplying the change but with the old list
handling)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-22 23:00:30 +01:00
Mark Stapp 438ef98701 ospfd: fix some dicey pointer arith in snmp module
Coverity reports some uses of 'oid *' as if they were 'char *';
try to correct that.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-09-21 10:46:02 -04:00
Renato Westphal f07ff222f8 ospfd: add support for NSSA Type-7 address ranges
Implement NSSA address ranges as specified by RFC 3101:

   NSSA border routers may be configured with Type-7 address ranges.
   Each Type-7 address range is defined as an [address,mask] pair.  Many
   separate Type-7 networks may fall into a single Type-7 address range,
   just as a subnetted network is composed of many separate subnets.
   NSSA border routers may aggregate Type-7 routes by advertising a
   single Type-5 LSA for each Type-7 address range.  The Type-5 LSA
   resulting from a Type-7 address range match will be distributed to
   all Type-5 capable areas.

Syntax:
  area A.B.C.D nssa range A.B.C.D/M [<not-advertise|cost (0-16777215)>]

Example:
  router ospf
   router-id 1.1.1.1
   area 1 nssa
   area 1 nssa range 172.16.0.0/16
   area 1 nssa range 10.1.0.0/16
  !

Since regular area ranges and NSSA ranges have a lot in common,
this commit reuses the existing infrastructure for area ranges as
much as possible to avoid code duplication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03:00
Donald Sharp cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp 29a1a53d6c ospfd: Remove MTYPE_TMP
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 11:43:57 -05:00
Donatas Abraitis 6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Donald Sharp abb1bf8d32 ospfd: Use AF_UNSPEC instead of setting to 0
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 13:20:43 -05:00
Donald Sharp b72aae2e04 *: Cleanup some documentation from quagga->frr
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 14:41:27 -05:00
rgirada 059fd3a48a ospfd: Adding apropriate ism state in ptop neighbors.
Description:
	In PointToPoint networks, There wont be DR and BDR.
	But by default, All neighbours ism state is shown as
	DR_OTHER.

	Changed the nbr state format to <nbrsate>/- (ex : FULL/-)
	to P2pnetworks.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-26 05:36:20 -07:00
David Lamparter 09781197b6 build: make builddir include path consistent
... by referencing all autogenerated headers relative to the root
directory.  (90% of the changes here is `version.h`.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:33 +02:00
Pat Ruddy 9e26322126 lib, bgpd: add a specific oid_copy function for IPv6 addrs
Do not overload the v4 oid_copy_addr function for ipv6
coverity does not like this kind of thing.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-03-25 15:24:50 +00:00
David Lamparter 80413c2073 *: require semicolon after FRR_DAEMON_INFO & co.
... again ...

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:39 +01:00
Donald Sharp 153bdb3d03 ospfd: ospf_nbr_nbma_lookup_next always returns NULL
The calling function of ospf_nbr_nbma_lookup_next calls
this function and then immediately returns when it
gets the NULL.  Just cleanup a bit more code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-28 14:56:11 -05:00
Donatas Abraitis 3a6290bdd1 *: Replace s_addr check agains 0 with INADDR_ANY
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-14 21:03:38 +02:00
Mark Stapp 96b663a381 ospfd: replace inet_ntoa
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 13:37:25 -04:00
Babis Chalios 8ab046a480 ospfd: fix invocation of ospfTrapNbrStateChange
ospfNbrStateChange is generated when the state of neighbor regresses or
it progresses to a terminal state. When transitioning to or from Full
state on non-broadcast multi-access and broadcast networks the trap
should be sent by the designated router. This last condition was not
taken into account when checking for the conditions of generating the
trap.

Fixes volta/volta-stack#1811

Signed-off-by: Babis Chalios <mail@bchalios.io>
2020-10-15 11:16:01 +02:00
Donald Sharp b2145a4004 ospfd: Fix possible null deref
It is possible that area is null, let's ensure it isn't.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-16 20:16:02 -04:00
Donatas Abraitis 0d6f7fd6fd *: Replace sizeof something to sizeof(something)
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis)

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-08 21:44:53 +02:00
Donatas Abraitis 15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Donatas Abraitis 752022670a *: Remove break after return
Just a deadcode.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-02-13 15:39:54 +02:00
Donald Sharp 45559c4dfe ospfd: nbr->oi is never null
We test nbr->oi in a couple of places for null, but
in the majority of places of the nbr->oi data is being
used we just access it.  Touch up code to trust this
assertion and make the code more consistent in others.

Found in Coverity.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-21 18:47:13 -05:00
Quentin Young 9165c5f5ff *: remove trailing newlines from zlog messages
Zlog puts its own newlines on, and doing this makes logs look nasty.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-03-14 18:41:15 +00:00
Quentin Young 97b5d752d7 *: use array_size instead of raw division
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:16 +00:00
David Lamparter 4f4060f6ab *: fix clang-6 SA warnings
I don't see these in CI, but my local clang-6 does emit warnings for
these.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 20:34:35 +02:00
Donald Sharp 19c0412aad ospfd: Remove unused function
The ospf_external_route_lookup function was not
being used so let's just remove it.

Unfortunately the removal was not quite so simple as
that ospf_asbr.h was being used to generate a reference
for the `struct ospf_route` data structure, so we
need to fix up the compile by fixing up header
inclusions so that ospf_route.h is actually included

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-21 08:40:51 -04:00
paco d11c6941dc
babeld, eigrpd, ospfd: unsigned negative check
After Cppcheck 1.72 feedback

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-18 19:07:24 +02:00
Quentin Young 7862377088 ospfd: remove unnecessary assignment
Not sure what's going on here but it doesn't need to be

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-17 13:58:24 -04:00
Quentin Young d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Lou Berger 996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00
Chirag Shah 05ba78e4d9 ospfd: Set filter to unbound debug logs
Ticket:CM-19213

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-12-27 10:13:38 -08:00
Chirag Shah b5a8894de6 ospfd: OSPFv2 VRF Support
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-10-03 09:15:19 -07:00
David Lamparter 9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22 14:52:33 +02:00
whitespace / reindent c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -04:00
whitespace / reindent d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
Quentin Young 56b4067930 *: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b

The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21 15:22:21 +00:00
David Lamparter 896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
David Lamparter 5986b66b82 *: snmp: convert into modules
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-25 08:52:36 +01:00
David Lamparter 3012671ffa *: use hooks for sending SNMP traps
This means there are no ties into the SNMP code anymore other than the
init call at startup.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-25 08:52:36 +01:00
David Lamparter 4525281af1 *: get rid of zlog(*, LOG_LEVEL, ...)
Result of running the following Coccinelle patch + fixups:
<<EOF
/* long-forms: zlog(NULL, <level>, ...)
 *    =>       zlog_level(...)
 */

@@
expression list args;
@@
- zlog(NULL, LOG_DEBUG, args)
+ zlog_debug(args)

@@
expression list args;
@@
- zlog(NULL, LOG_NOTICE, args)
+ zlog_notice(args)

@@
expression list args;
@@
- zlog(NULL, LOG_INFO, args)
+ zlog_info(args)

@@
expression list args;
@@
- zlog(NULL, LOG_WARNING, args)
+ zlog_warn(args)

@@
expression list args;
@@
- zlog(NULL, LOG_ERR, args)
+ zlog_err(args)

/* long-forms: zlog(base->log, <level>, ...)
 *    =>       zlog_level(...)
 */

@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_DEBUG, args)
+ zlog_debug(args)

@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_NOTICE, args)
+ zlog_notice(args)

@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_INFO, args)
+ zlog_info(args)

@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_WARNING, args)
+ zlog_warn(args)

@@
expression base;
expression list args;
@@
- zlog(base->log, LOG_ERR, args)
+ zlog_err(args)

EOF

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-03-08 00:15:39 +01:00
Paul Jakma b892f1ddfe *: use an ifindex_t type, defined in lib/if.h, for ifindex values
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-18 07:35:38 -04:00
David Lamparter c66f9c6186 *: get rid of "MTYPE 0"
A few places are using 0 in place of the MTYPE_* argument.  The
following rewrite of the alloc tracking won't deal with that, so let's
use MTYPE_TMP instead.

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[DL: v2: fix XFREE(0, foo) calls too]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-07-28 07:27:48 -04:00
David Lamparter 1c6f50bf2d *: snmp: add a load of "static" specifiers
Make it easier to see which bits in *_snmp.c are actually referenced
from non-SNMP parts of the code.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-07-28 07:27:47 -04:00
David Lamparter 19c3598b92 *: fix in_addr initialisers
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 5181a0296687a6004dd00c7c0874886c9ff0bf60)
2016-05-26 15:33:32 +00:00
Joakim Tjernlund 14fcc0e631 ospfd: ospf_nbr_nbma_set()/ospf_snmp_vl_add() add unlock
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Acked-by: Feng Lu <lu.feng@6wind.com>
(cherry picked from commit 4de398e3b676bcf041984e285dba12f229215419)
2016-05-26 15:33:31 +00:00
David Lamparter 7e6350359a snmp: fix warnings
batch-fix all warnings that come up when enabling AgentX SNMP support.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit dfee58f1d41a2e36c7f5f38a3ef5712224131824)
2016-05-26 15:33:29 +00:00
David Lamparter 6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

Patches can be adapted simply by:
	sed -e 's%^L%%' -i filename.patch
(you can type page feeds in some environments with Ctrl-V Ctrl-L)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-04 06:58:02 +02:00
Vincent Bernat 8046ba6ec4 snmp: let handlers accept OID from a lesser prefix
Most table handlers do not expect to be given an OID whose prefix is
outside what they can handle. This is not a problem with the SMUX
implementation since it always correct the OID such that the prefix
matches. However, this is not the case for the AgentX
implementation. A new function, smux_header_table() is used to do this
normalization.
2012-06-25 19:03:23 +02:00