summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2006-03-15 19:39:09 +0000
committerandre <andre@FreeBSD.org>2006-03-15 19:39:09 +0000
commit71d2be426c8d4c957d7a6ff97b44f40f70658dfb (patch)
tree7224bb46da1d4e67413b249aff1877bc52a6294d
parent66352feceecbad66c181c2800cbdfe5009a5343f (diff)
downloadFreeBSD-src-71d2be426c8d4c957d7a6ff97b44f40f70658dfb.zip
FreeBSD-src-71d2be426c8d4c957d7a6ff97b44f40f70658dfb.tar.gz
- Fill in the correct rtm_index for RTM_ADD and RTM_CHANGE messages.
- Allow RTM_CHANGE to change a number of route flags as specified by RTF_FMASK. - The unused rtm_use field in struct rt_msghdr is redesignated as rtm_fmask field to communicate route flag changes in RTM_CHANGE messages from userland. The use count of a route was moved to rtm_rmx a long time ago. For source code compatibility reasons a define of rtm_use to rtm_fmask is provided. These changes faciliate running of multiple cooperating routing daemons at the same time without causing undesired interference. Open[BGP|OSPF]D make use of these features to have IGP routes override EGP ones. Obtained from: OpenBSD (claudio@) MFC after: 3 days
-rw-r--r--sys/net/route.h8
-rw-r--r--sys/net/rtsock.c8
2 files changed, 15 insertions, 1 deletions
diff --git a/sys/net/route.h b/sys/net/route.h
index b7f514c..b408213 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -169,6 +169,11 @@ struct ortentry {
#define RTF_MULTICAST 0x800000 /* route represents a mcast address */
/* 0x1000000 and up unassigned */
+/* Mask of RTF flags that are allowed to be modified by RTM_CHANGE. */
+#define RTF_FMASK \
+ (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \
+ RTF_REJECT | RTF_STATIC)
+
/*
* Routing statistics.
*/
@@ -192,7 +197,8 @@ struct rt_msghdr {
pid_t rtm_pid; /* identify sender */
int rtm_seq; /* for sender to identify action */
int rtm_errno; /* why failed */
- int rtm_use; /* from rtentry */
+ int rtm_fmask; /* bitmask used in RTM_CHANGE message */
+#define rtm_use rtm_fmask /* deprecated, use rtm_rmx->rmx_pksent */
u_long rtm_inits; /* which metrics we are initializing */
struct rt_metrics rtm_rmx; /* metrics themselves */
};
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index f0a978d..ea3bac2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -379,6 +379,7 @@ route_output(struct mbuf *m, struct socket *so)
RT_LOCK(saved_nrt);
rt_setmetrics(rtm->rtm_inits,
&rtm->rtm_rmx, &saved_nrt->rt_rmx);
+ rtm->rtm_index = saved_nrt->rt_ifp->if_index;
RT_REMREF(saved_nrt);
saved_nrt->rt_genmask = info.rti_info[RTAX_GENMASK];
RT_UNLOCK(saved_nrt);
@@ -480,6 +481,7 @@ route_output(struct mbuf *m, struct socket *so)
}
(void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, NULL);
rtm->rtm_flags = rt->rt_flags;
+ rtm->rtm_use = 0;
rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
rtm->rtm_addrs = info.rti_addrs;
break;
@@ -522,8 +524,14 @@ route_output(struct mbuf *m, struct socket *so)
rt->rt_ifp = info.rti_ifp;
}
}
+ /* Allow some flags to be toggled on change. */
+ if (rtm->rtm_fmask & RTF_FMASK)
+ rt->rt_flags = (rt->rt_flags &
+ ~rtm->rtm_fmask) |
+ (rtm->rtm_flags & rtm->rtm_fmask);
rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
&rt->rt_rmx);
+ rtm->rtm_index = rt->rt_ifp->if_index;
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info);
if (info.rti_info[RTAX_GENMASK])
OpenPOWER on IntegriCloud