summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
Diffstat (limited to 'zebra')
-rw-r--r--zebra/ChangeLog10
-rw-r--r--zebra/connected.c5
-rw-r--r--zebra/rib.h20
-rw-r--r--zebra/rt_netlink.c58
-rw-r--r--zebra/zebra_rib.c21
-rw-r--r--zebra/zebra_vty.c222
-rw-r--r--zebra/zserv.c6
7 files changed, 339 insertions, 3 deletions
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index 3ea4f57f..55b11223 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -569,7 +569,17 @@
(remainder) Sanitise refcounting of route_node's. Convert to
rib_queue_add, rib_addnode and rib_delnode. Change XMALLOC/memset
to XCALLOC. Remove calls to nexthop_delete and nexthop_free.
+
+2005-04-24 Calin Velea <vcalinus@gemenii.ro>
+
+ * rt_netlink.c: Modified netlink_route(), netlink_routing_table(),
+ netlink_route_change() to use realms when working with kernel
+ table
+ * zebra_rib.c, zebra_vty.c, zserv.c, connected.c: realm support
+ for static routes
+ * rib.h: Add realm attribute to rib and static_ipv4 structs
+
2005-04-10 Paul Jakma <paul@dishone.st>
* if_ioctl_solaris.c: (if_lookup_linklocal) fix order of args
diff --git a/zebra/connected.c b/zebra/connected.c
index 44002e76..2b31aa3a 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -200,8 +200,13 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc)
if (prefix_ipv4_any (&p))
return;
+#ifndef SUPPORT_REALMS
rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, RT_TABLE_MAIN,
ifp->metric, 0);
+#else
+ rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, RT_TABLE_MAIN,
+ ifp->metric, 0, 0);
+#endif
rib_update ();
}
diff --git a/zebra/rib.h b/zebra/rib.h
index 04fbbecf..dd1bfbbc 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -73,6 +73,12 @@ struct rib
u_char nexthop_num;
u_char nexthop_active_num;
u_char nexthop_fib_num;
+
+#ifdef SUPPORT_REALMS
+ /* Realm information */
+ u_int16_t realmto;
+#endif
+
};
/* Static route information. */
@@ -104,6 +110,11 @@ struct static_ipv4
see ZEBRA_FLAG_REJECT
ZEBRA_FLAG_BLACKHOLE
*/
+
+#ifdef SUPPORT_REALMS
+ u_int16_t realmto;
+#endif
+
};
#ifdef HAVE_IPV6
@@ -226,7 +237,11 @@ extern struct route_table *vrf_static_table (afi_t afi, safi_t safi, u_int32_t i
* also implicitly withdraw equal prefix of same type. */
extern int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, unsigned int ifindex,
+#ifndef SUPPORT_REALMS
u_int32_t vrf_id, u_int32_t, u_char);
+#else
+ u_int32_t vrf_id, u_int32_t, u_char, u_int16_t);
+#endif
extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *);
@@ -246,7 +261,12 @@ extern void rib_init (void);
extern int
static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
+#ifndef SUPPORT_REALMS
u_char flags, u_char distance, u_int32_t vrf_id);
+#else
+ u_char flags, u_char distance, u_int32_t vrf_id, u_int16_t realmto);
+#endif
+
extern int
static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 216625e9..5e19ec6a 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -738,6 +738,12 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
void *dest;
void *gate;
+#ifdef SUPPORT_REALMS
+ u_int32_t rta_flow;
+ u_int16_t realmto = 0;
+#endif
+
+
rtm = NLMSG_DATA (h);
if (h->nlmsg_type != RTM_NEWROUTE)
@@ -799,7 +805,19 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
memcpy (&p.prefix, dest, 4);
p.prefixlen = rtm->rtm_dst_len;
+#ifndef SUPPORT_REALMS
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, index, table, metric, 0);
+#else
+ if (tb[RTA_FLOW])
+ {
+ rta_flow = *(u_int32_t *) RTA_DATA (tb[RTA_FLOW]);
+ realmto = rta_flow & 0xFFFF;
+ }
+
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, index, table, metric, 0,
+ realmto);
+#endif
+
}
#ifdef HAVE_IPV6
if (rtm->rtm_family == AF_INET6)
@@ -931,8 +949,20 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h)
inet_ntoa (p.prefix), p.prefixlen);
}
- if (h->nlmsg_type == RTM_NEWROUTE)
+ if (h->nlmsg_type == RTM_NEWROUTE) {
+#ifndef SUPPORT_REALMS
rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, 0, 0);
+#else
+ if (tb[RTA_FLOW])
+ {
+ u_int32_t rta_flow = *(u_int32_t *) RTA_DATA (tb[RTA_FLOW]);
+ u_int16_t realmto = rta_flow & 0xFFFF;
+ rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table, 0, 0,
+ realmto);
+ }
+#endif
+
+ }
else
rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table);
}
@@ -1330,7 +1360,13 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl)
/* Routing table change via netlink interface. */
int
netlink_route (int cmd, int family, void *dest, int length, void *gate,
+#ifdef SUPPORT_REALMS
+ int index, int zebra_flags, int table,
+ u_int16_t realmto, u_int16_t realmfrom)
+#else
int index, int zebra_flags, int table)
+#endif
+
{
int ret;
int bytelen;
@@ -1390,6 +1426,17 @@ netlink_route (int cmd, int family, void *dest, int length, void *gate,
addattr32 (&req.n, sizeof req, RTA_OIF, index);
}
+#ifdef SUPPORT_REALMS
+ if (realmto || realmfrom)
+ {
+ u_int32_t rta_flow;
+ rta_flow = ((u_int32_t) realmfrom) << 16;
+ rta_flow |= (u_int32_t) realmto;
+
+ addattr32 (&req.n, sizeof req, RTA_FLOW, rta_flow);
+ }
+#endif
+
/* Destination netlink address. */
memset (&snl, 0, sizeof snl);
snl.nl_family = AF_NETLINK;
@@ -1467,6 +1514,11 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib,
goto skip;
}
+#ifdef SUPPORT_REALMS
+ if (rib->realmto)
+ addattr32 (&req.n, sizeof req, RTA_FLOW, rib->realmto);
+#endif
+
/* Multipath case. */
if (rib->nexthop_active_num == 1 || MULTIPATH_NUM == 1)
{
@@ -1813,7 +1865,11 @@ kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate,
unsigned int index, int flags, int table)
{
return netlink_route (RTM_DELROUTE, AF_INET6, &dest->prefix,
+#ifndef SUPPORT_REALMS
dest->prefixlen, gate, index, flags, table);
+#else
+ dest->prefixlen, gate, index, flags, table, 0, 0);
+#endif
}
#endif /* HAVE_IPV6 */
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 02c73d12..64d23199 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1232,7 +1232,12 @@ rib_delnode (struct route_node *rn, struct rib *rib)
int
rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
struct in_addr *gate, unsigned int ifindex, u_int32_t vrf_id,
+#ifndef SUPPORT_REALMS
u_int32_t metric, u_char distance)
+#else
+ u_int32_t metric, u_char distance, u_int16_t realmto)
+#endif
+
{
struct rib *rib;
struct rib *same = NULL;
@@ -1315,6 +1320,10 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p,
/* Link new rib to node.*/
rib_addnode (rn, rib);
+#ifdef SUPPORT_REALMS
+ rib->realmto = realmto;
+#endif
+
/* Free implicit route.*/
if (same)
rib_delnode (rn, same);
@@ -1559,6 +1568,10 @@ static_install_ipv4 (struct prefix *p, struct static_ipv4 *si)
rib->distance = si->distance;
rib->metric = 0;
rib->nexthop_num = 0;
+#ifdef SUPPORT_REALMS
+ rib->realmto = si->realmto;
+#endif
+
switch (si->type)
{
@@ -1662,7 +1675,11 @@ static_uninstall_ipv4 (struct prefix *p, struct static_ipv4 *si)
/* Add static route into static route configuration. */
int
static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
+#ifndef SUPPORT_REALMS
u_char flags, u_char distance, u_int32_t vrf_id)
+#else
+ u_char flags, u_char distance, u_int32_t vrf_id, u_int16_t realmto)
+#endif
{
u_char type = 0;
struct route_node *rn;
@@ -1717,6 +1734,10 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname,
si->distance = distance;
si->flags = flags;
+#ifdef SUPPORT_REALMS
+ si->realmto = realmto;
+#endif
+
if (gate)
si->gate.ipv4 = *gate;
if (ifname)
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 68e6f920..33906e3d 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -33,7 +33,12 @@
static int
zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
const char *mask_str, const char *gate_str,
+#ifndef SUPPORT_REALMS
const char *flag_str, const char *distance_str)
+#else
+ const char *flag_str, const char *distance_str, const char *realm_str)
+#endif
+
{
int ret;
u_char distance;
@@ -43,6 +48,23 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
const char *ifname;
u_char flag = 0;
+#ifdef SUPPORT_REALMS
+ u_int16_t realmto = 0;
+ u_int32_t realmid;
+ int res;
+
+ if (realm_str != NULL) {
+ res = rtnl_rtrealm_a2n (&realmid, realm_str);
+ if (res < 0) {
+ vty_out (vty, "%%Realm '%s' not found in rt_realms has invalid value%s",
+ realm_str, VTY_NEWLINE);
+ return CMD_ERR_INCOMPLETE;
+ }
+ realmto = (u_int16_t)realmid;
+ }
+#endif
+
+
ret = str2prefix (dest_str, &p);
if (ret <= 0)
{
@@ -80,7 +102,11 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
return CMD_WARNING;
}
if (add_cmd)
+#ifndef SUPPORT_REALMS
static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0);
+#else
+ static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0, realmto);
+#endif
else
static_delete_ipv4 (&p, NULL, NULL, distance, 0);
return CMD_SUCCESS;
@@ -106,7 +132,11 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
if (gate_str == NULL)
{
if (add_cmd)
+#ifndef SUPPORT_REALMS
static_add_ipv4 (&p, NULL, NULL, flag, distance, 0);
+#else
+ static_add_ipv4 (&p, NULL, NULL, flag, distance, 0, realmto);
+#endif
else
static_delete_ipv4 (&p, NULL, NULL, distance, 0);
@@ -121,8 +151,14 @@ zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
else
ifname = gate_str;
- if (add_cmd)
+ if (add_cmd) {
+#ifndef SUPPORT_REALMS
static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, distance, 0);
+#else
+ static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, distance, 0, realmto);
+#endif
+
+ }
else
static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, distance, 0);
@@ -140,7 +176,11 @@ DEFUN (ip_route,
"IP gateway interface name\n"
"Null interface\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL, NULL);
+#endif
}
DEFUN (ip_route_flags,
@@ -154,7 +194,11 @@ DEFUN (ip_route_flags,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL, NULL);
+#endif
}
DEFUN (ip_route_flags2,
@@ -166,7 +210,11 @@ DEFUN (ip_route_flags2,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL, NULL);
+#endif
}
/* Mask as A.B.C.D format. */
@@ -181,7 +229,11 @@ DEFUN (ip_route_mask,
"IP gateway interface name\n"
"Null interface\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL);
+#endif
}
DEFUN (ip_route_mask_flags,
@@ -196,7 +248,11 @@ DEFUN (ip_route_mask_flags,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL);
+#endif
}
DEFUN (ip_route_mask_flags2,
@@ -209,7 +265,11 @@ DEFUN (ip_route_mask_flags2,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL);
+#endif
}
/* Distance option value. */
@@ -224,7 +284,11 @@ DEFUN (ip_route_distance,
"Null interface\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2], NULL);
+#endif
}
DEFUN (ip_route_flags_distance,
@@ -239,7 +303,12 @@ DEFUN (ip_route_flags_distance,
"Silently discard pkts when matched\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3], NULL);
+#endif
+
}
DEFUN (ip_route_flags_distance2,
@@ -252,7 +321,11 @@ DEFUN (ip_route_flags_distance2,
"Silently discard pkts when matched\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2], NULL);
+#endif
}
DEFUN (ip_route_mask_distance,
@@ -267,7 +340,12 @@ DEFUN (ip_route_mask_distance,
"Null interface\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL);
+#endif
+
}
DEFUN (ip_route_mask_flags_distance,
@@ -283,7 +361,12 @@ DEFUN (ip_route_mask_flags_distance,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], NULL);
+#endif
+
}
DEFUN (ip_route_mask_flags_distance2,
@@ -297,7 +380,12 @@ DEFUN (ip_route_mask_flags_distance2,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
+#else
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], NULL);
+#endif
+
}
DEFUN (no_ip_route,
@@ -311,7 +399,12 @@ DEFUN (no_ip_route,
"IP gateway interface name\n"
"Null interface\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL, NULL);
+#endif
+
}
ALIAS (no_ip_route,
@@ -336,7 +429,12 @@ DEFUN (no_ip_route_flags2,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL, NULL);
+#endif
+
}
DEFUN (no_ip_route_mask,
@@ -351,7 +449,12 @@ DEFUN (no_ip_route_mask,
"IP gateway interface name\n"
"Null interface\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL);
+#endif
+
}
ALIAS (no_ip_route_mask,
@@ -378,7 +481,12 @@ DEFUN (no_ip_route_mask_flags2,
"Emit an ICMP unreachable when matched\n"
"Silently discard pkts when matched\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL);
+#endif
+
}
DEFUN (no_ip_route_distance,
@@ -393,7 +501,12 @@ DEFUN (no_ip_route_distance,
"Null interface\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2], NULL);
+#endif
+
}
DEFUN (no_ip_route_flags_distance,
@@ -409,7 +522,12 @@ DEFUN (no_ip_route_flags_distance,
"Silently discard pkts when matched\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3], NULL);
+#endif
+
}
DEFUN (no_ip_route_flags_distance2,
@@ -423,7 +541,12 @@ DEFUN (no_ip_route_flags_distance2,
"Silently discard pkts when matched\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2], NULL);
+#endif
+
}
DEFUN (no_ip_route_mask_distance,
@@ -439,7 +562,12 @@ DEFUN (no_ip_route_mask_distance,
"Null interface\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL);
+#endif
+
}
DEFUN (no_ip_route_mask_flags_distance,
@@ -456,7 +584,12 @@ DEFUN (no_ip_route_mask_flags_distance,
"Silently discard pkts when matched\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], NULL);
+#endif
+
}
DEFUN (no_ip_route_mask_flags_distance2,
@@ -471,9 +604,72 @@ DEFUN (no_ip_route_mask_flags_distance2,
"Silently discard pkts when matched\n"
"Distance value for this route\n")
{
+#ifndef SUPPORT_REALMS
return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
+#else
+ return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], NULL);
+#endif
+
+}
+
+#ifdef SUPPORT_REALMS
+DEFUN (ip_route_realm,
+ ip_route_realm_cmd,
+ "ip route A.B.C.D/M (A.B.C.D|INTERFACE) realm (<1-255>|WORD)",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "IP gateway address\n"
+ "IP gateway interface name\n"
+ "Destination realm value or name\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL, argv[2]);
}
+DEFUN (ip_route_mask_realm,
+ ip_route_mask_realm_cmd,
+ "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) realm (<1-255>|WORD)",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "IP gateway address\n"
+ "IP gateway interface name\n"
+ "Destination realm value or name\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3]);
+}
+
+DEFUN (ip_route_pref_realm,
+ ip_route_pref_realm_cmd,
+ "ip route A.B.C.D/M (A.B.C.D|INTERFACE) <1-255> realm (<1-255>|WORD)",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix (e.g. 10.0.0.0/8)\n"
+ "IP gateway address\n"
+ "IP gateway interface name\n"
+ "Distance value for this route\n"
+ "Destination realm value or name\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2], argv[3]);
+}
+
+DEFUN (ip_route_mask_pref_realm,
+ ip_route_mask_pref_realm_cmd,
+ "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) <1-255> realm (<1-255>|WORD)",
+ IP_STR
+ "Establish static routes\n"
+ "IP destination prefix\n"
+ "IP destination prefix mask\n"
+ "IP gateway address\n"
+ "IP gateway interface name\n"
+ "Distance value for this route\n")
+{
+ return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4]);
+}
+#endif /* SUPPORT_REALMS */
+
+
/* New RIB. Detailed information for IPv4 route. */
static void
vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
@@ -492,6 +688,10 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
vty_out (vty, ", best");
if (rib->refcnt)
vty_out (vty, ", refcnt %ld", rib->refcnt);
+#ifdef SUPPORT_REALMS
+ if (rib->realmto)
+ vty_out (vty, ", realm %5u", rib->realmto);
+#endif
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
vty_out (vty, ", blackhole");
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
@@ -555,7 +755,12 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
}
if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
vty_out (vty, " inactive");
-
+#ifdef SUPPORT_REALMS
+ if (rib->realmto) {
+ char realmbuf[50];
+ vty_out (vty, " realm %5s", rtnl_rtrealm_n2a (rib->realmto, realmbuf, sizeof (realmbuf)));
+ }
+#endif
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
{
vty_out (vty, " (recursive");
@@ -1046,6 +1251,13 @@ static_config_ipv4 (struct vty *vty)
if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
vty_out (vty, " %d", si->distance);
+#ifdef SUPPORT_REALMS
+ if (si->realmto) {
+ char realmbuf[11];
+ vty_out (vty, " realm %s", rtnl_rtrealm_n2a (si->realmto, realmbuf, sizeof realmbuf));
+ }
+#endif
+
vty_out (vty, "%s", VTY_NEWLINE);
write = 1;
@@ -1895,6 +2107,12 @@ zebra_vty_init (void)
install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
+#ifdef SUPPORT_REALMS
+ install_element (CONFIG_NODE, &ip_route_realm_cmd);
+ install_element (CONFIG_NODE, &ip_route_mask_realm_cmd);
+ install_element (CONFIG_NODE, &ip_route_pref_realm_cmd);
+ install_element (CONFIG_NODE, &ip_route_mask_pref_realm_cmd);
+#endif
install_element (CONFIG_NODE, &ip_route_distance_cmd);
install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 1703d3f5..1713c536 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -803,6 +803,12 @@ zread_ipv4_add (struct zserv *client, u_short length)
/* Table */
rib->table=zebrad.rtm_table_default;
+#ifdef SUPPORT_REALMS
+ if (CHECK_FLAG (message, ZAPI_MESSAGE_REALMTO))
+ rib->realmto = stream_getw (s);
+ else
+ rib->realmto = 0;
+#endif
rib_add_ipv4_multipath (&p, rib);
return 0;
}