Changed fix (ee2ce4fc986d) because routes with NULL ifaces are especially interesting...
authorSven-Ola Tuecke <sven-ola@gmx.de>
Sat, 20 Dec 2008 18:22:28 +0000 (19:22 +0100)
committerSven-Ola Tuecke <sven-ola@gmx.de>
Sat, 20 Dec 2008 18:22:28 +0000 (19:22 +0100)
lib/httpinfo/src/olsrd_httpinfo.c
lib/txtinfo/src/olsrd_txtinfo.c
src/linux/net.c

index 2a9392e..cc04f57 100644 (file)
@@ -801,7 +801,7 @@ static void build_route(struct autobuf *abuf, const struct rt_entry * rt)
                  get_linkcost_text(rt->rt_best->rtp_metric.cost, true, &lqbuffer));
   abuf_appendf(abuf,
                  "<td align=\"center\">%s</td></tr>\n",
-                 rt->rt_best->rtp_nexthop.interface->int_name);
+                 rt->rt_best->rtp_nexthop.interface ? rt->rt_best->rtp_nexthop.interface->int_name : "[null]");
 }
 
 static void build_routes_body(struct autobuf *abuf)
index 6c68b00..2335cb0 100644 (file)
@@ -492,16 +492,14 @@ static int ipc_print_routes(struct ipc_conn *conn)
         struct ipaddr_str buf;
         struct ipprefix_str prefixstr;
         struct lqtextbuffer lqbuffer;
-        if (rt->rt_best->rtp_nexthop.interface) {
-          if (abuf_appendf(&conn->resp,
+        if (abuf_appendf(&conn->resp,
                             "%s\t%s\t%u\t%s\t%s\t\n",
                             olsr_ip_prefix_to_string(&prefixstr, &rt->rt_dst),
                             olsr_ip_to_string(&buf, &rt->rt_best->rtp_nexthop.gateway),
                             rt->rt_best->rtp_metric.hops,
                             get_linkcost_text(rt->rt_best->rtp_metric.cost, true, &lqbuffer),
-                            rt->rt_best->rtp_nexthop.interface->int_name) < 0) {
+                            rt->rt_best->rtp_nexthop.interface ? rt->rt_best->rtp_nexthop.interface->int_name : "[null]") < 0) {
             return -1;
-          }
         }
     } OLSR_FOR_ALL_RT_ENTRIES_END(rt);
 
index d8c025d..95ff413 100644 (file)
@@ -59,7 +59,7 @@
 #include <syslog.h>
 #include <errno.h>
 #include <unistd.h>
-
+#include <assert.h>
 
 /* Redirect proc entry */
 #define REDIRECT_PROC "/proc/sys/net/ipv4/conf/%s/send_redirects"
@@ -457,7 +457,7 @@ getsocket(int bufspace, char *int_name)
   memset(&sin4, 0, sizeof(sin4));
   sin4.sin_family = AF_INET;
   sin4.sin_port = htons(OLSRPORT);
-  sin4.sin_addr.s_addr = INADDR_ANY;
+  assert(sin4.sin_addr.s_addr == INADDR_ANY);
   if (bind(sock, (struct sockaddr *)&sin4, sizeof(sin4)) < 0) {
     perror("bind");
     syslog(LOG_ERR, "bind: %m");
@@ -554,7 +554,7 @@ getsocket6(int bufspace, char *int_name)
   memset(&sin6, 0, sizeof(sin6));
   sin6.sin6_family = AF_INET6;
   sin6.sin6_port = htons(OLSRPORT);
-  //(addrsock6.sin6_addr).s_addr = IN6ADDR_ANY_INIT;
+  assert(0 == memcmp(&sin6.sin6_addr, &in6addr_any, sizeof(sin6.sin6_addr))); /* == IN6ADDR_ANY_INIT */
   if (bind(sock, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
     perror("bind");
     syslog(LOG_ERR, "bind: %m");