Remove RTF_PRCLONING from routing table and adjust users of it
accordingly. The define is left intact for ABI compatibility with userland. This is a pre-step for the introduction of tcp_hostcache. The network stack remains fully useable with this change. Reviewed by: sam (mentor), bms Reviewed by: -net, -current, core@kame.net (IPv6 parts) Approved by: re (scottl)
This commit is contained in:
parent
3257da0c40
commit
26d02ca7ba
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122921
@ -139,7 +139,7 @@ rtalloc1(struct sockaddr *dst, int report, u_long ignflags)
|
||||
*/
|
||||
newrt = rt = (struct rtentry *)rn;
|
||||
nflags = rt->rt_flags & ~ignflags;
|
||||
if (report && (nflags & (RTF_CLONING | RTF_PRCLONING))) {
|
||||
if (report && (nflags & RTF_CLONING)) {
|
||||
/*
|
||||
* We are apparently adding (report = 0 in delete).
|
||||
* If it requires that it be cloned, do so.
|
||||
@ -584,7 +584,7 @@ rtexpunge(struct rtentry *rt)
|
||||
* Now search what's left of the subtree for any cloned
|
||||
* routes which might have been formed from this node.
|
||||
*/
|
||||
if ((rt->rt_flags & (RTF_CLONING | RTF_PRCLONING)) && rt_mask(rt))
|
||||
if ((rt->rt_flags & RTF_CLONING) && rt_mask(rt))
|
||||
rnh->rnh_walktree_from(rnh, rt_key(rt), rt_mask(rt),
|
||||
rt_fixdelete, rt);
|
||||
|
||||
@ -647,7 +647,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
*/
|
||||
if (flags & RTF_HOST) {
|
||||
netmask = 0;
|
||||
flags &= ~(RTF_CLONING | RTF_PRCLONING);
|
||||
flags &= ~RTF_CLONING;
|
||||
}
|
||||
switch (req) {
|
||||
case RTM_DELETE:
|
||||
@ -669,7 +669,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
* Now search what's left of the subtree for any cloned
|
||||
* routes which might have been formed from this node.
|
||||
*/
|
||||
if ((rt->rt_flags & (RTF_CLONING | RTF_PRCLONING)) &&
|
||||
if ((rt->rt_flags & RTF_CLONING) &&
|
||||
rt_mask(rt)) {
|
||||
rnh->rnh_walktree_from(rnh, dst, rt_mask(rt),
|
||||
rt_fixdelete, rt);
|
||||
@ -716,7 +716,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
ifa = rt->rt_ifa;
|
||||
/* XXX locking? */
|
||||
flags = rt->rt_flags &
|
||||
~(RTF_CLONING | RTF_PRCLONING | RTF_STATIC);
|
||||
~(RTF_CLONING | RTF_STATIC);
|
||||
flags |= RTF_WASCLONED;
|
||||
gateway = rt->rt_gateway;
|
||||
if ((netmask = rt->rt_genmask) == 0)
|
||||
@ -777,11 +777,11 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
/*
|
||||
* Uh-oh, we already have one of these in the tree.
|
||||
* We do a special hack: if the route that's already
|
||||
* there was generated by the protocol-cloning
|
||||
* mechanism, then we just blow it away and retry
|
||||
* the insertion of the new one.
|
||||
* there was generated by the cloning mechanism
|
||||
* then we just blow it away and retry the insertion
|
||||
* of the new one.
|
||||
*/
|
||||
rt2 = rtalloc1(dst, 0, RTF_PRCLONING);
|
||||
rt2 = rtalloc1(dst, 0, 0);
|
||||
if (rt2 && rt2->rt_parent) {
|
||||
rtexpunge(rt2);
|
||||
RT_UNLOCK(rt2);
|
||||
@ -820,7 +820,7 @@ rtrequest1(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt)
|
||||
("no route to clone from"));
|
||||
rt->rt_rmx = (*ret_nrt)->rt_rmx; /* copy metrics */
|
||||
rt->rt_rmx.rmx_pksent = 0; /* reset packet counter */
|
||||
if ((*ret_nrt)->rt_flags & (RTF_CLONING | RTF_PRCLONING)) {
|
||||
if ((*ret_nrt)->rt_flags & RTF_CLONING) {
|
||||
/*
|
||||
* NB: We do not bump the refcnt on the parent
|
||||
* entry under the assumption that it will
|
||||
@ -896,7 +896,7 @@ rt_fixdelete(struct radix_node *rn, void *vp)
|
||||
struct rtentry *rt0 = vp;
|
||||
|
||||
if (rt->rt_parent == rt0 &&
|
||||
!(rt->rt_flags & (RTF_PINNED | RTF_CLONING | RTF_PRCLONING))) {
|
||||
!(rt->rt_flags & (RTF_PINNED | RTF_CLONING))) {
|
||||
return rtrequest(RTM_DELETE, rt_key(rt),
|
||||
(struct sockaddr *)0, rt_mask(rt),
|
||||
rt->rt_flags, (struct rtentry **)0);
|
||||
@ -937,7 +937,7 @@ rt_fixchange(struct radix_node *rn, void *vp)
|
||||
#endif
|
||||
|
||||
if (!rt->rt_parent ||
|
||||
(rt->rt_flags & (RTF_PINNED | RTF_CLONING | RTF_PRCLONING))) {
|
||||
(rt->rt_flags & (RTF_PINNED | RTF_CLONING))) {
|
||||
#ifdef DEBUG
|
||||
if(rtfcdebug) printf("no parent, pinned or cloning\n");
|
||||
#endif
|
||||
@ -1087,10 +1087,11 @@ rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)
|
||||
* correct choice anyway), and avoid the resulting reference loops
|
||||
* by disallowing any route to run through itself as a gateway.
|
||||
* This is obviously mandatory when we get rt->rt_output().
|
||||
* XXX: After removal of PRCLONING this is probably not needed anymore.
|
||||
*/
|
||||
if (rt->rt_flags & RTF_GATEWAY) {
|
||||
/* XXX LOR here */
|
||||
rt->rt_gwroute = rtalloc1(gate, 1, RTF_PRCLONING);
|
||||
rt->rt_gwroute = rtalloc1(gate, 1, 0);
|
||||
if (rt->rt_gwroute == rt) {
|
||||
RTFREE_LOCKED(rt->rt_gwroute);
|
||||
rt->rt_gwroute = 0;
|
||||
|
@ -151,7 +151,11 @@ struct ortentry {
|
||||
#define RTF_PROTO2 0x4000 /* protocol specific routing flag */
|
||||
#define RTF_PROTO1 0x8000 /* protocol specific routing flag */
|
||||
|
||||
#define RTF_PRCLONING 0x10000 /* protocol requires cloning */
|
||||
/* XXX: temporary to stay API/ABI compatible with userland */
|
||||
#ifndef _KERNEL
|
||||
#define RTF_PRCLONING 0x10000 /* unused, for compatibility */
|
||||
#endif
|
||||
|
||||
#define RTF_WASCLONED 0x20000 /* route generated through cloning */
|
||||
#define RTF_PROTO3 0x40000 /* protocol specific routing flag */
|
||||
/* 0x80000 unused */
|
||||
|
@ -72,15 +72,6 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)rt_key(rt);
|
||||
struct radix_node *ret;
|
||||
|
||||
/*
|
||||
* For IP, all unicast non-host routes are automatically cloning.
|
||||
*/
|
||||
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
|
||||
@ -94,8 +85,7 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
*
|
||||
* 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.)
|
||||
* dubious since it's so easy to inspect the address).
|
||||
*/
|
||||
if (rt->rt_flags & RTF_HOST) {
|
||||
if (in_broadcast(sin->sin_addr, rt->rt_ifp)) {
|
||||
@ -105,6 +95,8 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
rt->rt_flags |= RTF_LOCAL;
|
||||
}
|
||||
}
|
||||
if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
|
||||
rt->rt_flags |= RTF_MULTICAST;
|
||||
|
||||
if (!rt->rt_rmx.rmx_mtu && !(rt->rt_rmx.rmx_locks & RTV_MTU) &&
|
||||
rt->rt_ifp)
|
||||
@ -118,8 +110,7 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
* Find out if it is because of an
|
||||
* ARP entry and delete it if so.
|
||||
*/
|
||||
rt2 = rtalloc1((struct sockaddr *)sin, 0,
|
||||
RTF_CLONING | RTF_PRCLONING);
|
||||
rt2 = rtalloc1((struct sockaddr *)sin, 0, RTF_CLONING);
|
||||
if (rt2) {
|
||||
if (rt2->rt_flags & RTF_LLINFO &&
|
||||
rt2->rt_flags & RTF_HOST &&
|
||||
@ -379,7 +370,7 @@ in_ifadownkill(struct radix_node *rn, void *xap)
|
||||
* the routes that rtrequest() would have in any case,
|
||||
* so that behavior is not needed there.
|
||||
*/
|
||||
rt->rt_flags &= ~(RTF_CLONING | RTF_PRCLONING);
|
||||
rt->rt_flags &= ~RTF_CLONING;
|
||||
rtexpunge(rt);
|
||||
}
|
||||
RT_UNLOCK(rt);
|
||||
|
@ -488,7 +488,7 @@ ip_fastforward(struct mbuf *m)
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
dst->sin_addr.s_addr = dest;
|
||||
rtalloc_ign(&ro, (RTF_PRCLONING | RTF_CLONING));
|
||||
rtalloc_ign(&ro, RTF_CLONING);
|
||||
|
||||
/*
|
||||
* Route there and interface still up?
|
||||
@ -692,7 +692,7 @@ ip_fastforward(struct mbuf *m)
|
||||
dst->sin_family = AF_INET;
|
||||
dst->sin_len = sizeof(*dst);
|
||||
dst->sin_addr.s_addr = dest;
|
||||
rtalloc_ign(&ro, (RTF_PRCLONING | RTF_CLONING));
|
||||
rtalloc_ign(&ro, RTF_CLONING);
|
||||
|
||||
/*
|
||||
* Route there and interface still up?
|
||||
|
@ -463,7 +463,7 @@ verify_rev_path(struct in_addr src, struct ifnet *ifp)
|
||||
dst->sin_len = sizeof(*dst);
|
||||
dst->sin_addr = src;
|
||||
|
||||
rtalloc_ign(&ro, RTF_CLONING|RTF_PRCLONING);
|
||||
rtalloc_ign(&ro, RTF_CLONING);
|
||||
}
|
||||
|
||||
if ((ro.ro_rt == NULL) || (ifp == NULL) ||
|
||||
|
@ -415,7 +415,7 @@ icmp_input(m, off)
|
||||
int mtu;
|
||||
|
||||
rt = rtalloc1((struct sockaddr *)&icmpsrc, 0,
|
||||
RTF_CLONING | RTF_PRCLONING);
|
||||
RTF_CLONING);
|
||||
if (rt && (rt->rt_flags & RTF_HOST)
|
||||
&& !(rt->rt_rmx.rmx_locks & RTV_MTU)) {
|
||||
mtu = ntohs(icp->icmp_nextmtu);
|
||||
|
@ -1621,7 +1621,7 @@ ip_rtaddr(dst)
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_addr = dst;
|
||||
rtalloc_ign(&ro, (RTF_PRCLONING | RTF_CLONING));
|
||||
rtalloc_ign(&ro, RTF_CLONING);
|
||||
|
||||
if (ro.ro_rt == 0)
|
||||
return ((struct in_ifaddr *)0);
|
||||
@ -1884,7 +1884,7 @@ ip_forward(struct mbuf *m, int srcrt, struct sockaddr_in *next_hop)
|
||||
sin->sin_family = AF_INET;
|
||||
sin->sin_len = sizeof(*sin);
|
||||
sin->sin_addr = pkt_dst;
|
||||
rtalloc_ign(&ro, (RTF_PRCLONING | RTF_CLONING));
|
||||
rtalloc_ign(&ro, RTF_CLONING);
|
||||
|
||||
rt = ro.ro_rt;
|
||||
|
||||
|
@ -311,7 +311,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro,
|
||||
* for correct operation (as it is for ARP).
|
||||
*/
|
||||
if (ro->ro_rt == 0)
|
||||
rtalloc_ign(ro, RTF_PRCLONING);
|
||||
rtalloc(ro);
|
||||
if (ro->ro_rt == 0) {
|
||||
ipstat.ips_noroute++;
|
||||
error = EHOSTUNREACH;
|
||||
@ -940,7 +940,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro,
|
||||
bcopy(dst, &ro_fwd->ro_dst, sizeof(*dst));
|
||||
|
||||
ro_fwd->ro_rt = 0;
|
||||
rtalloc_ign(ro_fwd, RTF_PRCLONING);
|
||||
rtalloc(ro_fwd);
|
||||
|
||||
if (ro_fwd->ro_rt == 0) {
|
||||
ipstat.ips_noroute++;
|
||||
|
@ -1141,8 +1141,7 @@ icmp6_mtudisc_update(ip6cp, validated)
|
||||
htons(m->m_pkthdr.rcvif->if_index);
|
||||
}
|
||||
/* sin6.sin6_scope_id = XXX: should be set if DST is a scoped addr */
|
||||
rt = rtalloc1((struct sockaddr *)&sin6, 0,
|
||||
RTF_CLONING | RTF_PRCLONING);
|
||||
rt = rtalloc1((struct sockaddr *)&sin6, 0, RTF_CLONING);
|
||||
|
||||
if (rt && (rt->rt_flags & RTF_HOST) &&
|
||||
!(rt->rt_rmx.rmx_locks & RTV_MTU)) {
|
||||
@ -2135,8 +2134,7 @@ icmp6_reflect(m, off)
|
||||
sin6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
sin6->sin6_addr = ip6->ip6_dst;
|
||||
|
||||
rtalloc_ign((struct route *)&icmp6_reflect_rt.ro_rt,
|
||||
RTF_PRCLONING);
|
||||
rtalloc((struct route *)&icmp6_reflect_rt.ro_rt);
|
||||
}
|
||||
|
||||
if (icmp6_reflect_rt.ro_rt == 0)
|
||||
|
@ -116,16 +116,9 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt);
|
||||
struct radix_node *ret;
|
||||
|
||||
/*
|
||||
* For IPv6, all unicast non-host routes are automatically cloning.
|
||||
*/
|
||||
if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_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 IPv6 output and input:
|
||||
* For local addresses, we make sure that RTF_LOCAL is set,
|
||||
@ -160,8 +153,7 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
* Find out if it is because of an
|
||||
* ARP entry and delete it if so.
|
||||
*/
|
||||
rt2 = rtalloc1((struct sockaddr *)sin6, 0,
|
||||
RTF_CLONING | RTF_PRCLONING);
|
||||
rt2 = rtalloc1((struct sockaddr *)sin6, 0, RTF_CLONING);
|
||||
if (rt2) {
|
||||
if (rt2->rt_flags & RTF_LLINFO &&
|
||||
rt2->rt_flags & RTF_HOST &&
|
||||
@ -188,8 +180,7 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
* net route entry, 3ffe:0501:: -> if0.
|
||||
* This case should not raise an error.
|
||||
*/
|
||||
rt2 = rtalloc1((struct sockaddr *)sin6, 0,
|
||||
RTF_CLONING | RTF_PRCLONING);
|
||||
rt2 = rtalloc1((struct sockaddr *)sin6, 0, RTF_CLONING);
|
||||
if (rt2) {
|
||||
if ((rt2->rt_flags & (RTF_CLONING|RTF_HOST|RTF_GATEWAY))
|
||||
== RTF_CLONING
|
||||
|
@ -343,8 +343,7 @@ ip6_forward(m, srcrt)
|
||||
}
|
||||
|
||||
/* this probably fails but give it a try again */
|
||||
rtalloc_ign((struct route *)&ip6_forward_rt,
|
||||
RTF_PRCLONING);
|
||||
rtalloc((struct route *)&ip6_forward_rt);
|
||||
}
|
||||
|
||||
if (ip6_forward_rt.ro_rt == 0) {
|
||||
@ -368,7 +367,7 @@ ip6_forward(m, srcrt)
|
||||
dst->sin6_family = AF_INET6;
|
||||
dst->sin6_addr = ip6->ip6_dst;
|
||||
|
||||
rtalloc_ign((struct route *)&ip6_forward_rt, RTF_PRCLONING);
|
||||
rtalloc((struct route *)&ip6_forward_rt);
|
||||
if (ip6_forward_rt.ro_rt == 0) {
|
||||
ip6stat.ip6s_noroute++;
|
||||
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute);
|
||||
|
@ -499,7 +499,7 @@ ip6_input(m)
|
||||
dst6->sin6_family = AF_INET6;
|
||||
dst6->sin6_addr = ip6->ip6_dst;
|
||||
|
||||
rtalloc_ign((struct route *)&ip6_forward_rt, RTF_PRCLONING);
|
||||
rtalloc((struct route *)&ip6_forward_rt);
|
||||
}
|
||||
|
||||
#define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key))
|
||||
|
Loading…
Reference in New Issue
Block a user