Date: Thu, 8 Nov 2012 22:40:24 +0000 (UTC) From: Andre Oppermann <andre@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r242802 - user/andre/tcp_workqueue/sys/net Message-ID: <201211082240.qA8MeOQe039620@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andre Date: Thu Nov 8 22:40:24 2012 New Revision: 242802 URL: http://svnweb.freebsd.org/changeset/base/242802 Log: Save this for later continuation: Different approach on ECMP (equal cost multi path) routing. Instead of having shadow rtentry's linked behind the one in the trie, just have an array of different egress interface and next-hops. This simplifies the code significantly. A normal add to the routing table then sets the main next- hop. A ECMP aware add or modify can change any of the other next hops in the rtentry. The next-hop list is sorted by priority (distance in Cisco parlance) with the highest first. Equal priority next-hops are next to each other sorted by next-hop IP address. If the highest priority has more than one next-hop load is equally shared among them. All other routes with lower weight are not used. When a higher priority next-hop is removed or flagged as unavailable (eg. interface link down) the next higher priority prefix will become active. When only unavailable next-hops are in the rtentry it is ignored and a less specific match is searched for. If no route is found the lookup will fail. When an unavailable next-hop becomes available again, the rtentry is valid again and will match on lookups. This way we can implement suppression of routes on link state down interfaces without having to actually remove the rtentry. Additionally it is automatically reinstated when the link comes back. This way for example a OSPF route can take precedence and NLRI reachability is ensured. This is the same behavior as of Cisco, Juniper and other router vendors. Modified: user/andre/tcp_workqueue/sys/net/route.h Modified: user/andre/tcp_workqueue/sys/net/route.h ============================================================================== --- user/andre/tcp_workqueue/sys/net/route.h Thu Nov 8 21:40:05 2012 (r242801) +++ user/andre/tcp_workqueue/sys/net/route.h Thu Nov 8 22:40:24 2012 (r242802) @@ -112,6 +112,14 @@ struct mbuf; #include <net/radix_mpath.h> #endif #endif +struct rtgw { + struct ifnet *rtgw_ifp; /* the answer: interface to use */ + struct sockaddr *rtgw_gateway; /* value */ + uint16_t rtgw_flags; /* nexthop flags */ + uint8_t rtgw_priority; /* nexthop weight */ +}; +#define RTGW_VALID 0x00000001 + struct rtentry { struct radix_node rt_nodes[2]; /* tree glue, and other values */ /* @@ -121,18 +129,19 @@ struct rtentry { */ #define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key))) #define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask))) - struct sockaddr *rt_gateway; /* value */ int rt_flags; /* up/down?, host/net */ - int rt_refcnt; /* # held references */ - struct ifnet *rt_ifp; /* the answer: interface to use */ + struct rtgw rt_gw[8]; /* equal cost multipath */ struct ifaddr *rt_ifa; /* the answer: interface address to use */ struct rt_metrics_lite rt_rmx; /* metrics used by rx'ing protocols */ u_int rt_fibnum; /* which FIB */ + int rt_refcnt; /* # held references */ #ifdef _KERNEL /* XXX ugly, user apps use this definition but don't have a mtx def */ struct mtx rt_mtx; /* mutex for routing entry */ #endif }; +#define rt_ifp rt_gw[0].rtgw_ifp +#define rt_gateway rt_gw[0].rtgw_gateway /* * Following structure necessary for 4.3 compatibility; @@ -141,11 +150,11 @@ struct rtentry { struct ortentry { u_long rt_hash; /* to speed lookups */ struct sockaddr rt_dst; /* key */ - struct sockaddr rt_gateway; /* value */ + struct sockaddr rt_gateway_o; /* value */ short rt_flags; /* up/down?, host/net */ short rt_refcnt; /* # held references */ u_long rt_use; /* raw # packets forwarded */ - struct ifnet *rt_ifp; /* the answer: interface to use */ + struct ifnet *rt_ifp_o; /* the answer: interface to use */ }; #define rt_use rt_rmx.rmx_pksent
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211082240.qA8MeOQe039620>