Add support for two separate cloning flags, one set by the lower layers,

and one set by the protocol family.  Also add another parameter to
rtalloc1() to allow for any interface flags to be ignored; currently
this is only useful for RTF_PRCLONING.  Get rid of rt_prflags and re-unite
with rt_flags.  Add T/TCP ``route metrics''.

NB: YOU MUST RECOMPILE `route' AND OTHER RELATED PROGRAMS AS A RESULT OF
THIS CHANGE.

This also adds a new interface parameter, `ifi_physical', which will
eventually replace IFF_ALTPHYS as the mechanism for specifying the
particular physical connection desired on a multiple-connection card.

NB: YOU MUST RECOMPILE `ifconfig' AND OTHER RELATED PROGRAMS AS A RESULT OF
THIS CHANGE.
This commit is contained in:
Garrett Wollman 1994-12-13 22:31:49 +00:00
parent 0d2d94f67b
commit 995add1a12
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=5099
6 changed files with 46 additions and 23 deletions

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)if.h 8.1 (Berkeley) 6/10/93 * @(#)if.h 8.1 (Berkeley) 6/10/93
* $Id: if.h,v 1.9 1994/11/15 14:41:34 bde Exp $ * $Id: if.h,v 1.10 1994/11/16 02:16:18 phk Exp $
*/ */
#ifndef _NET_IF_H_ #ifndef _NET_IF_H_
@ -101,6 +101,7 @@ struct ifnet {
struct if_data { struct if_data {
/* generic interface information */ /* generic interface information */
u_char ifi_type; /* ethernet, tokenring, etc */ u_char ifi_type; /* ethernet, tokenring, etc */
u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */
u_char ifi_addrlen; /* media address length */ u_char ifi_addrlen; /* media address length */
u_char ifi_hdrlen; /* media header length */ u_char ifi_hdrlen; /* media header length */
u_long ifi_mtu; /* maximum transmission unit */ u_long ifi_mtu; /* maximum transmission unit */
@ -146,6 +147,7 @@ struct ifnet {
}; };
#define if_mtu if_data.ifi_mtu #define if_mtu if_data.ifi_mtu
#define if_type if_data.ifi_type #define if_type if_data.ifi_type
#define if_physical if_data.ifi_physical
#define if_addrlen if_data.ifi_addrlen #define if_addrlen if_data.ifi_addrlen
#define if_hdrlen if_data.ifi_hdrlen #define if_hdrlen if_data.ifi_hdrlen
#define if_metric if_data.ifi_metric #define if_metric if_data.ifi_metric
@ -186,6 +188,16 @@ struct ifnet {
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
/*
* These really don't belong here, but there's no other obviously appropriate
* location.
*/
#define IFP_AUI 0
#define IFP_10BASE2 1
#define IFP_10BASET 2
/* etc. */
/* /*
* Output queues (ifp->if_snd) and internetwork datagram level (pup level 1) * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
* input routines have queues of messages stored on ifqueue structures * input routines have queues of messages stored on ifqueue structures

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
* $Id: if_ethersubr.c,v 1.3 1994/10/11 23:16:24 wollman Exp $ * $Id: if_ethersubr.c,v 1.4 1994/11/24 14:29:38 davidg Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -114,7 +114,7 @@ ether_output(ifp, m0, dst, rt0)
ifp->if_lastchange = time; ifp->if_lastchange = time;
if (rt = rt0) { if (rt = rt0) {
if ((rt->rt_flags & RTF_UP) == 0) { if ((rt->rt_flags & RTF_UP) == 0) {
if (rt0 = rt = rtalloc1(dst, 1)) if (rt0 = rt = rtalloc1(dst, 1, 0UL))
rt->rt_refcnt--; rt->rt_refcnt--;
else else
senderr(EHOSTUNREACH); senderr(EHOSTUNREACH);
@ -124,7 +124,8 @@ ether_output(ifp, m0, dst, rt0)
goto lookup; goto lookup;
if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) { if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
rtfree(rt); rt = rt0; rtfree(rt); rt = rt0;
lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1); lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1,
0UL);
if ((rt = rt->rt_gwroute) == 0) if ((rt = rt->rt_gwroute) == 0)
senderr(EHOSTUNREACH); senderr(EHOSTUNREACH);
} }

View file

@ -380,6 +380,7 @@ int sppp_output (struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct
h->protocol = htons (PPP_ISO); h->protocol = htons (PPP_ISO);
break; break;
#endif #endif
nosupport:
default: default:
m_freem (m); m_freem (m);
splx (s); splx (s);

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)route.c 8.2 (Berkeley) 11/15/93 * @(#)route.c 8.2 (Berkeley) 11/15/93
* $Id: route.c,v 1.10 1994/11/02 04:41:25 wollman Exp $ * $Id: route.c,v 1.11 1994/11/03 01:04:30 wollman Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -88,25 +88,28 @@ rtalloc(ro)
{ {
if (ro->ro_rt && ro->ro_rt->rt_ifp && (ro->ro_rt->rt_flags & RTF_UP)) if (ro->ro_rt && ro->ro_rt->rt_ifp && (ro->ro_rt->rt_flags & RTF_UP))
return; /* XXX */ return; /* XXX */
ro->ro_rt = rtalloc1(&ro->ro_dst, 1); ro->ro_rt = rtalloc1(&ro->ro_dst, 1, 0UL);
} }
struct rtentry * struct rtentry *
rtalloc1(dst, report) rtalloc1(dst, report, ignflags)
register struct sockaddr *dst; register struct sockaddr *dst;
int report; int report;
u_long ignflags;
{ {
register struct radix_node_head *rnh = rt_tables[dst->sa_family]; register struct radix_node_head *rnh = rt_tables[dst->sa_family];
register struct rtentry *rt; register struct rtentry *rt;
register struct radix_node *rn; register struct radix_node *rn;
struct rtentry *newrt = 0; struct rtentry *newrt = 0;
struct rt_addrinfo info; struct rt_addrinfo info;
u_long nflags;
int s = splnet(), err = 0, msgtype = RTM_MISS; int s = splnet(), err = 0, msgtype = RTM_MISS;
if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) && if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) &&
((rn->rn_flags & RNF_ROOT) == 0)) { ((rn->rn_flags & RNF_ROOT) == 0)) {
newrt = rt = (struct rtentry *)rn; newrt = rt = (struct rtentry *)rn;
if (report && (rt->rt_flags & RTF_CLONING)) { nflags = rt->rt_flags & ~ignflags;
if (report && (nflags & (RTF_CLONING | RTF_PRCLONING))) {
err = rtrequest(RTM_RESOLVE, dst, SA(0), err = rtrequest(RTM_RESOLVE, dst, SA(0),
SA(0), 0, &newrt); SA(0), 0, &newrt);
if (err) { if (err) {
@ -199,7 +202,7 @@ rtredirect(dst, gateway, netmask, flags, src, rtp)
error = ENETUNREACH; error = ENETUNREACH;
goto out; goto out;
} }
rt = rtalloc1(dst, 0); rt = rtalloc1(dst, 0, 0UL);
/* /*
* If the redirect isn't from our current router for this dst, * If the redirect isn't from our current router for this dst,
* it's either old or wrong. If it redirects us to ourselves, * it's either old or wrong. If it redirects us to ourselves,
@ -319,7 +322,7 @@ ifa_ifwithroute(flags, dst, gateway)
if (ifa == 0) if (ifa == 0)
ifa = ifa_ifwithnet(gateway); ifa = ifa_ifwithnet(gateway);
if (ifa == 0) { if (ifa == 0) {
struct rtentry *rt = rtalloc1(dst, 0); struct rtentry *rt = rtalloc1(dst, 0, 0UL);
if (rt == 0) if (rt == 0)
return (0); return (0);
rt->rt_refcnt--; rt->rt_refcnt--;
@ -383,8 +386,8 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
if (ret_nrt == 0 || (rt = *ret_nrt) == 0) if (ret_nrt == 0 || (rt = *ret_nrt) == 0)
senderr(EINVAL); senderr(EINVAL);
ifa = rt->rt_ifa; ifa = rt->rt_ifa;
flags = rt->rt_flags & ~RTF_CLONING; flags = rt->rt_flags & ~(RTF_CLONING | RTF_PRCLONING);
prflags = rt->rt_prflags | RTPRF_WASCLONED; flags |= RTF_WASCLONED;
gateway = rt->rt_gateway; gateway = rt->rt_gateway;
if ((netmask = rt->rt_genmask) == 0) if ((netmask = rt->rt_genmask) == 0)
flags |= RTF_HOST; flags |= RTF_HOST;
@ -407,7 +410,6 @@ rtrequest(req, dst, gateway, netmask, flags, ret_nrt)
senderr(ENOBUFS); senderr(ENOBUFS);
Bzero(rt, sizeof(*rt)); Bzero(rt, sizeof(*rt));
rt->rt_flags = RTF_UP | flags; rt->rt_flags = RTF_UP | flags;
rt->rt_prflags = prflags;
if (rt_setgate(rt, dst, gateway)) { if (rt_setgate(rt, dst, gateway)) {
Free(rt); Free(rt);
senderr(ENOBUFS); senderr(ENOBUFS);
@ -473,7 +475,7 @@ rt_setgate(rt0, dst, gate)
rt = rt0; rt->rt_gwroute = 0; rt = rt0; rt->rt_gwroute = 0;
} }
if (rt->rt_flags & RTF_GATEWAY) { if (rt->rt_flags & RTF_GATEWAY) {
rt->rt_gwroute = rtalloc1(gate, 1); rt->rt_gwroute = rtalloc1(gate, 1, 0UL);
} }
return 0; return 0;
} }
@ -522,7 +524,7 @@ rtinit(ifa, cmd, flags)
rt_maskedcopy(dst, deldst, ifa->ifa_netmask); rt_maskedcopy(dst, deldst, ifa->ifa_netmask);
dst = deldst; dst = deldst;
} }
rt = rtalloc1(dst, 0); rt = rtalloc1(dst, 0, 0UL);
if (rt) { if (rt) {
rt->rt_refcnt--; rt->rt_refcnt--;
if (rt->rt_ifa != ifa) { if (rt->rt_ifa != ifa) {

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)route.h 8.3 (Berkeley) 4/19/94 * @(#)route.h 8.3 (Berkeley) 4/19/94
* $Id: route.h,v 1.4 1994/08/21 05:11:46 paul Exp $ * $Id: route.h,v 1.5 1994/11/03 01:04:32 wollman Exp $
*/ */
#ifndef _NET_ROUTE_H_ #ifndef _NET_ROUTE_H_
@ -69,6 +69,8 @@ struct rt_metrics {
u_long rmx_rtt; /* estimated round trip time */ u_long rmx_rtt; /* estimated round trip time */
u_long rmx_rttvar; /* estimated rtt variance */ u_long rmx_rttvar; /* estimated rtt variance */
u_long rmx_pksent; /* packets sent using this route */ u_long rmx_pksent; /* packets sent using this route */
u_long rmx_ttcp_cc; /* cached last T/TCP CC option rcvd */
u_long rmx_ttcp_ccsent; /* cached last T/TCP CC option sent */
}; };
/* /*
@ -96,15 +98,16 @@ struct rtentry {
#define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask)) #define rt_mask(r) ((struct sockaddr *)((r)->rt_nodes->rn_mask))
struct sockaddr *rt_gateway; /* value */ struct sockaddr *rt_gateway; /* value */
/* XXX - rt_flags should be unified with rt_prflags */ /* XXX - rt_flags should be unified with rt_prflags */
short rt_flags; /* up/down?, host/net */ short rt_filler; /* up/down?, host/net */
short rt_refcnt; /* # held references */ short rt_refcnt; /* # held references */
u_long rt_prflags; /* protocol-specific flags */ u_long rt_flags; /* protocol-specific flags */
struct ifnet *rt_ifp; /* the answer: interface to use */ struct ifnet *rt_ifp; /* the answer: interface to use */
struct ifaddr *rt_ifa; /* the answer: interface to use */ struct ifaddr *rt_ifa; /* the answer: interface to use */
struct sockaddr *rt_genmask; /* for generation of cloned routes */ struct sockaddr *rt_genmask; /* for generation of cloned routes */
caddr_t rt_llinfo; /* pointer to link level info cache */ caddr_t rt_llinfo; /* pointer to link level info cache */
struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */ struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */
struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */ struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */
int (*rt_output) __P(()); /* output routine for this (rt,if) */
}; };
/* /*
@ -139,7 +142,10 @@ struct ortentry {
#define RTF_PROTO2 0x4000 /* protocol specific routing flag */ #define RTF_PROTO2 0x4000 /* protocol specific routing flag */
#define RTF_PROTO1 0x8000 /* protocol specific routing flag */ #define RTF_PROTO1 0x8000 /* protocol specific routing flag */
#define RTPRF_WASCLONED 0x1 /* route generated through cloning */ #define RTF_PRCLONING 0x10000 /* protocol requires cloning */
#define RTF_WASCLONED 0x20000 /* route generated through cloning */
#define RTF_PROTO3 0x40000 /* protocol specific routing flag */
/* 0x80000 and up unassigned */
/* /*
* Routing statistics. * Routing statistics.
@ -169,7 +175,7 @@ struct rt_msghdr {
struct rt_metrics rtm_rmx; /* metrics themselves */ struct rt_metrics rtm_rmx; /* metrics themselves */
}; };
#define RTM_VERSION 3 /* Up the ante and ignore older versions */ #define RTM_VERSION 4 /* Up the ante and ignore older versions */
#define RTM_ADD 0x1 /* Add Route */ #define RTM_ADD 0x1 /* Add Route */
#define RTM_DELETE 0x2 /* Delete Route */ #define RTM_DELETE 0x2 /* Delete Route */
@ -257,8 +263,9 @@ int rt_setgate __P((struct rtentry *,
void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *)); void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));
void rtable_init __P((void **)); void rtable_init __P((void **));
void rtalloc __P((struct route *)); void rtalloc __P((struct route *));
void rtalloc_ign __P((struct route *, unsigned long));
struct rtentry * struct rtentry *
rtalloc1 __P((struct sockaddr *, int)); rtalloc1 __P((struct sockaddr *, int, unsigned long));
void rtfree __P((struct rtentry *)); void rtfree __P((struct rtentry *));
int rtinit __P((struct ifaddr *, int, int)); int rtinit __P((struct ifaddr *, int, int));
int rtioctl __P((int, caddr_t, struct proc *)); int rtioctl __P((int, caddr_t, struct proc *));

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)rtsock.c 8.3 (Berkeley) 1/4/94 * @(#)rtsock.c 8.3 (Berkeley) 1/4/94
* $Id: rtsock.c,v 1.6 1994/10/08 22:38:26 phk Exp $ * $Id: rtsock.c,v 1.7 1994/10/11 23:16:29 wollman Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -196,7 +196,7 @@ route_output(m, so)
case RTM_GET: case RTM_GET:
case RTM_CHANGE: case RTM_CHANGE:
case RTM_LOCK: case RTM_LOCK:
rt = rtalloc1(dst, 0); rt = rtalloc1(dst, 0, 0UL);
if (rt == 0) if (rt == 0)
senderr(ESRCH); senderr(ESRCH);
if (rtm->rtm_type != RTM_GET) {/* XXX: too grotty */ if (rtm->rtm_type != RTM_GET) {/* XXX: too grotty */