Commit Graph

123 Commits

Author SHA1 Message Date
David Lamparter
97bd5c48de Merge remote-tracking branch 'frr/master' into pull-624 2017-06-13 09:18:14 +02:00
Donald Sharp
657cde1267 lib: Add zapi_route function.
Allow routing protocols to call one function to add/delete
routes into zebra.  Future commits will start adding
this code to individual routing protocols.

Why are we doing this?  Well the zapi_ipv[4|6]_route functions
are fundamentally broken in their ability to pass down anything
but NEXTHOP_TYPE_IFINDEX or NEXTHOP_TYPE_IPV[4|6] and we need
the ability to pass down a bit more information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-04 19:14:44 -04:00
Donald Sharp
1da2945621 lib, zebra: Pass up kernel table_id for vrf's
pim controls the vrf table creation for due to the way that
pim must interact with the kernel.  In order to match the
table_id for unicast <-> multicast( not necessary but a
real nice to have ) we need to pass up from zebra the
table_id associated with the vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-02 13:43:15 -04:00
David Lamparter
fa84d1932b Merge branch 'stable/3.0'
Conflicts:
	ldpd/lde.c
	zebra/label_manager.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-18 14:14:00 +02:00
David Lamparter
bac7b7b935 Merge pull request #537 from donaldsharp/vrf_stuff
Vrf stuff
2017-05-17 22:06:39 +02:00
Donald Sharp
7922fc65ae lib, zebra: Cleanup vrf api some
Segregate the vrf enable/disable functionality from other vrf
code.  This is to ensure that people are not actually using
the functions when they should not be.  Also document the
why of it properly in the new vrf_int.h header.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-05-15 19:02:34 -04:00
David Lamparter
896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
ßingen
5c7ef8dc4f lm: Make relay label manager async
To avoid blocking zebra when it's acting as a proxy for an external
label manager.

Besides:

Fix get chunk reconnection. Socket was still being destroyed on failure,
so next attempt would never work.

Filter out unwanted messages in lm sync sock.
Until LDE client sends ZEBRA_LABEL_MANAGER_CONNECT message, zserv
doesn't know which kind of client it is, so it might enqueue unwanted
messages like interface add, interface up, etc. Changes in this commit
discard those messages in the client side in case they arrive before the
expected response.

Change function name for zclient_connect in label manager to avoid
confusion with zclient one.

Signed-off-by: ßingen <bingen@voltanet.io>
2017-05-11 19:20:08 +02:00
Quentin Young
66e78ae64b *: update thread_add_* calls
Pass pointer to pointer instead of assigning by return value. See
previous commit message.

To ensure that the behavior stays functionally correct, any assignments
with the result of a thread_add* function have been transformed to set
the pointer to null before passing it. These can be removed wherever the
pointer is known to already be null.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:22 +00:00
Quentin Young
ffa2c8986d *: remove THREAD_ON macros, add nullity check
The way thread.c is written, a caller who wishes to be able to cancel a
thread or avoid scheduling it twice must keep a reference to the thread.
Typically this is done with a long lived pointer whose value is checked
for null in order to know if the thread is currently scheduled.  The
check-and-schedule idiom is so common that several wrapper macros in
thread.h existed solely to provide it.

This patch removes those macros and adds a new parameter to all
thread_add_* functions which is a pointer to the struct thread * to
store the result of a scheduling call. If the value passed is non-null,
the thread will only be scheduled if the value is null. This helps with
consistency.

A Coccinelle spatch has been used to transform code of the form:

  if (t == NULL)
    t = thread_add_* (...)

to the form

  thread_add_* (..., &t)

The THREAD_ON macros have also been transformed to the underlying
thread.c calls.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-09 20:44:19 +00:00
Donald Sharp
c05f73e0f4 Merge remote-tracking branch 'origin/master' into mpls2 2017-04-26 07:50:02 -04:00
Donald Sharp
08c08a35c6 lib: Fix debugs to be guarded.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-04-08 08:55:40 -04:00
Don Slice
a64448baa6 zebra: labeled unicast handling
Support install of labeled-unicast routes by a client. This would be
BGP, in order to install routes corresponding to AFI/SAFI 1/4 (IPv4)
or 2/4 (IPv6). Convert labeled-unicast routes into label forwarding
entries (i.e., transit LSPs) when there is a static label binding.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-04-06 10:29:19 -04:00
Don Slice
5aba114af4 zebra: fec register
Implement interface that allows a client to register a FEC for obtaining
a label binding (in-label). Update client whenever the label binding is
updated and cleanup when client goes away.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-04-06 10:29:19 -04:00
Donald Sharp
2d7f0d76c6 lib, zebra: Add ability to pass interface speed up from zebra
This is a prepatory commit for future improvements.

Add a change to the zapi to pass the interface speed up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-04-03 14:49:35 -04:00
Donald Sharp
80f16600af Merge pull request #285 from bingen/label_manager_3
Implement generic label manager
2017-03-21 11:40:20 -04:00
ßingen
fea12efb86 Implement generic label manager
Label Manager allows to share MPLS label space among different
daemons. Each daemon can request a chunk of consecutive labels and
release it if it doesn't need them anymore. Label Manager stores the
daemon protocol and instance to identify the owner client. It uses them
to perform garbage collection, releasing all label chunks from a client
when it gets disconnected or reconnected.

Additionally, every client can request that the chunk is never garbage
collected. In that case client has the responsibility to release
non-used labels.

Zebra can host the label manager itself (if no -l param is provided) or
connect to an external one using zserv/zclient (providing its address
with -l param).

Client code is in lib/zclient.c, but currently only LDP is using it.

TODO: Allow for custom ranges requests, i.e., specify the start label
besides the chunk.
TODO: Release labels from LDP.

Signed-off-by: Bingen Eguzkitza <bingen@voltanet.io>
2017-03-20 17:10:41 +01:00
Donald Sharp
07a112a1dc lib: Refactor if_get_by_name_len to be VRF aware
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:41:07 -04:00
Donald Sharp
fa787f911c lib, ospfd: Refactor if_lookup_by_name_len
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:32:09 -04:00
Donald Sharp
7e2b760345 *: Remove non-vrf based ifindex lookup
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-03-15 10:26:53 -04:00
David Lamparter
148781210f lib: fix remaining coverity issues
Reported-by: Coverity
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10 15:04:06 +01:00
Donald Sharp
c28e5b2a83 lib: Fix SA issue with stream s read
We were checking for non-null of 'struct stream *s'
after we did a stream_getl, which would have crashed
the program.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-01 19:43:43 -05:00
David Lamparter
d75f3b00e7 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>
2017-01-30 13:47:04 +01:00
ßingen
5cd459e86e lib: Fix missing break in zlcient switch 2017-01-25 14:33:01 +01:00
Donald Sharp
56c1f7d852 frr: Remove HAVE_IPV6 from code base
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-13 08:05:50 -05:00
Donald Sharp
b0e67bb019 lib: Partial Revert of 4ecc09d and modify zclient connect behavior
Commit 43cc09d has been shown to cause several issues with clients
connecting.

Partial revert, since I wanted to keep the debug logs added
for that commit, as well remove the piece of code that
stops attempting to connect to zebra.  If we've failed
a bunch of times, there is nothing wrong with continuing
to do so once every 60 seconds.  I've debug guarded
the connect failure for those people running bgp
without zebra.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-12-14 18:24:57 -02:00
Renato Westphal
5f3d1bdf3c *: rename two vrf functions
Since VRFs can be searched by vrf_id or name, make this explicit in the
helper functions.

s/vrf_lookup/vrf_lookup_by_id/
s/zebra_vrf_lookup/zebra_vrf_lookup_by_id/

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-28 16:18:35 -02:00
Donald Sharp
41246cb614 lib: Fix redist memory free'ing
When shutting down, properly free memory associated
with zclient.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-19 11:44:39 -04:00
Renato Westphal
43e7c3b421 lib/zebra: remove code duplication in redist_del_instance()
Change redist_check_instance() to return a pointer instead of returning 1
on success. This way this function can be reused in redist_del_instance()
instead of duplicating the same logic there.

Also, remove unnecessary call to redist_check_instance() in
zebra_redistribute_delete().

While here, remove unnecessary cast from void* in redist_add_instance().

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-10-18 08:51:24 -04:00
Christian Franke
dc9ffce878 *: Consistently support 32-bit route tags
This patch improves zebra,ripd,ripngd,ospfd and bgpd so that they can
make use of 32-bit route tags in the case of zebra,ospf,bgp or 16-bit
route-tags in the case of ripd,ripngd.

It is based on the following patch:

    commit d25764028829a3a30cdbabe85f32408a63cccadf
    Author: Paul Jakma <paul.jakma@hpe.com>
    Date:   Fri Jul 1 14:23:45 2016 +0100

    *: Widen width of Zserv routing tag field.

But also contains the changes which make this actually useful for all
the daemons.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-07 21:05:05 -04:00
David Lamparter
615d426587 lib: fix vrf_bitmap leak in zclient_free()
zclient_stop(), which is used as antagonist to zclient_init(), needs to
undo the vrf_bitmap allocation.  Otherwise zclient_init() will leak the
allocated memory, for example when zclient_reset() is used.

Reported-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-09-28 15:41:06 -04:00
Christian Franke
0fc452dc57 Make route flags a 32bit field
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-23 12:12:43 -04:00
Paul Jakma
d91788284e lib: Check prefix length from zebra is sensible
* zclient.c: prefix length on router-id and interface address add
  messages not sanity checked.  fix.

* */*_zebra.c: Prefix length on zebra route read was not checked, and
  clients use it to write to storage.  An evil zebra could overflow
  client structures by sending overly long prefixlen.

Prompted by discussions with:

Donald Sharp <sharpd@cumulusnetworks.com>
2016-09-23 12:12:17 -04:00
Donald Sharp
b99c382167 Revert "Make route flags a 32bit field"
This reverts commit 85eda2c985.
2016-09-23 12:11:21 -04:00
Christian Franke
85eda2c985 Make route flags a 32bit field
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-23 09:51:43 -04:00
Renato Westphal
a4b46f4c16 *: remove dead code
Since recently zebra uses only the ZEBRA_REDISTRIBUTE_* messages
to advertise redistributed routes to its clientes. Now the old
ZEBRA_IPV*_ROUTE_* messages are only used for client->zebra communication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23 09:31:24 -04:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.

The zebra change is slightly annoying because there is no nice place to
put the #include "zebra_memory.h" statement.

bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the
library for its own use.  This is bad practice and would break when the
memtype are made static.

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-19 16:31:04 -04:00
Olivier Dugeon
16f1b9ee29 Update Traffic Engineering Support for OSPFD
NOTE: I am squashing several commits together because they
do not independently compile and we need this ability to
do any type of sane testing on the patches.  Since this
series builds together I am doing this. -DBS

This new structure is the basis to get new link parameters for
Traffic Engineering from Zebra/interface layer to OSPFD and ISISD
for the support of Traffic Engineering

* lib/if.[c,h]: link parameters struture and get/set functions
* lib/command.[c,h]: creation of a new link-node
* lib/zclient.[c,h]: modification to the ZBUS message to convey the
link parameters structure
* lib/zebra.h: New ZBUS message

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support for IEEE 754 format

* lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to
  safely convert between big-endian IEEE-754 single and double binary
  format, as used in IETF RFCs, and C99.  Implementation depends on host
  using __STDC_IEC_559__, which should be everything we care about.  Should
  correctly error out otherwise.
* lib/network.[c,h]: Add ntohf and htonf converter
* lib/memtypes.c: Add new memeory type for Traffic Engineering support

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add link parameters support to Zebra

* zebra/interface.c:
   - Add new link-params CLI commands
   - Add new functions to set/get link parameters for interface
* zebra/redistribute.[c,h]: Add new function to propagate link parameters
to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering.
* zebra/redistribute_null.c: Add new function
zebra_interface_parameters_update()
* zebra/zserv.[c,h]: Add new functions to send link parameters

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support of new link-params CLI to vtysh

In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue
to use the ordered version for adding line i.e. config_add_line_uniq() to print
Interface CLI commands as it completely break the new LINK_PARAMS_NODE.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Update Traffic Engineering support for OSPFD

These patches update original code to RFC3630 (OSPF-TE) and add support of
RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support
of RFC6827 (ASON - GMPLS).

* ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering
* ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392
* ospfd/ospf_packet.c: Update checking of OSPF_OPTION
* ospfd/ospf_vty.[c,h]: Update ospf_str2area_id
* ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get
Link Parameters information from the interface to populate Traffic Engineering
metrics
* ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN)
* ospfd/ospf_te.[c,h]: Major modifications to update the code to new
link parameters structure and new RFCs

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

tmp
2016-09-03 11:05:50 -04:00
Timo Teräs
8ccc7e802b lib, zebra: unify link layer type and hardware address handling
This removes the BSD specific usage of struct sockaddr_dl
hardware address. This unifies to use explict hw_addr member for
the address, and zebra specific enumeration for the link layer
type.

Additionally the zapi is updated to never send platform specific
structures over the wire, but the ll_type along with hw_addr_len
and hw_addr are now sent for all platforms.

Based on initial work by Paul Jakma.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Author:    Timo Teräs <timo.teras@iki.fi>
#
# rebase in progress; onto 9c2f85d
# You are currently editing a commit while rebasing branch 'renato' on '9c2f85d'.
#
# Changes to be committed:
#	modified:   isisd/isis_circuit.c
#	modified:   lib/if.c
#	modified:   lib/if.h
#	modified:   lib/zclient.c
#	modified:   zebra/interface.c
#	modified:   zebra/interface.h
#	modified:   zebra/kernel_socket.c
#	modified:   zebra/rt_netlink.c
#	modified:   zebra/rtadv.c
#	modified:   zebra/zserv.c
#
# Untracked files:
#	"\033\033OA\033OB\033"
#	0001-bgpd-fix-build-on-Solaris.patch
#	ldpd/
#	redhat/ldpd.init
#	redhat/ldpd.service
#	tags
#
2016-09-03 11:05:50 -04:00
Donald Sharp
5b30316ea5 bgpd, lib, ospfd, pimd, zebra: Use nexthop_types_t
Use the 'enum nexthop_types_t' instead of
the zebra.h #defines.  And remove code from
zebra.h that does not belong there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-02 10:36:28 -04:00
Timo Teräs
c50ca33acf zebra: implement per-route mtu handling
This commits allow overriding MTU using netlink attributes on
per-route basis. This is useful for routing protocols that can
advertice prefix specific MTUs between routers (e.g. NHRP).

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
(cherry picked from commit b11f3b54c842117e22e2f5cf1561ea34eee8dfcc)
2016-08-21 13:11:42 -04:00
Paul Jakma
b892f1ddfe *: use an ifindex_t type, defined in lib/if.h, for ifindex values
(cherry picked from commit 9099f9b2a66e86f8a90d7fe18f61bd2bb1bc6744)
2016-08-18 07:35:38 -04:00
Donald Sharp
195dd232eb lib/zclient: Consolidate error reporting for zclient_read_header
All functions that call zclient_read_header immediately turn around
and check to ensure that the version and marker fields are correct
Move this code into zclient_read_header

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit a9d4cb33faa6af622240190a80f41c4672374925)
2016-06-09 10:33:27 -04:00
Timo Teräs
855110bb0b lib: make prefix2str simpler to use, and use it in zclient
Returning the buffer allows using it in the logging functions
in easier way. This also makes the API consistent with sockunion.

Add also PREFIX_STRLEN to be the generic buffer length required
for any prefix string representation.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 41eb9a4305fbcb206c900a18af7df7115d857d60)
2016-06-09 08:28:38 -04:00
David Lamparter
744f468530 lib: use const consistently for zserv path
The global variable is missing its const, but the accessor function has
a meaningless extra const in exchange...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-06-08 12:44:53 -04:00
Everton Marques
1b91e000c6 zclient: Revert lib export of zclient_socket()/zclient_socket_un(). 2016-05-29 21:01:50 -04:00
Everton Marques
1b428050e9 zebra: Export zclient_socket_un(). 2016-05-29 20:52:26 -04:00
Donald Sharp
ebe32f70f1 lib: Fixup zclient api to be consistent
All ZAPI commands pass the zclient around not
the individual stream we need.  Switch code
over to follow conventions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-26 20:11:15 -04:00
Donald Sharp
e7a2870b47 lib: Fix vrf_id_t data type
We were reading a u_int16_t for vrf_id_t.  While technically
the same thing, I'd like to make sure we think about vrf_id_t's
as vrf_id_t's.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-26 19:52:10 -04:00
Nicolas Dichtel
5511908940 bgpd/pimd: fix zAPI parsing
Commit c99f3481a598 has changed the API. Now, the vrfid has been added in
the header, thus we must read it before parsing the rest of the message.

To ease code maintenance, let's add a new function to read a zAPI header.

Fixes: c99f3481a598 ("*: add VRF ID in the API message header")
Reported-by: Martin Winter <mwinter@opensourcerouting.org>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Tested-by: Martin Winter <mwinter@opensourcerouting.org>
2016-05-25 20:38:33 -04:00