Commit graph

364 commits

Author SHA1 Message Date
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04:00
Donald Sharp 6a72124df9 babeld, lib, nhrpd: Add likely and unlikely macros
We have 2 competing versions of likely and unlikely
in babeld and nhrpd.  Standardize onto lower case
versions and consolidate in the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-23 07:54:56 -04:00
Donald Sharp d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
David Lamparter 637a914d19 nhrpd: drop peer references on freeing cache entry
When dropping an interface (e.g. at shutdown) while there are still
valid cache entries, the reference held on the cache entries' peer
pointers was leaking.

Fixes: #12505
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-19 12:38:49 +01: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
David Lamparter 47a3a82770 *: manual SPDX License ID conversions
The files converted in this commit either had some random misspelling or
formatting weirdness that made them escape automated replacement, or
have a particularly "weird" licensing setup (e.g. dual-licensed.)

This also marks a bunch of "public domain" files as SPDX License "NONE".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:07 +01:00
Donald Sharp d0038397b7 nhrpd: Add missing enum's to switch statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 15:15:42 -05:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Donald Sharp cf00164b69 *: Create and use infrastructure to show debugs in lib
There are lib debugs being set but never show up in
`show debug` commands because there was no way to show
that they were being used.  Add a bit of infrastructure
to allow this and then use it for `debug route-map`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-07 12:39:05 -04:00
Dmitrii Turlupov 8d1d3fdf7b nhrpd: Use nhrp_interface_update_nbma when source vrf was changed
1. Run frr:
interface enp0s8
 ip address 193.168.1.2/24
exit
!
interface gre1
 ip address 10.8.1.2/32
 ip nhrp network-id 1
 ip nhrp nhs dynamic nbma 193.168.1.1
 tunnel source enp0s8
exit

Log:

NHS: Register 10.8.1.2 -> 10.8.1.2 (timeout 2)
Send Registration-Request(3) 10.8.1.2 -> 10.8.1.2
Recv Registration-Reply(4) 10.8.1.1 -> 10.8.1.2

2. Create VRF and move enp0s8 to VRF
 ip link set enp0s8 master vrf1

Before patch:
NHS: Waiting link for 193.168.1.1

After patch:
NHS: Register 10.8.1.2 -> 10.8.1.2 (timeout 2)

Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2022-08-22 15:54:18 +03:00
Donald Sharp 7fc3f834e9 nhrpd: Use frr_weak_random()
Convert usage of rand() to frr_weak_random()

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-15 15:45:05 -04:00
Donatas Abraitis 47e1288431 *: Replace sockunion2str => %pSU
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21 13:34:56 +03:00
Donald Sharp 45f68cb8b4 nhrpd: r is always < 0 at some points of if else statements
Since r is always < 0 at the last if/else there is no point
in testing for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 16:31:35 -04: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
anlan_cs 8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
David Lamparter 5b4f4e626f build: first header *must* be zebra.h or config.h
This has already been a requirement for Solaris, it is still a
requirement for some of the autoconf feature checks to work correctly,
and it will be a requirement for `-fms-extensions`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04 18:33:10 +02:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Donatas Abraitis 3757f96485 bgpd,pimd,isisd,nhrpd: Convert to vty_json()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-31 21:20:41 +02:00
Igor Ryzhov 788a036fdb *: do not print vrf name for interface config when using vrf-lite
VRF name should not be printed in the config since 574445ec. The update
was done for NB config output but I missed it for regular vty output.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-24 14:44:05 +03:00
Igor Ryzhov ac2cb9bf94 *: rework renaming the default VRF
Currently, it is possible to rename the default VRF either by passing
`-o` option to zebra or by creating a file in `/var/run/netns` and
binding it to `/proc/self/ns/net`.

In both cases, only zebra knows about the rename and other daemons learn
about it only after they connect to zebra. This is a problem, because
daemons may read their config before they connect to zebra. To handle
this rename after the config is read, we have some special code in every
single daemon, which is not very bad but not desirable in my opinion.
But things are getting worse when we need to handle this in northbound
layer as we have to manually rewrite the config nodes. This approach is
already hacky, but still works as every daemon handles its own NB
structures. But it is completely incompatible with the central
management daemon architecture we are aiming for, as mgmtd doesn't even
have a connection with zebra to learn from it. And it shouldn't have it,
because operational state changes should never affect configuration.

To solve the problem and simplify the code, I propose to expand the `-o`
option to all daemons. By using the startup option, we let daemons know
about the rename before they read their configs so we don't need any
special code to deal with it. There's an easy way to pass the option to
all daemons by using `frr_global_options` variable.

Unfortunately, the second way of renaming by creating a file in
`/var/run/netns` is incompatible with the new mgmtd architecture.
Theoretically, we could force daemons to read their configs only after
they connect to zebra, but it means adding even more code to handle a
very specific use-case. And anyway this won't work for mgmtd as it
doesn't have a connection with zebra. So I had to remove this option.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-12-21 22:09:29 +03:00
Donatas Abraitis e2144103f8
Merge pull request #9878 from pguibert6WIND/resolver_vrf
lib: resolver per vrf support
2021-12-01 08:12:33 +02:00
Philippe Guibert c742573b67 lib: resolver per vrf support
add a parameter to resolver api that is the vrf identifier. this permits
to make resolution self to each vrf. in case vrf netns backend is used,
this is very practical, since resolution can happen on one netns, while
it is not the case in an other one.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-11-23 09:02:23 +01:00
Igor Ryzhov 096f7609f9 *: cleanup ifp->vrf_id
Since f60a1188 we store a pointer to the VRF in the interface structure.
There's no need anymore to store a separate vrf_id field.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22 20:47:23 +03:00
Donald Sharp 7cc91e67a3 *: Convert quagga_signal_X to frr_signal_X
Naming functions/data structures more appropriately for
the project we are actually in.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 14:41:27 -05:00
Russ White a2b52cbeb4
Merge pull request #9854 from opensourcerouting/zapi-call-table
*: convert zclient callbacks to table
2021-10-26 11:33:44 -04:00
Philippe Guibert db52be551b nhrpd: align nhrp privs with definition from others
nhrp_privs global context is aligned with other daemon contexts

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-10-21 13:49:38 +02:00
David Lamparter a243d1db93 *: convert zclient callbacks to table
This removes a giant `switch { }` block from lib/zclient.c and
harmonizes all zclient callback function types to be the same (some had
a subset of the args, some had a void return, now they all have
ZAPI_CALLBACK_ARGS and int return.)

Apart from getting rid of the giant switch, this is a minor security
benefit since the function pointers are now in a `const` array, so they
can't be overwritten by e.g. heap overflows for code execution anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-20 13:28:46 +02:00
David Lamparter 6a59615859 nhrpd: drop list.h
`number_of_linked_lists_in_frr--;`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:51 +02:00
David Lamparter f9aa07b1a8 nhrpd: convert zbuf queue to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:51 +02:00
David Lamparter b4f3d41bfd nhrpd: convert SA list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:51 +02:00
David Lamparter 811de44f34 nhrpd: convert reg list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:51 +02:00
David Lamparter db4db2bbda nhrpd: convert mcast list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:58:47 +02:00
David Lamparter 2ab2a76101 nhrpd: convert nhs list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:55:39 +02:00
David Lamparter 865bf787fa nhrpd: convert notifier list to DLIST
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-19 14:55:39 +02:00
Donatas Abraitis 56fb213493 nhrpd: Do not explicitly set the thread pointer to NULL
FRR should only ever use the appropriate THREAD_ON/THREAD_OFF
semantics.  This is espacially true for the functions we
end up calling the thread for.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-04 19:29:06 +03:00
Russ White 648c73647d
Merge pull request #9488 from pguibert6WIND/fix_nhrp_neigh_state
Fix nhrp neigh state
2021-08-27 19:00:45 -04:00
David Lamparter 8268be3d16
Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-arg
lib: remove unused argument from vrf_cmd_init
2021-08-27 10:39:45 +02:00
Christian Hopps d448e2c5f9
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
2021-08-26 11:57:33 -04:00
Igor Ryzhov cfc369c43a lib: remove unused argument from vrf_cmd_init
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 12:01:22 +03:00
Philippe Guibert c4e1fd52a1 nhrp, zebra, lib: pass exact received neighbor state value to nhrp
As NHRP expects some notification of neighboring entries on GRE
interface, when a new interface notification is encountered, the
exact neighbor state flag is found. Previously, the flag passed
to the upper layer was forced to NDM_STATE which is REACHABLE,
as can be seen on below trace:

2021/08/25 10:58:39 NHRP: [QQ0NK-1H449] Netlink: new-neigh 102.1.1.1 dev gre1 lladdr 10.125.0.2 nud 0x2 cache used 1 type 5

When passing the real value, NHRP received an other value like STALE.

2021/08/25 11:28:44 NHRP: [QQ0NK-1H449] Netlink: new-neigh 102.1.1.1 dev gre1 lladdr 10.125.0.2 nud 0x4 cache used 0 type 5

This flag is important for NHRP, as it permits to monitor the link
layer of NHRP entries.

Fixes: d603c0774e ("nhrp, zebra, lib: enforce usage of zapi_neigh_ip structure")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-26 09:19:42 +02:00
Donatas Abraitis d10bda270e *: Drop break after using frr_help_exit() in switch/case
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-25 10:49:05 +03:00
Igor Ryzhov 07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
Donald Sharp 2570a9f165
Merge pull request #8262 from reubendowle/fixes/nhrp-misc-fixes
nhrp misc fixes
2021-08-08 07:27:41 -04:00
Dmitrii Turlupov 7a807a20d9 nhrp: fix display of nhs command.
Before:
ip nhrp nhs dynamicnbma 192.168.1.1

After:
ip nhrp nhs dynamic nbma 192.168.1.1

Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2021-08-03 14:10:54 +03:00
Igor Ryzhov 9da01b0b7b *: cleanup interface node installation
The only difference in daemons' interface node definition is the config
write function. No need to define the node in every daemon, just pass
the callback as an argument to a library function and define the node
there.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-29 21:35:25 +03:00
Igor Ryzhov f5eef2d5a8 lib: remove vrf-interface config when removing the VRF
If we have the following configuration:
```
vrf red
 smth
 exit-vrf
!
interface red vrf red
 smth
```
And we delete the VRF using "no vrf red" command, we end up with:
```
interface red
 smth
```
Interface config is preserved but moved to the default VRF.

This is not an expected behavior. We should remove the interface config
when the VRF is deleted.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-21 18:04:46 +03:00
Amol Lad 2b55509d6c nhrpd: Clear cache when shortcuts are cleared
This is required because with the cache entry in place traffic will continue
via the shortcut path until the cache entry expires.

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-05-18 14:27:05 +12:00
Amol Lad 32dbbf1a10 nhrpd: Set prefix correctly in resolution request
RFC2332 requires prefix length be 0xFF only when uniqueness bit is set.

Without this change Cisco spokes will reject resolution request messages

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-05-18 14:27:05 +12:00
Reuben Dowle f07757ae1e nhrpd: Fix corrupt address being shown for shortcuts with no cache entry
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-05-18 14:27:05 +12:00
Mark Stapp 3d4b999fab
Merge pull request #8237 from pguibert6WIND/nhrp_use_zebra_2
Nhrp use zebra 2
2021-05-05 07:57:04 -04:00
Philippe Guibert dee1c6c338 nhrpd: move prototype to top of file
nhrp prototype function was not declared at top of the file.
fixing it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Philippe Guibert db51f0cd10 nhrp: Preserve mtu during interface up/down and tunnel source change
preserve mtu upon interface flapping and tunnel source change.

Signed-off-by:Reuben Dowle <reuben.dowle@4rf.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Philippe Guibert 372b887859 nhrpd: clean up SA warning with strncpy
strncpy is replaced by strlcpy.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Philippe Guibert aea6c49e01 nhrpd: cleaning netlink gre information
flush netlink related dependencies with gre information.
Add some linux headers required to compile with it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
Philippe Guibert 7f48cfa5e4 nhrpd: redirect netlink gre with zebra
as zebra has a new api to get gre and set gre source commands,
netlink gre get and netlink gre source function calls are redirected to zebra
by using the zapi interface.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-30 10:33:18 +02:00
David Lamparter 642ac49da4 *: remaining zassert => assert
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:25:51 +02:00
David Lamparter 6a0eb6885b *: drop zassert.h
It's not actually working properly...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-23 12:06:35 +02: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
Mark Stapp f5a1fb4f32 nhrpd: fix coverity warning about os_socket()
Ensure we don't try to use an invalid fd in nhrpd, reported
by coverity.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-04-14 09:57:41 -04:00
Jafar Al-Gharaibeh d75213d260
Merge pull request #8153 from reubendowle/nhrp-multicast
nhrp, ospf: add nhrp multicast for OSPF DMVPN
2021-04-13 12:49:28 -05:00
Philippe Guibert a8807299ef nhrpd: remove useless typedef
this typedef was useless. remote it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-13 08:58:54 +02:00
Philippe Guibert d603c0774e nhrp, zebra, lib: enforce usage of zapi_neigh_ip structure
zapi_nbr structure is renamed to zapi_neigh_ip.
Initially used to set a neighbor ip entry for gre interfaces, this
structure is used to get events from the zebra layer to nhrp layer.

The ndm state has been added, as it is needed on both sides.
The zebra dplane layer is slightly modified.

Also, to clarify what ZEBRA_NEIGH_ADD/DEL means, a rename is done:
it is called now ZEBRA_NEIGH_IP_ADD/DEL, and it signified that this
zapi interface permits to set link operations by associating ip
addresses to link addresses.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-13 08:58:49 +02:00
Philippe Guibert 850b2b70ac nhrp: avoid crashing when terminating interface contexts
avoid crashing when terminating interface contexts.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-12 19:23:57 +02:00
Philippe Guibert f468a45af2 nhrpd: add a zebra api to configure neighbor table per interface
neighbor table per interface is being configured per interface, via
zebra api.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-12 19:23:53 +02:00
Philippe Guibert 05657ec2b7 nhrp, lib, zebra: add/del neighbor entry possible from nhrp
a zebra api is extended to offer ability to add or remove neighbor
entry from daemon. Also this extension makes possible to add neigh
entry, not only between IPs and macs, but also between IPs and NBMA IPs.
This API supports configuring ipv6/ipv4 entries with ipv4/ipv6 lladdr.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert b3b7510464 nhrpd: link layer registration to notifications
neighbor notifications are done in zebra. so, instead of relying on
nhrp, rely on zebra by using zebra api interface.
Consequently, the code originally used in nhrp for netlink neighor
notification is no more used.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert e8263bdb77 nhrpd: use CALLOC instead of MALLOC
in order to apply a memset to a non initialised structure, use CALLOC
instead of MALLOC

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Philippe Guibert 4030737044 nhrpd: lookup appropriate ipsec path
lookup appropriate ipsec path. there are systems where the path where
the charon.vici file is not in standard paths. For that, 'ipsec
--piddir' may help in solving the path.

result of ipsec --piddir is as follow for example:
'
/etc/ike/ipsec.d/run
'

Note that the assumption is done that even if there are several
instances of strongswan across the vrfs, the charon.vici path file is
the same across vrfs. Consequently, as there is a thread per vrf that
performs vici initialisation, and file path retrieval is part of the
vici initialisation procedure, in order to avoid intempestive system
calls, use a boolean 'vici_charon_filepath_done' to avoid doing
unnecessary calls.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-04-09 18:29:58 +02:00
Reuben Dowle 46d3c1859b nhrpd: Change sockunion2str to %pSU in a few places
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-08 08:45:51 +12:00
Donald Sharp 2a1fa50ecf nhrpd: Fixup tab usage and sockunion2str usage
For some reason the usage of tabs in a string snuck in as well
as using a sockunion2str instead of %pSU.  Fix.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-06 10:09:48 -04:00
Reuben Dowle c2bb9917b1 nhrpd: Fix style issues
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle 4946316150 nhrpd: Add missing semicolon
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle 32ff81f6c9 nhrpd: Improve debug message for multicast interception
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle 63c0a73559 nhrpd: Cleanup multicast nflog handler function
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Amol Lad 9084e20961 nhrpd: Introduce new - nflog mutlicast-nflog-group (1-65535) - command
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle 9f7f6d3c6b nhrpd: Use ethertype defines instead of hard-coded values
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle ca317495b8 nhrpd: Use strlcpy not unsafe strncpy
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle 0f8595a9f4 nhrpd: Fix style violation issues
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:23:42 +12:00
Reuben Dowle 4f7a37ace3 nhrpd: Use correct printf format specifier
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:22:59 +12:00
Reuben Dowle 0da7701aa2 nhrpd: Fix multicast crash due to dangling references to nhrp peers
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:22:59 +12:00
Amol Lad fa31fcf2ea nhrpd: Add support for forwarding multicast packets
Forwarding multicast is a pre-requisite for allowing multicast based routing
protocols such as OSPF to work with DMVPN

This code relies on externally adding iptables rule. For example:
iptables -A OUTPUT -d 224.0.0.0/24 -o gre1 -j NFLOG --nflog-group 224

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-06 09:22:59 +12:00
Jafar Al-Gharaibeh 283981e4a7
Merge pull request #8240 from reubendowle/fixes/nhrp-nat
nhrp: NAT fixes
2021-04-03 22:37:25 -05:00
Reuben Dowle ba113ac64e nhrpd: Fix memory leak in error path when forwarding packets
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-01 14:52:15 +13:00
Reuben Dowle d0c9d09aa9 nhrpd: Ensure invalid pointer is not used if two NAT extensions received
Also cleanup some minor style issues

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-04-01 14:06:24 +13:00
Philippe Guibert 0551aeadff nhrpd: Make some debug prints more informative
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-29 10:21:16 +13:00
Amold Lad bcf5673d61 nhrpd: Display post-nat NBMA for local addresses
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-29 10:17:19 +13:00
Reuben Dowle 6baf035ce3 nhrpd: Remove unecessary new line from debug messages
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-29 10:17:18 +13:00
Donatas Abraitis 37916b2b11
Merge pull request #8121 from opensourcerouting/macro-cleanup
*: require ISO C11 + semicolons after file-scope macros
2021-03-22 11:00:34 +02:00
Reuben Dowle 4ddc702ad2 nhrpd: Use %pSU instead of sockunion2str
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-19 19:10:53 +13:00
Reuben Dowle 00683a1479 nhrpd: Fix some style issues
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-19 09:31:45 +13:00
Donald Sharp dccd71c182 nhrpd: Remove newline from log message
We should not be putting new lines in log messages.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-18 10:32:01 -04:00
Amol Lad e8089de123 nhrpd: Set prefix length in NAT extension in resolution-reply
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Reuben Dowle 9025515c25 nhrpd: Ensure invalid NAT extension info cannot be used
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Reuben Dowle 18cc9c4293 nhrpd: Use SU_ADDRSTRLEN where appropriate
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Amol Lad 611915ae89 nhrpd: populate correct prefix length in NAT extension in Reg-Reply
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Amol Lad 85365e51f0 nhrpd: Add Claimed NBMA field in sh ip nhrp cache output
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Amol Lad 94eae49d01 nhrpd: add NHS details in NAT Extension header
Hub uses this to check if is itself behind a NAT

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Amol Lad 1bd508da17 nhrpd: copy NAT extension if present else attempt to populate
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Amol Lad 9c292647a9 nhrpd: parse multiple CIEs in NAT extension header
Cisco devices send can send multiple CIEs so we must search for the correct CIE

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00
Amol Lad 5e70e83b9e nhrpd: Add empty NAT extension header for Non Natted Spoke in Resolution-Reply
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
2021-03-18 16:35:41 +13:00