From 94c00335652ff7ec0f4110d51be6cdd78979997e Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 12 Apr 2017 18:54:40 -0700 Subject: [PATCH 01/96] redhat: Replace tab's with spaces in README Signed-off-by: Martin Winter --- redhat/README.rpm_build.md | 140 ++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 71 deletions(-) diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index 6bec5d65cd..d3fd271c62 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -4,71 +4,69 @@ Building your own FRRouting RPM 1. Install the following packages to build the RPMs: - yum install git autoconf automake libtool make gawk readline-devel \ - texinfo dejagnu net-snmp-devel groff rpm-build net-snmp-devel \ - libcap-devel texi2html + yum install git autoconf automake libtool make gawk readline-devel \ + texinfo dejagnu net-snmp-devel groff rpm-build net-snmp-devel \ + libcap-devel texi2html - (use `dnf install` on new Fedora instead of `yum install `) - + (use `dnf install` on new Fedora instead of `yum install`) + 2. Checkout FRR under a **unpriviledged** user account - git clone https://github.com/frrouting/frr.git frr + git clone https://github.com/frrouting/frr.git frr 3. Run Bootstrap and make distribution tar.gz - cd frr - ./bootstrap.sh - ./configure --with-pkg-extra-version=-MyRPMVersion - make dist - - Note: configure parameters are not important for the RPM building - except the - `with-pkg-extra-version` if you want to give the RPM a specific name to - mark your own unoffical build + cd frr + ./bootstrap.sh + ./configure --with-pkg-extra-version=-MyRPMVersion + make dist + + Note: configure parameters are not important for the RPM building - except the `with-pkg-extra-version` if you want to give the RPM a specific name to + mark your own unoffical build 4. Create RPM directory structure and populate with sources - mkdir rpmbuild - mkdir rpmbuild/SOURCES - mkdir rpmbuild/SPECS - cp redhat/*.spec rpmbuild/SPECS/ - cp frr*.tar.gz rpmbuild/SOURCES/ + mkdir rpmbuild + mkdir rpmbuild/SOURCES + mkdir rpmbuild/SPECS + cp redhat/*.spec rpmbuild/SPECS/ + cp frr*.tar.gz rpmbuild/SOURCES/ 5. Edit rpm/SPECS/frr.spec with configuration as needed - Look at the beginning of the file and adjust the following parameters to enable - or disable features as required: - - ################# frr configure options #################### - # with-feature options + Look at the beginning of the file and adjust the following parameters to enable or disable features as required: + + ################# frr configure options #################### + # with-feature options %{!?with_snmp: %global with_snmp 1 } %{!?with_vtysh: %global with_vtysh 1 } %{!?with_ospf_te: %global with_ospf_te 1 } - %{!?with_opaque_lsa: %global with_opaque_lsa 1 } - %{!?with_tcp_zebra: %global with_tcp_zebra 0 } - %{!?with_vtysh: %global with_vtysh 1 } - %{!?with_pam: %global with_pam 1 } + %{!?with_opaque_lsa: %global with_opaque_lsa 1 } + %{!?with_tcp_zebra: %global with_tcp_zebra 0 } + %{!?with_vtysh: %global with_vtysh 1 } + %{!?with_pam: %global with_pam 1 } %{!?with_ospfclient: %global with_ospfclient 1 } - %{!?with_ospfapi: %global with_ospfapi 1 } - %{!?with_irdp: %global with_irdp 1 } - %{!?with_rtadv: %global with_rtadv 1 } - %{!?with_isisd: %global with_isisd 1 } - %{!?with_pimd: %global with_pimd 1 } - %{!?with_mpls: %global with_mpls 0 } - %{!?with_ldpd: %global with_ldpd 0 } - %{!?with_shared: %global with_shared 1 } - %{!?with_multipath: %global with_multipath 64 } - %{!?frr_user: %global frr_user frr } - %{!?vty_group: %global vty_group frrvt } - %{!?with_fpm: %global with_fpm 0 } - %{!?with_watchfrr: %global with_watchfrr 1 } + %{!?with_ospfapi: %global with_ospfapi 1 } + %{!?with_irdp: %global with_irdp 1 } + %{!?with_rtadv: %global with_rtadv 1 } + %{!?with_isisd: %global with_isisd 1 } + %{!?with_pimd: %global with_pimd 1 } + %{!?with_mpls: %global with_mpls 0 } + %{!?with_ldpd: %global with_ldpd 0 } + %{!?with_shared: %global with_shared 1 } + %{!?with_multipath: %global with_multipath 64 } + %{!?frr_user: %global frr_user frr } + %{!?vty_group: %global vty_group frrvt } + %{!?with_fpm: %global with_fpm 0 } + %{!?with_watchfrr: %global with_watchfrr 1 } 6. Build the RPM - rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/frr.spec + rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/frr.spec DONE. -If all works correctly, then you should end up with the RPMs under `rpmbuild/RPMS` -and the Source RPM under `rpmbuild/SRPMS` +If all works correctly, then you should end up with the RPMs under +`rpmbuild/RPMS` and the Source RPM under `rpmbuild/SRPMS` Enabling daemons after installation of the package: @@ -77,54 +75,54 @@ Enabling daemons after installation of the package: ### init.d based systems (ie CentOS 6): 1. Enable the daemons as needed to run after boot (Zebra is mandatory) - - chkconfig zebra on - chkconfig ospfd on - chkconfig ospf6d on - chkconfig bgpd on - ... etc + + chkconfig zebra on + chkconfig ospfd on + chkconfig ospf6d on + chkconfig bgpd on + ... etc 2. If you want to run `watchfrr`, then configure `/etc/sysconfig/frr` and uncomment the line with the daemons for `watchfrr` to monitor, then enable watchfrr - chkconfig watchfrr on + chkconfig watchfrr on 3. Check your firewall / IPtables to make sure the routing protocols are allowed. - + 4. Start the daemons (or reboot) - service zebra start - service bgpd start - service ospfd start - ... etc - + service zebra start + service bgpd start + service ospfd start + ... etc + Configuration is stored in `/etc/frr/*.conf` files. ### systemd based systems (ie CentOS 7, Fedora 22) 1. Enable the daemons as needed to run after boot (Zebra is mandatory) - - systemctl enable zebra - systemctl enable ospfd - systemctl enable ospf6d - systemctl enable bgpd - ... etc + + systemctl enable zebra + systemctl enable ospfd + systemctl enable ospf6d + systemctl enable bgpd + ... etc - Note: There is no watchfrr on systemd based systems. Systemd contains - the functionality of monitoring and restarting daemons. + Note: There is no watchfrr on systemd based systems. Systemd contains + the functionality of monitoring and restarting daemons. 2. Check your firewall / IPtables to make sure the routing protocols are allowed. - + 3. Start the daemons (or reboot) - systemctl start zebra - systemctl start bgpd - systemctl start ospfd - ... etc - + systemctl start zebra + systemctl start bgpd + systemctl start ospfd + ... etc + Configuration is stored in `/etc/frr/*.conf` files. From 9a581ae412cb5f6b91220f9a765d2135d6650fb9 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 12 Apr 2017 19:10:35 -0700 Subject: [PATCH 02/96] redhat: Remove tab's with spaces in frr.spec.in to make it better readable Signed-off-by: Martin Winter --- redhat/frr.spec.in | 444 ++++++++++++++++++++++----------------------- 1 file changed, 222 insertions(+), 222 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 6d94b5a5cc..0d3bf6db20 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -10,33 +10,33 @@ ####################### FRRouting (FRR) configure options ######################### # with-feature options -%{!?with_tcp_zebra: %global with_tcp_zebra 0 } -%{!?with_pam: %global with_pam 0 } -%{!?with_ospfclient: %global with_ospfclient 1 } -%{!?with_ospfapi: %global with_ospfapi 1 } -%{!?with_irdp: %global with_irdp 1 } -%{!?with_rtadv: %global with_rtadv 1 } -%{!?with_mpls: %global with_mpls 0 } -%{!?with_ldpd: %global with_ldpd 0 } -%{!?with_shared: %global with_shared 1 } -%{!?with_multipath: %global with_multipath 256 } -%{!?frr_user: %global frr_user frr } -%{!?vty_group: %global vty_group frrvty } -%{!?with_fpm: %global with_fpm 0 } -%{!?with_watchfrr: %global with_watchfrr 1 } -%{!?with_bgp_vnc: %global with_bgp_vnc 0 } +%{!?with_tcp_zebra: %global with_tcp_zebra 0 } +%{!?with_pam: %global with_pam 0 } +%{!?with_ospfclient: %global with_ospfclient 1 } +%{!?with_ospfapi: %global with_ospfapi 1 } +%{!?with_irdp: %global with_irdp 1 } +%{!?with_rtadv: %global with_rtadv 1 } +%{!?with_mpls: %global with_mpls 0 } +%{!?with_ldpd: %global with_ldpd 0 } +%{!?with_shared: %global with_shared 1 } +%{!?with_multipath: %global with_multipath 256 } +%{!?frr_user: %global frr_user frr } +%{!?vty_group: %global vty_group frrvty } +%{!?with_fpm: %global with_fpm 0 } +%{!?with_watchfrr: %global with_watchfrr 1 } +%{!?with_bgp_vnc: %global with_bgp_vnc 0 } # path defines -%define _sysconfdir /etc/frr -%define _sbindir /usr/lib/frr -%define zeb_src %{_builddir}/%{name}-%{frrversion} -%define zeb_rh_src %{zeb_src}/redhat -%define zeb_docs %{zeb_src}/doc -%define frr_tools %{zeb_src}/tools -%define cumulus_dir %{zeb_src}/cumulus/etc +%define _sysconfdir /etc/frr +%define _sbindir /usr/lib/frr +%define zeb_src %{_builddir}/%{name}-%{frrversion} +%define zeb_rh_src %{zeb_src}/redhat +%define zeb_docs %{zeb_src}/doc +%define frr_tools %{zeb_src}/tools +%define cumulus_dir %{zeb_src}/cumulus/etc # defines for configure -%define _localstatedir /var/run/frr +%define _localstatedir /var/run/frr ############################################################################ #### Version String tweak @@ -55,77 +55,77 @@ # If init system is systemd, then always disable watchfrr # %if "%{initsystem}" == "systemd" - # Note: For systems with systemd, watchfrr will NOT be built. Systemd - # takes over the role of restarting crashed processes. Value will - # be overwritten with 0 below for systemd independent on the setting here - %global with_watchfrr 1 + # Note: For systems with systemd, watchfrr will NOT be built. Systemd + # takes over the role of restarting crashed processes. Value will + # be overwritten with 0 below for systemd independent on the setting here + %global with_watchfrr 1 %endif # if FPM is enabled, then enable tcp_zebra as well # %if %{with_fpm} - %global with_tcp_zebra 1 + %global with_tcp_zebra 1 %endif # misc internal defines -%{!?frr_uid: %global frr_uid 92 } -%{!?frr_gid: %global frr_gid 92 } -%{!?vty_gid: %global vty_gid 85 } +%{!?frr_uid: %global frr_uid 92 } +%{!?frr_gid: %global frr_gid 92 } +%{!?vty_gid: %global vty_gid 85 } -%define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospfd6d +%define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospfd6d %if %{with_ldpd} -%define daemon_ldpd ldpd +%define daemon_ldpd ldpd %else -%define daemon_ldpd "" +%define daemon_ldpd "" %endif %if %{with_watchfrr} -%define daemon_watchfrr watchfrr +%define daemon_watchfrr watchfrr %else -%define daemon_watchfrr "" +%define daemon_watchfrr "" %endif -%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_watchfrr} +%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_watchfrr} # allow build dir to be kept -%{!?keep_build: %global keep_build 0 } +%{!?keep_build: %global keep_build 0 } #release sub-revision (the two digits after the CONFDATE) -%{!?release_rev: %global release_rev 01 } +%{!?release_rev: %global release_rev 01 } Summary: Routing daemon -Name: frr -Version: %{rpmversion} -Release: @CONFDATE@%{release_rev}%{?dist} -License: GPLv2+ -Group: System Environment/Daemons -Source0: http://www.frrouting.org/releases/frr/%{name}-%{frrversion}.tar.gz -URL: http://www.frrouting.org -Requires: ncurses json-c -Requires(pre): /sbin/install-info +Name: frr +Version: %{rpmversion} +Release: @CONFDATE@%{release_rev}%{?dist} +License: GPLv2+ +Group: System Environment/Daemons +Source0: http://www.frrouting.org/releases/frr/%{name}-%{frrversion}.tar.gz +URL: http://www.frrouting.org +Requires: ncurses json-c +Requires(pre): /sbin/install-info Requires(preun): /sbin/install-info -Requires(post): /sbin/install-info -BuildRequires: texi2html texinfo autoconf patch libcap-devel groff -BuildRequires: readline readline-devel ncurses ncurses-devel -BuildRequires: json-c-devel bison flex -Requires: ncurses initscripts +Requires(post): /sbin/install-info +BuildRequires: texi2html texinfo autoconf patch libcap-devel groff +BuildRequires: readline readline-devel ncurses ncurses-devel +BuildRequires: json-c-devel bison flex +Requires: ncurses initscripts %if %{with_pam} -BuildRequires: pam-devel -Requires: pam +BuildRequires: pam-devel +Requires: pam %endif %if "%{initsystem}" == "systemd" -BuildRequires: systemd -Requires(post): systemd -Requires(preun): systemd -Requires(postun): systemd +BuildRequires: systemd +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd %else # Initscripts > 5.60 is required for IPv6 support -Requires(pre): initscripts >= 5.60 +Requires(pre): initscripts >= 5.60 %endif -Provides: routingdaemon = %{version}-%{release} -BuildRoot: %{_tmppath}/%{name}-%{version}-root -Obsoletes: bird gated mrt zebra frr-sysvinit +Provides: routingdaemon = %{version}-%{release} +BuildRoot: %{_tmppath}/%{name}-%{version}-root +Obsoletes: bird gated mrt zebra frr-sysvinit %description FRRouting is a free software that manages TCP/IP based routing @@ -174,76 +174,76 @@ developing OSPF-API and frr applications. --libdir=%{_libdir} \ --libexecdir=%{_libexecdir} \ --localstatedir=%{_localstatedir} \ - --disable-werror \ + --disable-werror \ %if !%{with_shared} - --disable-shared \ + --disable-shared \ %endif %if %{with_multipath} - --enable-multipath=%{with_multipath} \ + --enable-multipath=%{with_multipath} \ %endif %if %{with_tcp_zebra} - --enable-tcp-zebra \ + --enable-tcp-zebra \ %endif - --enable-vtysh \ + --enable-vtysh \ %if %{with_ospfclient} - --enable-ospfclient=yes \ + --enable-ospfclient=yes \ %else - --enable-ospfclient=no\ + --enable-ospfclient=no\ %endif %if %{with_ospfapi} - --enable-ospfapi=yes \ + --enable-ospfapi=yes \ %else - --enable-ospfapi=no \ + --enable-ospfapi=no \ %endif %if %{with_irdp} - --enable-irdp=yes \ + --enable-irdp=yes \ %else - --enable-irdp=no \ + --enable-irdp=no \ %endif %if %{with_rtadv} - --enable-rtadv=yes \ + --enable-rtadv=yes \ %else - --enable-rtadv=no \ + --enable-rtadv=no \ %endif %if %{with_mpls} - --enable-mpls=yes \ + --enable-mpls=yes \ %else - --disable-mpls \ + --disable-mpls \ %endif %if %{with_ldpd} - --enable-ldpd \ + --enable-ldpd \ %else - --disable-ldpd \ + --disable-ldpd \ %endif %if %{with_pam} - --with-libpam \ + --with-libpam \ %endif %if 0%{?frr_user:1} - --enable-user=%frr_user \ - --enable-group=%frr_user \ + --enable-user=%frr_user \ + --enable-group=%frr_user \ %endif %if 0%{?vty_group:1} - --enable-vty-group=%vty_group \ + --enable-vty-group=%vty_group \ %endif %if %{with_fpm} - --enable-fpm \ + --enable-fpm \ %else - --disable-fpm \ + --disable-fpm \ %endif %if %{with_watchfrr} - --enable-watchfrr \ + --enable-watchfrr \ %else - --disable-watchfrr \ + --disable-watchfrr \ %endif %if %{with_bgp_vnc} - --enable-bgp-vnc \ + --enable-bgp-vnc \ %else - --disable-bgp-vnc \ + --disable-bgp-vnc \ %endif - --enable-gcc-rdynamic \ - --enable-isisd=yes \ - --enable-systemd=yes \ - --enable-poll=yes + --enable-gcc-rdynamic \ + --enable-isisd=yes \ + --enable-systemd=yes \ + --enable-poll=yes make %{?_smp_mflags} MAKEINFO="makeinfo --no-split" @@ -268,14 +268,14 @@ rm -rf %{buildroot}/usr/share/info/dir %if "%{initsystem}" == "systemd" mkdir -p %{buildroot}%{_unitdir} install %{frr_tools}/frr.service \ - %{buildroot}%{_unitdir}/frr.service + %{buildroot}%{_unitdir}/frr.service %else mkdir -p %{buildroot}/etc/rc.d/init.d for daemon in %{all_daemons} ; do - if [ x"${daemon}" != x"" ] ; then - install %{zeb_rh_src}/${daemon}.init \ - %{buildroot}/etc/rc.d/init.d/${daemon} - fi + if [ x"${daemon}" != x"" ] ; then + install %{zeb_rh_src}/${daemon}.init \ + %{buildroot}/etc/rc.d/init.d/${daemon} + fi done %endif @@ -283,9 +283,9 @@ install %{cumulus_dir}/frr/debian.conf %{buildroot}/etc/frr install %{cumulus_dir}/frr/daemons %{buildroot}/etc/frr install -m644 %{cumulus_dir}/default/frr %{buildroot}/etc/default install -m644 %{zeb_rh_src}/frr.pam \ - %{buildroot}/etc/pam.d/frr + %{buildroot}/etc/pam.d/frr install -m644 %{zeb_rh_src}/frr.logrotate \ - %{buildroot}/etc/logrotate.d/frr + %{buildroot}/etc/logrotate.d/frr install -d -m750 %{buildroot}/var/run/frr %pre @@ -318,11 +318,11 @@ fi zebra_spec_add_service () { - # Add port /etc/services entry if it isn't already there - if [ -f /etc/services ] && \ - ! %__sed -e 's/#.*$//' /etc/services | %__grep -wq $1 ; then - echo "$1 $2 # $3" >> /etc/services - fi + # Add port /etc/services entry if it isn't already there + if [ -f /etc/services ] && \ + ! %__sed -e 's/#.*$//' /etc/services | %__grep -wq $1 ; then + echo "$1 $2 # $3" >> /etc/services + fi } zebra_spec_add_service zebrasrv 2600/tcp "zebra service" @@ -343,11 +343,11 @@ zebra_spec_add_service ldpd 2612/tcp "LDPd vty" %if "%{initsystem}" == "systemd" for daemon in %all_daemons ; do - %systemd_post frr.service + %systemd_post frr.service done %else for daemon in %all_daemons ; do - /sbin/chkconfig --add ${daemon} + /sbin/chkconfig --add ${daemon} done %endif @@ -355,28 +355,28 @@ done # Create dummy files if they don't exist so basic functions can be used. if [ ! -e %{_sysconfdir}/zebra.conf ]; then - echo "hostname `hostname`" > %{_sysconfdir}/zebra.conf + echo "hostname `hostname`" > %{_sysconfdir}/zebra.conf %if 0%{?frr_user:1} - chown %frr_user:%frr_user %{_sysconfdir}/zebra.conf* + chown %frr_user:%frr_user %{_sysconfdir}/zebra.conf* %endif - chmod 640 %{_sysconfdir}/zebra.conf + chmod 640 %{_sysconfdir}/zebra.conf fi for daemon in %{all_daemons} ; do - if [ ! -e %{_sysconfdir}/${daemon}.conf ]; then - touch %{_sysconfdir}/${daemon}.conf - %if 0%{?frr_user:1} - chown %frr_user:%frr_user %{_sysconfdir}/${daemon}.conf* - %endif - fi + if [ ! -e %{_sysconfdir}/${daemon}.conf ]; then + touch %{_sysconfdir}/${daemon}.conf + %if 0%{?frr_user:1} + chown %frr_user:%frr_user %{_sysconfdir}/${daemon}.conf* + %endif + fi done %if %{with_watchfrr} - # No config for watchfrr - this is part of /etc/sysconfig/frr - rm -f %{_sysconfdir}/watchfrr.* + # No config for watchfrr - this is part of /etc/sysconfig/frr + rm -f %{_sysconfdir}/watchfrr.* %endif if [ ! -e %{_sysconfdir}/vtysh.conf ]; then - touch %{_sysconfdir}/vtysh.conf - chmod 640 %{_sysconfdir}/vtysh.conf + touch %{_sysconfdir}/vtysh.conf + chmod 640 %{_sysconfdir}/vtysh.conf %if 0%{?vty_group:1} chown frr:%{vty_group} %{_sysconfdir}/vtysh.conf* %endif @@ -384,96 +384,96 @@ fi %postun if [ "$1" -ge 1 ]; then - # Find out which daemons need to be restarted. - for daemon in %all_daemons ; do - if [ -f /var/lock/subsys/${daemon} ]; then - eval restart_${daemon}=yes - else - eval restart_${daemon}=no - fi - done - # Rename restart flags for daemons handled specially. - running_zebra="$restart_zebra" - restart_zebra=no - %if %{with_watchfrr} - running_watchfrr="$restart_watchfrr" - restart_watchfrr=no - %endif - - %if "%{initsystem}" == "systemd" - ## - ## Systemd Version - ## - # No watchfrr for systemd version - # - # Stop all daemons other than zebra. - for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - %systemd_postun ${daemon}.service - done - # Restart zebra. - [ "$running_zebra" = yes ] && \ - %systemd_postun_with_restart $daemon.service - # Start all daemons other than zebra. - for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - %systemd_post ${daemon}.service - done - %else - ## - ## init.d Version - ## - %if %{with_watchfrr} - # Stop watchfrr first. - [ "$running_watchfrr" = yes ] && \ - /etc/rc.d/init.d/watchfrr stop >/dev/null 2>&1 - %endif - # Stop all daemons other than zebra and watchfrr. - for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - done - # Restart zebra. - [ "$running_zebra" = yes ] && \ - /etc/rc.d/init.d/zebra restart >/dev/null 2>&1 - # Start all daemons other than zebra and watchfrr. - for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/${daemon} start >/dev/null 2>&1 - done - %if %{with_watchfrr} - # Start watchfrr last. - # Avoid postun scriptlet error if watchfrr is not running. - [ "$running_watchfrr" = yes ] && \ - /etc/rc.d/init.d/watchfrr start >/dev/null 2>&1 || : - %endif - %endif + # Find out which daemons need to be restarted. + for daemon in %all_daemons ; do + if [ -f /var/lock/subsys/${daemon} ]; then + eval restart_${daemon}=yes + else + eval restart_${daemon}=no + fi + done + # Rename restart flags for daemons handled specially. + running_zebra="$restart_zebra" + restart_zebra=no + %if %{with_watchfrr} + running_watchfrr="$restart_watchfrr" + restart_watchfrr=no + %endif + + %if "%{initsystem}" == "systemd" + ## + ## Systemd Version + ## + # No watchfrr for systemd version + # + # Stop all daemons other than zebra. + for daemon in %all_daemons ; do + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + %systemd_postun ${daemon}.service + done + # Restart zebra. + [ "$running_zebra" = yes ] && \ + %systemd_postun_with_restart $daemon.service + # Start all daemons other than zebra. + for daemon in %all_daemons ; do + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + %systemd_post ${daemon}.service + done + %else + ## + ## init.d Version + ## + %if %{with_watchfrr} + # Stop watchfrr first. + [ "$running_watchfrr" = yes ] && \ + /etc/rc.d/init.d/watchfrr stop >/dev/null 2>&1 + %endif + # Stop all daemons other than zebra and watchfrr. + for daemon in %all_daemons ; do + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 + done + # Restart zebra. + [ "$running_zebra" = yes ] && \ + /etc/rc.d/init.d/zebra restart >/dev/null 2>&1 + # Start all daemons other than zebra and watchfrr. + for daemon in %all_daemons ; do + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + /etc/rc.d/init.d/${daemon} start >/dev/null 2>&1 + done + %if %{with_watchfrr} + # Start watchfrr last. + # Avoid postun scriptlet error if watchfrr is not running. + [ "$running_watchfrr" = yes ] && \ + /etc/rc.d/init.d/watchfrr start >/dev/null 2>&1 || : + %endif + %endif fi %preun %if "%{initsystem}" == "systemd" - ## - ## Systemd Version - ## - if [ "$1" = "0" ]; then - for daemon in %all_daemons ; do - %systemd_preun ${daemon}.service - done - fi + ## + ## Systemd Version + ## + if [ "$1" = "0" ]; then + for daemon in %all_daemons ; do + %systemd_preun ${daemon}.service + done + fi %else - ## - ## init.d Version - ## - if [ "$1" = "0" ]; then - for daemon in %all_daemons ; do - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - /sbin/chkconfig --del ${daemon} - done - fi + ## + ## init.d Version + ## + if [ "$1" = "0" ]; then + for daemon in %all_daemons ; do + /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 + /sbin/chkconfig --del ${daemon} + done + fi %endif /sbin/install-info --delete %{_infodir}/frr.info.gz %{_infodir}/dir @@ -512,7 +512,7 @@ rm -rf %{buildroot} %{_sbindir}/frr-reload.pyc %{_sbindir}/frr-reload.pyo %if %{with_watchfrr} - %{_sbindir}/watchfrr + %{_sbindir}/watchfrr %endif %{_sbindir}/ripngd %{_sbindir}/ospf6d @@ -528,22 +528,22 @@ rm -rf %{buildroot} %{_bindir}/* %config /etc/frr/[!v]* %if "%{initsystem}" == "systemd" - %config %{_unitdir}/frr.service + %config %{_unitdir}/frr.service %else - %config /etc/rc.d/init.d/zebra - %if %{with_watchfrr} - %config /etc/rc.d/init.d/watchfrr - %endif - %config /etc/rc.d/init.d/ripd - %config /etc/rc.d/init.d/ospfd - %config /etc/rc.d/init.d/bgpd - %config /etc/rc.d/init.d/ripngd - %config /etc/rc.d/init.d/ospf6d - %config /etc/rc.d/init.d/isisd - %config /etc/rc.d/init.d/pimd - %if %{with_ldpd} - %config /etc/rc.d/init.d/ldpd - %endif + %config /etc/rc.d/init.d/zebra + %if %{with_watchfrr} + %config /etc/rc.d/init.d/watchfrr + %endif + %config /etc/rc.d/init.d/ripd + %config /etc/rc.d/init.d/ospfd + %config /etc/rc.d/init.d/bgpd + %config /etc/rc.d/init.d/ripngd + %config /etc/rc.d/init.d/ospf6d + %config /etc/rc.d/init.d/isisd + %config /etc/rc.d/init.d/pimd + %if %{with_ldpd} + %config /etc/rc.d/init.d/ldpd + %endif %endif %config(noreplace) /etc/default/frr %config(noreplace) /etc/pam.d/frr From 58f20b90ee59c393706abaf022c809a03414b7a4 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 12 Apr 2017 20:23:18 -0700 Subject: [PATCH 03/96] redhat: Fix dependencies for rpm package - Add bison, flex & autoconf - Remove systemd for systems without it (i.e. CentOS 6) - Update doc to reflect dependencies Signed-off-by: Martin Winter --- redhat/README.rpm_build.md | 12 ++++++++++-- redhat/frr.spec.in | 8 +++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index d3fd271c62..fa1d56e0ef 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -6,10 +6,18 @@ Building your own FRRouting RPM yum install git autoconf automake libtool make gawk readline-devel \ texinfo dejagnu net-snmp-devel groff rpm-build net-snmp-devel \ - libcap-devel texi2html + libcap-devel texi2html bison flex + + Additionally, on systems with systemd (CentOS 7, Fedora) + + yum install systemd-devel (use `dnf install` on new Fedora instead of `yum install`) - + + **CentOS 6:** Please check doc/Building_FRR_on_CentOS6.md for details on + how to install required version of autoconf, automake and bison. The + versions in the common Repo are too old. + 2. Checkout FRR under a **unpriviledged** user account git clone https://github.com/frrouting/frr.git frr diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 0d3bf6db20..385d5f4202 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -106,16 +106,16 @@ Requires: ncurses json-c Requires(pre): /sbin/install-info Requires(preun): /sbin/install-info Requires(post): /sbin/install-info -BuildRequires: texi2html texinfo autoconf patch libcap-devel groff +BuildRequires: texi2html texinfo autoconf automake patch libcap-devel groff BuildRequires: readline readline-devel ncurses ncurses-devel -BuildRequires: json-c-devel bison flex +BuildRequires: json-c-devel bison >= 2.7 flex Requires: ncurses initscripts %if %{with_pam} BuildRequires: pam-devel Requires: pam %endif %if "%{initsystem}" == "systemd" -BuildRequires: systemd +BuildRequires: systemd systemd-devel Requires(post): systemd Requires(preun): systemd Requires(postun): systemd @@ -242,7 +242,9 @@ developing OSPF-API and frr applications. %endif --enable-gcc-rdynamic \ --enable-isisd=yes \ +%if "%{initsystem}" == "systemd" --enable-systemd=yes \ +%endif --enable-poll=yes make %{?_smp_mflags} MAKEINFO="makeinfo --no-split" From 1b2b1230428c8864d6dad5368cbbec56664b3bba Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Thu, 13 Apr 2017 15:00:16 -0700 Subject: [PATCH 04/96] redhat: Fix ospf6d typo in frr.spec.in Signed-off-by: Martin Winter --- redhat/frr.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 385d5f4202..4497155f28 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -72,7 +72,7 @@ %{!?frr_gid: %global frr_gid 92 } %{!?vty_gid: %global vty_gid 85 } -%define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospfd6d +%define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospf6d %if %{with_ldpd} %define daemon_ldpd ldpd From a88f3f42f934ccdd8209004f42ebf5cb22317450 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Thu, 13 Apr 2017 17:33:24 -0700 Subject: [PATCH 05/96] redhat: Don't set file attributes for symlinks Signed-off-by: Martin Winter --- redhat/frr.spec.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 4497155f28..cffa6cc8ec 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -524,8 +524,9 @@ rm -rf %{buildroot} %{_sbindir}/ldpd %endif %if %{with_shared} -%attr(755,root,root) %{_libdir}/lib*.so -%attr(755,root,root) %{_libdir}/lib*.so.* +%{_libdir}/lib*.so +%{_libdir}/lib*.so.0 +%attr(755,root,root) %{_libdir}/lib*.so.0.* %endif %{_bindir}/* %config /etc/frr/[!v]* From 386fcd12a498426273dd660d3cfb192e4143d9c3 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Thu, 13 Apr 2017 17:34:26 -0700 Subject: [PATCH 06/96] redhat: Move frr-reload python script to it's own sub package to avoid the python2 requirement for main frr package Signed-off-by: Martin Winter --- redhat/frr.spec.in | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index cffa6cc8ec..2f7fc8ba4f 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -144,6 +144,14 @@ Group: System Environment/Daemons %description contrib Contributed/3rd party tools which may be of use with frr. +%package pythontools +Summary: python tools for frr +Requires: python >= 2.7 python-ipaddr +Group: System Environment/Daemons + +%description pythontools +Contributed python 2.7 tools which may be of use with frr. + %package devel Summary: Header and object files for frr development Group: System Environment/Daemons @@ -510,9 +518,6 @@ rm -rf %{buildroot} %{_sbindir}/bgpd %{_sbindir}/ssd %{_sbindir}/frr -%{_sbindir}/frr-reload.py -%{_sbindir}/frr-reload.pyc -%{_sbindir}/frr-reload.pyo %if %{with_watchfrr} %{_sbindir}/watchfrr %endif @@ -556,6 +561,12 @@ rm -rf %{buildroot} %defattr(-,root,root) %doc tools +%files pythontools +%defattr(-,root,root) +%{_sbindir}/frr-reload.py +%{_sbindir}/frr-reload.pyc +%{_sbindir}/frr-reload.pyo + %files devel %defattr(-,root,root) %if %{with_ospfclient} From 41b86ba421cd517be34411a8e47c083b4a39db2b Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Thu, 13 Apr 2017 18:54:58 -0700 Subject: [PATCH 07/96] redhat: Always disable PIMd on CentOS 6 and RedHat 6 systems as they are too old to correctly support the protocol Signed-off-by: Martin Winter --- redhat/frr.spec.in | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 2f7fc8ba4f..2cbc8f81c3 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -25,6 +25,7 @@ %{!?with_fpm: %global with_fpm 0 } %{!?with_watchfrr: %global with_watchfrr 1 } %{!?with_bgp_vnc: %global with_bgp_vnc 0 } +%{!?with_pimd: %global with_pimd 1 } # path defines %define _sysconfdir /etc/frr @@ -61,7 +62,16 @@ %global with_watchfrr 1 %endif -# if FPM is enabled, then enable tcp_zebra as well +#### Check for RedHat 6.x or CentOS 6.x - they are too old to support PIM. +#### Always disable it on these old systems unconditionally +%{expand: %%global redhat6 %(if [[ `cat /etc/redhat-release 2> /dev/null` =~ release\ 6\. ]]; then echo 6; fi)} +# +# if CentOS 6 / RedHat 6, then disable PIMd +%if "%{redhat6}" == "6" + %global with_pimd 0 +%endif + +# if FPM is enabled, then enable tcp_zebra as well # %if %{with_fpm} %global with_tcp_zebra 1 @@ -72,7 +82,7 @@ %{!?frr_gid: %global frr_gid 92 } %{!?vty_gid: %global vty_gid 85 } -%define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospf6d +%define daemon_list zebra ripd ospfd bgpd isisd ripngd ospf6d %if %{with_ldpd} %define daemon_ldpd ldpd @@ -80,13 +90,19 @@ %define daemon_ldpd "" %endif +%if %{with_pimd} +%define daemon_pimd pimd +%else +%define daemon_pimd "" +%endif + %if %{with_watchfrr} %define daemon_watchfrr watchfrr %else %define daemon_watchfrr "" %endif -%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_watchfrr} +%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_pimd} %{daemon_watchfrr} # allow build dir to be kept %{!?keep_build: %global keep_build 0 } @@ -223,6 +239,11 @@ developing OSPF-API and frr applications. %else --disable-ldpd \ %endif +%if %{with_pimd} + --enable-pimd \ +%else + --disable-pimd \ +%endif %if %{with_pam} --with-libpam \ %endif @@ -346,7 +367,9 @@ zebra_spec_add_service ospf6d 2606/tcp "OSPF6d vty" zebra_spec_add_service ospfapi 2607/tcp "OSPF-API" %endif zebra_spec_add_service isisd 2608/tcp "ISISd vty" +%if %{with_pimd} zebra_spec_add_service pimd 2611/tcp "PIMd vty" +%endif %if %{with_ldpd} zebra_spec_add_service ldpd 2612/tcp "LDPd vty" %endif @@ -523,7 +546,9 @@ rm -rf %{buildroot} %endif %{_sbindir}/ripngd %{_sbindir}/ospf6d -%{_sbindir}/pimd +%if %{with_pimd} + %{_sbindir}/pimd +%endif %{_sbindir}/isisd %if %{with_ldpd} %{_sbindir}/ldpd @@ -548,7 +573,9 @@ rm -rf %{buildroot} %config /etc/rc.d/init.d/ripngd %config /etc/rc.d/init.d/ospf6d %config /etc/rc.d/init.d/isisd - %config /etc/rc.d/init.d/pimd + %if %{with_pimd} + %config /etc/rc.d/init.d/pimd + %endif %if %{with_ldpd} %config /etc/rc.d/init.d/ldpd %endif @@ -584,7 +611,12 @@ rm -rf %{buildroot} %endif %changelog -* Fri Jan 6 2017 Martin Winter - %{version} +* Thu Apr 13 2017 Martin Winter - %{version} +- new subpackage frr-pythontools with python 2.7 restart script +- remove PIMd from CentOS/RedHat 6 RPM packages (won't work - too old) +- Various other RPM package fixes for FRR 2.0 + +* Fri Jan 6 2017 Martin Winter - Renamed to frr for FRRouting fork of Quagga * Thu Feb 11 2016 Paul Jakma From 33fdbd5efb2ee997d1b4e10ef6da55536bcba7d5 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Fri, 14 Apr 2017 01:28:13 -0700 Subject: [PATCH 08/96] redhat: Fix install (daemon selection) and make postun scripts compatible with fedora Signed-off-by: Martin Winter --- redhat/frr.spec.in | 70 +++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 2cbc8f81c3..13f6fca600 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -380,7 +380,9 @@ for daemon in %all_daemons ; do done %else for daemon in %all_daemons ; do - /sbin/chkconfig --add ${daemon} + if [ x"${daemon}" != x"" ] ; then + /sbin/chkconfig --add ${daemon} + fi done %endif @@ -395,11 +397,13 @@ if [ ! -e %{_sysconfdir}/zebra.conf ]; then chmod 640 %{_sysconfdir}/zebra.conf fi for daemon in %{all_daemons} ; do - if [ ! -e %{_sysconfdir}/${daemon}.conf ]; then - touch %{_sysconfdir}/${daemon}.conf - %if 0%{?frr_user:1} - chown %frr_user:%frr_user %{_sysconfdir}/${daemon}.conf* - %endif + if [ x"${daemon}" != x"" ] ; then + if [ ! -e %{_sysconfdir}/${daemon}.conf ]; then + touch %{_sysconfdir}/${daemon}.conf + %if 0%{?frr_user:1} + chown %frr_user:%frr_user %{_sysconfdir}/${daemon}.conf* + %endif + fi fi done %if %{with_watchfrr} @@ -419,10 +423,12 @@ fi if [ "$1" -ge 1 ]; then # Find out which daemons need to be restarted. for daemon in %all_daemons ; do - if [ -f /var/lock/subsys/${daemon} ]; then - eval restart_${daemon}=yes - else - eval restart_${daemon}=no + if [ x"${daemon}" != x"" ] ; then + if [ -f /var/lock/subsys/${daemon} ]; then + eval restart_${daemon}=yes + else + eval restart_${daemon}=no + fi fi done # Rename restart flags for daemons handled specially. @@ -441,18 +447,24 @@ if [ "$1" -ge 1 ]; then # # Stop all daemons other than zebra. for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - %systemd_postun ${daemon}.service + if [ x"${daemon}" != x"" ] ; then + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + %systemd_postun ${daemon}.service + : + fi done # Restart zebra. [ "$running_zebra" = yes ] && \ %systemd_postun_with_restart $daemon.service # Start all daemons other than zebra. for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - %systemd_post ${daemon}.service + if [ x"${daemon}" != x"" ] ; then + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + %systemd_post ${daemon}.service + : + fi done %else ## @@ -465,18 +477,22 @@ if [ "$1" -ge 1 ]; then %endif # Stop all daemons other than zebra and watchfrr. for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 + if [ x"${daemon}" != x"" ] ; then + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 + fi done # Restart zebra. [ "$running_zebra" = yes ] && \ /etc/rc.d/init.d/zebra restart >/dev/null 2>&1 # Start all daemons other than zebra and watchfrr. for daemon in %all_daemons ; do - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/${daemon} start >/dev/null 2>&1 + if [ x"${daemon}" != x"" ] ; then + eval restart=\$restart_${daemon} + [ "$restart" = yes ] && \ + /etc/rc.d/init.d/${daemon} start >/dev/null 2>&1 + fi done %if %{with_watchfrr} # Start watchfrr last. @@ -494,7 +510,9 @@ fi ## if [ "$1" = "0" ]; then for daemon in %all_daemons ; do - %systemd_preun ${daemon}.service + if [ x"${daemon}" != x"" ] ; then + %systemd_preun ${daemon}.service + fi done fi %else @@ -503,8 +521,10 @@ fi ## if [ "$1" = "0" ]; then for daemon in %all_daemons ; do - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - /sbin/chkconfig --del ${daemon} + if [ x"${daemon}" != x"" ] ; then + /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 + /sbin/chkconfig --del ${daemon} + fi done fi %endif From df1a7ae4ce04022e040ec36f1ae91d819e792498 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Fri, 14 Apr 2017 02:20:31 -0700 Subject: [PATCH 09/96] redhat: Fix previously added centos6/redhat6 check Signed-off-by: Martin Winter --- redhat/frr.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 13f6fca600..9982cca3d7 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -64,7 +64,7 @@ #### Check for RedHat 6.x or CentOS 6.x - they are too old to support PIM. #### Always disable it on these old systems unconditionally -%{expand: %%global redhat6 %(if [[ `cat /etc/redhat-release 2> /dev/null` =~ release\ 6\. ]]; then echo 6; fi)} +%{expand: %%global redhat6 %(if [[ `cat /etc/redhat-release 2> /dev/null` =~ release\ 6\. ]]; then echo 6; else echo 0; fi)} # # if CentOS 6 / RedHat 6, then disable PIMd %if "%{redhat6}" == "6" From 4d3bac5b1477916b8486f69529b3fbffcbd5e3a0 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Fri, 14 Apr 2017 02:21:44 -0700 Subject: [PATCH 10/96] redhat: Add python2 build requirement to pythontools sub package Signed-off-by: Martin Winter --- redhat/frr.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 9982cca3d7..354a73242d 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -162,6 +162,7 @@ Contributed/3rd party tools which may be of use with frr. %package pythontools Summary: python tools for frr +BuildRequires: python >= 2.7 Requires: python >= 2.7 python-ipaddr Group: System Environment/Daemons From 36d85ca8e302d803e864854af1b64b24b1ce78b4 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 15 Apr 2017 02:00:15 -0700 Subject: [PATCH 11/96] watchfrr: Remove the HAVE_CUMULUS around the watchfrr.started file. It's always useful Signed-off-by: Martin Winter --- watchfrr/watchfrr.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 83f00252c8..f6aa7eeab8 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -703,12 +703,10 @@ daemon_send_ready (void) static int sent = 0; if (!sent && gs.numdown == 0) { -#if defined (HAVE_CUMULUS) FILE *fp; fp = fopen(DAEMON_VTY_DIR "/watchfrr.started", "w"); fclose(fp); -#endif zlog_notice ("Watchfrr: Notifying Systemd we are up and running"); systemd_send_started(master, 0); sent = 1; From c2953ac5d66c071c38e80305ba9d62d44da40625 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 15 Apr 2017 03:13:07 -0700 Subject: [PATCH 12/96] redhat: Add (combined) init.d script for FRR with daemon selection based on /etc/frr/daemons - Provide new frr init script - Remove separate per-deamon init.d scripts Signed-off-by: Martin Winter --- redhat/Makefile.am | 5 +- redhat/bgpd.init | 72 ------ redhat/daemons | 59 +++++ redhat/frr.init | 555 +++++++++++++++++++++++++++++++++++++++++++ redhat/frr.spec.in | 52 +--- redhat/frr.sysconfig | 25 -- redhat/isisd.init | 72 ------ redhat/ldpd.init | 72 ------ redhat/ospf6d.init | 72 ------ redhat/ospfd.init | 72 ------ redhat/pimd.init | 72 ------ redhat/ripd.init | 72 ------ redhat/ripngd.init | 72 ------ redhat/watchfrr.init | 66 ----- redhat/zebra.init | 73 ------ 15 files changed, 626 insertions(+), 785 deletions(-) delete mode 100644 redhat/bgpd.init create mode 100644 redhat/daemons create mode 100755 redhat/frr.init delete mode 100644 redhat/frr.sysconfig delete mode 100644 redhat/isisd.init delete mode 100644 redhat/ldpd.init delete mode 100644 redhat/ospf6d.init delete mode 100644 redhat/ospfd.init delete mode 100644 redhat/pimd.init delete mode 100644 redhat/ripd.init delete mode 100644 redhat/ripngd.init delete mode 100644 redhat/watchfrr.init delete mode 100644 redhat/zebra.init diff --git a/redhat/Makefile.am b/redhat/Makefile.am index f7a143ff73..0a851a38d2 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -1,8 +1,5 @@ -EXTRA_DIST = bgpd.init isisd.init \ - ospf6d.init ospfd.init ldpd.init \ +EXTRA_DIST = frr.init daemons \ frr.logrotate frr.pam frr.spec \ - frr.sysconfig ripd.init ripngd.init \ - watchfrr.init pimd.init zebra.init \ README.rpm_build.md diff --git a/redhat/bgpd.init b/redhat/bgpd.init deleted file mode 100644 index d200b0baaa..0000000000 --- a/redhat/bgpd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/bgpd.conf - -### BEGIN INIT INFO -# Provides: bgpd -# Short-Description: BGP routing engine -# Description: BGP routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="bgpd" -cmd=bgpd -LOCK_FILE=/var/lock/subsys/bgpd -CONF_FILE=/etc/frr/bgpd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $BGPD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/daemons b/redhat/daemons new file mode 100644 index 0000000000..ce0f7747a2 --- /dev/null +++ b/redhat/daemons @@ -0,0 +1,59 @@ +# This file tells the frr package which daemons to start. +# +# Entries are in the format: =(yes|no|priority) +# 0, "no" = disabled +# 1, "yes" = highest priority +# 2 .. 10 = lower priorities +# +# For daemons which support multiple instances, a 2nd line listing +# the instances can be added. Eg for ospfd: +# ospfd=yes +# ospfd_instances="1,2" +# +# Priorities were suggested by Dancer . +# They're used to start the FRR daemons in more than one step +# (for example start one or two at network initialization and the +# rest later). The number of FRR daemons being small, priorities +# must be between 1 and 9, inclusive (or the initscript has to be +# changed). /etc/init.d/frr then can be started as +# +# /etc/init.d/frr > +# +# where priority 0 is the same as 'stop', priority 10 or 'start' +# means 'start all' +# +# Sample configurations for these daemons can be found in +# /usr/share/doc/frr/examples/. +# +# ATTENTION: +# +# When activation a daemon at the first time, a config file, even if it is +# empty, has to be present *and* be owned by the user and group "frr", else +# the daemon will not be started by /etc/init.d/frr. The permissions should +# be u=rw,g=r,o=. +# When using "vtysh" such a config file is also needed. It should be owned by +# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too. +# +watchfrr_enable=no +watchfrr_options=("-Az" "-b_" "-r/etc/init.d/frr_restart_%s" "-s/etc/init.d/frr_start_%s" "-k/etc/init.d/frr_stop_%s") +# +zebra=no +bgpd=no +ospfd=no +ospf6d=no +ripd=no +ripngd=no +isisd=no +ldpd=no +# +# Command line options for the daemons +# +zebra_options=("-A 127.0.0.1") +bgpd_options=("-A 127.0.0.1") +ospfd_options=("-A 127.0.0.1") +ospf6d_options=("-A ::1") +ripd_options=("-A 127.0.0.1") +ripngd_options=("-A ::1") +isisd_options=("-A 127.0.0.1") +ldpd_options=("-A 127.0.0.1") + diff --git a/redhat/frr.init b/redhat/frr.init new file mode 100755 index 0000000000..c8c0cee407 --- /dev/null +++ b/redhat/frr.init @@ -0,0 +1,555 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/frr +# +# Start/Stop the FRR Routing daemons +# +# +# chkconfig: 2345 15 85 +# +# description: FRRouting (FRR) is a routing suite for IP routing protocols +# like BGP, OSPF, RIP and others. This script contols the main +# daemon "frr" as well as the individual protocol daemons. +# +### BEGIN INIT INFO +# Provides: frr +# Required-Start: $local_fs $network $syslog +# Required-Stop: $local_fs $syslog +# Should-Start: $syslog +# Should-Stop: $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start/Stop the FRR Routing daemons +# Description: FRRouting (FRR) is a routing suite for IP routing protocols +# like BGP, OSPF, RIP and others. This script contols the main +# daemon "frr" as well as the individual protocol daemons. +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +D_PATH=/usr/lib/frr +C_PATH=/etc/frr +V_PATH=/var/run/frr + +# Local Daemon selection may be done by using /etc/frr/daemons. +# See /usr/share/doc/frr/README.Debian.gz for further information. +# Keep zebra first and do not list watchfrr! +DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd pimd ldpd" +MAX_INSTANCES=5 +RELOAD_SCRIPT=/usr/lib/frr/frr-reload.py + +. /etc/init.d/functions + +# Print the name of the pidfile. +pidfile() +{ + echo "$V_PATH/$1.pid" +} + +# Print the name of the vtysh. +vtyfile() +{ + echo "$V_PATH/$1.vty" +} + +# Check if daemon is started by using the pidfile. +started() +{ + [ ! -e `pidfile $1` ] && return 3 + if [ -n "$2" ] && [ "$2" == "log" ]; then + status -p `pidfile $1` $1 && return 0 || return $? + else + kill -0 `cat \`pidfile $1\`` 2> /dev/null || return 1 + return 0 + fi +} + +# Loads the config via vtysh -b if configured to do so. +vtysh_b () +{ + # Rember, that all variables have been incremented by 1 in convert_daemon_prios() + if [ "$vtysh_enable" = 2 -a -f $C_PATH/frr.conf ]; then + /usr/bin/vtysh -b -n + fi +} + +# Check if the daemon is activated and if its executable and config files +# are in place. +# params: daemon name +# returns: 0=ok, 1=error +check_daemon() +{ + # If the integrated config file is used the others are not checked. + if [ -r "$C_PATH/frr.conf" ]; then + return 0 + fi + + # vtysh_enable has no config file nor binary so skip check. + # (Not sure why vtysh_enable is in this list but does not hurt) + if [ $1 != "watchfrr" -a $1 != "vtysh_enable" ]; then + # check for daemon binary + if [ ! -x "$D_PATH/$1" ]; then return 1; fi + + # check for config file + if [ -n "$2" ]; then + if [ ! -r "$C_PATH/$1-$2.conf" ]; then + touch "$C_PATH/$1-$2.conf" + chown frr:frr "$C_PATH/$1-$2.conf" + fi + elif [ ! -r "$C_PATH/$1.conf" ]; then + touch "$C_PATH/$1.conf" + chown frr:frr "$C_PATH/$1.conf" + fi + fi + return 0 +} + +# Starts the server if it's not already running according to the pid file. +# The Frr daemons creates the pidfile when starting. +start() +{ + ulimit -n $MAX_FDS > /dev/null 2> /dev/null + if [ "$1" = "watchfrr" ]; then + + # We may need to restart watchfrr if new daemons are added and/or + # removed + if started "$1" ; then + stop watchfrr + else + # Echo only once. watchfrr is printed in the stop above + echo -n " $1" + fi + + if [ -e /var/run/frr/watchfrr.started ] ; then + rm /var/run/frr/watchfrr.started + fi + daemon --pidfile=`pidfile $1` "$D_PATH/$1" -d "${watchfrr_options[@]}" + RETVAL=$? + [ $RETVAL -ne 0 ] && break + for i in `seq 1 10`; + do + if [ -e /var/run/frr/watchfrr.started ] ; then + RETVAL=0 + break + else + sleep 1 + fi + done + RETVAL=1 + elif [ -n "$2" ]; then + echo -n " $1-$2" + if ! check_daemon $1 $2 ; then + echo -n " (binary does not exist)" + return; + fi + daemon --pidfile=`pidfile $1-$2` "$D_PATH/$1" -d `eval echo "$""$1""_options"` -n "$2" + RETVAL=$? + else + echo -n " $1 " + if ! check_daemon $1; then + echo " (binary does not exist)" + return; + fi + daemon --pidfile=`pidfile $1` "$D_PATH/$1" -d `eval echo "$""$1""_options"` + RETVAL=$? + fi + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$1 + return $RETVAL +} + +# Stop the daemon given in the parameter, printing its name to the terminal. +stop() +{ + local inst + + if [ -n "$2" ]; then + inst="$1-$2" + else + inst="$1" + fi + + if ! started "$inst" ; then + # echo -n " ($inst)" + return 0 + else + echo -n " $inst" + PIDFILE=`pidfile $inst` + PID=`cat $PIDFILE 2>/dev/null` + killproc -p "$PIDFILE" "$D_PATH/$1" + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $lockfile + rm -f `pidfile $inst` + rm -f `vtyfile $inst` + echo + return $RETVAL + fi +} + +# Converts values from /etc/frr/daemons to all-numeric values. +convert_daemon_prios() +{ + for name in $DAEMONS zebra vtysh_enable watchfrr_enable; do + # First, assign the value set by the user to $value + eval value=\${${name}:0:3} + + # Daemon not activated or entry missing? + if [ "$value" = "no" -o "$value" = "" ]; then value=0; fi + + # These strings parsed for backwards compatibility. + if [ "$value" = "yes" -o "$value" = "true" ]; then + value=1; + fi + + # Zebra is threatened special. It must be between 0=off and the first + # user assigned value "1" so we increase all other enabled daemons' values. + if [ "$name" != "zebra" -a "$value" -gt 0 ]; then value=`expr "$value" + 1`; fi + + # If e.g. name is zebra then we set "zebra=yes". + eval $name=$value + done +} + +# Starts watchfrr for all wanted daemons. +start_watchfrr() +{ + local daemon_name + local daemon_prio + local found_one + local daemon_inst + + # Start the monitor daemon only if desired. + if [ 0 -eq "$watchfrr_enable" ]; then + return + fi + + # Check variable type + if ! declare -p watchfrr_options | grep -q '^declare \-a'; then + echo + echo "ERROR: The variable watchfrr_options from /etc/frr/daemons must be a BASH array!" + echo "ERROR: Please convert config file and restart!" + exit 1 + fi + + # Which daemons have been started? + found_one=0 + for daemon_name in $DAEMONS; do + eval daemon_prio=\$$daemon_name + if [ "$daemon_prio" -gt 0 ]; then + eval "daemon_inst=\${${daemon_name}_instances//,/ }" + if [ -n "$daemon_inst" ]; then + for inst in ${daemon_inst}; do + eval "inst_disable=\${${daemon_name}_${inst}}" + if [ -z ${inst_disable} ] || [ ${inst_disable} != 0 ]; then + if check_daemon $daemon_name $inst; then + watchfrr_options+=("${daemon_name}-${inst}") + fi + fi + done + else + if check_daemon $daemon_name; then + watchfrr_options+=($daemon_name) + fi + fi + found_one=1 + fi + done + + # Start if at least one daemon is activated. + if [ $found_one -eq 1 ]; then + echo "Starting FRRouting monitor daemon:" + start watchfrr + fi +} + +# Stopps watchfrr. +stop_watchfrr() +{ + echo "Stopping FRRouting monitor daemon:" + stop watchfrr +} + +# Stops all daemons that have a lower level of priority than the given. +# (technically if daemon_prio >= wanted_prio) +stop_prio() +{ + local wanted_prio + local daemon_prio + local daemon_list + local daemon_inst + local inst + + if [ -n "$2" ] && [[ "$2" =~ (.*)-(.*) ]]; then + daemon=${BASH_REMATCH[1]} + inst=${BASH_REMATCH[2]} + else + daemon="$2" + fi + + wanted_prio=$1 + daemon_list=${daemon:-$DAEMONS} + + echo "Stopping FRRouting daemons (prio:$wanted_prio):" + + for prio_i in `seq 10 -1 $wanted_prio`; do + for daemon_name in $daemon_list; do + eval daemon_prio=\${${daemon_name}:0:3} + daemon_inst="" + if [ $daemon_prio -eq $prio_i ]; then + eval "daemon_inst=\${${daemon_name}_instances//,/ }" + if [ -n "$daemon_inst" ]; then + for i in ${daemon_inst}; do + if [ -n "$inst" ] && [ "$i" == "$inst" ]; then + stop "$daemon_name" "$inst" + elif [ x"$inst" == x ]; then + stop "$daemon_name" "$i" + fi + done + else + stop "$daemon_name" + fi + fi + done + done + + if [ -z "$inst" ]; then + # Now stop other daemons that're prowling, coz the daemons file changed + echo "Stopping other FRRouting daemons" + if [ -n "$daemon" ]; then + eval "file_list_suffix="$V_PATH"/"$daemon*"" + else + eval "file_list_suffix="$V_PATH/*"" + fi + for pidfile in $file_list_suffix.pid; do + if [ -f "$pidfile" ]; then + filename=${pidfile##*/} + daemon=${filename%.*} + echo -n " $daemon" + killproc -p "$pidfile" "$daemon" + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $lockfile + rm -f "$pidfile" + echo + fi + done + echo -n "Removing remaining .vty files" + for vtyfile in $file_list_suffix.vty; do + rm -rf "$vtyfile" + done + echo + fi +} + +# Starts all daemons that have a higher level of priority than the given. +# (technically if daemon_prio <= wanted_prio) +start_prio() +{ + local wanted_prio + local daemon_prio + local daemon_list + local daemon_name + local daemon_inst + local inst + + if [ -n "$2" ] && [[ "$2" =~ (.*)-(.*) ]]; then + daemon=${BASH_REMATCH[1]} + inst=${BASH_REMATCH[2]} + else + daemon="$2" + fi + + wanted_prio=$1 + daemon_list=${daemon:-$DAEMONS} + + echo "Starting FRRouting daemons (prio:$wanted_prio):" + + for prio_i in `seq 1 $wanted_prio`; do + for daemon_name in $daemon_list; do + eval daemon_prio=\$${daemon_name} + daemon_inst="" + if [ $daemon_prio -eq $prio_i ]; then + eval "daemon_inst=\${${daemon_name}_instances//,/ }" + if [ -n "$daemon_inst" ]; then + if [ `echo "$daemon_inst" | wc -w` -gt ${MAX_INSTANCES} ]; then + echo "Max instances supported is ${MAX_INSTANCES}. Aborting" + exit 1 + fi + # Check if we're starting again by switching from single instance + # to MI version + if started "$daemon_name"; then + PIDFILE=`pidfile $daemon_name` + killproc -p "$PIDFILE" "$daemon_name" + rm -f `pidfile $1` + rm -f `vtyfile $1` + fi + + for i in ${daemon_inst}; do + if [ -n "$inst" ] && [ "$i" == "$inst" ]; then + start "$daemon_name" "$inst" + elif [ x"$inst" == x ]; then + start "$daemon_name" "$i" + fi + done + else + # Check if we're starting again by switching from + # single instance to MI version + eval "file_list_suffix="$V_PATH"/"$daemon_name-*"" + for pidfile in $file_list_suffix.pid; do + if [ -f "$pidfile" ]; then + killproc -p "$pidfile" "$daemon_name" + rm -rf "$pidfile" + fi + done + for vtyfile in $file_list_suffix.vty; do + rm -rf "$vtyfile" + done + + start "$daemon_name" + fi + fi + done + done +} + +check_status() +{ + local daemon_name + local daemon_prio + local daemon_inst + local failed_status=0 + + if [ -n "$1" ] && [[ "$1" =~ (.*)-(.*) ]]; then + daemon=${BASH_REMATCH[1]} + inst=${BASH_REMATCH[2]} + else + daemon="$1" + fi + + daemon_list=${daemon:-$DAEMONS} + + # Which daemons have been started? + for daemon_name in $daemon_list; do + eval daemon_prio=\$$daemon_name + if [ "$daemon_prio" -gt 0 ]; then + eval "daemon_inst=\${${daemon_name}_instances//,/ }" + if [ -n "$daemon_inst" ]; then + for i in ${daemon_inst}; do + if [ -n "$inst" -a "$inst" = "$i" ]; then + started "$1" "log" || failed_status=$? + elif [ -z "$inst" ]; then + started "$daemon_name-$i" "log" || failed_status=$? + fi + done + else + started "$daemon_name" "log" || failed_status=$? + fi + fi + done + + # All daemons that need to have been started are up and running + return $failed_status +} + +######################################################### +# Main program # +######################################################### + +# Config broken but script must exit silently. +[ ! -r "$C_PATH/daemons" ] && exit 0 + +# Load configuration +. "$C_PATH/daemons" + +# Read configuration variable file if it is present +[ -r /etc/sysconfig/frr ] && . /etc/sysconfig/frr + +MAX_INSTANCES=${MAX_INSTANCES:=5} + +# Set priority of un-startable daemons to 'no' and substitute 'yes' to '0' +convert_daemon_prios + +if [ ! -d $V_PATH ]; then + echo "Creating $V_PATH" + mkdir -p $V_PATH + chown frr:frr $V_PATH + chmod 755 /$V_PATH +fi + +if [ -n "$3" ] && [ "$3" != "all" ]; then + dmn="$2"-"$3" +elif [ -n "$2" ] && [ "$2" != "all" ]; then + dmn="$2" +fi + +case "$1" in + start) + # Try to load this necessary (at least for 2.6) module. + if [ -d /lib/modules/`uname -r` ] ; then + echo "Loading capability module if not yet done." + LC_ALL=C modprobe -a capability 2>&1 | egrep -v "(not found|Can't locate)" + fi + + # Start all daemons + cd $C_PATH/ + if [ "$2" != "watchfrr" ]; then + start_prio 10 $dmn + fi + start_watchfrr + vtysh_b + ;; + + 1|2|3|4|5|6|7|8|9|10) + # Stop/start daemons for the appropriate priority level + stop_prio $1 + start_prio $1 + vtysh_b + ;; + + stop|0) + # Stop all daemons at level '0' or 'stop' + stop_watchfrr + if [ "$dmn" != "watchfrr" ]; then + [ -n "${dmn}" ] && eval "${dmn/-/_}=0" + stop_prio 0 $dmn + fi + + if [ -z "$dmn" -o "$dmn" = "zebra" ]; then + echo "Removing all routes made by zebra." + ip route flush proto zebra + else + [ -n "$dmn" ] && eval "${dmn/-/_}=0" + start_watchfrr + fi + ;; + + reload) + # Just apply the commands that have changed, no restart necessary + [ ! -x "$RELOAD_SCRIPT" ] && echo "frr-reload script not available" && exit 0 + NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}" + [ ! -r $NEW_CONFIG_FILE ] && echo "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1 + echo "Applying only incremental changes to running configuration from frr.conf" + "$RELOAD_SCRIPT" --reload /etc/frr/frr.conf + exit $? + ;; + + status) + check_status $dmn + exit $? + ;; + + restart|force-reload) + $0 stop $dmn + sleep 1 + $0 start $dmn + ;; + + *) + echo "Usage: /etc/init.d/frr {start|stop|status|reload|restart|force-reload|} [daemon]" + echo " E.g. '/etc/init.d/frr 5' would start all daemons with a prio 1-5." + echo " reload applies only modifications from the running config to all daemons." + echo " reload neither restarts starts any daemon nor starts any new ones." + echo " Read /usr/share/doc/frr/README.Debian for details." + exit 1 + ;; +esac + +exit 0 diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 354a73242d..17a07d1555 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -34,7 +34,6 @@ %define zeb_rh_src %{zeb_src}/redhat %define zeb_docs %{zeb_src}/doc %define frr_tools %{zeb_src}/tools -%define cumulus_dir %{zeb_src}/cumulus/etc # defines for configure %define _localstatedir /var/run/frr @@ -162,8 +161,8 @@ Contributed/3rd party tools which may be of use with frr. %package pythontools Summary: python tools for frr -BuildRequires: python >= 2.7 -Requires: python >= 2.7 python-ipaddr +BuildRequires: python +Requires: python python-ipaddr Group: System Environment/Daemons %description pythontools @@ -303,17 +302,11 @@ install %{frr_tools}/frr.service \ %{buildroot}%{_unitdir}/frr.service %else mkdir -p %{buildroot}/etc/rc.d/init.d -for daemon in %{all_daemons} ; do - if [ x"${daemon}" != x"" ] ; then - install %{zeb_rh_src}/${daemon}.init \ - %{buildroot}/etc/rc.d/init.d/${daemon} - fi -done +install %{zeb_rh_src}/frr.init \ + %{buildroot}/etc/rc.d/init.d/frr %endif -install %{cumulus_dir}/frr/debian.conf %{buildroot}/etc/frr -install %{cumulus_dir}/frr/daemons %{buildroot}/etc/frr -install -m644 %{cumulus_dir}/default/frr %{buildroot}/etc/default +install %{zeb_rh_src}/daemons %{buildroot}/etc/frr install -m644 %{zeb_rh_src}/frr.pam \ %{buildroot}/etc/pam.d/frr install -m644 %{zeb_rh_src}/frr.logrotate \ @@ -380,11 +373,7 @@ for daemon in %all_daemons ; do %systemd_post frr.service done %else -for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - /sbin/chkconfig --add ${daemon} - fi -done +/sbin/chkconfig --add frr %endif /sbin/install-info %{_infodir}/frr.info.gz %{_infodir}/dir @@ -521,12 +510,8 @@ fi ## init.d Version ## if [ "$1" = "0" ]; then - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - /sbin/chkconfig --del ${daemon} - fi - done + /etc/rc.d/init.d/frr stop >/dev/null 2>&1 + /sbin/chkconfig --del frr fi %endif /sbin/install-info --delete %{_infodir}/frr.info.gz %{_infodir}/dir @@ -572,7 +557,7 @@ rm -rf %{buildroot} %endif %{_sbindir}/isisd %if %{with_ldpd} -%{_sbindir}/ldpd + %{_sbindir}/ldpd %endif %if %{with_shared} %{_libdir}/lib*.so @@ -584,24 +569,9 @@ rm -rf %{buildroot} %if "%{initsystem}" == "systemd" %config %{_unitdir}/frr.service %else - %config /etc/rc.d/init.d/zebra - %if %{with_watchfrr} - %config /etc/rc.d/init.d/watchfrr - %endif - %config /etc/rc.d/init.d/ripd - %config /etc/rc.d/init.d/ospfd - %config /etc/rc.d/init.d/bgpd - %config /etc/rc.d/init.d/ripngd - %config /etc/rc.d/init.d/ospf6d - %config /etc/rc.d/init.d/isisd - %if %{with_pimd} - %config /etc/rc.d/init.d/pimd - %endif - %if %{with_ldpd} - %config /etc/rc.d/init.d/ldpd - %endif + %config /etc/rc.d/init.d/frr %endif -%config(noreplace) /etc/default/frr +%config /etc/frr/daemons %config(noreplace) /etc/pam.d/frr %config(noreplace) %attr(640,root,root) /etc/logrotate.d/* diff --git a/redhat/frr.sysconfig b/redhat/frr.sysconfig deleted file mode 100644 index 97c28c807d..0000000000 --- a/redhat/frr.sysconfig +++ /dev/null @@ -1,25 +0,0 @@ -# -# Default: Bind all daemon vtys to the loopback(s) only -# -BGPD_OPTS="-A 127.0.0.1" -ISISD_OPTS="-A ::1" -OSPF6D_OPTS="-A ::1" -OSPFD_OPTS="-A 127.0.0.1" -RIPD_OPTS="-A 127.0.0.1" -RIPNGD_OPTS="-A ::1" -ZEBRA_OPTS="-A 127.0.0.1" -PIMD_OPTS="-A 127.0.0.1" -LDPD_OPTS="-A 127.0.0.1" - -# Watchfrr configuration for LSB initscripts -# -# (Not needed with systemd: the service files are configured to automatically -# restart any daemon on failure. If zebra fails, all running daemons will be -# stopped; zebra will be started again; and then the previously running daemons -# will be started again.) -# -# Uncomment and edit this line to reflect the daemons you are actually using: -#WATCH_DAEMONS="zebra bgpd ospfd ospf6d ripd ripngd" -# -# Timer values can be adjusting by editing this line: -WATCH_OPTS="-Az -b_ -r/sbin/service_%s_restart -s/sbin/service_%s_start -k/sbin/service_%s_stop" diff --git a/redhat/isisd.init b/redhat/isisd.init deleted file mode 100644 index b309e07542..0000000000 --- a/redhat/isisd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/isisd.conf - -### BEGIN INIT INFO -# Provides: isisd -# Short-Description: IS-IS routing engine -# Description: IS-IS routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="isisd" -cmd=isisd -LOCK_FILE=/var/lock/subsys/isisd -CONF_FILE=/etc/frr/isisd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $ISISD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ldpd.init b/redhat/ldpd.init deleted file mode 100644 index 3ade9bfe9f..0000000000 --- a/redhat/ldpd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ldpd.conf - -### BEGIN INIT INFO -# Provides: ldpd -# Short-Description: LDP engine -# Description: LDP engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ldpd" -cmd=ldpd -LOCK_FILE=/var/lock/subsys/ldpd -CONF_FILE=/etc/frr/ldpd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $LDPD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ospf6d.init b/redhat/ospf6d.init deleted file mode 100644 index 5c5a2af236..0000000000 --- a/redhat/ospf6d.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ospf6d.conf - -### BEGIN INIT INFO -# Provides: ospf6d -# Short-Description: OSPF routing engine for IPv6 -# Description: OSPF routing engine for use with Zebra and IPv6 -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ospf6d" -cmd=ospf6d -LOCK_FILE=/var/lock/subsys/ospf6d -CONF_FILE=/etc/frr/ospf6d.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $OSPF6D_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ospfd.init b/redhat/ospfd.init deleted file mode 100644 index e9cbbc739c..0000000000 --- a/redhat/ospfd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ospfd.conf - -### BEGIN INIT INFO -# Provides: ospfd -# Short-Description: OSPF routing engine -# Description: OSPF routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ospfd" -cmd=ospfd -LOCK_FILE=/var/lock/subsys/ospfd -CONF_FILE=/etc/frr/ospfd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $OSPFD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/pimd.init b/redhat/pimd.init deleted file mode 100644 index 85cbf8d2b1..0000000000 --- a/redhat/pimd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/pimd.conf - -### BEGIN INIT INFO -# Provides: pimd -# Short-Description: PIM multicast routing engine -# Description: PIM routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="pimd" -cmd=pimd -LOCK_FILE=/var/lock/subsys/pimd -CONF_FILE=/etc/frr/pimd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $PIMD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ripd.init b/redhat/ripd.init deleted file mode 100644 index 8e25a83f4b..0000000000 --- a/redhat/ripd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ripd.conf - -### BEGIN INIT INFO -# Provides: ripd -# Short-Description: RIP routing engine -# Description: RIP routing engine for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ripd" -cmd=ripd -LOCK_FILE=/var/lock/subsys/ripd -CONF_FILE=/etc/frr/ripd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $RIPD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/ripngd.init b/redhat/ripngd.init deleted file mode 100644 index 7b9fde4085..0000000000 --- a/redhat/ripngd.init +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# chkconfig: - 16 84 -# config: /etc/frr/ripngd.conf - -### BEGIN INIT INFO -# Provides: ripngd -# Short-Description: RIP routing engine for IPv6 -# Description: RIP routing engine for use with Zebra and IPv6 -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="ripngd" -cmd=ripngd -LOCK_FILE=/var/lock/subsys/ripngd -CONF_FILE=/etc/frr/ripngd.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - daemon $cmd -d $RIPNGD_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/watchfrr.init b/redhat/watchfrr.init deleted file mode 100644 index bc83415167..0000000000 --- a/redhat/watchfrr.init +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash -# chkconfig: 2345 17 83 - -### BEGIN INIT INFO -# Provides: watchfrr -# Short-Description: Frr watchdog -# Description: Frr watchdog for use with Zebra -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="watchfrr" -cmd=watchfrr -LOCK_FILE=/var/lock/subsys/watchfrr - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # Check that there are daemons to be monitored. - [ -z "$WATCH_DAEMONS" ] && exit 1 - - echo -n $"Starting $PROG: " - daemon $cmd -d $WATCH_OPTS $WATCH_DAEMONS - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL diff --git a/redhat/zebra.init b/redhat/zebra.init deleted file mode 100644 index 1afb785431..0000000000 --- a/redhat/zebra.init +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# chkconfig: - 15 85 -# config: /etc/frr/zebra.conf - -### BEGIN INIT INFO -# Provides: zebra -# Short-Description: GNU Zebra routing manager -# Description: GNU Zebra routing manager -### END INIT INFO - -# source function library -. /etc/rc.d/init.d/functions - -# Get network config -. /etc/sysconfig/network - -# frr command line options -. /etc/sysconfig/frr - -RETVAL=0 -PROG="zebra" -cmd=zebra -LOCK_FILE=/var/lock/subsys/zebra -CONF_FILE=/etc/frr/zebra.conf - -case "$1" in - start) - # Check that networking is up. - [ "${NETWORKING}" = "no" ] && exit 1 - - # The process must be configured first. - [ -f $CONF_FILE ] || exit 6 - if [ `id -u` -ne 0 ]; then - echo $"Insufficient privilege" 1>&2 - exit 4 - fi - - echo -n $"Starting $PROG: " - /sbin/ip route flush proto zebra - daemon $cmd -d $ZEBRA_OPTS -f $CONF_FILE - RETVAL=$? - [ $RETVAL -eq 0 ] && touch $LOCK_FILE - echo - ;; - stop) - echo -n $"Shutting down $PROG: " - killproc $cmd - RETVAL=$? - [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE - echo - ;; - restart|reload|force-reload) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart|try-restart) - if [ -f $LOCK_FILE ]; then - $0 stop - $0 start - fi - RETVAL=$? - ;; - status) - status $cmd - RETVAL=$? - ;; - *) - echo $"Usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" - exit 2 -esac - -exit $RETVAL From 178b92ceb1a8016a1b39ce37fea8671b0dfc6b21 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 15 Apr 2017 03:29:34 -0700 Subject: [PATCH 13/96] redhat: /etc/frr/daemons needs to be marked as no replace config to be save from overwriting Signed-off-by: Martin Winter --- redhat/frr.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 17a07d1555..1697837391 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -571,7 +571,7 @@ rm -rf %{buildroot} %else %config /etc/rc.d/init.d/frr %endif -%config /etc/frr/daemons +%config(noreplace) /etc/frr/daemons %config(noreplace) /etc/pam.d/frr %config(noreplace) %attr(640,root,root) /etc/logrotate.d/* From 2cdd3d94fcaddacb97e470f97a56e422b259872d Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 17 Apr 2017 18:17:16 -0700 Subject: [PATCH 14/96] redhat: Add frr.service file for redhat based systemd systems (using init script) Signed-off-by: Martin Winter --- redhat/Makefile.am | 2 +- redhat/frr.service | 23 +++++++++++++++++++++++ redhat/frr.spec.in | 28 ++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 redhat/frr.service diff --git a/redhat/Makefile.am b/redhat/Makefile.am index 0a851a38d2..74856cfd82 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -1,5 +1,5 @@ -EXTRA_DIST = frr.init daemons \ +EXTRA_DIST = frr.init frr.service daemons \ frr.logrotate frr.pam frr.spec \ README.rpm_build.md diff --git a/redhat/frr.service b/redhat/frr.service new file mode 100644 index 0000000000..cc6ec429a3 --- /dev/null +++ b/redhat/frr.service @@ -0,0 +1,23 @@ +[Unit] +Description=FRRouting (FRR) +After=syslog.target networking.service +OnFailure=heartbeat-failed@%n.service + +[Service] +Nice=-5 +Type=forking +NotifyAccess=all +StartLimitInterval=3m +StartLimitBurst=3 +TimeoutSec=1m +WatchdogSec=60s +RestartSec=5 +Restart=on-abnormal +LimitNOFILE=1024 +ExecStart=/usr/lib/frr/frr start +ExecStop=/usr/lib/frr/frr stop +ExecReload=/usr/lib/frr/frr reload + +[Install] +WantedBy=network-online.target + diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 1697837391..489b945967 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -294,12 +294,16 @@ make DESTDIR=%{buildroot} INSTALL="install -p" CP="cp -p" install # Remove this file, as it is uninstalled and causes errors when building on RH9 rm -rf %{buildroot}/usr/share/info/dir +# Remove debian init script if it was installed +rm -f %{buildroot}%{_sbindir}/frr # install /etc sources %if "%{initsystem}" == "systemd" mkdir -p %{buildroot}%{_unitdir} -install %{frr_tools}/frr.service \ +install %{zeb_rh_src}/frr.service \ %{buildroot}%{_unitdir}/frr.service +install %{zeb_rh_src}/frr.init \ + %{buildroot}%{_sbindir}/frr %else mkdir -p %{buildroot}/etc/rc.d/init.d install %{zeb_rh_src}/frr.init \ @@ -384,7 +388,7 @@ if [ ! -e %{_sysconfdir}/zebra.conf ]; then %if 0%{?frr_user:1} chown %frr_user:%frr_user %{_sysconfdir}/zebra.conf* %endif - chmod 640 %{_sysconfdir}/zebra.conf + chmod 640 %{_sysconfdir}/zebra.conf* fi for daemon in %{all_daemons} ; do if [ x"${daemon}" != x"" ] ; then @@ -396,6 +400,10 @@ for daemon in %{all_daemons} ; do fi fi done +%if 0%{?frr_user:1} + chown %frr_user:%frr_user %{_sysconfdir}/daemons +%endif + %if %{with_watchfrr} # No config for watchfrr - this is part of /etc/sysconfig/frr rm -f %{_sysconfdir}/watchfrr.* @@ -404,8 +412,10 @@ done if [ ! -e %{_sysconfdir}/vtysh.conf ]; then touch %{_sysconfdir}/vtysh.conf chmod 640 %{_sysconfdir}/vtysh.conf +%if 0%{?frr_user:1} %if 0%{?vty_group:1} - chown frr:%{vty_group} %{_sysconfdir}/vtysh.conf* + chown %{frr_user}:%{vty_group} %{_sysconfdir}/vtysh.conf* +%endif %endif fi @@ -545,8 +555,7 @@ rm -rf %{buildroot} %{_sbindir}/ospfd %{_sbindir}/ripd %{_sbindir}/bgpd -%{_sbindir}/ssd -%{_sbindir}/frr +%exclude %{_sbindir}/ssd %if %{with_watchfrr} %{_sbindir}/watchfrr %endif @@ -565,13 +574,14 @@ rm -rf %{buildroot} %attr(755,root,root) %{_libdir}/lib*.so.0.* %endif %{_bindir}/* -%config /etc/frr/[!v]* +%config(noreplace) /etc/frr/[!v]* +%attr(750,%frr_user,%frr_user) /etc/frr/daemons %if "%{initsystem}" == "systemd" %config %{_unitdir}/frr.service + %{_sbindir}/frr %else %config /etc/rc.d/init.d/frr %endif -%config(noreplace) /etc/frr/daemons %config(noreplace) /etc/pam.d/frr %config(noreplace) %attr(640,root,root) /etc/logrotate.d/* @@ -602,9 +612,11 @@ rm -rf %{buildroot} %endif %changelog -* Thu Apr 13 2017 Martin Winter - %{version} +* Thu Apr 17 2017 Martin Winter - %{version} - new subpackage frr-pythontools with python 2.7 restart script - remove PIMd from CentOS/RedHat 6 RPM packages (won't work - too old) +- converted to single frr init script (not per daemon) based on debian init script +- created systemd service file for systemd based systems (which uses init script) - Various other RPM package fixes for FRR 2.0 * Fri Jan 6 2017 Martin Winter From 19ced9a4b834206d39f5f70d4fc5d0d77b70be41 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 17 Apr 2017 18:34:32 -0700 Subject: [PATCH 15/96] redhat: fix upgrade script (%postun), remove invalid mpls package selection (it's always built and auto detected), add ldpd Signed-off-by: Martin Winter --- redhat/frr.spec.in | 90 +++++----------------------------------------- 1 file changed, 9 insertions(+), 81 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 489b945967..6f29f0f984 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -16,8 +16,7 @@ %{!?with_ospfapi: %global with_ospfapi 1 } %{!?with_irdp: %global with_irdp 1 } %{!?with_rtadv: %global with_rtadv 1 } -%{!?with_mpls: %global with_mpls 0 } -%{!?with_ldpd: %global with_ldpd 0 } +%{!?with_ldpd: %global with_ldpd 1 } %{!?with_shared: %global with_shared 1 } %{!?with_multipath: %global with_multipath 256 } %{!?frr_user: %global frr_user frr } @@ -210,9 +209,9 @@ developing OSPF-API and frr applications. %endif --enable-vtysh \ %if %{with_ospfclient} - --enable-ospfclient=yes \ + --enable-ospfclient \ %else - --enable-ospfclient=no\ + --disable-ospfclient\ %endif %if %{with_ospfapi} --enable-ospfapi=yes \ @@ -229,11 +228,6 @@ developing OSPF-API and frr applications. %else --enable-rtadv=no \ %endif -%if %{with_mpls} - --enable-mpls=yes \ -%else - --disable-mpls \ -%endif %if %{with_ldpd} --enable-ldpd \ %else @@ -421,85 +415,19 @@ fi %postun if [ "$1" -ge 1 ]; then - # Find out which daemons need to be restarted. - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - if [ -f /var/lock/subsys/${daemon} ]; then - eval restart_${daemon}=yes - else - eval restart_${daemon}=no - fi - fi - done - # Rename restart flags for daemons handled specially. - running_zebra="$restart_zebra" - restart_zebra=no - %if %{with_watchfrr} - running_watchfrr="$restart_watchfrr" - restart_watchfrr=no - %endif - + # + # Upgrade from older version + # %if "%{initsystem}" == "systemd" ## ## Systemd Version ## - # No watchfrr for systemd version - # - # Stop all daemons other than zebra. - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - %systemd_postun ${daemon}.service - : - fi - done - # Restart zebra. - [ "$running_zebra" = yes ] && \ - %systemd_postun_with_restart $daemon.service - # Start all daemons other than zebra. - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - %systemd_post ${daemon}.service - : - fi - done + %systemd_postun frr.service %else ## ## init.d Version ## - %if %{with_watchfrr} - # Stop watchfrr first. - [ "$running_watchfrr" = yes ] && \ - /etc/rc.d/init.d/watchfrr stop >/dev/null 2>&1 - %endif - # Stop all daemons other than zebra and watchfrr. - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/${daemon} stop >/dev/null 2>&1 - fi - done - # Restart zebra. - [ "$running_zebra" = yes ] && \ - /etc/rc.d/init.d/zebra restart >/dev/null 2>&1 - # Start all daemons other than zebra and watchfrr. - for daemon in %all_daemons ; do - if [ x"${daemon}" != x"" ] ; then - eval restart=\$restart_${daemon} - [ "$restart" = yes ] && \ - /etc/rc.d/init.d/${daemon} start >/dev/null 2>&1 - fi - done - %if %{with_watchfrr} - # Start watchfrr last. - # Avoid postun scriptlet error if watchfrr is not running. - [ "$running_watchfrr" = yes ] && \ - /etc/rc.d/init.d/watchfrr start >/dev/null 2>&1 || : - %endif + /etc/rc.d/init.d/frr restart >/dev/null 2>&1 %endif fi @@ -511,7 +439,7 @@ fi if [ "$1" = "0" ]; then for daemon in %all_daemons ; do if [ x"${daemon}" != x"" ] ; then - %systemd_preun ${daemon}.service + %systemd_preun frr.service fi done fi From 3630ef2d240d7021b7835424713888b39da0e90c Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 17 Apr 2017 18:45:50 -0700 Subject: [PATCH 16/96] redhat: Update documentation for RPM build and usage Signed-off-by: Martin Winter --- redhat/README.rpm_build.md | 58 +++++++++++--------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index fa1d56e0ef..4513eda635 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -1,6 +1,6 @@ Building your own FRRouting RPM ====================================== -(Tested on CentOS 6, CentOS 7 and Fedora 22.) +(Tested on CentOS 6, CentOS 7 and Fedora 24.) 1. Install the following packages to build the RPMs: @@ -46,19 +46,12 @@ Building your own FRRouting RPM ################# frr configure options #################### # with-feature options %{!?with_snmp: %global with_snmp 1 } - %{!?with_vtysh: %global with_vtysh 1 } - %{!?with_ospf_te: %global with_ospf_te 1 } - %{!?with_opaque_lsa: %global with_opaque_lsa 1 } %{!?with_tcp_zebra: %global with_tcp_zebra 0 } - %{!?with_vtysh: %global with_vtysh 1 } %{!?with_pam: %global with_pam 1 } %{!?with_ospfclient: %global with_ospfclient 1 } %{!?with_ospfapi: %global with_ospfapi 1 } %{!?with_irdp: %global with_irdp 1 } %{!?with_rtadv: %global with_rtadv 1 } - %{!?with_isisd: %global with_isisd 1 } - %{!?with_pimd: %global with_pimd 1 } - %{!?with_mpls: %global with_mpls 0 } %{!?with_ldpd: %global with_ldpd 0 } %{!?with_shared: %global with_shared 1 } %{!?with_multipath: %global with_multipath 64 } @@ -66,6 +59,8 @@ Building your own FRRouting RPM %{!?vty_group: %global vty_group frrvt } %{!?with_fpm: %global with_fpm 0 } %{!?with_watchfrr: %global with_watchfrr 1 } + %{!?with_bgp_vnc: %global with_bgp_vnc 0 } + %{!?with_pimd: %global with_pimd 1 } 6. Build the RPM @@ -82,55 +77,36 @@ Enabling daemons after installation of the package: ### init.d based systems (ie CentOS 6): -1. Enable the daemons as needed to run after boot (Zebra is mandatory) +1. Edit /etc/frr/daemons and enable required routing daemons (Zebra is probably needed for most deployments, so make sure to enable it.) + +2. Enable the daemons as needed to run after boot (Zebra is mandatory) - chkconfig zebra on - chkconfig ospfd on - chkconfig ospf6d on - chkconfig bgpd on - ... etc - -2. If you want to run `watchfrr`, then configure `/etc/sysconfig/frr` - and uncomment the line with the daemons for `watchfrr` to monitor, - then enable watchfrr - - chkconfig watchfrr on + chkconfig frr on 3. Check your firewall / IPtables to make sure the routing protocols are allowed. -4. Start the daemons (or reboot) +5. Start the FRR daemons (or reboot) - service zebra start - service bgpd start - service ospfd start - ... etc + service frr start -Configuration is stored in `/etc/frr/*.conf` files. +Configuration is stored in `/etc/frr/*.conf` files and daemon selection is stored in `/etc/frr/daemons`. -### systemd based systems (ie CentOS 7, Fedora 22) +### systemd based systems (ie CentOS 7, Fedora 24) -1. Enable the daemons as needed to run after boot (Zebra is mandatory) +1. Edit /etc/frr/daemons and enable required routing daemons (Zebra is probably needed for most deployments, so make sure to enable it.) + +2. Enable the frr daemons to run after boot. - systemctl enable zebra - systemctl enable ospfd - systemctl enable ospf6d - systemctl enable bgpd - ... etc - - Note: There is no watchfrr on systemd based systems. Systemd contains - the functionality of monitoring and restarting daemons. + systemctl enable frr 2. Check your firewall / IPtables to make sure the routing protocols are allowed. 3. Start the daemons (or reboot) - systemctl start zebra - systemctl start bgpd - systemctl start ospfd - ... etc + systemctl start frr -Configuration is stored in `/etc/frr/*.conf` files. +Configuration is stored in `/etc/frr/*.conf` files and daemon selection is stored in `/etc/frr/daemons`. From b387c334d4a2ea66a1088771784d621190681930 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 19 Apr 2017 18:12:10 -0700 Subject: [PATCH 17/96] redhat: Fix BuildRequires for FRR/2.0 and duplicate /etc/frr/daemons - add make & gcc - remove autoconf and automake (not needed to build from src.rpm) - fix texi2html version detection for case when no texi2html is installed (broke yum-builddep) - fix duplicate listing of /etc/frr/daemons Signed-off-by: Martin Winter --- redhat/frr.spec.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 6f29f0f984..c78fc54b7e 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -8,7 +8,7 @@ # rpms again and again on the same day, so the newer rpms can be installed. # bumping the number each time. -####################### FRRouting (FRR) configure options ######################### +#################### FRRouting (FRR) configure options ##################### # with-feature options %{!?with_tcp_zebra: %global with_tcp_zebra 0 } %{!?with_pam: %global with_pam 0 } @@ -45,7 +45,7 @@ #### Check version of texi2html # Old versions don't support "--number-footnotes" option. -%{expand: %%global texi2htmlversion %(/usr/bin/texi2html --version | cut -d. -f1)} +%{expand: %%global texi2htmlversion %(if [[ -f /usr/bin/texi2html ]]; then /usr/bin/texi2html --version | cut -d. -f1; else echo 0; fi)} #### Check for systemd or init.d (upstart) # Check for init.d (upstart) as used in CentOS 6 or systemd (ie CentOS 7) @@ -120,9 +120,9 @@ Requires: ncurses json-c Requires(pre): /sbin/install-info Requires(preun): /sbin/install-info Requires(post): /sbin/install-info -BuildRequires: texi2html texinfo autoconf automake patch libcap-devel groff +BuildRequires: gcc texi2html texinfo patch libcap-devel groff BuildRequires: readline readline-devel ncurses ncurses-devel -BuildRequires: json-c-devel bison >= 2.7 flex +BuildRequires: json-c-devel bison >= 2.7 flex make Requires: ncurses initscripts %if %{with_pam} BuildRequires: pam-devel @@ -502,8 +502,8 @@ rm -rf %{buildroot} %attr(755,root,root) %{_libdir}/lib*.so.0.* %endif %{_bindir}/* -%config(noreplace) /etc/frr/[!v]* -%attr(750,%frr_user,%frr_user) /etc/frr/daemons +%config(noreplace) /etc/frr/[!v]*.conf* +%config(noreplace) %attr(750,%frr_user,%frr_user) /etc/frr/daemons %if "%{initsystem}" == "systemd" %config %{_unitdir}/frr.service %{_sbindir}/frr From 362bca980cff0242ba6c99e340e4921be8102749 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 19 Apr 2017 18:39:49 -0700 Subject: [PATCH 18/96] redhat: fix duplicate Requires: line in spec file Signed-off-by: Martin Winter --- redhat/frr.spec.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index c78fc54b7e..d1684672f7 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -116,14 +116,13 @@ License: GPLv2+ Group: System Environment/Daemons Source0: http://www.frrouting.org/releases/frr/%{name}-%{frrversion}.tar.gz URL: http://www.frrouting.org -Requires: ncurses json-c Requires(pre): /sbin/install-info Requires(preun): /sbin/install-info Requires(post): /sbin/install-info BuildRequires: gcc texi2html texinfo patch libcap-devel groff BuildRequires: readline readline-devel ncurses ncurses-devel BuildRequires: json-c-devel bison >= 2.7 flex make -Requires: ncurses initscripts +Requires: ncurses json-c initscripts %if %{with_pam} BuildRequires: pam-devel Requires: pam From 6dc47763f4e54cb38bf611cac1594d1127389fad Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 19 Apr 2017 18:41:45 -0700 Subject: [PATCH 19/96] redhat: redirect reload function in frr init script to restart if reload script is not installed (fixes systemctl restart) Signed-off-by: Martin Winter --- redhat/frr.init | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/redhat/frr.init b/redhat/frr.init index c8c0cee407..ba3731e777 100755 --- a/redhat/frr.init +++ b/redhat/frr.init @@ -523,9 +523,17 @@ case "$1" in reload) # Just apply the commands that have changed, no restart necessary - [ ! -x "$RELOAD_SCRIPT" ] && echo "frr-reload script not available" && exit 0 + if [ ! -x "$RELOAD_SCRIPT" ]; then + echo "frr-reload script not installed - Executing full restart instead" + $0 restart + exit $? + fi NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}" - [ ! -r $NEW_CONFIG_FILE ] && echo "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1 + if [ ! -r $NEW_CONFIG_FILE ]; then + echo "Unable to read configuration file $NEW_CONFIG_FILE. Only supporting integrated config - Executing full restart instead" + $0 restart + exit $? + fi echo "Applying only incremental changes to running configuration from frr.conf" "$RELOAD_SCRIPT" --reload /etc/frr/frr.conf exit $? From f9e0332e10bd618dedff581d55326dd0515bdbe3 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Wed, 19 Apr 2017 18:45:03 -0700 Subject: [PATCH 20/96] redhat: fix README for rpm package build - correct requirements - add comment on bison 2.7 installation on CentOS 6 Signed-off-by: Martin Winter --- redhat/README.rpm_build.md | 55 +++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index 4513eda635..daa4a4861f 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -2,11 +2,17 @@ Building your own FRRouting RPM ====================================== (Tested on CentOS 6, CentOS 7 and Fedora 24.) -1. Install the following packages to build the RPMs: +1. On CentOS 6 (which doesn't provide a bison/automake/autoconf of a recent enough version): + - Check out ../doc/Building_FRR_on_CentOS6.md for details on installing + a bison/automake/autoconf to support frr building. + + Newer automake/autoconf/bison is only needed to build the rpm and is + **not** needed to install the binary rpm package + +2. Install the following packages to build the RPMs: yum install git autoconf automake libtool make gawk readline-devel \ - texinfo dejagnu net-snmp-devel groff rpm-build net-snmp-devel \ - libcap-devel texi2html bison flex + texinfo net-snmp-devel groff pkgconfig rpm-build json-c-devel pam-devel texi2html bison Additionally, on systems with systemd (CentOS 7, Fedora) @@ -18,11 +24,11 @@ Building your own FRRouting RPM how to install required version of autoconf, automake and bison. The versions in the common Repo are too old. -2. Checkout FRR under a **unpriviledged** user account +3. Checkout FRR under a **unpriviledged** user account git clone https://github.com/frrouting/frr.git frr -3. Run Bootstrap and make distribution tar.gz +4. Run Bootstrap and make distribution tar.gz cd frr ./bootstrap.sh @@ -32,7 +38,7 @@ Building your own FRRouting RPM Note: configure parameters are not important for the RPM building - except the `with-pkg-extra-version` if you want to give the RPM a specific name to mark your own unoffical build -4. Create RPM directory structure and populate with sources +5. Create RPM directory structure and populate with sources mkdir rpmbuild mkdir rpmbuild/SOURCES @@ -40,29 +46,28 @@ Building your own FRRouting RPM cp redhat/*.spec rpmbuild/SPECS/ cp frr*.tar.gz rpmbuild/SOURCES/ -5. Edit rpm/SPECS/frr.spec with configuration as needed +6. Edit rpm/SPECS/frr.spec with configuration as needed Look at the beginning of the file and adjust the following parameters to enable or disable features as required: - ################# frr configure options #################### + ############### FRRouting (FRR) configure options ################# # with-feature options - %{!?with_snmp: %global with_snmp 1 } - %{!?with_tcp_zebra: %global with_tcp_zebra 0 } - %{!?with_pam: %global with_pam 1 } - %{!?with_ospfclient: %global with_ospfclient 1 } - %{!?with_ospfapi: %global with_ospfapi 1 } - %{!?with_irdp: %global with_irdp 1 } - %{!?with_rtadv: %global with_rtadv 1 } - %{!?with_ldpd: %global with_ldpd 0 } - %{!?with_shared: %global with_shared 1 } - %{!?with_multipath: %global with_multipath 64 } - %{!?frr_user: %global frr_user frr } - %{!?vty_group: %global vty_group frrvt } - %{!?with_fpm: %global with_fpm 0 } - %{!?with_watchfrr: %global with_watchfrr 1 } - %{!?with_bgp_vnc: %global with_bgp_vnc 0 } - %{!?with_pimd: %global with_pimd 1 } + %{!?with_tcp_zebra: %global with_tcp_zebra 0 } + %{!?with_pam: %global with_pam 0 } + %{!?with_ospfclient: %global with_ospfclient 1 } + %{!?with_ospfapi: %global with_ospfapi 1 } + %{!?with_irdp: %global with_irdp 1 } + %{!?with_rtadv: %global with_rtadv 1 } + %{!?with_ldpd: %global with_ldpd 1 } + %{!?with_shared: %global with_shared 1 } + %{!?with_multipath: %global with_multipath 256 } + %{!?frr_user: %global frr_user frr } + %{!?vty_group: %global vty_group frrvty } + %{!?with_fpm: %global with_fpm 0 } + %{!?with_watchfrr: %global with_watchfrr 1 } + %{!?with_bgp_vnc: %global with_bgp_vnc 0 } + %{!?with_pimd: %global with_pimd 1 } -6. Build the RPM +7. Build the RPM rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/frr.spec From 20701ca33a643179f8d86c2f3bb06403e17c0602 Mon Sep 17 00:00:00 2001 From: smccroskey Date: Thu, 27 Apr 2017 19:39:24 -0700 Subject: [PATCH 21/96] redhat: use %initsystem check that works when chrooted `systemctl' returns different, non-useful output while in a chroot. Switch to checking if /sbin/init is a symlink to the systemd binary. With this change the build works in a mock chroot. Signed-off-by: Silas McCroskey --- redhat/frr.spec.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index d1684672f7..3f39f007e6 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -49,7 +49,7 @@ #### Check for systemd or init.d (upstart) # Check for init.d (upstart) as used in CentOS 6 or systemd (ie CentOS 7) -%{expand: %%global initsystem %(if [[ `/sbin/init --version 2> /dev/null` =~ upstart ]]; then echo upstart; elif [[ `systemctl` =~ -\.mount ]]; then echo systemd; fi)} +%{expand: %%global initsystem %(if [[ `/sbin/init --version 2> /dev/null` =~ upstart ]]; then echo upstart; elif [[ `file /sbin/init` =~ "symbolic link to \`../lib/systemd/systemd'" ]]; then echo systemd; fi)} # # If init system is systemd, then always disable watchfrr # From ee22bbae78d0a17c0f34da106f77ba2fd80e6b0d Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Fri, 12 May 2017 12:05:46 -0700 Subject: [PATCH 22/96] pimd: Fix to Tx S,G Join when SGRpt->Join state -Upon Rx (*,G) Join w/o SGRpt at RP, trigger (S,G) Join towards FHR, unset SGRpt flag from channel, add (*,G) oif to (S,G) entry. -Add I am not RP check to triger SGRpt on *,G path otherwise, send S,G Prune on SPT path from RP to FHR upon receving *,G Prune. -Upon Rx SGRpt receive, remove OIF(downstream where Prune received) from specific S,G. Testing Done: pim-smoke Ran 95 tests in 11790.552s FAILED (SKIP=10, failures=4) Signed-off-by: Chirag Shah --- pimd/pim_ifchannel.c | 23 ++++++----------------- pimd/pim_ifchannel.h | 2 +- pimd/pim_join.c | 39 +++++++++++++++++++++++++++++++-------- pimd/pim_rpf.c | 13 +++++++------ pimd/pim_upstream.c | 5 +++-- 5 files changed, 48 insertions(+), 34 deletions(-) diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index d46cc70b06..6f5e8f1493 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -1287,7 +1287,7 @@ pim_ifchannel_scan_forward_start (struct interface *new_ifp) * we get End of Message */ void -pim_ifchannel_set_star_g_join_state (struct pim_ifchannel *ch, int eom, uint8_t source_flags, uint8_t join) +pim_ifchannel_set_star_g_join_state (struct pim_ifchannel *ch, int eom, uint8_t source_flags, uint8_t join, uint8_t starg_alone) { struct pim_ifchannel *child; struct listnode *ch_node; @@ -1302,10 +1302,11 @@ pim_ifchannel_set_star_g_join_state (struct pim_ifchannel *ch, int eom, uint8_t for (ALL_LIST_ELEMENTS_RO (ch->sources, ch_node, child)) { /* Only *,G Join received and no (SG-RPT) prune. + eom = 1, only (W,G) join_alone is true, WC and RPT are set. Scan all S,G associated to G and if any SG-RPT remove the SG-RPT flag. */ - if (join && (source_flags & PIM_RPT_BIT_MASK) && + if (eom && starg_alone && (source_flags & PIM_RPT_BIT_MASK) && (source_flags & PIM_WILDCARD_BIT_MASK)) { if (PIM_IF_FLAG_TEST_S_G_RPT(child->flags)) @@ -1316,25 +1317,13 @@ pim_ifchannel_set_star_g_join_state (struct pim_ifchannel *ch, int eom, uint8_t if (up) { if (PIM_DEBUG_TRACE) - zlog_debug ("%s: clearing SGRpt flag, add inherit oif to up %s ", __PRETTY_FUNCTION__, up->sg_str); + zlog_debug ("%s: SGRpt flag is cleared, add inherit oif to up %s", + __PRETTY_FUNCTION__, up->sg_str); pim_channel_add_oif (up->channel_oil, ch->interface, PIM_OIF_FLAG_PROTO_STAR); + pim_ifchannel_ifjoin_switch(__PRETTY_FUNCTION__, child, PIM_IFJOIN_JOIN); } } } - /* Received SG-RPT Prune delete oif from S,G */ - else if (join == 0 && (source_flags & PIM_RPT_BIT_MASK) && - !(source_flags & PIM_WILDCARD_BIT_MASK)) - { - struct pim_upstream *up = child->upstream; - - PIM_IF_FLAG_SET_S_G_RPT(child->flags); - if (up) - { - if (PIM_DEBUG_TRACE) - zlog_debug ("%s: SGRpt Set, del inherit oif from up %s", __PRETTY_FUNCTION__, up->sg_str); - pim_channel_del_oif (up->channel_oil, ch->interface, PIM_OIF_FLAG_PROTO_STAR); - } - } if (!PIM_IF_FLAG_TEST_S_G_RPT(child->flags)) continue; diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h index 3ffb9190fb..4c804cc720 100644 --- a/pimd/pim_ifchannel.h +++ b/pimd/pim_ifchannel.h @@ -151,7 +151,7 @@ void pim_ifchannel_update_my_assert_metric(struct pim_ifchannel *ch); void pim_ifchannel_update_assert_tracking_desired(struct pim_ifchannel *ch); void pim_ifchannel_scan_forward_start (struct interface *new_ifp); -void pim_ifchannel_set_star_g_join_state (struct pim_ifchannel *ch, int eom, uint8_t source_flags, uint8_t join); +void pim_ifchannel_set_star_g_join_state (struct pim_ifchannel *ch, int eom, uint8_t source_flags, uint8_t join, uint8_t starg_alone); int pim_ifchannel_compare (struct pim_ifchannel *ch1, struct pim_ifchannel *ch2); diff --git a/pimd/pim_join.c b/pimd/pim_join.c index 828781a467..2da0b99353 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -215,7 +215,8 @@ int pim_joinprune_recv(struct interface *ifp, uint16_t msg_num_joined_sources; uint16_t msg_num_pruned_sources; int source; - struct pim_ifchannel *ch = NULL; + struct pim_ifchannel *starg_ch = NULL, *sg_ch = NULL; + uint8_t starg_alone = 0; memset (&sg, 0, sizeof (struct prefix_sg)); addr_offset = pim_parse_addr_group (&sg, @@ -274,9 +275,10 @@ int pim_joinprune_recv(struct interface *ifp, if (sg.src.s_addr == INADDR_ANY) { - ch = pim_ifchannel_find (ifp, &sg); - if (ch) - pim_ifchannel_set_star_g_join_state (ch, 0, msg_source_flags, 1); + starg_alone = 1; + starg_ch = pim_ifchannel_find (ifp, &sg); + if (starg_ch) + pim_ifchannel_set_star_g_join_state (starg_ch, 0, msg_source_flags, 1, starg_alone); } } @@ -289,16 +291,33 @@ int pim_joinprune_recv(struct interface *ifp, return -8; } - buf += addr_offset; + sg_ch = pim_ifchannel_find (ifp, &sg); + buf += addr_offset; + starg_alone = 0; recv_prune(ifp, neigh, msg_holdtime, msg_upstream_addr.u.prefix4, &sg, msg_source_flags); + + /* Received SG-RPT Prune delete oif from specific S,G */ + if (starg_ch && sg_ch && (msg_source_flags & PIM_RPT_BIT_MASK) + && !(msg_source_flags & PIM_WILDCARD_BIT_MASK)) + { + struct pim_upstream *up = sg_ch->upstream; + PIM_IF_FLAG_SET_S_G_RPT(sg_ch->flags); + if (up) + { + if (PIM_DEBUG_TRACE) + zlog_debug ("%s: SGRpt flag is set, del inherit oif from up %s", + __PRETTY_FUNCTION__, up->sg_str); + pim_channel_del_oif (up->channel_oil, starg_ch->interface, PIM_OIF_FLAG_PROTO_STAR); + } + } } - if (ch) - pim_ifchannel_set_star_g_join_state (ch, 1, msg_source_flags, 0); - ch = NULL; + if (starg_ch) + pim_ifchannel_set_star_g_join_state (starg_ch, 1, msg_source_flags, 0, starg_alone); + starg_ch = NULL; } /* scan groups */ return 0; @@ -502,6 +521,10 @@ int pim_joinprune_send(struct pim_rpf *rpf, packet_size += group_size; pim_msg_build_jp_groups (grp, group, group_size); + if (PIM_DEBUG_PIM_TRACE) + zlog_debug ("%s: interface %s num_joins %u num_prunes %u", __PRETTY_FUNCTION__, + rpf->source_nexthop.interface->name, ntohs(grp->joins), ntohs (grp->prunes)); + grp = (struct pim_jp_groups *)curr_ptr; if (packet_left < sizeof (struct pim_jp_groups) || msg->num_groups == 255) { diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index f46ebfb979..d16106dec8 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -244,17 +244,18 @@ enum pim_rpf_result pim_rpf_update(struct pim_upstream *up, struct pim_rpf *old, { return PIM_RPF_FAILURE; } - } + } rpf->rpf_addr.family = AF_INET; rpf->rpf_addr.u.prefix4 = pim_rpf_find_rpf_addr(up); - if (pim_rpf_addr_is_inaddr_any(rpf) && PIM_DEBUG_ZEBRA) { - /* RPF'(S,G) not found */ - zlog_debug("%s %s: RPF'%s not found: won't send join upstream", + if (pim_rpf_addr_is_inaddr_any(rpf) && PIM_DEBUG_ZEBRA) + { + /* RPF'(S,G) not found */ + zlog_debug("%s %s: RPF'%s not found: won't send join upstream", __FILE__, __PRETTY_FUNCTION__, up->sg_str); - /* warning only */ - } + /* warning only */ + } /* detect change in pim_nexthop */ if (nexthop_mismatch(&rpf->source_nexthop, &saved.source_nexthop)) { diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 6fadfc2f29..af9c3913a5 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -582,8 +582,9 @@ pim_upstream_switch(struct pim_upstream *up, if (old_state == PIM_UPSTREAM_JOINED) pim_msdp_up_join_state_changed(up); - /* IHR, Trigger SGRpt on *,G IIF to prune S,G from RPT */ - if (pim_upstream_is_sg_rpt(up) && up->parent) + /* IHR, Trigger SGRpt on *,G IIF to prune S,G from RPT towards RP. + If I am RP for G then send S,G prune to its IIF. */ + if (pim_upstream_is_sg_rpt(up) && up->parent && !I_am_RP(up->sg.grp)) { if (PIM_DEBUG_PIM_TRACE_DETAIL) zlog_debug ("%s: *,G IIF %s S,G IIF %s ", __PRETTY_FUNCTION__, From fe881ec5a19f2d8b8d3582a76a7237ed1a8fe928 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 22 May 2017 04:04:35 -0700 Subject: [PATCH 23/96] redhat: fix previous merge. initsystem detection should now work for mock builds and native builds on systemd based systems Signed-off-by: Martin Winter --- redhat/frr.spec.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 3f39f007e6..133ed1fcd0 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -49,7 +49,7 @@ #### Check for systemd or init.d (upstart) # Check for init.d (upstart) as used in CentOS 6 or systemd (ie CentOS 7) -%{expand: %%global initsystem %(if [[ `/sbin/init --version 2> /dev/null` =~ upstart ]]; then echo upstart; elif [[ `file /sbin/init` =~ "symbolic link to \`../lib/systemd/systemd'" ]]; then echo systemd; fi)} +%{expand: %%global initsystem %(if [[ `/sbin/init --version 2> /dev/null` =~ upstart ]]; then echo upstart; elif [[ `file /sbin/init` =~ "symbolic link to \`../lib/systemd/systemd'" ]]; then echo systemd; elif [[ `systemctl` =~ -\.mount ]]; then echo systemd; fi)} # # If init system is systemd, then always disable watchfrr # @@ -539,7 +539,7 @@ rm -rf %{buildroot} %endif %changelog -* Thu Apr 17 2017 Martin Winter - %{version} +* Mon Apr 17 2017 Martin Winter - %{version} - new subpackage frr-pythontools with python 2.7 restart script - remove PIMd from CentOS/RedHat 6 RPM packages (won't work - too old) - converted to single frr init script (not per daemon) based on debian init script From da4b95e740dcd919d054c66a084a60f0e7dcb5ef Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 22 May 2017 04:07:22 -0700 Subject: [PATCH 24/96] redhat: Disallow reload function for unsupported systems Before the change, a reload triggered a restart if the python reload script wasn't installed or for non-integrated configs With this change, the reload is rejected with an error in this case (and suggests the installation of the python script package) Signed-off-by: Martin Winter --- redhat/frr.init | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/redhat/frr.init b/redhat/frr.init index ba3731e777..96c0a833af 100755 --- a/redhat/frr.init +++ b/redhat/frr.init @@ -524,15 +524,13 @@ case "$1" in reload) # Just apply the commands that have changed, no restart necessary if [ ! -x "$RELOAD_SCRIPT" ]; then - echo "frr-reload script not installed - Executing full restart instead" - $0 restart - exit $? + echo "frr-reload - reload not supported. Use restart or install frr-pythontools package" + exit 1 fi NEW_CONFIG_FILE="${2:-$C_PATH/frr.conf}" if [ ! -r $NEW_CONFIG_FILE ]; then - echo "Unable to read configuration file $NEW_CONFIG_FILE. Only supporting integrated config - Executing full restart instead" - $0 restart - exit $? + echo "Unable to read configuration file $NEW_CONFIG_FILE. Only supporting integrated config" + exit 1 fi echo "Applying only incremental changes to running configuration from frr.conf" "$RELOAD_SCRIPT" --reload /etc/frr/frr.conf From b3dfccc87b3d2693583a1bccb5a41ac29d46bd36 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 22 May 2017 04:08:44 -0700 Subject: [PATCH 25/96] redhat: Fix missing packages in requirements section of README Signed-off-by: Martin Winter --- redhat/README.rpm_build.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index daa4a4861f..d2b0814364 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -12,7 +12,8 @@ Building your own FRRouting RPM 2. Install the following packages to build the RPMs: yum install git autoconf automake libtool make gawk readline-devel \ - texinfo net-snmp-devel groff pkgconfig rpm-build json-c-devel pam-devel texi2html bison + texinfo net-snmp-devel groff pkgconfig rpm-build json-c-devel \ + pam-devel texi2html bison libcap-devel flex Additionally, on systems with systemd (CentOS 7, Fedora) From eee6117a6226a353f0d531661dec6d3f6641e6c4 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Fri, 26 May 2017 15:13:08 +0000 Subject: [PATCH 26/96] bgpd: fix issue with ipv6 ecmp with vrfs Problem reported by customer that ipv6 wasn't installing ecmp paths when using vrfs. Found a vrf-unware call in bgp_zebra_announce that was the culprit. Testing of the fix looks good. Ticket: CM-15545 Signed-off-by: Don Slice --- bgpd/bgp_zebra.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index d07fc65bdf..1998dabc24 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1509,7 +1509,8 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, if (!ifindex) { if (mpinfo->peer->conf_if || mpinfo->peer->ifname) - ifindex = ifname2ifindex (mpinfo->peer->conf_if ? mpinfo->peer->conf_if : mpinfo->peer->ifname); + ifindex = ifname2ifindex_vrf (mpinfo->peer->conf_if ? mpinfo->peer->conf_if : + mpinfo->peer->ifname, bgp->vrf_id); else if (mpinfo->peer->nexthop.ifp) ifindex = mpinfo->peer->nexthop.ifp->ifindex; } From 9e8df9882c7c3fcc80aba2923cafd8d3188d83ad Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Tue, 23 May 2017 13:23:04 -0500 Subject: [PATCH 27/96] vtysh: fix a compile error when user/group are disabled If FRR is configured explicilty with --disable-user and --disable-group, FRR_USER and FRR_GROUP will not be defined and can be safely skipped in vtysh. Signed-off-by: Jafar Al-Gharaibeh --- vtysh/vtysh.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 24ac9675e8..17b95707d6 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2488,6 +2488,7 @@ vtysh_write_config_integrated(void) err++; } +#ifdef FRR_USER pwentry = getpwnam (FRR_USER); if (pwentry) uid = pwentry->pw_uid; @@ -2496,7 +2497,8 @@ vtysh_write_config_integrated(void) printf ("%% Warning: could not look up user \"%s\"\n", FRR_USER); err++; } - +#endif +#ifdef FRR_GROUP grentry = getgrnam (FRR_GROUP); if (grentry) gid = grentry->gr_gid; @@ -2505,6 +2507,7 @@ vtysh_write_config_integrated(void) printf ("%% Warning: could not look up group \"%s\"\n", FRR_GROUP); err++; } +#endif if (!fstat (fd, &st)) { From 3c5211b4c9c1fef0ba0b540f2504d4d09488012e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 25 May 2017 13:53:50 -0400 Subject: [PATCH 28/96] vtysh: Add back some missing bgp commands Signed-off-by: Donald Sharp --- vtysh/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index a8dbb8d71d..9a5008f9d7 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -50,6 +50,7 @@ vtysh_scan += $(top_srcdir)/bgpd/bgp_dump.c vtysh_scan += $(top_srcdir)/bgpd/bgp_evpn_vty.c vtysh_scan += $(top_srcdir)/bgpd/bgp_filter.c vtysh_scan += $(top_srcdir)/bgpd/bgp_mplsvpn.c +vtysh_scan += $(top_srcdir)/bgpd/bgp_nexthop.c vtysh_scan += $(top_srcdir)/bgpd/bgp_route.c vtysh_scan += $(top_srcdir)/bgpd/bgp_routemap.c vtysh_scan += $(top_srcdir)/bgpd/bgp_vty.c From 75bcb3558d25b8ca7d3383f5c2c648d0aceae103 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 10 May 2017 18:09:49 +0000 Subject: [PATCH 29/96] lib: remove select() poll() is present on every supported platform and does not have an upper limit on file descriptors. Signed-off-by: Quentin Young [DL: split off from AWAKEN() change] --- lib/thread.c | 303 +++++++++++++-------------------------------------- lib/thread.h | 19 +--- 2 files changed, 75 insertions(+), 247 deletions(-) diff --git a/lib/thread.c b/lib/thread.c index ccb635a87d..7f58aea789 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -379,12 +379,11 @@ thread_master_create (void) rv->handle_signals = true; rv->owner = pthread_self(); -#if defined(HAVE_POLL_CALL) rv->handler.pfdsize = rv->fd_limit; rv->handler.pfdcount = 0; rv->handler.pfds = XCALLOC (MTYPE_THREAD_MASTER, sizeof (struct pollfd) * rv->handler.pfdsize); -#endif + return rv; } @@ -419,18 +418,6 @@ thread_list_delete (struct thread_list *list, struct thread *thread) return thread; } -static void -thread_delete_fd (struct thread **thread_array, struct thread *thread) -{ - thread_array[thread->u.fd] = NULL; -} - -static void -thread_add_fd (struct thread **thread_array, struct thread *thread) -{ - thread_array[thread->u.fd] = thread; -} - /* Thread list is empty or not. */ static int thread_empty (struct thread_list *list) @@ -544,9 +531,7 @@ thread_master_free (struct thread_master *m) thread_queue_free (m, m->background); pthread_mutex_destroy (&m->mtx); -#if defined(HAVE_POLL_CALL) XFREE (MTYPE_THREAD_MASTER, m->handler.pfds); -#endif XFREE (MTYPE_THREAD_MASTER, m); pthread_mutex_lock (&cpu_record_mtx); @@ -646,58 +631,9 @@ thread_get (struct thread_master *m, u_char type, return thread; } -#if defined (HAVE_POLL_CALL) - -#define fd_copy_fd_set(X) (X) - -/* generic add thread function */ -static struct thread * -generic_thread_add(struct thread_master *m, int (*func) (struct thread *), - void *arg, int fd, int dir, debugargdef) -{ - struct thread *thread; - - u_char type; - short int event; - - if (dir == THREAD_READ) - { - event = (POLLIN | POLLHUP); - type = THREAD_READ; - } - else - { - event = (POLLOUT | POLLHUP); - type = THREAD_WRITE; - } - - nfds_t queuepos = m->handler.pfdcount; - nfds_t i=0; - for (i=0; ihandler.pfdcount; i++) - if (m->handler.pfds[i].fd == fd) - { - queuepos = i; - break; - } - - /* is there enough space for a new fd? */ - assert (queuepos < m->handler.pfdsize); - - thread = thread_get (m, type, func, arg, debugargpass); - m->handler.pfds[queuepos].fd = fd; - m->handler.pfds[queuepos].events |= event; - if (queuepos == m->handler.pfdcount) - m->handler.pfdcount++; - - return thread; -} -#else - -#define fd_copy_fd_set(X) (X) -#endif - static int -fd_select (struct thread_master *m, int size, thread_fd_set *read, thread_fd_set *write, thread_fd_set *except, struct timeval *timer_wait) +fd_poll (struct thread_master *m, struct pollfd *pfds, nfds_t pfdsize, + nfds_t count, struct timeval *timer_wait) { int num; @@ -714,7 +650,6 @@ fd_select (struct thread_master *m, int size, thread_fd_set *read, thread_fd_set * no event is detected. If the value is zero, the behavior is default. */ -#if defined(HAVE_POLL_CALL) int timeout = -1; if (timer_wait != NULL && m->selectpoll_timeout == 0) // use the default value @@ -725,57 +660,10 @@ fd_select (struct thread_master *m, int size, thread_fd_set *read, thread_fd_set timeout = 0; num = poll (m->handler.pfds, m->handler.pfdcount + m->handler.pfdcountsnmp, timeout); -#else - struct timeval timeout; - - if (m->selectpoll_timeout > 0) // use the user's timeout - { - timeout.tv_sec = m->selectpoll_timeout / 1000; - timeout.tv_usec = (m->selectpoll_timeout % 1000) * 1000; - timer_wait = &timeout; - } - else if (m->selectpoll_timeout < 0) // effect a poll (return immediately) - { - timeout.tv_sec = 0; - timeout.tv_usec = 0; - timer_wait = &timeout; - } - num = select (size, read, write, except, timer_wait); -#endif return num; } -static int -fd_is_set (struct thread *thread, thread_fd_set *fdset, int pos) -{ -#if defined(HAVE_POLL_CALL) - return 1; -#else - return FD_ISSET (THREAD_FD (thread), fdset); -#endif -} - -static int -fd_clear_read_write (struct thread *thread) -{ -#if !defined(HAVE_POLL_CALL) - thread_fd_set *fdset = NULL; - int fd = THREAD_FD (thread); - - if (thread->type == THREAD_READ) - fdset = &thread->master->handler.readfd; - else - fdset = &thread->master->handler.writefd; - - if (!FD_ISSET (fd, fdset)) - return 0; - - FD_CLR (fd, fdset); -#endif - return 1; -} - /* Add new read thread. */ struct thread * funcname_thread_add_read_write (int dir, struct thread_master *m, @@ -792,32 +680,26 @@ funcname_thread_add_read_write (int dir, struct thread_master *m, return NULL; } -#if defined (HAVE_POLL_CALL) - thread = generic_thread_add(m, func, arg, fd, dir, debugargpass); -#else - if (fd >= FD_SETSIZE) - { - zlog_err ("File descriptor %d is >= FD_SETSIZE (%d). Please recompile" - "with --enable-poll=yes", fd, FD_SETSIZE); - assert (fd < FD_SETSIZE && !"fd >= FD_SETSIZE"); - } - thread_fd_set *fdset = NULL; - if (dir == THREAD_READ) - fdset = &m->handler.readfd; - else - fdset = &m->handler.writefd; + /* default to a new pollfd */ + nfds_t queuepos = m->handler.pfdcount; - if (FD_ISSET (fd, fdset)) - { - zlog_warn ("There is already %s fd [%d]", - (dir == THREAD_READ) ? "read" : "write", fd); - } - else - { - FD_SET (fd, fdset); - thread = thread_get (m, dir, func, arg, debugargpass); - } -#endif + /* if we already have a pollfd for our file descriptor, find and use it */ + for (nfds_t i = 0; i < m->handler.pfdcount; i++) + if (m->handler.pfds[i].fd == fd) + { + queuepos = i; + break; + } + + assert (queuepos < m->handler.pfdsize); + + thread = thread_get (m, dir, func, arg, debugargpass); + + m->handler.pfds[queuepos].fd = fd; + m->handler.pfds[queuepos].events |= (dir == THREAD_READ ? POLLIN : POLLOUT); + + if (queuepos == m->handler.pfdcount) + m->handler.pfdcount++; if (thread) { @@ -825,9 +707,9 @@ funcname_thread_add_read_write (int dir, struct thread_master *m, { thread->u.fd = fd; if (dir == THREAD_READ) - thread_add_fd (m->read, thread); + m->read[thread->u.fd] = thread; else - thread_add_fd (m->write, thread); + m->write[thread->u.fd] = thread; } pthread_mutex_unlock (&thread->mtx); @@ -995,10 +877,7 @@ funcname_thread_add_event (struct thread_master *m, static void thread_cancel_read_or_write (struct thread *thread, short int state) { -#if defined(HAVE_POLL_CALL) - nfds_t i; - - for (i=0;imaster->handler.pfdcount;++i) + for (nfds_t i = 0; i < thread->master->handler.pfdcount; ++i) if (thread->master->handler.pfds[i].fd == thread->u.fd) { thread->master->handler.pfds[i].events &= ~(state); @@ -1013,9 +892,6 @@ thread_cancel_read_or_write (struct thread *thread, short int state) return; } } -#endif - - fd_clear_read_write (thread); } /** @@ -1039,19 +915,11 @@ thread_cancel (struct thread *thread) switch (thread->type) { case THREAD_READ: -#if defined (HAVE_POLL_CALL) thread_cancel_read_or_write (thread, POLLIN | POLLHUP); -#else - thread_cancel_read_or_write (thread, 0); -#endif thread_array = thread->master->read; break; case THREAD_WRITE: -#if defined (HAVE_POLL_CALL) thread_cancel_read_or_write (thread, POLLOUT | POLLHUP); -#else - thread_cancel_read_or_write (thread, 0); -#endif thread_array = thread->master->write; break; case THREAD_TIMER: @@ -1082,7 +950,7 @@ thread_cancel (struct thread *thread) } else if (thread_array) { - thread_delete_fd (thread_array, thread); + thread_array[thread->u.fd] = NULL; } else { @@ -1168,7 +1036,7 @@ thread_timer_wait (struct pqueue *queue, struct timeval *timer_val) static struct thread * thread_run (struct thread_master *m, struct thread *thread, - struct thread *fetch) + struct thread *fetch) { *fetch = *thread; thread_add_unuse (m, thread); @@ -1176,7 +1044,8 @@ thread_run (struct thread_master *m, struct thread *thread, } static int -thread_process_fds_helper (struct thread_master *m, struct thread *thread, thread_fd_set *fdset, short int state, int pos) +thread_process_io_helper (struct thread_master *m, struct thread *thread, + short state, int pos) { struct thread **thread_array; @@ -1188,76 +1057,60 @@ thread_process_fds_helper (struct thread_master *m, struct thread *thread, threa else thread_array = m->write; - if (fd_is_set (thread, fdset, pos)) - { - fd_clear_read_write (thread); - thread_delete_fd (thread_array, thread); - thread_list_add (&m->ready, thread); - thread->type = THREAD_READY; -#if defined(HAVE_POLL_CALL) - thread->master->handler.pfds[pos].events &= ~(state); -#endif - return 1; - } - return 0; + thread_array[thread->u.fd] = NULL; + thread_list_add (&m->ready, thread); + thread->type = THREAD_READY; + /* if another pthread scheduled this file descriptor for the event we're + * responding to, no problem; we're getting to it now */ + thread->master->handler.pfds[pos].events &= ~(state); + return 1; } -#if defined(HAVE_POLL_CALL) - -/* check poll events */ static void -check_pollfds(struct thread_master *m, fd_set *readfd, int num) +thread_process_io (struct thread_master *m, struct pollfd *pfds, + unsigned int num, unsigned int count) { - nfds_t i = 0; - int ready = 0; - for (i = 0; i < m->handler.pfdcount && ready < num ; ++i) + unsigned int ready = 0; + + for (nfds_t i = 0; i < count && ready < num ; ++i) { - /* no event for current fd? immideatly continue */ - if(m->handler.pfds[i].revents == 0) + /* no event for current fd? immediately continue */ + if (pfds[i].revents == 0) continue; ready++; - /* POLLIN / POLLOUT process event */ - if (m->handler.pfds[i].revents & (POLLIN | POLLHUP)) - thread_process_fds_helper(m, m->read[m->handler.pfds[i].fd], NULL, POLLIN, i); - if (m->handler.pfds[i].revents & POLLOUT) - thread_process_fds_helper(m, m->write[m->handler.pfds[i].fd], NULL, POLLOUT, i); + /* Unless someone has called thread_cancel from another pthread, the only + * thing that could have changed in m->handler.pfds while we were + * asleep is the .events field in a given pollfd. Barring thread_cancel() + * that value should be a superset of the values we have in our copy, so + * there's no need to update it. Similarily, barring deletion, the fd + * should still be a valid index into the master's pfds. */ + if (pfds[i].revents & (POLLIN | POLLHUP)) + thread_process_io_helper(m, m->read[pfds[i].fd], POLLIN, i); + if (pfds[i].revents & POLLOUT) + thread_process_io_helper(m, m->write[pfds[i].fd], POLLOUT, i); - /* remove fd from list on POLLNVAL */ - if (m->handler.pfds[i].revents & POLLNVAL) + /* if one of our file descriptors is garbage, remove the same from + * both pfds + update sizes and index */ + if (pfds[i].revents & POLLNVAL) { - memmove(m->handler.pfds+i, - m->handler.pfds+i+1, - (m->handler.pfdsize-i-1) * sizeof(struct pollfd)); - m->handler.pfdcount--; - i--; + memmove (m->handler.pfds + i, + m->handler.pfds + i + 1, + (m->handler.pfdcount - i - 1) * sizeof(struct pollfd)); + m->handler.pfdcount--; + + memmove (pfds + i, pfds + i + 1, + (count - i - 1) * sizeof(struct pollfd)); + count--; + i--; } - else - m->handler.pfds[i].revents = 0; } } -#endif - -static void -thread_process_fds (struct thread_master *m, thread_fd_set *rset, thread_fd_set *wset, int num) -{ -#if defined (HAVE_POLL_CALL) - check_pollfds (m, rset, num); -#else - int ready = 0, index; - - for (index = 0; index < m->fd_limit && ready < num; ++index) - { - ready += thread_process_fds_helper (m, m->read[index], rset, 0, 0); - ready += thread_process_fds_helper (m, m->write[index], wset, 0, 0); - } -#endif -} /* Add all timers that have popped to the ready list. */ static unsigned int -thread_timer_process (struct pqueue *queue, struct timeval *timenow) +thread_process_timers (struct pqueue *queue, struct timeval *timenow) { struct thread *thread; unsigned int ready = 0; @@ -1300,9 +1153,6 @@ struct thread * thread_fetch (struct thread_master *m, struct thread *fetch) { struct thread *thread; - thread_fd_set readfd; - thread_fd_set writefd; - thread_fd_set exceptfd; struct timeval now; struct timeval timer_val = { .tv_sec = 0, .tv_usec = 0 }; struct timeval timer_val_bg; @@ -1338,13 +1188,6 @@ thread_fetch (struct thread_master *m, struct thread *fetch) /* Normal event are the next highest priority. */ thread_process (&m->event); - /* Structure copy. */ -#if !defined(HAVE_POLL_CALL) - readfd = fd_copy_fd_set(m->handler.readfd); - writefd = fd_copy_fd_set(m->handler.writefd); - exceptfd = fd_copy_fd_set(m->handler.exceptfd); -#endif - /* Calculate select wait timer if nothing else to do */ if (m->ready.count == 0) { @@ -1362,7 +1205,7 @@ thread_fetch (struct thread_master *m, struct thread *fetch) timer_wait = &timer_val; } - num = fd_select (m, FD_SETSIZE, &readfd, &writefd, &exceptfd, timer_wait); + num = fd_poll (m, pfds, m->handler.pfdsize, count, timer_wait); /* Signals should get quick treatment */ if (num < 0) @@ -1372,20 +1215,20 @@ thread_fetch (struct thread_master *m, struct thread *fetch) pthread_mutex_unlock (&m->mtx); continue; /* signal received - process it */ } - zlog_warn ("select() error: %s", safe_strerror (errno)); + zlog_warn ("poll() error: %s", safe_strerror (errno)); pthread_mutex_unlock (&m->mtx); return NULL; } /* Check foreground timers. Historically, they have had higher - priority than I/O threads, so let's push them onto the ready - list in front of the I/O threads. */ + * priority than I/O threads, so let's push them onto the ready + * list in front of the I/O threads. */ monotime(&now); - thread_timer_process (m->timer, &now); + thread_process_timers (m->timer, &now); /* Got IO, process it */ if (num > 0) - thread_process_fds (m, &readfd, &writefd, num); + thread_process_io (m, pfds, num, count); #if 0 /* If any threads were made ready above (I/O or foreground timer), @@ -1403,7 +1246,7 @@ thread_fetch (struct thread_master *m, struct thread *fetch) #endif /* Background timer/events, lowest priority */ - thread_timer_process (m->background, &now); + thread_process_timers (m->background, &now); if ((thread = thread_trim_head (&m->ready)) != NULL) { diff --git a/lib/thread.h b/lib/thread.h index 7e79eb38dc..e40bf64855 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -22,8 +22,9 @@ #define _ZEBRA_THREAD_H #include -#include "monotime.h" #include +#include +#include "monotime.h" struct rusage_t { @@ -44,14 +45,6 @@ struct thread_list struct pqueue; -/* - * Abstract it so we can use different methodologies to - * select on data. - */ -typedef fd_set thread_fd_set; - -#if defined(HAVE_POLL_CALL) -#include struct fd_handler { /* number of pfd stored in pfds */ @@ -62,14 +55,6 @@ struct fd_handler nfds_t pfdsize; struct pollfd *pfds; }; -#else -struct fd_handler -{ - fd_set readfd; - fd_set writefd; - fd_set exceptfd; -}; -#endif /* Master of the theads. */ struct thread_master From 3bf2673b3094727edee168f4b5a93095420f6b23 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 10 May 2017 18:09:49 +0000 Subject: [PATCH 30/96] lib: allow pthreads to poke poll() When scheduling a task onto a thread master owned by another pthread, we need to lock the thread master's mutex. However, if the pthread which owns that thread master is in poll(), we could be stuck waiting for a very long time. To solve this, we copy all data poll() needs and unlock during poll(). To break the target pthread out of poll(), thread_master has gained a pipe whose reading end is passed into poll(). After an event that requires immediate action by the target pthread, a byte is written into the pipe in order to wake it up. Signed-off-by: Quentin Young [DL: split off from select() removal] --- lib/thread.c | 66 ++++++++++++++++++++++++++++++++++++++-------------- lib/thread.h | 1 + 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/lib/thread.c b/lib/thread.c index 7f58aea789..4077358dcf 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -30,6 +30,7 @@ #include "pqueue.h" #include "command.h" #include "sigevent.h" +#include "network.h" DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread") DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master") @@ -40,6 +41,12 @@ DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats") #include #endif +#define AWAKEN(m) \ + do { \ + static unsigned char wakebyte = 0x01; \ + write (m->io_pipe[1], &wakebyte, 1); \ + } while (0); + static pthread_mutex_t cpu_record_mtx = PTHREAD_MUTEX_INITIALIZER; static struct hash *cpu_record = NULL; @@ -378,6 +385,8 @@ thread_master_create (void) rv->spin = true; rv->handle_signals = true; rv->owner = pthread_self(); + pipe (rv->io_pipe); + set_nonblocking (rv->io_pipe[0]); rv->handler.pfdsize = rv->fd_limit; rv->handler.pfdcount = 0; @@ -530,6 +539,8 @@ thread_master_free (struct thread_master *m) thread_list_free (m, &m->unuse); thread_queue_free (m, m->background); pthread_mutex_destroy (&m->mtx); + close (m->io_pipe[0]); + close (m->io_pipe[1]); XFREE (MTYPE_THREAD_MASTER, m->handler.pfds); XFREE (MTYPE_THREAD_MASTER, m); @@ -635,23 +646,20 @@ static int fd_poll (struct thread_master *m, struct pollfd *pfds, nfds_t pfdsize, nfds_t count, struct timeval *timer_wait) { - int num; - - /* If timer_wait is null here, that means either select() or poll() should - * block indefinitely, unless the thread_master has overriden it. select() - * and poll() differ in the timeout values they interpret as an indefinite - * block; select() requires a null pointer, while poll takes a millisecond - * value of -1. - * - * The thread_master owner has the option of overriding the default behavior - * by setting ->selectpoll_timeout. If the value is positive, it specifies - * the maximum number of milliseconds to wait. If the timeout is -1, it - * specifies that we should never wait and always return immediately even if - * no event is detected. If the value is zero, the behavior is default. - */ + if (count == 0) + return 0; + /* If timer_wait is null here, that means poll() should block indefinitely, + * unless the thread_master has overriden it by setting ->selectpoll_timeout. + * If the value is positive, it specifies the maximum number of milliseconds + * to wait. If the timeout is -1, it specifies that we should never wait and + * always return immediately even if no event is detected. If the value is + * zero, the behavior is default. */ int timeout = -1; + /* number of file descriptors with events */ + int num; + if (timer_wait != NULL && m->selectpoll_timeout == 0) // use the default value timeout = (timer_wait->tv_sec*1000) + (timer_wait->tv_usec/1000); else if (m->selectpoll_timeout > 0) // use the user's timeout @@ -659,7 +667,17 @@ fd_poll (struct thread_master *m, struct pollfd *pfds, nfds_t pfdsize, else if (m->selectpoll_timeout < 0) // effect a poll (return immediately) timeout = 0; - num = poll (m->handler.pfds, m->handler.pfdcount + m->handler.pfdcountsnmp, timeout); + /* add poll pipe poker */ + assert (count + 1 < pfdsize); + pfds[count].fd = m->io_pipe[0]; + pfds[count].events = POLLIN; + pfds[count].revents = 0x00; + + num = poll (pfds, count + 1, timeout); + + static unsigned char trash[64]; + if (num > 0 && pfds[count].revents != 0 && num--) + while (read (m->io_pipe[0], &trash, sizeof (trash)) > 0); return num; } @@ -691,7 +709,8 @@ funcname_thread_add_read_write (int dir, struct thread_master *m, break; } - assert (queuepos < m->handler.pfdsize); + /* make sure we have room for this fd + pipe poker fd */ + assert (queuepos + 1 < m->handler.pfdsize); thread = thread_get (m, dir, func, arg, debugargpass); @@ -761,6 +780,8 @@ funcname_thread_add_timer_timeval (struct thread_master *m, } } pthread_mutex_unlock (&thread->mtx); + + AWAKEN (m); } pthread_mutex_unlock (&m->mtx); @@ -868,6 +889,8 @@ funcname_thread_add_event (struct thread_master *m, *t_ptr = thread; thread->ref = t_ptr; } + + AWAKEN (m); } pthread_mutex_unlock (&m->mtx); @@ -1205,7 +1228,16 @@ thread_fetch (struct thread_master *m, struct thread *fetch) timer_wait = &timer_val; } - num = fd_poll (m, pfds, m->handler.pfdsize, count, timer_wait); + /* copy pollfds so we can unlock during blocking calls to poll() */ + struct pollfd pfds[m->handler.pfdsize]; + unsigned int count = m->handler.pfdcount + m->handler.pfdcountsnmp; + memcpy (pfds, m->handler.pfds, count * sizeof (struct pollfd)); + + pthread_mutex_unlock (&m->mtx); + { + num = fd_poll (m, pfds, m->handler.pfdsize, count, timer_wait); + } + pthread_mutex_lock (&m->mtx); /* Signals should get quick treatment */ if (num < 0) diff --git a/lib/thread.h b/lib/thread.h index e40bf64855..753aa41ffd 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -66,6 +66,7 @@ struct thread_master struct thread_list ready; struct thread_list unuse; struct pqueue *background; + int io_pipe[2]; int fd_limit; struct fd_handler handler; unsigned long alloc; From a772d6eae61ccb090de8dda5df43e2770879baa0 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 18 May 2017 18:14:52 +0000 Subject: [PATCH 31/96] lib: missed AWAKEN in r/w thread scheduler Signed-off-by: Quentin Young --- lib/thread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/thread.c b/lib/thread.c index 4077358dcf..0188ae6c0b 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -738,6 +738,8 @@ funcname_thread_add_read_write (int dir, struct thread_master *m, thread->ref = t_ptr; } } + + AWAKEN (m); } pthread_mutex_unlock (&m->mtx); From f040db8f7ab0b4c49ea8f5ae781d1629e3db8723 Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Tue, 30 May 2017 15:02:34 +0000 Subject: [PATCH 32/96] bgpd: resolve IPv6 LL and Global nexthop issue Signed-off-by: Daniel Walton --- bgpd/bgp_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5c18483c9b..b3e1f8b27e 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1455,7 +1455,7 @@ subgroup_announce_check (struct bgp_node *rn, struct bgp_info *ri, #define NEXTHOP_IS_V6 (\ (safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\ - (p->family == AF_INET6 || peer_cap_enhe(peer, AFI_IP6, safi))) || \ + (p->family == AF_INET6 || peer_cap_enhe(peer, afi, safi))) || \ ((safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN) &&\ attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN)) From ad9a08250169daeb163a951c491cdc740afda34c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 31 May 2017 16:24:04 +0200 Subject: [PATCH 33/96] build: fix pcreposix check pcreposix_regexec doesn't exist (anymore?), it's just regexec. Also, if the user specifies --enable-pcreposix, not finding it is a fatal error. Signed-off-by: David Lamparter --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9b4af1f2bf..9b0f627362 100755 --- a/configure.ac +++ b/configure.ac @@ -1271,8 +1271,9 @@ dnl --------------------------- dnl check system has PCRE regexp dnl --------------------------- if test "x$enable_pcreposix" = "xyes"; then - AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no - AC_MSG_WARN([*** falling back to other regex library ***]) ]) + AC_CHECK_LIB(pcreposix, regexec, [], [ + AC_MSG_ERROR([--enable-pcreposix given but unable to find libpcreposix]) + ]) fi AC_SUBST(HAVE_LIBPCREPOSIX) From 8c88ac94fa8b847643eb03cbce2faa3e4d16d6a3 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 17:30:53 +0000 Subject: [PATCH 34/96] lib: make writing end of pipe nonblocking Signed-off-by: Quentin Young --- lib/thread.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/thread.c b/lib/thread.c index 0188ae6c0b..848e39e1ae 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -387,6 +387,7 @@ thread_master_create (void) rv->owner = pthread_self(); pipe (rv->io_pipe); set_nonblocking (rv->io_pipe[0]); + set_nonblocking (rv->io_pipe[1]); rv->handler.pfdsize = rv->fd_limit; rv->handler.pfdcount = 0; From 16764760f7ad0af3cfda4fe497a8b158242ee4f7 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 17:40:38 +0000 Subject: [PATCH 35/96] frr: remove --enable-poll vestigial Signed-off-by: Quentin Young --- configure.ac | 6 ------ 1 file changed, 6 deletions(-) diff --git a/configure.ac b/configure.ac index c8b0a78bc6..5e4cfce16d 100755 --- a/configure.ac +++ b/configure.ac @@ -312,8 +312,6 @@ AC_ARG_ENABLE(fpm, AS_HELP_STRING([--enable-fpm], [enable Forwarding Plane Manager support])) AC_ARG_ENABLE(systemd, AS_HELP_STRING([--enable-systemd], [enable Systemd support])) -AC_ARG_ENABLE(poll, - AS_HELP_STRING([--enable-poll], [enable usage of Poll instead of select])) AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror], [enable -Werror (recommended for developers only)])) AC_ARG_ENABLE(cumulus, @@ -364,10 +362,6 @@ if test "${enable_rr_semantics}" != "no" ; then AC_DEFINE(HAVE_V6_RR_SEMANTICS,, Compile in v6 Route Replacement Semantics) fi -if test "${enable_poll}" = "yes" ; then - AC_DEFINE(HAVE_POLL_CALL,,Compile systemd support in) -fi - dnl ---------- dnl MPLS check dnl ---------- From a663a38ef8e4bcbb726b089a014c826745851d3e Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 19:00:39 +0000 Subject: [PATCH 36/96] ospfd: fix virtual-link timers commands Use {} semantics, correct docstrings, switchup parsing. Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 67 ++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index bb908ead2f..0b3984c0af 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -988,15 +988,15 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) "Use null authentication\n" \ "Use message-digest authentication\n" -#define VLINK_HELPSTR_TIME_PARAM_NOSECS \ - "Time between HELLO packets\n" \ - "Time between retransmitting lost link state advertisements\n" \ - "Link state transmit delay\n" \ - "Interval time after which a neighbor is declared down\n" - #define VLINK_HELPSTR_TIME_PARAM \ - VLINK_HELPSTR_TIME_PARAM_NOSECS \ - "Seconds\n" + "Time between HELLO packets\n" \ + "Seconds\n" \ + "Time between retransmitting lost link state advertisements\n" \ + "Seconds\n" \ + "Link state transmit delay\n" \ + "Seconds\n" \ + "Interval time after which a neighbor is declared down\n" \ + "Seconds\n" \ #define VLINK_HELPSTR_AUTH_SIMPLE \ "Authentication password (key)\n" \ @@ -1131,16 +1131,8 @@ DEFUN (ospf_area_vlink, DEFUN (ospf_area_vlink_intervals, ospf_area_vlink_intervals_cmd, - "area virtual-link A.B.C.D" - " (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "]]]", + "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) { VTY_DECLVAR_CONTEXT(ospf, ospf); @@ -1165,17 +1157,17 @@ DEFUN (ospf_area_vlink_intervals, vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); return CMD_WARNING; } - for (unsigned int i = 0; i < 4; i++) + + for (int idx = 4; idx < argc; idx++) { - int idx = 0; - if (argv_find (argv, argc, "hello-interval", &idx)) - vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "retransmit-interval", &idx)) - vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "transmit-delay", &idx)) - vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "dead-interval", &idx)) - vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10); + if (strmatch (argv[idx]->text, "hello-interval")) + vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "retransmit-interval")) + vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "transmit-delay")) + vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "dead-interval")) + vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); } /* Action configuration */ @@ -1294,17 +1286,9 @@ DEFUN (no_ospf_area_vlink, DEFUN (no_ospf_area_vlink_intervals, no_ospf_area_vlink_intervals_cmd, - "no area virtual-link A.B.C.D" - " (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "]]]", + "no area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", NO_STR VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) { VTY_DECLVAR_CONTEXT(ospf, ospf); @@ -1330,16 +1314,15 @@ DEFUN (no_ospf_area_vlink_intervals, return CMD_WARNING; } - for (unsigned int i = 0; i < 4; i++) + for (int idx = 5; idx < argc; idx++) { - int idx = 0; - if (argv_find (argv, argc, "hello-interval", &idx)) + if (strmatch (argv[idx]->text, "hello-interval")) vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; - else if (argv_find (argv, argc, "retransmit-interval", &idx)) + else if (strmatch (argv[idx]->text, "retransmit-interval")) vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; - else if (argv_find (argv, argc, "transmit-delay", &idx)) + else if (strmatch (argv[idx]->text, "transmit-delay")) vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; - else if (argv_find (argv, argc, "dead-interval", &idx)) + else if (strmatch (argv[idx]->text, "dead-interval")) vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; } From b1c02cec70dfe53af19c44c71339bf721e701973 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 19:04:53 +0000 Subject: [PATCH 37/96] ospfd: shufflin move virtual-link command down to be next to its no form Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 90 ++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0b3984c0af..cded08d323 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -1129,51 +1129,6 @@ DEFUN (ospf_area_vlink, } -DEFUN (ospf_area_vlink_intervals, - ospf_area_vlink_intervals_cmd, - "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM) -{ - VTY_DECLVAR_CONTEXT(ospf, ospf); - struct ospf_vl_config_data vl_config; - int ret = 0; - - ospf_vl_config_data_init(&vl_config, vty); - - char *area_id = argv[1]->arg; - char *router_id = argv[3]->arg; - - ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); - if (ret < 0) - { - vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = inet_aton (router_id, &vl_config.vl_peer); - if (! ret) - { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); - return CMD_WARNING; - } - - for (int idx = 4; idx < argc; idx++) - { - if (strmatch (argv[idx]->text, "hello-interval")) - vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "retransmit-interval")) - vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "transmit-delay")) - vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "dead-interval")) - vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); - } - - /* Action configuration */ - return ospf_vl_set (ospf, &vl_config); -} - DEFUN (no_ospf_area_vlink, no_ospf_area_vlink_cmd, "no area virtual-link A.B.C.D [authentication] [] []", @@ -1284,6 +1239,51 @@ DEFUN (no_ospf_area_vlink, return ospf_vl_set (ospf, &vl_config); } +DEFUN (ospf_area_vlink_intervals, + ospf_area_vlink_intervals_cmd, + "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", + VLINK_HELPSTR_IPADDR + VLINK_HELPSTR_TIME_PARAM) +{ + VTY_DECLVAR_CONTEXT(ospf, ospf); + struct ospf_vl_config_data vl_config; + int ret = 0; + + ospf_vl_config_data_init(&vl_config, vty); + + char *area_id = argv[1]->arg; + char *router_id = argv[3]->arg; + + ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); + if (ret < 0) + { + vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ret = inet_aton (router_id, &vl_config.vl_peer); + if (! ret) + { + vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); + return CMD_WARNING; + } + + for (int idx = 4; idx < argc; idx++) + { + if (strmatch (argv[idx]->text, "hello-interval")) + vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "retransmit-interval")) + vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "transmit-delay")) + vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "dead-interval")) + vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); + } + + /* Action configuration */ + return ospf_vl_set (ospf, &vl_config); +} + DEFUN (no_ospf_area_vlink_intervals, no_ospf_area_vlink_intervals_cmd, "no area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", From 8062bf1c6b64aa8ef5c64454afd749cba0247a4e Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 21:27:08 +0000 Subject: [PATCH 38/96] zebra: more informative error messages for mpls labels Signed-off-by: Quentin Young --- zebra/zebra_mpls.c | 69 ++++++++++++++++++++++++++++------------------ zebra/zebra_vty.c | 40 +++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 33 deletions(-) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index b547c62566..9cfa607c3e 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1734,44 +1734,59 @@ mpls_processq_init (struct zebra_t *zebra) /* * String to label conversion, labels separated by '/'. + * + * @param label_str labels separated by / + * @param num_labels number of labels; zero if conversion was unsuccessful + * @param labels preallocated mpls_label_t array of size MPLS_MAX_LABELS; only + * modified if the conversion succeeded + * @return 0 on success + * -1 if the string could not be parsed as integers + * -2 if a label was inside the reserved range (0-15) + * -3 if the number of labels given exceeds MPLS_MAX_LABELS */ int mpls_str2label (const char *label_str, u_int8_t *num_labels, mpls_label_t *labels) { - char *endp; - int i; + char *ostr; // copy of label string (start) + char *lstr; // copy of label string + char *nump; // pointer to next segment + char *endp; // end pointer + int i; // for iterating label_str + int rc; // return code + mpls_label_t pl[MPLS_MAX_LABELS]; // parsed labels + /* labels to zero until we have a successful parse */ + ostr = lstr = XSTRDUP (MTYPE_TMP, label_str); *num_labels = 0; - for (i = 0; i < MPLS_MAX_LABELS; i++) + rc = 0; + + for (i = 0; i < MPLS_MAX_LABELS && lstr && !rc; i++) { - mpls_label_t label; + nump = strsep (&lstr, "/"); + pl[i] = strtoul(nump, &endp, 10); - label = strtoul(label_str, &endp, 0); - - /* validity checks */ - if (endp == label_str) - return -1; - - if (!IS_MPLS_UNRESERVED_LABEL(label)) - return -1; - - labels[i] = label; - if (*endp == '\0') - { - *num_labels = i + 1; - return 0; - } - - /* Check separator. */ - if (*endp != '/') - return -1; - - label_str = endp + 1; + /* format check */ + if (*endp != '\0') + rc = -1; + /* validity check */ + else if (!IS_MPLS_UNRESERVED_LABEL(pl[i])) + rc = -2; } - /* Too many labels. */ - return -1; + /* excess labels */ + if (!rc && i == MPLS_MAX_LABELS && lstr) + rc = -3; + + if (!rc) + { + *num_labels = i + 1; + memcpy (labels, pl, *num_labels * sizeof (mpls_label_t)); + } + + XFREE (MTYPE_TMP, ostr); + + return rc; } /* diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d0d761af95..8970766389 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -126,10 +126,24 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, VTY_NEWLINE); return CMD_WARNING; } - if (mpls_str2label (label_str, &snh_label.num_labels, - snh_label.label)) + int rc = mpls_str2label (label_str, &snh_label.num_labels, + snh_label.label); + if (rc < 0) { - vty_out (vty, "%% Malformed label(s)%s", VTY_NEWLINE); + switch (rc) { + case -1: + vty_out (vty, "%% Malformed label(s)%s", VTY_NEWLINE); + break; + case -2: + vty_out (vty, "%% Cannot use reserved label(s) (%d-%d)%s", + MPLS_MIN_RESERVED_LABEL, MPLS_MAX_RESERVED_LABEL, + VTY_NEWLINE); + break; + case -3: + vty_out (vty, "%% Too many labels. Enter %d or fewer%s", + MPLS_MAX_LABELS, VTY_NEWLINE); + break; + } return CMD_WARNING; } } @@ -2047,10 +2061,24 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, VTY_NEWLINE); return CMD_WARNING; } - if (mpls_str2label (label_str, &snh_label.num_labels, - snh_label.label)) + int rc = mpls_str2label (label_str, &snh_label.num_labels, + snh_label.label); + if (rc < 0) { - vty_out (vty, "%% Malformed label(s)%s", VTY_NEWLINE); + switch (rc) { + case -1: + vty_out (vty, "%% Malformed label(s)%s", VTY_NEWLINE); + break; + case -2: + vty_out (vty, "%% Cannot use reserved label(s) (%d-%d)%s", + MPLS_MIN_RESERVED_LABEL, MPLS_MAX_RESERVED_LABEL, + VTY_NEWLINE); + break; + case -3: + vty_out (vty, "%% Too many labels. Enter %d or fewer%s", + MPLS_MAX_LABELS, VTY_NEWLINE); + break; + } return CMD_WARNING; } } From 6feb1a21affd126552228bf24f79248e3c27082c Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 21:50:20 +0000 Subject: [PATCH 39/96] zebra: define mpls label helpstr Signed-off-by: Quentin Young --- zebra/zebra_mpls.h | 2 + zebra/zebra_mpls_vty.c | 96 ++++++++++++++---------------------------- zebra/zebra_vty.c | 45 +++++++------------- 3 files changed, 49 insertions(+), 94 deletions(-) diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 1f17de67a3..319091520d 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -43,6 +43,8 @@ (((nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6 || \ (nhlfe)->nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) ? AF_INET6 : AF_INET) +#define MPLS_LABEL_HELPSTR "Specify label(s) for this route\nOne or more " \ + "labels in the range (16-1048575) separated by '/'\n" /* Typedefs */ diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index 3010a3bd8a..56f3e5196e 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -321,8 +321,7 @@ DEFUN (ip_route_label, "IP gateway address\n" "IP gateway interface name\n" "Null interface\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, NULL, NULL, argv[5]->arg); @@ -339,8 +338,7 @@ DEFUN (ip_route_tag_label, "Null interface\n" "Set tag for this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, NULL, NULL, argv[7]->arg); @@ -357,8 +355,7 @@ DEFUN (ip_route_mask_label, "IP gateway address\n" "IP gateway interface name\n" "Null interface\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL, argv[6]->arg); @@ -376,8 +373,7 @@ DEFUN (ip_route_mask_tag_label, "Null interface\n" "Set tag for this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, @@ -395,8 +391,7 @@ DEFUN (ip_route_distance_label, "IP gateway interface name\n" "Null interface\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, argv[4]->arg, NULL, argv[6]->arg); @@ -414,8 +409,7 @@ DEFUN (ip_route_tag_distance_label, "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, argv[5]->arg, @@ -433,8 +427,7 @@ DEFUN (ip_route_mask_distance_label, "IP gateway interface name\n" "Null interface\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); @@ -453,8 +446,7 @@ DEFUN (ip_route_mask_tag_distance_label, "Set tag for this route\n" "Tag value\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[2]->arg, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, NULL, argv[9]->arg); @@ -470,8 +462,7 @@ DEFUN (no_ip_route_label, "IP gateway address\n" "IP gateway interface name\n" "Null interface\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, NULL, NULL, argv[6]->arg); @@ -489,8 +480,7 @@ DEFUN (no_ip_route_tag_label, "Null interface\n" "Tag of this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, NULL, NULL, argv[8]->arg); @@ -507,8 +497,7 @@ DEFUN (no_ip_route_mask_label, "IP gateway address\n" "IP gateway interface name\n" "Null interface\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, NULL, argv[7]->arg); @@ -527,8 +516,7 @@ DEFUN (no_ip_route_mask_tag_label, "Null interface\n" "Tag of this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, NULL, NULL, argv[9]->arg); @@ -545,8 +533,7 @@ DEFUN (no_ip_route_distance_label, "IP gateway interface name\n" "Null interface\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); @@ -565,8 +552,7 @@ DEFUN (no_ip_route_tag_distance_label, "Tag of this route\n" "Tag value\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, NULL, argv[9]->arg); @@ -584,8 +570,7 @@ DEFUN (no_ip_route_mask_distance_label, "IP gateway interface name\n" "Null interface\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[6]->arg, NULL, argv[8]->arg); @@ -605,8 +590,7 @@ DEFUN (no_ip_route_mask_tag_distance_label, "Tag of this route\n" "Tag value\n" "Distance value for this route\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[3]->arg, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, NULL, argv[10]->arg); @@ -620,8 +604,7 @@ DEFUN (ipv6_route_label, "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, NULL, NULL, NULL, argv[5]->arg); } @@ -636,8 +619,7 @@ DEFUN (ipv6_route_tag_label, "IPv6 gateway interface name\n" "Set tag for this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, argv[5]->arg, NULL, NULL, argv[7]->arg); } @@ -650,8 +632,7 @@ DEFUN (ipv6_route_ifname_label, "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, NULL, NULL, NULL, argv[6]->arg); } @@ -665,8 +646,7 @@ DEFUN (ipv6_route_ifname_tag_label, "IPv6 gateway interface name\n" "Set tag for this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, NULL, NULL, argv[8]->arg); } @@ -680,8 +660,7 @@ DEFUN (ipv6_route_pref_label, "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, NULL, argv[4]->arg, NULL, argv[6]->arg); } @@ -697,8 +676,7 @@ DEFUN (ipv6_route_pref_tag_label, "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, NULL, NULL, argv[5]->arg, argv[6]->arg, NULL, argv[8]->arg); } @@ -712,8 +690,7 @@ DEFUN (ipv6_route_ifname_pref_label, "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); } @@ -729,8 +706,7 @@ DEFUN (ipv6_route_ifname_pref_tag_label, "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 1, argv[2]->arg, NULL, argv[3]->arg, argv[4]->arg, NULL, argv[6]->arg, argv[7]->arg, NULL, argv[9]->arg); } @@ -744,8 +720,7 @@ DEFUN (no_ipv6_route_label, "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, NULL, NULL, NULL, argv[6]->arg); } @@ -761,8 +736,7 @@ DEFUN (no_ipv6_route_tag_label, "IPv6 gateway interface name\n" "Set tag for this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argv[6]->arg, NULL, NULL, argv[8]->arg); } @@ -776,8 +750,7 @@ DEFUN (no_ipv6_route_ifname_label, "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" "IPv6 gateway address\n" "IPv6 gateway interface name\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, NULL, NULL, NULL, argv[7]->arg); } @@ -793,8 +766,7 @@ DEFUN (no_ipv6_route_ifname_tag_label, "IPv6 gateway interface name\n" "Set tag for this route\n" "Tag value\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, NULL, NULL, argv[9]->arg); } @@ -809,8 +781,7 @@ DEFUN (no_ipv6_route_pref_label, "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, NULL, argv[5]->arg, NULL, argv[7]->arg); } @@ -827,8 +798,7 @@ DEFUN (no_ipv6_route_pref_tag_label, "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, NULL, NULL, argv[6]->arg, argv[7]->arg, NULL, argv[9]->arg); } @@ -843,8 +813,7 @@ DEFUN (no_ipv6_route_ifname_pref_label, "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, NULL, argv[6]->arg, NULL, argv[8]->arg); } @@ -861,8 +830,7 @@ DEFUN (no_ipv6_route_ifname_pref_tag_label, "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" - "Specify label(s) for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { return static_ipv6_func (vty, 0, argv[3]->arg, NULL, argv[4]->arg, argv[5]->arg, NULL, argv[7]->arg, argv[8]->arg, NULL, argv[10]->arg); } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 8970766389..d250942fa5 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -435,8 +435,7 @@ DEFUN (ip_route_flags, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4_prefixlen = 2; int idx_reject_blackhole = 3; @@ -469,8 +468,7 @@ DEFUN (ip_route_mask, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4 = 2; int idx_ipv4_2 = 3; @@ -501,8 +499,7 @@ DEFUN (ip_route_mask_flags, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4 = 2; int idx_ipv4_2 = 3; @@ -535,8 +532,7 @@ DEFUN (no_ip_route, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4_prefixlen = 3; int idx_ipv4_ifname_null = 4; @@ -567,8 +563,7 @@ DEFUN (no_ip_route_flags, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4_prefixlen = 3; int idx_curr = 5; @@ -598,8 +593,7 @@ DEFUN (no_ip_route_mask, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4 = 3; int idx_ipv4_2 = 4; @@ -632,8 +626,7 @@ DEFUN (no_ip_route_mask_flags, "Tag value\n" "Distance value for this route\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv4 = 3; int idx_ipv4_2 = 4; @@ -2184,8 +2177,7 @@ DEFUN (ipv6_route, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 2; int idx_ipv6_ifname; @@ -2233,8 +2225,7 @@ DEFUN (ipv6_route_flags, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 2; int idx_ipv6_ifname; @@ -2283,8 +2274,7 @@ DEFUN (ipv6_route_ifname, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 2; int idx_ipv6 = 3; @@ -2335,8 +2325,7 @@ DEFUN (ipv6_route_ifname_flags, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 2; int idx_ipv6; @@ -2390,8 +2379,7 @@ DEFUN (no_ipv6_route, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 3; int idx_ipv6_ifname; @@ -2439,8 +2427,7 @@ DEFUN (no_ipv6_route_flags, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 3; int idx_ipv6_ifname; @@ -2490,8 +2477,7 @@ DEFUN (no_ipv6_route_ifname, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 3; int idx_ipv6; @@ -2543,8 +2529,7 @@ DEFUN (no_ipv6_route_ifname_flags, "Tag value\n" "Distance value for this prefix\n" VRF_CMD_HELP_STR - "Specify labels for this route\n" - "One or more labels separated by '/'\n") + MPLS_LABEL_HELPSTR) { int idx_ipv6_prefixlen = 3; int idx_ipv6; From 95db01eb22d4afe43a7f37243077f24b0b90ae9d Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 23:21:40 +0000 Subject: [PATCH 40/96] lib: use heap for pollfds a bunch of pollfds can cause a stack overflow when using a stack allocated buffer...silly me... Signed-off-by: Quentin Young --- lib/thread.c | 13 +++++++------ lib/thread.h | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/thread.c b/lib/thread.c index 848e39e1ae..2f15659a18 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -393,6 +393,8 @@ thread_master_create (void) rv->handler.pfdcount = 0; rv->handler.pfds = XCALLOC (MTYPE_THREAD_MASTER, sizeof (struct pollfd) * rv->handler.pfdsize); + rv->handler.copy = XCALLOC (MTYPE_THREAD_MASTER, + sizeof (struct pollfd) * rv->handler.pfdsize); return rv; } @@ -544,6 +546,7 @@ thread_master_free (struct thread_master *m) close (m->io_pipe[1]); XFREE (MTYPE_THREAD_MASTER, m->handler.pfds); + XFREE (MTYPE_THREAD_MASTER, m->handler.copy); XFREE (MTYPE_THREAD_MASTER, m); pthread_mutex_lock (&cpu_record_mtx); @@ -1231,17 +1234,15 @@ thread_fetch (struct thread_master *m, struct thread *fetch) timer_wait = &timer_val; } - /* copy pollfds so we can unlock during blocking calls to poll() */ - struct pollfd pfds[m->handler.pfdsize]; unsigned int count = m->handler.pfdcount + m->handler.pfdcountsnmp; - memcpy (pfds, m->handler.pfds, count * sizeof (struct pollfd)); + memcpy (m->handler.copy, m->handler.pfds, count * sizeof (struct pollfd)); pthread_mutex_unlock (&m->mtx); { - num = fd_poll (m, pfds, m->handler.pfdsize, count, timer_wait); + num = fd_poll (m, m->handler.copy, m->handler.pfdsize, count, timer_wait); } pthread_mutex_lock (&m->mtx); - + /* Signals should get quick treatment */ if (num < 0) { @@ -1263,7 +1264,7 @@ thread_fetch (struct thread_master *m, struct thread *fetch) /* Got IO, process it */ if (num > 0) - thread_process_io (m, pfds, num, count); + thread_process_io (m, m->handler.copy, num, count); #if 0 /* If any threads were made ready above (I/O or foreground timer), diff --git a/lib/thread.h b/lib/thread.h index 753aa41ffd..608fb8b8c0 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -53,7 +53,10 @@ struct fd_handler nfds_t pfdcountsnmp; /* number of pfd that fit in the allocated space of pfds */ nfds_t pfdsize; + /* file descriptors to monitor for i/o */ struct pollfd *pfds; + /* chunk used for temp copy of pollfds */ + struct pollfd *copy; }; /* Master of the theads. */ From f0f77c9a590bf538033602a0b2da6084c9ea22e2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 1 Jun 2017 07:26:25 -0400 Subject: [PATCH 41/96] zebra: Refactor 'struct rib' to be 'struct route_entry' The 'struct rib' data structure is missnamed. It really is a 'struct route_entry' as part of the 'struct route_node'. We have 1 'struct route_entry' per route src. As such 1 route node can have multiple route entries if multiple protocols attempt to install the same route. Signed-off-by: Donald Sharp --- doc/next-hop-tracking.txt | 2 +- zebra/kernel_null.c | 2 +- zebra/redistribute.c | 168 ++++---- zebra/redistribute.h | 8 +- zebra/redistribute_null.c | 8 +- zebra/rib.h | 101 ++--- zebra/rt.h | 2 +- zebra/rt_netlink.c | 76 ++-- zebra/rt_socket.c | 32 +- zebra/zebra_fpm.c | 28 +- zebra/zebra_fpm_dt.c | 30 +- zebra/zebra_fpm_netlink.c | 24 +- zebra/zebra_fpm_private.h | 6 +- zebra/zebra_fpm_protobuf.c | 28 +- zebra/zebra_memory.c | 2 +- zebra/zebra_memory.h | 2 +- zebra/zebra_mpls.c | 62 +-- zebra/zebra_mpls.h | 8 +- zebra/zebra_rib.c | 800 ++++++++++++++++++------------------- zebra/zebra_rnh.c | 162 ++++---- zebra/zebra_rnh.h | 2 +- zebra/zebra_routemap.c | 16 +- zebra/zebra_routemap.h | 2 +- zebra/zebra_snmp.c | 68 ++-- zebra/zebra_static.c | 112 +++--- zebra/zebra_vrf.c | 6 +- zebra/zebra_vty.c | 206 +++++----- zebra/zserv.c | 166 ++++---- zebra/zserv.h | 2 +- 29 files changed, 1058 insertions(+), 1073 deletions(-) diff --git a/doc/next-hop-tracking.txt b/doc/next-hop-tracking.txt index d64433e2fe..12ed63947b 100644 --- a/doc/next-hop-tracking.txt +++ b/doc/next-hop-tracking.txt @@ -252,7 +252,7 @@ rnh table: struct rnh { u_char flags; - struct rib *state; + struct route_entry *state; struct list *client_list; struct route_node *node; }; diff --git a/zebra/kernel_null.c b/zebra/kernel_null.c index ad96ce41ca..5f1a054bdc 100644 --- a/zebra/kernel_null.c +++ b/zebra/kernel_null.c @@ -31,7 +31,7 @@ #include "zebra/rib.h" int kernel_route_rib (struct prefix *a, struct prefix *b, - struct rib *old, struct rib *new) { return 0; } + struct route_entry *old, struct route_entry *new) { return 0; } int kernel_address_add_ipv4 (struct interface *a, struct connected *b) { diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 1493bd9cb6..9f63aeb4e9 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -79,7 +79,7 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id) struct prefix p; struct route_table *table; struct route_node *rn; - struct rib *newrib; + struct route_entry *newre; for (afi = AFI_IP; afi <= AFI_IP6; afi++) { @@ -95,10 +95,10 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id) if (! rn) continue; - RNODE_FOREACH_RIB (rn, newrib) - if (CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED) - && newrib->distance != DISTANCE_INFINITY) - zsend_redistribute_route (1, client, &rn->p, NULL, newrib); + RNODE_FOREACH_RE (rn, newre) + if (CHECK_FLAG (newre->flags, ZEBRA_FLAG_SELECTED) + && newre->distance != DISTANCE_INFINITY) + zsend_redistribute_route (1, client, &rn->p, NULL, newre); route_unlock_node (rn); } @@ -108,7 +108,7 @@ zebra_redistribute_default (struct zserv *client, vrf_id_t vrf_id) static void zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t vrf_id, int afi) { - struct rib *newrib; + struct route_entry *newre; struct route_table *table; struct route_node *rn; @@ -117,7 +117,7 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v return; for (rn = route_top (table); rn; rn = route_next (rn)) - RNODE_FOREACH_RIB (rn, newrib) + RNODE_FOREACH_RE (rn, newre) { struct prefix *dst_p, *src_p; srcdest_rnode_prefixes(rn, &dst_p, &src_p); @@ -125,21 +125,21 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("%s: checking: selected=%d, type=%d, distance=%d, " "zebra_check_addr=%d", __func__, - CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED), - newrib->type, newrib->distance, + CHECK_FLAG (newre->flags, ZEBRA_FLAG_SELECTED), + newre->type, newre->distance, zebra_check_addr (dst_p)); - if (! CHECK_FLAG (newrib->flags, ZEBRA_FLAG_SELECTED)) + if (! CHECK_FLAG (newre->flags, ZEBRA_FLAG_SELECTED)) continue; if ((type != ZEBRA_ROUTE_ALL && - (newrib->type != type || newrib->instance != instance))) + (newre->type != type || newre->instance != instance))) continue; - if (newrib->distance == DISTANCE_INFINITY) + if (newre->distance == DISTANCE_INFINITY) continue; if (! zebra_check_addr (dst_p)) continue; - zsend_redistribute_route (1, client, dst_p, src_p, newrib); + zsend_redistribute_route (1, client, dst_p, src_p, newre); } } @@ -147,7 +147,7 @@ zebra_redistribute (struct zserv *client, int type, u_short instance, vrf_id_t v /* withdraw redistribution if add cannot be done for client */ void redistribute_update (struct prefix *p, struct prefix *src_p, - struct rib *rib, struct rib *prev_rib) + struct route_entry *re, struct route_entry *prev_re) { struct listnode *node, *nnode; struct zserv *client; @@ -158,9 +158,9 @@ redistribute_update (struct prefix *p, struct prefix *src_p, if (IS_ZEBRA_DEBUG_RIB) { inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN); - zlog_debug ("%u:%s/%d: Redist update rib %p (type %d), old %p (type %d)", - rib->vrf_id, buf, p->prefixlen, rib, rib->type, - prev_rib, prev_rib ? prev_rib->type : -1); + zlog_debug ("%u:%s/%d: Redist update re %p (type %d), old %p (type %d)", + re->vrf_id, buf, p->prefixlen, re, re->type, + prev_re, prev_re ? prev_re->type : -1); } afi = family2afi(p->family); @@ -174,33 +174,33 @@ redistribute_update (struct prefix *p, struct prefix *src_p, { send_redistribute = 0; - if (is_default (p) && vrf_bitmap_check (client->redist_default, rib->vrf_id)) + if (is_default (p) && vrf_bitmap_check (client->redist_default, re->vrf_id)) send_redistribute = 1; - else if (vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], rib->vrf_id)) + else if (vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], re->vrf_id)) send_redistribute = 1; - else if (rib->instance && redist_check_instance (&client->mi_redist[afi][rib->type], - rib->instance)) + else if (re->instance && redist_check_instance (&client->mi_redist[afi][re->type], + re->instance)) send_redistribute = 1; - else if (vrf_bitmap_check (client->redist[afi][rib->type], rib->vrf_id)) + else if (vrf_bitmap_check (client->redist[afi][re->type], re->vrf_id)) send_redistribute = 1; if (send_redistribute) { - zsend_redistribute_route (1, client, p, src_p, rib); + zsend_redistribute_route (1, client, p, src_p, re); } - else if (prev_rib && - ((rib->instance && - redist_check_instance(&client->mi_redist[afi][prev_rib->type], - rib->instance)) || - vrf_bitmap_check (client->redist[afi][prev_rib->type], rib->vrf_id))) + else if (prev_re && + ((re->instance && + redist_check_instance(&client->mi_redist[afi][prev_re->type], + re->instance)) || + vrf_bitmap_check (client->redist[afi][prev_re->type], re->vrf_id))) { - zsend_redistribute_route (0, client, p, src_p, prev_rib); + zsend_redistribute_route (0, client, p, src_p, prev_re); } } } void -redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib) +redistribute_delete (struct prefix *p, struct prefix *src_p, struct route_entry *re) { struct listnode *node, *nnode; struct zserv *client; @@ -210,12 +210,12 @@ redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib) if (IS_ZEBRA_DEBUG_RIB) { inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN); - zlog_debug ("%u:%s/%d: Redist delete rib %p (type %d)", - rib->vrf_id, buf, p->prefixlen, rib, rib->type); + zlog_debug ("%u:%s/%d: Redist delete re %p (type %d)", + re->vrf_id, buf, p->prefixlen, re, re->type); } /* Add DISTANCE_INFINITY check. */ - if (rib->distance == DISTANCE_INFINITY) + if (re->distance == DISTANCE_INFINITY) return; afi = family2afi(p->family); @@ -228,14 +228,14 @@ redistribute_delete (struct prefix *p, struct prefix *src_p, struct rib *rib) for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) { if ((is_default (p) && - vrf_bitmap_check (client->redist_default, rib->vrf_id)) || - vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], rib->vrf_id) || - (rib->instance && - redist_check_instance(&client->mi_redist[afi][rib->type], - rib->instance)) || - vrf_bitmap_check (client->redist[afi][rib->type], rib->vrf_id)) + vrf_bitmap_check (client->redist_default, re->vrf_id)) || + vrf_bitmap_check (client->redist[afi][ZEBRA_ROUTE_ALL], re->vrf_id) || + (re->instance && + redist_check_instance(&client->mi_redist[afi][re->type], + re->instance)) || + vrf_bitmap_check (client->redist[afi][re->type], re->vrf_id)) { - zsend_redistribute_route (0, client, p, src_p, rib); + zsend_redistribute_route (0, client, p, src_p, re); } } } @@ -490,18 +490,18 @@ zebra_interface_vrf_update_add (struct interface *ifp, vrf_id_t old_vrf_id) } int -zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char *rmap_name) +zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, const char *rmap_name) { - struct rib *newrib; - struct rib *same; + struct route_entry *newre; + struct route_entry *same; struct prefix p; struct nexthop *nhop; union g_addr *gate; route_map_result_t ret = RMAP_MATCH; if (rmap_name) - ret = zebra_import_table_route_map_check (AFI_IP, rib->type, &rn->p, rib->nexthop, rib->vrf_id, - rib->tag, rmap_name); + ret = zebra_import_table_route_map_check (AFI_IP, re->type, &rn->p, re->nexthop, re->vrf_id, + re->tag, rmap_name); if (ret == RMAP_MATCH) { @@ -511,13 +511,13 @@ zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char p.prefixlen = rn->p.prefixlen; p.u.prefix4 = rn->p.u.prefix4; - RNODE_FOREACH_RIB (rn, same) + RNODE_FOREACH_RE (rn, same) { - if (CHECK_FLAG (same->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (same->status, ROUTE_ENTRY_REMOVED)) continue; - if (same->type == rib->type && same->instance == rib->instance - && same->table == rib->table + if (same->type == re->type && same->instance == re->instance + && same->table == re->table && same->type != ZEBRA_ROUTE_CONNECT) break; } @@ -526,51 +526,51 @@ zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char zebra_del_import_table_entry (rn, same); - if (rib->nexthop_num == 1) + if (re->nexthop_num == 1) { - nhop = rib->nexthop; + nhop = re->nexthop; if (nhop->type == NEXTHOP_TYPE_IFINDEX) gate = NULL; else gate = (union g_addr *)&nhop->gate.ipv4; - rib_add (AFI_IP, SAFI_UNICAST, rib->vrf_id, ZEBRA_ROUTE_TABLE, - rib->table, 0, &p, NULL, gate, (union g_addr *)&nhop->src.ipv4, + rib_add (AFI_IP, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, + re->table, 0, &p, NULL, gate, (union g_addr *)&nhop->src.ipv4, nhop->ifindex, zebrad.rtm_table_default, - rib->metric, rib->mtu, - zebra_import_table_distance[AFI_IP][rib->table]); + re->metric, re->mtu, + zebra_import_table_distance[AFI_IP][re->table]); } - else if (rib->nexthop_num > 1) + else if (re->nexthop_num > 1) { - newrib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); - newrib->type = ZEBRA_ROUTE_TABLE; - newrib->distance = zebra_import_table_distance[AFI_IP][rib->table]; - newrib->flags = rib->flags; - newrib->metric = rib->metric; - newrib->mtu = rib->mtu; - newrib->table = zebrad.rtm_table_default; - newrib->nexthop_num = 0; - newrib->uptime = time(NULL); - newrib->instance = rib->table; + newre = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); + newre->type = ZEBRA_ROUTE_TABLE; + newre->distance = zebra_import_table_distance[AFI_IP][re->table]; + newre->flags = re->flags; + newre->metric = re->metric; + newre->mtu = re->mtu; + newre->table = zebrad.rtm_table_default; + newre->nexthop_num = 0; + newre->uptime = time(NULL); + newre->instance = re->table; /* Assuming these routes are never recursive */ - for (nhop = rib->nexthop; nhop; nhop = nhop->next) - rib_copy_nexthops(newrib, nhop); + for (nhop = re->nexthop; nhop; nhop = nhop->next) + route_entry_copy_nexthops(newre, nhop); - rib_add_multipath(AFI_IP, SAFI_UNICAST, &p, NULL, newrib); + rib_add_multipath(AFI_IP, SAFI_UNICAST, &p, NULL, newre); } } } else { - zebra_del_import_table_entry (rn, rib); + zebra_del_import_table_entry (rn, re); } /* DD: Add IPv6 code */ return 0; } int -zebra_del_import_table_entry (struct route_node *rn, struct rib *rib) +zebra_del_import_table_entry (struct route_node *rn, struct route_entry *re) { struct prefix p; @@ -580,8 +580,8 @@ zebra_del_import_table_entry (struct route_node *rn, struct rib *rib) p.prefixlen = rn->p.prefixlen; p.u.prefix4 = rn->p.u.prefix4; - rib_delete (AFI_IP, SAFI_UNICAST, rib->vrf_id, ZEBRA_ROUTE_TABLE, - rib->table, rib->flags, &p, NULL, NULL, + rib_delete (AFI_IP, SAFI_UNICAST, re->vrf_id, ZEBRA_ROUTE_TABLE, + re->table, re->flags, &p, NULL, NULL, 0, zebrad.rtm_table_default); } /* DD: Add IPv6 code */ @@ -594,7 +594,7 @@ int zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance, const char *rmap_name, int add) { struct route_table *table; - struct rib *rib; + struct route_entry *re; struct route_node *rn; if (!is_zebra_valid_kernel_table(table_id) || @@ -647,23 +647,23 @@ zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance, const cha if (!rn->info) continue; - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; break; } - if (!rib) + if (!re) continue; if (((afi == AFI_IP) && (rn->p.family == AF_INET)) || ((afi == AFI_IP6) && (rn->p.family == AF_INET6))) { if (add) - zebra_add_import_table_entry (rn, rib, rmap_name); + zebra_add_import_table_entry (rn, re, rmap_name); else - zebra_del_import_table_entry (rn, rib); + zebra_del_import_table_entry (rn, re); } } return 0; @@ -713,7 +713,7 @@ zebra_import_table_rm_update () afi_t afi; int i; struct route_table *table; - struct rib *rib; + struct route_entry *re; struct route_node *rn; const char *rmap_name; @@ -736,19 +736,19 @@ zebra_import_table_rm_update () if (!rn->info) continue; - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; break; } - if (!rib) + if (!re) continue; if (((afi == AFI_IP) && (rn->p.family == AF_INET)) || ((afi == AFI_IP6) && (rn->p.family == AF_INET6))) - zebra_add_import_table_entry (rn, rib, rmap_name); + zebra_add_import_table_entry (rn, re, rmap_name); } } } diff --git a/zebra/redistribute.h b/zebra/redistribute.h index 8a78574980..429ec1bfdc 100644 --- a/zebra/redistribute.h +++ b/zebra/redistribute.h @@ -36,8 +36,8 @@ extern void zebra_redistribute_default_delete (int, struct zserv *, int, struct zebra_vrf *zvrf); extern void redistribute_update (struct prefix *, struct prefix *, - struct rib *, struct rib *); -extern void redistribute_delete (struct prefix *, struct prefix *, struct rib *); + struct route_entry *, struct route_entry *); +extern void redistribute_delete (struct prefix *, struct prefix *, struct route_entry *); extern void zebra_interface_up_update (struct interface *); extern void zebra_interface_down_update (struct interface *); @@ -57,9 +57,9 @@ extern int zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance, const char *rmap_name, int add); extern int zebra_add_import_table_entry (struct route_node *rn, - struct rib *rib, const char *rmap_name); + struct route_entry *re, const char *rmap_name); extern int zebra_del_import_table_entry (struct route_node *rn, - struct rib *rib); + struct route_entry *re); extern int is_zebra_import_table_enabled(afi_t, u_int32_t table_id); extern int zebra_import_table_config(struct vty *); diff --git a/zebra/redistribute_null.c b/zebra/redistribute_null.c index 7f40c21782..3b83a6b6ae 100644 --- a/zebra/redistribute_null.c +++ b/zebra/redistribute_null.c @@ -39,9 +39,9 @@ void zebra_redistribute_default_delete (int a, struct zserv *b, int c, { return; } void redistribute_update (struct prefix *a, struct prefix *b, - struct rib *c, struct rib *d) + struct route_entry *c, struct route_entry *d) { return; } -void redistribute_delete (struct prefix *a, struct prefix *b, struct rib *c) +void redistribute_delete (struct prefix *a, struct prefix *b, struct route_entry *c) { return; } void zebra_interface_up_update (struct interface *a) @@ -75,10 +75,10 @@ int zebra_import_table (afi_t afi, u_int32_t table_id, u_int32_t distance, const char *rmap_name, int add) { return 0; } -int zebra_add_import_table_entry (struct route_node *rn, struct rib *rib, const char *rmap_name) +int zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, const char *rmap_name) { return 0; } -int zebra_del_import_table_entry (struct route_node *rn, struct rib *rib) +int zebra_del_import_table_entry (struct route_node *rn, struct route_entry *re) { return 0; } int is_zebra_import_table_enabled(afi_t afi, u_int32_t table_id) diff --git a/zebra/rib.h b/zebra/rib.h index 7bcbf56bde..3f4fb81f6d 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -37,11 +37,11 @@ #define DISTANCE_INFINITY 255 #define ZEBRA_KERNEL_TABLE_MAX 252 /* support for no more than this rt tables */ -struct rib +struct route_entry { /* Link list. */ - struct rib *next; - struct rib *prev; + struct route_entry *next; + struct route_entry *prev; /* Nexthop structure */ struct nexthop *nexthop; @@ -85,11 +85,11 @@ struct rib /* RIB internal status */ u_char status; -#define RIB_ENTRY_REMOVED 0x1 +#define ROUTE_ENTRY_REMOVED 0x1 /* to simplify NHT logic when NHs change, instead of doing a NH by NH cmp */ -#define RIB_ENTRY_NEXTHOPS_CHANGED 0x2 -#define RIB_ENTRY_CHANGED 0x4 -#define RIB_ENTRY_SELECTED_FIB 0x8 +#define ROUTE_ENTRY_NEXTHOPS_CHANGED 0x2 +#define ROUTE_ENTRY_CHANGED 0x4 +#define ROUTE_ENTRY_SELECTED_FIB 0x8 /* Nexthop information. */ u_char nexthop_num; @@ -125,7 +125,7 @@ typedef struct rib_dest_t_ /* * Doubly-linked list of routes for this prefix. */ - struct rib *routes; + struct route_entry *routes; /* * Flags, see below. @@ -161,22 +161,22 @@ typedef struct rib_dest_t_ /* * Macro to iterate over each route for a destination (prefix). */ -#define RIB_DEST_FOREACH_ROUTE(dest, rib) \ - for ((rib) = (dest) ? (dest)->routes : NULL; (rib); (rib) = (rib)->next) +#define RE_DEST_FOREACH_ROUTE(dest, re) \ + for ((re) = (dest) ? (dest)->routes : NULL; (re); (re) = (re)->next) /* * Same as above, but allows the current node to be unlinked. */ -#define RIB_DEST_FOREACH_ROUTE_SAFE(dest, rib, next) \ - for ((rib) = (dest) ? (dest)->routes : NULL; \ - (rib) && ((next) = (rib)->next, 1); \ - (rib) = (next)) +#define RE_DEST_FOREACH_ROUTE_SAFE(dest, re, next) \ + for ((re) = (dest) ? (dest)->routes : NULL; \ + (re) && ((next) = (re)->next, 1); \ + (re) = (next)) -#define RNODE_FOREACH_RIB(rn, rib) \ - RIB_DEST_FOREACH_ROUTE (rib_dest_from_rnode (rn), rib) +#define RNODE_FOREACH_RE(rn, re) \ + RE_DEST_FOREACH_ROUTE (rib_dest_from_rnode (rn), re) -#define RNODE_FOREACH_RIB_SAFE(rn, rib, next) \ - RIB_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), rib, next) +#define RNODE_FOREACH_RE_SAFE(rn, re, next) \ + RE_DEST_FOREACH_ROUTE_SAFE (rib_dest_from_rnode (rn), re, next) /* The following for loop allows to iterate over the nexthop * structure of routes. @@ -283,17 +283,28 @@ typedef enum RIB_UPDATE_OTHER } rib_update_event_t; -extern struct nexthop *rib_nexthop_ifindex_add (struct rib *, ifindex_t); -extern struct nexthop *rib_nexthop_blackhole_add (struct rib *); -extern struct nexthop *rib_nexthop_ipv4_add (struct rib *, struct in_addr *, - struct in_addr *); -extern struct nexthop *rib_nexthop_ipv4_ifindex_add (struct rib *, - struct in_addr *, - struct in_addr *, - ifindex_t); -extern void rib_nexthop_add (struct rib *rib, struct nexthop *nexthop); -extern void rib_copy_nexthops (struct rib *rib, struct nexthop *nh); +extern struct nexthop *route_entry_nexthop_ifindex_add (struct route_entry *, ifindex_t); +extern struct nexthop *route_entry_nexthop_blackhole_add (struct route_entry *); +extern struct nexthop *route_entry_nexthop_ipv4_add (struct route_entry *, + struct in_addr *, + struct in_addr *); +extern struct nexthop *route_entry_nexthop_ipv4_ifindex_add (struct route_entry *, + struct in_addr *, + struct in_addr *, + ifindex_t); +extern void route_entry_nexthop_delete (struct route_entry *re, struct nexthop *nexthop); +extern struct nexthop *route_entry_nexthop_ipv6_add (struct route_entry *, + struct in6_addr *); +extern struct nexthop *route_entry_nexthop_ipv6_ifindex_add (struct route_entry *re, + struct in6_addr *ipv6, + ifindex_t ifindex); +extern void route_entry_nexthop_add (struct route_entry *re, struct nexthop *nexthop); +extern void route_entry_copy_nexthops (struct route_entry *re, struct nexthop *nh); +#define route_entry_dump(prefix, src, re) _route_entry_dump(__func__, prefix, src, re) +extern void _route_entry_dump (const char *, + union prefixconstptr, + union prefixconstptr, const struct route_entry *); /* RPF lookup behaviour */ enum multicast_mode { @@ -309,13 +320,9 @@ enum multicast_mode extern void multicast_mode_ipv4_set (enum multicast_mode mode); extern enum multicast_mode multicast_mode_ipv4_get (void); -extern int nexthop_has_fib_child(struct nexthop *); extern void rib_lookup_and_dump (struct prefix_ipv4 *, vrf_id_t); extern void rib_lookup_and_pushup (struct prefix_ipv4 *, vrf_id_t); -#define rib_dump(prefix, src, rib) _rib_dump(__func__, prefix, src, rib) -extern void _rib_dump (const char *, - union prefixconstptr, - union prefixconstptr, const struct rib *); + extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *, vrf_id_t); #define ZEBRA_RIB_LOOKUP_ERROR -1 @@ -324,20 +331,16 @@ extern int rib_lookup_ipv4_route (struct prefix_ipv4 *, union sockunion *, #define ZEBRA_RIB_FOUND_CONNECTED 2 #define ZEBRA_RIB_NOTFOUND 3 -extern void rib_nexthop_delete (struct rib *rib, struct nexthop *nexthop); -extern struct nexthop *rib_nexthop_ipv6_add (struct rib *, struct in6_addr *); -extern struct nexthop *rib_nexthop_ipv6_ifindex_add (struct rib *rib, - struct in6_addr *ipv6, - ifindex_t ifindex); + extern int is_zebra_valid_kernel_table(u_int32_t table_id); extern int is_zebra_main_routing_table(u_int32_t table_id); extern int zebra_check_addr (struct prefix *p); -extern void rib_addnode (struct route_node *rn, struct rib *rib, int process); -extern void rib_delnode (struct route_node *rn, struct rib *rib); -extern int rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old); -extern int rib_uninstall_kernel (struct route_node *rn, struct rib *rib); +extern void rib_addnode (struct route_node *rn, struct route_entry *re, int process); +extern void rib_delnode (struct route_node *rn, struct route_entry *re); +extern int rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_entry *old); +extern int rib_uninstall_kernel (struct route_node *rn, struct route_entry *re); /* NOTE: * All rib_add function will not just add prefix into RIB, but @@ -349,19 +352,19 @@ extern int rib_add (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_int32_t, u_int32_t, u_char); extern int rib_add_multipath (afi_t afi, safi_t safi, struct prefix *, - struct prefix_ipv6 *src_p, struct rib *); + struct prefix_ipv6 *src_p, struct route_entry *); extern void rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, int flags, struct prefix *p, struct prefix_ipv6 *src_p, union g_addr *gate, ifindex_t ifindex, u_int32_t table_id); -extern struct rib *rib_match (afi_t afi, safi_t safi, vrf_id_t, union g_addr *, +extern struct route_entry *rib_match (afi_t afi, safi_t safi, vrf_id_t, union g_addr *, struct route_node **rn_out); -extern struct rib *rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, +extern struct route_entry *rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, struct route_node **rn_out); -extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t); +extern struct route_entry *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t); extern void rib_update (vrf_id_t, rib_update_event_t); extern void rib_weed_tables (void); @@ -371,10 +374,10 @@ extern void rib_init (void); extern unsigned long rib_score_proto (u_char proto, u_short instance); extern void rib_queue_add (struct route_node *rn); extern void meta_queue_free (struct meta_queue *mq); -extern int zebra_rib_labeled_unicast (struct rib *rib); +extern int zebra_rib_labeled_unicast (struct route_entry *re); extern struct route_table *rib_table_ipv6; -extern void rib_unlink (struct route_node *, struct rib *); +extern void rib_unlink (struct route_node *, struct route_entry *); extern int rib_gc_dest (struct route_node *rn); extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter); @@ -408,7 +411,7 @@ rib_dest_from_rnode (struct route_node *rn) * Returns a pointer to the list of routes corresponding to the given * route_node. */ -static inline struct rib * +static inline struct route_entry * rnode_to_ribs (struct route_node *rn) { rib_dest_t *dest; diff --git a/zebra/rt.h b/zebra/rt.h index 5f2441a9ce..a39af87b5a 100644 --- a/zebra/rt.h +++ b/zebra/rt.h @@ -29,7 +29,7 @@ #include "zebra/zebra_mpls.h" extern int kernel_route_rib (struct prefix *, struct prefix *, - struct rib *, struct rib *); + struct route_entry *, struct route_entry *); extern int kernel_address_add_ipv4 (struct interface *, struct connected *); extern int kernel_address_delete_ipv4 (struct interface *, struct connected *); diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index f22f4acb08..88cdfbcae1 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -342,22 +342,22 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h, { /* This is a multipath route */ - struct rib *rib; + struct route_entry *re; struct rtnexthop *rtnh = (struct rtnexthop *) RTA_DATA (tb[RTA_MULTIPATH]); len = RTA_PAYLOAD (tb[RTA_MULTIPATH]); - rib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); - rib->type = ZEBRA_ROUTE_KERNEL; - rib->distance = 0; - rib->flags = flags; - rib->metric = metric; - rib->mtu = mtu; - rib->vrf_id = vrf_id; - rib->table = table; - rib->nexthop_num = 0; - rib->uptime = time (NULL); + re = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); + re->type = ZEBRA_ROUTE_KERNEL; + re->distance = 0; + re->flags = flags; + re->metric = metric; + re->mtu = mtu; + re->vrf_id = vrf_id; + re->table = table; + re->nexthop_num = 0; + re->uptime = time (NULL); for (;;) { @@ -380,31 +380,31 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h, if (rtm->rtm_family == AF_INET) { if (index) - rib_nexthop_ipv4_ifindex_add (rib, gate, prefsrc, index); + route_entry_nexthop_ipv4_ifindex_add (re, gate, prefsrc, index); else - rib_nexthop_ipv4_add (rib, gate, prefsrc); + route_entry_nexthop_ipv4_add (re, gate, prefsrc); } else if (rtm->rtm_family == AF_INET6) { if (index) - rib_nexthop_ipv6_ifindex_add (rib, gate, index); + route_entry_nexthop_ipv6_ifindex_add (re, gate, index); else - rib_nexthop_ipv6_add (rib,gate); + route_entry_nexthop_ipv6_add (re,gate); } } else - rib_nexthop_ifindex_add (rib, index); + route_entry_nexthop_ifindex_add (re, index); len -= NLMSG_ALIGN(rtnh->rtnh_len); rtnh = RTNH_NEXT(rtnh); } zserv_nexthop_num_warn(__func__, (const struct prefix *)&p, - rib->nexthop_num); - if (rib->nexthop_num == 0) - XFREE (MTYPE_RIB, rib); + re->nexthop_num); + if (re->nexthop_num == 0) + XFREE (MTYPE_RE, re); else - rib_add_multipath (AFI_IP, SAFI_UNICAST, &p, NULL, rib); + rib_add_multipath (AFI_IP, SAFI_UNICAST, &p, NULL, re); } } else @@ -1168,7 +1168,7 @@ netlink_neigh_update (int cmd, int ifindex, uint32_t addr, char *lla, int llalen /* Update flag indicates whether this is a "replace" or not. */ static int netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, - struct rib *rib, int update) + struct route_entry *re, int update) { int bytelen; struct sockaddr_nl snl; @@ -1189,7 +1189,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, } req; struct zebra_ns *zns = zebra_ns_lookup (NS_DEFAULT); - struct zebra_vrf *zvrf = vrf_info_lookup (rib->vrf_id); + struct zebra_vrf *zvrf = vrf_info_lookup (re->vrf_id); memset (&req, 0, sizeof req - NL_PKT_BUF_SIZE); @@ -1203,10 +1203,10 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, req.r.rtm_family = family; req.r.rtm_dst_len = p->prefixlen; req.r.rtm_src_len = src_p ? src_p->prefixlen : 0; - req.r.rtm_protocol = get_rt_proto(rib->type); + req.r.rtm_protocol = get_rt_proto(re->type); req.r.rtm_scope = RT_SCOPE_UNIVERSE; - if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT)) + if ((re->flags & ZEBRA_FLAG_BLACKHOLE) || (re->flags & ZEBRA_FLAG_REJECT)) discard = 1; else discard = 0; @@ -1215,9 +1215,9 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, { if (discard) { - if (rib->flags & ZEBRA_FLAG_BLACKHOLE) + if (re->flags & ZEBRA_FLAG_BLACKHOLE) req.r.rtm_type = RTN_BLACKHOLE; - else if (rib->flags & ZEBRA_FLAG_REJECT) + else if (re->flags & ZEBRA_FLAG_REJECT) req.r.rtm_type = RTN_UNREACHABLE; else assert (RTN_BLACKHOLE != RTN_UNREACHABLE); /* false */ @@ -1238,21 +1238,21 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, addattr32 (&req.n, sizeof req, RTA_PRIORITY, NL_DEFAULT_ROUTE_METRIC); /* Table corresponding to this route. */ - if (rib->table < 256) - req.r.rtm_table = rib->table; + if (re->table < 256) + req.r.rtm_table = re->table; else { req.r.rtm_table = RT_TABLE_UNSPEC; - addattr32(&req.n, sizeof req, RTA_TABLE, rib->table); + addattr32(&req.n, sizeof req, RTA_TABLE, re->table); } - if (rib->mtu || rib->nexthop_mtu) + if (re->mtu || re->nexthop_mtu) { char buf[NL_PKT_BUF_SIZE]; struct rtattr *rta = (void *) buf; - u_int32_t mtu = rib->mtu; - if (!mtu || (rib->nexthop_mtu && rib->nexthop_mtu < mtu)) - mtu = rib->nexthop_mtu; + u_int32_t mtu = re->mtu; + if (!mtu || (re->nexthop_mtu && re->nexthop_mtu < mtu)) + mtu = re->nexthop_mtu; rta->rta_type = RTA_METRICS; rta->rta_len = RTA_LENGTH(0); rta_addattr_l (rta, NL_PKT_BUF_SIZE, RTAX_MTU, &mtu, sizeof mtu); @@ -1263,7 +1263,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, if (discard) { if (cmd == RTM_NEWROUTE) - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { /* We shouldn't encounter recursive nexthops on discard routes, * but it is probably better to handle that case correctly anyway. @@ -1277,7 +1277,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, /* Count overall nexthops so we can decide whether to use singlepath * or multipath case. */ nexthop_num = 0; - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -1293,7 +1293,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, if (nexthop_num == 1 || multipath_num == 1) { nexthop_num = 0; - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) { @@ -1364,7 +1364,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p, rtnh = RTA_DATA (rta); nexthop_num = 0; - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (nexthop_num >= multipath_num) break; @@ -1497,7 +1497,7 @@ kernel_get_ipmr_sg_stats (void *in) int kernel_route_rib (struct prefix *p, struct prefix *src_p, - struct rib *old, struct rib *new) + struct route_entry *old, struct route_entry *new) { if (!old && new) return netlink_route_multipath (RTM_NEWROUTE, p, src_p, new, 0); diff --git a/zebra/rt_socket.c b/zebra/rt_socket.c index 3e4833016a..ee706a1e8c 100644 --- a/zebra/rt_socket.c +++ b/zebra/rt_socket.c @@ -71,7 +71,7 @@ sin_masklen (struct in_addr mask) /* Interface between zebra message and rtm message. */ static int -kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib) +kernel_rtm_ipv4 (int cmd, struct prefix *p, struct route_entry *re) { struct sockaddr_in *mask = NULL; @@ -106,7 +106,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib) #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* Make gateway. */ - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -172,16 +172,16 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib) gate ? (union sockunion *)&sin_gate : NULL, smplsp, ifindex, - rib->flags, - rib->metric); + re->flags, + re->metric); if (IS_ZEBRA_DEBUG_RIB) { if (!gate) { - zlog_debug ("%s: %s: attention! gate not found for rib %p", - __func__, prefix_buf, rib); - rib_dump (p, NULL, rib); + zlog_debug ("%s: %s: attention! gate not found for re %p", + __func__, prefix_buf, re); + route_entry_dump (p, NULL, re); } else inet_ntop (AF_INET, &sin_gate.sin_addr, gate_buf, INET_ADDRSTRLEN); @@ -230,7 +230,7 @@ kernel_rtm_ipv4 (int cmd, struct prefix *p, struct rib *rib) /* If there was no useful nexthop, then complain. */ if (nexthop_num == 0 && IS_ZEBRA_DEBUG_KERNEL) - zlog_debug ("%s: No useful nexthops were found in RIB entry %p", __func__, rib); + zlog_debug ("%s: No useful nexthops were found in RIB entry %p", __func__, re); return 0; /*XXX*/ } @@ -262,7 +262,7 @@ sin6_masklen (struct in6_addr mask) /* Interface between zebra message and rtm message. */ static int -kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib) +kernel_rtm_ipv6 (int cmd, struct prefix *p, struct route_entry *re) { struct sockaddr_in6 *mask; struct sockaddr_in6 sin_dest, sin_mask, sin_gate; @@ -289,7 +289,7 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib) #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ /* Make gateway. */ - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -349,8 +349,8 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib) gate ? (union sockunion *)&sin_gate : NULL, NULL, ifindex, - rib->flags, - rib->metric); + re->flags, + re->metric); #if 0 if (error) @@ -377,21 +377,21 @@ kernel_rtm_ipv6 (int cmd, struct prefix *p, struct rib *rib) } static int -kernel_rtm (int cmd, struct prefix *p, struct rib *rib) +kernel_rtm (int cmd, struct prefix *p, struct route_entry *re) { switch (PREFIX_FAMILY(p)) { case AF_INET: - return kernel_rtm_ipv4 (cmd, p, rib); + return kernel_rtm_ipv4 (cmd, p, re); case AF_INET6: - return kernel_rtm_ipv6 (cmd, p, rib); + return kernel_rtm_ipv6 (cmd, p, re); } return 0; } int kernel_route_rib (struct prefix *p, struct prefix *src_p, - struct rib *old, struct rib *new) + struct route_entry *old, struct route_entry *new) { int route = 0; diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 2a23ff1027..37068c1fae 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -866,7 +866,7 @@ zfpm_writes_pending (void) * value indicates an error. */ static inline int -zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf, +zfpm_encode_route (rib_dest_t *dest, struct route_entry *re, char *in_buf, size_t in_buf_len, fpm_msg_type_e *msg_type) { size_t len; @@ -881,7 +881,7 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf, case ZFPM_MSG_FORMAT_PROTOBUF: #ifdef HAVE_PROTOBUF - len = zfpm_protobuf_encode_route (dest, rib, (uint8_t *) in_buf, + len = zfpm_protobuf_encode_route (dest, re, (uint8_t *) in_buf, in_buf_len); *msg_type = FPM_MSG_TYPE_PROTOBUF; #endif @@ -890,8 +890,8 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf, case ZFPM_MSG_FORMAT_NETLINK: #ifdef HAVE_NETLINK *msg_type = FPM_MSG_TYPE_NETLINK; - cmd = rib ? RTM_NEWROUTE : RTM_DELROUTE; - len = zfpm_netlink_encode_route (cmd, dest, rib, in_buf, in_buf_len); + cmd = re ? RTM_NEWROUTE : RTM_DELROUTE; + len = zfpm_netlink_encode_route (cmd, dest, re, in_buf, in_buf_len); assert(fpm_msg_align(len) == len); *msg_type = FPM_MSG_TYPE_NETLINK; #endif /* HAVE_NETLINK */ @@ -908,19 +908,19 @@ zfpm_encode_route (rib_dest_t *dest, struct rib *rib, char *in_buf, /* * zfpm_route_for_update * - * Returns the rib that is to be sent to the FPM for a given dest. + * Returns the re that is to be sent to the FPM for a given dest. */ -struct rib * +struct route_entry * zfpm_route_for_update (rib_dest_t *dest) { - struct rib *rib; + struct route_entry *re; - RIB_DEST_FOREACH_ROUTE (dest, rib) + RE_DEST_FOREACH_ROUTE (dest, re) { - if (!CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) + if (!CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB)) continue; - return rib; + return re; } /* @@ -944,7 +944,7 @@ zfpm_build_updates (void) size_t msg_len; size_t data_len; fpm_msg_hdr_t *hdr; - struct rib *rib; + struct route_entry *re; int is_add, write_msg; fpm_msg_type_e msg_type; @@ -974,8 +974,8 @@ zfpm_build_updates (void) data = fpm_msg_data (hdr); - rib = zfpm_route_for_update (dest); - is_add = rib ? 1 : 0; + re = zfpm_route_for_update (dest); + is_add = re ? 1 : 0; write_msg = 1; @@ -990,7 +990,7 @@ zfpm_build_updates (void) } if (write_msg) { - data_len = zfpm_encode_route (dest, rib, (char *) data, buf_end - data, + data_len = zfpm_encode_route (dest, re, (char *) data, buf_end - data, &msg_type); assert (data_len); diff --git a/zebra/zebra_fpm_dt.c b/zebra/zebra_fpm_dt.c index db28b6f0e4..916640928b 100644 --- a/zebra/zebra_fpm_dt.c +++ b/zebra/zebra_fpm_dt.c @@ -67,13 +67,13 @@ extern int zfpm_dt_benchmark_protobuf_decode (int argc, const char **argv); * Selects a suitable rib destination for fpm interface tests. */ static int -zfpm_dt_find_route (rib_dest_t **dest_p, struct rib **rib_p) +zfpm_dt_find_route (rib_dest_t **dest_p, struct route_entry **re_p) { struct route_node *rnode; route_table_iter_t iter; struct route_table *table; rib_dest_t *dest; - struct rib *rib; + struct route_entry *re; int ret; table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); @@ -88,15 +88,15 @@ zfpm_dt_find_route (rib_dest_t **dest_p, struct rib **rib_p) if (!dest) continue; - rib = zfpm_route_for_update(dest); - if (!rib) + re = zfpm_route_for_update(dest); + if (!re) continue; - if (rib->nexthop_active_num <= 0) + if (re->nexthop_active_num <= 0) continue; *dest_p = dest; - *rib_p = rib; + *re_p = re; ret = 1; goto done; } @@ -117,7 +117,7 @@ zfpm_dt_benchmark_netlink_encode (int argc, const char **argv) { int times, i, len; rib_dest_t *dest; - struct rib *rib; + struct route_entry *re; char buf[4096]; times = 100000; @@ -125,12 +125,12 @@ zfpm_dt_benchmark_netlink_encode (int argc, const char **argv) times = atoi(argv[0]); } - if (!zfpm_dt_find_route(&dest, &rib)) { + if (!zfpm_dt_find_route(&dest, &re)) { return 1; } for (i = 0; i < times; i++) { - len = zfpm_netlink_encode_route(RTM_NEWROUTE, dest, rib, buf, sizeof(buf)); + len = zfpm_netlink_encode_route(RTM_NEWROUTE, dest, re, buf, sizeof(buf)); if (len <= 0) { return 2; } @@ -150,7 +150,7 @@ zfpm_dt_benchmark_protobuf_encode (int argc, const char **argv) { int times, i, len; rib_dest_t *dest; - struct rib *rib; + struct route_entry *re; uint8_t buf[4096]; times = 100000; @@ -158,12 +158,12 @@ zfpm_dt_benchmark_protobuf_encode (int argc, const char **argv) times = atoi(argv[0]); } - if (!zfpm_dt_find_route(&dest, &rib)) { + if (!zfpm_dt_find_route(&dest, &re)) { return 1; } for (i = 0; i < times; i++) { - len = zfpm_protobuf_encode_route(dest, rib, buf, sizeof(buf)); + len = zfpm_protobuf_encode_route(dest, re, buf, sizeof(buf)); if (len <= 0) { return 2; } @@ -229,7 +229,7 @@ zfpm_dt_benchmark_protobuf_decode (int argc, const char **argv) { int times, i, len; rib_dest_t *dest; - struct rib *rib; + struct route_entry *re; uint8_t msg_buf[4096]; QPB_DECLARE_STACK_ALLOCATOR (allocator, 8192); Fpm__Message *fpm_msg; @@ -240,13 +240,13 @@ zfpm_dt_benchmark_protobuf_decode (int argc, const char **argv) if (argc > 0) times = atoi(argv[0]); - if (!zfpm_dt_find_route (&dest, &rib)) + if (!zfpm_dt_find_route (&dest, &re)) return 1; /* * Encode the route into the message buffer once only. */ - len = zfpm_protobuf_encode_route (dest, rib, msg_buf, sizeof (msg_buf)); + len = zfpm_protobuf_encode_route (dest, re, msg_buf, sizeof (msg_buf)); if (len <= 0) return 2; diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 4ca7b59726..c5647debc3 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -231,7 +231,7 @@ netlink_proto_from_route_type (int type) */ static int netlink_route_info_fill (netlink_route_info_t *ri, int cmd, - rib_dest_t *dest, struct rib *rib) + rib_dest_t *dest, struct route_entry *re) { struct nexthop *nexthop, *tnexthop; int recursing; @@ -250,18 +250,18 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd, * An RTM_DELROUTE need not be accompanied by any nexthops, * particularly in our communication with the FPM. */ - if (cmd == RTM_DELROUTE && !rib) + if (cmd == RTM_DELROUTE && !re) return 1; - if (!rib) + if (!re) { - zfpm_debug ("%s: Expected non-NULL rib pointer", __PRETTY_FUNCTION__); + zfpm_debug ("%s: Expected non-NULL re pointer", __PRETTY_FUNCTION__); return 0; } - ri->rtm_protocol = netlink_proto_from_route_type (rib->type); + ri->rtm_protocol = netlink_proto_from_route_type (re->type); - if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT)) + if ((re->flags & ZEBRA_FLAG_BLACKHOLE) || (re->flags & ZEBRA_FLAG_REJECT)) discard = 1; else discard = 0; @@ -270,9 +270,9 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd, { if (discard) { - if (rib->flags & ZEBRA_FLAG_BLACKHOLE) + if (re->flags & ZEBRA_FLAG_BLACKHOLE) ri->rtm_type = RTN_BLACKHOLE; - else if (rib->flags & ZEBRA_FLAG_REJECT) + else if (re->flags & ZEBRA_FLAG_REJECT) ri->rtm_type = RTN_UNREACHABLE; else assert (0); @@ -281,12 +281,12 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd, ri->rtm_type = RTN_UNICAST; } - ri->metric = &rib->metric; + ri->metric = &re->metric; if (discard) return 1; - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (ri->num_nhs >= multipath_num) break; @@ -474,14 +474,14 @@ zfpm_log_route_info (netlink_route_info_t *ri, const char *label) * value indicates an error. */ int -zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct rib *rib, +zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct route_entry *re, char *in_buf, size_t in_buf_len) { netlink_route_info_t ri_space, *ri; ri = &ri_space; - if (!netlink_route_info_fill (ri, cmd, dest, rib)) + if (!netlink_route_info_fill (ri, cmd, dest, re)) return 0; zfpm_log_route_info (ri, __FUNCTION__); diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h index 49650541e7..441a22a798 100644 --- a/zebra/zebra_fpm_private.h +++ b/zebra/zebra_fpm_private.h @@ -49,12 +49,12 @@ static inline void zfpm_debug(const char *format, ...) { return; } * Externs */ extern int -zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct rib *rib, +zfpm_netlink_encode_route (int cmd, rib_dest_t *dest, struct route_entry *re, char *in_buf, size_t in_buf_len); extern int -zfpm_protobuf_encode_route (rib_dest_t *dest, struct rib *rib, +zfpm_protobuf_encode_route (rib_dest_t *dest, struct route_entry *re, uint8_t *in_buf, size_t in_buf_len); -extern struct rib *zfpm_route_for_update (rib_dest_t *dest); +extern struct route_entry *zfpm_route_for_update (rib_dest_t *dest); #endif /* _ZEBRA_FPM_PRIVATE_H */ diff --git a/zebra/zebra_fpm_protobuf.c b/zebra/zebra_fpm_protobuf.c index 312d4cd3ed..375fde921e 100644 --- a/zebra/zebra_fpm_protobuf.c +++ b/zebra/zebra_fpm_protobuf.c @@ -41,7 +41,7 @@ */ static Fpm__DeleteRoute * create_delete_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, - struct rib *rib) + struct route_entry *re) { Fpm__DeleteRoute *msg; @@ -141,7 +141,7 @@ add_nexthop (qpb_allocator_t *allocator, Fpm__AddRoute *msg, rib_dest_t *dest, */ static Fpm__AddRoute * create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, - struct rib *rib) + struct route_entry *re) { Fpm__AddRoute *msg; int discard; @@ -167,18 +167,18 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, */ msg->sub_address_family = QPB__SUB_ADDRESS_FAMILY__UNICAST; msg->key = fpm_route_key_create (allocator, rib_dest_prefix(dest)); - qpb_protocol_set (&msg->protocol, rib->type); + qpb_protocol_set (&msg->protocol, re->type); - if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT)) + if ((re->flags & ZEBRA_FLAG_BLACKHOLE) || (re->flags & ZEBRA_FLAG_REJECT)) discard = 1; else discard = 0; if (discard) { - if (rib->flags & ZEBRA_FLAG_BLACKHOLE) { + if (re->flags & ZEBRA_FLAG_BLACKHOLE) { msg->route_type = FPM__ROUTE_TYPE__BLACKHOLE; - } else if (rib->flags & ZEBRA_FLAG_REJECT) { + } else if (re->flags & ZEBRA_FLAG_REJECT) { msg->route_type = FPM__ROUTE_TYPE__UNREACHABLE; } else { assert (0); @@ -189,13 +189,13 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, msg->route_type = FPM__ROUTE_TYPE__NORMAL; } - msg->metric = rib->metric; + msg->metric = re->metric; /* * Figure out the set of nexthops to be added to the message. */ num_nhs = 0; - for (ALL_NEXTHOPS_RO (rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO (re->nexthop, nexthop, tnexthop, recursing)) { if (num_nhs >= multipath_num) break; @@ -245,7 +245,7 @@ create_add_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, */ static Fpm__Message * create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, - struct rib *rib) + struct route_entry *re) { Fpm__Message *msg; @@ -257,9 +257,9 @@ create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, fpm__message__init(msg); - if (!rib) { + if (!re) { msg->type = FPM__MESSAGE__TYPE__DELETE_ROUTE; - msg->delete_route = create_delete_route_message(allocator, dest, rib); + msg->delete_route = create_delete_route_message(allocator, dest, re); if (!msg->delete_route) { assert(0); return NULL; @@ -268,7 +268,7 @@ create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, } msg->type = FPM__MESSAGE__TYPE__ADD_ROUTE; - msg->add_route = create_add_route_message(allocator, dest, rib); + msg->add_route = create_add_route_message(allocator, dest, re); if (!msg->add_route) { assert(0); return NULL; @@ -287,7 +287,7 @@ create_route_message (qpb_allocator_t *allocator, rib_dest_t *dest, * value indicates an error. */ int -zfpm_protobuf_encode_route (rib_dest_t *dest, struct rib *rib, +zfpm_protobuf_encode_route (rib_dest_t *dest, struct route_entry *re, uint8_t *in_buf, size_t in_buf_len) { Fpm__Message *msg; @@ -296,7 +296,7 @@ zfpm_protobuf_encode_route (rib_dest_t *dest, struct rib *rib, QPB_INIT_STACK_ALLOCATOR (allocator); - msg = create_route_message(&allocator, dest, rib); + msg = create_route_message(&allocator, dest, re); if (!msg) { assert(0); return 0; diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c index 51c240ae28..b8e1a130eb 100644 --- a/zebra/zebra_memory.c +++ b/zebra/zebra_memory.c @@ -28,7 +28,7 @@ DEFINE_MGROUP(ZEBRA, "zebra") DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix") DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF") -DEFINE_MTYPE(ZEBRA, RIB, "RIB") +DEFINE_MTYPE(ZEBRA, RE, "Route Entry") DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue") DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route") DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination") diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h index 35d70d81ee..e3439d5f64 100644 --- a/zebra/zebra_memory.h +++ b/zebra/zebra_memory.h @@ -28,7 +28,7 @@ DECLARE_MGROUP(ZEBRA) DECLARE_MTYPE(RTADV_PREFIX) DECLARE_MTYPE(ZEBRA_NS) DECLARE_MTYPE(ZEBRA_VRF) -DECLARE_MTYPE(RIB) +DECLARE_MTYPE(RE) DECLARE_MTYPE(RIB_QUEUE) DECLARE_MTYPE(STATIC_ROUTE) DECLARE_MTYPE(RIB_DEST) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index b547c62566..db02a025f9 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -65,7 +65,7 @@ static u_int32_t fec_derive_label_from_index (struct zebra_vrf *vrf, zebra_fec_t *fec); static int lsp_install (struct zebra_vrf *zvrf, mpls_label_t label, - struct route_node *rn, struct rib *rib); + struct route_node *rn, struct route_entry *re); static int lsp_uninstall (struct zebra_vrf *zvrf, mpls_label_t label); static int @@ -168,7 +168,7 @@ mpls_processq_init (struct zebra_t *zebra); */ static int lsp_install (struct zebra_vrf *zvrf, mpls_label_t label, - struct route_node *rn, struct rib *rib) + struct route_node *rn, struct route_entry *re) { struct hash *lsp_table; zebra_ile_t tmp_ile; @@ -184,7 +184,7 @@ lsp_install (struct zebra_vrf *zvrf, mpls_label_t label, if (!lsp_table) return -1; - lsp_type = lsp_type_from_rib_type (rib->type); + lsp_type = lsp_type_from_re_type (re->type); added = changed = 0; /* Locate or allocate LSP entry. */ @@ -198,7 +198,7 @@ lsp_install (struct zebra_vrf *zvrf, mpls_label_t label, * the label advertised by the recursive nexthop (plus we don't have the * logic yet to push multiple labels). */ - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) { /* Skip inactive and recursive entries. */ if (!CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) @@ -441,7 +441,7 @@ fec_change_update_lsp (struct zebra_vrf *zvrf, zebra_fec_t *fec, mpls_label_t ol { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; afi_t afi; /* Uninstall label forwarding entry, if previously installed. */ @@ -464,16 +464,16 @@ fec_change_update_lsp (struct zebra_vrf *zvrf, zebra_fec_t *fec, mpls_label_t ol if (!rn) return 0; - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)) break; } - if (!rib || !zebra_rib_labeled_unicast (rib)) + if (!re || !zebra_rib_labeled_unicast (re)) return 0; - if (lsp_install (zvrf, fec->label, rn, rib)) + if (lsp_install (zvrf, fec->label, rn, re)) return -1; return 0; @@ -656,7 +656,7 @@ nhlfe_nexthop_active_ipv4 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop) struct route_table *table; struct prefix_ipv4 p; struct route_node *rn; - struct rib *match; + struct route_entry *match; struct nexthop *match_nh; table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, VRF_DEFAULT); @@ -676,9 +676,9 @@ nhlfe_nexthop_active_ipv4 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop) route_unlock_node (rn); /* Locate a valid connected route. */ - RNODE_FOREACH_RIB (rn, match) + RNODE_FOREACH_RE (rn, match) { - if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED) || + if (CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED) || !CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED)) continue; @@ -708,7 +708,7 @@ nhlfe_nexthop_active_ipv6 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop) struct route_table *table; struct prefix_ipv6 p; struct route_node *rn; - struct rib *match; + struct route_entry *match; table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, VRF_DEFAULT); if (!table) @@ -727,10 +727,10 @@ nhlfe_nexthop_active_ipv6 (zebra_nhlfe_t *nhlfe, struct nexthop *nexthop) route_unlock_node (rn); /* Locate a valid connected route. */ - RNODE_FOREACH_RIB (rn, match) + RNODE_FOREACH_RE (rn, match) { if ((match->type == ZEBRA_ROUTE_CONNECT) && - !CHECK_FLAG (match->status, RIB_ENTRY_REMOVED) && + !CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED) && CHECK_FLAG (match->flags, ZEBRA_FLAG_SELECTED)) break; } @@ -1809,7 +1809,7 @@ mpls_label2str (u_int8_t num_labels, mpls_label_t *labels, * Install dynamic LSP entry. */ int -zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib) +zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re) { struct route_table *table; zebra_fec_t *fec; @@ -1829,7 +1829,7 @@ zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct ri if (fec->label == MPLS_IMP_NULL_LABEL) return 0; - if (lsp_install (zvrf, fec->label, rn, rib)) + if (lsp_install (zvrf, fec->label, rn, re)) return -1; return 0; @@ -1839,7 +1839,7 @@ zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct ri * Uninstall dynamic LSP entry, if any. */ int -zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib) +zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re) { struct route_table *table; zebra_fec_t *fec; @@ -2296,7 +2296,7 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type, { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; struct nexthop *nexthop; /* Lookup table. */ @@ -2306,18 +2306,18 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type, /* Lookup existing route */ rn = route_node_get (table, prefix); - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->distance == distance) + if (re->distance == distance) break; } - if (rib == NULL) + if (re == NULL) return -1; - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) { switch (nexthop->type) { @@ -2356,8 +2356,8 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type, else return 0; - SET_FLAG (rib->status, RIB_ENTRY_CHANGED); - SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); rib_queue_add (rn); return 0; @@ -2534,7 +2534,7 @@ mpls_ldp_ftn_uninstall_all (struct zebra_vrf *zvrf, int afi) { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; struct nexthop *nexthop; int update; @@ -2546,13 +2546,13 @@ mpls_ldp_ftn_uninstall_all (struct zebra_vrf *zvrf, int afi) for (rn = route_top (table); rn; rn = route_next (rn)) { update = 0; - RNODE_FOREACH_RIB (rn, rib) - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + RNODE_FOREACH_RE (rn, re) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) if (nexthop->nh_label_type == ZEBRA_LSP_LDP) { nexthop_del_labels (nexthop); - SET_FLAG (rib->status, RIB_ENTRY_CHANGED); - SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); update = 1; } diff --git a/zebra/zebra_mpls.h b/zebra/zebra_mpls.h index 1f17de67a3..047b432136 100644 --- a/zebra/zebra_mpls.h +++ b/zebra/zebra_mpls.h @@ -208,13 +208,13 @@ zebra_mpls_write_label_block_config (struct vty *vty, struct zebra_vrf *vrf); * Install dynamic LSP entry. */ int -zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib); +zebra_mpls_lsp_install (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re); /* * Uninstall dynamic LSP entry, if any. */ int -zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct rib *rib); +zebra_mpls_lsp_uninstall (struct zebra_vrf *zvrf, struct route_node *rn, struct route_entry *re); /* * Registration from a client for the label binding for a FEC. If a binding @@ -449,9 +449,9 @@ lsp_distance (enum lsp_types_t type) * are converted into LSPs. */ static inline enum lsp_types_t -lsp_type_from_rib_type (int rib_type) +lsp_type_from_re_type (int re_type) { - switch (rib_type) + switch (re_type) { case ZEBRA_ROUTE_STATIC: return ZEBRA_LSP_STATIC; diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 5f457a6fc5..ca15d7eadc 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -184,10 +184,10 @@ zebra_check_addr (struct prefix *p) /* Add nexthop to the end of a rib node's nexthop list */ void -rib_nexthop_add (struct rib *rib, struct nexthop *nexthop) +route_entry_nexthop_add (struct route_entry *re, struct nexthop *nexthop) { - nexthop_add(&rib->nexthop, nexthop); - rib->nexthop_num++; + nexthop_add(&re->nexthop, nexthop); + re->nexthop_num++; } @@ -196,7 +196,7 @@ rib_nexthop_add (struct rib *rib, struct nexthop *nexthop) * copy_nexthop - copy a nexthop to the rib structure. */ void -rib_copy_nexthops (struct rib *rib, struct nexthop *nh) +route_entry_copy_nexthops (struct route_entry *re, struct nexthop *nh) { struct nexthop *nexthop; @@ -209,28 +209,28 @@ rib_copy_nexthops (struct rib *rib, struct nexthop *nh) if (nh->nh_label) nexthop_add_labels (nexthop, nh->nh_label_type, nh->nh_label->num_labels, &nh->nh_label->label[0]); - rib_nexthop_add(rib, nexthop); + route_entry_nexthop_add(re, nexthop); if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) copy_nexthops(&nexthop->resolved, nh->resolved); } /* Delete specified nexthop from the list. */ void -rib_nexthop_delete (struct rib *rib, struct nexthop *nexthop) +route_entry_nexthop_delete (struct route_entry *re, struct nexthop *nexthop) { if (nexthop->next) nexthop->next->prev = nexthop->prev; if (nexthop->prev) nexthop->prev->next = nexthop->next; else - rib->nexthop = nexthop->next; - rib->nexthop_num--; + re->nexthop = nexthop->next; + re->nexthop_num--; } struct nexthop * -rib_nexthop_ifindex_add (struct rib *rib, ifindex_t ifindex) +route_entry_nexthop_ifindex_add (struct route_entry *re, ifindex_t ifindex) { struct nexthop *nexthop; @@ -238,13 +238,13 @@ rib_nexthop_ifindex_add (struct rib *rib, ifindex_t ifindex) nexthop->type = NEXTHOP_TYPE_IFINDEX; nexthop->ifindex = ifindex; - rib_nexthop_add (rib, nexthop); + route_entry_nexthop_add (re, nexthop); return nexthop; } struct nexthop * -rib_nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src) +route_entry_nexthop_ipv4_add (struct route_entry *re, struct in_addr *ipv4, struct in_addr *src) { struct nexthop *nexthop; @@ -254,13 +254,13 @@ rib_nexthop_ipv4_add (struct rib *rib, struct in_addr *ipv4, struct in_addr *src if (src) nexthop->src.ipv4 = *src; - rib_nexthop_add (rib, nexthop); + route_entry_nexthop_add (re, nexthop); return nexthop; } struct nexthop * -rib_nexthop_ipv4_ifindex_add (struct rib *rib, struct in_addr *ipv4, +route_entry_nexthop_ipv4_ifindex_add (struct route_entry *re, struct in_addr *ipv4, struct in_addr *src, ifindex_t ifindex) { struct nexthop *nexthop; @@ -280,13 +280,13 @@ rib_nexthop_ipv4_ifindex_add (struct rib *rib, struct in_addr *ipv4, SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK); } - rib_nexthop_add (rib, nexthop); + route_entry_nexthop_add (re, nexthop); return nexthop; } struct nexthop * -rib_nexthop_ipv6_add (struct rib *rib, struct in6_addr *ipv6) +route_entry_nexthop_ipv6_add (struct route_entry *re, struct in6_addr *ipv6) { struct nexthop *nexthop; @@ -294,13 +294,13 @@ rib_nexthop_ipv6_add (struct rib *rib, struct in6_addr *ipv6) nexthop->type = NEXTHOP_TYPE_IPV6; nexthop->gate.ipv6 = *ipv6; - rib_nexthop_add (rib, nexthop); + route_entry_nexthop_add (re, nexthop); return nexthop; } struct nexthop * -rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6, +route_entry_nexthop_ipv6_ifindex_add (struct route_entry *re, struct in6_addr *ipv6, ifindex_t ifindex) { struct nexthop *nexthop; @@ -310,53 +310,35 @@ rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6, nexthop->gate.ipv6 = *ipv6; nexthop->ifindex = ifindex; - rib_nexthop_add (rib, nexthop); + route_entry_nexthop_add (re, nexthop); return nexthop; } struct nexthop * -rib_nexthop_blackhole_add (struct rib *rib) +route_entry_nexthop_blackhole_add (struct route_entry *re) { struct nexthop *nexthop; nexthop = nexthop_new(); nexthop->type = NEXTHOP_TYPE_BLACKHOLE; - SET_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE); + SET_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE); - rib_nexthop_add (rib, nexthop); + route_entry_nexthop_add (re, nexthop); return nexthop; } -/* This method checks whether a recursive nexthop has at - * least one resolved nexthop in the fib. - */ -int -nexthop_has_fib_child(struct nexthop *nexthop) -{ - struct nexthop *nh; - - if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) - return 0; - - for (nh = nexthop->resolved; nh; nh = nh->next) - if (CHECK_FLAG (nh->flags, NEXTHOP_FLAG_FIB)) - return 1; - - return 0; -} - /* If force flag is not set, do not modify falgs at all for uninstall the route from FIB. */ static int -nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, +nexthop_active (afi_t afi, struct route_entry *re, struct nexthop *nexthop, int set, struct route_node *top) { struct prefix p; struct route_table *table; struct route_node *rn; - struct rib *match; + struct route_entry *match; int resolved; struct nexthop *newhop, *tnewhop; struct nexthop *resolved_hop; @@ -369,10 +351,10 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, if (set) { UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE); - zebra_deregister_rnh_static_nexthops(rib->vrf_id, nexthop->resolved, top); + zebra_deregister_rnh_static_nexthops(re->vrf_id, nexthop->resolved, top); nexthops_free(nexthop->resolved); nexthop->resolved = NULL; - rib->nexthop_mtu = 0; + re->nexthop_mtu = 0; } /* Skip nexthops that have been filtered out due to route-map */ @@ -419,7 +401,7 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, break; } /* Lookup table. */ - table = zebra_vrf_table (afi, SAFI_UNICAST, rib->vrf_id); + table = zebra_vrf_table (afi, SAFI_UNICAST, re->vrf_id); if (! table) return 0; @@ -438,15 +420,15 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, !nh_resolve_via_default (p.family)) return 0; - RNODE_FOREACH_RIB (rn, match) + RNODE_FOREACH_RE (rn, match) { - if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED)) continue; /* if the next hop is imported from another table, skip it */ if (match->type == ZEBRA_ROUTE_TABLE) continue; - if (CHECK_FLAG (match->status, RIB_ENTRY_SELECTED_FIB)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_SELECTED_FIB)) break; } @@ -480,7 +462,7 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, } return 1; } - else if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_INTERNAL)) + else if (CHECK_FLAG (re->flags, ZEBRA_FLAG_INTERNAL)) { resolved = 0; for (newhop = match->nexthop; newhop; newhop = newhop->next) @@ -490,7 +472,7 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, if (set) { SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE); - SET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + SET_FLAG(re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); resolved_hop = nexthop_new(); SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE); @@ -552,7 +534,7 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, } return resolved; } - else if (rib->type == ZEBRA_ROUTE_STATIC) + else if (re->type == ZEBRA_ROUTE_STATIC) { resolved = 0; for (ALL_NEXTHOPS_RO(match->nexthop, newhop, tnewhop, recursing)) @@ -622,7 +604,7 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, resolved = 1; } if (resolved && set) - rib->nexthop_mtu = match->mtu; + re->nexthop_mtu = match->mtu; return resolved; } else @@ -634,14 +616,14 @@ nexthop_active (afi_t afi, struct rib *rib, struct nexthop *nexthop, int set, return 0; } -struct rib * +struct route_entry * rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id, union g_addr *addr, struct route_node **rn_out) { struct prefix p; struct route_table *table; struct route_node *rn; - struct rib *match; + struct route_entry *match; struct nexthop *newhop, *tnewhop; int recursing; @@ -670,11 +652,11 @@ rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id, route_unlock_node (rn); /* Pick up selected route. */ - RNODE_FOREACH_RIB (rn, match) + RNODE_FOREACH_RE (rn, match) { - if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED)) continue; - if (CHECK_FLAG (match->status, RIB_ENTRY_SELECTED_FIB)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_SELECTED_FIB)) break; } @@ -711,10 +693,10 @@ rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id, return NULL; } -struct rib * +struct route_entry * rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, struct route_node **rn_out) { - struct rib *rib = NULL, *mrib = NULL, *urib = NULL; + struct route_entry *re = NULL, *mre = NULL, *ure = NULL; struct route_node *m_rn = NULL, *u_rn = NULL; union g_addr gaddr = { .ipv4 = addr }; @@ -726,34 +708,34 @@ rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, struct route_nod return rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, rn_out); case MCAST_NO_CONFIG: case MCAST_MIX_MRIB_FIRST: - rib = mrib = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn); - if (!mrib) - rib = urib = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn); + re = mre = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn); + if (!mre) + re = ure = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn); break; case MCAST_MIX_DISTANCE: - mrib = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn); - urib = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn); - if (mrib && urib) - rib = urib->distance < mrib->distance ? urib : mrib; - else if (mrib) - rib = mrib; - else if (urib) - rib = urib; + mre = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn); + ure = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn); + if (mre && ure) + re = ure->distance < mre->distance ? ure : mre; + else if (mre) + re = mre; + else if (ure) + re = ure; break; case MCAST_MIX_PFXLEN: - mrib = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn); - urib = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn); - if (mrib && urib) - rib = u_rn->p.prefixlen > m_rn->p.prefixlen ? urib : mrib; - else if (mrib) - rib = mrib; - else if (urib) - rib = urib; + mre = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn); + ure = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn); + if (mre && ure) + re = u_rn->p.prefixlen > m_rn->p.prefixlen ? ure : mre; + else if (mre) + re = mre; + else if (ure) + re = ure; break; } if (rn_out) - *rn_out = (rib == mrib) ? m_rn : u_rn; + *rn_out = (re == mre) ? m_rn : u_rn; if (IS_ZEBRA_DEBUG_RIB) { @@ -762,11 +744,11 @@ rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, struct route_nod zlog_debug("%s: %s: found %s, using %s", __func__, buf, - mrib ? (urib ? "MRIB+URIB" : "MRIB") : - urib ? "URIB" : "nothing", - rib == urib ? "URIB" : rib == mrib ? "MRIB" : "none"); + mre ? (ure ? "MRIB+URIB" : "MRIB") : + ure ? "URIB" : "nothing", + re == ure ? "URIB" : re == mre ? "MRIB" : "none"); } - return rib; + return re; } void @@ -783,12 +765,12 @@ multicast_mode_ipv4_get (void) return ipv4_multicast_mode; } -struct rib * +struct route_entry * rib_lookup_ipv4 (struct prefix_ipv4 *p, vrf_id_t vrf_id) { struct route_table *table; struct route_node *rn; - struct rib *match; + struct route_entry *match; struct nexthop *nexthop, *tnexthop; int recursing; @@ -806,11 +788,11 @@ rib_lookup_ipv4 (struct prefix_ipv4 *p, vrf_id_t vrf_id) /* Unlock node. */ route_unlock_node (rn); - RNODE_FOREACH_RIB (rn, match) + RNODE_FOREACH_RE (rn, match) { - if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED)) continue; - if (CHECK_FLAG (match->status, RIB_ENTRY_SELECTED_FIB)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_SELECTED_FIB)) break; } @@ -830,7 +812,7 @@ rib_lookup_ipv4 (struct prefix_ipv4 *p, vrf_id_t vrf_id) /* * This clone function, unlike its original rib_lookup_ipv4(), checks * if specified IPv4 route record (prefix/mask -> gate) exists in - * the whole RIB and has RIB_ENTRY_SELECTED_FIB set. + * the whole RIB and has ROUTE_ENTRY_SELECTED_FIB set. * * Return values: * -1: error @@ -845,7 +827,7 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate, { struct route_table *table; struct route_node *rn; - struct rib *match; + struct route_entry *match; struct nexthop *nexthop, *tnexthop; int recursing; int nexthops_active; @@ -866,11 +848,11 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate, route_unlock_node (rn); /* Find out if a "selected" RR for the discovered RIB entry exists ever. */ - RNODE_FOREACH_RIB (rn, match) + RNODE_FOREACH_RE (rn, match) { - if (CHECK_FLAG (match->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_REMOVED)) continue; - if (CHECK_FLAG (match->status, RIB_ENTRY_SELECTED_FIB)) + if (CHECK_FLAG (match->status, ROUTE_ENTRY_SELECTED_FIB)) break; } @@ -919,7 +901,7 @@ rib_lookup_ipv4_route (struct prefix_ipv4 *p, union sockunion * qgate, */ static unsigned -nexthop_active_check (struct route_node *rn, struct rib *rib, +nexthop_active_check (struct route_node *rn, struct route_entry *re, struct nexthop *nexthop, int set) { struct interface *ifp; @@ -938,7 +920,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, switch (nexthop->type) { case NEXTHOP_TYPE_IFINDEX: - ifp = if_lookup_by_index (nexthop->ifindex, rib->vrf_id); + ifp = if_lookup_by_index (nexthop->ifindex, re->vrf_id); if (ifp && if_is_operative(ifp)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else @@ -947,14 +929,14 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV4_IFINDEX: family = AFI_IP; - if (nexthop_active (AFI_IP, rib, nexthop, set, rn)) + if (nexthop_active (AFI_IP, re, nexthop, set, rn)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); break; case NEXTHOP_TYPE_IPV6: family = AFI_IP6; - if (nexthop_active (AFI_IP6, rib, nexthop, set, rn)) + if (nexthop_active (AFI_IP6, re, nexthop, set, rn)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -965,7 +947,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, family = AFI_IP6; if (IN6_IS_ADDR_LINKLOCAL (&nexthop->gate.ipv6)) { - ifp = if_lookup_by_index (nexthop->ifindex, rib->vrf_id); + ifp = if_lookup_by_index (nexthop->ifindex, re->vrf_id); if (ifp && if_is_operative(ifp)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else @@ -973,7 +955,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, } else { - if (nexthop_active (AFI_IP6, rib, nexthop, set, rn)) + if (nexthop_active (AFI_IP6, re, nexthop, set, rn)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); else UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -990,7 +972,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, /* XXX: What exactly do those checks do? Do we support * e.g. IPv4 routes with IPv6 nexthops or vice versa? */ - if (RIB_SYSTEM_ROUTE(rib) || + if (RIB_SYSTEM_ROUTE(re) || (family == AFI_IP && p->family != AF_INET) || (family == AFI_IP6 && p->family != AF_INET6)) return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); @@ -1012,16 +994,16 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr)); /* It'll get set if required inside */ - ret = zebra_route_map_check(family, rib->type, p, nexthop, rib->vrf_id, - rib->tag); + ret = zebra_route_map_check(family, re->type, p, nexthop, re->vrf_id, + re->tag); if (ret == RMAP_DENYMATCH) { if (IS_ZEBRA_DEBUG_RIB) { srcdest_rnode2str(rn, buf, sizeof(buf)); zlog_debug("%u:%s: Filtering out with NH out %s due to route map", - rib->vrf_id, buf, - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + re->vrf_id, buf, + ifindex2ifname (nexthop->ifindex, re->vrf_id)); } UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); } @@ -1029,34 +1011,34 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, } /* Iterate over all nexthops of the given RIB entry and refresh their - * ACTIVE flag. rib->nexthop_active_num is updated accordingly. If any - * nexthop is found to toggle the ACTIVE flag, the whole rib structure - * is flagged with RIB_ENTRY_CHANGED. The 4th 'set' argument is + * ACTIVE flag. re->nexthop_active_num is updated accordingly. If any + * nexthop is found to toggle the ACTIVE flag, the whole re structure + * is flagged with ROUTE_ENTRY_CHANGED. The 4th 'set' argument is * transparently passed to nexthop_active_check(). * * Return value is the new number of active nexthops. */ static int -nexthop_active_update (struct route_node *rn, struct rib *rib, int set) +nexthop_active_update (struct route_node *rn, struct route_entry *re, int set) { struct nexthop *nexthop; union g_addr prev_src; unsigned int prev_active, new_active, old_num_nh; ifindex_t prev_index; - old_num_nh = rib->nexthop_active_num; + old_num_nh = re->nexthop_active_num; - rib->nexthop_active_num = 0; - UNSET_FLAG (rib->status, RIB_ENTRY_CHANGED); + re->nexthop_active_num = 0; + UNSET_FLAG (re->status, ROUTE_ENTRY_CHANGED); - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) { /* No protocol daemon provides src and so we're skipping tracking it */ prev_src = nexthop->rmap_src; prev_active = CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); prev_index = nexthop->ifindex; - if ((new_active = nexthop_active_check (rn, rib, nexthop, set))) - rib->nexthop_active_num++; + if ((new_active = nexthop_active_check (rn, re, nexthop, set))) + re->nexthop_active_num++; /* Don't allow src setting on IPv6 addr for now */ if (prev_active != new_active || prev_index != nexthop->ifindex || @@ -1067,20 +1049,20 @@ nexthop_active_update (struct route_node *rn, struct rib *rib, int set) nexthop->type < NEXTHOP_TYPE_BLACKHOLE) && !(IPV6_ADDR_SAME (&prev_src.ipv6, &nexthop->rmap_src.ipv6)))) { - SET_FLAG (rib->status, RIB_ENTRY_CHANGED); - SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); } } - if (old_num_nh != rib->nexthop_active_num) - SET_FLAG (rib->status, RIB_ENTRY_CHANGED); + if (old_num_nh != re->nexthop_active_num) + SET_FLAG (re->status, ROUTE_ENTRY_CHANGED); - if (CHECK_FLAG (rib->status, RIB_ENTRY_CHANGED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_CHANGED)) { - SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + SET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); } - return rib->nexthop_active_num; + return re->nexthop_active_num; } /* @@ -1088,15 +1070,15 @@ nexthop_active_update (struct route_node *rn, struct rib *rib, int set) * (nexthops) must have a label. */ int -zebra_rib_labeled_unicast (struct rib *rib) +zebra_rib_labeled_unicast (struct route_entry *re) { struct nexthop *nexthop = NULL, *tnexthop; int recursing; - if (rib->type != ZEBRA_ROUTE_BGP) + if (re->type != ZEBRA_ROUTE_BGP) return 0; - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) if (!nexthop->nh_label || !nexthop->nh_label->num_labels) return 0; @@ -1107,20 +1089,20 @@ zebra_rib_labeled_unicast (struct rib *rib) * is only used for IPv4. */ int -rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old) +rib_install_kernel (struct route_node *rn, struct route_entry *re, struct route_entry *old) { int ret = 0; struct nexthop *nexthop, *tnexthop; rib_table_info_t *info = srcdest_rnode_table_info(rn); int recursing; struct prefix *p, *src_p; - struct zebra_vrf *zvrf = vrf_info_lookup (rib->vrf_id); + struct zebra_vrf *zvrf = vrf_info_lookup (re->vrf_id); srcdest_rnode_prefixes (rn, &p, &src_p); if (info->safi != SAFI_UNICAST) { - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); return ret; } @@ -1130,13 +1112,13 @@ rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old) * the kernel. */ hook_call(rib_update, rn, "installing in kernel"); - ret = kernel_route_rib (p, src_p, old, rib); + ret = kernel_route_rib (p, src_p, old, re); zvrf->installs++; /* If install succeeds, update FIB flag for nexthops. */ if (!ret) { - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) continue; @@ -1153,20 +1135,20 @@ rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old) /* Uninstall the route from kernel. */ int -rib_uninstall_kernel (struct route_node *rn, struct rib *rib) +rib_uninstall_kernel (struct route_node *rn, struct route_entry *re) { int ret = 0; struct nexthop *nexthop, *tnexthop; rib_table_info_t *info = srcdest_rnode_table_info(rn); int recursing; struct prefix *p, *src_p; - struct zebra_vrf *zvrf = vrf_info_lookup (rib->vrf_id); + struct zebra_vrf *zvrf = vrf_info_lookup (re->vrf_id); srcdest_rnode_prefixes (rn, &p, &src_p); if (info->safi != SAFI_UNICAST) { - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); return ret; } @@ -1176,10 +1158,10 @@ rib_uninstall_kernel (struct route_node *rn, struct rib *rib) * the kernel. */ hook_call(rib_update, rn, "uninstalling from kernel"); - ret = kernel_route_rib (p, src_p, rib, NULL); + ret = kernel_route_rib (p, src_p, re, NULL); zvrf->removals++; - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); return ret; @@ -1187,32 +1169,32 @@ rib_uninstall_kernel (struct route_node *rn, struct rib *rib) /* Uninstall the route from kernel. */ static void -rib_uninstall (struct route_node *rn, struct rib *rib) +rib_uninstall (struct route_node *rn, struct route_entry *re) { rib_table_info_t *info = srcdest_rnode_table_info(rn); - if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB)) { if (info->safi == SAFI_UNICAST) hook_call(rib_update, rn, "rib_uninstall"); - if (! RIB_SYSTEM_ROUTE (rib)) - rib_uninstall_kernel (rn, rib); + if (! RIB_SYSTEM_ROUTE (re)) + rib_uninstall_kernel (rn, re); /* If labeled-unicast route, uninstall transit LSP. */ - if (zebra_rib_labeled_unicast (rib)) - zebra_mpls_lsp_uninstall (info->zvrf, rn, rib); + if (zebra_rib_labeled_unicast (re)) + zebra_mpls_lsp_uninstall (info->zvrf, rn, re); - UNSET_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB); + UNSET_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB); } - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)) { struct prefix *p, *src_p; srcdest_rnode_prefixes (rn, &p, &src_p); - redistribute_delete (p, src_p, rib); - UNSET_FLAG (rib->flags, ZEBRA_FLAG_SELECTED); + redistribute_delete (p, src_p, re); + UNSET_FLAG (re->flags, ZEBRA_FLAG_SELECTED); } } @@ -1278,23 +1260,23 @@ rib_gc_dest (struct route_node *rn) static void rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn, - struct rib *new) + struct route_entry *new) { hook_call(rib_update, rn, "new route selected"); /* Update real nexthop. This may actually determine if nexthop is active or not. */ if (!nexthop_active_update (rn, new, 1)) { - UNSET_FLAG(new->status, RIB_ENTRY_CHANGED); + UNSET_FLAG(new->status, ROUTE_ENTRY_CHANGED); return; } - SET_FLAG (new->status, RIB_ENTRY_SELECTED_FIB); + SET_FLAG (new->status, ROUTE_ENTRY_SELECTED_FIB); if (IS_ZEBRA_DEBUG_RIB) { char buf[SRCDEST2STR_BUFFER]; srcdest_rnode2str(rn, buf, sizeof(buf)); - zlog_debug ("%u:%s: Adding route rn %p, rib %p (type %d)", + zlog_debug ("%u:%s: Adding route rn %p, re %p (type %d)", zvrf_id (zvrf), buf, rn, new, new->type); } @@ -1313,12 +1295,12 @@ rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn, } } - UNSET_FLAG(new->status, RIB_ENTRY_CHANGED); + UNSET_FLAG(new->status, ROUTE_ENTRY_CHANGED); } static void rib_process_del_fib(struct zebra_vrf *zvrf, struct route_node *rn, - struct rib *old) + struct route_entry *old) { hook_call(rib_update, rn, "removing existing route"); @@ -1327,7 +1309,7 @@ rib_process_del_fib(struct zebra_vrf *zvrf, struct route_node *rn, { char buf[SRCDEST2STR_BUFFER]; srcdest_rnode2str(rn, buf, sizeof(buf)); - zlog_debug ("%u:%s: Deleting route rn %p, rib %p (type %d)", + zlog_debug ("%u:%s: Deleting route rn %p, re %p (type %d)", zvrf_id (zvrf), buf, rn, old, old->type); } @@ -1338,16 +1320,16 @@ rib_process_del_fib(struct zebra_vrf *zvrf, struct route_node *rn, if (!RIB_SYSTEM_ROUTE (old)) rib_uninstall_kernel (rn, old); - UNSET_FLAG (old->status, RIB_ENTRY_SELECTED_FIB); + UNSET_FLAG (old->status, ROUTE_ENTRY_SELECTED_FIB); /* Update nexthop for route, reset changed flag. */ nexthop_active_update (rn, old, 1); - UNSET_FLAG(old->status, RIB_ENTRY_CHANGED); + UNSET_FLAG(old->status, ROUTE_ENTRY_CHANGED); } static void rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, - struct rib *old, struct rib *new) + struct route_entry *old, struct route_entry *new) { struct nexthop *nexthop = NULL, *tnexthop; int recursing; @@ -1359,7 +1341,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, * something has changed. */ if (new != old || - CHECK_FLAG (new->status, RIB_ENTRY_CHANGED)) + CHECK_FLAG (new->status, ROUTE_ENTRY_CHANGED)) { hook_call(rib_update, rn, "updating existing route"); @@ -1378,11 +1360,11 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, char buf[SRCDEST2STR_BUFFER]; srcdest_rnode2str(rn, buf, sizeof(buf)); if (new != old) - zlog_debug ("%u:%s: Updating route rn %p, rib %p (type %d) " + zlog_debug ("%u:%s: Updating route rn %p, re %p (type %d) " "old %p (type %d)", zvrf_id (zvrf), buf, rn, new, new->type, old, old->type); else - zlog_debug ("%u:%s: Updating route rn %p, rib %p (type %d)", + zlog_debug ("%u:%s: Updating route rn %p, re %p (type %d)", zvrf_id (zvrf), buf, rn, new, new->type); } @@ -1423,7 +1405,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, /* Update for redistribution. */ if (installed) - SET_FLAG (new->status, RIB_ENTRY_SELECTED_FIB); + SET_FLAG (new->status, ROUTE_ENTRY_SELECTED_FIB); } /* @@ -1437,12 +1419,12 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, char buf[SRCDEST2STR_BUFFER]; srcdest_rnode2str(rn, buf, sizeof(buf)); if (new != old) - zlog_debug ("%u:%s: Deleting route rn %p, rib %p (type %d) " + zlog_debug ("%u:%s: Deleting route rn %p, re %p (type %d) " "old %p (type %d) - %s", zvrf_id (zvrf), buf, rn, new, new->type, old, old->type, nh_active ? "install failed" : "nexthop inactive"); else - zlog_debug ("%u:%s: Deleting route rn %p, rib %p (type %d) - %s", + zlog_debug ("%u:%s: Deleting route rn %p, re %p (type %d) - %s", zvrf_id (zvrf), buf, rn, new, new->type, nh_active ? "install failed" : "nexthop inactive"); } @@ -1453,7 +1435,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, if (!RIB_SYSTEM_ROUTE (old)) rib_uninstall_kernel (rn, old); - UNSET_FLAG (new->status, RIB_ENTRY_SELECTED_FIB); + UNSET_FLAG (new->status, ROUTE_ENTRY_SELECTED_FIB); } } else @@ -1482,20 +1464,20 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, /* Update prior route. */ if (new != old) { - UNSET_FLAG (old->status, RIB_ENTRY_SELECTED_FIB); + UNSET_FLAG (old->status, ROUTE_ENTRY_SELECTED_FIB); /* Set real nexthop. */ nexthop_active_update (rn, old, 1); - UNSET_FLAG(old->status, RIB_ENTRY_CHANGED); + UNSET_FLAG(old->status, ROUTE_ENTRY_CHANGED); } /* Clear changed flag. */ - UNSET_FLAG(new->status, RIB_ENTRY_CHANGED); + UNSET_FLAG(new->status, ROUTE_ENTRY_CHANGED); } /* Check if 'alternate' RIB entry is better than 'current'. */ -static struct rib * -rib_choose_best (struct rib *current, struct rib *alternate) +static struct route_entry * +rib_choose_best (struct route_entry *current, struct route_entry *alternate) { if (current == NULL) return alternate; @@ -1539,13 +1521,13 @@ rib_choose_best (struct rib *current, struct rib *alternate) static void rib_process (struct route_node *rn) { - struct rib *rib; - struct rib *next; - struct rib *old_selected = NULL; - struct rib *new_selected = NULL; - struct rib *old_fib = NULL; - struct rib *new_fib = NULL; - struct rib *best = NULL; + struct route_entry *re; + struct route_entry *next; + struct route_entry *old_selected = NULL; + struct route_entry *new_selected = NULL; + struct route_entry *old_fib = NULL; + struct route_entry *new_fib = NULL; + struct route_entry *best = NULL; char buf[SRCDEST2STR_BUFFER]; rib_dest_t *dest; struct zebra_vrf *zvrf = NULL; @@ -1568,31 +1550,31 @@ rib_process (struct route_node *rn) if (IS_ZEBRA_DEBUG_RIB_DETAILED) zlog_debug ("%u:%s: Processing rn %p", vrf_id, buf, rn); - RNODE_FOREACH_RIB_SAFE (rn, rib, next) + RNODE_FOREACH_RE_SAFE (rn, re, next) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) - zlog_debug ("%u:%s: Examine rib %p (type %d) status %x flags %x " + zlog_debug ("%u:%s: Examine re %p (type %d) status %x flags %x " "dist %d metric %d", - vrf_id, buf, rib, rib->type, rib->status, - rib->flags, rib->distance, rib->metric); + vrf_id, buf, re, re->type, re->status, + re->flags, re->distance, re->metric); - UNSET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + UNSET_FLAG(re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); - /* Currently selected rib. */ - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) + /* Currently selected re. */ + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)) { assert (old_selected == NULL); - old_selected = rib; + old_selected = re; } /* Currently in fib */ - if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB)) { assert (old_fib == NULL); - old_fib = rib; + old_fib = re; } /* Skip deleted entries from selection */ - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; /* Skip unreachable nexthop. */ @@ -1606,68 +1588,68 @@ rib_process (struct route_node *rn) * the nexthop_active_update() code. Thus, we might miss changes to * recursive NHs. */ - if (!CHECK_FLAG(rib->status, RIB_ENTRY_CHANGED) && - ! nexthop_active_update (rn, rib, 0)) + if (!CHECK_FLAG(re->status, ROUTE_ENTRY_CHANGED) && + ! nexthop_active_update (rn, re, 0)) { - if (rib->type == ZEBRA_ROUTE_TABLE) + if (re->type == ZEBRA_ROUTE_TABLE) { /* XXX: HERE BE DRAGONS!!!!! * In all honesty, I have not yet figured out what this part - * does or why the RIB_ENTRY_CHANGED test above is correct + * does or why the ROUTE_ENTRY_CHANGED test above is correct * or why we need to delete a route here, and also not whether * this concerns both selected and fib route, or only selected * or only fib */ /* This entry was denied by the 'ip protocol table' route-map, we * need to delete it */ - if (rib != old_selected) + if (re != old_selected) { if (IS_ZEBRA_DEBUG_RIB) zlog_debug ("%s: %s: imported via import-table but denied " "by the ip protocol table route-map", __func__, buf); - rib_unlink (rn, rib); + rib_unlink (rn, re); } else - SET_FLAG (rib->status, RIB_ENTRY_REMOVED); + SET_FLAG (re->status, ROUTE_ENTRY_REMOVED); } continue; } /* Infinite distance. */ - if (rib->distance == DISTANCE_INFINITY) + if (re->distance == DISTANCE_INFINITY) { - UNSET_FLAG (rib->status, RIB_ENTRY_CHANGED); + UNSET_FLAG (re->status, ROUTE_ENTRY_CHANGED); continue; } - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_FIB_OVERRIDE)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_FIB_OVERRIDE)) { - best = rib_choose_best(new_fib, rib); + best = rib_choose_best(new_fib, re); if (new_fib && best != new_fib) - UNSET_FLAG (new_fib->status, RIB_ENTRY_CHANGED); + UNSET_FLAG (new_fib->status, ROUTE_ENTRY_CHANGED); new_fib = best; } else { - best = rib_choose_best(new_selected, rib); + best = rib_choose_best(new_selected, re); if (new_selected && best != new_selected) - UNSET_FLAG (new_selected->status, RIB_ENTRY_CHANGED); + UNSET_FLAG (new_selected->status, ROUTE_ENTRY_CHANGED); new_selected = best; } - if (best != rib) - UNSET_FLAG (rib->status, RIB_ENTRY_CHANGED); - } /* RNODE_FOREACH_RIB */ + if (best != re) + UNSET_FLAG (re->status, ROUTE_ENTRY_CHANGED); + } /* RNODE_FOREACH_RE */ /* If no FIB override route, use the selected route also for FIB */ if (new_fib == NULL) new_fib = new_selected; /* After the cycle is finished, the following pointers will be set: - * old_selected --- RIB entry currently having SELECTED - * new_selected --- RIB entry that is newly SELECTED - * old_fib --- RIB entry currently in kernel FIB - * new_fib --- RIB entry that is newly to be in kernel FIB + * old_selected --- RE entry currently having SELECTED + * new_selected --- RE entry that is newly SELECTED + * old_fib --- RE entry currently in kernel FIB + * new_fib --- RE entry that is newly to be in kernel FIB * * new_selected will get SELECTED flag, and is going to be redistributed * the zclients. new_fib (which can be new_selected) will be installed in kernel. @@ -1683,10 +1665,10 @@ rib_process (struct route_node *rn) (void *)new_fib); } - /* Buffer RIB_ENTRY_CHANGED here, because it will get cleared if + /* Buffer ROUTE_ENTRY_CHANGED here, because it will get cleared if * fib == selected */ bool selected_changed = new_selected && CHECK_FLAG(new_selected->status, - RIB_ENTRY_CHANGED); + ROUTE_ENTRY_CHANGED); /* Update fib according to selection results */ if (new_fib && old_fib) @@ -1718,7 +1700,7 @@ rib_process (struct route_node *rn) if (new_selected && new_selected != new_fib) { nexthop_active_update(rn, new_selected, 1); - UNSET_FLAG(new_selected->status, RIB_ENTRY_CHANGED); + UNSET_FLAG(new_selected->status, ROUTE_ENTRY_CHANGED); } if (old_selected) @@ -1737,17 +1719,17 @@ rib_process (struct route_node *rn) } } - /* Remove all RIB entries queued for removal */ - RNODE_FOREACH_RIB_SAFE (rn, rib, next) + /* Remove all RE entries queued for removal */ + RNODE_FOREACH_RE_SAFE (rn, re, next) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) { if (IS_ZEBRA_DEBUG_RIB) { - rnode_debug (rn, vrf_id, "rn %p, removing rib %p", - (void *)rn, (void *)rib); + rnode_debug (rn, vrf_id, "rn %p, removing re %p", + (void *)rn, (void *)re); } - rib_unlink(rn, rib); + rib_unlink(rn, re); } } @@ -1884,11 +1866,11 @@ static const u_char meta_queue_map[ZEBRA_ROUTE_MAX] = { static void rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn) { - struct rib *rib; + struct route_entry *re; - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - u_char qindex = meta_queue_map[rib->type]; + u_char qindex = meta_queue_map[re->type]; struct zebra_vrf *zvrf; /* Invariant: at this point we always have rn->info set. */ @@ -1896,7 +1878,7 @@ rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn) RIB_ROUTE_QUEUED (qindex))) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) - rnode_debug (rn, rib->vrf_id, "rn %p is already queued in sub-queue %u", + rnode_debug (rn, re->vrf_id, "rn %p is already queued in sub-queue %u", (void *)rn, qindex); continue; } @@ -1907,10 +1889,10 @@ rib_meta_queue_add (struct meta_queue *mq, struct route_node *rn) mq->size++; if (IS_ZEBRA_DEBUG_RIB_DETAILED) - rnode_debug (rn, rib->vrf_id, "queued rn %p into sub-queue %u", + rnode_debug (rn, re->vrf_id, "queued rn %p into sub-queue %u", (void *)rn, qindex); - zvrf = zebra_vrf_lookup_by_id (rib->vrf_id); + zvrf = zebra_vrf_lookup_by_id (re->vrf_id); if (zvrf) zvrf->flags |= ZEBRA_VRF_RIB_SCHEDULED; } @@ -2019,22 +2001,22 @@ rib_queue_init (struct zebra_t *zebra) * The queue length is bounded by the maximal size of the routing table, * as a route_node will not be requeued, if already queued. * - * RIBs are submitted via rib_addnode or rib_delnode which set minimal - * state, or static_install_route (when an existing RIB is updated) + * REs are submitted via rib_addnode or rib_delnode which set minimal + * state, or static_install_route (when an existing RE is updated) * and then submit route_node to queue for best-path selection later. - * Order of add/delete state changes are preserved for any given RIB. + * Order of add/delete state changes are preserved for any given RE. * - * Deleted RIBs are reaped during best-path selection. + * Deleted REs are reaped during best-path selection. * * rib_addnode - * |-> rib_link or unset RIB_ENTRY_REMOVE |->Update kernel with - * |-------->| | best RIB, if required + * |-> rib_link or unset ROUTE_ENTRY_REMOVE |->Update kernel with + * |-------->| | best RE, if required * | | * static_install->|->rib_addqueue...... -> rib_process * | | * |-------->| |-> rib_unlink - * |-> set RIB_ENTRY_REMOVE | - * rib_delnode (RIB freed) + * |-> set ROUTE_ENTRY_REMOVE | + * rib_delnode (RE freed) * * The 'info' pointer of a route_node points to a rib_dest_t * ('dest'). Queueing state for a route_node is kept on the dest. The @@ -2051,22 +2033,22 @@ rib_queue_init (struct zebra_t *zebra) * */ -/* Add RIB to head of the route node. */ +/* Add RE to head of the route node. */ static void -rib_link (struct route_node *rn, struct rib *rib, int process) +rib_link (struct route_node *rn, struct route_entry *re, int process) { - struct rib *head; + struct route_entry *head; rib_dest_t *dest; afi_t afi; const char *rmap_name; - assert (rib && rn); + assert (re && rn); dest = rib_dest_from_rnode (rn); if (!dest) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) - rnode_debug (rn, rib->vrf_id, "rn %p adding dest", rn); + rnode_debug (rn, re->vrf_id, "rn %p adding dest", rn); dest = XCALLOC (MTYPE_RIB_DEST, sizeof (rib_dest_t)); route_lock_node (rn); /* rn route table reference */ @@ -2077,17 +2059,17 @@ rib_link (struct route_node *rn, struct rib *rib, int process) head = dest->routes; if (head) { - head->prev = rib; + head->prev = re; } - rib->next = head; - dest->routes = rib; + re->next = head; + dest->routes = re; afi = (rn->p.family == AF_INET) ? AFI_IP : (rn->p.family == AF_INET6) ? AFI_IP6 : AFI_MAX; - if (is_zebra_import_table_enabled (afi, rib->table)) + if (is_zebra_import_table_enabled (afi, re->table)) { - rmap_name = zebra_get_import_table_route_map (afi, rib->table); - zebra_add_import_table_entry(rn, rib, rmap_name); + rmap_name = zebra_get_import_table_route_map (afi, re->table); + zebra_add_import_table_entry(rn, re, rmap_name); } else if (process) @@ -2095,20 +2077,20 @@ rib_link (struct route_node *rn, struct rib *rib, int process) } void -rib_addnode (struct route_node *rn, struct rib *rib, int process) +rib_addnode (struct route_node *rn, struct route_entry *re, int process) { - /* RIB node has been un-removed before route-node is processed. - * route_node must hence already be on the queue for processing.. + /* RE node has been un-removed before route-node is processed. + * route_node must hence already be on the queue for processing.. */ - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) { if (IS_ZEBRA_DEBUG_RIB) - rnode_debug (rn, rib->vrf_id, "rn %p, un-removed rib %p", (void *)rn, (void *)rib); + rnode_debug (rn, re->vrf_id, "rn %p, un-removed re %p", (void *)rn, (void *)re); - UNSET_FLAG (rib->status, RIB_ENTRY_REMOVED); + UNSET_FLAG (re->status, ROUTE_ENTRY_REMOVED); return; } - rib_link (rn, rib, process); + rib_link (rn, re, process); } /* @@ -2121,58 +2103,58 @@ rib_addnode (struct route_node *rn, struct rib *rib, int process) * longer required to be deleted. */ void -rib_unlink (struct route_node *rn, struct rib *rib) +rib_unlink (struct route_node *rn, struct route_entry *re) { rib_dest_t *dest; - assert (rn && rib); + assert (rn && re); if (IS_ZEBRA_DEBUG_RIB) - rnode_debug (rn, rib->vrf_id, "rn %p, rib %p", (void *)rn, (void *)rib); + rnode_debug (rn, re->vrf_id, "rn %p, re %p", (void *)rn, (void *)re); dest = rib_dest_from_rnode (rn); - if (rib->next) - rib->next->prev = rib->prev; + if (re->next) + re->next->prev = re->prev; - if (rib->prev) - rib->prev->next = rib->next; + if (re->prev) + re->prev->next = re->next; else { - dest->routes = rib->next; + dest->routes = re->next; } - /* free RIB and nexthops */ - zebra_deregister_rnh_static_nexthops (rib->vrf_id, rib->nexthop, rn); - nexthops_free(rib->nexthop); - XFREE (MTYPE_RIB, rib); + /* free RE and nexthops */ + zebra_deregister_rnh_static_nexthops (re->vrf_id, re->nexthop, rn); + nexthops_free(re->nexthop); + XFREE (MTYPE_RE, re); } void -rib_delnode (struct route_node *rn, struct rib *rib) +rib_delnode (struct route_node *rn, struct route_entry *re) { afi_t afi; if (IS_ZEBRA_DEBUG_RIB) - rnode_debug (rn, rib->vrf_id, "rn %p, rib %p, removing", (void *)rn, (void *)rib); - SET_FLAG (rib->status, RIB_ENTRY_REMOVED); + rnode_debug (rn, re->vrf_id, "rn %p, re %p, removing", (void *)rn, (void *)re); + SET_FLAG (re->status, ROUTE_ENTRY_REMOVED); afi = (rn->p.family == AF_INET) ? AFI_IP : (rn->p.family == AF_INET6) ? AFI_IP6 : AFI_MAX; - if (is_zebra_import_table_enabled (afi, rib->table)) + if (is_zebra_import_table_enabled (afi, re->table)) { - zebra_del_import_table_entry(rn, rib); + zebra_del_import_table_entry(rn, re); /* Just clean up if non main table */ if (IS_ZEBRA_DEBUG_RIB) { char buf[SRCDEST2STR_BUFFER]; srcdest_rnode2str(rn, buf, sizeof(buf)); - zlog_debug ("%u:%s: Freeing route rn %p, rib %p (type %d)", - rib->vrf_id, buf, rn, rib, rib->type); + zlog_debug ("%u:%s: Freeing route rn %p, re %p (type %d)", + re->vrf_id, buf, rn, re, re->type); } - rib_unlink(rn, rib); + rib_unlink(rn, re); } else { @@ -2180,15 +2162,15 @@ rib_delnode (struct route_node *rn, struct rib *rib) } } -/* This function dumps the contents of a given RIB entry into +/* This function dumps the contents of a given RE entry into * standard debug log. Calling function name and IP prefix in * question are passed as 1st and 2nd arguments. */ -void _rib_dump (const char * func, - union prefixconstptr pp, - union prefixconstptr src_pp, - const struct rib * rib) +void _route_entry_dump (const char * func, + union prefixconstptr pp, + union prefixconstptr src_pp, + const struct route_entry * re) { const struct prefix *p = pp.p; const struct prefix *src_p = src_pp.p; @@ -2198,40 +2180,40 @@ void _rib_dump (const char * func, struct nexthop *nexthop, *tnexthop; int recursing; - zlog_debug ("%s: dumping RIB entry %p for %s%s%s vrf %u", func, (const void *)rib, + zlog_debug ("%s: dumping RE entry %p for %s%s%s vrf %u", func, (const void *)re, prefix2str(pp, straddr, sizeof(straddr)), is_srcdst ? " from " : "", is_srcdst ? prefix2str(src_pp, srcaddr, sizeof(srcaddr)) : "", - rib->vrf_id); + re->vrf_id); zlog_debug ( "%s: refcnt == %lu, uptime == %lu, type == %u, instance == %d, table == %d", func, - rib->refcnt, - (unsigned long) rib->uptime, - rib->type, - rib->instance, - rib->table + re->refcnt, + (unsigned long) re->uptime, + re->type, + re->instance, + re->table ); zlog_debug ( "%s: metric == %u, mtu == %u, distance == %u, flags == %u, status == %u", func, - rib->metric, - rib->mtu, - rib->distance, - rib->flags, - rib->status + re->metric, + re->mtu, + re->distance, + re->flags, + re->status ); zlog_debug ( "%s: nexthop_num == %u, nexthop_active_num == %u", func, - rib->nexthop_num, - rib->nexthop_active_num + re->nexthop_num, + re->nexthop_active_num ); - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { inet_ntop (p->family, &nexthop->gate, straddr, INET6_ADDRSTRLEN); zlog_debug @@ -2249,14 +2231,14 @@ void _rib_dump (const char * func, } /* This is an exported helper to rtm_read() to dump the strange - * RIB entry found by rib_lookup_ipv4_route() + * RE entry found by rib_lookup_ipv4_route() */ void rib_lookup_and_dump (struct prefix_ipv4 * p, vrf_id_t vrf_id) { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; char prefix_buf[INET_ADDRSTRLEN]; /* Lookup table. */ @@ -2267,7 +2249,7 @@ void rib_lookup_and_dump (struct prefix_ipv4 * p, vrf_id_t vrf_id) return; } - /* Scan the RIB table for exactly matching RIB entry. */ + /* Scan the RIB table for exactly matching RE entry. */ rn = route_node_lookup (table, (struct prefix *) p); /* No route for this prefix. */ @@ -2282,31 +2264,31 @@ void rib_lookup_and_dump (struct prefix_ipv4 * p, vrf_id_t vrf_id) route_unlock_node (rn); /* let's go */ - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { zlog_debug ( - "%s: rn %p, rib %p: %s, %s", + "%s: rn %p, re %p: %s, %s", __func__, (void *)rn, - (void *)rib, - (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED) ? "removed" : "NOT removed"), - (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) ? "selected" : "NOT selected") + (void *)re, + (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED) ? "removed" : "NOT removed"), + (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED) ? "selected" : "NOT selected") ); - rib_dump (p, NULL, rib); + route_entry_dump (p, NULL, re); } } /* Check if requested address assignment will fail due to another * route being installed by zebra in FIB already. Take necessary * actions, if needed: remove such a route from FIB and deSELECT - * corresponding RIB entry. Then put affected RN into RIBQ head. + * corresponding RE entry. Then put affected RN into RIBQ head. */ void rib_lookup_and_pushup (struct prefix_ipv4 * p, vrf_id_t vrf_id) { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; unsigned changed = 0; if (NULL == (table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id))) @@ -2322,27 +2304,27 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p, vrf_id_t vrf_id) /* Unlock node. */ route_unlock_node (rn); - /* Check all RIB entries. In case any changes have to be done, requeue + /* Check all RE entries. In case any changes have to be done, requeue * the RN into RIBQ head. If the routing message about the new connected * route (generated by the IP address we are going to assign very soon) - * comes before the RIBQ is processed, the new RIB entry will join + * comes before the RIBQ is processed, the new RE entry will join * RIBQ record already on head. This is necessary for proper revalidation - * of the rest of the RIB. + * of the rest of the RE. */ - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB) && - ! RIB_SYSTEM_ROUTE (rib)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB) && + ! RIB_SYSTEM_ROUTE (re)) { changed = 1; if (IS_ZEBRA_DEBUG_RIB) { char buf[PREFIX_STRLEN]; zlog_debug ("%u:%s: freeing way for connected prefix", - rib->vrf_id, prefix2str(&rn->p, buf, sizeof(buf))); - rib_dump (&rn->p, NULL, rib); + re->vrf_id, prefix2str(&rn->p, buf, sizeof(buf))); + route_entry_dump (&rn->p, NULL, re); } - rib_uninstall (rn, rib); + rib_uninstall (rn, re); } } if (changed) @@ -2351,16 +2333,16 @@ void rib_lookup_and_pushup (struct prefix_ipv4 * p, vrf_id_t vrf_id) int rib_add_multipath (afi_t afi, safi_t safi, struct prefix *p, - struct prefix_ipv6 *src_p, struct rib *rib) + struct prefix_ipv6 *src_p, struct route_entry *re) { struct route_table *table; struct route_node *rn; - struct rib *same; + struct route_entry *same; struct nexthop *nexthop; int ret = 0; int family; - if (!rib) + if (!re) return 0; if (p->family == AF_INET) @@ -2371,7 +2353,7 @@ rib_add_multipath (afi_t afi, safi_t safi, struct prefix *p, assert(!src_p || family == AFI_IP6); /* Lookup table. */ - table = zebra_vrf_table_with_table_id (family, safi, rib->vrf_id, rib->table); + table = zebra_vrf_table_with_table_id (family, safi, re->vrf_id, re->table); if (! table) return 0; @@ -2381,14 +2363,14 @@ rib_add_multipath (afi_t afi, safi_t safi, struct prefix *p, apply_mask_ipv6 (src_p); /* Set default distance by route type. */ - if (rib->distance == 0) + if (re->distance == 0) { - rib->distance = route_info[rib->type].distance; + re->distance = route_info[re->type].distance; /* iBGP distance is 200. */ - if (rib->type == ZEBRA_ROUTE_BGP - && CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) - rib->distance = 200; + if (re->type == ZEBRA_ROUTE_BGP + && CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP)) + re->distance = 200; } /* Lookup route node.*/ @@ -2396,32 +2378,32 @@ rib_add_multipath (afi_t afi, safi_t safi, struct prefix *p, /* If same type of route are installed, treat it as a implicit withdraw. */ - RNODE_FOREACH_RIB (rn, same) + RNODE_FOREACH_RE (rn, same) { - if (CHECK_FLAG (same->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (same->status, ROUTE_ENTRY_REMOVED)) continue; - if (same->type == rib->type && same->instance == rib->instance - && same->table == rib->table + if (same->type == re->type && same->instance == re->instance + && same->table == re->table && same->type != ZEBRA_ROUTE_CONNECT) break; } /* If this route is kernel route, set FIB flag to the route. */ - if (rib->type == ZEBRA_ROUTE_KERNEL || rib->type == ZEBRA_ROUTE_CONNECT) - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + if (re->type == ZEBRA_ROUTE_KERNEL || re->type == ZEBRA_ROUTE_CONNECT) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); - /* Link new rib to node.*/ + /* Link new re to node.*/ if (IS_ZEBRA_DEBUG_RIB) { - rnode_debug(rn, rib->vrf_id, "Inserting route rn %p, rib %p (type %d) existing %p", - (void *)rn, (void *)rib, rib->type, (void *)same); + rnode_debug(rn, re->vrf_id, "Inserting route rn %p, re %p (type %d) existing %p", + (void *)rn, (void *)re, re->type, (void *)same); if (IS_ZEBRA_DEBUG_RIB_DETAILED) - rib_dump (p, src_p, rib); + route_entry_dump (p, src_p, re); } - rib_addnode (rn, rib, 1); + rib_addnode (rn, re, 1); ret = 1; /* Free implicit route.*/ @@ -2442,9 +2424,9 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, { struct route_table *table; struct route_node *rn; - struct rib *rib; - struct rib *fib = NULL; - struct rib *same = NULL; + struct route_entry *re; + struct route_entry *fib = NULL; + struct route_entry *same = NULL; struct nexthop *nexthop, *tnexthop; int recursing; char buf2[INET6_ADDRSTRLEN]; @@ -2482,31 +2464,31 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, } /* Lookup same type route. */ - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) - fib = rib; + if (CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB)) + fib = re; - if (rib->type != type) + if (re->type != type) continue; - if (rib->instance != instance) + if (re->instance != instance) continue; - if (rib->type == ZEBRA_ROUTE_CONNECT && (nexthop = rib->nexthop) && + if (re->type == ZEBRA_ROUTE_CONNECT && (nexthop = re->nexthop) && nexthop->type == NEXTHOP_TYPE_IFINDEX) { if (nexthop->ifindex != ifindex) continue; - if (rib->refcnt) + if (re->refcnt) { - rib->refcnt--; + re->refcnt--; route_unlock_node (rn); route_unlock_node (rn); return; } - same = rib; + same = re; break; } /* Make sure that the route found has the same gateway. */ @@ -2514,14 +2496,14 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, { if (gate == NULL) { - same = rib; + same = re; break; } - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) if (IPV4_ADDR_SAME (&nexthop->gate.ipv4, gate) || IPV6_ADDR_SAME (&nexthop->gate.ipv6, gate)) { - same = rib; + same = re; break; } if (same) @@ -2537,7 +2519,7 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, { if (IS_ZEBRA_DEBUG_RIB) { - rnode_debug (rn, vrf_id, "rn %p, rib %p (type %d) was deleted from kernel, adding", + rnode_debug (rn, vrf_id, "rn %p, re %p (type %d) was deleted from kernel, adding", rn, fib, fib->type); } if (allow_delete) @@ -2546,7 +2528,7 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, for (nexthop = fib->nexthop; nexthop; nexthop = nexthop->next) UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); - UNSET_FLAG (fib->status, RIB_ENTRY_SELECTED_FIB); + UNSET_FLAG (fib->status, ROUTE_ENTRY_SELECTED_FIB); } else { @@ -2592,8 +2574,8 @@ rib_add (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_int32_t table_id, u_int32_t metric, u_int32_t mtu, u_char distance) { - struct rib *rib; - struct rib *same = NULL; + struct route_entry *re; + struct route_entry *same = NULL; struct route_table *table; struct route_node *rn; struct nexthop *nexthop; @@ -2628,44 +2610,44 @@ rib_add (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, /* If same type of route are installed, treat it as a implicit withdraw. */ - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->type != type) + if (re->type != type) continue; - if (rib->instance != instance) + if (re->instance != instance) continue; - if (rib->type != ZEBRA_ROUTE_CONNECT) + if (re->type != ZEBRA_ROUTE_CONNECT) { - same = rib; + same = re; break; } /* Duplicate connected route comes in. */ - else if ((nexthop = rib->nexthop) && + else if ((nexthop = re->nexthop) && nexthop->type == NEXTHOP_TYPE_IFINDEX && nexthop->ifindex == ifindex && - !CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + !CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) { - rib->refcnt++; + re->refcnt++; return 0 ; } } - /* Allocate new rib structure. */ - rib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); + /* Allocate new re structure. */ + re = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); - rib->type = type; - rib->instance = instance; - rib->distance = distance; - rib->flags = flags; - rib->metric = metric; - rib->mtu = mtu; - rib->table = table_id; - rib->vrf_id = vrf_id; - rib->nexthop_num = 0; - rib->uptime = time (NULL); + re->type = type; + re->instance = instance; + re->distance = distance; + re->flags = flags; + re->metric = metric; + re->mtu = mtu; + re->table = table_id; + re->vrf_id = vrf_id; + re->nexthop_num = 0; + re->uptime = time (NULL); /* Nexthop settings. */ if (gate) @@ -2673,36 +2655,36 @@ rib_add (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, if (afi == AFI_IP6) { if (ifindex) - rib_nexthop_ipv6_ifindex_add (rib, &gate->ipv6, ifindex); + route_entry_nexthop_ipv6_ifindex_add (re, &gate->ipv6, ifindex); else - rib_nexthop_ipv6_add (rib, &gate->ipv6); + route_entry_nexthop_ipv6_add (re, &gate->ipv6); } else { if (ifindex) - rib_nexthop_ipv4_ifindex_add (rib, &gate->ipv4, &src->ipv4, ifindex); + route_entry_nexthop_ipv4_ifindex_add (re, &gate->ipv4, &src->ipv4, ifindex); else - rib_nexthop_ipv4_add (rib, &gate->ipv4, &src->ipv4); + route_entry_nexthop_ipv4_add (re, &gate->ipv4, &src->ipv4); } } else - rib_nexthop_ifindex_add (rib, ifindex); + route_entry_nexthop_ifindex_add (re, ifindex); /* 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) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB); /* Link new rib to node.*/ if (IS_ZEBRA_DEBUG_RIB) { - rnode_debug (rn, vrf_id, "Inserting route rn %p, rib %p (type %d) existing %p", - (void *)rn, (void *)rib, rib->type, (void *)same); + rnode_debug (rn, vrf_id, "Inserting route rn %p, re %p (type %d) existing %p", + (void *)rn, (void *)re, re->type, (void *)same); if (IS_ZEBRA_DEBUG_RIB_DETAILED) - rib_dump (p, src_p, rib); + route_entry_dump (p, src_p, re); } - rib_addnode (rn, rib, 1); + rib_addnode (rn, re, 1); /* Free implicit route.*/ if (same) @@ -2717,7 +2699,7 @@ static void rib_update_table (struct route_table *table, rib_update_event_t event) { struct route_node *rn; - struct rib *rib, *next; + struct route_entry *re, *next; /* Walk all routes and queue for processing, if appropriate for * the trigger event. @@ -2733,16 +2715,16 @@ rib_update_table (struct route_table *table, rib_update_event_t event) * triggered upon an interface event as connected routes always * get queued for processing. */ - RNODE_FOREACH_RIB_SAFE (rn, rib, next) + RNODE_FOREACH_RE_SAFE (rn, re, next) { - if (rib->type == ZEBRA_ROUTE_OSPF || - rib->type == ZEBRA_ROUTE_OSPF6 || - rib->type == ZEBRA_ROUTE_BGP) + if (re->type == ZEBRA_ROUTE_OSPF || + re->type == ZEBRA_ROUTE_OSPF6 || + re->type == ZEBRA_ROUTE_BGP) continue; /* protocol will handle. */ - else if (rib->type == ZEBRA_ROUTE_STATIC) + else if (re->type == ZEBRA_ROUTE_STATIC) { struct nexthop *nh; - for (nh = rib->nexthop; nh; nh = nh->next) + for (nh = re->nexthop; nh; nh = nh->next) if (!(nh->type == NEXTHOP_TYPE_IPV4 || nh->type == NEXTHOP_TYPE_IPV6)) break; @@ -2794,19 +2776,19 @@ static void rib_weed_table (struct route_table *table) { struct route_node *rn; - struct rib *rib; - struct rib *next; + struct route_entry *re; + struct route_entry *next; if (table) for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB_SAFE (rn, rib, next) + RNODE_FOREACH_RE_SAFE (rn, re, next) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->table != zebrad.rtm_table_default && - rib->table != RT_TABLE_MAIN) - rib_delnode (rn, rib); + if (re->table != zebrad.rtm_table_default && + re->table != RT_TABLE_MAIN) + rib_delnode (rn, re); } } @@ -2830,23 +2812,23 @@ static void rib_sweep_table (struct route_table *table) { struct route_node *rn; - struct rib *rib; - struct rib *next; + struct route_entry *re; + struct route_entry *next; int ret = 0; if (table) for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB_SAFE (rn, rib, next) + RNODE_FOREACH_RE_SAFE (rn, re, next) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->type == ZEBRA_ROUTE_KERNEL && - CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELFROUTE)) + if (re->type == ZEBRA_ROUTE_KERNEL && + CHECK_FLAG (re->flags, ZEBRA_FLAG_SELFROUTE)) { - ret = rib_uninstall_kernel (rn, rib); + ret = rib_uninstall_kernel (rn, re); if (! ret) - rib_delnode (rn, rib); + rib_delnode (rn, re); } } } @@ -2871,19 +2853,19 @@ static unsigned long rib_score_proto_table (u_char proto, u_short instance, struct route_table *table) { struct route_node *rn; - struct rib *rib; - struct rib *next; + struct route_entry *re; + struct route_entry *next; unsigned long n = 0; if (table) for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB_SAFE (rn, rib, next) + RNODE_FOREACH_RE_SAFE (rn, re, next) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->type == proto && rib->instance == instance) + if (re->type == proto && re->instance == instance) { - rib_delnode (rn, rib); + rib_delnode (rn, re); n++; } } @@ -2912,20 +2894,20 @@ rib_close_table (struct route_table *table) { struct route_node *rn; rib_table_info_t *info = table->info; - struct rib *rib; + struct route_entry *re; if (table) for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (!CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) + if (!CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB)) continue; if (info->safi == SAFI_UNICAST) hook_call(rib_update, rn, NULL); - if (! RIB_SYSTEM_ROUTE (rib)) - rib_uninstall_kernel (rn, rib); + if (! RIB_SYSTEM_ROUTE (re)) + rib_uninstall_kernel (rn, re); } } diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 16c157e307..66b1cc78ca 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -48,8 +48,8 @@ #include "zebra/interface.h" #include "zebra/zebra_memory.h" -static void free_state(vrf_id_t vrf_id, struct rib *rib, struct route_node *rn); -static void copy_state(struct rnh *rnh, struct rib *rib, +static void free_state(vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn); +static void copy_state(struct rnh *rnh, struct route_entry *re, struct route_node *rn); #define lookup_rnh_table(v, f) \ ({ \ @@ -61,7 +61,7 @@ static void copy_state(struct rnh *rnh, struct rib *rib, t; \ }) -static int compare_state(struct rib *r1, struct rib *r2); +static int compare_state(struct route_entry *r1, struct route_entry *r2); static int send_client(struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vrf_id); static void print_rnh(struct route_node *rn, struct vty *vty); @@ -305,7 +305,7 @@ zebra_deregister_rnh_static_nexthops (vrf_id_t vrf_id, struct nexthop *nexthop, */ static int zebra_rnh_apply_nht_rmap(int family, struct route_node *prn, - struct rib *rib, int proto) + struct route_entry *re, int proto) { int at_least_one = 0; int rmap_family; /* Route map has diff AF family enum */ @@ -314,11 +314,11 @@ zebra_rnh_apply_nht_rmap(int family, struct route_node *prn, rmap_family = (family == AF_INET) ? AFI_IP : AFI_IP6; - if (prn && rib) + if (prn && re) { - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) { - ret = zebra_nht_route_map_check(rmap_family, proto, &prn->p, rib, + ret = zebra_nht_route_map_check(rmap_family, proto, &prn->p, re, nexthop); if (ret != RMAP_DENYMATCH) { @@ -335,17 +335,17 @@ zebra_rnh_apply_nht_rmap(int family, struct route_node *prn, } /* - * Determine appropriate route (RIB entry) resolving a tracked entry + * Determine appropriate route (RE entry) resolving a tracked entry * (nexthop or BGP route for import). */ -static struct rib * +static struct route_entry * zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type, struct route_node *nrn, struct rnh *rnh, struct route_node **prn) { struct route_table *route_table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; *prn = NULL; @@ -363,29 +363,29 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type, if ((type == RNH_NEXTHOP_TYPE) && (is_default_prefix (&rn->p) && !nh_resolve_via_default(rn->p.family))) - rib = NULL; + re = NULL; else if ((type == RNH_IMPORT_CHECK_TYPE) && CHECK_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH) && !prefix_same(&nrn->p, &rn->p)) - rib = NULL; + re = NULL; else { /* Identify appropriate route entry. */ - RNODE_FOREACH_RIB(rn, rib) + RNODE_FOREACH_RE(rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (! CHECK_FLAG (rib->status, RIB_ENTRY_SELECTED_FIB)) + if (! CHECK_FLAG (re->status, ROUTE_ENTRY_SELECTED_FIB)) continue; if (CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED)) { - if (rib->type == ZEBRA_ROUTE_CONNECT) + if (re->type == ZEBRA_ROUTE_CONNECT) break; - if (rib->type == ZEBRA_ROUTE_NHRP) + if (re->type == ZEBRA_ROUTE_NHRP) { struct nexthop *nexthop; - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) if (nexthop->type == NEXTHOP_TYPE_IFINDEX) break; if (nexthop) @@ -393,7 +393,7 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type, } } else if ((type == RNH_IMPORT_CHECK_TYPE) && - (rib->type == ZEBRA_ROUTE_BGP)) + (re->type == ZEBRA_ROUTE_BGP)) continue; else break; @@ -402,9 +402,9 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type, /* Need to unlock route node */ route_unlock_node(rn); - if (rib) + if (re) *prn = rn; - return rib; + return re; } /* @@ -414,7 +414,7 @@ zebra_rnh_resolve_entry (vrf_id_t vrfid, int family, rnh_type_t type, static void zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force, struct route_node *nrn, struct rnh *rnh, - struct rib *rib) + struct route_entry *re) { int state_changed = 0; struct zserv *client; @@ -423,20 +423,20 @@ zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force, struct nexthop *nexthop, *tnexthop; int recursing; - if (rib && (rnh->state == NULL)) + if (re && (rnh->state == NULL)) { - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) { state_changed = 1; break; } } - else if (!rib && (rnh->state != NULL)) + else if (!re && (rnh->state != NULL)) state_changed = 1; - if (compare_state(rib, rnh->state)) - copy_state(rnh, rib, nrn); + if (compare_state(re, rnh->state)) + copy_state(rnh, re, nrn); if (state_changed || force) { @@ -461,7 +461,7 @@ zebra_rnh_eval_import_check_entry (vrf_id_t vrfid, int family, int force, static void zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family, struct route_node *nrn, struct rnh *rnh, - struct route_node *prn, struct rib *rib) + struct route_node *prn, struct route_entry *re) { struct listnode *node; struct zserv *client; @@ -472,7 +472,7 @@ zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family, if (IS_ZEBRA_DEBUG_NHT) { prefix2str(&nrn->p, bufn, INET6_ADDRSTRLEN); - if (prn && rib) + if (prn && re) { prefix2str(&prn->p, bufp, INET6_ADDRSTRLEN); zlog_debug("%u:%s: NH resolved over route %s", vrfid, bufn, bufp); @@ -483,12 +483,12 @@ zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family, for (ALL_LIST_ELEMENTS_RO(rnh->client_list, node, client)) { - if (prn && rib) + if (prn && re) { /* Apply route-map for this client to route resolving this * nexthop to see if it is filtered or not. */ - num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, rib, + num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, re, client->proto); if (num_resolving_nh) rnh->filtered[client->proto] = 0; @@ -515,12 +515,12 @@ zebra_rnh_notify_protocol_clients (vrf_id_t vrfid, int family, static void zebra_rnh_process_static_routes (vrf_id_t vrfid, int family, struct route_node *nrn, struct rnh *rnh, - struct route_node *prn, struct rib *rib) + struct route_node *prn, struct route_entry *re) { struct listnode *node; int num_resolving_nh = 0; struct route_node *static_rn; - struct rib *srib; + struct route_entry *sre; struct nexthop *nexthop; char bufn[INET6_ADDRSTRLEN]; char bufp[INET6_ADDRSTRLEN]; @@ -533,12 +533,12 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family, prefix2str(&prn->p, bufp, INET6_ADDRSTRLEN); } - if (prn && rib) + if (prn && re) { /* Apply route-map for "static" to route resolving this * nexthop to see if it is filtered or not. */ - num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, rib, + num_resolving_nh = zebra_rnh_apply_nht_rmap(family, prn, re, ZEBRA_ROUTE_STATIC); if (num_resolving_nh) rnh->filtered[ZEBRA_ROUTE_STATIC] = 0; @@ -552,15 +552,15 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family, for (ALL_LIST_ELEMENTS_RO(rnh->zebra_static_route_list, node, static_rn)) { - RNODE_FOREACH_RIB(static_rn, srib) + RNODE_FOREACH_RE(static_rn, sre) { - if (srib->type != ZEBRA_ROUTE_STATIC) + if (sre->type != ZEBRA_ROUTE_STATIC) continue; /* Set the filter flag for the correct nexthop - static route may * be having multiple. We care here only about registered nexthops. */ - for (nexthop = srib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = sre->nexthop; nexthop; nexthop = nexthop->next) { switch (nexthop->type) { @@ -593,7 +593,7 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family, if (IS_ZEBRA_DEBUG_NHT) { prefix2str(&static_rn->p, bufs, INET6_ADDRSTRLEN); - if (prn && rib) + if (prn && re) zlog_debug("%u:%s: NH change %s, scheduling static route %s", vrfid, bufn, num_resolving_nh ? "" : "(filtered by route-map)", bufs); @@ -602,8 +602,8 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family, vrfid, bufn, bufs); } - SET_FLAG(srib->status, RIB_ENTRY_CHANGED); - SET_FLAG(srib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + SET_FLAG(sre->status, ROUTE_ENTRY_CHANGED); + SET_FLAG(sre->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); } rib_queue_add(static_rn); @@ -618,7 +618,7 @@ zebra_rnh_process_static_routes (vrf_id_t vrfid, int family, static void zebra_rnh_eval_nexthop_entry (vrf_id_t vrfid, int family, int force, struct route_node *nrn, struct rnh *rnh, - struct route_node *prn, struct rib *rib) + struct route_node *prn, struct route_entry *re) { int state_changed = 0; @@ -633,12 +633,12 @@ zebra_rnh_eval_nexthop_entry (vrf_id_t vrfid, int family, int force, else memset(&rnh->resolved_route, 0, sizeof(struct prefix)); - copy_state(rnh, rib, nrn); + copy_state(rnh, re, nrn); state_changed = 1; } - else if (compare_state(rib, rnh->state)) + else if (compare_state(re, rnh->state)) { - copy_state(rnh, rib, nrn); + copy_state(rnh, re, nrn); state_changed = 1; } @@ -663,7 +663,7 @@ zebra_rnh_evaluate_entry (vrf_id_t vrfid, int family, int force, rnh_type_t type struct route_node *nrn) { struct rnh *rnh; - struct rib *rib; + struct route_entry *re; struct route_node *prn; char bufn[INET6_ADDRSTRLEN]; @@ -676,31 +676,31 @@ zebra_rnh_evaluate_entry (vrf_id_t vrfid, int family, int force, rnh_type_t type rnh = nrn->info; - /* Identify route entry (RIB) resolving this tracked entry. */ - rib = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn); + /* Identify route entry (RE) resolving this tracked entry. */ + re = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn); /* If the entry cannot be resolved and that is also the existing state, * there is nothing further to do. */ - if (!rib && rnh->state == NULL && !force) + if (!re && rnh->state == NULL && !force) return; /* Process based on type of entry. */ if (type == RNH_IMPORT_CHECK_TYPE) zebra_rnh_eval_import_check_entry (vrfid, family, force, - nrn, rnh, rib); + nrn, rnh, re); else zebra_rnh_eval_nexthop_entry (vrfid, family, force, - nrn, rnh, prn, rib); + nrn, rnh, prn, re); } /* - * Clear the RIB_ENTRY_NEXTHOPS_CHANGED flag - * from the rib entries. + * Clear the ROUTE_ENTRY_NEXTHOPS_CHANGED flag + * from the re entries. * * Please note we are doing this *after* we have * notified the world about each nexthop as that - * we can have a situation where one rib entry + * we can have a situation where one re entry * covers multiple nexthops we are interested in. */ static void @@ -708,15 +708,15 @@ zebra_rnh_clear_nhc_flag (vrf_id_t vrfid, int family, rnh_type_t type, struct route_node *nrn) { struct rnh *rnh; - struct rib *rib; + struct route_entry *re; struct route_node *prn; rnh = nrn->info; - rib = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn); + re = zebra_rnh_resolve_entry (vrfid, family, type, nrn, rnh, &prn); - if (rib) - UNSET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); + if (re) + UNSET_FLAG (re->status, ROUTE_ENTRY_NEXTHOPS_CHANGED); } /* Evaluate all tracked entries (nexthops or routes for import into BGP) @@ -812,25 +812,25 @@ zebra_cleanup_rnh_client (vrf_id_t vrf_id, int family, struct zserv *client, } /** - * free_state - free up the rib structure associated with the rnh. + * free_state - free up the re structure associated with the rnh. */ static void -free_state (vrf_id_t vrf_id, struct rib *rib, struct route_node *rn) +free_state (vrf_id_t vrf_id, struct route_entry *re, struct route_node *rn) { - if (!rib) + if (!re) return; - /* free RIB and nexthops */ - zebra_deregister_rnh_static_nexthops (vrf_id, rib->nexthop, rn); - nexthops_free(rib->nexthop); - XFREE (MTYPE_RIB, rib); + /* free RE and nexthops */ + zebra_deregister_rnh_static_nexthops (vrf_id, re->nexthop, rn); + nexthops_free(re->nexthop); + XFREE (MTYPE_RE, re); } static void -copy_state (struct rnh *rnh, struct rib *rib, struct route_node *rn) +copy_state (struct rnh *rnh, struct route_entry *re, struct route_node *rn) { - struct rib *state; + struct route_entry *state; struct nexthop *nh; if (rnh->state) @@ -839,20 +839,20 @@ copy_state (struct rnh *rnh, struct rib *rib, struct route_node *rn) rnh->state = NULL; } - if (!rib) + if (!re) return; - state = XCALLOC (MTYPE_RIB, sizeof (struct rib)); - state->type = rib->type; - state->metric = rib->metric; + state = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); + state->type = re->type; + state->metric = re->metric; - for (nh = rib->nexthop; nh; nh = nh->next) - rib_copy_nexthops(state, nh); + for (nh = re->nexthop; nh; nh = nh->next) + route_entry_copy_nexthops(state, nh); rnh->state = state; } static int -compare_state (struct rib *r1, struct rib *r2) +compare_state (struct route_entry *r1, struct route_entry *r2) { if (!r1 && !r2) @@ -867,7 +867,7 @@ compare_state (struct rib *r1, struct rib *r2) if (r1->nexthop_num != r2->nexthop_num) return 1; - if (CHECK_FLAG(r1->status, RIB_ENTRY_NEXTHOPS_CHANGED)) + if (CHECK_FLAG(r1->status, ROUTE_ENTRY_NEXTHOPS_CHANGED)) return 1; return 0; @@ -877,7 +877,7 @@ static int send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vrf_id) { struct stream *s; - struct rib *rib; + struct route_entry *re; unsigned long nump; u_char num; struct nexthop *nexthop; @@ -886,7 +886,7 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr ? ZEBRA_IMPORT_CHECK_UPDATE : ZEBRA_NEXTHOP_UPDATE; rn = rnh->node; - rib = rnh->state; + re = rnh->state; /* Get output stream. */ s = client->obuf; @@ -910,14 +910,14 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr __FUNCTION__, rn->p.family); break; } - if (rib) + if (re) { - stream_putc (s, rib->distance); - stream_putl (s, rib->metric); + stream_putc (s, re->distance); + stream_putl (s, re->metric); num = 0; nump = stream_get_endp(s); stream_putc (s, 0); - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) if ((CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) || CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) && CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h index a75674d0cb..d26b7be250 100644 --- a/zebra/zebra_rnh.h +++ b/zebra/zebra_rnh.h @@ -37,7 +37,7 @@ struct rnh /* VRF identifier. */ vrf_id_t vrf_id; - struct rib *state; + struct route_entry *state; struct prefix resolved_route; struct list *client_list; struct list *zebra_static_route_list; /* static routes dependent on this NH */ diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 4a81cb635d..6ec43e592c 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1351,7 +1351,7 @@ zebra_del_import_table_route_map (afi_t afi, uint32_t table) } route_map_result_t -zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p, +zebra_import_table_route_map_check (int family, int re_type, struct prefix *p, struct nexthop *nexthop, vrf_id_t vrf_id, route_tag_t tag, const char *rmap_name) { struct route_map *rmap = NULL; @@ -1360,11 +1360,11 @@ zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p, nh_obj.nexthop = nexthop; nh_obj.vrf_id = vrf_id; - nh_obj.source_protocol = rib_type; + nh_obj.source_protocol = re_type; nh_obj.metric = 0; nh_obj.tag = tag; - if (rib_type >= 0 && rib_type < ZEBRA_ROUTE_MAX) + if (re_type >= 0 && re_type < ZEBRA_ROUTE_MAX) rmap = route_map_lookup_by_name (rmap_name); if (rmap) { ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj); @@ -1375,17 +1375,17 @@ zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p, route_map_result_t zebra_nht_route_map_check (int family, int client_proto, struct prefix *p, - struct rib * rib, struct nexthop *nexthop) + struct route_entry * re, struct nexthop *nexthop) { struct route_map *rmap = NULL; route_map_result_t ret = RMAP_MATCH; struct nh_rmap_obj nh_obj; nh_obj.nexthop = nexthop; - nh_obj.vrf_id = rib->vrf_id; - nh_obj.source_protocol = rib->type; - nh_obj.metric = rib->metric; - nh_obj.tag = rib->tag; + nh_obj.vrf_id = re->vrf_id; + nh_obj.source_protocol = re->type; + nh_obj.metric = re->metric; + nh_obj.tag = re->tag; if (client_proto >= 0 && client_proto < ZEBRA_ROUTE_MAX) rmap = route_map_lookup_by_name (nht_rm[family][client_proto]); diff --git a/zebra/zebra_routemap.h b/zebra/zebra_routemap.h index 94981a3cd6..ac9cc40efa 100644 --- a/zebra/zebra_routemap.h +++ b/zebra/zebra_routemap.h @@ -43,7 +43,7 @@ extern route_map_result_t zebra_route_map_check (int family, int rib_type, extern route_map_result_t zebra_nht_route_map_check (int family, int client_proto, struct prefix *p, - struct rib *, + struct route_entry *, struct nexthop *nexthop); diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 7c2e6697ce..bb1cee7840 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -143,7 +143,7 @@ ipFwNumber (struct variable *v, oid objid[], size_t *objid_len, static int result; struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED) return NULL; @@ -155,7 +155,7 @@ ipFwNumber (struct variable *v, oid objid[], size_t *objid_len, /* Return number of routing entries. */ result = 0; for (rn = route_top (table); rn; rn = route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) result++; return (u_char *)&result; @@ -168,7 +168,7 @@ ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len, static int result; struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; if (smux_header_generic(v, objid, objid_len, exact, val_len, write_method) == MATCH_FAILED) return NULL; @@ -180,7 +180,7 @@ ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len, /* Return number of routing entries. */ result = 0; for (rn = route_top (table); rn; rn = route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) result++; return (u_char *)&result; @@ -256,15 +256,15 @@ proto_trans(int type) } static void -check_replace(struct route_node *np2, struct rib *rib2, - struct route_node **np, struct rib **rib) +check_replace(struct route_node *np2, struct route_entry *re2, + struct route_node **np, struct route_entry **re) { int proto, proto2; if (!*np) { *np = np2; - *rib = rib2; + *re = re2; return; } @@ -273,39 +273,39 @@ check_replace(struct route_node *np2, struct rib *rib2, if (in_addr_cmp(&(*np)->p.u.prefix, &np2->p.u.prefix) > 0) { *np = np2; - *rib = rib2; + *re = re2; return; } - proto = proto_trans((*rib)->type); - proto2 = proto_trans(rib2->type); + proto = proto_trans((*re)->type); + proto2 = proto_trans(re2->type); if (proto2 > proto) return; if (proto2 < proto) { *np = np2; - *rib = rib2; + *re = re2; return; } - if (in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4, - (u_char *)&rib2->nexthop->gate.ipv4) <= 0) + if (in_addr_cmp((u_char *)&(*re)->nexthop->gate.ipv4, + (u_char *)&re2->nexthop->gate.ipv4) <= 0) return; *np = np2; - *rib = rib2; + *re = re2; return; } static void get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, - int exact, struct route_node **np, struct rib **rib) + int exact, struct route_node **np, struct route_entry **re) { struct in_addr dest; struct route_table *table; struct route_node *np2; - struct rib *rib2; + struct route_entry *re2; int proto; int policy; struct in_addr nexthop; @@ -328,7 +328,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, /* Init return variables */ *np = NULL; - *rib = NULL; + *re = NULL; /* Short circuit exact matches of wrong length */ @@ -374,11 +374,11 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, { if (!in_addr_cmp(&(*np)->p.u.prefix, (u_char *)&dest)) { - RNODE_FOREACH_RIB (*np, *rib) + RNODE_FOREACH_RE (*np, *re) { - if (!in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4, + if (!in_addr_cmp((u_char *)&(*re)->nexthop->gate.ipv4, (u_char *)&nexthop)) - if (proto == proto_trans((*rib)->type)) + if (proto == proto_trans((*re)->type)) return; } } @@ -393,34 +393,34 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, /* Check destination first */ if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) > 0) - RNODE_FOREACH_RIB (np2, rib2) - check_replace(np2, rib2, np, rib); + RNODE_FOREACH_RE (np2, re2) + check_replace(np2, re2, np, re); if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) == 0) - { /* have to look at each rib individually */ - RNODE_FOREACH_RIB (np2, rib2) + { /* have to look at each re individually */ + RNODE_FOREACH_RE (np2, re2) { int proto2, policy2; - proto2 = proto_trans(rib2->type); + proto2 = proto_trans(re2->type); policy2 = 0; if ((policy < policy2) || ((policy == policy2) && (proto < proto2)) || ((policy == policy2) && (proto == proto2) - && (in_addr_cmp((u_char *)&rib2->nexthop->gate.ipv4, + && (in_addr_cmp((u_char *)&re2->nexthop->gate.ipv4, (u_char *) &nexthop) >= 0) )) - check_replace(np2, rib2, np, rib); + check_replace(np2, re2, np, re); } } } - if (!*rib) + if (!*re) return; policy = 0; - proto = proto_trans((*rib)->type); + proto = proto_trans((*re)->type); *objid_len = v->namelen + 10; pnt = (u_char *) &(*np)->p.u.prefix; @@ -433,7 +433,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len, { struct nexthop *nexthop; - nexthop = (*rib)->nexthop; + nexthop = (*re)->nexthop; if (nexthop) { pnt = (u_char *) &nexthop->gate.ipv4; @@ -450,7 +450,7 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len, int exact, size_t *val_len, WriteMethod **write_method) { struct route_node *np; - struct rib *rib; + struct route_entry *re; static int result; static int resarr[2]; static struct in_addr netmask; @@ -460,11 +460,11 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len, == MATCH_FAILED) return NULL; - get_fwtable_route_node(v, objid, objid_len, exact, &np, &rib); + get_fwtable_route_node(v, objid, objid_len, exact, &np, &re); if (!np) return NULL; - nexthop = rib->nexthop; + nexthop = re->nexthop; if (! nexthop) return NULL; @@ -501,7 +501,7 @@ ipFwTable (struct variable *v, oid objid[], size_t *objid_len, return (u_char *)&result; break; case IPFORWARDPROTO: - result = proto_trans(rib->type); + result = proto_trans(re->type); *val_len = sizeof(int); return (u_char *)&result; break; diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index b218eb5210..05336ca6b2 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -40,7 +40,7 @@ void static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct prefix_ipv6 *src_p, struct static_route *si) { - struct rib *rib; + struct route_entry *re; struct route_node *rn; struct route_table *table; struct prefix nh_p; @@ -55,20 +55,20 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, /* Lookup existing route */ rn = srcdest_rnode_get (table, p, src_p); - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance) + if (re->type == ZEBRA_ROUTE_STATIC && re->distance == si->distance) break; } - if (rib) + if (re) { /* if tag value changed , update old value in RIB */ - if (rib->tag != si->tag) - rib->tag = si->tag; + if (re->tag != si->tag) + re->tag = si->tag; /* Same distance static route is there. Update it with new nexthop. */ @@ -76,27 +76,27 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, switch (si->type) { case STATIC_IPV4_GATEWAY: - nexthop = rib_nexthop_ipv4_add (rib, &si->addr.ipv4, NULL); + nexthop = route_entry_nexthop_ipv4_add (re, &si->addr.ipv4, NULL); nh_p.family = AF_INET; nh_p.prefixlen = IPV4_MAX_BITLEN; nh_p.u.prefix4 = si->addr.ipv4; zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn); break; case STATIC_IFINDEX: - nexthop = rib_nexthop_ifindex_add (rib, si->ifindex); + nexthop = route_entry_nexthop_ifindex_add (re, si->ifindex); break; case STATIC_BLACKHOLE: - nexthop = rib_nexthop_blackhole_add (rib); + nexthop = route_entry_nexthop_blackhole_add (re); break; case STATIC_IPV6_GATEWAY: - nexthop = rib_nexthop_ipv6_add (rib, &si->addr.ipv6); + nexthop = route_entry_nexthop_ipv6_add (re, &si->addr.ipv6); nh_p.family = AF_INET6; nh_p.prefixlen = IPV6_MAX_BITLEN; nh_p.u.prefix6 = si->addr.ipv6; zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn); break; case STATIC_IPV6_GATEWAY_IFINDEX: - nexthop = rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6, + nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &si->addr.ipv6, si->ifindex); break; } @@ -111,8 +111,8 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, if (IS_ZEBRA_DEBUG_RIB) { inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN); - zlog_debug ("%u:%s/%d: Modifying route rn %p, rib %p (type %d)", - si->vrf_id, buf, p->prefixlen, rn, rib, rib->type); + zlog_debug ("%u:%s/%d: Modifying route rn %p, re %p (type %d)", + si->vrf_id, buf, p->prefixlen, rn, re, re->type); } } /* Schedule route for processing or invoke NHT, as appropriate. */ @@ -125,42 +125,42 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, else { /* This is new static route. */ - rib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); + re = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); - rib->type = ZEBRA_ROUTE_STATIC; - rib->instance = 0; - rib->distance = si->distance; - rib->metric = 0; - rib->mtu = 0; - rib->vrf_id = si->vrf_id; - rib->table = si->vrf_id ? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id : zebrad.rtm_table_default; - rib->nexthop_num = 0; - rib->tag = si->tag; + re->type = ZEBRA_ROUTE_STATIC; + re->instance = 0; + re->distance = si->distance; + re->metric = 0; + re->mtu = 0; + re->vrf_id = si->vrf_id; + re->table = si->vrf_id ? (zebra_vrf_lookup_by_id(si->vrf_id))->table_id : zebrad.rtm_table_default; + re->nexthop_num = 0; + re->tag = si->tag; switch (si->type) { case STATIC_IPV4_GATEWAY: - nexthop = rib_nexthop_ipv4_add (rib, &si->addr.ipv4, NULL); + nexthop = route_entry_nexthop_ipv4_add (re, &si->addr.ipv4, NULL); nh_p.family = AF_INET; nh_p.prefixlen = IPV4_MAX_BITLEN; nh_p.u.prefix4 = si->addr.ipv4; zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn); break; case STATIC_IFINDEX: - nexthop = rib_nexthop_ifindex_add (rib, si->ifindex); + nexthop = route_entry_nexthop_ifindex_add (re, si->ifindex); break; case STATIC_BLACKHOLE: - nexthop = rib_nexthop_blackhole_add (rib); + nexthop = route_entry_nexthop_blackhole_add (re); break; case STATIC_IPV6_GATEWAY: - nexthop = rib_nexthop_ipv6_add (rib, &si->addr.ipv6); + nexthop = route_entry_nexthop_ipv6_add (re, &si->addr.ipv6); nh_p.family = AF_INET6; nh_p.prefixlen = IPV6_MAX_BITLEN; nh_p.u.prefix6 = si->addr.ipv6; zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn); break; case STATIC_IPV6_GATEWAY_IFINDEX: - nexthop = rib_nexthop_ipv6_ifindex_add (rib, &si->addr.ipv6, + nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &si->addr.ipv6, si->ifindex); break; } @@ -170,7 +170,7 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, &si->snh_label.label[0]); /* Save the flags of this static routes (reject, blackhole) */ - rib->flags = si->flags; + re->flags = si->flags; if (IS_ZEBRA_DEBUG_RIB) { @@ -178,21 +178,21 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, if (IS_ZEBRA_DEBUG_RIB) { inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN); - zlog_debug ("%u:%s/%d: Inserting route rn %p, rib %p (type %d)", - si->vrf_id, buf, p->prefixlen, rn, rib, rib->type); + zlog_debug ("%u:%s/%d: Inserting route rn %p, re %p (type %d)", + si->vrf_id, buf, p->prefixlen, rn, re, re->type); } } - /* Link this rib to the tree. Schedule for processing or invoke NHT, + /* Link this re to the tree. Schedule for processing or invoke NHT, * as appropriate. */ if (si->type == STATIC_IPV4_GATEWAY || si->type == STATIC_IPV6_GATEWAY) { - rib_addnode (rn, rib, 0); + rib_addnode (rn, re, 0); zebra_evaluate_rnh(si->vrf_id, nh_p.family, 1, RNH_NEXTHOP_TYPE, &nh_p); } else - rib_addnode (rn, rib, 1); + rib_addnode (rn, re, 1); } } @@ -230,7 +230,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct prefix_ipv6 *src_p, struct static_route *si) { struct route_node *rn; - struct rib *rib; + struct route_entry *re; struct nexthop *nexthop; struct route_table *table; struct prefix nh_p; @@ -245,24 +245,24 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, if (! rn) return; - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) + if (CHECK_FLAG (re->status, ROUTE_ENTRY_REMOVED)) continue; - if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance && - rib->tag == si->tag) + if (re->type == ZEBRA_ROUTE_STATIC && re->distance == si->distance && + re->tag == si->tag) break; } - if (! rib) + if (! re) { route_unlock_node (rn); return; } /* Lookup nexthop. */ - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) if (static_nexthop_same (nexthop, si)) break; @@ -274,8 +274,8 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, } /* Check nexthop. */ - if (rib->nexthop_num == 1) - rib_delnode (rn, rib); + if (re->nexthop_num == 1) + rib_delnode (rn, re); else { /* Mark this nexthop as inactive and reinstall the route. Then, delete @@ -288,31 +288,31 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, if (IS_ZEBRA_DEBUG_RIB) { inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN); - zlog_debug ("%u:%s/%d: Modifying route rn %p, rib %p (type %d)", - si->vrf_id, buf, p->prefixlen, rn, rib, rib->type); + zlog_debug ("%u:%s/%d: Modifying route rn %p, re %p (type %d)", + si->vrf_id, buf, p->prefixlen, rn, re, re->type); } } UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) { /* If there are other active nexthops, do an update. */ - if (rib->nexthop_active_num > 1) + if (re->nexthop_active_num > 1) { /* Update route in kernel if it's in fib */ - if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB)) - rib_install_kernel (rn, rib, rib); + if (CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB)) + rib_install_kernel (rn, re, re); /* Update redistribution if it's selected */ - if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED)) - redistribute_update (p, (struct prefix*)src_p, rib, NULL); + if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) + redistribute_update (p, (struct prefix*)src_p, re, NULL); } else { /* Remove from redistribute if selected route becomes inactive */ - if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED)) - redistribute_delete (p, (struct prefix*)src_p, rib); + if (CHECK_FLAG(re->flags, ZEBRA_FLAG_SELECTED)) + redistribute_delete (p, (struct prefix*)src_p, re); /* Remove from kernel if fib route becomes inactive */ - if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB)) - rib_uninstall_kernel (rn, rib); + if (CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB)) + rib_uninstall_kernel (rn, re); } } @@ -329,7 +329,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, nh_p.prefixlen = IPV6_MAX_BITLEN; nh_p.u.prefix6 = nexthop->gate.ipv6; } - rib_nexthop_delete (rib, nexthop); + route_entry_nexthop_delete (re, nexthop); zebra_deregister_rnh_static_nh(si->vrf_id, &nh_p, rn); nexthop_free (nexthop); } diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 94e2506186..2a759c2e79 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -334,10 +334,10 @@ zebra_vrf_table_with_table_id (afi_t afi, safi_t safi, static void zebra_rtable_node_cleanup (struct route_table *table, struct route_node *node) { - struct rib *rib, *next; + struct route_entry *re, *next; - RNODE_FOREACH_RIB_SAFE (node, rib, next) - rib_unlink (node, rib); + RNODE_FOREACH_RE_SAFE (node, re, next) + rib_unlink (node, re); if (node->info) XFREE (MTYPE_RIB_DEST, node->info); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index d0d761af95..c865a8ed1e 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -321,7 +321,7 @@ DEFUN (show_ip_rpf_addr, int idx_ipv4 = 3; struct in_addr addr; struct route_node *rn; - struct rib *rib; + struct route_entry *re; int ret; ret = inet_aton (argv[idx_ipv4]->arg, &addr); @@ -331,9 +331,9 @@ DEFUN (show_ip_rpf_addr, return CMD_WARNING; } - rib = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn); + re = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn); - if (rib) + if (re) vty_show_ip_route_detail (vty, rn, 1); else vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE); @@ -640,13 +640,13 @@ DEFUN (no_ip_route_mask_flags, static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) { - struct rib *rib; + struct route_entry *re; struct nexthop *nexthop, *tnexthop; int recursing; char buf[SRCDEST2STR_BUFFER]; struct zebra_vrf *zvrf; - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { const char *mcast_info = ""; if (mcast) @@ -660,42 +660,42 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, "Routing entry for %s%s%s", srcdest_rnode2str(rn, buf, sizeof(buf)), mcast_info, VTY_NEWLINE); - vty_out (vty, " Known via \"%s", zebra_route_string (rib->type)); - if (rib->instance) - vty_out (vty, "[%d]", rib->instance); + vty_out (vty, " Known via \"%s", zebra_route_string (re->type)); + if (re->instance) + vty_out (vty, "[%d]", re->instance); vty_out (vty, "\""); - vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); - if (rib->tag) - vty_out (vty, ", tag %d", rib->tag); - if (rib->mtu) - vty_out (vty, ", mtu %u", rib->mtu); - if (rib->vrf_id != VRF_DEFAULT) + vty_out (vty, ", distance %u, metric %u", re->distance, re->metric); + if (re->tag) + vty_out (vty, ", tag %d", re->tag); + if (re->mtu) + vty_out (vty, ", mtu %u", re->mtu); + if (re->vrf_id != VRF_DEFAULT) { - zvrf = vrf_info_lookup(rib->vrf_id); + zvrf = vrf_info_lookup(re->vrf_id); vty_out (vty, ", vrf %s", zvrf_name (zvrf)); } - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)) vty_out (vty, ", best"); - if (rib->refcnt) - vty_out (vty, ", refcnt %ld", rib->refcnt); - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) + if (re->refcnt) + vty_out (vty, ", refcnt %ld", re->refcnt); + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE)) vty_out (vty, ", blackhole"); - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT)) vty_out (vty, ", reject"); vty_out (vty, "%s", VTY_NEWLINE); - if (rib->type == ZEBRA_ROUTE_RIP - || rib->type == ZEBRA_ROUTE_OSPF - || rib->type == ZEBRA_ROUTE_ISIS - || rib->type == ZEBRA_ROUTE_NHRP - || rib->type == ZEBRA_ROUTE_TABLE - || rib->type == ZEBRA_ROUTE_BGP) + if (re->type == ZEBRA_ROUTE_RIP + || re->type == ZEBRA_ROUTE_OSPF + || re->type == ZEBRA_ROUTE_ISIS + || re->type == ZEBRA_ROUTE_NHRP + || re->type == ZEBRA_ROUTE_TABLE + || re->type == ZEBRA_ROUTE_BGP) { time_t uptime; struct tm *tm; uptime = time (NULL); - uptime -= rib->uptime; + uptime -= re->uptime; tm = gmtime (&uptime); vty_out (vty, " Last update "); @@ -713,7 +713,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, " ago%s", VTY_NEWLINE); } - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { char addrstr[32]; @@ -728,7 +728,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4)); if (nexthop->ifindex) vty_out (vty, ", via %s", - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6_IFINDEX: @@ -736,11 +736,11 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); if (nexthop->ifindex) vty_out (vty, ", via %s", - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_IFINDEX: vty_out (vty, " directly connected, %s", - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_BLACKHOLE: vty_out (vty, " directly connected, Null0"); @@ -796,7 +796,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) } static void -vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, +vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *re, json_object *json) { struct nexthop *nexthop, *tnexthop; @@ -814,41 +814,41 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, json_nexthops = json_object_new_array(); json_object_string_add(json_route, "prefix", srcdest_rnode2str (rn, buf, sizeof buf)); - json_object_string_add(json_route, "protocol", zebra_route_string(rib->type)); + json_object_string_add(json_route, "protocol", zebra_route_string(re->type)); - if (rib->instance) - json_object_int_add(json_route, "instance", rib->instance); + if (re->instance) + json_object_int_add(json_route, "instance", re->instance); - if (rib->vrf_id) - json_object_int_add(json_route, "vrfId", rib->vrf_id); + if (re->vrf_id) + json_object_int_add(json_route, "vrfId", re->vrf_id); - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)) json_object_boolean_true_add(json_route, "selected"); - if (rib->type != ZEBRA_ROUTE_CONNECT && rib->type != ZEBRA_ROUTE_KERNEL) + if (re->type != ZEBRA_ROUTE_CONNECT && re->type != ZEBRA_ROUTE_KERNEL) { - json_object_int_add(json_route, "distance", rib->distance); - json_object_int_add(json_route, "metric", rib->metric); + json_object_int_add(json_route, "distance", re->distance); + json_object_int_add(json_route, "metric", re->metric); } - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE)) json_object_boolean_true_add(json_route, "blackhole"); - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT)) json_object_boolean_true_add(json_route, "reject"); - if (rib->type == ZEBRA_ROUTE_RIP - || rib->type == ZEBRA_ROUTE_OSPF - || rib->type == ZEBRA_ROUTE_ISIS - || rib->type == ZEBRA_ROUTE_NHRP - || rib->type == ZEBRA_ROUTE_TABLE - || rib->type == ZEBRA_ROUTE_BGP) + if (re->type == ZEBRA_ROUTE_RIP + || re->type == ZEBRA_ROUTE_OSPF + || re->type == ZEBRA_ROUTE_ISIS + || re->type == ZEBRA_ROUTE_NHRP + || re->type == ZEBRA_ROUTE_TABLE + || re->type == ZEBRA_ROUTE_BGP) { time_t uptime; struct tm *tm; uptime = time (NULL); - uptime -= rib->uptime; + uptime -= re->uptime; tm = gmtime (&uptime); if (uptime < ONE_DAY_SECOND) @@ -861,7 +861,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, json_object_string_add(json_route, "uptime", buf); } - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { json_nexthop = json_object_new_object(); @@ -878,7 +878,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, if (nexthop->ifindex) { json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex); - json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id)); } break; case NEXTHOP_TYPE_IPV6: @@ -889,14 +889,14 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, if (nexthop->ifindex) { json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex); - json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id)); } break; case NEXTHOP_TYPE_IFINDEX: json_object_boolean_true_add(json_nexthop, "directlyConnected"); json_object_int_add(json_nexthop, "interfaceIndex", nexthop->ifindex); - json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + json_object_string_add(json_nexthop, "interfaceName", ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_BLACKHOLE: json_object_boolean_true_add(json_nexthop, "blackhole"); @@ -955,26 +955,26 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, } /* Nexthop information. */ - for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) + for (ALL_NEXTHOPS_RO(re->nexthop, nexthop, tnexthop, recursing)) { - if (nexthop == rib->nexthop) + if (nexthop == re->nexthop) { /* Prefix information. */ - len = vty_out (vty, "%c", zebra_route_char (rib->type)); - if (rib->instance) - len += vty_out (vty, "[%d]", rib->instance); + len = vty_out (vty, "%c", zebra_route_char (re->type)); + if (re->instance) + len += vty_out (vty, "[%d]", re->instance); len += vty_out (vty, "%c%c %s", - CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) + CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED) ? '>' : ' ', CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', srcdest_rnode2str (rn, buf, sizeof buf)); /* Distance and metric display. */ - if (rib->type != ZEBRA_ROUTE_CONNECT - && rib->type != ZEBRA_ROUTE_KERNEL) - len += vty_out (vty, " [%d/%d]", rib->distance, - rib->metric); + if (re->type != ZEBRA_ROUTE_CONNECT + && re->type != ZEBRA_ROUTE_KERNEL) + len += vty_out (vty, " [%d/%d]", re->distance, + re->metric); } else vty_out (vty, " %c%*c", @@ -989,7 +989,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4)); if (nexthop->ifindex) vty_out (vty, ", %s", - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6_IFINDEX: @@ -997,12 +997,12 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); if (nexthop->ifindex) vty_out (vty, ", %s", - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_IFINDEX: vty_out (vty, " is directly connected, %s", - ifindex2ifname (nexthop->ifindex, rib->vrf_id)); + ifindex2ifname (nexthop->ifindex, re->vrf_id)); break; case NEXTHOP_TYPE_BLACKHOLE: vty_out (vty, " is directly connected, Null0"); @@ -1049,23 +1049,23 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib, nexthop->nh_label->label, buf, BUFSIZ, 1)); } - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_BLACKHOLE)) vty_out (vty, ", bh"); - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_REJECT)) vty_out (vty, ", rej"); - if (rib->type == ZEBRA_ROUTE_RIP - || rib->type == ZEBRA_ROUTE_OSPF - || rib->type == ZEBRA_ROUTE_ISIS - || rib->type == ZEBRA_ROUTE_NHRP - || rib->type == ZEBRA_ROUTE_TABLE - || rib->type == ZEBRA_ROUTE_BGP) + if (re->type == ZEBRA_ROUTE_RIP + || re->type == ZEBRA_ROUTE_OSPF + || re->type == ZEBRA_ROUTE_ISIS + || re->type == ZEBRA_ROUTE_NHRP + || re->type == ZEBRA_ROUTE_TABLE + || re->type == ZEBRA_ROUTE_BGP) { time_t uptime; struct tm *tm; uptime = time (NULL); - uptime -= rib->uptime; + uptime -= re->uptime; tm = gmtime (&uptime); if (uptime < ONE_DAY_SECOND) @@ -1097,7 +1097,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; int first = 1; struct zebra_vrf *zvrf = NULL; char buf[BUFSIZ]; @@ -1137,12 +1137,12 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, /* Show all routes. */ for (rn = route_top (table); rn; rn = route_next (rn)) { - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - if (use_fib && !CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB)) + if (use_fib && !CHECK_FLAG(re->status, ROUTE_ENTRY_SELECTED_FIB)) continue; - if (tag && rib->tag != tag) + if (tag && re->tag != tag) continue; if (longer_prefix_p && ! prefix_match (longer_prefix_p, &rn->p)) @@ -1163,10 +1163,10 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, continue; } - if (type && rib->type != type) + if (type && re->type != type) continue; - if (ospf_instance_id && (rib->type != ZEBRA_ROUTE_OSPF || rib->instance != ospf_instance_id)) + if (ospf_instance_id && (re->type != ZEBRA_ROUTE_OSPF || re->instance != ospf_instance_id)) continue; if (use_json) @@ -1190,7 +1190,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, afi_t afi, safi_t safi, } } - vty_show_ip_route (vty, rn, rib, json_prefix); + vty_show_ip_route (vty, rn, re, json_prefix); } if (json_prefix) @@ -1567,7 +1567,7 @@ static void vty_show_ip_route_summary (struct vty *vty, struct route_table *table) { struct route_node *rn; - struct rib *rib; + struct route_entry *re; #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; @@ -1578,25 +1578,25 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table) memset (&rib_cnt, 0, sizeof(rib_cnt)); memset (&fib_cnt, 0, sizeof(fib_cnt)); for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { - is_ibgp = (rib->type == ZEBRA_ROUTE_BGP && - CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)); + is_ibgp = (re->type == ZEBRA_ROUTE_BGP && + CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP)); rib_cnt[ZEBRA_ROUTE_TOTAL]++; if (is_ibgp) rib_cnt[ZEBRA_ROUTE_IBGP]++; else - rib_cnt[rib->type]++; + rib_cnt[re->type]++; - if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) + if (CHECK_FLAG (re->flags, ZEBRA_FLAG_SELECTED)) { fib_cnt[ZEBRA_ROUTE_TOTAL]++; if (is_ibgp) fib_cnt[ZEBRA_ROUTE_IBGP]++; else - fib_cnt[rib->type]++; + fib_cnt[re->type]++; } } @@ -1642,7 +1642,7 @@ static void vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) { struct route_node *rn; - struct rib *rib; + struct route_entry *re; struct nexthop *nexthop; #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) @@ -1654,25 +1654,25 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) memset (&rib_cnt, 0, sizeof(rib_cnt)); memset (&fib_cnt, 0, sizeof(fib_cnt)); for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { /* * In case of ECMP, count only once. */ cnt = 0; - for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next) + for (nexthop = re->nexthop; (!cnt && nexthop); nexthop = nexthop->next) { cnt++; rib_cnt[ZEBRA_ROUTE_TOTAL]++; - rib_cnt[rib->type]++; + rib_cnt[re->type]++; if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) { fib_cnt[ZEBRA_ROUTE_TOTAL]++; - fib_cnt[rib->type]++; + fib_cnt[re->type]++; } - if (rib->type == ZEBRA_ROUTE_BGP && - CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) + if (re->type == ZEBRA_ROUTE_BGP && + CHECK_FLAG (re->flags, ZEBRA_FLAG_IBGP)) { rib_cnt[ZEBRA_ROUTE_IBGP]++; if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) @@ -2816,7 +2816,7 @@ DEFUN (show_ipv6_mroute, { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; @@ -2829,14 +2829,14 @@ DEFUN (show_ipv6_mroute, /* Show all IPv6 route. */ for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { if (first) { vty_out (vty, SHOW_ROUTE_V6_HEADER); first = 0; } - vty_show_ip_route (vty, rn, rib, NULL); + vty_show_ip_route (vty, rn, re, NULL); } return CMD_SUCCESS; } @@ -2959,7 +2959,7 @@ DEFUN (show_ipv6_mroute_vrf_all, { struct route_table *table; struct route_node *rn; - struct rib *rib; + struct route_entry *re; struct vrf *vrf; struct zebra_vrf *zvrf; int first = 1; @@ -2972,14 +2972,14 @@ DEFUN (show_ipv6_mroute_vrf_all, /* Show all IPv6 route. */ for (rn = route_top (table); rn; rn = srcdest_route_next (rn)) - RNODE_FOREACH_RIB (rn, rib) + RNODE_FOREACH_RE (rn, re) { if (first) { vty_out (vty, SHOW_ROUTE_V6_HEADER); first = 0; } - vty_show_ip_route (vty, rn, rib, NULL); + vty_show_ip_route (vty, rn, re, NULL); } } return CMD_SUCCESS; diff --git a/zebra/zserv.c b/zebra/zserv.c index e93299d622..29cdb98082 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -608,7 +608,7 @@ zsend_interface_update (int cmd, struct zserv *client, struct interface *ifp) */ int zsend_redistribute_route (int add, struct zserv *client, struct prefix *p, - struct prefix *src_p, struct rib *rib) + struct prefix *src_p, struct route_entry *re) { afi_t afi; int cmd; @@ -658,12 +658,12 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p, stream_reset (s); memset(&dummy_nh, 0, sizeof(struct nexthop)); - zserv_create_header (s, cmd, rib->vrf_id); + zserv_create_header (s, cmd, re->vrf_id); /* Put type and nexthop. */ - stream_putc (s, rib->type); - stream_putw (s, rib->instance); - stream_putl (s, rib->flags); + stream_putc (s, re->type); + stream_putw (s, re->instance); + stream_putl (s, re->flags); /* marker for message flags field */ messmark = stream_get_endp (s); @@ -682,10 +682,10 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p, stream_write (s, (u_char *) & src_p->u.prefix, psize); } - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) { /* We don't send any nexthops when there's a multipath */ - if (rib->nexthop_active_num > 1 && client->proto != ZEBRA_ROUTE_LDP) + if (re->nexthop_active_num > 1 && client->proto != ZEBRA_ROUTE_LDP) { SET_FLAG (zapi_flags, ZAPI_MESSAGE_NEXTHOP); SET_FLAG (zapi_flags, ZAPI_MESSAGE_IFINDEX); @@ -764,22 +764,22 @@ zsend_redistribute_route (int add, struct zserv *client, struct prefix *p, /* Distance */ SET_FLAG (zapi_flags, ZAPI_MESSAGE_DISTANCE); - stream_putc (s, rib->distance); + stream_putc (s, re->distance); /* Metric */ SET_FLAG (zapi_flags, ZAPI_MESSAGE_METRIC); - stream_putl (s, rib->metric); + stream_putl (s, re->metric); /* Tag */ - if (rib->tag) + if (re->tag) { SET_FLAG(zapi_flags, ZAPI_MESSAGE_TAG); - stream_putl(s, rib->tag); + stream_putl(s, re->tag); } /* MTU */ SET_FLAG (zapi_flags, ZAPI_MESSAGE_MTU); - stream_putl (s, rib->mtu); + stream_putl (s, re->mtu); /* write real message flags value */ stream_putc_at (s, messmark, zapi_flags); @@ -1044,7 +1044,7 @@ zserv_fec_unregister (struct zserv *client, int sock, u_short length) Returns both route metric and protocol distance. */ static int -zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struct rib *rib, struct zebra_vrf *zvrf) +zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struct route_entry *re, struct zebra_vrf *zvrf) { struct stream *s; unsigned long nump; @@ -1059,17 +1059,17 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc zserv_create_header (s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf_id (zvrf)); stream_put_in_addr (s, &addr); - if (rib) + if (re) { - stream_putc (s, rib->distance); - stream_putl (s, rib->metric); + stream_putc (s, re->distance); + stream_putl (s, re->metric); num = 0; nump = stream_get_endp(s); /* remember position for nexthop_num */ stream_putc (s, 0); /* reserve room for nexthop_num */ /* Only non-recursive routes are elegible to resolve the nexthop we * are looking up. Therefore, we will just iterate over the top * chain of nexthops. */ - for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) + for (nexthop = re->nexthop; nexthop; nexthop = nexthop->next) if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) num += zsend_write_nexthop (s, nexthop); @@ -1169,14 +1169,14 @@ zserv_nexthop_num_warn (const char *caller, const struct prefix *p, const unsign /* This function support multiple nexthop. */ /* - * Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update rib and + * Parse the ZEBRA_IPV4_ROUTE_ADD sent from client. Update re and * add kernel route. */ static int zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) { int i; - struct rib *rib; + struct route_entry *re; struct prefix p; u_char message; struct in_addr nhop_addr; @@ -1192,16 +1192,16 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) /* Get input stream. */ s = client->ibuf; - /* Allocate new rib. */ - rib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); + /* Allocate new re. */ + re = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); /* Type, flags, message. */ - rib->type = stream_getc (s); - rib->instance = stream_getw (s); - rib->flags = stream_getl (s); + re->type = stream_getc (s); + re->instance = stream_getw (s); + re->flags = stream_getl (s); message = stream_getc (s); safi = stream_getw (s); - rib->uptime = time (NULL); + re->uptime = time (NULL); /* IPv4 prefix. */ memset (&p, 0, sizeof (struct prefix_ipv4)); @@ -1210,7 +1210,7 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) stream_get (&p.u.prefix4, s, PSIZE (p.prefixlen)); /* VRF ID */ - rib->vrf_id = zvrf_id (zvrf); + re->vrf_id = zvrf_id (zvrf); /* Nexthop parse. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP)) @@ -1226,11 +1226,11 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) { case NEXTHOP_TYPE_IFINDEX: ifindex = stream_getl (s); - rib_nexthop_ifindex_add (rib, ifindex); + route_entry_nexthop_ifindex_add (re, ifindex); break; case NEXTHOP_TYPE_IPV4: nhop_addr.s_addr = stream_get_ipv4 (s); - nexthop = rib_nexthop_ipv4_add (rib, &nhop_addr, NULL); + nexthop = route_entry_nexthop_ipv4_add (re, &nhop_addr, NULL); /* For labeled-unicast, each nexthop is followed by label. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_LABEL)) { @@ -1241,13 +1241,13 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) case NEXTHOP_TYPE_IPV4_IFINDEX: nhop_addr.s_addr = stream_get_ipv4 (s); ifindex = stream_getl (s); - rib_nexthop_ipv4_ifindex_add (rib, &nhop_addr, NULL, ifindex); + route_entry_nexthop_ipv4_ifindex_add (re, &nhop_addr, NULL, ifindex); break; case NEXTHOP_TYPE_IPV6: stream_forward_getp (s, IPV6_MAX_BYTELEN); break; case NEXTHOP_TYPE_BLACKHOLE: - rib_nexthop_blackhole_add (rib); + route_entry_nexthop_blackhole_add (re); break; } } @@ -1255,27 +1255,27 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) /* Distance. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE)) - rib->distance = stream_getc (s); + re->distance = stream_getc (s); /* Metric. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC)) - rib->metric = stream_getl (s); + re->metric = stream_getl (s); /* Tag */ if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG)) - rib->tag = stream_getl (s); + re->tag = stream_getl (s); else - rib->tag = 0; + re->tag = 0; if (CHECK_FLAG (message, ZAPI_MESSAGE_MTU)) - rib->mtu = stream_getl (s); + re->mtu = stream_getl (s); else - rib->mtu = 0; + re->mtu = 0; /* Table */ - rib->table = zvrf->table_id; + re->table = zvrf->table_id; - ret = rib_add_multipath (AFI_IP, safi, &p, NULL, rib); + ret = rib_add_multipath (AFI_IP, safi, &p, NULL, re); /* Stats */ if (ret > 0) @@ -1384,11 +1384,11 @@ static int zread_ipv4_nexthop_lookup_mrib (struct zserv *client, u_short length, struct zebra_vrf *zvrf) { struct in_addr addr; - struct rib *rib; + struct route_entry *re; addr.s_addr = stream_get_ipv4 (client->ibuf); - rib = rib_match_ipv4_multicast (zvrf_id (zvrf), addr, NULL); - return zsend_ipv4_nexthop_lookup_mrib (client, addr, rib, zvrf); + re = rib_match_ipv4_multicast (zvrf_id (zvrf), addr, NULL); + return zsend_ipv4_nexthop_lookup_mrib (client, addr, re, zvrf); } /* Zebra server IPv6 prefix add function. */ @@ -1398,7 +1398,7 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct unsigned int i; struct stream *s; struct in6_addr nhop_addr; - struct rib *rib; + struct route_entry *re; u_char message; u_char nexthop_num; u_char nexthop_type; @@ -1416,16 +1416,16 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct memset (&nhop_addr, 0, sizeof (struct in6_addr)); - /* Allocate new rib. */ - rib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); + /* Allocate new re. */ + re = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); /* Type, flags, message. */ - rib->type = stream_getc (s); - rib->instance = stream_getw (s); - rib->flags = stream_getl (s); + re->type = stream_getc (s); + re->instance = stream_getw (s); + re->flags = stream_getl (s); message = stream_getc (s); safi = stream_getw (s); - rib->uptime = time (NULL); + re->uptime = time (NULL); /* IPv4 prefix. */ memset (&p, 0, sizeof (struct prefix_ipv4)); @@ -1434,10 +1434,10 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct stream_get (&p.u.prefix4, s, PSIZE (p.prefixlen)); /* VRF ID */ - rib->vrf_id = zvrf_id (zvrf); + re->vrf_id = zvrf_id (zvrf); /* We need to give nh-addr, nh-ifindex with the same next-hop object - * to the rib to ensure that IPv6 multipathing works; need to coalesce + * to the re to ensure that IPv6 multipathing works; need to coalesce * these. Clients should send the same number of paired set of * next-hop-addr/next-hop-ifindices. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP)) @@ -1474,7 +1474,7 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct } break; case NEXTHOP_TYPE_BLACKHOLE: - rib_nexthop_blackhole_add (rib); + route_entry_nexthop_blackhole_add (re); break; } } @@ -1484,43 +1484,43 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct { if ((i < nh_count) && !IN6_IS_ADDR_UNSPECIFIED (&nexthops[i])) { if ((i < if_count) && ifindices[i]) - nexthop = rib_nexthop_ipv6_ifindex_add (rib, &nexthops[i], ifindices[i]); + nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &nexthops[i], ifindices[i]); else - nexthop = rib_nexthop_ipv6_add (rib, &nexthops[i]); + nexthop = route_entry_nexthop_ipv6_add (re, &nexthops[i]); if (CHECK_FLAG (message, ZAPI_MESSAGE_LABEL)) nexthop_add_labels (nexthop, nexthop->nh_label_type, 1, &labels[i]); } else { if ((i < if_count) && ifindices[i]) - rib_nexthop_ifindex_add (rib, ifindices[i]); + route_entry_nexthop_ifindex_add (re, ifindices[i]); } } } /* Distance. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE)) - rib->distance = stream_getc (s); + re->distance = stream_getc (s); /* Metric. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC)) - rib->metric = stream_getl (s); + re->metric = stream_getl (s); /* Tag */ if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG)) - rib->tag = stream_getl (s); + re->tag = stream_getl (s); else - rib->tag = 0; + re->tag = 0; if (CHECK_FLAG (message, ZAPI_MESSAGE_MTU)) - rib->mtu = stream_getl (s); + re->mtu = stream_getl (s); else - rib->mtu = 0; + re->mtu = 0; /* Table */ - rib->table = zvrf->table_id; + re->table = zvrf->table_id; - ret = rib_add_multipath (AFI_IP6, safi, &p, NULL, rib); + ret = rib_add_multipath (AFI_IP6, safi, &p, NULL, re); /* Stats */ if (ret > 0) client->v4_route_add_cnt++; @@ -1536,7 +1536,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) unsigned int i; struct stream *s; struct in6_addr nhop_addr; - struct rib *rib; + struct route_entry *re; u_char message; u_char nexthop_num; u_char nexthop_type; @@ -1555,16 +1555,16 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) memset (&nhop_addr, 0, sizeof (struct in6_addr)); - /* Allocate new rib. */ - rib = XCALLOC (MTYPE_RIB, sizeof (struct rib)); + /* Allocate new re. */ + re = XCALLOC (MTYPE_RE, sizeof (struct route_entry)); /* Type, flags, message. */ - rib->type = stream_getc (s); - rib->instance = stream_getw (s); - rib->flags = stream_getl (s); + re->type = stream_getc (s); + re->instance = stream_getw (s); + re->flags = stream_getl (s); message = stream_getc (s); safi = stream_getw (s); - rib->uptime = time (NULL); + re->uptime = time (NULL); /* IPv6 prefix. */ memset (&p, 0, sizeof (struct prefix_ipv6)); @@ -1584,7 +1584,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) src_pp = NULL; /* We need to give nh-addr, nh-ifindex with the same next-hop object - * to the rib to ensure that IPv6 multipathing works; need to coalesce + * to the re to ensure that IPv6 multipathing works; need to coalesce * these. Clients should send the same number of paired set of * next-hop-addr/next-hop-ifindices. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP)) @@ -1620,7 +1620,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) } break; case NEXTHOP_TYPE_BLACKHOLE: - rib_nexthop_blackhole_add (rib); + route_entry_nexthop_blackhole_add (re); break; } } @@ -1630,43 +1630,43 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) { if ((i < nh_count) && !IN6_IS_ADDR_UNSPECIFIED (&nexthops[i])) { if ((i < if_count) && ifindices[i]) - nexthop = rib_nexthop_ipv6_ifindex_add (rib, &nexthops[i], ifindices[i]); + nexthop = route_entry_nexthop_ipv6_ifindex_add (re, &nexthops[i], ifindices[i]); else - nexthop = rib_nexthop_ipv6_add (rib, &nexthops[i]); + nexthop = route_entry_nexthop_ipv6_add (re, &nexthops[i]); if (CHECK_FLAG (message, ZAPI_MESSAGE_LABEL)) nexthop_add_labels (nexthop, nexthop->nh_label_type, 1, &labels[i]); } else { if ((i < if_count) && ifindices[i]) - rib_nexthop_ifindex_add (rib, ifindices[i]); + route_entry_nexthop_ifindex_add (re, ifindices[i]); } } } /* Distance. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE)) - rib->distance = stream_getc (s); + re->distance = stream_getc (s); /* Metric. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC)) - rib->metric = stream_getl (s); + re->metric = stream_getl (s); /* Tag */ if (CHECK_FLAG (message, ZAPI_MESSAGE_TAG)) - rib->tag = stream_getl (s); + re->tag = stream_getl (s); else - rib->tag = 0; + re->tag = 0; if (CHECK_FLAG (message, ZAPI_MESSAGE_MTU)) - rib->mtu = stream_getl (s); + re->mtu = stream_getl (s); else - rib->mtu = 0; + re->mtu = 0; /* VRF ID */ - rib->vrf_id = zvrf_id (zvrf); - rib->table = zvrf->table_id; + re->vrf_id = zvrf_id (zvrf); + re->table = zvrf->table_id; - ret = rib_add_multipath (AFI_IP6, safi, &p, src_pp, rib); + ret = rib_add_multipath (AFI_IP6, safi, &p, src_pp, re); /* Stats */ if (ret > 0) client->v6_route_add_cnt++; diff --git a/zebra/zserv.h b/zebra/zserv.h index 2fafd040cf..dcc98d83f7 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -162,7 +162,7 @@ extern void nbr_connected_add_ipv6 (struct interface *, struct in6_addr *); extern void nbr_connected_delete_ipv6 (struct interface *, struct in6_addr *); extern int zsend_interface_update (int, struct zserv *, struct interface *); extern int zsend_redistribute_route (int, struct zserv *, struct prefix *, - struct prefix *, struct rib *); + struct prefix *, struct route_entry *); extern int zsend_router_id_update (struct zserv *, struct prefix *, vrf_id_t); extern int zsend_interface_vrf_update (struct zserv *, struct interface *, From 509fac8d8564fcb3d0bec3be9567312f6d83e889 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 1 Jun 2017 19:23:00 +0200 Subject: [PATCH 42/96] release: frr-3.0-rc0 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d9bed28c95..e6f680d85a 100755 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ ## AC_PREREQ(2.60) -AC_INIT(frr, 3.0, [https://github.com/frrouting/frr/issues]) +AC_INIT(frr, 3.0-rc0, [https://github.com/frrouting/frr/issues]) PACKAGE_URL="https://frrouting.org/" PACKAGE_FULLNAME="FRRouting" AC_SUBST(PACKAGE_FULLNAME) From 95c7c2dd3de348f4de93d6772967cddee83a0bb7 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 1 Jun 2017 20:05:15 -0400 Subject: [PATCH 43/96] doc: Fix up some missed stuff for Ubuntu 12.04 build doc Signed-off-by: Donald Sharp --- doc/Building_FRR_on_Ubuntu1204.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/Building_FRR_on_Ubuntu1204.md b/doc/Building_FRR_on_Ubuntu1204.md index 033e05bcdb..e79614a57e 100644 --- a/doc/Building_FRR_on_Ubuntu1204.md +++ b/doc/Building_FRR_on_Ubuntu1204.md @@ -13,7 +13,7 @@ Add packages: apt-get install git autoconf automake libtool make gawk libreadline-dev \ texinfo libpam0g-dev dejagnu libjson0-dev pkg-config libpam0g-dev \ - libjson0-dev flex python-pip libc-ares-dev python3-dev + libjson0-dev flex python-pip libc-ares-dev python3-dev libxml2 libxml2-dev Install newer bison from 14.04 package source (Ubuntu 12.04 package source is too old) @@ -51,6 +51,11 @@ Install newer version of autoconf and automake: sudo make install cd .. +Install XML::LibXML + + sudo cpan + install XML::LibXML + Install pytest: pip install pytest From 4b872c22a3a4d7a3a96adf2b9313afa79324de02 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 1 Jun 2017 20:09:06 -0400 Subject: [PATCH 44/96] nhrpd: Guard a debug that was constantly spewing information This debug when nhrpd was just running but not configured was constantly being sent to the log file. Filling it with useless information Signed-off-by: Donald Sharp --- nhrpd/vici.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nhrpd/vici.c b/nhrpd/vici.c index 244562d547..18faca2d5a 100644 --- a/nhrpd/vici.c +++ b/nhrpd/vici.c @@ -421,7 +421,7 @@ static int vici_reconnect(struct thread *t) fd = sock_open_unix("/var/run/charon.vici"); if (fd < 0) { - zlog_warn("%s: failure connecting VICI socket: %s", + debugf(NHRP_DEBUG_VICI, "%s: failure connecting VICI socket: %s", __PRETTY_FUNCTION__, strerror(errno)); thread_add_timer(master, vici_reconnect, vici, 2, &vici->t_reconnect); From bade23d3b02d5e7c71a2d9fbdad2456a9668b174 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 1 Jun 2017 20:11:19 -0400 Subject: [PATCH 45/96] pimd: Remove some unneeded debugs from pim Signed-off-by: Donald Sharp --- pimd/pim_bfd.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index 5c10df32e1..b0915fa628 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -44,15 +44,10 @@ pim_bfd_write_config (struct vty *vty, struct interface *ifp) struct pim_interface *pim_ifp = ifp->info; struct bfd_info *bfd_info = NULL; - if (!pim_ifp) - return; bfd_info = (struct bfd_info *) pim_ifp->bfd_info; if (!bfd_info) - { - zlog_debug ("%s: interface %s bfd_info is NULL ", __PRETTY_FUNCTION__, - ifp->name); - return; - } + return; + if (CHECK_FLAG (bfd_info->flags, BFD_FLAG_PARAM_CFG)) vty_out (vty, " ip pim bfd %d %d %d%s", bfd_info->detect_mult, bfd_info->required_min_rx, @@ -94,7 +89,6 @@ pim_bfd_info_nbr_create (struct pim_interface *pim_ifp, if (!neigh->bfd_info) return; - zlog_debug ("%s: bfd_info ", __PRETTY_FUNCTION__); nbr_bfd_info = (struct bfd_info *) neigh->bfd_info; nbr_bfd_info->detect_mult = pim_ifp->bfd_info->detect_mult; From 58f1b7ccbdaf8054e6b2ece1bf3840663aea6214 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 2 Jun 2017 07:35:38 -0400 Subject: [PATCH 46/96] zebra: Fix help string ordering Signed-off-by: Donald Sharp --- zebra/rtadv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 7f46066a63..5b0b44572f 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1403,8 +1403,8 @@ DEFUN (ipv6_nd_router_preference, "Neighbor discovery\n" "Default router preference\n" "High default router preference\n" - "Low default router preference\n" - "Medium default router preference (default)\n") + "Medium default router preference (default)\n" + "Low default router preference\n") { int idx_high_medium_low = 3; VTY_DECLVAR_CONTEXT (interface, ifp); From 09acca5bb04fd97a5946de8dc763f42b8f6f7743 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 17:08:29 +0000 Subject: [PATCH 47/96] frr: ignore 'compile_commands.json' This file is generated by most tooling for Clang and generally wants to be in the root directory. Best to ignore it. https://clang.llvm.org/docs/JSONCompilationDatabase.html Signed-off-by: Quentin Young --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 76d396ef25..5b88cf25af 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ GRTAGS GPATH *.la *.lo +compile_commands.json From 2b4dc78f7f16b4eceb8ea7b94e2c88cc9605a5b5 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 17:24:01 +0000 Subject: [PATCH 48/96] lib: free varhandler on exit Signed-off-by: Quentin Young --- lib/command.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/command.c b/lib/command.c index eb163f6189..38d28a1388 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2611,5 +2611,6 @@ cmd_terminate () if (host.config) XFREE (MTYPE_HOST, host.config); + list_delete (varhandlers); qobj_finish (); } From 1da29456213a3062206bc7646de169e32e9cc324 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 17 May 2017 16:20:29 -0400 Subject: [PATCH 49/96] lib, zebra: Pass up kernel table_id for vrf's pim controls the vrf table creation for due to the way that pim must interact with the kernel. In order to match the table_id for unicast <-> multicast( not necessary but a real nice to have ) we need to pass up from zebra the table_id associated with the vrf. Signed-off-by: Donald Sharp --- lib/vrf.h | 17 +++++++++++++++++ lib/zclient.c | 3 +++ zebra/zserv.c | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/lib/vrf.h b/lib/vrf.h index fe2b4842b0..d470349f00 100644 --- a/lib/vrf.h +++ b/lib/vrf.h @@ -56,6 +56,20 @@ enum { #define VRF_CMD_HELP_STR "Specify the VRF\nThe VRF name\n" #define VRF_ALL_CMD_HELP_STR "Specify the VRF\nAll VRFs\n" +/* + * Pass some OS specific data up through + * to the daemons + */ +struct vrf_data +{ + union + { + struct { + uint32_t table_id; + } l; + }; +}; + struct vrf { RB_ENTRY(vrf) id_entry, name_entry; @@ -76,6 +90,9 @@ struct vrf /* User data */ void *info; + /* The table_id from the kernel */ + struct vrf_data data; + QOBJ_FIELDS }; RB_HEAD (vrf_id_head, vrf); diff --git a/lib/zclient.c b/lib/zclient.c index a53e8112c8..b3a9338928 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -1077,12 +1077,15 @@ zclient_vrf_add (struct zclient *zclient, vrf_id_t vrf_id) { struct vrf *vrf; char vrfname_tmp[VRF_NAMSIZ]; + struct vrf_data data; + stream_get (&data, zclient->ibuf, sizeof (struct vrf_data)); /* Read interface name. */ stream_get (vrfname_tmp, zclient->ibuf, VRF_NAMSIZ); /* Lookup/create vrf by vrf_id. */ vrf = vrf_get (vrf_id, vrfname_tmp); + vrf->data = data; vrf_enable (vrf); } diff --git a/zebra/zserv.c b/zebra/zserv.c index e93299d622..b131b208c6 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -192,6 +192,11 @@ zserv_encode_interface (struct stream *s, struct interface *ifp) static void zserv_encode_vrf (struct stream *s, struct zebra_vrf *zvrf) { + struct vrf_data data; + + data.l.table_id = zvrf->table_id; + /* Pass the tableid */ + stream_put (s, &data, sizeof (struct vrf_data)); /* Interface information. */ stream_put (s, zvrf_name (zvrf), VRF_NAMSIZ); From 9a7aa8be43d3ec65f239f1740f86dbc1923824c6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 22 May 2017 15:43:20 -0400 Subject: [PATCH 50/96] vtysh: Cleanup some stuff(tm) 1) vtysh_config_dump was not properly indented. Fix 2) Add VRF_NODE to be line_uniq when parsing return from sub-daemons 3) Fix 'no log monitor' to be line_uniq as well Signed-off-by: Donald Sharp --- vtysh/vtysh_config.c | 64 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index f25b5f26f7..9e40e3f518 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -183,9 +183,10 @@ vtysh_config_parse_line (void *arg, const char *line) config->index = INTERFACE_NODE; } else if (config->index == RMAP_NODE || - config->index == INTERFACE_NODE || - config->index == NS_NODE || - config->index == VTY_NODE) + config->index == INTERFACE_NODE || + config->index == NS_NODE || + config->index == VTY_NODE || + config->index == VRF_NODE) config_add_line_uniq (config->line, line); else config_add_line (config->line, line); @@ -278,6 +279,7 @@ vtysh_config_parse_line (void *arg, const char *line) || strncmp (line, "hostname", strlen ("hostname")) == 0 || strncmp (line, "frr", strlen ("frr")) == 0 || strncmp (line, "agentx", strlen ("agentx")) == 0 + || strncmp (line, "no log", strlen ("no log")) == 0 ) config_add_line_uniq (config_top, line); else @@ -319,41 +321,41 @@ vtysh_config_dump (FILE *fp) for (i = 0; i < vector_active (configvec); i++) if ((master = vector_slot (configvec, i)) != NULL) { - for (ALL_LIST_ELEMENTS (master, node, nnode, config)) - { - /* Don't print empty sections for interface/vrf. Route maps on the - * other hand could have a legitimate empty section at the end. - */ - if ((config->index == INTERFACE_NODE || (config->index == VRF_NODE)) - && list_isempty (config->line)) - continue; + for (ALL_LIST_ELEMENTS (master, node, nnode, config)) + { + /* Don't print empty sections for interface/vrf. Route maps on the + * other hand could have a legitimate empty section at the end. + */ + if ((config->index == INTERFACE_NODE || config->index == VRF_NODE) + && list_isempty (config->line)) + continue; - fprintf (fp, "%s\n", config->name); - fflush (fp); + fprintf (fp, "%s\n", config->name); + fflush (fp); - for (ALL_LIST_ELEMENTS (config->line, mnode, mnnode, line)) - { - fprintf (fp, "%s\n", line); - fflush (fp); - } - if (! NO_DELIMITER (i)) - { - fprintf (fp, "!\n"); - fflush (fp); - } - } - if (NO_DELIMITER (i)) - { - fprintf (fp, "!\n"); - fflush (fp); - } + for (ALL_LIST_ELEMENTS (config->line, mnode, mnnode, line)) + { + fprintf (fp, "%s\n", line); + fflush (fp); + } + if (! NO_DELIMITER (i)) + { + fprintf (fp, "!\n"); + fflush (fp); + } + } + if (NO_DELIMITER (i)) + { + fprintf (fp, "!\n"); + fflush (fp); + } } for (i = 0; i < vector_active (configvec); i++) if ((master = vector_slot (configvec, i)) != NULL) { - list_delete (master); - vector_slot (configvec, i) = NULL; + list_delete (master); + vector_slot (configvec, i) = NULL; } list_delete_all_node (config_top); } From 9ce0f6a5df11f50da67c035b2f4eae3838f72106 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 23 May 2017 07:31:01 -0400 Subject: [PATCH 51/96] ospfd: Make OSPF TE warnings be less chatty If you are not using OSPF-TE than there is no need to be warned that we cannot find anything about it. Signed-off-by: Donald Sharp --- ospfd/ospf_te.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 804b1fb652..1afe20b958 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -838,8 +838,9 @@ initialize_linkparams (struct mpls_te_link *lp) if ((oi = lookup_oi_by_ifp (ifp, NULL, OI_ANY)) == NULL) { - zlog_warn("MPLS-TE(initialize_linkparams) Could not find corresponding OSPF Interface for %s", - ifp->name); + if (IS_DEBUG_OSPF_TE) + zlog_warn("MPLS-TE(initialize_linkparams) Could not find corresponding OSPF Interface for %s", + ifp->name); return; } @@ -991,7 +992,8 @@ ospf_mpls_te_update_if (struct interface *ifp) /* Get Link context from interface */ if ((lp = lookup_linkparams_by_ifp(ifp)) == NULL) { - zlog_warn ("OSPF MPLS-TE Update: Did not find Link Parameters context for interface %s", ifp->name); + if (IS_DEBUG_OSPF_TE) + zlog_warn ("OSPF MPLS-TE Update: Did not find Link Parameters context for interface %s", ifp->name); return; } From 7656e7fc468b89dec8399a8034c18064f7ddf71b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 4 May 2017 10:44:51 -0400 Subject: [PATCH 52/96] pimd: Remove qpim_inaddr_any In prep for switching over to having PIM understand VRF remove the qpim_inaddr_any global variable and just use INADDR_ANY directly. Signed-off-by: Donald Sharp --- pimd/pim_iface.c | 2 +- pimd/pim_ifchannel.c | 8 +++++--- pimd/pimd.c | 4 +--- pimd/pimd.h | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index f36a9b3cbb..afaa951724 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -297,7 +297,7 @@ static int detect_primary_address_change(struct interface *ifp, int changed; if (force_prim_as_any) - new_prim_addr = qpim_inaddr_any; + new_prim_addr.s_addr = INADDR_ANY; else new_prim_addr = pim_find_primary_addr(ifp); diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 9b79c032c8..6dc607e1bc 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -387,12 +387,14 @@ const char *pim_ifchannel_ifassert_name(enum pim_ifassert_state ifassert_state) */ void reset_ifassert_state(struct pim_ifchannel *ch) { + struct in_addr any = { .s_addr = INADDR_ANY }; + THREAD_OFF(ch->t_ifassert_timer); pim_ifassert_winner_set(ch, - PIM_IFASSERT_NOINFO, - qpim_inaddr_any, - qpim_infinite_assert_metric); + PIM_IFASSERT_NOINFO, + any, + qpim_infinite_assert_metric); } struct pim_ifchannel *pim_ifchannel_find(struct interface *ifp, diff --git a/pimd/pimd.c b/pimd/pimd.c index 51a0833cd5..c31d2a99a1 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -61,7 +61,6 @@ struct thread *qpim_rpf_cache_refresher = NULL; int64_t qpim_rpf_cache_refresh_requests = 0; int64_t qpim_rpf_cache_refresh_events = 0; int64_t qpim_rpf_cache_refresh_last = 0; -struct in_addr qpim_inaddr_any; struct list *qpim_ssmpingd_list = NULL; struct in_addr qpim_ssmpingd_group_addr; int64_t qpim_scan_oil_events = 0; @@ -293,7 +292,6 @@ void pim_init() pim_mroute_socket_enable(); - qpim_inaddr_any.s_addr = PIM_NET_INADDR_ANY; /* RFC 4601: 4.6.3. Assert Metrics @@ -306,7 +304,7 @@ void pim_init() qpim_infinite_assert_metric.rpt_bit_flag = 1; qpim_infinite_assert_metric.metric_preference = PIM_ASSERT_METRIC_PREFERENCE_MAX; qpim_infinite_assert_metric.route_metric = PIM_ASSERT_ROUTE_METRIC_MAX; - qpim_infinite_assert_metric.ip_address = qpim_inaddr_any; + qpim_infinite_assert_metric.ip_address.s_addr = INADDR_ANY; pim_if_init(); pim_cmd_init(); diff --git a/pimd/pimd.h b/pimd/pimd.h index ec98c5bfd1..18520f57e1 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -140,7 +140,6 @@ struct thread *qpim_rpf_cache_refresher; int64_t qpim_rpf_cache_refresh_requests; int64_t qpim_rpf_cache_refresh_events; int64_t qpim_rpf_cache_refresh_last; -struct in_addr qpim_inaddr_any; struct list *qpim_ssmpingd_list; /* list of struct ssmpingd_sock */ struct in_addr qpim_ssmpingd_group_addr; int64_t qpim_scan_oil_events; From 3ba26039264381b6c575dbc66d94d186021cae60 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Fri, 2 Jun 2017 15:35:25 -0700 Subject: [PATCH 53/96] ospfd: Fix ospf timers command ospf timers related commands under router ospf were not accepted due to incorrect argument count check. timers throttle lsa all (0-5000) timers throttle spf (0-600000) (0-600000) (0-600000) timers lsa arrival (0-1000) timers lsa min-arrival (0-600000) Signed-off-by: Chirag Shah --- ospfd/ospf_vty.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index bb908ead2f..d987fef433 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -2222,7 +2222,7 @@ DEFUN (ospf_timers_min_ls_interval, int idx_number = 4; unsigned int interval; - if (argc != 1) + if (argc < 5) { vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); return CMD_WARNING; @@ -2264,7 +2264,7 @@ DEFUN (ospf_timers_min_ls_arrival, int idx_number = 3; unsigned int arrival; - if (argc != 1) + if (argc < 4) { vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); return CMD_WARNING; @@ -2309,7 +2309,7 @@ DEFUN (ospf_timers_throttle_spf, int idx_number_3 = 5; unsigned int delay, hold, max; - if (argc != 3) + if (argc < 6) { vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); return CMD_WARNING; @@ -2352,7 +2352,7 @@ DEFUN (ospf_timers_lsa, int idx_number = 3; unsigned int minarrival; - if (argc != 1) + if (argc < 4) { vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); return CMD_WARNING; From be0fbdebca3dbb9266a5196d88f504141ea44b0f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 2 Jun 2017 11:14:54 -0300 Subject: [PATCH 54/96] ldpd: fix bug in pseudowire control-word negotiation Bingen discovered a bug in the pseudowire control-word negotiation that might happen when the "control-word exclude" command is used. Under some very specific conditions, ldpd might ignore a PWID label mapping when it shouldn't. This patch removes a wrong optimization that was preventing ldpd to call l2vpn_pw_reset() every time we change the configuration of a pseudowire. Signed-off-by: Renato Westphal --- ldpd/ldpd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 61e8e8268c..2975231e56 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -1673,8 +1673,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl) session_shutdown(nbr, S_SHUTDOWN, 0, 0); } } - if (ldpd_process == PROC_LDE_ENGINE && - !reset_nbr && reinstall_pwfec) + if (ldpd_process == PROC_LDE_ENGINE && reinstall_pwfec) l2vpn_pw_exit(pw); pw->lsr_id = xp->lsr_id; pw->af = xp->af; @@ -1696,8 +1695,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl) pw->flags &= ~F_PW_STATIC_NBR_ADDR; if (ldpd_process == PROC_LDP_ENGINE && reinstall_tnbr) ldpe_l2vpn_pw_init(pw); - if (ldpd_process == PROC_LDE_ENGINE && - !reset_nbr && reinstall_pwfec) { + if (ldpd_process == PROC_LDE_ENGINE && reinstall_pwfec) { l2vpn->pw_type = xl->pw_type; l2vpn->mtu = xl->mtu; l2vpn_pw_init(pw); From ca70b756bf4c5b4aeb554fc1acd2c98aa696d6d7 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 2 Jun 2017 11:27:54 -0300 Subject: [PATCH 55/96] ldpd: remove variable that is not necessary anymore Signed-off-by: Renato Westphal --- ldpd/lde_lib.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c index 89aa6d4201..8dc305cac1 100644 --- a/ldpd/lde_lib.c +++ b/ldpd/lde_lib.c @@ -437,7 +437,6 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln) struct lde_req *lre; struct lde_map *me; struct l2vpn_pw *pw; - int msgsource = 0; lde_map2fec(map, ln->id, &fec); @@ -538,18 +537,12 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln) default: break; } - - msgsource = 1; } /* LMp.13 & LMp.16: Record the mapping from this peer */ if (me == NULL) me = lde_map_add(ln, fn, 0); me->map = *map; - if (msgsource == 0) - /* LMp.13: just return since we use liberal lbl retention */ - return; - /* * LMp.17 - LMp.27 are unnecessary since we don't need to implement * loop detection. LMp.28 - LMp.30 are unnecessary because we are From e4a82008c60e9508e53595eea2ff94051171b28c Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 2 Jun 2017 19:08:14 -0300 Subject: [PATCH 56/96] ldpd: further improvements in the configuration handling This patch attempts to make the code easier to read by removing a global variable and changing a few other things. Also, ldpd now calls merge_config() only after reading the whole initial configuration at startup, instead of doing that for every command in the configuration file. Signed-off-by: Renato Westphal --- ldpd/ldp_vty_conf.c | 84 ++++++++++++++++++++++----------------------- ldpd/ldpd.c | 57 +++++++++++++++++------------- ldpd/ldpd.h | 4 +-- 3 files changed, 77 insertions(+), 68 deletions(-) diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 37288f4c00..8394907142 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -431,7 +431,7 @@ ldp_vty_mpls_ldp(struct vty *vty, struct vty_arg *args[]) vty_conf->flags |= F_LDPD_ENABLED; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -458,7 +458,7 @@ ldp_vty_address_family(struct vty *vty, struct vty_arg *args[]) if (disable) { af_conf->flags &= ~F_LDPD_AF_ENABLED; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -474,7 +474,7 @@ ldp_vty_address_family(struct vty *vty, struct vty_arg *args[]) } af_conf->flags |= F_LDPD_AF_ENABLED; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -530,7 +530,7 @@ ldp_vty_disc_holdtime(struct vty *vty, struct vty_arg *args[]) break; } } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); break; case LDP_IPV4_NODE: case LDP_IPV6_NODE: @@ -556,7 +556,7 @@ ldp_vty_disc_holdtime(struct vty *vty, struct vty_arg *args[]) break; } } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); break; case LDP_IPV4_IFACE_NODE: case LDP_IPV6_IFACE_NODE: @@ -570,7 +570,7 @@ ldp_vty_disc_holdtime(struct vty *vty, struct vty_arg *args[]) else ia->hello_holdtime = secs; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); break; default: fatalx("ldp_vty_disc_holdtime: unexpected node"); @@ -631,7 +631,7 @@ ldp_vty_disc_interval(struct vty *vty, struct vty_arg *args[]) break; } } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); break; case LDP_IPV4_NODE: case LDP_IPV6_NODE: @@ -657,7 +657,7 @@ ldp_vty_disc_interval(struct vty *vty, struct vty_arg *args[]) break; } } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); break; case LDP_IPV4_IFACE_NODE: case LDP_IPV6_IFACE_NODE: @@ -671,7 +671,7 @@ ldp_vty_disc_interval(struct vty *vty, struct vty_arg *args[]) else ia->hello_interval = secs; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); break; default: fatalx("ldp_vty_disc_interval: unexpected node"); @@ -706,7 +706,7 @@ ldp_vty_targeted_hello_accept(struct vty *vty, struct vty_arg *args[]) af_conf->acl_thello_accept_from[0] = '\0'; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -758,7 +758,7 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, struct vty_arg *args[]) nbrp->flags |= F_NBRP_KEEPALIVE; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -790,7 +790,7 @@ ldp_vty_af_session_holdtime(struct vty *vty, struct vty_arg *args[]) else af_conf->keepalive = secs; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -836,7 +836,7 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) ia->hello_holdtime = 0; ia->hello_interval = 0; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -854,12 +854,12 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) RB_INSERT(iface_head, &vty_conf->iface_tree, iface); QOBJ_REG(iface, iface); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); } else { ia = iface_af_get(iface, af); if (!ia->enabled) { ia->enabled = 1; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); } } @@ -901,7 +901,7 @@ ldp_vty_trans_addr(struct vty *vty, struct vty_arg *args[]) } } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -940,7 +940,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[]) RB_REMOVE(tnbr_head, &vty_conf->tnbr_tree, tnbr); free(tnbr); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -953,7 +953,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[]) RB_INSERT(tnbr_head, &vty_conf->tnbr_tree, tnbr); QOBJ_REG(tnbr, tnbr); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -990,7 +990,7 @@ ldp_vty_label_advertise(struct vty *vty, struct vty_arg *args[]) af_conf->acl_label_advertise_for[0] = '\0'; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1021,7 +1021,7 @@ ldp_vty_label_allocate(struct vty *vty, struct vty_arg *args[]) sizeof(af_conf->acl_label_allocate_for)); } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1052,7 +1052,7 @@ ldp_vty_label_expnull(struct vty *vty, struct vty_arg *args[]) af_conf->acl_label_expnull_for[0] = '\0'; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1089,7 +1089,7 @@ ldp_vty_label_accept(struct vty *vty, struct vty_arg *args[]) af_conf->acl_label_accept_for[0] = '\0'; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1111,7 +1111,7 @@ ldp_vty_ttl_security(struct vty *vty, struct vty_arg *args[]) else af_conf->flags |= F_LDPD_AF_NO_GTSM; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1135,7 +1135,7 @@ ldp_vty_router_id(struct vty *vty, struct vty_arg *args[]) } } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1152,7 +1152,7 @@ ldp_vty_ds_cisco_interop(struct vty *vty, struct vty_arg *args[]) else vty_conf->flags |= F_LDPD_DS_CISCO_INTEROP; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1169,7 +1169,7 @@ ldp_vty_trans_pref_ipv4(struct vty *vty, struct vty_arg *args[]) else vty_conf->trans_pref = DUAL_STACK_LDPOV4; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1220,7 +1220,7 @@ ldp_vty_neighbor_password(struct vty *vty, struct vty_arg *args[]) nbrp->auth.method = AUTH_MD5SIG; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1280,7 +1280,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, struct vty_arg *args[]) nbrp->gtsm_enabled = 0; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1313,7 +1313,7 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) RB_REMOVE(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn); l2vpn_del(l2vpn); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1330,7 +1330,7 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1350,7 +1350,7 @@ ldp_vty_l2vpn_bridge(struct vty *vty, struct vty_arg *args[]) else strlcpy(l2vpn->br_ifname, ifname, sizeof(l2vpn->br_ifname)); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1378,7 +1378,7 @@ ldp_vty_l2vpn_mtu(struct vty *vty, struct vty_arg *args[]) else l2vpn->mtu = mtu; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1404,7 +1404,7 @@ ldp_vty_l2vpn_pwtype(struct vty *vty, struct vty_arg *args[]) else l2vpn->pw_type = pw_type; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1430,7 +1430,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1447,7 +1447,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif); QOBJ_REG(lif, l2vpn_if); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1476,7 +1476,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1498,7 +1498,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw); - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1522,7 +1522,7 @@ ldp_vty_l2vpn_pw_cword(struct vty *vty, struct vty_arg *args[]) pw->flags |= F_PW_CWORD_CONF; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1555,7 +1555,7 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, struct vty_arg *args[]) pw->flags |= F_PW_STATIC_NBR_ADDR; } - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1582,7 +1582,7 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, struct vty_arg *args[]) else pw->lsr_id = lsr_id; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1610,7 +1610,7 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, struct vty_arg *args[]) else pw->pwid = pwid; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } @@ -1628,7 +1628,7 @@ ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, struct vty_arg *args[]) else pw->flags &= ~F_PW_STATUSTLV_CONF; - ldp_reload(vty_conf); + ldp_config_apply(vty, vty_conf); return (CMD_SUCCESS); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 2975231e56..6993ad15cc 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -53,6 +53,7 @@ static void main_imsg_send_net_sockets(int); static void main_imsg_send_net_socket(int, enum socket_type); static int main_imsg_send_config(struct ldpd_conf *); static void ldp_config_normalize(struct ldpd_conf *); +static void ldp_config_reset(struct ldpd_conf *); static void ldp_config_reset_main(struct ldpd_conf *); static void ldp_config_reset_af(struct ldpd_conf *, int); static void ldp_config_reset_l2vpns(struct ldpd_conf *); @@ -131,20 +132,13 @@ sighup(void) { log_info("SIGHUP received"); - /* reset vty_conf */ - ldp_config_reset_main(vty_conf); - ldp_config_reset_l2vpns(vty_conf); - - /* read configuration file without applying any changes */ - global.sighup = 1; - vty_read_config(ldpd_di.config_file, config_default); - global.sighup = 0; - /* - * Apply the new configuration all at once, this way merge_config() - * will be the least disruptive as possible. + * Do a full configuration reload. In other words, reset vty_conf + * and build a new configuartion from scratch. */ - ldp_reload(vty_conf); + ldp_config_reset(vty_conf); + vty_read_config(ldpd_di.config_file, config_default); + ldp_config_apply(NULL, vty_conf); } /* SIGINT / SIGTERM handler. */ @@ -324,22 +318,22 @@ main(int argc, char *argv[]) ldp_vty_init(); ldp_zebra_init(master); - /* create base configuration with sane defaults */ - ldpd_conf = config_new_empty(); - ldp_config_reset_main(ldpd_conf); - /* - * Create vty_conf as a duplicate of the main configuration. All - * configuration requests (e.g. CLI) act on vty_conf and then call - * ldp_reload() to merge the changes into ldpd_conf. + * Create base configuration with sane defaults. All configuration + * requests (e.g. CLI) act on vty_conf and then call ldp_config_apply() + * to merge the changes into ldpd_conf, which contains the actual + * running configuration. */ + ldpd_conf = config_new_empty(); vty_conf = config_new_empty(); - ldp_config_reset_main(vty_conf); QOBJ_REG(vty_conf, ldpd_conf); /* read configuration file and daemonize */ frr_config_fork(); + /* apply configuration */ + ldp_config_apply(NULL, vty_conf); + /* setup pipes to children */ if ((iev_ldpe = calloc(1, sizeof(struct imsgev))) == NULL || (iev_ldpe_sync = calloc(1, sizeof(struct imsgev))) == NULL || @@ -406,8 +400,7 @@ ldpd_shutdown(void) config_clear(ldpd_conf); - ldp_config_reset_main(vty_conf); - ldp_config_reset_l2vpns(vty_conf); + ldp_config_reset(vty_conf); QOBJ_UNREG(vty_conf); free(vty_conf); @@ -952,9 +945,15 @@ main_imsg_send_config(struct ldpd_conf *xconf) } int -ldp_reload(struct ldpd_conf *xconf) +ldp_config_apply(struct vty *vty, struct ldpd_conf *xconf) { - if (global.sighup) + /* + * When reading from a configuration file (startup and sighup), we + * call merge_config() only once after the whole config has been read. + * This is the optimal and least disruptive way to update the running + * configuration. + */ + if (vty && vty->type == VTY_FILE) return (0); ldp_config_normalize(xconf); @@ -1031,6 +1030,13 @@ ldp_config_normalize(struct ldpd_conf *xconf) } } +static void +ldp_config_reset(struct ldpd_conf *conf) +{ + ldp_config_reset_main(conf); + ldp_config_reset_l2vpns(conf); +} + static void ldp_config_reset_main(struct ldpd_conf *conf) { @@ -1760,6 +1766,9 @@ config_new_empty(void) RB_INIT(&xconf->nbrp_tree); RB_INIT(&xconf->l2vpn_tree); + /* set default values */ + ldp_config_reset(xconf); + return (xconf); } diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 3acc4fbe2d..352a7b0d7e 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -29,6 +29,7 @@ #include "qobj.h" #include "prefix.h" #include "filter.h" +#include "vty.h" #include "ldp.h" @@ -516,7 +517,6 @@ struct ldpd_af_global { struct ldpd_global { int cmd_opts; - int sighup; struct in_addr rtr_id; struct ldpd_af_global ipv4; struct ldpd_af_global ipv6; @@ -719,7 +719,7 @@ struct ldpd_af_conf *ldp_af_conf_get(struct ldpd_conf *, int); struct ldpd_af_global *ldp_af_global_get(struct ldpd_global *, int); int ldp_is_dual_stack(struct ldpd_conf *); in_addr_t ldp_rtr_id_get(struct ldpd_conf *); -int ldp_reload(struct ldpd_conf *); +int ldp_config_apply(struct vty *, struct ldpd_conf *); void ldp_clear_config(struct ldpd_conf *); void merge_config(struct ldpd_conf *, struct ldpd_conf *); struct ldpd_conf *config_new_empty(void); From fac05f2fd6495532cf2d24bd2ab49c6e6dbda1d4 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Fri, 2 Jun 2017 22:52:41 -0700 Subject: [PATCH 57/96] ospfd: fix clear ip ospf interface cmd clear ip ospf interface parsing issue, instead of arguement of interface "IFNAME" parsed. Signed-off-by: Chirag Shah --- ospfd/ospf_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index d987fef433..bcab2e90ff 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -9099,7 +9099,7 @@ DEFUN (clear_ip_ospf_interface, } else /* Interface name is specified. */ { - if ((ifp = if_lookup_by_name (argv[idx_ifname]->text, VRF_DEFAULT)) == NULL) + if ((ifp = if_lookup_by_name (argv[idx_ifname]->arg, VRF_DEFAULT)) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else ospf_interface_clear(ifp); From e321aed1e94777335ae682b86420ee28145e0a26 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sun, 4 Jun 2017 00:43:34 -0700 Subject: [PATCH 58/96] redhat/frr.spec.in: Fix postun script for Fedora. Fedora uninstall showed some non-fatal postun script error because of an empty if which only applied to other distro's Signed-off-by: Martin Winter --- redhat/frr.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 133ed1fcd0..41023dc35f 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -428,6 +428,7 @@ if [ "$1" -ge 1 ]; then ## /etc/rc.d/init.d/frr restart >/dev/null 2>&1 %endif + : fi %preun From f1c2f411430b996af6a3373a173b249af888c59c Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 19:00:39 +0000 Subject: [PATCH 59/96] ospfd: fix virtual-link timers commands Use {} semantics, correct docstrings, switchup parsing. Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 67 ++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index caf1b0c668..c6465f1934 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -989,15 +989,15 @@ ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) "Use null authentication\n" \ "Use message-digest authentication\n" -#define VLINK_HELPSTR_TIME_PARAM_NOSECS \ - "Time between HELLO packets\n" \ - "Time between retransmitting lost link state advertisements\n" \ - "Link state transmit delay\n" \ - "Interval time after which a neighbor is declared down\n" - #define VLINK_HELPSTR_TIME_PARAM \ - VLINK_HELPSTR_TIME_PARAM_NOSECS \ - "Seconds\n" + "Time between HELLO packets\n" \ + "Seconds\n" \ + "Time between retransmitting lost link state advertisements\n" \ + "Seconds\n" \ + "Link state transmit delay\n" \ + "Seconds\n" \ + "Interval time after which a neighbor is declared down\n" \ + "Seconds\n" \ #define VLINK_HELPSTR_AUTH_SIMPLE \ "Authentication password (key)\n" \ @@ -1132,16 +1132,8 @@ DEFUN (ospf_area_vlink, DEFUN (ospf_area_vlink_intervals, ospf_area_vlink_intervals_cmd, - "area virtual-link A.B.C.D" - " (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "]]]", + "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) { VTY_DECLVAR_CONTEXT(ospf, ospf); @@ -1166,17 +1158,17 @@ DEFUN (ospf_area_vlink_intervals, vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); return CMD_WARNING; } - for (unsigned int i = 0; i < 4; i++) + + for (int idx = 4; idx < argc; idx++) { - int idx = 0; - if (argv_find (argv, argc, "hello-interval", &idx)) - vl_config.hello_interval = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "retransmit-interval", &idx)) - vl_config.retransmit_interval = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "transmit-delay", &idx)) - vl_config.transmit_delay = strtol(argv[idx+1]->arg, NULL, 10); - else if (argv_find (argv, argc, "dead-interval", &idx)) - vl_config.dead_interval = strtol(argv[idx+1]->arg, NULL, 10); + if (strmatch (argv[idx]->text, "hello-interval")) + vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "retransmit-interval")) + vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "transmit-delay")) + vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "dead-interval")) + vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); } /* Action configuration */ @@ -1295,17 +1287,9 @@ DEFUN (no_ospf_area_vlink, DEFUN (no_ospf_area_vlink_intervals, no_ospf_area_vlink_intervals_cmd, - "no area virtual-link A.B.C.D" - " (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "[ (1-65535)" - "]]]", + "no area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", NO_STR VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM - VLINK_HELPSTR_TIME_PARAM VLINK_HELPSTR_TIME_PARAM) { VTY_DECLVAR_CONTEXT(ospf, ospf); @@ -1331,16 +1315,15 @@ DEFUN (no_ospf_area_vlink_intervals, return CMD_WARNING; } - for (unsigned int i = 0; i < 4; i++) + for (int idx = 5; idx < argc; idx++) { - int idx = 0; - if (argv_find (argv, argc, "hello-interval", &idx)) + if (strmatch (argv[idx]->text, "hello-interval")) vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; - else if (argv_find (argv, argc, "retransmit-interval", &idx)) + else if (strmatch (argv[idx]->text, "retransmit-interval")) vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; - else if (argv_find (argv, argc, "transmit-delay", &idx)) + else if (strmatch (argv[idx]->text, "transmit-delay")) vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; - else if (argv_find (argv, argc, "dead-interval", &idx)) + else if (strmatch (argv[idx]->text, "dead-interval")) vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; } From 0c2206de310506f9d420e4c99fe2fcab50973fd1 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 31 May 2017 19:04:53 +0000 Subject: [PATCH 60/96] ospfd: shufflin move virtual-link command down to be next to its no form Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 90 ++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c6465f1934..49840a34b4 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -1130,51 +1130,6 @@ DEFUN (ospf_area_vlink, } -DEFUN (ospf_area_vlink_intervals, - ospf_area_vlink_intervals_cmd, - "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", - VLINK_HELPSTR_IPADDR - VLINK_HELPSTR_TIME_PARAM) -{ - VTY_DECLVAR_CONTEXT(ospf, ospf); - struct ospf_vl_config_data vl_config; - int ret = 0; - - ospf_vl_config_data_init(&vl_config, vty); - - char *area_id = argv[1]->arg; - char *router_id = argv[3]->arg; - - ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); - if (ret < 0) - { - vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = inet_aton (router_id, &vl_config.vl_peer); - if (! ret) - { - vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); - return CMD_WARNING; - } - - for (int idx = 4; idx < argc; idx++) - { - if (strmatch (argv[idx]->text, "hello-interval")) - vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "retransmit-interval")) - vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "transmit-delay")) - vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); - else if (strmatch (argv[idx]->text, "dead-interval")) - vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); - } - - /* Action configuration */ - return ospf_vl_set (ospf, &vl_config); -} - DEFUN (no_ospf_area_vlink, no_ospf_area_vlink_cmd, "no area virtual-link A.B.C.D [authentication] [] []", @@ -1285,6 +1240,51 @@ DEFUN (no_ospf_area_vlink, return ospf_vl_set (ospf, &vl_config); } +DEFUN (ospf_area_vlink_intervals, + ospf_area_vlink_intervals_cmd, + "area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", + VLINK_HELPSTR_IPADDR + VLINK_HELPSTR_TIME_PARAM) +{ + VTY_DECLVAR_CONTEXT(ospf, ospf); + struct ospf_vl_config_data vl_config; + int ret = 0; + + ospf_vl_config_data_init(&vl_config, vty); + + char *area_id = argv[1]->arg; + char *router_id = argv[3]->arg; + + ret = str2area_id (area_id, &vl_config.area_id, &vl_config.area_id_fmt); + if (ret < 0) + { + vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ret = inet_aton (router_id, &vl_config.vl_peer); + if (! ret) + { + vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE); + return CMD_WARNING; + } + + for (int idx = 4; idx < argc; idx++) + { + if (strmatch (argv[idx]->text, "hello-interval")) + vl_config.hello_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "retransmit-interval")) + vl_config.retransmit_interval = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "transmit-delay")) + vl_config.transmit_delay = strtol(argv[++idx]->arg, NULL, 10); + else if (strmatch (argv[idx]->text, "dead-interval")) + vl_config.dead_interval = strtol(argv[++idx]->arg, NULL, 10); + } + + /* Action configuration */ + return ospf_vl_set (ospf, &vl_config); +} + DEFUN (no_ospf_area_vlink_intervals, no_ospf_area_vlink_intervals_cmd, "no area virtual-link A.B.C.D {hello-interval (1-65535)|retransmit-interval (1-65535)|transmit-delay (1-65535)|dead-interval (1-65535)}", From 7d6e13e13838ca05573ac28e1cc4ace4585ed6e2 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 19:10:03 +0000 Subject: [PATCH 61/96] ospfd: fix 'show ip ospf interface json' json obj not recreated for each interface Signed-off-by: Quentin Young --- ospfd/ospf_vty.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 49840a34b4..0eb3aa6a8a 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -3536,7 +3536,6 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, if (use_json) { json = json_object_new_object(); - json_interface_sub = json_object_new_object(); } if (ospf->instance) @@ -3555,7 +3554,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, { if (ospf_oi_count(ifp)) { + if (use_json) + json_interface_sub = json_object_new_object(); + show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); + if (use_json) json_object_object_add (json, ifp->name, json_interface_sub); } @@ -3573,7 +3576,11 @@ show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc, } else { + if (use_json) + json_interface_sub = json_object_new_object(); + show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json); + if (use_json) json_object_object_add(json, ifp->name, json_interface_sub); } From ce2570bc0a1810a6dd1eaea683d4a8a73c00a53c Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 21:48:01 +0000 Subject: [PATCH 62/96] bgpd: fix large-community-list commands Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 66689c8367..7e2912440a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -11249,6 +11249,7 @@ lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, return CMD_WARNING; } + idx = 0; argv_find (argv, argc, "AA:BB:CC", &idx); argv_find (argv, argc, "LINE", &idx); /* Concat community string argument. */ From cb63fd542ac770fa8cfd572db8d1e4afc8498e35 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 21:20:33 +0000 Subject: [PATCH 63/96] ospf6d: fix filter-list commands incorrect indexes resulted in use of area id as the name of the prefix list Signed-off-by: Quentin Young --- ospf6d/ospf6_area.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index fd5e84d88c..a010ff322a 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -610,21 +610,23 @@ DEFUN (area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { - int idx_ipv4 = 1; - int idx_word = 4; + char *inout = argv[argc - 1]->text; + char *areaid = argv[1]->arg; + char *plistname = argv[4]->arg; + struct ospf6_area *area; struct prefix_list *plist; - OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area); + OSPF6_CMD_AREA_GET (areaid, area); - plist = prefix_list_lookup (AFI_IP6, argv[idx_ipv4]->arg); - if (strncmp (argv[idx_word]->arg, "in", 2) == 0) + plist = prefix_list_lookup (AFI_IP6, plistname); + if (strmatch (inout, "in")) { PREFIX_LIST_IN (area) = plist; if (PREFIX_NAME_IN (area)) free (PREFIX_NAME_IN (area)); - PREFIX_NAME_IN (area) = strdup (argv[idx_ipv4]->arg); + PREFIX_NAME_IN (area) = strdup (plistname); ospf6_abr_reimport (area); } else @@ -633,7 +635,7 @@ DEFUN (area_filter_list, if (PREFIX_NAME_OUT (area)) free (PREFIX_NAME_OUT (area)); - PREFIX_NAME_OUT (area) = strdup (argv[idx_ipv4]->arg); + PREFIX_NAME_OUT (area) = strdup (plistname); ospf6_abr_enable_area (area); } @@ -652,16 +654,18 @@ DEFUN (no_area_filter_list, "Filter networks sent to this area\n" "Filter networks sent from this area\n") { - int idx_ipv4 = 2; - int idx_word = 5; + char *inout = argv[argc - 1]->text; + char *areaid = argv[2]->arg; + char *plistname = argv[5]->arg; + struct ospf6_area *area; - OSPF6_CMD_AREA_GET (argv[idx_ipv4]->arg, area); + OSPF6_CMD_AREA_GET (areaid, area); - if (strncmp (argv[idx_word]->arg, "in", 2) == 0) + if (strmatch (inout, "in")) { if (PREFIX_NAME_IN (area)) - if (strcmp (PREFIX_NAME_IN (area), argv[idx_ipv4]->arg) != 0) + if (!strmatch (PREFIX_NAME_IN (area), plistname)) return CMD_SUCCESS; PREFIX_LIST_IN (area) = NULL; @@ -674,7 +678,7 @@ DEFUN (no_area_filter_list, else { if (PREFIX_NAME_OUT (area)) - if (strcmp (PREFIX_NAME_OUT (area), argv[idx_ipv4]->arg) != 0) + if (!strmatch (PREFIX_NAME_OUT (area), plistname)) return CMD_SUCCESS; PREFIX_LIST_OUT (area) = NULL; From 406f99f81d8d77bc5b2905afec2c4ed53739b306 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 20:53:37 +0000 Subject: [PATCH 64/96] bgpd: fix addpath buffer overrun Signed-off-by: Quentin Young --- bgpd/bgp_debug.c | 11 +++++++---- bgpd/bgp_updgrp_packet.c | 35 +++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index 232f53c778..fb350d51a1 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -40,8 +40,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_updgrp.h" #include "bgpd/bgp_mplsvpn.h" -#define BGP_ADDPATH_STR 20 - unsigned long conf_bgp_debug_as4; unsigned long conf_bgp_debug_neighbor_events; unsigned long conf_bgp_debug_events; @@ -2132,7 +2130,12 @@ bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, { char rd_buf[RD_ADDRSTRLEN]; char pfx_buf[PREFIX_STRLEN]; - char pathid_buf[BGP_ADDPATH_STR]; + /* ' with addpath ID ' 17 + * max strlen of uint32 + 10 + * +/- (in case of idiocy) + 1 + * null terminator + 1 + * ============================ 29 */ + char pathid_buf[30]; if (size < BGP_PRD_PATH_STRLEN) return NULL; @@ -2140,7 +2143,7 @@ bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, /* Note: Path-id is created by default, but only included in update sometimes. */ pathid_buf[0] = '\0'; if (addpath_valid) - sprintf(pathid_buf, " with addpath ID %d", addpath_id); + snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u", addpath_id); if (prd) snprintf (str, size, "RD %s %s%s", diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 5872ca6f3f..588f8a66fa 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -650,17 +650,6 @@ subgroup_packets_to_build (struct update_subgroup *subgrp) return 0; } -static void -bgp_info_addpath_tx_str (int addpath_encode, u_int32_t addpath_tx_id, - char *buf) -{ - buf[0] = '\0'; - if (addpath_encode) - sprintf(buf, " with addpath ID %d", addpath_tx_id); - else - buf[0] = '\0'; -} - /* Make BGP update packet. */ struct bpacket * subgroup_update_packet (struct update_subgroup *subgrp) @@ -1051,11 +1040,21 @@ subgroup_default_update_packet (struct update_subgroup *subgrp, { char attrstr[BUFSIZ]; char buf[PREFIX_STRLEN]; + /* ' with addpath ID ' 17 + * max strlen of uint32 + 10 + * +/- (in case of idiocy) + 1 + * null terminator + 1 + * ============================ 29 */ char tx_id_buf[30]; + attrstr[0] = '\0'; bgp_dump_attr (peer, attr, attrstr, BUFSIZ); - bgp_info_addpath_tx_str (addpath_encode, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, tx_id_buf); + + if (addpath_encode) + snprintf(tx_id_buf, sizeof (tx_id_buf), " with addpath ID %u", + BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE); + zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s%s %s", (SUBGRP_UPDGRP (subgrp))->id, subgrp->id, prefix2str (&p, buf, sizeof (buf)), @@ -1125,9 +1124,17 @@ subgroup_default_withdraw_packet (struct update_subgroup *subgrp) if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) { char buf[PREFIX_STRLEN]; - char tx_id_buf[INET6_BUFSIZ]; + /* ' with addpath ID ' 17 + * max strlen of uint32 + 10 + * +/- (in case of idiocy) + 1 + * null terminator + 1 + * ============================ 29 */ + char tx_id_buf[30]; + + if (addpath_encode) + snprintf(tx_id_buf, sizeof (tx_id_buf), " with addpath ID %u", + BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE); - bgp_info_addpath_tx_str (addpath_encode, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, tx_id_buf); zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s%s -- unreachable", (SUBGRP_UPDGRP (subgrp))->id, subgrp->id, prefix2str (&p, buf, sizeof (buf)), tx_id_buf); From 33a57d94fadfce9951fbcf74f7f7a4e85492b00a Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 30 May 2017 08:30:57 -0300 Subject: [PATCH 65/96] bgpd: fix segfault with some show commands The following commands were causing bgpd to crash when vpnv4/vpnv6 static routes are configured: bgpd aborted: vtysh -c "show ip bgp view all ipv4 vpn json" bgpd aborted: vtysh -c "show ip bgp view all ipv4 vpn" bgpd aborted: vtysh -c "show ip bgp view all ipv6 vpn json" bgpd aborted: vtysh -c "show ip bgp view all ipv6 vpn" bgpd aborted: vtysh -c "show ip bgp vrf all ipv4 vpn json" bgpd aborted: vtysh -c "show ip bgp vrf all ipv4 vpn" bgpd aborted: vtysh -c "show ip bgp vrf all ipv6 vpn json" bgpd aborted: vtysh -c "show ip bgp vrf all ipv6 vpn" bgpd aborted: vtysh -c "show bgp view all ipv4 vpn json" bgpd aborted: vtysh -c "show bgp view all ipv4 vpn" bgpd aborted: vtysh -c "show bgp view all ipv6 vpn json" bgpd aborted: vtysh -c "show bgp view all ipv6 vpn" bgpd aborted: vtysh -c "show bgp vrf all ipv4 vpn json" bgpd aborted: vtysh -c "show bgp vrf all ipv4 vpn" bgpd aborted: vtysh -c "show bgp vrf all ipv6 vpn json" bgpd aborted: vtysh -c "show bgp vrf all ipv6 vpn" Problem found with the CLI fuzzer. Signed-off-by: Renato Westphal --- bgpd/bgp_route.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 38e696d11b..9b85ad3d96 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7852,7 +7852,6 @@ bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, { struct listnode *node, *nnode; struct bgp *bgp; - struct bgp_table *table; int is_first = 1; if (use_json) @@ -7878,9 +7877,7 @@ bgp_show_all_instances_routes_vty (struct vty *vty, afi_t afi, safi_t safi, ? "Default" : bgp->name, VTY_NEWLINE); } - table = bgp->rib[afi][safi]; - bgp_show_table (vty, bgp, table, - bgp_show_type_normal, NULL, use_json); + bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL, use_json); } From 31c6fa450a4ce10348b8a4633ba287b22b7eba00 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sun, 4 Jun 2017 21:01:52 +0000 Subject: [PATCH 66/96] zebra: remove extraneous help string caused tag to display null0 helpstr Signed-off-by: Quentin Young --- zebra/zebra_vty.c | 1 - 1 file changed, 1 deletion(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 6c3dfe0e06..6f1c81eda1 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2172,7 +2172,6 @@ DEFUN (ipv6_route, "IPv6 gateway address\n" "IPv6 gateway interface name\n" "Null interface\n" - "Null interface\n" "Set tag for this route\n" "Tag value\n" "Distance value for this prefix\n" From a9609069a5cf67f20b28d93dfdf2d5d05299a0c7 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Mon, 5 Jun 2017 13:13:57 +0000 Subject: [PATCH 67/96] bgpd: fix ipv6 network statement label-index node Problem reported with the inability to define "network x:x:x::/64 label-index" to the config. Found that the install_element was pointing to the wrong node. Ticket: CM-16615 Signed-off-by: Don Slice --- bgpd/bgp_route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index b3e1f8b27e..a345cb6526 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10988,10 +10988,10 @@ bgp_route_init (void) install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd); install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd); install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd); - install_element (BGP_IPV6_NODE, &ipv6_bgp_network_label_index_cmd); - install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_label_index_cmd); - install_element (BGP_IPV6_NODE, &ipv6_bgp_network_label_index_route_map_cmd); - install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_label_index_route_map_cmd); + install_element (BGP_IPV6L_NODE, &ipv6_bgp_network_label_index_cmd); + install_element (BGP_IPV6L_NODE, &no_ipv6_bgp_network_label_index_cmd); + install_element (BGP_IPV6L_NODE, &ipv6_bgp_network_label_index_route_map_cmd); + install_element (BGP_IPV6L_NODE, &no_ipv6_bgp_network_label_index_route_map_cmd); install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd); install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd); From 0b4d8f1e38ea1dbade4d2f714775608b379e992e Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 18 Apr 2017 12:04:44 -0300 Subject: [PATCH 68/96] ldpd: split log.c into two files This is basically to keep in sync with OpenBSD's ldpd(8) where the same change was done. Signed-off-by: Renato Westphal --- ldpd/Makefile.am | 2 +- ldpd/lde.c | 1 + ldpd/ldpd.c | 1 + ldpd/ldpd.h | 30 +++ ldpd/ldpe.c | 1 + ldpd/log.c | 477 +--------------------------------------------- ldpd/log.h | 66 +++---- ldpd/logmsg.c | 487 +++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 549 insertions(+), 516 deletions(-) create mode 100644 ldpd/logmsg.c diff --git a/ldpd/Makefile.am b/ldpd/Makefile.am index 19f819ae36..b760b44573 100644 --- a/ldpd/Makefile.am +++ b/ldpd/Makefile.am @@ -16,7 +16,7 @@ EXTRA_DIST += ldp_vty.xml libldp_a_SOURCES = \ accept.c address.c adjacency.c control.c hello.c init.c interface.c \ keepalive.c l2vpn.c labelmapping.c lde.c lde_lib.c ldpd.c \ - ldpe.c log.c neighbor.c notification.c packet.c pfkey.c \ + ldpe.c log.c logmsg.c neighbor.c notification.c packet.c pfkey.c \ socket.c util.c ldp_vty_cmds.c ldp_vty_conf.c ldp_vty_exec.c \ ldp_debug.c ldp_zebra.c diff --git a/ldpd/lde.c b/ldpd/lde.c index 36998e7cf8..c4a610b6d3 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -163,6 +163,7 @@ lde(const char *user, const char *group, u_short instance) setproctitle("label decision engine"); #endif ldpd_process = PROC_LDE_ENGINE; + log_procname = log_procnames[PROC_LDE_ENGINE]; /* drop privileges */ if (user) diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index def3d2e2f3..8da830ccef 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -208,6 +208,7 @@ main(int argc, char *argv[]) const char *instance_char = NULL; ldpd_process = PROC_MAIN; + log_procname = log_procnames[ldpd_process]; saved_argv0 = argv[0]; if (saved_argv0 == NULL) diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 10742cf0dc..759f1d0da5 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -439,6 +439,12 @@ enum ldpd_process { PROC_LDE_ENGINE } ldpd_process; +static const char * const log_procnames[] = { + "parent", + "ldpe", + "lde" +}; + enum socket_type { LDP_SOCKET_DISC, LDP_SOCKET_EDISC, @@ -762,6 +768,30 @@ int sock_set_ipv6_mcast_hops(int, int); int sock_set_ipv6_mcast(struct iface *); int sock_set_ipv6_mcast_loop(int); +/* logmsg.h */ +struct in6_addr; +union ldpd_addr; +struct hello_source; +struct fec; + +const char *log_sockaddr(void *); +const char *log_in6addr(const struct in6_addr *); +const char *log_in6addr_scope(const struct in6_addr *, unsigned int); +const char *log_addr(int, const union ldpd_addr *); +char *log_label(uint32_t); +const char *log_time(time_t); +char *log_hello_src(const struct hello_source *); +const char *log_map(const struct map *); +const char *log_fec(const struct fec *); +const char *af_name(int); +const char *socket_name(int); +const char *nbr_state_name(int); +const char *if_state_name(int); +const char *if_type_name(enum iface_type); +const char *msg_name(uint16_t); +const char *status_code_name(uint32_t); +const char *pw_type_name(uint16_t); + /* quagga */ extern struct thread_master *master; extern char ctl_sock_path[MAXPATHLEN]; diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 1bec3d2a95..e82416276b 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -113,6 +113,7 @@ ldpe(const char *user, const char *group, const char *ctl_path) setproctitle("ldp engine"); #endif ldpd_process = PROC_LDP_ENGINE; + log_procname = log_procnames[ldpd_process]; LIST_INIT(&global.addr_list); RB_INIT(&global.adj_tree); diff --git a/ldpd/log.c b/ldpd/log.c index 407668bb03..408aaeb699 100644 --- a/ldpd/log.c +++ b/ldpd/log.c @@ -25,15 +25,8 @@ #include #include -#include "mpls.h" -static const char * const procnames[] = { - "parent", - "ldpe", - "lde" -}; - -void vlog(int, const char *, va_list); +const char *log_procname; void logit(int pri, const char *fmt, ...) @@ -133,15 +126,15 @@ void fatal(const char *emsg) { if (emsg == NULL) - logit(LOG_CRIT, "fatal in %s: %s", procnames[ldpd_process], + logit(LOG_CRIT, "fatal in %s: %s", log_procname, strerror(errno)); else if (errno) logit(LOG_CRIT, "fatal in %s: %s: %s", - procnames[ldpd_process], emsg, strerror(errno)); + log_procname, emsg, strerror(errno)); else logit(LOG_CRIT, "fatal in %s: %s", - procnames[ldpd_process], emsg); + log_procname, emsg); exit(1); } @@ -152,465 +145,3 @@ fatalx(const char *emsg) errno = 0; fatal(emsg); } - -#define NUM_LOGS 4 -const char * -log_sockaddr(void *vp) -{ - static char buf[NUM_LOGS][NI_MAXHOST]; - static int round = 0; - struct sockaddr *sa = vp; - - round = (round + 1) % NUM_LOGS; - - if (getnameinfo(sa, sockaddr_len(sa), buf[round], NI_MAXHOST, NULL, 0, - NI_NUMERICHOST)) - return ("(unknown)"); - else - return (buf[round]); -} - -const char * -log_in6addr(const struct in6_addr *addr) -{ - struct sockaddr_in6 sa_in6; - - memset(&sa_in6, 0, sizeof(sa_in6)); -#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - sa_in6.sin6_len = sizeof(sa_in6); -#endif - sa_in6.sin6_family = AF_INET6; - sa_in6.sin6_addr = *addr; - - recoverscope(&sa_in6); - - return (log_sockaddr(&sa_in6)); -} - -const char * -log_in6addr_scope(const struct in6_addr *addr, unsigned int ifindex) -{ - struct sockaddr_in6 sa_in6; - - memset(&sa_in6, 0, sizeof(sa_in6)); -#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - sa_in6.sin6_len = sizeof(sa_in6); -#endif - sa_in6.sin6_family = AF_INET6; - sa_in6.sin6_addr = *addr; - - addscope(&sa_in6, ifindex); - - return (log_sockaddr(&sa_in6)); -} - -const char * -log_addr(int af, const union ldpd_addr *addr) -{ - static char buf[NUM_LOGS][INET6_ADDRSTRLEN]; - static int round = 0; - - switch (af) { - case AF_INET: - round = (round + 1) % NUM_LOGS; - if (inet_ntop(AF_INET, &addr->v4, buf[round], - sizeof(buf[round])) == NULL) - return ("???"); - return (buf[round]); - case AF_INET6: - return (log_in6addr(&addr->v6)); - default: - break; - } - - return ("???"); -} - -#define TF_BUFS 4 -#define TF_LEN 32 - -char * -log_label(uint32_t label) -{ - char *buf; - static char tfbuf[TF_BUFS][TF_LEN]; /* ring buffer */ - static int idx = 0; - - buf = tfbuf[idx++]; - if (idx == TF_BUFS) - idx = 0; - - switch (label) { - case NO_LABEL: - snprintf(buf, TF_LEN, "-"); - break; - case MPLS_LABEL_IMPLNULL: - snprintf(buf, TF_LEN, "imp-null"); - break; - case MPLS_LABEL_IPV4NULL: - case MPLS_LABEL_IPV6NULL: - snprintf(buf, TF_LEN, "exp-null"); - break; - default: - snprintf(buf, TF_LEN, "%u", label); - break; - } - - return (buf); -} - -const char * -log_time(time_t t) -{ - char *buf; - static char tfbuf[TF_BUFS][TF_LEN]; /* ring buffer */ - static int idx = 0; - unsigned int sec, min, hrs, day, week; - - buf = tfbuf[idx++]; - if (idx == TF_BUFS) - idx = 0; - - week = t; - - sec = week % 60; - week /= 60; - min = week % 60; - week /= 60; - hrs = week % 24; - week /= 24; - day = week % 7; - week /= 7; - - if (week > 0) - snprintf(buf, TF_LEN, "%02uw%01ud%02uh", week, day, hrs); - else if (day > 0) - snprintf(buf, TF_LEN, "%01ud%02uh%02um", day, hrs, min); - else - snprintf(buf, TF_LEN, "%02u:%02u:%02u", hrs, min, sec); - - return (buf); -} - -char * -log_hello_src(const struct hello_source *src) -{ - static char buf[64]; - - switch (src->type) { - case HELLO_LINK: - snprintf(buf, sizeof(buf), "iface %s", - src->link.ia->iface->name); - break; - case HELLO_TARGETED: - snprintf(buf, sizeof(buf), "source %s", - log_addr(src->target->af, &src->target->addr)); - break; - } - - return (buf); -} - -const char * -log_map(const struct map *map) -{ - static char buf[128]; - - switch (map->type) { - case MAP_TYPE_WILDCARD: - if (snprintf(buf, sizeof(buf), "wildcard") < 0) - return ("???"); - break; - case MAP_TYPE_PREFIX: - if (snprintf(buf, sizeof(buf), "%s/%u", - log_addr(map->fec.prefix.af, &map->fec.prefix.prefix), - map->fec.prefix.prefixlen) == -1) - return ("???"); - break; - case MAP_TYPE_PWID: - if (snprintf(buf, sizeof(buf), "pw-id %u group-id %u (%s)", - map->fec.pwid.pwid, map->fec.pwid.group_id, - pw_type_name(map->fec.pwid.type)) == -1) - return ("???"); - break; - case MAP_TYPE_TYPED_WCARD: - if (snprintf(buf, sizeof(buf), "typed wildcard") < 0) - return ("???"); - switch (map->fec.twcard.type) { - case MAP_TYPE_PREFIX: - if (snprintf(buf + strlen(buf), sizeof(buf) - - strlen(buf), " (prefix, address-family %s)", - af_name(map->fec.twcard.u.prefix_af)) < 0) - return ("???"); - break; - case MAP_TYPE_PWID: - if (snprintf(buf + strlen(buf), sizeof(buf) - - strlen(buf), " (pwid, type %s)", - pw_type_name(map->fec.twcard.u.pw_type)) < 0) - return ("???"); - break; - default: - if (snprintf(buf + strlen(buf), sizeof(buf) - - strlen(buf), " (unknown type)") < 0) - return ("???"); - break; - } - break; - default: - return ("???"); - } - - return (buf); -} - -const char * -log_fec(const struct fec *fec) -{ - static char buf[64]; - union ldpd_addr addr; - - switch (fec->type) { - case FEC_TYPE_IPV4: - addr.v4 = fec->u.ipv4.prefix; - if (snprintf(buf, sizeof(buf), "ipv4 %s/%u", - log_addr(AF_INET, &addr), fec->u.ipv4.prefixlen) == -1) - return ("???"); - break; - case FEC_TYPE_IPV6: - addr.v6 = fec->u.ipv6.prefix; - if (snprintf(buf, sizeof(buf), "ipv6 %s/%u", - log_addr(AF_INET6, &addr), fec->u.ipv6.prefixlen) == -1) - return ("???"); - break; - case FEC_TYPE_PWID: - if (snprintf(buf, sizeof(buf), - "pwid %u (%s) - %s", - fec->u.pwid.pwid, pw_type_name(fec->u.pwid.type), - inet_ntoa(fec->u.pwid.lsr_id)) == -1) - return ("???"); - break; - default: - return ("???"); - } - - return (buf); -} - -/* names */ -const char * -af_name(int af) -{ - switch (af) { - case AF_INET: - return ("ipv4"); - case AF_INET6: - return ("ipv6"); -#ifdef AF_MPLS - case AF_MPLS: - return ("mpls"); -#endif - default: - return ("UNKNOWN"); - } -} - -const char * -socket_name(int type) -{ - switch (type) { - case LDP_SOCKET_DISC: - return ("discovery"); - case LDP_SOCKET_EDISC: - return ("extended discovery"); - case LDP_SOCKET_SESSION: - return ("session"); - default: - return ("UNKNOWN"); - } -} - -const char * -nbr_state_name(int state) -{ - switch (state) { - case NBR_STA_PRESENT: - return ("PRESENT"); - case NBR_STA_INITIAL: - return ("INITIALIZED"); - case NBR_STA_OPENREC: - return ("OPENREC"); - case NBR_STA_OPENSENT: - return ("OPENSENT"); - case NBR_STA_OPER: - return ("OPERATIONAL"); - default: - return ("UNKNOWN"); - } -} - -const char * -if_state_name(int state) -{ - switch (state) { - case IF_STA_DOWN: - return ("DOWN"); - case IF_STA_ACTIVE: - return ("ACTIVE"); - default: - return ("UNKNOWN"); - } -} - -const char * -if_type_name(enum iface_type type) -{ - switch (type) { - case IF_TYPE_POINTOPOINT: - return ("POINTOPOINT"); - case IF_TYPE_BROADCAST: - return ("BROADCAST"); - } - /* NOTREACHED */ - return ("UNKNOWN"); -} - -const char * -msg_name(uint16_t msg) -{ - static char buf[16]; - - switch (msg) { - case MSG_TYPE_NOTIFICATION: - return ("notification"); - case MSG_TYPE_HELLO: - return ("hello"); - case MSG_TYPE_INIT: - return ("initialization"); - case MSG_TYPE_KEEPALIVE: - return ("keepalive"); - case MSG_TYPE_CAPABILITY: - return ("capability"); - case MSG_TYPE_ADDR: - return ("address"); - case MSG_TYPE_ADDRWITHDRAW: - return ("address withdraw"); - case MSG_TYPE_LABELMAPPING: - return ("label mapping"); - case MSG_TYPE_LABELREQUEST: - return ("label request"); - case MSG_TYPE_LABELWITHDRAW: - return ("label withdraw"); - case MSG_TYPE_LABELRELEASE: - return ("label release"); - case MSG_TYPE_LABELABORTREQ: - default: - snprintf(buf, sizeof(buf), "[%08x]", msg); - return (buf); - } -} - -const char * -status_code_name(uint32_t status) -{ - static char buf[16]; - - switch (status) { - case S_SUCCESS: - return ("Success"); - case S_BAD_LDP_ID: - return ("Bad LDP Identifier"); - case S_BAD_PROTO_VER: - return ("Bad Protocol Version"); - case S_BAD_PDU_LEN: - return ("Bad PDU Length"); - case S_UNKNOWN_MSG: - return ("Unknown Message Type"); - case S_BAD_MSG_LEN: - return ("Bad Message Length"); - case S_UNKNOWN_TLV: - return ("Unknown TLV"); - case S_BAD_TLV_LEN: - return ("Bad TLV Length"); - case S_BAD_TLV_VAL: - return ("Malformed TLV Value"); - case S_HOLDTIME_EXP: - return ("Hold Timer Expired"); - case S_SHUTDOWN: - return ("Shutdown"); - case S_LOOP_DETECTED: - return ("Loop Detected"); - case S_UNKNOWN_FEC: - return ("Unknown FEC"); - case S_NO_ROUTE: - return ("No Route"); - case S_NO_LABEL_RES: - return ("No Label Resources"); - case S_AVAILABLE: - return ("Label Resources Available"); - case S_NO_HELLO: - return ("Session Rejected, No Hello"); - case S_PARM_ADV_MODE: - return ("Rejected Advertisement Mode Parameter"); - case S_MAX_PDU_LEN: - return ("Rejected Max PDU Length Parameter"); - case S_PARM_L_RANGE: - return ("Rejected Label Range Parameter"); - case S_KEEPALIVE_TMR: - return ("KeepAlive Timer Expired"); - case S_LAB_REQ_ABRT: - return ("Label Request Aborted"); - case S_MISS_MSG: - return ("Missing Message Parameters"); - case S_UNSUP_ADDR: - return ("Unsupported Address Family"); - case S_KEEPALIVE_BAD: - return ("Bad KeepAlive Time"); - case S_INTERN_ERR: - return ("Internal Error"); - case S_ILLEGAL_CBIT: - return ("Illegal C-Bit"); - case S_WRONG_CBIT: - return ("Wrong C-Bit"); - case S_INCPT_BITRATE: - return ("Incompatible bit-rate"); - case S_CEP_MISCONF: - return ("CEP-TDM mis-configuration"); - case S_PW_STATUS: - return ("PW Status"); - case S_UNASSIGN_TAI: - return ("Unassigned/Unrecognized TAI"); - case S_MISCONF_ERR: - return ("Generic Misconfiguration Error"); - case S_WITHDRAW_MTHD: - return ("Label Withdraw PW Status Method"); - case S_UNSSUPORTDCAP: - return ("Unsupported Capability"); - case S_ENDOFLIB: - return ("End-of-LIB"); - case S_TRANS_MISMTCH: - return ("Transport Connection Mismatch"); - case S_DS_NONCMPLNCE: - return ("Dual-Stack Noncompliance"); - default: - snprintf(buf, sizeof(buf), "[%08x]", status); - return (buf); - } -} - -const char * -pw_type_name(uint16_t pw_type) -{ - static char buf[64]; - - switch (pw_type) { - case PW_TYPE_ETHERNET_TAGGED: - return ("Eth Tagged"); - case PW_TYPE_ETHERNET: - return ("Ethernet"); - case PW_TYPE_WILDCARD: - return ("Wildcard"); - default: - snprintf(buf, sizeof(buf), "[%0x]", pw_type); - return (buf); - } -} diff --git a/ldpd/log.h b/ldpd/log.h index 4d6da43cac..8c236ff5fe 100644 --- a/ldpd/log.h +++ b/ldpd/log.h @@ -16,50 +16,32 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef _LOG_H_ -#define _LOG_H_ +#ifndef LOG_H +#define LOG_H #include -struct in6_addr; -union ldpd_addr; -struct hello_source; -struct fec; +extern const char *log_procname; -void logit(int, const char *, ...) - __attribute__((__format__ (printf, 2, 3))); -void log_warn(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_warnx(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_info(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_notice(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_debug(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void fatal(const char *) - __attribute__ ((noreturn)) - __attribute__((__format__ (printf, 1, 0))); -void fatalx(const char *) - __attribute__ ((noreturn)) - __attribute__((__format__ (printf, 1, 0))); -const char *log_sockaddr(void *); -const char *log_in6addr(const struct in6_addr *); -const char *log_in6addr_scope(const struct in6_addr *, unsigned int); -const char *log_addr(int, const union ldpd_addr *); -char *log_label(uint32_t); -const char *log_time(time_t); -char *log_hello_src(const struct hello_source *); -const char *log_map(const struct map *); -const char *log_fec(const struct fec *); -const char *af_name(int); -const char *socket_name(int); -const char *nbr_state_name(int); -const char *if_state_name(int); -const char *if_type_name(enum iface_type); -const char *msg_name(uint16_t); -const char *status_code_name(uint32_t); -const char *pw_type_name(uint16_t); +void logit(int, const char *, ...) + __attribute__((__format__ (printf, 2, 3))); +void vlog(int, const char *, va_list) + __attribute__((__format__ (printf, 2, 0))); +void log_warn(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_warnx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_info(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_notice(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_debug(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void fatal(const char *) + __attribute__ ((noreturn)) + __attribute__((__format__ (printf, 1, 0))); +void fatalx(const char *) + __attribute__ ((noreturn)) + __attribute__((__format__ (printf, 1, 0))); -#endif /* _LOG_H_ */ +#endif /* LOG_H */ diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c new file mode 100644 index 0000000000..c819b33b43 --- /dev/null +++ b/ldpd/logmsg.c @@ -0,0 +1,487 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2003, 2004 Henning Brauer + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "mpls.h" + +#include "ldpd.h" +#include "ldpe.h" +#include "lde.h" + +#define NUM_LOGS 4 +const char * +log_sockaddr(void *vp) +{ + static char buf[NUM_LOGS][NI_MAXHOST]; + static int round = 0; + struct sockaddr *sa = vp; + + round = (round + 1) % NUM_LOGS; + + if (getnameinfo(sa, sockaddr_len(sa), buf[round], NI_MAXHOST, NULL, 0, + NI_NUMERICHOST)) + return ("(unknown)"); + else + return (buf[round]); +} + +const char * +log_in6addr(const struct in6_addr *addr) +{ + struct sockaddr_in6 sa_in6; + + memset(&sa_in6, 0, sizeof(sa_in6)); +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN + sa_in6.sin6_len = sizeof(sa_in6); +#endif + sa_in6.sin6_family = AF_INET6; + sa_in6.sin6_addr = *addr; + + recoverscope(&sa_in6); + + return (log_sockaddr(&sa_in6)); +} + +const char * +log_in6addr_scope(const struct in6_addr *addr, unsigned int ifindex) +{ + struct sockaddr_in6 sa_in6; + + memset(&sa_in6, 0, sizeof(sa_in6)); +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN + sa_in6.sin6_len = sizeof(sa_in6); +#endif + sa_in6.sin6_family = AF_INET6; + sa_in6.sin6_addr = *addr; + + addscope(&sa_in6, ifindex); + + return (log_sockaddr(&sa_in6)); +} + +const char * +log_addr(int af, const union ldpd_addr *addr) +{ + static char buf[NUM_LOGS][INET6_ADDRSTRLEN]; + static int round = 0; + + switch (af) { + case AF_INET: + round = (round + 1) % NUM_LOGS; + if (inet_ntop(AF_INET, &addr->v4, buf[round], + sizeof(buf[round])) == NULL) + return ("???"); + return (buf[round]); + case AF_INET6: + return (log_in6addr(&addr->v6)); + default: + break; + } + + return ("???"); +} + +#define TF_BUFS 4 +#define TF_LEN 32 + +char * +log_label(uint32_t label) +{ + char *buf; + static char tfbuf[TF_BUFS][TF_LEN]; /* ring buffer */ + static int idx = 0; + + buf = tfbuf[idx++]; + if (idx == TF_BUFS) + idx = 0; + + switch (label) { + case NO_LABEL: + snprintf(buf, TF_LEN, "-"); + break; + case MPLS_LABEL_IMPLNULL: + snprintf(buf, TF_LEN, "imp-null"); + break; + case MPLS_LABEL_IPV4NULL: + case MPLS_LABEL_IPV6NULL: + snprintf(buf, TF_LEN, "exp-null"); + break; + default: + snprintf(buf, TF_LEN, "%u", label); + break; + } + + return (buf); +} + +const char * +log_time(time_t t) +{ + char *buf; + static char tfbuf[TF_BUFS][TF_LEN]; /* ring buffer */ + static int idx = 0; + unsigned int sec, min, hrs, day, week; + + buf = tfbuf[idx++]; + if (idx == TF_BUFS) + idx = 0; + + week = t; + + sec = week % 60; + week /= 60; + min = week % 60; + week /= 60; + hrs = week % 24; + week /= 24; + day = week % 7; + week /= 7; + + if (week > 0) + snprintf(buf, TF_LEN, "%02uw%01ud%02uh", week, day, hrs); + else if (day > 0) + snprintf(buf, TF_LEN, "%01ud%02uh%02um", day, hrs, min); + else + snprintf(buf, TF_LEN, "%02u:%02u:%02u", hrs, min, sec); + + return (buf); +} + +char * +log_hello_src(const struct hello_source *src) +{ + static char buf[64]; + + switch (src->type) { + case HELLO_LINK: + snprintf(buf, sizeof(buf), "iface %s", + src->link.ia->iface->name); + break; + case HELLO_TARGETED: + snprintf(buf, sizeof(buf), "source %s", + log_addr(src->target->af, &src->target->addr)); + break; + } + + return (buf); +} + +const char * +log_map(const struct map *map) +{ + static char buf[128]; + + switch (map->type) { + case MAP_TYPE_WILDCARD: + if (snprintf(buf, sizeof(buf), "wildcard") < 0) + return ("???"); + break; + case MAP_TYPE_PREFIX: + if (snprintf(buf, sizeof(buf), "%s/%u", + log_addr(map->fec.prefix.af, &map->fec.prefix.prefix), + map->fec.prefix.prefixlen) == -1) + return ("???"); + break; + case MAP_TYPE_PWID: + if (snprintf(buf, sizeof(buf), "pw-id %u group-id %u (%s)", + map->fec.pwid.pwid, map->fec.pwid.group_id, + pw_type_name(map->fec.pwid.type)) == -1) + return ("???"); + break; + case MAP_TYPE_TYPED_WCARD: + if (snprintf(buf, sizeof(buf), "typed wildcard") < 0) + return ("???"); + switch (map->fec.twcard.type) { + case MAP_TYPE_PREFIX: + if (snprintf(buf + strlen(buf), sizeof(buf) - + strlen(buf), " (prefix, address-family %s)", + af_name(map->fec.twcard.u.prefix_af)) < 0) + return ("???"); + break; + case MAP_TYPE_PWID: + if (snprintf(buf + strlen(buf), sizeof(buf) - + strlen(buf), " (pwid, type %s)", + pw_type_name(map->fec.twcard.u.pw_type)) < 0) + return ("???"); + break; + default: + if (snprintf(buf + strlen(buf), sizeof(buf) - + strlen(buf), " (unknown type)") < 0) + return ("???"); + break; + } + break; + default: + return ("???"); + } + + return (buf); +} + +const char * +log_fec(const struct fec *fec) +{ + static char buf[64]; + union ldpd_addr addr; + + switch (fec->type) { + case FEC_TYPE_IPV4: + addr.v4 = fec->u.ipv4.prefix; + if (snprintf(buf, sizeof(buf), "ipv4 %s/%u", + log_addr(AF_INET, &addr), fec->u.ipv4.prefixlen) == -1) + return ("???"); + break; + case FEC_TYPE_IPV6: + addr.v6 = fec->u.ipv6.prefix; + if (snprintf(buf, sizeof(buf), "ipv6 %s/%u", + log_addr(AF_INET6, &addr), fec->u.ipv6.prefixlen) == -1) + return ("???"); + break; + case FEC_TYPE_PWID: + if (snprintf(buf, sizeof(buf), + "pwid %u (%s) - %s", + fec->u.pwid.pwid, pw_type_name(fec->u.pwid.type), + inet_ntoa(fec->u.pwid.lsr_id)) == -1) + return ("???"); + break; + default: + return ("???"); + } + + return (buf); +} + +/* names */ +const char * +af_name(int af) +{ + switch (af) { + case AF_INET: + return ("ipv4"); + case AF_INET6: + return ("ipv6"); +#ifdef AF_MPLS + case AF_MPLS: + return ("mpls"); +#endif + default: + return ("UNKNOWN"); + } +} + +const char * +socket_name(int type) +{ + switch (type) { + case LDP_SOCKET_DISC: + return ("discovery"); + case LDP_SOCKET_EDISC: + return ("extended discovery"); + case LDP_SOCKET_SESSION: + return ("session"); + default: + return ("UNKNOWN"); + } +} + +const char * +nbr_state_name(int state) +{ + switch (state) { + case NBR_STA_PRESENT: + return ("PRESENT"); + case NBR_STA_INITIAL: + return ("INITIALIZED"); + case NBR_STA_OPENREC: + return ("OPENREC"); + case NBR_STA_OPENSENT: + return ("OPENSENT"); + case NBR_STA_OPER: + return ("OPERATIONAL"); + default: + return ("UNKNOWN"); + } +} + +const char * +if_state_name(int state) +{ + switch (state) { + case IF_STA_DOWN: + return ("DOWN"); + case IF_STA_ACTIVE: + return ("ACTIVE"); + default: + return ("UNKNOWN"); + } +} + +const char * +if_type_name(enum iface_type type) +{ + switch (type) { + case IF_TYPE_POINTOPOINT: + return ("POINTOPOINT"); + case IF_TYPE_BROADCAST: + return ("BROADCAST"); + } + /* NOTREACHED */ + return ("UNKNOWN"); +} + +const char * +msg_name(uint16_t msg) +{ + static char buf[16]; + + switch (msg) { + case MSG_TYPE_NOTIFICATION: + return ("notification"); + case MSG_TYPE_HELLO: + return ("hello"); + case MSG_TYPE_INIT: + return ("initialization"); + case MSG_TYPE_KEEPALIVE: + return ("keepalive"); + case MSG_TYPE_CAPABILITY: + return ("capability"); + case MSG_TYPE_ADDR: + return ("address"); + case MSG_TYPE_ADDRWITHDRAW: + return ("address withdraw"); + case MSG_TYPE_LABELMAPPING: + return ("label mapping"); + case MSG_TYPE_LABELREQUEST: + return ("label request"); + case MSG_TYPE_LABELWITHDRAW: + return ("label withdraw"); + case MSG_TYPE_LABELRELEASE: + return ("label release"); + case MSG_TYPE_LABELABORTREQ: + default: + snprintf(buf, sizeof(buf), "[%08x]", msg); + return (buf); + } +} + +const char * +status_code_name(uint32_t status) +{ + static char buf[16]; + + switch (status) { + case S_SUCCESS: + return ("Success"); + case S_BAD_LDP_ID: + return ("Bad LDP Identifier"); + case S_BAD_PROTO_VER: + return ("Bad Protocol Version"); + case S_BAD_PDU_LEN: + return ("Bad PDU Length"); + case S_UNKNOWN_MSG: + return ("Unknown Message Type"); + case S_BAD_MSG_LEN: + return ("Bad Message Length"); + case S_UNKNOWN_TLV: + return ("Unknown TLV"); + case S_BAD_TLV_LEN: + return ("Bad TLV Length"); + case S_BAD_TLV_VAL: + return ("Malformed TLV Value"); + case S_HOLDTIME_EXP: + return ("Hold Timer Expired"); + case S_SHUTDOWN: + return ("Shutdown"); + case S_LOOP_DETECTED: + return ("Loop Detected"); + case S_UNKNOWN_FEC: + return ("Unknown FEC"); + case S_NO_ROUTE: + return ("No Route"); + case S_NO_LABEL_RES: + return ("No Label Resources"); + case S_AVAILABLE: + return ("Label Resources Available"); + case S_NO_HELLO: + return ("Session Rejected, No Hello"); + case S_PARM_ADV_MODE: + return ("Rejected Advertisement Mode Parameter"); + case S_MAX_PDU_LEN: + return ("Rejected Max PDU Length Parameter"); + case S_PARM_L_RANGE: + return ("Rejected Label Range Parameter"); + case S_KEEPALIVE_TMR: + return ("KeepAlive Timer Expired"); + case S_LAB_REQ_ABRT: + return ("Label Request Aborted"); + case S_MISS_MSG: + return ("Missing Message Parameters"); + case S_UNSUP_ADDR: + return ("Unsupported Address Family"); + case S_KEEPALIVE_BAD: + return ("Bad KeepAlive Time"); + case S_INTERN_ERR: + return ("Internal Error"); + case S_ILLEGAL_CBIT: + return ("Illegal C-Bit"); + case S_WRONG_CBIT: + return ("Wrong C-Bit"); + case S_INCPT_BITRATE: + return ("Incompatible bit-rate"); + case S_CEP_MISCONF: + return ("CEP-TDM mis-configuration"); + case S_PW_STATUS: + return ("PW Status"); + case S_UNASSIGN_TAI: + return ("Unassigned/Unrecognized TAI"); + case S_MISCONF_ERR: + return ("Generic Misconfiguration Error"); + case S_WITHDRAW_MTHD: + return ("Label Withdraw PW Status Method"); + case S_UNSSUPORTDCAP: + return ("Unsupported Capability"); + case S_ENDOFLIB: + return ("End-of-LIB"); + case S_TRANS_MISMTCH: + return ("Transport Connection Mismatch"); + case S_DS_NONCMPLNCE: + return ("Dual-Stack Noncompliance"); + default: + snprintf(buf, sizeof(buf), "[%08x]", status); + return (buf); + } +} + +const char * +pw_type_name(uint16_t pw_type) +{ + static char buf[64]; + + switch (pw_type) { + case PW_TYPE_ETHERNET_TAGGED: + return ("Eth Tagged"); + case PW_TYPE_ETHERNET: + return ("Ethernet"); + case PW_TYPE_WILDCARD: + return ("Wildcard"); + default: + snprintf(buf, sizeof(buf), "[%0x]", pw_type); + return (buf); + } +} From 9785dbcbca1a09806217e20b033a71789a89623b Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 18 Apr 2017 12:14:15 -0300 Subject: [PATCH 69/96] ldpd: fix log level of log_warn() and log_warnx() The log_warn() and log_warnx() functions indicate non-critical warnings and errors, so use LOG_ERR instead of LOG_CRIT. Keep using LOG_CRIT only in fatal() and fatalx() since these functions indicate critical errors (when the program needs to exit). Signed-off-by: Renato Westphal --- ldpd/log.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ldpd/log.c b/ldpd/log.c index 408aaeb699..fc8c995ba3 100644 --- a/ldpd/log.c +++ b/ldpd/log.c @@ -66,16 +66,16 @@ log_warn(const char *emsg, ...) /* best effort to even work in out of memory situations */ if (emsg == NULL) - logit(LOG_CRIT, "%s", strerror(errno)); + logit(LOG_ERR, "%s", strerror(errno)); else { va_start(ap, emsg); if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) { /* we tried it... */ - vlog(LOG_CRIT, emsg, ap); - logit(LOG_CRIT, "%s", strerror(errno)); + vlog(LOG_ERR, emsg, ap); + logit(LOG_ERR, "%s", strerror(errno)); } else { - vlog(LOG_CRIT, nfmt, ap); + vlog(LOG_ERR, nfmt, ap); free(nfmt); } va_end(ap); @@ -88,7 +88,7 @@ log_warnx(const char *emsg, ...) va_list ap; va_start(ap, emsg); - vlog(LOG_CRIT, emsg, ap); + vlog(LOG_ERR, emsg, ap); va_end(ap); } From e0d7c8996d6fe3bc39a1b9fd0310f17ff272ec1a Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 18 Apr 2017 12:17:30 -0300 Subject: [PATCH 70/96] ldpd: call openzlog() in the child processes as well Signed-off-by: Renato Westphal --- ldpd/ldpd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 8da830ccef..5fbdf52ec2 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -282,14 +282,14 @@ main(int argc, char *argv[]) exit(1); } + openzlog(ldpd_di.progname, "LDP", 0, + LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); + if (lflag) lde(user, group, instance); else if (eflag) ldpe(user, group, ctl_sock_path); - openzlog(ldpd_di.progname, "LDP", 0, - LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); - if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_parent2ldpe) == -1) fatal("socketpair"); if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, From e75f810c2f6d3322e981c3e50f7d87f181005461 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 18 Apr 2017 22:03:35 -0300 Subject: [PATCH 71/96] ldpd: simplify initialization of the child processes In order to have separate ASLR/cookies per process, ldpd calls exec() in the child processes after fork() (this is also known as the fork+exec model). This is an important security feature but it makes the initialization of the child processes a bit more complicated as they're not a copy of the parent anymore, so all parameters given via command line are lost. To solve this problem, we were creating an argv array by hand with all necessary parameters and providing it to the exec() syscall. This works but it's a very ugly solution. This patch introduces a different approach to solve the problem: send an IMSG_INIT message to the child processes with all parameters they need in order to initialize properly. This makes adding additional initialization parameters much more convenient and less error prone. Signed-off-by: Renato Westphal Conflicts: ldpd/ldpd.c ldpd/ldpd.h --- ldpd/control.c | 18 +++++------ ldpd/control.h | 4 +-- ldpd/lde.c | 60 ++++++++++++++++++++-------------- ldpd/lde.h | 3 +- ldpd/ldpd.c | 65 ++++++++++--------------------------- ldpd/ldpd.h | 13 ++++++-- ldpd/ldpe.c | 88 ++++++++++++++++++++++++++++---------------------- ldpd/ldpe.h | 3 +- 8 files changed, 127 insertions(+), 127 deletions(-) diff --git a/ldpd/control.c b/ldpd/control.c index 5c530e1b70..d40e0342c1 100644 --- a/ldpd/control.c +++ b/ldpd/control.c @@ -37,7 +37,7 @@ struct ctl_conns ctl_conns; static int control_fd; int -control_init(void) +control_init(char *path) { struct sockaddr_un s_un; int fd; @@ -51,28 +51,28 @@ control_init(void) memset(&s_un, 0, sizeof(s_un)); s_un.sun_family = AF_UNIX; - strlcpy(s_un.sun_path, ctl_sock_path, sizeof(s_un.sun_path)); + strlcpy(s_un.sun_path, path, sizeof(s_un.sun_path)); - if (unlink(ctl_sock_path) == -1) + if (unlink(path) == -1) if (errno != ENOENT) { - log_warn("%s: unlink %s", __func__, ctl_sock_path); + log_warn("%s: unlink %s", __func__, path); close(fd); return (-1); } old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); if (bind(fd, (struct sockaddr *)&s_un, sizeof(s_un)) == -1) { - log_warn("%s: bind: %s", __func__, ctl_sock_path); + log_warn("%s: bind: %s", __func__, path); close(fd); umask(old_umask); return (-1); } umask(old_umask); - if (chmod(ctl_sock_path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) { + if (chmod(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) { log_warn("%s: chmod", __func__); close(fd); - (void)unlink(ctl_sock_path); + (void)unlink(path); return (-1); } @@ -93,11 +93,11 @@ control_listen(void) } void -control_cleanup(void) +control_cleanup(char *path) { accept_del(control_fd); close(control_fd); - unlink(ctl_sock_path); + unlink(path); } /* ARGSUSED */ diff --git a/ldpd/control.h b/ldpd/control.h index 32c49fdf87..0e66a1636a 100644 --- a/ldpd/control.h +++ b/ldpd/control.h @@ -29,9 +29,9 @@ TAILQ_HEAD(ctl_conns, ctl_conn); extern struct ctl_conns ctl_conns; -int control_init(void); +int control_init(char *); int control_listen(void); -void control_cleanup(void); +void control_cleanup(char *); int control_imsg_relay(struct imsg *); #endif /* _CONTROL_H_ */ diff --git a/ldpd/lde.c b/ldpd/lde.c index c4a610b6d3..ed8274bec7 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -152,12 +152,9 @@ zclient_sync_init(u_short instance) /* label decision engine */ void -lde(const char *user, const char *group, u_short instance) +lde(void) { struct thread thread; - struct timeval now; - - ldeconf = config_new_empty(); #ifdef HAVE_SETPROCTITLE setproctitle("label decision engine"); @@ -165,18 +162,6 @@ lde(const char *user, const char *group, u_short instance) ldpd_process = PROC_LDE_ENGINE; log_procname = log_procnames[PROC_LDE_ENGINE]; - /* drop privileges */ - if (user) - lde_privs.user = user; - if (group) - lde_privs.group = group; - zprivs_init(&lde_privs); - -#ifdef HAVE_PLEDGE - if (pledge("stdio recvfd unix", NULL) == -1) - fatal("pledge"); -#endif - master = thread_master_create(); /* setup signal handler */ @@ -195,21 +180,38 @@ lde(const char *user, const char *group, u_short instance) fatal(NULL); imsg_init(&iev_main_sync->ibuf, LDPD_FD_SYNC); - /* start the LIB garbage collector */ - lde_gc_start_timer(); - - gettimeofday(&now, NULL); - global.uptime = now.tv_sec; - - /* Init synchronous zclient and label list */ - zclient_sync_init(instance); - lde_label_list_init(); + /* create base configuration */ + ldeconf = config_new_empty(); /* Fetch next active thread. */ while (thread_fetch(master, &thread)) thread_call(&thread); } +void +lde_init(struct ldpd_init *init) +{ + /* drop privileges */ + if (init->user) + lde_privs.user = init->user; + if (init->group) + lde_privs.group = init->group; + zprivs_init(&lde_privs); + +#ifdef HAVE_PLEDGE + if (pledge("stdio recvfd unix", NULL) == -1) + fatal("pledge"); +#endif + + /* start the LIB garbage collector */ + lde_gc_start_timer(); + + /* Init synchronous zclient and label list */ + zclient_serv_path_set(init->zclient_serv_path); + zclient_sync_init(init->instance); + lde_label_list_init(); +} + static void lde_shutdown(void) { @@ -553,6 +555,14 @@ lde_dispatch_parent(struct thread *thread) iev_ldpe->handler_write = ldp_write_handler; iev_ldpe->ev_write = NULL; break; + case IMSG_INIT: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(struct ldpd_init)) + fatalx("INIT imsg with wrong len"); + + memcpy(&init, imsg.data, sizeof(init)); + lde_init(&init); + break; case IMSG_RECONF_CONF: if ((nconf = malloc(sizeof(struct ldpd_conf))) == NULL) diff --git a/ldpd/lde.h b/ldpd/lde.h index 57791cd1b0..3349d4ca00 100644 --- a/ldpd/lde.h +++ b/ldpd/lde.h @@ -139,7 +139,8 @@ extern struct nbr_tree lde_nbrs; extern struct thread *gc_timer; /* lde.c */ -void lde(const char *, const char *, u_short instance); +void lde(void); +void lde_init(struct ldpd_init *); int lde_imsg_compose_parent(int, pid_t, void *, uint16_t); int lde_imsg_compose_ldpe(int, uint32_t, pid_t, void *, uint16_t); int lde_acl_check(char *, int, union ldpd_addr *, uint8_t); diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 5fbdf52ec2..bdf7097323 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -44,8 +44,7 @@ #include "libfrr.h" static void ldpd_shutdown(void); -static pid_t start_child(enum ldpd_process, char *, int, int, - const char *, const char *, const char *, const char *); +static pid_t start_child(enum ldpd_process, char *, int, int); static int main_dispatch_ldpe(struct thread *); static int main_dispatch_lde(struct thread *); static int main_imsg_send_ipc_sockets(struct imsgbuf *, @@ -77,6 +76,7 @@ DEFINE_QOBJ_TYPE(l2vpn) DEFINE_QOBJ_TYPE(ldpd_conf) struct ldpd_global global; +struct ldpd_init init; struct ldpd_conf *ldpd_conf, *vty_conf; static struct imsgev *iev_ldpe, *iev_ldpe_sync; @@ -200,12 +200,7 @@ main(int argc, char *argv[]) int lflag = 0, eflag = 0; int pipe_parent2ldpe[2], pipe_parent2ldpe_sync[2]; int pipe_parent2lde[2], pipe_parent2lde_sync[2]; - char *ctl_sock_custom_path = NULL; char *ctl_sock_name; - const char *user = NULL; - const char *group = NULL; - u_short instance = 0; - const char *instance_char = NULL; ldpd_process = PROC_MAIN; log_procname = log_procnames[ldpd_process]; @@ -242,17 +237,14 @@ main(int argc, char *argv[]) * sensible config */ ctl_sock_name = (char *)LDPD_SOCKET; - ctl_sock_custom_path = optarg; - strlcpy(ctl_sock_path, ctl_sock_custom_path, - sizeof(ctl_sock_path)); + strlcpy(ctl_sock_path, optarg, sizeof(ctl_sock_path)); strlcat(ctl_sock_path, "/", sizeof(ctl_sock_path)); strlcat(ctl_sock_path, ctl_sock_name, sizeof(ctl_sock_path)); break; case 'n': - instance = atoi(optarg); - instance_char = optarg; - if (instance < 1) + init.instance = atoi(optarg); + if (init.instance < 1) exit(0); break; case 'L': @@ -267,8 +259,11 @@ main(int argc, char *argv[]) } } - user = ldpd_privs.user; - group = ldpd_privs.group; + strlcpy(init.user, ldpd_privs.user, sizeof(init.user)); + strlcpy(init.group, ldpd_privs.group, sizeof(init.group)); + strlcpy(init.ctl_sock_path, ctl_sock_path, sizeof(init.ctl_sock_path)); + strlcpy(init.zclient_serv_path, zclient_serv_path_get(), + sizeof(init.zclient_serv_path)); argc -= optind; argv += optind; @@ -286,9 +281,9 @@ main(int argc, char *argv[]) LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); if (lflag) - lde(user, group, instance); + lde(); else if (eflag) - ldpe(user, group, ctl_sock_path); + ldpe(); if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_parent2ldpe) == -1) fatal("socketpair"); @@ -317,11 +312,9 @@ main(int argc, char *argv[]) /* start children */ lde_pid = start_child(PROC_LDE_ENGINE, saved_argv0, - pipe_parent2lde[1], pipe_parent2lde_sync[1], - user, group, ctl_sock_custom_path, instance_char); + pipe_parent2lde[1], pipe_parent2lde_sync[1]); ldpe_pid = start_child(PROC_LDP_ENGINE, saved_argv0, - pipe_parent2ldpe[1], pipe_parent2ldpe_sync[1], - user, group, ctl_sock_custom_path, instance_char); + pipe_parent2ldpe[1], pipe_parent2ldpe_sync[1]); /* drop privileges */ zprivs_init(&ldpd_privs); @@ -389,6 +382,7 @@ main(int argc, char *argv[]) if (main_imsg_send_ipc_sockets(&iev_ldpe->ibuf, &iev_lde->ibuf)) fatal("could not establish imsg links"); + main_imsg_compose_both(IMSG_INIT, &init, sizeof(init)); main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, sizeof(ldp_debug)); main_imsg_send_config(ldpd_conf); @@ -453,11 +447,9 @@ ldpd_shutdown(void) } static pid_t -start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync, - const char *user, const char *group, const char *ctl_sock_custom_path, - const char *instance) +start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync) { - char *argv[13]; + char *argv[3]; int argc = 0; pid_t pid; @@ -488,29 +480,6 @@ start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync, argv[argc++] = (char *)"-E"; break; } - if (user) { - argv[argc++] = (char *)"-u"; - argv[argc++] = (char *)user; - } - if (group) { - argv[argc++] = (char *)"-g"; - argv[argc++] = (char *)group; - } - if (ctl_sock_custom_path) { - argv[argc++] = (char *)"--ctl_socket"; - argv[argc++] = (char *)ctl_sock_custom_path; - } - /* zclient serv path */ -#ifdef HAVE_TCP_ZEBRA -#else - argv[argc++] = (char *)"-z"; - argv[argc++] = (char *)zclient_serv_path_get(); -#endif - /* instance */ - if (instance) { - argv[argc++] = (char *)"-n"; - argv[argc++] = (char *)instance; - } argv[argc++] = NULL; execvp(argv0, argv); diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 759f1d0da5..97239ed08e 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -147,7 +147,16 @@ enum imsg_type { IMSG_LOG, IMSG_ACL_CHECK, IMSG_GET_LABEL_CHUNK, - IMSG_RELEASE_LABEL_CHUNK + IMSG_RELEASE_LABEL_CHUNK, + IMSG_INIT +}; + +struct ldpd_init { + char user[256]; + char group[256]; + char ctl_sock_path[MAXPATHLEN]; + char zclient_serv_path[MAXPATHLEN]; + u_short instance; }; union ldpd_addr { @@ -510,7 +519,6 @@ struct ldpd_af_global { struct ldpd_global { int cmd_opts; int sighup; - time_t uptime; struct in_addr rtr_id; struct ldpd_af_global ipv4; struct ldpd_af_global ipv6; @@ -655,6 +663,7 @@ struct ctl_pw { extern struct ldpd_conf *ldpd_conf, *vty_conf; extern struct ldpd_global global; +extern struct ldpd_init init; /* parse.y */ struct ldpd_conf *parse_config(char *); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index e82416276b..1248d4f86e 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -103,47 +103,17 @@ static struct quagga_signal_t ldpe_signals[] = /* label distribution protocol engine */ void -ldpe(const char *user, const char *group, const char *ctl_path) +ldpe(void) { struct thread thread; - leconf = config_new_empty(); - #ifdef HAVE_SETPROCTITLE setproctitle("ldp engine"); #endif ldpd_process = PROC_LDP_ENGINE; log_procname = log_procnames[ldpd_process]; - LIST_INIT(&global.addr_list); - RB_INIT(&global.adj_tree); - TAILQ_INIT(&global.pending_conns); - if (inet_pton(AF_INET, AllRouters_v4, &global.mcast_addr_v4) != 1) - fatal("inet_pton"); - if (inet_pton(AF_INET6, AllRouters_v6, &global.mcast_addr_v6) != 1) - fatal("inet_pton"); -#ifdef __OpenBSD__ - global.pfkeysock = pfkey_init(); -#endif - - /* drop privileges */ - if (user) - ldpe_privs.user = user; - if (group) - ldpe_privs.group = group; - zprivs_init(&ldpe_privs); - - strlcpy(ctl_sock_path, ctl_path, sizeof(ctl_sock_path)); - if (control_init() == -1) - fatalx("control socket setup failed"); - -#ifdef HAVE_PLEDGE - if (pledge("stdio cpath inet mcast recvfd", NULL) == -1) - fatal("pledge"); -#endif - master = thread_master_create(); - accept_init(); /* setup signal handler */ signal_init(master, array_size(ldpe_signals), ldpe_signals); @@ -161,7 +131,45 @@ ldpe(const char *user, const char *group, const char *ctl_path) fatal(NULL); imsg_init(&iev_main_sync->ibuf, LDPD_FD_SYNC); + /* create base configuration */ + leconf = config_new_empty(); + + /* Fetch next active thread. */ + while (thread_fetch(master, &thread)) + thread_call(&thread); +} + +void +ldpe_init(struct ldpd_init *init) +{ + /* drop privileges */ + if (init->user) + ldpe_privs.user = init->user; + if (init->group) + ldpe_privs.group = init->group; + zprivs_init(&ldpe_privs); + + /* listen on ldpd control socket */ + strlcpy(ctl_sock_path, init->ctl_sock_path, sizeof(ctl_sock_path)); + if (control_init(ctl_sock_path) == -1) + fatalx("control socket setup failed"); + TAILQ_INIT(&ctl_conns); + control_listen(); + +#ifdef HAVE_PLEDGE + if (pledge("stdio cpath inet mcast recvfd", NULL) == -1) + fatal("pledge"); +#endif + + LIST_INIT(&global.addr_list); + RB_INIT(&global.adj_tree); + TAILQ_INIT(&global.pending_conns); + if (inet_pton(AF_INET, AllRouters_v4, &global.mcast_addr_v4) != 1) + fatal("inet_pton"); + if (inet_pton(AF_INET6, AllRouters_v6, &global.mcast_addr_v6) != 1) + fatal("inet_pton"); #ifdef __OpenBSD__ + global.pfkeysock = pfkey_init(); if (sysdep.no_pfkey == 0) pfkey_ev = thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock); @@ -175,16 +183,10 @@ ldpe(const char *user, const char *group, const char *ctl_path) global.ipv6.ldp_edisc_socket = -1; global.ipv6.ldp_session_socket = -1; - /* listen on ldpd control socket */ - TAILQ_INIT(&ctl_conns); - control_listen(); - if ((pkt_ptr = calloc(1, IBUF_READ_SIZE)) == NULL) fatal(__func__); - /* Fetch next active thread. */ - while (thread_fetch(master, &thread)) - thread_call(&thread); + accept_init(); } static void @@ -203,7 +205,7 @@ ldpe_shutdown(void) msgbuf_clear(&iev_main_sync->ibuf.w); close(iev_main_sync->ibuf.fd); - control_cleanup(); + control_cleanup(ctl_sock_path); config_clear(leconf); #ifdef __OpenBSD__ @@ -352,6 +354,14 @@ ldpe_dispatch_main(struct thread *thread) iev_lde->handler_write = ldp_write_handler; iev_lde->ev_write = NULL; break; + case IMSG_INIT: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(struct ldpd_init)) + fatalx("INIT imsg with wrong len"); + + memcpy(&init, imsg.data, sizeof(init)); + ldpe_init(&init); + break; case IMSG_CLOSE_SOCKETS: af = imsg.hdr.peerid; diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index a3f41a8b9f..2c1ba46c6b 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -195,7 +195,8 @@ int tlv_decode_fec_elm(struct nbr *, struct ldp_msg *, char *, uint16_t, struct map *); /* ldpe.c */ -void ldpe(const char *, const char *, const char *); +void ldpe(void); +void ldpe_init(struct ldpd_init *); int ldpe_imsg_compose_parent(int, pid_t, void *, uint16_t); int ldpe_imsg_compose_lde(int, uint32_t, pid_t, void *, From b3121cd7d14f28cad53d39d9fbf09b036d3e95c9 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 19 Apr 2017 15:15:56 -0300 Subject: [PATCH 72/96] ldpd: fix segfault after failed initialization When ldpd fails to start for some reason, like failing to create a pid file, the child processes call their shutdown functions without being completely initialized. This patch adds some protections to prevent a segmentation fault on such circumstances. Signed-off-by: Renato Westphal --- ldpd/lde.c | 9 ++++++--- ldpd/ldpe.c | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index ed8274bec7..3dfcd8f885 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -216,8 +216,10 @@ static void lde_shutdown(void) { /* close pipes */ - msgbuf_clear(&iev_ldpe->ibuf.w); - close(iev_ldpe->ibuf.fd); + if (iev_ldpe) { + msgbuf_clear(&iev_ldpe->ibuf.w); + close(iev_ldpe->ibuf.fd); + } msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); msgbuf_clear(&iev_main_sync->ibuf.w); @@ -229,7 +231,8 @@ lde_shutdown(void) config_clear(ldeconf); - free(iev_ldpe); + if (iev_ldpe) + free(iev_ldpe); free(iev_main); free(iev_main_sync); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 1248d4f86e..bd0f9dbd6f 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -196,9 +196,11 @@ ldpe_shutdown(void) struct adj *adj; /* close pipes */ - msgbuf_write(&iev_lde->ibuf.w); - msgbuf_clear(&iev_lde->ibuf.w); - close(iev_lde->ibuf.fd); + if (iev_lde) { + msgbuf_write(&iev_lde->ibuf.w); + msgbuf_clear(&iev_lde->ibuf.w); + close(iev_lde->ibuf.fd); + } msgbuf_write(&iev_main->ibuf.w); msgbuf_clear(&iev_main->ibuf.w); close(iev_main->ibuf.fd); @@ -226,7 +228,8 @@ ldpe_shutdown(void) adj_del(adj, S_SHUTDOWN); /* clean up */ - free(iev_lde); + if (iev_lde) + free(iev_lde); free(iev_main); free(iev_main_sync); free(pkt_ptr); From 30f35e856608b29c7e4f091c7a22f4a3b4019258 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 19 Apr 2017 15:28:43 -0300 Subject: [PATCH 73/96] ldpd: remove unnecessary checks if a signal was caught Signed-off-by: Renato Westphal --- ldpd/lde.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index 3dfcd8f885..426af8dbe8 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -119,13 +119,6 @@ static struct quagga_signal_t lde_signals[] = }, }; -static void -lde_sleep (void) -{ - sleep(1); - if (lde_signals[0].caught || lde_signals[1].caught) - lde_shutdown(); -} struct zclient *zclient_sync = NULL; static void zclient_sync_init(u_short instance) @@ -138,7 +131,7 @@ zclient_sync_init(u_short instance) zclient_sync->instance = instance; while (zclient_socket_connect (zclient_sync) < 0) { fprintf(stderr, "Error connecting synchronous zclient!\n"); - lde_sleep(); + sleep(1); } /* make socket non-blocking */ sock_set_nonblock(zclient_sync->sock); @@ -146,7 +139,7 @@ zclient_sync_init(u_short instance) /* Connect to label manager */ while (lm_label_manager_connect (zclient_sync) != 0) { fprintf(stderr, "Error connecting to label manager!\n"); - lde_sleep(); + sleep(1); } } @@ -1628,7 +1621,7 @@ lde_label_list_init(void) /* get first chunk */ while (lde_get_label_chunk () != 0) { fprintf(stderr, "Error getting first label chunk!\n"); - lde_sleep(); + sleep(1); } } From d8292558bde9802b8267deff44dabb87b12b885f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 19 Apr 2017 16:59:50 -0300 Subject: [PATCH 74/96] ldpd: use synchronous channels for sending log messages This is necessary to guarantee that all log messages sent from the child processes are received in the parent process right away. Without this patch, when a child process calls fatal() or fatalx(), the log messages don't make it to the parent because the child doesn't have a chance to flush its buffers before exiting. Signed-off-by: Renato Westphal --- ldpd/lde.c | 13 ++++++++++--- ldpd/lde.h | 1 + ldpd/ldpe.c | 7 +++++++ ldpd/ldpe.h | 1 + ldpd/log.c | 6 ++++-- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index 426af8dbe8..1c7458ce73 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -130,7 +130,7 @@ zclient_sync_init(u_short instance) zclient_sync->redist_default = ZEBRA_ROUTE_LDP; zclient_sync->instance = instance; while (zclient_socket_connect (zclient_sync) < 0) { - fprintf(stderr, "Error connecting synchronous zclient!\n"); + log_warnx("Error connecting synchronous zclient!"); sleep(1); } /* make socket non-blocking */ @@ -138,7 +138,7 @@ zclient_sync_init(u_short instance) /* Connect to label manager */ while (lm_label_manager_connect (zclient_sync) != 0) { - fprintf(stderr, "Error connecting to label manager!\n"); + log_warnx("Error connecting to label manager!"); sleep(1); } } @@ -240,6 +240,13 @@ lde_imsg_compose_parent(int type, pid_t pid, void *data, uint16_t datalen) return (imsg_compose_event(iev_main, type, 0, pid, -1, data, datalen)); } +void +lde_imsg_compose_parent_sync(int type, pid_t pid, void *data, uint16_t datalen) +{ + imsg_compose_event(iev_main_sync, type, 0, pid, -1, data, datalen); + imsg_flush(&iev_main_sync->ibuf); +} + int lde_imsg_compose_ldpe(int type, uint32_t peerid, pid_t pid, void *data, uint16_t datalen) @@ -1620,7 +1627,7 @@ lde_label_list_init(void) /* get first chunk */ while (lde_get_label_chunk () != 0) { - fprintf(stderr, "Error getting first label chunk!\n"); + log_warnx("Error getting first label chunk!"); sleep(1); } } diff --git a/ldpd/lde.h b/ldpd/lde.h index 3349d4ca00..c1d66f9fff 100644 --- a/ldpd/lde.h +++ b/ldpd/lde.h @@ -142,6 +142,7 @@ extern struct thread *gc_timer; void lde(void); void lde_init(struct ldpd_init *); int lde_imsg_compose_parent(int, pid_t, void *, uint16_t); +void lde_imsg_compose_parent_sync(int, pid_t, void *, uint16_t); int lde_imsg_compose_ldpe(int, uint32_t, pid_t, void *, uint16_t); int lde_acl_check(char *, int, union ldpd_addr *, uint8_t); uint32_t lde_update_label(struct fec_node *); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index bd0f9dbd6f..20cc9f7444 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -245,6 +245,13 @@ ldpe_imsg_compose_parent(int type, pid_t pid, void *data, uint16_t datalen) return (imsg_compose_event(iev_main, type, 0, pid, -1, data, datalen)); } +void +ldpe_imsg_compose_parent_sync(int type, pid_t pid, void *data, uint16_t datalen) +{ + imsg_compose_event(iev_main_sync, type, 0, pid, -1, data, datalen); + imsg_flush(&iev_main_sync->ibuf); +} + int ldpe_imsg_compose_lde(int type, uint32_t peerid, pid_t pid, void *data, uint16_t datalen) diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index 2c1ba46c6b..d34ca4dc24 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -199,6 +199,7 @@ void ldpe(void); void ldpe_init(struct ldpd_init *); int ldpe_imsg_compose_parent(int, pid_t, void *, uint16_t); +void ldpe_imsg_compose_parent_sync(int, pid_t, void *, uint16_t); int ldpe_imsg_compose_lde(int, uint32_t, pid_t, void *, uint16_t); int ldpe_acl_check(char *, int, union ldpd_addr *, uint8_t); diff --git a/ldpd/log.c b/ldpd/log.c index fc8c995ba3..b138e5754a 100644 --- a/ldpd/log.c +++ b/ldpd/log.c @@ -46,11 +46,13 @@ vlog(int pri, const char *fmt, va_list ap) switch (ldpd_process) { case PROC_LDE_ENGINE: vsnprintf(buf, sizeof(buf), fmt, ap); - lde_imsg_compose_parent(IMSG_LOG, pri, buf, strlen(buf) + 1); + lde_imsg_compose_parent_sync(IMSG_LOG, pri, buf, + strlen(buf) + 1); break; case PROC_LDP_ENGINE: vsnprintf(buf, sizeof(buf), fmt, ap); - ldpe_imsg_compose_parent(IMSG_LOG, pri, buf, strlen(buf) + 1); + ldpe_imsg_compose_parent_sync(IMSG_LOG, pri, buf, + strlen(buf) + 1); break; case PROC_MAIN: vzlog(pri, fmt, ap); From 3dcdcbb478d760208e7d82241bbdc359e9479475 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 19 Apr 2017 17:12:35 -0300 Subject: [PATCH 75/96] ldpd: minor changes in the output of some show commands Signed-off-by: Renato Westphal --- ldpd/ldp_vty_exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c index a149b7fe35..ffd20abb4a 100644 --- a/ldpd/ldp_vty_exec.c +++ b/ldpd/ldp_vty_exec.c @@ -517,8 +517,7 @@ show_nbr_msg(struct vty *vty, struct imsg *imsg, struct show_params *params) nbr_state_name(nbr->nbr_state), addr); if (strlen(addr) > 15) vty_out(vty, "%s%48s", VTY_NEWLINE, " "); - vty_out(vty, " %8s%s", nbr->uptime == 0 ? "-" : - log_time(nbr->uptime), VTY_NEWLINE); + vty_out(vty, " %8s%s", log_time(nbr->uptime), VTY_NEWLINE); break; case IMSG_CTL_END: return (1); @@ -909,6 +908,7 @@ show_nbr_capabilities_msg(struct vty *vty, struct imsg *imsg, struct show_params vty_out(vty, "Peer LDP Identifier: %s:0%s", inet_ntoa(nbr->id), VTY_NEWLINE); show_nbr_capabilities(vty, nbr); + vty_out(vty, "%s", VTY_NEWLINE); break; case IMSG_CTL_END: vty_out(vty, "%s", VTY_NEWLINE); From 9b2868bc019b15a878b3b08d165194b8c00b0e63 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 19 Apr 2017 19:31:19 -0300 Subject: [PATCH 76/96] ldpd: accept notifications during the session establishment process If we don't do this, we'll never trigger the backoff exponential timer since it's impossible to distinguish between Initialization NAK's and general errors. Also: * Implement some missing bits from RFC 5036; * remove superfluous log message in session_shutdown() (send_notification() logs that we're sending a fatal notification). Regression introduced by commit 8819fc3. Fixes the following ANVL LDP regressions: 6.19 and 6.21. Signed-off-by: Renato Westphal --- ldpd/notification.c | 10 ++++++++++ ldpd/packet.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ldpd/notification.c b/ldpd/notification.c index f10faa4a54..4a5f3c8fa4 100644 --- a/ldpd/notification.c +++ b/ldpd/notification.c @@ -237,6 +237,16 @@ recv_notification(struct nbr *nbr, char *buf, uint16_t len) if (nbr->state == NBR_STA_OPENSENT) nbr_start_idtimer(nbr); + /* + * RFC 5036 - Section 3.5.1.1: + * "When an LSR receives a Shutdown message during session + * initialization, it SHOULD transmit a Shutdown message and + * then close the transport connection". + */ + if (nbr->state != NBR_STA_OPER && nm.status_code == S_SHUTDOWN) + send_notification(nbr->tcp, S_SHUTDOWN, + msg.id, msg.type); + nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); return (-1); } diff --git a/ldpd/packet.c b/ldpd/packet.c index 46893b992b..75e1a9a027 100644 --- a/ldpd/packet.c +++ b/ldpd/packet.c @@ -519,6 +519,8 @@ session_read(struct thread *thread) return (0); } break; + case MSG_TYPE_NOTIFICATION: + break; default: if (nbr->state != NBR_STA_OPER) { session_shutdown(nbr, S_SHUTDOWN, @@ -661,8 +663,6 @@ session_shutdown(struct nbr *nbr, uint32_t status, uint32_t msg_id, case NBR_STA_OPENREC: case NBR_STA_OPENSENT: case NBR_STA_OPER: - log_debug("%s: lsr-id %s", __func__, inet_ntoa(nbr->id)); - send_notification(nbr->tcp, status, msg_id, msg_type); nbr_fsm(nbr, NBR_EVT_CLOSE_SESSION); From a8e8b867974cfbc37aeabe34b067f10448690bd2 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 21 Apr 2017 15:41:14 -0300 Subject: [PATCH 77/96] ldpd: be more conservative with labels On unstable networks, routes can be lost and relearned very often. If we deallocate the input label every time a route is lost and allocate a new one when the route is relearned, a lot of changes are made in vain. This patch introduces a logic in which labels are preserved for at least five minutes before being deallocated by the LIB garbage collector. This is consistent with what other implementations do. Signed-off-by: Renato Westphal --- ldpd/lde_lib.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c index db2682a173..b074bf3498 100644 --- a/ldpd/lde_lib.c +++ b/ldpd/lde_lib.c @@ -383,20 +383,23 @@ lde_kernel_update(struct fec *fec) if (LIST_EMPTY(&fn->nexthops)) { RB_FOREACH(ln, nbr_tree, &lde_nbrs) lde_send_labelwithdraw(ln, fn, NULL, NULL); - fn->local_label = NO_LABEL; fn->data = NULL; + + /* + * Do not deallocate the local label now, do that only in the + * LIB garbage collector. This will prevent ldpd from changing + * the input label of some prefixes too often when running on + * an unstable network. Also, restart the garbage collector + * timer so that labels are deallocated only when the network + * is stabilized. + */ + lde_gc_start_timer(); } else { - uint32_t previous_label; - - previous_label = fn->local_label; fn->local_label = lde_update_label(fn); - - if (fn->local_label != NO_LABEL && - fn->local_label != previous_label) { + if (fn->local_label != NO_LABEL && RB_EMPTY(&fn->upstream)) /* FEC.1: perform lsr label distribution procedure */ RB_FOREACH(ln, nbr_tree, &lde_nbrs) lde_send_labelmapping(ln, fn, 1); - } } LIST_FOREACH(fnh, &fn->nexthops, entry) { From 79f62ef746f4cc6e1f9c233a4f1afab86d928d46 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 21 Apr 2017 19:39:11 -0300 Subject: [PATCH 78/96] ldpd: improve ldp_zebra_read_route() Log deleted routes and simplify the code a bit. Signed-off-by: Renato Westphal --- ldpd/ldp_zebra.c | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index fde6e56c64..3320238a05 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -360,6 +360,7 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, struct kroute kr; int nhnum = 0, nhlen; size_t nhmark; + int add = 0; memset(&kr, 0, sizeof(kr)); s = zclient->ibuf; @@ -426,21 +427,14 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, if (CHECK_FLAG(message_flags, ZAPI_MESSAGE_NEXTHOP)) stream_set_getp(s, nhmark); - if (nhnum == 0) { - switch (command) { - case ZEBRA_REDISTRIBUTE_IPV4_ADD: - case ZEBRA_REDISTRIBUTE_IPV6_ADD: - return (0); - case ZEBRA_REDISTRIBUTE_IPV4_DEL: - case ZEBRA_REDISTRIBUTE_IPV6_DEL: - debug_zebra_in("route delete %s/%d (%s)", - log_addr(kr.af, &kr.prefix), kr.prefixlen, - zebra_route_string(type)); - break; - default: - fatalx("ldp_zebra_read_route: unknown command"); - } - } + if (command == ZEBRA_REDISTRIBUTE_IPV4_ADD || + command == ZEBRA_REDISTRIBUTE_IPV6_ADD) + add = 1; + + if (nhnum == 0) + debug_zebra_in("route %s %s/%d (%s)", (add) ? "add" : "delete", + log_addr(kr.af, &kr.prefix), kr.prefixlen, + zebra_route_string(type)); /* loop through all the nexthops */ for (; nhnum > 0; nhnum--) { @@ -457,19 +451,14 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, stream_getc(s); /* ifindex_num, unused. */ kr.ifindex = stream_getl(s); - switch (command) { - case ZEBRA_REDISTRIBUTE_IPV4_ADD: - case ZEBRA_REDISTRIBUTE_IPV6_ADD: - debug_zebra_in("route add %s/%d nexthop %s " - "ifindex %u (%s)", log_addr(kr.af, &kr.prefix), - kr.prefixlen, log_addr(kr.af, &kr.nexthop), - kr.ifindex, zebra_route_string(type)); + debug_zebra_in("route %s %s/%d nexthop %s ifindex %u (%s)", + (add) ? "add" : "delete", log_addr(kr.af, &kr.prefix), + kr.prefixlen, log_addr(kr.af, &kr.nexthop), kr.ifindex, + zebra_route_string(type)); + + if (add) main_imsg_compose_lde(IMSG_NETWORK_ADD, 0, &kr, sizeof(kr)); - break; - default: - break; - } } main_imsg_compose_lde(IMSG_NETWORK_UPDATE, 0, &kr, sizeof(kr)); From abb160061189c9e4a1a8ab28aea4acbd64c32066 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 21 Apr 2017 22:10:42 -0300 Subject: [PATCH 79/96] ldpd: schedule the sending of label messages when necessary Once we send a Label Withdraw, we can't send a Label Mapping for the same FEC until we receive a Label Release from the peer. This is due to some limitations in the LDP algorithms described in Appendix A. ("LDP Label Distribution Procedures") of RFC 5036. To workaround this issue, make it possible to schedule the sending of a Label Mapping as soon as a Label Release is received for the same FEC. The easiest way to test this patch is by typing the "label local advertise explicit-null" command. ldpd will withdraw all null labels using a Wildcard FEC and then send new Label Mappings as soon the corresponding Label Releases are received. Signed-off-by: Renato Westphal --- ldpd/lde.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- ldpd/lde.h | 3 +++ ldpd/lde_lib.c | 36 ++++++++++++++++++++++++++---------- 3 files changed, 72 insertions(+), 14 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index 1c7458ce73..e5d1402832 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -917,10 +917,23 @@ lde_map2fec(struct map *map, struct in_addr lsr_id, struct fec *fec) void lde_send_labelmapping(struct lde_nbr *ln, struct fec_node *fn, int single) { - struct lde_req *lre; - struct lde_map *me; - struct map map; - struct l2vpn_pw *pw; + struct lde_wdraw *lw; + struct lde_map *me; + struct lde_req *lre; + struct map map; + struct l2vpn_pw *pw; + + /* + * We shouldn't send a new label mapping if we have a pending + * label release to receive. In this case, schedule to send a + * label mapping as soon as a label release is received. + */ + lw = (struct lde_wdraw *)fec_find(&ln->sent_wdraw, &fn->fec); + if (lw) { + if (!fec_find(&ln->sent_map_pending, &fn->fec)) + lde_map_pending_add(ln, fn); + return; + } /* * This function skips SL.1 - 3 and SL.9 - 14 because the label @@ -1226,6 +1239,7 @@ lde_nbr_new(uint32_t peerid, struct lde_nbr *new) ln->peerid = peerid; fec_init(&ln->recv_map); fec_init(&ln->sent_map); + fec_init(&ln->sent_map_pending); fec_init(&ln->recv_req); fec_init(&ln->sent_req); fec_init(&ln->sent_wdraw); @@ -1281,6 +1295,7 @@ lde_nbr_del(struct lde_nbr *ln) fec_clear(&ln->recv_map, lde_map_free); fec_clear(&ln->sent_map, lde_map_free); + fec_clear(&ln->sent_map_pending, free); fec_clear(&ln->recv_req, free); fec_clear(&ln->sent_req, free); fec_clear(&ln->sent_wdraw, free); @@ -1431,6 +1446,30 @@ lde_map_free(void *ptr) free(map); } +struct fec * +lde_map_pending_add(struct lde_nbr *ln, struct fec_node *fn) +{ + struct fec *map; + + map = calloc(1, sizeof(*map)); + if (map == NULL) + fatal(__func__); + + *map = fn->fec; + if (fec_insert(&ln->sent_map_pending, map)) + log_warnx("failed to add %s to sent map (pending)", + log_fec(map)); + + return (map); +} + +void +lde_map_pending_del(struct lde_nbr *ln, struct fec *map) +{ + fec_remove(&ln->sent_map_pending, map); + free(map); +} + struct lde_req * lde_req_add(struct lde_nbr *ln, struct fec *fec, int sent) { diff --git a/ldpd/lde.h b/ldpd/lde.h index c1d66f9fff..1cce483832 100644 --- a/ldpd/lde.h +++ b/ldpd/lde.h @@ -95,6 +95,7 @@ struct lde_nbr { struct fec_tree sent_req; struct fec_tree recv_map; struct fec_tree sent_map; + struct fec_tree sent_map_pending; struct fec_tree sent_wdraw; TAILQ_HEAD(, lde_addr) addr_list; }; @@ -171,6 +172,8 @@ struct lde_nbr *lde_nbr_find_by_lsrid(struct in_addr); struct lde_nbr *lde_nbr_find_by_addr(int, union ldpd_addr *); struct lde_map *lde_map_add(struct lde_nbr *, struct fec_node *, int); void lde_map_del(struct lde_nbr *, struct lde_map *, int); +struct fec *lde_map_pending_add(struct lde_nbr *, struct fec_node *); +void lde_map_pending_del(struct lde_nbr *, struct fec *); struct lde_req *lde_req_add(struct lde_nbr *, struct fec *, int); void lde_req_del(struct lde_nbr *, struct lde_req *, int); struct lde_wdraw *lde_wdraw_add(struct lde_nbr *, struct fec_node *); diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c index b074bf3498..37a670bc8c 100644 --- a/ldpd/lde_lib.c +++ b/ldpd/lde_lib.c @@ -662,6 +662,7 @@ lde_check_release(struct map *map, struct lde_nbr *ln) struct fec_node *fn; struct lde_wdraw *lw; struct lde_map *me; + struct fec *pending_map; /* wildcard label release */ if (map->type == MAP_TYPE_WILDCARD || @@ -677,17 +678,24 @@ lde_check_release(struct map *map, struct lde_nbr *ln) if (fn == NULL) return; + /* LRl.6: check sent map list and remove it if available */ + me = (struct lde_map *)fec_find(&ln->sent_map, &fn->fec); + if (me && (map->label == NO_LABEL || map->label == me->map.label)) + lde_map_del(ln, me, 1); + /* LRl.3: first check if we have a pending withdraw running */ lw = (struct lde_wdraw *)fec_find(&ln->sent_wdraw, &fn->fec); if (lw && (map->label == NO_LABEL || map->label == lw->label)) { /* LRl.4: delete record of outstanding label withdraw */ lde_wdraw_del(ln, lw); - } - /* LRl.6: check sent map list and remove it if available */ - me = (struct lde_map *)fec_find(&ln->sent_map, &fn->fec); - if (me && (map->label == NO_LABEL || map->label == me->map.label)) - lde_map_del(ln, me, 1); + /* send pending label mapping if any */ + pending_map = fec_find(&ln->sent_map_pending, &fn->fec); + if (pending_map) { + lde_send_labelmapping(ln, fn, 1); + lde_map_pending_del(ln, pending_map); + } + } /* * LRl.11 - 13 are unnecessary since we remove the label from @@ -702,6 +710,7 @@ lde_check_release_wcard(struct map *map, struct lde_nbr *ln) struct fec_node *fn; struct lde_wdraw *lw; struct lde_map *me; + struct fec *pending_map; RB_FOREACH(f, fec_tree, &ft) { fn = (struct fec_node *)f; @@ -711,17 +720,24 @@ lde_check_release_wcard(struct map *map, struct lde_nbr *ln) if (lde_wildcard_apply(map, &fn->fec, me) == 0) continue; + /* LRl.6: check sent map list and remove it if available */ + if (me && + (map->label == NO_LABEL || map->label == me->map.label)) + lde_map_del(ln, me, 1); + /* LRl.3: first check if we have a pending withdraw running */ lw = (struct lde_wdraw *)fec_find(&ln->sent_wdraw, &fn->fec); if (lw && (map->label == NO_LABEL || map->label == lw->label)) { /* LRl.4: delete record of outstanding lbl withdraw */ lde_wdraw_del(ln, lw); - } - /* LRl.6: check sent map list and remove it if available */ - if (me && - (map->label == NO_LABEL || map->label == me->map.label)) - lde_map_del(ln, me, 1); + /* send pending label mapping if any */ + pending_map = fec_find(&ln->sent_map_pending, &fn->fec); + if (pending_map) { + lde_send_labelmapping(ln, fn, 1); + lde_map_pending_del(ln, pending_map); + } + } /* * LRl.11 - 13 are unnecessary since we remove the label from From cb7426d40354d69a2705ee01240aef8a211cf3db Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 22 Apr 2017 10:55:27 -0300 Subject: [PATCH 80/96] ldpd: allow targeted neighbors over any interface It's doesn't make sense to enforce that a targeted-hello is received on an LDP-enabled interface. It should be possible, for example, to use LDP only to signal pseudowires and other another protocol (e.g. RSVP-TE) to create end-to-end LSPs. Signed-off-by: Renato Westphal --- ldpd/packet.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ldpd/packet.c b/ldpd/packet.c index 75e1a9a027..df6bd8e57a 100644 --- a/ldpd/packet.c +++ b/ldpd/packet.c @@ -27,7 +27,7 @@ #include "sockopt.h" static struct iface *disc_find_iface(unsigned int, int, - union ldpd_addr *, int); + union ldpd_addr *); static int session_read(struct thread *); static int session_write(struct thread *); static ssize_t session_get_pdu(struct ibuf_read *, char **); @@ -134,7 +134,7 @@ disc_recv_packet(struct thread *thread) int af; union ldpd_addr src; unsigned int ifindex = 0; - struct iface *iface; + struct iface *iface = NULL; uint16_t len; struct ldp_hdr ldp_hdr; uint16_t pdu_len; @@ -212,9 +212,11 @@ disc_recv_packet(struct thread *thread) ifindex = getsockopt_ifindex(af, &m); /* find a matching interface */ - iface = disc_find_iface(ifindex, af, &src, multicast); - if (iface == NULL) - return (0); + if (multicast) { + iface = disc_find_iface(ifindex, af, &src); + if (iface == NULL) + return (0); + } /* check packet size */ len = (uint16_t)r; @@ -280,8 +282,7 @@ disc_recv_packet(struct thread *thread) } static struct iface * -disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src, - int multicast) +disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src) { struct iface *iface; struct iface_af *ia; @@ -299,7 +300,7 @@ disc_find_iface(unsigned int ifindex, int af, union ldpd_addr *src, * "Link-local IPv6 address MUST be used as the source IP address in * IPv6 LDP Link Hellos". */ - if (multicast && af == AF_INET6 && !IN6_IS_ADDR_LINKLOCAL(&src->v6)) + if (af == AF_INET6 && !IN6_IS_ADDR_LINKLOCAL(&src->v6)) return (NULL); return (iface); From 602c726ef2a37597d9cba1f0adafc9bc4fc7e3db Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 22 Apr 2017 12:03:14 -0300 Subject: [PATCH 81/96] ldpd: fix bug when changing the transport address When the transport address is changed, all interfaces and targeted neighbors are temporary disabled in the ldpe process until new sockets bound to the new transport address are received from the parent. This patch fixes a problem in which adjacencies weren't being removed after the associated targeted neighbors were disabled. This was causing ldpd not to set some MD5 sockoptions for new neighbors are thus preventing MD5-protected sessions to come up after a change in the transport-address. Signed-off-by: Renato Westphal --- ldpd/adjacency.c | 31 ++++++++++++++++++++++--------- ldpd/interface.c | 9 +++++---- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 8659202ee4..3ec57f1589 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -29,6 +29,8 @@ static __inline int adj_compare(struct adj *, struct adj *); static int adj_itimer(struct thread *); static __inline int tnbr_compare(struct tnbr *, struct tnbr *); static void tnbr_del(struct ldpd_conf *, struct tnbr *); +static void tnbr_start(struct tnbr *); +static void tnbr_stop(struct tnbr *); static int tnbr_hello_timer(struct thread *); static void tnbr_start_hello_timer(struct tnbr *); static void tnbr_stop_hello_timer(struct tnbr *); @@ -245,9 +247,7 @@ tnbr_new(int af, union ldpd_addr *addr) static void tnbr_del(struct ldpd_conf *xconf, struct tnbr *tnbr) { - tnbr_stop_hello_timer(tnbr); - if (tnbr->adj) - adj_del(tnbr->adj, S_SHUTDOWN); + tnbr_stop(tnbr); RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr); free(tnbr); } @@ -273,6 +273,23 @@ tnbr_check(struct ldpd_conf *xconf, struct tnbr *tnbr) return (tnbr); } +static void +tnbr_start(struct tnbr *tnbr) +{ + send_hello(HELLO_TARGETED, NULL, tnbr); + tnbr_start_hello_timer(tnbr); + tnbr->state = TNBR_STA_ACTIVE; +} + +static void +tnbr_stop(struct tnbr *tnbr) +{ + tnbr_stop_hello_timer(tnbr); + if (tnbr->adj) + adj_del(tnbr->adj, S_SHUTDOWN); + tnbr->state = TNBR_STA_DOWN; +} + void tnbr_update(struct tnbr *tnbr) { @@ -292,16 +309,12 @@ tnbr_update(struct tnbr *tnbr) if (!socket_ok || !rtr_id_ok) return; - tnbr->state = TNBR_STA_ACTIVE; - send_hello(HELLO_TARGETED, NULL, tnbr); - - tnbr_start_hello_timer(tnbr); + tnbr_start(tnbr); } else if (tnbr->state == TNBR_STA_ACTIVE) { if (socket_ok && rtr_id_ok) return; - tnbr->state = TNBR_STA_DOWN; - tnbr_stop_hello_timer(tnbr); + tnbr_stop(tnbr); } } diff --git a/ldpd/interface.c b/ldpd/interface.c index 7be8be755e..440bb2dca0 100644 --- a/ldpd/interface.c +++ b/ldpd/interface.c @@ -287,8 +287,9 @@ if_start(struct iface *iface, int af) } send_hello(HELLO_LINK, ia, NULL); - if_start_hello_timer(ia); + ia->state = IF_STA_ACTIVE; + return (0); } @@ -318,9 +319,11 @@ if_reset(struct iface *iface, int af) if_leave_ipv6_group(iface, &global.mcast_addr_v6); break; default: - fatalx("if_start: unknown af"); + fatalx("if_reset: unknown af"); } + ia->state = IF_STA_DOWN; + return (0); } @@ -367,14 +370,12 @@ if_update_af(struct iface_af *ia) !socket_ok || !rtr_id_ok) return; - ia->state = IF_STA_ACTIVE; if_start(ia->iface, ia->af); } else if (ia->state == IF_STA_ACTIVE) { if (ia->enabled && ia->iface->operative && addr_ok && socket_ok && rtr_id_ok) return; - ia->state = IF_STA_DOWN; if_reset(ia->iface, ia->af); } } From 6bbf78cf5278c2b011bcb4f22fd92dbefd113e0e Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 27 Apr 2017 08:56:15 -0300 Subject: [PATCH 82/96] ldpd: fix issues detected by Coverity Scan Signed-off-by: Renato Westphal --- ldpd/lde.c | 10 ++-------- ldpd/ldpe.c | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index e5d1402832..0cfc02d5ba 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -80,10 +80,6 @@ static zebra_capabilities_t _caps_p [] = static struct zebra_privs_t lde_privs = { -#if defined(FRR_USER) && defined(FRR_GROUP) - .user = FRR_USER, - .group = FRR_GROUP, -#endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, #endif @@ -185,10 +181,8 @@ void lde_init(struct ldpd_init *init) { /* drop privileges */ - if (init->user) - lde_privs.user = init->user; - if (init->group) - lde_privs.group = init->group; + lde_privs.user = init->user; + lde_privs.group = init->group; zprivs_init(&lde_privs); #ifdef HAVE_PLEDGE diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 20cc9f7444..017eec2502 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -66,10 +66,6 @@ static zebra_capabilities_t _caps_p [] = struct zebra_privs_t ldpe_privs = { -#if defined(FRR_USER) && defined(FRR_GROUP) - .user = FRR_USER, - .group = FRR_GROUP, -#endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, #endif @@ -143,10 +139,8 @@ void ldpe_init(struct ldpd_init *init) { /* drop privileges */ - if (init->user) - ldpe_privs.user = init->user; - if (init->group) - ldpe_privs.group = init->group; + ldpe_privs.user = init->user; + ldpe_privs.group = init->group; zprivs_init(&ldpe_privs); /* listen on ldpd control socket */ From c18ac4c29a829edd98591931ba4ed827b3569095 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 2 Jun 2017 11:14:54 -0300 Subject: [PATCH 83/96] ldpd: fix bug in pseudowire control-word negotiation Bingen discovered a bug in the pseudowire control-word negotiation that might happen when the "control-word exclude" command is used. Under some very specific conditions, ldpd might ignore a PWID label mapping when it shouldn't. This patch removes a wrong optimization that was preventing ldpd to call l2vpn_pw_reset() every time we change the configuration of a pseudowire. Signed-off-by: Renato Westphal --- ldpd/ldpd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index bdf7097323..f9e44012ef 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -1679,8 +1679,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl) session_shutdown(nbr, S_SHUTDOWN, 0, 0); } } - if (ldpd_process == PROC_LDE_ENGINE && - !reset_nbr && reinstall_pwfec) + if (ldpd_process == PROC_LDE_ENGINE && reinstall_pwfec) l2vpn_pw_exit(pw); pw->lsr_id = xp->lsr_id; pw->af = xp->af; @@ -1702,8 +1701,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl) pw->flags &= ~F_PW_STATIC_NBR_ADDR; if (ldpd_process == PROC_LDP_ENGINE && reinstall_tnbr) ldpe_l2vpn_pw_init(pw); - if (ldpd_process == PROC_LDE_ENGINE && - !reset_nbr && reinstall_pwfec) { + if (ldpd_process == PROC_LDE_ENGINE && reinstall_pwfec) { l2vpn->pw_type = xl->pw_type; l2vpn->mtu = xl->mtu; l2vpn_pw_init(pw); From d23670ca0348f990fdd801bf15904ecf2df569ff Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 5 Jun 2017 14:19:15 -0700 Subject: [PATCH 84/96] redhat: Remove accidental leftover HEAD tag from merge Signed-off-by: Martin Winter --- redhat/frr.spec.in | 1 - 1 file changed, 1 deletion(-) diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index d7cb517ea8..57deeae2ab 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -10,7 +10,6 @@ #################### FRRouting (FRR) configure options ##################### # with-feature options -<<<<<<< HEAD %{!?with_tcp_zebra: %global with_tcp_zebra 0 } %{!?with_pam: %global with_pam 0 } %{!?with_ospfclient: %global with_ospfclient 1 } From 5a76db684adfedef5ae0926686a1d85fe7fff1ac Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Mon, 5 Jun 2017 16:59:20 -0700 Subject: [PATCH 85/96] redhat: Cleanup more merge fixes and add nhrpd/eigrpd to red hat package Signed-off-by: Martin Winter --- redhat/README.rpm_build.md | 2 + redhat/daemons | 4 ++ redhat/frr.init | 2 +- redhat/frr.logrotate | 17 ++++++++ redhat/frr.spec.in | 85 ++++++++++++++++++++++++-------------- 5 files changed, 77 insertions(+), 33 deletions(-) diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index d2b0814364..dd01babf50 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -59,6 +59,8 @@ Building your own FRRouting RPM %{!?with_irdp: %global with_irdp 1 } %{!?with_rtadv: %global with_rtadv 1 } %{!?with_ldpd: %global with_ldpd 1 } + %{!?with_nhrpd: %global with_nhrpd 1 } + %{!?with_eigrp: %global with_eigrpd 1 } %{!?with_shared: %global with_shared 1 } %{!?with_multipath: %global with_multipath 256 } %{!?frr_user: %global frr_user frr } diff --git a/redhat/daemons b/redhat/daemons index ce0f7747a2..e08302cb5c 100644 --- a/redhat/daemons +++ b/redhat/daemons @@ -45,6 +45,8 @@ ripd=no ripngd=no isisd=no ldpd=no +nhrpd=no +eigrpd=no # # Command line options for the daemons # @@ -56,4 +58,6 @@ ripd_options=("-A 127.0.0.1") ripngd_options=("-A ::1") isisd_options=("-A 127.0.0.1") ldpd_options=("-A 127.0.0.1") +nhrpd_options=("-A 127.0.0.1") +eigrpd_options=("-A 127.0.0.1") diff --git a/redhat/frr.init b/redhat/frr.init index 96c0a833af..0a922aab58 100755 --- a/redhat/frr.init +++ b/redhat/frr.init @@ -33,7 +33,7 @@ V_PATH=/var/run/frr # Local Daemon selection may be done by using /etc/frr/daemons. # See /usr/share/doc/frr/README.Debian.gz for further information. # Keep zebra first and do not list watchfrr! -DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd pimd ldpd" +DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd pimd ldpd nhrpd eigrpd" MAX_INSTANCES=5 RELOAD_SCRIPT=/usr/lib/frr/frr-reload.py diff --git a/redhat/frr.logrotate b/redhat/frr.logrotate index 2db3af63dd..f43a86efe7 100644 --- a/redhat/frr.logrotate +++ b/redhat/frr.logrotate @@ -61,3 +61,20 @@ /bin/kill -USR1 `cat /var/run/frr/ldpd.pid 2> /dev/null` 2> /dev/null || true endscript } + +/var/log/frr/nhrpd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/nhrpd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/eigrpd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/eigrpd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + diff --git a/redhat/frr.spec.in b/redhat/frr.spec.in index 57deeae2ab..fea80d7f72 100644 --- a/redhat/frr.spec.in +++ b/redhat/frr.spec.in @@ -10,32 +10,31 @@ #################### FRRouting (FRR) configure options ##################### # with-feature options -%{!?with_tcp_zebra: %global with_tcp_zebra 0 } -%{!?with_pam: %global with_pam 0 } -%{!?with_ospfclient: %global with_ospfclient 1 } -%{!?with_ospfapi: %global with_ospfapi 1 } -%{!?with_irdp: %global with_irdp 1 } -%{!?with_rtadv: %global with_rtadv 1 } -%{!?with_mpls: %global with_mpls 1 } -%{!?with_ldpd: %global with_ldpd 1 } -%{!?with_nhrpd: %global with_nhrpd 1 } -%{!?with_shared: %global with_shared 1 } -%{!?with_multipath: %global with_multipath 256 } -%{!?frr_user: %global frr_user frr } -%{!?vty_group: %global vty_group frrvty } -%{!?with_fpm: %global with_fpm 0 } -%{!?with_watchfrr: %global with_watchfrr 1 } -%{!?with_bgp_vnc: %global with_bgp_vnc 0 } -%{!?with_pimd: %global with_pimd 1 } +%{!?with_tcp_zebra: %global with_tcp_zebra 0 } +%{!?with_pam: %global with_pam 0 } +%{!?with_ospfclient: %global with_ospfclient 1 } +%{!?with_ospfapi: %global with_ospfapi 1 } +%{!?with_irdp: %global with_irdp 1 } +%{!?with_rtadv: %global with_rtadv 1 } +%{!?with_ldpd: %global with_ldpd 1 } +%{!?with_nhrpd: %global with_nhrpd 1 } +%{!?with_eigrpd: %global with_eigrpd 1 } +%{!?with_shared: %global with_shared 1 } +%{!?with_multipath: %global with_multipath 256 } +%{!?frr_user: %global frr_user frr } +%{!?vty_group: %global vty_group frrvty } +%{!?with_fpm: %global with_fpm 0 } +%{!?with_watchfrr: %global with_watchfrr 1 } +%{!?with_bgp_vnc: %global with_bgp_vnc 0 } +%{!?with_pimd: %global with_pimd 1 } # path defines -%define _sysconfdir /etc/frr -%define _sbindir /usr/lib/frr -%define zeb_src %{_builddir}/%{name}-%{frrversion} -%define zeb_rh_src %{zeb_src}/redhat -%define zeb_docs %{zeb_src}/doc -%define frr_tools %{zeb_src}/tools -%define frr_tools_etc %{frr_tools}/etc +%define _sysconfdir /etc/frr +%define _sbindir /usr/lib/frr +%define zeb_src %{_builddir}/%{name}-%{frrversion} +%define zeb_rh_src %{zeb_src}/redhat +%define zeb_docs %{zeb_src}/doc +%define frr_tools %{zeb_src}/tools # defines for configure %define _localstatedir /var/run/frr @@ -83,7 +82,7 @@ %{!?frr_gid: %global frr_gid 92 } %{!?vty_gid: %global vty_gid 85 } -%define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospf6d +%define daemon_list zebra ripd ospfd bgpd isisd ripngd ospf6d %if %{with_ldpd} %define daemon_ldpd ldpd @@ -103,13 +102,19 @@ %define daemon_nhrpd "" %endif +%if %{with_eigrpd} +%define daemon_eigrpd eigrpd +%else +%define daemon_eigrpd "" +%endif + %if %{with_watchfrr} %define daemon_watchfrr watchfrr %else %define daemon_watchfrr "" %endif -%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_nhrpd} %{daemon_watchfrr} +%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_pimd} %{daemon_nhrpd} %{daemon_eigrpd} %{daemon_watchfrr} # allow build dir to be kept %{!?keep_build: %global keep_build 0 } @@ -155,7 +160,7 @@ protocol. It takes multi-server and multi-thread approach to resolve the current complexity of the Internet. FRRouting supports BGP4, OSPFv2, OSPFv3, ISIS, RIP, RIPng, PIM, LDP -and NHRP. +NHRP and EIGRP. FRRouting is a fork of Quagga. @@ -251,6 +256,11 @@ developing OSPF-API and frr applications. %else --disable-nhrpd \ %endif +%if %{with_eigrpd} + --enable-eigrpd \ +%else + --disable-eigrpd \ +%endif %if %{with_pam} --with-libpam \ %endif @@ -317,9 +327,7 @@ install %{zeb_rh_src}/frr.init \ %{buildroot}/etc/rc.d/init.d/frr %endif -install %{frr_tools_dir}/frr/daemons.conf %{buildroot}/etc/frr -install %{frr_tools_dir}/frr/daemons %{buildroot}/etc/frr -install -m644 %{frr_tools_dir}/default/frr %{buildroot}/etc/default +install %{zeb_rh_src}/daemons %{buildroot}/etc/frr install -m644 %{zeb_rh_src}/frr.pam \ %{buildroot}/etc/pam.d/frr install -m644 %{zeb_rh_src}/frr.logrotate \ @@ -374,6 +382,9 @@ zebra_spec_add_service ospf6d 2606/tcp "OSPF6d vty" zebra_spec_add_service ospfapi 2607/tcp "OSPF-API" %endif zebra_spec_add_service isisd 2608/tcp "ISISd vty" +%if %{with_eigrpd} +zebra_spec_add_service eigrpd 2609/tcp "EIGRPd vty" +%endif %if %{with_nhrpd} zebra_spec_add_service nhrpd 2610/tcp "NHRPd vty" %endif @@ -515,8 +526,11 @@ rm -rf %{buildroot} %if %{with_ldpd} %{_sbindir}/ldpd %endif +%if %{with_eigrpd} + %{_sbindir}/eigrpd +%endif %if %{with_nhrpd} -%{_sbindir}/nhrpd + %{_sbindir}/nhrpd %endif %if %{with_shared} %{_libdir}/lib*.so @@ -560,9 +574,16 @@ rm -rf %{buildroot} %dir %attr(755,root,root) %{_includedir}/%{name}/ospfapi %{_includedir}/%name/ospfapi/*.h %endif +%if %{with_eigrpd} +%dir %attr(755,root,root) %{_includedir}/%{name}/eigrpd +%{_includedir}/%name/eigrpd/*.h +%endif %changelog -* Mon Apr 17 2017 Martin Winter - %{version} +* Mon Jun 5 2017 Martin Winter - %{version} +- added NHRP and EIGRP daemon + +* Mon Apr 17 2017 Martin Winter - new subpackage frr-pythontools with python 2.7 restart script - remove PIMd from CentOS/RedHat 6 RPM packages (won't work - too old) - converted to single frr init script (not per daemon) based on debian init script From 72a83d6daa28f6eadb17114d0fda97e7de168d86 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Mon, 5 Jun 2017 18:21:52 -0700 Subject: [PATCH 86/96] pimd: fix pim bfd crash and bfd neigh down During running config, all IFPs are traversed, bfd interface config write need to check for ifp->info null in case pim info is missing and skip the interface. bfd update for address change need to check if particular pim neighbor's address matches with bfd address update Signed-off-by: Chirag Shah --- pimd/pim_bfd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index b0915fa628..938e35e81a 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -44,6 +44,9 @@ pim_bfd_write_config (struct vty *vty, struct interface *ifp) struct pim_interface *pim_ifp = ifp->info; struct bfd_info *bfd_info = NULL; + if (!pim_ifp) + return; + bfd_info = (struct bfd_info *) pim_ifp->bfd_info; if (!bfd_info) return; @@ -194,6 +197,8 @@ pim_bfd_if_param_set (struct interface *ifp, u_int32_t min_rx, struct pim_interface *pim_ifp = ifp->info; int command = 0; + if (!pim_ifp) + return; bfd_set_param ((struct bfd_info **) &(pim_ifp->bfd_info), min_rx, min_tx, detect_mult, defaults, &command); @@ -259,6 +264,10 @@ pim_bfd_interface_dest_update (int command, struct zclient *zclient, for (ALL_LIST_ELEMENTS (pim_ifp->pim_neighbor_list, neigh_node, neigh_nextnode, neigh)) { + /* Check neigh address matches with BFD address */ + if (neigh->source_addr.s_addr != p.u.prefix4.s_addr) + continue; + bfd_info = (struct bfd_info *) neigh->bfd_info; if (bfd_info->status == status) { From d990e3847c1fbad25bdfa2727f156d9acc56ec3f Mon Sep 17 00:00:00 2001 From: Don Slice Date: Fri, 2 Jun 2017 12:22:53 -0700 Subject: [PATCH 87/96] bgpd: add "set label-index" route-map option Added the ability to set the label-index value based on criteria other than the network statement. Manual testing looks good and added to the ticket. Ticket: CM-16513 Signed-off-by: Don Slice Reviewed-by: CCR-6339 --- bgpd/bgp_route.c | 16 +++++------ bgpd/bgp_routemap.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index b3e1f8b27e..fd5e7f2633 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -5017,7 +5017,7 @@ DEFUN (bgp_network_mask_natural_backdoor, DEFUN (bgp_network_label_index, bgp_network_label_index_cmd, - "network A.B.C.D/M label-index (0-4294967294)", + "network A.B.C.D/M label-index (0-471788)", "Specify a network to announce via BGP\n" "IP prefix /, e.g., 35.0.0.0/8\n" "Label index to associate with the prefix\n" @@ -5032,7 +5032,7 @@ DEFUN (bgp_network_label_index, DEFUN (bgp_network_label_index_route_map, bgp_network_label_index_route_map_cmd, - "network A.B.C.D/M label-index (0-4294967294) route-map WORD", + "network A.B.C.D/M label-index (0-471788) route-map WORD", "Specify a network to announce via BGP\n" "IP prefix\n" "Label index to associate with the prefix\n" @@ -5117,7 +5117,7 @@ DEFUN (no_bgp_network_mask_natural, ALIAS (no_bgp_network, no_bgp_network_label_index_cmd, - "no network A.B.C.D/M label-index (0-4294967294)", + "no network A.B.C.D/M label-index (0-471788)", NO_STR "Specify a network to announce via BGP\n" "IP prefix /, e.g., 35.0.0.0/8\n" @@ -5126,7 +5126,7 @@ ALIAS (no_bgp_network, ALIAS (no_bgp_network, no_bgp_network_label_index_route_map_cmd, - "no network A.B.C.D/M label-index (0-4294967294) route-map WORD", + "no network A.B.C.D/M label-index (0-471788) route-map WORD", NO_STR "Specify a network to announce via BGP\n" "IP prefix\n" @@ -5164,7 +5164,7 @@ DEFUN (ipv6_bgp_network_route_map, DEFUN (ipv6_bgp_network_label_index, ipv6_bgp_network_label_index_cmd, - "network X:X::X:X/M label-index (0-4294967294)", + "network X:X::X:X/M label-index (0-471788)", "Specify a network to announce via BGP\n" "IPv6 prefix /\n" "Label index to associate with the prefix\n" @@ -5179,7 +5179,7 @@ DEFUN (ipv6_bgp_network_label_index, DEFUN (ipv6_bgp_network_label_index_route_map, ipv6_bgp_network_label_index_route_map_cmd, - "network X:X::X:X/M label-index (0-4294967294) route-map WORD", + "network X:X::X:X/M label-index (0-471788) route-map WORD", "Specify a network to announce via BGP\n" "IPv6 prefix\n" "Label index to associate with the prefix\n" @@ -5209,7 +5209,7 @@ DEFUN (no_ipv6_bgp_network, ALIAS (no_ipv6_bgp_network, no_ipv6_bgp_network_label_index_cmd, - "no network X:X::X:X/M label-index (0-4294967294)", + "no network X:X::X:X/M label-index (0-471788)", NO_STR "Specify a network to announce via BGP\n" "IPv6 prefix /\n" @@ -5218,7 +5218,7 @@ ALIAS (no_ipv6_bgp_network, ALIAS (no_ipv6_bgp_network, no_ipv6_bgp_network_label_index_route_map_cmd, - "no network X:X::X:X/M label-index (0-4294967294) route-map WORD", + "no network X:X::X:X/M label-index (0-471788) route-map WORD", NO_STR "Specify a network to announce via BGP\n" "IPv6 prefix\n" diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 570fcc1a34..f3f71253b1 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2207,6 +2207,41 @@ static struct route_map_rule_cmd route_set_tag_cmd = route_map_rule_tag_free, }; +/* Set label-index to object. object must be pointer to struct bgp_info */ +static route_map_result_t +route_set_label_index (void *rule, struct prefix *prefix, + route_map_object_t type, void *object) +{ + struct rmap_value *rv; + struct bgp_info *bgp_info; + u_int32_t label_index; + + if (type == RMAP_BGP) + { + /* Fetch routemap's rule information. */ + rv = rule; + bgp_info = object; + + /* Set label-index value. */ + label_index = rv->value; + if (label_index) + { + (bgp_attr_extra_get (bgp_info->attr))->label_index = label_index; + bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_PREFIX_SID); + } + } + + return RMAP_OKAY; +} + +/* Route map commands for label-index set. */ +static struct route_map_rule_cmd route_set_label_index_cmd = +{ + "label-index", + route_set_label_index, + route_value_compile, + route_value_free, +}; /* `match ipv6 address IP_ACCESS_LIST' */ @@ -3654,6 +3689,33 @@ DEFUN (no_set_weight, argv[idx_weight]->arg); } +DEFUN (set_label_index, + set_label_index_cmd, + "set label-index (0-471788)", + SET_STR + "Label index to associate with the prefix\n" + "Label index value\n") +{ + int idx_number = 2; + return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), "label-index", + argv[idx_number]->arg); +} + +DEFUN (no_set_label_index, + no_set_label_index_cmd, + "no set label-index [(0-471788)]", + NO_STR + SET_STR + "Label index to associate with the prefix\n" + "Label index value\n") +{ + int idx_label_index = 3; + if (argc <= idx_label_index) + return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), + "label-index", NULL); + return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), "label-index", + argv[idx_label_index]->arg); +} DEFUN (set_aspath_prepend_asn, set_aspath_prepend_asn_cmd, @@ -4549,6 +4611,7 @@ bgp_route_map_init (void) route_map_install_set (&route_set_ip_nexthop_cmd); route_map_install_set (&route_set_local_pref_cmd); route_map_install_set (&route_set_weight_cmd); + route_map_install_set (&route_set_label_index_cmd); route_map_install_set (&route_set_metric_cmd); route_map_install_set (&route_set_aspath_prepend_cmd); route_map_install_set (&route_set_aspath_exclude_cmd); @@ -4565,6 +4628,7 @@ bgp_route_map_init (void) route_map_install_set (&route_set_ecommunity_rt_cmd); route_map_install_set (&route_set_ecommunity_soo_cmd); route_map_install_set (&route_set_tag_cmd); + route_map_install_set (&route_set_label_index_cmd); install_element (RMAP_NODE, &match_peer_cmd); install_element (RMAP_NODE, &match_peer_local_cmd); @@ -4594,7 +4658,9 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &set_local_pref_cmd); install_element (RMAP_NODE, &no_set_local_pref_cmd); install_element (RMAP_NODE, &set_weight_cmd); + install_element (RMAP_NODE, &set_label_index_cmd); install_element (RMAP_NODE, &no_set_weight_cmd); + install_element (RMAP_NODE, &no_set_label_index_cmd); install_element (RMAP_NODE, &set_aspath_prepend_asn_cmd); install_element (RMAP_NODE, &set_aspath_prepend_lastas_cmd); install_element (RMAP_NODE, &set_aspath_exclude_cmd); From 82fc5591f440ee9810ce2c5d90d41a9f419062c8 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 5 Jun 2017 20:18:48 +0000 Subject: [PATCH 88/96] lib: allow infinite sleep in poll() If fd_poll() is called with no file descriptors, an incorrect check in the function prelude causes it to return instantly; for a thread that wishes to poll but has no file descriptors, this results in busy waiting. Desired behavior is to block. Signed-off-by: Quentin Young --- lib/thread.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/thread.c b/lib/thread.c index 848e39e1ae..2280b96316 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -647,9 +647,6 @@ static int fd_poll (struct thread_master *m, struct pollfd *pfds, nfds_t pfdsize, nfds_t count, struct timeval *timer_wait) { - if (count == 0) - return 0; - /* If timer_wait is null here, that means poll() should block indefinitely, * unless the thread_master has overriden it by setting ->selectpoll_timeout. * If the value is positive, it specifies the maximum number of milliseconds From c7fb183833c81f9f6199272585882a635816c666 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 2 Jun 2017 20:53:37 +0000 Subject: [PATCH 89/96] bgpd: fix addpath buffer overrun Signed-off-by: Quentin Young [DL: removed compile_commands.json] --- bgpd/bgp_debug.c | 11 +++++++---- bgpd/bgp_updgrp_packet.c | 35 +++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index f4722e62dc..a39ec90cc6 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -40,8 +40,6 @@ #include "bgpd/bgp_updgrp.h" #include "bgpd/bgp_mplsvpn.h" -#define BGP_ADDPATH_STR 20 - unsigned long conf_bgp_debug_as4; unsigned long conf_bgp_debug_neighbor_events; unsigned long conf_bgp_debug_events; @@ -2139,7 +2137,12 @@ bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, { char rd_buf[RD_ADDRSTRLEN]; char pfx_buf[PREFIX_STRLEN]; - char pathid_buf[BGP_ADDPATH_STR]; + /* ' with addpath ID ' 17 + * max strlen of uint32 + 10 + * +/- (just in case) + 1 + * null terminator + 1 + * ============================ 29 */ + char pathid_buf[30]; if (size < BGP_PRD_PATH_STRLEN) return NULL; @@ -2147,7 +2150,7 @@ bgp_debug_rdpfxpath2str (struct prefix_rd *prd, union prefixconstptr pu, /* Note: Path-id is created by default, but only included in update sometimes. */ pathid_buf[0] = '\0'; if (addpath_valid) - sprintf(pathid_buf, " with addpath ID %d", addpath_id); + snprintf(pathid_buf, sizeof(pathid_buf), " with addpath ID %u", addpath_id); if (prd) snprintf (str, size, "RD %s %s%s", diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index 7a45cddca9..567e1e927e 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -651,17 +651,6 @@ subgroup_packets_to_build (struct update_subgroup *subgrp) return 0; } -static void -bgp_info_addpath_tx_str (int addpath_encode, u_int32_t addpath_tx_id, - char *buf) -{ - buf[0] = '\0'; - if (addpath_encode) - sprintf(buf, " with addpath ID %d", addpath_tx_id); - else - buf[0] = '\0'; -} - /* Make BGP update packet. */ struct bpacket * subgroup_update_packet (struct update_subgroup *subgrp) @@ -1079,11 +1068,21 @@ subgroup_default_update_packet (struct update_subgroup *subgrp, { char attrstr[BUFSIZ]; char buf[PREFIX_STRLEN]; + /* ' with addpath ID ' 17 + * max strlen of uint32 + 10 + * +/- (just in case) + 1 + * null terminator + 1 + * ============================ 29 */ char tx_id_buf[30]; + attrstr[0] = '\0'; bgp_dump_attr (attr, attrstr, BUFSIZ); - bgp_info_addpath_tx_str (addpath_encode, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, tx_id_buf); + + if (addpath_encode) + snprintf(tx_id_buf, sizeof (tx_id_buf), " with addpath ID %u", + BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE); + zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s%s %s", (SUBGRP_UPDGRP (subgrp))->id, subgrp->id, prefix2str (&p, buf, sizeof (buf)), @@ -1153,9 +1152,17 @@ subgroup_default_withdraw_packet (struct update_subgroup *subgrp) if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) { char buf[PREFIX_STRLEN]; - char tx_id_buf[INET6_BUFSIZ]; + /* ' with addpath ID ' 17 + * max strlen of uint32 + 10 + * +/- (just in case) + 1 + * null terminator + 1 + * ============================ 29 */ + char tx_id_buf[30]; + + if (addpath_encode) + snprintf(tx_id_buf, sizeof (tx_id_buf), " with addpath ID %u", + BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE); - bgp_info_addpath_tx_str (addpath_encode, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE, tx_id_buf); zlog_debug ("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s%s -- unreachable", (SUBGRP_UPDGRP (subgrp))->id, subgrp->id, prefix2str (&p, buf, sizeof (buf)), tx_id_buf); From 8b81993eb3c1236baa82e2388f4c85183df5eb33 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Tue, 6 Jun 2017 09:29:30 -0700 Subject: [PATCH 90/96] bgpd: set bgp label-index range to (0-1048560) Based on suggestions made in the FRR technical meeting, making the label-index range 2^20-16 for the max label size minus the reserved labels. Ticket: CM-16513 Signed-off-by: Don Slice --- bgpd/bgp_route.c | 16 ++++++++-------- bgpd/bgp_routemap.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index fd5e7f2633..0e27e47a6c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -5017,7 +5017,7 @@ DEFUN (bgp_network_mask_natural_backdoor, DEFUN (bgp_network_label_index, bgp_network_label_index_cmd, - "network A.B.C.D/M label-index (0-471788)", + "network A.B.C.D/M label-index (0-1048560)", "Specify a network to announce via BGP\n" "IP prefix /, e.g., 35.0.0.0/8\n" "Label index to associate with the prefix\n" @@ -5032,7 +5032,7 @@ DEFUN (bgp_network_label_index, DEFUN (bgp_network_label_index_route_map, bgp_network_label_index_route_map_cmd, - "network A.B.C.D/M label-index (0-471788) route-map WORD", + "network A.B.C.D/M label-index (0-1048560) route-map WORD", "Specify a network to announce via BGP\n" "IP prefix\n" "Label index to associate with the prefix\n" @@ -5117,7 +5117,7 @@ DEFUN (no_bgp_network_mask_natural, ALIAS (no_bgp_network, no_bgp_network_label_index_cmd, - "no network A.B.C.D/M label-index (0-471788)", + "no network A.B.C.D/M label-index (0-1048560)", NO_STR "Specify a network to announce via BGP\n" "IP prefix /, e.g., 35.0.0.0/8\n" @@ -5126,7 +5126,7 @@ ALIAS (no_bgp_network, ALIAS (no_bgp_network, no_bgp_network_label_index_route_map_cmd, - "no network A.B.C.D/M label-index (0-471788) route-map WORD", + "no network A.B.C.D/M label-index (0-1048560) route-map WORD", NO_STR "Specify a network to announce via BGP\n" "IP prefix\n" @@ -5164,7 +5164,7 @@ DEFUN (ipv6_bgp_network_route_map, DEFUN (ipv6_bgp_network_label_index, ipv6_bgp_network_label_index_cmd, - "network X:X::X:X/M label-index (0-471788)", + "network X:X::X:X/M label-index (0-1048560)", "Specify a network to announce via BGP\n" "IPv6 prefix /\n" "Label index to associate with the prefix\n" @@ -5179,7 +5179,7 @@ DEFUN (ipv6_bgp_network_label_index, DEFUN (ipv6_bgp_network_label_index_route_map, ipv6_bgp_network_label_index_route_map_cmd, - "network X:X::X:X/M label-index (0-471788) route-map WORD", + "network X:X::X:X/M label-index (0-1048560) route-map WORD", "Specify a network to announce via BGP\n" "IPv6 prefix\n" "Label index to associate with the prefix\n" @@ -5209,7 +5209,7 @@ DEFUN (no_ipv6_bgp_network, ALIAS (no_ipv6_bgp_network, no_ipv6_bgp_network_label_index_cmd, - "no network X:X::X:X/M label-index (0-471788)", + "no network X:X::X:X/M label-index (0-1048560)", NO_STR "Specify a network to announce via BGP\n" "IPv6 prefix /\n" @@ -5218,7 +5218,7 @@ ALIAS (no_ipv6_bgp_network, ALIAS (no_ipv6_bgp_network, no_ipv6_bgp_network_label_index_route_map_cmd, - "no network X:X::X:X/M label-index (0-471788) route-map WORD", + "no network X:X::X:X/M label-index (0-1048560) route-map WORD", NO_STR "Specify a network to announce via BGP\n" "IPv6 prefix\n" diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index f3f71253b1..6c6b622626 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3691,7 +3691,7 @@ DEFUN (no_set_weight, DEFUN (set_label_index, set_label_index_cmd, - "set label-index (0-471788)", + "set label-index (0-1048560)", SET_STR "Label index to associate with the prefix\n" "Label index value\n") @@ -3703,7 +3703,7 @@ DEFUN (set_label_index, DEFUN (no_set_label_index, no_set_label_index_cmd, - "no set label-index [(0-471788)]", + "no set label-index [(0-1048560)]", NO_STR SET_STR "Label index to associate with the prefix\n" From 43cf4ba452fd9f9c2adaf36e3d5487dae7a1fb99 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 7 Jun 2017 15:43:23 -0400 Subject: [PATCH 91/96] zebra: Fix the metaq to be aware of all routing protocols we could see Signed-off-by: Donald Sharp --- zebra/rib.h | 2 +- zebra/zebra_rib.c | 36 +++++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/zebra/rib.h b/zebra/rib.h index 3f4fb81f6d..88f2bf39ab 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -99,7 +99,7 @@ struct route_entry /* meta-queue structure: * sub-queue 0: connected, kernel * sub-queue 1: static - * sub-queue 2: RIP, RIPng, OSPF, OSPF6, IS-IS + * sub-queue 2: RIP, RIPng, OSPF, OSPF6, IS-IS, EIGRP, NHRP * sub-queue 3: iBGP, eBGP * sub-queue 4: any other origin (if any) */ diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index ca15d7eadc..ae514ad94a 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1845,19 +1845,29 @@ meta_queue_process (struct work_queue *dummy, void *data) * 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_NHRP] = 2, - [ZEBRA_ROUTE_BGP] = 3, - [ZEBRA_ROUTE_HSLS] = 4, - [ZEBRA_ROUTE_TABLE] = 1, + [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_PIM] = 4, // Shouldn't happen but for safety + [ZEBRA_ROUTE_EIGRP] = 2, + [ZEBRA_ROUTE_NHRP] = 2, + [ZEBRA_ROUTE_HSLS] = 4, + [ZEBRA_ROUTE_OLSR] = 4, + [ZEBRA_ROUTE_TABLE] = 1, + [ZEBRA_ROUTE_LDP] = 4, + [ZEBRA_ROUTE_VNC] = 3, + [ZEBRA_ROUTE_VNC_DIRECT] = 3, + [ZEBRA_ROUTE_VNC_DIRECT_RH] = 3, + [ZEBRA_ROUTE_BGP_DIRECT] = 3, + [ZEBRA_ROUTE_BGP_DIRECT_EXT] = 3, + [ZEBRA_ROUTE_ALL] = 4, // Shouldn't happen but for safety }; /* Look into the RN and queue it into one or more priority queues, From 1152f4866964f693b59ba4a73fb6c6ac654884f7 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 7 Jun 2017 15:47:35 -0400 Subject: [PATCH 92/96] lib: Add some breadcrumbs for new route types Signed-off-by: Donald Sharp --- lib/route_types.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/route_types.txt b/lib/route_types.txt index 7625d1f690..d26211e1ac 100644 --- a/lib/route_types.txt +++ b/lib/route_types.txt @@ -39,7 +39,10 @@ # # Long description: Full description, but should try fit on a line. #### - +# +# If you add a new routing protocol here, make sure you go update +# meta_queue_map in zebra_rib.c +# ## type cname daemon C 4 6 short help ZEBRA_ROUTE_SYSTEM, system, NULL, 'X', 0, 0, "Reserved" ZEBRA_ROUTE_KERNEL, kernel, zebra, 'K', 1, 1, "kernel route" From f0725ca87c28f1de4c77fc176a0f14a71967a8ce Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 7 Jun 2017 18:57:46 -0400 Subject: [PATCH 93/96] bgpd: Fix missing newline Signed-off-by: Donald Sharp --- bgpd/rfapi/bgp_rfapi_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 6002046bcd..2caaa5ce38 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -3385,7 +3385,7 @@ DEFUN (vnc_vrf_policy_nexthop, "Specify next hop to use for VRF advertised prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" - "Use configured router-id (default)") + "Use configured router-id (default)\n") { VTY_DECLVAR_CONTEXT_SUB(rfapi_nve_group_cfg, rfg); struct prefix p; From a587d00bace8e675b897abda12e8b2a0fc752b11 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 8 Jun 2017 01:53:50 +0000 Subject: [PATCH 94/96] *: remove THREAD_BACKGROUND it's just an alias for a millisecond timer used in exactly nine places and serves only to complicate Signed-off-by: Quentin Young --- bgpd/bgp_updgrp.c | 4 +- bgpd/rfapi/rfapi_import.c | 2 +- lib/thread.c | 74 +++-------------------------------- lib/thread.h | 12 +----- lib/workqueue.c | 4 +- tests/lib/test_heavy_thread.c | 4 +- zebra/zebra_fpm.c | 10 ++--- 7 files changed, 19 insertions(+), 91 deletions(-) diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 04d262050f..287323bda9 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -1169,8 +1169,8 @@ update_subgroup_trigger_merge_check (struct update_subgroup *subgrp, return 0; subgrp->t_merge_check = NULL; - thread_add_background(bm->master, update_subgroup_merge_check_thread_cb, subgrp, 0, - &subgrp->t_merge_check); + thread_add_timer_msec (bm->master, update_subgroup_merge_check_thread_cb, subgrp, + 0, &subgrp->t_merge_check); SUBGRP_INCR_STAT (subgrp, merge_checks_triggered); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 741ad7d705..cefb9ef85a 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -3051,7 +3051,7 @@ rfapiBiStartWithdrawTimer ( lifetime_msec = (lifetime * 1000) + jitter; bi->extra->vnc.import.timer = NULL; - thread_add_background(bm->master, timer_service_func, wcb, lifetime_msec, + thread_add_timer_msec(bm->master, timer_service_func, wcb, lifetime_msec, &bi->extra->vnc.import.timer); } diff --git a/lib/thread.c b/lib/thread.c index 8c54ec6cea..bf3500fd8b 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -96,13 +96,12 @@ vty_out_cpu_thread_history(struct vty* vty, a->total_active, a->cpu.total/1000, a->cpu.total%1000, a->total_calls, a->cpu.total/a->total_calls, a->cpu.max, a->real.total/a->total_calls, a->real.max); - vty_out(vty, " %c%c%c%c%c%c %s%s", + vty_out(vty, " %c%c%c%c%c %s%s", a->types & (1 << THREAD_READ) ? 'R':' ', a->types & (1 << THREAD_WRITE) ? 'W':' ', a->types & (1 << THREAD_TIMER) ? 'T':' ', a->types & (1 << THREAD_EVENT) ? 'E':' ', a->types & (1 << THREAD_EXECUTE) ? 'X':' ', - a->types & (1 << THREAD_BACKGROUND) ? 'B' : ' ', a->funcname, VTY_NEWLINE); } @@ -195,10 +194,6 @@ DEFUN (show_thread_cpu, case 'X': filter |= (1 << THREAD_EXECUTE); break; - case 'b': - case 'B': - filter |= (1 << THREAD_BACKGROUND); - break; default: break; } @@ -287,10 +282,6 @@ DEFUN (clear_thread_cpu, case 'X': filter |= (1 << THREAD_EXECUTE); break; - case 'b': - case 'B': - filter |= (1 << THREAD_BACKGROUND); - break; default: break; } @@ -379,9 +370,8 @@ thread_master_create (void) /* Initialize the timer queues */ rv->timer = pqueue_create(); - rv->background = pqueue_create(); - rv->timer->cmp = rv->background->cmp = thread_timer_cmp; - rv->timer->update = rv->background->update = thread_timer_update; + rv->timer->cmp = thread_timer_cmp; + rv->timer->update = thread_timer_update; rv->spin = true; rv->handle_signals = true; rv->owner = pthread_self(); @@ -540,7 +530,6 @@ thread_master_free (struct thread_master *m) thread_list_free (m, &m->event); thread_list_free (m, &m->ready); thread_list_free (m, &m->unuse); - thread_queue_free (m, m->background); pthread_mutex_destroy (&m->mtx); close (m->io_pipe[0]); close (m->io_pipe[1]); @@ -757,7 +746,7 @@ funcname_thread_add_timer_timeval (struct thread_master *m, assert (m != NULL); - assert (type == THREAD_TIMER || type == THREAD_BACKGROUND); + assert (type == THREAD_TIMER); assert (time_relative); pthread_mutex_lock (&m->mtx); @@ -768,7 +757,7 @@ funcname_thread_add_timer_timeval (struct thread_master *m, return NULL; } - queue = ((type == THREAD_TIMER) ? m->timer : m->background); + queue = m->timer; thread = thread_get (m, type, func, arg, debugargpass); pthread_mutex_lock (&thread->mtx); @@ -836,31 +825,6 @@ funcname_thread_add_timer_tv (struct thread_master *m, t_ptr, debugargpass); } -/* Add a background thread, with an optional millisec delay */ -struct thread * -funcname_thread_add_background (struct thread_master *m, - int (*func) (struct thread *), void *arg, long delay, - struct thread **t_ptr, debugargdef) -{ - struct timeval trel; - - assert (m != NULL); - - if (delay) - { - trel.tv_sec = delay / 1000; - trel.tv_usec = 1000*(delay % 1000); - } - else - { - trel.tv_sec = 0; - trel.tv_usec = 0; - } - - return funcname_thread_add_timer_timeval (m, func, THREAD_BACKGROUND, arg, &trel, - t_ptr, debugargpass); -} - /* Add simple event thread. */ struct thread * funcname_thread_add_event (struct thread_master *m, @@ -957,9 +921,6 @@ thread_cancel (struct thread *thread) case THREAD_READY: list = &thread->master->ready; break; - case THREAD_BACKGROUND: - queue = thread->master->background; - break; default: goto done; break; @@ -1181,9 +1142,7 @@ thread_fetch (struct thread_master *m, struct thread *fetch) struct thread *thread; struct timeval now; struct timeval timer_val = { .tv_sec = 0, .tv_usec = 0 }; - struct timeval timer_val_bg; struct timeval *timer_wait = &timer_val; - struct timeval *timer_wait_bg; do { @@ -1218,11 +1177,6 @@ thread_fetch (struct thread_master *m, struct thread *fetch) if (m->ready.count == 0) { timer_wait = thread_timer_wait (m->timer, &timer_val); - timer_wait_bg = thread_timer_wait (m->background, &timer_val_bg); - - if (timer_wait_bg && - (!timer_wait || (timercmp (timer_wait, timer_wait_bg, >)))) - timer_wait = timer_wait_bg; } if (timer_wait && timer_wait->tv_sec < 0) @@ -1263,24 +1217,6 @@ thread_fetch (struct thread_master *m, struct thread *fetch) if (num > 0) thread_process_io (m, m->handler.copy, num, count); -#if 0 - /* If any threads were made ready above (I/O or foreground timer), - perhaps we should avoid adding background timers to the ready - list at this time. If this is code is uncommented, then background - timer threads will not run unless there is nothing else to do. */ - if ((thread = thread_trim_head (&m->ready)) != NULL) - { - fetch = thread_run (m, thread, fetch); - if (fetch->ref) - *fetch->ref = NULL; - pthread_mutex_unlock (&m->mtx); - return fetch; - } -#endif - - /* Background timer/events, lowest priority */ - thread_process_timers (m->background, &now); - if ((thread = thread_trim_head (&m->ready)) != NULL) { fetch = thread_run (m, thread, fetch); diff --git a/lib/thread.h b/lib/thread.h index 608fb8b8c0..86f839810f 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -68,7 +68,6 @@ struct thread_master struct thread_list event; struct thread_list ready; struct thread_list unuse; - struct pqueue *background; int io_pipe[2]; int fd_limit; struct fd_handler handler; @@ -131,9 +130,8 @@ struct cpu_thread_history #define THREAD_TIMER 2 #define THREAD_EVENT 3 #define THREAD_READY 4 -#define THREAD_BACKGROUND 5 -#define THREAD_UNUSED 6 -#define THREAD_EXECUTE 7 +#define THREAD_UNUSED 5 +#define THREAD_EXECUTE 6 /* Thread yield time. */ #define THREAD_YIELD_TIME_SLOT 10 * 1000L /* 10ms */ @@ -166,9 +164,6 @@ struct cpu_thread_history #define thread_add_event(m,f,a,v,t) funcname_thread_add_event(m,f,a,v,t,#f,__FILE__,__LINE__) #define thread_execute(m,f,a,v) funcname_thread_execute(m,f,a,v,#f,__FILE__,__LINE__) -/* The 4th arg to thread_add_background is the # of milliseconds to delay. */ -#define thread_add_background(m,f,a,v,t) funcname_thread_add_background(m,f,a,v,t,#f,__FILE__,__LINE__) - /* Prototypes. */ extern struct thread_master *thread_master_create (void); extern void thread_master_free (struct thread_master *); @@ -189,9 +184,6 @@ extern struct thread * funcname_thread_add_timer_tv (struct thread_master *, extern struct thread * funcname_thread_add_event (struct thread_master *, int (*)(struct thread *), void *, int, struct thread **, debugargdef); -extern struct thread * funcname_thread_add_background (struct thread_master *, - int (*)(struct thread *), void *, long, struct thread **, debugargdef); - extern void funcname_thread_execute (struct thread_master *, int (*)(struct thread *), void *, int, debugargdef); #undef debugargdef diff --git a/lib/workqueue.c b/lib/workqueue.c index f992588399..8a06502894 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -126,8 +126,8 @@ work_queue_schedule (struct work_queue *wq, unsigned int delay) && (listcount (wq->items) > 0) ) { wq->thread = NULL; - thread_add_background(wq->master, work_queue_run, wq, delay, - &wq->thread); + thread_add_timer_msec (wq->master, work_queue_run, wq, delay, + &wq->thread); /* set thread yield time, if needed */ if (wq->thread && wq->spec.yield != THREAD_YIELD_TIME_SLOT) thread_set_yield_time (wq->thread, wq->spec.yield); diff --git a/tests/lib/test_heavy_thread.c b/tests/lib/test_heavy_thread.c index 3b85619d3a..b39b3b7d46 100644 --- a/tests/lib/test_heavy_thread.c +++ b/tests/lib/test_heavy_thread.c @@ -90,7 +90,7 @@ clear_something (struct thread *thread) ws->i++; if (thread_should_yield(thread)) { - thread_add_background(master, clear_something, ws, 0, NULL); + thread_add_timer_msec (master, clear_something, ws, 0, NULL); return 0; } } @@ -134,7 +134,7 @@ DEFUN (clear_foo, ws->vty = vty; ws->i = ITERS_FIRST; - thread_add_background(master, clear_something, ws, 0, NULL); + thread_add_timer_msec (master, clear_something, ws, 0, NULL); return CMD_SUCCESS; } diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 37068c1fae..00b604c265 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -564,8 +564,8 @@ zfpm_conn_up_thread_cb (struct thread *thread) zfpm_g->stats.t_conn_up_yields++; zfpm_rnodes_iter_pause (iter); zfpm_g->t_conn_up = NULL; - thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0, - &zfpm_g->t_conn_up); + thread_add_timer_msec (zfpm_g->master, zfpm_conn_up_thread_cb, NULL, 0, + &zfpm_g->t_conn_up); return 0; } @@ -598,7 +598,7 @@ zfpm_connection_up (const char *detail) zfpm_debug ("Starting conn_up thread"); zfpm_g->t_conn_up = NULL; - thread_add_background(zfpm_g->master, zfpm_conn_up_thread_cb, 0, 0, + thread_add_timer_msec(zfpm_g->master, zfpm_conn_up_thread_cb, NULL, 0, &zfpm_g->t_conn_up); zfpm_g->stats.t_conn_up_starts++; } @@ -688,7 +688,7 @@ zfpm_conn_down_thread_cb (struct thread *thread) zfpm_g->stats.t_conn_down_yields++; zfpm_rnodes_iter_pause (iter); zfpm_g->t_conn_down = NULL; - thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0, + thread_add_timer_msec(zfpm_g->master, zfpm_conn_down_thread_cb, NULL, 0, &zfpm_g->t_conn_down); return 0; } @@ -736,7 +736,7 @@ zfpm_connection_down (const char *detail) zfpm_debug ("Starting conn_down thread"); zfpm_rnodes_iter_init (&zfpm_g->t_conn_down_state.iter); zfpm_g->t_conn_down = NULL; - thread_add_background(zfpm_g->master, zfpm_conn_down_thread_cb, 0, 0, + thread_add_timer_msec(zfpm_g->master, zfpm_conn_down_thread_cb, NULL, 0, &zfpm_g->t_conn_down); zfpm_g->stats.t_conn_down_starts++; From 9c3bf1cee7123c400224da00f60cca1bece802bd Mon Sep 17 00:00:00 2001 From: Alex Couloumbis Date: Thu, 8 Jun 2017 07:55:25 -0400 Subject: [PATCH 95/96] zebra: Fix --disable-rtadv to actually compile Signed-off-by: Alex Couloumbis Signed-off-by: Donald Sharp --- zebra/interface.c | 2 ++ zebra/misc_null.c | 2 ++ zebra/zserv.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/zebra/interface.c b/zebra/interface.c index c60cb8dcbc..9393305f06 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -849,6 +849,7 @@ if_up (struct interface *ifp) if_nbr_ipv6ll_to_ipv4ll_neigh_add_all (ifp); +#if defined (HAVE_RTADV) /* Enable fast tx of RA if enabled && RA interval is not in msecs */ if (zif->rtadv.AdvSendAdvertisements && (zif->rtadv.MaxRtrAdvInterval >= 1000)) @@ -856,6 +857,7 @@ if_up (struct interface *ifp) zif->rtadv.inFastRexmit = 1; zif->rtadv.NumFastReXmitsRemain = RTADV_NUM_FAST_REXMITS; } +#endif /* Install connected routes to the kernel. */ if_install_connected (ifp); diff --git a/zebra/misc_null.c b/zebra/misc_null.c index b125becdc9..f58eb628b0 100644 --- a/zebra/misc_null.c +++ b/zebra/misc_null.c @@ -25,7 +25,9 @@ #include "zebra/irdp.h" #include "zebra/interface.h" +#if defined (HAVE_RTADV) void rtadv_config_write (struct vty *vty, struct interface *ifp) { return; } +#endif void irdp_config_write (struct vty *vty, struct interface *ifp) { return; } #ifdef HAVE_PROC_NET_DEV void ifstat_update_proc (void) { return; } diff --git a/zebra/zserv.c b/zebra/zserv.c index ea4c769fa5..9d05a3b9df 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2396,10 +2396,14 @@ zebra_client_read (struct thread *thread) zebra_ptm_bfd_client_register(client, sock, length); break; case ZEBRA_INTERFACE_ENABLE_RADV: +#if defined (HAVE_RTADV) zebra_interface_radv_set (client, sock, length, zvrf, 1); +#endif break; case ZEBRA_INTERFACE_DISABLE_RADV: +#if defined (HAVE_RTADV) zebra_interface_radv_set (client, sock, length, zvrf, 0); +#endif break; case ZEBRA_MPLS_LABELS_ADD: case ZEBRA_MPLS_LABELS_DELETE: From 1f047d8d2c6ccee7816ae63775fb36860fc8113a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 8 Jun 2017 08:48:10 -0400 Subject: [PATCH 96/96] tools, zebra: Fix netlink notification of who owns the routes For NHRP, EIGRP and LDP( This is for consistency as opposed to correctness ) assign some new values to routes to be installed into the kernel so we can know who owns them later. Signed-off-by: Donald Sharp --- tools/etc/iproute2/rt_protos.d/frr.conf | 4 +++- zebra/rt_netlink.c | 13 ++++++++++++- zebra/rt_netlink.h | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/etc/iproute2/rt_protos.d/frr.conf b/tools/etc/iproute2/rt_protos.d/frr.conf index 3f55b11268..2d3b884e7e 100644 --- a/tools/etc/iproute2/rt_protos.d/frr.conf +++ b/tools/etc/iproute2/rt_protos.d/frr.conf @@ -5,4 +5,6 @@ 188 ospf 189 rip 190 ripng -191 static +191 nhrp +192 eigrp +193 ldp diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 88cdfbcae1..9bad7991a5 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -121,7 +121,9 @@ static inline int is_selfroute(int proto) { if ((proto == RTPROT_BGP) || (proto == RTPROT_OSPF) || (proto == RTPROT_STATIC) || (proto == RTPROT_ZEBRA) || - (proto == RTPROT_ISIS) || (proto == RTPROT_RIPNG)) { + (proto == RTPROT_ISIS) || (proto == RTPROT_RIPNG) || + (proto == RTPROT_NHRP) || (proto == RTPROT_EIGRP) || + (proto == RTPROT_LDP)) { return 1; } @@ -150,6 +152,15 @@ static inline int get_rt_proto(int proto) case ZEBRA_ROUTE_RIPNG: proto = RTPROT_RIPNG; break; + case ZEBRA_ROUTE_NHRP: + proto = RTPROT_NHRP; + break; + case ZEBRA_ROUTE_EIGRP: + proto = RTPROT_EIGRP; + break; + case ZEBRA_ROUTE_LDP: + proto = RTPROT_LDP; + break; default: proto = RTPROT_ZEBRA; break; diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h index 4ec5f18535..6f9487542c 100644 --- a/zebra/rt_netlink.h +++ b/zebra/rt_netlink.h @@ -33,6 +33,9 @@ #define RTPROT_OSPF 188 #define RTPROT_RIP 189 #define RTPROT_RIPNG 190 +#define RTPROT_NHRP 191 +#define RTPROT_EIGRP 192 +#define RTPROT_LDP 193 void rt_netlink_init (void);