zebra: process information about new addresses

Because of a change of semantics in the Linux kernel, information
about changes made by zebra itself was not considered for updates.
This change should fix this by accounting for the new semantics.

It is based on a patch by lich posted to the bugzilla #486

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: make if_subnet_delete a bit more strict

Enhance if_subnet_delete so it will complain about improper use.
Also, fix one occurence of improper use where it was called for
IPv6 as well.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: clear ZEBRA_IFC_CONFIGURED on "no ipv6 addr"

To match the semantics of IPv4, the ZEBRA_IFC_CONFIGURED flag
should be cleared when an IPv6 connected is uninstalled via
vty.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: consolidate connected_implicit_withdraw

connected_implicit_withdraw is used at two places and followed by exactly
the same code. Move that code into connected_implicit_withdraw and give
that function a more descriptive name.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: warn if advertising connected with _REAL unset

The implementation in zebra and the zclient protocol allow to communicate
addresses to clients which are not yet in the kernel.

This is usually not done and most clients seem to expect an address to be
configured in the kernel when they receive it. Therefore, it seems
reasonable to issue a warning when advertising an address to the clients
that is not yet in the kernel.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: add ZEBRA_IFC_QUEUED to keep track of kernel state

As there are timeframes when we don't get a notification from the kernel
about new addresses. (e.g. while Linux performs IPv6 DAD), we need to
have some information whether an address has been sent to the kernel or
not.

One case where this is relevant would be a user adding an IPv6 address,
but deleting it before DAD has been complete. With the next patch which
removes some (ill assuming) synchronous parts in address setup,
ipv6_address_uninstall would not know whether or not it has to actually
delete the prefix from the kernel. Resolving these windows where we lack
information is what the flag ZEBRA_IFC_QUEUED is intended for.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: don't change connected state from zebra/interface.c

Try to avoid changing connected state from zebra/interface.c as this
means making assumptions about kernel behaviour which may be or may
become wrong. This state should rather be updated by events from the
kernel.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: improve interface shutdown behaviour

Linux removes IPv6 addresses when the interface is set down. Those
addresses need to be readded when the interface is set up again.

Also, an interface should not be reactivated from shutdown by configuring
an ip address.

Finally, remove the three-state logic for the shutdown setting as its
sole current use may be mild confusion.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ospfv3-code-refactor.patch

Move common OSPF (in ospfd and ospf6d) defines and macros into a single file.
That file is lib/libospf.h.  Also got rid of timer routines that were
duplicated between thread.c, ospf_lsa.c and ospf6d.h. Making them common avoids
my duplicating the code a third time for some of the ospfv3 patches coming
down the pipeline. Now there's a single set of these time-related routines
(timeval_add, timeval_subtract, timeval_adjust etc.) across threads, OSPFv2
and OSPFv3.

Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Reviewed-by: Scott Feldman <sfeldma@cumulusnetworks.com>
ospfv3-make-maxage-thread-periodic.patch

A million apologies for sending the previous email with the hellishly
long subject line. That was hopefully the last kink in the system, and
subsequent patch emails will be just that: patches.
isisd,ospf6d: use bug-report information from autoconf

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ospf6d: don't run DR election early on "ipv6 ospf6 priority"

On changing the router priority, DR election should only be run when it
was completed at least once before.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ospf6d: fix refcounting in ospf6_asbr_lsa_remove

When iterating over a list, also the last node should be unlocked again.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ospf6d: set cmsg size correctly

On both Linux and FreeBSD, msg_controllen should be set to
CMSG_LEN, not CMSG_SPACE. This avoids sending 4 bytes of
trailing garbage to the kernel.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ospf6d: clear DR info on interface_down

This fixes an issue where ospf6d would send incorrect hellos and
perform wrong DR election when an interface went down and up
again.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
ospf6d: improve ordered shutdown

Improve the _disable/_enable infrastructure so it gets into
a more usable shape and make 'no router ospf6' actually work.
WIP: ospf6d: handle missing link local address more gracefully

ospf6 can't run on an interface without a link local address.
Don't start the state machine when an interface comes up without
such an ip and bring it up later, when a usable link local
address is added.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>