summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in_rmx.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1996-05-06 17:42:13 +0000
committerwollman <wollman@FreeBSD.org>1996-05-06 17:42:13 +0000
commita62508b8bee3bafa48a7604857ce29517058ee90 (patch)
tree8093bc9089a487f8a96db12b540bd49c5f390c9d /sys/netinet/in_rmx.c
parent05b36227ad904ca4a0a741f9386b23c4a18e9f94 (diff)
downloadFreeBSD-src-a62508b8bee3bafa48a7604857ce29517058ee90.zip
FreeBSD-src-a62508b8bee3bafa48a7604857ce29517058ee90.tar.gz
Add three new route flags to help determine what sort of address
the destination represents. For IP: - Iff it is a host route, RTF_LOCAL and RTF_BROADCAST indicate local (belongs to this host) and broadcast addresses, respectively. - For all routes, RTF_MULTICAST is set if the destination is multicast. The RTF_BROADCAST flag is used by ip_output() to eliminate a call to in_broadcast() in a common case; this gives about 1% in our packet-generation experiments. All three flags might be used (although they aren't now) to determine whether a packet can be forwarded; a given host route can represent a forwardable address if: (rt->rt_flags & (RTF_HOST | RTF_LOCAL | RTF_BROADCAST | RTF_MULTICAST)) == RTF_HOST Obviously, one still has to do all the work if a host route is not present, but this code allows one to cache the results of such a lookup if rtalloc1() is called without masking RTF_PRCLONING.
Diffstat (limited to 'sys/netinet/in_rmx.c')
-rw-r--r--sys/netinet/in_rmx.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c
index df4fc3b..2d671e5 100644
--- a/sys/netinet/in_rmx.c
+++ b/sys/netinet/in_rmx.c
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: in_rmx.c,v 1.23 1996/01/23 05:15:30 fenner Exp $
+ * $Id: in_rmx.c,v 1.24 1996/04/26 18:31:41 wollman Exp $
*/
/*
@@ -84,9 +84,38 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
/*
* For IP, all unicast non-host routes are automatically cloning.
*/
- if(!(rt->rt_flags & (RTF_HOST | RTF_CLONING))) {
- if(!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
- rt->rt_flags |= RTF_PRCLONING;
+ if(IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
+ rt->rt_flags |= RTF_MULTICAST;
+
+ if(!(rt->rt_flags & (RTF_HOST | RTF_CLONING | RTF_MULTICAST))) {
+ rt->rt_flags |= RTF_PRCLONING;
+ }
+
+ /*
+ * A little bit of help for both IP output and input:
+ * For host routes, we make sure that RTF_BROADCAST
+ * is set for anything that looks like a broadcast address.
+ * This way, we can avoid an expensive call to in_broadcast()
+ * in ip_output() most of the time (because the route passed
+ * to ip_output() is almost always a host route).
+ *
+ * We also do the same for local addresses, with the thought
+ * that this might one day be used to speed up ip_input().
+ *
+ * We also mark routes to multicast addresses as such, because
+ * it's easy to do and might be useful (but this is much more
+ * dubious since it's so easy to inspect the address). (This
+ * is done above.)
+ */
+ if (rt->rt_flags & RTF_HOST) {
+ if (in_broadcast(sin->sin_addr, rt->rt_ifp)) {
+ rt->rt_flags |= RTF_BROADCAST;
+ } else {
+#define satosin(sa) ((struct sockaddr_in *)sa)
+ if (satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr
+ == sin->sin_addr.s_addr)
+ rt->rt_flags |= RTF_LOCAL;
+#undef satosin
}
}
OpenPOWER on IntegriCloud