<p>Hi<br></p><p>I just wrote a simple (but os-independent) plugin for inserting missing routes into kernel,..</p><p>This one is os-independent, and just inserts all routes at a configureable interval</p><p>I also plan another plugin (route_mon) using rtnetlink broadcast messages, to react immediately on extrenal route deletions,..</p>
<p>while writing the plugin i also patched the linux specific parts of kernel route processing, handling "File exists" and "No such process" for the current olsr code completely similar to successful insertions/deletions, and providing return valöues to distinguish between if needed,..</p>
<p>any comments?</p><p>is it ok to push it to tip (together with my plugin, which relies (only for meaningful syslog/debugoutput) on the new return values of olsrd_add_route())</p><p>curent code of the simple plugin is here <a href="http://193.238.157.18/~markus/route_check">193.238.157.18/~markus/route_check</a></p>
<p>Markus</p><p>diff -r 71bcb86ad5ca src/linux/kernel_routes.c<br>--- a/src/linux/kernel_routes.c Sat Dec 20 19:24:59 2008 +0100<br>+++ b/src/linux/kernel_routes.c Sun Dec 21 12:54:56 2008 +0100<br>@@ -62,6 +62,7 @@<br> memcpy(RTA_DATA(rta), data, len);<br>
}<br> <br>+/* retrun -1 on error, 0 file exists/no such process and > 0 on successful change of kernel tables)*/<br> static int olsr_netlink_route(const struct rt_entry *rt, uint8_t family, uint8_t rttable, __u16 cmd)<br>
{<br> int ret = 0;<br>@@ -131,8 +132,17 @@<br> if (NLMSG_ERROR == h->nlmsg_type) {<br> if (NLMSG_LENGTH(sizeof(struct nlmsgerr) <= h->nlmsg_len)) {<br> const struct nlmsgerr *l_err = (struct nlmsgerr*)NLMSG_DATA(h);<br>
+ /* interprete 17=fileexists as successful! */<br> errno = -l_err->error;<br>- if (0 != errno) {<br>+ /* report success on already exist */<br>+ if ((errno == 17) & (cmd == RTM_NEWROUTE)) {<br>
+ ret = 0;<br>+ }<br>+ /* report success on No such process*/<br>+ else if ((errno == 3) & (cmd == RTM_DELROUTE)) {<br>+ ret = 0;<br>+ }<br>+ else if (0 != errno) {<br> ret = -1;<br>
}<br>diff -r 71bcb86ad5ca src/process_routes.c<br>--- a/src/process_routes.c Sat Dec 20 19:24:59 2008 +0100<br>+++ b/src/process_routes.c Sun Dec 21 12:54:56 2008 +0100<br>@@ -178,9 +178,9 @@<br> /**<br> * Process a route from the kernel addition list.<br>
*<br>- *@return nada<br>+ *@ return 1 on successfull addition, 0 on file exists, -1 on kernel error, -2 on no ioctl<br> */<br>-static void<br>+int16_t<br> olsr_add_kernel_route(struct rt_entry *rt)<br> {<br> <br>@@ -191,9 +191,11 @@<br>
if(error < 0) {<br> const char * const err_msg = strerror(errno);<br> const char * const routestr = olsr_rtp_to_string(rt->rt_best);<br>+ /*print error message if different to File Exists (if warn_on_existing is true)*/<br>
OLSR_PRINTF(1, "KERN: ERROR adding %s: %s\n", routestr, err_msg);<br> <br> olsr_syslog(OLSR_LOG_ERR, "Add route %s: %s", routestr, err_msg);<br>+ return -1;<br> } else {<br> <br> /* route addition has suceeded */<br>
@@ -205,7 +207,9 @@<br> /* lock the interface such that it does not vanish underneath us */<br> lock_interface(rt->rt_nexthop.interface);<br> }<br>+ return error;<br> }<br>+ return -2;<br> }<br> <br>
/**<br>diff -r 71bcb86ad5ca src/process_routes.h<br>--- a/src/process_routes.h Sat Dec 20 19:24:59 2008 +0100<br>+++ b/src/process_routes.h Sun Dec 21 12:54:56 2008 +0100<br>@@ -56,7 +56,7 @@<br> void olsr_update_kernel_routes(void);<br>
void olsr_delete_all_kernel_routes(void);<br> uint8_t olsr_rt_flags(const struct rt_entry *);<br>-<br>+int16_t olsr_add_kernel_route(struct rt_entry *);<br> #endif<br> <br> /*<br><br></p>