Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build FRR 8.3.1 RPMs (for Route Views) #1

Open
2 tasks
ryeleo opened this issue Oct 3, 2022 · 0 comments · May be fixed by #2
Open
2 tasks

Build FRR 8.3.1 RPMs (for Route Views) #1

ryeleo opened this issue Oct 3, 2022 · 0 comments · May be fixed by #2
Labels
collector Issue related to Route Views collector(s). enhancement New feature or request help wanted Extra attention is needed triage Needs intake-processing & prioritization.

Comments

@ryeleo
Copy link

ryeleo commented Oct 3, 2022

Acceptance Criteria

  • Build RPMs for FRR 8.3.1 following instructions below
  • Get new FRR version integrated into (private) RV infra repo, with help of @routeviews/maintainers

Building FRR Instructions

ℹ Copied from "Building FRR" docs in (private) infra repo

For RouteViews, we use a custom version of FRR.
Mainly, we customize FRR to enable telnet sessions to access the FRR shell.

This document walks through the process to modify FRR source code and build scripts then run the build.
Additionally, this document discusses how to deploy and test the FRR build once it is ready to go!

Downloading and Patching FRR

We have a VM that has many prerequisites pre-installed: build.routeviews.org
Important: apparently the rpmbuild command actually requires a host with proper DNS resolution available -- this build server fulfills that requirement.

This document describes the building and packaging process for frr in the context of routeviews.
These instructions are based on FRR Packaging for RedHat instructions and FRR Packing for Debian instructions.

Today, these instructions assume CentOS 7, or Ubuntu 20.04

Download FRR Source Code

First, you'll need to clone git repo and choose the branch/version that you want to build.
In this example, we are building the latest 'stable/8.1' version of FRR source code.

git clone https://github.com/frrouting/frr.git
cd frr
git checkout stable/8.1

It is a good idea to create a routeviews-specific local branch (off of the stable branch).

git checkout -b rv-frr-8.1 

Apply VTY Patch

We patch the VTY code with some enhanced logging to make our lives easier.

  1. In file /lib/libfrr.c find the method static void frr_vty_serv(void).

  2. Within that method, encase the line vty_serv_sock(di->vty_addr, di->vty_port, di->vty_path); with logging, like the following:

     #if defined(HAVE_PRIV_VTY)
         if (di->privs->change(ZPRIVS_RAISE)) {
             zlog_err("unable to raise privs for %s's, vty", di->name);
         }
     #endif
    
         vty_serv_sock(di->vty_addr, di->vty_port, di->vty_path);
    
     #if defined(HAVE_PRIV_VTY)
         if (di->privs->change(ZPRIVS_LOWER)) {
             zlog_err("unable to lower privs for %s's, vty", di->name);
         }
     #endif
    

Create Build Flags for --enable-privileged-vty

In file /configure.ac

Add the following:

AC_ARG_ENABLE(privileged_vty,
    AS_HELP_STRING([--enable-privileged-vty], [Allow vty to bind to privileged ports]))

And:

if test "${enable_privileged_vty}" = "yes"; then
    AC_DEFINE([HAVE_PRIV_VTY],,[Allow vty to bind to privileged ports])
fi

In the corresponding sections with similar commands.

ℹ Hint: Search for HAVE_SHELL_ACCESS to find the appropriate sections of the code.

CentOS 7 Packaging Instructions

Required Packages

First, you must install required packages:

sudo yum install git autoconf automake libtool make \
    readline-devel texinfo net-snmp-devel groff pkgconfig \
    json-c-devel pam-devel bison flex pytest c-ares-devel \
    python-devel python-sphinx libcap-devel \
    elfutils-libelf-devel libunwind-devel \
    libssh libssh-devel librtr-devel

In addition, a special version libyang and libyang-devel are required to build FRR.
Today, this version of libyang is actually only available via an FRR RPM repository.
The instructions to add this repo to your CentOS 7 build server are copied below:

FRRVER="frr-stable"
curl -O https://rpm.frrouting.org/repo/$FRRVER-repo-1-0.el7.noarch.rpm
sudo yum install ./$FRRVER*

With the FRR RPM repo available, now you can simply install libyang2 using yum:

sudo yum install libyang2

Create RPM Package

Creating the RPM package requires many steps; from bootstrapping to

Bootstrap

Run the following commands in the root directory of the repo:

./bootstrap.sh
./configure --with-pkg-extra-version=-rv
make dist

Establish rpmbuild directory

Create the rpmbuild directory - from the root directory of the frr repo:

mkdir -p rpmbuild/SOURCES rpmbuild/SPECS
cp redhat/*.spec rpmbuild/SPECS/.
cp frr*.tar.gz rpmbuild/SOURCES/.

Choose FRR Features

  1. Open the file rpmbuild/SPECS/frr.spec for editing.
  2. Disable all features in the # with-feature options section except for the flags indicated in the table below:

All other flags should be 0.

Flag Why leave enabled?
with_bfdd frr will fail building without this.
with_eigrpd frr will fail building without this.
with_multipath There's no harm in leaving this.
with_watchfrr Needed for systemd integration.
with_opsfapi frr will fail building without this.
with_opsfclient frr will fail building without this.
  1. At the end of # with-feature options, add the following line to enable our newly added 'enable_privileged_vty' feature:

     %{!?with_privileged_vty: %global with_privileged_vty 1 }
    
  2. In the middle of the %configure \ section, add the following lines (also to enable our newly added 'enable_privileged_vty' feature):

     %if %{with_privileged_vty}
         --enable-privileged-vty \
     %endif
    

Important: Do not put this at the very end, otherwise the line-continuation logic may break!

Build the RPM

Finally, everything is in place so that we can run rpmbuild!

This will take a few minutes.

rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/frr.spec

If the rpmbuild command succeeds, all of the RPM packages will be written to the rpmbuilds/[S]RPMS/ directories.
The rpmbuild output will indicate where these files have been written:

Wrote: /root/frr/rpmbuild/SRPMS/frr-8.1_rv-01.el7.src.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-8.1_rv-01.el7.x86_64.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-contrib-8.1_rv-01.el7.x86_64.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-pythontools-8.1_rv-01.el7.x86_64.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-devel-8.1_rv-01.el7.x86_64.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-rpki-rtrlib-8.1_rv-01.el7.x86_64.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-snmp-8.1_rv-01.el7.x86_64.rpm
Wrote: /root/frr/rpmbuild/RPMS/x86_64/frr-debuginfo-8.1_rv-01.el7.x86_64.rpm

Additional required packages (at runtime)

In addition to the packages we just created, we need ensure some supporting rpms are up to date as well.
They can be found as artifacts on the (public) FRR Build Server.

At the time of writing, only the following rpms are required:

librtr.*.el7.x86_64.rpm
librtr-devel.*el7.x86_64.rpm
@ryeleo ryeleo added collector Issue related to Route Views collector(s). enhancement New feature or request help wanted Extra attention is needed labels Oct 3, 2022
@ryeleo ryeleo linked a pull request Oct 12, 2022 that will close this issue
@ryeleo ryeleo added the triage Needs intake-processing & prioritization. label Oct 12, 2022
ryeleo pushed a commit that referenced this issue Nov 10, 2022
Fixing the crash:

> #0  0x0000560aa80f8e30 in lspdb_const_find (h=<error reading variable: Cannot access memory at address 0x7fff5e95efe8>, item=<error reading variable: Cannot access memory at address 0x7fff5e95efe0>) at ./isisd/isis_lsp.h:64
> #1  0x0000560aa80f8e9d in lspdb_find (h=0x560aaa1ed3b8, item=0x7fff5e95f050) at ./isisd/isis_lsp.h:64
> #2  0x0000560aa80f92f9 in lsp_search (head=0x560aaa1ed3b8, id=0x7fff5e95f200 "") at isisd/isis_lsp.c:100
> FRRouting#3  0x0000560aa8113d69 in spf_adj_list_parse_tlv (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, id=0x560aad331a78 "", desig_is_id=0x0, pseudo_metric=0, metric=3, oldmetric=false, subtlvs=0x0) at isisd/isis_spf.c:1330
> FRRouting#4  0x0000560aa811419d in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1f4e50, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1429
> FRRouting#5  0x0000560aa81141fe in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1ff8e0, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1442
> FRRouting#6  0x0000560aa81141fe in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1f4e50, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1442
> (...)
> #65507 0x0000560aa81141fe in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1ff8e0, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1442
> #65508 0x0000560aa81141fe in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1f4e50, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1442
> #65509 0x0000560aa81141fe in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1ff8e0, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1442
> #65510 0x0000560aa81141fe in spf_adj_list_parse_lsp (spftree=0x560aaa1f09d0, adj_list=0x560aaa214480, lsp=0x560aaa1f4e50, pseudo_nodeid=0x0, pseudo_metric=0) at isisd/isis_spf.c:1442
> #65511 0x0000560aa8114313 in isis_spf_build_adj_list (spftree=0x560aaa1f09d0, lsp=0x560aaa1f4e50) at isisd/isis_spf.c:1455
> #65512 0x0000560aa8114f09 in isis_run_spf (spftree=0x560aaa1f09d0) at isisd/isis_spf.c:1775
> #65513 0x0000560aa8115057 in isis_run_spf_with_protection (area=0x560aaa1ed3b0, spftree=0x560aaa1f09d0) at isisd/isis_spf.c:1801
> #65514 0x0000560aa8115311 in isis_run_spf_cb (thread=0x7fff5f15e5a0) at isisd/isis_spf.c:1859
> #65515 0x00007f90bac66dcc in thread_call (thread=0x7fff5f15e5a0) at lib/thread.c:2002
> #65516 0x00007f90bac013ee in frr_run (master=0x560aa9f5cb40) at lib/libfrr.c:1196
> #65517 0x0000560aa80e7da2 in main (argc=2, argv=0x7fff5f15e7b8, envp=0x7fff5f15e7d0) at isisd/isis_main.c:273

The fix is similar to the crash fix included in d9884a7
("isisd: Prepare IS-IS for Link State support"). The fix was:

> diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
> index 94353a5bc8..92d329f035 100644
> --- a/isisd/isis_lsp.c
> +++ b/isisd/isis_lsp.c
> @@ -2166,7 +2178,7 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid,
>  	if (lsp->hdr.seqno == 0 || lsp->hdr.rem_lifetime == 0)
>  		return LSP_ITER_CONTINUE;
>
> -	/* Parse main LSP. */
> +	/* Parse LSP */
>  	if (lsp->tlvs) {
>  		if (!fabricd && !pseudo_lsp && family == AF_INET
>  		    && mtid == ISIS_MT_IPV4_UNICAST) {
> @@ -2236,13 +2248,17 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid,
>  		}
>  	}
>
> -	/* Parse LSP fragments. */
> -	for (ALL_LIST_ELEMENTS_RO(lsp->lspu.frags, node, frag)) {
> -		if (!frag->tlvs)
> -			continue;
> +	/* Parse LSP fragments if it is not a fragment itself */
> +	if (!LSP_FRAGMENT(lsp->hdr.lsp_id))
> +		for (ALL_LIST_ELEMENTS_RO(lsp->lspu.frags, node, frag)) {
> +			if (!frag->tlvs)
> +				continue;
>
> -		isis_lsp_iterate_ip_reach(frag, family, mtid, cb, arg);
> -	}
> +			if (isis_lsp_iterate_ip_reach(frag, family, mtid, cb,
> +						      arg)
> +			    == LSP_ITER_STOP)
> +				return LSP_ITER_STOP;
> +		}
>
>  	return LSP_ITER_CONTINUE;
>  }

Fixes: 7b36d36 ("isisd: make the SPF code more modular")
Fixes: 5e56a50 ("isisd: fix infinite loop when parsing LSPs")
Signed-off-by: Louis Scalbert <[email protected]>
(cherry picked from commit 8c8a5a0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collector Issue related to Route Views collector(s). enhancement New feature or request help wanted Extra attention is needed triage Needs intake-processing & prioritization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant