Statistics
| Branch: | Revision:

iof-bird-daemon / doc / bird.sgml @ ba1dda49

History | View | Annotate | Download (17 KB)

1
<!doctype linuxdoc system>
2

    
3
<!--
4
	Bird documentation
5

    
6
    Look for "about this documentation" section to learn more.
7

    
8
    (set-fill-column 100)
9

    
10
    Copyright 1999,2000 Pavel Machek <pavel@ucw.cz>, distribute under GPL version 2 or later.
11

    
12
 -->
13

    
14
<article>
15

    
16
<title>Bird
17
<author>
18
Pavel Machek <tt/pavel@ucw.cz/
19

    
20
<date>2000
21
<abstract>
22
This document contains documentation for BIRD Internet Routing Daemon
23
</abstract>
24

    
25
<!-- Table of contents -->
26
<toc>
27

    
28
<!-- Begin the document -->
29

    
30
<sect>Introduction
31

    
32
<sect1>What is bird
33

    
34
<p><label id="intro"> You may wonder what 'bird' means. It is acronym of 'BIRD Internet Routing
35
Daemon', and we think that's cool name. Its task is similar to what firmware of Cisco routers does,
36
or what gated <HTMLURL URL="http://www.gated.org/"> or GNU zebra <HTMLURL
37
URL="http://www.zebra.org/"> does. However, you can not run Cisco's firmware on "normal" computer
38
and gated is really hard to configure and comes under wrong license. Bird is being developed on
39
Charles University, Prague, and can be freely distributed under terms of GNU General Public
40
License. Bird is designed to run on Unix and unix-like systems, it is primarily developed on Linux.
41

    
42
<sect1>About this documentation
43

    
44
<p>This documentation can have 4 forms: sgml (this is master copy), html, ASCII text (generated from
45
html) and dvi/postscript (generated from sgml using sgmltools). You should always edit master copy,
46
it is slightly modified linuxdoc dtd.  Anything in &lt;descrip&gt; tags is considered definition of
47
configuration primitives, &lt;cf&gt; is fragment of configuration within normal text, &lt;m&gt; is
48
"meta" information within fragment of configuration -- something in config which is not keyword.
49

    
50
<sect>Configuration
51

    
52
<sect1>Introduction
53

    
54
<p>Bird is configured using text configuration file. At startup, bird reads <file/bird.conf/
55
(unless -c command line parameter is given). Really simple configuration file might look like this:
56

    
57
<code>
58
protocol kernel {
59
	persist;		# Don't remove routes on bird shutdown
60
	scan time 20;		# Scan kernel routing table every 20 seconds
61
	export all;		# Default is export none
62
}
63

    
64
protocol device {
65
	scan time 10;		# Scan interfaces every 10 seconds
66
}
67

    
68
protocol rip {
69
	export all;
70
	import all;
71
}
72
</code>
73

    
74
<p>Everything on a line after <cf/#/ is a comment, whitespace is
75
ignored. If there's variable number of options, it is grouped using
76
<cf/{ }/ brackets. Each option is terminated by <cf/;/.
77

    
78
<p>You can find example of more complicated configuration file in <file>doc/bird.conf.example</file>.
79

    
80
<sect1>Global options
81

    
82
<p><descrip>
83
	<tag>log "<m/filename/"|syslog|stderr all|{ <m/list of
84
	classes/ }</tag> set logging of classes (either all or <cf/{
85
	error, trace }/ etc.) into selected destination. Classes are:
86
	<cf/debug/ for debugging message, <cf/trace/, <cf/info/,
87
	<cf/remote/ for messages about misbehaviour of remote side, <cf/warning/,
88
	<cf/error/, <cf/auth/, <cf/fatal/, <cf/bug/ for internal bugs
89
	of bird. You may specify more than one <cf/log/ line to log to multiple
90
	destinations.
91
				  
92
	<tag>debug protocols all|off|{ states, routes, filters, interfaces, events, packets }</tag>
93
	sets global default of debugging options.
94

    
95
	<tag>filter <m/name/{ <m/commands/ }</tag> define filter. You can learn more about filters
96
	in next chapter.
97
 
98
	<tag>protocol rip|ospf|bgp <m/[name]/ { <m>protocol options</m> }</tag> define protocol
99
	instance, called name (or called something like rip5 if you omit name). You can learn more
100
	about configuring protocols in their own chapters.
101

    
102
	<tag>define constant = expression</tag> define constant. You can use it later in every place
103
	you could use simple integer.
104

    
105
	<tag>router id <m/num.num.num.num/</tag> set router id. Router
106
	id needs to be world-wide unique 32bit number, identifying
107
	router. It is usually one of router's IP addresses.
108

    
109
	<tag>table <m/name/</tag> create new routing table.
110

    
111
	<tag>eval <m/expr/</tag> evaluates given filter expression. It is used for testing.
112
</descrip>
113

    
114
<sect1>Per-protocol options
115

    
116
<p>Several options are per-protocol, but all protocols support them. They are described here.
117

    
118
<descrip>
119
	<tag>preference <m/expr/</tag> sets preference of this protocol.
120

    
121
	<tag>disabled</tag> disables given protocol.
122

    
123
	<tag>debug <m/setting/</tag> this is similar to global debug setting, except that it only
124
	affects one protocol.
125

    
126
	<tag>import <m/filter/</tag> filter can be either either <cf> { <m>filter commands</m>
127
	}</cf> or <cf>filter <m/name/</cf>. Import filter works in direction from protocol to main
128
	routing table.
129

    
130
	<tag>export <m/filter/</tag> This is similar to <cf>export</cf> keyword, except that it
131
	works in direction from main routing table to protocol.
132

    
133
	<tag>table <m/name/</tag> Connect this protocol to non-default table.
134
</descrip>
135

    
136
<p>There are per-protocol options that give sense only with certain protocols.
137

    
138
<descrip>
139
	<tag>passwords { password "<m/password/" from <m/time/ to <m/time/ passive <m/time/ id
140
	<m/num/ [...] }</tag> specifies passwords to be used with this protocol. Passive time is
141
	time from which password is not announced but is allowed. id is password id, as needed by
142
	certain protocols.
143

    
144
	<tag>interface "<m/mask/" [ { <m/option/ ; [ ... ] } ]</tag> specifies, which interfaces
145
	this protocol is active at, and allows you to set options on interface-by-interface
146
	basis. Mask is specified in shell-like patters, thus <cf>interface "*" { mode broadcast;
147
	};</cf> will start given protocol on all interfaces, with <cf>mode broadcast;</cf> option.
148
</descrip>
149

    
150
<sect>Filters
151

    
152
<sect1>Introduction
153

    
154
<p>Bird contains rather simple programming language. (No, it can not yet read mail :-). There are
155
two objects in this language: filters and functions. Filters are called by bird core when route is
156
being passed between protocol and main routing table, and filters may call functions. Functions may
157
call other functions, but recursion is not allowed. Filter language contains control structures such
158
as if's and switches, but it allows no loops. Filters are
159
interpreted. Filter using many features can be found in <file>filter/test.conf</file>. 
160

    
161
<p>You can find sources of filters language in <file>filter/</file>
162
directory. <file>filter/config.Y</file> contains filter grammar, and basically translates source from
163
user into tree of <cf>f_inst</cf> structures. These trees are later interpreted using code in
164
<file>filter/filter.c</file>. Filters internally work with values/variables in <tt>struct
165
f_val</tt>, which contains type of value and value.
166

    
167
<p>Filter basically gets the route, looks at its attributes and
168
modifies some of them if it wishes. At the end, it decides, whether to
169
pass change route through (using <cf/accept/), or whether to <cf/reject/ given route. It looks
170
like this:
171

    
172
<code>
173
filter not_too_far
174
int var;
175
{
176
	if defined( rip_metric ) then
177
		var = rip_metric;
178
	else {
179
		var = 1;
180
		rip_metric = 1;
181
	}
182
	if rip_metric &gt; 10 then
183
		reject "RIP metric is too big";
184
	else
185
		accept "ok";
186
}
187
</code>
188

    
189
<p>As you can see, filter has a header, list of local variables, and body. Header consists of
190
<cf/filter/ keyword, followed by (unique) name of filter. List of local variables consists of
191
pairs <cf><M>type name</M>;</cf>, where each pair defines one local variable. Body consists of
192
<cf> { <M>statements</M> }</cf>. Statements are terminated by <cf/;/. You can group
193
several statements into one by <cf>{ <M>statements</M> }</cf> construction, that is useful if
194
you want to make bigger block of code conditional.
195

    
196
<p>Bird supports functions, so that you don't have to repeat same blocks of code over and
197
over. Functions can have zero or more parameters, and can have local variables. Function basically
198
looks like this:
199

    
200
<code>
201
function name ()
202
int local_variable;
203
{
204
	local_variable = 5;
205
}
206

    
207
function with_parameters (int parameter)
208
{
209
	print parameter;
210
}
211
</code>
212

    
213
<p>Unlike C, variables are declared after function line but before first {. You can not declare
214
variables in nested blocks. Functions are called like in C: <cf>name();
215
with_parameters(5);</cf>. Function may return value using <cf>return <m/[expr]/</cf>
216
syntax. Returning value exits from current function (this is similar to C).
217

    
218
<p>Filters are declared in similar way to functions, except they can not have explicit
219
parameters. They get route table entry as implicit parameter. Route table entry is passed implicitly
220
to any functions being called. Filter must terminate with either accept or reject statement.
221

    
222
<sect1>Data types
223

    
224
<p>Each variable and each value has certain type. Unlike C, filters distinguish between integers and
225
booleans (that is to prevent you from shooting in the foot).
226

    
227
<descrip>
228
	<tag/bool/ this is boolean type, it can have only two values, <cf/TRUE/ and
229
	  <cf/FALSE/. Boolean is not compatible with integer and is the only type you can use in if
230
	  statements.
231

    
232
	<tag/int/ this is common integer, you can expect it to store signed values from -2000000000
233
	  to +2000000000.
234

    
235
	<tag/pair/ this is pair of two short integers. Each component can have values from 0 to
236
	  65535. Constant of this type is written as <cf/(1234,5678)/.
237

    
238
	<tag/string/ this is string of characters. There are no ways to modify strings in
239
	  filters. You can pass them between functions, assign to variable of type string, print
240
	  such variables, but you can not concatenate two strings (for example). String constants
241
	  are written as <cf/"This is a string constant"/.
242

    
243
	<tag/ip/ this type can hold single ip address. Depending on version of bird you are using, it
244
	  can be IPv4 or IPv6 address. IPv4 addresses are written (as you would expect) as
245
	  <cf/1.2.3.4/. You can apply special operator <cf>.mask(<M>num</M>)</cf>
246
	  on values of type ip. It masks out all but first <cf><M>num</M></cf> bits from ip
247
	  address. So <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
248

    
249
	<tag/prefix/ this type can hold ip address, prefix len pair. Prefixes are written as
250
	  <cf><M>ipaddress</M>/<M>pxlen</M></cf>, or
251
	  <cf><m>ipaddress</m>/<m>netmask</m></cf> There are two special
252
	  operators on prefix:
253
	  <cf/.ip/, which separates ip address from the pair, and <cf/.len/, which separates prefix
254
	  len from the pair.
255

    
256
	<tag/int|ip|prefix|pair set/
257
	  filters know four types of sets. Sets are similar to strings: you can pass them around
258
	  but you can not modify them. Constant of type <cf>set int</cf> looks like <cf>
259
	  [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
260
	  sets. Sets of prefixes are special: you can specify which prefixes should match them by
261
	  using <cf>[ 1.0.0.0/8+, 2.0.0.0/8-, 3.0.0.0/8{5,6} ]</cf>. 3.0.0.0/8{5,6} matches
262
	  prefixes 3.X.X.X, whose prefix length is 5 to 6. 3.0.0.0/8+ is shorthand for 3.0.0.0/{0,8},
263
	  3.0.0.0/8- is shorthand for 3.0.0.0/{0,7}.
264

    
265
	<tag/enum/
266
	  enumerational types are halfway-internal in the bird. You can not define your own
267
	  variable of enumerational type, but some predefined variables are of enumerational
268
	  type. Enumerational types are incompatible with each other, again, for your
269
	  protection.
270

    
271
	<tag/bgppath/
272

    
273
	<tag/clist/
274

    
275
	<tag/bgpmask/
276
	  
277
</descrip>
278

    
279
<sect1>Operations
280

    
281
<p>Filter language supports common integer operations <cf>(+,-,*,/)</cf>, parenthesis <cf/(a*(b+c))/, comparation
282
<cf/(a=b, a!=b, a&lt;b, a&gt;=b)/. Special operators include <cf/&tilde;/ for "in" operation. In operation can be
283
used on element and set of that elements, or on ip and prefix, or on prefix and prefix. Its result
284
is true if element is in given set or if ip address is inside given prefix. Operator <cf/=/ is used to assign value
285
to variable.
286

    
287
<sect1>Control structures
288

    
289
<p>Filters support two control structures: if/then/else and case. Syntax of if/then/else is <cf>if
290
<M>expression</M> then <M>command</M>; else <M>command</M>;</cf> and you can use <cf>{
291
<M>command_1</M>; <M>command_2</M>; <M>...</M> }</cf> instead of one or both commands. <cf>else</cf>
292
clause may be omitted.
293

    
294
<p><cf>case</cf> is similar to case from Pascal. Syntax is <cf>case <m/expr/ { else |
295
<m/num_or_prefix [ .. num_or_prefix]/ : <m/statement/ ; [ ... ] }</cf>. Expression after
296
<cf>case</cf> can be of any type that can be on the left side of &tilde; operator, and anything that could
297
be member of set is allowed before :. Multiple commands are allowed without {} grouping. If argument
298
matches neither of : clauses, else: clause is used. (Case is actually implemented as set matching,
299
internally.)
300

    
301
<p>Here is example that uses if and case structures:
302

    
303
<code>
304
case arg1 {
305
	2: print "two"; print "I can do more commands without {}";
306
	3 .. 5: print "three to five";
307
	else: print "something else";
308
	}
309

    
310
if 1234 = i then printn "."; else { print "*** FAIL: if 1 else"; }
311
</code>
312

    
313
<sect1>Route attributes
314

    
315
<p>Filter is implicitly passed route, and it can access its attributes, just like it accesses variables.
316

    
317
<descrip>
318
	<tag>defined( <m>attribute</m></tag>
319
	returns TRUE if given attribute is defined. Access to undefined attribute results in runtime error.
320

    
321
	<tag/prefix network/
322
	network this route is talking about.
323

    
324
	<tag/ip from/
325
	who told me about this route.
326
	
327
	<tag/ip gw/
328
	what is nexthop packets routed using this route should be forwarded to.
329

    
330
	<tag/enum source/
331
	what protocol told me about this route. This can have values such as <cf/RTS_RIP/ or <cf/RTS_OSPF_EXT/.
332
</descrip>
333

    
334
<p>Plus, there are protocol-specific attributes, which are described in protocol sections.
335

    
336
<sect>Protocols
337

    
338
<sect1>Rip
339

    
340
<sect2>Introduction
341

    
342
<p>Rip protocol (sometimes called Rest In Pieces) is simple protocol, where each router broadcasts
343
distances to all networks he can reach. When router hears distance to other network, it increments
344
it and broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some network goes
345
unreachable, routers keep telling each other that distance is old distance plus 1 (actually, plus
346
interface metric, which is usually one). After some time, distance reaches infinity (that's 15 in
347
rip) and all routers know that network is unreachable. Rip tries to minimize situations where
348
counting to infinity is necessary, because it is slow. Due to infinity being 16, you can not use
349
rip on networks where maximal distance is bigger than 15 hosts. You can read more about rip at <HTMLURL
350
URL="http://www.ietf.org/html.charters/rip-charter.html">.
351

    
352
<sect2>Configuration
353

    
354
<p>In addition to options generic to other protocols, rip supports following options:
355

    
356
<descrip>
357
	<tag/authentication none|password|md5/ selects authentication method to use. None means that
358
	  packets are not authenticated at all, password means that plaintext password is embedded
359
	  into each packet, and md5 means that packets are authenticated using md5 cryptographic
360
	  hash. If you set authentication to non-none, it is good idea to add <cf>passwords { }</cf>
361
	  section.
362

    
363
	<tag>honor always|neighbor|never </tag>specifies, when should be routing table updates
364
	  honored. (Always, when sent from host on directly connected network, or never.)
365
</descrip>
366

    
367
<p>There are two options that can be specified per-interface. First is <cf>metric</cf>, with
368
default one.  Second is <cf>mode multicast|broadcast|quiet|nolisten|version1</cf>, it selects mode for
369
rip to work in. If nothing is specified, rip runs in multicasts mode. <cf>version1</cf> is
370
currently equivalent to <cf>broadcast</cf>, and it makes rip talk at broadcast address even
371
through multicast mode is possible. <cf>quiet</cf> option means that rip will not transmit
372
periodic messages onto this interface and <cf>nolisten</cf> means that rip will talk to this
373
interface but not listen on it.
374

    
375
<p>Following options generally override specified behavior from rfc. If you use any of these
376
options, bird will no longer be rfc-compatible, which means it will not be able to talk to anything
377
other than equally misconfigured bird. I warned you.
378

    
379
<descrip>
380
	<tag>port <M>number</M></tag>
381
	  selects IP port to operate on, default 520. (This is useful when testing bird, if you
382
	  set this to address &gt;1024, you will not need to run bird with uid==0).
383

    
384
	<tag>infinity <M>number</M></tag>
385
	  select value of infinity, default 16. Bigger values will make protocol convergence
386
	  even slower.
387

    
388
	<tag>period <M>number</M>
389
	  </tag>specifies number of seconds between periodic updates. Default is 30 seconds. Lower
390
	  number will mean faster convergence but bigger network load.
391

    
392
	<tag>timeouttime <M>number</M>
393
	  </tag>specifies how old route has to be to be considered unreachable. Default is 4*period.
394

    
395
	<tag>garbagetime <M>number</M>
396
	  </tag>specifies how old route has to be to be discarded. Default is 10*period.
397
</descrip>
398

    
399
<p>In addition, rip defines two filter variables, both of type it. <cf>rip_metric</cf> is rip
400
metric of current route, <cf>rip_tag</cf> is tag of current route.
401

    
402
<code>
403
protocol rip MyRIP_test {
404
        debug all;
405
        port 1520;
406
        period 7;
407
        garbagetime 60;
408
        interface "*";
409
        honour neighbour;
410
        passwords { password "ahoj" from 0 to 10;
411
                password "nazdar" from 10;
412
        }
413
        authentication none;
414
        import filter { print "importing"; accept; };
415
        export filter { print "exporting"; accept; };
416
}
417
</code>
418

    
419
</article>
420

    
421
<!--
422
# LocalWords: IPv doctype verb GPL Cisco sgml html Cisco's unix dvi sgmltools linuxdoc dtd descrip config conf syslog stderr auth ospf bgp router's IP expr num inst bool int ip px len enum cf md rfc doc
423
-->