Commit Graph

109 Commits

Author SHA1 Message Date
Philippe Guibert
f21536d2f0 bfd: add bfdd_privs to the bglobal structure
this structure contains the bfdd_privs structure in charge of the
privilege settings. The initialisation has moved a bit, in order that
the preinit settings are done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert
533ba31ff4 bfdd: show bfd [vrf NAME] peer command change
the vrf keyword is possible through show bfd command. However, there is
a change with previous version, since that show command was accepting
vrf keyword, only after peer keyword. Now, the vrf keyword is accepted,
but before peer keyword.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert
6f37416509 bfdd: add show bfd [vrf NAME] counters command
that command permits to filter bfd peer counter contexts per vrf.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert
9146cc2a10 bfdd: add show bfd [vrf NAME] peers command
this command permits to filter among the list of bfd peers which one is
to be displayed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert
5ef92a2b20 bfdd: avoid creating duplicate peer contexts
when configuring bfd peers, some parameters may or may not be taken into
account to search for a previous context. This has as consequence that
the result is different with the order of vty commands:

bfd
peer 4.5.6.7 vrf AAAA local-address 1.2.3.5
end
peer 4.5.6.7 vrf AAAA   <--- should not create new session
end

Similarly, the user thinks it has overwritten some key parameters like
local address, whereas it is wrong.
here, some informational message should be present.

bfd
peer 4.5.6.7 vrf AAAA
end
peer 4.5.6.7 vrf AAAA local-address 1.2.3.5
<--- should inform that the key lookup 1.2.3.5 is wrong
end

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:42 +02:00
Philippe Guibert
3e60827a3b bfdd: do not insert obs entry in the list, once disabled
the bfd entry has not to be inserted in the obs list again.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:54:30 +02:00
Philippe Guibert
b433551595 bfdd: check bfd on upon interface presence from separate vrf
if a separate vrf detects a new interface, then some bfd sessions may be
run.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:54:30 +02:00
Philippe Guibert
d24af713c1 bfdd: upon vrf enable/disable, update bs and obs list
parse observer list, and update bs context if vrf pointer is not yet populated.
this is helpful for validation, but also will permit bfd to send
notification to remote daemon.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:54:30 +02:00
Philippe Guibert
54aadda13d bfdd: register to interfaces from other vrfs
registration for new interfaces is done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:53:07 +02:00
Philippe Guibert
45b000d085 bfdd, zebra: pass the vrf identifier between zebra and bfdd
messages from daemons to bfd daemons go through zebra. zebra reuses the
vrf identifier to send messages to bfd.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:53:07 +02:00
Philippe Guibert
7bcadbaefe bfdd: socket handling per vrf context
sockets are created foreach network namespace context enabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
9fc0bc5cfc bfdd: add vrf framework
vrf initialisation is done. hooks are installed. no specific action is
done, except the vrf initialisation.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
1f4b73e54c bfdd: use vrf api for creation socket with binding with vrf lite
in the case vrf-lite is used, it is possible to call SO_BINDTODVICE, by
using vrf_socket() call.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
218afa3671 bfdd: permit to configure both iface and vrf
it is possible to configure both iface and vrfname. also, the
appropriate vrf is used, in case an iface is given.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
4e6b48d3db bfdd: add sys_admin capability and net_raw capability
in order to be able to create sockets on separate namespaces, add the
privs setting needed.
the former capability is needed to use SO_BINDTODEVICE option.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
e52a638341 bfdd: socket creation in a vrf can be done
vrf_socket() call is performed instead of socket() call.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
5764d816d3 bfdd: remove the constraint of bfd vrf and multihop
there is no specific constraints that should prevent from configuring a
multihop bfd session within a bfd session.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
bc50bcc83c bfdd: move bfd_ses_[xx] to bfd_sess_[xx] like other routines
this is a change to be more consistent with function naming convention
in bfd. a small change for 3 functions.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert
1ac865e7d4 bfdd: use logging convention for remaining zlog_debug
zlog_debug is being replaced with log_debug, because all bfdd code uses
that way of logging information.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Quentin Young
121f9dee7c *: use ZAPI_CALLBACK_ARGS macro for zapi handlers
This macro:
- Marks ZAPI callbacks for readability
- Standardizes argument names
- Makes it simple to add ZAPI arguments in the future
- Ensures proper types
- Looks better
- Shortens function declarations

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-03 20:57:35 +00:00
Russ White
a34fd5b9f1
Merge pull request #4155 from pguibert6WIND/bfd_increase_config
bfdd: avoid having bfd config inherited from operation context
2019-04-25 18:48:35 -04:00
Rafael Zalamena
545d3f7046 bfdd: fix UDP source port range
RFC 5881 Section 4 tells us that the BFD source port must be between
49152 and 65535 inclusive.

Spotted by Lucian Cristian.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-04-25 14:41:44 -03:00
Philippe Guibert
4c741971a5 bfdd: remove operational bfd sessions from remote daemons
when a remote daemon wants to get rid of a session, a request is sent,
but the deletion of the bfd session was not done. The flush is done,
provided that there is not someone else that is using that session.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-18 11:48:16 +02:00
Philippe Guibert
6bdb4a42ac bfdd: avoid having bfd config inherited from operation context
there are cases where bfd sessions are created from remote daemons. in
that case, the bfd daemon were appearing in both operational and
configuration contexts of bfd. Change that by only keeping operational
contexts.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-18 11:48:16 +02:00
Renato Westphal
84cffea04f
Merge pull request #4042 from donaldsharp/bfd_sa
bfdd: Clean up assignment without being used SA issue
2019-03-30 00:19:24 -03:00
Donald Sharp
9d6c33eadf bfdd, nhrpd, pimd: When deleting an interface clean up
When we delete an interface, we need to set the interface
ifindex to an internal value so that we don't end up in
a state where the re-addition of the same ifindex, due to
a rename operation, causes an infinite loop.

Fixes:#4007
Fix-Suggested-by: Saravanan K
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-29 12:44:05 -04:00
Donald Sharp
3cef9b7ffd bfdd: Clean up assignment without being used SA issue
Clang's SA is reporting that we have a assignment without
subsuquent use.  Modify the code such that we no-longer
do this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-29 11:35:07 -04:00
Donald Sharp
ed74032b7f bfdd: Prevent uninited use of data
Running valgrind w/ bfdd and shut/no shuting interfaces
can result in this valgrind issue:

==20279== Conditional jump or move depends on uninitialised value(s)
==20279==    at 0x115848: bfdd_sessions_enable_address (ptm_adapter.c:644)
==20279==    by 0x115848: bfdd_interface_address_update (ptm_adapter.c:674)
==20279==    by 0x48D8CAB: zclient_read (zclient.c:2698)
==20279==    by 0x48CCEE3: thread_call (thread.c:1603)
==20279==    by 0x48A84EF: frr_run (libfrr.c:1011)
==20279==    by 0x10DAC3: main (bfdd.c:236)
==20279==

When creating the bso data structure set the bso_isaddress to false
as a default value.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-20 10:32:58 -04:00
Rafael Zalamena
4cf4e83297 bfdd: fix echo loopback function
Add the address family to the sockaddr structure otherwise `sendmsg`
will fail with `EAFNOSUPPORT`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-19 17:25:00 -03:00
Rafael Zalamena
5ff7d1be75 bfdd: fix JSON API local-address translation
Get the local-address from the right key struct member.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-19 17:22:58 -03:00
Rafael Zalamena
261e0ba94d bfdd: don't enable sessions without local-address
When the local-address configured by the peer doesn't exist, then we
must observe the session until the mentioned address comes up.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-11 22:03:29 -03:00
Rafael Zalamena
79b4a6fceb bfdd: change session lookup data structure
Use simplier data structure key to avoid having to do complex and
error-prone key building (e.g. avoid expecting caller to know IPv6
scope id, interface index, vrf index etc...).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-11 22:03:23 -03:00
Rafael Zalamena
2435b7defe bfdd: fix single hop IPv6 configurations
Don't assume IPv6 will always be multi hop and handle the single hop
link-local address case.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-06 17:50:04 -03:00
Quentin Young
76f0146890 *: do not check XMALLOC / XCALLOC for null ret
They never return NULL

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:44 +00:00
Quentin Young
d8729f8cb5 *: use proper bool initializers & fix comparisons
- bools should be initialized with true/false
- bools do not need to be compared

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:16 +00:00
Tim Bray
e3b78da875 *: Rename backet to bucket
Presume typo from original author

Signed-off-by: Tim Bray <tim@kooky.org>
2019-02-25 16:22:36 +00:00
Rafael Zalamena
9f37770f59 bfdd: fix CI warnings
Fix a few checkpatch warnings and a clang analyzer warning of
uninitialized variable.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena
e945606e1e bfdd: fix discriminator mismatch log message
The discriminator is an unsigned 32bit variable.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena
0c1af3e49f bfdd: apply new timers on on-going connections
Apply new timers when only one side is negotiating new settings: when
sending the final bit we must apply the remote settings, otherwise
we'll keep the previous transmission rate.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena
33400b469e bfdd: header clean up
Remove some unused definitions in the bfd daemon header.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena
46c8ef96a3 bfdd: don't allow VRF for single hop session
Single hop sessions already allow you to select the interface, which
should be enough to determine the VRF we are running in.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena
d245e522f0 bfdd: implement session interface observer
Allow `bfdd` to configure inexisting interfaces / VRF and only activate
them once the interface/VRF start existing. This implementation doesn't
handle dynamic VRFs yet.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena
843b324ddd bfdd: generate random session identificators
This also avoids returning `session_id == 0` which should not happen.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
6f4beb7b30 bfdd: remove unused vrf/interface data structures
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
b333abc295 bfdd: refactor session lookup
Use internal data to lookup sessions. This approach has two main
advantages:

  * it uses less memory because it doesn't use strings for interface /
    vrf, it uses OS indexes instead;
  * prepares code to support VRF;

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
b912b189c7 bfdd: slow down on peer connection loss
Lets be more RFC 5880 compliant and slow down control packets on
connection loss.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
ff91bf7fb2 bfdd: don't try to start echo on protocol restart
`echo-mode` should and will automatically start after session goes up
and it is allowed by the remote peer. See `bs_echo_timer_handler` for
more information.

This avoids having echo controling code spread.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
1f2d5f91ee bfdd: change slow time value
Let's use the RFC 5880 suggested value of 1 second for slow
transmission speed.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
f43b93686f bfdd: simplify timer data structure
Remove some legacy left overs of the old timer data structure bits and
use a simpler version:

  We always keep the current configuration in the timer structure, but
  also keep the running timers (before poll transition) in
  `cur_timers`.

  With this we can remove `new_timers` and avoid timer copy
  configuration copy on final handler (this also simplifies peer
  show command).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena
f78dd3a793 bfdd: don't poll to make echo/multiplier changes
RFC 5880 says that it is only necessary to run polling in two cases:

  - Desired minimum transmission interval;
  - Required minimum receive interval;

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00