summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
Diffstat (limited to 'zebra')
-rw-r--r--zebra/.cvsignore1
-rw-r--r--zebra/Makefile.am7
-rw-r--r--zebra/Makefile.in423
-rw-r--r--zebra/if_ioctl.c35
-rw-r--r--zebra/interface.c152
-rw-r--r--zebra/ioctl.c17
-rw-r--r--zebra/ipforward_proc.c32
-rw-r--r--zebra/ipforward_solaris.c58
-rw-r--r--zebra/ipforward_sysctl.c43
-rw-r--r--zebra/kernel_socket.c10
-rw-r--r--zebra/main.c35
-rw-r--r--zebra/rt_netlink.c41
-rw-r--r--zebra/rt_socket.c53
-rw-r--r--zebra/rtadv.c13
-rw-r--r--zebra/zebra_snmp.c3
-rw-r--r--zebra/zserv.c9
16 files changed, 165 insertions, 767 deletions
diff --git a/zebra/.cvsignore b/zebra/.cvsignore
index 95401bfa..f5169639 100644
--- a/zebra/.cvsignore
+++ b/zebra/.cvsignore
@@ -1,4 +1,5 @@
Makefile
+Makefile.in
*.o
zebra
zebra.conf
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
index ce564672..6214767d 100644
--- a/zebra/Makefile.am
+++ b/zebra/Makefile.am
@@ -13,10 +13,9 @@ rt_method = @RT_METHOD@
rtread_method = @RTREAD_METHOD@
kernel_method = @KERNEL_METHOD@
other_method = @OTHER_METHOD@
-libcap = @LIBCAP@
otherobj = $(ipforward) $(if_method) $(if_proc) $(rt_method) \
- $(rtread_method) $(kernel_method) $(other_method) $(libcap)
+ $(rtread_method) $(kernel_method) $(other_method)
sbin_PROGRAMS = zebra
@@ -26,7 +25,7 @@ zebra_SOURCES = \
noinst_HEADERS = \
connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
- interface.h ipforward.h
+ interface.h ipforward.h irdp.h
zebra_LDADD = ../lib/libzebra.a $(otherobj) $(LIB_IPV6)
@@ -39,7 +38,7 @@ EXTRA_DIST = $(sysconf_DATA) if_ioctl.c if_netlink.c if_proc.c if_sysctl.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 \
rtread_getmsg.c kernel_socket.c kernel_netlink.c mtu_kvm.c \
- GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB
+ GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB irdp.c
#client : client_main.o ../lib/libzebra.a
# $(CC) -g -o client client_main.o ../lib/libzebra.a $(LIBS) $(LIB_IPV6)
diff --git a/zebra/Makefile.in b/zebra/Makefile.in
deleted file mode 100644
index 5383bcb5..00000000
--- a/zebra/Makefile.in
+++ /dev/null
@@ -1,423 +0,0 @@
-# Makefile.in generated by automake 1.6.3 from Makefile.am.
-# @configure_input@
-
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
-# Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = @program_transform_name@
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-host_alias = @host_alias@
-host_triplet = @host@
-
-EXEEXT = @EXEEXT@
-OBJEXT = @OBJEXT@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-AMTAR = @AMTAR@
-AR = @AR@
-AWK = @AWK@
-BGPD = @BGPD@
-CC = @CC@
-CPP = @CPP@
-CURSES = @CURSES@
-DEPDIR = @DEPDIR@
-IF_METHOD = @IF_METHOD@
-IF_PROC = @IF_PROC@
-
-INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-IPFORWARD = @IPFORWARD@
-KERNEL_METHOD = @KERNEL_METHOD@
-LIBPAM = @LIBPAM@
-
-LIB_IPV6 = @LIB_IPV6@
-LIB_REGEX = @LIB_REGEX@
-MULTIPATH_NUM = @MULTIPATH_NUM@
-OSPF6D = @OSPF6D@
-OSPFD = @OSPFD@
-OTHER_METHOD = @OTHER_METHOD@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-RIPD = @RIPD@
-RIPNGD = @RIPNGD@
-RTREAD_METHOD = @RTREAD_METHOD@
-RT_METHOD = @RT_METHOD@
-STRIP = @STRIP@
-VERSION = @VERSION@
-VTYSH = @VTYSH@
-ZEBRA = @ZEBRA@
-am__include = @am__include@
-am__quote = @am__quote@
-install_sh = @install_sh@
-DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" -DMULTIPATH_NUM=@MULTIPATH_NUM@
-INSTALL_SDATA = @INSTALL@ -m 600
-
-ipforward = @IPFORWARD@
-if_method = @IF_METHOD@
-if_proc = @IF_PROC@
-rt_method = @RT_METHOD@
-rtread_method = @RTREAD_METHOD@
-kernel_method = @KERNEL_METHOD@
-other_method = @OTHER_METHOD@
-
-otherobj = $(ipforward) $(if_method) $(if_proc) $(rt_method) \
- $(rtread_method) $(kernel_method) $(other_method)
-
-
-sbin_PROGRAMS = zebra
-
-zebra_SOURCES = \
- zserv.c main.c interface.c connected.c ioctl.c zebra_rib.c \
- redistribute.c debug.c rtadv.c zebra_snmp.c zebra_vty.c
-
-
-noinst_HEADERS = \
- connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
- interface.h ipforward.h
-
-
-zebra_LDADD = ../lib/libzebra.a $(otherobj) $(LIB_IPV6)
-
-zebra_DEPENDENCIES = $(otherobj)
-
-sysconf_DATA = zebra.conf.sample
-
-EXTRA_DIST = $(sysconf_DATA) if_ioctl.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 \
- rtread_getmsg.c kernel_socket.c kernel_netlink.c mtu_kvm.c \
- GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB
-
-subdir = zebra
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-sbin_PROGRAMS = zebra$(EXEEXT)
-PROGRAMS = $(sbin_PROGRAMS)
-
-am_zebra_OBJECTS = zserv.$(OBJEXT) main.$(OBJEXT) interface.$(OBJEXT) \
- connected.$(OBJEXT) ioctl.$(OBJEXT) zebra_rib.$(OBJEXT) \
- redistribute.$(OBJEXT) debug.$(OBJEXT) rtadv.$(OBJEXT) \
- zebra_snmp.$(OBJEXT) zebra_vty.$(OBJEXT)
-zebra_OBJECTS = $(am_zebra_OBJECTS)
-zebra_LDFLAGS =
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/connected.Po ./$(DEPDIR)/debug.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/interface.Po ./$(DEPDIR)/ioctl.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/redistribute.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/rtadv.Po ./$(DEPDIR)/zebra_rib.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/zebra_snmp.Po ./$(DEPDIR)/zebra_vty.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/zserv.Po
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-CFLAGS = @CFLAGS@
-DIST_SOURCES = $(zebra_SOURCES)
-DATA = $(sysconf_DATA)
-
-HEADERS = $(noinst_HEADERS)
-
-DIST_COMMON = $(noinst_HEADERS) ChangeLog Makefile.am Makefile.in
-SOURCES = $(zebra_SOURCES)
-
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .o .obj
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
- cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign zebra/Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
-sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-install-sbinPROGRAMS: $(sbin_PROGRAMS)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(sbindir)
- @list='$(sbin_PROGRAMS)'; for p in $$list; do \
- p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- if test -f $$p \
- ; then \
- f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f"; \
- $(INSTALL_PROGRAM_ENV) $(sbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(sbindir)/$$f; \
- else :; fi; \
- done
-
-uninstall-sbinPROGRAMS:
- @$(NORMAL_UNINSTALL)
- @list='$(sbin_PROGRAMS)'; for p in $$list; do \
- f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " rm -f $(DESTDIR)$(sbindir)/$$f"; \
- rm -f $(DESTDIR)$(sbindir)/$$f; \
- done
-
-clean-sbinPROGRAMS:
- -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
-zebra$(EXEEXT): $(zebra_OBJECTS) $(zebra_DEPENDENCIES)
- @rm -f zebra$(EXEEXT)
- $(LINK) $(zebra_LDFLAGS) $(zebra_OBJECTS) $(zebra_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT) core *.core
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connected.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/redistribute.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtadv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zebra_rib.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zebra_snmp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zebra_vty.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zserv.Po@am__quote@
-
-distclean-depend:
- -rm -rf ./$(DEPDIR)
-
-.c.o:
-@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
-
-.c.obj:
-@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- $(COMPILE) -c `cygpath -w $<`
-CCDEPMODE = @CCDEPMODE@
-uninstall-info-am:
-sysconfDATA_INSTALL = $(INSTALL_DATA)
-
-uninstall-sysconfDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(sysconf_DATA)'; for p in $$list; do \
- f="`echo $$p | sed -e 's|^.*/||'`"; \
- echo " rm -f $(DESTDIR)$(sysconfdir)/$$f"; \
- rm -f $(DESTDIR)$(sysconfdir)/$$f; \
- done
-
-ETAGS = etags
-ETAGSFLAGS =
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- mkid -fID $$unique
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(ETAGS_ARGS)$$tags$$unique" \
- || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-
-top_distdir = ..
-distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
-
-distdir: $(DISTFILES)
- @list='$(DISTFILES)'; for file in $$list; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test "$$dir" != "$$file" && test "$$dir" != "."; then \
- dir="/$$dir"; \
- $(mkinstalldirs) "$(distdir)$$dir"; \
- else \
- dir=''; \
- fi; \
- if test -d $$d/$$file; then \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
- fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
- else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(PROGRAMS) $(DATA) $(HEADERS)
-
-installdirs:
- $(mkinstalldirs) $(DESTDIR)$(sbindir) $(DESTDIR)$(sysconfdir)
-
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am
-
-distclean: distclean-am
-
-distclean-am: clean-am distclean-compile distclean-depend \
- distclean-generic distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-exec-am: install-sbinPROGRAMS install-sysconfDATA
-
-install-info: install-info-am
-
-install-man:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
-
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic
-
-uninstall-am: uninstall-info-am uninstall-sbinPROGRAMS \
- uninstall-sysconfDATA
-
-.PHONY: GTAGS all all-am check check-am clean clean-generic \
- clean-sbinPROGRAMS distclean distclean-compile distclean-depend \
- distclean-generic distclean-tags distdir dvi dvi-am info \
- info-am install install-am install-data install-data-am \
- install-exec install-exec-am install-info install-info-am \
- install-man install-sbinPROGRAMS install-strip \
- install-sysconfDATA installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic tags uninstall \
- uninstall-am uninstall-info-am uninstall-sbinPROGRAMS \
- uninstall-sysconfDATA
-
-
-#client : client_main.o ../lib/libzebra.a
-# $(CC) -g -o client client_main.o ../lib/libzebra.a $(LIBS) $(LIB_IPV6)
-
-install-sysconfDATA: $(sysconf_DATA)
- @$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
- @list='$(sysconf_DATA)'; for p in $$list; do \
- if test -f $(srcdir)/$$p; then \
- echo " $(INSTALL_SDATA) $(srcdir)/$$p $(DESTDIR)$(sysconfdir)/$$p"; \
- $(INSTALL_SDATA) $(srcdir)/$$p $(DESTDIR)$(sysconfdir)/$$p; \
- else if test -f $$p; then \
- echo " $(INSTALL_SDATA) $$p $(DESTDIR)$(sysconfdir)/$$p"; \
- $(INSTALL_SDATA) $$p $(DESTDIR)$(sysconfdir)/$$p; \
- fi; fi; \
- done
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 46f53011..c9797996 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -130,14 +130,11 @@ interface_list_ioctl ()
int
if_get_index (struct interface *ifp)
{
- static int if_fake_index = 1;
-
-#ifdef HAVE_BROKEN_ALIASES
- /* Linux 2.2.X does not provide individual interface index for aliases. */
- ifp->ifindex = if_fake_index++;
- return ifp->ifindex;
-#else
-#ifdef SIOCGIFINDEX
+#if defined(HAVE_IF_NAMETOINDEX)
+ /* Modern systems should have if_nametoindex(3). */
+ ifp->ifindex = if_nametoindex(ifp->name);
+#elif defined(SIOCGIFINDEX) && !defined(HAVE_BROKEN_ALIASES)
+ /* Fall-back for older linuxes. */
int ret;
struct ifreq ifreq;
@@ -157,13 +154,20 @@ if_get_index (struct interface *ifp)
#else
ifp->ifindex = ifreq.ifr_index;
#endif
- return ifp->ifindex;
#else
+/* Linux 2.2.X does not provide individual interface index
+ for aliases and we know it. For others issue a warning. */
+#if !defined(HAVE_BROKEN_ALIASES)
+#warning "Using if_fake_index. You may want to add appropriate"
+#warning "mapping from ifname to ifindex for your system..."
+#endif
+ /* This branch probably won't provide usable results, but anyway... */
+ static int if_fake_index = 1;
ifp->ifindex = if_fake_index++;
+#endif
+
return ifp->ifindex;
-#endif /* SIOCGIFINDEX */
-#endif /* HAVE_BROKEN_ALIASES */
}
#ifdef SIOCGIFHWADDR
@@ -287,6 +291,15 @@ if_getaddrs ()
}
}
+#if defined(KAME)
+ if (IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr))
+ {
+ addr->sin6_scope_id =
+ ntohs(*(u_int16_t *)&addr->sin6_addr.s6_addr[2]);
+ addr->sin6_addr.s6_addr[2] = addr->sin6_addr.s6_addr[3] = 0;
+ }
+#endif
+
connected_add_ipv6 (ifp, &addr->sin6_addr, prefixlen, dest_pnt);
}
#endif /* HAVE_IPV6 */
diff --git a/zebra/interface.c b/zebra/interface.c
index 5629ebb3..f2374316 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -147,7 +147,7 @@ if_addr_wakeup (struct interface *ifp)
zebra_interface_address_add_update (ifp, ifc);
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv4 (ifp, ifc);
}
#ifdef HAVE_IPV6
@@ -170,7 +170,7 @@ if_addr_wakeup (struct interface *ifp)
zebra_interface_address_add_update (ifp, ifc);
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv6 (ifp, ifc);
}
#endif /* HAVE_IPV6 */
@@ -182,6 +182,14 @@ if_addr_wakeup (struct interface *ifp)
void
if_add_update (struct interface *ifp)
{
+ struct zebra_if *if_data;
+
+ if_data = ifp->info;
+ if (if_data->multicast == IF_ZEBRA_MULTICAST_ON)
+ if_set_flags (ifp, IFF_MULTICAST);
+ else if (if_data->multicast == IF_ZEBRA_MULTICAST_OFF)
+ if_unset_flags (ifp, IFF_MULTICAST);
+
zebra_interface_add_update (ifp);
if (! CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
@@ -326,16 +334,16 @@ if_down (struct interface *ifp)
void
if_refresh (struct interface *ifp)
{
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
{
if_get_flags (ifp);
- if (! if_is_up (ifp))
+ if (! if_is_operative (ifp))
if_down (ifp);
}
else
{
if_get_flags (ifp);
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
if_up (ifp);
}
}
@@ -471,8 +479,22 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
struct connected *connected;
listnode node;
- vty_out (vty, "Interface %s%s", ifp->name,
- VTY_NEWLINE);
+ vty_out (vty, "Interface %s is ", ifp->name);
+ if (if_is_up(ifp)) {
+ vty_out (vty, "up, line protocol ");
+
+ if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) {
+ if (if_is_running(ifp))
+ vty_out (vty, "is up%s", VTY_NEWLINE);
+ else
+ vty_out (vty, "is down%s", VTY_NEWLINE);
+ } else {
+ vty_out (vty, "detection is disabled%s", VTY_NEWLINE);
+ }
+ } else {
+ vty_out (vty, "down%s", VTY_NEWLINE);
+ }
+
if (ifp->desc)
vty_out (vty, " Description: %s%s", ifp->desc,
VTY_NEWLINE);
@@ -652,36 +674,6 @@ DEFUN_NOSH (zebra_interface,
return ret;
}
-DEFUN (no_zebra_interface,
- no_zebra_interface_cmd,
- "no interface IFNAME",
- "Delete a pseudo interface's configuration\n"
- "Interface's name\n")
-{
- struct interface *ifp;
-
- ifp = if_lookup_by_name(argv[0]);
-
- if (ifp == NULL)
- {
- vty_out (vty, "Inteface %s does not exist%s",
- argv[0],
- VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
- {
- vty_out(vty, "Only inactive interfaces can be deleted%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- /* Delete interface */
- if_delete(ifp);
-
- return CMD_SUCCESS;
-}
-
struct cmd_node interface_node =
{
INTERFACE_NODE,
@@ -739,16 +731,19 @@ DEFUN (multicast,
struct zebra_if *if_data;
ifp = (struct interface *) vty->index;
- ret = if_set_flags (ifp, IFF_MULTICAST);
- if (ret < 0)
+ if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
- vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE);
- return CMD_WARNING;
+ ret = if_set_flags (ifp, IFF_MULTICAST);
+ if (ret < 0)
+ {
+ vty_out (vty, "Can't set multicast flag%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if_refresh (ifp);
}
- if_refresh (ifp);
if_data = ifp->info;
if_data->multicast = IF_ZEBRA_MULTICAST_ON;
-
+
return CMD_SUCCESS;
}
@@ -763,19 +758,65 @@ DEFUN (no_multicast,
struct zebra_if *if_data;
ifp = (struct interface *) vty->index;
- ret = if_unset_flags (ifp, IFF_MULTICAST);
- if (ret < 0)
+ if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
{
- vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE);
- return CMD_WARNING;
+ ret = if_unset_flags (ifp, IFF_MULTICAST);
+ if (ret < 0)
+ {
+ vty_out (vty, "Can't unset multicast flag%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if_refresh (ifp);
}
- if_refresh (ifp);
if_data = ifp->info;
if_data->multicast = IF_ZEBRA_MULTICAST_OFF;
return CMD_SUCCESS;
}
+DEFUN (linkdetect,
+ linkdetect_cmd,
+ "link-detect",
+ "Enable link detection on interface\n")
+{
+ struct interface *ifp;
+ int if_was_operative;
+
+ ifp = (struct interface *) vty->index;
+ if_was_operative = if_is_operative(ifp);
+ SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
+
+ /* When linkdetection is enabled, if might come down */
+ if (!if_is_operative(ifp) && if_was_operative) if_down(ifp);
+
+ /* FIXME: Will defer status change forwarding if interface
+ does not come down! */
+
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_linkdetect,
+ no_linkdetect_cmd,
+ "no link-detect",
+ NO_STR
+ "Disable link detection on interface\n")
+{
+ struct interface *ifp;
+ int if_was_operative;
+
+ ifp = (struct interface *) vty->index;
+ if_was_operative = if_is_operative(ifp);
+ UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION);
+
+ /* Interface may come up after disabling link detection */
+ if (if_is_operative(ifp) && !if_was_operative) if_up(ifp);
+
+ /* FIXME: see linkdetect_cmd */
+
+ return CMD_SUCCESS;
+}
+
DEFUN (shutdown_if,
shutdown_if_cmd,
"shutdown",
@@ -845,7 +886,7 @@ DEFUN (bandwidth_if,
ifp->bandwidth = bandwidth;
/* force protocols to recalculate routes due to cost change */
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
zebra_interface_up_update (ifp);
return CMD_SUCCESS;
@@ -864,7 +905,7 @@ DEFUN (no_bandwidth_if,
ifp->bandwidth = 0;
/* force protocols to recalculate routes due to cost change */
- if (if_is_up (ifp))
+ if (if_is_operative (ifp))
zebra_interface_up_update (ifp);
return CMD_SUCCESS;
@@ -957,7 +998,7 @@ ip_address_install (struct vty *vty, struct interface *ifp, char *addr_str,
zebra_interface_address_add_update (ifp, ifc);
/* If interface is up register connected route. */
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv4 (ifp, ifc);
}
@@ -1165,7 +1206,7 @@ ipv6_address_install (struct vty *vty, struct interface *ifp, char *addr_str,
zebra_interface_address_add_update (ifp, ifc);
/* If interface is up register connected route. */
- if (if_is_up(ifp))
+ if (if_is_operative(ifp))
connected_up_ipv6 (ifp, ifc);
}
@@ -1301,6 +1342,9 @@ if_config_write (struct vty *vty)
if (ifp->bandwidth != 0)
vty_out(vty, " bandwidth %u%s", ifp->bandwidth, VTY_NEWLINE);
+ if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))
+ vty_out(vty, " link-detect%s", VTY_NEWLINE);
+
for (addrnode = listhead (ifp->connected); addrnode; nextnode (addrnode))
{
ifc = getdata (addrnode);
@@ -1357,12 +1401,14 @@ zebra_if_init ()
install_element (VIEW_NODE, &show_interface_cmd);
install_element (ENABLE_NODE, &show_interface_cmd);
install_element (CONFIG_NODE, &zebra_interface_cmd);
- install_element (CONFIG_NODE, &no_zebra_interface_cmd);
+ install_element (CONFIG_NODE, &no_interface_cmd);
install_default (INTERFACE_NODE);
install_element (INTERFACE_NODE, &interface_desc_cmd);
install_element (INTERFACE_NODE, &no_interface_desc_cmd);
install_element (INTERFACE_NODE, &multicast_cmd);
install_element (INTERFACE_NODE, &no_multicast_cmd);
+ install_element (INTERFACE_NODE, &linkdetect_cmd);
+ install_element (INTERFACE_NODE, &no_linkdetect_cmd);
install_element (INTERFACE_NODE, &shutdown_if_cmd);
install_element (INTERFACE_NODE, &no_shutdown_if_cmd);
install_element (INTERFACE_NODE, &bandwidth_if_cmd);
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index f8e7f22b..3e5d1d2f 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -27,13 +27,10 @@
#include "prefix.h"
#include "ioctl.h"
#include "log.h"
-#include "privs.h"
#include "zebra/rib.h"
#include "zebra/rt.h"
-extern struct zebra_privs_t zserv_privs;
-
/* clear and set interface name string */
void
ifreq_set_name (struct ifreq *ifreq, struct interface *ifp)
@@ -49,19 +46,14 @@ if_ioctl (u_long request, caddr_t buffer)
int ret = 0;
int err = 0;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
sock = socket (AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
perror ("socket");
exit (1);
}
+
ret = ioctl (sock, request, buffer);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
if (ret < 0)
{
err = errno;
@@ -84,21 +76,14 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer)
int ret = 0;
int err = 0;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
sock = socket (AF_INET6, SOCK_DGRAM, 0);
if (sock < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
perror ("socket");
exit (1);
}
ret = ioctl (sock, request, buffer);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
if (ret < 0)
{
err = errno;
diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c
index a31ec84b..eb8cef01 100644
--- a/zebra/ipforward_proc.c
+++ b/zebra/ipforward_proc.c
@@ -22,11 +22,6 @@
#include <zebra.h>
-#include "log.h"
-#include "privs.h"
-
-extern struct zebra_privs_t zserv_privs;
-
char proc_net_snmp[] = "/proc/net/snmp";
static void
@@ -73,15 +68,9 @@ int
ipforward_on ()
{
FILE *fp;
-
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno) );
fp = fopen (proc_ipv4_forwarding, "w");
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
-
+
if (fp == NULL)
return -1;
@@ -97,14 +86,7 @@ ipforward_off ()
{
FILE *fp;
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno));
-
fp = fopen (proc_ipv4_forwarding, "w");
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
-
if (fp == NULL)
return -1;
@@ -142,13 +124,7 @@ ipforward_ipv6_on ()
{
FILE *fp;
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno));
-
fp = fopen (proc_ipv6_forwarding, "w");
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
if (fp == NULL)
return -1;
@@ -165,13 +141,7 @@ ipforward_ipv6_off ()
{
FILE *fp;
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno));
-
fp = fopen (proc_ipv6_forwarding, "w");
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
if (fp == NULL)
return -1;
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c
index 27a3afde..63d1110c 100644
--- a/zebra/ipforward_solaris.c
+++ b/zebra/ipforward_solaris.c
@@ -22,7 +22,6 @@
#include <zebra.h>
#include "log.h"
-#include "prefix.h"
/*
** Solaris should define IP_DEV_NAME in <inet/ip.h>, but we'll save
@@ -34,9 +33,6 @@
#define IP_DEV_NAME "/dev/ip"
#endif
/*
-
-extern struct zebra_privs_t zserv_privs;
-
** This is a limited ndd style function that operates one integer
** value only. Errors return -1. ND_SET commands return 0 on
** success. ND_GET commands return the value on success (which could
@@ -44,7 +40,6 @@ extern struct zebra_privs_t zserv_privs;
** name of the parameter being referenced.
*/
-
static int
solaris_nd(const int cmd, const char* parameter, const int value)
{
@@ -72,43 +67,26 @@ solaris_nd(const int cmd, const char* parameter, const int value)
strioctl.ic_timout = 0;
strioctl.ic_len = ND_BUFFER_SIZE;
strioctl.ic_dp = nd_buf;
-
- if ( zserv_privs.change (ZPRIVS_RAISE) )
- zlog_err ("solaris_nd: Can't raise privileges");
- if ((fd = open (device, O_RDWR)) < 0)
- {
- zlog_warn("failed to open device %s - %s", device, strerror(errno));
- if ( zserv_privs.change (ZPRIVS_LOWER) )
- zlog_err ("solaris_nd: Can't lower privileges");
- return -1;
- }
- if (ioctl (fd, I_STR, &strioctl) < 0)
- {
- if ( zserv_privs.change (ZPRIVS_LOWER) )
- zlog_err ("solaris_nd: Can't lower privileges");
- close (fd);
- zlog_warn("ioctl I_STR failed on device %s - %s", device,strerror(errno));
- return -1;
- }
+ if ((fd = open (device, O_RDWR)) < 0) {
+ zlog_warn("failed to open device %s - %s", device, strerror(errno));
+ return -1;
+ }
+ if (ioctl (fd, I_STR, &strioctl) < 0) {
+ close (fd);
+ zlog_warn("ioctl I_STR failed on device %s - %s", device,strerror(errno));
+ return -1;
+ }
close(fd);
- if ( zserv_privs.change (ZPRIVS_LOWER) )
- zlog_err ("solaris_nd: Can't lower privileges");
-
- if (cmd == ND_GET)
- {
- errno = 0;
- retval = atoi(nd_buf);
- if (errno)
- {
- zlog_warn("failed to convert returned value to integer - %s",
- strerror(errno));
- retval = -1;
- }
- }
- else
- {
- retval = 0;
+ if (cmd == ND_GET) {
+ errno = 0;
+ retval = atoi(nd_buf);
+ if (errno) {
+ zlog_warn("failed to convert returned value to integer - %s",strerror(errno));
+ retval = -1;
}
+ } else {
+ retval = 0;
+ }
return retval;
}
diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c
index 53b6c6f0..828eb865 100644
--- a/zebra/ipforward_sysctl.c
+++ b/zebra/ipforward_sysctl.c
@@ -20,7 +20,6 @@
*/
#include <zebra.h>
-#include "privs.h"
#ifdef NRL
#include <netinet6/in6.h>
@@ -30,8 +29,6 @@
#define MIB_SIZ 4
-extern struct zebra_privs_t zserv_privs;
-
/* IPv4 forwarding control MIB. */
int mib[MIB_SIZ] =
{
@@ -63,17 +60,11 @@ ipforward_on ()
int ipforwarding = 1;
len = sizeof ipforwarding;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- if (sysctl (mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0)
+ if (sysctl (mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
zlog_warn ("Can't set ipforwarding on");
return -1;
}
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
return ipforwarding;
}
@@ -84,17 +75,11 @@ ipforward_off ()
int ipforwarding = 0;
len = sizeof ipforwarding;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- if (sysctl (mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0)
+ if (sysctl (mib, MIB_SIZ, NULL, NULL, &ipforwarding, len) < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
zlog_warn ("Can't set ipforwarding on");
return -1;
}
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
return ipforwarding;
}
@@ -121,17 +106,11 @@ ipforward_ipv6 ()
int ip6forwarding = 0;
len = sizeof ip6forwarding;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- if (sysctl (mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0)
+ if (sysctl (mib_ipv6, MIB_SIZ, &ip6forwarding, &len, 0, 0) < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
zlog_warn ("can't get ip6forwarding value");
return -1;
}
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
return ip6forwarding;
}
@@ -142,17 +121,11 @@ ipforward_ipv6_on ()
int ip6forwarding = 1;
len = sizeof ip6forwarding;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- if (sysctl (mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len) < 0)
+ if (sysctl (mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len) < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
zlog_warn ("can't get ip6forwarding value");
return -1;
}
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
return ip6forwarding;
}
@@ -163,17 +136,11 @@ ipforward_ipv6_off ()
int ip6forwarding = 0;
len = sizeof ip6forwarding;
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- if (sysctl (mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len) < 0)
+ if (sysctl (mib_ipv6, MIB_SIZ, NULL, NULL, &ip6forwarding, len) < 0)
{
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
zlog_warn ("can't get ip6forwarding value");
return -1;
}
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
return ip6forwarding;
}
#endif /* HAVE_IPV6 */
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 30e0fb1d..17893a87 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -31,14 +31,11 @@
#include "str.h"
#include "table.h"
#include "rib.h"
-#include "privs.h"
#include "zebra/interface.h"
#include "zebra/zserv.h"
#include "zebra/debug.h"
-extern struct zebra_privs_t zserv_privs;
-
/* Socket length roundup function. */
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
@@ -801,23 +798,16 @@ kernel_read (struct thread *thread)
void
routing_socket ()
{
- if ( zserv_privs.change (ZPRIVS_RAISE) )
- zlog_err ("routing_socket: Can't raise privileges");
-
routing_sock = socket (AF_ROUTE, SOCK_RAW, 0);
if (routing_sock < 0)
{
- if ( zserv_privs.change (ZPRIVS_LOWER) )
- zlog_err ("routing_socket: Can't lower privileges");
zlog_warn ("Can't init kernel routing socket");
return;
}
if (fcntl (routing_sock, F_SETFL, O_NONBLOCK) < 0)
zlog_warn ("Can't set O_NONBLOCK to routing socket");
- if ( zserv_privs.change (ZPRIVS_LOWER) )
- zlog_err ("routing_socket: Can't lower privileges");
/* kernel_read needs rewrite. */
thread_add_read (master, kernel_read, NULL, routing_sock);
diff --git a/zebra/main.c b/zebra/main.c
index 72b1fc4e..66469a2f 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -1,4 +1,5 @@
-/* zebra daemon main routine.
+/*
+ * zebra daemon main routine.
* Copyright (C) 1997, 98 Kunihiro Ishiguro
*
* This file is part of GNU Zebra.
@@ -29,7 +30,6 @@
#include "memory.h"
#include "prefix.h"
#include "log.h"
-#include "privs.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
@@ -62,32 +62,10 @@ struct option longopts[] =
{ "vty_addr", required_argument, NULL, 'A'},
{ "vty_port", required_argument, NULL, 'P'},
{ "retain", no_argument, NULL, 'r'},
- { "user", required_argument, NULL, 'u'},
{ "version", no_argument, NULL, 'v'},
{ 0 }
};
-zebra_capabilities_t _caps_p [] =
-{
- ZCAP_ADMIN,
- ZCAP_SYS_ADMIN,
-};
-
-/* zebra privileges to run with */
-struct zebra_privs_t zserv_privs =
-{
-#if defined(ZEBRA_USER) && defined(ZEBRA_GROUP)
- .user = ZEBRA_USER,
- .group = ZEBRA_GROUP,
-#endif
-#ifdef VTY_GROUP
- .vty_group = VTY_GROUP,
-#endif
- .caps_p = _caps_p,
- .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]),
- .cap_num_i = 0
-};
-
/* Default configuration file path. */
char config_current[] = DEFAULT_CONFIG_FILE;
char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE;
@@ -115,7 +93,6 @@ redistribution between different routing protocols.\n\n\
-A, --vty_addr Set vty's bind address\n\
-P, --vty_port Set vty's port number\n\
-r, --retain When program terminates, retain added route by zebra.\n\
--u, --user User and group to run as\n\
-v, --version Print program version\n\
-h, --help Display this help and exit\n\
\n\
@@ -219,7 +196,7 @@ main (int argc, char **argv)
{
int opt;
- opt = getopt_long (argc, argv, "bdklf:hA:P:ru:v", longopts, 0);
+ opt = getopt_long (argc, argv, "bdklf:hA:P:rv", longopts, 0);
if (opt == EOF)
break;
@@ -262,9 +239,6 @@ main (int argc, char **argv)
case 'r':
retain_mode = 1;
break;
- case 'u':
- zserv_privs.user = zserv_privs.group = optarg;
- break;
case 'v':
print_version (progname);
exit (0);
@@ -281,9 +255,6 @@ main (int argc, char **argv)
/* Make master thread emulator. */
master = thread_master_create ();
- /* privs initialise */
- zprivs_init (&zserv_privs);
-
/* Vty related initialize. */
signal_init ();
cmd_init (1);
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index e1514623..87062dc5 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -34,7 +34,6 @@
#include "table.h"
#include "rib.h"
#include "thread.h"
-#include "privs.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
@@ -68,8 +67,6 @@ struct message nlmsg_str[] =
extern int rtm_table_default;
-extern struct zebra_privs_t zserv_privs;
-
/* Make socket for Linux netlink interface. */
static int
netlink_socket (struct nlsock *nl, unsigned long groups)
@@ -101,25 +98,14 @@ netlink_socket (struct nlsock *nl, unsigned long groups)
snl.nl_groups = groups;
/* Bind the socket to the netlink structure for anything. */
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- {
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- return -1;
- }
-
ret = bind (sock, (struct sockaddr *) &snl, sizeof snl);
if (ret < 0)
{
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog (NULL, LOG_ERR, "Can't lower privileges");
zlog (NULL, LOG_ERR, "Can't bind %s socket to group 0x%x: %s",
nl->name, snl.nl_groups, strerror (errno));
close (sock);
return -1;
}
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog (NULL, LOG_ERR, "Can't lower privileges");
/* multiple netlink sockets will have different nl_pid */
namelen = sizeof snl;
@@ -200,28 +186,14 @@ netlink_request (int family, int type, struct nlsock *nl)
req.nlh.nlmsg_pid = 0;
req.nlh.nlmsg_seq = ++nl->seq;
req.g.rtgen_family = family;
-
- /* linux appears to check capabilities on every message
- * have to raise caps for every message sent
- */
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- {
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- return -1;
- }
ret = sendto (nl->sock, (void*) &req, sizeof req, 0,
(struct sockaddr*) &snl, sizeof snl);
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
if (ret < 0)
- {
+ {
zlog (NULL, LOG_ERR, "%s sendto failed: %s", nl->name, strerror (errno));
return -1;
}
-
return 0;
}
@@ -243,13 +215,7 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *),
struct msghdr msg = { (void*)&snl, sizeof snl, &iov, 1, NULL, 0, 0};
struct nlmsghdr *h;
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog (NULL, LOG_ERR, "Can't raise privileges");
-
status = recvmsg (nl->sock, &msg, 0);
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog (NULL, LOG_ERR, "Can't lower privileges");
if (status < 0)
{
@@ -1138,12 +1104,7 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl)
n->nlmsg_seq);
/* Send message to netlink interface. */
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog (NULL, LOG_ERR, "Can't raise privileges");
status = sendmsg (nl->sock, &msg, 0);
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
if (status < 0)
{
zlog (NULL, LOG_ERR, "netlink_talk sendmsg() error: %s",
diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c
index d603c60d..19b2fc2f 100644
--- a/zebra/rt_socket.c
+++ b/zebra/rt_socket.c
@@ -27,13 +27,10 @@
#include "sockunion.h"
#include "log.h"
#include "str.h"
-#include "privs.h"
#include "zebra/debug.h"
#include "zebra/rib.h"
-extern struct zebra_privs_t zserv_privs;
-
int
rtm_write (int message,
union sockunion *dest,
@@ -190,29 +187,13 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib, int family)
int
kernel_add_ipv4 (struct prefix *p, struct rib *rib)
{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv4 (RTM_ADD, p, rib, AF_INET);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
+ return kernel_rtm_ipv4 (RTM_ADD, p, rib, AF_INET);
}
int
kernel_delete_ipv4 (struct prefix *p, struct rib *rib)
{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv4 (RTM_DELETE, p, rib, AF_INET);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
+ return kernel_rtm_ipv4 (RTM_DELETE, p, rib, AF_INET);
}
#ifdef HAVE_IPV6
@@ -440,29 +421,13 @@ kernel_rtm_ipv6_multipath (int cmd, struct prefix *p, struct rib *rib,
int
kernel_add_ipv6 (struct prefix *p, struct rib *rib)
{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv6_multipath (RTM_ADD, p, rib, AF_INET6);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
+ return kernel_rtm_ipv6_multipath (RTM_ADD, p, rib, AF_INET6);
}
int
kernel_delete_ipv6 (struct prefix *p, struct rib *rib)
{
- int route;
-
- if (zserv_privs.change(ZPRIVS_RAISE))
- zlog (NULL, LOG_ERR, "Can't raise privileges");
- route = kernel_rtm_ipv6_multipath (RTM_DELETE, p, rib, AF_INET6);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
+ return kernel_rtm_ipv6_multipath (RTM_DELETE, p, rib, AF_INET6);
}
/* Delete IPv6 route from the kernel. */
@@ -470,14 +435,6 @@ int
kernel_delete_ipv6_old (struct prefix_ipv6 *dest, struct in6_addr *gate,
int index, int flags, 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);
- if (zserv_privs.change(ZPRIVS_LOWER))
- zlog (NULL, LOG_ERR, "Can't lower privileges");
-
- return route;
+ return kernel_rtm_ipv6 (RTM_DELETE, dest, gate, index, flags);
}
#endif /* HAVE_IPV6 */
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 9dcee8ea..8f4b3778 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -29,14 +29,11 @@
#include "prefix.h"
#include "linklist.h"
#include "command.h"
-#include "privs.h"
#include "zebra/interface.h"
#include "zebra/rtadv.h"
#include "zebra/debug.h"
-extern struct zebra_privs_t zserv_privs;
-
#if defined (HAVE_IPV6) && defined (RTADV)
/* If RFC2133 definition is used. */
@@ -146,7 +143,7 @@ rtadv_send_packet (int sock, struct interface *ifp)
struct cmsghdr *cmsgptr;
struct in6_pktinfo *pkt;
struct sockaddr_in6 addr;
-#ifdef HAVE_SOCKADDR_DL
+#if HAVE_SOCKADDR_DL
struct sockaddr_dl *sdl;
#endif /* HAVE_SOCKADDR_DL */
char adata [sizeof (struct cmsghdr) + sizeof (struct in6_pktinfo)];
@@ -412,16 +409,8 @@ rtadv_make_socket (void)
int ret;
struct icmp6_filter filter;
- if ( zserv_privs.change (ZPRIVS_RAISE) )
- zlog_err ("rtadv_make_socket: could not raise privs, %s",
- strerror (errno) );
-
sock = socket (AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
- if ( zserv_privs.change (ZPRIVS_LOWER) )
- zlog_err ("rtadv_make_socket: could not lower privs, %s",
- strerror (errno) );
-
/* When we can't make ICMPV6 socket simply back. Router
advertisement feature will not be supported. */
if (sock < 0)
diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c
index b028c3ec..051aaaa7 100644
--- a/zebra/zebra_snmp.c
+++ b/zebra/zebra_snmp.c
@@ -22,6 +22,9 @@
#include <zebra.h>
#ifdef HAVE_SNMP
+#ifdef HAVE_NETSNMP
+#include <net-snmp/net-snmp-config.h>
+#endif
#include <asn1.h>
#include <snmp.h>
#include <snmp_impl.h>
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 975574af..70e7672d 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -33,7 +33,6 @@
#include "sockunion.h"
#include "log.h"
#include "zclient.h"
-#include "privs.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
@@ -51,8 +50,6 @@ int rtm_table_default = 0;
void zebra_event (enum event event, int sock, struct zserv *client);
-extern struct zebra_privs_t zserv_privs;
-
extern struct thread_master *master;
/* For logging of zebra meesages. */
@@ -1641,9 +1638,6 @@ zebra_serv ()
sockopt_reuseaddr (accept_sock);
sockopt_reuseport (accept_sock);
- if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog (NULL, LOG_ERR, "Can't raise privileges");
-
ret = bind (accept_sock, (struct sockaddr *)&addr,
sizeof (struct sockaddr_in));
if (ret < 0)
@@ -1653,9 +1647,6 @@ zebra_serv ()
close (accept_sock); /* Avoid sd leak. */
return;
}
-
- if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog (NULL, LOG_ERR, "Can't lower privileges");
ret = listen (accept_sock, 1);
if (ret < 0)