2002-12-13 21:15:29 +01:00
|
|
|
/* Zebra's client header.
|
|
|
|
* Copyright (C) 1999 Kunihiro Ishiguro
|
|
|
|
*
|
|
|
|
* 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.
|
2017-05-13 10:25:29 +02:00
|
|
|
*
|
2002-12-13 21:15:29 +01:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ZEBRA_ZCLIENT_H
|
|
|
|
#define _ZEBRA_ZCLIENT_H
|
|
|
|
|
2017-08-21 03:10:50 +02:00
|
|
|
/* For struct zapi_route. */
|
2011-12-25 17:52:09 +01:00
|
|
|
#include "prefix.h"
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* For struct interface and struct connected. */
|
|
|
|
#include "if.h"
|
|
|
|
|
*: 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
|
|
|
/* For vrf_bitmap_t. */
|
|
|
|
#include "vrf.h"
|
|
|
|
|
2017-05-15 17:09:28 +02:00
|
|
|
/* For union g_addr */
|
|
|
|
#include "nexthop.h"
|
|
|
|
|
|
|
|
/* For union pw_protocol_fields */
|
|
|
|
#include "pw.h"
|
|
|
|
|
2018-12-18 14:09:29 +01:00
|
|
|
#include "mlag.h"
|
2020-07-20 13:43:54 +02:00
|
|
|
#include "srte.h"
|
2018-12-18 14:09:29 +01:00
|
|
|
|
2020-04-21 01:53:19 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-06-02 22:05:01 +02:00
|
|
|
/* Zebra types. Used in Zserv message header. */
|
|
|
|
typedef uint16_t zebra_size_t;
|
|
|
|
|
2019-06-02 21:29:10 +02:00
|
|
|
/* Marker value used in new Zserv, in the byte location corresponding
|
|
|
|
* the command value in the old zserv header. To allow old and new
|
|
|
|
* Zserv headers to be distinguished from each other.
|
|
|
|
*/
|
|
|
|
#define ZEBRA_HEADER_MARKER 254
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* For input/output buffer to zebra. */
|
2019-05-31 14:51:07 +02:00
|
|
|
#define ZEBRA_MAX_PACKET_SIZ 16384U
|
2020-08-20 20:13:34 +02:00
|
|
|
#define ZEBRA_SMALL_PACKET_SIZE 200U
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Zebra header size. */
|
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
|
|
|
#define ZEBRA_HEADER_SIZE 10
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2017-08-06 07:35:50 +02:00
|
|
|
/* special socket path name to use TCP
|
|
|
|
* @ is used as first character because that's abstract socket names on Linux
|
|
|
|
*/
|
|
|
|
#define ZAPI_TCP_PATHNAME "@tcp"
|
|
|
|
|
2018-03-07 12:54:16 +01:00
|
|
|
/* IPset size name stands for the name of the ipset entry
|
|
|
|
* that can be created by using some zapi interfaces
|
|
|
|
*/
|
|
|
|
#define ZEBRA_IPSET_NAME_SIZE 32
|
|
|
|
|
2018-03-12 09:23:48 +01:00
|
|
|
/* IPTable action is defined by two values: either
|
|
|
|
* forward or drop
|
|
|
|
*/
|
|
|
|
#define ZEBRA_IPTABLES_FORWARD 0
|
|
|
|
#define ZEBRA_IPTABLES_DROP 1
|
|
|
|
|
2018-11-14 04:14:04 +01:00
|
|
|
/* Zebra FEC register command flags. */
|
|
|
|
#define ZEBRA_FEC_REGISTER_LABEL 0x1
|
|
|
|
#define ZEBRA_FEC_REGISTER_LABEL_INDEX 0x2
|
|
|
|
|
2020-01-29 07:50:27 +01:00
|
|
|
/* Client capabilities */
|
|
|
|
enum zserv_client_capabilities {
|
|
|
|
ZEBRA_CLIENT_GR_CAPABILITIES = 1,
|
|
|
|
ZEBRA_CLIENT_ROUTE_UPDATE_COMPLETE = 2,
|
|
|
|
ZEBRA_CLIENT_ROUTE_UPDATE_PENDING = 3,
|
|
|
|
ZEBRA_CLIENT_GR_DISABLE = 4,
|
|
|
|
ZEBRA_CLIENT_RIB_STALE_TIME
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Macro to check if there GR enabled. */
|
|
|
|
#define ZEBRA_CLIENT_GR_ENABLED(X) (X == ZEBRA_CLIENT_GR_CAPABILITIES)
|
2019-10-25 20:58:57 +02:00
|
|
|
|
2020-07-20 13:43:54 +02:00
|
|
|
#define ZEBRA_SR_POLICY_NAME_MAX_LENGTH 100
|
|
|
|
|
2017-08-06 07:35:50 +02:00
|
|
|
extern struct sockaddr_storage zclient_addr;
|
|
|
|
extern socklen_t zclient_addr_len;
|
|
|
|
|
2016-12-12 18:47:48 +01:00
|
|
|
/* Zebra message types. */
|
|
|
|
typedef enum {
|
|
|
|
ZEBRA_INTERFACE_ADD,
|
|
|
|
ZEBRA_INTERFACE_DELETE,
|
|
|
|
ZEBRA_INTERFACE_ADDRESS_ADD,
|
|
|
|
ZEBRA_INTERFACE_ADDRESS_DELETE,
|
|
|
|
ZEBRA_INTERFACE_UP,
|
|
|
|
ZEBRA_INTERFACE_DOWN,
|
2017-06-13 14:59:32 +02:00
|
|
|
ZEBRA_INTERFACE_SET_MASTER,
|
2019-02-05 23:02:40 +01:00
|
|
|
ZEBRA_INTERFACE_SET_PROTODOWN,
|
2017-08-20 02:59:41 +02:00
|
|
|
ZEBRA_ROUTE_ADD,
|
|
|
|
ZEBRA_ROUTE_DELETE,
|
2017-11-09 19:55:46 +01:00
|
|
|
ZEBRA_ROUTE_NOTIFY_OWNER,
|
2016-12-12 18:47:48 +01:00
|
|
|
ZEBRA_REDISTRIBUTE_ADD,
|
|
|
|
ZEBRA_REDISTRIBUTE_DELETE,
|
|
|
|
ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
|
|
|
|
ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
|
|
|
|
ZEBRA_ROUTER_ID_ADD,
|
|
|
|
ZEBRA_ROUTER_ID_DELETE,
|
|
|
|
ZEBRA_ROUTER_ID_UPDATE,
|
|
|
|
ZEBRA_HELLO,
|
2018-04-18 17:10:27 +02:00
|
|
|
ZEBRA_CAPABILITIES,
|
2016-12-12 18:47:48 +01:00
|
|
|
ZEBRA_NEXTHOP_REGISTER,
|
|
|
|
ZEBRA_NEXTHOP_UNREGISTER,
|
|
|
|
ZEBRA_NEXTHOP_UPDATE,
|
|
|
|
ZEBRA_INTERFACE_NBR_ADDRESS_ADD,
|
|
|
|
ZEBRA_INTERFACE_NBR_ADDRESS_DELETE,
|
|
|
|
ZEBRA_INTERFACE_BFD_DEST_UPDATE,
|
|
|
|
ZEBRA_IMPORT_ROUTE_REGISTER,
|
|
|
|
ZEBRA_IMPORT_ROUTE_UNREGISTER,
|
|
|
|
ZEBRA_IMPORT_CHECK_UPDATE,
|
|
|
|
ZEBRA_BFD_DEST_REGISTER,
|
|
|
|
ZEBRA_BFD_DEST_DEREGISTER,
|
|
|
|
ZEBRA_BFD_DEST_UPDATE,
|
|
|
|
ZEBRA_BFD_DEST_REPLAY,
|
2017-08-21 03:10:50 +02:00
|
|
|
ZEBRA_REDISTRIBUTE_ROUTE_ADD,
|
|
|
|
ZEBRA_REDISTRIBUTE_ROUTE_DEL,
|
2016-12-12 18:47:48 +01:00
|
|
|
ZEBRA_VRF_UNREGISTER,
|
|
|
|
ZEBRA_VRF_ADD,
|
|
|
|
ZEBRA_VRF_DELETE,
|
2018-01-30 19:30:36 +01:00
|
|
|
ZEBRA_VRF_LABEL,
|
2016-12-12 18:47:48 +01:00
|
|
|
ZEBRA_INTERFACE_VRF_UPDATE,
|
|
|
|
ZEBRA_BFD_CLIENT_REGISTER,
|
2018-06-27 18:40:50 +02:00
|
|
|
ZEBRA_BFD_CLIENT_DEREGISTER,
|
2016-12-12 18:47:48 +01:00
|
|
|
ZEBRA_INTERFACE_ENABLE_RADV,
|
|
|
|
ZEBRA_INTERFACE_DISABLE_RADV,
|
|
|
|
ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,
|
|
|
|
ZEBRA_INTERFACE_LINK_PARAMS,
|
|
|
|
ZEBRA_MPLS_LABELS_ADD,
|
|
|
|
ZEBRA_MPLS_LABELS_DELETE,
|
2019-08-08 20:57:13 +02:00
|
|
|
ZEBRA_MPLS_LABELS_REPLACE,
|
2020-07-20 13:43:54 +02:00
|
|
|
ZEBRA_SR_POLICY_SET,
|
|
|
|
ZEBRA_SR_POLICY_DELETE,
|
|
|
|
ZEBRA_SR_POLICY_NOTIFY_STATUS,
|
2016-12-12 18:47:48 +01:00
|
|
|
ZEBRA_IPMR_ROUTE_STATS,
|
2017-03-20 15:34:49 +01:00
|
|
|
ZEBRA_LABEL_MANAGER_CONNECT,
|
2018-06-07 15:28:12 +02:00
|
|
|
ZEBRA_LABEL_MANAGER_CONNECT_ASYNC,
|
2017-03-20 15:34:49 +01:00
|
|
|
ZEBRA_GET_LABEL_CHUNK,
|
|
|
|
ZEBRA_RELEASE_LABEL_CHUNK,
|
2017-02-01 19:10:56 +01:00
|
|
|
ZEBRA_FEC_REGISTER,
|
|
|
|
ZEBRA_FEC_UNREGISTER,
|
|
|
|
ZEBRA_FEC_UPDATE,
|
2017-06-28 10:51:10 +02:00
|
|
|
ZEBRA_ADVERTISE_DEFAULT_GW,
|
2019-02-04 02:24:59 +01:00
|
|
|
ZEBRA_ADVERTISE_SVI_MACIP,
|
2017-11-20 06:47:04 +01:00
|
|
|
ZEBRA_ADVERTISE_SUBNET,
|
2017-05-15 07:38:26 +02:00
|
|
|
ZEBRA_ADVERTISE_ALL_VNI,
|
2018-04-14 00:01:12 +02:00
|
|
|
ZEBRA_LOCAL_ES_ADD,
|
|
|
|
ZEBRA_LOCAL_ES_DEL,
|
2020-03-28 01:14:45 +01:00
|
|
|
ZEBRA_REMOTE_ES_VTEP_ADD,
|
|
|
|
ZEBRA_REMOTE_ES_VTEP_DEL,
|
|
|
|
ZEBRA_LOCAL_ES_EVI_ADD,
|
|
|
|
ZEBRA_LOCAL_ES_EVI_DEL,
|
2017-05-15 07:38:26 +02:00
|
|
|
ZEBRA_VNI_ADD,
|
|
|
|
ZEBRA_VNI_DEL,
|
2017-10-08 03:49:27 +02:00
|
|
|
ZEBRA_L3VNI_ADD,
|
|
|
|
ZEBRA_L3VNI_DEL,
|
2017-05-15 07:38:26 +02:00
|
|
|
ZEBRA_REMOTE_VTEP_ADD,
|
|
|
|
ZEBRA_REMOTE_VTEP_DEL,
|
2017-05-15 07:44:13 +02:00
|
|
|
ZEBRA_MACIP_ADD,
|
|
|
|
ZEBRA_MACIP_DEL,
|
2017-11-20 06:47:04 +01:00
|
|
|
ZEBRA_IP_PREFIX_ROUTE_ADD,
|
|
|
|
ZEBRA_IP_PREFIX_ROUTE_DEL,
|
2017-05-15 07:44:13 +02:00
|
|
|
ZEBRA_REMOTE_MACIP_ADD,
|
|
|
|
ZEBRA_REMOTE_MACIP_DEL,
|
2018-11-02 01:55:07 +01:00
|
|
|
ZEBRA_DUPLICATE_ADDR_DETECTION,
|
2017-05-15 17:09:28 +02:00
|
|
|
ZEBRA_PW_ADD,
|
|
|
|
ZEBRA_PW_DELETE,
|
|
|
|
ZEBRA_PW_SET,
|
|
|
|
ZEBRA_PW_UNSET,
|
|
|
|
ZEBRA_PW_STATUS_UPDATE,
|
2018-02-15 01:52:01 +01:00
|
|
|
ZEBRA_RULE_ADD,
|
|
|
|
ZEBRA_RULE_DELETE,
|
|
|
|
ZEBRA_RULE_NOTIFY_OWNER,
|
2018-03-05 17:57:29 +01:00
|
|
|
ZEBRA_TABLE_MANAGER_CONNECT,
|
|
|
|
ZEBRA_GET_TABLE_CHUNK,
|
|
|
|
ZEBRA_RELEASE_TABLE_CHUNK,
|
2018-03-07 13:21:14 +01:00
|
|
|
ZEBRA_IPSET_CREATE,
|
|
|
|
ZEBRA_IPSET_DESTROY,
|
|
|
|
ZEBRA_IPSET_ENTRY_ADD,
|
|
|
|
ZEBRA_IPSET_ENTRY_DELETE,
|
2018-03-07 15:46:00 +01:00
|
|
|
ZEBRA_IPSET_NOTIFY_OWNER,
|
|
|
|
ZEBRA_IPSET_ENTRY_NOTIFY_OWNER,
|
2018-03-12 09:23:48 +01:00
|
|
|
ZEBRA_IPTABLE_ADD,
|
|
|
|
ZEBRA_IPTABLE_DELETE,
|
|
|
|
ZEBRA_IPTABLE_NOTIFY_OWNER,
|
2018-10-05 00:42:57 +02:00
|
|
|
ZEBRA_VXLAN_FLOOD_CONTROL,
|
2019-03-19 21:56:46 +01:00
|
|
|
ZEBRA_VXLAN_SG_ADD,
|
|
|
|
ZEBRA_VXLAN_SG_DEL,
|
2019-07-02 20:20:34 +02:00
|
|
|
ZEBRA_VXLAN_SG_REPLAY,
|
2019-11-12 09:17:13 +01:00
|
|
|
ZEBRA_MLAG_PROCESS_UP,
|
|
|
|
ZEBRA_MLAG_PROCESS_DOWN,
|
2019-11-12 07:36:17 +01:00
|
|
|
ZEBRA_MLAG_CLIENT_REGISTER,
|
|
|
|
ZEBRA_MLAG_CLIENT_UNREGISTER,
|
|
|
|
ZEBRA_MLAG_FORWARD_MSG,
|
2020-04-29 16:49:21 +02:00
|
|
|
ZEBRA_NHG_ADD,
|
|
|
|
ZEBRA_NHG_DEL,
|
|
|
|
ZEBRA_NHG_NOTIFY_OWNER,
|
2019-12-17 23:00:52 +01:00
|
|
|
ZEBRA_ERROR,
|
2020-04-06 22:10:13 +02:00
|
|
|
ZEBRA_CLIENT_CAPABILITIES,
|
|
|
|
ZEBRA_OPAQUE_MESSAGE,
|
|
|
|
ZEBRA_OPAQUE_REGISTER,
|
|
|
|
ZEBRA_OPAQUE_UNREGISTER,
|
2020-08-06 13:07:01 +02:00
|
|
|
ZEBRA_NEIGH_DISCOVER,
|
2020-11-06 04:09:28 +01:00
|
|
|
ZEBRA_ROUTE_NOTIFY_REQUEST,
|
2020-12-08 00:01:01 +01:00
|
|
|
ZEBRA_CLIENT_CLOSE_NOTIFY,
|
2016-12-12 18:47:48 +01:00
|
|
|
} zebra_message_types_t;
|
|
|
|
|
2019-12-17 23:00:52 +01:00
|
|
|
enum zebra_error_types {
|
2020-01-29 07:50:27 +01:00
|
|
|
ZEBRA_UNKNOWN_ERROR, /* Error of unknown type */
|
2019-12-17 23:00:52 +01:00
|
|
|
ZEBRA_NO_VRF, /* Vrf in header was not found */
|
|
|
|
ZEBRA_INVALID_MSG_TYPE, /* No handler found for msg type */
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline const char *zebra_error_type2str(enum zebra_error_types type)
|
|
|
|
{
|
|
|
|
const char *ret = "UNKNOWN";
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ZEBRA_UNKNOWN_ERROR:
|
|
|
|
ret = "ZEBRA_UNKNOWN_ERROR";
|
|
|
|
break;
|
|
|
|
case ZEBRA_NO_VRF:
|
|
|
|
ret = "ZEBRA_NO_VRF";
|
|
|
|
break;
|
|
|
|
case ZEBRA_INVALID_MSG_TYPE:
|
|
|
|
ret = "ZEBRA_INVALID_MSG_TYPE";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
struct redist_proto {
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t enabled;
|
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
|
|
|
struct list *instances;
|
|
|
|
};
|
|
|
|
|
2018-04-18 17:10:27 +02:00
|
|
|
struct zclient_capabilities {
|
|
|
|
uint32_t ecmp;
|
|
|
|
bool mpls_enabled;
|
2018-12-18 14:09:29 +01:00
|
|
|
enum mlag_role role;
|
2018-04-18 17:10:27 +02:00
|
|
|
};
|
|
|
|
|
2019-10-25 20:58:57 +02:00
|
|
|
/* Graceful Restart Capabilities message */
|
|
|
|
struct zapi_cap {
|
2020-01-29 07:50:27 +01:00
|
|
|
enum zserv_client_capabilities cap;
|
|
|
|
uint32_t stale_removal_time;
|
|
|
|
afi_t afi;
|
|
|
|
safi_t safi;
|
|
|
|
vrf_id_t vrf_id;
|
2019-10-25 20:58:57 +02:00
|
|
|
};
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Structure for the zebra client. */
|
|
|
|
struct zclient {
|
2015-09-23 22:26:56 +02:00
|
|
|
/* The thread master we schedule ourselves on */
|
|
|
|
struct thread_master *master;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-10-11 16:37:20 +02:00
|
|
|
/* Priviledges to change socket values */
|
|
|
|
struct zebra_privs_t *privs;
|
|
|
|
|
2017-11-09 20:34:42 +01:00
|
|
|
/* Do we care about failure events for route install? */
|
|
|
|
bool receive_notify;
|
|
|
|
|
2020-03-06 16:33:40 +01:00
|
|
|
/* Is this a synchronous client? */
|
|
|
|
bool synchronous;
|
|
|
|
|
2020-04-14 16:45:09 +02:00
|
|
|
/* Session id (optional) to support clients with multiple sessions */
|
|
|
|
uint32_t session_id;
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Socket to zebra daemon. */
|
|
|
|
int sock;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Connection failure count. */
|
|
|
|
int fail;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Input buffer for zebra message. */
|
|
|
|
struct stream *ibuf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Output buffer for zebra message. */
|
|
|
|
struct stream *obuf;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
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
|
|
|
/* Buffer of data waiting to be written to zebra. */
|
|
|
|
struct buffer *wb;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Read and connect thread. */
|
|
|
|
struct thread *t_read;
|
|
|
|
struct thread *t_connect;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
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
|
|
|
/* Thread to write buffered data to zebra. */
|
|
|
|
struct thread *t_write;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Redistribute information. */
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t redist_default; /* clients protocol */
|
|
|
|
unsigned short instance;
|
*: 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
|
|
|
struct redist_proto mi_redist[AFI_MAX][ZEBRA_ROUTE_MAX];
|
|
|
|
vrf_bitmap_t redist[AFI_MAX][ZEBRA_ROUTE_MAX];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Redistribute defauilt. */
|
2019-01-11 22:20:13 +01:00
|
|
|
vrf_bitmap_t default_information[AFI_MAX];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-05-03 20:41:00 +02:00
|
|
|
#define ZAPI_CALLBACK_ARGS \
|
|
|
|
int cmd, struct zclient *zclient, uint16_t length, vrf_id_t vrf_id
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Pointer to the callback functions. */
|
*: 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
|
|
|
void (*zebra_connected)(struct zclient *);
|
2018-04-18 17:10:27 +02:00
|
|
|
void (*zebra_capabilities)(struct zclient_capabilities *cap);
|
2020-10-12 15:51:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When the zclient attempts to write the stream data to
|
|
|
|
* it's named pipe to/from zebra, we may have a situation
|
|
|
|
* where the other daemon has not fully drained the data
|
|
|
|
* from the socket. In this case provide a mechanism
|
|
|
|
* where we will *still* buffer the data to be sent
|
|
|
|
* and also provide a callback mechanism to the appropriate
|
|
|
|
* place where we can signal that we're ready to receive
|
|
|
|
* more data.
|
|
|
|
*/
|
|
|
|
void (*zebra_buffer_write_ready)(void);
|
2019-05-03 20:41:00 +02:00
|
|
|
int (*router_id_update)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_address_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_address_delete)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_link_params)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_bfd_dest_update)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_nbr_address_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_nbr_address_delete)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*interface_vrf_update)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*nexthop_update)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*import_check_update)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*bfd_dest_replay)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*redistribute_route_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*redistribute_route_del)(ZAPI_CALLBACK_ARGS);
|
2017-02-01 19:10:56 +01:00
|
|
|
int (*fec_update)(int, struct zclient *, uint16_t);
|
2019-05-03 20:41:00 +02:00
|
|
|
int (*local_es_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_es_del)(ZAPI_CALLBACK_ARGS);
|
2020-03-28 01:14:45 +01:00
|
|
|
int (*local_es_evi_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_es_evi_del)(ZAPI_CALLBACK_ARGS);
|
2019-05-03 20:41:00 +02:00
|
|
|
int (*local_vni_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_vni_del)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_l3vni_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_l3vni_del)(ZAPI_CALLBACK_ARGS);
|
|
|
|
void (*local_ip_prefix_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
void (*local_ip_prefix_del)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_macip_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*local_macip_del)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*pw_status_update)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*route_notify_owner)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*rule_notify_owner)(ZAPI_CALLBACK_ARGS);
|
|
|
|
void (*label_chunk)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*ipset_notify_owner)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*ipset_entry_notify_owner)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*iptable_notify_owner)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*vxlan_sg_add)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*vxlan_sg_del)(ZAPI_CALLBACK_ARGS);
|
2019-11-12 09:17:13 +01:00
|
|
|
int (*mlag_process_up)(void);
|
|
|
|
int (*mlag_process_down)(void);
|
|
|
|
int (*mlag_handle_msg)(struct stream *msg, int len);
|
2020-04-29 16:49:21 +02:00
|
|
|
int (*nhg_notify_owner)(ZAPI_CALLBACK_ARGS);
|
2019-12-17 23:00:52 +01:00
|
|
|
int (*handle_error)(enum zebra_error_types error);
|
2020-04-06 22:10:13 +02:00
|
|
|
int (*opaque_msg_handler)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*opaque_register_handler)(ZAPI_CALLBACK_ARGS);
|
|
|
|
int (*opaque_unregister_handler)(ZAPI_CALLBACK_ARGS);
|
2020-07-20 13:43:54 +02:00
|
|
|
int (*sr_policy_notify_status)(ZAPI_CALLBACK_ARGS);
|
2020-12-08 00:01:01 +01:00
|
|
|
int (*zebra_client_close_notify)(ZAPI_CALLBACK_ARGS);
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Zebra API message flag. */
|
|
|
|
#define ZAPI_MESSAGE_NEXTHOP 0x01
|
2017-08-21 03:10:50 +02:00
|
|
|
#define ZAPI_MESSAGE_DISTANCE 0x02
|
|
|
|
#define ZAPI_MESSAGE_METRIC 0x04
|
|
|
|
#define ZAPI_MESSAGE_TAG 0x08
|
|
|
|
#define ZAPI_MESSAGE_MTU 0x10
|
|
|
|
#define ZAPI_MESSAGE_SRCPFX 0x20
|
2019-11-11 21:50:30 +01:00
|
|
|
/* Backup nexthops are present */
|
|
|
|
#define ZAPI_MESSAGE_BACKUP_NEXTHOPS 0x40
|
2020-07-28 23:36:51 +02:00
|
|
|
#define ZAPI_MESSAGE_NHG 0x80
|
2018-02-10 00:38:02 +01:00
|
|
|
/*
|
|
|
|
* This should only be used by a DAEMON that needs to communicate
|
|
|
|
* the table being used is not in the VRF. You must pass the
|
|
|
|
* default vrf, else this will be ignored.
|
|
|
|
*/
|
2020-12-07 18:13:06 +01:00
|
|
|
#define ZAPI_MESSAGE_TABLEID 0x0100
|
|
|
|
#define ZAPI_MESSAGE_SRTE 0x0200
|
2020-12-05 01:40:22 +01:00
|
|
|
#define ZAPI_MESSAGE_OPAQUE 0x0400
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-08-24 16:56:15 +02:00
|
|
|
#define ZSERV_VERSION 6
|
2006-01-16 02:54:02 +01:00
|
|
|
/* Zserv protocol message header */
|
2018-03-07 17:23:58 +01:00
|
|
|
struct zmsghdr {
|
2006-01-16 02:54:02 +01:00
|
|
|
uint16_t length;
|
2018-03-07 18:30:51 +01:00
|
|
|
/* Always set to 255 in new zserv */
|
2018-03-07 17:23:58 +01:00
|
|
|
uint8_t marker;
|
2006-01-16 02:54:02 +01:00
|
|
|
uint8_t version;
|
*: 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
|
|
|
vrf_id_t vrf_id;
|
2006-01-16 02:54:02 +01:00
|
|
|
uint16_t command;
|
2019-10-11 14:56:39 +02:00
|
|
|
} __attribute__((packed));
|
|
|
|
#define ZAPI_HEADER_CMD_LOCATION offsetof(struct zmsghdr, command)
|
2006-01-16 02:54:02 +01:00
|
|
|
|
2020-08-20 20:50:38 +02:00
|
|
|
/*
|
|
|
|
* ZAPI nexthop. Note that these are sorted when associated with ZAPI routes,
|
|
|
|
* and that sorting must be aligned with the sorting of nexthops in
|
|
|
|
* lib/nexthop.c. Any new fields must be accounted for in zapi_nexthop_cmp().
|
|
|
|
*/
|
2017-08-20 02:25:12 +02:00
|
|
|
struct zapi_nexthop {
|
|
|
|
enum nexthop_types_t type;
|
2018-02-08 15:12:12 +01:00
|
|
|
vrf_id_t vrf_id;
|
2017-08-20 02:25:12 +02:00
|
|
|
ifindex_t ifindex;
|
2019-11-13 22:06:06 +01:00
|
|
|
uint8_t flags;
|
2012-04-11 23:52:46 +02:00
|
|
|
union {
|
|
|
|
union g_addr gate;
|
|
|
|
enum blackhole_type bh_type;
|
|
|
|
};
|
2017-08-21 00:57:36 +02:00
|
|
|
|
|
|
|
/* MPLS labels for BGP-LU or Segment Routing */
|
|
|
|
uint8_t label_num;
|
|
|
|
mpls_label_t labels[MPLS_MAX_LABELS];
|
2017-11-29 08:40:30 +01:00
|
|
|
|
|
|
|
struct ethaddr rmac;
|
2019-12-06 16:28:05 +01:00
|
|
|
|
|
|
|
uint32_t weight;
|
2019-11-11 21:50:30 +01:00
|
|
|
|
2020-06-30 21:52:37 +02:00
|
|
|
/* Backup nexthops, for IP-FRR, TI-LFA, etc */
|
|
|
|
uint8_t backup_num;
|
|
|
|
uint8_t backup_idx[NEXTHOP_MAX_BACKUPS];
|
2020-07-20 13:43:54 +02:00
|
|
|
|
|
|
|
/* SR-TE color. */
|
|
|
|
uint32_t srte_color;
|
2017-08-20 02:25:12 +02:00
|
|
|
};
|
|
|
|
|
2019-11-13 22:06:06 +01:00
|
|
|
/*
|
2019-11-11 21:50:30 +01:00
|
|
|
* ZAPI nexthop flags values - we're encoding a single octet
|
|
|
|
* initially, so ensure that the on-the-wire encoding continues
|
|
|
|
* to match the number of valid flags.
|
2019-11-13 22:06:06 +01:00
|
|
|
*/
|
2019-11-11 21:50:30 +01:00
|
|
|
|
2019-11-13 22:06:06 +01:00
|
|
|
#define ZAPI_NEXTHOP_FLAG_ONLINK 0x01
|
|
|
|
#define ZAPI_NEXTHOP_FLAG_LABEL 0x02
|
2019-12-06 16:28:05 +01:00
|
|
|
#define ZAPI_NEXTHOP_FLAG_WEIGHT 0x04
|
2019-11-11 21:50:30 +01:00
|
|
|
#define ZAPI_NEXTHOP_FLAG_HAS_BACKUP 0x08 /* Nexthop has a backup */
|
2019-11-13 22:06:06 +01:00
|
|
|
|
2020-09-22 21:27:35 +02:00
|
|
|
/*
|
|
|
|
* ZAPI Nexthop Group. For use with protocol creation of nexthop groups.
|
|
|
|
*/
|
|
|
|
struct zapi_nhg {
|
2020-09-25 19:48:21 +02:00
|
|
|
uint16_t proto;
|
2020-09-22 21:27:35 +02:00
|
|
|
uint32_t id;
|
2020-09-25 19:48:21 +02:00
|
|
|
|
2020-09-22 21:27:35 +02:00
|
|
|
uint16_t nexthop_num;
|
|
|
|
struct zapi_nexthop nexthops[MULTIPATH_NUM];
|
2020-09-25 19:48:21 +02:00
|
|
|
|
|
|
|
uint16_t backup_nexthop_num;
|
|
|
|
struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
|
2020-09-22 21:27:35 +02:00
|
|
|
};
|
|
|
|
|
2017-11-06 19:04:19 +01:00
|
|
|
/*
|
|
|
|
* Some of these data structures do not map easily to
|
|
|
|
* a actual data structure size giving different compilers
|
|
|
|
* and systems. For those data structures we need
|
|
|
|
* to use the smallest available stream_getX/putX functions
|
|
|
|
* to encode/decode.
|
|
|
|
*/
|
2017-06-05 01:14:44 +02:00
|
|
|
struct zapi_route {
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t type;
|
|
|
|
unsigned short instance;
|
2017-06-05 01:14:44 +02:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t flags;
|
2019-06-02 21:24:19 +02:00
|
|
|
/*
|
|
|
|
* Cause Zebra to consider this routes nexthops recursively
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_ALLOW_RECURSION 0x01
|
|
|
|
/*
|
|
|
|
* This is a route that is read in on startup that was left around
|
|
|
|
* from a previous run of FRR
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_SELFROUTE 0x02
|
|
|
|
/*
|
|
|
|
* This flag is used to tell Zebra that the BGP route being passed
|
|
|
|
* down is a IBGP route
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_IBGP 0x04
|
|
|
|
/*
|
|
|
|
* This is a route that has been selected for FIB installation.
|
|
|
|
* This flag is set in zebra and can be passed up to routing daemons
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_SELECTED 0x08
|
|
|
|
/*
|
|
|
|
* This is a route that we are telling Zebra that this route *must*
|
|
|
|
* win and will be installed even over ZEBRA_FLAG_SELECTED
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_FIB_OVERRIDE 0x10
|
|
|
|
/*
|
|
|
|
* This flag tells Zebra that the route is a EVPN route and should
|
|
|
|
* be treated specially
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_EVPN_ROUTE 0x20
|
|
|
|
/*
|
|
|
|
* This flag tells Zebra that it should treat the distance passed
|
|
|
|
* down as an additional discriminator for route selection of the
|
|
|
|
* route entry. This mainly is used for backup static routes.
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_RR_USE_DISTANCE 0x40
|
2020-09-18 21:47:27 +02:00
|
|
|
/*
|
|
|
|
* This flag tells everyone that the route was intentionally
|
|
|
|
* not offloaded and the route will be sent to the cpu for
|
|
|
|
* forwarding. This flag makes no sense unless you are in
|
|
|
|
* an asic offload situation
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_TRAPPED 0x80
|
|
|
|
/*
|
|
|
|
* This flag tells everyone that the route has been
|
|
|
|
* successfully offloaded to an asic for forwarding.
|
|
|
|
* This flag makes no sense unless you are in an asic
|
|
|
|
* offload situation.
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_OFFLOADED 0x100
|
2020-10-26 13:46:57 +01:00
|
|
|
/*
|
|
|
|
* This flag tells everyone that the route has
|
|
|
|
* failed offloading.
|
|
|
|
* This flag makes no sense unless you are in an asic
|
|
|
|
* offload situation.
|
|
|
|
*/
|
|
|
|
#define ZEBRA_FLAG_OFFLOAD_FAILED 0x200
|
2017-06-05 01:14:44 +02:00
|
|
|
|
2020-06-04 19:11:35 +02:00
|
|
|
/* The older XXX_MESSAGE flags live here */
|
2020-07-20 13:43:54 +02:00
|
|
|
uint32_t message;
|
2017-06-05 01:14:44 +02:00
|
|
|
|
2017-11-06 19:04:19 +01:00
|
|
|
/*
|
|
|
|
* This is an enum but we are going to treat it as a uint8_t
|
|
|
|
* for purpose of encoding/decoding
|
|
|
|
*/
|
2017-06-05 01:14:44 +02:00
|
|
|
safi_t safi;
|
|
|
|
|
2017-08-20 02:25:12 +02:00
|
|
|
struct prefix prefix;
|
|
|
|
struct prefix_ipv6 src_prefix;
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t nexthop_num;
|
2017-08-20 02:25:12 +02:00
|
|
|
struct zapi_nexthop nexthops[MULTIPATH_NUM];
|
2017-06-05 01:14:44 +02:00
|
|
|
|
2019-11-11 21:50:30 +01:00
|
|
|
/* Support backup routes for IP FRR, TI-LFA, traffic engineering */
|
|
|
|
uint16_t backup_nexthop_num;
|
|
|
|
struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
|
|
|
|
|
2020-05-01 23:56:23 +02:00
|
|
|
uint32_t nhgid;
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t distance;
|
2017-06-05 01:14:44 +02:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t metric;
|
2017-06-05 01:14:44 +02:00
|
|
|
|
|
|
|
route_tag_t tag;
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t mtu;
|
2017-06-05 01:14:44 +02:00
|
|
|
|
|
|
|
vrf_id_t vrf_id;
|
2017-10-13 10:13:48 +02:00
|
|
|
|
2018-02-10 00:38:02 +01:00
|
|
|
uint32_t tableid;
|
2020-07-20 13:43:54 +02:00
|
|
|
|
|
|
|
/* SR-TE color (used for nexthop updates only). */
|
|
|
|
uint32_t srte_color;
|
2020-12-05 01:40:22 +01:00
|
|
|
|
|
|
|
#define ZAPI_MESSAGE_OPAQUE_LENGTH 1024
|
|
|
|
struct {
|
|
|
|
uint16_t length;
|
|
|
|
uint8_t data[ZAPI_MESSAGE_OPAQUE_LENGTH];
|
|
|
|
} opaque;
|
2017-06-05 01:14:44 +02:00
|
|
|
};
|
|
|
|
|
2019-08-08 02:06:03 +02:00
|
|
|
struct zapi_labels {
|
2019-08-08 20:51:05 +02:00
|
|
|
uint8_t message;
|
2020-04-02 15:29:36 +02:00
|
|
|
#define ZAPI_LABELS_FTN 0x01
|
|
|
|
#define ZAPI_LABELS_HAS_BACKUPS 0x02
|
2019-08-08 02:06:03 +02:00
|
|
|
enum lsp_types_t type;
|
|
|
|
mpls_label_t local_label;
|
2019-08-08 20:51:05 +02:00
|
|
|
struct {
|
|
|
|
struct prefix prefix;
|
|
|
|
uint8_t type;
|
|
|
|
unsigned short instance;
|
|
|
|
} route;
|
2020-02-13 22:47:41 +01:00
|
|
|
|
2019-08-08 20:57:13 +02:00
|
|
|
uint16_t nexthop_num;
|
2020-02-13 22:47:41 +01:00
|
|
|
struct zapi_nexthop nexthops[MULTIPATH_NUM];
|
2020-04-02 15:29:36 +02:00
|
|
|
|
|
|
|
/* Backup nexthops, if present */
|
|
|
|
uint16_t backup_nexthop_num;
|
|
|
|
struct zapi_nexthop backup_nexthops[MULTIPATH_NUM];
|
2019-08-08 02:06:03 +02:00
|
|
|
};
|
|
|
|
|
2020-07-20 13:43:54 +02:00
|
|
|
struct zapi_srte_tunnel {
|
|
|
|
enum lsp_types_t type;
|
|
|
|
mpls_label_t local_label;
|
|
|
|
uint8_t label_num;
|
|
|
|
mpls_label_t labels[MPLS_MAX_LABELS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zapi_sr_policy {
|
|
|
|
uint32_t color;
|
|
|
|
struct ipaddr endpoint;
|
|
|
|
char name[SRTE_POLICY_NAME_MAX_LENGTH];
|
|
|
|
struct zapi_srte_tunnel segment_list;
|
|
|
|
int status;
|
|
|
|
};
|
|
|
|
|
2017-05-15 17:09:28 +02:00
|
|
|
struct zapi_pw {
|
|
|
|
char ifname[IF_NAMESIZE];
|
|
|
|
ifindex_t ifindex;
|
|
|
|
int type;
|
|
|
|
int af;
|
|
|
|
union g_addr nexthop;
|
|
|
|
uint32_t local_label;
|
|
|
|
uint32_t remote_label;
|
|
|
|
uint8_t flags;
|
|
|
|
union pw_protocol_fields data;
|
|
|
|
uint8_t protocol;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zapi_pw_status {
|
|
|
|
char ifname[IF_NAMESIZE];
|
|
|
|
ifindex_t ifindex;
|
|
|
|
uint32_t status;
|
|
|
|
};
|
|
|
|
|
2020-12-06 01:45:52 +01:00
|
|
|
/* IGP instance data associated to a RLFA. */
|
|
|
|
struct zapi_rlfa_igp {
|
|
|
|
vrf_id_t vrf_id;
|
|
|
|
int protocol;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
char area_tag[32];
|
|
|
|
struct {
|
|
|
|
int tree_id;
|
|
|
|
int level;
|
|
|
|
unsigned int run_id;
|
|
|
|
} spf;
|
|
|
|
} isis;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IGP -> LDP RLFA (un)registration message. */
|
|
|
|
struct zapi_rlfa_request {
|
|
|
|
/* IGP instance data. */
|
|
|
|
struct zapi_rlfa_igp igp;
|
|
|
|
|
|
|
|
/* Destination prefix. */
|
|
|
|
struct prefix destination;
|
|
|
|
|
|
|
|
/* PQ node address. */
|
|
|
|
struct in_addr pq_address;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* LDP -> IGP RLFA label update. */
|
|
|
|
struct zapi_rlfa_response {
|
|
|
|
/* IGP instance data. */
|
|
|
|
struct zapi_rlfa_igp igp;
|
|
|
|
|
|
|
|
/* Destination prefix. */
|
|
|
|
struct prefix destination;
|
|
|
|
|
|
|
|
/* Resolved LDP labels. */
|
|
|
|
mpls_label_t pq_label;
|
|
|
|
uint16_t nexthop_num;
|
|
|
|
struct {
|
|
|
|
int family;
|
|
|
|
union g_addr gate;
|
|
|
|
mpls_label_t label;
|
|
|
|
} nexthops[MULTIPATH_NUM];
|
|
|
|
};
|
|
|
|
|
2017-11-09 19:55:46 +01:00
|
|
|
enum zapi_route_notify_owner {
|
|
|
|
ZAPI_ROUTE_FAIL_INSTALL,
|
|
|
|
ZAPI_ROUTE_BETTER_ADMIN_WON,
|
|
|
|
ZAPI_ROUTE_INSTALLED,
|
2018-03-08 16:25:12 +01:00
|
|
|
ZAPI_ROUTE_REMOVED,
|
|
|
|
ZAPI_ROUTE_REMOVE_FAIL,
|
2017-11-09 19:55:46 +01:00
|
|
|
};
|
|
|
|
|
2020-04-29 16:49:21 +02:00
|
|
|
enum zapi_nhg_notify_owner {
|
|
|
|
ZAPI_NHG_FAIL_INSTALL,
|
|
|
|
ZAPI_NHG_INSTALLED,
|
|
|
|
ZAPI_NHG_REMOVED,
|
|
|
|
ZAPI_NHG_REMOVE_FAIL,
|
|
|
|
};
|
|
|
|
|
2018-03-21 11:55:38 +01:00
|
|
|
enum zapi_rule_notify_owner {
|
|
|
|
ZAPI_RULE_FAIL_INSTALL,
|
|
|
|
ZAPI_RULE_INSTALLED,
|
|
|
|
ZAPI_RULE_REMOVED,
|
2018-05-18 16:22:23 +02:00
|
|
|
ZAPI_RULE_FAIL_REMOVE,
|
2018-03-21 11:55:38 +01:00
|
|
|
};
|
|
|
|
|
2018-03-07 12:54:16 +01:00
|
|
|
enum ipset_type {
|
|
|
|
IPSET_NET_NET = 1,
|
|
|
|
IPSET_NET_PORT_NET,
|
|
|
|
IPSET_NET_PORT,
|
|
|
|
IPSET_NET
|
|
|
|
};
|
|
|
|
|
2018-03-07 15:46:00 +01:00
|
|
|
enum zapi_ipset_notify_owner {
|
|
|
|
ZAPI_IPSET_FAIL_INSTALL,
|
|
|
|
ZAPI_IPSET_INSTALLED,
|
|
|
|
ZAPI_IPSET_REMOVED,
|
2018-05-18 16:22:23 +02:00
|
|
|
ZAPI_IPSET_FAIL_REMOVE,
|
2018-03-07 15:46:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum zapi_ipset_entry_notify_owner {
|
|
|
|
ZAPI_IPSET_ENTRY_FAIL_INSTALL,
|
|
|
|
ZAPI_IPSET_ENTRY_INSTALLED,
|
|
|
|
ZAPI_IPSET_ENTRY_REMOVED,
|
2018-05-18 16:22:23 +02:00
|
|
|
ZAPI_IPSET_ENTRY_FAIL_REMOVE,
|
2018-03-07 15:46:00 +01:00
|
|
|
};
|
|
|
|
|
2018-03-12 09:23:48 +01:00
|
|
|
enum zapi_iptable_notify_owner {
|
|
|
|
ZAPI_IPTABLE_FAIL_INSTALL,
|
|
|
|
ZAPI_IPTABLE_INSTALLED,
|
|
|
|
ZAPI_IPTABLE_REMOVED,
|
2018-05-18 16:22:23 +02:00
|
|
|
ZAPI_IPTABLE_FAIL_REMOVE,
|
2018-03-12 09:23:48 +01:00
|
|
|
};
|
|
|
|
|
2020-11-07 00:21:50 +01:00
|
|
|
enum zclient_send_status {
|
|
|
|
ZCLIENT_SEND_FAILURE = -1,
|
|
|
|
ZCLIENT_SEND_SUCCESS = 0,
|
|
|
|
ZCLIENT_SEND_BUFFERED = 1
|
|
|
|
};
|
|
|
|
|
2019-12-03 22:14:34 +01:00
|
|
|
static inline const char *
|
|
|
|
zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note)
|
|
|
|
{
|
|
|
|
const char *ret = "UNKNOWN";
|
|
|
|
|
|
|
|
switch (note) {
|
|
|
|
case ZAPI_RULE_FAIL_INSTALL:
|
|
|
|
ret = "ZAPI_RULE_FAIL_INSTALL";
|
|
|
|
break;
|
|
|
|
case ZAPI_RULE_INSTALLED:
|
|
|
|
ret = "ZAPI_RULE_INSTALLED";
|
|
|
|
break;
|
|
|
|
case ZAPI_RULE_FAIL_REMOVE:
|
|
|
|
ret = "ZAPI_RULE_FAIL_REMOVE";
|
|
|
|
break;
|
|
|
|
case ZAPI_RULE_REMOVED:
|
|
|
|
ret = "ZAPI_RULE_REMOVED";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-06-28 10:51:10 +02:00
|
|
|
/* Zebra MAC types */
|
2017-11-13 12:19:52 +01:00
|
|
|
#define ZEBRA_MACIP_TYPE_STICKY 0x01 /* Sticky MAC*/
|
|
|
|
#define ZEBRA_MACIP_TYPE_GW 0x02 /* gateway (SVI) mac*/
|
2018-07-07 06:46:46 +02:00
|
|
|
#define ZEBRA_MACIP_TYPE_ROUTER_FLAG 0x04 /* Router Flag - proxy NA */
|
|
|
|
#define ZEBRA_MACIP_TYPE_OVERRIDE_FLAG 0x08 /* Override Flag */
|
2019-08-09 03:58:03 +02:00
|
|
|
#define ZEBRA_MACIP_TYPE_SVI_IP 0x10 /* SVI MAC-IP */
|
2020-03-26 14:20:07 +01:00
|
|
|
#define ZEBRA_MACIP_TYPE_PROXY_ADVERT 0x20 /* Not locally active */
|
|
|
|
#define ZEBRA_MACIP_TYPE_SYNC_PATH 0x40 /* sync path */
|
|
|
|
/* XXX - flags is an u8; that needs to be changed to u32 if you need
|
|
|
|
* to allocate past 0x80
|
|
|
|
*/
|
2017-06-28 10:51:10 +02:00
|
|
|
|
2020-05-09 01:35:09 +02:00
|
|
|
/* Zebra ES VTEP flags (ZEBRA_REMOTE_ES_VTEP_ADD) */
|
|
|
|
/* ESR has been rxed from the VTEP. Only VTEPs that have advertised the
|
|
|
|
* Type-4 route can participate in DF election.
|
|
|
|
*/
|
|
|
|
#define ZAPI_ES_VTEP_FLAG_ESR_RXED (1 << 0)
|
|
|
|
|
2019-01-15 00:19:48 +01:00
|
|
|
enum zebra_neigh_state { ZEBRA_NEIGH_INACTIVE = 0, ZEBRA_NEIGH_ACTIVE = 1 };
|
|
|
|
|
2017-11-09 20:34:42 +01:00
|
|
|
struct zclient_options {
|
|
|
|
bool receive_notify;
|
2020-03-06 16:33:40 +01:00
|
|
|
bool synchronous;
|
2017-11-09 20:34:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct zclient_options zclient_options_default;
|
|
|
|
|
2020-04-22 15:41:01 +02:00
|
|
|
/*
|
2020-05-13 20:32:13 +02:00
|
|
|
* We reserve the top 4 bits for l2-NHG, everything else
|
|
|
|
* is for zebra/proto l3-NHG.
|
|
|
|
*
|
2020-04-22 15:41:01 +02:00
|
|
|
* Each client is going to get it's own nexthop group space
|
2020-05-13 20:32:13 +02:00
|
|
|
* and we'll separate them, we'll figure out where to start based upon
|
|
|
|
* the route_types.h
|
2020-04-22 15:41:01 +02:00
|
|
|
*/
|
2020-05-13 20:32:13 +02:00
|
|
|
#define ZEBRA_NHG_PROTO_UPPER \
|
|
|
|
((uint32_t)250000000) /* Bottom 28 bits then rounded down */
|
|
|
|
#define ZEBRA_NHG_PROTO_SPACING (ZEBRA_NHG_PROTO_UPPER / ZEBRA_ROUTE_MAX)
|
|
|
|
#define ZEBRA_NHG_PROTO_LOWER \
|
|
|
|
(ZEBRA_NHG_PROTO_SPACING * (ZEBRA_ROUTE_CONNECT + 1))
|
|
|
|
|
2020-04-22 15:41:01 +02:00
|
|
|
extern uint32_t zclient_get_nhg_start(uint32_t proto);
|
|
|
|
|
2018-11-02 13:54:58 +01:00
|
|
|
extern struct zclient *zclient_new(struct thread_master *m,
|
|
|
|
struct zclient_options *opt);
|
2017-11-09 20:34:42 +01:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
extern void zclient_init(struct zclient *, int, unsigned short,
|
2018-03-06 20:02:52 +01:00
|
|
|
struct zebra_privs_t *privs);
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
extern int zclient_start(struct zclient *);
|
|
|
|
extern void zclient_stop(struct zclient *);
|
|
|
|
extern void zclient_reset(struct zclient *);
|
[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
|
|
|
extern void zclient_free(struct 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
|
|
|
|
2011-11-25 15:51:48 +01:00
|
|
|
extern int zclient_socket_connect(struct zclient *);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
extern unsigned short *redist_check_instance(struct redist_proto *,
|
|
|
|
unsigned short);
|
|
|
|
extern void redist_add_instance(struct redist_proto *, unsigned short);
|
|
|
|
extern void redist_del_instance(struct redist_proto *, unsigned short);
|
2020-01-14 07:15:04 +01:00
|
|
|
extern void redist_del_all_instances(struct redist_proto *red);
|
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-01-30 19:30:36 +01:00
|
|
|
/*
|
|
|
|
* Send to zebra that the specified vrf is using label to resolve
|
|
|
|
* itself for L3VPN's. Repeated calls of this function with
|
|
|
|
* different labels will cause an effective update of the
|
2018-02-08 16:19:34 +01:00
|
|
|
* label for lookup. If you pass in MPLS_LABEL_NONE
|
2018-01-30 19:30:36 +01:00
|
|
|
* we will cause a delete action and remove this label pop
|
|
|
|
* operation.
|
2018-02-14 07:11:09 +01:00
|
|
|
*
|
|
|
|
* The underlying AF_MPLS doesn't care about afi's
|
|
|
|
* but we can make the zebra_vrf keep track of what
|
|
|
|
* we have installed and play some special games
|
|
|
|
* to get them both installed.
|
2018-01-30 19:30:36 +01:00
|
|
|
*/
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_vrf_label(struct zclient *zclient, vrf_id_t vrf_id, afi_t afi,
|
|
|
|
mpls_label_t label, enum lsp_types_t ltype);
|
2018-01-30 19:30:36 +01:00
|
|
|
|
2016-02-12 20:37:33 +01:00
|
|
|
extern void zclient_send_reg_requests(struct zclient *, vrf_id_t);
|
|
|
|
extern void zclient_send_dereg_requests(struct zclient *, vrf_id_t);
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_router_id_update(struct zclient *zclient,
|
|
|
|
zebra_message_types_t type, afi_t afi,
|
|
|
|
vrf_id_t vrf_id);
|
|
|
|
|
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_interface_radv_req(struct zclient *zclient, vrf_id_t vrf_id,
|
|
|
|
struct interface *ifp, int enable,
|
|
|
|
int ra_interval);
|
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_interface_protodown(struct zclient *zclient, vrf_id_t vrf_id,
|
|
|
|
struct interface *ifp, bool down);
|
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
|
|
|
|
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 redistribute command to zebra daemon. Do not update zclient state. */
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zebra_redistribute_send(int command, struct zclient *, afi_t, int type,
|
|
|
|
unsigned short instance, vrf_id_t vrf_id);
|
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
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zebra_redistribute_default_send(int command, struct zclient *zclient, afi_t afi,
|
|
|
|
vrf_id_t vrf_id);
|
2019-01-11 22:20:13 +01:00
|
|
|
|
2020-11-06 04:09:28 +01:00
|
|
|
/* Send route notify request to zebra */
|
|
|
|
extern int zebra_route_notify_send(int command, struct zclient *zclient,
|
|
|
|
bool set);
|
|
|
|
|
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
|
|
|
/* If state has changed, update state and call zebra_redistribute_send. */
|
2015-05-20 03:03:45 +02:00
|
|
|
extern void zclient_redistribute(int command, struct zclient *, afi_t, int type,
|
2018-03-27 21:13:34 +02:00
|
|
|
unsigned short instance, vrf_id_t vrf_id);
|
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
|
|
|
|
|
|
|
/* If state has changed, update state and send the command to zebra. */
|
*: 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
|
|
|
extern void zclient_redistribute_default(int command, struct zclient *,
|
2019-01-11 22:20:13 +01:00
|
|
|
afi_t, vrf_id_t vrf_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-10-12 15:51:09 +02:00
|
|
|
/*
|
|
|
|
* Send the message in zclient->obuf to the zebra daemon (or enqueue it).
|
|
|
|
* Returns:
|
|
|
|
* -1 on a I/O error
|
|
|
|
* 0 data was successfully sent
|
|
|
|
* 1 data was buffered for future usage
|
|
|
|
*/
|
2020-11-07 00:21:50 +01:00
|
|
|
extern enum zclient_send_status zclient_send_message(struct zclient *);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2006-01-17 18:43:18 +01:00
|
|
|
/* create header for command, length to be filled in by user later */
|
*: 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
|
|
|
extern void zclient_create_header(struct stream *, uint16_t, vrf_id_t);
|
2018-03-07 17:23:58 +01:00
|
|
|
/*
|
|
|
|
* Read sizeof(struct zmsghdr) bytes from the provided socket and parse the
|
|
|
|
* received data into the specified fields. If this is successful, read the
|
|
|
|
* rest of the packet into the provided stream.
|
|
|
|
*
|
|
|
|
* s
|
|
|
|
* The stream to read into
|
|
|
|
*
|
|
|
|
* sock
|
|
|
|
* The socket to read from
|
|
|
|
*
|
|
|
|
* size
|
|
|
|
* Parsed message size will be placed in the pointed-at integer
|
|
|
|
*
|
|
|
|
* marker
|
|
|
|
* Parsed marker will be placed in the pointed-at byte
|
|
|
|
*
|
|
|
|
* version
|
|
|
|
* Parsed version will be placed in the pointed-at byte
|
|
|
|
*
|
|
|
|
* vrf_id
|
|
|
|
* Parsed VRF ID will be placed in the pointed-at vrf_id_t
|
|
|
|
*
|
|
|
|
* cmd
|
|
|
|
* Parsed command number will be placed in the pointed-at integer
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* -1 if:
|
|
|
|
* - insufficient data for header was read
|
|
|
|
* - a version mismatch was detected
|
|
|
|
* - a marker mismatch was detected
|
|
|
|
* - header size field specified more data than could be read
|
|
|
|
*/
|
2018-03-27 21:13:34 +02:00
|
|
|
extern 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);
|
2018-03-07 17:23:58 +01:00
|
|
|
/*
|
|
|
|
* Parse header from ZAPI message stream into struct zmsghdr.
|
|
|
|
* This function assumes the stream getp points at the first byte of the header.
|
|
|
|
* If the function is successful then the stream getp will point to the byte
|
|
|
|
* immediately after the last byte of the header.
|
|
|
|
*
|
|
|
|
* zmsg
|
|
|
|
* The stream containing the header
|
|
|
|
*
|
|
|
|
* hdr
|
|
|
|
* The header struct to parse into.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* true if parsing succeeded, false otherwise
|
|
|
|
*/
|
|
|
|
extern bool zapi_parse_header(struct stream *zmsg, struct zmsghdr *hdr);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_interface_set_master(struct zclient *client, struct interface *master,
|
|
|
|
struct interface *slave);
|
*: 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
|
|
|
extern struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t);
|
|
|
|
extern struct connected *zebra_interface_address_read(int, struct stream *,
|
|
|
|
vrf_id_t);
|
|
|
|
extern struct nbr_connected *
|
|
|
|
zebra_interface_nbr_address_read(int, struct stream *, vrf_id_t);
|
2016-02-25 20:30:53 +01:00
|
|
|
extern struct interface *zebra_interface_vrf_update_read(struct stream *s,
|
|
|
|
vrf_id_t vrf_id,
|
|
|
|
vrf_id_t *new_vrf_id);
|
2020-03-01 07:21:56 +01:00
|
|
|
extern int zebra_router_id_update_read(struct stream *s, struct prefix *rid);
|
2018-01-08 14:57:44 +01:00
|
|
|
|
2019-01-18 19:06:00 +01:00
|
|
|
extern struct interface *zebra_interface_link_params_read(struct stream *s,
|
|
|
|
vrf_id_t vrf_id);
|
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
|
|
|
extern size_t zebra_interface_link_params_write(struct stream *,
|
|
|
|
struct interface *);
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_get_label_chunk(struct zclient *zclient, uint8_t keep,
|
|
|
|
uint32_t chunk_size, uint32_t base);
|
2018-04-07 20:13:07 +02:00
|
|
|
|
2018-06-07 15:28:12 +02:00
|
|
|
extern int lm_label_manager_connect(struct zclient *zclient, int async);
|
2018-03-27 21:13:34 +02:00
|
|
|
extern int lm_get_label_chunk(struct zclient *zclient, uint8_t keep,
|
2019-06-12 16:33:12 +02:00
|
|
|
uint32_t base, uint32_t chunk_size,
|
|
|
|
uint32_t *start, uint32_t *end);
|
2017-03-20 15:34:49 +01:00
|
|
|
extern int lm_release_label_chunk(struct zclient *zclient, uint32_t start,
|
|
|
|
uint32_t end);
|
2018-03-05 17:57:29 +01:00
|
|
|
extern int tm_table_manager_connect(struct zclient *zclient);
|
|
|
|
extern int tm_get_table_chunk(struct zclient *zclient, uint32_t chunk_size,
|
|
|
|
uint32_t *start, uint32_t *end);
|
|
|
|
extern int tm_release_table_chunk(struct zclient *zclient, uint32_t start,
|
|
|
|
uint32_t end);
|
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient,
|
|
|
|
int cmd,
|
|
|
|
struct zapi_sr_policy *zp);
|
2020-07-20 13:43:54 +02:00
|
|
|
extern int zapi_sr_policy_encode(struct stream *s, int cmd,
|
|
|
|
struct zapi_sr_policy *zp);
|
|
|
|
extern int zapi_sr_policy_decode(struct stream *s, struct zapi_sr_policy *zp);
|
|
|
|
extern int zapi_sr_policy_notify_status_decode(struct stream *s,
|
|
|
|
struct zapi_sr_policy *zp);
|
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status zebra_send_mpls_labels(struct zclient *zclient,
|
|
|
|
int cmd,
|
|
|
|
struct zapi_labels *zl);
|
2019-08-08 02:06:03 +02:00
|
|
|
extern int zapi_labels_encode(struct stream *s, int cmd,
|
|
|
|
struct zapi_labels *zl);
|
|
|
|
extern int zapi_labels_decode(struct stream *s, struct zapi_labels *zl);
|
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status zebra_send_pw(struct zclient *zclient,
|
|
|
|
int command, struct zapi_pw *pw);
|
2020-03-01 07:21:56 +01:00
|
|
|
extern int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS,
|
|
|
|
struct zapi_pw_status *pw);
|
2017-05-15 17:09:28 +02:00
|
|
|
|
2020-11-07 00:21:50 +01:00
|
|
|
extern enum zclient_send_status zclient_route_send(uint8_t, struct zclient *,
|
|
|
|
struct zapi_route *);
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_rnh(struct zclient *zclient, int command, const struct prefix *p,
|
|
|
|
bool exact_match, vrf_id_t vrf_id);
|
2019-11-13 22:06:06 +01:00
|
|
|
int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
|
2020-07-20 13:43:54 +02:00
|
|
|
uint32_t api_flags, uint32_t api_message);
|
2018-03-27 21:13:34 +02:00
|
|
|
extern int zapi_route_encode(uint8_t, struct stream *, struct zapi_route *);
|
2020-04-29 16:49:21 +02:00
|
|
|
extern int zapi_route_decode(struct stream *s, struct zapi_route *api);
|
|
|
|
extern int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
|
|
|
|
uint32_t api_flags, uint32_t api_message);
|
|
|
|
bool zapi_nhg_notify_decode(struct stream *s, uint32_t *id,
|
|
|
|
enum zapi_nhg_notify_owner *note);
|
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,
|
2020-11-06 04:09:28 +01:00
|
|
|
enum zapi_route_notify_owner *note,
|
|
|
|
afi_t *afi, safi_t *safi);
|
2018-02-23 19:48:06 +01:00
|
|
|
bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
|
2020-09-10 17:31:39 +02:00
|
|
|
uint32_t *priority, uint32_t *unique, char *ifname,
|
2018-02-23 19:48:06 +01:00
|
|
|
enum zapi_rule_notify_owner *note);
|
2018-03-07 15:46:00 +01:00
|
|
|
bool zapi_ipset_notify_decode(struct stream *s,
|
|
|
|
uint32_t *unique,
|
|
|
|
enum zapi_ipset_notify_owner *note);
|
|
|
|
|
2020-09-25 19:48:21 +02:00
|
|
|
|
|
|
|
extern int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
|
|
|
|
extern int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_nhg_send(struct zclient *zclient, int cmd, struct zapi_nhg *api_nhg);
|
2020-04-29 16:49:21 +02:00
|
|
|
|
2018-03-07 15:46:00 +01:00
|
|
|
#define ZEBRA_IPSET_NAME_SIZE 32
|
|
|
|
|
|
|
|
bool zapi_ipset_entry_notify_decode(struct stream *s,
|
|
|
|
uint32_t *unique,
|
|
|
|
char *ipset_name,
|
|
|
|
enum zapi_ipset_entry_notify_owner *note);
|
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);
|
2018-03-07 15:46:00 +01:00
|
|
|
|
2020-01-16 22:25:22 +01:00
|
|
|
extern struct nexthop *
|
|
|
|
nexthop_from_zapi_nexthop(const struct zapi_nexthop *znh);
|
2019-11-13 22:06:06 +01:00
|
|
|
int zapi_nexthop_from_nexthop(struct zapi_nexthop *znh,
|
|
|
|
const struct nexthop *nh);
|
2020-01-16 22:25:22 +01:00
|
|
|
int zapi_backup_nexthop_from_nexthop(struct zapi_nexthop *znh,
|
|
|
|
const struct nexthop *nh);
|
2018-02-05 09:44:29 +01:00
|
|
|
extern bool zapi_nexthop_update_decode(struct stream *s,
|
|
|
|
struct zapi_route *nhr);
|
2020-04-03 21:00:13 +02:00
|
|
|
const char *zapi_nexthop2str(const struct zapi_nexthop *znh, char *buf,
|
|
|
|
int bufsize);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-12-17 23:00:52 +01:00
|
|
|
/* Decode the zebra error message */
|
|
|
|
extern bool zapi_error_decode(struct stream *s, enum zebra_error_types *error);
|
|
|
|
|
2020-01-29 07:50:27 +01:00
|
|
|
/* Encode and decode restart capabilities */
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_capabilities_send(uint32_t cmd, struct zclient *zclient,
|
|
|
|
struct zapi_cap *api);
|
2020-01-29 07:50:27 +01:00
|
|
|
extern int32_t zapi_capabilities_decode(struct stream *s, struct zapi_cap *api);
|
|
|
|
|
2012-04-11 23:52:46 +02:00
|
|
|
static inline void zapi_route_set_blackhole(struct zapi_route *api,
|
2017-08-30 17:23:01 +02:00
|
|
|
enum blackhole_type bh_type)
|
2012-04-11 23:52:46 +02:00
|
|
|
{
|
|
|
|
api->nexthop_num = 1;
|
|
|
|
api->nexthops[0].type = NEXTHOP_TYPE_BLACKHOLE;
|
2018-02-08 15:12:12 +01:00
|
|
|
api->nexthops[0].vrf_id = VRF_DEFAULT;
|
2012-04-11 23:52:46 +02:00
|
|
|
api->nexthops[0].bh_type = bh_type;
|
|
|
|
SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
|
|
|
|
};
|
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_mlag_register(struct zclient *client, uint32_t bit_map);
|
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_mlag_deregister(struct zclient *client);
|
2019-11-12 07:36:17 +01:00
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status zclient_send_mlag_data(struct zclient *client,
|
|
|
|
struct stream *client_s);
|
2012-04-11 23:52:46 +02:00
|
|
|
|
2020-04-06 22:10:13 +02:00
|
|
|
/*
|
|
|
|
* Send an OPAQUE message, contents opaque to zebra - but note that
|
|
|
|
* the length of the payload is restricted by the zclient's
|
|
|
|
* outgoing message buffer.
|
|
|
|
* The message header is a message subtype; please use the registry
|
|
|
|
* below to avoid sub-type collisions. Clients use the registration
|
|
|
|
* apis to manage the specific opaque subtypes they want to receive.
|
|
|
|
*/
|
2020-11-11 20:14:37 +01:00
|
|
|
enum zclient_send_status zclient_send_opaque(struct zclient *zclient,
|
|
|
|
uint32_t type, const uint8_t *data,
|
|
|
|
size_t datasize);
|
2020-04-06 22:10:13 +02:00
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
enum zclient_send_status
|
|
|
|
zclient_send_opaque_unicast(struct zclient *zclient, uint32_t type,
|
|
|
|
uint8_t proto, uint16_t instance,
|
|
|
|
uint32_t session_id, const uint8_t *data,
|
|
|
|
size_t datasize);
|
2020-06-04 19:11:35 +02:00
|
|
|
|
|
|
|
/* Struct representing the decoded opaque header info */
|
|
|
|
struct zapi_opaque_msg {
|
|
|
|
uint32_t type; /* Subtype */
|
|
|
|
uint16_t len; /* len after zapi header and this info */
|
|
|
|
uint16_t flags;
|
|
|
|
|
|
|
|
/* Client-specific info - *if* UNICAST flag is set */
|
|
|
|
uint8_t proto;
|
|
|
|
uint16_t instance;
|
|
|
|
uint32_t session_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ZAPI_OPAQUE_FLAG_UNICAST 0x01
|
|
|
|
|
2020-04-06 22:10:13 +02:00
|
|
|
/* Simple struct to convey registration/unreg requests */
|
|
|
|
struct zapi_opaque_reg_info {
|
|
|
|
/* Message subtype */
|
|
|
|
uint32_t type;
|
|
|
|
|
|
|
|
/* Client session tuple */
|
|
|
|
uint8_t proto;
|
|
|
|
uint16_t instance;
|
|
|
|
uint32_t session_id;
|
|
|
|
};
|
|
|
|
|
2020-06-04 19:11:35 +02:00
|
|
|
/* Decode incoming opaque */
|
|
|
|
int zclient_opaque_decode(struct stream *msg, struct zapi_opaque_msg *info);
|
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
enum zclient_send_status zclient_register_opaque(struct zclient *zclient,
|
|
|
|
uint32_t type);
|
|
|
|
enum zclient_send_status zclient_unregister_opaque(struct zclient *zclient,
|
|
|
|
uint32_t type);
|
2020-06-04 15:40:35 +02:00
|
|
|
int zapi_opaque_reg_decode(struct stream *msg,
|
|
|
|
struct zapi_opaque_reg_info *info);
|
2020-04-06 22:10:13 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Registry of opaque message types. Please do not reuse an in-use
|
|
|
|
* type code; some daemons are likely relying on it.
|
|
|
|
*/
|
|
|
|
enum zapi_opaque_registry {
|
|
|
|
/* Request link-state database dump, at restart for example */
|
|
|
|
LINK_STATE_REQUEST = 1,
|
|
|
|
/* Update containing link-state db info */
|
|
|
|
LINK_STATE_UPDATE = 2,
|
2020-07-22 18:10:59 +02:00
|
|
|
/* Request LDP-SYNC state from LDP */
|
|
|
|
LDP_IGP_SYNC_IF_STATE_REQUEST = 3,
|
|
|
|
/* Update containing LDP IGP Sync State info */
|
|
|
|
LDP_IGP_SYNC_IF_STATE_UPDATE = 4,
|
|
|
|
/* Announce that LDP is up */
|
|
|
|
LDP_IGP_SYNC_ANNOUNCE_UPDATE = 5,
|
2020-12-06 01:45:52 +01:00
|
|
|
/* Register RLFA with LDP */
|
|
|
|
LDP_RLFA_REGISTER = 7,
|
|
|
|
/* Unregister all RLFAs with LDP */
|
|
|
|
LDP_RLFA_UNREGISTER_ALL = 8,
|
|
|
|
/* Announce LDP labels associated to a previously registered RLFA */
|
|
|
|
LDP_RLFA_LABELS = 9,
|
2020-04-06 22:10:13 +02:00
|
|
|
};
|
|
|
|
|
2020-03-06 16:33:40 +01:00
|
|
|
/* Send the hello message.
|
|
|
|
* Returns 0 for success or -1 on an I/O error.
|
|
|
|
*/
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status zclient_send_hello(struct zclient *client);
|
2020-03-06 16:33:40 +01:00
|
|
|
|
2020-11-11 20:14:37 +01:00
|
|
|
extern enum zclient_send_status
|
|
|
|
zclient_send_neigh_discovery_req(struct zclient *zclient,
|
|
|
|
const struct interface *ifp,
|
|
|
|
const struct prefix *p);
|
2020-08-06 13:07:01 +02:00
|
|
|
|
2020-12-08 00:01:01 +01:00
|
|
|
struct zapi_client_close_info {
|
|
|
|
/* Client session tuple */
|
|
|
|
uint8_t proto;
|
|
|
|
uint16_t instance;
|
|
|
|
uint32_t session_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Decode incoming client close notify */
|
|
|
|
extern int zapi_client_close_notify_decode(struct stream *s,
|
|
|
|
struct zapi_client_close_info *info);
|
|
|
|
|
2020-04-21 01:53:19 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#endif /* _ZEBRA_ZCLIENT_H */
|