2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-11-13 23:48:56 +01:00
|
|
|
/* Header file exported by rt_netlink.c to zebra.
|
|
|
|
* Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ZEBRA_RT_NETLINK_H
|
|
|
|
#define _ZEBRA_RT_NETLINK_H
|
|
|
|
|
|
|
|
#ifdef HAVE_NETLINK
|
|
|
|
|
2016-09-12 14:02:39 +02:00
|
|
|
#include "zebra/zebra_mpls.h"
|
2018-10-23 16:57:01 +02:00
|
|
|
#include "zebra/zebra_dplane.h"
|
2016-09-12 14:02:39 +02:00
|
|
|
|
2019-03-25 15:11:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-11-13 23:48:56 +01:00
|
|
|
|
2017-10-05 14:54:03 +02:00
|
|
|
/*
|
|
|
|
* Additional protocol strings to push into routes
|
|
|
|
* If we add anything new here please make sure
|
|
|
|
* to update:
|
|
|
|
* zebra2proto Function
|
|
|
|
* proto2zebra Function
|
|
|
|
* is_selfroute Function
|
|
|
|
* tools/frr To flush the route upon exit
|
|
|
|
*
|
|
|
|
* Finally update this file to allow iproute2 to
|
|
|
|
* know about this new route.
|
|
|
|
* tools/etc/iproute2/rt_protos.d
|
|
|
|
*/
|
2017-01-11 23:33:39 +01:00
|
|
|
#define RTPROT_BGP 186
|
|
|
|
#define RTPROT_ISIS 187
|
|
|
|
#define RTPROT_OSPF 188
|
|
|
|
#define RTPROT_RIP 189
|
|
|
|
#define RTPROT_RIPNG 190
|
2017-06-08 15:16:28 +02:00
|
|
|
#if !defined(RTPROT_BABEL)
|
2017-10-05 14:54:03 +02:00
|
|
|
#define RTPROT_BABEL 42
|
2017-06-08 15:16:28 +02:00
|
|
|
#endif
|
2017-06-08 14:48:10 +02:00
|
|
|
#define RTPROT_NHRP 191
|
|
|
|
#define RTPROT_EIGRP 192
|
|
|
|
#define RTPROT_LDP 193
|
2017-11-10 18:55:16 +01:00
|
|
|
#define RTPROT_SHARP 194
|
2018-04-27 20:53:46 +02:00
|
|
|
#define RTPROT_PBR 195
|
2018-05-25 20:36:12 +02:00
|
|
|
#define RTPROT_ZSTATIC 196
|
2018-06-11 14:09:23 +02:00
|
|
|
#define RTPROT_OPENFABRIC 197
|
2020-07-20 13:43:54 +02:00
|
|
|
#define RTPROT_SRTE 198
|
2017-01-11 23:33:39 +01:00
|
|
|
|
2017-05-26 03:11:24 +02:00
|
|
|
void rt_netlink_init(void);
|
2017-01-11 23:33:39 +01:00
|
|
|
|
2018-10-23 16:57:01 +02:00
|
|
|
/* MPLS label forwarding table change, using dataplane context information. */
|
2020-06-10 11:44:31 +02:00
|
|
|
extern ssize_t netlink_mpls_multipath_msg_encode(int cmd,
|
|
|
|
struct zebra_dplane_ctx *ctx,
|
|
|
|
void *buf, size_t buflen);
|
2018-10-23 16:57:01 +02:00
|
|
|
|
2020-06-10 11:44:31 +02:00
|
|
|
extern ssize_t netlink_route_multipath_msg_encode(int cmd,
|
|
|
|
struct zebra_dplane_ctx *ctx,
|
|
|
|
uint8_t *data, size_t datalen,
|
2023-07-26 22:30:07 +02:00
|
|
|
bool fpm, bool force_nhg,
|
|
|
|
bool force_rr);
|
2019-12-09 16:36:18 +01:00
|
|
|
extern ssize_t netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx,
|
2020-07-15 15:14:08 +02:00
|
|
|
void *data, size_t datalen);
|
2019-12-04 14:37:40 +01:00
|
|
|
|
2018-05-23 15:37:06 +02:00
|
|
|
extern int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup);
|
2016-02-01 19:55:42 +01:00
|
|
|
extern int netlink_route_read(struct zebra_ns *zns);
|
2012-11-13 23:48:56 +01:00
|
|
|
|
2019-02-26 00:18:07 +01:00
|
|
|
extern int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id,
|
|
|
|
int startup);
|
|
|
|
extern int netlink_nexthop_read(struct zebra_ns *zns);
|
2020-06-10 11:44:31 +02:00
|
|
|
extern ssize_t netlink_nexthop_msg_encode(uint16_t cmd,
|
|
|
|
const struct zebra_dplane_ctx *ctx,
|
2022-12-25 06:52:57 +01:00
|
|
|
void *buf, size_t buflen, bool fpm);
|
2019-02-26 00:18:07 +01:00
|
|
|
|
2020-11-27 16:45:35 +01:00
|
|
|
extern ssize_t netlink_lsp_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
|
|
|
|
size_t buflen);
|
|
|
|
|
2018-05-23 15:37:06 +02:00
|
|
|
extern int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id);
|
2017-05-15 07:44:13 +02:00
|
|
|
extern int netlink_macfdb_read(struct zebra_ns *zns);
|
|
|
|
extern int netlink_macfdb_read_for_bridge(struct zebra_ns *zns,
|
|
|
|
struct interface *ifp,
|
2021-07-27 09:47:52 +02:00
|
|
|
struct interface *br_if,
|
|
|
|
vlanid_t vid);
|
2021-07-27 18:29:00 +02:00
|
|
|
extern int netlink_macfdb_read_mcast_for_vni(struct zebra_ns *zns,
|
|
|
|
struct interface *ifp, vni_t vni);
|
2017-05-15 07:44:13 +02:00
|
|
|
extern int netlink_neigh_read(struct zebra_ns *zns);
|
|
|
|
extern int netlink_neigh_read_for_vlan(struct zebra_ns *zns,
|
|
|
|
struct interface *vlan_if);
|
2018-12-11 06:33:16 +01:00
|
|
|
extern int netlink_macfdb_read_specific_mac(struct zebra_ns *zns,
|
|
|
|
struct interface *br_if,
|
2021-04-19 20:26:57 +02:00
|
|
|
const struct ethaddr *mac,
|
|
|
|
uint16_t vid);
|
|
|
|
extern int netlink_neigh_read_specific_ip(const struct ipaddr *ip,
|
2018-12-11 06:33:16 +01:00
|
|
|
struct interface *vlan_if);
|
2017-05-15 07:44:13 +02:00
|
|
|
|
2020-07-15 15:14:08 +02:00
|
|
|
struct nl_batch;
|
|
|
|
extern enum netlink_msg_status
|
|
|
|
netlink_put_route_update_msg(struct nl_batch *bth,
|
|
|
|
struct zebra_dplane_ctx *ctx);
|
|
|
|
extern enum netlink_msg_status
|
|
|
|
netlink_put_nexthop_update_msg(struct nl_batch *bth,
|
|
|
|
struct zebra_dplane_ctx *ctx);
|
|
|
|
extern enum netlink_msg_status
|
|
|
|
netlink_put_mac_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
|
|
|
|
extern enum netlink_msg_status
|
|
|
|
netlink_put_neigh_update_msg(struct nl_batch *bth,
|
|
|
|
struct zebra_dplane_ctx *ctx);
|
|
|
|
extern enum netlink_msg_status
|
|
|
|
netlink_put_lsp_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
|
|
|
|
extern enum netlink_msg_status
|
|
|
|
netlink_put_pw_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
|
|
|
|
|
2022-10-04 21:41:36 +02:00
|
|
|
int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
|
|
|
|
ns_id_t ns_id, int startup,
|
|
|
|
struct zebra_dplane_ctx *ctx);
|
|
|
|
|
2020-09-23 16:11:08 +02:00
|
|
|
#ifdef NETLINK_DEBUG
|
|
|
|
const char *nlmsg_type2str(uint16_t type);
|
|
|
|
const char *af_type2str(int type);
|
|
|
|
const char *ifi_type2str(int type);
|
|
|
|
const char *rta_type2str(int type);
|
|
|
|
const char *rtm_type2str(int type);
|
2022-01-26 06:07:57 +01:00
|
|
|
const char *ifla_pdr_type2str(int type);
|
|
|
|
const char *ifla_info_type2str(int type);
|
2020-09-23 16:11:08 +02:00
|
|
|
const char *rtm_protocol2str(int type);
|
|
|
|
const char *rtm_scope2str(int type);
|
|
|
|
const char *rtm_rta2str(int type);
|
|
|
|
const char *neigh_rta2str(int type);
|
|
|
|
const char *ifa_rta2str(int type);
|
|
|
|
const char *nhm_rta2str(int type);
|
2022-02-08 04:37:23 +01:00
|
|
|
const char *frh_rta2str(int type);
|
|
|
|
const char *frh_action2str(uint8_t action);
|
2020-09-23 16:11:08 +02:00
|
|
|
const char *nlmsg_flags2str(uint16_t flags, char *buf, size_t buflen);
|
|
|
|
const char *if_flags2str(uint32_t flags, char *buf, size_t buflen);
|
|
|
|
const char *rtm_flags2str(uint32_t flags, char *buf, size_t buflen);
|
|
|
|
const char *neigh_state2str(uint32_t flags, char *buf, size_t buflen);
|
|
|
|
const char *neigh_flags2str(uint32_t flags, char *buf, size_t buflen);
|
|
|
|
const char *ifa_flags2str(uint32_t flags, char *buf, size_t buflen);
|
|
|
|
const char *nh_flags2str(uint32_t flags, char *buf, size_t buflen);
|
|
|
|
|
|
|
|
void nl_dump(void *msg, size_t msglen);
|
zebra_fpm: Add support for other protocols in fpm:netlink
fpm:netlink format doesn't indicate the protocol information
in routes of BGP, OSPF and other protocols. Routes of those
protocols just indicate protocol as zebra.
The below route is actually BGP route but 'proto': 11
indicates that it is zebra.
{'attrs': [('RTA_DST', 'dummy'),
('RTA_PRIORITY', 0),
('RTA_GATEWAY', 'dummy'),
('RTA_OIF', 2)],
'dst_len': 32,
'family': 2,
'flags': 0,
'header': {'flags': 1025,
'length': 60,
'pid': 3160253895,
'sequence_number': 0,
'type': 24},
'proto': 11,
'scope': 0,
'src_len': 0,
'table': 254,
'tos': 0,
'type': 1}
with this change it is now seen with 'proto': 186
indicates that it is BGP.
{'attrs': [('RTA_DST', 'dummy'),
('RTA_PRIORITY', 0),
('RTA_GATEWAY', 'dummy'),
('RTA_OIF', 2)],
'dst_len': 32,
'family': 2,
'flags': 0,
'header': {'flags': 1025,
'length': 60,
'pid': 3160253895,
'sequence_number': 0,
'type': 24},
'proto': 186,
'scope': 0,
'src_len': 0,
'table': 254,
'tos': 0,
'type': 1}
Signed-off-by: Spoorthi K <spk@redhat.com>
2023-01-23 04:34:04 +01:00
|
|
|
|
|
|
|
extern int zebra2proto(int proto);
|
|
|
|
|
2020-09-23 16:11:08 +02:00
|
|
|
#endif /* NETLINK_DEBUG */
|
|
|
|
|
2019-03-25 15:11:55 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-13 23:48:56 +01:00
|
|
|
#endif /* HAVE_NETLINK */
|
|
|
|
|
|
|
|
#endif /* _ZEBRA_RT_NETLINK_H */
|