A bit of a route socket bug...
Matthew Luckie
mjl at luckie.org.nz
Fri Jul 8 00:22:09 GMT 2005
I'm not very familiar with the route code, but here is what i came up with.
[mjl at rayon mjl]$ sudo route change 10.3.2.1 127.0.0.1
route: writing to routing socket: No such process
change host 10.3.2.1: gateway 127.0.0.1: not in table
the code checks that if changing a host or network route, that the
route returned by a lookup matches this type. for network routes, it
also ensures that the netmask matches.
--- rtsock.c.orig Fri Jul 8 11:56:36 2005
+++ rtsock.c Fri Jul 8 12:12:39 2005
@@ -489,6 +489,30 @@
case RTM_CHANGE:
/*
+ * Check that the route returned is exactly the one
+ * that was looked up, so that some other route is not
+ * changed in error.
+ * Ensure the type of route (host/net) to be changed
+ * matches, and ensure that the route matches if net
+ * by checking that the netmask matches.
+ */
+ if (rt->rt_flags & RTF_HOST) {
+ if((info.rti_flags & RTF_HOST) == 0) {
+ RT_UNLOCK(rt);
+ senderr(ESRCH);
+ }
+ } else {
+ if((info.rti_flags & RTF_HOST) ||
+ info.rti_info[RTAX_NETMASK] == NULL ||
+ rt_mask(rt) == NULL ||
+ !sa_equal(info.rti_info[RTAX_NETMASK],
+ rt_mask(rt))) {
+ RT_UNLOCK(rt);
+ senderr(ESRCH);
+ }
+ }
+
+ /*
* New gateway could require new ifaddr, ifp;
* flags may also be different; ifp may be specified
* by ll sockaddr when protocol address is ambiguous
More information about the freebsd-net
mailing list