Browse Source

Merge 'patch-tracking/4/proposed/netdef-solaris' into accepted

Paul Jakma 4 years ago
parent
commit
283596fd6d

+ 1 - 1
bgpd/bgp_attr.c

@@ -1817,7 +1817,7 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
   /* same goes for as4_aggregator */
   struct aspath *as4_path = NULL;
   as_t as4_aggregator = 0;
-  struct in_addr as4_aggregator_addr = { 0 };
+  struct in_addr as4_aggregator_addr = { .s_addr = 0 };
 
   /* Initialize bitmap. */
   memset (seen, 0, BGP_ATTR_BITMAP_SIZE);

+ 1 - 1
bgpd/bgp_snmp.c

@@ -121,7 +121,7 @@ oid bgp_oid [] = { BGP4MIB };
 oid bgp_trap_oid [] = { BGP4MIB, 0 };
 
 /* IP address 0.0.0.0. */
-static struct in_addr bgp_empty_addr = {0};
+static struct in_addr bgp_empty_addr = { .s_addr = 0 };
 
 /* Hook functions. */
 static u_char *bgpVersion (struct variable *, oid [], size_t *, int,

+ 1 - 1
configure.ac

@@ -792,7 +792,7 @@ AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \
 	strtol strtoul strlcat strlcpy \
 	daemon snprintf vsnprintf \
 	if_nametoindex if_indextoname getifaddrs \
-	uname fcntl])
+	uname fcntl getgrouplist])
 
 AC_CHECK_FUNCS(setproctitle, ,
   [AC_CHECK_LIB(util, setproctitle, 

+ 13 - 12
isisd/isis_dlpi.c

@@ -174,7 +174,7 @@ dlpiok (int fd, t_uscalar_t oprim)
   dl_ok_ack_t *doa = (dl_ok_ack_t *)dlpi_ctl;
 
   retv = dlpirctl (fd);
-  if (retv < DL_OK_ACK_SIZE || doa->dl_primitive != DL_OK_ACK ||
+  if (retv < (ssize_t)DL_OK_ACK_SIZE || doa->dl_primitive != DL_OK_ACK ||
     doa->dl_correct_primitive != oprim)
     {
       return -1;
@@ -196,7 +196,7 @@ dlpiinfo (int fd)
   /* Info_req uses M_PCPROTO. */
   dlpisend (fd, &dir, sizeof (dir), NULL, 0, RS_HIPRI);
   retv = dlpirctl (fd);
-  if (retv < DL_INFO_ACK_SIZE || dlpi_ctl[0] != DL_INFO_ACK)
+  if (retv < (ssize_t)DL_INFO_ACK_SIZE || dlpi_ctl[0] != DL_INFO_ACK)
     return -1;
   else
     return retv;
@@ -251,7 +251,7 @@ dlpibind (int fd)
   dlpisend (fd, &dbr, sizeof (dbr), NULL, 0, 0);
 
   retv = dlpirctl (fd);
-  if (retv < DL_BIND_ACK_SIZE || dba->dl_primitive != DL_BIND_ACK)
+  if (retv < (ssize_t)DL_BIND_ACK_SIZE || dba->dl_primitive != DL_BIND_ACK)
     return -1;
   else
     return 0;
@@ -287,12 +287,13 @@ dlpiaddr (int fd, u_char *addr)
   dlpisend (fd, &dpar, sizeof (dpar), NULL, 0, 0);
 
   retv = dlpirctl (fd);
-  if (retv < DL_PHYS_ADDR_ACK_SIZE || dpaa->dl_primitive != DL_PHYS_ADDR_ACK)
+  if (retv < (ssize_t)DL_PHYS_ADDR_ACK_SIZE
+      || dpaa->dl_primitive != DL_PHYS_ADDR_ACK)
     return -1;
 
   if (dpaa->dl_addr_offset < DL_PHYS_ADDR_ACK_SIZE ||
     dpaa->dl_addr_length != ETHERADDRL ||
-    dpaa->dl_addr_offset + dpaa->dl_addr_length > retv)
+    dpaa->dl_addr_offset + dpaa->dl_addr_length > (size_t)retv)
     return -1;
 
   bcopy((char *)dpaa + dpaa->dl_addr_offset, addr, ETHERADDRL);
@@ -302,7 +303,7 @@ dlpiaddr (int fd, u_char *addr)
 static int
 open_dlpi_dev (struct isis_circuit *circuit)
 {
-  int fd, unit, retval;
+  int fd = -1, unit, retval;
   char devpath[MAXPATHLEN];
   dl_info_ack_t *dia = (dl_info_ack_t *)dlpi_ctl;
   ssize_t acklen;
@@ -403,8 +404,8 @@ open_dlpi_dev (struct isis_circuit *circuit)
     case DL_100BT:
       break;
     default:
-      zlog_warn ("%s: unexpected mac type on %s: %d", __func__,
-	circuit->interface->name, dia->dl_mac_type);
+      zlog_warn ("%s: unexpected mac type on %s: %lld", __func__,
+	circuit->interface->name, (long long)dia->dl_mac_type);
       close (fd);
       return ISIS_WARNING;
     }
@@ -556,13 +557,13 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
       return ISIS_WARNING;
     }
 
-  if (ctlbuf.len < DL_UNITDATA_IND_SIZE ||
+  if (ctlbuf.len < (ssize_t)DL_UNITDATA_IND_SIZE ||
     dui->dl_primitive != DL_UNITDATA_IND)
     return ISIS_WARNING;
 
   if (dui->dl_src_addr_length != ETHERADDRL + 2 ||
     dui->dl_src_addr_offset < DL_UNITDATA_IND_SIZE ||
-    dui->dl_src_addr_offset + dui->dl_src_addr_length > ctlbuf.len)
+    dui->dl_src_addr_offset + dui->dl_src_addr_length > (size_t)ctlbuf.len)
     return ISIS_WARNING;
 
   memcpy (ssnpa, (char *)dui + dui->dl_src_addr_offset +
@@ -588,9 +589,9 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
   int buflen;
 
   buflen = stream_get_endp (circuit->snd_stream) + LLC_LEN;
-  if (buflen > sizeof (sock_buff))
+  if ((size_t)buflen > sizeof (sock_buff))
     {
-      zlog_warn ("isis_send_pdu_bcast: sock_buff size %lu is less than "
+      zlog_warn ("isis_send_pdu_bcast: sock_buff size %zu is less than "
 		 "output pdu size %d on circuit %s",
 		 sizeof (sock_buff), buflen, circuit->interface->name);
       return ISIS_WARNING;

+ 1 - 0
isisd/topology/random.c

@@ -7,6 +7,7 @@
 /*                                                                   */
 /*********************************************************************/
 
+#include <zebra.h>
 #include <sys/types.h>
 #include <sys/times.h>
 

+ 1 - 0
isisd/topology/spacyc.c

@@ -1,3 +1,4 @@
+#include <zebra.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

+ 2 - 2
isisd/topology/spgrid.c

@@ -1,11 +1,11 @@
+#include <zebra.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "random.c"
 
-#include <zebra.h>
-
 #include "thread.h"
 #include "vty.h"
 #include "log.h"

+ 2 - 0
isisd/topology/sprand.c

@@ -1,3 +1,5 @@
+#include <zebra.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

+ 0 - 4
lib/getopt.c

@@ -30,10 +30,6 @@
 # define _NO_PROTO
 #endif
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
 #include <zebra.h>
 
 #if !defined __STDC__ || !__STDC__

+ 0 - 4
lib/getopt1.c

@@ -20,10 +20,6 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <zebra.h>
 #include "getopt.h"
 

+ 35 - 0
lib/privs.c

@@ -622,6 +622,41 @@ zprivs_state_null (void)
   return zprivs_null_state;
 }
 
+#ifndef HAVE_GETGROUPLIST
+/* Solaris 11 has no getgrouplist() */
+static int
+getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups)
+{
+  struct group *grp;
+  size_t usridx;
+  int pos = 0, ret;
+
+  if (pos < *ngroups)
+    groups[pos] = group;
+  pos++;
+
+  setgrent();
+  while ((grp = getgrent()))
+    {
+      if (grp->gr_gid == group)
+        continue;
+      for (usridx = 0; grp->gr_mem[usridx] != NULL; usridx++)
+        if (!strcmp (grp->gr_mem[usridx], user))
+          {
+            if (pos < *ngroups)
+              groups[pos] = grp->gr_gid;
+            pos++;
+            break;
+          }
+    }
+  endgrent();
+
+  ret = (pos <= *ngroups) ? pos : -1;
+  *ngroups = pos;
+  return ret;
+}
+#endif /* HAVE_GETGROUPLIST */
+
 void
 zprivs_init(struct zebra_privs_t *zprivs)
 {

+ 1 - 1
lib/stream.c

@@ -20,8 +20,8 @@
  * 02111-1307, USA.  
  */
 
-#include <stddef.h>
 #include <zebra.h>
+#include <stddef.h>
 
 #include "stream.h"
 #include "memory.h"

+ 1 - 1
lib/workqueue.c

@@ -21,7 +21,7 @@
  * 02111-1307, USA.  
  */
 
-#include <lib/zebra.h>
+#include <zebra.h>
 #include "thread.h"
 #include "memory.h"
 #include "workqueue.h"

+ 0 - 1
lib/zebra.h

@@ -27,7 +27,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
 #ifdef SUNOS_5
 #define _XPG4_2
-#define __EXTENSIONS__
 typedef unsigned int    u_int32_t;
 typedef unsigned short  u_int16_t;
 typedef unsigned char   u_int8_t;

+ 1 - 1
ospf6d/ospf6_snmp.c

@@ -628,7 +628,7 @@ ospfv3WwLsdbEntry (struct variable *v, oid *name, size_t *length,
   int len;
   oid *offset;
   int offsetlen;
-  struct ospf6_area *oa;
+  struct ospf6_area *oa = NULL;
   struct listnode *node;
   struct interface *iif;
   struct ospf6_interface *oi = NULL;

+ 1 - 0
ospfclient/Makefile.am

@@ -5,6 +5,7 @@ AM_CFLAGS = $(WERROR)
 
 lib_LTLIBRARIES = libospfapiclient.la
 libospfapiclient_la_LDFLAGS = -version-info 0:0:0
+libospfapiclient_la_LIBADD = ../ospfd/libospf.la ../lib/libzebra.la
 
 sbin_PROGRAMS = ospfclient
 

+ 1 - 0
ospfd/Makefile.am

@@ -7,6 +7,7 @@ INSTALL_SDATA=@INSTALL@ -m 600
 
 lib_LTLIBRARIES = libospf.la
 libospf_la_LDFLAGS = -version-info 0:0:0
+libospf_la_LIBADD = ../lib/libzebra.la
 
 sbin_PROGRAMS = ospfd
 

+ 2 - 2
ospfd/ospf_packet.c

@@ -644,8 +644,8 @@ ospf_write (struct thread *thread)
   struct listnode *node;
 #ifdef WANT_OSPF_WRITE_FRAGMENT
   static u_int16_t ipid = 0;
-#endif /* WANT_OSPF_WRITE_FRAGMENT */
   u_int16_t maxdatasize;
+#endif /* WANT_OSPF_WRITE_FRAGMENT */
 #define OSPF_WRITE_IPHL_SHIFT 2
   
   ospf->t_write = NULL;
@@ -659,7 +659,6 @@ ospf_write (struct thread *thread)
   /* seed ipid static with low order bits of time */
   if (ipid == 0)
     ipid = (time(NULL) & 0xffff);
-#endif /* WANT_OSPF_WRITE_FRAGMENT */
 
   /* convenience - max OSPF data per packet,
    * and reliability - not more data, than our
@@ -667,6 +666,7 @@ ospf_write (struct thread *thread)
    */
   maxdatasize = MIN (oi->ifp->mtu, ospf->maxsndbuflen) -
     sizeof (struct ip);
+#endif /* WANT_OSPF_WRITE_FRAGMENT */
   
   /* Get one packet from queue. */
   op = ospf_fifo_head (oi->obuf);

+ 1 - 1
ospfd/ospf_snmp.c

@@ -213,7 +213,7 @@ oid ospf_oid [] = { OSPF2MIB };
 oid ospf_trap_oid [] = { OSPF2MIB, 16, 2 }; /* Not reverse mappable! */
 
 /* IP address 0.0.0.0. */
-static struct in_addr ospf_empty_addr = {0};
+static struct in_addr ospf_empty_addr = { .s_addr = 0 };
 
 /* Hook functions. */
 static u_char *ospfGeneralGroup (struct variable *, oid *, size_t *,

+ 2 - 2
pimd/pim_cmd.c

@@ -20,10 +20,10 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
-#include <sys/ioctl.h>
-
 #include <zebra.h>
 
+#include <sys/ioctl.h>
+
 #include "command.h"
 #include "if.h"
 #include "prefix.h"

+ 2 - 0
pimd/pim_igmp_join.c

@@ -20,6 +20,8 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <string.h>

+ 2 - 0
pimd/pim_int.c

@@ -20,6 +20,8 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>

+ 2 - 1
pimd/pim_signals.c

@@ -20,9 +20,10 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include <signal.h>
 
-#include <zebra.h>
 #include "sigevent.h"
 #include "memory.h"
 #include "log.h"

+ 4 - 4
pimd/pim_sock.c

@@ -20,6 +20,7 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
 #include "pim_mroute.h"
 
 #include <sys/types.h>
@@ -31,7 +32,6 @@
 #include <netdb.h>
 #include <errno.h>
 
-#include <zebra.h>
 #include "log.h"
 #include "privs.h"
 
@@ -80,9 +80,9 @@ int pim_socket_mcast(int protocol, struct in_addr ifaddr, int loop)
   /* Needed to obtain destination address from recvmsg() */
   {
 #if defined(HAVE_IP_PKTINFO)
-    /* Linux IP_PKTINFO */
+    /* Linux and Solaris IP_PKTINFO */
     int opt = 1;
-    if (setsockopt(fd, SOL_IP, IP_PKTINFO, &opt, sizeof(opt))) {
+    if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &opt, sizeof(opt))) {
       zlog_warn("Could not set IP_PKTINFO on socket fd=%d: errno=%d: %s",
 		fd, errno, safe_strerror(errno));
     }
@@ -306,7 +306,7 @@ int pim_socket_recvfromto(int fd, uint8_t *buf, size_t len,
        cmsg = CMSG_NXTHDR(&msgh,cmsg)) {
 
 #ifdef HAVE_IP_PKTINFO
-    if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
+    if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
       struct in_pktinfo *i = (struct in_pktinfo *) CMSG_DATA(cmsg);
       if (to)
 	((struct sockaddr_in *) to)->sin_addr = i->ipi_addr;

+ 2 - 2
pimd/pim_ssmpingd.c

@@ -110,9 +110,9 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)
   /* Needed to obtain destination address from recvmsg() */
   {
 #if defined(HAVE_IP_PKTINFO)
-    /* Linux IP_PKTINFO */
+    /* Linux and Solaris IP_PKTINFO */
     int opt = 1;
-    if (setsockopt(fd, SOL_IP, IP_PKTINFO, &opt, sizeof(opt))) {
+    if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &opt, sizeof(opt))) {
       zlog_warn("%s: could not set IP_PKTINFO on socket fd=%d: errno=%d: %s",
 		__PRETTY_FUNCTION__, fd, errno, safe_strerror(errno));
     }

+ 3 - 1
pimd/pim_static.c

@@ -20,6 +20,8 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include "pim_static.h"
 #include "pim_time.h"
 #include "pim_str.h"
@@ -40,7 +42,7 @@ static struct static_route * static_route_alloc()
 
    s_route = XCALLOC(MTYPE_PIM_STATIC_ROUTE, sizeof(*s_route));
    if (!s_route) {
-     zlog_err("PIM XCALLOC(%lu) failure", sizeof(*s_route));
+     zlog_err("PIM XCALLOC(%u) failure", sizeof(*s_route));
      return 0;
    }
    return s_route;

+ 2 - 2
pimd/pim_str.c

@@ -20,12 +20,12 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 
-#include <zebra.h>
-
 #include "log.h"
 
 #include "pim_str.h"

+ 2 - 1
pimd/pim_time.c

@@ -20,11 +20,12 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include <string.h>
 #include <sys/time.h>
 #include <time.h>
 
-#include <zebra.h>
 #include "log.h"
 #include "thread.h"
 

+ 2 - 0
pimd/pim_version.c

@@ -20,6 +20,8 @@
   $QuaggaId: $Format:%an, %ai, %h$ $
 */
 
+#include <zebra.h>
+
 #include "pim_version.h"
 
 const char * const PIMD_VERSION = PIMD_VERSION_STR;

+ 2 - 0
tests/prng.c

@@ -23,6 +23,8 @@
  * 02111-1307, USA.
  */
 
+#include <zebra.h>
+
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>

+ 2 - 0
tests/test-cli.c

@@ -20,6 +20,8 @@
  * 02111-1307, USA.
  */
 
+#include <zebra.h>
+
 #include "common-cli.h"
 
 DUMMY_DEFUN(cmd0,  "arg ipv4 A.B.C.D");

+ 2 - 2
tests/test-timer-correctness.c

@@ -23,11 +23,11 @@
  * 02111-1307, USA.
  */
 
+#include <zebra.h>
+
 #include <stdio.h>
 #include <unistd.h>
 
-#include <zebra.h>
-
 #include "memory.h"
 #include "pqueue.h"
 #include "prng.h"

+ 3 - 2
tests/test-timer-performance.c

@@ -22,11 +22,12 @@
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#include <stdio.h>
-#include <unistd.h>
 
 #include <zebra.h>
 
+#include <stdio.h>
+#include <unistd.h>
+
 #include "thread.h"
 #include "pqueue.h"
 #include "prng.h"

+ 2 - 1
zebra/Makefile.am

@@ -39,7 +39,8 @@ testzebra_SOURCES = test_main.c zebra_rib.c interface.c connected.c debug.c \
 noinst_HEADERS = \
 	connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
 	interface.h ipforward.h irdp.h router-id.h kernel_socket.h \
-	rt_netlink.h zebra_fpm.h zebra_fpm_private.h
+	rt_netlink.h zebra_fpm.h zebra_fpm_private.h \
+	ioctl_solaris.h
 
 zebra_LDADD = $(otherobj) ../lib/libzebra.la $(LIBCAP)
 

+ 3 - 4
zebra/if_ioctl_solaris.c

@@ -33,15 +33,14 @@
 #include "vrf.h"
 
 #include "zebra/interface.h"
+#include "zebra/ioctl_solaris.h"
 #include "zebra/rib.h"
 
-void lifreq_set_name (struct lifreq *, const char *);
-int if_get_flags_direct (const char *, uint64_t *, unsigned int af);
 static int if_get_addr (struct interface *, struct sockaddr *, const char *);
 static void interface_info_ioctl (struct interface *);
 extern struct zebra_privs_t zserv_privs;
 
-int
+static int
 interface_list_ioctl (int af)
 {
   int ret;
@@ -210,7 +209,7 @@ end:
 }
 
 /* Get interface's index by ioctl. */
-int
+static int
 if_get_index (struct interface *ifp)
 {
   int ret;

+ 4 - 3
zebra/ioctl_solaris.c

@@ -32,6 +32,7 @@
 #include "zebra/rib.h"
 #include "zebra/rt.h"
 #include "zebra/interface.h"
+#include "zebra/ioctl_solaris.h"
 
 extern struct zebra_privs_t zserv_privs;
 
@@ -309,7 +310,7 @@ if_get_flags_direct (const char *ifname, uint64_t *flags, unsigned int af)
 void
 if_get_flags (struct interface *ifp)
 {
-  int ret4, ret6;
+  int ret4 = 0, ret6 = 0;
   uint64_t newflags = 0;
   uint64_t tmpflags;
 
@@ -410,7 +411,7 @@ if_prefix_add_ipv6 (struct interface *ifp, struct connected *ifc)
   char addrbuf[PREFIX_STRLEN];
 
   zlog_warn ("Can't set %s on interface %s",
-             prefix2str(ifc->address->prefix, addrbuf, sizeof(addrbuf)),
+             prefix2str(ifc->address, addrbuf, sizeof(addrbuf)),
              ifp->name);
 
   return 0;
@@ -423,7 +424,7 @@ if_prefix_delete_ipv6 (struct interface *ifp, struct connected *ifc)
   char addrbuf[PREFIX_STRLEN];
 
   zlog_warn ("Can't delete %s on interface %s",
-             prefix2str(ifc->address->prefix, addrbuf, sizeof(addrbuf)),
+             prefix2str(ifc->address, addrbuf, sizeof(addrbuf)),
              ifp->name);
 
   return 0;

+ 29 - 0
zebra/ioctl_solaris.h

@@ -0,0 +1,29 @@
+/*
+ * Interface looking up by ioctl () on Solaris.
+ * Copyright (C) 1999 Kunihiro Ishiguro
+ *
+ * This file is part of Quagga.
+ *
+ * Quagga is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * Quagga is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Quagga; see the file COPYING.  If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _ZEBRA_IF_IOCTL_SOLARIS_H
+#define _ZEBRA_IF_IOCTL_SOLARIS_H
+
+void lifreq_set_name (struct lifreq *, const char *);
+int if_get_flags_direct (const char *, uint64_t *, unsigned int af);
+
+#endif /* _ZEBRA_IF_IOCTL_SOLARIS_H */

+ 15 - 6
zebra/kernel_socket.c

@@ -70,6 +70,12 @@ extern struct zebra_t zebrad;
 #define ROUNDUP(a)	RT_ROUNDUP(a)
 #endif /* defined(RT_ROUNDUP) */
 
+#if defined(SUNOS_5)
+/* Solaris has struct sockaddr_in[6] definitions at 16 / 32 bytes size,
+ * so the whole concept doesn't really apply. */
+#define ROUNDUP(a)      (a)
+#endif
+
 /*
  * If ROUNDUP has not yet been defined in terms of platform-provided
  * defines, attempt to cope with heuristics.
@@ -134,6 +140,8 @@ extern struct zebra_t zebrad;
 static inline void
 rta_copy (union sockunion *dest, caddr_t src) {
   int len;
+  if (!dest)
+    return;
 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
   len = (((struct sockaddr *)src)->sa_len > sizeof (*dest)) ?
             sizeof (*dest) : ((struct sockaddr *)src)->sa_len ;
@@ -148,8 +156,7 @@ rta_copy (union sockunion *dest, caddr_t src) {
   if ((RTMADDRS) & (RTA)) \
     { \
       int len = SAROUNDUP ((PNT)); \
-      if ( ((DEST) != NULL) && \
-           af_check (((struct sockaddr *)(PNT))->sa_family)) \
+      if (af_check (((struct sockaddr *)(PNT))->sa_family)) \
         rta_copy((DEST), (PNT)); \
       (PNT) += len; \
     }
@@ -157,8 +164,7 @@ rta_copy (union sockunion *dest, caddr_t src) {
   if ((RTMADDRS) & (RTA)) \
     { \
       int len = SAROUNDUP ((PNT)); \
-      if ((DEST) != NULL) \
-        rta_copy((DEST), (PNT)); \
+      rta_copy((DEST), (PNT)); \
       (PNT) += len; \
     }
 
@@ -732,7 +738,9 @@ ifam_read (struct ifa_msghdr *ifam)
       /* Unset interface index from link-local address when IPv6 stack
 	 is KAME. */
       if (IN6_IS_ADDR_LINKLOCAL (&addr.sin6.sin6_addr))
-	SET_IN6_LINKLOCAL_IFINDEX (addr.sin6.sin6_addr, 0);
+        {
+          SET_IN6_LINKLOCAL_IFINDEX (addr.sin6.sin6_addr, 0);
+        }
 
       if (ifam->ifam_type == RTM_NEWADDR)
 	connected_add_ipv6 (ifp, flags, &addr.sin6.sin6_addr, 
@@ -1152,7 +1160,8 @@ rtmsg_debug (struct rt_msghdr *rtm)
   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);
+  zlog_debug ("Kernel: pid %lld, rtm_addrs 0x%x",
+              (long long)rtm->rtm_pid, rtm->rtm_addrs);
 }
 
 /* This is pretty gross, better suggestions welcome -- mhandler */

+ 6 - 0
zebra/rt_socket.c

@@ -41,6 +41,7 @@ extern int rtm_write (int message, union sockunion *dest,
                       union sockunion *mask, union sockunion *gate,
                       unsigned int index, int zebra_flags, int metric);
 
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
 /* Adjust netmask socket length. Return value is a adjusted sin_len
    value. */
 static int
@@ -63,6 +64,7 @@ sin_masklen (struct in_addr mask)
     len--;
   return len;
 }
+#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
 
 /* Interface between zebra message and rtm message. */
 static int
@@ -244,6 +246,7 @@ kernel_delete_ipv4 (struct prefix *p, struct rib *rib)
 
 #ifdef HAVE_IPV6
 
+#ifdef SIN6_LEN
 /* Calculate sin6_len value for netmask socket value. */
 static int
 sin6_masklen (struct in6_addr mask)
@@ -266,6 +269,7 @@ sin6_masklen (struct in6_addr mask)
 
   return len;
 }
+#endif /* SIN6_LEN */
 
 /* Interface between zebra message and rtm message. */
 static int
@@ -368,6 +372,8 @@ kernel_rtm_ipv6_multipath (int cmd, struct prefix *p, struct rib *rib,
 	  zlog_info ("kernel_rtm_ipv6_multipath(): nexthop %d add error=%d.",
 	    nexthop_num, error);
 	}
+#else
+      (void)error;
 #endif
 
       nexthop_num++;

+ 3 - 3
zebra/rtread_getmsg.c

@@ -156,13 +156,13 @@ route_read (struct zebra_vrf *zvrf)
 
 		/* This is normal loop termination */
 		if (retval == 0 &&
-			msgdata.len >= sizeof (struct T_optmgmt_ack) &&
+			(size_t)msgdata.len >= sizeof (struct T_optmgmt_ack) &&
 			TLIack->PRIM_type == T_OPTMGMT_ACK &&
 			TLIack->MGMT_flags == T_SUCCESS &&
 			MIB2hdr->len == 0)
 			break;
 
-		if (msgdata.len >= sizeof (struct T_error_ack) &&
+		if ((size_t)msgdata.len >= sizeof (struct T_error_ack) &&
 			TLIerr->PRIM_type == T_ERROR_ACK) {
 			zlog_warn ("getmsg(ctl) returned T_ERROR_ACK: %s",
 				safe_strerror ((TLIerr->TLI_error == TSYSERR)
@@ -174,7 +174,7 @@ route_read (struct zebra_vrf *zvrf)
 		   like what GateD does in this instance, but not
 		   critical yet. */
 		if (retval != MOREDATA ||
-			msgdata.len < sizeof (struct T_optmgmt_ack) ||
+			(size_t)msgdata.len < sizeof (struct T_optmgmt_ack) ||
 			TLIack->PRIM_type != T_OPTMGMT_ACK ||
 			TLIack->MGMT_flags != T_SUCCESS) {
 			errno = ENOMSG;