From 71d2be426c8d4c957d7a6ff97b44f40f70658dfb Mon Sep 17 00:00:00 2001 From: andre Date: Wed, 15 Mar 2006 19:39:09 +0000 Subject: - 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 --- sys/net/rtsock.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/net/rtsock.c') 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]) -- cgit v1.1