On Tue, Dec 08, 2009 at 02:37:51AM -0800, Doran Mori wrote:
> Here's the patch for making the RTF_UP show up properly when changing
> a gateway from/to an up/down link.
>
> --- /usr/src/sys/net/rtsock.c Tue Dec 1 00:36:58 2009
> +++ rtsock.c Mon Dec 7 23:36:20 2009
> @@ -641,6 +641,19 @@ report:
> }
> }
>
> + /* new gateway, possible link state change */
> + if ((LINK_STATE_IS_UP(ifa->ifa_ifp->if_link_state) ||
> + ifa->ifa_ifp->if_link_state ==
> LINK_STATE_UNKNOWN) &&
> + ifa->ifa_ifp->if_flags & IFF_UP) {
> + rt->rt_flags |= RTF_UP;
> + rt->rt_priority &= RTP_MASK;
> + }
> + else {
> + rt->rt_flags &= ~RTF_UP;
> + rtm->rtm_flags &= RTF_UP;
> + rt->rt_priority |= RTP_DOWN;
> + }
> +
This is not correct and expains why you had to change radix_mpath.c.
If you change the rt_priority you must rebalance the dupedkey list so that
the order remains correct. It is also only necessary when the ifp changes.
So here is what I came up with that is totaly untested and maybe wrong as
well.
--
:wq Claudio
Index: route.c
===================================================================
RCS file: /cvs/src/sys/net/route.c,v
retrieving revision 1.114
diff -u -p -r1.114 route.c
--- route.c 3 Nov 2009 10:59:04 -0000 1.114
+++ route.c 15 Dec 2009 14:48:36 -0000
@@ -152,9 +152,6 @@ int okaytoclone(u_int, int);
int rtflushclone1(struct radix_node *, void *);
void rtflushclone(struct radix_node_head *, struct rtentry *);
int rt_if_remove_rtdelete(struct radix_node *, void *);
-#ifndef SMALL_KERNEL
-int rt_if_linkstate_change(struct radix_node *, void *);
-#endif
#define LABELID_MAX 50000
Index: route.h
===================================================================
RCS file: /cvs/src/sys/net/route.h,v
retrieving revision 1.65
diff -u -p -r1.65 route.h
--- route.h 3 Nov 2009 10:59:04 -0000 1.65
+++ route.h 15 Dec 2009 14:48:23 -0000
@@ -394,6 +394,7 @@ int rtrequest1(int, struct rt_addrinfo
void rt_if_remove(struct ifnet *);
#ifndef SMALL_KERNEL
void rt_if_track(struct ifnet *);
+int rt_if_linkstate_change(struct radix_node *, void *);
#endif
int rtdeletemsg(struct rtentry *, u_int);
Index: rtsock.c
===================================================================
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.95
diff -u -p -r1.95 rtsock.c
--- rtsock.c 3 Nov 2009 10:59:04 -0000 1.95
+++ rtsock.c 15 Dec 2009 14:49:53 -0000
@@ -638,6 +638,11 @@ report:
rt->rt_ifa = ifa;
ifa->ifa_refcnt++;
rt->rt_ifp = ifp;
+#ifndef SMALL_KERNEL
+ /* recheck link state after ifp change */
+ rt_if_linkstate_change(
+ (struct radix_node *)rt, ifp);
+#endif
}
}
@@ -651,6 +656,7 @@ report:
&rt->rt_rmx);
rtm->rtm_index = rt->rt_ifp->if_index;
rtm->rtm_priority = rt->rt_priority & RTP_MASK;
+ rtm->rtm_flags = rt->rt_flags;
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info);
if (genmask)