/* NB: read comments in code for refcounting before using! */
static struct route_node *srcdest_srcnode_get(struct route_node *rn,
- struct prefix_ipv6 *src_p)
+ const struct prefix_ipv6 *src_p)
{
struct srcdest_rnode *srn;
route_unlock_node(rn);
}
- return route_node_get(srn->src_table, (struct prefix *)src_p);
+ return route_node_get(srn->src_table, (const struct prefix *)src_p);
}
-static struct route_node *srcdest_srcnode_lookup(struct route_node *rn,
- struct prefix_ipv6 *src_p)
+static struct route_node *srcdest_srcnode_lookup(
+ struct route_node *rn,
+ const struct prefix_ipv6 *src_p)
{
struct srcdest_rnode *srn;
if (!srn->src_table)
return NULL;
- return route_node_lookup(srn->src_table, (struct prefix *)src_p);
+ return route_node_lookup(srn->src_table, (const struct prefix *)src_p);
}
/* ----- exported functions ----- */
}
struct route_node *srcdest_rnode_get(struct route_table *table,
- union prefixptr dst_pu,
- struct prefix_ipv6 *src_p)
+ union prefixconstptr dst_pu,
+ const struct prefix_ipv6 *src_p)
{
- struct prefix_ipv6 *dst_p = dst_pu.p6;
+ const struct prefix_ipv6 *dst_p = dst_pu.p6;
struct route_node *rn;
- rn = route_node_get(table, (struct prefix *)dst_p);
+ rn = route_node_get(table, (const struct prefix *)dst_p);
return srcdest_srcnode_get(rn, src_p);
}
struct route_node *srcdest_rnode_lookup(struct route_table *table,
- union prefixptr dst_pu,
- struct prefix_ipv6 *src_p)
+ union prefixconstptr dst_pu,
+ const struct prefix_ipv6 *src_p)
{
- struct prefix_ipv6 *dst_p = dst_pu.p6;
+ const struct prefix_ipv6 *dst_p = dst_pu.p6;
struct route_node *rn;
struct route_node *srn;
- rn = route_node_lookup_maynull(table, (struct prefix *)dst_p);
+ rn = route_node_lookup_maynull(table, (const struct prefix *)dst_p);
srn = srcdest_srcnode_lookup(rn, src_p);
if (rn != NULL && rn == srn && !rn->info) {
return srn;
}
-void srcdest_rnode_prefixes(struct route_node *rn, struct prefix **p,
- struct prefix **src_p)
+void srcdest_rnode_prefixes(struct route_node *rn, const struct prefix **p,
+ const struct prefix **src_p)
{
if (rnode_is_srcnode(rn)) {
struct route_node *dst_rn = rn->table->info;
const char *srcdest_rnode2str(struct route_node *rn, char *str, int size)
{
- struct prefix *dst_p, *src_p;
+ const struct prefix *dst_p, *src_p;
char dst_buf[PREFIX_STRLEN], src_buf[PREFIX_STRLEN];
srcdest_rnode_prefixes(rn, &dst_p, &src_p);
extern struct route_table *srcdest_table_init(void);
extern struct route_node *srcdest_rnode_get(struct route_table *table,
- union prefixptr dst_pu,
- struct prefix_ipv6 *src_p);
+ union prefixconstptr dst_pu,
+ const struct prefix_ipv6 *src_p);
extern struct route_node *srcdest_rnode_lookup(struct route_table *table,
- union prefixptr dst_pu,
- struct prefix_ipv6 *src_p);
-extern void srcdest_rnode_prefixes(struct route_node *rn, struct prefix **p,
- struct prefix **src_p);
+ union prefixconstptr dst_pu,
+ const struct prefix_ipv6 *src_p);
+extern void srcdest_rnode_prefixes(struct route_node *rn,
+ const struct prefix **p,
+ const struct prefix **src_p);
extern const char *srcdest_rnode2str(struct route_node *rn, char *str,
int size);
extern struct route_node *srcdest_route_next(struct route_node *rn);
}
}
-int addattr_l(struct nlmsghdr *n, unsigned int maxlen, int type, void *data,
- unsigned int alen)
+int addattr_l(struct nlmsghdr *n, unsigned int maxlen, int type,
+ const void *data, unsigned int alen)
{
int len;
struct rtattr *rta;
return 0;
}
-int rta_addattr_l(struct rtattr *rta, unsigned int maxlen, int type, void *data,
- unsigned int alen)
+int rta_addattr_l(struct rtattr *rta, unsigned int maxlen, int type,
+ const void *data, unsigned int alen)
{
unsigned int len;
struct rtattr *subrta;
extern void netlink_parse_rtattr(struct rtattr **tb, int max,
struct rtattr *rta, int len);
extern int addattr_l(struct nlmsghdr *n, unsigned int maxlen, int type,
- void *data, unsigned int alen);
+ const void *data, unsigned int alen);
extern int rta_addattr_l(struct rtattr *rta, unsigned int maxlen, int type,
- void *data, unsigned int alen);
+ const void *data, unsigned int alen);
extern int addattr16(struct nlmsghdr *n, unsigned int maxlen, int type,
uint16_t data);
extern int addattr32(struct nlmsghdr *n, unsigned int maxlen, int type,
for (rn = route_top(table); rn; rn = srcdest_route_next(rn))
RNODE_FOREACH_RE (rn, newre) {
- struct prefix *dst_p, *src_p;
+ const struct prefix *dst_p, *src_p;
char buf[PREFIX_STRLEN];
srcdest_rnode_prefixes(rn, &dst_p, &src_p);
/* Either advertise a route for redistribution to registered clients or */
/* withdraw redistribution if add cannot be done for client */
-void redistribute_update(struct prefix *p, struct prefix *src_p,
+void redistribute_update(const struct prefix *p, const struct prefix *src_p,
struct route_entry *re, struct route_entry *prev_re)
{
struct listnode *node, *nnode;
}
}
-void redistribute_delete(struct prefix *p, struct prefix *src_p,
+void redistribute_delete(const struct prefix *p, const struct prefix *src_p,
struct route_entry *re)
{
struct listnode *node, *nnode;
extern void zebra_redistribute_default_delete(ZAPI_HANDLER_ARGS);
/* ----------------- */
-extern void redistribute_update(struct prefix *, struct prefix *,
+extern void redistribute_update(const struct prefix *p,
+ const struct prefix *src_p,
struct route_entry *, struct route_entry *);
-extern void redistribute_delete(struct prefix *, struct prefix *,
+extern void redistribute_delete(const struct prefix *p,
+ const struct prefix *src_p,
struct route_entry *);
extern void zebra_interface_up_update(struct interface *);
extern int is_zebra_valid_kernel_table(uint32_t table_id);
extern int is_zebra_main_routing_table(uint32_t table_id);
-extern int zebra_check_addr(struct prefix *p);
+extern int zebra_check_addr(const struct prefix *p);
extern void rib_addnode(struct route_node *rn, struct route_entry *re,
int process);
* a re-add.
*/
extern enum dp_req_result kernel_route_rib(struct route_node *rn,
- struct prefix *p,
- struct prefix *src_p,
+ const struct prefix *p,
+ const struct prefix *src_p,
struct route_entry *old,
struct route_entry *new);
* so let's separate it out and allow the result to
* be passed back up.
*/
-extern void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p,
+extern void kernel_route_rib_pass_fail(struct route_node *rn,
+ const struct prefix *p,
struct route_entry *re,
enum dp_results res);
* @param zvrf: The vrf we are in
* @param tableid: The table we are working on
*/
-static void _netlink_route_debug(int cmd, struct prefix *p,
- int family, struct zebra_vrf *zvrf,
+static void _netlink_route_debug(int cmd, const struct prefix *p,
+ int family, vrf_id_t vrfid,
uint32_t tableid)
{
if (IS_ZEBRA_DEBUG_KERNEL) {
"netlink_route_multipath(): %s %s vrf %u(%u)",
nl_msg_type_to_str(cmd),
prefix2str(p, buf, sizeof(buf)),
- zvrf_id(zvrf), tableid);
+ vrfid, tableid);
}
}
/* Routing table change via netlink interface. */
/* Update flag indicates whether this is a "replace" or not. */
-static int netlink_route_multipath(int cmd, struct prefix *p,
- struct prefix *src_p, struct route_entry *re,
+static int netlink_route_multipath(int cmd, const struct prefix *p,
+ const struct prefix *src_p,
+ struct route_entry *re,
int update)
{
int bytelen;
addattr32(&req.n, sizeof req, RTA_TABLE, re->table);
}
- _netlink_route_debug(cmd, p, family, zvrf, re->table);
+ _netlink_route_debug(cmd, p, family, zvrf_id(zvrf), re->table);
/*
* If we are not updating the route and we have received
}
enum dp_req_result kernel_route_rib(struct route_node *rn,
- struct prefix *p,
- struct prefix *src_p,
+ const struct prefix *p,
+ const struct prefix *src_p,
struct route_entry *old,
struct route_entry *new)
{
}
enum dp_req_result kernel_route_rib(struct route_node *rn,
- struct prefix *p,
- struct prefix *src_p,
+ const struct prefix *p,
+ const struct prefix *src_p,
struct route_entry *old,
struct route_entry *new)
{
return zserv_send_message(client, s);
}
-int zsend_redistribute_route(int cmd, struct zserv *client, struct prefix *p,
- struct prefix *src_p, struct route_entry *re)
+int zsend_redistribute_route(int cmd, struct zserv *client,
+ const struct prefix *p,
+ const struct prefix *src_p, struct route_entry *re)
{
struct zapi_route api;
struct zapi_nexthop *api_nh;
return zserv_send_message(client, s);
}
-int zsend_route_notify_owner(struct route_entry *re, struct prefix *p,
- enum zapi_route_notify_owner note)
+/*
+ * Common utility send route notification, called from a path using a
+ * route_entry and from a path using a dataplane context.
+ */
+static int route_notify_internal(const struct prefix *p, int type,
+ uint16_t instance, vrf_id_t vrf_id,
+ uint32_t table_id,
+ enum zapi_route_notify_owner note)
{
struct zserv *client;
struct stream *s;
uint8_t blen;
- client = zserv_find_client(re->type, re->instance);
+ client = zserv_find_client(type, instance);
if (!client || !client->notify_owner) {
if (IS_ZEBRA_DEBUG_PACKET) {
char buff[PREFIX_STRLEN];
zlog_debug(
"Not Notifying Owner: %u about prefix %s(%u) %d vrf: %u",
- re->type, prefix2str(p, buff, sizeof(buff)),
- re->table, note, re->vrf_id);
+ type, prefix2str(p, buff, sizeof(buff)),
+ table_id, note, vrf_id);
}
return 0;
}
char buff[PREFIX_STRLEN];
zlog_debug("Notifying Owner: %u about prefix %s(%u) %d vrf: %u",
- re->type, prefix2str(p, buff, sizeof(buff)),
- re->table, note, re->vrf_id);
+ type, prefix2str(p, buff, sizeof(buff)),
+ table_id, note, vrf_id);
}
s = stream_new(ZEBRA_MAX_PACKET_SIZ);
stream_reset(s);
- zclient_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, re->vrf_id);
+ zclient_create_header(s, ZEBRA_ROUTE_NOTIFY_OWNER, vrf_id);
stream_put(s, ¬e, sizeof(note));
stream_putc(s, p->prefixlen);
stream_put(s, &p->u.prefix, blen);
- stream_putl(s, re->table);
+ stream_putl(s, table_id);
stream_putw_at(s, 0, stream_get_endp(s));
return zserv_send_message(client, s);
}
+int zsend_route_notify_owner(struct route_entry *re, const struct prefix *p,
+ enum zapi_route_notify_owner note)
+{
+ return (route_notify_internal(p, re->type, re->instance, re->vrf_id,
+ re->table, note));
+}
+
void zsend_rule_notify_owner(struct zebra_pbr_rule *rule,
enum zapi_rule_notify_owner note)
{
extern int zsend_interface_update(int cmd, struct zserv *client,
struct interface *ifp);
extern int zsend_redistribute_route(int cmd, struct zserv *zclient,
- struct prefix *p, struct prefix *src_p,
+ const struct prefix *p,
+ const struct prefix *src_p,
struct route_entry *re);
extern int zsend_router_id_update(struct zserv *zclient, struct prefix *p,
vrf_id_t vrf_id);
extern int zsend_interface_link_params(struct zserv *zclient,
struct interface *ifp);
extern int zsend_pw_update(struct zserv *client, struct zebra_pw *pw);
-extern int zsend_route_notify_owner(struct route_entry *re, struct prefix *p,
+extern int zsend_route_notify_owner(struct route_entry *re,
+ const struct prefix *p,
enum zapi_route_notify_owner note);
extern void zsend_rule_notify_owner(struct zebra_pbr_rule *rule,
return 0;
}
-int zebra_check_addr(struct prefix *p)
+int zebra_check_addr(const struct prefix *p)
{
if (p->family == AF_INET) {
uint32_t addr;
return nexthop;
}
-static void nexthop_set_resolved(afi_t afi, struct nexthop *newhop,
+static void nexthop_set_resolved(afi_t afi, const struct nexthop *newhop,
struct nexthop *nexthop)
{
struct nexthop *resolved_hop;
route_map_result_t ret = RMAP_MATCH;
int family;
char buf[SRCDEST2STR_BUFFER];
- struct prefix *p, *src_p;
+ const struct prefix *p, *src_p;
srcdest_rnode_prefixes(rn, &p, &src_p);
if (rn->p.family == AF_INET)
return 1;
}
-void kernel_route_rib_pass_fail(struct route_node *rn, struct prefix *p,
+void kernel_route_rib_pass_fail(struct route_node *rn, const struct prefix *p,
struct route_entry *re,
enum dp_results res)
{
{
struct nexthop *nexthop;
rib_table_info_t *info = srcdest_rnode_table_info(rn);
- struct prefix *p, *src_p;
+ const struct prefix *p, *src_p;
struct zebra_vrf *zvrf = vrf_info_lookup(re->vrf_id);
srcdest_rnode_prefixes(rn, &p, &src_p);
{
struct nexthop *nexthop;
rib_table_info_t *info = srcdest_rnode_table_info(rn);
- struct prefix *p, *src_p;
+ const struct prefix *p, *src_p;
struct zebra_vrf *zvrf = vrf_info_lookup(re->vrf_id);
srcdest_rnode_prefixes(rn, &p, &src_p);
}
if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) {
- struct prefix *p, *src_p;
+ const struct prefix *p, *src_p;
+
srcdest_rnode_prefixes(rn, &p, &src_p);
redistribute_delete(p, src_p, re);
char buf[SRCDEST2STR_BUFFER];
rib_dest_t *dest;
struct zebra_vrf *zvrf = NULL;
- struct prefix *p, *src_p;
+ const struct prefix *p, *src_p;
+
srcdest_rnode_prefixes(rn, &p, &src_p);
vrf_id_t vrf_id = VRF_UNKNOWN;
}
route_map_result_t zebra_route_map_check(int family, int rib_type,
- uint8_t instance, struct prefix *p,
+ uint8_t instance,
+ const struct prefix *p,
struct nexthop *nexthop,
vrf_id_t vrf_id, route_tag_t tag)
{
rmap = route_map_lookup_by_name(
proto_rm[family][ZEBRA_ROUTE_MAX]);
if (rmap) {
- ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj);
+ ret = route_map_apply(rmap, (struct prefix *)p,
+ RMAP_ZEBRA, &nh_obj);
}
return (ret);
const char *rmap_name);
extern route_map_result_t
zebra_route_map_check(int family, int rib_type, uint8_t instance,
- struct prefix *p, struct nexthop *nexthop,
+ const struct prefix *p, struct nexthop *nexthop,
vrf_id_t vrf_id, route_tag_t tag);
extern route_map_result_t
zebra_nht_route_map_check(int family, int client_proto, struct prefix *p,
#include "zebra/zebra_memory.h"
/* Install static route into rib. */
-void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
- struct prefix_ipv6 *src_p, struct static_route *si)
+void static_install_route(afi_t afi, safi_t safi, const struct prefix *p,
+ const struct prefix_ipv6 *src_p,
+ struct static_route *si)
{
struct route_entry *re;
struct route_node *rn;
}
/* Uninstall static route from RIB. */
-void static_uninstall_route(afi_t afi, safi_t safi, struct prefix *p,
- struct prefix_ipv6 *src_p, struct static_route *si)
+void static_uninstall_route(afi_t afi, safi_t safi, const struct prefix *p,
+ const struct prefix_ipv6 *src_p,
+ struct static_route *si)
{
struct route_node *rn;
struct route_entry *re;
struct route_table *stable;
struct route_node *rn;
struct static_route *si;
- struct prefix *p, *src_pp;
+ const struct prefix *p, *src_pp;
struct prefix_ipv6 *src_p;
struct vrf *vrf;
uint32_t table_id;
};
-extern void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
- struct prefix_ipv6 *src_p,
+extern void static_install_route(afi_t afi, safi_t safi, const struct prefix *p,
+ const struct prefix_ipv6 *src_p,
struct static_route *si);
-extern void static_uninstall_route(afi_t afi, safi_t safi, struct prefix *p,
- struct prefix_ipv6 *src_p,
+extern void static_uninstall_route(afi_t afi, safi_t safi,
+ const struct prefix *p,
+ const struct prefix_ipv6 *src_p,
struct static_route *si);
extern int static_add_route(afi_t, safi_t safi, uint8_t type, struct prefix *p,