1
0
mirror of https://github.com/bgp/bgpq4.git synced 2024-05-11 05:55:05 +00:00

- documentation updated,

- Job Snijders BIRD patch corrected (style, minor errors)
- .spec updated to match upcoming version
This commit is contained in:
Alexandre Snarskii
2014-06-05 13:24:04 +04:00
parent e3abb19109
commit af36c505a0
9 changed files with 245 additions and 164 deletions

View File

@@ -1,3 +1,7 @@
0.1.21 (2014-06-05)
- new flag -b: generate prefix-filters for BIRD (http://bird.network.cz),
contributed by Job Snijders.
0.1.20-todo2 (2014-05-01)
- new flag -r <len>, allowing bgpq to generate limited set of more-specific
routes - only routes with prefix-length >= <len> are accepted.

View File

@@ -37,5 +37,5 @@ install: bgpq3
depend:
makedepend -- $(CFLAGS) -- $(SRCS)
bgpq3.html: README.md
markdown2 README.md > bgpq3.html
bgpq3.html: readme.header README.md
cat readme.header README.md | @MARKDOWN@ > bgpq3.html

View File

@@ -37,7 +37,7 @@
.Fl f Ar asn |
.Fl G Ar asn
.Oc
.Op Fl 346ADdJjX
.Op Fl 346AbDdJjX
.Op Fl r Ar len
.Op Fl R Ar len
.Op Fl m Ar max

View File

@@ -148,7 +148,8 @@ main(int argc, char* argv[])
if(aggregate) debug_aggregation++;
aggregate=1;
break;
case 'b': if(expander.vendor) vendor_exclusive();
case 'b':
if(expander.vendor) vendor_exclusive();
expander.vendor=V_BIRD;
break;
case 'd': debug_expander++;

View File

@@ -1,4 +1,4 @@
<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
<html><head><style type='text/css'>
h1 { color: #3c78b5; border-bottom: 3px solid #3c78b5; font-size: 180%; }
@@ -9,134 +9,174 @@ code { font-size:12px; background-color:#f8f8ff; border:1px; }
pre { border: 1px dotted #3c78b5; background-color: #f8f8ff; margin: 1em 1em;}
body { width: 80%; margin: 0 3em; }
ul { list-style: none; }
</style></head><body></p>
</style></head><body>
<h2>NAME</h2>
<p><code>bgpq3</code> - bgp filtering automation for Cisco and Juniper routers</p>
<h2>SYNOPSIS</h2>
<pre><code>bgpq3 [-h host] [-S sources] [-EP] [-f asn | -G asn] [-36ADdJjX] [-R len] [-m max] OBJECTS [...]
<pre><code>bgpq3 [-h host] [-S sources] [-EP] [-f asn | -G asn] [-346ADdJjX] [-r len] [-R len] [-m max] OBJECTS [...]
</code></pre>
<h2>DESCRIPTION</h2>
<p>The bgpq3 utility used to generate Cisco and Juniper prefix-lists,
extended access-lists, policy-statement terms and as-path lists based on
RADB data.</p>
<p>The options are as follows:</p>
<ul>
<li><p>-3 </p>
<li>
<p>-3 <br />
</p>
<blockquote>
<p>assume that your device is asn32-capable.</p>
</blockquote></li>
<li><p>-6 </p>
</blockquote>
</li>
<li>
<p>-4 </p>
<blockquote>
<p>generate IPv4 prefix/access-lists (default).</p>
</blockquote>
</li>
<li>
<p>-6 <br />
</p>
<blockquote>
<p>generate IPv6 prefix/access-lists (IPv4 by default).</p>
</blockquote></li>
<li><p>-A </p>
</blockquote>
</li>
<li>
<p>-A <br />
</p>
<blockquote>
<p>try to aggregate generated filters as much as possible (not all
output formats supported).</p>
</blockquote></li>
<li><p>-d </p>
</blockquote>
</li>
<li>
<p>-b</p>
<blockquote>
<p>generate output in BIRD format (default: Cisco).</p>
</blockquote>
</li>
<li>
<p>-d <br />
</p>
<blockquote>
<p>enable some debugging output.</p>
</blockquote></li>
<li><p>-D </p>
</blockquote>
</li>
<li>
<p>-D <br />
</p>
<blockquote>
<p>use asdot notation for Cisco as-path access-lists.</p>
</blockquote></li>
<li><p>-E </p>
</blockquote>
</li>
<li>
<p>-E <br />
</p>
<blockquote>
<p>generate extended access-list (Cisco) or policy-statement term using
route-filters (Juniper).</p>
</blockquote></li>
<li><p>-f number</p>
</blockquote>
</li>
<li>
<p>-f number</p>
<blockquote>
<p>generate input as-path access-list.</p>
</blockquote></li>
<li><p>-G number</p>
</blockquote>
</li>
<li>
<p>-G number</p>
<blockquote>
<p>generate output as-path access-list.</p>
</blockquote></li>
<li><p>-h host</p>
</blockquote>
</li>
<li>
<p>-h host</p>
<blockquote>
<p>host running IRRD database (default: whois.radb.net).</p>
</blockquote></li>
<li><p>-J </p>
</blockquote>
</li>
<li>
<p>-J <br />
</p>
<blockquote>
<p>generate config for Juniper (default: Cisco).</p>
</blockquote></li>
<li><p>-j </p>
</blockquote>
</li>
<li>
<p>-j <br />
</p>
<blockquote>
<p>generate output in JSON format (default: Cisco).</p>
</blockquote></li>
<li><p>-m len </p>
</blockquote>
</li>
<li>
<p>-m len<br />
</p>
<blockquote>
<p>maximum length of accepted prefixes (default: 32 for IPv4, 128 for IPv6).</p>
</blockquote></li>
<li><p>-M match </p>
</blockquote>
</li>
<li>
<p>-M match </p>
<blockquote>
<p>extra match conditions for Juniper route-filters.</p>
</blockquote></li>
<li><p>-l name </p>
</blockquote>
</li>
<li>
<p>-l name </p>
<blockquote>
<p>name of generated entry.</p>
</blockquote></li>
<li><p>-P </p>
</blockquote>
</li>
<li>
<p>-P <br />
</p>
<blockquote>
<p>generate prefix-list (default behaviour, flag added for backward
compatibility only).</p>
</blockquote></li>
<li><p>-R len </p>
</blockquote>
</li>
<li>
<p>-r len </p>
<pre><code>&gt; allow more-specific routes with masklen starting with specified
length.
</code></pre>
</li>
<li>
<p>-R len<br />
</p>
<blockquote>
<p>allow more-specific routes up to specified masklen too.
(Please, note: objects with prefix-length greater than specified length
will be always allowed.)</p>
</blockquote></li>
<li><p>-S sources </p>
</blockquote>
</li>
<li>
<p>-S sources </p>
<blockquote>
<p>use specified sources only (default: RADB,RIPE,APNIC).</p>
</blockquote></li>
<li><p>-T </p>
</blockquote>
</li>
<li>
<p>-T <br />
</p>
<blockquote>
<p>disable pipelining.</p>
</blockquote></li>
<li><p>-X </p>
</blockquote>
</li>
<li>
<p>-X <br />
</p>
<blockquote>
<p>generate config for Cisco IOS XR devices (plain IOS by default).</p>
</blockquote></li>
</blockquote>
</li>
</ul>
<p><code>OBJECTS</code> means networks (in prefix format), autonomous systems and as-macros.</p>
<p><code>OBJECTS</code> means networks (in prefix format), autonomous systems, as-sets
and route-sets. </p>
<h2>EXAMPLES</h2>
<p>Generating named Juniper prefix-filter for <code>AS20597</code>:</p>
<pre><code> user@host:~&gt;bgpq3 -Jl eltel AS20597
policy-options {
replace:
@@ -157,10 +197,8 @@ RADB data.</p>
}
}
</code></pre>
<p>For Cisco we can use aggregation (-A) flag to make this prefix-filter
more compact:</p>
<pre><code> user@host:~&gt;bgpq3 -Al eltel AS20597
no ip prefix-list eltel
ip prefix-list eltel permit 81.9.0.0/20
@@ -175,54 +213,45 @@ more compact:</p>
ip prefix-list eltel permit 89.112.64.0/19
ip prefix-list eltel permit 217.170.64.0/19 ge 20 le 20
</code></pre>
<p>and, as you see, prefixes <code>89.112.0.0/19</code> and <code>89.112.32.0/19</code> now aggregated
into single entry </p>
<pre><code>ip prefix-list eltel permit 89.112.0.0/18 ge 19 le 19.
</code></pre>
<p>Well, for Juniper we can generate even more interesting policy-statement,
using <code>-M &lt;extra match conditions&gt;</code>, <code>-R &lt;len&gt;</code> and hierarchical names:</p>
<pre><code> user@host:~&gt;bgpq3 -AJEl eltel/specifics -R 32 -M "community blackhole" AS20597
using <code>-M &lt;extra match conditions&gt;</code>, <code>-r &lt;len&gt;</code>, <code>-R &lt;len&gt;</code> and hierarchical
names:</p>
<pre><code> user@host:~&gt;bgpq3 -AJEl eltel/specifics -r 29 -R 32 -M "community blackhole" AS20597
policy-options {
policy-statement eltel {
term specifics {
replace:
from {
community blackhole;
route-filter 81.9.0.0/20 upto /32;
route-filter 81.9.32.0/20 upto /32;
route-filter 81.9.96.0/20 upto /32;
route-filter 81.222.128.0/20 upto /32;
route-filter 81.222.192.0/18 upto /32;
route-filter 85.249.8.0/21 upto /32;
route-filter 85.249.224.0/19 upto /32;
route-filter 89.112.0.0/18 prefix-length-range /19-/32;
route-filter 89.112.64.0/19 upto /32;
route-filter 217.170.64.0/19 prefix-length-range /20-/32;
route-filter 81.9.0.0/20 prefix-length-range /29-/32;
route-filter 81.9.32.0/20 prefix-length-range /29-/32;
route-filter 81.9.96.0/20 prefix-length-range /29-/32;
route-filter 81.222.128.0/20 prefix-length-range /29-/32;
route-filter 81.222.192.0/18 prefix-length-range /29-/32;
route-filter 85.249.8.0/21 prefix-length-range /29-/32;
route-filter 85.249.224.0/19 prefix-length-range /29-/32;
route-filter 89.112.0.0/17 prefix-length-range /29-/32;
route-filter 217.170.64.0/19 prefix-length-range /29-/32;
}
}
}
}
</code></pre>
<p>generated policy-option term now allows all more-specific routes
for eltel networks if they marked with community 'blackhole' (defined
elsewhere in configuration).</p>
<p>generated policy-option term now allows more-specific routes in range
/29 - /32 for eltel networks if they marked with community 'blackhole'
(defined elsewhere in configuration).</p>
<p>Of course, <code>bgpq3</code> supports IPv6 (-6):</p>
<pre><code> user@host:~&gt;bgpq3 -6l as-retn-6 AS-RETN6
no ipv6 prefix-list as-retn-6
ipv6 prefix-list as-retn-6 permit 2001:7fb:fe00::/48
ipv6 prefix-list as-retn-6 permit 2001:7fb:fe01::/48
[....]
</code></pre>
<p>and ASN32</p>
<pre><code> user@host:~&gt;bgpq3 -J3f 112 AS-SPACENET
policy-options {
replace:
@@ -234,12 +263,9 @@ elsewhere in configuration).</p>
}
}
</code></pre>
<p>see <code>AS196611</code> in the end of the list ? That's <code>AS3.3</code> in 'asplain' notation.</p>
<p>If your router does not support ASN32 (yet) you should not use switch -3,
and the result will be next:</p>
<pre><code> user@host:~&gt;bgpq3 -f 112 AS-SPACENET
no ip as-path access-list NN
ip as-path access-list NN permit ^112( 112)*$
@@ -249,31 +275,22 @@ and the result will be next:</p>
ip as-path access-list NN permit ^112( [0-9]+)* (25152|31529|34127|34906)$
ip as-path access-list NN permit ^112( [0-9]+)* (35052|41720|43628|44450)$
</code></pre>
<p><code>AS196611</code> is no more in the list, however, <code>AS23456</code> (transition AS) would
have been added to list if it were not present.</p>
<h2>DIAGNOSTICS</h2>
<p>When everything is OK, <code>bgpq3</code> generates result to standard output and
exits with status == 0. In case of errors they are printed to stderr and
program exits with non-zero status.</p>
<h2>NOTES ON ULTRA-LARGE PREFIX-LISTS</h2>
<p>When using <code>bgpq3</code> to expand extra-large AS-SETs, <code>bgpq3</code> may stuck
due to lacking tcp buffer size. To avoid this, tune your OS.
FreeBSD can be tuned in the following way:</p>
<pre><code>sysctl -w net.inet.tcp.sendbuf_max=16777216
</code></pre>
<p>Please note that generated prefix-lists may not fit your router's
limitations. For example, JunOS supports only 85,325 prefixes in
each prefix-list <a href="http://www.juniper.net/techpubs/en_US/junos11.4/topics/reference/configuration-statement/prefix-list-edit-policy-options.html">4</a>. </p>
<h2>SEE ALSO</h2>
<ol>
<li><a href="http://www.radb.net/">Routing Arbiter</a></li>
<li><a href="http://www.ietf.org/internet-drafts/draft-michaelson-4byte-as-representation-05.txt">draft-michaelson-4byte-as-representation-05.txt</a>
@@ -282,11 +299,7 @@ each prefix-list <a href="http://www.juniper.net/techpubs/en_US/junos11.4/topics
for information on Cisco implementation of ASN32.</li>
<li><a href="http://www.juniper.net/techpubs/en_US/junos11.4/topics/reference/configuration-statement/prefix-list-edit-policy-options.html">JunOS prefix-lists limitation</a></li>
</ol>
<h2>AUTHOR</h2>
<p>Alexandre Snarskii <a href="mailto:snar@snar.spb.ru">snar@snar.spb.ru</a></p>
<h2>Program Homepage</h2>
<p><a href="http://snar.spb.ru/prog/bgpq3/">http://snar.spb.ru/prog/bgpq3/</a></p>

View File

@@ -1,12 +1,12 @@
Name: bgpq3
Version: 0.1.19
Version: 0.1.21
Release: 0%{?dist}
Group: System/Utilities
Summary: Automate BGP filter generation based on routing database information
URL: http://snar.spb.ru/prog/bgpq3/
License: BSD
Source0: http://snar.spb.ru/prog/bgpq3/bgpq3-0.1.19.tgz
Source0: http://snar.spb.ru/prog/bgpq3/bgpq3-0.1.21.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
@@ -35,6 +35,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Thu Jun 5 2014 Alexandre Snarskii <snar@snar.spb.ru> 0.1.21-0.snar
- Version updated
* Thu May 9 2013 Alexandre Snarskii <snar@snar.spb.ru> 0.1.19-0.snar
- Version updated

45
configure vendored
View File

@@ -586,6 +586,7 @@ PACKAGE_URL=''
ac_subst_vars='LTLIBOBJS
LIBOBJS
MARKDOWN
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
@@ -2756,6 +2757,50 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
for ac_prog in markdown_py markdown2 markdown
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_MARKDOWN+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$MARKDOWN"; then
ac_cv_prog_MARKDOWN="$MARKDOWN" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_MARKDOWN="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
MARKDOWN=$ac_cv_prog_MARKDOWN
if test -n "$MARKDOWN"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MARKDOWN" >&5
$as_echo "$MARKDOWN" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$MARKDOWN" && break
done
test -n "$MARKDOWN" || MARKDOWN="echo"
for ac_func in strlcpy
do :

View File

@@ -3,6 +3,8 @@ AC_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_INSTALL
AC_CHECK_PROGS([MARKDOWN], [markdown_py markdown2 markdown], [echo])
AC_CHECK_FUNCS(strlcpy)
AC_CHECK_LIB(socket,socket)

13
readme.header Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
<html><head><style type='text/css'>
h1 { color: #3c78b5; border-bottom: 3px solid #3c78b5; font-size: 180%; }
h2 { color: #3c78b5; border-bottom: 2px solid #3c78b5; font-size: 140%; }
h3 { color: #3c78b5; border-bottom: 1px dotted #3c78b5; font-size: 129%; }
em { color: #0000FF; }
code { font-size:12px; background-color:#f8f8ff; border:1px; }
pre { border: 1px dotted #3c78b5; background-color: #f8f8ff; margin: 1em 1em;}
body { width: 80%; margin: 0 3em; }
ul { list-style: none; }
</style></head><body>