zebra: factor out rib debug logs

Introduces a logging function that takes a struct route_node * argument,
and prefixes log output with that node's prefix.  While this removes
some duplication, it will also later be useful for srcdest route nodes.

Behaviour before and after the patch should be exactly identical.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
zebra: receive ZAPI IPv6 source prefix

Check and read the IPv6 source prefix on ZAPI messages, and pass it down
to the RIB functions (which do nothing with it yet.)  Since the RIB
functions now all have a new extra argument, this also updates the
kernel route read functions to supply NULL.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib: send ZAPI IPv6 source prefix

This introduces ZAPI_MESSAGE_SRCPFX, and if set adds a source prefix
field to ZAPI IPv6 route messages sent from daemons to zebra.  The
function calls all have a new prefix_ipv6 * argument specifying the
source, or NULL.  All daemons currently supply NULL.

Zebra support for processing the field was added in the previous patch,
however, zebra does not do anything useful with the value yet.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib: add route_node_lookup_maynull

The sourcedest code needs to get the route_node even if its info pointer
is NULL (which occurs when there are srcdest routes, but no general
destination route.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
zebra: add second-level route_table for srcdest

IPv6 srcdest routes need to be keyed by both destination and source
prefix.  Since the lookup order is destination first, the simplest thing
to do here is to add a second route_table to destination entries, which
then contain source entries.  Sadly, the result is somewhat confusing
since a route_node might now be either a source node or a destination
node.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
zebra: add srcdest helpers & debug

This introduces a helper function to get source and destination prefix
from a given route node (which can be either a destination or a source
route), and extends route node debug logging function.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
*: read and ignore srcdest routes on ZAPI

Since zebra might be sending srcdest routes down to the various daemons,
they need to understand the presence of the field at the very least.
Sadly, that's also the best we can do at this point since none of the
protocols has support for handling srcdest routes.  The only consistent
thing to do is to ignore them throughout.

If an administrator wants to have the srcdest route as non-srcdest in a
protocol, setting a non-srcdest static route (possibly blackhole) is
probably the best way to go.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
zebra: send/use srcdest source prefix in ZAPI/RIB

Now that we can represent sourcedest routes, this fixes up the RIB's
usage of prefix data and passes source information down into the kernel
calls and out on ZAPI.

TODO: test on *BSD (NOT compile-checked!)
zebra: netlink: add srcdest route support

This implements processing the RTA_SRC attribute on routes received from
kernel, passing along the source prefix to the RIB functions, and adds
the attribute on updates to the kernel.

NB: "src" was in use as variable name for the "prefsrc" attribute on
routes, which indicates the preferred source address for IPv4.  These
variables have been renamed to "prefsrc".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
TODO: zebra: show commands for srcdest
zebra: cleanup srcdest routes when client disconnects

Signed-off-by: Christian Franke <nobody@nowhere.ws>
zebra: fix support for ifindex src-dest routes

Signed-off-by: Christian Franke <nobody@nowhere.ws>
lib,zebra: move srcdest_table from zebra_rib into libzebra

- make srcdest routing table reusable by putting it into lib
- make the srcdest routing table structure more opaque
- implement a srcdest routing table iterator

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
lib: fix a refcounting issue in src_node_lookup

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
lib: match route_node_lookup behavior with srcdest_rnode_lookup

Return NULL from srcdest_rnode_lookup if the found route_node has
rn->info == NULL. This is to match the behavior of route_node_lookup.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
lib: suppport route_table_finish on srcdest_table

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
lib,zebra: refactor srcdest_table a bit

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
tests: add a test for the srcdest_table structure

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
zebra: support static srcdest routes

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Included the source in the source files

They are just passed as is, most of the time. I have to work
on their handling.

Conflicts:
	babeld/message.c
	babeld/message.h
	babeld/route.c
	babeld/xroute.c