diff options
-rw-r--r-- | lib/Makefile.am | 5 | ||||
-rw-r--r-- | lib/if_rmap.c | 7 | ||||
-rw-r--r-- | lib/zebra.h | 3 | ||||
-rw-r--r-- | ospfd/ospf_interface.c | 13 | ||||
-rw-r--r-- | ripngd/Makefile.am | 4 | ||||
-rw-r--r-- | ripngd/ripngd.c | 4 | ||||
-rw-r--r-- | vtysh/Makefile.am | 4 | ||||
-rwxr-xr-x | vtysh/extract.pl | 18 | ||||
-rw-r--r-- | zebra/ipforward_solaris.c | 130 |
9 files changed, 132 insertions, 56 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index dbd105aa..16e90b23 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -10,7 +10,7 @@ libzebra_a_SOURCES = \ print_version.c checksum.c vector.c linklist.c vty.c command.c \ sockunion.c prefix.c thread.c if.c memory.c buffer.c table.c hash.c \ filter.c routemap.c distribute.c stream.c str.c log.c plist.c \ - zclient.c sockopt.c smux.c md5.c keychain.c privs.c + zclient.c sockopt.c smux.c md5.c if_rmap.c keychain.c privs.c libzebra_a_DEPENDENCIES = @LIB_REGEX@ @LIBCAP@ @@ -20,7 +20,8 @@ noinst_HEADERS = \ buffer.h command.h filter.h getopt.h hash.h if.h linklist.h log.h \ memory.h network.h prefix.h routemap.h distribute.h sockunion.h \ str.h stream.h table.h thread.h vector.h version.h vty.h zebra.h \ - plist.h zclient.h sockopt.h smux.h md5-gnu.h keychain.h privs.h + plist.h zclient.h sockopt.h smux.h md5-gnu.h if_rmap.h keychain.h \ + privs.h EXTRA_DIST = regex.c regex-gnu.h diff --git a/lib/if_rmap.c b/lib/if_rmap.c index d3031fad..42271025 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -299,7 +299,8 @@ void if_rmap_init (int node) { ifrmaphash = hash_create (if_rmap_hash_make, if_rmap_hash_cmp); - - install_element (node, &if_rmap_cmd); - install_element (node, &no_if_rmap_cmd); + if (node == RIPNG_NODE) { + install_element (RIPNG_NODE, &if_rmap_cmd); + install_element (RIPNG_NODE, &no_if_rmap_cmd); + } } diff --git a/lib/zebra.h b/lib/zebra.h index c9aaf70d..6a60b94b 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -28,9 +28,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 short u_int8_t; #endif /* SUNOS_5 */ #ifndef HAVE_SOCKLEN_T diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 80538d57..a1b10c74 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -135,7 +135,10 @@ ospf_add_to_if (struct interface *ifp, struct ospf_interface *oi) p.prefixlen = IPV4_MAX_PREFIXLEN; rn = route_node_get (IF_OIFS (ifp), &p); - assert (! rn->info); + /* rn->info should either be NULL or equal to this oi + * as route_node_get may return an existing node + */ + assert (! rn->info || rn->info == oi); rn->info = oi; } @@ -422,7 +425,12 @@ ospf_if_lookup_recv_if (struct ospf *ospf, struct in_addr src) else { if (prefix_match (oi->address, (struct prefix *) &addr)) - match = oi; + { + if ( (match == NULL) || + (match->address->prefixlen < oi->address->prefixlen) + ) + match = oi; + } } } @@ -464,7 +472,6 @@ ospf_new_if_params () struct ospf_if_params *oip; oip = XMALLOC (MTYPE_OSPF_IF_PARAMS, sizeof (struct ospf_if_params)); - memset (oip, 0, sizeof (struct ospf_if_params)); if (!oip) return NULL; diff --git a/ripngd/Makefile.am b/ripngd/Makefile.am index a54b1159..fffc1e8a 100644 --- a/ripngd/Makefile.am +++ b/ripngd/Makefile.am @@ -9,10 +9,10 @@ sbin_PROGRAMS = ripngd libripng_a_SOURCES = \ ripng_interface.c ripngd.c ripng_zebra.c ripng_route.c ripng_debug.c \ - ripng_routemap.c ripng_ifrmap.c + ripng_routemap.c noinst_HEADERS = \ - ripng_debug.h ripng_route.h ripngd.h ripng_ifrmap.h + ripng_debug.h ripng_route.h ripngd.h ripngd_SOURCES = \ ripng_main.c $(libripng_a_SOURCES) diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 677f7bbc..0f12785d 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -38,11 +38,11 @@ #include "plist.h" #include "routemap.h" #include "privs.c" +#include "if_rmap.h" #include "ripngd/ripngd.h" #include "ripngd/ripng_route.h" #include "ripngd/ripng_debug.h" -#include "ripngd/ripng_ifrmap.h" #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -2530,7 +2530,7 @@ ripng_init () route_map_add_hook (ripng_routemap_update); route_map_delete_hook (ripng_routemap_update); - if_rmap_init (); + if_rmap_init (RIPNG_NODE); if_rmap_hook_add (ripng_if_rmap_update); if_rmap_hook_delete (ripng_if_rmap_update); } diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index 39b7cee0..7a21409f 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -16,9 +16,9 @@ sysconf_DATA = vtysh.conf.sample EXTRA_DIST = extract.pl vtysh.conf.sample rebuild4: - ./extract.pl ../zebra/*.c ../ripd/*.c ../ospfd/*.c ../bgpd/*.c ../lib/keychain.c ../lib/routemap.c ../lib/filter.c ../lib/plist.c ../lib/distribute.c > vtysh_cmd.c + ./extract.pl ../zebra/*.c ../ripd/*.c ../ospfd/*.c ../bgpd/*.c ../lib/keychain.c ../lib/routemap.c ../lib/filter.c ../lib/plist.c ../lib/distribute.c ../lib/if_rmap.c > vtysh_cmd.c rebuild: - ./extract.pl ../zebra/*.c ../ripd/*.c ../ripngd/*.c ../ospfd/*.c ../ospf6d/*.c ../bgpd/*.c ../lib/keychain.c ../lib/routemap.c ../lib/filter.c ../lib/plist.c ../lib/distribute.c > vtysh_cmd.c + ./extract.pl ../zebra/*.c ../ripd/*.c ../ripngd/*.c ../ospfd/*.c ../ospf6d/*.c ../bgpd/*.c ../lib/keychain.c ../lib/routemap.c ../lib/filter.c ../lib/plist.c ../lib/distribute.c ../lib/if_rmap.c > vtysh_cmd.c vtysh_cmd.c: rebuild diff --git a/vtysh/extract.pl b/vtysh/extract.pl index 2f1c8200..ca88cf7b 100755 --- a/vtysh/extract.pl +++ b/vtysh/extract.pl @@ -53,7 +53,7 @@ $ignore{'"show route-map"'} = "ignore"; foreach (@ARGV) { $file = $_; - open (FH, "cpp -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -I. -I.. -I../lib $file |"); + open (FH, "cpp -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -DHAVE_IPV6 -I. -I.. -I../lib $file |"); local $/; undef $/; $line = <FH>; close (FH); @@ -85,7 +85,7 @@ foreach (@ARGV) { $protocol = "VTYSH_RIPD"; } if ($file =~ /routemap.c/) { - $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD"; + $protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD"; } if ($file =~ /filter.c/) { if ($defun_array[1] =~ m/ipv6/) { @@ -96,11 +96,21 @@ foreach (@ARGV) { } if ($file =~ /plist.c/) { if ($defun_array[1] =~ m/ipv6/) { - $protocol = "VTYSH_RIPNGD|VTYSH_BGPD"; + $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD"; } else { - $protocol = "VTYSH_RIPD|VTYSH_BGPD"; + $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD"; } } + if ($file =~ /distribute.c/) { + if ($defun_array[1] =~ m/ipv6/) { + $protocol = "VTYSH_RIPNGD"; + } else { + $protocol = "VTYSH_RIPD"; + } + } + if ($file =~ /if_rmap.c/) { + $protocol = "VTYSH_RIPNGD"; + } } else { ($protocol) = ($file =~ /\/([a-z0-9]+)/); $protocol = "VTYSH_" . uc $protocol; diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c index 99b0e1a8..63d1110c 100644 --- a/zebra/ipforward_solaris.c +++ b/zebra/ipforward_solaris.c @@ -21,57 +21,117 @@ */ #include <zebra.h> +#include "log.h" -#include "memory.h" +/* +** Solaris should define IP_DEV_NAME in <inet/ip.h>, but we'll save +** configure.in changes for another day. We can use the same device +** for both IPv4 and IPv6. +*/ +/* #include <inet/ip.h> */ +#ifndef IP_DEV_NAME +#define IP_DEV_NAME "/dev/ip" +#endif +/* +** This is a limited ndd style function that operates one integer +** value only. Errors return -1. ND_SET commands return 0 on +** success. ND_GET commands return the value on success (which could +** be -1 and be confused for an error). The parameter is the string +** name of the parameter being referenced. +*/ -int -ipforward () +static int +solaris_nd(const int cmd, const char* parameter, const int value) { - int fd, ret; - int ipforwarding = 0; - char forward[] = "ip_forwarding"; - char *buf; - struct strioctl si; - - buf = (char *) XMALLOC (MTYPE_TMP, sizeof forward + 1); - strcpy (buf, forward); - - fd = open ("/dev/ip", O_RDWR); - if (fd < 0) { - free (buf); - /* need logging here */ - /* "I can't get ipforwarding value because can't open /dev/ip" */ +#define ND_BUFFER_SIZE 1024 + int fd; + char nd_buf[ND_BUFFER_SIZE]; + struct strioctl strioctl; + const char* device = IP_DEV_NAME; + int retval; + memset(nd_buf, '\0', ND_BUFFER_SIZE); + /* + ** ND_SET takes a NULL delimited list of strings further terminated + ** buy a NULL. ND_GET returns a list in a similar layout, although + ** here we only use the first result. + */ + if (cmd == ND_SET) { + snprintf(nd_buf, ND_BUFFER_SIZE, "%s%c%d%c", parameter, '\0', value,'\0'); + } else if (cmd == ND_GET) { + snprintf(nd_buf, ND_BUFFER_SIZE, "%s", parameter); + } else { + zlog_err("internal error - inappropriate command given to solaris_nd()%s:%d", __FILE__, __LINE__); return -1; } - - si.ic_cmd = ND_GET; - si.ic_timout = 0; - si.ic_len = strlen (buf) + 1; - si.ic_dp = (caddr_t) buf; - - ret = ioctl (fd, I_STR, &si); - close (fd); - - if (ret < 0) { - free (buf); - /* need logging here */ - /* can't get ipforwarding value : ioctl failed */ + strioctl.ic_cmd = cmd; + strioctl.ic_timout = 0; + strioctl.ic_len = ND_BUFFER_SIZE; + strioctl.ic_dp = nd_buf; + if ((fd = open (device, O_RDWR)) < 0) { + zlog_warn("failed to open device %s - %s", device, strerror(errno)); + return -1; + } + if (ioctl (fd, I_STR, &strioctl) < 0) { + close (fd); + zlog_warn("ioctl I_STR failed on device %s - %s", device,strerror(errno)); return -1; } + close(fd); + if (cmd == ND_GET) { + errno = 0; + retval = atoi(nd_buf); + if (errno) { + zlog_warn("failed to convert returned value to integer - %s",strerror(errno)); + retval = -1; + } + } else { + retval = 0; + } + return retval; +} - ipforwarding = atoi (buf); - free (buf); - return ipforwarding; +static int +solaris_nd_set(const char* parameter, const int value) { + return solaris_nd(ND_SET, parameter, value); +} +static int +solaris_nd_get(const char* parameter) { + return solaris_nd(ND_GET, parameter, 0); +} +int +ipforward() +{ + return solaris_nd_get("ip_forwarding"); } int ipforward_on () { - return 0; + (void) solaris_nd_set("ip_forwarding", 1); + return ipforward(); } int ipforward_off () { - return 0; + (void) solaris_nd_set("ip_forwarding", 0); + return ipforward(); +} +#ifdef HAVE_IPV6 +int ipforward_ipv6() +{ + return solaris_nd_get("ip6_fowarding"); +} +int +ipforward_ipv6_on () +{ + (void) solaris_nd_set("ip6_forwarding", 1); + return ipforward_ipv6(); +} +int +ipforward_ipv6_off () +{ + (void) solaris_nd_set("ip6_forwarding", 0); + return ipforward_ipv6(); } +#endif /* HAVE_IPV6 */ |