Hi,

because of a bug in ospf6d I tried to allow ospf6d to change cloning
routes to gateway routes and the other way around. I've noticed there is
a check which tries to forbid this, but the check is broken. It allows to
toggle ALL rt flags, if ONE common bit in RTF_FMASK and rtm_fmask is set.
Because of this bug my modified ospf6d is working fine because it can set
proper route flags.

I'm asking me what is the reason for the check? In my opinion a process
which writes to a route socket, should know how it has to handle route
flags. If the process doesn't want to modify the route flags it has just
to specify an empty rtm_fmask. It's confusing for developers if there is
a bitmask (RTF_FMASK) that prohibit silently to change flags, which are
explicitly specified to be changeable by an other bitmask (rtm_fmask).

Does anybody knows a situation were changing route flags would break
something, which would make it necessary to delete a route first and add
the same route with different flags again? If not please remove the
check.

Regards,

Florian


Index: net/route.h
===================================================================
RCS file: /cvs/src/sys/net/route.h,v
retrieving revision 1.78
diff -u -p -r1.78 route.h
--- net/route.h 19 Sep 2012 16:14:01 -0000      1.78
+++ net/route.h 28 Nov 2012 20:52:19 -0000
@@ -146,11 +146,6 @@ struct rtentry {
 #define RTF_MPATH      0x40000         /* multipath route or operation */
 #define RTF_MPLS       0x100000        /* MPLS additional infos */

-/* 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)
-
 #ifndef _KERNEL
 /* obsoleted */
 #define RTF_SOURCE     0x20000         /* this route has a source
selector */
Index: net/rtsock.c
===================================================================
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.123
diff -u -p -r1.123 rtsock.c
--- net/rtsock.c        20 Sep 2012 20:53:13 -0000      1.123
+++ net/rtsock.c        28 Nov 2012 20:52:20 -0000
@@ -836,11 +836,8 @@ report:
                                }
                        }
 #endif
-                       /* Hack to allow some flags to be toggled */
-                       if (rtm->rtm_fmask & RTF_FMASK)
-                               rt->rt_flags = (rt->rt_flags &
-                                   ~rtm->rtm_fmask) |
-                                   (rtm->rtm_flags & rtm->rtm_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);

Reply via email to