#include "zebra/rt_netlink.h"
#include "zebra/rib.h"
-int kernel_route_rib (struct prefix *a, struct rib *old, struct rib *new) { return 0; }
+int kernel_route_rib (struct prefix *a, struct prefix *b,
+ struct rib *old, struct rib *new) { return 0; }
int kernel_address_add_ipv4 (struct interface *a, struct connected *b)
{
#include "linklist.h"
#include "log.h"
#include "vrf.h"
+#include "srcdest_table.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
RNODE_FOREACH_RIB (rn, newrib)
if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)
&& newrib->distance != DISTANCE_INFINITY)
- zsend_redistribute_route (1, client, &rn->p, newrib);
+ zsend_redistribute_route (1, client, &rn->p, NULL, newrib);
route_unlock_node (rn);
}
for (rn = route_top (table); rn; rn = route_next (rn))
RNODE_FOREACH_RIB (rn, newrib)
{
+ struct prefix *dst_p, *src_p;
+ srcdest_rnode_prefixes(rn, &dst_p, &src_p);
+
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("%s: checking: selected=%d, type=%d, distance=%d, "
"zebra_check_addr=%d", __func__,
CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED),
newrib->type, newrib->distance,
- zebra_check_addr (&rn->p));
+ zebra_check_addr (dst_p));
if (! CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED))
continue;
continue;
if (newrib->distance == DISTANCE_INFINITY)
continue;
- if (! zebra_check_addr (&rn->p))
+ if (! zebra_check_addr (dst_p))
continue;
- zsend_redistribute_route (1, client, &rn->p, newrib);
+ zsend_redistribute_route (1, client, dst_p, src_p, newrib);
}
}
}
/* 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 rib *rib, struct rib *prev_rib)
+redistribute_update (struct prefix *p, struct prefix *src_p,
+ struct rib *rib, struct rib *prev_rib)
{
struct listnode *node, *nnode;
struct zserv *client;
if (send_redistribute)
{
- zsend_redistribute_route (1, client, p, rib);
+ zsend_redistribute_route (1, client, p, src_p, rib);
}
else if (prev_rib &&
((rib->instance &&
rib->instance)) ||
vrf_bitmap_check (client->redist[afi][prev_rib->type], rib->vrf_id)))
{
- zsend_redistribute_route (0, client, p, prev_rib);
+ zsend_redistribute_route (0, client, p, src_p, prev_rib);
}
}
}
void
-redistribute_delete (struct prefix *p, struct rib *rib)
+redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib)
{
struct listnode *node, *nnode;
struct zserv *client;
rib->instance)) ||
vrf_bitmap_check (client->redist[afi][rib->type], rib->vrf_id))
{
- zsend_redistribute_route (0, client, p, rib);
+ zsend_redistribute_route (0, client, p, src_p, rib);
}
}
}
extern void zebra_redistribute_default_delete (int, struct zserv *, int,
struct zebra_vrf *zvrf);
-extern void redistribute_update (struct prefix *, struct rib *, struct rib *);
-extern void redistribute_delete (struct prefix *, struct rib *);
+extern void redistribute_update (struct prefix *, struct prefix *,
+ struct rib *, struct rib *);
+extern void redistribute_delete (struct prefix *, struct prefix *, struct rib *);
extern void zebra_interface_up_update (struct interface *);
extern void zebra_interface_down_update (struct interface *);
struct zebra_vrf *zvrf)
{ return; }
-void redistribute_update (struct prefix *a, struct rib *b, struct rib *c)
+void redistribute_update (struct prefix *a, struct prefix *b,
+ struct rib *c, struct rib *d)
{ return; }
-void redistribute_delete (struct prefix *a, struct rib *b)
+void redistribute_delete (struct prefix *a, struct prefix *b, struct rib *c)
{ return; }
void zebra_interface_up_update (struct interface *a)
#include "vrf.h"
#include "if.h"
#include "mpls.h"
+#include "srcdest_table.h"
#define DISTANCE_INFINITY 255
#define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */
extern int nexthop_has_fib_child(struct nexthop *);
extern void rib_lookup_and_dump (struct prefix_ipv4 *, vrf_id_t);
extern void rib_lookup_and_pushup (struct prefix_ipv4 *, vrf_id_t);
-#define rib_dump(prefix ,rib) _rib_dump(__func__, prefix, rib)
+#define rib_dump(prefix, src, rib) _rib_dump(__func__, prefix, src, rib)
extern void _rib_dump (const char *,
+ union prefix46constptr,
union prefix46constptr, const struct rib *);
extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *,
vrf_id_t);
static inline struct route_table *
rib_dest_table (rib_dest_t *dest)
{
- return dest->rnode->table;
+ return srcdest_rnode_table(dest->rnode);
}
/*
#include "zebra/zebra_ns.h"
#include "zebra/zebra_mpls.h"
-extern int kernel_route_rib (struct prefix *, struct rib *, struct rib *);
+extern int kernel_route_rib (struct prefix *, struct prefix *,
+ struct rib *, struct rib *);
extern int kernel_address_add_ipv4 (struct interface *, struct connected *);
extern int kernel_address_delete_ipv4 (struct interface *, struct connected *);
struct rtattr *tb[RTA_MAX + 1];
u_char flags = 0;
struct prefix p;
+ struct prefix_ipv6 src_p;
vrf_id_t vrf_id = VRF_DEFAULT;
char anyaddr[16] = { 0 };
- int index;
+ int index = 0;
int table;
- int metric;
+ int metric = 0;
u_int32_t mtu = 0;
- void *dest;
- void *gate;
- void *src;
+ void *dest = NULL;
+ void *gate = NULL;
+ void *prefsrc = NULL; /* IPv4 preferred source host address */
+ void *src = NULL; /* IPv6 srcdest source prefix */
rtm = NLMSG_DATA (h);
if (rtm->rtm_protocol == RTPROT_KERNEL)
return 0;
- if (rtm->rtm_src_len != 0)
- return 0;
-
/* We don't care about change notifications for the MPLS table. */
/* TODO: Revisit this. */
if (rtm->rtm_family == AF_MPLS)
if (rtm->rtm_protocol == RTPROT_ZEBRA)
flags |= ZEBRA_FLAG_SELFROUTE;
- index = 0;
- metric = 0;
- dest = NULL;
- gate = NULL;
- src = NULL;
-
if (tb[RTA_OIF])
index = *(int *) RTA_DATA (tb[RTA_OIF]);
else
dest = anyaddr;
+ if (tb[RTA_SRC])
+ src = RTA_DATA (tb[RTA_SRC]);
+ else
+ src = anyaddr;
+
if (tb[RTA_PREFSRC])
- src = RTA_DATA (tb[RTA_PREFSRC]);
+ prefsrc = RTA_DATA (tb[RTA_PREFSRC]);
if (tb[RTA_GATEWAY])
gate = RTA_DATA (tb[RTA_GATEWAY]);
memcpy (&p.u.prefix4, dest, 4);
p.prefixlen = rtm->rtm_dst_len;
+ if (rtm->rtm_src_len != 0)
+ return 0;
+
if (!tb[RTA_MULTIPATH])
rib_add (AFI_IP, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL,
- 0, flags, &p, NULL, gate, src, index,
+ 0, flags, &p, NULL, gate, prefsrc, index,
table, metric, mtu, 0);
else
{
if (gate)
{
if (index)
- rib_nexthop_ipv4_ifindex_add (rib, gate, src, index);
+ rib_nexthop_ipv4_ifindex_add (rib, gate, prefsrc, index);
else
- rib_nexthop_ipv4_add (rib, gate, src);
+ rib_nexthop_ipv4_add (rib, gate, prefsrc);
}
else
rib_nexthop_ifindex_add (rib, index);
memcpy (&p.u.prefix6, dest, 16);
p.prefixlen = rtm->rtm_dst_len;
+ src_p.family = AF_INET6;
+ memcpy (&src_p.prefix, src, 16);
+ src_p.prefixlen = rtm->rtm_src_len;
+
rib_add (AFI_IP6, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL,
- 0, flags, &p, NULL, gate, src, index,
+ 0, flags, &p, &src_p, gate, prefsrc, index,
table, metric, mtu, 0);
}
vrf_id_t vrf_id = VRF_DEFAULT;
char anyaddr[16] = { 0 };
- int index;
+ int index = 0;
int table;
- int metric;
+ int metric = 0;
u_int32_t mtu = 0;
- void *dest;
- void *gate;
- void *src;
+ void *dest = NULL;
+ void *gate = NULL;
+ void *prefsrc = NULL; /* IPv4 preferred source host address */
+ void *src = NULL; /* IPv6 srcdest source prefix */
rtm = NLMSG_DATA (h);
if (rtm->rtm_protocol == RTPROT_ZEBRA)
SET_FLAG(zebra_flags, ZEBRA_FLAG_SELFROUTE);
- if (rtm->rtm_src_len != 0)
- {
- zlog_warn ("netlink_route_change(): no src len");
- return 0;
- }
-
/* Table corresponding to route. */
if (tb[RTA_TABLE])
table = *(int *) RTA_DATA (tb[RTA_TABLE]);
return 0;
}
- index = 0;
- metric = 0;
- dest = NULL;
- gate = NULL;
- src = NULL;
-
if (tb[RTA_OIF])
index = *(int *) RTA_DATA (tb[RTA_OIF]);
else
dest = anyaddr;
+ if (tb[RTA_SRC])
+ src = RTA_DATA (tb[RTA_SRC]);
+ else
+ src = anyaddr;
+
if (tb[RTA_GATEWAY])
gate = RTA_DATA (tb[RTA_GATEWAY]);
if (tb[RTA_PREFSRC])
- src = RTA_DATA (tb[RTA_PREFSRC]);
+ prefsrc = RTA_DATA (tb[RTA_PREFSRC]);
if (h->nlmsg_type == RTM_NEWROUTE)
{
memcpy (&p.u.prefix4, dest, 4);
p.prefixlen = rtm->rtm_dst_len;
+ if (rtm->rtm_src_len != 0)
+ {
+ zlog_warn ("unsupported IPv4 sourcedest route (dest %s/%d)",
+ inet_ntoa (p.u.prefix4), p.prefixlen);
+ return 0;
+ }
+
if (IS_ZEBRA_DEBUG_KERNEL)
{
char buf[PREFIX_STRLEN];
{
if (!tb[RTA_MULTIPATH])
rib_add (AFI_IP, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL,
- 0, 0, &p, NULL, gate, src, index,
- table, metric, mtu, 0);
+ 0, 0, &p, NULL, gate, prefsrc, index,
+ table, metric, mtu, 0);
else
{
/* This is a multipath route */
if (gate)
{
if (index)
- rib_nexthop_ipv4_ifindex_add (rib, gate, src, index);
+ rib_nexthop_ipv4_ifindex_add (rib, gate, prefsrc, index);
else
- rib_nexthop_ipv4_add (rib, gate, src);
+ rib_nexthop_ipv4_add (rib, gate, prefsrc);
}
else
rib_nexthop_ifindex_add (rib, index);
if (rtm->rtm_family == AF_INET6)
{
struct prefix p;
+ struct prefix_ipv6 src_p;
p.family = AF_INET6;
memcpy (&p.u.prefix6, dest, 16);
p.prefixlen = rtm->rtm_dst_len;
+ src_p.family = AF_INET6;
+ memcpy (&src_p.prefix, src, 16);
+ src_p.prefixlen = rtm->rtm_src_len;
+
if (IS_ZEBRA_DEBUG_KERNEL)
{
char buf[PREFIX_STRLEN];
- zlog_debug ("%s %s vrf %u",
+ char buf2[PREFIX_STRLEN];
+ zlog_debug ("%s %s%s%s vrf %u",
nl_msg_type_to_str (h->nlmsg_type),
- prefix2str (&p, buf, sizeof(buf)), vrf_id);
+ prefix2str (&p, buf, sizeof(buf)),
+ src_p.prefixlen ? " from " : "",
+ src_p.prefixlen ? prefix2str(&src_p, buf2, sizeof(buf2)) : "",
+ vrf_id);
}
if (h->nlmsg_type == RTM_NEWROUTE)
rib_add (AFI_IP6, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL,
- 0, 0, &p, NULL, gate, src, index,
+ 0, 0, &p, &src_p, gate, prefsrc, index,
table, metric, mtu, 0);
else
rib_delete (AFI_IP6, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL,
- 0, zebra_flags, &p, NULL, gate, index, table);
+ 0, zebra_flags, &p, &src_p, gate, index, table);
}
return 0;
/* 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 rib *rib,
- int update)
+netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
+ struct rib *rib, int update)
{
int bytelen;
struct sockaddr_nl snl;
req.n.nlmsg_type = cmd;
req.r.rtm_family = family;
req.r.rtm_dst_len = p->prefixlen;
+ req.r.rtm_src_len = src_p ? src_p->prefixlen : 0;
req.r.rtm_protocol = RTPROT_ZEBRA;
req.r.rtm_scope = RT_SCOPE_UNIVERSE;
}
addattr_l (&req.n, sizeof req, RTA_DST, &p->u.prefix, bytelen);
+ if (src_p)
+ addattr_l (&req.n, sizeof req, RTA_SRC, &src_p->u.prefix, bytelen);
/* Metric. */
/* Hardcode the metric for all routes coming from zebra. Metric isn't used
}
int
-kernel_route_rib (struct prefix *p, struct rib *old, struct rib *new)
+kernel_route_rib (struct prefix *p, struct prefix *src_p,
+ struct rib *old, struct rib *new)
{
if (!old && new)
- return netlink_route_multipath (RTM_NEWROUTE, p, new, 0);
+ return netlink_route_multipath (RTM_NEWROUTE, p, src_p, new, 0);
if (old && !new)
- return netlink_route_multipath (RTM_DELROUTE, p, old, 0);
+ return netlink_route_multipath (RTM_DELROUTE, p, src_p, old, 0);
- return netlink_route_multipath (RTM_NEWROUTE, p, new, 1);
+ return netlink_route_multipath (RTM_NEWROUTE, p, src_p, new, 1);
}
int
{
zlog_debug ("%s: %s: attention! gate not found for rib %p",
__func__, prefix_buf, rib);
- rib_dump (p, rib);
+ rib_dump (p, NULL, rib);
}
else
inet_ntop (AF_INET, &sin_gate.sin_addr, gate_buf, INET_ADDRSTRLEN);
}
int
-kernel_route_rib (struct prefix *p, struct rib *old, struct rib *new)
+kernel_route_rib (struct prefix *p, struct prefix *src_p,
+ struct rib *old, struct rib *new)
{
int route = 0;
+ if (src_p && src_p->prefixlen)
+ {
+ zlog (NULL, LOG_ERR, "route add: IPv6 sourcedest routes unsupported!");
+ return 1;
+ }
+
if (zserv_privs.change(ZPRIVS_RAISE))
zlog (NULL, LOG_ERR, "Can't raise privileges");
#include "nexthop.h"
#include "vrf.h"
#include "mpls.h"
+#include "srcdest_table.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
_rnode_zlog(const char *_func, vrf_id_t vrf_id, struct route_node *rn, int priority,
const char *msgfmt, ...)
{
- char buf[PREFIX_STRLEN + 8];
+ char buf[SRCDEST2STR_BUFFER + sizeof(" (MRIB)")];
char msgbuf[512];
va_list ap;
if (rn)
{
- rib_table_info_t *info = rn->table->info;
+ rib_table_info_t *info = srcdest_rnode_table_info (rn);
+ srcdest_rnode2str(rn, buf, sizeof(buf));
- prefix2str(&rn->p, buf, sizeof(buf));
if (info->safi == SAFI_MULTICAST)
strcat(buf, " (MRIB)");
}
nexthop_active_check (struct route_node *rn, struct rib *rib,
struct nexthop *nexthop, int set)
{
- rib_table_info_t *info = rn->table->info;
struct interface *ifp;
route_map_result_t ret = RMAP_MATCH;
int family;
- char buf[INET6_ADDRSTRLEN+1];
+ char buf[SRCDEST2STR_BUFFER];
+ struct prefix *p, *src_p;
+ srcdest_rnode_prefixes (rn, &p, &src_p);
if (rn->p.family == AF_INET)
family = AFI_IP;
/* XXX: What exactly do those checks do? Do we support
* e.g. IPv4 routes with IPv6 nexthops or vice versa? */
if (RIB_SYSTEM_ROUTE(rib) ||
- (family == AFI_IP && rn->p.family != AF_INET) ||
- (family == AFI_IP6 && rn->p.family != AF_INET6))
+ (family == AFI_IP && p->family != AF_INET) ||
+ (family == AFI_IP6 && p->family != AF_INET6))
return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
/* The original code didn't determine the family correctly
* in every case.
*/
if (!family)
- family = info->afi;
+ {
+ rib_table_info_t *info;
+
+ info = srcdest_rnode_table_info(rn);
+ family = info->afi;
+ }
memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr));
/* It'll get set if required inside */
- ret = zebra_route_map_check(family, rib->type, &rn->p, nexthop, rib->vrf_id,
+ ret = zebra_route_map_check(family, rib->type, p, nexthop, rib->vrf_id,
rib->tag);
if (ret == RMAP_DENYMATCH)
{
if (IS_ZEBRA_DEBUG_RIB)
{
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, sizeof (buf));
- zlog_debug("%u:%s/%d: Filtering out with NH out %s due to route map",
- rib->vrf_id, buf, rn->p.prefixlen,
+ srcdest_rnode2str(rn, buf, sizeof(buf));
+ zlog_debug("%u:%s: Filtering out with NH out %s due to route map",
+ rib->vrf_id, buf,
ifindex2ifname_vrf (nexthop->ifindex, rib->vrf_id));
}
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
{
int ret = 0;
struct nexthop *nexthop, *tnexthop;
- rib_table_info_t *info = rn->table->info;
+ rib_table_info_t *info = srcdest_rnode_table_info(rn);
int recursing;
+ struct prefix *p, *src_p;
+
+ srcdest_rnode_prefixes (rn, &p, &src_p);
if (info->safi != SAFI_UNICAST)
{
* the kernel.
*/
zfpm_trigger_update (rn, "installing in kernel");
- ret = kernel_route_rib (&rn->p, old, rib);
+ ret = kernel_route_rib (p, src_p, old, rib);
/* If install succeeds, update FIB flag for nexthops. */
if (!ret)
{
int ret = 0;
struct nexthop *nexthop, *tnexthop;
- rib_table_info_t *info = rn->table->info;
+ rib_table_info_t *info = srcdest_rnode_table_info(rn);
int recursing;
+ struct prefix *p, *src_p;
+
+ srcdest_rnode_prefixes (rn, &p, &src_p);
if (info->safi != SAFI_UNICAST)
{
* the kernel.
*/
zfpm_trigger_update (rn, "uninstalling from kernel");
- ret = kernel_route_rib (&rn->p, rib, NULL);
+ ret = kernel_route_rib (p, src_p, rib, NULL);
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
static void
rib_uninstall (struct route_node *rn, struct rib *rib)
{
- rib_table_info_t *info = rn->table->info;
+ rib_table_info_t *info = srcdest_rnode_table_info(rn);
if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
{
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
{
- redistribute_delete (&rn->p, rib);
+ struct prefix *p, *src_p;
+ srcdest_rnode_prefixes (rn, &p, &src_p);
+
+ redistribute_delete (p, src_p, rib);
UNSET_FLAG (rib->flags, ZEBRA_FLAG_SELECTED);
}
}
rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn,
struct rib *new)
{
- char buf[INET6_ADDRSTRLEN];
-
zfpm_trigger_update (rn, "new route selected");
/* Update real nexthop. This may actually determine if nexthop is active or not. */
SET_FLAG (new->status, RIB_ENTRY_SELECTED_FIB);
if (IS_ZEBRA_DEBUG_RIB)
{
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: Adding route rn %p, rib %p (type %d)",
- zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type);
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
+ zlog_debug ("%u:%s: Adding route rn %p, rib %p (type %d)",
+ zvrf_id (zvrf), buf, rn, new, new->type);
}
if (!RIB_SYSTEM_ROUTE (new))
{
if (rib_install_kernel (rn, new, NULL))
{
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_warn ("%u:%s/%d: Route install failed",
- zvrf_id (zvrf), buf, rn->p.prefixlen);
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
+ zlog_warn ("%u:%s: Route install failed",
+ zvrf_id (zvrf), buf);
}
}
rib_process_del_fib(struct zebra_vrf *zvrf, struct route_node *rn,
struct rib *old)
{
- char buf[INET6_ADDRSTRLEN];
-
zfpm_trigger_update (rn, "removing existing route");
/* Uninstall from kernel. */
if (IS_ZEBRA_DEBUG_RIB)
{
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: Deleting route rn %p, rib %p (type %d)",
- zvrf_id (zvrf), buf, rn->p.prefixlen, rn, old, old->type);
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
+ zlog_debug ("%u:%s: Deleting route rn %p, rib %p (type %d)",
+ zvrf_id (zvrf), buf, rn, old, old->type);
}
if (!RIB_SYSTEM_ROUTE (old))
rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn,
struct rib *old, struct rib *new)
{
- char buf[INET6_ADDRSTRLEN];
struct nexthop *nexthop = NULL, *tnexthop;
int recursing;
int nh_active = 0;
int installed = 1;
- if (IS_ZEBRA_DEBUG_RIB)
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
-
/*
* We have to install or update if a new route has been selected or
* something has changed.
{
if (IS_ZEBRA_DEBUG_RIB)
{
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
if (new != old)
- zlog_debug ("%u:%s/%d: Updating route rn %p, rib %p (type %d) "
- "old %p (type %d)", zvrf_id (zvrf), buf, rn->p.prefixlen,
+ zlog_debug ("%u:%s: Updating route rn %p, rib %p (type %d) "
+ "old %p (type %d)", zvrf_id (zvrf), buf,
rn, new, new->type, old, old->type);
else
- zlog_debug ("%u:%s/%d: Updating route rn %p, rib %p (type %d)",
- zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type);
+ zlog_debug ("%u:%s: Updating route rn %p, rib %p (type %d)",
+ zvrf_id (zvrf), buf, rn, new, new->type);
}
/* Non-system route should be installed. */
if (!RIB_SYSTEM_ROUTE (new))
{
if (rib_install_kernel (rn, new, old))
{
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
installed = 0;
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_warn ("%u:%s/%d: Route install failed",
- zvrf_id (zvrf), buf, rn->p.prefixlen);
+ zlog_warn ("%u:%s: Route install failed", zvrf_id (zvrf), buf);
}
}
{
if (IS_ZEBRA_DEBUG_RIB)
{
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
if (new != old)
- zlog_debug ("%u:%s/%d: Deleting route rn %p, rib %p (type %d) "
- "old %p (type %d) - %s", zvrf_id (zvrf), buf, rn->p.prefixlen,
+ zlog_debug ("%u:%s: Deleting route rn %p, rib %p (type %d) "
+ "old %p (type %d) - %s", zvrf_id (zvrf), buf,
rn, new, new->type, old, old->type,
nh_active ? "install failed" : "nexthop inactive");
else
- zlog_debug ("%u:%s/%d: Deleting route rn %p, rib %p (type %d) - %s",
- zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type,
+ zlog_debug ("%u:%s: Deleting route rn %p, rib %p (type %d) - %s",
+ zvrf_id (zvrf), buf, rn, new, new->type,
nh_active ? "install failed" : "nexthop inactive");
}
struct rib *old_fib = NULL;
struct rib *new_fib = NULL;
struct rib *best = NULL;
- char buf[INET6_ADDRSTRLEN];
+ char buf[SRCDEST2STR_BUFFER];
rib_dest_t *dest;
struct zebra_vrf *zvrf = NULL;
+ struct prefix *p, *src_p;
+ srcdest_rnode_prefixes(rn, &p, &src_p);
vrf_id_t vrf_id = VRF_UNKNOWN;
assert (rn);
}
if (IS_ZEBRA_DEBUG_RIB)
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
+ srcdest_rnode2str(rn, buf, sizeof(buf));
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- zlog_debug ("%u:%s/%d: Processing rn %p", vrf_id, buf, rn->p.prefixlen, rn);
+ zlog_debug ("%u:%s: Processing rn %p", vrf_id, buf, rn);
RNODE_FOREACH_RIB_SAFE (rn, rib, next)
{
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- zlog_debug ("%u:%s/%d: Examine rib %p (type %d) status %x flags %x "
+ zlog_debug ("%u:%s: Examine rib %p (type %d) status %x flags %x "
"dist %d metric %d",
- vrf_id, buf, rn->p.prefixlen, rib, rib->type, rib->status,
+ vrf_id, buf, rib, rib->type, rib->status,
rib->flags, rib->distance, rib->metric);
UNSET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
if (rib != old_selected)
{
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug ("%s: %s/%d: imported via import-table but denied "
+ zlog_debug ("%s: %s: imported via import-table but denied "
"by the ip protocol table route-map",
- __func__, buf, rn->p.prefixlen);
+ __func__, buf);
rib_unlink (rn, rib);
}
else
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
{
- zlog_debug ("%u:%s/%d: After processing: old_selected %p new_selected %p old_fib %p new_fib %p",
- vrf_id, buf, rn->p.prefixlen,
+ zlog_debug ("%u:%s: After processing: old_selected %p new_selected %p old_fib %p new_fib %p",
+ vrf_id, buf,
(void *)old_selected,
(void *)new_selected,
(void *)old_fib,
if (old_selected)
{
if (!new_selected)
- redistribute_delete(&rn->p, old_selected);
+ redistribute_delete(p, src_p, old_selected);
if (old_selected != new_selected)
UNSET_FLAG (old_selected->flags, ZEBRA_FLAG_SELECTED);
}
{
/* Install new or replace existing redistributed entry */
SET_FLAG (new_selected->flags, ZEBRA_FLAG_SELECTED);
- redistribute_update (&rn->p, new_selected, old_selected);
+ redistribute_update (p, src_p, new_selected, old_selected);
}
}
{
struct listnode *lnode = listhead (subq);
struct route_node *rnode;
- char buf[INET6_ADDRSTRLEN];
rib_dest_t *dest;
struct zebra_vrf *zvrf = NULL;
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
{
- inet_ntop (rnode->p.family, &rnode->p.u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: rn %p dequeued from sub-queue %u",
- zvrf ? zvrf_id (zvrf) : 0, buf, rnode->p.prefixlen, rnode, qindex);
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rnode, buf, sizeof(buf));
+ zlog_debug ("%u:%s: rn %p dequeued from sub-queue %u",
+ zvrf ? zvrf_id (zvrf) : 0, buf, rnode, qindex);
}
if (rnode->info)
/* Just clean up if non main table */
if (IS_ZEBRA_DEBUG_RIB)
{
- char buf[INET6_ADDRSTRLEN];
- if (IS_ZEBRA_DEBUG_RIB)
- {
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: Freeing route rn %p, rib %p (type %d)",
- rib->vrf_id, buf, rn->p.prefixlen, rn, rib, rib->type);
- }
+ char buf[SRCDEST2STR_BUFFER];
+ srcdest_rnode2str(rn, buf, sizeof(buf));
+ zlog_debug ("%u:%s: Freeing route rn %p, rib %p (type %d)",
+ rib->vrf_id, buf, rn, rib, rib->type);
}
rib_unlink(rn, rib);
*/
void _rib_dump (const char * func,
- union prefix46constptr pp, const struct rib * rib)
+ union prefix46constptr pp,
+ union prefix46constptr src_pp,
+ const struct rib * rib)
{
const struct prefix *p = pp.p;
+ const struct prefix *src_p = src_pp.p;
+ bool is_srcdst = src_p && src_p->prefixlen;
char straddr[PREFIX_STRLEN];
+ char srcaddr[PREFIX_STRLEN];
struct nexthop *nexthop, *tnexthop;
int recursing;
- zlog_debug ("%s: dumping RIB entry %p for %s vrf %u", func, (const void *)rib,
- prefix2str(pp, straddr, sizeof(straddr)), rib->vrf_id);
+ zlog_debug ("%s: dumping RIB entry %p for %s%s%s vrf %u", func, (const void *)rib,
+ prefix2str(pp, straddr, sizeof(straddr)),
+ is_srcdst ? " from " : "",
+ is_srcdst ? prefix2str(src_pp, srcaddr, sizeof(srcaddr)) : "",
+ rib->vrf_id);
zlog_debug
(
"%s: refcnt == %lu, uptime == %lu, type == %u, instance == %d, table == %d",
(CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED) ? "removed" : "NOT removed"),
(CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) ? "selected" : "NOT selected")
);
- rib_dump (p, rib);
+ rib_dump (p, NULL, rib);
}
}
char buf[PREFIX_STRLEN];
zlog_debug ("%u:%s: freeing way for connected prefix",
rib->vrf_id, prefix2str(&rn->p, buf, sizeof(buf)));
- rib_dump (&rn->p, rib);
+ rib_dump (&rn->p, NULL, rib);
}
rib_uninstall (rn, rib);
}
else
family = AFI_IP6;
+ assert(!src_p || family == AFI_IP6);
+
/* Lookup table. */
table = zebra_vrf_table_with_table_id (family, safi, rib->vrf_id, rib->table);
if (! table)
/* Make it sure prefixlen is applied to the prefix. */
apply_mask (p);
+ if (src_p)
+ apply_mask_ipv6 (src_p);
/* Set default distance by route type. */
if (rib->distance == 0)
}
/* Lookup route node.*/
- rn = route_node_get (table, p);
+ rn = srcdest_rnode_get (table, p, src_p);
/* If same type of route are installed, treat it as a implicit
withdraw. */
/* Link new rib to node.*/
if (IS_ZEBRA_DEBUG_RIB)
{
- char buf[INET6_ADDRSTRLEN];
- if (IS_ZEBRA_DEBUG_RIB)
- {
- inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: Inserting route rn %p, rib %p (type %d) "
- "existing %p",
- rib->vrf_id, buf, p->prefixlen, (void *)rn,
- (void *)rib, rib->type, (void *)same);
- }
+ rnode_debug(rn, rib->vrf_id, "Inserting route rn %p, rib %p (type %d) existing %p",
+ (void *)rn, (void *)rib, rib->type, (void *)same);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- rib_dump ((struct prefix *)p, rib);
+ rib_dump (p, src_p, rib);
}
rib_addnode (rn, rib, 1);
ret = 1;
struct rib *same = NULL;
struct nexthop *nexthop, *tnexthop;
int recursing;
- char buf1[PREFIX_STRLEN];
char buf2[INET6_ADDRSTRLEN];
+ assert(!src_p || afi == AFI_IP6);
+
/* Lookup table. */
table = zebra_vrf_table_with_table_id (afi, safi, vrf_id, table_id);
if (! table)
/* Apply mask. */
apply_mask (p);
+ if (src_p)
+ apply_mask_ipv6 (src_p);
/* Lookup route node. */
- rn = route_node_lookup (table, p);
+ rn = srcdest_rnode_lookup (table, p, src_p);
if (! rn)
{
+ char dst_buf[PREFIX_STRLEN], src_buf[PREFIX_STRLEN];
+
+ prefix2str(p, dst_buf, sizeof(dst_buf));
+ if (src_p && src_p->prefixlen)
+ prefix2str(src_p, src_buf, sizeof(src_buf));
+ else
+ src_buf[0] = '\0';
+
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug ("%u:%s: doesn't exist in rib",
- vrf_id, prefix2str (p, buf1, sizeof(buf1)));
+ zlog_debug ("%u:%s%s%s doesn't exist in rib",
+ vrf_id, dst_buf,
+ (src_buf[0] != '\0') ? " from " : "",
+ src_buf);
return ZEBRA_ERR_RTNOEXIST;
}
{
if (IS_ZEBRA_DEBUG_RIB)
{
- zlog_debug ("%u:%s: rn %p, rib %p (type %d) was deleted "
- "from kernel, adding",
- vrf_id, prefix2str(p, buf1, INET6_ADDRSTRLEN),
- rn, fib, fib->type);
+ rnode_debug (rn, vrf_id, "rn %p, rib %p (type %d) was deleted from kernel, adding",
+ rn, fib, fib->type);
}
if (allow_delete)
{
if (IS_ZEBRA_DEBUG_RIB)
{
if (gate)
- zlog_debug ("%u:%s: via %s ifindex %d type %d "
+ rnode_debug(rn, vrf_id, "via %s ifindex %d type %d "
"doesn't exist in rib",
- vrf_id, prefix2str (p, buf1, sizeof(buf1)),
- inet_ntop (family2afi(afi), gate, buf2, INET_ADDRSTRLEN),
+ inet_ntop (family2afi(afi), gate, buf2, INET_ADDRSTRLEN), /* FIXME */
ifindex,
type);
else
- zlog_debug ("%u:%s: ifindex %d type %d doesn't exist in rib",
- vrf_id, prefix2str (p, buf1, sizeof(buf1)),
+ rnode_debug (rn, vrf_id, "ifindex %d type %d doesn't exist in rib",
ifindex,
type);
}
struct route_node *rn;
struct nexthop *nexthop;
+ assert(!src_p || afi == AFI_IP6);
+
/* Lookup table. */
table = zebra_vrf_table_with_table_id (afi, safi, vrf_id, table_id);
if (! table)
/* Make sure mask is applied. */
apply_mask (p);
+ if (src_p)
+ apply_mask_ipv6 (src_p);
/* Set default distance by route type. */
if (distance == 0)
}
/* Lookup route node.*/
- rn = route_node_get (table, p);
+ rn = srcdest_rnode_get (table, p, src_p);
/* If same type of route are installed, treat it as a implicit
withdraw. */
/* Link new rib to node.*/
if (IS_ZEBRA_DEBUG_RIB)
{
- char buf[INET6_ADDRSTRLEN];
- if (IS_ZEBRA_DEBUG_RIB)
- {
- inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: Inserting route rn %p, rib %p (type %d) "
- "existing %p",
- vrf_id, buf, p->prefixlen, (void *)rn,
- (void *)rib, rib->type, (void *)same);
- }
+ rnode_debug (rn, vrf_id, "Inserting route rn %p, rib %p (type %d) existing %p",
+ (void *)rn, (void *)rib, rib->type, (void *)same);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
- rib_dump (p, rib);
+ rib_dump (p, src_p, rib);
}
rib_addnode (rn, rib, 1);
/* Walk all routes and queue for processing, if appropriate for
* the trigger event.
*/
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
{
switch (event)
{
struct rib *next;
if (table)
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB_SAFE (rn, rib, next)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
int ret = 0;
if (table)
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB_SAFE (rn, rib, next)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
unsigned long n = 0;
if (table)
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB_SAFE (rn, rib, next)
{
if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED))
n++;
}
}
-
return n;
}
struct rib *rib;
if (table)
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
if (!CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB))
rib_install_kernel (rn, rib, rib);
/* Update redistribution if it's selected */
if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED))
- redistribute_update (&rn->p, rib, NULL);
+ redistribute_update (&rn->p, NULL, rib, NULL);
}
else
{
/* Remove from redistribute if selected route becomes inactive */
if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED))
- redistribute_delete (&rn->p, rib);
+ redistribute_delete (&rn->p, NULL, rib);
/* Remove from kernel if fib route becomes inactive */
if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB))
rib_uninstall_kernel (rn, rib);
#include "linklist.h"
#include "command.h"
#include "memory.h"
+#include "srcdest_table.h"
#include "vty.h"
#include "zebra/debug.h"
}
static void
-zebra_rtable_node_destroy (route_table_delegate_t *delegate,
- struct route_table *table, struct route_node *node)
+zebra_rtable_node_cleanup (struct route_table *table, struct route_node *node)
{
struct rib *rib, *next;
if (node->info)
XFREE (MTYPE_RIB_DEST, node->info);
-
- route_node_destroy (delegate, table, node);
}
static void
}
static void
-zebra_rnhtable_node_destroy (route_table_delegate_t *delegate,
- struct route_table *table, struct route_node *node)
+zebra_rnhtable_node_cleanup (struct route_table *table, struct route_node *node)
{
if (node->info)
zebra_free_rnh (node->info);
-
- route_node_destroy (delegate, table, node);
}
-route_table_delegate_t zebra_rtable_delegate = {
- .create_node = route_node_create,
- .destroy_node = zebra_rtable_node_destroy
-};
-
route_table_delegate_t zebra_stable_delegate = {
.create_node = route_node_create,
.destroy_node = zebra_stable_node_destroy
};
-route_table_delegate_t zebra_rnhtable_delegate = {
- .create_node = route_node_create,
- .destroy_node = zebra_rnhtable_node_destroy
-};
-
/*
* Create a routing table for the specific AFI/SAFI in the given VRF.
*/
assert (!zvrf->table[afi][safi]);
- table = route_table_init_with_delegate (&zebra_rtable_delegate);
+ if (afi == AFI_IP6)
+ table = srcdest_table_init();
+ else
+ table = route_table_init();
+ table->cleanup = zebra_rtable_node_cleanup;
zvrf->table[afi][safi] = table;
info = XCALLOC (MTYPE_RIB_TABLE_INFO, sizeof (*info));
struct zebra_vrf *zvrf;
afi_t afi;
safi_t safi;
+ struct route_table *table;
zvrf = XCALLOC (MTYPE_ZEBRA_VRF, sizeof (struct zebra_vrf));
route_table_init_with_delegate (&zebra_stable_delegate);
}
- zvrf->rnh_table[afi] =
- route_table_init_with_delegate (&zebra_rnhtable_delegate);
- zvrf->import_check_table[afi] =
- route_table_init_with_delegate (&zebra_rnhtable_delegate);
+ table = route_table_init();
+ table->cleanup = zebra_rnhtable_node_cleanup;
+ zvrf->rnh_table[afi] = table;
+
+ table = route_table_init();
+ table->cleanup = zebra_rnhtable_node_cleanup;
+ zvrf->import_check_table[afi] = table;
}
zebra_mpls_init_tables (zvrf);
{
if (zvrf->other_table[afi][table_id] == NULL)
{
- table = route_table_init();
+ table = (afi == AFI_IP6) ? srcdest_table_init() : route_table_init();
info = XCALLOC (MTYPE_RIB_TABLE_INFO, sizeof (*info));
info->zvrf = zvrf;
info->afi = afi;
#include "vrf.h"
#include "mpls.h"
#include "routemap.h"
+#include "srcdest_table.h"
#include "zebra/zserv.h"
#include "zebra/zebra_vrf.h"
struct rib *rib;
struct nexthop *nexthop, *tnexthop;
int recursing;
- char buf[PREFIX_STRLEN];
+ char buf[SRCDEST2STR_BUFFER];
struct zebra_vrf *zvrf;
RNODE_FOREACH_RIB (rn, rib)
const char *mcast_info = "";
if (mcast)
{
- rib_table_info_t *info = rn->table->info;
+ rib_table_info_t *info = srcdest_rnode_table_info(rn);
mcast_info = (info->safi == SAFI_MULTICAST)
? " using Multicast RIB"
: " using Unicast RIB";
}
vty_out (vty, "Routing entry for %s%s%s",
- prefix2str (&rn->p, buf, sizeof(buf)), mcast_info,
+ srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info,
VTY_NEWLINE);
vty_out (vty, " Known via \"%s", zebra_route_string (rib->type));
if (rib->instance)
struct nexthop *nexthop, *tnexthop;
int recursing;
int len = 0;
- char buf[BUFSIZ];
+ char buf[SRCDEST2STR_BUFFER];
json_object *json_nexthops = NULL;
json_object *json_nexthop = NULL;
json_object *json_route = NULL;
json_route = json_object_new_object();
json_nexthops = json_object_new_array();
- json_object_string_add(json_route, "prefix", prefix2str (&rn->p, buf, sizeof buf));
+ json_object_string_add(json_route, "prefix", srcdest_rnode2str (rn, buf, sizeof buf));
json_object_string_add(json_route, "protocol", zebra_route_string(rib->type));
if (rib->instance)
? '>' : ' ',
CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
? '*' : ' ',
- prefix2str (&rn->p, buf, sizeof buf));
+ srcdest_rnode2str (rn, buf, sizeof buf));
/* Distance and metric display. */
if (rib->type != ZEBRA_ROUTE_CONNECT
memset (&rib_cnt, 0, sizeof(rib_cnt));
memset (&fib_cnt, 0, sizeof(fib_cnt));
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
is_ibgp = (rib->type == ZEBRA_ROUTE_BGP &&
memset (&rib_cnt, 0, sizeof(rib_cnt));
memset (&fib_cnt, 0, sizeof(fib_cnt));
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
int first = 1;
vrf_id_t vrf_id = VRF_DEFAULT;
struct zebra_vrf *zvrf = NULL;
- char buf[BUFSIZ];
+ char buf[SRCDEST2STR_BUFFER];
json_object *json = NULL;
json_object *json_prefix = NULL;
json = json_object_new_object();
/* Show all IPv6 route. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
{
RNODE_FOREACH_RIB (rn, rib)
{
if (json_prefix)
{
- prefix2str (&rn->p, buf, sizeof buf);
+ srcdest_rnode2str (rn, buf, sizeof buf);
json_object_object_add(json, buf, json_prefix);
json_prefix = NULL;
}
else
{
/* Show all IPv6 route. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
{
RNODE_FOREACH_RIB (rn, rib)
{
return CMD_SUCCESS;
/* Show all IPv6 routes with matching tag value. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
if (rib->tag != tag)
return CMD_SUCCESS;
/* Show matched type IPv6 routes. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
- if (prefix_match (&p, &rn->p))
- {
- if (first)
- {
- vty_out (vty, SHOW_ROUTE_V6_HEADER);
- first = 0;
- }
- vty_show_ip_route (vty, rn, rib, NULL);
- }
+ {
+ struct prefix *p, *src_p;
+ srcdest_rnode_prefixes(rn, &p, &src_p);
+
+ if (prefix_match (p, &rn->p))
+ {
+ if (first)
+ {
+ vty_out (vty, SHOW_ROUTE_V6_HEADER);
+ first = 0;
+ }
+ vty_show_ip_route (vty, rn, rib, NULL);
+ }
+ }
return CMD_SUCCESS;
}
return CMD_SUCCESS;
/* Show matched type IPv6 routes. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == type)
{
return CMD_SUCCESS;
/* Show all IPv6 route. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
if (first)
continue;
/* Show all IPv6 route. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
if (first)
continue;
/* Show all IPv6 routes with matching tag value. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
if (rib->tag != tag)
continue;
/* Show matched type IPv6 routes. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
- if (prefix_match (&p, &rn->p))
- {
- if (first)
- {
- vty_out (vty, SHOW_ROUTE_V6_HEADER);
- first = 0;
- }
-
- if (vrf_header)
+ {
+ struct prefix *p, *src_p;
+ srcdest_rnode_prefixes(rn, &p, &src_p);
+ if (prefix_match (p, &rn->p))
{
- vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
- vrf_header = 0;
+ if (first)
+ {
+ vty_out (vty, SHOW_ROUTE_V6_HEADER);
+ first = 0;
+ }
+
+ if (vrf_header)
+ {
+ vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE);
+ vrf_header = 0;
+ }
+ vty_show_ip_route (vty, rn, rib, NULL);
}
- vty_show_ip_route (vty, rn, rib, NULL);
- }
+ }
vrf_header = 1;
}
continue;
/* Show matched type IPv6 routes. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
if (rib->type == type)
{
continue;
/* Show all IPv6 route. */
- for (rn = route_top (table); rn; rn = route_next (rn))
+ for (rn = route_top (table); rn; rn = srcdest_route_next (rn))
RNODE_FOREACH_RIB (rn, rib)
{
if (first)
*/
int
zsend_redistribute_route (int add, struct zserv *client, struct prefix *p,
- struct rib *rib)
+ struct prefix *src_p, struct rib *rib)
{
afi_t afi;
int cmd;
stream_putc (s, p->prefixlen);
stream_write (s, (u_char *) & p->u.prefix, psize);
+ if (src_p)
+ {
+ SET_FLAG (zapi_flags, ZAPI_MESSAGE_SRCPFX);
+ psize = PSIZE (src_p->prefixlen);
+ stream_putc (s, src_p->prefixlen);
+ stream_write (s, (u_char *) & src_p->u.prefix, psize);
+ }
+
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
{
/* We don't send any nexthops when there's a multipath */
extern void nbr_connected_delete_ipv6 (struct interface *, struct in6_addr *);
extern int zsend_interface_update (int, struct zserv *, struct interface *);
extern int zsend_redistribute_route (int, struct zserv *, struct prefix *,
- struct rib *);
+ struct prefix *, struct rib *);
extern int zsend_router_id_update (struct zserv *, struct prefix *,
vrf_id_t);
extern int zsend_interface_vrf_update (struct zserv *, struct interface *,