]> git.puffer.fish Git - mirror/frr.git/commitdiff
Switch from LOOKUP() to lookup() for rtm_type (see bug #401 for details).
authorDenis Ovsienko <linux@pilot.org.ua>
Fri, 14 Sep 2007 11:31:55 +0000 (11:31 +0000)
committerDenis Ovsienko <linux@pilot.org.ua>
Fri, 14 Sep 2007 11:31:55 +0000 (11:31 +0000)
zebra/ChangeLog
zebra/kernel_socket.c
zebra/kernel_socket.h
zebra/rt_socket.c

index b7c4d5ce5d4644ba83f9420ccf3826d499e7105a..36d194aa5404f3d5b45d79ca260bd96126f6dd98 100644 (file)
@@ -1,3 +1,11 @@
+2007-09-14 Denis Ovsienko
+
+       * rt_socket.c: (kernel_rtm_ipv4) Use lookup() instead of
+         LOOKUP/mes_lookup() for rtm_type_str, as this is more
+         appropriate for sparse code-spaces (#401).
+       * kernel_socket.c: (rtm_read, rtmsg_debug): Idem.
+       * kernel_socket.[ch]: We don't need rtm_type_str_max any more.
+
 2007-09-12 Denis Ovsienko
 
        * rt_socket.c: (kernel_rtm_ipv4) prefix_buf could be passed
index ff858bd3dfee5f66d98189437bd6e77ba15081e0..df2b5d809efa5004b179d2c947ee41aa0eff1411 100644 (file)
@@ -160,7 +160,6 @@ struct message rtm_type_str[] =
 #endif /* RTM_IFANNOUNCE */
   {0,            NULL}
 };
-int rtm_type_str_max = sizeof (rtm_type_str) / sizeof (struct message) - 1;
 
 struct message rtm_flag_str[] =
 {
@@ -754,7 +753,7 @@ rtm_read (struct rt_msghdr *rtm)
     return;
   if (IS_ZEBRA_DEBUG_KERNEL)
     zlog_debug ("%s: got rtm of type %d (%s)", __func__, rtm->rtm_type,
-      LOOKUP (rtm_type_str, rtm->rtm_type));
+      lookup (rtm_type_str, rtm->rtm_type));
 
 #ifdef RTF_CLONED      /*bsdi, netbsd 1.6*/
   if (flags & RTF_CLONED)
@@ -820,17 +819,17 @@ rtm_read (struct rt_msghdr *rtm)
             {
               case ZEBRA_RIB_NOTFOUND:
                 zlog_debug ("%s: %s %s/%d: desync: RR isn't yet in RIB, while already in FIB",
-                  __func__, LOOKUP (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+                  __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
                 break;
               case ZEBRA_RIB_FOUND_CONNECTED:
               case ZEBRA_RIB_FOUND_NOGATE:
                 inet_ntop (AF_INET, &gate.sin.sin_addr, gate_buf, INET_ADDRSTRLEN);
                 zlog_debug ("%s: %s %s/%d: desync: RR is in RIB, but gate differs (ours is %s)",
-                  __func__, LOOKUP (rtm_type_str, rtm->rtm_type), buf, p.prefixlen, gate_buf);
+                  __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen, gate_buf);
                 break;
               case ZEBRA_RIB_FOUND_EXACT: /* RIB RR == FIB RR */
                 zlog_debug ("%s: %s %s/%d: done Ok",
-                  __func__, LOOKUP (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+                  __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
                 rib_lookup_and_dump (&p);
                 return;
                 break;
@@ -843,18 +842,18 @@ rtm_read (struct rt_msghdr *rtm)
             {
               case ZEBRA_RIB_FOUND_EXACT:
                 zlog_debug ("%s: %s %s/%d: desync: RR is still in RIB, while already not in FIB",
-                  __func__, LOOKUP (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+                  __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
                 rib_lookup_and_dump (&p);
                 break;
               case ZEBRA_RIB_FOUND_CONNECTED:
               case ZEBRA_RIB_FOUND_NOGATE:
                 zlog_debug ("%s: %s %s/%d: desync: RR is still in RIB, plus gate differs",
-                  __func__, LOOKUP (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+                  __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
                 rib_lookup_and_dump (&p);
                 break;
               case ZEBRA_RIB_NOTFOUND: /* RIB RR == FIB RR */
                 zlog_debug ("%s: %s %s/%d: done Ok",
-                  __func__, LOOKUP (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+                  __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
                 rib_lookup_and_dump (&p);
                 return;
                 break;
@@ -862,7 +861,7 @@ rtm_read (struct rt_msghdr *rtm)
             break;
           default:
             zlog_debug ("%s: %s/%d: warning: loopback RTM of type %s received",
-              __func__, buf, p.prefixlen, LOOKUP (rtm_type_str, rtm->rtm_type));
+              __func__, buf, p.prefixlen, lookup (rtm_type_str, rtm->rtm_type));
         }
         return;
       }
@@ -1063,7 +1062,7 @@ rtm_write (int message,
 static void
 rtmsg_debug (struct rt_msghdr *rtm)
 {
-  zlog_debug ("Kernel: Len: %d Type: %s", rtm->rtm_msglen, LOOKUP (rtm_type_str, rtm->rtm_type));
+  zlog_debug ("Kernel: Len: %d Type: %s", rtm->rtm_msglen, lookup (rtm_type_str, rtm->rtm_type));
   rtm_flag_dump (rtm->rtm_flags);
   zlog_debug ("Kernel: message seq %d", rtm->rtm_seq);
   zlog_debug ("Kernel: pid %d, rtm_addrs 0x%x", rtm->rtm_pid, rtm->rtm_addrs);
index c903786b491f4be1de97de4a01c4dd757cbe702b..8f8a20756ed74c0d077f2b973fae7b3bdaa8461d 100644 (file)
@@ -29,6 +29,5 @@ extern int ifm_read (struct if_msghdr *);
 extern int rtm_write (int, union sockunion *, union sockunion *,
                       union sockunion *, unsigned int, int, int);
 extern struct message rtm_type_str[];
-extern int rtm_type_str_max;
 
 #endif /* __ZEBRA_KERNEL_SOCKET_H */
index 63e4612f3d9bcbdd6b4d1a6d2851daceb5e26528..1b8ded7eefaa13955e6183edb8c902f7b6f7e948 100644 (file)
@@ -211,14 +211,14 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
                if (!IS_ZEBRA_DEBUG_RIB)
                  inet_ntop (AF_INET, &p->u.prefix, prefix_buf, INET_ADDRSTRLEN);
                zlog_err ("%s: %s/%d: rtm_write() unexpectedly returned %d for command %s",
-                 __func__, prefix_buf, p->prefixlen, error, LOOKUP (rtm_type_str, cmd));
+                 __func__, prefix_buf, p->prefixlen, error, lookup (rtm_type_str, cmd));
                break;
            }
          } /* if (cmd and flags make sense) */
        else
          if (IS_ZEBRA_DEBUG_RIB)
            zlog_debug ("%s: odd command %s for flags %d",
-             __func__, LOOKUP (rtm_type_str, cmd), nexthop->flags);
+             __func__, lookup (rtm_type_str, cmd), nexthop->flags);
      } /* for (nexthop = ... */
  
    /* If there was no useful nexthop, then complain. */