[zebra] Routemap support on received routes, with 'set src' command (linux)
2007-05-01 David L Stevens <dlstevens@us.ibm.com>
* (general) These changes collectively add route-map and
prefix-list support to zebra and fix a bug in "show
route-map" (with no argument).
* doc/main.texi: added route-map, prefix-list, ip protocol
and set src documentation
* lib/command.h: added PROTOCOL_NODE type
* lib/log.c: (proto_name2num) new function, protocol name to
number translation.
* lib/routemap.c: (vty_show_route_map) fixed "show route-map"
without route-map name
* lib/routemap.h: added RMAP_ZEBRA type
* lib/zebra.h: added proto_name2num() prototype
* vtysh/extract.pl.in: added VTYSH_ZEBRA flag for route-map and
plist
* vtysh/Makefile.am: added zebra_routemap.c
* vtysh/vtysh.h: added VTYSH_ZEBRA flag to VTYSH_RMAP
* zebra/connected.c: (connected_up_ipv4) added src preference argument
to rib_add_ipv4()
* zebra/kernel_socket.c: (rtm_read) ditto
* zebra/main.c: added prefix list initialization
* zebra/Makefile.am: added zebra_routemap.c source file
* zebra/rib.h: added generic address union "g_addr" and use in
existing places that had an explicit union.
Added "src" to struct nexthop.
Added preferred src arg to nexthop_ipv4_add and rib_add_ipv4.
* zebra/rt_netlink.c: (netlink_routing_table) set preferred source on
netlink messages.
(netlink_route_change) ditto
(netlink_route_multipath) ditto.
* zebra/rtread_getmsg.c: (handle_route_entry) added (NULL) src to
rib_add_ipv4() call.
* zebra/rtread_proc.c: (proc_route_read) ditto
* zebra/zebra_rib.c: (nexthop_ipv4_add) add src argument.
(nexthop_ipv4_ifindex_add) ditto
(rib_add_ipv4) ditto
(nexthop_active_check) Add route-map processing.
* zebra/zebra_routemap.c: new file for zebra route-map commands.
* zebra/zebra_vty.c: (ip_protocol_cmd) Apply route-map to protocol
(vty_show_ip_route_detail) added "src" printing
(vty_show_ip_route) ditto
(show_ip_protocol_cmd) new command, list routemaps.
(config_write_protocol) write out routemap protocl config.
(zebra_vty_init) Install the new routemap protocol commands.
* zebra/zserv.c: (zread_ipv4_add) added (NULL) src arg
(zebra_init) init zebra route-maps.
* zebra/zserv.h: add zebra_route_map_init
diff --git a/zebra/rib.h b/zebra/rib.h
index 04fbbec..7b2bd42 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -28,6 +28,14 @@
#define DISTANCE_INFINITY 255
/* Routing information base. */
+
+union g_addr {
+ struct in_addr ipv4;
+#ifdef HAVE_IPV6
+ struct in6_addr ipv6;
+#endif /* HAVE_IPV6 */
+};
+
struct rib
{
/* Status Flags for the *route_node*, but kept in the head RIB.. */
@@ -167,24 +175,13 @@
#define NEXTHOP_FLAG_RECURSIVE (1 << 2) /* Recursive nexthop. */
/* Nexthop address or interface name. */
- union
- {
- struct in_addr ipv4;
-#ifdef HAVE_IPV6
- struct in6_addr ipv6;
-#endif /* HAVE_IPV6*/
- } gate;
+ union g_addr gate;
/* Recursive lookup nexthop. */
u_char rtype;
unsigned int rifindex;
- union
- {
- struct in_addr ipv4;
-#ifdef HAVE_IPV6
- struct in6_addr ipv6;
-#endif /* HAVE_IPV6 */
- } rgate;
+ union g_addr rgate;
+ union g_addr src;
};
/* Routing table instance. */
@@ -212,7 +209,8 @@
extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int);
extern struct nexthop *nexthop_ifname_add (struct rib *, char *);
extern struct nexthop *nexthop_blackhole_add (struct rib *);
-extern struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *);
+extern struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *,
+ struct in_addr *);
#ifdef HAVE_IPV6
extern struct nexthop *nexthop_ipv6_add (struct rib *, struct in6_addr *);
#endif /* HAVE_IPV6 */
@@ -225,8 +223,9 @@
* All rib_add_ipv[46]* functions will not just add prefix into RIB, but
* 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,
- u_int32_t vrf_id, u_int32_t, u_char);
+ struct in_addr *gate, struct in_addr *src,
+ unsigned int ifindex, u_int32_t vrf_id,
+ u_int32_t, u_char);
extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *);