Add code to be a bit smarter about IP routes, conditioned on the option

IN_RMX.  (Eventually this will be standard, but I just wrote the code today
and don't want to break anyone.)
This commit is contained in:
Garrett Wollman 1994-11-02 04:41:39 +00:00
parent 734d3eaf71
commit 5c2dae8edc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4073
4 changed files with 21 additions and 22 deletions

View File

@ -175,6 +175,7 @@ netinet/igmp.c optional inet
netinet/in.c optional inet
netinet/in_pcb.c optional inet
netinet/in_proto.c optional inet
netinet/in_rmx.c optional in_rmx
netinet/ip_icmp.c optional inet
netinet/ip_input.c optional inet
netinet/ip_mroute.c optional inet

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)radix.h 8.1 (Berkeley) 6/10/93
* $Id: radix.h,v 1.2 1994/08/02 07:46:31 davidg Exp $
* $Id: radix.h,v 1.3 1994/08/21 05:11:45 paul Exp $
*/
#ifndef _NET_RADIX_H_
@ -118,6 +118,8 @@ struct radix_node_head {
__P((void *v, struct radix_node_head *head));
int (*rnh_walktree) /* traverse tree */
__P((struct radix_node_head *head, int (*f)(), void *w));
void (*rnh_close) /* do something when the last ref drops */
__P((struct radix_node *rn, struct radix_node_head *head));
struct radix_node rnh_nodes[3]; /* empty tree for common case */
};

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)route.c 8.2 (Berkeley) 11/15/93
* $Id: route.c,v 1.8 1994/10/02 17:48:26 phk Exp $
* $Id: route.c,v 1.9 1994/10/11 23:16:27 wollman Exp $
*/
#include <sys/param.h>
@ -136,11 +136,16 @@ void
rtfree(rt)
register struct rtentry *rt;
{
register struct radix_node_head *rnh =
rt_tables[rt_key(rt)->sa_family];
register struct ifaddr *ifa;
if (rt == 0)
panic("rtfree");
rt->rt_refcnt--;
if(rnh->rnh_close && rt->rt_refcnt == 0) {
rnh->rnh_close((struct radix_node *)rt, rnh);
}
if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_UP) == 0) {
if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT))
panic ("rtfree 2");
@ -344,7 +349,6 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
register struct radix_node_head *rnh;
struct ifaddr *ifa;
struct sockaddr *ndst;
int doexpire = 0;
#define senderr(x) { error = x ; goto bad; }
if ((rnh = rt_tables[dst->sa_family]) == 0)
@ -383,21 +387,7 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
if ((netmask = rt->rt_genmask) == 0)
flags |= RTF_HOST;
if (flags & RTF_STATIC) {
/*
* We make a few assumptions here which are not
* necessarily valid for everybody.
* 1) static cloning routes want this treatment
* 2) somebody's link layer out there is
* timing these things out
*
* (2) in particular is not presently true for any
* p2p links, but we hope that this will not cause
* problems. (I believe that these extra routes
* can never cause incorrect operation, but they
* really should get timed out to free the memory.)
*/
flags &= ~RTF_STATIC;
doexpire = 1;
}
goto makeroute;
@ -438,9 +428,6 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
rt->rt_ifp = ifa->ifa_ifp;
if (req == RTM_RESOLVE)
rt->rt_rmx = (*ret_nrt)->rt_rmx; /* copy metrics */
if (doexpire)
rt->rt_rmx.rmx_expire =
time.tv_sec + 1200; /* XXX MAGIC CONSTANT */
if (ifa->ifa_rtrequest)
ifa->ifa_rtrequest(req, rt, SA(ret_nrt ? *ret_nrt : 0));
if (ret_nrt) {

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_proto.c 8.1 (Berkeley) 6/10/93
* $Id: in_proto.c,v 1.5 1994/09/14 03:10:08 wollman Exp $
* $Id: in_proto.c,v 1.6 1994/09/15 10:36:52 davidg Exp $
*/
#include <sys/param.h>
@ -154,10 +154,19 @@ struct protosw inetsw[] = {
},
};
#ifdef IN_RMX
extern int in_inithead(void **, int);
#endif
struct domain inetdomain =
{ AF_INET, "internet", 0, 0, 0,
inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
rn_inithead, 32, sizeof(struct sockaddr_in) };
#ifdef IN_RMX
in_inithead, 32, sizeof(struct sockaddr_in)
#else
rn_inithead, 32, sizeof(struct sockaddr_in)
#endif
};
#include "imp.h"
#if NIMP > 0