[quagga-dev 10291] FreeBSD 4.11 support -- patches included

Jim Carroll jim at carroll.com
Fri Mar 1 21:29:02 GMT 2013


We still require FreeBSD 4.11 in our production environment (I know, I
know.it's got a few whiskers). We were able to patch quagga-099.22 to run on
FreeBSD 4.11, and we wanted to share these back. The primary sequences of
patches have todo with the fact that the toolchain on 4.11 is based on GCC
2.95.4

 

Below are the patches to get Quagga to compile.

 

 

 

diff -brpwu quagga-0.99.22-ORIG/configure quagga-0.99.22-MODIFIED/configure

--- quagga-0.99.22-ORIG/configure       Sat Feb  9 21:29:42 2013

+++ quagga-0.99.22-MODIFIED/configure   Fri Mar  1 14:55:13 2013

@@ -4862,7 +4862,7 @@ if test "x${cflags_specified}" = "x" ; t

$as_echo "Intel default" >&6; }

         ;;

     "GCC")

-       CFLAGS="-Os -fno-omit-frame-pointer -g -std=gnu99 -Wall"

+       CFLAGS="-Os -fno-omit-frame-pointer -g -Wall"

        CFLAGS="${CFLAGS} -Wsign-compare -Wpointer-arith"

        CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings"

        CFLAGS="${CFLAGS} -Wmissing-prototypes -Wmissing-declarations"

diff -brpwu quagga-0.99.22-ORIG/lib/buffer.c
quagga-0.99.22-MODIFIED/lib/buffer.c

--- quagga-0.99.22-ORIG/lib/buffer.c    Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/lib/buffer.c        Fri Mar  1 14:43:21 2013

@@ -53,7 +53,12 @@ struct buffer_data

   size_t sp;

 

   /* Actual data stream (variable length). */

+#if defined(__FreeBSD__) && __FreeBSD__ == 4

+  unsigned char data[0];  /* real dimension is buffer->size */

+#else

   unsigned char data[];  /* real dimension is buffer->size */

+#endif

+

};

 

/* It should always be true that: 0 <= sp <= cp <= size */

@@ -77,10 +82,14 @@ buffer_new (size_t size)

     b->size = size;

   else

     {

-      static size_t default_size;

+      static size_t default_size = 0;

       if (!default_size)

         {

+#if defined(__FreeBSD__) && __FreeBSD__ == 4

+        long pgsz = getpagesize();

+#else

          long pgsz = sysconf(_SC_PAGESIZE);

+#endif

          default_size = ((((BUFFER_SIZE_DEFAULT-1)/pgsz)+1)*pgsz);

        }

       b->size = default_size;

@@ -148,7 +157,12 @@ buffer_add (struct buffer *b)

{

   struct buffer_data *d;

 

+#if defined(__FreeBSD__) && __FreeBSD__ == 4

+  // simulate the new style gcc offsetof

+  d = XMALLOC(MTYPE_BUFFER_DATA, offsetof(struct buffer_data, data) +
b->size);

+#else

   d = XMALLOC(MTYPE_BUFFER_DATA, offsetof(struct buffer_data,
data[b->size]));

+#endif

   d->cp = d->sp = 0;

   d->next = NULL;

diff -brpwu quagga-0.99.22-ORIG/lib/if.h quagga-0.99.22-MODIFIED/lib/if.h

--- quagga-0.99.22-ORIG/lib/if.h        Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/lib/if.h    Fri Mar  1 14:43:24 2013

@@ -109,7 +109,7 @@ struct interface

      * best with C aliasing rules. */

     struct sockaddr_dl sdl;

     struct sockaddr_storage sdl_storage;

-  };

+  } H;

#else

   unsigned short hw_type;

   u_char hw_addr[INTERFACE_HWADDR_MAX];

diff -brpwu quagga-0.99.22-ORIG/lib/prefix.c
quagga-0.99.22-MODIFIED/lib/prefix.c

--- quagga-0.99.22-ORIG/lib/prefix.c    Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/lib/prefix.c        Fri Mar  1 15:26:26 2013

@@ -471,10 +471,21 @@ u_char

ip_masklen (struct in_addr netmask)

{

   uint32_t tmp = ~ntohl(netmask.s_addr);

-  if (tmp)

+  if (tmp) {

     /* clz: count leading zeroes. sadly, the behaviour of this builtin

      * is undefined for a 0 argument, even though most CPUs give 32 */

+#if defined(__FreeBSD__) && __FreeBSD__ == 4

+       int ls = 0;

+

+       while (tmp != 0) {

+               ls++;

+               tmp >>= 1;

+               }

+       return 32 - ls;

+#else

     return __builtin_clz(tmp);

+#endif

+       }

   else

     return 32;

}

diff -brpwu quagga-0.99.22-ORIG/lib/zclient.c
quagga-0.99.22-MODIFIED/lib/zclient.c

--- quagga-0.99.22-ORIG/lib/zclient.c   Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/lib/zclient.c       Fri Mar  1 14:43:28 2013

@@ -734,7 +734,7 @@ zebra_interface_if_set_value (struct str

   ifp->mtu6 = stream_getl (s);

   ifp->bandwidth = stream_getl (s);

#ifdef HAVE_STRUCT_SOCKADDR_DL

-  stream_get (&ifp->sdl, s, sizeof (ifp->sdl_storage));

+  stream_get (&ifp->H.sdl, s, sizeof (ifp->H.sdl_storage));

#else

   ifp->hw_addr_len = stream_getl (s);

   if (ifp->hw_addr_len)

diff -brpwu quagga-0.99.22-ORIG/ospfd/ospf_api.c
quagga-0.99.22-MODIFIED/ospfd/ospf_api.c

--- quagga-0.99.22-ORIG/ospfd/ospf_api.c        Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/ospfd/ospf_api.c    Fri Mar  1 15:28:56 2013

@@ -68,7 +68,7 @@ api_opaque_lsa_print (struct lsa_header

   struct opaque_lsa

   {

     struct lsa_header header;

-    u_char mydata[];

+    u_char mydata[0];

   };

 

   struct opaque_lsa *olsa;

diff -brpwu quagga-0.99.22-ORIG/zebra/interface.c
quagga-0.99.22-MODIFIED/zebra/interface.c

--- quagga-0.99.22-ORIG/zebra/interface.c       Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/zebra/interface.c   Fri Mar  1 14:44:46 2013

@@ -723,7 +723,7 @@ if_dump_vty (struct vty *vty, struct int

 

   /* Hardware address. */

#ifdef HAVE_STRUCT_SOCKADDR_DL

-  sdl = &ifp->sdl;

+  sdl = &ifp->H.sdl;

   if (sdl != NULL && sdl->sdl_alen != 0)

     {

       int i;

diff -brpwu quagga-0.99.22-ORIG/zebra/kernel_socket.c
quagga-0.99.22-MODIFIED/zebra/kernel_socket.c

--- quagga-0.99.22-ORIG/zebra/kernel_socket.c   Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/zebra/kernel_socket.c       Fri Mar  1 14:44:48
2013

@@ -488,7 +488,7 @@ ifm_read (struct if_msghdr *ifm)

       if (ifnlen)

       {

#ifdef HAVE_STRUCT_SOCKADDR_DL_SDL_LEN

-       memcpy (&ifp->sdl, sdl, sdl->sdl_len);

+       memcpy (&ifp->H.sdl, sdl, sdl->sdl_len);

#else

        memcpy (&ifp->sdl, sdl, sizeof (struct sockaddr_dl));

#endif /* HAVE_STRUCT_SOCKADDR_DL_SDL_LEN */

@@ -948,13 +948,14 @@ rtm_read (struct rt_msghdr *rtm)

#ifdef HAVE_IPV6

   if (dest.sa.sa_family == AF_INET6)

     {

+      struct prefix_ipv6 p;

+      unsigned int ifindex = 0;

+

       /* One day we might have a debug section here like one in the

        * IPv4 case above. Just ignore own messages at the moment.

        */

       if (rtm->rtm_type != RTM_GET && rtm->rtm_pid == pid)

         return;

-      struct prefix_ipv6 p;

-      unsigned int ifindex = 0;

 

       p.family = AF_INET6;

       p.prefix = dest.sin6.sin6_addr;

@@ -1065,7 +1066,7 @@ rtm_write (int message,

             __func__, dest_buf, mask_buf, index);

           return -1;

         }

-      gate = (union sockunion *) & ifp->sdl;

+      gate = (union sockunion *) & ifp->H.sdl;

     }

 

   if (mask)

diff -brpwu quagga-0.99.22-ORIG/zebra/rt_socket.c
quagga-0.99.22-MODIFIED/zebra/rt_socket.c

--- quagga-0.99.22-ORIG/zebra/rt_socket.c       Thu Nov 22 05:22:35 2012

+++ quagga-0.99.22-MODIFIED/zebra/rt_socket.c   Fri Mar  1 14:44:49 2013

@@ -98,8 +98,8 @@ kernel_rtm_ipv4 (int cmd, struct prefix

   /* Make gateway. */

   for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)

     {

-      gate = 0;

       char gate_buf[INET_ADDRSTRLEN] = "NULL";

+      gate = 0;

 

       /*

        * XXX We need to refrain from kernel operations in some cases,

diff -brpwu quagga-0.99.22-ORIG/zebra/rtadv.c
quagga-0.99.22-MODIFIED/zebra/rtadv.c

--- quagga-0.99.22-ORIG/zebra/rtadv.c   Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/zebra/rtadv.c       Fri Mar  1 14:44:49 2013

@@ -314,7 +314,7 @@ rtadv_send_packet (int sock, struct inte

 

   /* Hardware address. */

#ifdef HAVE_STRUCT_SOCKADDR_DL

-  sdl = &ifp->sdl;

+  sdl = &ifp->H.sdl;

   if (sdl != NULL && sdl->sdl_alen != 0)

     {

       buf[len++] = ND_OPT_SOURCE_LINKADDR;

diff -brpwu quagga-0.99.22-ORIG/zebra/zserv.c
quagga-0.99.22-MODIFIED/zebra/zserv.c

--- quagga-0.99.22-ORIG/zebra/zserv.c   Sat Jan 26 21:25:34 2013

+++ quagga-0.99.22-MODIFIED/zebra/zserv.c       Fri Mar  1 14:44:50 2013

@@ -153,7 +153,7 @@ zserv_encode_interface (struct stream *s

   stream_putl (s, ifp->mtu6);

   stream_putl (s, ifp->bandwidth);

#ifdef HAVE_STRUCT_SOCKADDR_DL

-  stream_put (s, &ifp->sdl, sizeof (ifp->sdl_storage));

+  stream_put (s, &ifp->H.sdl, sizeof (ifp->H.sdl_storage));

#else

   stream_putl (s, ifp->hw_addr_len);

  if (ifp->hw_addr_len)

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20130301/bb549512/attachment-0001.html>


More information about the Quagga-dev mailing list