]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
5 years agodoc: change vrrp to listen on port 2619
Quentin Young [Mon, 15 Apr 2019 22:15:28 +0000 (22:15 +0000)]
doc: change vrrp to listen on port 2619

2617 was taken by BFD while VRRP was indev.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: include vrrp_packet.h in subdir.am
Quentin Young [Mon, 25 Mar 2019 21:18:06 +0000 (21:18 +0000)]
vrrpd: include vrrp_packet.h in subdir.am

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: display configured adv int in json output
Quentin Young [Wed, 20 Mar 2019 04:55:35 +0000 (04:55 +0000)]
vrrpd: display configured adv int in json output

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: change all user facing times to ms
Quentin Young [Wed, 20 Mar 2019 04:50:22 +0000 (04:50 +0000)]
vrrpd: change all user facing times to ms

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: tweak startup criteria for v6 VRRP router
Quentin Young [Fri, 15 Mar 2019 19:54:37 +0000 (19:54 +0000)]
vrrpd: tweak startup criteria for v6 VRRP router

* Remove check for having at least 2 IPv6 addresses on the macvlan
  device; this was only taking place in v6, and breaking the ability to
  start VRRP on an IPv6 macvlan that was already set to protodown on
* Improve log messaging indicating that we cannot start because we
  haven't got any VIPs configured

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agozebra: don't protodown a NULL interface
Quentin Young [Thu, 14 Mar 2019 19:51:32 +0000 (19:51 +0000)]
zebra: don't protodown a NULL interface

We were running into some problems where VRRP is trying to protodown
interfaces that no longer exist. While this is a minor bug in its own
right, this was crashing Zebra because Zebra was not doing a null check
after its ifindex lookup.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add asserts for VRRPv2 and IPv6
Quentin Young [Thu, 14 Mar 2019 15:56:39 +0000 (15:56 +0000)]
vrrpd: add asserts for VRRPv2 and IPv6

Disallow adding IPv6 addresses to VRRPv2 routers.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: do not start v6 router if using VRRPv2
Quentin Young [Thu, 14 Mar 2019 15:54:49 +0000 (15:54 +0000)]
vrrpd: do not start v6 router if using VRRPv2

v2 doesn't support IPv6.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: make useless assert useful
Quentin Young [Thu, 14 Mar 2019 15:43:22 +0000 (15:43 +0000)]
vrrpd: make useless assert useful

Assert would always come back true due to improper placement.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: late bind to Tx address
Quentin Young [Thu, 14 Mar 2019 15:18:20 +0000 (15:18 +0000)]
vrrpd: late bind to Tx address

Stupid stupid stupid. I can just bind to the Tx address right before I
Tx, since if I've gotten there I know my link is up.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix v2 master_down_interval computation
Quentin Young [Wed, 13 Mar 2019 18:37:48 +0000 (18:37 +0000)]
vrrpd: fix v2 master_down_interval computation

VRRPv2 uses the configured advertisement interval to compute the master
down timer, whereas VRRPv3 uses the one advertised by the master. Fix
computation to use the configured in in v2.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: include auth fields in v2 packet
Quentin Young [Wed, 13 Mar 2019 17:18:36 +0000 (17:18 +0000)]
vrrpd: include auth fields in v2 packet

Based on looking at other vendors, seems I misinterpreted the RFC - type
0 auth (no authentication) still requires the authentication fields to
be present, just set to all zero.

This should fix VRRPv2 interop with other vendors.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: allow centisecond precision for vrrpv2
Quentin Young [Tue, 12 Mar 2019 17:31:39 +0000 (17:31 +0000)]
vrrpd: allow centisecond precision for vrrpv2

The RFC is not clear about how precise the skew time calculation should
be in VRRPv2. The advertisement interval is given in seconds, and the
field in the advertisement packet only supports non-fractional seconds,
so I was following this for calculating skew time as well. However the
skew time formula in vrrpv2 always yields a fractional amount of seconds
in the range (0-1), which right now means we always truncate to 0
seconds. I doubt this is what the RFC wanted so I'm allowing centisecond
precision for skew time.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: display primary address in json output
Quentin Young [Fri, 8 Mar 2019 18:52:56 +0000 (18:52 +0000)]
vrrpd: display primary address in json output

And also, fill in the non-json output with a :: for the v6 primary since
we're letting the operating system select which one it wants to use and
we don't actually know what our primary address is. Another thing to
revisit in the future...

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agoRevert "Revert "vrrpd: protodown mvlans when shutting down""
Quentin Young [Fri, 8 Mar 2019 18:35:04 +0000 (18:35 +0000)]
Revert "Revert "vrrpd: protodown mvlans when shutting down""

Now that the requirement of knowing our VRRP IPv6 primary address in
advance is lifted, it's no problem for us that the macvlans could be
down when we get them. We can handle this in both the v4 and v6 case
now, so we don't need to behave as if they should always be left up.

This reverts commit 6eae67dabcbc31a2117ce3847c18ac52b3b76b1e.

5 years agovrrpd: allow OS to choose VRRP IPv6 src address
Quentin Young [Fri, 8 Mar 2019 18:30:03 +0000 (18:30 +0000)]
vrrpd: allow OS to choose VRRP IPv6 src address

Under IPv6, Linux will look at our destination address and select the
source address with the smallest scope that covers the destination. For
the VRRP multicast address ff02::12, Linux will always select a link
local address.

We can take advantage of this behavior to avoid a subtle and complicated
class of bugs caused by Zebra's semantics around inoperative interfaces.
As far as Zebra is concerned, an inoperative interface has no addresses
assigned to it. This is a real bummer for VRRP because it's quite
possible that the IPv6 VRRP macvlan device is down when we attach to it,
and we would really like to be able to know in advance which address we
will be transmitting IPv6 advertisements from without having to bring an
interface up to convince Zebra to tell us its address list.

In the future, though, it would be better to be explicit about selecting
the link local we want. This will require adding the ability to Zebra to
read and send us address information for inoperative interfaces.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agoRevert "vrrpd: protodown mvlans when shutting down"
Quentin Young [Thu, 7 Mar 2019 21:18:03 +0000 (21:18 +0000)]
Revert "vrrpd: protodown mvlans when shutting down"

This reverts commit 9ed05814d5451379d37b6b3382b5b886afa1230f

5 years agovrrpd: protodown mvlans when shutting down
Quentin Young [Thu, 7 Mar 2019 19:14:14 +0000 (19:14 +0000)]
vrrpd: protodown mvlans when shutting down

This way VMACs get uninstalled from any lower-layer hardware.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: clean up logging
Quentin Young [Thu, 7 Mar 2019 18:46:02 +0000 (18:46 +0000)]
vrrpd: clean up logging

* Always include address family when available
* Log advertisement decodes on one line

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agoRevert "vrrpd: use parent interface LLA for advert tx"
Quentin Young [Wed, 6 Mar 2019 20:00:57 +0000 (20:00 +0000)]
Revert "vrrpd: use parent interface LLA for advert tx"

This reverts commit 23e1accb0b083713ee7b0ef7fb08a0c47d4bbc85.

This bug has now been fixed by preconfiguring the VRRP macvlan
interfaces to use addrgenmode random instead of eui64.

5 years agovrrpd: disallow setting priority = 255
Quentin Young [Wed, 6 Mar 2019 18:34:34 +0000 (18:34 +0000)]
vrrpd: disallow setting priority = 255

Assuming we fix our automatic detection method in the future, we won't
be able to revert this back to disallowing 255 without breaking user
configs. Let's just disallow it now, there's no functional difference
still.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix broken reads when reinitializing
Quentin Young [Tue, 5 Mar 2019 20:33:27 +0000 (20:33 +0000)]
vrrpd: fix broken reads when reinitializing

When a VRRP router was shut down - either due to an administrative
event, or its interface getting deleted, or some other reason - it was
forgetting to cancel its read task. When it was started again, the read
task was still around, and so it wasn't getting scheduled again with the
new socket fd's. This caused our socket to queue ingress packets but
never read them, resulting in the restarted router always electing
itself to Master (since it wasn't listening to any other advertisements,
even though the kernel was delivering them).

The t_write cancellation call doesn't matter here, but I'm putting it in
there because it doesn't hurt and this way I won't forget about it if it
becomes necessary in the future.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovtysh: don't sort vrrp interface config
Quentin Young [Tue, 5 Mar 2019 18:57:14 +0000 (18:57 +0000)]
vtysh: don't sort vrrp interface config

It is order dependent

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix debug message = -> <=
Quentin Young [Tue, 5 Mar 2019 18:38:20 +0000 (18:38 +0000)]
vrrpd: fix debug message = -> <=

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: delay sending advert/garp/una for ifup pt 2
Quentin Young [Mon, 4 Mar 2019 20:15:25 +0000 (20:15 +0000)]
vrrpd: delay sending advert/garp/una for ifup pt 2

Pt 2: When transitioning directly into Master (because we are the
address owner), wait until Zebra sets the macvlan device to protodown
off before transmitting advertisements, gratuitous ARPs, or Unsolicited
Neighbor Advertisements.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: delay sending adverts/garp/una for iface up
Quentin Young [Mon, 4 Mar 2019 18:46:08 +0000 (18:46 +0000)]
vrrpd: delay sending adverts/garp/una for iface up

When transitioning to Master from Backup, wait until Zebra sets the
macvlan device to protodown off before transmitting advertisements,
gratuitous ARPs, or Unsolicited Neighbor Advertisements.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: allow user to set priority = 255
Quentin Young [Mon, 4 Mar 2019 17:27:55 +0000 (17:27 +0000)]
vrrpd: allow user to set priority = 255

Too many problems with implicit ownership determination via duplicate
address assignment. Will revisit that in the future. For now, allow user
to specify 255 as a priority value. This is functionally no different
than any other priority value; it just serves as a self-documenting way
of saying you want one router to always be master.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix sign compare on armel
Quentin Young [Fri, 1 Mar 2019 17:11:06 +0000 (17:11 +0000)]
vrrpd: fix sign compare on armel

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix interface block config writes
Quentin Young [Thu, 28 Feb 2019 23:48:09 +0000 (23:48 +0000)]
vrrpd: fix interface block config writes

Improper reuse of list node broke config writes of multiple instances

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix autoconfig of protodown'd interfaces
Quentin Young [Thu, 28 Feb 2019 23:13:20 +0000 (23:13 +0000)]
vrrpd: fix autoconfig of protodown'd interfaces

When autoconfiguring VRRP, interfaces that are protodown'd should be
automatically brought up. Otherwise Zebra won't send us their interface
addresses and we'll sit in Initialize forever.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add more debugging info
Quentin Young [Thu, 28 Feb 2019 22:12:23 +0000 (22:12 +0000)]
vrrpd: add more debugging info

* Add reason why we are discarding adverts
* Add primary IP to show vrrp output

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix unsigned - signed cmp
Quentin Young [Thu, 28 Feb 2019 21:41:21 +0000 (21:41 +0000)]
vrrpd: fix unsigned - signed cmp

For some reason this warning only shows up on armel

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: check start for manual v6 addr add
Quentin Young [Thu, 28 Feb 2019 20:47:04 +0000 (20:47 +0000)]
vrrpd: check start for manual v6 addr add

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: use parent interface LLA for advert tx
Quentin Young [Thu, 28 Feb 2019 19:00:26 +0000 (19:00 +0000)]
vrrpd: use parent interface LLA for advert tx

Interface MACs for v6 macvlan devices are the same, so the link local
address will be the same, which breaks mastership election based on
primary address comparison. Use the parent interface link local address.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: only update one vrrp_router list at a time
Quentin Young [Thu, 28 Feb 2019 18:25:39 +0000 (18:25 +0000)]
vrrpd: only update one vrrp_router list at a time

When using an autoconfigured VRRP instance, when an interface address
was added or deleted we were trying to update the address list for both
v4 and v6 vrrp_router's which sometimes would cause all the addresses to
get deleted off of one of them and result in an automatic shutdown.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: set autoconfed VRRP ifaces protodown off
Quentin Young [Wed, 27 Feb 2019 22:46:24 +0000 (22:46 +0000)]
vrrpd: set autoconfed VRRP ifaces protodown off

If we just detected a macvlan and used it to automatically create an
interface, set that interface into protodown off. This way users don't
have to manually bring the interface back up in order to get autoconfig
to work again.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix bad fmt specifiers in dgram validator
Quentin Young [Wed, 27 Feb 2019 22:07:58 +0000 (22:07 +0000)]
vrrpd: fix bad fmt specifiers in dgram validator

They used a %u where they should have used a PRIu16, and a %lu where
they wanted a %zu. Shame!

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: log why vrouter could not be started
Quentin Young [Wed, 27 Feb 2019 20:56:33 +0000 (20:56 +0000)]
vrrpd: log why vrouter could not be started

If we do a checkstart and cannot start the VRRP router, log the reason
why for debugging purposes.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: be less smart about interface state
Quentin Young [Wed, 27 Feb 2019 20:46:35 +0000 (20:46 +0000)]
vrrpd: be less smart about interface state

Stop caring about interface state so much. It's screwing up autoconfig
because Zebra's message semantics are pretty much absolute nonsense when
it comes to indicating interface state.

This change will cause us to do things like attempt to transmit
advertisements on a down interface, but I'd rather have the user see
those error messages in the log file than force them to fight vrrpd to
convince it that, yes, they actually do want a VRRP instance created.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: style cleanup
Quentin Young [Tue, 26 Feb 2019 18:49:11 +0000 (18:49 +0000)]
vrrpd: style cleanup

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: allow configuring global defaults
Quentin Young [Mon, 25 Feb 2019 21:43:36 +0000 (21:43 +0000)]
vrrpd: allow configuring global defaults

Allow configuring the following as global defaults:

- Priority
- Advertisement interval
- Preempt mode
- Administrative shutdown

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add statistics collection
Quentin Young [Fri, 22 Feb 2019 18:51:38 +0000 (18:51 +0000)]
vrrpd: add statistics collection

Collect and display the following:
- Advertisement Tx/Rx
- GARP Tx/Rx
- NDISC Tx/Rx
- # transitions

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: follow frrouting json conventions
Quentin Young [Fri, 22 Feb 2019 18:51:10 +0000 (18:51 +0000)]
vrrpd: follow frrouting json conventions

Use camelCase for json keys

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: do not transition to backup on ifdown
Quentin Young [Thu, 21 Feb 2019 22:42:55 +0000 (22:42 +0000)]
vrrpd: do not transition to backup on ifdown

Transitioning to backup on an interface down causes all sorts of
problems when it comes back up, not least of which is breaking preempt
mode.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: stop session before nulling iface
Quentin Young [Thu, 21 Feb 2019 16:36:58 +0000 (16:36 +0000)]
vrrpd: stop session before nulling iface

When an interface is deleted from the system, stop any attached VRRP
sessions before nulling out the interface fields.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: cleanup formatting for vty show cmd
Quentin Young [Wed, 20 Feb 2019 19:07:13 +0000 (19:07 +0000)]
vrrpd: cleanup formatting for vty show cmd

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add json support to show command
Quentin Young [Wed, 20 Feb 2019 19:06:49 +0000 (19:06 +0000)]
vrrpd: add json support to show command

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agolib: add more convenient boolean adder for json
Quentin Young [Wed, 20 Feb 2019 19:04:34 +0000 (19:04 +0000)]
lib: add more convenient boolean adder for json

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: default to accept mode = true
Quentin Young [Tue, 19 Feb 2019 23:42:06 +0000 (23:42 +0000)]
vrrpd: default to accept mode = true

We have no facilities to enforce accept mode = false yet so this is
updated to reflect the actual state of the system.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add administrative shutdown option
Quentin Young [Tue, 19 Feb 2019 23:39:42 +0000 (23:39 +0000)]
vrrpd: add administrative shutdown option

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: don't update interface addrs on ifup
Quentin Young [Tue, 19 Feb 2019 22:36:34 +0000 (22:36 +0000)]
vrrpd: don't update interface addrs on ifup

Updating interface addresses on autoconfigured VRRP instances when we
receive notification that an interface is up will cause us to delete
that VRRP instance because Zebra deletes all interface addresses when an
interfaces goes down so when it comes back up it has no addresses which
causes us to delete the instance, then Zebra subsequently sends us the
addresses which causes the instance to get recreated, however in a
non-owner scenario this will merely cause us to start in Backup, wait a
while, transition to Master, protodown off our interface, get an
interface up notification, delete all our ip addresses, destroy
ourselves, receive address notifications, recreate ourselves, reenter
Backup and cycle through it all over again.

So we just have to assume that no addresses went away since this
interface was last up.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: use if_is_operative()
Quentin Young [Tue, 19 Feb 2019 22:01:35 +0000 (22:01 +0000)]
vrrpd: use if_is_operative()

Checks for interface usability instead of admin state, which is what I
wanted anyway. Also removes the operstate check when binding interfaces.
This way we can bind currently inoperative interfaces, won't start until
they're at least admin up, but *will* start if they're carrier down,
because we can fix that (and probably caused it :)

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: enable vrrp zebra debugging
Quentin Young [Tue, 19 Feb 2019 21:08:36 +0000 (21:08 +0000)]
vrrpd: enable vrrp zebra debugging

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: ignore address deletion if iface is down
Quentin Young [Tue, 19 Feb 2019 20:11:04 +0000 (20:11 +0000)]
vrrpd: ignore address deletion if iface is down

See code comment for explanation

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: check for v6 link-local before starting
Quentin Young [Fri, 15 Feb 2019 22:40:31 +0000 (22:40 +0000)]
vrrpd: check for v6 link-local before starting

Having a v6 link-local is a precondition for starting a v6 VRRP router;
check that we do.

Also add some helpful comments to the check-start function because good
lord that thing is getting unwieldy.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: tweak interface tracking on ifdown
Quentin Young [Fri, 15 Feb 2019 19:32:08 +0000 (19:32 +0000)]
vrrpd: tweak interface tracking on ifdown

Change the interface tracking code to react to an interface down by
automatically transitioning to Backup, instead of shutting down the
session. This is because we get ZEBRA_INTERFACE_DOWN messages when we
set an interface to protodown as part of transitioning to Backup; if we
shut down the session in response to these messages, we end up shutting
ourselves down every time we try to transition to Backup.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: only bind to link locals for v6 adverts
Quentin Young [Thu, 14 Feb 2019 23:40:20 +0000 (23:40 +0000)]
vrrpd: only bind to link locals for v6 adverts

Was missing a check to make sure that the v6 address we select as the
source IP for advertisements was a link local address

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: interface tracking
Quentin Young [Thu, 14 Feb 2019 22:28:51 +0000 (22:28 +0000)]
vrrpd: interface tracking

* Dynamically bind interfaces when they become available
* Automatically start VRRP sessions when their interfaces are added or
  come up
* Automatically shut down VRRP sessions when their interfaces are
  deleted or go down
* Automatically unbind interfaces when they are deleted

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: better messaging for interface binds
Quentin Young [Wed, 13 Feb 2019 22:37:41 +0000 (22:37 +0000)]
vrrpd: better messaging for interface binds

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: skip binding interface after create
Quentin Young [Wed, 13 Feb 2019 22:16:56 +0000 (22:16 +0000)]
vrrpd: skip binding interface after create

When automatically creating new VRRP instances, we don't need to try to
bind them to macvlan interfaces again. We only need to do that when we
got notified that a new interface came up and want an existing VRRP
instance to update its interface bindings.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: close sockets on shutdown
Quentin Young [Wed, 13 Feb 2019 22:15:37 +0000 (22:15 +0000)]
vrrpd: close sockets on shutdown

When shutting down a VRRP router, kill the sockets as well. Too
dangerous to try to reuse them.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: log addresses for autoconfig
Quentin Young [Wed, 13 Feb 2019 21:40:54 +0000 (21:40 +0000)]
vrrpd: log addresses for autoconfig

When adding and removing addreses. log them. Also include a VRID tag
when autoconfiguring new instances.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix incorrect index for vrrp event names
Quentin Young [Wed, 13 Feb 2019 21:40:37 +0000 (21:40 +0000)]
vrrpd: fix incorrect index for vrrp event names

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: update auto*, init scripts, etc
Quentin Young [Wed, 13 Feb 2019 20:24:56 +0000 (20:24 +0000)]
vrrpd: update auto*, init scripts, etc

Add vrrpd to all the usual places daemons need to go

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix err messaging for ipv6 addr add
Quentin Young [Wed, 13 Feb 2019 20:02:54 +0000 (20:02 +0000)]
vrrpd: fix err messaging for ipv6 addr add

* Add newline to message
* Change pasted IPv4 to IPv6

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add support for configuration writing
Quentin Young [Wed, 13 Feb 2019 19:56:40 +0000 (19:56 +0000)]
vrrpd: add support for configuration writing

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: remove ifindex from hash key computation
Quentin Young [Wed, 13 Feb 2019 19:54:03 +0000 (19:54 +0000)]
vrrpd: remove ifindex from hash key computation

Ifindexes apparently change more often than one might expect and so are
not suitable for use in hash keys.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: set DSCP byte on adverts to CS6
Quentin Young [Tue, 12 Feb 2019 22:47:48 +0000 (22:47 +0000)]
vrrpd: set DSCP byte on adverts to CS6

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: properly retrieve pkt src address
Quentin Young [Tue, 12 Feb 2019 21:22:20 +0000 (21:22 +0000)]
vrrpd: properly retrieve pkt src address

* Fix null dereference when retrieving IPv6 source address
* Change IPv4 code path to use system-specified source address instead
  of the one delivered in the IPv4 raw header

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix bug in v6 autoconfiguration
Quentin Young [Tue, 12 Feb 2019 20:41:43 +0000 (20:41 +0000)]
vrrpd: fix bug in v6 autoconfiguration

Typo caused the IPv4 VRRP router to be shutdown instead of the IPv6 one,
and sometimes a crash.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: use debugging knobs
Quentin Young [Tue, 12 Feb 2019 20:39:55 +0000 (20:39 +0000)]
vrrpd: use debugging knobs

* Gate all debugging messages with the debugging system
* Simplify a bit of debugging where it was easy to do inline

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add debugging knobs
Quentin Young [Tue, 12 Feb 2019 20:39:13 +0000 (20:39 +0000)]
vrrpd: add debugging knobs

* Add control structures for debugging
* Add CLI commands for debugging

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: minor cosmetic fix for sh vrrp
Quentin Young [Tue, 12 Feb 2019 17:34:00 +0000 (17:34 +0000)]
vrrpd: minor cosmetic fix for sh vrrp

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: set sockets to -1 after closing
Quentin Young [Mon, 11 Feb 2019 21:22:05 +0000 (21:22 +0000)]
vrrpd: set sockets to -1 after closing

This also fixes a bug where assigning the same address as a VIP twice
would succeed the second time even if it actually failed both times.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix missing \n in cli
Quentin Young [Mon, 11 Feb 2019 21:21:49 +0000 (21:21 +0000)]
vrrpd: fix missing \n in cli

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: autoconfig support, continued
Quentin Young [Mon, 11 Feb 2019 20:44:49 +0000 (20:44 +0000)]
vrrpd: autoconfig support, continued

* Add support for interface up/down + address add/del events when using
  autoconfigure mode
* Add autoconfig information to show command

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: allow creation of adverts with no addresses
Quentin Young [Mon, 11 Feb 2019 16:36:09 +0000 (16:36 +0000)]
vrrpd: allow creation of adverts with no addresses

Fuzz testing revealed a crash in which VRRPD tries to create an
advertisement packet with no IP addresses. Should never occur under
normal use but might as well patch.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: ingress pkt validation dbg cleanups
Quentin Young [Sat, 9 Feb 2019 07:02:34 +0000 (07:02 +0000)]
vrrpd: ingress pkt validation dbg cleanups

* Use proper format specifiers for some data
* Print the correct sizes when reporting IP size errors

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: don't restart when changing priority
Quentin Young [Fri, 8 Feb 2019 19:52:24 +0000 (19:52 +0000)]
vrrpd: don't restart when changing priority

Both master and backup should be able to react to priority changes
without requiring a restart.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: properly find iface in manual cfg mode
Quentin Young [Fri, 8 Feb 2019 19:47:55 +0000 (19:47 +0000)]
vrrpd: properly find iface in manual cfg mode

As a crutch, interface search when manually configuring VRRP on an
interface did a prefix match on the name of macvlan interfaces,
comparing its name to the name of the interface VRRP was configured on
in order to determine if the interface under question was a subinterface
of the configured interface. This is obviously fragile and prone to
failure. We now pass up parent interface info from Zebra so use that
instead to correctly deduce parent-child relationships.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: autoconfig support
Quentin Young [Thu, 7 Feb 2019 23:48:49 +0000 (23:48 +0000)]
vrrpd: autoconfig support

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add cli for preempt mode
Quentin Young [Wed, 6 Feb 2019 21:19:06 +0000 (21:19 +0000)]
vrrpd: add cli for preempt mode

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: specify version when parsing vrrp packet
Quentin Young [Wed, 6 Feb 2019 16:49:19 +0000 (16:49 +0000)]
vrrpd: specify version when parsing vrrp packet

Move a bit more validation into vrrp_packet.c

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix skew time calculation
Quentin Young [Wed, 6 Feb 2019 16:38:38 +0000 (16:38 +0000)]
vrrpd: fix skew time calculation

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: protodown macvlan in backup state
Quentin Young [Tue, 5 Feb 2019 22:02:40 +0000 (22:02 +0000)]
vrrpd: protodown macvlan in backup state

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: add support for VRRPv2
Quentin Young [Mon, 4 Feb 2019 19:56:12 +0000 (19:56 +0000)]
vrrpd: add support for VRRPv2

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: better logging for advertisement rx
Quentin Young [Mon, 4 Feb 2019 17:42:39 +0000 (17:42 +0000)]
vrrpd: better logging for advertisement rx

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: use ipaddr size macro
Quentin Young [Fri, 1 Feb 2019 21:26:45 +0000 (21:26 +0000)]
vrrpd: use ipaddr size macro

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agolib: add sizing macro to ipaddr.h
Quentin Young [Fri, 1 Feb 2019 21:23:02 +0000 (21:23 +0000)]
lib: add sizing macro to ipaddr.h

Useful for getting the size of the relevant data in the `ip` field of
struct ipaddr.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: use address cmp for priority tiebreak
Quentin Young [Fri, 1 Feb 2019 21:22:18 +0000 (21:22 +0000)]
vrrpd: use address cmp for priority tiebreak

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: check rx'd advertisement checksum
Quentin Young [Fri, 1 Feb 2019 20:54:44 +0000 (20:54 +0000)]
vrrpd: check rx'd advertisement checksum

And retrieve source address, since we need it anyway.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: cleanup vrrp packet crafting code
Quentin Young [Fri, 1 Feb 2019 18:49:16 +0000 (18:49 +0000)]
vrrpd: cleanup vrrp packet crafting code

* Prefix all packet functions with 'vrrp_pkt'
* Break out checksum computation into separate function
* Accept version field when building advertisements
* Update doc comments

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: use correct mtypes
Quentin Young [Fri, 1 Feb 2019 17:55:56 +0000 (17:55 +0000)]
vrrpd: use correct mtypes

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: handle address deletion, don't accept dupes
Quentin Young [Wed, 30 Jan 2019 21:47:55 +0000 (21:47 +0000)]
vrrpd: handle address deletion, don't accept dupes

* Do nothing if user tries to add the same IP twice
* Implement deletion of IPs
* Deactivate virtual router if all IPs are deleted
* Deduplicate add / remove code

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: same VRID, different interface
Quentin Young [Tue, 29 Jan 2019 20:51:35 +0000 (20:51 +0000)]
vrrpd: same VRID, different interface

Identify VRRP instances by the 2-tuple (ifp, vrid) instead of by VRID,
allowing the same instance to be configured on different interfaces.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: fix headers
Quentin Young [Tue, 29 Jan 2019 19:59:01 +0000 (19:59 +0000)]
vrrpd: fix headers

* Add include guards where missing
* Add include guard comments where missing
* Fix copyright notices
* Sort includes

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: improve show vrrp
Quentin Young [Tue, 29 Jan 2019 19:17:15 +0000 (19:17 +0000)]
vrrpd: improve show vrrp

* Dump all relevant interface names for each instance
* Compact IPvX address display

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: send ND Router Advertisements
Quentin Young [Mon, 28 Jan 2019 20:15:00 +0000 (20:15 +0000)]
vrrpd: send ND Router Advertisements

Send ND Router Advertisements when IPv6 VR is in Master state.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agovrrpd: send ICMPv6 Neighbor Advertisements
Quentin Young [Sun, 27 Jan 2019 23:08:01 +0000 (23:08 +0000)]
vrrpd: send ICMPv6 Neighbor Advertisements

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
5 years agolib: add function to get iface link-local
Quentin Young [Fri, 25 Jan 2019 21:48:17 +0000 (21:48 +0000)]
lib: add function to get iface link-local

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>