2002-12-13 21:15:29 +01:00
|
|
|
/* Zebra's client library.
|
|
|
|
* Copyright (C) 1999 Kunihiro Ishiguro
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
* Copyright (C) 2005 Andrew J. Schorr
|
2002-12-13 21:15:29 +01:00
|
|
|
*
|
|
|
|
* This file is part of GNU Zebra.
|
|
|
|
*
|
|
|
|
* GNU Zebra is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published
|
|
|
|
* by the Free Software Foundation; either version 2, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
2017-05-13 10:25:29 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-12-13 21:15:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "stream.h"
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
#include "buffer.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "network.h"
|
2017-05-16 01:02:34 +02:00
|
|
|
#include "vrf.h"
|
|
|
|
#include "vrf_int.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "if.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "zclient.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "table.h"
|
2016-09-02 16:32:14 +02:00
|
|
|
#include "nexthop.h"
|
2017-03-20 15:34:49 +01:00
|
|
|
#include "mpls.h"
|
2017-10-11 16:37:20 +02:00
|
|
|
#include "sockopt.h"
|
2018-03-21 11:55:38 +01:00
|
|
|
#include "pbr.h"
|
2018-04-10 21:57:09 +02:00
|
|
|
#include "nexthop_group.h"
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2015-05-29 05:48:31 +02:00
|
|
|
DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient")
|
2017-02-10 15:04:06 +01:00
|
|
|
DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs")
|
2015-05-29 05:48:31 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Zebra client events. */
|
2017-07-17 14:03:14 +02:00
|
|
|
enum event { ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT };
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Prototype for event manager. */
|
2017-07-17 14:03:14 +02:00
|
|
|
static void zclient_event(enum event, struct zclient *);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-08-06 07:35:50 +02:00
|
|
|
struct sockaddr_storage zclient_addr;
|
|
|
|
socklen_t zclient_addr_len;
|
2011-11-25 15:51:48 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* This file local debug flag. */
|
|
|
|
int zclient_debug = 0;
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2018-03-06 20:02:52 +01:00
|
|
|
struct zclient_options zclient_options_default = {.receive_notify = false};
|
2017-11-09 20:34:42 +01:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Allocate zclient structure. */
|
2017-11-09 20:34:42 +01:00
|
|
|
struct zclient *zclient_new_notify(struct thread_master *master,
|
|
|
|
struct zclient_options *opt)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct zclient *zclient;
|
|
|
|
zclient = XCALLOC(MTYPE_ZCLIENT, sizeof(struct zclient));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
zclient->ibuf = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
|
|
|
zclient->obuf = stream_new(ZEBRA_MAX_PACKET_SIZ);
|
|
|
|
zclient->wb = buffer_new(0);
|
|
|
|
zclient->master = master;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-11-09 20:34:42 +01:00
|
|
|
zclient->receive_notify = opt->receive_notify;
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return zclient;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
[bgpd] Stability fixes including bugs 397, 492
I've spent the last several weeks working on stability fixes to bgpd.
These patches fix all of the numerous crashes, assertion failures, memory
leaks and memory stomping I could find. Valgrind was used extensively.
Added new function bgp_exit() to help catch problems. If "debug bgp" is
configured and bgpd exits with status of 0, statistics on remaining
lib/memory.c allocations are printed to stderr. It is my hope that other
developers will use this to stay on top of memory issues.
Example questionable exit:
bgpd: memstats: Current memory utilization in module LIB:
bgpd: memstats: Link List : 6
bgpd: memstats: Link Node : 5
bgpd: memstats: Hash : 8
bgpd: memstats: Hash Bucket : 2
bgpd: memstats: Hash Index : 8
bgpd: memstats: Work queue : 3
bgpd: memstats: Work queue item : 2
bgpd: memstats: Work queue name string : 3
bgpd: memstats: Current memory utilization in module BGP:
bgpd: memstats: BGP instance : 1
bgpd: memstats: BGP peer : 1
bgpd: memstats: BGP peer hostname : 1
bgpd: memstats: BGP attribute : 1
bgpd: memstats: BGP extra attributes : 1
bgpd: memstats: BGP aspath : 1
bgpd: memstats: BGP aspath str : 1
bgpd: memstats: BGP table : 24
bgpd: memstats: BGP node : 1
bgpd: memstats: BGP route : 1
bgpd: memstats: BGP synchronise : 8
bgpd: memstats: BGP Process queue : 1
bgpd: memstats: BGP node clear queue : 1
bgpd: memstats: NOTE: If configuration exists, utilization may be expected.
Example clean exit:
bgpd: memstats: No remaining tracked memory utilization.
This patch fixes bug #397: "Invalid free in bgp_announce_check()".
This patch fixes bug #492: "SIGBUS in bgpd/bgp_route.c:
bgp_clear_route_node()".
My apologies for not separating out these changes into individual patches.
The complexity of doing so boggled what is left of my brain. I hope this
is all still useful to the community.
This code has been production tested, in non-route-server-client mode, on
a linux 32-bit box and a 64-bit box.
Release/reset functions, used by bgp_exit(), added to:
bgpd/bgp_attr.c,h
bgpd/bgp_community.c,h
bgpd/bgp_dump.c,h
bgpd/bgp_ecommunity.c,h
bgpd/bgp_filter.c,h
bgpd/bgp_nexthop.c,h
bgpd/bgp_route.c,h
lib/routemap.c,h
File by file analysis:
* bgpd/bgp_aspath.c: Prevent re-use of ashash after it is released.
* bgpd/bgp_attr.c: #if removed uncalled cluster_dup().
* bgpd/bgp_clist.c,h: Allow community_list_terminate() to be called from
bgp_exit().
* bgpd/bgp_filter.c: Fix aslist->name use without allocation check, and
also fix memory leak.
* bgpd/bgp_main.c: Created bgp_exit() exit routine. This function frees
allocations made as part of bgpd initialization and, to some extent,
configuration. If "debug bgp" is configured, memory stats are printed
as described above.
* bgpd/bgp_nexthop.c: zclient_new() already allocates stream for
ibuf/obuf, so bgp_scan_init() shouldn't do it too. Also, made it so
zlookup is global so bgp_exit() can use it.
* bgpd/bgp_packet.c: bgp_capability_msg_parse() call to bgp_clear_route()
adjusted to use new BGP_CLEAR_ROUTE_NORMAL flag.
* bgpd/bgp_route.h: Correct reference counter "lock" to be signed.
bgp_clear_route() now accepts a bgp_clear_route_type of either
BGP_CLEAR_ROUTE_NORMAL or BGP_CLEAR_ROUTE_MY_RSCLIENT.
* bgpd/bgp_route.c:
- bgp_process_rsclient(): attr was being zero'ed and then
bgp_attr_extra_free() was being called with it, even though it was
never filled with valid data.
- bgp_process_rsclient(): Make sure rsclient->group is not NULL before
use.
- bgp_processq_del(): Add call to bgp_table_unlock().
- bgp_process(): Add call to bgp_table_lock().
- bgp_update_rsclient(): memset clearing of new_attr not needed since
declarationw with "= { 0 }" does it. memset was already commented
out.
- bgp_update_rsclient(): Fix screwed up misleading indentation.
- bgp_withdraw_rsclient(): Fix screwed up misleading indentation.
- bgp_clear_route_node(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT.
- bgp_clear_node_queue_del(): Add call to bgp_table_unlock() and also
free struct bgp_clear_node_queue used for work item.
- bgp_clear_node_complete(): Do peer_unlock() after BGP_EVENT_ADD() in
case peer is released by peer_unlock() call.
- bgp_clear_route_table(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT. Use
struct bgp_clear_node_queue to supply data to worker. Add call to
bgp_table_lock().
- bgp_clear_route(): Add support for BGP_CLEAR_ROUTE_NORMAL or
BGP_CLEAR_ROUTE_MY_RSCLIENT.
- bgp_clear_route_all(): Use BGP_CLEAR_ROUTE_NORMAL.
Bug 397 fixes:
- bgp_default_originate()
- bgp_announce_table()
* bgpd/bgp_table.h:
- struct bgp_table: Added reference count. Changed type of owner to be
"struct peer *" rather than "void *".
- struct bgp_node: Correct reference counter "lock" to be signed.
* bgpd/bgp_table.c:
- Added bgp_table reference counting.
- bgp_table_free(): Fixed cleanup code. Call peer_unlock() on owner if
set.
- bgp_unlock_node(): Added assertion.
- bgp_node_get(): Added call to bgp_lock_node() to code path that it was
missing from.
* bgpd/bgp_vty.c:
- peer_rsclient_set_vty(): Call peer_lock() as part of peer assignment
to owner. Handle failure gracefully.
- peer_rsclient_unset_vty(): Add call to bgp_clear_route() with
BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.
* bgpd/bgp_zebra.c: Made it so zclient is global so bgp_exit() can use it.
* bgpd/bgpd.c:
- peer_lock(): Allow to be called when status is "Deleted".
- peer_deactivate(): Supply BGP_CLEAR_ROUTE_NORMAL purpose to
bgp_clear_route() call.
- peer_delete(): Common variable listnode pn. Fix bug in which rsclient
was only dealt with if not part of a peer group. Call
bgp_clear_route() for rsclient, if appropriate, and do so with
BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.
- peer_group_get(): Use XSTRDUP() instead of strdup() for conf->host.
- peer_group_bind(): Call bgp_clear_route() for rsclient, and do so with
BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.
- bgp_create(): Use XSTRDUP() instead of strdup() for peer_self->host.
- bgp_delete(): Delete peers before groups, rather than after. And then
rather than deleting rsclients, verify that there are none at this
point.
- bgp_unlock(): Add assertion.
- bgp_free(): Call bgp_table_finish() rather than doing XFREE() itself.
* lib/command.c,h: Compiler warning fixes. Add cmd_terminate(). Fixed
massive leak in install_element() in which cmd_make_descvec() was being
called more than once for the same cmd->strvec/string/doc.
* lib/log.c: Make closezlog() check fp before calling fclose().
* lib/memory.c: Catch when alloc count goes negative by using signed
counts. Correct #endif comment. Add log_memstats_stderr().
* lib/memory.h: Add log_memstats_stderr().
* lib/thread.c: thread->funcname was being accessed in thread_call() after
it had been freed. Rearranged things so that thread_call() frees
funcname. Also made it so thread_master_free() cleans up cpu_record.
* lib/vty.c,h: Use global command_cr. Add vty_terminate().
* lib/zclient.c,h: Re-enable zclient_free().
2009-07-18 07:44:03 +02:00
|
|
|
/* This function is only called when exiting, because
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
many parts of the code do not check for I/O errors, so they could
|
|
|
|
reference an invalid pointer if the structure was ever freed.
|
|
|
|
|
[bgpd] Stability fixes including bugs 397, 492
I've spent the last several weeks working on stability fixes to bgpd.
These patches fix all of the numerous crashes, assertion failures, memory
leaks and memory stomping I could find. Valgrind was used extensively.
Added new function bgp_exit() to help catch problems. If "debug bgp" is
configured and bgpd exits with status of 0, statistics on remaining
lib/memory.c allocations are printed to stderr. It is my hope that other
developers will use this to stay on top of memory issues.
Example questionable exit:
bgpd: memstats: Current memory utilization in module LIB:
bgpd: memstats: Link List : 6
bgpd: memstats: Link Node : 5
bgpd: memstats: Hash : 8
bgpd: memstats: Hash Bucket : 2
bgpd: memstats: Hash Index : 8
bgpd: memstats: Work queue : 3
bgpd: memstats: Work queue item : 2
bgpd: memstats: Work queue name string : 3
bgpd: memstats: Current memory utilization in module BGP:
bgpd: memstats: BGP instance : 1
bgpd: memstats: BGP peer : 1
bgpd: memstats: BGP peer hostname : 1
bgpd: memstats: BGP attribute : 1
bgpd: memstats: BGP extra attributes : 1
bgpd: memstats: BGP aspath : 1
bgpd: memstats: BGP aspath str : 1
bgpd: memstats: BGP table : 24
bgpd: memstats: BGP node : 1
bgpd: memstats: BGP route : 1
bgpd: memstats: BGP synchronise : 8
bgpd: memstats: BGP Process queue : 1
bgpd: memstats: BGP node clear queue : 1
bgpd: memstats: NOTE: If configuration exists, utilization may be expected.
Example clean exit:
bgpd: memstats: No remaining tracked memory utilization.
This patch fixes bug #397: "Invalid free in bgp_announce_check()".
This patch fixes bug #492: "SIGBUS in bgpd/bgp_route.c:
bgp_clear_route_node()".
My apologies for not separating out these changes into individual patches.
The complexity of doing so boggled what is left of my brain. I hope this
is all still useful to the community.
This code has been production tested, in non-route-server-client mode, on
a linux 32-bit box and a 64-bit box.
Release/reset functions, used by bgp_exit(), added to:
bgpd/bgp_attr.c,h
bgpd/bgp_community.c,h
bgpd/bgp_dump.c,h
bgpd/bgp_ecommunity.c,h
bgpd/bgp_filter.c,h
bgpd/bgp_nexthop.c,h
bgpd/bgp_route.c,h
lib/routemap.c,h
File by file analysis:
* bgpd/bgp_aspath.c: Prevent re-use of ashash after it is released.
* bgpd/bgp_attr.c: #if removed uncalled cluster_dup().
* bgpd/bgp_clist.c,h: Allow community_list_terminate() to be called from
bgp_exit().
* bgpd/bgp_filter.c: Fix aslist->name use without allocation check, and
also fix memory leak.
* bgpd/bgp_main.c: Created bgp_exit() exit routine. This function frees
allocations made as part of bgpd initialization and, to some extent,
configuration. If "debug bgp" is configured, memory stats are printed
as described above.
* bgpd/bgp_nexthop.c: zclient_new() already allocates stream for
ibuf/obuf, so bgp_scan_init() shouldn't do it too. Also, made it so
zlookup is global so bgp_exit() can use it.
* bgpd/bgp_packet.c: bgp_capability_msg_parse() call to bgp_clear_route()
adjusted to use new BGP_CLEAR_ROUTE_NORMAL flag.
* bgpd/bgp_route.h: Correct reference counter "lock" to be signed.
bgp_clear_route() now accepts a bgp_clear_route_type of either
BGP_CLEAR_ROUTE_NORMAL or BGP_CLEAR_ROUTE_MY_RSCLIENT.
* bgpd/bgp_route.c:
- bgp_process_rsclient(): attr was being zero'ed and then
bgp_attr_extra_free() was being called with it, even though it was
never filled with valid data.
- bgp_process_rsclient(): Make sure rsclient->group is not NULL before
use.
- bgp_processq_del(): Add call to bgp_table_unlock().
- bgp_process(): Add call to bgp_table_lock().
- bgp_update_rsclient(): memset clearing of new_attr not needed since
declarationw with "= { 0 }" does it. memset was already commented
out.
- bgp_update_rsclient(): Fix screwed up misleading indentation.
- bgp_withdraw_rsclient(): Fix screwed up misleading indentation.
- bgp_clear_route_node(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT.
- bgp_clear_node_queue_del(): Add call to bgp_table_unlock() and also
free struct bgp_clear_node_queue used for work item.
- bgp_clear_node_complete(): Do peer_unlock() after BGP_EVENT_ADD() in
case peer is released by peer_unlock() call.
- bgp_clear_route_table(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT. Use
struct bgp_clear_node_queue to supply data to worker. Add call to
bgp_table_lock().
- bgp_clear_route(): Add support for BGP_CLEAR_ROUTE_NORMAL or
BGP_CLEAR_ROUTE_MY_RSCLIENT.
- bgp_clear_route_all(): Use BGP_CLEAR_ROUTE_NORMAL.
Bug 397 fixes:
- bgp_default_originate()
- bgp_announce_table()
* bgpd/bgp_table.h:
- struct bgp_table: Added reference count. Changed type of owner to be
"struct peer *" rather than "void *".
- struct bgp_node: Correct reference counter "lock" to be signed.
* bgpd/bgp_table.c:
- Added bgp_table reference counting.
- bgp_table_free(): Fixed cleanup code. Call peer_unlock() on owner if
set.
- bgp_unlock_node(): Added assertion.
- bgp_node_get(): Added call to bgp_lock_node() to code path that it was
missing from.
* bgpd/bgp_vty.c:
- peer_rsclient_set_vty(): Call peer_lock() as part of peer assignment
to owner. Handle failure gracefully.
- peer_rsclient_unset_vty(): Add call to bgp_clear_route() with
BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.
* bgpd/bgp_zebra.c: Made it so zclient is global so bgp_exit() can use it.
* bgpd/bgpd.c:
- peer_lock(): Allow to be called when status is "Deleted".
- peer_deactivate(): Supply BGP_CLEAR_ROUTE_NORMAL purpose to
bgp_clear_route() call.
- peer_delete(): Common variable listnode pn. Fix bug in which rsclient
was only dealt with if not part of a peer group. Call
bgp_clear_route() for rsclient, if appropriate, and do so with
BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.
- peer_group_get(): Use XSTRDUP() instead of strdup() for conf->host.
- peer_group_bind(): Call bgp_clear_route() for rsclient, and do so with
BGP_CLEAR_ROUTE_MY_RSCLIENT purpose.
- bgp_create(): Use XSTRDUP() instead of strdup() for peer_self->host.
- bgp_delete(): Delete peers before groups, rather than after. And then
rather than deleting rsclients, verify that there are none at this
point.
- bgp_unlock(): Add assertion.
- bgp_free(): Call bgp_table_finish() rather than doing XFREE() itself.
* lib/command.c,h: Compiler warning fixes. Add cmd_terminate(). Fixed
massive leak in install_element() in which cmd_make_descvec() was being
called more than once for the same cmd->strvec/string/doc.
* lib/log.c: Make closezlog() check fp before calling fclose().
* lib/memory.c: Catch when alloc count goes negative by using signed
counts. Correct #endif comment. Add log_memstats_stderr().
* lib/memory.h: Add log_memstats_stderr().
* lib/thread.c: thread->funcname was being accessed in thread_call() after
it had been freed. Rearranged things so that thread_call() frees
funcname. Also made it so thread_master_free() cleans up cpu_record.
* lib/vty.c,h: Use global command_cr. Add vty_terminate().
* lib/zclient.c,h: Re-enable zclient_free().
2009-07-18 07:44:03 +02:00
|
|
|
Free zclient structure. */
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_free(struct zclient *zclient)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
if (zclient->ibuf)
|
|
|
|
stream_free(zclient->ibuf);
|
|
|
|
if (zclient->obuf)
|
|
|
|
stream_free(zclient->obuf);
|
|
|
|
if (zclient->wb)
|
|
|
|
buffer_free(zclient->wb);
|
|
|
|
|
|
|
|
XFREE(MTYPE_ZCLIENT, zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short *redist_check_instance(struct redist_proto *red,
|
|
|
|
unsigned short instance)
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct listnode *node;
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short *id;
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (!red->instances)
|
|
|
|
return NULL;
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(red->instances, node, id))
|
|
|
|
if (*id == instance)
|
|
|
|
return id;
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return NULL;
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
void redist_add_instance(struct redist_proto *red, unsigned short instance)
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short *in;
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
red->enabled = 1;
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (!red->instances)
|
|
|
|
red->instances = list_new();
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
in = XMALLOC(MTYPE_REDIST_INST, sizeof(unsigned short));
|
2017-07-17 14:03:14 +02:00
|
|
|
*in = instance;
|
|
|
|
listnode_add(red->instances, in);
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
void redist_del_instance(struct redist_proto *red, unsigned short instance)
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short *id;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
id = redist_check_instance(red, instance);
|
|
|
|
if (!id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
listnode_delete(red->instances, id);
|
|
|
|
XFREE(MTYPE_REDIST_INST, id);
|
|
|
|
if (!red->instances->count) {
|
|
|
|
red->enabled = 0;
|
2017-09-28 03:19:20 +02:00
|
|
|
list_delete_and_null(&red->instances);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
Multi-Instance OSPF Summary
——————————————-------------
- etc/init.d/quagga is modified to support creating separate ospf daemon
process for each instance. Each individual instance is monitored by
watchquagga just like any protocol daemons.(requires initd-mi.patch).
- Vtysh is modified to able to connect to multiple daemons of the same
protocol (supported for OSPF only for now).
- ospfd is modified to remember the Instance-ID that its invoked with. For
the entire life of the process it caters to any command request that
matches that instance-ID (unless its a non instance specific command).
Routes/messages to zebra are tagged with instance-ID.
- zebra route/redistribute mechanisms are modified to work with
[protocol type + instance-id]
- bgpd now has ability to have multiple instance specific redistribution
for a protocol (OSPF only supported/tested for now).
- zlog ability to display instance-id besides the protocol/daemon name.
- Changes in other daemons are to because of the needed integration with
some of the modified APIs/routines. (Didn’t prefer replicating too many
separate instance specific APIs.)
- config/show/debug commands are modified to take instance-id argument
as appropriate.
Guidelines to start using multi-instance ospf
---------------------------------------------
The patch is backward compatible, i.e for any previous way of single ospf
deamon(router ospf <cr>) will continue to work as is, including all the
show commands etc.
To enable multiple instances, do the following:
1. service quagga stop
2. Modify /etc/quagga/daemons to add instance-ids of each desired
instance in the following format:
ospfd=“yes"
ospfd_instances="1,2,3"
assuming you want to enable 3 instances with those instance ids.
3. Create corresponding ospfd config files as ospfd-1.conf, ospfd-2.conf
and ospfd-3.conf.
4. service quagga start/restart
5. Verify that the deamons are started as expected. You should see
ospfd started with -n <instance-id> option.
ps –ef | grep quagga
With that /var/run/quagga/ should have ospfd-<instance-id>.pid and
ospfd-<instance-id>/vty to each instance.
6. vtysh to work with instances as you would with any other deamons.
7. Overall most quagga semantics are the same working with the instance
deamon, like it is for any other daemon.
NOTE:
To safeguard against errors leading to too many processes getting invoked,
a hard limit on number of instance-ids is in place, currently its 5.
Allowed instance-id range is <1-65535>
Once daemons are up, show running from vtysh should show the instance-id
of each daemon as 'router ospf <instance-id>’ (without needing explicit
configuration)
Instance-id can not be changed via vtysh, other router ospf configuration
is allowed as before.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
2015-05-20 03:03:42 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Stop zebra client services. */
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_stop(struct zclient *zclient)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
afi_t afi;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient stopped");
|
|
|
|
|
|
|
|
/* Stop threads. */
|
|
|
|
THREAD_OFF(zclient->t_read);
|
|
|
|
THREAD_OFF(zclient->t_connect);
|
|
|
|
THREAD_OFF(zclient->t_write);
|
|
|
|
|
|
|
|
/* Reset streams. */
|
|
|
|
stream_reset(zclient->ibuf);
|
|
|
|
stream_reset(zclient->obuf);
|
|
|
|
|
|
|
|
/* Empty the write buffer. */
|
|
|
|
buffer_reset(zclient->wb);
|
|
|
|
|
|
|
|
/* Close socket. */
|
|
|
|
if (zclient->sock >= 0) {
|
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
}
|
|
|
|
zclient->fail = 0;
|
|
|
|
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
vrf_bitmap_free(zclient->redist[afi][i]);
|
|
|
|
zclient->redist[afi][i] = VRF_BITMAP_NULL;
|
|
|
|
}
|
|
|
|
redist_del_instance(
|
|
|
|
&zclient->mi_redist[afi][zclient->redist_default],
|
|
|
|
zclient->instance);
|
2016-10-19 17:44:39 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
vrf_bitmap_free(zclient->default_information);
|
|
|
|
zclient->default_information = VRF_BITMAP_NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_reset(struct zclient *zclient)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
afi_t afi;
|
2015-05-20 03:29:17 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
zclient_stop(zclient);
|
2015-05-20 03:29:17 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
redist_del_instance(
|
|
|
|
&zclient->mi_redist[afi][zclient->redist_default],
|
|
|
|
zclient->instance);
|
2015-05-20 03:29:17 +02:00
|
|
|
|
2018-03-06 20:02:52 +01:00
|
|
|
zclient_init(zclient, zclient->redist_default, zclient->instance,
|
|
|
|
zclient->privs);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-08-06 07:35:50 +02:00
|
|
|
/**
|
|
|
|
* Connect to zebra daemon.
|
|
|
|
* @param zclient a pointer to zclient structure
|
|
|
|
* @return socket fd just to make sure that connection established
|
|
|
|
* @see zclient_init
|
2017-11-09 20:34:42 +01:00
|
|
|
* @see zclient_new_notify
|
2017-08-06 07:35:50 +02:00
|
|
|
*/
|
|
|
|
int zclient_socket_connect(struct zclient *zclient)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int sock;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* We should think about IPv6 connection. */
|
2017-08-06 07:35:50 +02:00
|
|
|
sock = socket(zclient_addr.ss_family, SOCK_STREAM, 0);
|
2017-07-17 14:03:14 +02:00
|
|
|
if (sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
2017-08-06 07:35:50 +02:00
|
|
|
set_cloexec(sock);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-10-11 16:37:20 +02:00
|
|
|
zclient->privs->change(ZPRIVS_RAISE);
|
|
|
|
setsockopt_so_sendbuf(sock, 1048576);
|
|
|
|
zclient->privs->change(ZPRIVS_LOWER);
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Connect to zebra. */
|
2018-03-06 20:02:52 +01:00
|
|
|
ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);
|
2017-07-17 14:03:14 +02:00
|
|
|
if (ret < 0) {
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_warn("%s connect failure: %d(%s)",
|
|
|
|
__PRETTY_FUNCTION__, errno,
|
|
|
|
safe_strerror(errno));
|
|
|
|
close(sock);
|
|
|
|
return -1;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-08-06 07:35:50 +02:00
|
|
|
zclient->sock = sock;
|
2017-07-17 14:03:14 +02:00
|
|
|
return sock;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zclient_failed(struct zclient *zclient)
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
zclient->fail++;
|
|
|
|
zclient_stop(zclient);
|
|
|
|
zclient_event(ZCLIENT_CONNECT, zclient);
|
|
|
|
return -1;
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zclient_flush_data(struct thread *thread)
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct zclient *zclient = THREAD_ARG(thread);
|
|
|
|
|
|
|
|
zclient->t_write = NULL;
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
switch (buffer_flush_available(zclient->wb, zclient->sock)) {
|
|
|
|
case BUFFER_ERROR:
|
|
|
|
zlog_warn(
|
|
|
|
"%s: buffer_flush_available failed on zclient fd %d, closing",
|
|
|
|
__func__, zclient->sock);
|
|
|
|
return zclient_failed(zclient);
|
|
|
|
break;
|
|
|
|
case BUFFER_PENDING:
|
|
|
|
zclient->t_write = NULL;
|
|
|
|
thread_add_write(zclient->master, zclient_flush_data, zclient,
|
|
|
|
zclient->sock, &zclient->t_write);
|
|
|
|
break;
|
|
|
|
case BUFFER_EMPTY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
int zclient_send_message(struct zclient *zclient)
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
switch (buffer_write(zclient->wb, zclient->sock,
|
|
|
|
STREAM_DATA(zclient->obuf),
|
|
|
|
stream_get_endp(zclient->obuf))) {
|
|
|
|
case BUFFER_ERROR:
|
|
|
|
zlog_warn("%s: buffer_write failed to zclient fd %d, closing",
|
|
|
|
__func__, zclient->sock);
|
|
|
|
return zclient_failed(zclient);
|
|
|
|
break;
|
|
|
|
case BUFFER_EMPTY:
|
|
|
|
THREAD_OFF(zclient->t_write);
|
|
|
|
break;
|
|
|
|
case BUFFER_PENDING:
|
|
|
|
thread_add_write(zclient->master, zclient_flush_data, zclient,
|
|
|
|
zclient->sock, &zclient->t_write);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_create_header(struct stream *s, uint16_t command, vrf_id_t vrf_id)
|
2006-01-16 02:54:02 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
/* length placeholder, caller can update */
|
|
|
|
stream_putw(s, ZEBRA_HEADER_SIZE);
|
|
|
|
stream_putc(s, ZEBRA_HEADER_MARKER);
|
|
|
|
stream_putc(s, ZSERV_VERSION);
|
lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.
Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.
This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-14 16:01:36 +01:00
|
|
|
stream_putl(s, vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
stream_putw(s, command);
|
2006-01-16 02:54:02 +01:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
int zclient_read_header(struct stream *s, int sock, uint16_t *size,
|
|
|
|
uint8_t *marker, uint8_t *version, vrf_id_t *vrf_id,
|
|
|
|
uint16_t *cmd)
|
2015-09-16 09:42:36 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
if (stream_read(s, sock, ZEBRA_HEADER_SIZE) != ZEBRA_HEADER_SIZE)
|
|
|
|
return -1;
|
|
|
|
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETW(s, *size);
|
|
|
|
*size -= ZEBRA_HEADER_SIZE;
|
|
|
|
STREAM_GETC(s, *marker);
|
|
|
|
STREAM_GETC(s, *version);
|
lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.
Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.
This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-14 16:01:36 +01:00
|
|
|
STREAM_GETL(s, *vrf_id);
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETW(s, *cmd);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (*version != ZSERV_VERSION || *marker != ZEBRA_HEADER_MARKER) {
|
|
|
|
zlog_err(
|
|
|
|
"%s: socket %d version mismatch, marker %d, version %d",
|
|
|
|
__func__, sock, *marker, *version);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*size && stream_read(s, sock, *size) != *size)
|
|
|
|
return -1;
|
|
|
|
|
2017-11-10 14:51:34 +01:00
|
|
|
stream_failure:
|
2017-07-17 14:03:14 +02:00
|
|
|
return 0;
|
2015-09-16 09:42:36 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 17:23:58 +01:00
|
|
|
bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr)
|
|
|
|
{
|
|
|
|
STREAM_GETW(zmsg, hdr->length);
|
|
|
|
STREAM_GETC(zmsg, hdr->marker);
|
|
|
|
STREAM_GETC(zmsg, hdr->version);
|
2018-03-09 21:59:39 +01:00
|
|
|
STREAM_GETL(zmsg, hdr->vrf_id);
|
2018-03-07 17:23:58 +01:00
|
|
|
STREAM_GETW(zmsg, hdr->command);
|
|
|
|
return true;
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
/* Send simple Zebra message. */
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zebra_message_send(struct zclient *zclient, int command,
|
|
|
|
vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct stream *s;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Get zclient output buffer. */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Send very simple command only Zebra message. */
|
|
|
|
zclient_create_header(s, command, vrf_id);
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zebra_hello_send(struct zclient *zclient)
|
2011-12-11 15:48:47 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
if (zclient->redist_default) {
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
/* The VRF ID in the HELLO message is always 0. */
|
|
|
|
zclient_create_header(s, ZEBRA_HELLO, VRF_DEFAULT);
|
|
|
|
stream_putc(s, zclient->redist_default);
|
|
|
|
stream_putw(s, zclient->instance);
|
2017-11-09 20:34:42 +01:00
|
|
|
if (zclient->receive_notify)
|
|
|
|
stream_putc(s, 1);
|
|
|
|
else
|
|
|
|
stream_putc(s, 0);
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
return zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2011-12-11 15:48:47 +01:00
|
|
|
}
|
|
|
|
|
2018-02-14 07:11:09 +01:00
|
|
|
void zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi,
|
2018-02-08 15:50:32 +01:00
|
|
|
mpls_label_t label, enum lsp_types_t ltype)
|
2018-01-30 19:30:36 +01:00
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
zclient_create_header(s, ZEBRA_VRF_LABEL, vrf_id);
|
|
|
|
stream_putl(s, label);
|
2018-02-14 07:11:09 +01:00
|
|
|
stream_putc(s, afi);
|
2018-02-08 15:50:32 +01:00
|
|
|
stream_putc(s, ltype);
|
2018-01-30 19:30:36 +01:00
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
2016-02-12 20:37:33 +01:00
|
|
|
/* Send register requests to zebra daemon for the information in a VRF. */
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_send_reg_requests(struct zclient *zclient, vrf_id_t vrf_id)
|
*: add VRF ID in the API message header
The API messages are used by zebra to exchange the interfaces, addresses,
routes and router-id information with its clients. To distinguish which
VRF the information belongs to, a new field "VRF ID" is added in the
message header. And hence the message version is increased to 3.
* The new field "VRF ID" in the message header:
Length (2 bytes)
Marker (1 byte)
Version (1 byte)
VRF ID (2 bytes, newly added)
Command (2 bytes)
- Client side:
- zclient_create_header() adds the VRF ID in the message header.
- zclient_read() extracts and validates the VRF ID from the header,
and passes the VRF ID to the callback functions registered to
the API messages.
- All relative functions are appended with a new parameter "vrf_id",
including all the callback functions.
- "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6".
Clients need to correctly set the VRF ID when using the API
functions zapi_ipv4_route() and zapi_ipv6_route().
- Till now all messages sent from a client have the default VRF ID
"0" in the header.
- The HELLO message is special, which is used as the heart-beat of
a client, and has no relation with VRF. The VRF ID in the HELLO
message header will always be 0 and ignored by zebra.
- Zebra side:
- zserv_create_header() adds the VRF ID in the message header.
- zebra_client_read() extracts and validates the VRF ID from the
header, and passes the VRF ID to the functions which process
the received messages.
- All relative functions are appended with a new parameter "vrf_id".
* Suppress the messages in a VRF which a client does not care:
Some clients may not care about the information in the VRF X, and
zebra should not send the messages in the VRF X to those clients.
Extra flags are used to indicate which VRF is registered by a client,
and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client
can unregister a VRF when it does not need any information in that
VRF.
A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF
will automatically register to that VRF.
- lib/vrf:
A new utility "VRF bit-map" is provided to manage the flags for
VRFs, one bit per VRF ID.
- Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a
bit-map;
- Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag
in the given bit-map, corresponding to the given VRF ID;
- Use vrf_bitmap_check() to test whether the flag, in the given
bit-map and for the given VRF ID, is set.
- Client side:
- In "struct zclient", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
default_information
These flags are extended for each VRF, and controlled by the
clients themselves (or with the help of zclient_redistribute()
and zclient_redistribute_default()).
- Zebra side:
- In "struct zserv", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
redist_default
ifinfo
ridinfo
These flags are extended for each VRF, as the VRF registration
flags. They are maintained on receiving a ZEBRA_XXX_ADD or
ZEBRA_XXX_DELETE message.
When sending an interface/address/route/router-id message in
a VRF to a client, if the corresponding VRF registration flag
is not set, this message will not be dropped by zebra.
- A new function zread_vrf_unregister() is introduced to process
the new command ZEBRA_VRF_UNREGISTER. All the VRF registration
flags are cleared for the requested VRF.
Those clients, who support only the default VRF, will never receive
a message in a non-default VRF, thanks to the filter in zebra.
* New callback for the event of successful connection to zebra:
- zclient_start() is splitted, keeping only the code of connecting
to zebra.
- Now zclient_init()=>zclient_connect()=>zclient_start() operations
are purely dealing with the connection to zbera.
- Once zebra is successfully connected, at the end of zclient_start(),
a new callback is used to inform the client about connection.
- Till now, in the callback of connect-to-zebra event, all clients
send messages to zebra to request the router-id/interface/routes
information in the default VRF.
Of corse in future the client can do anything it wants in this
callback. For example, it may send requests for both default VRF
and some non-default VRFs.
Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Conflicts:
lib/zclient.h
lib/zebra.h
zebra/zserv.c
zebra/zserv.h
Conflicts:
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
lib/zebra.h
nhrpd/nhrp_interface.c
nhrpd/nhrp_route.c
nhrpd/nhrpd.h
ospf6d/ospf6_zebra.c
ospf6d/ospf6_zebra.h
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
ripd/rip_zebra.c
ripngd/ripng_zebra.c
zebra/redistribute.c
zebra/rt_netlink.c
zebra/zebra_rnh.c
zebra/zebra_rnh.h
zebra/zserv.c
zebra/zserv.h
2014-10-16 03:52:36 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int i;
|
|
|
|
afi_t afi;
|
|
|
|
|
|
|
|
/* If not connected to the zebra yet. */
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: send register messages for VRF %u", __func__,
|
|
|
|
vrf_id);
|
|
|
|
|
|
|
|
/* We need router-id information. */
|
|
|
|
zebra_message_send(zclient, ZEBRA_ROUTER_ID_ADD, vrf_id);
|
|
|
|
|
|
|
|
/* We need interface information. */
|
|
|
|
zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, vrf_id);
|
|
|
|
|
|
|
|
/* Set unwanted redistribute route. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
vrf_bitmap_set(zclient->redist[afi][zclient->redist_default],
|
|
|
|
vrf_id);
|
|
|
|
|
|
|
|
/* Flush all redistribute request. */
|
2018-01-23 00:16:59 +01:00
|
|
|
if (vrf_id == VRF_DEFAULT) {
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
if (!zclient->mi_redist[afi][i].enabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
struct listnode *node;
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short *id;
|
2018-01-23 00:16:59 +01:00
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(
|
|
|
|
zclient->mi_redist[afi][i]
|
2018-03-06 20:02:52 +01:00
|
|
|
.instances,
|
|
|
|
node, id))
|
2018-01-23 00:16:59 +01:00
|
|
|
if (!(i == zclient->redist_default
|
|
|
|
&& *id == zclient->instance))
|
|
|
|
zebra_redistribute_send(
|
|
|
|
ZEBRA_REDISTRIBUTE_ADD,
|
2018-03-06 20:02:52 +01:00
|
|
|
zclient, afi, i, *id,
|
2018-01-23 00:16:59 +01:00
|
|
|
VRF_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-02-28 08:57:59 +01:00
|
|
|
/* Resend all redistribute request. */
|
2017-07-17 14:03:14 +02:00
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
|
|
|
|
if (i != zclient->redist_default
|
|
|
|
&& vrf_bitmap_check(zclient->redist[afi][i],
|
|
|
|
vrf_id))
|
|
|
|
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD,
|
|
|
|
zclient, afi, i, 0,
|
|
|
|
vrf_id);
|
|
|
|
|
|
|
|
/* If default information is needed. */
|
|
|
|
if (vrf_bitmap_check(zclient->default_information, VRF_DEFAULT))
|
|
|
|
zebra_message_send(zclient, ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
|
|
|
|
vrf_id);
|
*: add VRF ID in the API message header
The API messages are used by zebra to exchange the interfaces, addresses,
routes and router-id information with its clients. To distinguish which
VRF the information belongs to, a new field "VRF ID" is added in the
message header. And hence the message version is increased to 3.
* The new field "VRF ID" in the message header:
Length (2 bytes)
Marker (1 byte)
Version (1 byte)
VRF ID (2 bytes, newly added)
Command (2 bytes)
- Client side:
- zclient_create_header() adds the VRF ID in the message header.
- zclient_read() extracts and validates the VRF ID from the header,
and passes the VRF ID to the callback functions registered to
the API messages.
- All relative functions are appended with a new parameter "vrf_id",
including all the callback functions.
- "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6".
Clients need to correctly set the VRF ID when using the API
functions zapi_ipv4_route() and zapi_ipv6_route().
- Till now all messages sent from a client have the default VRF ID
"0" in the header.
- The HELLO message is special, which is used as the heart-beat of
a client, and has no relation with VRF. The VRF ID in the HELLO
message header will always be 0 and ignored by zebra.
- Zebra side:
- zserv_create_header() adds the VRF ID in the message header.
- zebra_client_read() extracts and validates the VRF ID from the
header, and passes the VRF ID to the functions which process
the received messages.
- All relative functions are appended with a new parameter "vrf_id".
* Suppress the messages in a VRF which a client does not care:
Some clients may not care about the information in the VRF X, and
zebra should not send the messages in the VRF X to those clients.
Extra flags are used to indicate which VRF is registered by a client,
and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client
can unregister a VRF when it does not need any information in that
VRF.
A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF
will automatically register to that VRF.
- lib/vrf:
A new utility "VRF bit-map" is provided to manage the flags for
VRFs, one bit per VRF ID.
- Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a
bit-map;
- Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag
in the given bit-map, corresponding to the given VRF ID;
- Use vrf_bitmap_check() to test whether the flag, in the given
bit-map and for the given VRF ID, is set.
- Client side:
- In "struct zclient", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
default_information
These flags are extended for each VRF, and controlled by the
clients themselves (or with the help of zclient_redistribute()
and zclient_redistribute_default()).
- Zebra side:
- In "struct zserv", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
redist_default
ifinfo
ridinfo
These flags are extended for each VRF, as the VRF registration
flags. They are maintained on receiving a ZEBRA_XXX_ADD or
ZEBRA_XXX_DELETE message.
When sending an interface/address/route/router-id message in
a VRF to a client, if the corresponding VRF registration flag
is not set, this message will not be dropped by zebra.
- A new function zread_vrf_unregister() is introduced to process
the new command ZEBRA_VRF_UNREGISTER. All the VRF registration
flags are cleared for the requested VRF.
Those clients, who support only the default VRF, will never receive
a message in a non-default VRF, thanks to the filter in zebra.
* New callback for the event of successful connection to zebra:
- zclient_start() is splitted, keeping only the code of connecting
to zebra.
- Now zclient_init()=>zclient_connect()=>zclient_start() operations
are purely dealing with the connection to zbera.
- Once zebra is successfully connected, at the end of zclient_start(),
a new callback is used to inform the client about connection.
- Till now, in the callback of connect-to-zebra event, all clients
send messages to zebra to request the router-id/interface/routes
information in the default VRF.
Of corse in future the client can do anything it wants in this
callback. For example, it may send requests for both default VRF
and some non-default VRFs.
Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Conflicts:
lib/zclient.h
lib/zebra.h
zebra/zserv.c
zebra/zserv.h
Conflicts:
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
lib/zebra.h
nhrpd/nhrp_interface.c
nhrpd/nhrp_route.c
nhrpd/nhrpd.h
ospf6d/ospf6_zebra.c
ospf6d/ospf6_zebra.h
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
ripd/rip_zebra.c
ripngd/ripng_zebra.c
zebra/redistribute.c
zebra/rt_netlink.c
zebra/zebra_rnh.c
zebra/zebra_rnh.h
zebra/zserv.c
zebra/zserv.h
2014-10-16 03:52:36 +02:00
|
|
|
}
|
|
|
|
|
2016-02-12 20:37:33 +01:00
|
|
|
/* Send unregister requests to zebra daemon for the information in a VRF. */
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_send_dereg_requests(struct zclient *zclient, vrf_id_t vrf_id)
|
2016-02-12 20:37:33 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int i;
|
|
|
|
afi_t afi;
|
|
|
|
|
|
|
|
/* If not connected to the zebra yet. */
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: send deregister messages for VRF %u", __func__,
|
|
|
|
vrf_id);
|
|
|
|
|
|
|
|
/* We need router-id information. */
|
|
|
|
zebra_message_send(zclient, ZEBRA_ROUTER_ID_DELETE, vrf_id);
|
|
|
|
|
|
|
|
/* We need interface information. */
|
|
|
|
zebra_message_send(zclient, ZEBRA_INTERFACE_DELETE, vrf_id);
|
|
|
|
|
|
|
|
/* Set unwanted redistribute route. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
2018-01-23 00:18:38 +01:00
|
|
|
vrf_bitmap_unset(zclient->redist[afi][zclient->redist_default],
|
|
|
|
vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Flush all redistribute request. */
|
2018-01-23 00:16:59 +01:00
|
|
|
if (vrf_id == VRF_DEFAULT) {
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
if (!zclient->mi_redist[afi][i].enabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
struct listnode *node;
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short *id;
|
2018-01-23 00:16:59 +01:00
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(
|
|
|
|
zclient->mi_redist[afi][i]
|
2018-03-06 20:02:52 +01:00
|
|
|
.instances,
|
|
|
|
node, id))
|
2018-01-23 00:16:59 +01:00
|
|
|
if (!(i == zclient->redist_default
|
|
|
|
&& *id == zclient->instance))
|
|
|
|
zebra_redistribute_send(
|
|
|
|
ZEBRA_REDISTRIBUTE_DELETE,
|
2018-03-06 20:02:52 +01:00
|
|
|
zclient, afi, i, *id,
|
2018-01-23 00:16:59 +01:00
|
|
|
VRF_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Flush all redistribute request. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
|
|
|
|
if (i != zclient->redist_default
|
|
|
|
&& vrf_bitmap_check(zclient->redist[afi][i],
|
|
|
|
vrf_id))
|
|
|
|
zebra_redistribute_send(
|
|
|
|
ZEBRA_REDISTRIBUTE_DELETE, zclient, afi,
|
|
|
|
i, 0, vrf_id);
|
|
|
|
|
|
|
|
/* If default information is needed. */
|
|
|
|
if (vrf_bitmap_check(zclient->default_information, VRF_DEFAULT))
|
|
|
|
zebra_message_send(zclient, ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
|
|
|
|
vrf_id);
|
2016-02-12 20:37:33 +01:00
|
|
|
}
|
|
|
|
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
/* Send request to zebra daemon to start or stop RA. */
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
|
|
|
|
struct interface *ifp, int enable,
|
|
|
|
int ra_interval)
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct stream *s;
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* If not connected to the zebra yet. */
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return;
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Form and send message. */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (enable)
|
|
|
|
zclient_create_header(s, ZEBRA_INTERFACE_ENABLE_RADV, vrf_id);
|
|
|
|
else
|
|
|
|
zclient_create_header(s, ZEBRA_INTERFACE_DISABLE_RADV, vrf_id);
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
stream_putl(s, ifp->ifindex);
|
|
|
|
stream_putl(s, ra_interval);
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
zclient_send_message(zclient);
|
BGP: Trigger IPv6 router advertisements upon config of unnumbered neighbor
Instead of turning on IPv6 RA on every interface as soon as it has an IPv6
address, only enable it upon configuration of BGP neighbor. When the BGP
neighbor is deleted, signal that RAs can be turned off.
To support this, introduce new message interaction between BGP and Zebra.
Also, take appropriate actions in BGP upon interface add/del since the
unnumbered neighbor could exist prior to interface creation etc.
Only unnumbered IPv6 neighbors require RA, the /30 or /31 based neighbors
don't. However, to keep the interaction simple and not have to deal with
too many dynamic conditions (e.g., address deletes or neighbor change to/from
'v6only'), RAs on the interface are triggered upon any unnumbered neighbor
configuration.
BGP-triggered RAs will cause RAs to be initiated on the interface; however,
if BGP asks that RAs be stopped (upon delete of unnumbered neighbor), RAs
will continue to be exchanged if the operator has explicitly enabled.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-10640
Reviewed By: CCR-4589
Testing Done: Various manual and automated (refer to defect)
2016-05-02 22:53:38 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Make connection to zebra daemon. */
|
2017-07-17 14:03:14 +02:00
|
|
|
int zclient_start(struct zclient *zclient)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
if (zclient_debug)
|
|
|
|
zlog_info("zclient_start is called");
|
|
|
|
|
|
|
|
/* If already connected to the zebra. */
|
|
|
|
if (zclient->sock >= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Check connect thread. */
|
|
|
|
if (zclient->t_connect)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (zclient_socket_connect(zclient) < 0) {
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient connection fail");
|
|
|
|
zclient->fail++;
|
|
|
|
zclient_event(ZCLIENT_CONNECT, zclient);
|
|
|
|
return -1;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (set_nonblocking(zclient->sock) < 0)
|
|
|
|
zlog_warn("%s: set_nonblocking(%d) failed", __func__,
|
|
|
|
zclient->sock);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Clear fail count. */
|
|
|
|
zclient->fail = 0;
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient connect success with socket [%d]",
|
|
|
|
zclient->sock);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Create read thread. */
|
|
|
|
zclient_event(ZCLIENT_READ, zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
zebra_hello_send(zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Inform the successful connection. */
|
|
|
|
if (zclient->zebra_connected)
|
|
|
|
(*zclient->zebra_connected)(zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2015-05-20 03:04:20 +02:00
|
|
|
/* Initialize zebra client. Argument redist_default is unwanted
|
|
|
|
redistribute route type. */
|
2018-03-27 21:13:34 +02:00
|
|
|
void zclient_init(struct zclient *zclient, int redist_default,
|
|
|
|
unsigned short instance, struct zebra_privs_t *privs)
|
2015-05-20 03:04:20 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int afi, i;
|
|
|
|
|
|
|
|
/* Set -1 to the default socket value. */
|
|
|
|
zclient->sock = -1;
|
2017-10-11 16:37:20 +02:00
|
|
|
zclient->privs = privs;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Clear redistribution flags. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
|
|
|
|
zclient->redist[afi][i] = vrf_bitmap_init();
|
|
|
|
|
|
|
|
/* Set unwanted redistribute route. bgpd does not need BGP route
|
|
|
|
redistribution. */
|
|
|
|
zclient->redist_default = redist_default;
|
|
|
|
zclient->instance = instance;
|
|
|
|
/* Pending: make afi(s) an arg. */
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++)
|
|
|
|
redist_add_instance(&zclient->mi_redist[afi][redist_default],
|
|
|
|
instance);
|
|
|
|
|
|
|
|
/* Set default-information redistribute to zero. */
|
|
|
|
zclient->default_information = vrf_bitmap_init();
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient_start is called");
|
|
|
|
|
|
|
|
zclient_event(ZCLIENT_SCHEDULE, zclient);
|
*: add VRF ID in the API message header
The API messages are used by zebra to exchange the interfaces, addresses,
routes and router-id information with its clients. To distinguish which
VRF the information belongs to, a new field "VRF ID" is added in the
message header. And hence the message version is increased to 3.
* The new field "VRF ID" in the message header:
Length (2 bytes)
Marker (1 byte)
Version (1 byte)
VRF ID (2 bytes, newly added)
Command (2 bytes)
- Client side:
- zclient_create_header() adds the VRF ID in the message header.
- zclient_read() extracts and validates the VRF ID from the header,
and passes the VRF ID to the callback functions registered to
the API messages.
- All relative functions are appended with a new parameter "vrf_id",
including all the callback functions.
- "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6".
Clients need to correctly set the VRF ID when using the API
functions zapi_ipv4_route() and zapi_ipv6_route().
- Till now all messages sent from a client have the default VRF ID
"0" in the header.
- The HELLO message is special, which is used as the heart-beat of
a client, and has no relation with VRF. The VRF ID in the HELLO
message header will always be 0 and ignored by zebra.
- Zebra side:
- zserv_create_header() adds the VRF ID in the message header.
- zebra_client_read() extracts and validates the VRF ID from the
header, and passes the VRF ID to the functions which process
the received messages.
- All relative functions are appended with a new parameter "vrf_id".
* Suppress the messages in a VRF which a client does not care:
Some clients may not care about the information in the VRF X, and
zebra should not send the messages in the VRF X to those clients.
Extra flags are used to indicate which VRF is registered by a client,
and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client
can unregister a VRF when it does not need any information in that
VRF.
A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF
will automatically register to that VRF.
- lib/vrf:
A new utility "VRF bit-map" is provided to manage the flags for
VRFs, one bit per VRF ID.
- Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a
bit-map;
- Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag
in the given bit-map, corresponding to the given VRF ID;
- Use vrf_bitmap_check() to test whether the flag, in the given
bit-map and for the given VRF ID, is set.
- Client side:
- In "struct zclient", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
default_information
These flags are extended for each VRF, and controlled by the
clients themselves (or with the help of zclient_redistribute()
and zclient_redistribute_default()).
- Zebra side:
- In "struct zserv", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
redist_default
ifinfo
ridinfo
These flags are extended for each VRF, as the VRF registration
flags. They are maintained on receiving a ZEBRA_XXX_ADD or
ZEBRA_XXX_DELETE message.
When sending an interface/address/route/router-id message in
a VRF to a client, if the corresponding VRF registration flag
is not set, this message will not be dropped by zebra.
- A new function zread_vrf_unregister() is introduced to process
the new command ZEBRA_VRF_UNREGISTER. All the VRF registration
flags are cleared for the requested VRF.
Those clients, who support only the default VRF, will never receive
a message in a non-default VRF, thanks to the filter in zebra.
* New callback for the event of successful connection to zebra:
- zclient_start() is splitted, keeping only the code of connecting
to zebra.
- Now zclient_init()=>zclient_connect()=>zclient_start() operations
are purely dealing with the connection to zbera.
- Once zebra is successfully connected, at the end of zclient_start(),
a new callback is used to inform the client about connection.
- Till now, in the callback of connect-to-zebra event, all clients
send messages to zebra to request the router-id/interface/routes
information in the default VRF.
Of corse in future the client can do anything it wants in this
callback. For example, it may send requests for both default VRF
and some non-default VRFs.
Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Conflicts:
lib/zclient.h
lib/zebra.h
zebra/zserv.c
zebra/zserv.h
Conflicts:
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
lib/zebra.h
nhrpd/nhrp_interface.c
nhrpd/nhrp_route.c
nhrpd/nhrpd.h
ospf6d/ospf6_zebra.c
ospf6d/ospf6_zebra.h
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
ripd/rip_zebra.c
ripngd/ripng_zebra.c
zebra/redistribute.c
zebra/rt_netlink.c
zebra/zebra_rnh.c
zebra/zebra_rnh.h
zebra/zserv.c
zebra/zserv.h
2014-10-16 03:52:36 +02:00
|
|
|
}
|
2015-05-20 03:04:20 +02:00
|
|
|
|
*: add VRF ID in the API message header
The API messages are used by zebra to exchange the interfaces, addresses,
routes and router-id information with its clients. To distinguish which
VRF the information belongs to, a new field "VRF ID" is added in the
message header. And hence the message version is increased to 3.
* The new field "VRF ID" in the message header:
Length (2 bytes)
Marker (1 byte)
Version (1 byte)
VRF ID (2 bytes, newly added)
Command (2 bytes)
- Client side:
- zclient_create_header() adds the VRF ID in the message header.
- zclient_read() extracts and validates the VRF ID from the header,
and passes the VRF ID to the callback functions registered to
the API messages.
- All relative functions are appended with a new parameter "vrf_id",
including all the callback functions.
- "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6".
Clients need to correctly set the VRF ID when using the API
functions zapi_ipv4_route() and zapi_ipv6_route().
- Till now all messages sent from a client have the default VRF ID
"0" in the header.
- The HELLO message is special, which is used as the heart-beat of
a client, and has no relation with VRF. The VRF ID in the HELLO
message header will always be 0 and ignored by zebra.
- Zebra side:
- zserv_create_header() adds the VRF ID in the message header.
- zebra_client_read() extracts and validates the VRF ID from the
header, and passes the VRF ID to the functions which process
the received messages.
- All relative functions are appended with a new parameter "vrf_id".
* Suppress the messages in a VRF which a client does not care:
Some clients may not care about the information in the VRF X, and
zebra should not send the messages in the VRF X to those clients.
Extra flags are used to indicate which VRF is registered by a client,
and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client
can unregister a VRF when it does not need any information in that
VRF.
A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF
will automatically register to that VRF.
- lib/vrf:
A new utility "VRF bit-map" is provided to manage the flags for
VRFs, one bit per VRF ID.
- Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a
bit-map;
- Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag
in the given bit-map, corresponding to the given VRF ID;
- Use vrf_bitmap_check() to test whether the flag, in the given
bit-map and for the given VRF ID, is set.
- Client side:
- In "struct zclient", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
default_information
These flags are extended for each VRF, and controlled by the
clients themselves (or with the help of zclient_redistribute()
and zclient_redistribute_default()).
- Zebra side:
- In "struct zserv", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
redist_default
ifinfo
ridinfo
These flags are extended for each VRF, as the VRF registration
flags. They are maintained on receiving a ZEBRA_XXX_ADD or
ZEBRA_XXX_DELETE message.
When sending an interface/address/route/router-id message in
a VRF to a client, if the corresponding VRF registration flag
is not set, this message will not be dropped by zebra.
- A new function zread_vrf_unregister() is introduced to process
the new command ZEBRA_VRF_UNREGISTER. All the VRF registration
flags are cleared for the requested VRF.
Those clients, who support only the default VRF, will never receive
a message in a non-default VRF, thanks to the filter in zebra.
* New callback for the event of successful connection to zebra:
- zclient_start() is splitted, keeping only the code of connecting
to zebra.
- Now zclient_init()=>zclient_connect()=>zclient_start() operations
are purely dealing with the connection to zbera.
- Once zebra is successfully connected, at the end of zclient_start(),
a new callback is used to inform the client about connection.
- Till now, in the callback of connect-to-zebra event, all clients
send messages to zebra to request the router-id/interface/routes
information in the default VRF.
Of corse in future the client can do anything it wants in this
callback. For example, it may send requests for both default VRF
and some non-default VRFs.
Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Conflicts:
lib/zclient.h
lib/zebra.h
zebra/zserv.c
zebra/zserv.h
Conflicts:
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
lib/zebra.h
nhrpd/nhrp_interface.c
nhrpd/nhrp_route.c
nhrpd/nhrpd.h
ospf6d/ospf6_zebra.c
ospf6d/ospf6_zebra.h
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
ripd/rip_zebra.c
ripngd/ripng_zebra.c
zebra/redistribute.c
zebra/rt_netlink.c
zebra/zebra_rnh.c
zebra/zebra_rnh.h
zebra/zserv.c
zebra/zserv.h
2014-10-16 03:52:36 +02:00
|
|
|
/* This function is a wrapper function for calling zclient_start from
|
|
|
|
timer or event thread. */
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zclient_connect(struct thread *t)
|
*: add VRF ID in the API message header
The API messages are used by zebra to exchange the interfaces, addresses,
routes and router-id information with its clients. To distinguish which
VRF the information belongs to, a new field "VRF ID" is added in the
message header. And hence the message version is increased to 3.
* The new field "VRF ID" in the message header:
Length (2 bytes)
Marker (1 byte)
Version (1 byte)
VRF ID (2 bytes, newly added)
Command (2 bytes)
- Client side:
- zclient_create_header() adds the VRF ID in the message header.
- zclient_read() extracts and validates the VRF ID from the header,
and passes the VRF ID to the callback functions registered to
the API messages.
- All relative functions are appended with a new parameter "vrf_id",
including all the callback functions.
- "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6".
Clients need to correctly set the VRF ID when using the API
functions zapi_ipv4_route() and zapi_ipv6_route().
- Till now all messages sent from a client have the default VRF ID
"0" in the header.
- The HELLO message is special, which is used as the heart-beat of
a client, and has no relation with VRF. The VRF ID in the HELLO
message header will always be 0 and ignored by zebra.
- Zebra side:
- zserv_create_header() adds the VRF ID in the message header.
- zebra_client_read() extracts and validates the VRF ID from the
header, and passes the VRF ID to the functions which process
the received messages.
- All relative functions are appended with a new parameter "vrf_id".
* Suppress the messages in a VRF which a client does not care:
Some clients may not care about the information in the VRF X, and
zebra should not send the messages in the VRF X to those clients.
Extra flags are used to indicate which VRF is registered by a client,
and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client
can unregister a VRF when it does not need any information in that
VRF.
A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF
will automatically register to that VRF.
- lib/vrf:
A new utility "VRF bit-map" is provided to manage the flags for
VRFs, one bit per VRF ID.
- Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a
bit-map;
- Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag
in the given bit-map, corresponding to the given VRF ID;
- Use vrf_bitmap_check() to test whether the flag, in the given
bit-map and for the given VRF ID, is set.
- Client side:
- In "struct zclient", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
default_information
These flags are extended for each VRF, and controlled by the
clients themselves (or with the help of zclient_redistribute()
and zclient_redistribute_default()).
- Zebra side:
- In "struct zserv", the following flags are changed from
"u_char" to "vrf_bitmap_t":
redist[ZEBRA_ROUTE_MAX]
redist_default
ifinfo
ridinfo
These flags are extended for each VRF, as the VRF registration
flags. They are maintained on receiving a ZEBRA_XXX_ADD or
ZEBRA_XXX_DELETE message.
When sending an interface/address/route/router-id message in
a VRF to a client, if the corresponding VRF registration flag
is not set, this message will not be dropped by zebra.
- A new function zread_vrf_unregister() is introduced to process
the new command ZEBRA_VRF_UNREGISTER. All the VRF registration
flags are cleared for the requested VRF.
Those clients, who support only the default VRF, will never receive
a message in a non-default VRF, thanks to the filter in zebra.
* New callback for the event of successful connection to zebra:
- zclient_start() is splitted, keeping only the code of connecting
to zebra.
- Now zclient_init()=>zclient_connect()=>zclient_start() operations
are purely dealing with the connection to zbera.
- Once zebra is successfully connected, at the end of zclient_start(),
a new callback is used to inform the client about connection.
- Till now, in the callback of connect-to-zebra event, all clients
send messages to zebra to request the router-id/interface/routes
information in the default VRF.
Of corse in future the client can do anything it wants in this
callback. For example, it may send requests for both default VRF
and some non-default VRFs.
Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Conflicts:
lib/zclient.h
lib/zebra.h
zebra/zserv.c
zebra/zserv.h
Conflicts:
bgpd/bgp_nexthop.c
bgpd/bgp_nht.c
bgpd/bgp_zebra.c
isisd/isis_zebra.c
lib/zclient.c
lib/zclient.h
lib/zebra.h
nhrpd/nhrp_interface.c
nhrpd/nhrp_route.c
nhrpd/nhrpd.h
ospf6d/ospf6_zebra.c
ospf6d/ospf6_zebra.h
ospfd/ospf_vty.c
ospfd/ospf_zebra.c
pimd/pim_zebra.c
pimd/pim_zlookup.c
ripd/rip_zebra.c
ripngd/ripng_zebra.c
zebra/redistribute.c
zebra/rt_netlink.c
zebra/zebra_rnh.c
zebra/zebra_rnh.h
zebra/zserv.c
zebra/zserv.h
2014-10-16 03:52:36 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct zclient *zclient;
|
2015-05-20 03:04:20 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
zclient = THREAD_ARG(t);
|
|
|
|
zclient->t_connect = NULL;
|
2015-05-20 03:04:20 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient_connect is called");
|
2015-05-20 03:04:20 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return zclient_start(zclient);
|
2015-05-20 03:04:20 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 00:36:03 +01:00
|
|
|
int zclient_send_rnh(struct zclient *zclient, int command, struct prefix *p,
|
|
|
|
bool exact_match, vrf_id_t vrf_id)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, command, vrf_id);
|
|
|
|
stream_putc(s, (exact_match) ? 1 : 0);
|
|
|
|
|
|
|
|
stream_putw(s, PREFIX_FAMILY(p));
|
|
|
|
stream_putc(s, p->prefixlen);
|
|
|
|
switch (PREFIX_FAMILY(p)) {
|
|
|
|
case AF_INET:
|
|
|
|
stream_put_in_addr(s, &p->u.prefix4);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
stream_put(s, &(p->u.prefix6), 16);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
|
|
|
* "xdr_encode"-like interface that allows daemon (client) to send
|
|
|
|
* a message to zebra server for a route that needs to be
|
|
|
|
* added/deleted to the kernel. Info about the route is specified
|
|
|
|
* by the caller in a struct zapi_ipv4. zapi_ipv4_read() then writes
|
|
|
|
* the info down the zclient socket using the stream_* functions.
|
|
|
|
*
|
|
|
|
* The corresponding read ("xdr_decode") function on the server
|
|
|
|
* side is zread_ipv4_add()/zread_ipv4_delete().
|
|
|
|
*
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Length (2) | Command | Route Type |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | ZEBRA Flags | Message Flags | Prefix length |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Destination IPv4 Prefix for route |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Nexthop count |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* A number of IPv4 nexthop(s) or nexthop interface index(es) are then
|
|
|
|
* described, as per the Nexthop count. Each nexthop described as:
|
|
|
|
*
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | Nexthop Type | Set to one of ZEBRA_NEXTHOP_*
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | IPv4 Nexthop address or Interface Index number |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*
|
2012-04-11 23:52:46 +02:00
|
|
|
* Alternatively, if the route is a blackhole route, then Nexthop count
|
|
|
|
* is set to 1 and a nexthop of type NEXTHOP_TYPE_BLACKHOLE is the sole
|
|
|
|
* nexthop.
|
2017-07-17 14:03:14 +02:00
|
|
|
*
|
|
|
|
* The original struct zapi_ipv4, zapi_ipv4_route() and zread_ipv4_*()
|
|
|
|
* infrastructure was built around the traditional (32-bit "gate OR
|
|
|
|
* ifindex") nexthop data unit. A special encoding can be used to feed
|
|
|
|
* onlink (64-bit "gate AND ifindex") nexthops into zapi_ipv4_route()
|
|
|
|
* using the same zapi_ipv4 structure. This is done by setting zapi_ipv4
|
|
|
|
* fields as follows:
|
|
|
|
* - .message |= ZAPI_MESSAGE_NEXTHOP | ZAPI_MESSAGE_ONLINK
|
|
|
|
* - .nexthop_num == .ifindex_num
|
|
|
|
* - .nexthop and .ifindex are filled with gate and ifindex parts of
|
|
|
|
* each compound nexthop, both in the same order
|
|
|
|
*
|
|
|
|
* zapi_ipv4_route() will produce two nexthop data units for each such
|
|
|
|
* interleaved 64-bit nexthop. On the zserv side of the socket it will be
|
|
|
|
* mapped to a singlle NEXTHOP_TYPE_IPV4_IFINDEX_OL RIB nexthop structure.
|
|
|
|
*
|
|
|
|
* If ZAPI_MESSAGE_DISTANCE is set, the distance value is written as a 1
|
|
|
|
* byte value.
|
|
|
|
*
|
|
|
|
* If ZAPI_MESSAGE_METRIC is set, the metric value is written as an 8
|
|
|
|
* byte value.
|
|
|
|
*
|
|
|
|
* If ZAPI_MESSAGE_TAG is set, the tag value is written as a 4 byte value
|
|
|
|
*
|
|
|
|
* If ZAPI_MESSAGE_MTU is set, the mtu value is written as a 4 byte value
|
|
|
|
*
|
|
|
|
* XXX: No attention paid to alignment.
|
|
|
|
*/
|
2018-03-27 21:13:34 +02:00
|
|
|
int zapi_ipv4_route(uint8_t cmd, struct zclient *zclient, struct prefix_ipv4 *p,
|
2017-07-17 14:03:14 +02:00
|
|
|
struct zapi_ipv4 *api)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int i;
|
|
|
|
int psize;
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
/* Reset stream. */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
/* Some checks for labeled-unicast. The current expectation is that each
|
|
|
|
* nexthop is accompanied by a label in the case of labeled-unicast.
|
|
|
|
*/
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)
|
|
|
|
&& CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
|
|
|
/* We expect prefixes installed with labels and the number to
|
|
|
|
* match
|
|
|
|
* the number of nexthops.
|
|
|
|
*/
|
|
|
|
assert(api->label_num == api->nexthop_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
zclient_create_header(s, cmd, api->vrf_id);
|
|
|
|
|
|
|
|
/* Put type and nexthop. */
|
|
|
|
stream_putc(s, api->type);
|
|
|
|
stream_putw(s, api->instance);
|
|
|
|
stream_putl(s, api->flags);
|
|
|
|
stream_putc(s, api->message);
|
|
|
|
stream_putw(s, api->safi);
|
|
|
|
|
|
|
|
/* Put prefix information. */
|
|
|
|
psize = PSIZE(p->prefixlen);
|
|
|
|
stream_putc(s, p->prefixlen);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&p->prefix, psize);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Nexthop, ifindex, distance and metric information. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
2012-04-11 23:52:46 +02:00
|
|
|
stream_putc(s, api->nexthop_num + api->ifindex_num);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
for (i = 0; i < api->nexthop_num; i++) {
|
|
|
|
stream_putc(s, NEXTHOP_TYPE_IPV4);
|
|
|
|
stream_put_in_addr(s, api->nexthop[i]);
|
|
|
|
/* For labeled-unicast, each nexthop is followed by
|
|
|
|
* label. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL))
|
|
|
|
stream_putl(s, api->label[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < api->ifindex_num; i++) {
|
|
|
|
stream_putc(s, NEXTHOP_TYPE_IFINDEX);
|
|
|
|
stream_putl(s, api->ifindex[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
|
|
|
|
stream_putc(s, api->distance);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
|
|
|
|
stream_putl(s, api->metric);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
|
|
|
|
stream_putl(s, api->tag);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
|
|
|
|
stream_putl(s, api->mtu);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
int zapi_ipv4_route_ipv6_nexthop(uint8_t cmd, struct zclient *zclient,
|
2017-07-17 14:03:14 +02:00
|
|
|
struct prefix_ipv4 *p, struct zapi_ipv6 *api)
|
2015-06-11 18:19:12 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int i;
|
|
|
|
int psize;
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
/* Reset stream. */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
/* Some checks for labeled-unicast. The current expectation is that each
|
|
|
|
* nexthop is accompanied by a label in the case of labeled-unicast.
|
|
|
|
*/
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)
|
|
|
|
&& CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
|
|
|
/* We expect prefixes installed with labels and the number to
|
|
|
|
* match
|
|
|
|
* the number of nexthops.
|
|
|
|
*/
|
|
|
|
assert(api->label_num == api->nexthop_num);
|
2015-06-11 18:19:12 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
zclient_create_header(s, cmd, api->vrf_id);
|
|
|
|
|
|
|
|
/* Put type and nexthop. */
|
|
|
|
stream_putc(s, api->type);
|
|
|
|
stream_putw(s, api->instance);
|
|
|
|
stream_putl(s, api->flags);
|
|
|
|
stream_putc(s, api->message);
|
|
|
|
stream_putw(s, api->safi);
|
|
|
|
|
|
|
|
/* Put prefix information. */
|
|
|
|
psize = PSIZE(p->prefixlen);
|
|
|
|
stream_putc(s, p->prefixlen);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&p->prefix, psize);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Nexthop, ifindex, distance and metric information. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
2012-04-11 23:52:46 +02:00
|
|
|
stream_putc(s, api->nexthop_num + api->ifindex_num);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
for (i = 0; i < api->nexthop_num; i++) {
|
|
|
|
stream_putc(s, NEXTHOP_TYPE_IPV6);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)api->nexthop[i], 16);
|
2017-07-17 14:03:14 +02:00
|
|
|
/* For labeled-unicast, each nexthop is followed by
|
|
|
|
* label. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL))
|
|
|
|
stream_putl(s, api->label[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < api->ifindex_num; i++) {
|
|
|
|
stream_putc(s, NEXTHOP_TYPE_IFINDEX);
|
|
|
|
stream_putl(s, api->ifindex[i]);
|
|
|
|
}
|
2015-06-11 18:19:12 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
|
|
|
|
stream_putc(s, api->distance);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
|
|
|
|
stream_putl(s, api->metric);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
|
|
|
|
stream_putl(s, api->tag);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
|
|
|
|
stream_putl(s, api->mtu);
|
2015-06-11 18:19:12 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
2015-06-11 18:19:12 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return zclient_send_message(zclient);
|
2015-06-11 18:19:12 +02:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
int zapi_ipv6_route(uint8_t cmd, struct zclient *zclient, struct prefix_ipv6 *p,
|
2017-07-17 14:03:14 +02:00
|
|
|
struct prefix_ipv6 *src_p, struct zapi_ipv6 *api)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int i;
|
|
|
|
int psize;
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
/* either we have !SRCPFX && src_p == NULL, or SRCPFX && src_p != NULL
|
|
|
|
*/
|
|
|
|
assert(!(api->message & ZAPI_MESSAGE_SRCPFX) == !src_p);
|
|
|
|
|
|
|
|
/* Reset stream. */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
/* Some checks for labeled-unicast. The current expectation is that each
|
|
|
|
* nexthop is accompanied by a label in the case of labeled-unicast.
|
|
|
|
*/
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)
|
|
|
|
&& CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
|
|
|
/* We expect prefixes installed with labels and the number to
|
|
|
|
* match
|
|
|
|
* the number of nexthops.
|
|
|
|
*/
|
|
|
|
assert(api->label_num == api->nexthop_num);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
zclient_create_header(s, cmd, api->vrf_id);
|
|
|
|
|
|
|
|
/* Put type and nexthop. */
|
|
|
|
stream_putc(s, api->type);
|
|
|
|
stream_putw(s, api->instance);
|
|
|
|
stream_putl(s, api->flags);
|
|
|
|
stream_putc(s, api->message);
|
|
|
|
stream_putw(s, api->safi);
|
|
|
|
|
|
|
|
/* Put prefix information. */
|
|
|
|
psize = PSIZE(p->prefixlen);
|
|
|
|
stream_putc(s, p->prefixlen);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&p->prefix, psize);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {
|
|
|
|
psize = PSIZE(src_p->prefixlen);
|
|
|
|
stream_putc(s, src_p->prefixlen);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&src_p->prefix, psize);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Nexthop, ifindex, distance and metric information. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
2012-04-11 23:52:46 +02:00
|
|
|
stream_putc(s, api->nexthop_num + api->ifindex_num);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
for (i = 0; i < api->nexthop_num; i++) {
|
|
|
|
stream_putc(s, NEXTHOP_TYPE_IPV6);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)api->nexthop[i], 16);
|
2017-07-17 14:03:14 +02:00
|
|
|
/* For labeled-unicast, each nexthop is followed by
|
|
|
|
* label. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL))
|
|
|
|
stream_putl(s, api->label[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i < api->ifindex_num; i++) {
|
|
|
|
stream_putc(s, NEXTHOP_TYPE_IFINDEX);
|
|
|
|
stream_putl(s, api->ifindex[i]);
|
|
|
|
}
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
|
|
|
|
stream_putc(s, api->distance);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
|
|
|
|
stream_putl(s, api->metric);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
|
|
|
|
stream_putl(s, api->tag);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
|
|
|
|
stream_putl(s, api->mtu);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
int zclient_route_send(uint8_t cmd, struct zclient *zclient,
|
2017-08-20 02:59:41 +02:00
|
|
|
struct zapi_route *api)
|
2017-06-05 01:14:44 +02:00
|
|
|
{
|
2017-08-20 02:59:41 +02:00
|
|
|
if (zapi_route_encode(cmd, zclient->obuf, api) < 0)
|
|
|
|
return -1;
|
|
|
|
return zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
|
2017-08-20 02:59:41 +02:00
|
|
|
{
|
|
|
|
struct zapi_nexthop *api_nh;
|
2017-07-17 14:03:14 +02:00
|
|
|
int i;
|
|
|
|
int psize;
|
|
|
|
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, cmd, api->vrf_id);
|
|
|
|
|
|
|
|
stream_putc(s, api->type);
|
|
|
|
stream_putw(s, api->instance);
|
|
|
|
stream_putl(s, api->flags);
|
|
|
|
stream_putc(s, api->message);
|
2017-11-06 19:04:19 +01:00
|
|
|
stream_putc(s, api->safi);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Put prefix information. */
|
2017-08-20 02:59:41 +02:00
|
|
|
stream_putc(s, api->prefix.family);
|
2017-08-20 02:25:12 +02:00
|
|
|
psize = PSIZE(api->prefix.prefixlen);
|
|
|
|
stream_putc(s, api->prefix.prefixlen);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&api->prefix.u.prefix, psize);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {
|
2017-08-20 02:25:12 +02:00
|
|
|
psize = PSIZE(api->src_prefix.prefixlen);
|
|
|
|
stream_putc(s, api->src_prefix.prefixlen);
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&api->src_prefix.prefix, psize);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
|
2017-08-20 02:59:41 +02:00
|
|
|
/* Nexthops. */
|
2017-07-17 14:03:14 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
2017-08-20 02:25:12 +02:00
|
|
|
/* limit the number of nexthops if necessary */
|
|
|
|
if (api->nexthop_num > MULTIPATH_NUM) {
|
|
|
|
char buf[PREFIX2STR_BUFFER];
|
|
|
|
|
|
|
|
prefix2str(&api->prefix, buf, sizeof(buf));
|
|
|
|
zlog_warn(
|
2017-09-21 14:49:31 +02:00
|
|
|
"%s: prefix %s: can't encode %u nexthops "
|
|
|
|
"(maximum is %u)",
|
|
|
|
__func__, buf, api->nexthop_num, MULTIPATH_NUM);
|
|
|
|
return -1;
|
2017-08-20 02:25:12 +02:00
|
|
|
}
|
|
|
|
|
2017-08-24 14:30:08 +02:00
|
|
|
stream_putw(s, api->nexthop_num);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
for (i = 0; i < api->nexthop_num; i++) {
|
2017-08-20 02:25:12 +02:00
|
|
|
api_nh = &api->nexthops[i];
|
|
|
|
|
2018-02-08 15:12:12 +01:00
|
|
|
stream_putl(s, api_nh->vrf_id);
|
2017-08-20 02:25:12 +02:00
|
|
|
stream_putc(s, api_nh->type);
|
|
|
|
switch (api_nh->type) {
|
2017-07-17 14:03:14 +02:00
|
|
|
case NEXTHOP_TYPE_BLACKHOLE:
|
2017-08-28 06:01:13 +02:00
|
|
|
stream_putc(s, api_nh->bh_type);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV4:
|
2017-08-20 02:25:12 +02:00
|
|
|
stream_put_in_addr(s, &api_nh->gate.ipv4);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
2017-08-20 02:25:12 +02:00
|
|
|
stream_put_in_addr(s, &api_nh->gate.ipv4);
|
|
|
|
stream_putl(s, api_nh->ifindex);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IFINDEX:
|
2017-08-20 02:25:12 +02:00
|
|
|
stream_putl(s, api_nh->ifindex);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV6:
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&api_nh->gate.ipv6,
|
2017-08-20 02:25:12 +02:00
|
|
|
16);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&api_nh->gate.ipv6,
|
2017-08-20 02:25:12 +02:00
|
|
|
16);
|
|
|
|
stream_putl(s, api_nh->ifindex);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
2017-11-10 14:51:34 +01:00
|
|
|
default:
|
2018-03-06 20:02:52 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: Specified Nexthop type %d does not exist",
|
|
|
|
__PRETTY_FUNCTION__, api_nh->type);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2017-08-20 02:25:12 +02:00
|
|
|
|
2017-08-21 00:57:36 +02:00
|
|
|
/* MPLS labels for BGP-LU or Segment Routing */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)) {
|
|
|
|
if (api_nh->label_num > MPLS_MAX_LABELS) {
|
|
|
|
char buf[PREFIX2STR_BUFFER];
|
|
|
|
prefix2str(&api->prefix, buf,
|
|
|
|
sizeof(buf));
|
|
|
|
zlog_err(
|
|
|
|
"%s: prefix %s: can't encode "
|
|
|
|
"%u labels (maximum is %u)",
|
|
|
|
__func__, buf,
|
|
|
|
api_nh->label_num,
|
|
|
|
MPLS_MAX_LABELS);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream_putc(s, api_nh->label_num);
|
|
|
|
stream_put(s, &api_nh->labels[0],
|
|
|
|
api_nh->label_num
|
|
|
|
* sizeof(mpls_label_t));
|
|
|
|
}
|
2017-11-29 08:40:30 +01:00
|
|
|
|
|
|
|
/* Router MAC for EVPN routes. */
|
|
|
|
if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE))
|
|
|
|
stream_put(s, &(api_nh->rmac),
|
|
|
|
sizeof(struct ethaddr));
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-20 02:59:41 +02:00
|
|
|
/* Attributes. */
|
2017-07-17 14:03:14 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
|
|
|
|
stream_putc(s, api->distance);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
|
|
|
|
stream_putl(s, api->metric);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
|
|
|
|
stream_putl(s, api->tag);
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
|
|
|
|
stream_putl(s, api->mtu);
|
2018-02-10 00:38:02 +01:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
|
|
|
|
stream_putl(s, api->tableid);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
2017-08-20 02:59:41 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int zapi_route_decode(struct stream *s, struct zapi_route *api)
|
|
|
|
{
|
|
|
|
struct zapi_nexthop *api_nh;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(api, 0, sizeof(*api));
|
|
|
|
|
|
|
|
/* Type, flags, message. */
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api->type);
|
|
|
|
if (api->type > ZEBRA_ROUTE_MAX) {
|
|
|
|
zlog_warn("%s: Specified route type: %d is not a legal value\n",
|
2018-03-06 20:02:52 +01:00
|
|
|
__PRETTY_FUNCTION__, api->type);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
STREAM_GETW(s, api->instance);
|
|
|
|
STREAM_GETL(s, api->flags);
|
|
|
|
STREAM_GETC(s, api->message);
|
2017-11-06 19:04:19 +01:00
|
|
|
STREAM_GETC(s, api->safi);
|
2017-08-20 02:59:41 +02:00
|
|
|
|
|
|
|
/* Prefix. */
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api->prefix.family);
|
|
|
|
STREAM_GETC(s, api->prefix.prefixlen);
|
2017-08-20 02:59:41 +02:00
|
|
|
switch (api->prefix.family) {
|
|
|
|
case AF_INET:
|
2017-11-10 14:51:34 +01:00
|
|
|
if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) {
|
2018-03-06 20:02:52 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: V4 prefixlen is %d which should not be more than 32",
|
|
|
|
__PRETTY_FUNCTION__, api->prefix.prefixlen);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
|
|
|
case AF_INET6:
|
2017-11-10 14:51:34 +01:00
|
|
|
if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
|
2018-03-06 20:02:52 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: v6 prefixlen is %d which should not be more than 128",
|
|
|
|
__PRETTY_FUNCTION__, api->prefix.prefixlen);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
2017-11-10 14:51:34 +01:00
|
|
|
default:
|
|
|
|
zlog_warn("%s: Specified family %d is not v4 or v6",
|
|
|
|
__PRETTY_FUNCTION__, api->prefix.family);
|
|
|
|
return -1;
|
2017-08-20 02:59:41 +02:00
|
|
|
}
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GET(&api->prefix.u.prefix, s, PSIZE(api->prefix.prefixlen));
|
|
|
|
|
2017-08-20 02:59:41 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_SRCPFX)) {
|
|
|
|
api->src_prefix.family = AF_INET6;
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api->src_prefix.prefixlen);
|
|
|
|
if (api->src_prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
|
2018-03-06 20:02:52 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: SRC Prefix prefixlen received: %d is too large",
|
|
|
|
__PRETTY_FUNCTION__, api->src_prefix.prefixlen);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
STREAM_GET(&api->src_prefix.prefix, s,
|
2017-08-20 02:59:41 +02:00
|
|
|
PSIZE(api->src_prefix.prefixlen));
|
|
|
|
|
|
|
|
if (api->prefix.family != AF_INET6
|
2017-11-10 14:51:34 +01:00
|
|
|
|| api->src_prefix.prefixlen == 0) {
|
2018-03-06 20:02:52 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: SRC prefix specified in some manner that makes no sense",
|
|
|
|
__PRETTY_FUNCTION__);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
|
|
|
}
|
2017-08-20 02:59:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Nexthops. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETW(s, api->nexthop_num);
|
2017-08-20 02:59:41 +02:00
|
|
|
if (api->nexthop_num > MULTIPATH_NUM) {
|
|
|
|
zlog_warn("%s: invalid number of nexthops (%u)",
|
|
|
|
__func__, api->nexthop_num);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < api->nexthop_num; i++) {
|
|
|
|
api_nh = &api->nexthops[i];
|
|
|
|
|
2018-02-08 15:12:12 +01:00
|
|
|
STREAM_GETL(s, api_nh->vrf_id);
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api_nh->type);
|
2017-08-20 02:59:41 +02:00
|
|
|
switch (api_nh->type) {
|
|
|
|
case NEXTHOP_TYPE_BLACKHOLE:
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api_nh->bh_type);
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV4:
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GET(&api_nh->gate.ipv4.s_addr, s,
|
|
|
|
IPV4_MAX_BYTELEN);
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GET(&api_nh->gate.ipv4.s_addr, s,
|
|
|
|
IPV4_MAX_BYTELEN);
|
|
|
|
STREAM_GETL(s, api_nh->ifindex);
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IFINDEX:
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETL(s, api_nh->ifindex);
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV6:
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GET(&api_nh->gate.ipv6, s, 16);
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GET(&api_nh->gate.ipv6, s, 16);
|
|
|
|
STREAM_GETL(s, api_nh->ifindex);
|
2017-08-20 02:59:41 +02:00
|
|
|
break;
|
2017-11-10 14:51:34 +01:00
|
|
|
default:
|
2018-03-06 20:02:52 +01:00
|
|
|
zlog_warn(
|
|
|
|
"%s: Specified nexthop type %d does not exist",
|
|
|
|
__PRETTY_FUNCTION__, api_nh->type);
|
2017-11-10 14:51:34 +01:00
|
|
|
return -1;
|
2017-08-20 02:59:41 +02:00
|
|
|
}
|
|
|
|
|
2017-08-21 00:57:36 +02:00
|
|
|
/* MPLS labels for BGP-LU or Segment Routing */
|
2017-08-20 02:59:41 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_LABEL)) {
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api_nh->label_num);
|
2017-08-21 00:57:36 +02:00
|
|
|
|
|
|
|
if (api_nh->label_num > MPLS_MAX_LABELS) {
|
|
|
|
zlog_warn(
|
|
|
|
"%s: invalid number of MPLS "
|
|
|
|
"labels (%u)",
|
|
|
|
__func__, api_nh->label_num);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GET(&api_nh->labels[0], s,
|
2017-08-21 00:57:36 +02:00
|
|
|
api_nh->label_num
|
|
|
|
* sizeof(mpls_label_t));
|
2017-08-20 02:59:41 +02:00
|
|
|
}
|
2017-11-29 08:40:30 +01:00
|
|
|
|
|
|
|
/* Router MAC for EVPN routes. */
|
|
|
|
if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE))
|
|
|
|
stream_get(&(api_nh->rmac), s,
|
|
|
|
sizeof(struct ethaddr));
|
2017-08-20 02:59:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attributes. */
|
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_DISTANCE))
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, api->distance);
|
2017-08-20 02:59:41 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_METRIC))
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETL(s, api->metric);
|
2017-08-20 02:59:41 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TAG))
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETL(s, api->tag);
|
2017-08-20 02:59:41 +02:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_MTU))
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETL(s, api->mtu);
|
2018-02-10 00:38:02 +01:00
|
|
|
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_TABLEID))
|
|
|
|
STREAM_GETL(s, api->tableid);
|
2017-08-20 02:59:41 +02:00
|
|
|
|
2017-11-10 14:51:34 +01:00
|
|
|
stream_failure:
|
2017-08-20 02:59:41 +02:00
|
|
|
return 0;
|
2017-06-05 01:14:44 +02:00
|
|
|
}
|
|
|
|
|
2018-05-08 10:13:20 +02:00
|
|
|
static void zapi_encode_prefix(struct stream *s, struct prefix *p,
|
|
|
|
uint8_t family)
|
2018-03-21 11:55:38 +01:00
|
|
|
{
|
|
|
|
struct prefix any;
|
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
memset(&any, 0, sizeof(any));
|
|
|
|
any.family = family;
|
|
|
|
p = &any;
|
|
|
|
}
|
|
|
|
|
|
|
|
stream_putc(s, p->family);
|
|
|
|
stream_putc(s, p->prefixlen);
|
|
|
|
stream_put(s, &p->u.prefix, prefix_blen(p));
|
|
|
|
}
|
|
|
|
|
2018-05-08 10:13:20 +02:00
|
|
|
int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s, struct pbr_rule *zrule)
|
2018-03-21 11:55:38 +01:00
|
|
|
{
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, cmd, zrule->vrf_id);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We are sending one item at a time at the moment
|
|
|
|
*/
|
|
|
|
stream_putl(s, 1);
|
|
|
|
|
|
|
|
stream_putl(s, zrule->seq);
|
|
|
|
stream_putl(s, zrule->priority);
|
|
|
|
stream_putl(s, zrule->unique);
|
|
|
|
|
|
|
|
zapi_encode_prefix(s, &(zrule->filter.src_ip),
|
|
|
|
zrule->filter.src_ip.family);
|
2018-05-08 10:13:20 +02:00
|
|
|
stream_putw(s, zrule->filter.src_port); /* src port */
|
2018-03-21 11:55:38 +01:00
|
|
|
zapi_encode_prefix(s, &(zrule->filter.dst_ip),
|
|
|
|
zrule->filter.src_ip.family);
|
2018-05-08 10:13:20 +02:00
|
|
|
stream_putw(s, zrule->filter.dst_port); /* dst port */
|
|
|
|
stream_putw(s, zrule->filter.fwmark); /* fwmark */
|
2018-03-21 11:55:38 +01:00
|
|
|
|
|
|
|
stream_putl(s, zrule->action.table);
|
|
|
|
stream_putl(s, zrule->ifindex);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-11-09 19:55:46 +01:00
|
|
|
bool zapi_route_notify_decode(struct stream *s, struct prefix *p,
|
2018-02-10 01:27:52 +01:00
|
|
|
uint32_t *tableid,
|
2017-11-09 19:55:46 +01:00
|
|
|
enum zapi_route_notify_owner *note)
|
|
|
|
{
|
2018-02-14 03:34:07 +01:00
|
|
|
uint32_t t;
|
|
|
|
|
2017-11-09 19:55:46 +01:00
|
|
|
STREAM_GET(note, s, sizeof(*note));
|
|
|
|
|
|
|
|
STREAM_GETC(s, p->family);
|
|
|
|
STREAM_GETC(s, p->prefixlen);
|
2018-03-06 20:02:52 +01:00
|
|
|
STREAM_GET(&p->u.prefix, s, prefix_blen(p));
|
2018-02-14 03:34:07 +01:00
|
|
|
STREAM_GETL(s, t);
|
|
|
|
|
|
|
|
*tableid = t;
|
2017-11-09 19:55:46 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-23 19:48:06 +01:00
|
|
|
bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
|
|
|
|
uint32_t *priority, uint32_t *unique,
|
|
|
|
ifindex_t *ifindex,
|
|
|
|
enum zapi_rule_notify_owner *note)
|
|
|
|
{
|
|
|
|
uint32_t prio, seq, uni;
|
|
|
|
ifindex_t ifi;
|
|
|
|
|
|
|
|
STREAM_GET(note, s, sizeof(*note));
|
|
|
|
|
|
|
|
STREAM_GETL(s, seq);
|
|
|
|
STREAM_GETL(s, prio);
|
|
|
|
STREAM_GETL(s, uni);
|
|
|
|
STREAM_GETL(s, ifi);
|
|
|
|
|
|
|
|
if (zclient_debug)
|
2018-05-08 10:13:20 +02:00
|
|
|
zlog_debug("%s: %u %u %u %u", __PRETTY_FUNCTION__, seq, prio,
|
|
|
|
uni, ifi);
|
2018-02-23 19:48:06 +01:00
|
|
|
*seqno = seq;
|
|
|
|
*priority = prio;
|
|
|
|
*unique = uni;
|
|
|
|
*ifindex = ifi;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-08 10:13:20 +02:00
|
|
|
bool zapi_ipset_notify_decode(struct stream *s, uint32_t *unique,
|
|
|
|
enum zapi_ipset_notify_owner *note)
|
2018-03-07 15:46:00 +01:00
|
|
|
{
|
|
|
|
uint32_t uni;
|
|
|
|
|
|
|
|
STREAM_GET(note, s, sizeof(*note));
|
|
|
|
|
|
|
|
STREAM_GETL(s, uni);
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni);
|
|
|
|
*unique = uni;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-05-08 10:13:20 +02:00
|
|
|
bool zapi_ipset_entry_notify_decode(struct stream *s, uint32_t *unique,
|
|
|
|
char *ipset_name,
|
|
|
|
enum zapi_ipset_entry_notify_owner *note)
|
2018-03-07 15:46:00 +01:00
|
|
|
{
|
|
|
|
uint32_t uni;
|
|
|
|
|
|
|
|
STREAM_GET(note, s, sizeof(*note));
|
|
|
|
|
|
|
|
STREAM_GETL(s, uni);
|
|
|
|
|
2018-05-08 10:13:20 +02:00
|
|
|
STREAM_GET(ipset_name, s, ZEBRA_IPSET_NAME_SIZE);
|
2018-03-07 15:46:00 +01:00
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni);
|
|
|
|
*unique = uni;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-12 09:38:53 +01:00
|
|
|
bool zapi_iptable_notify_decode(struct stream *s,
|
|
|
|
uint32_t *unique,
|
|
|
|
enum zapi_iptable_notify_owner *note)
|
|
|
|
{
|
|
|
|
uint32_t uni;
|
|
|
|
|
|
|
|
STREAM_GET(note, s, sizeof(*note));
|
|
|
|
|
|
|
|
STREAM_GETL(s, uni);
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: %u", __PRETTY_FUNCTION__, uni);
|
|
|
|
*unique = uni;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-05 09:44:29 +01:00
|
|
|
struct nexthop *nexthop_from_zapi_nexthop(struct zapi_nexthop *znh)
|
|
|
|
{
|
|
|
|
struct nexthop *n = nexthop_new();
|
|
|
|
|
|
|
|
n->type = znh->type;
|
2018-02-08 15:12:12 +01:00
|
|
|
n->vrf_id = znh->vrf_id;
|
2018-02-05 09:44:29 +01:00
|
|
|
n->ifindex = znh->ifindex;
|
|
|
|
n->gate = znh->gate;
|
|
|
|
|
|
|
|
/*
|
2018-03-24 00:57:03 +01:00
|
|
|
* This function currently handles labels
|
2018-02-05 09:44:29 +01:00
|
|
|
*/
|
2018-03-24 00:57:03 +01:00
|
|
|
if (znh->label_num) {
|
|
|
|
nexthop_add_labels(n, ZEBRA_LSP_NONE, znh->label_num,
|
2018-05-08 10:13:20 +02:00
|
|
|
znh->labels);
|
2018-03-24 00:57:03 +01:00
|
|
|
}
|
2018-02-05 09:44:29 +01:00
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
memset(nhr, 0, sizeof(*nhr));
|
|
|
|
|
|
|
|
STREAM_GETW(s, nhr->prefix.family);
|
|
|
|
STREAM_GETC(s, nhr->prefix.prefixlen);
|
2018-03-06 20:02:52 +01:00
|
|
|
switch (nhr->prefix.family) {
|
2018-02-05 09:44:29 +01:00
|
|
|
case AF_INET:
|
|
|
|
STREAM_GET(&nhr->prefix.u.prefix4.s_addr, s, IPV4_MAX_BYTELEN);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
STREAM_GET(&nhr->prefix.u.prefix6, s, IPV6_MAX_BYTELEN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-01 01:22:47 +01:00
|
|
|
STREAM_GETC(s, nhr->type);
|
|
|
|
STREAM_GETW(s, nhr->instance);
|
2018-02-05 09:44:29 +01:00
|
|
|
STREAM_GETC(s, nhr->distance);
|
|
|
|
STREAM_GETL(s, nhr->metric);
|
|
|
|
STREAM_GETC(s, nhr->nexthop_num);
|
|
|
|
|
2018-03-06 20:02:52 +01:00
|
|
|
for (i = 0; i < nhr->nexthop_num; i++) {
|
2018-02-05 09:44:29 +01:00
|
|
|
STREAM_GETC(s, nhr->nexthops[i].type);
|
|
|
|
switch (nhr->nexthops[i].type) {
|
|
|
|
case NEXTHOP_TYPE_IPV4:
|
|
|
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
2018-03-06 20:02:52 +01:00
|
|
|
STREAM_GET(&nhr->nexthops[i].gate.ipv4.s_addr, s,
|
|
|
|
IPV4_MAX_BYTELEN);
|
2018-02-05 09:44:29 +01:00
|
|
|
STREAM_GETL(s, nhr->nexthops[i].ifindex);
|
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IFINDEX:
|
|
|
|
STREAM_GETL(s, nhr->nexthops[i].ifindex);
|
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_IPV6:
|
|
|
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
2018-03-06 20:02:52 +01:00
|
|
|
STREAM_GET(&nhr->nexthops[i].gate.ipv6, s,
|
|
|
|
IPV6_MAX_BYTELEN);
|
2018-02-05 09:44:29 +01:00
|
|
|
STREAM_GETL(s, nhr->nexthops[i].ifindex);
|
|
|
|
break;
|
|
|
|
case NEXTHOP_TYPE_BLACKHOLE:
|
|
|
|
break;
|
|
|
|
}
|
2018-03-16 15:53:58 +01:00
|
|
|
STREAM_GETC(s, nhr->nexthops[i].label_num);
|
|
|
|
if (nhr->nexthops[i].label_num > MPLS_MAX_LABELS) {
|
|
|
|
zlog_warn("%s: invalid number of MPLS labels (%u)",
|
|
|
|
__func__, nhr->nexthops[i].label_num);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (nhr->nexthops[i].label_num)
|
|
|
|
STREAM_GET(&nhr->nexthops[i].labels[0], s,
|
|
|
|
nhr->nexthops[i].label_num
|
2018-05-08 10:13:20 +02:00
|
|
|
* sizeof(mpls_label_t));
|
2018-02-05 09:44:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
stream_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2004-05-08 13:48:26 +02:00
|
|
|
* send a ZEBRA_REDISTRIBUTE_ADD or ZEBRA_REDISTRIBUTE_DELETE
|
|
|
|
* for the route type (ZEBRA_ROUTE_KERNEL etc.). The zebra server will
|
2017-07-17 14:03:14 +02:00
|
|
|
* then set/unset redist[type] in the client handle (a struct zserv) for the
|
2004-05-08 13:48:26 +02:00
|
|
|
* sending client
|
|
|
|
*/
|
2017-07-17 14:03:14 +02:00
|
|
|
int zebra_redistribute_send(int command, struct zclient *zclient, afi_t afi,
|
2018-03-27 21:13:34 +02:00
|
|
|
int type, unsigned short instance, vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
zclient_create_header(s, command, vrf_id);
|
|
|
|
stream_putc(s, afi);
|
|
|
|
stream_putc(s, type);
|
|
|
|
stream_putw(s, instance);
|
|
|
|
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2016-02-09 16:23:03 +01:00
|
|
|
/* Get prefix in ZServ format; family should be filled in on prefix */
|
2017-07-17 14:03:14 +02:00
|
|
|
static void zclient_stream_get_prefix(struct stream *s, struct prefix *p)
|
2016-02-09 16:23:03 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
size_t plen = prefix_blen(p);
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t c;
|
2017-07-17 14:03:14 +02:00
|
|
|
p->prefixlen = 0;
|
|
|
|
|
|
|
|
if (plen == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stream_get(&p->u.prefix, s, plen);
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, c);
|
2017-07-17 14:03:14 +02:00
|
|
|
p->prefixlen = MIN(plen * 8, c);
|
2017-11-10 14:51:34 +01:00
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return;
|
2016-02-09 16:23:03 +01:00
|
|
|
}
|
|
|
|
|
2004-10-03 20:18:34 +02:00
|
|
|
/* Router-id update from zebra daemon. */
|
2017-07-17 14:03:14 +02:00
|
|
|
void zebra_router_id_update_read(struct stream *s, struct prefix *rid)
|
2004-10-03 20:18:34 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Fetch interface address. */
|
2017-11-10 14:51:34 +01:00
|
|
|
STREAM_GETC(s, rid->family);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
zclient_stream_get_prefix(s, rid);
|
2017-11-10 14:51:34 +01:00
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return;
|
2004-10-03 20:18:34 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Interface addition from zebra daemon. */
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2004-05-08 13:48:26 +02:00
|
|
|
* The format of the message sent with type ZEBRA_INTERFACE_ADD or
|
|
|
|
* ZEBRA_INTERFACE_DELETE from zebra to the client is:
|
|
|
|
* 0 1 2 3
|
|
|
|
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | ifname |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | ifindex |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | status |
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | if_flags |
|
2006-01-11 02:59:04 +01:00
|
|
|
* | |
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | metric |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
2017-03-30 21:37:22 +02:00
|
|
|
* | speed |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | ifmtu |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | ifmtu6 |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | bandwidth |
|
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
* | Link Layer Type |
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | Harware Address Length |
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | Hardware Address if HW lenght different from 0 |
|
|
|
|
* | ... max INTERFACE_HWADDR_MAX |
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | Link_params? | Whether a link-params follows: 1 or 0.
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
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-04-19 16:21:46 +02:00
|
|
|
* | Link_params 0 or 1 INTERFACE_LINK_PARAMS_SIZE sized |
|
|
|
|
* | .... (struct if_link_params). |
|
2004-05-08 13:48:26 +02:00
|
|
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static void zclient_vrf_add(struct zclient *zclient, vrf_id_t vrf_id)
|
2016-02-01 21:11:39 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct vrf *vrf;
|
|
|
|
char vrfname_tmp[VRF_NAMSIZ];
|
|
|
|
struct vrf_data data;
|
2016-02-01 21:11:39 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
stream_get(&data, zclient->ibuf, sizeof(struct vrf_data));
|
|
|
|
/* Read interface name. */
|
|
|
|
stream_get(vrfname_tmp, zclient->ibuf, VRF_NAMSIZ);
|
2016-02-01 21:11:39 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Lookup/create vrf by vrf_id. */
|
|
|
|
vrf = vrf_get(vrf_id, vrfname_tmp);
|
2017-12-22 16:02:51 +01:00
|
|
|
vrf->data.l.table_id = data.l.table_id;
|
|
|
|
memcpy(vrf->data.l.netns_name, data.l.netns_name, NS_NAMSIZ);
|
2017-07-17 14:03:14 +02:00
|
|
|
vrf_enable(vrf);
|
2016-02-01 21:11:39 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static void zclient_vrf_delete(struct zclient *zclient, vrf_id_t vrf_id)
|
2016-02-01 21:11:39 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct vrf *vrf;
|
2016-02-01 21:11:39 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Lookup vrf by vrf_id. */
|
|
|
|
vrf = vrf_lookup_by_id(vrf_id);
|
2016-02-01 21:11:39 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
|
|
|
* If a routing protocol doesn't know about a
|
|
|
|
* vrf that is about to be deleted. There is
|
|
|
|
* no point in attempting to delete it.
|
|
|
|
*/
|
|
|
|
if (!vrf)
|
|
|
|
return;
|
2016-05-13 14:24:50 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
vrf_delete(vrf);
|
2016-02-01 21:11:39 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *zebra_interface_add_read(struct stream *s, vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *ifp;
|
|
|
|
char ifname_tmp[INTERFACE_NAMSIZ];
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Read interface name. */
|
|
|
|
stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Lookup/create interface by name. */
|
2017-10-03 03:05:57 +02:00
|
|
|
ifp = if_get_by_name(ifname_tmp, vrf_id, 0);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
zebra_interface_if_set_value(s, ifp);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return ifp;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/*
|
2004-05-08 13:48:26 +02:00
|
|
|
* Read interface up/down msg (ZEBRA_INTERFACE_UP/ZEBRA_INTERFACE_DOWN)
|
|
|
|
* from zebra server. The format of this message is the same as
|
|
|
|
* that sent for ZEBRA_INTERFACE_ADD/ZEBRA_INTERFACE_DELETE (see
|
|
|
|
* comments for zebra_interface_add_read), except that no sockaddr_dl
|
|
|
|
* is sent at the tail of the message.
|
|
|
|
*/
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *ifp;
|
|
|
|
char ifname_tmp[INTERFACE_NAMSIZ];
|
|
|
|
|
|
|
|
/* Read interface name. */
|
|
|
|
stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
|
|
|
|
|
|
|
|
/* Lookup this by interface index. */
|
2017-10-03 03:05:57 +02:00
|
|
|
ifp = if_lookup_by_name(ifname_tmp, vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
if (ifp == NULL) {
|
|
|
|
zlog_warn("INTERFACE_STATE: Cannot find IF %s in VRF %d",
|
|
|
|
ifname_tmp, vrf_id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
zebra_interface_if_set_value(s, ifp);
|
|
|
|
|
|
|
|
return ifp;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static void link_params_set_value(struct stream *s, struct if_link_params *iflp)
|
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-04-19 16:21:46 +02:00
|
|
|
{
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (iflp == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
iflp->lp_status = stream_getl(s);
|
|
|
|
iflp->te_metric = stream_getl(s);
|
|
|
|
iflp->max_bw = stream_getf(s);
|
|
|
|
iflp->max_rsv_bw = stream_getf(s);
|
|
|
|
uint32_t bwclassnum = stream_getl(s);
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < bwclassnum && i < MAX_CLASS_TYPE; i++)
|
|
|
|
iflp->unrsv_bw[i] = stream_getf(s);
|
|
|
|
if (i < bwclassnum)
|
|
|
|
zlog_err(
|
|
|
|
"%s: received %d > %d (MAX_CLASS_TYPE) bw entries"
|
|
|
|
" - outdated library?",
|
|
|
|
__func__, bwclassnum, MAX_CLASS_TYPE);
|
|
|
|
}
|
|
|
|
iflp->admin_grp = stream_getl(s);
|
|
|
|
iflp->rmt_as = stream_getl(s);
|
|
|
|
iflp->rmt_ip.s_addr = stream_get_ipv4(s);
|
|
|
|
|
|
|
|
iflp->av_delay = stream_getl(s);
|
|
|
|
iflp->min_delay = stream_getl(s);
|
|
|
|
iflp->max_delay = stream_getl(s);
|
|
|
|
iflp->delay_var = stream_getl(s);
|
|
|
|
|
|
|
|
iflp->pkt_loss = stream_getf(s);
|
|
|
|
iflp->res_bw = stream_getf(s);
|
|
|
|
iflp->ava_bw = stream_getf(s);
|
|
|
|
iflp->use_bw = stream_getf(s);
|
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-04-19 16:21:46 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *zebra_interface_link_params_read(struct stream *s)
|
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-04-19 16:21:46 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct if_link_params *iflp;
|
|
|
|
ifindex_t ifindex;
|
2017-02-02 01:43:43 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
assert(s);
|
2017-02-02 01:43:43 +01:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
ifindex = stream_getl(s);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *ifp = if_lookup_by_index(ifindex, VRF_DEFAULT);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (ifp == NULL) {
|
|
|
|
zlog_err("%s: unknown ifindex %u, shouldn't happen", __func__,
|
|
|
|
ifindex);
|
|
|
|
return NULL;
|
|
|
|
}
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if ((iflp = if_link_params_get(ifp)) == NULL)
|
|
|
|
return NULL;
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
link_params_set_value(s, iflp);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return ifp;
|
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-04-19 16:21:46 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
void zebra_interface_if_set_value(struct stream *s, struct interface *ifp)
|
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-04-19 16:21:46 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t link_params_status = 0;
|
2018-04-10 21:57:09 +02:00
|
|
|
ifindex_t old_ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-04-10 21:57:09 +02:00
|
|
|
old_ifindex = ifp->ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
/* Read interface's index. */
|
2017-10-03 03:06:04 +02:00
|
|
|
if_set_index(ifp, stream_getl(s));
|
2017-07-17 14:03:14 +02:00
|
|
|
ifp->status = stream_getc(s);
|
|
|
|
|
|
|
|
/* Read interface's value. */
|
|
|
|
ifp->flags = stream_getq(s);
|
|
|
|
ifp->ptm_enable = stream_getc(s);
|
|
|
|
ifp->ptm_status = stream_getc(s);
|
|
|
|
ifp->metric = stream_getl(s);
|
|
|
|
ifp->speed = stream_getl(s);
|
|
|
|
ifp->mtu = stream_getl(s);
|
|
|
|
ifp->mtu6 = stream_getl(s);
|
|
|
|
ifp->bandwidth = stream_getl(s);
|
|
|
|
ifp->ll_type = stream_getl(s);
|
|
|
|
ifp->hw_addr_len = stream_getl(s);
|
|
|
|
if (ifp->hw_addr_len)
|
|
|
|
stream_get(ifp->hw_addr, s,
|
|
|
|
MIN(ifp->hw_addr_len, INTERFACE_HWADDR_MAX));
|
|
|
|
|
|
|
|
/* Read Traffic Engineering status */
|
|
|
|
link_params_status = stream_getc(s);
|
|
|
|
/* Then, Traffic Engineering parameters if any */
|
|
|
|
if (link_params_status) {
|
|
|
|
struct if_link_params *iflp = if_link_params_get(ifp);
|
|
|
|
link_params_set_value(s, iflp);
|
|
|
|
}
|
2018-04-10 21:57:09 +02:00
|
|
|
|
|
|
|
nexthop_group_interface_state_change(ifp, old_ifindex);
|
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-04-19 16:21:46 +02:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
size_t zebra_interface_link_params_write(struct stream *s,
|
|
|
|
struct interface *ifp)
|
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-04-19 16:21:46 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
size_t w;
|
|
|
|
struct if_link_params *iflp;
|
|
|
|
int i;
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (s == NULL || ifp == NULL || ifp->link_params == NULL)
|
|
|
|
return 0;
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
iflp = ifp->link_params;
|
|
|
|
w = 0;
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
w += stream_putl(s, iflp->lp_status);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
w += stream_putl(s, iflp->te_metric);
|
|
|
|
w += stream_putf(s, iflp->max_bw);
|
|
|
|
w += stream_putf(s, iflp->max_rsv_bw);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
w += stream_putl(s, MAX_CLASS_TYPE);
|
|
|
|
for (i = 0; i < MAX_CLASS_TYPE; i++)
|
|
|
|
w += stream_putf(s, iflp->unrsv_bw[i]);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
w += stream_putl(s, iflp->admin_grp);
|
|
|
|
w += stream_putl(s, iflp->rmt_as);
|
|
|
|
w += stream_put_in_addr(s, &iflp->rmt_ip);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
w += stream_putl(s, iflp->av_delay);
|
|
|
|
w += stream_putl(s, iflp->min_delay);
|
|
|
|
w += stream_putl(s, iflp->max_delay);
|
|
|
|
w += stream_putl(s, iflp->delay_var);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
w += stream_putf(s, iflp->pkt_loss);
|
|
|
|
w += stream_putf(s, iflp->res_bw);
|
|
|
|
w += stream_putf(s, iflp->ava_bw);
|
|
|
|
w += stream_putf(s, iflp->use_bw);
|
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-04-19 16:21:46 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
return w;
|
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-04-19 16:21:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-05-08 13:48:26 +02:00
|
|
|
* format of message for address additon is:
|
|
|
|
* 0
|
|
|
|
* 0 1 2 3 4 5 6 7
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | type | ZEBRA_INTERFACE_ADDRESS_ADD or
|
|
|
|
* +-+-+-+-+-+-+-+-+ ZEBRA_INTERFACE_ADDRES_DELETE
|
|
|
|
* | |
|
|
|
|
* + +
|
|
|
|
* | ifindex |
|
|
|
|
* + +
|
|
|
|
* | |
|
|
|
|
* + +
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | ifc_flags | flags for connected address
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | addr_family |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | addr... |
|
|
|
|
* : :
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | addr_len | len of addr. E.g., addr_len = 4 for ipv4 addrs.
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | daddr.. |
|
|
|
|
* : :
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static int memconstant(const void *s, int c, size_t n)
|
2004-10-19 21:44:43 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
const uint8_t *p = s;
|
2004-10-19 21:44:43 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
while (n-- > 0)
|
|
|
|
if (*p++ != c)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
2004-10-19 21:44:43 +02:00
|
|
|
}
|
|
|
|
|
2015-05-20 02:47:23 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
struct connected *zebra_interface_address_read(int type, struct stream *s,
|
|
|
|
vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
ifindex_t ifindex;
|
|
|
|
struct interface *ifp;
|
|
|
|
struct connected *ifc;
|
|
|
|
struct prefix p, d, *dp;
|
|
|
|
int plen;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t ifc_flags;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
memset(&p, 0, sizeof(p));
|
|
|
|
memset(&d, 0, sizeof(d));
|
|
|
|
|
|
|
|
/* Get interface index. */
|
|
|
|
ifindex = stream_getl(s);
|
|
|
|
|
|
|
|
/* Lookup index. */
|
|
|
|
ifp = if_lookup_by_index(ifindex, vrf_id);
|
|
|
|
if (ifp == NULL) {
|
|
|
|
zlog_warn("INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
|
|
|
|
(type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL",
|
|
|
|
ifindex, vrf_id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch flag. */
|
|
|
|
ifc_flags = stream_getc(s);
|
|
|
|
|
|
|
|
/* Fetch interface address. */
|
|
|
|
d.family = p.family = stream_getc(s);
|
|
|
|
plen = prefix_blen(&d);
|
|
|
|
|
|
|
|
zclient_stream_get_prefix(s, &p);
|
|
|
|
|
|
|
|
/* Fetch destination address. */
|
|
|
|
stream_get(&d.u.prefix, s, plen);
|
|
|
|
|
|
|
|
/* N.B. NULL destination pointers are encoded as all zeroes */
|
|
|
|
dp = memconstant(&d.u.prefix, 0, plen) ? NULL : &d;
|
|
|
|
|
|
|
|
if (type == ZEBRA_INTERFACE_ADDRESS_ADD) {
|
|
|
|
ifc = connected_lookup_prefix_exact(ifp, &p);
|
|
|
|
if (!ifc) {
|
|
|
|
/* N.B. NULL destination pointers are encoded as all
|
|
|
|
* zeroes */
|
|
|
|
ifc = connected_add_by_prefix(ifp, &p, dp);
|
|
|
|
}
|
|
|
|
if (ifc) {
|
|
|
|
ifc->flags = ifc_flags;
|
|
|
|
if (ifc->destination)
|
|
|
|
ifc->destination->prefixlen =
|
|
|
|
ifc->address->prefixlen;
|
|
|
|
else if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_PEER)) {
|
|
|
|
/* carp interfaces on OpenBSD with 0.0.0.0/0 as
|
|
|
|
* "peer" */
|
|
|
|
char buf[PREFIX_STRLEN];
|
|
|
|
zlog_warn(
|
|
|
|
"warning: interface %s address %s "
|
|
|
|
"with peer flag set, but no peer address!",
|
2018-05-08 10:13:20 +02:00
|
|
|
ifp->name,
|
|
|
|
prefix2str(ifc->address, buf,
|
|
|
|
sizeof buf));
|
2017-07-17 14:03:14 +02:00
|
|
|
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
assert(type == ZEBRA_INTERFACE_ADDRESS_DELETE);
|
|
|
|
ifc = connected_delete_by_prefix(ifp, &p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ifc;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2004-05-08 13:48:26 +02:00
|
|
|
|
2015-05-20 02:40:40 +02:00
|
|
|
/*
|
|
|
|
* format of message for neighbor connected address is:
|
|
|
|
* 0
|
|
|
|
* 0 1 2 3 4 5 6 7
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | type | ZEBRA_INTERFACE_NBR_ADDRESS_ADD or
|
|
|
|
* +-+-+-+-+-+-+-+-+ ZEBRA_INTERFACE_NBR_ADDRES_DELETE
|
|
|
|
* | |
|
|
|
|
* + +
|
|
|
|
* | ifindex |
|
|
|
|
* + +
|
|
|
|
* | |
|
|
|
|
* + +
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | addr_family |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | addr... |
|
|
|
|
* : :
|
|
|
|
* | |
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
* | addr_len | len of addr.
|
|
|
|
* +-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
struct nbr_connected *
|
2017-07-17 14:03:14 +02:00
|
|
|
zebra_interface_nbr_address_read(int type, struct stream *s, vrf_id_t vrf_id)
|
2015-05-20 02:40:40 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
unsigned int ifindex;
|
|
|
|
struct interface *ifp;
|
|
|
|
struct prefix p;
|
|
|
|
struct nbr_connected *ifc;
|
|
|
|
|
|
|
|
/* Get interface index. */
|
|
|
|
ifindex = stream_getl(s);
|
|
|
|
|
|
|
|
/* Lookup index. */
|
|
|
|
ifp = if_lookup_by_index(ifindex, vrf_id);
|
|
|
|
if (ifp == NULL) {
|
|
|
|
zlog_warn("INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
|
|
|
|
(type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD"
|
|
|
|
: "DELETE",
|
|
|
|
ifindex, vrf_id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
p.family = stream_getc(s);
|
|
|
|
stream_get(&p.u.prefix, s, prefix_blen(&p));
|
|
|
|
p.prefixlen = stream_getc(s);
|
|
|
|
|
|
|
|
if (type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) {
|
|
|
|
/* Currently only supporting P2P links, so any new RA source
|
|
|
|
address is
|
|
|
|
considered as the replacement of the previously learnt
|
|
|
|
Link-Local address. */
|
|
|
|
if (!(ifc = listnode_head(ifp->nbr_connected))) {
|
|
|
|
ifc = nbr_connected_new();
|
|
|
|
ifc->address = prefix_new();
|
|
|
|
ifc->ifp = ifp;
|
|
|
|
listnode_add(ifp->nbr_connected, ifc);
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix_copy(ifc->address, &p);
|
|
|
|
} else {
|
|
|
|
assert(type == ZEBRA_INTERFACE_NBR_ADDRESS_DELETE);
|
|
|
|
|
|
|
|
ifc = nbr_connected_check(ifp, &p);
|
|
|
|
if (ifc)
|
|
|
|
listnode_delete(ifp->nbr_connected, ifc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ifc;
|
2015-05-20 02:40:40 +02:00
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
struct interface *zebra_interface_vrf_update_read(struct stream *s,
|
|
|
|
vrf_id_t vrf_id,
|
|
|
|
vrf_id_t *new_vrf_id)
|
2016-02-25 20:30:53 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
unsigned int ifindex;
|
|
|
|
struct interface *ifp;
|
lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.
Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.
This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-14 16:01:36 +01:00
|
|
|
vrf_id_t new_id;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Get interface index. */
|
|
|
|
ifindex = stream_getl(s);
|
|
|
|
|
|
|
|
/* Lookup interface. */
|
|
|
|
ifp = if_lookup_by_index(ifindex, vrf_id);
|
|
|
|
if (ifp == NULL) {
|
|
|
|
zlog_warn("INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
|
|
|
|
ifindex, vrf_id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch new VRF Id. */
|
|
|
|
new_id = stream_getw(s);
|
|
|
|
|
|
|
|
*new_vrf_id = new_id;
|
|
|
|
return ifp;
|
2016-02-25 20:30:53 +01:00
|
|
|
}
|
2017-04-26 11:50:21 +02:00
|
|
|
|
|
|
|
/* filter unwanted messages until the expected one arrives */
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zclient_read_sync_response(struct zclient *zclient,
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t expected_cmd)
|
2017-04-26 11:50:21 +02:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
struct stream *s;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t size = -1;
|
|
|
|
uint8_t marker;
|
|
|
|
uint8_t version;
|
2017-07-17 14:03:14 +02:00
|
|
|
vrf_id_t vrf_id;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t cmd;
|
2017-07-17 14:03:14 +02:00
|
|
|
fd_set readfds;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cmd = expected_cmd + 1;
|
|
|
|
while (ret == 0 && cmd != expected_cmd) {
|
|
|
|
s = zclient->ibuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
/* wait until response arrives */
|
|
|
|
FD_ZERO(&readfds);
|
|
|
|
FD_SET(zclient->sock, &readfds);
|
|
|
|
select(zclient->sock + 1, &readfds, NULL, NULL, NULL);
|
|
|
|
if (!FD_ISSET(zclient->sock, &readfds))
|
|
|
|
continue;
|
|
|
|
/* read response */
|
|
|
|
ret = zclient_read_header(s, zclient->sock, &size, &marker,
|
|
|
|
&version, &vrf_id, &cmd);
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: Response (%d bytes) received", __func__,
|
|
|
|
size);
|
|
|
|
}
|
|
|
|
if (ret != 0) {
|
|
|
|
zlog_err("%s: Invalid Sync Message Reply", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2017-04-26 11:50:21 +02:00
|
|
|
}
|
2017-03-20 15:34:49 +01:00
|
|
|
/**
|
|
|
|
* Connect to label manager in a syncronous way
|
|
|
|
*
|
|
|
|
* It first writes the request to zcient output buffer and then
|
|
|
|
* immediately reads the answer from the input buffer.
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to label manager (zebra)
|
|
|
|
* @result Result of response
|
|
|
|
*/
|
2017-07-17 14:03:14 +02:00
|
|
|
int lm_label_manager_connect(struct zclient *zclient)
|
2017-03-20 15:34:49 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int ret;
|
|
|
|
struct stream *s;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t result;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (zclient_debug)
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_debug("Connecting to Label Manager (LM)");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* send request */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, ZEBRA_LABEL_MANAGER_CONNECT, VRF_DEFAULT);
|
|
|
|
|
|
|
|
/* proto */
|
|
|
|
stream_putc(s, zclient->redist_default);
|
|
|
|
/* instance */
|
|
|
|
stream_putw(s, zclient->instance);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
ret = writen(zclient->sock, s->data, stream_get_endp(s));
|
|
|
|
if (ret < 0) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Can't write to zclient sock");
|
2017-07-17 14:03:14 +02:00
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ret == 0) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Zclient sock closed");
|
2017-07-17 14:03:14 +02:00
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (zclient_debug)
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_debug("LM connect request sent (%d bytes)", ret);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* read response */
|
|
|
|
if (zclient_read_sync_response(zclient, ZEBRA_LABEL_MANAGER_CONNECT)
|
|
|
|
!= 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
s = zclient->ibuf;
|
2018-04-26 10:56:19 +02:00
|
|
|
|
|
|
|
/* read instance and proto */
|
|
|
|
uint8_t proto = stream_getc(s);
|
|
|
|
uint16_t instance = stream_getw(s);
|
|
|
|
|
|
|
|
/* sanity */
|
|
|
|
if (proto != zclient->redist_default)
|
2018-05-08 10:13:20 +02:00
|
|
|
zlog_err(
|
|
|
|
"Wrong proto (%u) in LM connect response. Should be %u",
|
|
|
|
proto, zclient->redist_default);
|
2018-04-26 10:56:19 +02:00
|
|
|
if (instance != zclient->instance)
|
2018-05-08 10:13:20 +02:00
|
|
|
zlog_err(
|
|
|
|
"Wrong instId (%u) in LM connect response. Should be %u",
|
|
|
|
instance, zclient->instance);
|
2018-04-26 10:56:19 +02:00
|
|
|
|
|
|
|
/* result code */
|
2017-07-17 14:03:14 +02:00
|
|
|
result = stream_getc(s);
|
|
|
|
if (zclient_debug)
|
2018-05-08 10:13:20 +02:00
|
|
|
zlog_debug("LM connect-response received, result %u", result);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
return (int)result;
|
2017-03-20 15:34:49 +01:00
|
|
|
}
|
|
|
|
|
2018-04-07 20:13:07 +02:00
|
|
|
/*
|
|
|
|
* Asynchronous label chunk request
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to label manager (zebra)
|
|
|
|
* @param keep Avoid garbage collection
|
|
|
|
* @param chunk_size Amount of labels requested
|
|
|
|
* @result 0 on success, -1 otherwise
|
|
|
|
*/
|
2018-05-08 10:13:20 +02:00
|
|
|
int zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
|
|
|
|
uint32_t chunk_size)
|
2018-04-07 20:13:07 +02:00
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("Getting Label Chunk");
|
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
zclient_create_header(s, ZEBRA_GET_LABEL_CHUNK, VRF_DEFAULT);
|
2018-04-26 10:56:19 +02:00
|
|
|
/* proto */
|
|
|
|
stream_putc(s, zclient->redist_default);
|
|
|
|
/* instance */
|
|
|
|
stream_putw(s, zclient->instance);
|
2018-04-07 20:13:07 +02:00
|
|
|
stream_putc(s, keep);
|
|
|
|
stream_putl(s, chunk_size);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
2017-03-20 15:34:49 +01:00
|
|
|
/**
|
|
|
|
* Function to request a label chunk in a syncronous way
|
|
|
|
*
|
|
|
|
* It first writes the request to zlcient output buffer and then
|
|
|
|
* immediately reads the answer from the input buffer.
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to label manager (zebra)
|
|
|
|
* @param keep Avoid garbage collection
|
|
|
|
* @param chunk_size Amount of labels requested
|
|
|
|
* @param start To write first assigned chunk label to
|
|
|
|
* @param end To write last assigned chunk label to
|
|
|
|
* @result 0 on success, -1 otherwise
|
|
|
|
*/
|
2018-03-27 21:13:34 +02:00
|
|
|
int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
|
2017-07-17 14:03:14 +02:00
|
|
|
uint32_t chunk_size, uint32_t *start, uint32_t *end)
|
2017-03-20 15:34:49 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int ret;
|
|
|
|
struct stream *s;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t response_keep;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("Getting Label Chunk");
|
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* send request */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, ZEBRA_GET_LABEL_CHUNK, VRF_DEFAULT);
|
2018-04-26 10:56:19 +02:00
|
|
|
/* proto */
|
|
|
|
stream_putc(s, zclient->redist_default);
|
|
|
|
/* instance */
|
|
|
|
stream_putw(s, zclient->instance);
|
2017-07-17 14:03:14 +02:00
|
|
|
/* keep */
|
|
|
|
stream_putc(s, keep);
|
|
|
|
/* chunk size */
|
|
|
|
stream_putl(s, chunk_size);
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
ret = writen(zclient->sock, s->data, stream_get_endp(s));
|
|
|
|
if (ret < 0) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Can't write to zclient sock");
|
2017-07-17 14:03:14 +02:00
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ret == 0) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Zclient sock closed");
|
2017-07-17 14:03:14 +02:00
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (zclient_debug)
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_debug("Label chunk request (%d bytes) sent", ret);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* read response */
|
|
|
|
if (zclient_read_sync_response(zclient, ZEBRA_GET_LABEL_CHUNK) != 0)
|
|
|
|
return -1;
|
|
|
|
|
2018-04-26 10:56:19 +02:00
|
|
|
/* parse response */
|
2017-07-17 14:03:14 +02:00
|
|
|
s = zclient->ibuf;
|
2018-04-26 10:56:19 +02:00
|
|
|
|
|
|
|
/* read proto and instance */
|
|
|
|
uint8_t proto = stream_getc(s);
|
|
|
|
uint16_t instance = stream_getw(s);
|
|
|
|
|
|
|
|
/* sanities */
|
|
|
|
if (proto != zclient->redist_default)
|
|
|
|
zlog_err("Wrong proto (%u) in get chunk response. Should be %u",
|
2018-05-08 10:13:20 +02:00
|
|
|
proto, zclient->redist_default);
|
2018-04-26 10:56:19 +02:00
|
|
|
if (instance != zclient->instance)
|
|
|
|
zlog_err("Wrong instId (%u) in get chunk response Should be %u",
|
2018-05-08 10:13:20 +02:00
|
|
|
instance, zclient->instance);
|
2018-04-26 10:56:19 +02:00
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
/* keep */
|
|
|
|
response_keep = stream_getc(s);
|
|
|
|
/* start and end labels */
|
|
|
|
*start = stream_getl(s);
|
|
|
|
*end = stream_getl(s);
|
|
|
|
|
|
|
|
/* not owning this response */
|
|
|
|
if (keep != response_keep) {
|
|
|
|
zlog_err(
|
2018-05-01 20:43:14 +02:00
|
|
|
"Invalid Label chunk: %u - %u, keeps mismatch %u != %u",
|
|
|
|
*start, *end, keep, response_keep);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
/* sanity */
|
2018-02-01 00:24:06 +01:00
|
|
|
if (*start > *end || *start < MPLS_LABEL_UNRESERVED_MIN
|
|
|
|
|| *end > MPLS_LABEL_UNRESERVED_MAX) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Invalid Label chunk: %u - %u", *start, *end);
|
2017-07-17 14:03:14 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zclient_debug)
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_debug("Label Chunk assign: %u - %u (%u)", *start, *end,
|
2017-07-17 14:03:14 +02:00
|
|
|
response_keep);
|
|
|
|
|
|
|
|
return 0;
|
2017-03-20 15:34:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to release a label chunk
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to label manager (zebra)
|
|
|
|
* @param start First label of chunk
|
|
|
|
* @param end Last label of chunk
|
|
|
|
* @result 0 on success, -1 otherwise
|
|
|
|
*/
|
2017-07-17 14:03:14 +02:00
|
|
|
int lm_release_label_chunk(struct zclient *zclient, uint32_t start,
|
|
|
|
uint32_t end)
|
2017-03-20 15:34:49 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
int ret;
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_debug("Releasing Label Chunk %u - %u", start, end);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* send request */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, ZEBRA_RELEASE_LABEL_CHUNK, VRF_DEFAULT);
|
|
|
|
|
2018-04-26 10:56:19 +02:00
|
|
|
/* proto */
|
|
|
|
stream_putc(s, zclient->redist_default);
|
|
|
|
/* instance */
|
|
|
|
stream_putw(s, zclient->instance);
|
2017-07-17 14:03:14 +02:00
|
|
|
/* start */
|
|
|
|
stream_putl(s, start);
|
|
|
|
/* end */
|
|
|
|
stream_putl(s, end);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
ret = writen(zclient->sock, s->data, stream_get_endp(s));
|
|
|
|
if (ret < 0) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Can't write to zclient sock");
|
2017-07-17 14:03:14 +02:00
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ret == 0) {
|
2018-05-01 20:43:14 +02:00
|
|
|
zlog_err("Zclient sock connection closed");
|
2017-07-17 14:03:14 +02:00
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2017-03-20 15:34:49 +01:00
|
|
|
}
|
2016-02-25 20:30:53 +01:00
|
|
|
|
2018-03-05 17:57:29 +01:00
|
|
|
/**
|
|
|
|
* Connect to table manager in a syncronous way
|
|
|
|
*
|
|
|
|
* It first writes the request to zcient output buffer and then
|
|
|
|
* immediately reads the answer from the input buffer.
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to table manager (zebra)
|
|
|
|
* @result Result of response
|
|
|
|
*/
|
|
|
|
int tm_table_manager_connect(struct zclient *zclient)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct stream *s;
|
|
|
|
uint8_t result;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("Connecting to Table Manager");
|
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* send request */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, ZEBRA_TABLE_MANAGER_CONNECT, VRF_DEFAULT);
|
|
|
|
|
|
|
|
/* proto */
|
|
|
|
stream_putc(s, zclient->redist_default);
|
|
|
|
/* instance */
|
|
|
|
stream_putw(s, zclient->instance);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
ret = zclient_send_message(zclient);
|
|
|
|
if (ret < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
2018-05-08 10:13:20 +02:00
|
|
|
zlog_debug("%s: Table manager connect request sent", __func__);
|
2018-03-05 17:57:29 +01:00
|
|
|
|
|
|
|
/* read response */
|
|
|
|
if (zclient_read_sync_response(zclient, ZEBRA_TABLE_MANAGER_CONNECT)
|
|
|
|
!= 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* result */
|
|
|
|
s = zclient->ibuf;
|
|
|
|
STREAM_GETC(s, result);
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Table Manager connect response received, result %u",
|
|
|
|
__func__, result);
|
|
|
|
|
|
|
|
return (int)result;
|
|
|
|
stream_failure:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to request a table chunk in a syncronous way
|
|
|
|
*
|
|
|
|
* It first writes the request to zclient output buffer and then
|
|
|
|
* immediately reads the answer from the input buffer.
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to table manager (zebra)
|
|
|
|
* @param chunk_size Amount of table requested
|
|
|
|
* @param start to write first assigned chunk table RT ID to
|
|
|
|
* @param end To write last assigned chunk table RT ID to
|
|
|
|
* @result 0 on success, -1 otherwise
|
|
|
|
*/
|
|
|
|
int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
|
|
|
|
uint32_t *start, uint32_t *end)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("Getting Table Chunk");
|
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* send request */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, ZEBRA_GET_TABLE_CHUNK, VRF_DEFAULT);
|
|
|
|
/* chunk size */
|
|
|
|
stream_putl(s, chunk_size);
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
ret = writen(zclient->sock, s->data, stream_get_endp(s));
|
|
|
|
if (ret < 0) {
|
|
|
|
zlog_err("%s: can't write to zclient->sock", __func__);
|
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ret == 0) {
|
|
|
|
zlog_err("%s: zclient->sock connection closed", __func__);
|
|
|
|
close(zclient->sock);
|
|
|
|
zclient->sock = -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("%s: Table chunk request (%d bytes) sent", __func__,
|
|
|
|
ret);
|
|
|
|
|
|
|
|
/* read response */
|
|
|
|
if (zclient_read_sync_response(zclient, ZEBRA_GET_TABLE_CHUNK) != 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
s = zclient->ibuf;
|
|
|
|
/* start and end table IDs */
|
|
|
|
STREAM_GETL(s, *start);
|
|
|
|
STREAM_GETL(s, *end);
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("Table Chunk assign: %u - %u ", *start, *end);
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to release a table chunk
|
|
|
|
*
|
|
|
|
* @param zclient Zclient used to connect to table manager (zebra)
|
|
|
|
* @param start First label of table
|
|
|
|
* @param end Last label of chunk
|
|
|
|
* @result 0 on success, -1 otherwise
|
|
|
|
*/
|
|
|
|
int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
|
|
|
|
uint32_t end)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("Releasing Table Chunk");
|
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* send request */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
zclient_create_header(s, ZEBRA_RELEASE_TABLE_CHUNK, VRF_DEFAULT);
|
|
|
|
|
|
|
|
/* start */
|
|
|
|
stream_putl(s, start);
|
|
|
|
/* end */
|
|
|
|
stream_putl(s, end);
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-15 17:09:28 +02:00
|
|
|
int zebra_send_pw(struct zclient *zclient, int command, struct zapi_pw *pw)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
/* Reset stream. */
|
|
|
|
s = zclient->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
zclient_create_header(s, command, VRF_DEFAULT);
|
|
|
|
stream_write(s, pw->ifname, IF_NAMESIZE);
|
|
|
|
stream_putl(s, pw->ifindex);
|
|
|
|
|
|
|
|
/* Put type */
|
|
|
|
stream_putl(s, pw->type);
|
|
|
|
|
|
|
|
/* Put nexthop */
|
|
|
|
stream_putl(s, pw->af);
|
|
|
|
switch (pw->af) {
|
|
|
|
case AF_INET:
|
|
|
|
stream_put_in_addr(s, &pw->nexthop.ipv4);
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
2018-03-27 21:13:34 +02:00
|
|
|
stream_write(s, (uint8_t *)&pw->nexthop.ipv6, 16);
|
2017-05-15 17:09:28 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
zlog_err("%s: unknown af", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put labels */
|
|
|
|
stream_putl(s, pw->local_label);
|
|
|
|
stream_putl(s, pw->remote_label);
|
|
|
|
|
|
|
|
/* Put flags */
|
|
|
|
stream_putc(s, pw->flags);
|
|
|
|
|
|
|
|
/* Protocol specific fields */
|
|
|
|
stream_write(s, &pw->data, sizeof(union pw_protocol_fields));
|
|
|
|
|
|
|
|
/* Put length at the first point of the stream. */
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
|
|
|
|
return zclient_send_message(zclient);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive PW status update from Zebra and send it to LDE process.
|
|
|
|
*/
|
|
|
|
void zebra_read_pw_status_update(int command, struct zclient *zclient,
|
|
|
|
zebra_size_t length, vrf_id_t vrf_id,
|
|
|
|
struct zapi_pw_status *pw)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
memset(pw, 0, sizeof(struct zapi_pw_status));
|
|
|
|
s = zclient->ibuf;
|
|
|
|
|
|
|
|
/* Get data. */
|
|
|
|
stream_get(pw->ifname, s, IF_NAMESIZE);
|
|
|
|
pw->ifindex = stream_getl(s);
|
|
|
|
pw->status = stream_getl(s);
|
|
|
|
}
|
|
|
|
|
2018-04-18 17:10:27 +02:00
|
|
|
static void zclient_capability_decode(int command, struct zclient *zclient,
|
|
|
|
zebra_size_t length, vrf_id_t vrf_id)
|
|
|
|
{
|
|
|
|
struct zclient_capabilities cap;
|
|
|
|
struct stream *s = zclient->ibuf;
|
|
|
|
uint8_t mpls_enabled;
|
|
|
|
|
|
|
|
memset(&cap, 0, sizeof(cap));
|
|
|
|
STREAM_GETC(s, mpls_enabled);
|
|
|
|
cap.mpls_enabled = !!mpls_enabled;
|
|
|
|
STREAM_GETL(s, cap.ecmp);
|
|
|
|
|
|
|
|
if (zclient->zebra_capabilities)
|
|
|
|
(*zclient->zebra_capabilities)(&cap);
|
|
|
|
|
|
|
|
stream_failure:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Zebra client message read function. */
|
2017-07-17 14:03:14 +02:00
|
|
|
static int zclient_read(struct thread *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
size_t already;
|
|
|
|
uint16_t length, command;
|
|
|
|
uint8_t marker, version;
|
|
|
|
vrf_id_t vrf_id;
|
|
|
|
struct zclient *zclient;
|
|
|
|
|
|
|
|
/* Get socket to zebra. */
|
|
|
|
zclient = THREAD_ARG(thread);
|
|
|
|
zclient->t_read = NULL;
|
|
|
|
|
|
|
|
/* Read zebra header (if we don't have it already). */
|
|
|
|
if ((already = stream_get_endp(zclient->ibuf)) < ZEBRA_HEADER_SIZE) {
|
|
|
|
ssize_t nbyte;
|
|
|
|
if (((nbyte = stream_read_try(zclient->ibuf, zclient->sock,
|
|
|
|
ZEBRA_HEADER_SIZE - already))
|
|
|
|
== 0)
|
|
|
|
|| (nbyte == -1)) {
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug(
|
|
|
|
"zclient connection closed socket [%d].",
|
|
|
|
zclient->sock);
|
|
|
|
return zclient_failed(zclient);
|
|
|
|
}
|
|
|
|
if (nbyte != (ssize_t)(ZEBRA_HEADER_SIZE - already)) {
|
|
|
|
/* Try again later. */
|
|
|
|
zclient_event(ZCLIENT_READ, zclient);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
already = ZEBRA_HEADER_SIZE;
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Reset to read from the beginning of the incoming packet. */
|
|
|
|
stream_set_getp(zclient->ibuf, 0);
|
|
|
|
|
|
|
|
/* Fetch header values. */
|
|
|
|
length = stream_getw(zclient->ibuf);
|
|
|
|
marker = stream_getc(zclient->ibuf);
|
|
|
|
version = stream_getc(zclient->ibuf);
|
lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.
Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.
This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-14 16:01:36 +01:00
|
|
|
vrf_id = stream_getl(zclient->ibuf);
|
2017-07-17 14:03:14 +02:00
|
|
|
command = stream_getw(zclient->ibuf);
|
|
|
|
|
|
|
|
if (marker != ZEBRA_HEADER_MARKER || version != ZSERV_VERSION) {
|
|
|
|
zlog_err(
|
|
|
|
"%s: socket %d version mismatch, marker %d, version %d",
|
|
|
|
__func__, zclient->sock, marker, version);
|
|
|
|
return zclient_failed(zclient);
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (length < ZEBRA_HEADER_SIZE) {
|
|
|
|
zlog_err("%s: socket %d message length %u is less than %d ",
|
|
|
|
__func__, zclient->sock, length, ZEBRA_HEADER_SIZE);
|
|
|
|
return zclient_failed(zclient);
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
/* Length check. */
|
|
|
|
if (length > STREAM_SIZE(zclient->ibuf)) {
|
|
|
|
struct stream *ns;
|
|
|
|
zlog_warn(
|
|
|
|
"%s: message size %u exceeds buffer size %lu, expanding...",
|
2018-03-27 21:13:34 +02:00
|
|
|
__func__, length,
|
|
|
|
(unsigned long)STREAM_SIZE(zclient->ibuf));
|
2017-07-17 14:03:14 +02:00
|
|
|
ns = stream_new(length);
|
|
|
|
stream_copy(ns, zclient->ibuf);
|
|
|
|
stream_free(zclient->ibuf);
|
|
|
|
zclient->ibuf = ns;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read rest of zebra packet. */
|
|
|
|
if (already < length) {
|
|
|
|
ssize_t nbyte;
|
|
|
|
if (((nbyte = stream_read_try(zclient->ibuf, zclient->sock,
|
|
|
|
length - already))
|
|
|
|
== 0)
|
|
|
|
|| (nbyte == -1)) {
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug(
|
|
|
|
"zclient connection closed socket [%d].",
|
|
|
|
zclient->sock);
|
|
|
|
return zclient_failed(zclient);
|
|
|
|
}
|
|
|
|
if (nbyte != (ssize_t)(length - already)) {
|
|
|
|
/* Try again later. */
|
|
|
|
zclient_event(ZCLIENT_READ, zclient);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
length -= ZEBRA_HEADER_SIZE;
|
|
|
|
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient 0x%p command 0x%x VRF %u\n",
|
|
|
|
(void *)zclient, command, vrf_id);
|
|
|
|
|
|
|
|
switch (command) {
|
2018-04-18 17:10:27 +02:00
|
|
|
case ZEBRA_CAPABILITIES:
|
|
|
|
zclient_capability_decode(command, zclient, length, vrf_id);
|
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
case ZEBRA_ROUTER_ID_UPDATE:
|
|
|
|
if (zclient->router_id_update)
|
|
|
|
(*zclient->router_id_update)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_VRF_ADD:
|
|
|
|
zclient_vrf_add(zclient, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_VRF_DELETE:
|
|
|
|
zclient_vrf_delete(zclient, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_ADD:
|
|
|
|
if (zclient->interface_add)
|
|
|
|
(*zclient->interface_add)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_DELETE:
|
|
|
|
if (zclient->interface_delete)
|
|
|
|
(*zclient->interface_delete)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_ADDRESS_ADD:
|
|
|
|
if (zclient->interface_address_add)
|
|
|
|
(*zclient->interface_address_add)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_ADDRESS_DELETE:
|
|
|
|
if (zclient->interface_address_delete)
|
|
|
|
(*zclient->interface_address_delete)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_BFD_DEST_UPDATE:
|
|
|
|
if (zclient->interface_bfd_dest_update)
|
|
|
|
(*zclient->interface_bfd_dest_update)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_NBR_ADDRESS_ADD:
|
|
|
|
if (zclient->interface_nbr_address_add)
|
|
|
|
(*zclient->interface_nbr_address_add)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_NBR_ADDRESS_DELETE:
|
|
|
|
if (zclient->interface_nbr_address_delete)
|
|
|
|
(*zclient->interface_nbr_address_delete)(
|
|
|
|
command, zclient, length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_UP:
|
|
|
|
if (zclient->interface_up)
|
|
|
|
(*zclient->interface_up)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_DOWN:
|
|
|
|
if (zclient->interface_down)
|
|
|
|
(*zclient->interface_down)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_VRF_UPDATE:
|
|
|
|
if (zclient->interface_vrf_update)
|
|
|
|
(*zclient->interface_vrf_update)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_NEXTHOP_UPDATE:
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient rcvd nexthop update\n");
|
|
|
|
if (zclient->nexthop_update)
|
|
|
|
(*zclient->nexthop_update)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_IMPORT_CHECK_UPDATE:
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient rcvd import check update\n");
|
|
|
|
if (zclient->import_check_update)
|
|
|
|
(*zclient->import_check_update)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_BFD_DEST_REPLAY:
|
|
|
|
if (zclient->bfd_dest_replay)
|
|
|
|
(*zclient->bfd_dest_replay)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
2017-08-21 03:10:50 +02:00
|
|
|
case ZEBRA_REDISTRIBUTE_ROUTE_ADD:
|
|
|
|
if (zclient->redistribute_route_add)
|
|
|
|
(*zclient->redistribute_route_add)(command, zclient,
|
|
|
|
length, vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
2017-08-21 03:10:50 +02:00
|
|
|
case ZEBRA_REDISTRIBUTE_ROUTE_DEL:
|
|
|
|
if (zclient->redistribute_route_del)
|
|
|
|
(*zclient->redistribute_route_del)(command, zclient,
|
|
|
|
length, vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
break;
|
|
|
|
case ZEBRA_INTERFACE_LINK_PARAMS:
|
|
|
|
if (zclient->interface_link_params)
|
|
|
|
(*zclient->interface_link_params)(command, zclient,
|
|
|
|
length);
|
|
|
|
break;
|
|
|
|
case ZEBRA_FEC_UPDATE:
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug("zclient rcvd fec update\n");
|
|
|
|
if (zclient->fec_update)
|
|
|
|
(*zclient->fec_update)(command, zclient, length);
|
|
|
|
break;
|
2018-04-14 00:01:12 +02:00
|
|
|
case ZEBRA_LOCAL_ES_ADD:
|
|
|
|
if (zclient->local_es_add)
|
|
|
|
(*zclient->local_es_add)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_LOCAL_ES_DEL:
|
|
|
|
if (zclient->local_es_del)
|
|
|
|
(*zclient->local_es_del)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
case ZEBRA_VNI_ADD:
|
|
|
|
if (zclient->local_vni_add)
|
|
|
|
(*zclient->local_vni_add)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_VNI_DEL:
|
|
|
|
if (zclient->local_vni_del)
|
|
|
|
(*zclient->local_vni_del)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
2017-10-08 03:49:27 +02:00
|
|
|
case ZEBRA_L3VNI_ADD:
|
|
|
|
if (zclient->local_l3vni_add)
|
|
|
|
(*zclient->local_l3vni_add)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_L3VNI_DEL:
|
|
|
|
if (zclient->local_l3vni_del)
|
|
|
|
(*zclient->local_l3vni_del)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
2017-07-17 14:03:14 +02:00
|
|
|
case ZEBRA_MACIP_ADD:
|
|
|
|
if (zclient->local_macip_add)
|
|
|
|
(*zclient->local_macip_add)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_MACIP_DEL:
|
|
|
|
if (zclient->local_macip_del)
|
|
|
|
(*zclient->local_macip_del)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
2017-11-20 06:47:04 +01:00
|
|
|
case ZEBRA_IP_PREFIX_ROUTE_ADD:
|
|
|
|
if (zclient->local_ip_prefix_add)
|
|
|
|
(*zclient->local_ip_prefix_add)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_IP_PREFIX_ROUTE_DEL:
|
|
|
|
if (zclient->local_ip_prefix_del)
|
|
|
|
(*zclient->local_ip_prefix_del)(command, zclient,
|
|
|
|
length, vrf_id);
|
|
|
|
break;
|
2017-05-15 17:09:28 +02:00
|
|
|
case ZEBRA_PW_STATUS_UPDATE:
|
|
|
|
if (zclient->pw_status_update)
|
|
|
|
(*zclient->pw_status_update)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
2017-11-09 19:55:46 +01:00
|
|
|
case ZEBRA_ROUTE_NOTIFY_OWNER:
|
2018-02-23 20:40:46 +01:00
|
|
|
if (zclient->route_notify_owner)
|
|
|
|
(*zclient->route_notify_owner)(command, zclient, length,
|
|
|
|
vrf_id);
|
2017-11-09 19:55:46 +01:00
|
|
|
break;
|
2018-02-23 19:48:06 +01:00
|
|
|
case ZEBRA_RULE_NOTIFY_OWNER:
|
|
|
|
if (zclient->rule_notify_owner)
|
|
|
|
(*zclient->rule_notify_owner)(command, zclient, length,
|
|
|
|
vrf_id);
|
2018-04-07 20:13:07 +02:00
|
|
|
break;
|
|
|
|
case ZEBRA_GET_LABEL_CHUNK:
|
|
|
|
if (zclient->label_chunk)
|
|
|
|
(*zclient->label_chunk)(command, zclient, length,
|
2018-05-08 10:13:20 +02:00
|
|
|
vrf_id);
|
2018-04-07 20:13:07 +02:00
|
|
|
break;
|
2018-03-12 09:38:53 +01:00
|
|
|
case ZEBRA_IPSET_NOTIFY_OWNER:
|
|
|
|
if (zclient->ipset_notify_owner)
|
|
|
|
(*zclient->ipset_notify_owner)(command, zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_IPSET_ENTRY_NOTIFY_OWNER:
|
|
|
|
if (zclient->ipset_entry_notify_owner)
|
|
|
|
(*zclient->ipset_entry_notify_owner)(command,
|
|
|
|
zclient, length,
|
|
|
|
vrf_id);
|
|
|
|
break;
|
|
|
|
case ZEBRA_IPTABLE_NOTIFY_OWNER:
|
|
|
|
if (zclient->iptable_notify_owner)
|
|
|
|
(*zclient->iptable_notify_owner)(command,
|
|
|
|
zclient, length,
|
|
|
|
vrf_id);
|
2017-07-17 14:03:14 +02:00
|
|
|
default:
|
|
|
|
break;
|
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
Implement non-blocking zclient I/O with buffering.
* zclient.h (struct zclient): Add two fields to support non-blocking
I/O: struct buffer *wb, and struct thread *t_write.
(zclient_free): Remove function.
(zebra_redistribute_send): Change 2nd arg from socket fd to
struct zclient * (needed to support non-blocking I/O and buffering).
(zclient_send_message): New function to send an arbitrary
message with non-blocking I/O.
* zclient.c (zclient_new): Create write buffer.
(zclient_free): Remove unused function.
(zclient_stop): Must cancel new t_write thread. Also, reset
all buffers: ibuf, obuf, and wb.
(zclient_failed): New helper function for typical error handling.
(zclient_flush_data): New thread to flush queued data.
(zclient_send_message): New function to send the message in
zclient->obuf to zebra using non-blocking I/O and buffering.
(zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use
new zclient_send_message function instead of calling writen.
(zclient_start): Set socket non-blocking. Also, change 2nd arg
to zebra_redistribute_send from zclient->sock to zclient.
(zebra_redistribute_send): Change 2nd arg to struct zclient *.
Can now use zclient->obuf to assemble the message instead of
allocating a temporary stream. And call zclient_send_message to
send the message instead of writen.
(zclient_read): Convert to support non-blocking I/O by using
stream_read_try instead of deprecated stream_read.
(zclient_redistribute): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead
of writen.
* rip_zebra.c (rip_redistribute_set, rip_redistribute_unset,
rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send
from zclient->sock to zclient.
* ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean):
Change 2nd arg to zebra_redistribute_send from zclient->sock
to zclient.
* bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset):
The 2nd arg to zebra_redistribute_send is now zclient instead of
zclient->sock.
* isis_zebra.h (isis_zebra_finish): Remove declaration of unused
function.
* isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message
to send the message to zebra instead of calling writen directly, since
zclient_send_message understands non-blocking I/O and will manage
the buffer queue appropriately.
(isis_zebra_finish): Remove unused function, particularly since
the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
|
|
|
if (zclient->sock < 0)
|
|
|
|
/* Connection was closed during packet processing. */
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* Register read thread. */
|
|
|
|
stream_reset(zclient->ibuf);
|
|
|
|
zclient_event(ZCLIENT_READ, zclient);
|
|
|
|
|
|
|
|
return 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_redistribute(int command, struct zclient *zclient, afi_t afi,
|
2018-03-27 21:13:34 +02:00
|
|
|
int type, unsigned short instance, vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (instance) {
|
|
|
|
if (command == ZEBRA_REDISTRIBUTE_ADD) {
|
|
|
|
if (redist_check_instance(
|
|
|
|
&zclient->mi_redist[afi][type], instance))
|
|
|
|
return;
|
|
|
|
redist_add_instance(&zclient->mi_redist[afi][type],
|
|
|
|
instance);
|
|
|
|
} else {
|
|
|
|
if (!redist_check_instance(
|
|
|
|
&zclient->mi_redist[afi][type], instance))
|
|
|
|
return;
|
|
|
|
redist_del_instance(&zclient->mi_redist[afi][type],
|
|
|
|
instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (command == ZEBRA_REDISTRIBUTE_ADD) {
|
|
|
|
if (vrf_bitmap_check(zclient->redist[afi][type],
|
|
|
|
vrf_id))
|
|
|
|
return;
|
|
|
|
vrf_bitmap_set(zclient->redist[afi][type], vrf_id);
|
|
|
|
} else {
|
|
|
|
if (!vrf_bitmap_check(zclient->redist[afi][type],
|
|
|
|
vrf_id))
|
|
|
|
return;
|
|
|
|
vrf_bitmap_unset(zclient->redist[afi][type], vrf_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zclient->sock > 0)
|
|
|
|
zebra_redistribute_send(command, zclient, afi, type, instance,
|
|
|
|
vrf_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
void zclient_redistribute_default(int command, struct zclient *zclient,
|
|
|
|
vrf_id_t vrf_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
if (command == ZEBRA_REDISTRIBUTE_DEFAULT_ADD) {
|
|
|
|
if (vrf_bitmap_check(zclient->default_information, vrf_id))
|
|
|
|
return;
|
|
|
|
vrf_bitmap_set(zclient->default_information, vrf_id);
|
|
|
|
} else {
|
|
|
|
if (!vrf_bitmap_check(zclient->default_information, vrf_id))
|
|
|
|
return;
|
|
|
|
vrf_bitmap_unset(zclient->default_information, vrf_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (zclient->sock > 0)
|
|
|
|
zebra_message_send(zclient, command, vrf_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2017-07-17 14:03:14 +02:00
|
|
|
static void zclient_event(enum event event, struct zclient *zclient)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2017-07-17 14:03:14 +02:00
|
|
|
switch (event) {
|
|
|
|
case ZCLIENT_SCHEDULE:
|
|
|
|
thread_add_event(zclient->master, zclient_connect, zclient, 0,
|
|
|
|
&zclient->t_connect);
|
|
|
|
break;
|
|
|
|
case ZCLIENT_CONNECT:
|
|
|
|
if (zclient_debug)
|
|
|
|
zlog_debug(
|
|
|
|
"zclient connect failures: %d schedule interval is now %d",
|
|
|
|
zclient->fail, zclient->fail < 3 ? 10 : 60);
|
|
|
|
thread_add_timer(zclient->master, zclient_connect, zclient,
|
|
|
|
zclient->fail < 3 ? 10 : 60,
|
|
|
|
&zclient->t_connect);
|
|
|
|
break;
|
|
|
|
case ZCLIENT_READ:
|
|
|
|
zclient->t_read = NULL;
|
|
|
|
thread_add_read(zclient->master, zclient_read, zclient,
|
|
|
|
zclient->sock, &zclient->t_read);
|
|
|
|
break;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2011-11-25 15:51:48 +01:00
|
|
|
|
2017-06-13 14:59:32 +02:00
|
|
|
void zclient_interface_set_master(struct zclient *client,
|
|
|
|
struct interface *master,
|
|
|
|
struct interface *slave)
|
|
|
|
{
|
|
|
|
struct stream *s;
|
|
|
|
|
|
|
|
s = client->obuf;
|
|
|
|
stream_reset(s);
|
|
|
|
|
|
|
|
zclient_create_header(s, ZEBRA_INTERFACE_SET_MASTER, master->vrf_id);
|
|
|
|
|
lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.
Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.
This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-14 16:01:36 +01:00
|
|
|
stream_putl(s, master->vrf_id);
|
2017-06-13 14:59:32 +02:00
|
|
|
stream_putl(s, master->ifindex);
|
lib: increase vrf_id from 16 bit to 32 bit identifier
This is a preparatory work for configuring vrf/frr over netns
vrf structure is being changed to 32 bit, and the VRF will have the
possibility to have a backend made up of NETNS.
Let's put some history.
Initially the 32 bit was because one wanted to map on vrf_id both the
VRFLITE and the NSID.
Initially, one would have liked to make zebra configure at the same time
both vrf lite and vrf from netns in a flat way. From the show
running perspective, one would have had both kind of vrfs, thatone
would configure on the same way.
however, it leads to inconsistencies in concepts, because it mixes vrf
vrf with vrf, and vrf is not always mapped with netns.
For instance, logical-router could also be used with netns. In that
case, it would not be possible to map vrf with netns.
There was an other reason why 32 bit is proposed. this is because
some systems handle NSID to 32 bits. As vrf lite exists only on
Linux, there are other systems that would like to use an other vrf
backend than vrf lite. The netns backend for vrf will be used for that
too. for instance, for windows or freebsd, some similar
netns concept exists; so it will be easier to reuse netns
backend for vrf, than reusing vrflite backend for vrf.
This commit is here to extend vrf_id to 32 bits. Following commits in a
second step will help in enable a VRF backend.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-12-14 16:01:36 +01:00
|
|
|
stream_putl(s, slave->vrf_id);
|
2017-06-13 14:59:32 +02:00
|
|
|
stream_putl(s, slave->ifindex);
|
|
|
|
|
|
|
|
stream_putw_at(s, 0, stream_get_endp(s));
|
|
|
|
zclient_send_message(client);
|
|
|
|
}
|