Skip to content

Commit 0ca729e

Browse files
committed
Add back Solaris support - initial commit
Builds on Solaris 11.4 with libyan (CESNET/libyang#2453): ./bootstrap.sh MAKE=gmake ./configure --disable-protobuf gmake gmake check
1 parent 3005868 commit 0ca729e

33 files changed

+1558
-46
lines changed

bfdd/bfdd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ distributed_bfd_init(const char *arg)
208208
union {
209209
struct sockaddr_in sin;
210210
struct sockaddr_in6 sin6;
211-
struct sockaddr_un sun;
211+
struct sockaddr_un un;
212212
} sa;
213213

214214
/* Basic parsing: find ':' to figure out type part and address part. */
@@ -236,9 +236,9 @@ distributed_bfd_init(const char *arg)
236236
if (strcmp(type, "unixc") == 0)
237237
is_client = true;
238238

239-
salen = sizeof(sa.sun);
240-
sa.sun.sun_family = AF_UNIX;
241-
strlcpy(sa.sun.sun_path, addr, sizeof(sa.sun.sun_path));
239+
salen = sizeof(sa.un);
240+
sa.un.sun_family = AF_UNIX;
241+
strlcpy(sa.un.sun_path, addr, sizeof(sa.un.sun_path));
242242
} else if (strcmp(type, "ipv4") == 0 || strcmp(type, "ipv4c") == 0) {
243243
if (strcmp(type, "ipv4c") == 0)
244244
is_client = true;

bfdd/dplane.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct bfd_dplane_ctx {
5151
struct sockaddr sa;
5252
struct sockaddr_in sin;
5353
struct sockaddr_in6 sin6;
54-
struct sockaddr_un sun;
54+
struct sockaddr_un un;
5555
} addr;
5656
/** Address length. */
5757
socklen_t addrlen;

bgpd/bgp_route.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14953,6 +14953,12 @@ static const char *table_stats_strs[][2] = {
1495314953
[BGP_STATS_MAX] = {NULL, NULL}
1495414954
};
1495514955

14956+
/* Avoid: error: braced-group within expression allowed only inside a function */
14957+
#ifdef __sun__
14958+
#undef MAX
14959+
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
14960+
#endif
14961+
1495614962
struct bgp_table_stats {
1495714963
struct bgp_table *table;
1495814964
unsigned long long counts[BGP_STATS_MAX];

bgpd/bgp_routemap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,10 +2294,12 @@ route_set_l3vpn_nexthop_encapsulation(void *rule, const struct prefix *prefix,
22942294

22952295
path = object;
22962296

2297+
#ifdef IPPROTO_GRE /* Solaris doesn't define IPPROTO_GRE */
22972298
if (rins->protocol != IPPROTO_GRE)
22982299
return RMAP_OKAY;
22992300

23002301
SET_FLAG(path->attr->rmap_change_flags, BATTR_RMAP_L3VPN_ACCEPT_GRE);
2302+
#endif
23012303
return RMAP_OKAY;
23022304
}
23032305

@@ -2310,7 +2312,9 @@ static void *route_set_l3vpn_nexthop_encapsulation_compile(const char *arg)
23102312
sizeof(struct rmap_l3vpn_nexthop_encapsulation_set));
23112313

23122314
/* XXX ALL GRE modes are accepted for now: gre or ip6gre */
2315+
#ifdef IPPROTO_GRE
23132316
rins->protocol = IPPROTO_GRE;
2317+
#endif
23142318

23152319
return rins;
23162320
}

configure.ac

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,13 +1164,6 @@ fi
11641164
dnl -------------------------
11651165
dnl Check other header files.
11661166
dnl -------------------------
1167-
AC_CHECK_HEADERS([ \
1168-
asm/types.h sys/endian.h])
1169-
1170-
AC_CHECK_HEADER([endian.h], [], [
1171-
AC_MSG_ERROR([missing endian.h])
1172-
])
1173-
11741167
AC_CHECK_LIB([atomic], [main], [LIBS="$LIBS -latomic"], [], [])
11751168

11761169
AC_CHECK_HEADER([stdatomic.h],[
@@ -1334,7 +1327,10 @@ is_linux=false
13341327
AC_MSG_CHECKING([which operating system interface to use])
13351328
case "$host_os" in
13361329
sunos* | solaris2*)
1337-
AC_MSG_FAILURE([Solaris support has been removed please see versions prior or equal to 7.5])
1330+
AC_MSG_RESULT([Solaris])
1331+
1332+
AC_DEFINE([SUNOS_5], [1], [Solaris])
1333+
AC_DEFINE([SOLARIS_IPV6], [1], Solaris IPv6)
13381334
;;
13391335
linux*)
13401336
AC_MSG_RESULT([Linux])

endian.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* substitution of system endina.h for Solaris */
2+
3+
#if !defined(__sun__)
4+
5+
#ifdef HAVE_SYS_ENDIAN_H
6+
#include <sys/endian.h>
7+
#endif
8+
#include <endian.h>
9+
10+
#else
11+
12+
#ifndef _ENDIAN_H
13+
#define _ENDIAN_H
14+
15+
#include <arpa/inet.h>
16+
#include <sys/types.h>
17+
#include <sys/byteorder.h>
18+
19+
// Numeric values commonly used for endian macros:
20+
#define LITTLE_ENDIAN 1234
21+
#define BIG_ENDIAN 4321
22+
#define PDP_ENDIAN 3412 // Rare, but occasionally referenced
23+
24+
#if defined(__sparc) || defined(__sparcv9)
25+
# define BYTE_ORDER BIG_ENDIAN
26+
# define __BYTE_ORDER BIG_ENDIAN
27+
#elif defined(__i386) || defined(__amd64) || defined(__x86_64)
28+
# define BYTE_ORDER LITTLE_ENDIAN
29+
# define __BYTE_ORDER LITTLE_ENDIAN
30+
#else
31+
# error "Unsupported architecture"
32+
#endif
33+
34+
// Byte swap wrappers, mapping to Solaris equivalents if used by your codebase
35+
#ifndef bswap_32
36+
# define bswap_32(x) BSWAP_32(x)
37+
#endif
38+
39+
#ifndef bswap_16
40+
# define bswap_16(x) BSWAP_16(x)
41+
#endif
42+
43+
#ifndef htobe64
44+
static inline uint64_t htobe64(uint64_t x) {
45+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
46+
return (((uint64_t)htonl(x & 0xFFFFFFFFULL)) << 32) | htonl(x >> 32);
47+
#else
48+
return x;
49+
#endif
50+
}
51+
#endif
52+
53+
#ifndef be64toh
54+
static inline uint64_t be64toh(uint64_t x) {
55+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
56+
return (((uint64_t)ntohl(x & 0xFFFFFFFFULL)) << 32) | ntohl(x >> 32);
57+
#else
58+
return x;
59+
#endif
60+
}
61+
#endif
62+
63+
#endif /* _ENDIAN_H */
64+
65+
#endif

isisd/isis_bpf.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636

3737
#include "privs.h"
3838

39+
#ifdef __sun__
40+
#include <sys/filio.h> /* for FIONREAD */
41+
#define ETHER_HDR_LEN 14
42+
#define ETHER_ADDR_LEN ETHERADDRL
43+
#endif
44+
3945
struct bpf_insn llcfilter[] = {
4046
BPF_STMT(BPF_LD + BPF_B + BPF_ABS,
4147
ETHER_HDR_LEN), /* check first byte */
@@ -270,10 +276,10 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level)
270276
*/
271277
eth = (struct ether_header *)sock_buff;
272278
if (level == 1)
273-
memcpy(eth->ether_dhost, ALL_L1_ISS, ETH_ALEN);
279+
memcpy(eth->ether_dhost.ether_addr_octet, ALL_L1_ISS, ETH_ALEN);
274280
else
275-
memcpy(eth->ether_dhost, ALL_L2_ISS, ETH_ALEN);
276-
memcpy(eth->ether_shost, circuit->u.bc.snpa, ETH_ALEN);
281+
memcpy(eth->ether_dhost.ether_addr_octet, ALL_L2_ISS, ETH_ALEN);
282+
memcpy(eth->ether_shost.ether_addr_octet, circuit->u.bc.snpa, ETH_ALEN);
277283
size_t frame_size = stream_get_endp(circuit->snd_stream) + LLC_LEN;
278284
eth->ether_type = htons(isis_ethertype(frame_size));
279285

isisd/isis_flags.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Institute of Communications Engineering
99
*/
1010

11+
#include <strings.h>
12+
1113
#include <zebra.h>
1214
#include "log.h"
1315
#include "linklist.h"

lib/event.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <signal.h>
1111
#include <sys/resource.h>
1212
#include <sys/stat.h>
13+
#ifdef __sun__
14+
#include <sys/loadavg.h>
15+
#endif
1316

1417
#include "frrevent.h"
1518
#include "memory.h"

lib/keychain_cli.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,16 @@ static long __timezone_offset(void)
173173

174174
time(&now);
175175
tm_now = localtime(&now);
176+
#if defined(__sun__)
177+
struct tm gm_tm;
178+
gmtime_r(&now, &gm_tm);
179+
gm_tm.tm_isdst = tm_now->tm_isdst;
180+
time_t local_time = mktime(tm_now);
181+
time_t gm_time = mktime(&gm_tm);
182+
return (long)difftime(local_time, gm_time);
183+
#else
176184
return tm_now->tm_gmtoff;
185+
#endif
177186
}
178187

179188
static int __lifetime_set(struct vty *vty, char timebuf[32],

0 commit comments

Comments
 (0)