diff options
164 files changed, 4787 insertions, 1649 deletions
@@ -17,13 +17,12 @@ config.status config.sub configure debian/build-stamp +debian/quagga debian/vyatta-quagga -debian/vyatta-quagga.substvars +debian/*.substvars debian/files -debian/vyatta-quagga.postinst.debhelper -debian/vyatta-quagga.postrm.debhelper -debian/vyatta-quagga.prerm.debhelper -debian/vyatta-quagga.debhelper.log +debian/*.debhelper +debian/*.log depcomp doc/defines.texi doc/mdate-sh diff --git a/ChangeLog b/ChangeLog index d526672c..cf5c774d 120000..100644 --- a/ChangeLog +++ b/ChangeLog @@ -1 +1,1990 @@ -debian/changelog
\ No newline at end of file +2008-07-22 Paul Jakma <paul.jakma@sun.com> + + * HACKING: Document preference for compiler conditional code, over + cpp conditional. + * configure.ac: DISABLE_BGP_ANNOUNCE always should be defined. + +2008-06-10 Paul Jakma <paul@jakma.org> + + * configure.ac: Bump version to 0.99.10 + +2008-05-29 Martin Nagy <mnagy@redhat.com> + + * */*main.c: Sanity check port numbers before using. + +2008-01-30 Peter Szilagyi <sp615@hszk.bme.hu> + + * lib/stream.h: Remove named 'new' parameter in prototype + for c++ header compatibility. + * ospfd/ospf_opaque.h: ditto + * ospfd/ospfd.h: Renamed struct export to _export for c++ + header compatibility. + * ospf6d/ospf6_area.h: ditto + +2008-01-11 Ingo Flaschberger <if@xip.at> + + * configure.ac: Improve HAVE_BSD_LINK_DETECT test. + +2008-01-10 Ingo Flaschberger <if@xip.at> + + * configure.ac: Define HAVE_BSD_LINK_DETECT if <net/if_media.h> is + present. + +2007-10-14 Paul Jakma <paul.jakma@sun.com> + + * NEWS: Note that MRT dumps are now version 2 + +2007-09-07 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump version to 0.99.9 + +2007-08-07 James Carlson <james.d.carlson@sun.com> + + * configure.ac: Added support for separate link-layer access + mechanisms in isisd. + +2007-07-27 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump version to 0.99.8 + +2007-06-25 Hasso Tepper <hasso@quagga.net> + + * configure.ac: Fix typo so it compiles again on BSD systems. + +2007-06-22 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: IRDP also depends on struct icmphdr, enabling + only on in_pktinfo breaks when an OS acquires pktinfo, as + Solaris NV has. Reported by Jim Carlson. + +2007-05-10 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Add back check for inet_aton, which got dropped + somehow in previous jumbo patch. + Use AC_GNU_SOURCE to define _GNU_SOURCE, rather than having + lib/zebra.h do it. + AC_FUNC_STRNLEN has side-effects with latest autoconf, use + AC_CHECK_FUNC on strnlen instead. + +2007-05-09 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: sys/conf.h depends on sys/param.h, at least on + FBSD 6.2. + (bug #363) Should check for in_pktinfo for IRDP + +2006-05-27 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: General cleanup of header and type checks, introducing + an internal define, QUAGGA_INCLUDES, to build up a list of + stuff to include so as to avoid 'present but cant be compiled' + warnings. + Misc additional checks of things missing according to autoscan. + Add LIBM, for bgpd's use of libm, so as to avoid burdening + LIBS, and all the binaries, with libm linkage. + Remove the bad practice of using m4 changequote(), just + quote the []'s in the case statements properly. + This should fix bugs 162, 303 and 178. + * */*.{c,h}: Update all HAVE_* to the standard autoconf namespaced + HAVE_* defines. I.e. HAVE_SA_LEN -> HAVE_STRUCT_SOCKADDR_SA_LEN, + * bgpd/Makefile.am: Add LIBM to bgpd's LDADD, for pow(). + +2007-04-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Change gcc CFLAGS from '-std=c99' to '-std=gnu99' + to improve portability. + +2007-04-29 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump to 0.99.7 + +2007-04-16 David Young <dyoung@pobox.com> + + * connected.c (zebra): Only suppress adding a connected + route to the kernel if it is already marked "real" + (ZEBRA_IFC_REAL), i.e., "in kernel." According to Paul + Jakma, this probably fixes Quagga bug #202. + +2007-02-06 Greg Troxel <Greg Troxel <gdt@ir.bbn.com>> + + * configure.ac: Use generic sed test, since autoconf 2.59 lacks + AC_PROG_SED and while 2.59 is somewhat crufty, it isn't officially + crufty. + +2007-02-06 Greg Troxel <Greg Troxel <gdt@ir.bbn.com> + + * bootstrap.sh: use -i to install missing files + +2007-02-03 Greg Troxel <Greg Troxel <gdt@ir.bbn.com> + + * configure.ac: add AC_PROG_SED + +2007-02-02 Greg Troxel <Greg Troxel <gdt@ir.bbn.com> + + * README.NetBSD: use bootstrap.sh instead of autoreconf + + * bootstrap.sh: new file with just 'autoreconf' + + * update-autotools: print out tool name before invoking to aid debugging + +2006-12-08 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump to 0.99.6 + +2006-10-04 Oliver Hookins <ohookins@gmail.com> + + * bgpd/bgp_main.c: Add configuration check option, with + '-C' rather than '-c' for consistency between daemons. + * isisd/isis_main.c: ditto + * ospf6d/ospf6_main.c: ditto + * ospfd/ospf_main.c: ditto + * ripngd/ripng_main.c: ditto + * vtysh/vtysh_main.c: ditto + * ripd/rip_main.c: Change the config check option to + '-C' and tidy up the code. + * zebra/main.c: ditto + +2006-10-04 Stergiakis Alexandros <astergiakis@antcor.com> + + * ripd/rip_main.c: This trivial patch introduces a new + command-line option '-c', which instructs zebra/ripd + to check its configuration file for validity, print + any error message, and then exit. This is useful when + the configuration file is edited by hand or otherwise, + and you simply want to validate it without any other + effect. + * zebra/main.c: ditto + +2006-08-27 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump to 0.99.5 + +2006-06-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.spec.in: Get default distro automatically + by using rpm to query the fedora-release version. + And fix a typo (should be default_dist, not dist_default). + +2006-05-28 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Update SOS CFLAGS, Xt shouldn't be used and + enable debug options. + Add a check for GNU Make and warn the user if it does not appear + to be the make used. + Check for Sun libc printstack(), add a general HAVE_STACK_TRACE + define for lib/log.c, if any supported stack symbol dumping + function is found (glibc backtrace/sun libc printstack). + +2006-05-10 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump to 0.99.4 + +2006-03-30 Paul Jakma <paul.jakma@sun.com> + + * TODO: Add reminder for useful MED functionality we should + implement. + +2006-02-15 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Check for mallinfo, being careful to link test + so we can detect things like umem being used (which doesn't + provide a mallinfo). + +2006-01-31 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Cleanup the hideous {net,ucd}-snmp section + by removing ucd-snmp. Hence fixing detection where + net-snmp is installed in /usr/local (Boris Kovalenko reported + the problem). + +2006-01-19 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Bump to 0.99.3 + +2005-11-26 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Collect together CFLAGS based on compiler + detected a bit. Recognise and set default CFLAGS for SunPro / + SOS10. + +2005-11-14 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Tell gcc we like C99. + [bug #231] Check and test for stdint.h. + +2005-11-11 Paul Jakma <paul.jakma@sun.com> + + * NEWS: Update. + * configure.ac: Bump to 0.99.2 + +2005-11-10 Paul Jakma <paul.jakma@sun.com> + + * HACKING: Add recommendation to provide a single Subject + style description to the commit message. + Add some recommendations for ChangeLog. + +2005-09-29 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Add the test for Solaris least-privileges. Set + defines for whether capabilities are supported and whether of + the linux or solaris variety. + Add missing-prototypes, missing-declarations, char-subscripts + and cast-qual warnings to default cflags, cause Hasso enjoys warnings, + and we really should clean the remaining ones up. (ie isisd..). + * (*/*main.c) Update the zebra_capabilities_t arrays in the various + daemons to match the changes made in lib/privs.h. + +2005-09-19 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Test existance of strndup. + +2005-08-25 Paul Jakma <paul@jakma.org> + + * configure.ac: Add -fno-omit-frame-pointer after -Os in default + cflags, just to be sure. + Fedora's readline library does not itself link to termcap, hence + we must pass the result of termcap tests in via OTHER-LIBRARIES + argument, otherwise the test of main in readline will fail due to + missing termcap systems. On systems like Debian, -ltermcap + is not needed for the readline test, because libreadline already + links to it. + +2005-08-25 Hasso Tepper <hasso at quagga.net> + + * configure.ac, vtysh/Makefile.am: Only vtysh needs to be linked + against libreadline and friends. + +2005-08-13 Paul Jakma <paul@jakma.org> + + * Makefile.am: (EXTRA_DIST) Add the trailing slash back in which + greg left out - tools bits weren't being included in dist, + which broke rpm builds :). + +2005-08-10 Greg Troxel <gdt@fnord.ir.bbn.com> + + * Makefile.am (EXTRA_DIST): add INSTALL.quagga.txt, because people + that patch releases need to know about autoconf required versions. + +2005-06-30 Louis Lagendijk <louis.lagendijk@gmail.com> + + * configure.ac: Actually test whether libc has IPv6 support. + +2005-06-28 Paul Jakma <paul.jakma@sun.com> + + * INSTALL.quagga.txt: GNU make is required now, because of manual + automatic rules in solaris/Makefile.am. (If someone knows how + to do these in a better way..). + GNU AWK is required for CVS checkout builds. + +2005-06-01 Paul Jakma <paul.jakma@sun.com> + + * NEWS: bgpd work queues and ripd auth-mode change + +2005-05-07 Yar Tikhiy <yar@comp.chem.msu.su> + + * configure.ac: Check for OSes which support passing ifindex in + struct ip_mreq. + +2005-04-29 Paul Jakma <paul.jakma@sun.com> + + * NEWS: Added some more 0.99 news. + * configure.ac: bump to 0.99.1 (0.99.0 was never released except + via CVS snapshots) + +2005-04-25 Paul Jakma <paul.jakma@sun.com> + + * HACKING: Add some notes about build system changes, to + document common oversights (common for me anyway). + Seperate sections with two newlines, easier to read. + +2005-04-16 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Added AC_ARG_ENABLE(time-check). By default, + warning messages will now be printed for threads or commands that take + longer than 5 seconds, but this configure argument can be used + to disable the checks or change the threshold. + +2005-04-16 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: check for gawk, needed to build memtypes.h + +2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Move AC_CANONICAL_* stuff before AM_INIT_AUTOMAKE to + eliminate warning message about AC_ARG_PROGRAM being called + before AC_CANONICAL_TARGET. + +2005-04-11 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Call AC_CANONICAL_{BUILD,TARGET} macros. Target isnt + set otherwise, afaict. AC_SUBST enable_{user,group,vty_group} and + quagga_statedir - the Solaris package bits for one need this. + configure the solaris/ Makefile. + * Makefile.am: solaris is a subdir - unconditional or else it wont + be included in non-solaris made dists. + +2005-04-10 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Fix host string recognition for Solaris Nevada aka + solaris2.10.1, and hopefully future such strings. + +2005-04-07 Paul Jakma <paul.jakma@sun.com> + + * (global): Fix up list loops to match changes in lib/linklist, + and some basic auditing of usage. + * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES + * HACKING: Add notes about deprecating interfaces and commands. + +2005-04-05 Paul Jakma <paul@dishone.st> + + * HACKING: remove the 'manually patch redhat/quagga.spec' bit + from RELEASE section. Let the rpm revision be CONFDATE, will work + fine. Expand on the importance of supplying good ChangeLog's in + the PATCH SUBMISSION section. + +2005-04-04 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Fix AC_LANG_SOURCE usage. It needs double square + brackets around source. Single ones broke square brackets in the + code (arrays). + +2005-04-03 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Use AC_RUN_IFELSE instead of obsolete AC_TRY_RUN macro + and define action for cross-compiling. + +2005-04-02 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Add --enable-isis-topology to enable isisd topology + generator code. + +2005-04-02 Paul Jakma <paul@dishone.st> + + * INSTALL.quagga.txt: Add note about additional CVS build + requirements, if one wishes to build ps/pdf docs. + +2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Add strnlen to AC_CHECK_FUNCS. + +2005-03-28 Hasso Tepper <hasso at quagga.net> + + * configure.ac, */Makefile.am: Fix previous commit. SNMP includes + must be after lib/ includes in some systems. Introduce SNMP_INCLUDES + for that. + +2005-03-28 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Fix most of "Presents But Cannot Compiled" warnings + about various headers. CFLAGS is not correct place to specify + includes, INCLUDES is for that. + +2005-03-27 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Add Intel compiler (icc) support. Although Intel + tries really hard to make icc look like gcc, there are some + differences. It's very verbose with -Wall and it doesn't support + the individual -W options. We are going to ignore some of these + warnings. + +2005-03-26 Hasso Tepper <hasso at quagga.net> + + * doc/defines.texi.in, lib/version.h.in: Update copyright string to + include year 2005. + +2005-03-25 Jean-Mickael Guerin <jean-mickael.guerin@6wind.com> + * configure.ac: add struct nd_opt_interval and struct + nd_opt_homeagent_info detection. + +2005-03-14 Paul Jakma <paul.jakma@sun.com> + + * (global) update all c files to match the lib/vector.h rename of + (struct vector).active to max, and vector_max macro to + vector_active. + +2005-03-12 Paul Jakma <paul.jakma@sun.com> + + * configure.ac: Solaris 8 can use the newer lifreq based methods + too, allows IPv6. + +2005-02-19 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Fix Linux detection. Host types like i686-pc-linux + didn't match the pattern. + +2005-02-09 Paul Jakma <paul.jakma@sun.com> + + * (global) Update code to match stream.h changes. + stream_get_putp effectively replaced with stream_get_endp. + stream_forward renamed to stream_forward_getp. + stream_forward_endp introduced to replace some previous + setting/manual twiddling of putp by daemons. + +2005-01-24 Paul Jakma <paul@dishone.st> + + * configure.ac: Bump version to 0.99.0 + +2005-01-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.spec.in: Fix postun script to avoid misleading error + message saying the postun scriptlet failed when watchquagga + is not running. + +2005-01-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Test for header file <ucontext.h> (for use in + signal processing). + +2005-01-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: If configure is invoked with --enable-snmp, but + the configure script is unable to find SNMP support on the platform, + then configure should give an error message and exit. + +2005-01-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.spec.in: Pass --enable-gcc-rdynamic to configure + to get gcc to link with -rdynamic for better backtraces. + When the rpm is upgraded, the restart logic now works as follows: + 1. stop watchquagga; 2. stop all routing daemons; 3. restart zebra + if it was running; 4. start all routing daemons that were running; + and 5. start watchquagga if it was running. + +2005-01-07 Paul Jakma <paul@dishone.st> + + * configure.ac: Bump version to 0.98.0 + +2005-01-05 Paul Jakma <paul@dishone.st> + + * configure.ac: Bump version to 0.97.5 + +2005-01-04 Greg Troxel <gdt@fnord.ir.bbn.com> + + * configure.ac: Use AC_MSG_CHECKING/AC_MSG_RESULT around + CMSG_FIRSTHDR check, so it shows up in the output of configure. + Tested on NetBSD, which doesn't define HAVE_BROKEN_CMSG_FIRSTHDR. + +2005-01-04 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Added test for broken CMSG_FIRSTHDR macro + (relevant for Solaris 8 and unpatched Solaris 9, don't know + whether other platforms are affected). + +2005-01-04 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * NEWS: Note improved logging facilities. + +2004-12-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Add new option --enable-gcc-rdynamic to link + with -rdynamic. + +2004-12-23 Paul Jakma <paul@dishone.st> + + configure.ac: Bump version to 0.97.4 + +2004-12-22 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.spec.in: daemonv6_list should contain only IPv6 daemons. + +2004-12-22 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.spec.in: Add watchquagga, and fix some other + logic to make sure that all daemons are restarted on upgrades + and stopped on package removal. + +2004-12-22 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.sysconfig: Define some variables to support watchquagga. + +2004-12-22 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * configure.ac: Add a define for DAEMON_VTY_DIR in config.h. + +2004-12-22 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * {configure.ac,Makefile.am}: Build watchquagga by default. + +2004-12-21 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * NEWS: Note addition of watchquagga. + * HACKING: Note that watchquagga is in testing phase. + +2004-12-21 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * watchquagga: New watchquagga daemon. + +2004-12-21 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/Makefile.am: Added watchquagga.init to EXTRA_DIST. + +2004-12-21 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/watchquagga.init: New file, init script for watchquagga. + +2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * HACKING: Indicate that header files should be consulted for + documentation, particularly logging levels in lib/log.h. + +2004-11-24 Paul Jakma <paul@dishone.st> + + * TODO: Add source routing, zebra filtering and lib/ documenting. + +2004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * global: Replace strerror with safe_strerror. And vtysh/vtysh.c + needs to include "log.h" to pick up the declaration. + +2004-11-19 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Avoid regeneration of doc/quagga.info for now. + +2004-11-17 Paul Jakma <paul@dishone.st> + + * INSTALL.quagga.txt: texinfo version corrected, so section on + that 4.7-x being unknown is not needed. + +2004-11-12 Paul Jakma <paul@dishone.st> + + * configure.ac: Fix AC_CONFIG_FILES, the chmod seems to run for + every input file, should be only be for vtysh/extract.pl, so that + should be a seperate AC_CONFIG_FILES. + * INSTALL: update-autotools, autoreconf -i will install this, remove + the file so it always matches the autoconf which created + configure (ie the quagga snapshot producing host). + * INSTALL.quagga.txt: Some quagga specific INSTALL notes. + * README: s/GNU Zebra/Quagga/ and refer to IS-IS support. + +2004-11-10 Andrew J. Schorr <ajschorr@alumni.princeton.edu> + + * redhat/quagga.spec.in: add comments showing how to get gcc verbosity + +2004-11-08 Paul Jakma <paul@dishone.st> + + * configure.ac: bump version to 0.97.3, release imminent. + +2004-11-06 Paul Jakma <paul@dishone.st> + + * configure.ac: Arguments to AC_OUTPUT is deprecated, use + AC_CONFIG_FILES instead. Rearrange the order slightly to put the + Makefiles first (silly aesthetic thing, dont know why I had to do + this ;) ). Add doc/defines.texi to the list. + * NEWS: bgp route-server support added, refer to docs. + * update-autotools: call automake with --add-missing and --copy, + former is important for obvious reasons, latter for dist files, + and --gnu to enable whatever extra goodness checks. + * {depcomp, install-sh, missing}: removed, auto-generated files. + +2004-11-05 Paul Jakma <paul@dishone.st> + + * HACKING: Expand on ChangeLogs, eg current practice for certain + directories and certain other meta-data is not to maintain a + ChangeLog. Expand on the commit message, IMHO, commit message + should always be ChangeLog for files where ChangeLog is kept. + Solaris is supported on any platform (with, at moment, an + additional patch). + +2004-10-23 Paul Jakma <paul@dishone.st> + + * configure.ac: bump version to 0.97.2, release imminent. + +2004-10-22 Paul Jakma <paul@dishone.st> + + * configure.ac: fix up enable help alignment slightly + Add --enable-gcc-ultra-verbose to set various gcc warnings which + should one day be fixed but are not serious problems or which + could be false-positives. + +2004-10-19 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * lib, zebra, ripd, ospfd, bgpd: Support NULL connected destination + pointers properly everywhere. Fix point-to-point logic to + support links where a dedicated subnet has been assigned. + PtP links with /31 subnets should now work where supported by O/S. + +2004-10-11 Paul Jakma <paul@dishone.st> + + * bump version to 0.97.1, release imminent. + +2004-10-07 Paul Jakma <paul@dishone.st> + + * bump version to 0.97.0, release imminent. + +2004-10-07 Greg Troxel <gdt@sunpal7.mit.edu> + + * configure.ac: remove -Wpacked; 2.95.3 doesn't support it. + +2004-10-05 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Removed -Wpadded. I don't have sooo much time that I + could care about padding ;). + +2004-09-30 Paul Jakma <paul@dishone.st> + + * Update default CFLAGS for gcc to keep Hasso busy. + +2004-09-27 Paul Jakma <paul@dishone.st> + + * update-autotools: libtoolize should copy files, rather than link. + the whole idea is that dist files should not need auto*, etc. + installed to be able to compile. + +2004-09-13 Hasso Tepper <hasso at quagga.net> + + * configure.ac: Disable isisd compiling by default. + +2004-09-13 Paul Jakma <paul@dishone.st> + + * configure.ac: capitalise the package name. autoconf lowercases + it for PACKAGE_TARNAME. + +2004-09-13 Jose Luis Rubio <jrubio@dit.upm.es> + (at Technical University of Madrid as part of Euro6ix Project) + + Enhanced Route Server functionality and Route-Maps: + + * bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to + support rs-clients. A 'struct bgp_table *rib' has been added to the + first (to mantain a separated RIB for each rs-client) and two new + route-maps have been added to the last (for import/export policies). + Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX}, + PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT. + + * bgpd/bgpd.c: Modified the functions that create/delete/etc peers in + order to consider the new fields included in 'struct peer' for + supporting rs-clients, i.e. the import/export route-maps and the + 'struct bgp_table'. + + * bgpd/bgp_route.{ch}: Modified several functions related with + receiving/sending announces in order to support the new Route Server + capabilities. + Function 'bgp_process' has been reorganized, creating an auxiliar + function for best path selection ('bgp_best_selection'). + Modified 'bgp_show' and 'bgp_show_route' for displaying information + about any RIB (and not only the main bgp RIB). + Added commands for displaying information about RS-clients RIBs: + 'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient + (A.B.C.D|X:X::X:X) X:X::X:X/M', etc + + * bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two + new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT}) + and 'void *owner' which points to 'struct bgp' or 'struct peer' which + owns the table. + When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set. + + * bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and + 'no neighbor ... route-server-client' now not only set/unset the flag + PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct + bgp_table' of the peer. Special actions are taken for peer_groups. + Command 'neighbor ... route-map WORD (in|out)' now also supports two + new kinds of route-map: 'import' and 'export'. + Added commands 'clear bgp * rsclient', etc. These commands allow a new + kind of soft_reconfig which affects only the RIB of the specified + RS-client. + Added commands 'show bgp rsclient summary', etc which display a + summary of the rs-clients configured for the corresponding address + family. + + * bgpd/bgp_routemap.c: A new match statement is available, + 'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in + import/export route-maps, and it matches when the peer who announces + (when used in an import route-map) or is going to receive (when used + in an export route-map) the route is the same than the one specified + in the statement. + For peer-groups the statement matches if the specified peer is member + of the peer-group. + A special version of the command, 'match peer local', matches with + routes originated by the Route Server (defined with 'network ...', + redistributed routes and default-originate). + + * lib/routemap.{ch}: Added a new clause 'call NAME' for use in + route-maps. It jumps into the specified route-map and when it returns + the first route-map ends if the called RM returns DENY_MATCH, or + continues in other case. + +2004-08-31 Greg Troxel <gdt@poblano.ir.bbn.com> + + * Makefile.am: make m4 as subdir, rather the EXTRA_DISTing it + + * configure.ac: add m4/Makefile to output list + +2004-08-31 Greg Troxel <gdt@poblano.ir.bbn.com> + + * Makefile.am: Only put pkgsrc dir in SUBDIRS if we should install + rc.d files. (Note that pkgsrc is always in DIST_SUBDIRS.) + + * configure.ac (pkgsrcdir): add new --enable-pkgsrcrcdir to give a + directory into which www.pkgsrc.org-style rc.d files are + installed. + +2004-08-19 Paul Jakma <paul@dishone.st> + + * Makefile.am: add m4 directory to EXTRA_DIST, and define + ACLOCAL_AMFLAGS to have aclocal pull in m4/ + * configure.ac: AM_PROG_LIBTOOL should be AC_... + * update-autotools: print a warning that this script is deprecated + +2004-08-17 Greg Troxel <gdt@fnord.ir.bbn.com> + + * update-autotools: print tools versions to aid people in sending + bug reports. + +2004-07-23 Greg Troxel <gdt@poblano.ir.bbn.com> + + * */Makefile.am: Use ../dir/libfoo.la, rather than "-L../dir + -lfoo", to avoid linking against installed libraries from a + previous version. + + * {lib,ospfd,ospfclient}/Makefile.am: explicitly define the shared + library version number to be 0.0 + + * configure.ac: remove spurious , so extract.pl is chmod'd +x. + + * HACKING: explain shared library versioning rules + +2004-07-22 Paul Jakma <paul@dishone.st> + + * configure.ac: modify default CFLAGS to be compiler agnostic + build Makefile for tests/ subdir. + +2004-07-14 Greg Troxel <gdt@poblano.ir.bbn.com> + + * Makefile.am (EXTRA_DIST): Add missing \, so tools stuff is + really in distfile. + +2004-06-30 Greg Troxel <gdt@poblano.ir.bbn.com> + + * */Makefile.am: use -L../lib -lzebra, so we pick up the shlib + version of libzebra when available. + + * configure.ac, update-autotools: Add libtool. + +2004-06-30 Greg Troxel <gdt@poblano.ir.bbn.com> + + * Makefile.am: add files to EXTRA_DIST rather than copying, and + omit the kludgy cleaning steps, which were failing when the list + to clean was empty. + +2004-06-30 Greg Troxel <gdt@poblano.ir.bbn.com> + + * configure.ac: Look for perl, and substitute into vtysh/extract.pl. + Search for termcap functions more expansively (fixes vtysh compile + on NetBSD). Clean up --enable-vtysh definition. + +2004-06-30 Greg Troxel <gdt@poblano.ir.bbn.com> + + * update-autotools: Use -rf on autom4te.cache. + +2004-06-20 Hasso Tepper <hasso@estpak.ee> + + * lib/vty.c: Don't attempt to load configuration file from current + directory. + * Update vty_read_config() calls in bgpd/bgp_main.c, isisd/isis_main.c, + ospf6d/ospf6_main.c, ospfd/ospf_main.c, ripd/rip_main.c, + ripngd/ripng_main.c and zebra/main.c. + +2004-05-11 Paul Jakma <paul@dishone.st> + + * configure.ac: Add solaris support for the zebra/*_solaris + method's, based on Sowmini's patches. + +2004-04-08 Paul Jakma <paul@dishone.st> + + * ospf_spf.h: Add backlink field to struct vertex + * ospf_spf.h: (ospf_vertex_new) initialise backlink + (ospf_lsa_has_link) return index of link back to + vertex V from candidate vertex W, or -1 if no link exists. + (ospf_spf_next) save backlink index for candidate vertex + * ospf_interface.c: (ospf_vl_set_params) Use the backlink index + to determine correct address for virtual-link peers. Fall back + to older "pick first link" method if no backlink index exists. + +2004-04-06 Hasso Tepper <hasso@estpak.ee> + + * zebra/ipforward_proc.c: Fixed lowering privileges. + * zebra/zserv.c: Fixed "(no) ipv6 forwarding" command logic. + * configure.ac: Added --disable-capabilities switch to configure. + +2004-03-22 Hasso Tepper <hasso@estpak.ee> + + * Readded SIGTERM handling so daemons can clean up their stuff if they + are killed (not murdered). + +2004-03-20 Michael Bruening <mike@vailsys.com> + + * ospfd/ospf_vty.c: Completed array distribute_str of route types with + addition of "isis". This array must be indexed by + ZEBRA_ROUTE_(SYSTEM|KERNEL|...) defines in zebra.h, and should + be updated with every route type addition. This fix allows + commands redistributing routes from (bgp|isis), like "router ospf + redistribute bgp ...", to be written to terminal, memory, file, + which would otherwise result in a seg fault or, possibly, config + file corruption. Overlooked in import of isisd. + * Similar fixes to bgpd/bgp_vty.c ospf6d/ospf6_asbr.c ripd/rip_zebra.c + and ripngd/ripng_zebra.c. + +2004-03-17 Jean-Yves Simon <lethalwp@tiscali.be> + + * zebra/main.c, ripd/rip_main.c: Fix typos sigusr1 -> sigint, + bugzilla #82. + +2004-03-16 David Young <dyoung@pobox.com> + + * (many) reference <lib/version.h> rather than "version.h", + because version.h is a generated file and not present in the + source tree when using objdir builds. + +2004-03-03 PC Drew <pc@superiorcomm.net> + + * lib/keychain.c: typecast time_t function to long, fixes compile + warning. + * lib/debug.c: wrapped function with ifdef HAVE_GLIBC_BACKTRACE fixes + compile warning when backtrace doesn't exist for that system. + * zebra/rtadv.c: for OpenBSD, added include statement for + netinet/icmp6.h + * zebra/zserv.c: added default case to switch statements, fixes compile + warning about certain NEXTHOP_TYPE enumeration values not being + handled. + * zebra/rt_socket.c: set *mask = NULL by default, fixes compile + warning, about mask possibly being used uninitialized. + * bgpd/bgp_nexthop.c: added default case to switch statements, fixes + compile warning about certain NEXTHOP_TYPE enumeration values not + being handled. + * ospfd/ospf_spf.c: typecast time_t to long, fixes compile warning. + * ospfd/ospf_route.c: typecast route_node->prefix to prefix_ipv4, fixes + compile warning. + * ospfd/ospf_route.c: typecast prefix_ipv4 to prefix, fixes compile + warning. + * ospfd/ospf_abr.c: typecast prefix to prefix_ipv4 in two instances, + fixes compile warning. + * vtysh/vtysh.c: fixed null pointer sentinel value when doing execl and + friends, fixes compile warning. + * ospf6d/ospf6_damp.c: typecast time_t to long in 4 instances, fixes + compile warning. + * ospf6d/ospf6_main.c: use MAXPATHLEN (if set) instead of 64 for the + _cwd array, fixes compile warning. + +2004-01-19 Paul Jakma <paul@dishone.st> + + * tests/test-sig.c: New file, regression test for sigevents. + * lib/Makefile.am: add sigevent.{c,h} + * (isis|rip|ripng|ospf|ospf6|bgp)d/\1_main.c: modify for sigevents. + * zebra/main.c: ditto. + +2004-01-10 Paul Jakma <paul@dishone.st> + + * Makefile.am: redhat/ is a dist subdir too. + +2004-01-10 Vincent Jardin <jardin@6wind.com> + + * configure.ac: add the redhat/Makefile as a AC_OUTPUT() argument. + It fixes build on FreeBSD 5.1 and FreeBSD 4.7 + +2004-01-08 Paul Jakma <paul@dishone.st> + + * Makefile.am: as per gdt, specify the redhat dir as a DIST_SUBDIR, + remove the redhat/... dist targets - instead these now go in.. + redhat/Makefile.am: (new) proper place to describe redhat/ dist + files, as well as allow quagga.spec to be regenerated properly. + redhat/quagga.sysconfig: specify conf file location. + redhat/quagga.spec.in: Add 2 patches to RPM build. + +2003-12-30 Paul Jakma <paul@dishone.st> + + * redhat/isisd.init: new file, init script for isisd. + redhat/quagga.sysconfig: new file, sysconfig file for quagga + initscripts. + redhat/quagga.spec.in: various cleanups, including sysconfig patch + from RH, fixed UID/GID as per RH EL, shell changed to + /sbin/nologin, daemon vty's listen to 127.1 only per default and + isisd packaged. + redhat/*.init: sysconfig support and runlevels specified. + +2003-12-30 Paul Jakma <paul@dishone.st> + + * Makefile.am: put the redhat/ stuff into EXTRA_DIST rather than + copying via dist-hook. Remove ~ files backup cruft from dists. + isisd/Makefile.am: sysconf example should go via + dist_examples_DATA. The include-netbsd/ headers werent mentioned + as sources and werent being copied into dists. + +2003-12-23 Vincent Jardin <jardin@6wind.com> + + * isisd: Import isisd from Sampo Saaristo's source code. + +2003-12-22 Christian Hammers <ch@lathspell.de> + + * configure.ac (and everywhere a regular file is opened for + writing): use file permissions from configure rather than + compiled-in umask. + +2003-12-22 Hasso Tepper <hasso@estpak.ee> + + * lib/linklist.c: Revert microfix I commited while reverting + [quagga-dev 227]. Caused by misreading code. + +2003-12-21 Hasso Tepper <hasso@estpak.ee> + + * lib/linklist.c: Revert patch [quagga-dev 227]. listnode_add_sort() + function should not drop nodes in any case. But fix behavior where + nodes were added to the end of list when cmp returned 0. + * lib/if.c: Check for duplicates before calling listnode_add_sort(). + +2003-12-08 Greg Troxel <gdt@fnord.ir.bbn.com> + + * {lib,ospfd,ospfapi}/Makefile.am: Use pkginclude_HEADERS rather + than include_HEADERS to place includes in + ${prefix}/include/quaggainstead of polluting ${prefix}/include. + +2003-12-04 Greg Troxel <gdt@poblano.ir.bbn.com> + + * configure.ac: When setting exampledir to sysconfdir as a + default, don't quote ${sysconfdir}. (Bug reported by Vincent + Jardin.) + +2003-12-03 Greg Troxel <gdt@poblano.ir.bbn.com> + + * configure.ac: Compile in Router Advertisement support by + default. Note that this does not default to sending RAs; it just + makes 'ipv6 nd send-ra' and 'ipv6 nd prefix-advertisement' + available. While others may prefer other tools, no argument has + been made that router advertisement support is such bloat that it + should be compiled out by default (it 9556 bytes on NetBSD/i386 vs + 8 bytes with the support compiled out). This reversion of a + previous change was done in consultation with Paul. + +2003-12-03 Greg Troxel <gdt@poblano.ir.bbn.com> + + * configure.ac: Move tests for v6 header files to after the check + for v6 code version, and conditionalize on the right variable. + (Fixes problem where v6 header files are not included when v6 is + enabled implicitly.) + +2003-12-03 Greg Troxel <gdt@poblano.ir.bbn.com> + + * configure.ac: Add --enable-exampledir to specify where example + config files should go, defaulting to sysconfdir. + + * */Makefile.am: use exampledir instead of sysconfdif for examples + +2003-11-02 Paul Jakma <paul@dishone.st> + + * bgpd/bgp_routemap.c: Fix up 'set ip next-hop A.B.C.D|peer-address' + route map command so that vtysh can use it. Modified version of + Hasso Tepper's patch. Fixes bug #52. + * configure.ac: FreeBSD has net-snmp in /usr/local. + * redhat/quagga.spec.in: Install libzebra headers with -devel + package. + +2003-11-02 Krzysztof Oledzki <oleq@ans.pl> + + * zebra/zebra_rib.c: Revert patch (dating from zebra.org) which + caused zebra to read all routes in all tables, rather than just + the main table. See [quagga-dev 280]. + +2003-10-30 Paul Jakma <paul@dishone.st> + + * configure.ac: netinet/in_systm.h is yet another well-known + header file we really should be checking for + +2003-10-27 kamatchi soundaram <kamatchi@tdd.sj.nec.com> + + * ospfd/ospfd.c: Do not increment act_int for an area, as it is done + by ospf_ism.c::ism_change_state() - results in incorrect figure + for active interfaces in an area. + +2003-10-27 Paul Jakma <paul@dishone.st> + + * lib/if.{ch}: remove ifc_pointtopoint() - left over from the + reverted RFC3021 patch. + +2003-10-27 Simon <lists@routemeister.net> + + * ospfd/ospfd.c: if_is_pointopoint() takes (struct interface *), was + being called with struct connected. Change to co->ifp. + +2003-10-27 Gilad Arnold <gilad.arnold@terayon.com> + + * zebra/zebra_rib.c: (nexthop_active_update) Check for multipath + limit when setting changed flag to avoid spurious changes. + (static_install_ipv{4,6}) dont uninstall by default, might not be + required - avoid spurious uninstalls. + (static_uninstall_ipv{4,6}) only uninstall the route if its + actually FIB route. + +2003-10-24 sowmini.varadhan@sun.com + + * ospfd/ospf_network.c: (ospf_sock_init) Exit if socket can not be + created. + +2003-10-24 Jose Luis Rubio Guivernau <jrubio@dit.upm.es> + + * Better 'show bgp' support for views (eg ipv6), see [quagga-dev 238] + * bgpd/bgp_route.c: (bgp_show) Take a struct bgp argument instead of + view string. + (bgp_show_neighbor_route) Take a struct peer argument instead of + ip string. + (peer_adj_routes) ditto + (show_adj_routes) ditto + (peer_lookup_in_view) new function to return appropriate struct + peer for a given view string. + (misc) Fixup all calls to above to reflect new calling arguments, + and use peer_lookup_in_view as needed. Additional commands + installed to use expanded functionality above, existing commands + modified to suit as well. + * bgpd/bgp_vty.c: 2 new aliases. + +2003-10-24 Paul Jakma <paul@dishone.st> + + * configure.ac: Check for fcntl() + * {bgpd,ospf,ospf6d,ripd,ripngd}/Makefile.am: Install conf file via + regular automake means, not magic install incantations, see + bug #38. + * lib/Makefile.am: install the headers, needed to link libzebra.a + (and hence libospf.a, OSPF-API, etc.) + +2003-10-24 waldi@debian.org + + * vtysh/Makefile.am: vtysh_cmd.c rebuild was broken because it + depended against source files without specification, i.e. it + used ../zebra instead of $(top_srcdir)/zebra. + +2003-10-23 Paul Jakma <paul@dishone.st> + + * configure.ac: IRIX configure.ac support. Sort of works. + sysctl() crashes though (ipforward), there's some kind of odd + padding in the PF_ROUTE socket messages and setsockopt() on + SOCK_RAW does not work (so ospfd doesnt work). + +2003-10-22 Paul Jakma <paul@dishone.st> + + * vtysh/Makefile.am: do not include vtysh_cmd.c in dists, its + configure dependent. (still need to find a way to make building of + it dependent on configure options or include all commands.) + +2003-10-22 Paul Jakma <paul@dishone.st> + + * lib/zebra.h: include limits.h if its there, its a portable header + and useful and not just solaris specific. net/route.h is also + useful. + +2003-10-22 Paul Jakma <paul@dishone.st> + + * lib/regex.c: bzero -> memset + * zebra/ioctl.c: ditto. bzero is not portable. + +2003-10-22 Paul Jakma <paul@dishone.st> + + * zebra/kernel_socket.c: HAVE_IPV6 conditional for WRAPUP when + HAVE_SA_LEN is not defined. bcopy -> memcpy, bcopy is not + portable. + +2003-10-22 Paul Jakma <paul@dishone.st> + + * configure.ac: Split up header checks into non-net, net and ipv6 + related. Checking of IPv6 is conditional. Add some more output + text for the end of the configure run. + +2003-10-18 Lorenzo Colitti <lorenzo@ripe.net> + + * bgpd/bgp_attr.c: (bgp_dump_routes_attr) Dont dump IPv4 nexthop + for IP. Dump MP_NLRI attr with IPv6 next-hop for AF_INET6 address + family prefixes. Accept prefix as argument. + * bgpd/bgp_attr.c: modify bgp_dump_routes_attr declaration. + * bgpd/bgp_dump.c: (bgp_dump_routes_entry) Modify calls to + bgp_dump_routes_attr. + (bgp_dump_common) Go by the family of the peering socket, not + configured address family when dumping peering information. + Add HAVE_IPV6 conditionals, eg missing from previous bgp interval + patch. + +2003-10-18 Lorenzo Colitti <lorenzo@ripe.net> + + * bgpd/bgp_dump.{c,h}: (bgp_dump_interval_add) Dump at discrete + fixed intervals rather than fixed intervals from startup time. + (bgp_dump_interval_func) Dont return immediately if file cant be + openeded, but reschedule interval dumps, even - admin might + fix problem in meantime. Close the dump file in between intervals. + (bgp_dump_init) account for MSG header when initialising stream + size. + +2003-10-15 Paul Jakma <paul@dishone.st> + + * ospfd/ospf_interface: (ospf_if_lookup_table) new function to + lookup oi for a given prefix in a given interfaces table of oi's. + (ospf_if_new) use ospf_if_lookup_table to deal with zebra + reporting new interface multiple times. + NB: This patch is a complete plaster-band of a hack. First, why is + zebra reporting interface events multiple times? Second, why does + ospfd maintain so many damn lists and tables relating to oi's - + these should be reconciled into one or two tables. + +2003-10-15 sowmini.varadhan@sun.com + + * ripd/ripd.c: (rip_send_packet) use rip->sock for mcast sends, + instead of creating one socket per send. send source addr to + rip_update_interface. + (rip_update_process) should send an update on every connected + network for each interface. + (rip_request_send) should send a request on every connected + network for each interface. + * ripd/ripd.h: update prototype for rip_interface_multicast_set + * ripd/rip_interface.c: (rip_interface_multicast_set) reorganized + so that it can be called repeatedly for aliased interfaces (on + multiple networks). + +2003-10-15 Jay Fenlason <fenlason@redhat.com> + + * lib/vty.c: (vty_telnet_option) Remote DoS exists if a telnet + end-sub-negotation is sent when no sub-negotation data has been + sent. Return immediately if no sub-negotation is in progress. + (vty_read) do not attempt to process options if no sub-negotation + is in progress. + +2003-10-15 Paul Jakma <paul@dishone.st> + + * lib/vty.c: (vty_save_cwd) dont crash if getcwd fails. try fallback + to SYSCONFDIR. Allocate cwd from the stack rather than relying on + (non-portable) getcwd() allocation (which we didnt seem to be + freeing). + +2003-10-13 Jay Fenlason <fenlason@redhat.com> + + * lib/zebra.h: define UINT32_MAX for those systems which do not + provide it. + * bgp_attr.h: define BGP_MED_MAX. + * bgp_route.c: update defines/constants to BGP_MED_MAX. + * bgp_routemap.c: ditto. clean up route_match_metric_compile + slightly to avoid unneccesary XMALLOC. + +2003-10-13 sowmini.varadhan@sun.com + + * ospf_lsa.h: Add OSPF_LSA_PREMATURE_AGE flag. + * ospf_lsa.c: added better debug comments. check sequence number in + ospf_lsa_install. ospf_maxage_lsa_remover() checks for + OSPF_LSA_PREMATURE_AGE and re-originates the lsa after ls_acks are + received. + * ospf_flood.c: improve debug statement- print ls_seqnum. + +2003-10-13 Douglas Fraser <doug+quagga@idmf.net> + + * zebra/connected.c: PtP revert fixup. Zebra was not creating + connected route for PtP peer. + +2003-10-07 Tarhon-Onu Victor <mituc@iasi.rdsnet.ro> + + * zebra/ipforward_proc.c: (ipforward) Close the fd for + /proc/net/snmp. See [quagga-dev 284] + +2003-09-29 Gilad Arnold <gilad.arnold@terayon.com> + + * zebra/zebra_rib.c: Fix possible dangling reference to rib + route_nodes - unlock it the appropriate number of times. (twice, + because of the implicit lock). see [quagga-dev 251]. + +2003-09-29 Paul Jakma <paul@dishone.st> + + * zebra/connected.c: revert the 'generic PtP' patch as it causes + far too many problems. People who use FreeSWAN should investigate + native linux ipsec. + * zebra/rt_netlink.c: ditto + * lib/if.c: ditto + * ripd/ripd.h: ditto + * ripd/ripd.c: ditto + * ripd/rip_interface.c: ditto + * ospfd/ospfd.c: ditto + * ospfd/ospf_snmp.c: ditto + * bgpd/bgp_nexthop.c: ditto + * ospfd/ospf_packet.c: Add debug output for some of the previously + completely silent drops of 'bad' packets. + * configure.ac: bump version + +2003-08-27 Jay Fenlason <fenlason@redhat.com> + + * lib/Makefile.am: Do not use a lib (libcap) as a dependency + * zebra/Makefile.am: Link in libcap + * bgpd/bgp_routemap.c: attr->med is type u_in32_t, should be + compared with UINT32_MAX + * ospfd/ospfd.c: remove redundant assert + * zebra/rtadv.c: add missing include for zebra/rib.h + +2003-09-24 Paul Jakma <paul@dishone.st> + + * lib/version.h: moved to version.h.in + * lib/version.h.in: New file, from version.h. Change hardcoded + package name and version to use the autoconf defined substition + variables. + * configure.ac: Fix up AC/AM_INIT* to new style. Remove the sed'ing + through lib/version.h for VERSION. Add lib/version.h to the + AC_OUTPUT list. Update the text output of quagga version at end + of configure run to use PACKAGE_VERSION. + * doc/.cvsignore: ignore quagga.pdf + * doc/.cvsignore: ignore version.h, its now autogenerated. + +2003-09-24 sowmini.varadhan@sun.com + + * lib/if.c: (if_cmp_func) fix infinite loop if + ifp1->name == ifp2->name + * lib/linklist.c: (if_cmp_func) Fix handling of case where + list->cmp returns 0. + * rip_interface.c: (rip_interface_address_add) call + rip_enable_apply(), or the interface is never considered up. + see [quagga-dev 225]. + * zebra/kernel_socket.c: Fix up WRAPUP macro to deal with multiple + address families in the absence of sa_len element in struct + sockaddr. + (ifm_read): Handle solaris 9 if_msghdr_t. + Deal with interfaces which are incomplete, lookup on name rather + than the placeholder interface index of -1. + +2003-09-24 Thomas Giger TGC <thomas.giger@tgc.de> + + * ospf_packet.c (ospf_associate_packet_vl): pass NULL struct + interface to ospf_if_lookup_by_local_addr() rather than the + receiving interface ifp, packets for VL's could come in any + interface. See quagga-dev 250. + +2003-04-13 Paul Jakma <paul@dishone.st> + + * Amir: Opaque LSA bug fix for deletion of Type11's + * configure.ac: use --localstatedir for Unix sockets + * Hasso Tepper: When flushing as-ext LSAs flush associated NSSA + LSAs. + +2003-04-04 Paul Jakma <paul@dishone.st> + + * Sync to Zebra CVS + * Fix lib/thread.h leak + * Fix small Opaque LSA leak + * Do not configure OSPF interfaces for secondary addresses + * vtysh fixes from Hasso + * Dave Watson's missing ntohs fix + +2003-03-25 Paul Jakma <paul@dishone.st> + + * Sync to Zebra CVS + +2003-03-17 Amir Guindehi <amir@datacore.ch> + + * Extended SNMP checks in configure.ac so that net-snmp works + +2003-03-17 Amir Guindehi <amir@datacore.ch> + Ralph Keller <keller@tik.ee.ethz.ch> + * merge OSPF-API + +2003-02-07 Paul Jakma <paul@dishone.st> + + * Sync to zebra CVS + +2003-02-03 Paul Jakma <paul@dishone.st> + + * Sync to zebra CVS + +2003-01-19 Paul Jakma <paul@dishone.st> + + * Temporary fix for Generic PtP wrt to IPv6 + +2003-01-17 Paul Jakma <paul@dishone.st> + + * Sync up to latest zebra.org CVS + * [zebra 16823] Bugfix and new feature in Opaque-LSA handling + Masahiko Endo <endo@suri.co.jp> + * [zebra 16824] [PATCH] nsm_kill_neighbor + Masahiko Endo <endo@suri.co.jp> + * [zebra 17217] [PATCH] show thread CPU + Yon Uriarte <havanna_moon@gmx.net> + * [zebra 17218] Re: [PATCH] CLI extensions. + Yon Uriarte <havanna_moon@gmx.net> + +2002-12-13 Paul Jakma <paul@dishone.st> + + * added support for vtysh 'write file' command to + write either per-daamon and/or integrated file + * ospfd md5 buffer copying fix (Greg Troxel) + * ospfd md5 sequence number derived from time() + * RIPv1 fixes and improvements (John Hay) + * link state detection (linux) ([zebra 12269]) + * Generic PtP and RFC3021 interface addressing support + (Frank van Maarseveen) + * Michal Ludvig <michal@logix.cz>: + [zebra 16525] PATCH: Bugfixes for KAME systems + * Kevin C Miller <kevinm@andrew.cmu.edu> + [zebra 16681] OSPF NSSA Patches + * Yon Uriarte <havanna_moon@gmx.net> + [zebra 16671] [PATCH] CLI extensions + * Masahiko Endo: [zebra 15475] - MPLS-TE docs + +2002-07-07 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * zebra-0.93 released. + +2002-06-28 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * update-autotools: Change file name from update-auto-tools.sh. + +2002-06-21 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * update-auto-tools.sh: Add a new script to clean up build + environment. + +2002-06-18 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * Shift to the latest build environment autoconf-2.53 and + automake-1.6.2. + +2001-10-22 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * Integrate Glen Turner <glen.turner@aarnet.edu.au>'s pid option. + +2001-08-19 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * zebra-0.92a released. + +2001-08-19 "Peter Galbavy" <peter.galbavy@knowtion.net> + + * configure.in: SNMP library check problem fix when the library is + installed under /usr/local/lib. + +2001-08-15 Kunihiro Ishiguro <kunihiro@ipinfusion.com> + + * zebra-0.92 released. + +2001-04-22 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (LIBPAM): Use ZEBRA_AC_C_BIGENDIAN to avoid a + warning. + (IF_METHOD): Use test -r instead of AC_CHECK_FILE to avoid + warnings. + + * config.guess: Update to 2000-11-10 version. + +2001-04-11 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Use AC_TRY_COMPILE instead of AC_EGREP_HEADER to + detect in_pktinfo structure. Suggested by: Vlad Lungu + <vlad@rls.roknet.ro>. + +2001-03-07 Michael Rozhavsky <mrozhavsky@opticalaccess.com> + + * configure.in: Add check for structure in_pktinfo. + +2001-02-07 "Bjoern A. Zeeb" <bzeeb+zebra@zabbadoz.net> + + * configure.in (USE_PAM): Fix PAM library detection code. + +2001-02-01 Kunihiro Ishiguro <kunihiro@zebra.org> + + * zebra-0.91 is released. + +2001-01-12 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Remove guile related definition. + +2001-01-11 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (ac_cv_htonl_works): HAVE_REPAIRABLE_HTONL is + removed. htonl should work fine on any platform. + +2001-01-10 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Remove --enable-oldrib option. + + * acconfig.h: OLD_RIB definition is removed. + + * zebra-0.90 is released. + + * configure.in (LIBS): Add check for sun_len field in struct + sun_len. + +2001-01-09 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Makefile.am: Include init/redhat files to distribution. + +2001-01-07 Yasuhiro Ohara <yasu@sfc.wide.ad.jp> + + * configure.in: check libm.a for BGPd compile error. + AC_CHECK_LIB(m, main) was added. + +2000-12-29 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: --enable-unixdomain becomes default. Add + --enable-tcp-zebra for TCP/IP communication between protocol + daemon and zebra. + + * COPYING.LIB: Added for lib/getopt.c, lib/getopt.h, + lib/getopt1.c, lib/md5-gnu.h, lib/md5.c, lib/regex-gnu.h, + lib/regex.c. + + * Makefile.am (dist-hook): Include tools/*.cgi to distribution. + +2000-12-26 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (MULTIPATH_NUM): --enable-multipath=ARG specify + multipath number. ARG must be digit. + +2000-12-11 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --enable-newrib for test new RIB code. + +2000-11-25 Yasuhiro Ohara <yasu@sfc.wide.ad.jp> + + * configure.in, config.h.in: Add check for libutil.h and + setproctitle(). + +2000-10-26 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --enable-nssa for OSPF NSSA option. + + * acconfig.h: Define HAVE_NSSA. + +2000-10-25 "Bjoern A. Zeeb" <bzeeb+zebra@zabbadoz.net> + + * configure.in: pam_misc is only linked when the platform is + GNU/Linux. + +2000-10-24 Arkadiusz Miskiewicz <misiek@pld.org.pl> + + * configure.in (LIBS): Add check for crypto library. test x`ls + ${ac_snmp}` is replaced with sipmle test -f. + +2000-10-23 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --enable-unixdomain option. This will be + default behavior in zebra-0.90. + +2000-10-02 Kunihiro Ishiguro <kunihiro@zebra.org> + + * zebra-0.89 is released. + +2000-09-27 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add check for Intel CPU for Solaris on x86 check. + +2000-09-21 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add check for getifaddrs(). + Set AM_INIT_AUTOMAKE version to 0.89. + +2000-09-14 Kunihiro Ishiguro <kunihiro@zebra.org> + + * config.guess: Update to the latest version. + + * config.sub: Likewise + +2000-09-14 David Lipovkov <dlipovkov@OpticalAccess.com> + + * REPORTING-BUGS: New file is added. + +2000-08-27 itojun@iijlab.net + + * configure.in: Add ncurses library check when --enable-vtysh is + specified. + +2000-08-22 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add check for readline/history.h. + + * acconfig.h: Remove pthread related variables. + + * configure.in: Add --with-libpam option for vtysh PAM + authentication. Remove --disable-pthread because we don't support + pthread. + +2000-08-17 Kunihiro Ishiguro <kunihiro@zebra.org> + + * zebra-0.88 is released. + + * configure.in: Add Solaris -lcurses for vtysh. + +2000-08-02 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add check for ncurses for compiling on Solaris. + +2000-07-27 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add check for libreadline when --enable-vtysh is + specified. + +2000-07-23 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add AC_DEFINE(OPEN_BSD). When OS is OpenBSD + interface method is if_ioctl.o + +2000-07-09 Chris Dunlop <chris@onthe.net.au> + + * acconfig.h: Add HAVE_BROKEN_ALIASES. + + * configure.in: Add --enable-broken-aliases. + +2000-06-12 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to zebra-0.87. + +2000-06-05 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Remove --enable-mpls-vpn. Now MPLS-VPN support is + default. + + * Set version to zebra-0.87-pre + + * Makefile.am: Likewise. + +2000-04-27 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.86. + +2000-03-21 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.85b for ospfd test. + +2000-03-20 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.85a for ospfd test. + +2000-03-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.85. + +2000-01-26 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Makefile.in: Regenerated by patched automake for fixing "make + clean" problem on FreeBSD. + +1999-12-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.83a. This is for *BSD static route lookup + problem. + +1999-12-06 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.83. + +1999-11-29 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.82. + +1999-11-23 Kunihiro Ishiguro <kunihiro@zebra.org> + + * aczebra.m4: New file added. + +1999-11-21 Michael Handler <handler@sub-rosa.com> + + * configure.in (LIBS): Add sa_len check of sockaddr. + + * acconfig.h: Add HAVE_SA_LEN. + +1999-11-12 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: Update version to zebra-0.81b for bgpd test. + +1999-11-09 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --enable-mbgp. + +1999-11-05 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Makefile.am (EXTRA_DIST): Add TODO to the distribution. + +1999-11-04 Kunihiro Ishiguro <kunihiro@zebra.org> + + * TODO: New file is added. + +1999-11-03 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: Update version to zebra-0.81a for ospfd test. + +1999-10-28 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: New option --enable-snmp is added. + +1999-10-24 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: Update version to zebra-0.80. + +1999-10-21 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: Update version to zebra-0.80-pre3 + +1999-10-18 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (LIBS): SNMP check is done by ucd-snmp/asn1.h. + +1999-10-10 Peter Galbavy <Peter.Galbavy@knowledge.com> + + * configure.in: Add support of OpenBSD. + +1999-10-04 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: Update version to zebra-0.80-pre2. + +1999-09-27 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: Update version to zebra-0.80-pre. From this version, + access-list and prefix-list's name space is divided into IPv4 and + IPv6. + +1999-09-17 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: For test recent fixes Set version to zebra-0.79a. + +1999-09-14 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: zebra-0.79 is out. + +1999-09-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: For ospfd's virtual link test. Set version to 0.78h. + +1999-09-07 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: For ospfd test. Set version to 0.78g. + +1999-09-05 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: For internal test of ospfd. Set version to 0.78f. + +1999-09-02 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: To test ospfd's fix, set version to 0.78e. + +1999-09-01 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: To test ospfd's area related bug fix, set version + to 0.78d. + +1999-09-01 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: To test ospfd, set version to 0.78c. + +1999-08-31 Janos Farkas <chexum@shadow.banki.hu> + + * Many misspelling correction. + +1999-08-31 Kunihiro Ishiguro <kunihiro@zebra.org> + + * version.h: To test ospfd, set version to 0.78b. + +1999-08-31 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (LIBS): Add UCD-SNMP include path check. + +1999-08-31 Lars Fenneberg <lf@elemental.net> + + * configure.in: The logic which detects the UCD-SNMP library + should first check in the default system locations for the library + and then in /usr/local. + +1999-08-27 itojun@iijlab.net + + * configure.in (LIBS): Fix problem about libsnmp.a check. + +1999-08-26 kay <kay@v6.access.co.jp> + + * configure.in (CFLAGS): Add <sys/socket.h> to check socklen_t. + +1999-08-24 VOP <vop@unity.net> + + * filter.c: Include "sockunion.h". + plist.c: Likewise. + table.c: Likewise. + +1999-08-24 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add netinet6/in6.h check. + +1999-08-21 Masaki Minami <masaki@minami.org> + + * BSD/OS 4.0 porting. + +1999-08-15 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --enable-netlink option to force to use Linux + netlink interface. + (CFLAGS): Add ucd-snmp library check. + + * acconfig.h: If socklen_t is not defined, typedef int to + socklen_t. + +1999-08-15 Arkadiusz Miskiewicz <misiek@misiek.eu.org> + + * configure.in: When --enable-ipv6 specified, then only kernel + version is checked. + +1999-08-14 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add GNU libc 2.1 check. + +1999-08-02 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Fix privious Linux IPv6 check changes. + +1999-08-02 Arkadiusz Miskiewicz <misiek@misiek.eu.org> + + * configure.in: Improve Linux IPv6 feature check. + +1999-07-29 Rick Payne <rickp@rossfell.co.uk> + + * Changed route-maps to behave in a more cisco-like fashion + +1999-07-27 Gerhard Poul <gpoul@gnu.org> + + * SERVICES: New file added. + +1999-07-12 itojun@iijlab.net + + * configure.in: Add check for getaddrinfo. Improve Kame related + library check. + +1999-07-07 Yasuhiro Ohara <yasu@sfc.wide.ad.jp> + + * configure.in, acconfig.h: Add check for FreeBSD 3.2. + +1999-07-07 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Delete check for netinet/ip6.h. + +1999-06-30 Gerhard Poul <gpoul@gnu.org> + + * README: remixed the old files and added some new parts. + moved some INSTALL stuff into INSTALL file. + moved some other stuff to doc/zebra.texi + +1999-06-29 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (LIBS): Add libresolv check. + Change --enabe-all-in-one option to --enable-one-vty. + +1999-06-20 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --enabe-all-in-one option. + +1999-06-16 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add socklen_t check. + +1999-06-16 Gerhard Poul <gpoul@gnu.org> + + * Many compile warnings fixed. + +1999-05-31 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Change message from Linux 2.2.X IPv6 to Linux IPv6. + OpenBSD (NRL) check is enabled. + +1999-05-30 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (LIBS): Add crypt library check. + +1999-05-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add sin6_scope_id in struct sockaddr_in6 check. + +1999-04-30 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.63 for first beta package. + +1999-04-15 Kunihiro Ishiguro <kunihiro@zebra.org> + + * guile.m4: Added from guile package. + +1999-04-14 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Set version to 0.60 for beta package preparation. + +1999-04-12 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Makefile.am: Add noninst_LIBRARIES each directory's Makefile.am. + This change is for linking these libraries to guile. + +1999-04-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (LIBS): Add struct rt_addrinfo check. + +1999-04-07 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: AC_STDC_HEADERS added. + +1999-03-29 Kunihiro Ishiguro <kunihiro@zebra.org> + + * Add dependencies to each directory's Makefile.am. + +1999-03-02 Peter Galbavy <Peter.Galbavy@knowledge.com> + + * reworked include file structure, and configure so that all + source files get all system-dependent include files by including + <zebra.h> which is really lib/zebra.h. This means that the + different programs include files are now available as #include + "zebra/zebra.h" - note the use of quotes, not <> as delimiters. + + In practical terms, if I haven't really screwed up, the main file + that maintainers for other OSes have to change is lib/zebra.h for + all the conditional includes etc. + + * added --disable-pthread for those systems that seem to have + POSIX threads, but do not work. OpenBSD 2.4+ is like that just + now. Changed all occurance of #ifdef PTHREAD to use HAVE_PTHREAD + instead. + +1999-02-24 <kunihiro@zebra.org> + + * configure.in: update to AC_PREREQ(1.13). + Change message from Linux 2.1.x to Linux 2.2.x. + * Added ospf6d directory support. + +1999-02-22 Peter Galbavy <Peter.Galbavy@knowledge.com> + + * added a "log" element to the BGPd peer structure, enabling us to + start thinging about a log stream per peer. This is currently + ignored by the wrapper code, but developers should try to use the + "appropriate" ZLOG stream. Documentation will follow, when the + real routines start to exist. + + The current plan is to use a copy of the BSD syslog() routines and + replace the syslog library function with our own. I will need + feedback from users of other platforms as this work is done to see + if all is well elsewhere. + + * preliminary work on zlog() library. directly replaces syslog() + currently with zlog(ZLOG *, ...) where the new first argument + is a pointer to a ZLOG structure (defined in lib/log.h) and will + encapsulate all the information necessary to maintain multiple + logging streams. + +1999-02-19 Peter Galbavy <Peter.Galbavy@knowledge.com> + + * added vsnprintf() macro to lib/str.h if required and removed + #ifdef SUNOS_5 dependency on it + +1999-02-18 Peter Galbavy <Peter.Galbavy@knowledge.com> + + * syslog support added + +1999-02-18 Peter Galbavy <Peter.Galbavy@knowledge.com> + + * configure.in: Add daemon function check. + +1999-01-21 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Add --disable-ipv6, --disable-zebra, + --disable-bgpd, --disable-ripd, --disable-ripngd, --disable-ospfd + options to configure. + +1998-12-07 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Check /usr/inet6/lib/libinet6.a exists or not. + +1998-10-14 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Comment out FreeBSD's libc_r detect section. At + this moment it doesn't work correctly with zebra. + + Netlink interface is only enabled when Linux kernel version is + upper than 2.1.0. + +1998-09-15 HEO SeonMeyong <seirios@matrix.iri.co.jp> + + * Hydrangea is now called KAME, so change all defines. + +1998-08-16 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: ifaliasreq check added. + +1998-08-12 Katsuhiro Kondou <kondou@nec.co.jp> + + * Patch is applied for compile under EWS4800 + +1998-06-09 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: delete old mtu_method check. + + * doc/zebra.texi (Kernel interface): chapter `Kernel interface' added + +1998-06-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: add new netlink check for GNU/Linux + +1998-06-07 Kunihiro Ishiguro <kunihiro@zebra.org> + + * doc/zebra.texi: Update Linux netlink chapter. + +1998-05-18 Yamashita TAKAO <jargon@lares.dti.ne.jp> + + * config.h.in: define PTHREAD if work on Solaris 2.6 + why delete the definition? I miss? + +1998-05-08 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: add net/if.h header check. + +1998-05-02 SeonMeyong HEO <seirios@Matrix.iri.co.jp> + + * zebra.tex,archfig.tex,zebra.sty: Manual file is added. + * zebra.texi: Modify Introduction text. + * RIPngd.c: Patch Hydrangea code. + +1998-05-01 Kunihiro Ishiguro <kunihiro@zebra.org> + + * .cvsignore: added. + + * Makerule.in: is gone. + * Makefile.am: Now we use automake to generate Makefile.in + +1998-03-19 Yamashita TAKAO <jargon@lares.dti.ne.jp> + + * lib/vty.c: modified the definition of *master + * lib/sockunion.c (inet_aton): add, but don't work. uum... + + +1998-03-15 Yamashita TAKAO <jargon@lares.dti.ne.jp> + + * configure.in: define PTHREAD if work on Solaris 2.6 + * config.h.in: likewise + * lib/thread.c: likewise + * lib/vty.c: likewise + +1998-03-15 SeonMeyong HEO <seirios@Matrix.iri.co.jp> + + * config.h.in: define INET6 if defined HAVE_IPV6 & HYDRANGEA + * bgpd/: remove include <netinet6/in6.h> line. + * lib/: remove include <netinet6/in6.h> line. + * ripbgd/: remove include <netinet6/in6.h> line. + * zebra/: remove include <netinet6/in6.h> line. + * ripd/*.c: remove include <netinet6/in6.h> line. + undefine IPV6 difinitions because RIPd is not worked for + IPv6 protocol. + + +1998-01-30 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: Change routing socket check method from + AC_TRY_COMPILE to AC_TRY_RUN because GNU libc version 2 has + AF_ROUTE but over linux it's meenigless. + +1998-01-06 Kunihiro Ishiguro <kunihiro@zebra.org> + + * config.h.in: remove err_t define. + +1997-11-18 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in (canonical): add check of IF_METHOD + +1997-09-27 Kunihiro Ishiguro <kunihiro@note.digital-magic.co.jp> + + * configure.in: add INRIA check + +1997-09-25 Kunihiro Ishiguro <kunihiro@note.digital-magic.co.jp> + + * configure.in (canonical): change ipforward_snmp.o to ipforward_proc.o + +1997-09-12 Kunihiro Ishiguro <kunihiro@zebra.org> + + * configure.in: change IRDPD to NDPD + +1997-08-18 Kunihiro Ishiguro <kunihiro@zebra.org> + + * INSTALL: new file + +1997-08-14 Kunihiro Ishiguro <kunihiro@zebra.org> + + * config.h: add XCALLOC() + @@ -1,5 +1,5 @@ -*- mode: text; -*- -$Id$ +$Id: HACKING,v 1.22 2008/07/22 21:11:48 paul Exp $ GUIDELINES FOR HACKING ON QUAGGA @@ -75,6 +75,28 @@ release. See also below regarding SHARED LIBRARY VERSIONING. +COMPILE-TIME CONDITIONAL CODE + +Please think very carefully before making code conditional at compile time, +as it increases maintenance burdens and user confusion. In particular, +please avoid gratuitious --enable-.... switches to the configure script - +typically code should be good enough to be in Quagga, or it shouldn't be +there at all. + +When code must be compile-time conditional, try have the compiler make it +conditional rather than the C pre-processor. I.e. this: + + if (SOME_SYMBOL) + frobnicate(); + +rather than: + + #ifdef SOME_SYMBOL + frobnicate (); + #endif /* SOME_SYMBOL */ + +Note that the former approach requires ensuring that SOME_SYMBOL will be +defined (watch your AC_DEFINEs). CHANGELOG diff --git a/INSTALL.quagga.txt b/INSTALL.quagga.txt index f627c922..4a5d2961 100644 --- a/INSTALL.quagga.txt +++ b/INSTALL.quagga.txt @@ -1,4 +1,4 @@ -# $Id$ +# $Id: INSTALL.quagga.txt,v 1.13 2007/02/06 19:56:31 gdt Exp $ -------------------------------------------------------------------------- Building and Installing Quagga from releases or snapshots: diff --git a/Makefile.am b/Makefile.am index a9a48ae1..96da94fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in. SUBDIRS = lib @ZEBRA@ @BGPD@ @RIPD@ @RIPNGD@ @OSPFD@ @OSPF6D@ \ - @ISISD@ @WATCHQUAGGA@ @WATCHLINK@ @VTYSH@ @OSPFCLIENT@ doc m4 @pkgsrcdir@ \ + @ISISD@ @WATCHQUAGGA@ @VTYSH@ @OSPFCLIENT@ doc m4 @pkgsrcdir@ \ redhat @SOLARIS@ DIST_SUBDIRS = lib zebra bgpd ripd ripngd ospfd ospf6d \ @@ -4,6 +4,8 @@ - [bgpd] MRT format changes to version 2. Those relying on bgpd MRT table dumps may need to update their tools. - [bgpd] Added new route-map set statement: "as-path exclude" +- Zebra RIB updates queue has evolved into a multi-level + structure to address RIB consistency issues. * Changes in Quagga 0.99.2 diff --git a/README.NetBSD b/README.NetBSD index 55e54af8..23bc886c 100755 --- a/README.NetBSD +++ b/README.NetBSD @@ -1,6 +1,6 @@ #!/bin/sh -$Id$ +$Id: README.NetBSD,v 1.5 2007/08/02 13:38:38 gdt Exp $ # This file is helpful for building quagga from cvs on NetBSD, and # probably on any system using pkgsrc. diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog index 4630ab97..6fe2b0f5 100644 --- a/bgpd/ChangeLog +++ b/bgpd/ChangeLog @@ -1,3 +1,82 @@ +2008-07-22 Paul Jakma <paul.jakma@sun.com> + + * bgp_{packet,route,advertise}.c: change to compiler testing of + DISABLE_BGP_ANNOUNCE, rather than cpp. + +2008-07-22 MIYAJIMA Mitsuharu <miyajima.mitsuharu@anchor.jp> + + * bgp_packet.c: (bgp_update_packet_eor) Fix crash triggerable + if a bgpd was compiled with --disable-bgp-announce and if GR is + advertised by peer. + +2008-07-22 Paul Jakma <paul.jakma@sun.com> + + * bgp_community.c: (community_str2com) assigns defaults to local + vars + * bgp_attr.c: (bgp_attr_parse) match format specifier to arg + * bgp_table.{c,h}: (bgp_table_top) can take a * to a const, quelling + warning in bgp_route.c + +2008-07-21 Paul Jakma <paul.jakma@sun.com> + + + * bgp_packet.c: (bgp_open_receive) fix warning in a zlog call + * bgp_vty.c: (bgp_vty_return) add return code + * bgpd.c: (bgp_master_init) setup the socket list. + * bgp_network.c: Remove the dual IPv4/6 socket thing for now, which + was implemented by Michael, until such time as its clear its + required for Linux (see sockopt comments). IPv6 support, including + IPv4 sessions on AF_INET6 sockets, therefore is broken, and the + '-l 0.0.0.0' arguments would need to be given to bgpd to make + things work here. + +2008-07-21 Michael H. Warfield <mhw@wittsend.com> + YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> + Tomohiko Kusuda <kusuda@inetcore.com> + Leigh Brown <leigh@solinno.co.uk> + + * bgp_network.c: (bgp_md5_set_one) shim between libzebra tcp-md5 + sockopt and bgpd. + (bgp_md5_set_socket) Helper for bgp_connect + (bgp_md5_set) setup TCP-MD5SIG for the given peer. + (bgp_connect) call out to bgp_md5_set_socket for the outgoing + connect socket. + (bgp_socket) save references to the listen sockets, needed if + TCP-MD5SIG is applied later or changed. + * bgp_vty.c: (*neighbor_password_cmd) New 'neighbor ... password' + commands. + * bgpd.c: (peer_{new,delete) manage TCP-MD5 password + (peer_group2peer_config_copy) inherit TCP-MD5 password + (peer_password_{un,}set) orchestrate the whole add/remove of TCP-MD5 + passwords: applying checks, stopping peers, and trying to return + errors to UI, etc. + (bgp_config_write_peer) save password. + Fix missing newline in writeout of neighbor ... port. + +2008-07-02 MIYAJIMA Mitsuharu <miyajima.mitsuharu@anchor.jp> + + * *.c: CMD_AS_RANGE was being used inside command strings, and thus + not being expanded, fix by dequoting. + +2008-07-02 Stephen Hemminger <stephen.hemminger@vyatta.com> + + * bgp_table.{c,h}: (bgp_table_finish) Take a double pointer and + scrub pointer in caller, so fixing double-free crashes seen + with route-server-client configuration. + * *.c: Adjust all callers of bgp_table_finish + +2008-07-02 Paul Jakma <paul.jakma@sun.com> + + * bgp_table.{c,h}: (bgp_node_delete, bgp_table_free) shouldn't be + exported. + +2008-06-07 Paul Jakma <paul@jakma.org> + + * bgp_attr.{c,h}: (bgp_mp_{un,}reach_parse) export, for unit tests. + * bgp_attr.c: (bgp_mp_reach_parse) Add logging. Tighten length test + to bounds check against the attribute length rather than the + stream length.. + 2008-06-01 jfletche@gmail.com * bgp_attr.c: (bgp_attr_aspathlimit) fix silly bug in flags check diff --git a/bgpd/IMPLEMENTATION.txt b/bgpd/IMPLEMENTATION.txt index ac087a38..fff360ab 100644 --- a/bgpd/IMPLEMENTATION.txt +++ b/bgpd/IMPLEMENTATION.txt @@ -1,4 +1,4 @@ -$Id$ +$Id: IMPLEMENTATION.txt,v 1.2 2005/02/15 17:10:03 gdt Exp $ This file contains notes about the internals of the BGP implementation. The initial impetus is understanding the memory usage diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c index 73b868a8..b9f4a85b 100644 --- a/bgpd/bgp_advertise.c +++ b/bgpd/bgp_advertise.c @@ -72,10 +72,10 @@ baa_hash_key (void *p) } static int -baa_hash_cmp (void *p1, void *p2) +baa_hash_cmp (const void *p1, const void *p2) { - struct bgp_advertise_attr * baa1 = (struct bgp_advertise_attr *) p1; - struct bgp_advertise_attr * baa2 = (struct bgp_advertise_attr *) p2; + const struct bgp_advertise_attr * baa1 = p1; + const struct bgp_advertise_attr * baa2 = p2; return attrhash_cmp (baa1->attr, baa2->attr); } @@ -220,9 +220,8 @@ bgp_adj_out_set (struct bgp_node *rn, struct peer *peer, struct prefix *p, struct bgp_adj_out *adj = NULL; struct bgp_advertise *adv; -#ifdef DISABLE_BGP_ANNOUNCE - return; -#endif /* DISABLE_BGP_ANNOUNCE */ + if (DISABLE_BGP_ANNOUNCE) + return; /* Look for adjacency information. */ if (rn) @@ -274,9 +273,8 @@ bgp_adj_out_unset (struct bgp_node *rn, struct peer *peer, struct prefix *p, struct bgp_adj_out *adj; struct bgp_advertise *adv; -#ifdef DISABLE_BGP_ANNOUNCE - return; -#endif /* DISABLE_BGP_ANNOUNCE */ + if (DISABLE_BGP_ANNOUNCE) + return; /* Lookup existing adjacency, if it is not there return immediately. */ for (adj = rn->adj_out; adj; adj = adj->next) diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 38c9caa6..242bd8ee 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -322,11 +322,7 @@ assegment_normalise (struct assegment *head) static struct aspath * aspath_new (void) { - struct aspath *aspath; - - aspath = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath)); - memset (aspath, 0, sizeof (struct aspath)); - return aspath; + return XCALLOC (MTYPE_AS_PATH, sizeof (struct aspath)); } /* Free AS path structure. */ @@ -1347,10 +1343,10 @@ aspath_add_seq (struct aspath *aspath, as_t asno) /* Compare leftmost AS value for MED check. If as1's leftmost AS and as2's leftmost AS is same return 1. */ int -aspath_cmp_left (struct aspath *aspath1, struct aspath *aspath2) +aspath_cmp_left (const struct aspath *aspath1, const struct aspath *aspath2) { - struct assegment *seg1 = NULL; - struct assegment *seg2 = NULL; + const struct assegment *seg1 = NULL; + const struct assegment *seg2 = NULL; if (!(aspath1 && aspath2)) return 0; @@ -1484,7 +1480,7 @@ aspath_reconcile_as4 ( struct aspath *aspath, struct aspath *as4path) as2's leftmost AS is same return 1. (confederation as-path only). */ int -aspath_cmp_left_confed (struct aspath *aspath1, struct aspath *aspath2) +aspath_cmp_left_confed (const struct aspath *aspath1, const struct aspath *aspath2) { if (! (aspath1 && aspath2) ) return 0; @@ -1769,10 +1765,10 @@ aspath_key_make (void *p) /* If two aspath have same value then return 1 else return 0 */ static int -aspath_cmp (void *arg1, void *arg2) +aspath_cmp (const void *arg1, const void *arg2) { - struct assegment *seg1 = ((struct aspath *)arg1)->segments; - struct assegment *seg2 = ((struct aspath *)arg2)->segments; + const struct assegment *seg1 = ((struct aspath *)arg1)->segments; + const struct assegment *seg2 = ((struct aspath *)arg2)->segments; while (seg1 || seg2) { diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index d8b41fa9..2b4625c8 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -72,8 +72,8 @@ extern struct aspath *aspath_prepend (struct aspath *, struct aspath *); extern struct aspath *aspath_filter_exclude (struct aspath *, struct aspath *); extern struct aspath *aspath_add_seq (struct aspath *, as_t); extern struct aspath *aspath_add_confed_seq (struct aspath *, as_t); -extern int aspath_cmp_left (struct aspath *, struct aspath *); -extern int aspath_cmp_left_confed (struct aspath *, struct aspath *); +extern int aspath_cmp_left (const struct aspath *, const struct aspath *); +extern int aspath_cmp_left_confed (const struct aspath *, const struct aspath *); extern struct aspath *aspath_delete_confed_seq (struct aspath *); extern struct aspath *aspath_empty (void); extern struct aspath *aspath_empty_get (void); diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index d58ad418..c52c776e 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -131,15 +131,13 @@ cluster_hash_key_make (void *p) } static int -cluster_hash_cmp (void *p1, void *p2) +cluster_hash_cmp (const void *p1, const void *p2) { - struct cluster_list * cluster1 = (struct cluster_list *) p1; - struct cluster_list * cluster2 = (struct cluster_list *) p2; + const struct cluster_list * cluster1 = p1; + const struct cluster_list * cluster2 = p2; - if (cluster1->length == cluster2->length && - memcmp (cluster1->list, cluster2->list, cluster1->length) == 0) - return 1; - return 0; + return (cluster1->length == cluster2->length && + memcmp (cluster1->list, cluster2->list, cluster1->length) == 0); } static void @@ -150,13 +148,13 @@ cluster_free (struct cluster_list *cluster) XFREE (MTYPE_CLUSTER, cluster); } +#if 0 static struct cluster_list * cluster_dup (struct cluster_list *cluster) { struct cluster_list *new; - new = XMALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list)); - memset (new, 0, sizeof (struct cluster_list)); + new = XCALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list)); new->length = cluster->length; if (cluster->length) @@ -169,6 +167,7 @@ cluster_dup (struct cluster_list *cluster) return new; } +#endif static struct cluster_list * cluster_intern (struct cluster_list *cluster) @@ -267,15 +266,13 @@ transit_hash_key_make (void *p) } static int -transit_hash_cmp (void *p1, void *p2) +transit_hash_cmp (const void *p1, const void *p2) { - struct transit * transit1 = (struct transit *) p1; - struct transit * transit2 = (struct transit *) p2; + const struct transit * transit1 = p1; + const struct transit * transit2 = p2; - if (transit1->length == transit2->length && - memcmp (transit1->val, transit2->val, transit1->length) == 0) - return 1; - return 0; + return (transit1->length == transit2->length && + memcmp (transit1->val, transit2->val, transit1->length) == 0); } static void @@ -393,10 +390,10 @@ attrhash_key_make (void *p) } int -attrhash_cmp (void *p1, void *p2) +attrhash_cmp (const void *p1, const void *p2) { - struct attr * attr1 = (struct attr *) p1; - struct attr * attr2 = (struct attr *) p2; + const struct attr * attr1 = p1; + const struct attr * attr2 = p2; if (attr1->flag == attr2->flag && attr1->origin == attr2->origin @@ -408,8 +405,8 @@ attrhash_cmp (void *p1, void *p2) && attr1->pathlimit.ttl == attr2->pathlimit.ttl && attr1->pathlimit.as == attr2->pathlimit.as) { - struct attr_extra *ae1 = attr1->extra; - struct attr_extra *ae2 = attr2->extra; + const struct attr_extra *ae1 = attr1->extra; + const struct attr_extra *ae2 = attr2->extra; if (ae1 && ae2 && ae1->aggregator_as == ae2->aggregator_as @@ -435,7 +432,7 @@ attrhash_cmp (void *p1, void *p2) } static void -attrhash_init () +attrhash_init (void) { attrhash = hash_create (attrhash_key_make, attrhash_cmp); } @@ -1259,7 +1256,7 @@ bgp_attr_cluster_list (struct peer *peer, bgp_size_t length, } /* Multiprotocol reachability information parse. */ -static int +int bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr, struct bgp_nlri *mp_update) { @@ -1277,8 +1274,13 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr, /* safe to read statically sized header? */ #define BGP_MP_REACH_MIN_SIZE 5 +#define LEN_LEFT (length - (stream_get_getp(s) - start)) if ((length > STREAM_READABLE(s)) || (length < BGP_MP_REACH_MIN_SIZE)) - return -1; + { + zlog_info ("%s: %s sent invalid length, %lu", + __func__, peer->host, (unsigned long)length); + return -1; + } /* Load AFI, SAFI. */ afi = stream_getw (s); @@ -1287,8 +1289,12 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr, /* Get nexthop length. */ attre->mp_nexthop_len = stream_getc (s); - if (STREAM_READABLE(s) < attre->mp_nexthop_len) - return -1; + if (LEN_LEFT < attre->mp_nexthop_len) + { + zlog_info ("%s: %s, MP nexthop length, %u, goes past end of attribute", + __func__, peer->host, attre->mp_nexthop_len); + return -1; + } /* Nexthop length check. */ switch (attre->mp_nexthop_len) @@ -1330,13 +1336,17 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr, break; #endif /* HAVE_IPV6 */ default: - zlog_info ("Wrong multiprotocol next hop length: %d", - attre->mp_nexthop_len); + zlog_info ("%s: (%s) Wrong multiprotocol next hop length: %d", + __func__, peer->host, attre->mp_nexthop_len); return -1; } - if (!STREAM_READABLE(s)) - return -1; + if (!LEN_LEFT) + { + zlog_info ("%s: (%s) Failed to read SNPA and NLRI(s)", + __func__, peer->host); + return -1; + } { u_char val; @@ -1346,15 +1356,23 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr, } /* must have nrli_len, what is left of the attribute */ - nlri_len = length - (stream_get_getp(s) - start); + nlri_len = LEN_LEFT; if ((!nlri_len) || (nlri_len > STREAM_READABLE(s))) - return -1; + { + zlog_info ("%s: (%s) Failed to read NLRI", + __func__, peer->host); + return -1; + } if (safi != BGP_SAFI_VPNV4) { ret = bgp_nlri_sanity_check (peer, afi, stream_pnt (s), nlri_len); - if (ret < 0) - return -1; + if (ret < 0) + { + zlog_info ("%s: (%s) NLRI doesn't pass sanity check", + __func__, peer->host); + return -1; + } } mp_update->afi = afi; @@ -1365,10 +1383,11 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr, stream_forward_getp (s, nlri_len); return 0; +#undef LEN_LEFT } /* Multiprotocol unreachable parse */ -static int +int bgp_mp_unreach_parse (struct peer *peer, bgp_size_t length, struct bgp_nlri *mp_withdraw) { @@ -1549,9 +1568,9 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size, && ((endp - startp) < (BGP_ATTR_MIN_LEN + 1))) { zlog (peer->log, LOG_WARNING, - "%s Extended length set, but just %tu bytes of attr header", + "%s Extended length set, but just %lu bytes of attr header", peer->host, - endp - STREAM_PNT (BGP_INPUT (peer))); + (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer)))); bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR, diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index e152b9f4..12149a17 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -163,7 +163,7 @@ extern bgp_size_t bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix_rd *, u_char *); extern void bgp_dump_routes_attr (struct stream *, struct attr *, struct prefix *); -extern int attrhash_cmp (void *, void *); +extern int attrhash_cmp (const void *, const void *); extern unsigned int attrhash_key_make (void *); extern void attr_show_all (struct vty *); extern unsigned long int attr_count (void); @@ -176,4 +176,9 @@ extern void cluster_unintern (struct cluster_list *); /* Transit attribute prototypes. */ void transit_unintern (struct transit *); +/* Exported for unit-test purposes only */ +extern int bgp_mp_reach_parse (struct peer *, bgp_size_t, struct attr *, + struct bgp_nlri *); +extern int bgp_mp_unreach_parse (struct peer *, bgp_size_t, struct bgp_nlri *); + #endif /* _QUAGGA_BGP_ATTR_H */ diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index a6ca1a46..6bf3b64a 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -51,11 +51,7 @@ community_list_master_lookup (struct community_list_handler *ch, int master) static struct community_entry * community_entry_new () { - struct community_entry *new; - - new = XMALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry)); - memset (new, 0, sizeof (struct community_entry)); - return new; + return XCALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry)); } /* Free community list entry. */ @@ -92,11 +88,7 @@ community_entry_free (struct community_entry *entry) static struct community_list * community_list_new () { - struct community_list *new; - - new = XMALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list)); - memset (new, 0, sizeof (struct community_list)); - return new; + return XCALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list)); } /* Free community-list. */ diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index d5e9821b..1cafdb3e 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -581,8 +581,8 @@ community_str2com (const char *str) { struct community *com = NULL; struct community *com_sort = NULL; - u_int32_t val; - enum community_token token; + u_int32_t val = 0; + enum community_token token = community_token_unknown; do { @@ -633,5 +633,6 @@ community_hash (void) void community_init (void) { - comhash = hash_create (community_hash_make, community_cmp); + comhash = hash_create ((unsigned int (*) (void *))community_hash_make, + (int (*) (const void *, const void *))community_cmp); } diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index a0a8557d..ba25f4d1 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -517,29 +517,28 @@ bgp_damp_disable (struct bgp *bgp, afi_t afi, safi_t safi) return 0; } -int +void bgp_config_write_damp (struct vty *vty) { - if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60 - && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE - && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS - && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_out (vty, " bgp dampening%s", VTY_NEWLINE); - else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60 - && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE - && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS - && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) - vty_out (vty, " bgp dampening %ld%s", - bgp_damp_cfg.half_life/60, - VTY_NEWLINE); - else - vty_out (vty, " bgp dampening %ld %d %d %ld%s", - bgp_damp_cfg.half_life/60, - bgp_damp_cfg.reuse_limit, - bgp_damp_cfg.suppress_value, - bgp_damp_cfg.max_suppress_time/60, - VTY_NEWLINE); - return 1; + if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60 + && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE + && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS + && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) + vty_out (vty, " bgp dampening%s", VTY_NEWLINE); + else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60 + && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE + && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS + && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4) + vty_out (vty, " bgp dampening %ld%s", + bgp_damp_cfg.half_life/60, + VTY_NEWLINE); + else + vty_out (vty, " bgp dampening %ld %d %d %ld%s", + bgp_damp_cfg.half_life/60, + bgp_damp_cfg.reuse_limit, + bgp_damp_cfg.suppress_value, + bgp_damp_cfg.max_suppress_time/60, + VTY_NEWLINE); } #define BGP_UPTIME_LEN 25 diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h index 37ed90bc..17c31cb9 100644 --- a/bgpd/bgp_damp.h +++ b/bgpd/bgp_damp.h @@ -140,7 +140,7 @@ extern void bgp_damp_info_free (struct bgp_damp_info *, int); extern void bgp_damp_info_clean (void); extern char * bgp_get_reuse_time (unsigned int, char*, size_t); extern int bgp_damp_decay (time_t, int); -extern int bgp_config_write_damp (struct vty *); +extern void bgp_config_write_damp (struct vty *); extern void bgp_damp_info_vty (struct vty *, struct bgp_info *); extern char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *); diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 757b9cf8..b7280d93 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -856,7 +856,7 @@ bgp_config_write_debug (struct vty *vty) return write; } -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index e815ea3c..53dea805 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -773,7 +773,7 @@ DEFUN (no_dump_bgp_routes, } /* BGP node structure. */ -struct cmd_node bgp_dump_node = +static struct cmd_node bgp_dump_node = { DUMP_NODE, "", diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 9e7ae1b3..c08673ce 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -247,15 +247,13 @@ ecommunity_hash_make (void *arg) /* Compare two Extended Communities Attribute structure. */ int -ecommunity_cmp (void *arg1, void *arg2) +ecommunity_cmp (const void *arg1, const void *arg2) { const struct ecommunity *ecom1 = arg1; const struct ecommunity *ecom2 = arg2; - if (ecom1->size == ecom2->size - && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0) - return 1; - return 0; + return (ecom1->size == ecom2->size + && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0); } /* Initialize Extended Comminities related hash. */ diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index 69014237..278721c8 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -72,7 +72,7 @@ extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short); extern struct ecommunity *ecommunity_dup (struct ecommunity *); extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *); extern struct ecommunity *ecommunity_intern (struct ecommunity *); -extern int ecommunity_cmp (void *, void *); +extern int ecommunity_cmp (const void *, const void *); extern void ecommunity_unintern (struct ecommunity *); extern unsigned int ecommunity_hash_make (void *); extern struct ecommunity *ecommunity_str2com (const char *, int, int); diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c index ab7f0703..e4cf91af 100644 --- a/bgpd/bgp_filter.c +++ b/bgpd/bgp_filter.c @@ -99,11 +99,7 @@ static struct as_list_master as_list_master = static struct as_filter * as_filter_new () { - struct as_filter *new; - - new = XMALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter)); - memset (new, 0, sizeof (struct as_filter)); - return new; + return XCALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter)); } /* Free allocated AS filter. */ @@ -179,11 +175,7 @@ as_list_lookup (const char *name) static struct as_list * as_list_new () { - struct as_list *new; - - new = XMALLOC (MTYPE_AS_LIST, sizeof (struct as_list)); - memset (new, 0, sizeof (struct as_list)); - return new; + return XCALLOC (MTYPE_AS_LIST, sizeof (struct as_list)); } static void @@ -679,7 +671,7 @@ config_write_as_list (struct vty *vty) return write; } -struct cmd_node as_list_node = +static struct cmd_node as_list_node = { AS_LIST_NODE, "", diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index e6d34afc..2089c6b5 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -203,6 +203,7 @@ main (int argc, char **argv) int dryrun = 0; char *progname; struct thread thread; + int tmp_port; /* Set umask before anything for security */ umask (0027); @@ -238,7 +239,11 @@ main (int argc, char **argv) pid_file = optarg; break; case 'p': - bm->port = atoi (optarg); + tmp_port = atoi (optarg); + if (tmp_port <= 0 || tmp_port > 0xffff) + bm->port = BGP_PORT_DEFAULT; + else + bm->port = tmp_port; break; case 'A': vty_addr = optarg; @@ -252,7 +257,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : BGP_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = BGP_VTY_PORT; break; case 'r': retain_mode = 1; diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index e981e718..87f7f7b6 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -29,6 +29,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "prefix.h" #include "command.h" #include "privs.h" +#include "linklist.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_fsm.h" @@ -39,33 +40,70 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA extern struct zebra_privs_t bgpd_privs; -#if defined(HAVE_TCP_MD5SIG) /* * Set MD5 key for the socket, for the given IPv4 peer address. * If the password is NULL or zero-length, the option will be disabled. */ -int -bgp_md5_set (int sock, struct sockaddr_in *sin, const char *password) +static int +bgp_md5_set_socket (int socket, union sockunion *su, const char *password) { - int ret, en; - - if ( bgpd_privs.change (ZPRIVS_RAISE) ) - zlog_err ("bgp_md5_set: could not raise privs"); - - ret = sockopt_tcp_signature (sock, sin, password); + int ret = -1; + int en = ENOSYS; + + assert (socket >= 0); + +#if HAVE_DECL_TCP_MD5SIG + ret = sockopt_tcp_signature (socket, su, password); en = errno; - - if (bgpd_privs.change (ZPRIVS_LOWER) ) - zlog_err ("bgp_md5_set: could not lower privs"); - +#endif /* HAVE_TCP_MD5SIG */ + if (ret < 0) zlog (NULL, LOG_WARNING, "can't set TCP_MD5SIG option on socket %d: %s", - sock, safe_strerror (en)); + socket, safe_strerror (en)); return ret; } +/* Helper for bgp_connect */ +static int +bgp_md5_set_connect (int socket, union sockunion *su, const char *password) +{ + int ret = -1; + +#if HAVE_DECL_TCP_MD5SIG + if ( bgpd_privs.change (ZPRIVS_RAISE) ) + { + zlog_err ("%s: could not raise privs", __func__); + return ret; + } + + ret = bgp_md5_set_socket (socket, su, password); + + if (bgpd_privs.change (ZPRIVS_LOWER) ) + zlog_err ("%s: could not lower privs", __func__); #endif /* HAVE_TCP_MD5SIG */ + + return ret; +} + +int +bgp_md5_set (struct peer *peer) +{ + struct listnode *node; + int fret = 0, ret; + int *socket; + + /* Just set the password on the listen socket(s). Outbound connections + * are taken care of in bgp_connect() below. + */ + for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, socket)) + { + ret = bgp_md5_set_socket ((int )socket, &peer->su, peer->password); + if (ret < 0) + fret = ret; + } + return fret; +} /* Accept bgp connection. */ static int @@ -266,17 +304,14 @@ bgp_connect (struct peer *peer) sockopt_reuseaddr (peer->fd); sockopt_reuseport (peer->fd); - + #ifdef IPTOS_PREC_INTERNETCONTROL if (sockunion_family (&peer->su) == AF_INET) setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL); #endif -#ifdef HAVE_TCP_MD5SIG - if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD)) - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (peer->fd, &peer->su.sin, peer->password); -#endif /* HAVE_TCP_MD5SIG */ + if (peer->password) + bgp_md5_set_connect (peer->fd, &peer->su, peer->password); /* Bind socket. */ bgp_bind (peer); @@ -328,10 +363,6 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) struct addrinfo req; struct addrinfo *ainfo; struct addrinfo *ainfo_save; -#if defined(HAVE_TCP_MD5SIG) && defined(IPV6_V6ONLY) - struct sockaddr_in sin; - int socklen, on = 1; -#endif int sock = 0; char port_str[BUFSIZ]; @@ -372,18 +403,12 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); #endif -#if defined(HAVE_TCP_MD5SIG) && defined(IPV6_V6ONLY) -/* We can not apply MD5SIG to an IPv6 socket. If this is an AF_INET6 - socket, we'll have to create another socket for IPv4*/ - +#ifdef IPV6_V6ONLY + /* Want only IPV6 on ipv6 socket (not mapped addresses) */ if (ainfo->ai_family == AF_INET6) { -/* Mark this one for IPv6 only */ - ret = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, + int on = 1; + setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &on, sizeof (on)); - if( ret < 0 ) { - en = errno; - zlog_err ("setsockopt V6ONLY: %s", safe_strerror (en)); - } } #endif @@ -409,67 +434,9 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) close (sock); continue; } - -#if defined(HAVE_TCP_MD5SIG) && defined(IPV6_V6ONLY) - thread_add_read (master, bgp_accept, bgp, sock); - - if (ainfo->ai_family != AF_INET6) - continue; - - /* If first socket was an IPv6 socket, we need to create an IPv4 - socket for use by the TCP_MD5SIG logic. This code is blatently - copied and modified from the alternate IPv4 only code from below... */ - - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - zlog_err ("socket: %s", safe_strerror (errno)); - continue; - } - - sockopt_reuseaddr (sock); - sockopt_reuseport (sock); - setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); - - memset (&sin, 0, sizeof (struct sockaddr_in)); - - sin.sin_family = AF_INET; - sin.sin_port = htons (port); - socklen = sizeof (struct sockaddr_in); -#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - sin.sin_len = socklen; -#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ - - if ( bgpd_privs.change (ZPRIVS_RAISE) ) - zlog_err ("bgp_socket: could not raise privs"); - - ret = bind (sock, (struct sockaddr *) &sin, socklen); - en = errno; - if (bgpd_privs.change (ZPRIVS_LOWER) ) - zlog_err ("bgp_bind_address: could not lower privs"); - - if (ret < 0) - { - zlog_err ("bind: %s", safe_strerror (en)); - close(sock); - continue; - } - - ret = listen (sock, 3); - if (ret < 0) - { - zlog_err ("listen: %s", safe_strerror (errno)); - close (sock); - continue; - } -#endif - -#ifdef HAVE_TCP_MD5SIG - bm->sock = sock; -#endif /* HAVE_TCP_MD5SIG */ - + + listnode_add (bm->listen_sockets, (void *)sock); thread_add_read (master, bgp_accept, bgp, sock); - } while ((ainfo = ainfo->ai_next) != NULL); @@ -540,9 +507,6 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) close (sock); return ret; } -#ifdef HAVE_TCP_MD5SIG - bm->sock = sock; -#endif /* HAVE_TCP_MD5SIG */ thread_add_read (bm->master, bgp_accept, bgp, sock); diff --git a/bgpd/bgp_network.h b/bgpd/bgp_network.h index e7119414..618d8dbb 100644 --- a/bgpd/bgp_network.h +++ b/bgpd/bgp_network.h @@ -21,12 +21,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_NETWORK_H #define _QUAGGA_BGP_NETWORK_H -#if defined(HAVE_TCP_MD5SIG) -extern int bgp_md5_set (int, struct sockaddr_in *, const char *); -#endif /* HAVE_TCP_MD5SIG */ - extern int bgp_socket (struct bgp *, unsigned short, char *); extern int bgp_connect (struct peer *); extern void bgp_getsockname (struct peer *); +extern int bgp_md5_set (struct peer *); + #endif /* _QUAGGA_BGP_NETWORK_H */ diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 4dd5d946..a184dd4a 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -98,11 +98,7 @@ bnc_nexthop_free (struct bgp_nexthop_cache *bnc) static struct bgp_nexthop_cache * bnc_new () { - struct bgp_nexthop_cache *new; - - new = XMALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache)); - memset (new, 0, sizeof (struct bgp_nexthop_cache)); - return new; + return XCALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache)); } static void diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index f92a88ad..19375ef9 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -235,9 +235,8 @@ bgp_update_packet_eor (struct peer *peer, afi_t afi, safi_t safi) struct stream *s; struct stream *packet; -#ifdef DISABLE_BGP_ANNOUNCE - return; -#endif /* DISABLE_BGP_ANNOUNCE */ + if (DISABLE_BGP_ANNOUNCE) + return NULL; if (BGP_DEBUG (normal, NORMAL)) zlog_debug ("send End-of-RIB for %s to %s", afi_safi_print (afi, safi), peer->host); @@ -369,9 +368,8 @@ bgp_default_update_send (struct peer *peer, struct attr *attr, char attrstr[BUFSIZ]; char buf[BUFSIZ]; -#ifdef DISABLE_BGP_ANNOUNCE - return; -#endif /* DISABLE_BGP_ANNOUNCE */ + if (DISABLE_BGP_ANNOUNCE) + return; if (afi == AFI_IP) str2prefix ("0.0.0.0/0", &p); @@ -438,9 +436,8 @@ bgp_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi) bgp_size_t total_attr_len; char buf[BUFSIZ]; -#ifdef DISABLE_BGP_ANNOUNCE - return; -#endif /* DISABLE_BGP_ANNOUNCE */ + if (DISABLE_BGP_ANNOUNCE) + return; if (afi == AFI_IP) str2prefix ("0.0.0.0/0", &p); @@ -960,9 +957,8 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, struct bgp_filter *filter; int orf_refresh = 0; -#ifdef DISABLE_BGP_ANNOUNCE - return; -#endif /* DISABLE_BGP_ANNOUNCE */ + if (DISABLE_BGP_ANNOUNCE) + return; filter = &peer->filter[afi][safi]; @@ -1190,9 +1186,9 @@ bgp_open_receive (struct peer *peer, bgp_size_t size) /* Receive OPEN message log */ if (BGP_DEBUG (normal, NORMAL)) - zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %u," + zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %d," " holdtime %d, id %s", - peer->host, version, (unsigned)remote_as, holdtime, + peer->host, version, remote_as, holdtime, inet_ntoa (remote_id)); /* BEGIN to read the capability here, but dont do it yet */ @@ -1237,7 +1233,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size) zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but no AS4." " Odd, but proceeding.", peer->host); else if (as4 < BGP_AS_MAX && BGP_DEBUG (as4, AS4)) - zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but AS4 %u fits " + zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but AS4 (%u) fits " "in 2-bytes, very odd peer.", peer->host, as4); if (as4) remote_as = as4; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f8eb7f7f..db8e36d5 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -129,16 +129,11 @@ bgp_info_extra_get (struct bgp_info *ri) static struct bgp_info * bgp_info_new () { - struct bgp_info *new; - - new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); - memset (new, 0, sizeof (struct bgp_info)); - - return new; + return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info)); } /* Free bgp route information. */ -static void +void bgp_info_free (struct bgp_info *binfo) { if (binfo->attr) @@ -151,39 +146,6 @@ bgp_info_free (struct bgp_info *binfo) XFREE (MTYPE_BGP_ROUTE, binfo); } -struct bgp_info * -bgp_info_lock (struct bgp_info *binfo) -{ - binfo->lock++; - return binfo; -} - -struct bgp_info * -bgp_info_unlock (struct bgp_info *binfo) -{ - assert (binfo && binfo->lock > 0); - binfo->lock--; - - if (binfo->lock == 0) - { -#if 0 - zlog_debug ("%s: unlocked and freeing", __func__); - zlog_backtrace (LOG_DEBUG); -#endif - bgp_info_free (binfo); - return NULL; - } - -#if 0 - if (binfo->lock == 1) - { - zlog_debug ("%s: unlocked to 1", __func__); - zlog_backtrace (LOG_DEBUG); - } -#endif - - return binfo; -} void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri) @@ -742,9 +704,8 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p, filter = &peer->filter[afi][safi]; bgp = peer->bgp; -#ifdef DISABLE_BGP_ANNOUNCE - return 0; -#endif + if (DISABLE_BGP_ANNOUNCE) + return 0; /* Do not send announces to RS-clients from the 'normal' bgp_table. */ if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) @@ -1095,9 +1056,8 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient, filter = &rsclient->filter[afi][safi]; bgp = rsclient->bgp; -#ifdef DISABLE_BGP_ANNOUNCE - return 0; -#endif + if (DISABLE_BGP_ANNOUNCE) + return 0; /* Do not send back route to sender. */ if (from == rsclient) @@ -2680,10 +2640,10 @@ bgp_clear_node_complete (struct work_queue *wq) { struct peer *peer = wq->spec.data; - peer_unlock (peer); /* bgp_clear_node_complete */ - /* Tickle FSM to start moving again */ BGP_EVENT_ADD (peer, Clearing_Completed); + + peer_unlock (peer); /* bgp_clear_node_complete */ } static void @@ -3123,10 +3083,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt, static struct bgp_static * bgp_static_new () { - struct bgp_static *new; - new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); - memset (new, 0, sizeof (struct bgp_static)); - return new; + return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static)); } static void @@ -4511,10 +4468,7 @@ struct bgp_aggregate static struct bgp_aggregate * bgp_aggregate_new () { - struct bgp_aggregate *new; - new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); - memset (new, 0, sizeof (struct bgp_aggregate)); - return new; + return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate)); } static void @@ -10861,10 +10815,7 @@ struct bgp_distance static struct bgp_distance * bgp_distance_new () { - struct bgp_distance *new; - new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); - memset (new, 0, sizeof (struct bgp_distance)); - return new; + return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance)); } static void diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index e5987972..3e65bb10 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -174,8 +174,25 @@ extern void bgp_clear_route_all (struct peer *); extern void bgp_clear_adj_in (struct peer *, afi_t, safi_t); extern void bgp_clear_stale_route (struct peer *, afi_t, safi_t); -extern struct bgp_info *bgp_info_lock (struct bgp_info *); -extern struct bgp_info *bgp_info_unlock (struct bgp_info *); +extern void bgp_info_free (struct bgp_info *); + +static inline struct bgp_info * +bgp_info_lock (struct bgp_info *binfo) +{ + binfo->lock++; + return binfo; +} + +static inline void +bgp_info_unlock (struct bgp_info *binfo) +{ + assert (binfo && binfo->lock > 0); + binfo->lock--; + + if (binfo->lock == 0) + bgp_info_free (binfo); +} + extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri); extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri); extern struct bgp_info_extra *bgp_info_extra_get (struct bgp_info *); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index b93b2682..78ad3f08 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -47,6 +47,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_filter.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_ecommunity.h" +#include "bgpd/bgp_vty.h" /* Memo of route-map commands. @@ -3451,7 +3452,7 @@ DEFUN (no_set_atomic_aggregate, DEFUN (set_aggregator_as, set_aggregator_as_cmd, - "set aggregator as CMD_AS_RANGE A.B.C.D", + "set aggregator as " CMD_AS_RANGE " A.B.C.D", SET_STR "BGP aggregator attribute\n" "AS number of aggregator\n" @@ -3523,7 +3524,7 @@ DEFUN (no_set_aggregator_as, ALIAS (no_set_aggregator_as, no_set_aggregator_as_val_cmd, - "no set aggregator as CMD_AS_RANGE A.B.C.D", + "no set aggregator as " CMD_AS_RANGE " A.B.C.D", NO_STR SET_STR "BGP aggregator attribute\n" diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index 5faf5856..15630a24 100644 --- a/bgpd/bgp_table.c +++ b/bgpd/bgp_table.c @@ -28,16 +28,15 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgpd.h" #include "bgpd/bgp_table.h" -void bgp_node_delete (struct bgp_node *); -void bgp_table_free (struct bgp_table *); +static void bgp_node_delete (struct bgp_node *); +static void bgp_table_free (struct bgp_table *); struct bgp_table * bgp_table_init (afi_t afi, safi_t safi) { struct bgp_table *rt; - rt = XMALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table)); - memset (rt, 0, sizeof (struct bgp_table)); + rt = XCALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table)); rt->type = BGP_TABLE_MAIN; rt->afi = afi; @@ -47,19 +46,16 @@ bgp_table_init (afi_t afi, safi_t safi) } void -bgp_table_finish (struct bgp_table *rt) +bgp_table_finish (struct bgp_table **rt) { - bgp_table_free (rt); + bgp_table_free (*rt); + *rt = NULL; } static struct bgp_node * bgp_node_create () { - struct bgp_node *rn; - - rn = (struct bgp_node *) XMALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node)); - memset (rn, 0, sizeof (struct bgp_node)); - return rn; + return XCALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node)); } /* Allocate new route node with prefix set. */ @@ -84,7 +80,7 @@ bgp_node_free (struct bgp_node *node) } /* Free route table. */ -void +static void bgp_table_free (struct bgp_table *rt) { struct bgp_node *tmp_node; @@ -229,7 +225,7 @@ bgp_unlock_node (struct bgp_node *node) /* Find matched prefix. */ struct bgp_node * -bgp_node_match (struct bgp_table *table, struct prefix *p) +bgp_node_match (const struct bgp_table *table, struct prefix *p) { struct bgp_node *node; struct bgp_node *matched; @@ -255,7 +251,7 @@ bgp_node_match (struct bgp_table *table, struct prefix *p) } struct bgp_node * -bgp_node_match_ipv4 (struct bgp_table *table, struct in_addr *addr) +bgp_node_match_ipv4 (const struct bgp_table *table, struct in_addr *addr) { struct prefix_ipv4 p; @@ -269,7 +265,7 @@ bgp_node_match_ipv4 (struct bgp_table *table, struct in_addr *addr) #ifdef HAVE_IPV6 struct bgp_node * -bgp_node_match_ipv6 (struct bgp_table *table, struct in6_addr *addr) +bgp_node_match_ipv6 (const struct bgp_table *table, struct in6_addr *addr) { struct prefix_ipv6 p; @@ -284,7 +280,7 @@ bgp_node_match_ipv6 (struct bgp_table *table, struct in6_addr *addr) /* Lookup same prefix node. Return NULL when we can't find route. */ struct bgp_node * -bgp_node_lookup (struct bgp_table *table, struct prefix *p) +bgp_node_lookup (const struct bgp_table *table, struct prefix *p) { struct bgp_node *node; @@ -304,7 +300,7 @@ bgp_node_lookup (struct bgp_table *table, struct prefix *p) /* Add node to routing table. */ struct bgp_node * -bgp_node_get (struct bgp_table *table, struct prefix *p) +bgp_node_get (struct bgp_table *const table, struct prefix *p) { struct bgp_node *new; struct bgp_node *node; @@ -360,7 +356,7 @@ bgp_node_get (struct bgp_table *table, struct prefix *p) } /* Delete node from the routing table. */ -void +static void bgp_node_delete (struct bgp_node *node) { struct bgp_node *child; @@ -405,7 +401,7 @@ bgp_node_delete (struct bgp_node *node) /* Get fist node and lock it. This function is useful when one want to lookup all the node exist in the routing table. */ struct bgp_node * -bgp_table_top (struct bgp_table *table) +bgp_table_top (const struct bgp_table *const table) { /* If there is no node in the routing table return NULL. */ if (table->top == NULL) @@ -499,7 +495,7 @@ bgp_route_next_until (struct bgp_node *node, struct bgp_node *limit) } unsigned long -bgp_table_count (struct bgp_table *table) +bgp_table_count (const struct bgp_table *table) { return table->count; } diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h index 62421e71..dfa7e1f3 100644 --- a/bgpd/bgp_table.h +++ b/bgpd/bgp_table.h @@ -68,21 +68,20 @@ struct bgp_node }; extern struct bgp_table *bgp_table_init (afi_t, safi_t); -extern void bgp_table_finish (struct bgp_table *); +extern void bgp_table_finish (struct bgp_table **); extern void bgp_unlock_node (struct bgp_node *node); -extern void bgp_node_delete (struct bgp_node *node); -extern struct bgp_node *bgp_table_top (struct bgp_table *); +extern struct bgp_node *bgp_table_top (const struct bgp_table *const); extern struct bgp_node *bgp_route_next (struct bgp_node *); extern struct bgp_node *bgp_route_next_until (struct bgp_node *, struct bgp_node *); -extern struct bgp_node *bgp_node_get (struct bgp_table *, struct prefix *); -extern struct bgp_node *bgp_node_lookup (struct bgp_table *, struct prefix *); +extern struct bgp_node *bgp_node_get (struct bgp_table *const, struct prefix *); +extern struct bgp_node *bgp_node_lookup (const struct bgp_table *const, struct prefix *); extern struct bgp_node *bgp_lock_node (struct bgp_node *node); -extern struct bgp_node *bgp_node_match (struct bgp_table *, struct prefix *); -extern struct bgp_node *bgp_node_match_ipv4 (struct bgp_table *, +extern struct bgp_node *bgp_node_match (const struct bgp_table *, struct prefix *); +extern struct bgp_node *bgp_node_match_ipv4 (const struct bgp_table *, struct in_addr *); #ifdef HAVE_IPV6 -extern struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *, +extern struct bgp_node *bgp_node_match_ipv6 (const struct bgp_table *, struct in6_addr *); #endif /* HAVE_IPV6 */ -extern unsigned long bgp_table_count (struct bgp_table *); +extern unsigned long bgp_table_count (const struct bgp_table *const); #endif /* _QUAGGA_BGP_TABLE_H */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0e689359..fc560d17 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -210,6 +210,9 @@ bgp_vty_return (struct vty *vty, int ret) case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: str = "Cannot have local-as same as BGP AS number"; break; + case BGP_ERR_TCPSIG_FAILED: + str = "Error while applying TCP-Sig to session(s)"; + break; } if (str) { @@ -308,7 +311,7 @@ DEFUN_DEPRECATED (neighbor_version, /* "router bgp" commands. */ DEFUN (router_bgp, router_bgp_cmd, - "router bgp CMD_AS_RANGE", + "router bgp " CMD_AS_RANGE, ROUTER_STR BGP_STR AS_STR) @@ -331,12 +334,12 @@ DEFUN (router_bgp, VTY_NEWLINE); return CMD_WARNING; case BGP_ERR_AS_MISMATCH: - vty_out (vty, "BGP is already running; AS is %u%s", (unsigned)as, VTY_NEWLINE); + vty_out (vty, "BGP is already running; AS is %d%s", as, VTY_NEWLINE); return CMD_WARNING; case BGP_ERR_INSTANCE_MISMATCH: vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE); - vty_out (vty, "BGP instance is already running; AS is %u%s", - (unsigned)as, VTY_NEWLINE); + vty_out (vty, "BGP instance is already running; AS is %d%s", + as, VTY_NEWLINE); return CMD_WARNING; } @@ -348,7 +351,7 @@ DEFUN (router_bgp, ALIAS (router_bgp, router_bgp_view_cmd, - "router bgp CMD_AS_RANGE view WORD", + "router bgp " CMD_AS_RANGE " view WORD", ROUTER_STR BGP_STR AS_STR @@ -358,7 +361,7 @@ ALIAS (router_bgp, /* "no router bgp" commands. */ DEFUN (no_router_bgp, no_router_bgp_cmd, - "no router bgp CMD_AS_RANGE", + "no router bgp " CMD_AS_RANGE, NO_STR ROUTER_STR BGP_STR @@ -388,7 +391,7 @@ DEFUN (no_router_bgp, ALIAS (no_router_bgp, no_router_bgp_view_cmd, - "no router bgp CMD_AS_RANGE view WORD", + "no router bgp " CMD_AS_RANGE " view WORD", NO_STR ROUTER_STR BGP_STR @@ -539,7 +542,7 @@ ALIAS (no_bgp_cluster_id, DEFUN (bgp_confederation_identifier, bgp_confederation_identifier_cmd, - "bgp confederation identifier CMD_AS_RANGE", + "bgp confederation identifier " CMD_AS_RANGE, "BGP specific commands\n" "AS confederation parameters\n" "AS number\n" @@ -580,7 +583,7 @@ DEFUN (no_bgp_confederation_identifier, ALIAS (no_bgp_confederation_identifier, no_bgp_confederation_identifier_arg_cmd, - "no bgp confederation identifier CMD_AS_RANGE", + "no bgp confederation identifier " CMD_AS_RANGE, NO_STR "BGP specific commands\n" "AS confederation parameters\n" @@ -589,7 +592,7 @@ ALIAS (no_bgp_confederation_identifier, DEFUN (bgp_confederation_peers, bgp_confederation_peers_cmd, - "bgp confederation peers .CMD_AS_RANGE", + "bgp confederation peers ." CMD_AS_RANGE, "BGP specific commands\n" "AS confederation parameters\n" "Peer ASs in BGP confederation\n" @@ -619,7 +622,7 @@ DEFUN (bgp_confederation_peers, DEFUN (no_bgp_confederation_peers, no_bgp_confederation_peers_cmd, - "no bgp confederation peers .CMD_AS_RANGE", + "no bgp confederation peers ." CMD_AS_RANGE, NO_STR "BGP specific commands\n" "AS confederation parameters\n" @@ -1277,10 +1280,10 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, switch (ret) { case BGP_ERR_PEER_GROUP_MEMBER: - vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", (unsigned)as, VTY_NEWLINE); + vty_out (vty, "%% Peer-group AS %d. Cannot configure remote-as for member%s", as, VTY_NEWLINE); return CMD_WARNING; case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: - vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", (unsigned)as, as_str, VTY_NEWLINE); + vty_out (vty, "%% The AS# can not be changed from %d to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE); return CMD_WARNING; } return bgp_vty_return (vty, ret); @@ -1288,7 +1291,7 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str, DEFUN (neighbor_remote_as, neighbor_remote_as_cmd, - NEIGHBOR_CMD2 "remote-as CMD_AS_RANGE", + NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE, NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a BGP neighbor\n" @@ -1352,7 +1355,7 @@ DEFUN (no_neighbor, ALIAS (no_neighbor, no_neighbor_remote_as_cmd, - NO_NEIGHBOR_CMD "remote-as CMD_AS_RANGE", + NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE, NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR @@ -1382,7 +1385,7 @@ DEFUN (no_neighbor_peer_group, DEFUN (no_neighbor_peer_group_remote_as, no_neighbor_peer_group_remote_as_cmd, - "no neighbor WORD remote-as CMD_AS_RANGE", + "no neighbor WORD remote-as " CMD_AS_RANGE, NO_STR NEIGHBOR_STR "Neighbor tag\n" @@ -1404,7 +1407,7 @@ DEFUN (no_neighbor_peer_group_remote_as, DEFUN (neighbor_local_as, neighbor_local_as_cmd, - NEIGHBOR_CMD2 "local-as CMD_AS_RANGE", + NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE, NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a local-as number\n" @@ -1423,7 +1426,7 @@ DEFUN (neighbor_local_as, DEFUN (neighbor_local_as_no_prepend, neighbor_local_as_no_prepend_cmd, - NEIGHBOR_CMD2 "local-as CMD_AS_RANGE no-prepend", + NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a local-as number\n" @@ -1462,7 +1465,7 @@ DEFUN (no_neighbor_local_as, ALIAS (no_neighbor_local_as, no_neighbor_local_as_val_cmd, - NO_NEIGHBOR_CMD2 "local-as CMD_AS_RANGE", + NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE, NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -1471,7 +1474,7 @@ ALIAS (no_neighbor_local_as, ALIAS (no_neighbor_local_as, no_neighbor_local_as_val2_cmd, - NO_NEIGHBOR_CMD2 "local-as CMD_AS_RANGE no-prepend", + NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -1479,7 +1482,6 @@ ALIAS (no_neighbor_local_as, "AS number used as local AS\n" "Do not prepend local-as to updates from ebgp peers\n") -#ifdef HAVE_TCP_MD5SIG DEFUN (neighbor_password, neighbor_password_cmd, NEIGHBOR_CMD2 "password LINE", @@ -1517,7 +1519,6 @@ DEFUN (no_neighbor_password, ret = peer_password_unset (peer); return bgp_vty_return (vty, ret); } -#endif /* HAVE_TCP_MD5SIG */ DEFUN (neighbor_activate, neighbor_activate_cmd, @@ -1600,7 +1601,7 @@ DEFUN (neighbor_set_peer_group, if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { - vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", (unsigned)as, VTY_NEWLINE); + vty_out (vty, "%% Peer with AS %d cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE); return CMD_WARNING; } @@ -2193,8 +2194,7 @@ peer_rsclient_unset_vty (struct vty *vty, const char *peer_str, listnode_delete (bgp->rsclient, peer); } - bgp_table_finish (peer->rib[afi][safi]); - peer->rib[afi][safi] = NULL; + bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]); return CMD_SUCCESS; } @@ -4363,7 +4363,7 @@ ALIAS (clear_ip_bgp_external, DEFUN (clear_ip_bgp_as, clear_ip_bgp_as_cmd, - "clear ip bgp CMD_AS_RANGE", + "clear ip bgp " CMD_AS_RANGE, CLEAR_STR IP_STR BGP_STR @@ -4374,14 +4374,14 @@ DEFUN (clear_ip_bgp_as, ALIAS (clear_ip_bgp_as, clear_bgp_as_cmd, - "clear bgp CMD_AS_RANGE", + "clear bgp " CMD_AS_RANGE, CLEAR_STR BGP_STR "Clear peers with the AS number\n") ALIAS (clear_ip_bgp_as, clear_bgp_ipv6_as_cmd, - "clear bgp ipv6 CMD_AS_RANGE", + "clear bgp ipv6 " CMD_AS_RANGE, CLEAR_STR BGP_STR "Address family\n" @@ -4893,7 +4893,7 @@ ALIAS (clear_bgp_external_soft_out, DEFUN (clear_ip_bgp_as_soft_out, clear_ip_bgp_as_soft_out_cmd, - "clear ip bgp CMD_AS_RANGE soft out", + "clear ip bgp " CMD_AS_RANGE " soft out", CLEAR_STR IP_STR BGP_STR @@ -4907,7 +4907,7 @@ DEFUN (clear_ip_bgp_as_soft_out, ALIAS (clear_ip_bgp_as_soft_out, clear_ip_bgp_as_out_cmd, - "clear ip bgp CMD_AS_RANGE out", + "clear ip bgp " CMD_AS_RANGE " out", CLEAR_STR IP_STR BGP_STR @@ -4916,7 +4916,7 @@ ALIAS (clear_ip_bgp_as_soft_out, DEFUN (clear_ip_bgp_as_ipv4_soft_out, clear_ip_bgp_as_ipv4_soft_out_cmd, - "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) soft out", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR @@ -4937,7 +4937,7 @@ DEFUN (clear_ip_bgp_as_ipv4_soft_out, ALIAS (clear_ip_bgp_as_ipv4_soft_out, clear_ip_bgp_as_ipv4_out_cmd, - "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) out", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR @@ -4949,7 +4949,7 @@ ALIAS (clear_ip_bgp_as_ipv4_soft_out, DEFUN (clear_ip_bgp_as_vpnv4_soft_out, clear_ip_bgp_as_vpnv4_soft_out_cmd, - "clear ip bgp CMD_AS_RANGE vpnv4 unicast soft out", + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out", CLEAR_STR IP_STR BGP_STR @@ -4965,7 +4965,7 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft_out, ALIAS (clear_ip_bgp_as_vpnv4_soft_out, clear_ip_bgp_as_vpnv4_out_cmd, - "clear ip bgp CMD_AS_RANGE vpnv4 unicast out", + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out", CLEAR_STR IP_STR BGP_STR @@ -4976,7 +4976,7 @@ ALIAS (clear_ip_bgp_as_vpnv4_soft_out, DEFUN (clear_bgp_as_soft_out, clear_bgp_as_soft_out_cmd, - "clear bgp CMD_AS_RANGE soft out", + "clear bgp " CMD_AS_RANGE " soft out", CLEAR_STR BGP_STR "Clear peers with the AS number\n" @@ -4989,7 +4989,7 @@ DEFUN (clear_bgp_as_soft_out, ALIAS (clear_bgp_as_soft_out, clear_bgp_ipv6_as_soft_out_cmd, - "clear bgp ipv6 CMD_AS_RANGE soft out", + "clear bgp ipv6 " CMD_AS_RANGE " soft out", CLEAR_STR BGP_STR "Address family\n" @@ -4999,7 +4999,7 @@ ALIAS (clear_bgp_as_soft_out, ALIAS (clear_bgp_as_soft_out, clear_bgp_as_out_cmd, - "clear bgp CMD_AS_RANGE out", + "clear bgp " CMD_AS_RANGE " out", CLEAR_STR BGP_STR "Clear peers with the AS number\n" @@ -5007,7 +5007,7 @@ ALIAS (clear_bgp_as_soft_out, ALIAS (clear_bgp_as_soft_out, clear_bgp_ipv6_as_out_cmd, - "clear bgp ipv6 CMD_AS_RANGE out", + "clear bgp ipv6 " CMD_AS_RANGE " out", CLEAR_STR BGP_STR "Address family\n" @@ -5797,7 +5797,7 @@ ALIAS (clear_bgp_external_in_prefix_filter, DEFUN (clear_ip_bgp_as_soft_in, clear_ip_bgp_as_soft_in_cmd, - "clear ip bgp CMD_AS_RANGE soft in", + "clear ip bgp " CMD_AS_RANGE " soft in", CLEAR_STR IP_STR BGP_STR @@ -5811,7 +5811,7 @@ DEFUN (clear_ip_bgp_as_soft_in, ALIAS (clear_ip_bgp_as_soft_in, clear_ip_bgp_as_in_cmd, - "clear ip bgp CMD_AS_RANGE in", + "clear ip bgp " CMD_AS_RANGE " in", CLEAR_STR IP_STR BGP_STR @@ -5820,7 +5820,7 @@ ALIAS (clear_ip_bgp_as_soft_in, DEFUN (clear_ip_bgp_as_in_prefix_filter, clear_ip_bgp_as_in_prefix_filter_cmd, - "clear ip bgp CMD_AS_RANGE in prefix-filter", + "clear ip bgp " CMD_AS_RANGE " in prefix-filter", CLEAR_STR IP_STR BGP_STR @@ -5834,7 +5834,7 @@ DEFUN (clear_ip_bgp_as_in_prefix_filter, DEFUN (clear_ip_bgp_as_ipv4_soft_in, clear_ip_bgp_as_ipv4_soft_in_cmd, - "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) soft in", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR @@ -5855,7 +5855,7 @@ DEFUN (clear_ip_bgp_as_ipv4_soft_in, ALIAS (clear_ip_bgp_as_ipv4_soft_in, clear_ip_bgp_as_ipv4_in_cmd, - "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) in", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR @@ -5867,7 +5867,7 @@ ALIAS (clear_ip_bgp_as_ipv4_soft_in, DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, clear_ip_bgp_as_ipv4_in_prefix_filter_cmd, - "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) in prefix-filter", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR @@ -5888,7 +5888,7 @@ DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, DEFUN (clear_ip_bgp_as_vpnv4_soft_in, clear_ip_bgp_as_vpnv4_soft_in_cmd, - "clear ip bgp CMD_AS_RANGE vpnv4 unicast soft in", + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in", CLEAR_STR IP_STR BGP_STR @@ -5904,7 +5904,7 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft_in, ALIAS (clear_ip_bgp_as_vpnv4_soft_in, clear_ip_bgp_as_vpnv4_in_cmd, - "clear ip bgp CMD_AS_RANGE vpnv4 unicast in", + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in", CLEAR_STR IP_STR BGP_STR @@ -5915,7 +5915,7 @@ ALIAS (clear_ip_bgp_as_vpnv4_soft_in, DEFUN (clear_bgp_as_soft_in, clear_bgp_as_soft_in_cmd, - "clear bgp CMD_AS_RANGE soft in", + "clear bgp " CMD_AS_RANGE " soft in", CLEAR_STR BGP_STR "Clear peers with the AS number\n" @@ -5928,7 +5928,7 @@ DEFUN (clear_bgp_as_soft_in, ALIAS (clear_bgp_as_soft_in, clear_bgp_ipv6_as_soft_in_cmd, - "clear bgp ipv6 CMD_AS_RANGE soft in", + "clear bgp ipv6 " CMD_AS_RANGE " soft in", CLEAR_STR BGP_STR "Address family\n" @@ -5938,7 +5938,7 @@ ALIAS (clear_bgp_as_soft_in, ALIAS (clear_bgp_as_soft_in, clear_bgp_as_in_cmd, - "clear bgp CMD_AS_RANGE in", + "clear bgp " CMD_AS_RANGE " in", CLEAR_STR BGP_STR "Clear peers with the AS number\n" @@ -5946,7 +5946,7 @@ ALIAS (clear_bgp_as_soft_in, ALIAS (clear_bgp_as_soft_in, clear_bgp_ipv6_as_in_cmd, - "clear bgp ipv6 CMD_AS_RANGE in", + "clear bgp ipv6 " CMD_AS_RANGE " in", CLEAR_STR BGP_STR "Address family\n" @@ -5955,7 +5955,7 @@ ALIAS (clear_bgp_as_soft_in, DEFUN (clear_bgp_as_in_prefix_filter, clear_bgp_as_in_prefix_filter_cmd, - "clear bgp CMD_AS_RANGE in prefix-filter", + "clear bgp " CMD_AS_RANGE " in prefix-filter", CLEAR_STR BGP_STR "Clear peers with the AS number\n" @@ -5968,7 +5968,7 @@ DEFUN (clear_bgp_as_in_prefix_filter, ALIAS (clear_bgp_as_in_prefix_filter, clear_bgp_ipv6_as_in_prefix_filter_cmd, - "clear bgp ipv6 CMD_AS_RANGE in prefix-filter", + "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter", CLEAR_STR BGP_STR "Address family\n" @@ -6283,7 +6283,7 @@ ALIAS (clear_bgp_external_soft, DEFUN (clear_ip_bgp_as_soft, clear_ip_bgp_as_soft_cmd, - "clear ip bgp CMD_AS_RANGE soft", + "clear ip bgp " CMD_AS_RANGE " soft", CLEAR_STR IP_STR BGP_STR @@ -6296,7 +6296,7 @@ DEFUN (clear_ip_bgp_as_soft, DEFUN (clear_ip_bgp_as_ipv4_soft, clear_ip_bgp_as_ipv4_soft_cmd, - "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) soft", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -6316,7 +6316,7 @@ DEFUN (clear_ip_bgp_as_ipv4_soft, DEFUN (clear_ip_bgp_as_vpnv4_soft, clear_ip_bgp_as_vpnv4_soft_cmd, - "clear ip bgp CMD_AS_RANGE vpnv4 unicast soft", + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft", CLEAR_STR IP_STR BGP_STR @@ -6331,7 +6331,7 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft, DEFUN (clear_bgp_as_soft, clear_bgp_as_soft_cmd, - "clear bgp CMD_AS_RANGE soft", + "clear bgp " CMD_AS_RANGE " soft", CLEAR_STR BGP_STR "Clear peers with the AS number\n" @@ -6343,7 +6343,7 @@ DEFUN (clear_bgp_as_soft, ALIAS (clear_bgp_as_soft, clear_bgp_ipv6_as_soft_cmd, - "clear bgp ipv6 CMD_AS_RANGE soft", + "clear bgp ipv6 " CMD_AS_RANGE " soft", CLEAR_STR BGP_STR "Address family\n" @@ -6669,8 +6669,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi) /* Usage summary and header */ vty_out (vty, - "BGP router identifier %s, local AS number %u%s", - inet_ntoa (bgp->router_id), (unsigned)bgp->as, VTY_NEWLINE); + "BGP router identifier %s, local AS number %d%s", + inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE); ents = bgp_table_count (bgp->rib[afi][safi]); vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, @@ -6716,8 +6716,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi) vty_out (vty, "4 "); - vty_out (vty, "%5u %7d %7d %8d %4d %4lu ", - (unsigned)peer->as, + vty_out (vty, "%5d %7d %7d %8d %4d %4lu ", + peer->as, peer->open_in + peer->update_in + peer->keepalive_in + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in, peer->open_out + peer->update_out + peer->keepalive_out @@ -7226,9 +7226,9 @@ bgp_show_peer (struct vty *vty, struct peer *p) /* Configured IP address. */ vty_out (vty, "BGP neighbor is %s, ", p->host); - vty_out (vty, "remote AS %u, ", (unsigned)p->as); - vty_out (vty, "local AS %u%s, ", - p->change_local_as ? (unsigned)p->change_local_as : (unsigned)p->local_as, + vty_out (vty, "remote AS %d, ", p->as); + vty_out (vty, "local AS %d%s, ", + p->change_local_as ? p->change_local_as : p->local_as, CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? " no-prepend" : ""); vty_out (vty, "%s link%s", @@ -8009,7 +8009,7 @@ bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, "Route Server's BGP router identifier %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); vty_out (vty, - "Route Server's local AS number %u%s", (unsigned)bgp->as, + "Route Server's local AS number %d%s", bgp->as, VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE); @@ -8749,42 +8749,42 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, } /* BGP node structure. */ -struct cmd_node bgp_node = +static struct cmd_node bgp_node = { BGP_NODE, "%s(config-router)# ", 1, }; -struct cmd_node bgp_ipv4_unicast_node = +static struct cmd_node bgp_ipv4_unicast_node = { BGP_IPV4_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_ipv4_multicast_node = +static struct cmd_node bgp_ipv4_multicast_node = { BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_ipv6_unicast_node = +static struct cmd_node bgp_ipv6_unicast_node = { BGP_IPV6_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_ipv6_multicast_node = +static struct cmd_node bgp_ipv6_multicast_node = { BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, }; -struct cmd_node bgp_vpnv4_node = +static struct cmd_node bgp_vpnv4_node = { BGP_VPNV4_NODE, "%s(config-router-af)# ", @@ -8938,11 +8938,9 @@ bgp_vty_init (void) install_element (BGP_NODE, &no_neighbor_local_as_val_cmd); install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd); -#ifdef HAVE_TCP_MD5SIG /* "neighbor password" commands. */ install_element (BGP_NODE, &neighbor_password_cmd); install_element (BGP_NODE, &no_neighbor_password_cmd); -#endif /* HAVE_TCP_MD5SIG */ /* "neighbor activate" commands. */ install_element (BGP_NODE, &neighbor_activate_cmd); @@ -10675,7 +10673,7 @@ community_list_config_write (struct vty *vty) return write; } -struct cmd_node community_list_node = +static struct cmd_node community_list_node = { COMMUNITY_LIST_NODE, "", diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index ec1143af..943b1777 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -640,7 +640,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, } #if 0 -#ifdef HAVE_IPV6 static unsigned int bgp_ifindex_by_nexthop (struct in6_addr *addr) { @@ -671,7 +670,6 @@ bgp_ifindex_by_nexthop (struct in6_addr *addr) } return 0; } -#endif /* HAVE_IPV6 */ #endif void diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index b37e577d..7f6ca168 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -114,46 +114,6 @@ bgp_option_check (int flag) return CHECK_FLAG (bm->options, flag); } -/* BGP flag manipulation. */ -int -bgp_flag_set (struct bgp *bgp, int flag) -{ - SET_FLAG (bgp->flags, flag); - return 0; -} - -int -bgp_flag_unset (struct bgp *bgp, int flag) -{ - UNSET_FLAG (bgp->flags, flag); - return 0; -} - -int -bgp_flag_check (struct bgp *bgp, int flag) -{ - return CHECK_FLAG (bgp->flags, flag); -} - -/* Internal function to set BGP structure configureation flag. */ -static void -bgp_config_set (struct bgp *bgp, int config) -{ - SET_FLAG (bgp->config, config); -} - -static void -bgp_config_unset (struct bgp *bgp, int config) -{ - UNSET_FLAG (bgp->config, config); -} - -static int -bgp_config_check (struct bgp *bgp, int config) -{ - return CHECK_FLAG (bgp->config, config); -} - /* Set BGP router identifier. */ int bgp_router_id_set (struct bgp *bgp, struct in_addr *id) @@ -684,7 +644,7 @@ peer_sort (struct peer *peer) } } -static inline void +void peer_free (struct peer *peer) { assert (peer->status == Deleted); @@ -719,49 +679,6 @@ peer_free (struct peer *peer) XFREE (MTYPE_BGP_PEER, peer); } - -/* increase reference count on a struct peer */ -struct peer * -peer_lock (struct peer *peer) -{ - assert (peer && (peer->lock >= 0)); - assert (peer->status != Deleted); - - peer->lock++; - - return peer; -} - -/* decrease reference count on a struct peer - * struct peer is freed and NULL returned if last reference - */ -struct peer * -peer_unlock (struct peer *peer) -{ - assert (peer && (peer->lock > 0)); - - peer->lock--; - - if (peer->lock == 0) - { -#if 0 - zlog_debug ("unlocked and freeing"); - zlog_backtrace (LOG_DEBUG); -#endif - peer_free (peer); - return NULL; - } - -#if 0 - if (peer->lock == 1) - { - zlog_debug ("unlocked to 1"); - zlog_backtrace (LOG_DEBUG); - } -#endif - - return peer; -} /* Allocate new peer object, implicitely locked. */ static struct peer * @@ -1190,7 +1107,7 @@ peer_delete (struct peer *peer) if ((pn = listnode_lookup (peer->group->peer, peer))) { - peer = peer_unlock (peer); /* group->peer list reference */ + peer_unlock (peer); /* group->peer list reference */ list_delete_node (peer->group->peer, pn); } peer->group = NULL; @@ -1204,19 +1121,16 @@ peer_delete (struct peer *peer) bgp_stop (peer); bgp_fsm_change_status (peer, Deleted); -#ifdef HAVE_TCP_MD5SIG /* Password configuration */ if (peer->password) { - free (peer->password); + XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; - if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) - && sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, NULL); + if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) + bgp_md5_set (peer); } -#endif /* HAVE_TCP_MD5SIG */ - + bgp_timer_set (peer); /* stops all timers for Deleted */ /* Delete from all peer list. */ @@ -1243,10 +1157,7 @@ peer_delete (struct peer *peer) for (afi = AFI_IP; afi < AFI_MAX; afi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) if (peer->rib[afi][safi] && ! peer->af_group[afi][safi]) - { - bgp_table_finish (peer->rib[afi][safi]); - peer->rib[afi][safi] = NULL; - } + bgp_table_finish (&peer->rib[afi][safi]); /* Buffers. */ if (peer->ibuf) @@ -1435,26 +1346,16 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer, else peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV; -#ifdef HAVE_TCP_MD5SIG /* password apply */ - if (CHECK_FLAG (conf->flags, PEER_FLAG_PASSWORD)) - { - if (peer->password) - free (peer->password); - peer->password = strdup (conf->password); + if (peer->password) + XFREE (MTYPE_PEER_PASSWORD, peer->password); - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, peer->password); - } - else if (peer->password) - { - free (peer->password); - peer->password = NULL; + if (conf->password) + peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, conf->password); + else + peer->password = NULL; - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, NULL); - } -#endif /* HAVE_TCP_MD5SIG */ + bgp_md5_set (peer); /* maximum-prefix */ peer->pmax[afi][safi] = conf->pmax[afi][safi]; @@ -1837,8 +1738,7 @@ peer_group_bind (struct bgp *bgp, union sockunion *su, list_delete_node (bgp->rsclient, pn); } - bgp_table_finish (peer->rib[afi][safi]); - peer->rib[afi][safi] = NULL; + bgp_table_finish (&peer->rib[afi][safi]); /* Import policy. */ if (peer->filter[afi][safi].map[RMAP_IMPORT].name) @@ -2054,7 +1954,7 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name) } /* Delete BGP instance. */ -int +void bgp_delete (struct bgp *bgp) { struct peer *peer; @@ -2102,8 +2002,6 @@ bgp_delete (struct bgp *bgp) XFREE (MTYPE_ROUTE_TABLE,bgp->rib[afi][safi]); } XFREE (MTYPE_BGP, bgp); - - return 0; } struct peer * @@ -3419,26 +3317,25 @@ peer_local_as_unset (struct peer *peer) return 0; } -#ifdef HAVE_TCP_MD5SIG /* Set password for authenticating with the peer. */ int peer_password_set (struct peer *peer, const char *password) { - struct peer_group *group; struct listnode *nn, *nnode; int len = password ? strlen(password) : 0; + int ret = BGP_SUCCESS; if ((len < PEER_PASSWORD_MINLEN) || (len > PEER_PASSWORD_MAXLEN)) return BGP_ERR_INVALID_VALUE; if (peer->password && strcmp (peer->password, password) == 0 && ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) - return 0; + return 0; - SET_FLAG (peer->flags, PEER_FLAG_PASSWORD); if (peer->password) - free (peer->password); - peer->password = strdup (password); + XFREE (MTYPE_PEER_PASSWORD, peer->password); + + peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, password); if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { @@ -3446,50 +3343,46 @@ peer_password_set (struct peer *peer, const char *password) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); - - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, peer->password); - return 0; + + return (bgp_md5_set (peer) >= 0) ? BGP_SUCCESS : BGP_ERR_TCPSIG_FAILED; } - group = peer->group; - /* #42# LIST_LOOP (group->peer, peer, nn) */ - for (ALL_LIST_ELEMENTS (group->peer, nn, nnode, peer)) + for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer)) { if (peer->password && strcmp (peer->password, password) == 0) continue; - - SET_FLAG (peer->flags, PEER_FLAG_PASSWORD); + if (peer->password) - free (peer->password); - peer->password = strdup (password); + XFREE (MTYPE_PEER_PASSWORD, peer->password); + + peer->password = XSTRDUP(MTYPE_PEER_PASSWORD, password); if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); - - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, peer->password); + + if (bgp_md5_set (peer) < 0) + ret = BGP_ERR_TCPSIG_FAILED; } - return 0; + return ret; } int peer_password_unset (struct peer *peer) { - struct peer_group *group; struct listnode *nn, *nnode; - if (! CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD) - && ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) + if (!peer->password + && !CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) return 0; - if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) + if (!CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (peer_group_active (peer) - && CHECK_FLAG (peer->group->conf->flags, PEER_FLAG_PASSWORD)) + && peer->group->conf->password + && strcmp (peer->group->conf->password, peer->password) == 0) return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; if (peer->status == Established) @@ -3497,46 +3390,37 @@ peer_password_unset (struct peer *peer) else BGP_EVENT_ADD (peer, BGP_Stop); - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, NULL); - - UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD); if (peer->password) - free (peer->password); + XFREE (MTYPE_PEER_PASSWORD, peer->password); + peer->password = NULL; + + bgp_md5_set (peer); return 0; } - UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD); - if (peer->password) - free (peer->password); + XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; - group = peer->group; - /* #42# LIST_LOOP (group->peer, peer, nn) */ - for (ALL_LIST_ELEMENTS (group->peer, nn, nnode, peer)) + for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer)) { - if (! CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD)) + if (!peer->password) continue; if (peer->status == Established) bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); else BGP_EVENT_ADD (peer, BGP_Stop); - - if (sockunion_family (&peer->su) == AF_INET) - bgp_md5_set (bm->sock, &peer->su.sin, NULL); - - UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD); - if (peer->password) - free (peer->password); + + XFREE (MTYPE_PEER_PASSWORD, peer->password); peer->password = NULL; + + bgp_md5_set (peer); } return 0; } -#endif /* HAVE_TCP_MD5SIG */ /* Set distribute list to the peer. */ int @@ -4543,13 +4427,13 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp, vty_out (vty, " neighbor %s peer-group%s", addr, VTY_NEWLINE); if (peer->as) - vty_out (vty, " neighbor %s remote-as %u%s", addr, (unsigned)peer->as, + vty_out (vty, " neighbor %s remote-as %d%s", addr, peer->as, VTY_NEWLINE); } else { if (! g_peer->as) - vty_out (vty, " neighbor %s remote-as %u%s", addr, (unsigned)peer->as, + vty_out (vty, " neighbor %s remote-as %d%s", addr, peer->as, VTY_NEWLINE); if (peer->af_group[AFI_IP][SAFI_UNICAST]) vty_out (vty, " neighbor %s peer-group %s%s", addr, @@ -4575,19 +4459,17 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp, ! CHECK_FLAG (g_peer->flags, PEER_FLAG_SHUTDOWN)) vty_out (vty, " neighbor %s shutdown%s", addr, VTY_NEWLINE); -#ifdef HAVE_TCP_MD5SIG /* Password. */ - if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD)) - if (! peer_group_active (peer) - || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSWORD) + if (peer->password) + if (!peer_group_active (peer) + || ! g_peer->password || strcmp (peer->password, g_peer->password) != 0) vty_out (vty, " neighbor %s password %s%s", addr, peer->password, VTY_NEWLINE); -#endif /* HAVE_TCP_MD5SIG */ /* BGP port. */ if (peer->port != BGP_PORT_DEFAULT) - vty_out (vty, " neighbor %s port %d%s", addr, peer->port, + vty_out (vty, " neighbor %s port %d%s", addr, peer->port, VTY_NEWLINE); /* Local interface name. */ @@ -4950,7 +4832,7 @@ bgp_config_write (struct vty *vty) vty_out (vty, "!%s", VTY_NEWLINE); /* Router bgp ASN */ - vty_out (vty, "router bgp %u", (unsigned)bgp->as); + vty_out (vty, "router bgp %d", bgp->as); if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) { @@ -5117,12 +4999,10 @@ bgp_master_init (void) bm = &bgp_master; bm->bgp = list_new (); + bm->listen_sockets = list_new (); bm->port = BGP_PORT_DEFAULT; bm->master = thread_master_create (); bm->start_time = time (NULL); -#ifdef HAVE_TCP_MD5SIG - bm->sock = -1; -#endif /* HAVE_TCP_MD5SIG */ } diff --git a/bgpd/bgpd.conf.sample b/bgpd/bgpd.conf.sample index 62cacc85..b6a8b6f1 100644 --- a/bgpd/bgpd.conf.sample +++ b/bgpd/bgpd.conf.sample @@ -2,7 +2,7 @@ ! ! BGPd sample configuratin file ! -! $Id$ +! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $ ! hostname bgpd password zebra diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index ef1f860b..f699dc35 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -42,6 +42,9 @@ struct bgp_master struct work_queue *process_main_queue; struct work_queue *process_rsclient_queue; + /* Listening sockets */ + struct list *listen_sockets; + /* BGP port number. */ u_int16_t port; @@ -56,11 +59,6 @@ struct bgp_master #define BGP_OPT_NO_FIB (1 << 0) #define BGP_OPT_MULTIPLE_INSTANCE (1 << 1) #define BGP_OPT_CONFIG_CISCO (1 << 2) - -#ifdef HAVE_TCP_MD5SIG - /* bgp receive socket */ - int sock; -#endif /* HAVE_TCP_MD5SIG */ }; /* BGP instance structure. */ @@ -363,7 +361,6 @@ struct peer /* NSF mode (graceful restart) */ u_char nsf[AFI_MAX][SAFI_MAX]; -#define PEER_FLAG_PASSWORD (1 << 9) /* password */ /* Per AF configuration flags. */ u_int32_t af_flags[AFI_MAX][SAFI_MAX]; @@ -383,7 +380,7 @@ struct peer #define PEER_FLAG_ORF_PREFIX_RM (1 << 13) /* orf capability receive-mode */ #define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */ #define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */ -#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */ +#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */ /* MD5 password */ char *password; @@ -543,13 +540,9 @@ struct peer #define PEER_RMAP_TYPE_EXPORT (1 << 7) /* neighbor route-map export */ }; -#if defined(HAVE_TCP_MD5SIG) - #define PEER_PASSWORD_MINLEN (1) #define PEER_PASSWORD_MAXLEN (80) -#endif /* HAVE_TCP_MD5SIG */ - /* This structure's member directly points incoming packet data stream. */ struct bgp_nlri @@ -803,7 +796,8 @@ enum bgp_clear_type #define BGP_ERR_INSTANCE_MISMATCH -26 #define BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP -27 #define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28 -#define BGP_ERR_MAX -29 +#define BGP_ERR_TCPSIG_FAILED -29 +#define BGP_ERR_MAX -30 extern struct bgp_master *bm; @@ -823,13 +817,32 @@ extern struct peer_group *peer_group_lookup (struct bgp *, const char *); extern struct peer_group *peer_group_get (struct bgp *, const char *); extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *, int *); -extern struct peer *peer_lock (struct peer *); -extern struct peer *peer_unlock (struct peer *); +extern void peer_free (struct peer *peer); extern int peer_sort (struct peer *peer); extern int peer_active (struct peer *); extern int peer_active_nego (struct peer *); extern struct peer *peer_create_accept (struct bgp *); extern char *peer_uptime (time_t, char *, size_t); + +static inline struct peer * +peer_lock (struct peer *peer) +{ + assert (peer && (peer->lock >= 0)); + assert (peer->status != Deleted); + + peer->lock++; + return peer; +} + +static inline void +peer_unlock (struct peer *peer) +{ + assert (peer && (peer->lock > 0)); + + if (--peer->lock == 0) + peer_free (peer); +} + extern int bgp_config_write (struct vty *); extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *); @@ -843,11 +856,46 @@ extern int bgp_option_unset (int); extern int bgp_option_check (int); extern int bgp_get (struct bgp **, as_t *, const char *); -extern int bgp_delete (struct bgp *); +extern void bgp_delete (struct bgp *); +extern void bgp_free (struct bgp *); -extern int bgp_flag_set (struct bgp *, int); -extern int bgp_flag_unset (struct bgp *, int); -extern int bgp_flag_check (struct bgp *, int); +/* BGP flag manipulation. */ +static inline void +bgp_flag_set (struct bgp *bgp, int flag) +{ + SET_FLAG (bgp->flags, flag); +} + +static inline void +bgp_flag_unset (struct bgp *bgp, int flag) +{ + UNSET_FLAG (bgp->flags, flag); +} + +static inline int +bgp_flag_check (const struct bgp *bgp, int flag) +{ + return CHECK_FLAG (bgp->flags, flag); +} + +/* Internal function to set BGP structure configureation flag. */ +static inline void +bgp_config_set (struct bgp *bgp, int config) +{ + SET_FLAG (bgp->config, config); +} + +static inline void +bgp_config_unset (struct bgp *bgp, int config) +{ + UNSET_FLAG (bgp->config, config); +} + +static inline int +bgp_config_check (const struct bgp *bgp, int config) +{ + return CHECK_FLAG (bgp->config, config); +} extern int bgp_router_id_set (struct bgp *, struct in_addr *); @@ -940,10 +988,9 @@ extern int peer_route_map_set (struct peer *, afi_t, safi_t, int, const char *); extern int peer_route_map_unset (struct peer *, afi_t, safi_t, int); extern int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *); -#ifdef HAVE_TCP_MD5SIG + extern int peer_password_set (struct peer *, const char *); extern int peer_password_unset (struct peer *); -#endif /* HAVE_TCP_MD5SIG */ extern int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t); diff --git a/configure.ac b/configure.ac index 1d2b2a3a..0224785c 100755 --- a/configure.ac +++ b/configure.ac @@ -5,10 +5,10 @@ ## Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org> ## Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st> ## -## $Id$ +## $Id: configure.ac,v 1.144 2008/07/22 21:11:48 paul Exp $ AC_PREREQ(2.53) -AC_INIT(Quagga, 0.99.9, [http://bugzilla.quagga.net]) +AC_INIT(Quagga, 0.99.10, [http://bugzilla.quagga.net]) AC_CONFIG_SRCDIR(lib/zebra.h) dnl ----------------------------------- @@ -208,8 +208,6 @@ AC_ARG_ENABLE(bgp-announce, [ --disable-bgp-announce, turn off BGP route announcement]) AC_ARG_ENABLE(netlink, [ --enable-netlink force to use Linux netlink interface]) -AC_ARG_ENABLE(linkdetect, -[ --enable-linkdetect use Linux link-detect configuration]) AC_ARG_ENABLE(broken-aliases, [ --enable-broken-aliases enable aliases as distinct interfaces for Linux 2.2.X]) AC_ARG_ENABLE(snmp, @@ -218,8 +216,6 @@ AC_ARG_WITH(libpam, [ --with-libpam use libpam for PAM support in vtysh]) AC_ARG_ENABLE(tcp-zebra, [ --enable-tcp-zebra enable TCP/IP socket connection between zebra and protocol daemon]) -AC_ARG_ENABLE(tcp-md5, -[ --enable-tcp-md5 enable TCP/IP md5 in BGPd]) AC_ARG_ENABLE(opaque-lsa, [ --enable-opaque-lsa enable OSPF Opaque-LSA with OSPFAPI support (RFC2370)]) AC_ARG_ENABLE(ospfapi, @@ -290,10 +286,6 @@ if test "${enable_tcp_zebra}" = "yes"; then AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication) fi -if test "${enable_tcp_md5}" = "yes"; then - AC_DEFINE(HAVE_TCP_MD5SIG,1,Enable TCP MD5 Signatures) -fi - if test "${enable_opaque_lsa}" = "yes"; then AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA) fi @@ -919,27 +911,39 @@ AC_CHECK_HEADER([net/if.h], QUAGGA_INCLUDES)], [], QUAGGA_INCLUDES ) +dnl ------------------------ +dnl TCP_MD5SIG socket option +dnl ------------------------ -dnl --------------------------------------------------------------- -dnl kernel link-detect enable via /proc/sys/net/ipv4/conf/ethX/link_detect -dnl --------------------------------------------------------------- -if test "${enable_linkdetect}" = "yes"; then - AC_DEFINE(HAVE_LINKDETECT,1,Enable Linux kernel linkdetect) - LINK_DETECT=if_linkdetect.o +AC_CHECK_HEADER([netinet/tcp.h], + [m4_define([MD5_INCLUDES], + QUAGGA_INCLUDES + [#include <netinet/tcp.h> + ]) + AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)], + [], + QUAGGA_INCLUDES) +if test $ac_cv_have_decl_TCP_MD5SIG = no; then + AC_CHECK_HEADER([linux/tcp.h], + [m4_define([MD5_INCLUDES], + QUAGGA_INCLUDES + [#include <linux/tcp.h> + ]) + AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)]) fi -AC_SUBST(LINK_DETECT) dnl ----------------------- dnl check proc file system. dnl ----------------------- -if test -r /proc/net/dev; then - AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev) - IF_PROC=if_proc.o -fi - -if test -r /proc/net/if_inet6; then - AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6) - IF_PROC=if_proc.o +if test "$netlink" != yes; then + if test -r /proc/net/dev; then + AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev) + IF_PROC=if_proc.o + fi + if test -r /proc/net/if_inet6; then + AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6) + IF_PROC=if_proc.o + fi fi AC_SUBST(IF_PROC) @@ -1209,7 +1213,9 @@ case "${enable_solaris}" in esac if test "${enable_bgp_announce}" = "no";then - AC_DEFINE(DISABLE_BGP_ANNOUNCE,,Disable BGP installation to zebra) + AC_DEFINE(DISABLE_BGP_ANNOUNCE,1,Disable BGP installation to zebra) +else + AC_DEFINE(DISABLE_BGP_ANNOUNCE,0,Disable BGP installation to zebra) fi AC_SUBST(ZEBRA) @@ -1219,7 +1225,6 @@ AC_SUBST(RIPNGD) AC_SUBST(OSPFD) AC_SUBST(OSPF6D) AC_SUBST(WATCHQUAGGA) -AC_SUBST(WATCHLINK) AC_SUBST(ISISD) AC_SUBST(SOLARIS) AC_SUBST(VTYSH) diff --git a/debian/changelog b/debian/changelog index 38e79b5c..27a97490 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -vyatta-quagga (0.99.9-14) unstable; urgency=low +vyatta-quagga (0.99.10-1) unstable; urgency=low 3.1.4 [ Mark O'Brien ] @@ -31,9 +31,9 @@ vyatta-quagga (0.99.9-13) unstable; urgency=low vyatta-quagga (0.99.9-12) unstable; urgency=low + * Merge in upstream version 0.99.10 + * Rename package from vyatta-quagga to quagga 3.1.2 - [ Mark O'Brien ] - [ Stephen Hemminger ] * Remove routes from FIB. @@ -61,7 +61,7 @@ vyatta-quagga (0.99.9-12) unstable; urgency=low [ Mark O'Brien ] - -- Mark O'Brien <mobrien@firebolt.vyatta.com> Wed, 23 Jul 2008 21:36:14 -0700 + -- Stephen Hemminger <shemminger@vyatta.com> Thu, 31 Jul 2008 14:16:57 -0700 vyatta-quagga (0.99.9-11) unstable; urgency=low diff --git a/debian/control b/debian/control index 26491df3..12718e01 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: vyatta-quagga Section: contrib/net Priority: extra -Maintainer: Tom Grennan <tgrennan@vyatta.com> +Maintainer: Stephen Hemminger <shemminger@vyatta.com> Build-Depends: debhelper (>= 5), autotools-dev, libncurses5-dev, @@ -15,14 +15,14 @@ Build-Depends: debhelper (>= 5), po-debconf, libsnmp-dev Standards-Version: 3.7.2 -Vcs-Git: http://suva.vyatta.git/quagga.git +Vcs-Git: http://suva.vyatta.com/git/vyatta-quagga.git Package: vyatta-quagga Architecture: any Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends} Pre-Depends: adduser -Conflicts: zebra, zebra-pj -Replaces: zebra, zebra-pj +Conflicts: zebra, zebra-pj, quagga +Replaces: zebra, zebra-pj, quagga Suggests: snmpd Description: BGP/OSPF/RIP routing daemon GNU Quagga is free software which manages TCP/IP based routing protocols. diff --git a/debian/rules b/debian/rules index c5b8cae4..67ee890b 100755 --- a/debian/rules +++ b/debian/rules @@ -20,11 +20,7 @@ BUILD_STAMP=debian/build-stamp CFLAGS = -Wall -g WANT_SNMP=1 -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif +CFLAGS += -Os ifeq ($(WANT_SNMP),1) xable_snmp = --enable-snmp @@ -59,9 +55,7 @@ configure += --enable-vty-group=quaggavty configure += --enable-configfile-mask=0640 configure += --enable-logfile-mask=0640 configure += --enable-rtadv -configure += --enable-tcp-md5 configure += --enable-gcc-rdynamic -configure += --enable-linkdetect configure += $(xable_snmp) configure += --with-libpam configure += CFLAGS="$(CFLAGS)" diff --git a/debian/vyatta-quagga.init.d b/debian/vyatta-quagga.init.d index 4e342f8b..fcf3e51a 100644 --- a/debian/vyatta-quagga.init.d +++ b/debian/vyatta-quagga.init.d @@ -32,7 +32,7 @@ for dir in $pid_dir $log_dir ; do done declare -a common_args=( -d -P 0 ) -declare -a zebra_args=( ${common_args[@]} -l -s 1048576 -i $pid_dir/zebra.pid ) +declare -a zebra_args=( ${common_args[@]} -l -S -s 1048576 -i $pid_dir/zebra.pid ) declare -a ripd_args=( ${common_args[@]} -i $pid_dir/ripd.pid ) declare -a ripngd_args=( ${common_args[@]} -i $pid_dir/ripngd.pid ) declare -a ospfd_args=( ${common_args[@]} -i $pid_dir/ospfd.pid ) @@ -48,9 +48,9 @@ vyatta_quagga_start () else daemons+=( zebra ) daemons+=( ripd ) -# daemons+=( ripngd ) + daemons+=( ripngd ) daemons+=( ospfd ) -# daemons+=( ospf6d ) + daemons+=( ospf6d ) # daemons+=( isisd ) daemons+=( bgpd ) fi diff --git a/debian/vyatta-quagga.preinst b/debian/vyatta-quagga.preinst index 41bc3df3..29c18b2b 100644 --- a/debian/vyatta-quagga.preinst +++ b/debian/vyatta-quagga.preinst @@ -11,7 +11,6 @@ RUN_DIR=/var/run/vyatta/quagga RUN_PDIR=${RUN_DIR%/*} ETC_DIR=/etc/vyatta/quagga ETC_PDIR=${ETC_DIR%/*} -WATCHLINK_DIR=/var/linkstatus # creating quaggavty group if it isn't already there if ! getent group quaggavty >/dev/null; then @@ -36,9 +35,6 @@ fi # Do not change permissions when upgrading as it would violate policy. if [ "$1" = "install" ]; then - # Install linkstatus directory - mkdir -p $WATCHLINK_DIR - touch $WATCHLINK_DIR/exclude # Logfiles are group readable in case users were put into the quagga group. mkdir -p $LOG_PDIR diff --git a/doc/main.texi b/doc/main.texi index 9966b356..49a1db4d 100644 --- a/doc/main.texi +++ b/doc/main.texi @@ -31,6 +31,10 @@ immediately. @itemx --keep_kernel When zebra starts up, don't delete old self inserted routes. +@item -S +@itemx --rib_system +Causes zebra to manage system routes (those not created by zebra) on link events. + @item -r @itemx --retain When program terminates, retain routes added by zebra. diff --git a/doc/zebra.8 b/doc/zebra.8 index 558e27be..8b15b98c 100644 --- a/doc/zebra.8 +++ b/doc/zebra.8 @@ -60,6 +60,10 @@ restart zebra. The likely default is \fB\fI/var/run/zebra.pid\fR. \fB\-k\fR, \fB\-\-keep_kernel\fR On startup, don't delete self inserted routes. .TP +\fB\-S\fR, \fB\-\-rib_system\fR +Manage all routes, on link transistion events, including those not generated by +zebra. +.TP \fB\-l\fR, \fB\-\-log_mode\fR Turn verbose logging on. .TP diff --git a/isisd/dict.c b/isisd/dict.c index 6c3e1e7f..8a7dc588 100644 --- a/isisd/dict.c +++ b/isisd/dict.c @@ -14,8 +14,8 @@ * into proprietary software; there is no requirement for such software to * contain a copyright notice related to this source. * - * $Id$ - * $Name$ + * $Id: dict.c,v 1.5 2007/08/07 18:49:18 paul Exp $ + * $Name: $ */ #include <stdlib.h> diff --git a/isisd/dict.h b/isisd/dict.h index 92972061..9395d1c0 100644 --- a/isisd/dict.h +++ b/isisd/dict.h @@ -14,8 +14,8 @@ * into proprietary software; there is no requirement for such software to * contain a copyright notice related to this source. * - * $Id$ - * $Name$ + * $Id: dict.h,v 1.3 2005/09/25 12:04:25 hasso Exp $ + * $Name: $ */ #ifndef DICT_H diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index af24988e..d2923b57 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -2028,7 +2028,7 @@ DEFUN (no_ipv6_router_isis, } #endif /* HAVE_IPV6 */ -struct cmd_node interface_node = { +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", 1, diff --git a/isisd/isisd.c b/isisd/isisd.c index 7c669fcb..1e84a1ce 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -2076,7 +2076,7 @@ isis_config_write (struct vty *vty) return write; } -struct cmd_node isis_node = { +static struct cmd_node isis_node = { ISIS_NODE, "%s(config-router)# ", 1 diff --git a/lib/ChangeLog b/lib/ChangeLog index da0fa8ca..688c44f7 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,26 @@ +2008-07-21 Paul Jakma <paul.jakma@sun.com> + + * sockunion.c: ifdef out various places that converted + v4mapped sockets to pure v4. Doesn't seem necessary at all, + presumably a workaround for now historical inet_ntop bugs (?) + +2008-07-21 Michael H. Warfield <mhw@wittsend.com> + YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> + + * sockopt.{c,h}: (sockopt_tcp_signature) Add TCP-MD5SIG support. + +2008-06-07 Paul Jakma <paul@jakma.org> + + * stream.{c,h}: (stream_{put,write}) add const qualifier to source + argument. Change u_char to void *. + +2008-06-02 Denis Ovsienko + + * workqueue.[ch]: completely drop WQ_AIM_HEAD flag and + work_queue_aim_head() function, they aren't needed any more + with the new meta queue structure; (work_queue_run) don't + increment the counter on work item requeueing + 2008-02-28 Paul Jakma <paul.jakma@sun.com> * log.c: (mes_lookup) Sowmini Varadhan diagnosed a problem where diff --git a/lib/command.c b/lib/command.c index f3d96ede..a9085eb7 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1,5 +1,5 @@ /* - $Id$ + $Id: command.c,v 1.55 2007/04/28 22:14:10 ajs Exp $ Command interpreter routine for virtual terminal [aka TeletYpe] Copyright (C) 1997, 98, 99 Kunihiro Ishiguro @@ -41,31 +41,31 @@ vector cmdvec = NULL; struct host host; /* Standard command node structures. */ -struct cmd_node auth_node = +static struct cmd_node auth_node = { AUTH_NODE, "Password: ", }; -struct cmd_node view_node = +static struct cmd_node view_node = { VIEW_NODE, "%s> ", }; -struct cmd_node auth_enable_node = +static struct cmd_node auth_enable_node = { AUTH_ENABLE_NODE, "Password: ", }; -struct cmd_node enable_node = +static struct cmd_node enable_node = { ENABLE_NODE, "%s# ", }; -struct cmd_node config_node = +static struct cmd_node config_node = { CONFIG_NODE, "%s(config)# ", diff --git a/lib/distribute.c b/lib/distribute.c index 3d616211..242a225c 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -38,12 +38,7 @@ void (*distribute_delete_hook) (struct distribute *); static struct distribute * distribute_new (void) { - struct distribute *new; - - new = XMALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute)); - memset (new, 0, sizeof (struct distribute)); - - return new; + return XCALLOC (MTYPE_DISTRIBUTE, sizeof (struct distribute)); } /* Free distribute object. */ @@ -134,7 +129,7 @@ distribute_hash_make (struct distribute *dist) /* If two distribute-list have same value then return 1 else return 0. This function is used by hash package. */ static int -distribute_cmp (struct distribute *dist1, struct distribute *dist2) +distribute_cmp (const struct distribute *dist1, const struct distribute *dist2) { if (dist1->ifname && dist2->ifname) if (strcmp (dist1->ifname, dist2->ifname) == 0) @@ -769,7 +764,7 @@ void distribute_list_init (int node) { disthash = hash_create ((unsigned int (*) (void *)) distribute_hash_make, - (int (*) (void *, void *)) distribute_cmp); + (int (*) (const void *, const void *)) distribute_cmp); if(node==RIP_NODE) { install_element (RIP_NODE, &distribute_list_all_cmd); diff --git a/lib/filter.c b/lib/filter.c index 069919bb..1509cc31 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -1857,7 +1857,7 @@ config_write_access (struct vty *vty, afi_t afi) } /* Access-list node. */ -struct cmd_node access_node = +static struct cmd_node access_node = { ACCESS_NODE, "", /* Access list has no interface. */ @@ -1953,7 +1953,7 @@ access_list_init_ipv4 (void) } #ifdef HAVE_IPV6 -struct cmd_node access_ipv6_node = +static struct cmd_node access_ipv6_node = { ACCESS_IPV6_NODE, "", @@ -27,14 +27,13 @@ /* Allocate a new hash. */ struct hash * hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), - int (*hash_cmp) (void *, void *)) + int (*hash_cmp) (const void *, const void *)) { struct hash *hash; hash = XMALLOC (MTYPE_HASH, sizeof (struct hash)); - hash->index = XMALLOC (MTYPE_HASH_INDEX, + hash->index = XCALLOC (MTYPE_HASH_INDEX, sizeof (struct hash_backet *) * size); - memset (hash->index, 0, sizeof (struct hash_backet *) * size); hash->size = size; hash->hash_key = hash_key; hash->hash_cmp = hash_cmp; @@ -46,7 +45,7 @@ hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), /* Allocate a new hash with default hash size. */ struct hash * hash_create (unsigned int (*hash_key) (void *), - int (*hash_cmp) (void *, void *)) + int (*hash_cmp) (const void *, const void *)) { return hash_create_size (HASHTABSIZE, hash_key, hash_cmp); } @@ -48,16 +48,16 @@ struct hash unsigned int (*hash_key) (void *); /* Data compare function. */ - int (*hash_cmp) (void *, void *); + int (*hash_cmp) (const void *, const void *); /* Backet alloc. */ unsigned long count; }; extern struct hash *hash_create (unsigned int (*) (void *), - int (*) (void *, void *)); + int (*) (const void *, const void *)); extern struct hash *hash_create_size (unsigned int, unsigned int (*) (void *), - int (*) (void *, void *)); + int (*) (const void *, const void *)); extern void *hash_get (struct hash *, void *, void * (*) (void *)); extern void *hash_alloc_intern (void *); diff --git a/lib/if_rmap.c b/lib/if_rmap.c index e6f753c2..ddc62fd5 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -120,13 +120,12 @@ if_rmap_hash_make (void *data) } static int -if_rmap_hash_cmp (void *arg1, void* arg2) +if_rmap_hash_cmp (const void *arg1, const void* arg2) { - struct if_rmap *if_rmap1 = arg1; - struct if_rmap *if_rmap2 = arg2; - if (strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0) - return 1; - return 0; + const struct if_rmap *if_rmap1 = arg1; + const struct if_rmap *if_rmap2 = arg2; + + return strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0; } static struct if_rmap * diff --git a/lib/keychain.c b/lib/keychain.c index 10928b11..6719cebf 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -31,10 +31,7 @@ struct list *keychain_list; static struct keychain * keychain_new (void) { - struct keychain *new; - new = XMALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain)); - memset (new, 0, sizeof (struct keychain)); - return new; + return XCALLOC (MTYPE_KEYCHAIN, sizeof (struct keychain)); } static void @@ -46,10 +43,7 @@ keychain_free (struct keychain *keychain) static struct key * key_new (void) { - struct key *new; - new = XMALLOC (MTYPE_KEY, sizeof (struct key)); - memset (new, 0, sizeof (struct key)); - return new; + return XCALLOC (MTYPE_KEY, sizeof (struct key)); } static void @@ -854,14 +848,14 @@ DEFUN (send_lifetime_duration_month_day, argv[3], argv[4]); } -struct cmd_node keychain_node = +static struct cmd_node keychain_node = { KEYCHAIN_NODE, "%s(config-keychain)# ", 1 }; -struct cmd_node keychain_key_node = +static struct cmd_node keychain_key_node = { KEYCHAIN_KEY_NODE, "%s(config-keychain-key)# ", diff --git a/lib/linklist.c b/lib/linklist.c index a16e9e18..485a80be 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -28,11 +28,7 @@ struct list * list_new (void) { - struct list *new; - - new = XMALLOC (MTYPE_LINK_LIST, sizeof (struct list)); - memset (new, 0, sizeof (struct list)); - return new; + return XCALLOC (MTYPE_LINK_LIST, sizeof (struct list)); } /* Free list. */ @@ -46,11 +42,7 @@ list_free (struct list *l) static struct listnode * listnode_new (void) { - struct listnode *node; - - node = XMALLOC (MTYPE_LINK_NODE, sizeof (struct listnode)); - memset (node, 0, sizeof (struct listnode)); - return node; + return XCALLOC (MTYPE_LINK_NODE, sizeof (struct listnode)); } /* Free listnode. */ @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: log.c,v 1.34 2008/02/28 23:26:02 paul Exp $ * * Logging of zebra * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro @@ -740,9 +740,9 @@ zlog_rotate (struct zlog *zl) /* Message lookup function. */ const char * -lookup (struct message *mes, int key) +lookup (const struct message *mes, int key) { - struct message *pnt; + const struct message *pnt; for (pnt = mes; pnt->key != 0; pnt++) if (pnt->key == key) @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: log.h,v 1.20 2008/02/28 23:26:02 paul Exp $ * * Zebra logging funcions. * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro @@ -105,27 +105,48 @@ extern void closezlog (struct zlog *zl); /* GCC have printf type attribute check. */ #ifdef __GNUC__ -#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b))) +#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((format (printf, a, b))) #else #define PRINTF_ATTRIBUTE(a,b) #endif /* __GNUC__ */ +#if !(__GNUC__ == 4) +/* Mark functions as cold. gcc will assume any path leading to a call + to them will be unlikely. This means a lot of paths leading up + to log messages are easily marked as not likely. +*/ +#define COLD_ATTRIBUTE __attribute__((__cold__)) +#else +#define COLD_ATTRIBUTE +#endif + /* Generic function for zlog. */ -extern void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); +extern void zlog (struct zlog *zl, int priority, const char *format, ...) + PRINTF_ATTRIBUTE(3, 4); /* Handy zlog functions. */ -extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); +extern void zlog_err (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_warn (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_info (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_notice (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; +extern void zlog_debug (const char *format, ...) + PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE; /* For bgpd's peer oriented log. */ -extern void plog_err (struct zlog *, const char *format, ...); -extern void plog_warn (struct zlog *, const char *format, ...); -extern void plog_info (struct zlog *, const char *format, ...); -extern void plog_notice (struct zlog *, const char *format, ...); -extern void plog_debug (struct zlog *, const char *format, ...); +extern void plog_err (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_warn (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_info (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_notice (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; +extern void plog_debug (struct zlog *, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE; /* Set logging level for the given destination. If the log_level argument is ZLOG_DISABLED, then the destination is disabled. @@ -144,7 +165,7 @@ extern int zlog_rotate (struct zlog *); /* For hackey massage lookup and check */ #define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)") -extern const char *lookup (struct message *, int); +extern const char *lookup (const struct message *, int); extern const char *mes_lookup (struct message *meslist, int max, int index, const char *no_item); @@ -1,6 +1,6 @@ /* $USAGI: md5.c,v 1.2 2000/11/02 11:59:24 yoshfuji Exp $ */ /* $KAME: md5.c,v 1.2 2000/05/27 07:07:48 jinmei Exp $ */ -/* $Id$ */ +/* $Id: md5.c,v 1.6 2006/01/17 23:39:04 vincent Exp $ */ /* * Copyright (C) 2004 6WIND @@ -1,6 +1,6 @@ /* $USAGI: md5.h,v 1.2 2000/11/02 11:59:25 yoshfuji Exp $ */ /* $KAME: md5.h,v 1.4 2000/03/27 04:36:22 sumikawa Exp $ */ -/* $Id$ */ +/* $Id: md5.h,v 1.3 2006/01/17 17:40:45 paul Exp $ */ /* * Copyright (C) 2004 6WIND diff --git a/lib/memory.c b/lib/memory.c index 9ed5e100..28b3d896 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -33,7 +33,7 @@ static void alloc_inc (int); static void alloc_dec (int); static void log_memstats(int log_priority); -static struct message mstr [] = +static const struct message mstr [] = { { MTYPE_THREAD, "thread" }, { MTYPE_THREAD_MASTER, "thread_master" }, diff --git a/lib/memtypes.awk b/lib/memtypes.awk index fbd5e251..5429f6e8 100644 --- a/lib/memtypes.awk +++ b/lib/memtypes.awk @@ -1,4 +1,4 @@ -# $Id$ +# $Id: memtypes.awk,v 1.4 2006/03/30 14:30:19 paul Exp $ # # Scan a file of memory definitions (see eg memtypes.c) and generate # a corresponding header file with an enum of the MTYPE's and declarations diff --git a/lib/memtypes.c b/lib/memtypes.c index f1b10e71..5c2c9034 100644 --- a/lib/memtypes.c +++ b/lib/memtypes.c @@ -6,7 +6,7 @@ * The script is sensitive to the format (though not whitespace), see * the top of memtypes.awk for more details. * - * $Id$ + * $Id: memtypes.c,v 1.13 2008/07/21 21:02:50 paul Exp $ */ #include "zebra.h" @@ -95,6 +95,7 @@ struct memory_list memory_list_bgp[] = { MTYPE_BGP_PEER_HOST, "BGP peer hostname" }, { MTYPE_PEER_GROUP, "Peer group" }, { MTYPE_PEER_DESC, "Peer description" }, + { MTYPE_PEER_PASSWORD, "Peer password string" }, { MTYPE_ATTR, "BGP attribute" }, { MTYPE_ATTR_EXTRA, "BGP extra attributes" }, { MTYPE_AS_PATH, "BGP aspath" }, diff --git a/lib/plist.c b/lib/plist.c index 6caece0e..e46dae0b 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -2623,7 +2623,7 @@ prefix_list_reset_orf (void) /* Prefix-list node. */ -struct cmd_node prefix_node = +static struct cmd_node prefix_node = { PREFIX_NODE, "", /* Prefix list has no interface. */ @@ -2732,7 +2732,7 @@ prefix_list_init_ipv4 (void) #ifdef HAVE_IPV6 /* Prefix-list node. */ -struct cmd_node prefix_ipv6_node = +static struct cmd_node prefix_ipv6_node = { PREFIX_IPV6_NODE, "", /* Prefix list has no interface. */ diff --git a/lib/route_types.awk b/lib/route_types.awk index eb3d382a..6078406c 100644 --- a/lib/route_types.awk +++ b/lib/route_types.awk @@ -1,4 +1,4 @@ -# $Id$ +# $Id: route_types.awk,v 1.3 2006/06/27 10:42:18 paul Exp $ # # Scan a file of route-type definitions (see eg route_types.txt) and # generate a corresponding header file with: diff --git a/lib/routemap.c b/lib/routemap.c index 58ed09a7..5f7a3182 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1280,7 +1280,7 @@ route_map_config_write (struct vty *vty) } /* Route map node structure. */ -struct cmd_node rmap_node = +static struct cmd_node rmap_node = { RMAP_NODE, "%s(config-route-map)# ", @@ -71,7 +71,7 @@ int debug_smux = 0; int fail = 0; /* SMUX node. */ -struct cmd_node smux_node = +static struct cmd_node smux_node = { SMUX_NODE, "" /* SMUX has no interface. */ diff --git a/lib/sockopt.c b/lib/sockopt.c index e0027e88..2f01199a 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -22,6 +22,7 @@ #include <zebra.h> #include "log.h" #include "sockopt.h" +#include "sockunion.h" int setsockopt_so_recvbuf (int sock, int size) @@ -494,35 +495,69 @@ sockopt_iphdrincl_swab_systoh (struct ip *iph) iph->ip_id = ntohs(iph->ip_id); } -#if defined(HAVE_TCP_MD5SIG) int -sockopt_tcp_signature (int sock, struct sockaddr_in *sin, const char *password) +sockopt_tcp_signature (int sock, union sockunion *su, const char *password) { - int keylen = password ? strlen(password) : 0; - -#if defined(GNU_LINUX) - - struct tcp_md5sig md5sig; - - bzero ((char *)&md5sig, sizeof(md5sig)); - memcpy (&md5sig.tcpm_addr, sin, sizeof(*sin)); - md5sig.tcpm_keylen = keylen; - if (keylen) - memcpy (md5sig.tcpm_key, password, keylen); - - return setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof md5sig); - -#else /* !GNU_LINUX */ - - int enable = keylen ? (TCP_SIG_SPI_BASE + sin->sin_port) : 0; - +#if HAVE_DECL_TCP_MD5SIG +#ifndef GNU_LINUX /* * XXX Need to do PF_KEY operation here to add/remove an SA entry, * and add/remove an SP entry for this peer's packet flows also. */ - return setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &enable, - sizeof(enable)); - -#endif /* !GNU_LINUX */ -} + int md5sig = password && *password ? 1 : 0; +#else + int keylen = password ? strlen (password) : 0; + struct tcp_md5sig md5sig; + union sockunion *su2, *susock; + int ret; + + /* Figure out whether the socket and the sockunion are the same family.. + * adding AF_INET to AF_INET6 needs to be v4 mapped, you'd think.. + */ + if (!(susock = sockunion_getsockname (sock))) + return -1; + + if (susock->sa.sa_family == su->sa.sa_family) + su2 = su; + else + { + /* oops.. */ + su2 = susock; + + if (su2->sa.sa_family == AF_INET) + { + sockunion_free (susock); + return -1; + }; + + /* If this does not work, then all users of this sockopt will need to + * differentiate between IPv4 and IPv6, and keep seperate sockets for + * each. + * + * Sadly, it doesn't seem to work at present. It's unknown whether + * this is a bug or not. + */ + if (su2->sa.sa_family == AF_INET6 + && su->sa.sa_family == AF_INET) + { + su2->sin6.sin6_family = AF_INET6; + /* V4Map the address */ + memset (&su2->sin6.sin6_addr, 0, sizeof (struct in6_addr)); + su2->sin6.sin6_addr.s6_addr32[2] = htonl(0xffff); + memcpy (&su2->sin6.sin6_addr.s6_addr32[3], &su->sin.sin_addr, 4); + } + } + + memset (&md5sig, 0, sizeof (md5sig)); + memcpy (&md5sig.tcpm_addr, su2, sizeof (*su2)); + md5sig.tcpm_keylen = keylen; + if (keylen) + memcpy (md5sig.tcpm_key, password, keylen); +#endif /* GNU_LINUX */ + ret = setsockopt (sock, IPPROTO_TCP, TCP_MD5SIG, &md5sig, sizeof md5sig); + sockunion_free (susock); + return ret; +#else /* HAVE_TCP_MD5SIG */ + return -2; #endif /* HAVE_TCP_MD5SIG */ +} diff --git a/lib/sockopt.h b/lib/sockopt.h index df0de61c..cb05c6fb 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -22,6 +22,8 @@ #ifndef _ZEBRA_SOCKOPT_H #define _ZEBRA_SOCKOPT_H +#include "sockunion.h" + extern int setsockopt_so_recvbuf (int sock, int size); extern int setsockopt_so_sendbuf (const int sock, int size); extern int getsockopt_so_sendbuf (const int sock); @@ -99,32 +101,6 @@ extern int getsockopt_ifindex (int, struct msghdr *); extern void sockopt_iphdrincl_swab_htosys (struct ip *iph); extern void sockopt_iphdrincl_swab_systoh (struct ip *iph); -#if defined(HAVE_TCP_MD5SIG) - -#if defined(GNU_LINUX) && !defined(TCP_MD5SIG) - -/* XXX these will come from <linux/tcp.h> eventually */ - -#define TCP_MD5SIG 14 -#define TCP_MD5SIG_MAXKEYLEN 80 - -struct tcp_md5sig { - struct sockaddr_storage tcpm_addr; /* address associated */ - __u16 __tcpm_pad1; /* zero */ - __u16 tcpm_keylen; /* key length */ - __u32 __tcpm_pad2; /* zero */ - __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */ -}; - -#endif /* defined(GNU_LINUX) && !defined(TCP_MD5SIG) */ - -#if !defined(GNU_LINUX) && !defined(TCP_SIG_SPI_BASE) -#define TCP_SIG_SPI_BASE 1000 /* XXX this will go away */ -#endif - -extern int sockopt_tcp_signature(int sock, struct sockaddr_in *sin, +extern int sockopt_tcp_signature(int sock, union sockunion *su, const char *password); - -#endif /* HAVE_TCP_MD5SIG */ - #endif /*_ZEBRA_SOCKOPT_H */ diff --git a/lib/sockunion.c b/lib/sockunion.c index 7721666e..1ae092bd 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -180,8 +180,7 @@ sockunion_str2su (const char *str) int ret; union sockunion *su; - su = XMALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); - memset (su, 0, sizeof (union sockunion)); + su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); ret = inet_pton (AF_INET, str, &su->sin.sin_addr); if (ret > 0) /* Valid IPv4 address format. */ @@ -254,6 +253,7 @@ sockunion_accept (int sock, union sockunion *su) client_sock = accept (sock, (struct sockaddr *) su, &len); /* Convert IPv4 compatible IPv6 address to IPv4 address. */ +#if 0 #ifdef HAVE_IPV6 if (su->sa.sa_family == AF_INET6) { @@ -268,7 +268,7 @@ sockunion_accept (int sock, union sockunion *su) } } #endif /* HAVE_IPV6 */ - +#endif return client_sock; } @@ -592,6 +592,7 @@ sockunion_getsockname (int fd) su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); memcpy (su, &name, sizeof (struct sockaddr_in6)); +#if 0 if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) { struct sockaddr_in sin; @@ -601,6 +602,7 @@ sockunion_getsockname (int fd) sin.sin_port = su->sin6.sin6_port; memcpy (su, &sin, sizeof (struct sockaddr_in)); } +#endif return su; } #endif /* HAVE_IPV6 */ @@ -645,7 +647,7 @@ sockunion_getpeername (int fd) { su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); memcpy (su, &name, sizeof (struct sockaddr_in6)); - +#if 0 if (IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) { struct sockaddr_in sin; @@ -655,6 +657,7 @@ sockunion_getpeername (int fd) sin.sin_port = su->sin6.sin6_port; memcpy (su, &sin, sizeof (struct sockaddr_in)); } +#endif return su; } #endif /* HAVE_IPV6 */ @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: str.h,v 1.4 2005/09/19 09:53:21 hasso Exp $ */ #ifndef _ZEBRA_STR_H diff --git a/lib/stream.c b/lib/stream.c index 7034d904..983330ff 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -458,7 +458,7 @@ stream_get_ipv4 (struct stream *s) * stream_write() is saner */ void -stream_put (struct stream *s, void *src, size_t size) +stream_put (struct stream *s, const void *src, size_t size) { /* XXX: CHECK_SIZE has strange semantics. It should be deprecated */ @@ -833,7 +833,7 @@ stream_recvmsg (struct stream *s, int fd, struct msghdr *msgh, int flags, /* Write data to buffer. */ size_t -stream_write (struct stream *s, u_char *ptr, size_t size) +stream_write (struct stream *s, const void *ptr, size_t size) { CHECK_SIZE(s, size); diff --git a/lib/stream.h b/lib/stream.h index 715a083d..3e4ba7b4 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -150,7 +150,7 @@ extern void stream_forward_getp (struct stream *, size_t); extern void stream_forward_endp (struct stream *, size_t); /* steam_put: NULL source zeroes out size_t bytes of stream */ -extern void stream_put (struct stream *, void *, size_t); +extern void stream_put (struct stream *, const void *, size_t); extern int stream_putc (struct stream *, u_char); extern int stream_putc_at (struct stream *, size_t, u_char); extern int stream_putw (struct stream *, u_int16_t); @@ -200,7 +200,7 @@ extern ssize_t stream_recvmsg (struct stream *s, int fd, struct msghdr *, extern ssize_t stream_recvfrom (struct stream *s, int fd, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); -extern size_t stream_write (struct stream *, u_char *, size_t); +extern size_t stream_write (struct stream *, const void *, size_t); /* reset the stream. See Note above */ extern void stream_reset (struct stream *); diff --git a/lib/thread.c b/lib/thread.c index 095dff4e..260e8c8e 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -223,8 +223,8 @@ cpu_record_hash_key (struct cpu_thread_history *a) } static int -cpu_record_hash_cmp (struct cpu_thread_history *a, - struct cpu_thread_history *b) +cpu_record_hash_cmp (const struct cpu_thread_history *a, + const struct cpu_thread_history *b) { return a->func == b->func; } @@ -410,7 +410,7 @@ thread_master_create () if (cpu_record == NULL) cpu_record = hash_create_size (1011, (unsigned int (*) (void *))cpu_record_hash_key, - (int (*) (void *, void *))cpu_record_hash_cmp); + (int (*) (const void *, const void *))cpu_record_hash_cmp); return (struct thread_master *) XCALLOC (MTYPE_THREAD_MASTER, sizeof (struct thread_master)); @@ -141,13 +141,6 @@ struct vty #define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP) #endif -/* GCC have printf type attribute check. */ -#ifdef __GNUC__ -#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b))) -#else -#define PRINTF_ATTRIBUTE(a,b) -#endif /* __GNUC__ */ - /* Utility macros to convert VTY argument to unsigned long or integer. */ #define VTY_GET_LONG(NAME,V,STR) \ do { \ diff --git a/lib/workqueue.c b/lib/workqueue.c index 8880b9e2..1d32d241 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -67,7 +67,6 @@ work_queue_new (struct thread_master *m, const char *queue_name) new->name = XSTRDUP (MTYPE_WORK_QUEUE_NAME, queue_name); new->master = m; SET_FLAG (new->flags, WQ_UNPLUGGED); - UNSET_FLAG (new->flags, WQ_AIM_HEAD); if ( (new->items = list_new ()) == NULL) { @@ -131,10 +130,7 @@ work_queue_add (struct work_queue *wq, void *data) } item->data = data; - if (CHECK_FLAG (wq->flags, WQ_AIM_HEAD)) - listnode_add_after (wq->items, NULL, item); - else - listnode_add (wq->items, item); + listnode_add (wq->items, item); work_queue_schedule (wq, wq->spec.hold); @@ -231,15 +227,6 @@ work_queue_unplug (struct work_queue *wq) work_queue_schedule (wq, wq->spec.hold); } -void -work_queue_aim_head (struct work_queue *wq, const unsigned aim_head) -{ - if (aim_head) - SET_FLAG (wq->flags, WQ_AIM_HEAD); - else - UNSET_FLAG (wq->flags, WQ_AIM_HEAD); -} - /* timer thread to process a work queue * will reschedule itself if required, * otherwise work_queue_item_add @@ -317,6 +304,7 @@ work_queue_run (struct thread *thread) } case WQ_REQUEUE: { + item->ran--; work_queue_item_requeue (wq, node); break; } diff --git a/lib/workqueue.h b/lib/workqueue.h index 3150c32e..f59499a0 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -48,7 +48,6 @@ struct work_queue_item }; #define WQ_UNPLUGGED (1 << 0) /* available for draining */ -#define WQ_AIM_HEAD (1 << 1) /* add new items before list head, not after tail */ struct work_queue { @@ -119,8 +118,6 @@ extern void work_queue_add (struct work_queue *, void *); extern void work_queue_plug (struct work_queue *wq); /* unplug the queue, allow it to be drained again */ extern void work_queue_unplug (struct work_queue *wq); -/* control the value for WQ_AIM_HEAD flag */ -extern void work_queue_aim_head (struct work_queue *wq, const unsigned); /* Helpers, exported for thread.c and command.c */ extern int work_queue_run (struct thread *); diff --git a/lib/zassert.h b/lib/zassert.h index 525d866c..123aee16 100644 --- a/lib/zassert.h +++ b/lib/zassert.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $ */ #ifndef _QUAGGA_ASSERT_H @@ -17,9 +17,17 @@ extern void _zlog_assert_failed (const char *assertion, const char *file, #define __ASSERT_FUNCTION NULL #endif -#define zassert(EX) ((void)((EX) ? 0 : \ - (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ - __ASSERT_FUNCTION), 0))) +#ifdef __GNUC__ +#define UNLIKELY(EX) __builtin_expect(!!(EX), 0) +#define LIKELY(EX) __builtin_expect(!!(EX), 1) +#else +#define UNLIKELY(EX) (EX) +#define LIKELY(EX) (EX) +#endif + +#define zassert(EX) ((void)(UNLIKELY(EX) ? 0 : \ + (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ + __ASSERT_FUNCTION), 0))) #undef assert #define assert(EX) zassert(EX) diff --git a/lib/zclient.c b/lib/zclient.c index 10e6b5fd..4a716a66 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -49,8 +49,7 @@ struct zclient * zclient_new () { struct zclient *zclient; - zclient = XMALLOC (MTYPE_ZCLIENT, sizeof (struct zclient)); - memset (zclient, 0, sizeof (struct zclient)); + zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient)); zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ); zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ); diff --git a/lib/zebra.h b/lib/zebra.h index d4f68cf0..2716460f 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -163,6 +163,7 @@ typedef int socklen_t; #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/filter.h> +#include <stddef.h> #else #define RT_TABLE_MAIN 0 #endif /* HAVE_NETLINK */ diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 00000000..ef7e16fd --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,161 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy + +scriptversion=2006-05-11.19 + +# Original author: Noah Friedman <friedman@prep.ai.mit.edu> +# Created: 1993-05-16 +# Public domain. +# +# This file is maintained in Automake, please report +# bugs to <bug-automake@gnu.org> or send patches to +# <automake-patches@gnu.org>. + +nl=' +' +IFS=" "" $nl" +errstatus=0 +dirmode= + +usage="\ +Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... + +Create each directory DIR (with mode MODE, if specified), including all +leading file name components. + +Report bugs to <bug-automake@gnu.org>." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" + exit $? + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --version) + echo "$0 $scriptversion" + exit $? + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and +# mkdir -p a/c at the same time, both will detect that a is missing, +# one will create a, then the other will try to create a and die with +# a "File exists" error. This is a problem when calling mkinstalldirs +# from a parallel make. We use --version in the probe to restrict +# ourselves to GNU mkdir, which is thread-safe. +case $dirmode in + '') + if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + test -d ./-p && rmdir ./-p + test -d ./--version && rmdir ./--version + fi + ;; + *) + if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && + test ! -d ./--version; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + else + # Clean up after NextStep and OpenStep mkdir. + for d in ./-m ./-p ./--version "./$dirmode"; + do + test -d $d && rmdir $d + done + fi + ;; +esac + +for file +do + case $file in + /*) pathcomp=/ ;; + *) pathcomp= ;; + esac + oIFS=$IFS + IFS=/ + set fnord $file + shift + IFS=$oIFS + + for d + do + test "x$d" = x && continue + + pathcomp=$pathcomp$d + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr= + chmod "$dirmode" "$pathcomp" || lasterr=$? + + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi + + pathcomp=$pathcomp/ + done +done + +exit $errstatus + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 95464b63..ab8c4519 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -1511,7 +1511,7 @@ config_write_ospf6_interface (struct vty *vty) return 0; } -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 8380bc89..680f4b7f 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -227,7 +227,8 @@ main (int argc, char *argv[], char *envp[]) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : OSPF6_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = OSPF6_VTY_PORT; break; case 'u': ospf6d_privs.user = optarg; diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index a5efcb8d..deaa7ff5 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -114,8 +114,7 @@ ospf6_create () { struct ospf6 *o; - o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6)); - memset (o, 0, sizeof (struct ospf6)); + o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6)); /* initialize */ gettimeofday (&o->starttime, (struct timezone *) NULL); @@ -651,7 +650,7 @@ config_write_ospf6 (struct vty *vty) } /* OSPF6 node structure. */ -struct cmd_node ospf6_node = +static struct cmd_node ospf6_node = { OSPF6_NODE, "%s(config-ospf6)# ", diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 4440a67f..7b3d2438 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -336,7 +336,7 @@ config_write_ospf6_zebra (struct vty *vty) } /* Zebra node structure. */ -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-zebra)# ", diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 3c84fe65..86836fc5 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -97,7 +97,7 @@ DEFUN (show_version_ospf6, return CMD_SUCCESS; } -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", diff --git a/ospfd/OSPF-ALIGNMENT.txt b/ospfd/OSPF-ALIGNMENT.txt index a5fe931b..dac6182f 100644 --- a/ospfd/OSPF-ALIGNMENT.txt +++ b/ospfd/OSPF-ALIGNMENT.txt @@ -1,4 +1,4 @@ -$Id$ +$Id: OSPF-ALIGNMENT.txt,v 1.1 2004/11/17 17:59:52 gdt Exp $ Greg Troxel <gdt@ir.bbn.com> 2004-11-17 diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c index b6c8bc90..fc3b51dd 100644 --- a/ospfd/ospf_api.c +++ b/ospfd/ospf_api.c @@ -99,8 +99,7 @@ msg_new (u_char msgtype, void *msgbody, u_int32_t seqnum, u_int16_t msglen) { struct msg *new; - new = XMALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg)); - memset (new, 0, sizeof (struct msg)); + new = XCALLOC (MTYPE_OSPF_API_MSG, sizeof (struct msg)); new->hdr.version = OSPF_API_VERSION; new->hdr.msgtype = msgtype; @@ -271,12 +270,7 @@ msg_get_seq (struct msg *msg) struct msg_fifo * msg_fifo_new () { - struct msg_fifo *new; - - new = XMALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo)); - memset (new, 0, sizeof (struct msg_fifo)); - - return new; + return XCALLOC (MTYPE_OSPF_API_FIFO, sizeof (struct msg_fifo)); } /* Add new message to fifo. */ diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index dac4c93f..15fd2e5f 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -937,8 +937,7 @@ ospf_apiserver_register_opaque_type (struct ospf_apiserver *apiserv, type. */ regtype = - XMALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type)); - memset (regtype, 0, sizeof (struct registered_opaque_type)); + XCALLOC (MTYPE_OSPF_APISERVER, sizeof (struct registered_opaque_type)); regtype->lsa_type = lsa_type; regtype->opaque_type = opaque_type; diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index a4826237..6f1b0b06 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -104,8 +104,7 @@ ospf_external_info_new (u_char type) struct external_info *new; new = (struct external_info *) - XMALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info)); - memset (new, 0, sizeof (struct external_info)); + XCALLOC (MTYPE_OSPF_EXTERNAL_INFO, sizeof (struct external_info)); new->type = type; ospf_reset_route_map_set_values (&new->route_map_set); diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 2fcbfe64..de9ef055 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1509,7 +1509,7 @@ DEFUN (show_debugging_ospf, } /* Debug node. */ -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 63681429..5d4f415f 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -638,8 +638,7 @@ ospf_if_new_hook (struct interface *ifp) { int rc = 0; - ifp->info = XMALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info)); - memset (ifp->info, 0, sizeof (struct ospf_if_info)); + ifp->info = XCALLOC (MTYPE_OSPF_IF_INFO, sizeof (struct ospf_if_info)); IF_OIFS (ifp) = route_table_init (); IF_OIFS_PARAMS (ifp) = route_table_init (); @@ -814,8 +813,7 @@ ospf_vl_data_new (struct ospf_area *area, struct in_addr vl_peer) { struct ospf_vl_data *vl_data; - vl_data = XMALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data)); - memset (vl_data, 0, sizeof (struct ospf_vl_data)); + vl_data = XCALLOC (MTYPE_OSPF_VL_DATA, sizeof (struct ospf_vl_data)); vl_data->vl_peer.s_addr = vl_peer.s_addr; vl_data->vl_area_id = area->area_id; @@ -1180,12 +1178,7 @@ ospf_vls_in_area (struct ospf_area *area) struct crypt_key * ospf_crypt_key_new () { - struct crypt_key *ck; - - ck = XMALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key)); - memset (ck, 0, sizeof (struct crypt_key)); - - return ck; + return XCALLOC (MTYPE_OSPF_CRYPT_KEY, sizeof (struct crypt_key)); } void diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index fccae82f..aff395af 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -326,12 +326,7 @@ ospf_lsa_discard (struct ospf_lsa *lsa) struct lsa_header * ospf_lsa_data_new (size_t size) { - struct lsa_header *new; - - new = (struct lsa_header *) XMALLOC (MTYPE_OSPF_LSA_DATA, size); - memset (new, 0, size); - - return new; + return XCALLOC (MTYPE_OSPF_LSA_DATA, size); } /* Duplicate LSA data. */ diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 27a12dd0..1a200a8f 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -245,7 +245,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : OSPF_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = OSPF_VTY_PORT; break; case 'u': ospfd_privs.user = optarg; diff --git a/ospfd/ospf_neighbor.c b/ospfd/ospf_neighbor.c index 843e93f6..967ca15d 100644 --- a/ospfd/ospf_neighbor.c +++ b/ospfd/ospf_neighbor.c @@ -69,8 +69,7 @@ ospf_nbr_new (struct ospf_interface *oi) struct ospf_neighbor *nbr; /* Allcate new neighbor. */ - nbr = XMALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor)); - memset (nbr, 0, sizeof (struct ospf_neighbor)); + nbr = XCALLOC (MTYPE_OSPF_NEIGHBOR, sizeof (struct ospf_neighbor)); /* Relate neighbor to the interface. */ nbr->oi = oi; diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c index e76b39b0..a16da41b 100644 --- a/ospfd/ospf_snmp.c +++ b/ospfd/ospf_snmp.c @@ -1389,11 +1389,7 @@ struct ospf_snmp_if struct ospf_snmp_if * ospf_snmp_if_new () { - struct ospf_snmp_if *osif; - - osif = XMALLOC (0, sizeof (struct ospf_snmp_if)); - memset (osif, 0, sizeof (struct ospf_snmp_if)); - return osif; + return XCALLOC (0, sizeof (struct ospf_snmp_if)); } void diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index a3ebe62e..c5ec0ad8 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -561,13 +561,13 @@ ospf_mpls_te_new_if (struct interface *ifp) goto out; } - if ((new = XMALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS, - sizeof (struct mpls_te_link))) == NULL) + new = XCALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS, + sizeof (struct mpls_te_link)); + if (new == NULL) { zlog_warn ("ospf_mpls_te_new_if: XMALLOC: %s", safe_strerror (errno)); goto out; } - memset (new, 0, sizeof (struct mpls_te_link)); new->area = NULL; new->flags = 0; diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c96b88ab..bfd90466 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -8056,7 +8056,7 @@ ospf_vty_show_init (void) /* ospfd's interface node. */ -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", @@ -8165,13 +8165,6 @@ ospf_vty_if_init (void) install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); } -/* Zebra node structure. */ -struct cmd_node zebra_node = -{ - ZEBRA_NODE, - "%s(config-router)#", -}; - static void ospf_vty_zebra_init (void) { @@ -8264,7 +8257,7 @@ ospf_vty_zebra_init (void) #endif /* 0 */ } -struct cmd_node ospf_node = +static struct cmd_node ospf_node = { OSPF_NODE, "%s(config-router)# ", diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index c627afb2..3afbcbb7 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -1126,10 +1126,7 @@ ospf_prefix_list_update (struct prefix_list *plist) static struct ospf_distance * ospf_distance_new (void) { - struct ospf_distance *new; - new = XMALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance)); - memset (new, 0, sizeof (struct ospf_distance)); - return new; + return XCALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance)); } static void diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 448f218e..d352a056 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -1385,9 +1385,8 @@ ospf_nbr_nbma_new (void) { struct ospf_nbr_nbma *nbr_nbma; - nbr_nbma = XMALLOC (MTYPE_OSPF_NEIGHBOR_STATIC, + nbr_nbma = XCALLOC (MTYPE_OSPF_NEIGHBOR_STATIC, sizeof (struct ospf_nbr_nbma)); - memset (nbr_nbma, 0, sizeof (struct ospf_nbr_nbma)); nbr_nbma->priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; nbr_nbma->v_poll = OSPF_POLL_INTERVAL_DEFAULT; diff --git a/pkgsrc/README.txt b/pkgsrc/README.txt index 1cae5c14..13ec449a 100644 --- a/pkgsrc/README.txt +++ b/pkgsrc/README.txt @@ -1,4 +1,4 @@ -$Id$ +$Id: README.txt,v 1.1 2004/08/27 15:57:35 gdt Exp $ This directory contains files for use with the pkgsrc framework (http://www.pkgsrc.org) used with NetBSD and other operating systems. diff --git a/ripd/ChangeLog b/ripd/ChangeLog index ecf353d0..60baef5d 100644 --- a/ripd/ChangeLog +++ b/ripd/ChangeLog @@ -1,3 +1,7 @@ +2008-05-29 Stephen Hemminger <stephen.hemminger@vyatta.com> + + * ripd.c: (rip_auth_md5) fix bogus empty string test + 2008-03-13 Paul Jakma <paul.jakma@sun.com> * ripd.c/rip_interface.c: Remove 0 entries from rip_msg diff --git a/ripd/rip_debug.c b/ripd/rip_debug.c index d788ea7e..64dc27c0 100644 --- a/ripd/rip_debug.c +++ b/ripd/rip_debug.c @@ -203,7 +203,7 @@ DEFUN (no_debug_rip_zebra, } /* Debug node. */ -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", /* Debug node has no interface. */ diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 915cd911..131898c2 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -50,11 +50,12 @@ static int rip_enable_if_lookup (const char *ifname); static int rip_enable_network_lookup2 (struct connected *connected); static void rip_enable_apply_all (void); -struct message ri_version_msg[] = +const struct message ri_version_msg[] = { {RI_RIP_VERSION_1, "1"}, {RI_RIP_VERSION_2, "2"}, {RI_RIP_VERSION_1_AND_2, "1 2"}, + {0, NULL} }; extern struct zebra_privs_t ripd_privs; @@ -118,8 +119,7 @@ rip_interface_new (void) { struct rip_interface *ri; - ri = XMALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface)); - memset (ri, 0, sizeof (struct rip_interface)); + ri = XCALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface)); /* Default authentication type is simple password for Cisco compatibility. */ @@ -240,6 +240,7 @@ rip_request_interface (struct interface *ifp) } } +#if 0 /* Send RIP request to the neighbor. */ static void rip_request_neighbor (struct in_addr addr) @@ -253,7 +254,6 @@ rip_request_neighbor (struct in_addr addr) rip_request_send (&to, NULL, rip->version_send, NULL); } -#if 0 /* Request routes at all interfaces. */ static void rip_request_neighbor_all (void) @@ -406,8 +406,8 @@ rip_interface_down (int command, struct zclient *zclient, zebra_size_t length) if (IS_RIP_DEBUG_ZEBRA) zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is down", - ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, - ifp->metric, ifp->mtu); + ifp->name, ifp->ifindex, + (unsigned long long) ifp->flags, ifp->metric, ifp->mtu); return 0; } @@ -427,7 +427,7 @@ rip_interface_up (int command, struct zclient *zclient, zebra_size_t length) if (IS_RIP_DEBUG_ZEBRA) zlog_debug ("interface %s index %d flags %#llx metric %d mtu %d is up", - ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, ifp->metric, ifp->mtu); /* Check if this interface is RIP enabled or not.*/ @@ -492,7 +492,7 @@ rip_interface_delete (int command, struct zclient *zclient, } zlog_info("interface delete %s index %d flags %#llx metric %d mtu %d", - ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, + ifp->name, ifp->ifindex, (unsigned long long) ifp->flags, ifp->metric, ifp->mtu); /* To support pseudo interface do not free interface structure. */ @@ -2058,7 +2058,7 @@ config_write_rip_network (struct vty *vty, int config_mode) return 0; } -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", diff --git a/ripd/rip_main.c b/ripd/rip_main.c index dfcd6c26..0b29107d 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -236,7 +236,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : RIP_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = RIP_VTY_PORT; break; case 'r': retain_mode = 1; diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c index e7d71f6c..0155f90e 100644 --- a/ripd/rip_offset.c +++ b/ripd/rip_offset.c @@ -63,11 +63,7 @@ strcmp_safe (const char *s1, const char *s2) static struct rip_offset_list * rip_offset_list_new (void) { - struct rip_offset_list *new; - - new = XMALLOC (MTYPE_RIP_OFFSET_LIST, sizeof (struct rip_offset_list)); - memset (new, 0, sizeof (struct rip_offset_list)); - return new; + return XCALLOC (MTYPE_RIP_OFFSET_LIST, sizeof (struct rip_offset_list)); } static void diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c index e0617890..fd912eba 100644 --- a/ripd/rip_peer.c +++ b/ripd/rip_peer.c @@ -36,11 +36,7 @@ struct list *peer_list; static struct rip_peer * rip_peer_new (void) { - struct rip_peer *new; - - new = XMALLOC (MTYPE_RIP_PEER, sizeof (struct rip_peer)); - memset (new, 0, sizeof (struct rip_peer)); - return new; + return XCALLOC (MTYPE_RIP_PEER, sizeof (struct rip_peer)); } static void diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index b924199f..c476d8f4 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -233,6 +233,7 @@ DEFUN (no_router_zebra, return CMD_SUCCESS; } +#if 0 static int rip_redistribute_set (int type) { @@ -246,6 +247,7 @@ rip_redistribute_set (int type) return CMD_SUCCESS; } +#endif static int rip_redistribute_unset (int type) @@ -651,7 +653,7 @@ config_write_rip_redistribute (struct vty *vty, int config_mode) } /* Zebra node structure. */ -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-router)# ", diff --git a/ripd/ripd.c b/ripd/ripd.c index af2e5d0e..fc8ce1b8 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -76,7 +76,7 @@ enum }; /* RIP command strings. */ -struct message rip_msg[] = +static const struct message rip_msg[] = { {RIP_REQUEST, "REQUEST"}, {RIP_RESPONSE, "RESPONSE"}, @@ -84,6 +84,7 @@ struct message rip_msg[] = {RIP_TRACEOFF, "TRACEOFF"}, {RIP_POLL, "POLL"}, {RIP_POLL_ENTRY, "POLL ENTRY"}, + {0, NULL}, }; /* Utility function to set boradcast option to the socket. */ @@ -111,11 +112,7 @@ rip_route_rte (struct rip_info *rinfo) static struct rip_info * rip_info_new () { - struct rip_info *new; - - new = XMALLOC (MTYPE_RIP_INFO, sizeof (struct rip_info)); - memset (new, 0, sizeof (struct rip_info)); - return new; + return XCALLOC (MTYPE_RIP_INFO, sizeof (struct rip_info)); } void @@ -2696,8 +2693,7 @@ rip_redistribute_withdraw (int type) static int rip_create (void) { - rip = XMALLOC (MTYPE_RIP, sizeof (struct rip)); - memset (rip, 0, sizeof (struct rip)); + rip = XCALLOC (MTYPE_RIP, sizeof (struct rip)); /* Set initial value. */ rip->version_send = RI_RIP_VERSION_2; @@ -3118,10 +3114,7 @@ struct rip_distance static struct rip_distance * rip_distance_new (void) { - struct rip_distance *new; - new = XMALLOC (MTYPE_RIP_DISTANCE, sizeof (struct rip_distance)); - memset (new, 0, sizeof (struct rip_distance)); - return new; + return XCALLOC (MTYPE_RIP_DISTANCE, sizeof (struct rip_distance)); } static void @@ -3510,7 +3503,7 @@ DEFUN (show_ip_rip_status, struct listnode *node; struct interface *ifp; struct rip_interface *ri; - extern struct message ri_version_msg[]; + extern const struct message ri_version_msg[]; const char *send_version; const char *receive_version; @@ -3689,7 +3682,7 @@ config_write_rip (struct vty *vty) } /* RIP node structure. */ -struct cmd_node rip_node = +static struct cmd_node rip_node = { RIP_NODE, "%s(config-router)# ", diff --git a/ripd/ripd.conf.sample b/ripd/ripd.conf.sample index f72e5e85..2902ff9c 100644 --- a/ripd/ripd.conf.sample +++ b/ripd/ripd.conf.sample @@ -2,7 +2,7 @@ ! ! RIPd sample configuration file ! -! $Id$ +! $Id: ripd.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $ ! hostname ripd password zebra diff --git a/ripngd/ripng_debug.c b/ripngd/ripng_debug.c index 7841fe21..aac254d4 100644 --- a/ripngd/ripng_debug.c +++ b/ripngd/ripng_debug.c @@ -204,7 +204,7 @@ DEFUN (no_debug_ripng_zebra, } /* Debug node. */ -struct cmd_node debug_node = +static struct cmd_node debug_node = { DEBUG_NODE, "", /* Debug node has no interface. */ diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c index cad6240b..06df6a10 100644 --- a/ripngd/ripng_interface.c +++ b/ripngd/ripng_interface.c @@ -1205,7 +1205,7 @@ interface_config_write (struct vty *vty) } /* ripngd's interface node. */ -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index 70553910..a18ce9de 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -240,7 +240,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : RIPNG_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = RIPNG_VTY_PORT; break; case 'r': retain_mode = 1; diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c index 34f5ac6c..0438b4bf 100644 --- a/ripngd/ripng_peer.c +++ b/ripngd/ripng_peer.c @@ -42,11 +42,7 @@ struct list *peer_list; struct ripng_peer * ripng_peer_new () { - struct ripng_peer *new; - - new = XMALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer)); - memset (new, 0, sizeof (struct ripng_peer)); - return new; + return XCALLOC (MTYPE_RIPNG_PEER, sizeof (struct ripng_peer)); } void diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 1f9bee0c..c624454e 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -538,7 +538,7 @@ zebra_config_write (struct vty *vty) } /* Zebra node structure. */ -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-router)# ", diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index a8277fe2..9bf40dff 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1820,8 +1820,7 @@ ripng_create () assert (ripng == NULL); /* Allocaste RIPng instance. */ - ripng = XMALLOC (MTYPE_RIPNG, sizeof (struct ripng)); - memset (ripng, 0, sizeof (struct ripng)); + ripng = XCALLOC (MTYPE_RIPNG, sizeof (struct ripng)); /* Default version and timer values. */ ripng->version = RIPNG_V1; @@ -2685,7 +2684,7 @@ ripng_config_write (struct vty *vty) } /* RIPng node structure. */ -struct cmd_node cmd_ripng_node = +static struct cmd_node cmd_ripng_node = { RIPNG_NODE, "%s(config-router)# ", diff --git a/ripngd/ripngd.conf.sample b/ripngd/ripngd.conf.sample index 1daf3b39..ad673e57 100644 --- a/ripngd/ripngd.conf.sample +++ b/ripngd/ripngd.conf.sample @@ -2,7 +2,7 @@ ! ! RIPngd sample configuration file ! -! $Id$ +! $Id: ripngd.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $ ! hostname ripngd password zebra diff --git a/solaris/ChangeLog b/solaris/ChangeLog index 8a2ad7d3..65135d99 100644 --- a/solaris/ChangeLog +++ b/solaris/ChangeLog @@ -1,3 +1,13 @@ +2008-07-03 Paul Jakma <paul.jakma@sun.com> + + * quagga.{xml,init}.in: Sync with OpenSolaris SFW. This changes the + SMF schema used, from the SMF schema supplied initially with + Quagga, to the version which was approved by the Sun PSARC for + inclusion into Solaris. This change is incompatible. Settings, + such as vty_port, etc. will not transfer over. The Sun schema is + however supported by Sun, and supports running Quagga in a zone + with IP instances, and configuration via the routeadm utility. + 2008-01-13 Paul Jakma <paul.jakma@sun.com> * Makefile.am: pkg target should depend on the 'depend.%' files. diff --git a/solaris/Makefile.am b/solaris/Makefile.am index 674f4ebf..835d3a70 100644 --- a/solaris/Makefile.am +++ b/solaris/Makefile.am @@ -1,5 +1,5 @@ # Solaris packages automake file -# $Id$ +# $Id: Makefile.am,v 1.9 2008/01/13 18:52:15 paul Exp $ # XXX This file uses GNU make extensions. diff --git a/solaris/quagga.init.in b/solaris/quagga.init.in index 30a9c694..b489b28e 100755 --- a/solaris/quagga.init.in +++ b/solaris/quagga.init.in @@ -1,6 +1,6 @@ #!/sbin/sh # -# Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # This file is part of Quagga. @@ -20,18 +20,156 @@ # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # -# $Id$ +# $Id: quagga.init.in,v 1.8 2008/07/03 20:41:08 paul Exp $ # # Starts/stops the given daemon SMFINCLUDE=/lib/svc/share/smf_include.sh +ROUTEADMINCLUDE=/lib/svc/share/routing_include.sh +GLOBAL_OPTIONS="PAfiug" DAEMON_PATH=@sbindir@ +USER=@enable_user@ +GROUP=@enable_group@ +# handle upgrade of daemon-args SMF property to new routeadm properties +# used during upgrade too by routeadm. +# relevant to S10U4+ only. +handle_routeadm_upgrade () { + GLOBAL_OPTIONS="PAfiug" + + daemon_args=`get_daemon_args $SMF_FMRI` + + if [ -n "$daemon_args" ]; then + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "$GLOBAL_OPTIONS" "P" vty_port 0 + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "$GLOBAL_OPTIONS" "A" vty_address + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "$GLOBAL_OPTIONS" "f" config_file + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "$GLOBAL_OPTIONS" "i" pid_file + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "$GLOBAL_OPTIONS" "u" user + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "$GLOBAL_OPTIONS" "g" group + + case "$1" in + zebra) + set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ + "${GLOBAL_OPTIONS}b" "b" batch true false + ;; + ripd|ripngd) + set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ + "${GLOBAL_OPTIONS}r" "r" retain true false + ;; + bgpd) + set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ + "${GLOBAL_OPTIONS}rnp" "r" retain true false + set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ + "${GLOBAL_OPTIONS}rnp" "n" no_kernel true false + set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ + "${GLOBAL_OPTIONS}rnp" "p" bgp_port + esac + clear_daemon_args $SMF_FMRI + fi +} + +upgrade_config () { + DAEMON=$1 + # handle upgrade of SUNWzebra to Quagga + if [ -d "/etc/quagga" -a ! -f "/etc/quagga/${DAEMON}.conf" ] ; then + if [ -f "/etc/sfw/zebra/${DAEMON}.conf" ] ; then + cp "/etc/sfw/zebra/${DAEMON}.conf" \ + "/etc/quagga/${DAEMON}.conf.upgrade" \ + || exit $SMF_EXIT_ERR_FATAL + chown "${USER}:${GROUP}" "/etc/quagga/${DAEMON}.conf.upgrade" \ + || exit $SMF_EXIT_ERR_FATAL + chmod 0600 "/etc/quagga/${DAEMON}.conf.upgrade" \ + || exit $SMF_EXIT_ERR_FATAL + mv "/etc/quagga/${DAEMON}.conf.upgrade" "/etc/quagga/${DAEMON}.conf" \ + || exit $SMF_EXIT_ERR_FATAL + fi + fi + + if [ ! -f "/etc/quagga/${DAEMON}.conf" ] ; then + touch "/etc/quagga/${DAEMON}.conf.new" \ + || exit $SMF_EXIT_ERR_FATAL + chown "${USER}:${GROUP}" "/etc/quagga/${DAEMON}.conf.new" \ + || exit $SMF_EXIT_ERR_FATAL + chmod 0600 "/etc/quagga/${DAEMON}.conf.new" \ + || exit $SMF_EXIT_ERR_FATAL + mv "/etc/quagga/${DAEMON}.conf.new" "/etc/quagga/${DAEMON}.conf" \ + || exit $SMF_EXIT_ERR_FATAL + fi +} + +# Relevant to S10+ quagga_is_globalzone () { - if [ "${QUAGGA_INIT_ZONENAME:=`/sbin/zonename`}" != "global" ]; then - return 1 - else + if [ "${QUAGGA_INIT_ZONENAME:=`/sbin/zonename`}" = "global" \ + -o `/sbin/zonename -t` = "exclusive" ]; then return 0 + else + return 1 + fi +} + +routeadm_daemon_args () { + # globals + args="`get_daemon_option_from_property $SMF_FMRI config_file f`" + args="${args} `get_daemon_option_from_property $SMF_FMRI vty_port P`" + args="${args} `get_daemon_option_from_property $SMF_FMRI vty_address A`" + args="${args} `get_daemon_option_from_property $SMF_FMRI pid_file i`" + + # user and group we need for config file upgrade.. + SMF_USER=`get_routeadm_property $SMF_FMRI user` + SMF_GROUP=`get_routeadm_property()$SMF_FMRI group` + if [ "${SMF_USER}" ] ; then + USER="${SMF_USER}" + args="${args} -u ${SMF_USER}" + fi + if [ "${SMF_GROUP}" ] ; then + GROUP="${SMF_GROUP}" + args="${args} -g ${SMF_GROUP}" + fi + + case $1 in + zebra) + args="${args} `get_daemon_option_from_boolean_property $SMF_FMRI batch -b true`" + ;; + ripd|ripngd) + args="${args} `get_daemon_option_from_boolean_property $SMF_FMRI retain -r true`" + ;; + bgpd) + args="${args} `get_daemon_option_from_boolean_property $SMF_FMRI retain -r true`" + args="${args} `get_daemon_option_from_boolean_property $SMF_FMRI no_kernel -n true`" + args="${args} `get_daemon_option_from_property $SMF_FMRI bgp_port p 179`" + ;; + esac + echo ${args} +} + +# certain daemons need zebra +routeadm_zebra_enable () { + + if [ "$DAEMON" = "zebra" ]; then + return + fi + + enable_zebra=`/usr/bin/svcprop -p \ + routing/enable_zebra $SMF_FMRI 2> /dev/null` + if [ "$enable_zebra" != "false" ]; then + zenabled=`/usr/bin/svcprop -p general/enabled zebra:quagga` + zenabledt=`/usr/bin/svcprop -p general_ovr/enabled zebra:quagga` + if [ "$zenabled" = "true" -o "$zenabledt" = "true" ]; then + /usr/sbin/svcadm disable zebra:quagga + /usr/sbin/svcadm enable -st zebra:quagga + else + /usr/sbin/svcadm enable -st zebra:quagga + fi + if [ "$?" != "0" ]; then + echo "Could not enable zebra:quagga" + exit $SMF_EXIT_ERR_FATAL + fi fi } @@ -39,6 +177,11 @@ quagga_is_globalzone () { # there is no SMF. Should allow this script to work pre-S10. if [ -f "$SMFINCLUDE" ] ; then . "$SMFINCLUDE"; + + # source the SMF-routeadm include if present.. + if [ -f "$ROUTEADMINCLUDE" ] ; then + . "$ROUTEADMINCLUDE" + fi else # pre-SMF system, fake up any functions and exit codes # which SMFINCLUDE usually provides. @@ -55,7 +198,7 @@ smf_present || DAEMON_ARGS="" usage () { if smf_present ; then - echo "Usage: $0 <daemon> <daemon arguments>"; + echo "Usage: $0 <daemon>"; else echo "Usage: $0 <stop|start> <daemon> <daemon arguments>"; fi @@ -67,7 +210,7 @@ usage () { case $1 in 'help' | 'usage') usage - exit SMF_EXIT_OK + exit $SMF_EXIT_OK ;; esac @@ -79,8 +222,6 @@ else fi DAEMON="$1" -shift -DAEMON_ARGS="$@" # daemon path must be given if [ -z "$DAEMON_PATH/$DAEMON" ]; then @@ -91,12 +232,9 @@ fi # only bgpd is suitable for running in a non-global zone, at this # time. case "${DAEMON}" in - zebra) - quagga_is_globalzone || exit $SMF_EXIT_OK - ;; bgpd) ;; - ospfd | ospf6d | ripd | ripngd ) + zebra | ospfd | ospf6d | ripd | ripngd ) quagga_is_globalzone || exit $SMF_EXIT_OK ;; *) @@ -105,6 +243,27 @@ case "${DAEMON}" in ;; esac +# Older Quagga SMF packages pass daemon args on the commandline +# Newer SMF routeadm model uses properties for each argument +# so we must handle that. +if [ smf_present -a -f "$ROUTEADMINCLUDE" ]; then + handle_routeadm_upgrade $DAEMON; + DAEMON_ARGS=`routeadm_daemon_args`; + routeadm_zebra_enable $DAEMON; +else + if [ $# -gt 0 ] ; then + shift + DAEMON_ARGS="$@" + fi +fi + +upgrade_config "$DAEMON" + +if [ ! -f "@sysconfdir@/${DAEMON}.conf" ] ; then + echo "Could not find config file, @sysconfdir@/${DAEMON}.conf" + exit $SMF_EXIT_ERR_CONFIG +fi + # we need @quagga_statedir@ to exist, it probably is on tmpfs. if [ ! -d @quagga_statedir@ ] ; then mkdir -p @quagga_statedir@ @@ -115,7 +274,11 @@ fi PIDFILE="@quagga_statedir@/${DAEMON}.pid" start () { - $DAEMON_PATH/$DAEMON $DAEMON_ARGS --pid_file ${PIDFILE} & + if [ ! -x "$DAEMON_PATH/$DAEMON" ] ; then + echo "Error, could not find daemon, $DAEMON_PATH/$DAEMON" + exit $SMF_EXIT_ERR_FATAL + fi + eval exec $DAEMON_PATH/$DAEMON $DAEMON_ARGS --pid_file ${PIDFILE} & } stop () { @@ -134,7 +297,7 @@ case "$QUAGGA_METHOD" in *) usage - exit SMF_EXIT_ERR_FATAL + exit $SMF_EXIT_ERR_FATAL ;; esac diff --git a/solaris/quagga.xml.in b/solaris/quagga.xml.in index 3cd402f6..50c52c22 100644 --- a/solaris/quagga.xml.in +++ b/solaris/quagga.xml.in @@ -18,18 +18,20 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Copyright 2005 Sun Microsystems, Inc. All rights reserved. + Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. ident "@(#)quagga.xml 1.0 05/03/15 SMI" --> -<service_bundle type='manifest' name='QUAGGAdaemons:quagga'> +<service_bundle type='manifest' name='SUNWquagga-daemons:quagga'> + <service name='network/routing/zebra' type='service' version='1'> - + + <single_instance /> <instance name='quagga' enabled='false'> <dependency name='fs' @@ -46,24 +48,24 @@ type='service'> <service_fmri value='svc:/network/initial' /> </dependency> - - <dependency name='config_data' + + <!-- do not not run unless routing-setup has run --> + <dependency + name='network_routing_setup' grouping='require_all' - restart_on='restart' - type='path'> - <service_fmri - value='file://localhost/@sysconfdir@/zebra.conf' /> + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/routing-setup' /> </dependency> - + <exec_method type='method' name='start' - exec='/lib/svc/method/quagga zebra %{routing/daemon-args}' + exec='/lib/svc/method/quagga zebra' timeout_seconds='60'> <method_context> <method_credential - user='root' group='root' - privileges='basic,net_icmpaccess,net_rawaccess,sys_admin,sys_net_config'/> + user='root' group='root'/> </method_context> </exec_method> @@ -84,17 +86,55 @@ <propval name='ignore_error' type='astring' value='core,signal' /> </property_group> - + + <!-- Properties in this group are used by routeadm (1M) --> + <property_group name='routeadm' type='application'> + <stability value='Unstable' /> + <!-- Identifies service as a routing service --> + <propval name='daemon' type='astring' + value='@sbindir@/zebra' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.value.routing' /> + <!-- zebra should not contribute to ipv4/ipv6 routing state --> + <propval name='protocol' type='astring' value='zebra' /> + </property_group> + + <!-- Properties in this group are modifiable via routeadm (1M) --> <property_group name='routing' type='application'> + <stability value='Evolving' /> <propval name='value_authorization' type='astring' - value='solaris.smf.modify.routing' /> - <propval name='daemon-args' type='astring' value='-P 0'/> + value='solaris.smf.value.routing' /> + + <!-- Options common to Quagga daemons + Property names are equivalent to the long + option name, consult Quagga documentation --> + <!-- The config file to use, if not the default --> + <propval name='config_file' type='astring' value=''/> + <!-- The vty_port to listen on if not the default. + 0 to disable --> + <propval name='vty_port' type='integer' value='0' /> + <!-- The address to bind the VTY interface to, if not any. --> + <propval name='vty_address' type='astring' value='' /> + <!-- The user to switch to after startup, if not the default --> + <propval name='user' type='astring' value='' /> + <!-- The group to switch to, if not the default. + If user is specified, this defaults to a group with + same name as user --> + <propval name='group' type='astring' value='' /> + <!-- The pidfile to use, if not the default of + @quagga_statedir@ --> + <propval name='pid_file' type='astring' value='' /> + + <!-- Options specific to zebra --> + <propval name='batch' type='boolean' value='false' /> </property_group> <property_group name='general' type='framework'> <!-- to start stop routing services --> <propval name='action_authorization' type='astring' value='solaris.smf.manage.routing' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.manage.routing' /> </property_group> <template> @@ -111,7 +151,7 @@ </documentation> </template> </instance> - <stability value='Evolving' /> + <stability value='Unstable' /> </service> <service @@ -129,39 +169,40 @@ value='svc:/system/filesystem/usr:default' /> </dependency> - <!-- Depends on Work-In-Progress, not yet in SNV - <dependency name='net' - grouping='require_all' - restart_on='none' + <dependency + name='ipv4-forwarding' + grouping='optional_all' + restart_on='refresh' type='service'> - <service_fmri value='svc:/network/routing/ipv4-routing' /> + <service_fmri value='svc:/network/ipv4-forwarding' /> </dependency> - --> - <dependency name='zebra' - grouping='require_all' - restart_on='restart' - type='service'> - <service_fmri value='svc:/network/routing/zebra:quagga' /> - </dependency> - - <dependency name='config_data' + <!-- do not not run unless routing-setup has run --> + <dependency + name='network_routing_setup' grouping='require_all' - restart_on='restart' - type='path'> - <service_fmri - value='file://localhost/@sysconfdir@/ripd.conf' /> + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/routing-setup' /> </dependency> + <!-- ensure that restart of zebra is propogated to daemon --> + <dependency + name='zebra' + grouping='optional_all' + restart_on='restart' + type='service'> + <service_fmri value='svc:/network/routing/zebra:quagga' /> + </dependency> + <exec_method type='method' name='start' - exec='/lib/svc/method/quagga ripd %{routing/daemon-args}' + exec='/lib/svc/method/quagga ripd' timeout_seconds='60'> <method_context> <method_credential - user='root' group='root' - privileges='basic,net_icmpaccess,net_privaddr,net_rawaccess'/> + user='root' group='root'/> </method_context> </exec_method> @@ -179,16 +220,52 @@ type='astring' value='core,signal' /> </property_group> + <!-- Properties in this group are used by routeadm (1M) --> + <property_group name='routeadm' type='application'> + <stability value='Unstable' /> + <!-- Identifies service as a routing service --> + <propval name='daemon' type='astring' + value='@sbindir@/ripd' /> + <propval name='legacy-daemon' type='astring' + value='/usr/sfw/sbin/ripdstart' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.value.routing' /> + <propval name='protocol' type='astring' value='ipv4' /> + </property_group> + + <!-- Properties in this group are modifiable via routeadm (1M) --> <property_group name='routing' type='application'> <propval name='value_authorization' type='astring' - value='solaris.smf.modify.routing' /> - <propval name='daemon-args' type='astring' value='-P 0'/> + value='solaris.smf.value.routing' /> + + <!-- Options common to Quagga daemons --> + <!-- The config file to use, if not the default --> + <propval name='config_file' type='astring' value=''/> + <!-- The vty_port to listen on if not the default. + 0 to disable --> + <propval name='vty_port' type='integer' value='0' /> + <!-- The address to bind the VTY interface to, if not any. --> + <propval name='vty_address' type='astring' value='' /> + <!-- The user to switch to after startup, if not the default --> + <propval name='user' type='astring' value='' /> + <!-- The group to switch to, if not the default. + If user is specified, this defaults to a group with + same name as user --> + <propval name='group' type='astring' value='' /> + <!-- The pidfile to use, if not the default of + @quagga_statedir@ --> + <propval name='pid_file' type='astring' value='' /> + + <!-- Options specific to ripd --> + <propval name='retain' type='boolean' value='false' /> </property_group> <property_group name='general' type='framework'> <!-- to start stop routing services --> <propval name='action_authorization' type='astring' value='solaris.smf.manage.routing' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.manage.routing' /> </property_group> <template> @@ -205,7 +282,7 @@ </documentation> </template> </instance> - <stability value='Evolving' /> + <stability value='Unstable' /> </service> <service @@ -223,39 +300,40 @@ value='svc:/system/filesystem/usr:default' /> </dependency> - <!-- Depends on WIP, not yet in SNV - <dependency name='net' - grouping='require_all' - restart_on='none' + <dependency + name='ipv6-forwarding' + grouping='optional_all' + restart_on='refresh' type='service'> - <service_fmri value='svc:/network/routing/ipv6-routing' /> + <service_fmri value='svc:/network/ipv6-forwarding' /> </dependency> - --> - <dependency name='zebra' - grouping='require_all' - restart_on='restart' - type='service'> - <service_fmri value='svc:/network/routing/zebra:quagga' /> + <!-- do not not run unless routing-setup has run --> + <dependency + name='network_routing_setup' + grouping='require_all' + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/routing-setup' /> </dependency> - <dependency name='config_data' - grouping='require_all' + <!-- ensure that restart of zebra is propogated to daemon --> + <dependency + name='zebra' + grouping='optional_all' restart_on='restart' - type='path'> - <service_fmri - value='file://localhost/@sysconfdir@/ripngd.conf' /> + type='service'> + <service_fmri value='svc:/network/routing/zebra:quagga' /> </dependency> - + <exec_method type='method' name='start' - exec='/lib/svc/method/quagga ripngd %{routing/daemon-args}' + exec='/lib/svc/method/quagga ripngd' timeout_seconds='60'> <method_context> <method_credential - user='root' group='root' - privileges='basic,net_icmpaccess,net_privaddr,net_rawaccess'/> + user='root' group='root'/> </method_context> </exec_method> @@ -273,16 +351,50 @@ type='astring' value='core,signal' /> </property_group> + <!-- Properties in this group are used by routeadm (1M) --> + <property_group name='routeadm' type='application'> + <stability value='Unstable' /> + <!-- Identifies service as a routing service --> + <propval name='daemon' type='astring' + value='@sbindir@/ripngd' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.value.routing' /> + <propval name='protocol' type='astring' value='ipv6'/> + </property_group> + + <!-- Properties in this group are modifiable via routeadm (1M) --> <property_group name='routing' type='application'> <propval name='value_authorization' type='astring' - value='solaris.smf.modify.routing' /> - <propval name='daemon-args' type='astring' value='-P 0'/> + value='solaris.smf.value.routing' /> + + <!-- Options common to Quagga daemons --> + <!-- The config file to use, if not the default --> + <propval name='config_file' type='astring' value=''/> + <!-- The vty_port to listen on if not the default. + 0 to disable --> + <propval name='vty_port' type='integer' value='0' /> + <!-- The address to bind the VTY interface to, if not any. --> + <propval name='vty_address' type='astring' value='' /> + <!-- The user to switch to after startup, if not the default --> + <propval name='user' type='astring' value='' /> + <!-- The group to switch to, if not the default. + If user is specified, this defaults to a group with + same name as user --> + <propval name='group' type='astring' value='' /> + <!-- The pidfile to use, if not the default of + @quagga_statedir@ --> + <propval name='pid_file' type='astring' value='' /> + + <!-- Options specific to ripngd --> + <propval name='retain' type='boolean' value='false' /> </property_group> <property_group name='general' type='framework'> <!-- to start stop routing services --> <propval name='action_authorization' type='astring' value='solaris.smf.manage.routing' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.manage.routing' /> </property_group> <template> @@ -299,7 +411,7 @@ </documentation> </template> </instance> - <stability value='Evolving' /> + <stability value='Unstable' /> </service> <service @@ -317,47 +429,51 @@ value='svc:/system/filesystem/usr:default' /> </dependency> - <!-- Depends on WIP, not yet in SNV - <dependency name='net' - grouping='require_all' - restart_on='none' + <dependency + name='ipv4-forwarding' + grouping='optional_all' + restart_on='refresh' type='service'> - <service_fmri value='svc:/network/routing/ipv4-routing' /> + <service_fmri value='svc:/network/ipv4-forwarding' /> </dependency> - --> - <dependency name='zebra' - grouping='require_all' - restart_on='restart' - type='service'> - <service_fmri value='svc:/network/routing/zebra:quagga' /> + <!-- do not not run unless routing-setup has run --> + <dependency + name='network_routing_setup' + grouping='require_all' + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/routing-setup' /> </dependency> - <dependency name='config_data' - grouping='require_all' + <!-- ensure that restart of zebra is propogated to daemon --> + <dependency + name='zebra' + grouping='optional_all' restart_on='restart' - type='path'> - <service_fmri - value='file://localhost/@sysconfdir@/ospfd.conf' /> + type='service'> + <service_fmri value='svc:/network/routing/zebra:quagga' /> </dependency> - + <exec_method type='method' name='start' - exec='/lib/svc/method/quagga ospfd %{routing/daemon-args}' + exec='/lib/svc/method/quagga ospfd' timeout_seconds='60'> <method_context> <method_credential - user='root' group='root' - privileges='basic,net_icmpaccess,net_privaddr,net_rawaccess,sys_net_config'/> + user='root' group='root'/> </method_context> </exec_method> + <!-- ospfd can take a long time to shutdown, due to graceful + shutdown + --> <exec_method type='method' name='stop' exec=':kill' - timeout_seconds='60'> + timeout_seconds='600'> </exec_method> <property_group name='startd' @@ -367,16 +483,49 @@ type='astring' value='core,signal' /> </property_group> + <!-- Properties in this group are used by routeadm (1M) --> + <property_group name='routeadm' type='application'> + <stability value='Unstable' /> + <!-- Identifies service as a routing service --> + <propval name='daemon' type='astring' + value='@sbindir@/ospfd' /> + <propval name='legacy-daemon' type='astring' + value='/usr/sfw/sbin/ospfdstart' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.value.routing' /> + <propval name='protocol' type='astring' value='ipv4'/> + </property_group> + + <!-- Properties in this group are modifiable via routeadm (1M) --> <property_group name='routing' type='application'> <propval name='value_authorization' type='astring' - value='solaris.smf.modify.routing' /> - <propval name='daemon-args' type='astring' value='-P 0'/> + value='solaris.smf.value.routing' /> + + <!-- Options common to Quagga daemons --> + <!-- The config file to use, if not the default --> + <propval name='config_file' type='astring' value=''/> + <!-- The vty_port to listen on if not the default. + 0 to disable --> + <propval name='vty_port' type='integer' value='0' /> + <!-- The address to bind the VTY interface to, if not any. --> + <propval name='vty_address' type='astring' value='' /> + <!-- The user to switch to after startup, if not the default --> + <propval name='user' type='astring' value='' /> + <!-- The group to switch to, if not the default. + If user is specified, this defaults to a group with + same name as user --> + <propval name='group' type='astring' value='' /> + <!-- The pidfile to use, if not the default of + @quagga_statedir@ --> + <propval name='pid_file' type='astring' value='' /> </property_group> <property_group name='general' type='framework'> <!-- to start stop routing services --> <propval name='action_authorization' type='astring' value='solaris.smf.manage.routing' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.manage.routing' /> </property_group> <template> @@ -393,7 +542,7 @@ </documentation> </template> </instance> - <stability value='Evolving' /> + <stability value='Unstable' /> </service> <service @@ -411,39 +560,40 @@ value='svc:/system/filesystem/usr:default' /> </dependency> - <!-- Depends on WIP, not yet in SNV - <dependency name='net' - grouping='require_all' - restart_on='none' + <dependency + name='ipv6-forwarding' + grouping='optional_all' + restart_on='refresh' type='service'> - <service_fmri value='svc:/network/routing/ipv6-routing' /> + <service_fmri value='svc:/network/ipv6-forwarding' /> </dependency> - --> - <dependency name='zebra' - grouping='require_all' - restart_on='restart' - type='service'> - <service_fmri value='svc:/network/routing/zebra:quagga' /> + <!-- do not not run unless routing-setup has run --> + <dependency + name='network_routing_setup' + grouping='require_all' + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/routing-setup' /> </dependency> - <dependency name='config_data' - grouping='require_all' + <!-- ensure that restart of zebra is propogated to daemon --> + <dependency + name='zebra' + grouping='optional_all' restart_on='restart' - type='path'> - <service_fmri - value='file://localhost/@sysconfdir@/ospf6d.conf' /> + type='service'> + <service_fmri value='svc:/network/routing/zebra:quagga' /> </dependency> - + <exec_method type='method' name='start' - exec='/lib/svc/method/quagga ospf6d %{routing/daemon-args}' + exec='/lib/svc/method/quagga ospf6d' timeout_seconds='60'> <method_context> <method_credential - user='root' group='root' - privileges='basic,net_icmpaccess,net_privaddr,net_rawaccess'/> + user='root' group='root'/> </method_context> </exec_method> @@ -461,22 +611,53 @@ type='astring' value='core,signal' /> </property_group> + <!-- Properties in this group are used by routeadm (1M) --> + <property_group name='routeadm' type='application'> + <stability value='Unstable' /> + <!-- Identifies service as a routing service --> + <propval name='daemon' type='astring' + value='@sbindir@/ospf6d' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.value.routing' /> + <propval name='protocol' type='astring' value='ipv6'/> + </property_group> + + <!-- Properties in this group are modifiable via routeadm (1M) --> <property_group name='routing' type='application'> <propval name='value_authorization' type='astring' - value='solaris.smf.modify.routing' /> - <propval name='daemon-args' type='astring' value='-P 0'/> + value='solaris.smf.value.routing' /> + + <!-- Options common to Quagga daemons --> + <!-- The config file to use, if not the default --> + <propval name='config_file' type='astring' value=''/> + <!-- The vty_port to listen on if not the default. + 0 to disable --> + <propval name='vty_port' type='integer' value='0' /> + <!-- The address to bind the VTY interface to, if not any. --> + <propval name='vty_address' type='astring' value='' /> + <!-- The user to switch to after startup, if not the default --> + <propval name='user' type='astring' value='' /> + <!-- The group to switch to, if not the default. + If user is specified, this defaults to a group with + same name as user --> + <propval name='group' type='astring' value='' /> + <!-- The pidfile to use, if not the default of + @quagga_statedir@ --> + <propval name='pid_file' type='astring' value='' /> </property_group> <property_group name='general' type='framework'> <!-- to start stop routing services --> <propval name='action_authorization' type='astring' value='solaris.smf.manage.routing' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.manage.routing' /> </property_group> <template> <common_name> <loctext xml:lang='C'> - Quagga: ospf6d, OSPFv3 IPv6 routing protocol daemon. + Quagga: ospf6d, OSPFv3 IPv6 routing protocol daemon. </loctext> </common_name> <documentation> @@ -487,7 +668,7 @@ </documentation> </template> </instance> - <stability value='Evolving' /> + <stability value='Unstable' /> </service> @@ -506,40 +687,48 @@ value='svc:/system/filesystem/usr:default' /> </dependency> - <!-- Depends on WIP, not yet in SNV - <dependency name='net' - grouping='require_any' - restart_on='none' + <dependency + name='ipv6-forwarding' + grouping='optional_all' + restart_on='refresh' type='service'> - <service_fmri value='svc:/network/routing/ipv6-routing' /> - <service_fmri value='svc:/network/routing/ipv4-routing' /> + <service_fmri value='svc:/network/ipv6-forwarding' /> + </dependency> + + <dependency + name='ipv4-forwarding' + grouping='optional_all' + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/ipv4-forwarding' /> </dependency> - --> - <dependency name='zebra' - grouping='optional_all' - restart_on='restart' - type='service'> - <service_fmri value='svc:/network/routing/zebra:quagga' /> + <!-- do not not run unless routing-setup has run --> + <dependency + name='network_routing_setup' + grouping='require_all' + restart_on='refresh' + type='service'> + <service_fmri value='svc:/network/routing-setup' /> </dependency> - <dependency name='config_data' - grouping='require_all' + <!-- ensure that restart of zebra is propogated to daemon --> + <dependency + name='zebra' + grouping='optional_all' restart_on='restart' - type='path'> - <service_fmri - value='file://localhost/@sysconfdir@/bgpd.conf' /> + type='service'> + <service_fmri value='svc:/network/routing/zebra:quagga' /> </dependency> - + <exec_method type='method' name='start' - exec='/lib/svc/method/quagga bgpd %{routing/daemon-args}' + exec='/lib/svc/method/quagga bgpd' timeout_seconds='60'> <method_context> <method_credential - user='root' group='root' - privileges='basic,net_icmpaccess,net_privaddr,net_rawaccess'/> + user='root' group='root'/> </method_context> </exec_method> @@ -557,16 +746,65 @@ type='astring' value='core,signal' /> </property_group> + <!-- Properties in this group are used by routeadm (1M) --> + <property_group name='routeadm' type='application'> + <stability value='Unstable' /> + <!-- Identifies service as a routing service --> + <propval name='daemon' type='astring' + value='@sbindir@/bgpd' /> + <propval name='legacy-daemon' type='astring' + value='/usr/sfw/sbin/bgpdstart' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.value.routing' /> + <property name='protocol' type='astring'> + <astring_list> + <value_node value='ipv4'/> + <value_node value='ipv6'/> + </astring_list> + </property> + </property_group> + + <!-- Properties in this group are modifiable via routeadm (1M) --> <property_group name='routing' type='application'> <propval name='value_authorization' type='astring' - value='solaris.smf.modify.routing' /> - <propval name='daemon-args' type='astring' value='-P 0'/> + value='solaris.smf.value.routing' /> + + <!-- Options common to Quagga daemons. --> + <!-- The config file to use, if not the default --> + <propval name='config_file' type='astring' value=''/> + <!-- The vty_port to listen on if not the default. + 0 to disable --> + <propval name='vty_port' type='integer' value='0' /> + <!-- The address to bind the VTY interface to, if not any. --> + <propval name='vty_address' type='astring' value='' /> + <!-- The user to switch to after startup, if not the default --> + <propval name='user' type='astring' value='' /> + <!-- The group to switch to, if not the default. + If user is specified, this defaults to a group with + same name as user --> + <propval name='group' type='astring' value='' /> + <!-- The pidfile to use, if not the default of + @quagga_statedir@ --> + <propval name='pid_file' type='astring' value='' /> + + <!-- Options specific to bgpd --> + <propval name='retain' type='boolean' value='false' /> + <propval name='no_kernel' type='boolean' value='false' /> + <propval name='bgp_port' type='astring' value='' /> + + <!-- + If enable_zebra is false, it will not be switched + on by the start method. + --> + <propval name='enable_zebra' type='boolean' value='true' /> </property_group> <property_group name='general' type='framework'> <!-- to start stop routing services --> <propval name='action_authorization' type='astring' value='solaris.smf.manage.routing' /> + <propval name='value_authorization' type='astring' + value='solaris.smf.manage.routing' /> </property_group> <template> @@ -583,6 +821,6 @@ </documentation> </template> </instance> - <stability value='Evolving' /> + <stability value='Unstable' /> </service> </service_bundle> diff --git a/tests/ChangeLog b/tests/ChangeLog index 098afb55..18696519 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2008-06-07 Paul Jakma <paul@jakma.org + + * bgp_mp_attr_test.c: MP_(UN)REACH_NLRI unit tests + 2008-02-23 Paul Jakma <paul.jakma@sun.com> * aspath_test.c: Test for 0-ASN sequences that still have data. diff --git a/tests/Makefile.am b/tests/Makefile.am index 2045496e..d00485f1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,9 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" noinst_PROGRAMS = testsig testbuffer testmemory heavy heavywq heavythread \ - aspathtest testprivs teststream testbgpcap ecommtest + aspathtest testprivs teststream testbgpcap ecommtest \ + testbgpmpattr + testsig_SOURCES = test-sig.c testbuffer_SOURCES = test-buffer.c testmemory_SOURCES = test-memory.c @@ -14,6 +16,7 @@ heavythread_SOURCES = heavy-thread.c main.c aspathtest_SOURCES = aspath_test.c testbgpcap_SOURCES = bgp_capability_test.c ecommtest_SOURCES = ecommunity_test.c +testbgpmpattr_SOURCES = bgp_mp_attr_test.c testsig_LDADD = ../lib/libzebra.la @LIBCAP@ testbuffer_LDADD = ../lib/libzebra.la @LIBCAP@ @@ -26,3 +29,4 @@ heavythread_LDADD = ../lib/libzebra.la @LIBCAP@ -lm aspathtest_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a testbgpcap_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a ecommtest_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a +testbgpmpattr_LDADD = ../lib/libzebra.la @LIBCAP@ -lm ../bgpd/libbgp.a diff --git a/tests/bgp_mp_attr_test.c b/tests/bgp_mp_attr_test.c new file mode 100644 index 00000000..dde0df2f --- /dev/null +++ b/tests/bgp_mp_attr_test.c @@ -0,0 +1,535 @@ +#include <zebra.h> + +#include "vty.h" +#include "stream.h" +#include "privs.h" +#include "memory.h" + +#include "bgpd/bgpd.h" +#include "bgpd/bgp_attr.h" +#include "bgpd/bgp_open.h" +#include "bgpd/bgp_debug.h" + +#define VT100_RESET "\x1b[0m" +#define VT100_RED "\x1b[31m" +#define VT100_GREEN "\x1b[32m" +#define VT100_YELLOW "\x1b[33m" + + +#define CAPABILITY 0 +#define DYNCAP 1 +#define OPT_PARAM 2 + +/* need these to link in libbgp */ +struct zebra_privs_t *bgpd_privs = NULL; +struct thread_master *master = NULL; + +static int failed = 0; +static int tty = 0; + +/* test segments to parse and validate, and use for other tests */ +static struct test_segment { + const char *name; + const char *desc; + const u_char data[1024]; + int len; +#define SHOULD_PARSE 0 +#define SHOULD_ERR -1 + int parses; /* whether it should parse or not */ + + /* AFI/SAFI validation */ + afi_t afi; + safi_t safi; +#define VALID_AFI 1 +#define INVALID_AFI 0 + int afi_valid; +} mp_reach_segments [] = +{ + { "IPv6", + "IPV6 MP Reach, global nexthop, 1 NLRI", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 16, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + }, + (4 + 16 + 1 + 5), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-2", + "IPV6 MP Reach, global nexthop, 2 NLRIs", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 16, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* ffee:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + }, + (4 + 16 + 1 + 5 + 9), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-default", + "IPV6 MP Reach, global nexthop, 2 NLRIs + default", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 16, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0x0, /* ::/0 */ + }, + (4 + 16 + 1 + 5 + 9 + 1), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-lnh", + "IPV6 MP Reach, global+local nexthops, 2 NLRIs + default", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 32, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ + 0x0, 0x0, 0x0, 0x0, + 0x2, 0x10, 0x2, 0xff, + 0x1, 0x2, 0x3, 0x4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0x0, /* ::/0 */ + }, + (4 + 32 + 1 + 5 + 9 + 1), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-nhlen", + "IPV6 MP Reach, inappropriate nexthop length", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 4, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ + 0x0, 0x0, 0x0, 0x0, + 0x2, 0x10, 0x2, 0xff, + 0x1, 0x2, 0x3, 0x4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0x0, /* ::/0 */ + }, + (4 + 32 + 1 + 5 + 9 + 1), + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-nhlen2", + "IPV6 MP Reach, invalid nexthop length", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 5, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ + 0x0, 0x0, 0x0, 0x0, + 0x2, 0x10, 0x2, 0xff, + 0x1, 0x2, 0x3, 0x4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0x0, /* ::/0 */ + }, + (4 + 32 + 1 + 5 + 9 + 1), + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-nhlen3", + "IPV6 MP Reach, nexthop length overflow", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 32, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + }, + (4 + 16), + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-nhlen4", + "IPV6 MP Reach, nexthop length short", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 16, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ + 0x0, 0x0, 0x0, 0x0, + 0x2, 0x10, 0x2, 0xff, + 0x1, 0x2, 0x3, 0x4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0x0, /* ::/0 */ + }, + (4 + 32 + 1 + 5 + 9 + 1), + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-nlri", + "IPV6 MP Reach, NLRI bitlen overflow", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* nexthop bytes */ 32, + /* Nexthop (global) */ 0xff, 0xfe, 0x1, 0x2, /* fffe:102:... */ + 0xaa, 0xbb, 0xcc, 0xdd, + 0x3, 0x4, 0x5, 0x6, + 0xa1, 0xa2, 0xa3, 0xa4, + /* Nexthop (local) */ 0xfe, 0x80, 0x0, 0x0, /* fe80::210:2ff:.. */ + 0x0, 0x0, 0x0, 0x0, + 0x2, 0x10, 0x2, 0xff, + 0x1, 0x2, 0x3, 0x4, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 120, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0, /* ::/0 */ + }, + (4 + 32 + 1 + 5 + 9 + 1), + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4", + "IPv4 MP Reach, 2 NLRIs + default", + { + /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, + /* nexthop bytes */ 4, + /* Nexthop */ 192, 168, 0, 1, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 17, 10, 2, 3, /* 10.2.3/17 */ + 0, /* 0/0 */ + }, + (4 + 4 + 1 + 3 + 4 + 1), + SHOULD_PARSE, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4-nhlen", + "IPv4 MP Reach, nexthop lenth overflow", + { + /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, + /* nexthop bytes */ 32, + /* Nexthop */ 192, 168, 0, 1, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 17, 10, 2, 3, /* 10.2.3/17 */ + 0, /* 0/0 */ + }, + (4 + 4 + 1 + 3 + 4 + 1), + SHOULD_ERR, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4-nlrilen", + "IPv4 MP Reach, nlri lenth overflow", + { + /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, + /* nexthop bytes */ 4, + /* Nexthop */ 192, 168, 0, 1, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 30, 10, + 0, /* 0/0 */ + }, + (4 + 4 + 1 + 3 + 2 + 1), + SHOULD_ERR, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4-vpnv4", + "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRIs", + { + /* AFI / SAFI */ 0x0, AFI_IP, BGP_SAFI_VPNV4, + /* nexthop bytes */ 12, + /* RD */ 0, 0, 1, 2, + 0, 0xff, 3, 4, + /* Nexthop */ 192, 168, 0, 1, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 17, 10, 2, 3, /* 10.2.3/17 */ + 0, /* 0/0 */ + }, + (4 + 12 + 1 + 3 + 4 + 1), + SHOULD_PARSE, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + /* From bug #385 */ + { "IPv6-bug", + "IPv6, global nexthop, 1 default NLRI", + { + /* AFI / SAFI */ 0x0, 0x2, 0x1, + /* nexthop bytes */ 0x20, + /* Nexthop (global) */ 0x20, 0x01, 0x04, 0x70, + 0x00, 0x01, 0x00, 0x06, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + /* Nexthop (local) */ 0xfe, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x02, 0x0c, 0xdb, 0xff, + 0xfe, 0xfe, 0xeb, 0x00, + /* SNPA (defunct, MBZ) */ 0, + /* NLRI tuples */ /* Should have 0 here for ::/0, but dont */ + }, + 37, + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + + { NULL, NULL, {0}, 0, 0} +}; + +/* MP_UNREACH_NLRI tests */ +static struct test_segment mp_unreach_segments [] = +{ + { "IPv6-unreach", + "IPV6 MP Unreach, 1 NLRI", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* NLRI tuples */ 32, 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + }, + (3 + 5), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-unreach2", + "IPV6 MP Unreach, 2 NLRIs", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + }, + (3 + 5 + 9), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-unreach-default", + "IPV6 MP Unreach, 2 NLRIs + default", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* NLRI tuples */ 32, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0x0, /* ::/0 */ + }, + (3 + 5 + 9 + 1), + SHOULD_PARSE, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv6-unreach-nlri", + "IPV6 MP Unreach, NLRI bitlen overflow", + { + /* AFI / SAFI */ 0x0, AFI_IP6, SAFI_UNICAST, + /* NLRI tuples */ 120, + 0xff, 0xfe, 0x1, 0x2, /* fffe:102::/32 */ + 64, + 0xff, 0xfe, 0x0, 0x1, /* fffe:1:2:3::/64 */ + 0x0, 0x2, 0x0, 0x3, + 0, /* ::/0 */ + }, + (3 + 5 + 9 + 1), + SHOULD_ERR, + AFI_IP6, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4-unreach", + "IPv4 MP Unreach, 2 NLRIs + default", + { + /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 17, 10, 2, 3, /* 10.2.3/17 */ + 0, /* 0/0 */ + }, + (3 + 3 + 4 + 1), + SHOULD_PARSE, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4-unreach-nlrilen", + "IPv4 MP Unreach, nlri length overflow", + { + /* AFI / SAFI */ 0x0, AFI_IP, SAFI_UNICAST, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 30, 10, + 0, /* 0/0 */ + }, + (3 + 3 + 2 + 1), + SHOULD_ERR, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + { "IPv4-unreach-vpnv4", + "IPv4/VPNv4 MP Unreach, RD, 3 NLRIs", + { + /* AFI / SAFI */ 0x0, AFI_IP, BGP_SAFI_VPNV4, + /* nexthop bytes */ 12, + /* RD */ 0, 0, 1, 2, + 0, 0xff, 3, 4, + /* Nexthop */ 192, 168, 0, 1, + /* SNPA (defunct, MBZ) */ 0x0, + /* NLRI tuples */ 16, 10, 1, /* 10.1/16 */ + 17, 10, 2, 3, /* 10.2.3/17 */ + 0, /* 0/0 */ + }, + (3 + 3 + 4 + 1), + SHOULD_PARSE, + AFI_IP, SAFI_UNICAST, VALID_AFI, + }, + { NULL, NULL, {0}, 0, 0} +}; + + +/* basic parsing test */ +static void +parse_test (struct peer *peer, struct test_segment *t, int type) +{ + int ret; + int oldfailed = failed; + struct attr attr; + struct bgp_nlri nlri; +#define RANDOM_FUZZ 35 + + stream_reset (peer->ibuf); + stream_put (peer->ibuf, NULL, RANDOM_FUZZ); + stream_set_getp (peer->ibuf, RANDOM_FUZZ); + + stream_write (peer->ibuf, t->data, t->len); + + printf ("%s: %s\n", t->name, t->desc); + + if (type == BGP_ATTR_MP_REACH_NLRI) + ret = bgp_mp_reach_parse (peer, t->len, &attr, &nlri); + else + ret = bgp_mp_unreach_parse (peer, t->len, &nlri); + + if (!ret) + { + safi_t safi = t->safi; + + if (bgp_afi_safi_valid_indices (t->afi, &safi) != t->afi_valid) + failed++; + + printf ("MP: %u/%u (%u): recv %u, nego %u\n", + t->afi, t->safi, safi, + peer->afc_recv[t->afi][safi], + peer->afc_nego[t->afi][safi]); + } + + printf ("parsed?: %s\n", ret ? "no" : "yes"); + + if (ret != t->parses) + failed++; + + if (tty) + printf ("%s", (failed > oldfailed) ? VT100_RED "failed!" VT100_RESET + : VT100_GREEN "OK" VT100_RESET); + else + printf ("%s", (failed > oldfailed) ? "failed!" : "OK" ); + + if (failed) + printf (" (%u)", failed); + + printf ("\n\n"); +} + +static struct bgp *bgp; +static as_t asn = 100; + +int +main (void) +{ + struct peer *peer; + int i, j; + + conf_bgp_debug_fsm = -1UL; + conf_bgp_debug_events = -1UL; + conf_bgp_debug_packet = -1UL; + conf_bgp_debug_normal = -1UL; + conf_bgp_debug_as4 = -1UL; + term_bgp_debug_fsm = -1UL; + term_bgp_debug_events = -1UL; + term_bgp_debug_packet = -1UL; + term_bgp_debug_normal = -1UL; + term_bgp_debug_as4 = -1UL; + + master = thread_master_create (); + bgp_master_init (); + + if (fileno (stdout) >= 0) + tty = isatty (fileno (stdout)); + + if (bgp_get (&bgp, &asn, NULL)) + return -1; + + peer = peer_create_accept (bgp); + peer->host = "foo"; + + for (i = AFI_IP; i < AFI_MAX; i++) + for (j = SAFI_UNICAST; j < SAFI_MAX; j++) + { + peer->afc[i][j] = 1; + peer->afc_adv[i][j] = 1; + } + + i = 0; + while (mp_reach_segments[i].name) + parse_test (peer, &mp_reach_segments[i++], BGP_ATTR_MP_REACH_NLRI); + + i = 0; + while (mp_unreach_segments[i].name) + parse_test (peer, &mp_unreach_segments[i++], BGP_ATTR_MP_UNREACH_NLRI); + + printf ("failures: %d\n", failed); + return failed; +} diff --git a/tests/heavy-thread.c b/tests/heavy-thread.c index 80f73cee..cd3a3b9d 100644 --- a/tests/heavy-thread.c +++ b/tests/heavy-thread.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: heavy-thread.c,v 1.2 2005/04/25 16:42:24 paul Exp $ * * This file is part of Quagga. * diff --git a/tests/heavy-wq.c b/tests/heavy-wq.c index a2c609d4..543b9dbb 100644 --- a/tests/heavy-wq.c +++ b/tests/heavy-wq.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: heavy-wq.c,v 1.4 2006/08/27 06:53:24 paul Exp $ * * This file is part of Quagga. * diff --git a/tests/heavy.c b/tests/heavy.c index d9bde8e2..577a4816 100644 --- a/tests/heavy.c +++ b/tests/heavy.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: heavy.c,v 1.3 2005/04/25 16:42:24 paul Exp $ * * This file is part of Quagga. * diff --git a/tests/main.c b/tests/main.c index 19e00082..edc3b2de 100644 --- a/tests/main.c +++ b/tests/main.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: main.c,v 1.1 2005/04/25 16:42:24 paul Exp $ * * This file is part of Quagga. * diff --git a/tests/test-privs.c b/tests/test-privs.c index c0e0d821..a888ea0f 100644 --- a/tests/test-privs.c +++ b/tests/test-privs.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: test-privs.c,v 1.1 2005/10/11 03:48:28 paul Exp $ * * This file is part of Quagga. * diff --git a/tools/multiple-bgpd.sh b/tools/multiple-bgpd.sh index 40977544..028ad696 100644 --- a/tools/multiple-bgpd.sh +++ b/tools/multiple-bgpd.sh @@ -6,19 +6,24 @@ NUM=5 VTYBASE=2610 ASBASE=64560 BGPD=/path/to/bgpd -PREFIX=192.168.145 +PREFIX=192.168.145. +#PREFIX=3ffe:123:456:: +ADDRPLEN=32 +CONFBASE=/tmp +PIDBASE=/var/run/quagga +CHOWNSTR=quagga:quagga for H in `seq 1 ${NUM}` ; do - CONF=/etc/quagga/bgpd${H}.conf - ADDR=${PREFIX}.${H} + CONF="${CONFBASE}"/bgpd${H}.conf + ADDR=${PREFIX}${H} if [ ! -e "$CONF" ] ; then # This sets up a ring of bgpd peerings NEXT=$(( ($H % ${NUM}) + 1 )) PREV=$(( (($H + 3) % ${NUM}) + 1 )) - NEXTADDR="${PREFIX}.${NEXT}" + NEXTADDR="${PREFIX}${NEXT}" NEXTAS=$((${ASBASE} + $NEXT)) - PREVADDR="${PREFIX}.${PREV}" + PREVADDR="${PREFIX}${PREV}" PREVAS=$((${ASBASE} + $PREV)) # Edit config to suit. @@ -39,17 +44,33 @@ for H in `seq 1 ${NUM}` ; do neighbor ${NEXTADDR} peer-group default neighbor ${PREVADDR} remote-as ${PREVAS} neighbor ${PREVADDR} peer-group default + ! + address-family ipv6 + network 3ffe:${H}::/48 + network 3ffe:${H}:1::/48 pathlimit 1 + network 3ffe:${H}:2::/48 pathlimit 3 + network 3ffe:${H}:3::/48 pathlimit 3 + neighbor default activate + neighbor default capability orf prefix-list both + neighbor default default-originate + neighbor ${NEXTADDR} peer-group default + neighbor ${PREVADDR} peer-group default + exit-address-family + ! + line vty + ! + end EOF - chown quagga:quagga "$CONF" + chown ${CHOWNSTR} "$CONF" fi # You may want to automatically add configure a local address # on a loop interface. # - # Solaris: ifconfig vni${H} plumb ${ADDR}/32 up - # Linux: ip address add ${ADDR}/32 dev lo 2> /dev/null - ${BGPD} -i /var/run/quagga/bgpd${H}.pid \ + # Solaris: ifconfig vni${H} plumb ${ADDR}/${ADDRPLEN} up + # Linux: ip address add ${ADDR}/${ADDRPLEN} dev lo 2> /dev/null + ${BGPD} -i "${PIDBASE}"/bgpd${H}.pid \ -l ${ADDR} \ - -f /etc/quagga/bgpd${H}.conf \ + -f "${CONF}" \ -P $((${VTYBASE}+${H})) \ -d done diff --git a/vtysh/ChangeLog b/vtysh/ChangeLog index de62763c..af55c6f2 100644 --- a/vtysh/ChangeLog +++ b/vtysh/ChangeLog @@ -1,3 +1,13 @@ +2008-07-03 MIYAJIMA Mitsuharu <miyajima.mitsuharu@anchor.jp> + + * extract.pl.in: Fix as-range to match CPP output. + * vtysh.c: Add missing router_bgp_view_cmd alias. + +2008-07-02 MIYAJIMA Mitsuharu <miyajima.mitsuharu@anchor.jp> + + * CMD_AS_RANGE was being used inside command strings, and thus + not being expanded, fix by dequoting. + 2007-06-20 Nicolas Deffayet <nicolas@deffayet.com> * vtysh.c: (vtysh_write_terminal) Write 'end' when done, diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index 789819c6..0b9ee516 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -37,8 +37,8 @@ $ignore{'"router ripng"'} = "ignore"; $ignore{'"router ospf"'} = "ignore"; $ignore{'"router ospf <0-65535>"'} = "ignore"; $ignore{'"router ospf6"'} = "ignore"; -$ignore{'"router bgp CMD_AS_RANGE"'} = "ignore"; -$ignore{'"router bgp CMD_AS_RANGE view WORD"'} = "ignore"; +$ignore{'"router bgp " "<1-4294967295>"'} = "ignore"; +$ignore{'"router bgp " "<1-4294967295>" " view WORD"'} = "ignore"; $ignore{'"router isis WORD"'} = "ignore"; $ignore{'"router zebra"'} = "ignore"; $ignore{'"address-family ipv4"'} = "ignore"; diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 9f47515d..bff06323 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -34,6 +34,7 @@ #include "memory.h" #include "vtysh/vtysh.h" #include "log.h" +#include "bgpd/bgp_vty.h" /* Struct VTY. */ struct vty *vty; @@ -271,7 +272,7 @@ vtysh_pager_init (void) } /* Command execution over the vty interface. */ -static void +static int vtysh_execute_func (const char *line, int pager) { int ret, cmd_stat; @@ -287,7 +288,7 @@ vtysh_execute_func (const char *line, int pager) vline = cmd_make_strvec (line); if (vline == NULL) - return; + return CMD_SUCCESS; saved_ret = ret = cmd_execute_command (vline, vty, &cmd, 1); saved_node = vty->node; @@ -335,6 +336,7 @@ vtysh_execute_func (const char *line, int pager) cmd_free_strvec (vline); + cmd_stat = ret; switch (ret) { case CMD_WARNING: @@ -393,7 +395,7 @@ vtysh_execute_func (const char *line, int pager) } fp = NULL; } - return; + return CMD_SUCCESS; } ret = cmd_execute_command (vline, vty, &cmd, 1); @@ -434,18 +436,19 @@ vtysh_execute_func (const char *line, int pager) } fp = NULL; } + return cmd_stat; } -void +int vtysh_execute_no_pager (const char *line) { - vtysh_execute_func (line, 0); + return vtysh_execute_func (line, 0); } -void +int vtysh_execute (const char *line) { - vtysh_execute_func (line, 1); + return vtysh_execute_func (line, 1); } /* Configration make from file. */ @@ -710,97 +713,97 @@ vtysh_completion (char *text, int start, int end) #endif /* Vty node structures. */ -struct cmd_node bgp_node = +static struct cmd_node bgp_node = { BGP_NODE, "%s(config-router)# ", }; -struct cmd_node rip_node = +static struct cmd_node rip_node = { RIP_NODE, "%s(config-router)# ", }; -struct cmd_node isis_node = +static struct cmd_node isis_node = { ISIS_NODE, "%s(config-router)# ", }; -struct cmd_node interface_node = +static struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", }; -struct cmd_node rmap_node = +static struct cmd_node rmap_node = { RMAP_NODE, "%s(config-route-map)# " }; -struct cmd_node zebra_node = +static struct cmd_node zebra_node = { ZEBRA_NODE, "%s(config-router)# " }; -struct cmd_node bgp_vpnv4_node = +static struct cmd_node bgp_vpnv4_node = { BGP_VPNV4_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv4_node = +static struct cmd_node bgp_ipv4_node = { BGP_IPV4_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv4m_node = +static struct cmd_node bgp_ipv4m_node = { BGP_IPV4M_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv6_node = +static struct cmd_node bgp_ipv6_node = { BGP_IPV6_NODE, "%s(config-router-af)# " }; -struct cmd_node bgp_ipv6m_node = +static struct cmd_node bgp_ipv6m_node = { BGP_IPV6M_NODE, "%s(config-router-af)# " }; -struct cmd_node ospf_node = +static struct cmd_node ospf_node = { OSPF_NODE, "%s(config-router)# " }; -struct cmd_node ripng_node = +static struct cmd_node ripng_node = { RIPNG_NODE, "%s(config-router)# " }; -struct cmd_node ospf6_node = +static struct cmd_node ospf6_node = { OSPF6_NODE, "%s(config-ospf6)# " }; -struct cmd_node keychain_node = +static struct cmd_node keychain_node = { KEYCHAIN_NODE, "%s(config-keychain)# " }; -struct cmd_node keychain_key_node = +static struct cmd_node keychain_key_node = { KEYCHAIN_KEY_NODE, "%s(config-keychain-key)# " @@ -838,7 +841,7 @@ DEFUNSH (VTYSH_ALL, DEFUNSH (VTYSH_BGPD, router_bgp, router_bgp_cmd, - "router bgp CMD_AS_RANGE", + "router bgp " CMD_AS_RANGE, ROUTER_STR BGP_STR AS_STR) @@ -847,6 +850,16 @@ DEFUNSH (VTYSH_BGPD, return CMD_SUCCESS; } +ALIAS_SH (VTYSH_BGPD, + router_bgp, + router_bgp_view_cmd, + "router bgp " CMD_AS_RANGE " view WORD", + ROUTER_STR + BGP_STR + AS_STR + "BGP view\n" + "view name\n") + DEFUNSH (VTYSH_BGPD, address_family_vpnv4, address_family_vpnv4_cmd, @@ -2341,6 +2354,7 @@ vtysh_init_vty (void) #endif install_element (CONFIG_NODE, &router_isis_cmd); install_element (CONFIG_NODE, &router_bgp_cmd); + install_element (CONFIG_NODE, &router_bgp_view_cmd); install_element (BGP_NODE, &address_family_vpnv4_cmd); install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); install_element (BGP_NODE, &address_family_ipv4_unicast_cmd); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 3ed0dd32..e711d593 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -42,8 +42,8 @@ extern int vtysh_connect_all (const char *optional_daemon_name); void vtysh_readline_init (void); void vtysh_user_init (void); -void vtysh_execute (const char *); -void vtysh_execute_no_pager (const char *); +int vtysh_execute (const char *); +int vtysh_execute_no_pager (const char *); char *vtysh_prompt (void); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index d655e073..23ff64f7 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -58,6 +58,9 @@ static char *line_read; /* Master of threads. */ struct thread_master *master; +/* Command logging */ +FILE *logfile; + /* SIGTSTP handler. This function care user's ^Z input. */ void sigtstp (int sig) @@ -159,6 +162,7 @@ struct option longopts[] = { "echo", no_argument, NULL, 'E'}, { "dryrun", no_argument, NULL, 'C'}, { "help", no_argument, NULL, 'h'}, + { "noerror", no_argument, NULL, 'n'}, { 0 } }; @@ -191,6 +195,18 @@ vtysh_rl_gets () return (line_read); } +static void log_it(const char *line) +{ + time_t t = time(NULL); + struct tm *tmp = localtime(&t); + char *user = getenv("USER") ? : "boot"; + char tod[64]; + + strftime(tod, sizeof tod, "%Y%m%d-%H:%M.%S", tmp); + + fprintf(logfile, "%s:%s %s\n", tod, user, line); +} + /* VTY shell main routine. */ int main (int argc, char **argv, char **env) @@ -206,14 +222,19 @@ main (int argc, char **argv, char **env) } *cmd = NULL; struct cmd_rec *tail = NULL; int echo_command = 0; + int no_error = 0; /* Preserve name of myself. */ progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); + /* if logging open now */ + if ((p = getenv("VTYSH_LOG")) != NULL) + logfile = fopen(p, "a"); + /* Option handling. */ while (1) { - opt = getopt_long (argc, argv, "be:c:d:EhC", longopts, 0); + opt = getopt_long (argc, argv, "be:c:d:nEhC", longopts, 0); if (opt == EOF) break; @@ -242,6 +263,9 @@ main (int argc, char **argv, char **env) case 'd': daemon_name = optarg; break; + case 'n': + no_error = 1; + break; case 'E': echo_command = 1; break; @@ -281,6 +305,10 @@ main (int argc, char **argv, char **env) if(dryrun) return(0); + /* Ignore error messages */ + if (no_error) + freopen("/dev/null", "w", stdout); + /* Make sure we pass authentication before proceeding. */ vtysh_auth (); @@ -299,19 +327,41 @@ main (int argc, char **argv, char **env) while (cmd != NULL) { + int ret; char *eol; while ((eol = strchr(cmd->line, '\n')) != NULL) { *eol = '\0'; + if (echo_command) - printf("%s%s\n", vtysh_prompt(), cmd->line); - vtysh_execute_no_pager(cmd->line); + printf("%s%s\n", vtysh_prompt(), cmd->line); + + if (logfile) + log_it(cmd->line); + + ret = vtysh_execute_no_pager(cmd->line); + if (!no_error && + ! (ret == CMD_SUCCESS || + ret == CMD_SUCCESS_DAEMON || + ret == CMD_WARNING)) + exit(1); + cmd->line = eol+1; } + if (echo_command) printf("%s%s\n", vtysh_prompt(), cmd->line); - vtysh_execute_no_pager (cmd->line); + + if (logfile) + log_it(cmd->line); + + ret = vtysh_execute_no_pager(cmd->line); + if (!no_error && + ! (ret == CMD_SUCCESS || + ret == CMD_SUCCESS_DAEMON || + ret == CMD_WARNING)) + exit(1); { struct cmd_rec *cr; diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index e3015056..58676c10 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -101,10 +101,7 @@ struct list *userlist; struct vtysh_user * user_new () { - struct vtysh_user *user; - user = XMALLOC (0, sizeof (struct vtysh_user)); - memset (user, 0, sizeof (struct vtysh_user)); - return user; + return XCALLOC (0, sizeof (struct vtysh_user)); } void diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c index f4c483cf..90cff00f 100644 --- a/watchquagga/watchquagga.c +++ b/watchquagga/watchquagga.c @@ -1,5 +1,5 @@ /* - $Id$ + $Id: watchquagga.c,v 1.12 2007/05/10 02:38:52 paul Exp $ Monitor status of quagga daemons and restart if necessary. diff --git a/zebra/ChangeLog b/zebra/ChangeLog index d9cae283..341c42a4 100644 --- a/zebra/ChangeLog +++ b/zebra/ChangeLog @@ -1,3 +1,33 @@ +2008-07-01 Paul Jakma <paul.jakma@sun.com> + + * ioctl.c: (if_get_flags) Deal more gracefully with failure + of the BSD link-state SIOCGIFMEDIA ioctl, as some interfaces + apparently don't implement it (e.g. tun). + Also, make BSD link-state checking be conditional on the + 'link-detect' interface configuration flag, as it should be. + Fixes bug #465. + +2008-06-02 Denis Ovsienko + + * connected.c: (connected_up_ipv4, connected_down_ipv4, + connected_up_ipv6, connected_down_ipv6): don't call + work_queue_aim_head() + * rib.h: adjust RIB_ROUTE_QUEUED macro for meta_queue, + declare meta_queue structure + * zebra_rib.c: (process_subq, meta_queue_process, rib_meta_queue_add, + meta_queue_new) new functions; (rib_queue_add) don't try checking + RIB_QUEUE_ADDED flag, rib_meta_queue_add() does it better, take care + of the meta queue instead; (rib_queue_init) initialize the meta queue + as well; (rib_lookup_and_pushup) don't call work_queue_aim_head(); + (rib_process) only do actual processing, don't do deallocation; + * zserv.h: include meta_queue field into zebra_t structure + +2008-05-29 Stephen Hemminger <stephen.hemminger@vyatta.com> + + * rt_netlink.c: (netlink_install_filter) BPF filter to catch and + drop responses to zebra's own route messages. + (kernel_init) add BPF filter on the netlink socket. + 2008-02-26 Denis Ovsienko * zebra_rib.[ch]: (rib_lookup_and_pushup) New function, which makes sure, that if_set_prefix() has nothing in its way of assigning an address. diff --git a/zebra/Makefile.am b/zebra/Makefile.am index 8977c893..5d8db411 100644 --- a/zebra/Makefile.am +++ b/zebra/Makefile.am @@ -10,14 +10,13 @@ LIBCAP = @LIBCAP@ ipforward = @IPFORWARD@ if_method = @IF_METHOD@ if_proc = @IF_PROC@ -link_detect = @LINK_DETECT@ rt_method = @RT_METHOD@ rtread_method = @RTREAD_METHOD@ kernel_method = @KERNEL_METHOD@ other_method = @OTHER_METHOD@ ioctl_method = @IOCTL_METHOD@ -otherobj = $(ioctl_method) $(ipforward) $(if_method) $(if_proc) $(link_detect) \ +otherobj = $(ioctl_method) $(ipforward) $(if_method) $(if_proc) \ $(rt_method) $(rtread_method) $(kernel_method) $(other_method) sbin_PROGRAMS = zebra @@ -30,7 +29,7 @@ zebra_SOURCES = \ irdp_main.c irdp_interface.c irdp_packet.c router-id.c testzebra_SOURCES = test_main.c zebra_rib.c interface.c connected.c debug.c \ - zebra_vty.c linkdetect_null.c \ + zebra_vty.c \ kernel_null.c redistribute_null.c ioctl_null.c misc_null.c noinst_HEADERS = \ @@ -43,7 +42,7 @@ testzebra_LDADD = $(LIBCAP) $(LIB_IPV6) ../lib/libzebra.la zebra_DEPENDENCIES = $(otherobj) -EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_linkdetect.c if_netlink.c if_proc.c \ +EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_netlink.c if_proc.c \ if_sysctl.c ipforward_aix.c ipforward_ews.c ipforward_proc.c \ ipforward_solaris.c ipforward_sysctl.c rt_ioctl.c rt_netlink.c \ rt_socket.c rtread_netlink.c rtread_proc.c rtread_sysctl.c \ diff --git a/zebra/client_main.c b/zebra/client_main.c index e59b09d0..c319aac7 100644 --- a/zebra/client_main.c +++ b/zebra/client_main.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: client_main.c,v 1.1 2002/12/13 20:15:30 paul Exp $ * * GNU Zebra client test main routine. * Copyright (C) 1997 Kunihiro Ishiguro diff --git a/zebra/connected.c b/zebra/connected.c index ca22a011..b235d8c0 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -36,6 +36,7 @@ #include "zebra/interface.h" #include "zebra/connected.h" extern struct zebra_t zebrad; + /* withdraw a connected address */ static void @@ -174,6 +175,7 @@ void connected_up_ipv4 (struct interface *ifp, struct connected *ifc) { struct prefix_ipv4 p; + struct in_addr src = ((struct prefix_ipv4 *) ifc->address)->prefix; if (! CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL)) return; @@ -188,21 +190,14 @@ connected_up_ipv4 (struct interface *ifp, struct connected *ifc) if (prefix_ipv4_any (&p)) return; - /* Always push arriving/departing connected routes into the head of - * the working queue to make possible proper validation of the rest - * of the RIB queue (which will contain the whole RIB after the first - * call to rib_update()). - */ - work_queue_aim_head (zebrad.ribq, 1); - rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, NULL, ifp->ifindex, - RT_TABLE_MAIN, ifp->metric, 0); - work_queue_aim_head (zebrad.ribq, 0); + rib_add_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, &src, + ifp->ifindex, RT_TABLE_MAIN, ifp->metric, 0, RT_SCOPE_LINK); rib_update (); } /* Add connected IPv4 route to the interface. */ -void +struct connected * connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, u_char prefixlen, struct in_addr *broad, const char *label) @@ -277,10 +272,10 @@ connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); /* nothing to do? */ - if ((ifc = connected_implicit_withdraw (ifp, ifc)) == NULL) - return; - + ifc = connected_implicit_withdraw (ifp, ifc); connected_announce (ifp, ifc); + + return ifc; } void @@ -302,9 +297,7 @@ connected_down_ipv4 (struct interface *ifp, struct connected *ifc) return; /* Same logic as for connected_up_ipv4(): push the changes into the head. */ - work_queue_aim_head (zebrad.ribq, 1); rib_delete_ipv4 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0); - work_queue_aim_head (zebrad.ribq, 0); rib_update (); } @@ -349,16 +342,14 @@ connected_up_ipv6 (struct interface *ifp, struct connected *ifc) return; #endif - work_queue_aim_head (zebrad.ribq, 1); rib_add_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0, ifp->metric, 0); - work_queue_aim_head (zebrad.ribq, 0); rib_update (); } /* Add connected IPv6 route to the interface. */ -void +struct connected * connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *addr, u_char prefixlen, struct in6_addr *broad, const char *label) @@ -405,10 +396,10 @@ connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *addr, if (label) ifc->label = XSTRDUP (MTYPE_CONNECTED_LABEL, label); - if ((ifc = connected_implicit_withdraw (ifp, ifc)) == NULL) - return; - + ifc = connected_implicit_withdraw (ifp, ifc); connected_announce (ifp, ifc); + + return ifc; } void @@ -426,9 +417,7 @@ connected_down_ipv6 (struct interface *ifp, struct connected *ifc) if (IN6_IS_ADDR_UNSPECIFIED (&p.prefix)) return; - work_queue_aim_head (zebrad.ribq, 1); rib_delete_ipv6 (ZEBRA_ROUTE_CONNECT, 0, &p, NULL, ifp->ifindex, 0); - work_queue_aim_head (zebrad.ribq, 0); rib_update (); } diff --git a/zebra/connected.h b/zebra/connected.h index 9595ddb1..8bfe4118 100644 --- a/zebra/connected.h +++ b/zebra/connected.h @@ -26,7 +26,7 @@ extern struct connected * connected_check (struct interface *ifp, struct prefix *p); -extern void +extern struct connected * connected_add_ipv4 (struct interface *ifp, int flags, struct in_addr *addr, u_char prefixlen, struct in_addr *broad, const char *label); @@ -39,7 +39,7 @@ extern void connected_up_ipv4 (struct interface *, struct connected *); extern void connected_down_ipv4 (struct interface *, struct connected *); #ifdef HAVE_IPV6 -extern void +extern struct connected * connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *address, u_char prefixlen, struct in6_addr *broad, const char *label); diff --git a/zebra/if_linkdetect.c b/zebra/if_linkdetect.c deleted file mode 100644 index 4f95c16e..00000000 --- a/zebra/if_linkdetect.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Interface link state tracking - * Copyright (C) 2008 Stephen Hemminger - * - * This file is part of GNU Zebra. - * - * GNU Zebra 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. - * - * GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free - * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include <zebra.h> -#include "log.h" -#include "privs.h" -#include "prefix.h" - -#include "zebra/interface.h" - -extern struct zebra_privs_t zserv_privs; - -static int -linkdetect (const char *name, const char *ver, int onoff) -{ - FILE *fp; - int save_errno; - char proc_name[128]; - - snprintf(proc_name, sizeof(proc_name)-1, - "/proc/sys/net/%s/conf/%s/link_detect", ver, name); - - if ( zserv_privs.change(ZPRIVS_RAISE) ) - zlog_err ("Can't raise privileges, %s", safe_strerror (errno) ); - - fp = fopen (proc_name, "w"); - save_errno = errno; - if (!fp) - { - if ( zserv_privs.change(ZPRIVS_LOWER) ) - zlog_err ("Can't lower privileges, %s", safe_strerror (errno)); - - zlog_info("Can't %s link-detect, %s:%s", - onoff ? "enable" : "disable", - proc_name, safe_strerror(save_errno)); - return -1; - } - else - { - fprintf (fp, "%d\n", onoff); - fclose (fp); - - if ( zserv_privs.change(ZPRIVS_LOWER) ) - zlog_err ("Can't lower privileges, %s", safe_strerror (errno)); - - return onoff; - } -} - -int -if_linkdetect_on (const char *name) -{ - return linkdetect (name, "ipv4", 1); -} - -int -if_linkdetect_off (const char *name) -{ - return linkdetect (name, "ipv4", 0); -} - -#ifdef HAVE_IPV6 -int -if_linkdetect_ipv6_on (const char *name) -{ - return linkdetect (name, "ipv6", 1); -} - -int -if_linkdetect_ipv6_off (const char *name) -{ - return linkdetect (name, "ipv6", 0); -} -#endif diff --git a/zebra/interface.c b/zebra/interface.c index 916c58a6..74c977a9 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -32,7 +32,6 @@ #include "connected.h" #include "log.h" #include "zclient.h" -#include "ipforward.h" #include "zebra/interface.h" #include "zebra/rtadv.h" @@ -49,8 +48,7 @@ if_zebra_new_hook (struct interface *ifp) { struct zebra_if *zebra_if; - zebra_if = XMALLOC (MTYPE_TMP, sizeof (struct zebra_if)); - memset (zebra_if, 0, sizeof (struct zebra_if)); + zebra_if = XCALLOC (MTYPE_TMP, sizeof (struct zebra_if)); zebra_if->multicast = IF_ZEBRA_MULTICAST_UNSPEC; zebra_if->shutdown = IF_ZEBRA_SHUTDOWN_UNSPEC; @@ -1032,12 +1030,6 @@ DEFUN (linkdetect, if_was_operative = if_is_operative(ifp); SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); - /* Enable FIB to remove kernel routes as well */ - if_linkdetect_on(ifp->name); -#ifdef HAVE_IPV6 - if_linkdetect_ipv6_on(ifp->name); -#endif - /* When linkdetection is enabled, if might come down */ if (!if_is_operative(ifp) && if_was_operative) if_down(ifp); @@ -1061,12 +1053,6 @@ DEFUN (no_linkdetect, if_was_operative = if_is_operative(ifp); UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); - /* Disable FIB update on link-detect */ - if_linkdetect_off(ifp->name); -#ifdef HAVE_IPV6 - if_linkdetect_ipv6_off(ifp->name); -#endif - /* Interface may come up after disabling link detection */ if (if_is_operative(ifp) && !if_was_operative) if_up(ifp); diff --git a/zebra/interface.h b/zebra/interface.h index 114270e7..0a6b0365 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -234,23 +234,6 @@ extern int interface_list_proc (void); extern int ifaddr_proc_ipv6 (void); #endif /* HAVE_PROC_NET_IF_INET6 */ -#ifdef HAVE_LINKDETECT -extern int if_linkdetect_on (const char *); -extern int if_linkdetect_off (const char *); -# ifdef HAVE_IPV6 -extern int if_linkdetect_ipv6_on (const char *); -extern int if_linkdetect_ipv6_off (const char *); -# endif -#else -#define if_linkdetect_on(name) -#define if_linkdetect_off(name) -# ifdef HAVE_IPV6 -#define if_linkdetect_ipv6_on(name) -#define if_linkdetect_ipv6_off(name) -# endif -#endif - - #ifdef BSDI extern int if_kvm_get_mtu (struct interface *); #endif /* BSDI */ diff --git a/zebra/ioctl.c b/zebra/ioctl.c index d536771a..5cf9e7b0 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -362,22 +362,29 @@ if_get_flags (struct interface *ifp) return; } #ifdef HAVE_BSD_LINK_DETECT /* Detect BSD link-state at start-up */ - (void) memset(&ifmr, 0, sizeof(ifmr)); - strncpy (&ifmr.ifm_name, ifp->name, IFNAMSIZ); - if (if_ioctl(SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) - { - zlog_err("if_ioctl(SIOCGIFMEDIA) failed: %s", safe_strerror(errno)); - return; - } - if (ifmr.ifm_status & IFM_AVALID) /* Link state is valid */ + + /* Per-default, IFF_RUNNING is held high, unless link-detect says + * otherwise - we abuse IFF_RUNNING inside zebra as a link-state flag, + * following practice on Linux and Solaris kernels + */ + SET_FLAG(ifreq.ifr_flags, IFF_RUNNING); + + if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) { - if (ifmr.ifm_status & IFM_ACTIVE) - SET_FLAG(ifreq.ifr_flags, IFF_RUNNING); - else - UNSET_FLAG(ifreq.ifr_flags, IFF_RUNNING); - } - else /* Force always up */ - SET_FLAG(ifreq.ifr_flags, IFF_RUNNING); + (void) memset(&ifmr, 0, sizeof(ifmr)); + strncpy (&ifmr.ifm_name, ifp->name, IFNAMSIZ); + + /* Seems not all interfaces implement this ioctl */ + if (if_ioctl(SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) + zlog_err("if_ioctl(SIOCGIFMEDIA) failed: %s", safe_strerror(errno)); + else if (ifmr.ifm_status & IFM_AVALID) /* Link state is valid */ + { + if (ifmr.ifm_status & IFM_ACTIVE) + SET_FLAG(ifreq.ifr_flags, IFF_RUNNING); + else + UNSET_FLAG(ifreq.ifr_flags, IFF_RUNNING); + } + } #endif /* HAVE_BSD_LINK_DETECT */ if_flags_update (ifp, (ifreq.ifr_flags & 0x0000ffff)); diff --git a/zebra/kernel_null.c b/zebra/kernel_null.c index 94b7b3c7..c72bbd09 100644 --- a/zebra/kernel_null.c +++ b/zebra/kernel_null.c @@ -12,9 +12,9 @@ int kernel_add_ipv4 (struct prefix *a, struct rib *b) { return 0; } #pragma weak kernel_delete_ipv4 = kernel_add_ipv4 int kernel_add_ipv6 (struct prefix *a, struct rib *b) { return 0; } #pragma weak kernel_delete_ipv6 = kernel_add_ipv6 -int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) -{ return 0; } +void kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, + unsigned int index, int table) +{ } int kernel_add_route (struct prefix_ipv4 *a, struct in_addr *b, int c, int d) { return 0; } diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 2e04b031..e77b9b78 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -126,7 +126,7 @@ extern struct zebra_t zebrad; (LEN) = 0; \ } /* Routing socket message types. */ -struct message rtm_type_str[] = +const struct message rtm_type_str[] = { {RTM_ADD, "RTM_ADD"}, {RTM_DELETE, "RTM_DELETE"}, diff --git a/zebra/linkdetect_null.c b/zebra/linkdetect_null.c deleted file mode 100644 index 1f160c8e..00000000 --- a/zebra/linkdetect_null.c +++ /dev/null @@ -1,28 +0,0 @@ -/* NULL method for testing. */ - -#include <zebra.h> - - -int -if_linkdetect_on (const char *name) -{ - return 0; -} - -int -if_linkdetect_off (const char *name) -{ - return 0; -} - -int -if_linkdetect_ipv6_on (const char *name) -{ - return 0; -} - -int -if_linkdetect_ipv6_off (const char *name) -{ - return 0; -} diff --git a/zebra/main.c b/zebra/main.c index 6019260f..ac0637b6 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -63,12 +63,16 @@ int keep_kernel_mode = 0; u_int32_t nl_rcvbufsize = 0; #endif /* HAVE_NETLINK */ +/* Manage system routes. */ +extern int rib_system_routes; + /* Command line options. */ struct option longopts[] = { { "batch", no_argument, NULL, 'b'}, { "daemon", no_argument, NULL, 'd'}, { "keep_kernel", no_argument, NULL, 'k'}, + { "rib_system", no_argument, NULL, 'S'}, { "log_mode", no_argument, NULL, 'l'}, { "config_file", required_argument, NULL, 'f'}, { "pid_file", required_argument, NULL, 'i'}, @@ -131,6 +135,7 @@ usage (char *progname, int status) "-i, --pid_file Set process identifier file name\n"\ "-k, --keep_kernel Don't delete old routes which installed by "\ "zebra.\n"\ + "-S, --system Manage all routes on link transistions\n" "-l, --log_mode Set verbose log mode flag\n"\ "-C, --dryrun Check configuration for validity and exit\n"\ "-A, --vty_addr Set vty's bind address\n"\ @@ -231,9 +236,9 @@ main (int argc, char **argv) int opt; #ifdef HAVE_NETLINK - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:C", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:CS", longopts, 0); #else - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vC", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vCS", longopts, 0); #endif /* HAVE_NETLINK */ if (opt == EOF) @@ -251,6 +256,9 @@ main (int argc, char **argv) case 'k': keep_kernel_mode = 1; break; + case 'S': + rib_system_routes = 1; + break; case 'C': dryrun = 1; break; @@ -275,7 +283,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : ZEBRA_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = ZEBRA_VTY_PORT; break; case 'r': retain_mode = 1; diff --git a/zebra/rib.h b/zebra/rib.h index f3572ffa..c39afa73 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -60,9 +60,12 @@ struct rib /* Type for this route. < ZEBRA_ROUTE_MAX */ u_int8_t type; + /* Scope for this route. */ + u_int8_t scope; + /* Status Flags for the *route_node*, but kept in the head RIB.. */ u_char rn_status; -#define RIB_ROUTE_QUEUED (1 << 0) +#define RIB_ROUTE_QUEUED(x) (1 << (x)) /* Distance. */ u_char distance; @@ -76,6 +79,7 @@ struct rib /* RIB internal status */ u_char status; #define RIB_ENTRY_REMOVED (1 << 0) +#define RIB_ENTRY_PRESERVE (2 << 0) /* Nexthop information. */ u_char nexthop_num; @@ -83,6 +87,20 @@ struct rib u_char nexthop_fib_num; }; +/* meta-queue structure: + * sub-queue 0: connected, kernel + * sub-queue 1: static + * sub-queue 2: RIP, RIPng, OSPF, OSPF6, IS-IS + * sub-queue 3: iBGP, eBGP + * sub-queue 4: any other origin (if any) + */ +#define MQ_SIZE 5 +struct meta_queue +{ + struct list *subq[MQ_SIZE]; + u_int32_t size; /* sum of lengths of all subqueues */ +}; + /* Static route information. */ struct static_ipv4 { @@ -207,7 +225,8 @@ struct vrf struct route_table *stable[AFI_MAX][SAFI_MAX]; }; -extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int); +extern struct nexthop *nexthop_ifindex_add (struct rib *, unsigned int, + struct in_addr *); extern struct nexthop *nexthop_ifname_add (struct rib *, char *); extern struct nexthop *nexthop_blackhole_add (struct rib *); extern struct nexthop *nexthop_ipv4_add (struct rib *, struct in_addr *, @@ -236,7 +255,7 @@ extern struct route_table *vrf_static_table (afi_t afi, safi_t safi, u_int32_t i extern int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, struct in_addr *gate, struct in_addr *src, unsigned int ifindex, u_int32_t vrf_id, - u_int32_t, u_char); + u_int32_t metric, u_int8_t distance, u_int8_t scope); extern int rib_add_ipv4_multipath (struct prefix_ipv4 *, struct rib *); @@ -36,8 +36,8 @@ extern int kernel_address_delete_ipv4 (struct interface *, struct connected *); #ifdef HAVE_IPV6 extern int kernel_add_ipv6 (struct prefix *, struct rib *); extern int kernel_delete_ipv6 (struct prefix *, struct rib *); -extern int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table); +extern void kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, + unsigned int index, int table); #endif /* HAVE_IPV6 */ diff --git a/zebra/rt_ioctl.c b/zebra/rt_ioctl.c index a5d588c7..d39ec4df 100644 --- a/zebra/rt_ioctl.c +++ b/zebra/rt_ioctl.c @@ -553,8 +553,8 @@ kernel_delete_ipv6 (struct prefix *p, struct rib *rib) /* Delete IPv6 route from the kernel. */ int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) + unsigned int index, int table) { - return kernel_ioctl_ipv6 (SIOCDELRT, dest, gate, index, flags); + return kernel_ioctl_ipv6 (SIOCDELRT, dest, gate, index, 0; } #endif /* HAVE_IPV6 */ diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index ba66ab90..f9f90224 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -53,7 +53,7 @@ struct nlsock } netlink = { -1, 0, {0}, "netlink-listen"}, /* kernel messages */ netlink_cmd = { -1, 0, {0}, "netlink-cmd"}; /* command channel */ -static struct message nlmsg_str[] = { +static const struct message nlmsg_str[] = { {RTM_NEWROUTE, "RTM_NEWROUTE"}, {RTM_DELROUTE, "RTM_DELROUTE"}, {RTM_GETROUTE, "RTM_GETROUTE"}, @@ -87,32 +87,11 @@ extern struct zebra_privs_t zserv_privs; extern u_int32_t nl_rcvbufsize; -/* Note: on netlink systems, there should be a 1-to-1 mapping between interface - names and ifindex values. */ -static void -set_ifindex(struct interface *ifp, unsigned int ifi_index) -{ - struct interface *oifp; +extern int rib_system_routes; - if (((oifp = if_lookup_by_index(ifi_index)) != NULL) && (oifp != ifp)) - { - if (ifi_index == IFINDEX_INTERNAL) - zlog_err("Netlink is setting interface %s ifindex to reserved " - "internal value %u", ifp->name, ifi_index); - else - { - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug("interface index %d was renamed from %s to %s", - ifi_index, oifp->name, ifp->name); - if (if_is_operative(oifp)) - zlog_err("interface rename detected on up interface: index %d " - "was renamed from %s to %s, results are uncertain!", - ifi_index, oifp->name, ifp->name); - if_delete_update(oifp); - } - } - ifp->ifindex = ifi_index; -} +static void +netlink_delroute (int family, void *dest, int length, void *gate, + int index, int table, int proto); static int netlink_recvbuf (struct nlsock *nl, uint32_t newsize) @@ -316,6 +295,13 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *), return -1; } + /* JF: Ignore messages that aren't from the kernel */ + if ( snl.nl_pid != 0 ) + { + zlog_debug ("Ignoring message from pid %u", snl.nl_pid ); + continue; + } + for (h = (struct nlmsghdr *) buf; NLMSG_OK (h, (unsigned int) status); h = NLMSG_NEXT (h, status)) { @@ -467,14 +453,28 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h) #endif /* IFLA_WIRELESS */ if (tb[IFLA_IFNAME] == NULL) - return -1; + { + zlog_err("%s: missing interface name in message", __func__); + return -1; + } name = (char *) RTA_DATA (tb[IFLA_IFNAME]); + if (ifi->ifi_index == IFINDEX_INTERNAL) + { + zlog_err("%s: reserved ifindex", __func__); + return -1; + } + /* Add interface. */ - ifp = if_get_by_name (name); - set_ifindex(ifp, ifi->ifi_index); + ifp = if_lookup_by_index(ifi->ifi_index); + if (!ifp) + { + ifp = if_create(name, strlen(name)); + ifp->ifindex = ifi->ifi_index; + } + strncpy(ifp->name, name, INTERFACE_NAMSIZ); ifp->flags = ifi->ifi_flags & 0x0000fffff; - ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); + ifp->mtu6 = ifp->mtu = *(uint32_t *) RTA_DATA (tb[IFLA_MTU]); ifp->metric = 1; /* Hardware type and address. */ @@ -528,7 +528,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) #ifdef HAVE_IPV6 && ifa->ifa_family != AF_INET6 #endif /* HAVE_IPV6 */ - ) + ) return 0; if (h->nlmsg_type != RTM_NEWADDR && h->nlmsg_type != RTM_DELADDR) @@ -553,7 +553,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) { char buf[BUFSIZ]; zlog_debug ("netlink_interface_addr %s %s:", - lookup (nlmsg_str, h->nlmsg_type), ifp->name); + lookup (nlmsg_str, h->nlmsg_type), ifp->name); if (tb[IFA_LOCAL]) zlog_debug (" IFA_LOCAL %s/%d", inet_ntop (ifa->ifa_family, RTA_DATA (tb[IFA_LOCAL]), @@ -619,9 +619,25 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) if (ifa->ifa_family == AF_INET) { if (h->nlmsg_type == RTM_NEWADDR) - connected_add_ipv4 (ifp, flags, - (struct in_addr *) addr, ifa->ifa_prefixlen, - (struct in_addr *) broad, label); + { + struct connected *ifc; + ifc = connected_add_ipv4 (ifp, flags, + (struct in_addr *) addr, ifa->ifa_prefixlen, + (struct in_addr *) broad, label); + + /* If address added, but interface is down, + then remove the FIB entry from kernel. + */ + if (rib_system_routes && ifc && !if_is_operative (ifp)) + { + struct prefix_ipv4 p; + PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc)); + apply_mask_ipv4 (&p); + + netlink_delroute (p.family, &p.prefix, p.prefixlen, NULL, + ifp->ifindex, RT_TABLE_MAIN, RTPROT_KERNEL); + } + } else connected_delete_ipv4 (ifp, flags, (struct in_addr *) addr, ifa->ifa_prefixlen, @@ -631,9 +647,9 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h) if (ifa->ifa_family == AF_INET6) { if (h->nlmsg_type == RTM_NEWADDR) - connected_add_ipv6 (ifp, flags, - (struct in6_addr *) addr, ifa->ifa_prefixlen, - (struct in6_addr *) broad, label); + connected_add_ipv6 (ifp, flags, + (struct in6_addr *) addr, ifa->ifa_prefixlen, + (struct in6_addr *) broad, label); else connected_delete_ipv6 (ifp, (struct in6_addr *) addr, ifa->ifa_prefixlen, @@ -704,7 +720,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) src = NULL; if (tb[RTA_OIF]) - index = *(int *) RTA_DATA (tb[RTA_OIF]); + index = *(uint32_t *) RTA_DATA (tb[RTA_OIF]); if (tb[RTA_DST]) dest = RTA_DATA (tb[RTA_DST]); @@ -719,7 +735,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) gate = RTA_DATA (tb[RTA_GATEWAY]); if (tb[RTA_PRIORITY]) - metric = *(int *) RTA_DATA(tb[RTA_PRIORITY]); + metric = *(uint32_t *) RTA_DATA(tb[RTA_PRIORITY]); if (rtm->rtm_family == AF_INET) { @@ -728,7 +744,8 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) memcpy (&p.prefix, dest, 4); p.prefixlen = rtm->rtm_dst_len; - rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index, table, metric, 0); + rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, flags, &p, gate, src, index, + table, metric, 0, rtm->rtm_scope); } #ifdef HAVE_IPV6 if (rtm->rtm_family == AF_INET6) @@ -746,7 +763,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h) return 0; } -struct message rtproto_str[] = { +static const struct message rtproto_str[] = { {RTPROT_REDIRECT, "redirect"}, {RTPROT_KERNEL, "kernel"}, {RTPROT_BOOT, "boot"}, @@ -835,7 +852,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h) src = NULL; if (tb[RTA_OIF]) - index = *(int *) RTA_DATA (tb[RTA_OIF]); + index = *(uint32_t *) RTA_DATA (tb[RTA_OIF]); if (tb[RTA_DST]) dest = RTA_DATA (tb[RTA_DST]); @@ -866,7 +883,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h) } if (h->nlmsg_type == RTM_NEWROUTE) - rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table, 0, 0); + rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, src, index, table, 0, + 0, rtm->rtm_scope); else rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, &p, gate, index, table); } @@ -941,70 +959,94 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) #endif /* IFLA_WIRELESS */ if (tb[IFLA_IFNAME] == NULL) - return -1; + { + zlog_err("%s: missing interface name", __func__); + return -1; + } name = (char *) RTA_DATA (tb[IFLA_IFNAME]); /* Add interface. */ if (h->nlmsg_type == RTM_NEWLINK) { unsigned long new_flags = ifi->ifi_flags & 0x0000fffff; - ifp = if_lookup_by_name (name); + unsigned int mtu = *(uint32_t *) RTA_DATA (tb[IFLA_MTU]); + ifp = if_lookup_by_index (ifi->ifi_index); + /* New interface */ if (ifp == NULL || !CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE)) { if (ifp == NULL) - ifp = if_get_by_name (name); + { + ifp = if_create(name, strlen(name)); + ifp->ifindex = ifi->ifi_index; + ifp->metric = 1; + } + else if (strcmp(ifp->name, name) != 0) + { + strncpy(ifp->name, name, INTERFACE_NAMSIZ); + } zlog_info ("interface %s index %d %s added.", name, ifi->ifi_index, if_flag_dump(new_flags)); - set_ifindex(ifp, ifi->ifi_index); ifp->flags = new_flags; - ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); - ifp->metric = 1; + ifp->mtu6 = ifp->mtu = mtu; - /* If new link is added. */ - if_add_update (ifp); + /* If new link is added. */ + if_add_update (ifp); } - else - { - /* Interface status change. */ - set_ifindex(ifp, ifi->ifi_index); - ifp->mtu6 = ifp->mtu = *(int *) RTA_DATA (tb[IFLA_MTU]); - ifp->metric = 1; + /* Interface status change. */ + else if (new_flags != ifp->flags) + { + ifp->mtu6 = ifp->mtu = mtu; - if (new_flags != ifp->flags) - { - zlog_info ("interface %s index %d changed %s.", - name, ifi->ifi_index, if_flag_dump(new_flags)); + zlog_info ("interface %s index %d changed %s.", + name, ifi->ifi_index, if_flag_dump(new_flags)); - if (if_is_operative (ifp)) - { - ifp->flags = new_flags; - if (!if_is_operative (ifp)) - if_down (ifp); - else - /* Must notify client daemons of new interface status. */ - zebra_interface_up_update (ifp); - } + if (if_is_operative (ifp)) + { + ifp->flags = new_flags; + if (!if_is_operative (ifp)) + if_down (ifp); else - { - ifp->flags = new_flags; - if (if_is_operative (ifp)) - if_up (ifp); - } + /* Must notify client daemons of new interface status. */ + zebra_interface_up_update (ifp); } - } + else + { + ifp->flags = new_flags; + if (if_is_operative (ifp)) + if_up (ifp); + } + } + /* Interface name change */ + else if (strcmp(ifp->name, name) != 0) + { + ifp->mtu = ifp->mtu6 = mtu; + zlog_info("interface index %d was renamed from %s to %s", + ifi->ifi_index, ifp->name, name); + + strncpy(ifp->name, name, INTERFACE_NAMSIZ); + rib_update(); + } + /* Interface mtu change */ + else if (mtu != ifp->mtu) + { + zlog_info("interface index %d mtu changed from %u to %u", + ifp->mtu, mtu); + ifp->mtu = ifp->mtu6 = mtu; + if (if_is_operative (ifp)) + zebra_interface_up_update (ifp); + } } else { // RTM_DELLINK. - ifp = if_lookup_by_name (name); - + ifp = if_lookup_by_index (ifi->ifi_index); if (ifp == NULL) { - zlog (NULL, LOG_WARNING, "interface %s is deleted but can't find", - name); + zlog (NULL, LOG_WARNING, "interface %s index %d is deleted but can't find", + name, ifi->ifi_index); return 0; } else @@ -1012,6 +1054,7 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h) name, ifi->ifi_index); if_delete_update (ifp); + if_delete (ifp); } return 0; } @@ -1205,11 +1248,6 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl) /* Request an acknowledgement by setting NLM_F_ACK */ n->nlmsg_flags |= NLM_F_ACK; - if (IS_ZEBRA_DEBUG_KERNEL) - zlog_debug ("netlink_talk: %s type %s(%u), seq=%u", nl->name, - lookup (nlmsg_str, n->nlmsg_type), n->nlmsg_type, - n->nlmsg_seq); - /* Send message to netlink interface. */ if (zserv_privs.change (ZPRIVS_RAISE)) zlog (NULL, LOG_ERR, "Can't raise privileges"); @@ -1234,15 +1272,11 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl) } /* Routing table change via netlink interface. */ -static int -netlink_route (int cmd, int family, void *dest, int length, void *gate, - int index, int zebra_flags, int table) +static void +netlink_delroute (int family, void *dest, int length, void *gate, + int index, int table, int proto) { - int ret; - int bytelen; - struct sockaddr_nl snl; - int discard; - + int bytelen = (family == AF_INET ? 4 : 16); struct { struct nlmsghdr n; @@ -1252,60 +1286,25 @@ netlink_route (int cmd, int family, void *dest, int length, void *gate, memset (&req, 0, sizeof req); - bytelen = (family == AF_INET ? 4 : 16); - req.n.nlmsg_len = NLMSG_LENGTH (sizeof (struct rtmsg)); - req.n.nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST; - req.n.nlmsg_type = cmd; + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = RTM_DELROUTE; req.r.rtm_family = family; + req.r.rtm_scope = RT_SCOPE_NOWHERE; req.r.rtm_table = table; req.r.rtm_dst_len = length; - if ((zebra_flags & ZEBRA_FLAG_BLACKHOLE) - || (zebra_flags & ZEBRA_FLAG_REJECT)) - discard = 1; - else - discard = 0; - - if (cmd == RTM_NEWROUTE) - { - req.r.rtm_protocol = RTPROT_ZEBRA; - req.r.rtm_scope = RT_SCOPE_UNIVERSE; - - if (discard) - { - if (zebra_flags & ZEBRA_FLAG_BLACKHOLE) - req.r.rtm_type = RTN_BLACKHOLE; - else if (zebra_flags & ZEBRA_FLAG_REJECT) - req.r.rtm_type = RTN_UNREACHABLE; - else - assert (RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */ - } - else - req.r.rtm_type = RTN_UNICAST; - } - if (dest) addattr_l (&req.n, sizeof req, RTA_DST, dest, bytelen); - if (!discard) - { - if (gate) - addattr_l (&req.n, sizeof req, RTA_GATEWAY, gate, bytelen); - if (index > 0) - addattr32 (&req.n, sizeof req, RTA_OIF, index); - } + if (gate) + addattr_l (&req.n, sizeof req, RTA_GATEWAY, gate, bytelen); - /* Destination netlink address. */ - memset (&snl, 0, sizeof snl); - snl.nl_family = AF_NETLINK; + if (index > 0) + addattr32 (&req.n, sizeof req, RTA_OIF, index); /* Talk to netlink socket. */ - ret = netlink_talk (&req.n, &netlink_cmd); - if (ret < 0) - return -1; - - return 0; + netlink_talk (&req.n, &netlink_cmd); } /* Routing table change via netlink interface. */ @@ -1342,11 +1341,22 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib, else discard = 0; + switch (rib->type) { + case ZEBRA_ROUTE_KERNEL: + /* FIXME: should remember original protocol from RTM_NEWLINK */ + req.r.rtm_protocol = RTPROT_BOOT; + break; + case ZEBRA_ROUTE_CONNECT: + req.r.rtm_protocol = RTPROT_KERNEL; + break; + default: + req.r.rtm_protocol = RTPROT_ZEBRA; + } + + req.r.rtm_scope = rib->scope; + if (cmd == RTM_NEWROUTE) { - req.r.rtm_protocol = RTPROT_ZEBRA; - req.r.rtm_scope = RT_SCOPE_UNIVERSE; - if (discard) { if (rib->flags & ZEBRA_FLAG_BLACKHOLE) @@ -1362,8 +1372,8 @@ netlink_route_multipath (int cmd, struct prefix *p, struct rib *rib, addattr_l (&req.n, sizeof req, RTA_DST, &p->u.prefix, bytelen); - /* Metric. */ - addattr32 (&req.n, sizeof req, RTA_PRIORITY, rib->metric); + if (rib->type != ZEBRA_ROUTE_CONNECT) + addattr32 (&req.n, sizeof req, RTA_PRIORITY, rib->metric); if (discard) { @@ -1762,12 +1772,12 @@ kernel_delete_ipv6 (struct prefix *p, struct rib *rib) } /* Delete IPv6 route from the kernel. */ -int +void kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) + unsigned int index, int table) { - return netlink_route (RTM_DELROUTE, AF_INET6, &dest->prefix, - dest->prefixlen, gate, index, flags, table); + netlink_delroute (AF_INET6, &dest->prefix, + dest->prefixlen, gate, index, table, RTPROT_ZEBRA); } #endif /* HAVE_IPV6 */ @@ -1856,19 +1866,13 @@ kernel_read (struct thread *thread) static void netlink_install_filter (int sock, __u32 pid) { struct sock_filter filter[] = { - /* 0: ldh [4] */ - BPF_STMT(BPF_LD|BPF_ABS|BPF_H, offsetof(struct nlmsghdr, nlmsg_type)), - /* 1: jeq 0x18 jt 3 jf 6 */ - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_NEWROUTE), 1, 0), - /* 2: jeq 0x19 jt 3 jf 6 */ - BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htons(RTM_DELROUTE), 0, 3), - /* 3: ldw [12] */ + /* 0: ldw [12] */ BPF_STMT(BPF_LD|BPF_ABS|BPF_W, offsetof(struct nlmsghdr, nlmsg_pid)), - /* 4: jeq XX jt 5 jf 6 */ + /* 1: jeq XX jt 2 jf 3 */ BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, htonl(pid), 0, 1), - /* 5: ret 0 (skip) */ + /* 2: ret 0 (skip) */ BPF_STMT(BPF_RET|BPF_K, 0), - /* 6: ret 0xffff (keep) */ + /* 3: ret 0xffff (keep) */ BPF_STMT(BPF_RET|BPF_K, 0xffff), }; @@ -1877,7 +1881,7 @@ static void netlink_install_filter (int sock, __u32 pid) .filter = filter, }; - if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog)) < 0) + if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER, &prog, sizeof(prog)) < 0) zlog_warn ("Can't install socket filter: %s\n", safe_strerror(errno)); } diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 1b8ded7e..9bbecb95 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -509,13 +509,13 @@ kernel_delete_ipv6 (struct prefix *p, struct rib *rib) /* Delete IPv6 route from the kernel. */ int kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate, - unsigned int index, int flags, int table) + unsigned int index, int table) { int route; if (zserv_privs.change(ZPRIVS_RAISE)) zlog (NULL, LOG_ERR, "Can't raise privileges"); - route = kernel_rtm_ipv6 (RTM_DELETE, dest, gate, index, flags); + route = kernel_rtm_ipv6 (RTM_DELETE, dest, gate, index); if (zserv_privs.change(ZPRIVS_LOWER)) zlog (NULL, LOG_ERR, "Can't lower privileges"); diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 0097e28f..86956ed7 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -84,10 +84,7 @@ struct rtadv *rtadv = NULL; static struct rtadv * rtadv_new (void) { - struct rtadv *new; - new = XMALLOC (MTYPE_TMP, sizeof (struct rtadv)); - memset (new, 0, sizeof (struct rtadv)); - return new; + return XCALLOC (MTYPE_TMP, sizeof (struct rtadv)); } #if 0 @@ -531,12 +528,7 @@ rtadv_make_socket (void) static struct rtadv_prefix * rtadv_prefix_new () { - struct rtadv_prefix *new; - - new = XMALLOC (MTYPE_RTADV_PREFIX, sizeof (struct rtadv_prefix)); - memset (new, 0, sizeof (struct rtadv_prefix)); - - return new; + return XCALLOC (MTYPE_RTADV_PREFIX, sizeof (struct rtadv_prefix)); } static void diff --git a/zebra/zebra.conf.sample b/zebra/zebra.conf.sample index cf135281..a5d0732f 100644 --- a/zebra/zebra.conf.sample +++ b/zebra/zebra.conf.sample @@ -2,7 +2,7 @@ ! ! zebra sample configuration file ! -! $Id$ +! $Id: zebra.conf.sample,v 1.1 2002/12/13 20:15:30 paul Exp $ ! hostname Router password zebra diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index a511577b..69249779 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -44,6 +44,9 @@ /* Default rtm_table for all clients */ extern struct zebra_t zebrad; +/* Should kernel routes be removed on link down? */ +int rib_system_routes = 0; + /* Hold time for RIB process, should be very minimal. * it is useful to able to set it otherwise for testing, hence exported * as global here for test-rig code. @@ -209,14 +212,16 @@ nexthop_free (struct nexthop *nexthop) } struct nexthop * -nexthop_ifindex_add (struct rib *rib, unsigned int ifindex) +nexthop_ifindex_add (struct rib *rib, unsigned int ifindex, + struct in_addr *src) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IFINDEX; nexthop->ifindex = ifindex; + if (src) + nexthop->src.ipv4 = *src; nexthop_add (rib, nexthop); @@ -228,8 +233,7 @@ nexthop_ifname_add (struct rib *rib, char *ifname) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IFNAME; nexthop->ifname = XSTRDUP (0, ifname); @@ -243,8 +247,7 @@ nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV4; nexthop->gate.ipv4 = *ipv4; if (src) @@ -261,8 +264,7 @@ nexthop_ipv4_ifindex_add (struct rib *rib, struct in_addr *ipv4, { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV4_IFINDEX; nexthop->gate.ipv4 = *ipv4; if (src) @@ -280,8 +282,7 @@ nexthop_ipv6_add (struct rib *rib, struct in6_addr *ipv6) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV6; nexthop->gate.ipv6 = *ipv6; @@ -296,8 +297,7 @@ nexthop_ipv6_ifname_add (struct rib *rib, struct in6_addr *ipv6, { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV6_IFNAME; nexthop->gate.ipv6 = *ipv6; nexthop->ifname = XSTRDUP (0, ifname); @@ -313,8 +313,7 @@ nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6, { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX; nexthop->gate.ipv6 = *ipv6; nexthop->ifindex = ifindex; @@ -330,8 +329,7 @@ nexthop_blackhole_add (struct rib *rib) { struct nexthop *nexthop; - nexthop = XMALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); - memset (nexthop, 0, sizeof (struct nexthop)); + nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop)); nexthop->type = NEXTHOP_TYPE_BLACKHOLE; SET_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE); @@ -444,7 +442,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, if (nexthop->type == NEXTHOP_TYPE_IPV4) nexthop->ifindex = newhop->ifindex; } - else + else { if (nexthop->ifindex != newhop->ifindex || CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) @@ -453,8 +451,8 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, return 1; } } - else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL) || - match->type == ZEBRA_ROUTE_STATIC) + else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL) + || match->type == ZEBRA_ROUTE_STATIC) { for (newhop = match->nexthop; newhop; newhop = newhop->next) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB) @@ -479,8 +477,6 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set, || newhop->ifindex != nexthop->ifindex || nexthop->gate.ipv4.s_addr != newhop->gate.ipv4.s_addr) SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED); - - return 1; } return 0; @@ -573,7 +569,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, if (nexthop->type == NEXTHOP_TYPE_IPV6) nexthop->ifindex = newhop->ifindex; } - else + else { if (nexthop->ifindex != newhop->ifindex || CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) @@ -582,7 +578,8 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, return 1; } } - else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL)) + else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL) || + match->type == ZEBRA_ROUTE_STATIC) { for (newhop = match->nexthop; newhop; newhop = newhop->next) if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB) @@ -607,8 +604,8 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set, } else if (! CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE) || newhop->ifindex != nexthop->ifindex - || !IPV6_ADDR_SAME(&nexthop->gate.ipv6, - &newhop->gate.ipv4)) + || !IPV6_ADDR_SAME(&nexthop->gate.ipv6, + &newhop->gate.ipv6)) SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED); return 1; @@ -654,12 +651,11 @@ rib_match_ipv4 (struct in_addr addr) for (match = rn->info; match; match = match->next) { if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) - continue; + continue; if (CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED)) break; } - /* If there is no selected route or matched route is EGP, go up tree. */ if (! match @@ -710,7 +706,6 @@ rib_lookup_ipv4 (struct prefix_ipv4 *p) /* Unlock node. */ route_unlock_node (rn); - /* Pick up selected route. */ for (match = rn->info; match; match = match->next) { if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) @@ -786,24 +781,24 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate) /* Ok, we have a cood candidate, let's check it's nexthop list... */ for (nexthop = match->nexthop; nexthop; nexthop = nexthop->next) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) - { - /* We are happy with either direct or recursive hexthop */ - if (nexthop->gate.ipv4.s_addr == qgate->sin.sin_addr.s_addr || - nexthop->rgate.ipv4.s_addr == qgate->sin.sin_addr.s_addr) - return ZEBRA_RIB_FOUND_EXACT; - else { - if (IS_ZEBRA_DEBUG_RIB) - { - char gate_buf[INET_ADDRSTRLEN], rgate_buf[INET_ADDRSTRLEN], qgate_buf[INET_ADDRSTRLEN]; - inet_ntop (AF_INET, &nexthop->gate.ipv4.s_addr, gate_buf, INET_ADDRSTRLEN); - inet_ntop (AF_INET, &nexthop->rgate.ipv4.s_addr, rgate_buf, INET_ADDRSTRLEN); - inet_ntop (AF_INET, &qgate->sin.sin_addr.s_addr, qgate_buf, INET_ADDRSTRLEN); - zlog_debug ("%s: qgate == %s, gate == %s, rgate == %s", __func__, qgate_buf, gate_buf, rgate_buf); - } - return ZEBRA_RIB_FOUND_NOGATE; + /* We are happy with either direct or recursive hexthop */ + if (nexthop->gate.ipv4.s_addr == qgate->sin.sin_addr.s_addr || + nexthop->rgate.ipv4.s_addr == qgate->sin.sin_addr.s_addr) + return ZEBRA_RIB_FOUND_EXACT; + else + { + if (IS_ZEBRA_DEBUG_RIB) + { + char gate_buf[INET_ADDRSTRLEN], rgate_buf[INET_ADDRSTRLEN], qgate_buf[INET_ADDRSTRLEN]; + inet_ntop (AF_INET, &nexthop->gate.ipv4.s_addr, gate_buf, INET_ADDRSTRLEN); + inet_ntop (AF_INET, &nexthop->rgate.ipv4.s_addr, rgate_buf, INET_ADDRSTRLEN); + inet_ntop (AF_INET, &qgate->sin.sin_addr.s_addr, qgate_buf, INET_ADDRSTRLEN); + zlog_debug ("%s: qgate == %s, gate == %s, rgate == %s", __func__, qgate_buf, gate_buf, rgate_buf); + } + return ZEBRA_RIB_FOUND_NOGATE; + } } - } return ZEBRA_RIB_NOTFOUND; } @@ -838,7 +833,7 @@ rib_match_ipv6 (struct in6_addr *addr) for (match = rn->info; match; match = match->next) { if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) - continue; + continue; if (CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED)) break; } @@ -872,8 +867,10 @@ rib_match_ipv6 (struct in6_addr *addr) } #endif /* HAVE_IPV6 */ -#define RIB_SYSTEM_ROUTE(R) \ +#define RIB_SYSTEM_ROUTE(R) \ ((R)->type == ZEBRA_ROUTE_KERNEL || (R)->type == ZEBRA_ROUTE_CONNECT) +#define RIB_SHOULD_UPDATE(R) \ + (! CHECK_FLAG((R)->status, RIB_ENTRY_PRESERVE) ) /* This function verifies reachability of one given nexthop, which can be * numbered or unnumbered, IPv4 or IPv6. The result is unconditionally stored @@ -884,7 +881,6 @@ rib_match_ipv6 (struct in6_addr *addr) * * The return value is the final value of 'ACTIVE' flag. */ - static int nexthop_active_check (struct route_node *rn, struct rib *rib, struct nexthop *nexthop, int set) @@ -900,7 +896,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, { case NEXTHOP_TYPE_IFINDEX: ifp = if_lookup_by_index (nexthop->ifindex); - if (ifp && if_is_operative (ifp)) + if (ifp && if_is_operative(ifp)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -909,7 +905,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, family = AFI_IP6; case NEXTHOP_TYPE_IFNAME: ifp = if_lookup_by_name (nexthop->ifname); - if (ifp && if_is_operative (ifp)) + if (ifp && if_is_operative(ifp)) { if (set) nexthop->ifindex = ifp->ifindex; @@ -943,7 +939,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6)) { ifp = if_lookup_by_index (nexthop->ifindex); - if (ifp && if_is_operative (ifp)) + if (ifp && if_is_operative(ifp)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -972,7 +968,8 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); rmap = 0; - if (rib->type < ZEBRA_ROUTE_MAX && proto_rm[family][rib->type]) + if (rib->type >= 0 && rib->type < ZEBRA_ROUTE_MAX && + proto_rm[family][rib->type]) rmap = route_map_lookup_by_name (proto_rm[family][rib->type]); if (!rmap && proto_rm[family][ZEBRA_ROUTE_MAX]) rmap = route_map_lookup_by_name (proto_rm[family][ZEBRA_ROUTE_MAX]); @@ -1056,8 +1053,6 @@ rib_uninstall_kernel (struct route_node *rn, struct rib *rib) break; #ifdef HAVE_IPV6 case AF_INET6: - if (IS_ZEBRA_DEBUG_RIB) - zlog_debug ("%s: calling kernel_delete_ipv4 (%p, %p)", __func__, rn, rib); ret = kernel_delete_ipv6 (&rn->p, rib); break; #endif /* HAVE_IPV6 */ @@ -1076,7 +1071,7 @@ rib_uninstall (struct route_node *rn, struct rib *rib) if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) { redistribute_delete (&rn->p, rib); - if (! RIB_SYSTEM_ROUTE (rib)) + if (RIB_SHOULD_UPDATE (rib)) rib_uninstall_kernel (rn, rib); UNSET_FLAG (rib->flags, ZEBRA_FLAG_SELECTED); } @@ -1085,15 +1080,14 @@ rib_uninstall (struct route_node *rn, struct rib *rib) static void rib_unlink (struct route_node *, struct rib *); /* Core function for processing routing information base. */ -static wq_item_status -rib_process (struct work_queue *wq, void *data) +static void +rib_process (struct route_node *rn) { struct rib *rib; struct rib *next; struct rib *fib = NULL; struct rib *select = NULL; struct rib *del = NULL; - struct route_node *rn = data; int installed = 0; struct nexthop *nexthop = NULL; char buf[INET6_ADDRSTRLEN]; @@ -1202,17 +1196,17 @@ rib_process (struct work_queue *wq, void *data) if (CHECK_FLAG (select->flags, ZEBRA_FLAG_CHANGED)) { redistribute_delete (&rn->p, select); - if (! RIB_SYSTEM_ROUTE (select)) + if (RIB_SHOULD_UPDATE (select)) rib_uninstall_kernel (rn, select); /* Set real nexthop. */ nexthop_active_update (rn, select, 1); - if (! RIB_SYSTEM_ROUTE (select)) + if (RIB_SHOULD_UPDATE (select)) rib_install_kernel (rn, select); redistribute_add (&rn->p, select); } - else if (! RIB_SYSTEM_ROUTE (select)) + else if (RIB_SHOULD_UPDATE (select)) { /* Housekeeping code to deal with race conditions in kernel with linux @@ -1243,7 +1237,7 @@ rib_process (struct work_queue *wq, void *data) zlog_debug ("%s: %s/%d: Removing existing route, fib %p", __func__, buf, rn->p.prefixlen, fib); redistribute_delete (&rn->p, fib); - if (! RIB_SYSTEM_ROUTE (fib)) + if (RIB_SHOULD_UPDATE (fib)) rib_uninstall_kernel (rn, fib); UNSET_FLAG (fib->flags, ZEBRA_FLAG_SELECTED); @@ -1263,7 +1257,7 @@ rib_process (struct work_queue *wq, void *data) /* Set real nexthop. */ nexthop_active_update (rn, select, 1); - if (! RIB_SYSTEM_ROUTE (select)) + if (RIB_SHOULD_UPDATE (select)) rib_install_kernel (rn, select); SET_FLAG (select->flags, ZEBRA_FLAG_SELECTED); redistribute_add (&rn->p, select); @@ -1281,10 +1275,100 @@ rib_process (struct work_queue *wq, void *data) end: if (IS_ZEBRA_DEBUG_RIB_Q) zlog_debug ("%s: %s/%d: rn %p dequeued", __func__, buf, rn->p.prefixlen, rn); - if (rn->info) - UNSET_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED); - route_unlock_node (rn); /* rib queue lock */ - return WQ_SUCCESS; +} + +/* Take a list of route_node structs and return 1, if there was a record + * picked from it and processed by rib_process(). Don't process more, + * than one RN record; operate only in the specified sub-queue. + */ +static unsigned int +process_subq (struct list * subq, u_char qindex) +{ + struct listnode *lnode = listhead (subq); + struct route_node *rnode; + + if (!lnode) + return 0; + + rnode = listgetdata (lnode); + rib_process (rnode); + + if (rnode->info) /* The first RIB record is holding the flags bitmask. */ + UNSET_FLAG (((struct rib *)rnode->info)->rn_status, RIB_ROUTE_QUEUED(qindex)); + + route_unlock_node (rnode); + list_delete_node (subq, lnode); + return 1; +} + +/* Dispatch the meta queue by picking, processing and unlocking the next RN from + * a non-empty sub-queue with lowest priority. wq is equal to zebra->ribq and data + * is pointed to the meta queue structure. + */ +static wq_item_status +meta_queue_process (struct work_queue *dummy, void *data) +{ + struct meta_queue * mq = data; + unsigned i; + + for (i = 0; i < MQ_SIZE; i++) + if (process_subq (mq->subq[i], i)) + { + mq->size--; + break; + } + return mq->size ? WQ_REQUEUE : WQ_SUCCESS; +} + +/* Map from rib types to queue type (priority) in meta queue */ +static const u_char meta_queue_map[ZEBRA_ROUTE_MAX] = { + [ZEBRA_ROUTE_SYSTEM] = 4, + [ZEBRA_ROUTE_KERNEL] = 0, + [ZEBRA_ROUTE_CONNECT] = 0, + [ZEBRA_ROUTE_STATIC] = 1, + [ZEBRA_ROUTE_RIP] = 2, + [ZEBRA_ROUTE_RIPNG] = 2, + [ZEBRA_ROUTE_OSPF] = 2, + [ZEBRA_ROUTE_OSPF6] = 2, + [ZEBRA_ROUTE_ISIS] = 2, + [ZEBRA_ROUTE_BGP] = 3, + [ZEBRA_ROUTE_HSLS] = 4, +}; + +/* Look into the RN and queue it into one or more priority queues, + * increasing the size for each data push done. + */ +static void +rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn) +{ + struct rib *rib; + char buf[INET6_ADDRSTRLEN]; + + if (IS_ZEBRA_DEBUG_RIB_Q) + inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); + + for (rib = rn->info; rib; rib = rib->next) + { + u_char qindex = meta_queue_map[rib->type]; + + /* Invariant: at this point we always have rn->info set. */ + if (CHECK_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED(qindex))) + { + if (IS_ZEBRA_DEBUG_RIB_Q) + zlog_debug ("%s: %s/%d: rn %p is already queued in sub-queue %u", + __func__, buf, rn->p.prefixlen, rn, qindex); + continue; + } + + SET_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED(qindex)); + listnode_add (mq->subq[qindex], rn); + route_lock_node (rn); + mq->size++; + + if (IS_ZEBRA_DEBUG_RIB_Q) + zlog_debug ("%s: %s/%d: queued rn %p into sub-queue %u", + __func__, buf, rn->p.prefixlen, rn, qindex); + } } /* Add route_node to work queue and schedule processing */ @@ -1306,17 +1390,6 @@ rib_queue_add (struct zebra_t *zebra, struct route_node *rn) return; } - /* Route-table node already queued, so nothing to do */ - if (CHECK_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED)) - { - if (IS_ZEBRA_DEBUG_RIB_Q) - zlog_debug ("%s: %s/%d: rn %p already queued", __func__, buf, - rn->p.prefixlen, rn); - return; - } - - route_lock_node (rn); /* rib queue lock */ - if (IS_ZEBRA_DEBUG_RIB_Q) zlog_info ("%s: %s/%d: work queue added", __func__, buf, rn->p.prefixlen); @@ -1325,13 +1398,21 @@ rib_queue_add (struct zebra_t *zebra, struct route_node *rn) if (zebra->ribq == NULL) { zlog_err ("%s: work_queue does not exist!", __func__); - route_unlock_node (rn); return; } - - work_queue_add (zebra->ribq, rn); - SET_FLAG (((struct rib *)rn->info)->rn_status, RIB_ROUTE_QUEUED); + /* The RIB queue should normally be either empty or holding the only work_queue_item + * element. In the latter case this element would hold a pointer to the meta queue + * structure, which must be used to actually queue the route nodes to process. So + * create the MQ holder, if necessary, then push the work into it in any case. + * This semantics was introduced after 0.99.9 release. + */ + + /* Should I invent work_queue_empty() and use it, or it's Ok to do as follows? */ + if (!zebra->ribq->items->count) + work_queue_add (zebra->ribq, zebra->mq); + + rib_meta_queue_add (zebra->mq, rn); if (IS_ZEBRA_DEBUG_RIB_Q) zlog_debug ("%s: %s/%d: rn %p queued", __func__, buf, rn->p.prefixlen, rn); @@ -1339,6 +1420,27 @@ rib_queue_add (struct zebra_t *zebra, struct route_node *rn) return; } +/* Create new meta queue. + A destructor function doesn't seem to be necessary here. + */ +static struct meta_queue * +meta_queue_new (void) +{ + struct meta_queue *new; + unsigned i; + + new = XCALLOC (MTYPE_WORK_QUEUE, sizeof (struct meta_queue)); + assert(new); + + for (i = 0; i < MQ_SIZE; i++) + { + new->subq[i] = list_new (); + assert(new->subq[i]); + } + + return new; +} + /* initialise zebra rib work queue */ static void rib_queue_init (struct zebra_t *zebra) @@ -1353,12 +1455,17 @@ rib_queue_init (struct zebra_t *zebra) } /* fill in the work queue spec */ - zebra->ribq->spec.workfunc = &rib_process; + zebra->ribq->spec.workfunc = &meta_queue_process; zebra->ribq->spec.errorfunc = NULL; /* XXX: TODO: These should be runtime configurable via vty */ zebra->ribq->spec.max_retries = 3; zebra->ribq->spec.hold = rib_process_hold_time; + if (!(zebra->mq = meta_queue_new ())) + { + zlog_err ("%s: could not initialise meta queue!", __func__); + return; + } return; } @@ -1516,7 +1623,7 @@ int rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, struct in_addr *gate, struct in_addr *src, unsigned int ifindex, u_int32_t vrf_id, - u_int32_t metric, u_char distance) + u_int32_t metric, u_int8_t distance, u_int8_t scope) { struct rib *rib; struct rib *same = NULL; @@ -1524,6 +1631,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, struct route_node *rn; struct nexthop *nexthop; + /* Lookup table. */ table = vrf_table (AFI_IP, SAFI_UNICAST, 0); if (! table) @@ -1579,6 +1687,7 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, rib->table = vrf_id; rib->nexthop_num = 0; rib->uptime = time (NULL); + rib->scope = scope; /* Nexthop settings. */ if (gate) @@ -1589,12 +1698,18 @@ rib_add_ipv4 (int type, int flags, struct prefix_ipv4 *p, nexthop_ipv4_add (rib, gate, src); } else - nexthop_ifindex_add (rib, ifindex); + nexthop_ifindex_add (rib, ifindex, src); /* If this route is kernel route, set FIB flag to the route. */ - if (type == ZEBRA_ROUTE_KERNEL || type == ZEBRA_ROUTE_CONNECT) - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) - SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + if (RIB_SYSTEM_ROUTE (rib)) + { + /* Mark system routes with the don't touch me flag */ + if (! rib_system_routes) + SET_FLAG(rib->status, RIB_ENTRY_PRESERVE); + + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + } /* Link new rib to node.*/ if (IS_ZEBRA_DEBUG_RIB) @@ -1630,7 +1745,7 @@ void rib_dump (const char * func, const struct prefix_ipv4 * p, const struct rib "%s: refcnt == %lu, uptime == %lu, type == %u, table == %d", func, rib->refcnt, - rib->uptime, + (unsigned long) rib->uptime, rib->type, rib->table ); @@ -1752,8 +1867,7 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p) */ for (rib = rn->info; rib; rib = rib->next) { - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) && - ! RIB_SYSTEM_ROUTE (rib)) + if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) && RIB_SHOULD_UPDATE (rib)) { changed = 1; if (IS_ZEBRA_DEBUG_RIB) @@ -1767,11 +1881,7 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p) } } if (changed) - { - work_queue_aim_head (zebrad.ribq, 1); rib_queue_add (&zebrad, rn); - work_queue_aim_head (zebrad.ribq, 0); - } } int @@ -2175,8 +2285,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, static_delete_ipv4 (p, gate, ifname, update->distance, vrf_id); /* Make new static route structure. */ - si = XMALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4)); - memset (si, 0, sizeof (struct static_ipv4)); + si = XCALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4)); si->type = type; si->distance = distance; @@ -2307,7 +2416,7 @@ rib_bogus_ipv6 (int type, struct prefix_ipv6 *p, if (type == ZEBRA_ROUTE_KERNEL && IN6_IS_ADDR_UNSPECIFIED (&p->prefix) && p->prefixlen == 96 && gate && IN6_IS_ADDR_UNSPECIFIED (gate)) { - kernel_delete_ipv6_old (p, gate, ifindex, 0, table); + kernel_delete_ipv6_old (p, gate, ifindex, table); return 1; } return 0; @@ -2389,12 +2498,18 @@ rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p, nexthop_ipv6_add (rib, gate); } else - nexthop_ifindex_add (rib, ifindex); + nexthop_ifindex_add (rib, ifindex, NULL); /* If this route is kernel route, set FIB flag to the route. */ if (type == ZEBRA_ROUTE_KERNEL || type == ZEBRA_ROUTE_CONNECT) - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) - SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + { + /* Mark system routes with the don't touch me flag */ + if (! rib_system_routes) + SET_FLAG(rib->status, RIB_ENTRY_PRESERVE); + + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); + } /* Link new rib to node.*/ rib_addnode (rn, rib); @@ -2725,8 +2840,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, } /* Make new static route structure. */ - si = XMALLOC (MTYPE_STATIC_IPV6, sizeof (struct static_ipv6)); - memset (si, 0, sizeof (struct static_ipv6)); + si = XCALLOC (MTYPE_STATIC_IPV6, sizeof (struct static_ipv6)); si->type = type; si->distance = distance; @@ -2943,7 +3057,7 @@ rib_close_table (struct route_table *table) for (rn = route_top (table); rn; rn = route_next (rn)) for (rib = rn->info; rib; rib = rib->next) { - if (! RIB_SYSTEM_ROUTE (rib) + if (RIB_SHOULD_UPDATE (rib) && CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) rib_uninstall_kernel (rn, rib); } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 0c313921..f50ab05e 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2030,10 +2030,10 @@ static int config_write_protocol(struct vty *vty) } /* table node for protocol filtering */ -struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; +static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; /* IP node for static routes. */ -struct cmd_node ip_node = { IP_NODE, "", 1 }; +static struct cmd_node ip_node = { IP_NODE, "", 1 }; /* Route VTY. */ void diff --git a/zebra/zserv.c b/zebra/zserv.c index ef79eaad..76e74088 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -773,7 +773,7 @@ zread_ipv4_add (struct zserv *client, u_short length) { case ZEBRA_NEXTHOP_IFINDEX: ifindex = stream_getl (s); - nexthop_ifindex_add (rib, ifindex); + nexthop_ifindex_add (rib, ifindex, NULL); break; case ZEBRA_NEXTHOP_IFNAME: ifname_len = stream_getc (s); @@ -1569,7 +1569,7 @@ config_write_table (struct vty *vty) } /* table node for routing tables. */ -struct cmd_node table_node = +static struct cmd_node table_node = { TABLE_NODE, "", /* This node has no interface. */ @@ -1689,7 +1689,7 @@ config_write_forwarding (struct vty *vty) } /* table node for routing tables. */ -struct cmd_node forwarding_node = +static struct cmd_node forwarding_node = { FORWARDING_NODE, "", /* This node has no interface. */ diff --git a/zebra/zserv.h b/zebra/zserv.h index 5e223776..87a33a45 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -80,6 +80,7 @@ struct zebra_t /* rib work queue */ struct work_queue *ribq; + struct meta_queue *mq; }; /* Count prefix size from mask length */ |