Commit graph

161 commits

Author SHA1 Message Date
Martin Mares
aa8761de94 Kernel route syncer now supports dynamic reconfiguration. Also it doesn't
depend on the startup counter hack now and uses a zero-time timer instead
to make itself scheduled after normal protocol startup.
2000-01-18 10:39:30 +00:00
Martin Mares
d272fe22dd Separated `official protocol names' used in status dumps from name templates
used for automatic generation of instance names.

	protocol->name is the official name
	protocol->template is the name template (usually "name%d"),
		should be all lowercase.

Updated all protocols to define the templates, checked that their configuration
grammar includes proto_name which generates the name and interns it in the
symbol table.
2000-01-17 11:52:50 +00:00
Martin Mares
f7fcb75252 Reconfiguration for device protocol. 2000-01-17 11:17:33 +00:00
Martin Mares
99278e1042 Wording changes. 2000-01-16 23:36:19 +00:00
Martin Mares
bf8558bc9c Converted shutdown to a kind of reconfiguration, it's no more handled
as a exception in protocol state machines. Introduced a `shutdown'
CLI command. Killed few reconfiguration bugs.
2000-01-16 17:40:26 +00:00
Martin Mares
50fe90edf3 First attempt on dynamic reconfiguration. There are still lots of bugs
and problems to solve, but the hardest part works.
2000-01-16 16:44:50 +00:00
Martin Mares
476e108425 Minor cleanups. 1999-12-16 13:51:43 +00:00
Martin Mares
e693ddff87 Handle cases when SIOCGIFINDEX is defined, but doesn't work (new glibc
with 2.0 kernels).
1999-12-16 13:23:32 +00:00
Martin Mares
a2867cd957 Better order of includes.
set_inaddr() moved to sysio.h.
1999-12-16 13:14:02 +00:00
Martin Mares
67ece6df42 Tried to clean up multicast handling. Now we don't try to guess
multicast abilities depending on definedness of symbols and use hard-wired
system-dependent configuration defines instead.

Please test whereever you can.
1999-12-16 13:06:13 +00:00
Martin Mares
f545d38707 Added universal locking mechanism which will solve problems
with protocols wanting to use the same port on the same interface
during reconfiguration time.

How to use locks: In the if_notify hook, just order locks for the
interfaces you want to work with and do the real socket opening after the
lock hook function gets called. When you stop using the socket, close
it and rfree() the lock.

Please update your protocols to use the new locking mechanism.
1999-12-09 18:54:20 +00:00
Martin Mares
30bc402ebb Temporary work-arounds for multicast problems. Needs further investigation. 1999-12-08 15:12:54 +00:00
Martin Mares
0da472d7e8 Except for special protocols (nowadays only the kernel syncer), don't
export host and link scope routes.
1999-12-08 14:16:13 +00:00
Martin Mares
dc82daaa9b - Path to control socket is selectable via command-line option.
- die() when control socket open failed.
1999-12-08 13:20:19 +00:00
Martin Mares
f78056fb2c Allow logging to stderr as well. 1999-12-06 13:51:04 +00:00
Martin Mares
a0c37b45e5 Logging is now configurable. You can define multiple log outputs (to both
files and syslog) and assign lists of message categories to each of them.
1999-12-06 13:45:56 +00:00
Martin Mares
a9c986f981 Added tracked_fopen() which is a fopen registered in resource database.
Will be used for log files.
1999-12-06 13:43:47 +00:00
Martin Mares
34350a5270 Implemented echoing of log messages to CLI connections. Just try `echo all'. 1999-12-06 12:34:45 +00:00
Martin Mares
afa8937ac8 Added tm_format_reltime() for formatting of relative time quantities. 1999-12-01 11:59:00 +00:00
Martin Mares
487d1afa52 Moved TIME_INFINITY to timer.h, so that it's publicly available. 1999-11-30 14:01:39 +00:00
Martin Mares
30770df2ab If the main event queue is not empty, call select() with zero timeout, so
that the events are ran again after the FD's are checked. This allows us
to schedule I/O checks between processing of user commands.
1999-11-17 12:04:24 +00:00
Martin Mares
b9672a845f The CLI I/O functions work as desired. 1999-10-31 15:43:44 +00:00
Martin Mares
7d3aab1c16 First steps of the Command Line Interface: I/O routines. 1999-10-29 12:10:10 +00:00
Martin Mares
b93abffae4 Implemented unix-domain sockets. 1999-10-29 12:09:29 +00:00
Martin Mares
ed6081502a Added skeleton of the client. Does nothing, but at least compiles. 1999-10-29 09:44:44 +00:00
Martin Mares
f782b72c53 Failure to set socket TOS is not a fatal error. 1999-10-02 11:06:44 +00:00
Martin Mares
f651941402 Added a function for generating 32-bit random numbers. 1999-08-17 20:47:40 +00:00
Martin Mares
4532a89e31 Taught Netlink how to behave in IPv6 world. 1999-08-03 19:37:37 +00:00
Martin Mares
4f22c98185 Support for IPv6 sockets. How nice one doesn't have to ifdef around
ten years of API evolution :-)
1999-08-03 19:36:51 +00:00
Martin Mares
dce267832a Basic support for IPv6. The system-dependent part doesn't work yet,
but the core routines are there and seem to be working.

   o  lib/ipv6.[ch] written
   o  Lexical analyser recognizes IPv6 addresses and when in IPv6
      mode, treats pure IPv4 addresses as router IDs.
   o  Router ID must be configured manually on IPv6 systems.
   o  Added SCOPE_ORGANIZATION for org-scoped IPv6 multicasts.
   o  Fixed few places where ipa_(hton|ntoh) was called as a function
      returning converted address.
1999-08-03 19:36:06 +00:00
Martin Mares
7de45ba4a0 Kernel route syncer supports multiple tables.
The changes are just too extensive for lazy me to list them
there, but see the comment at the top of sysdep/unix/krt.c.
The code got a bit more ifdeffy than I'd like, though.

Also fixed a bunch of FIXME's and added a couple of others. :)
1999-08-03 19:33:22 +00:00
Martin Mares
9273035403 Changes to interface handling on traditional Unices:
o  Aliases are interpreted as secondary addresses.
  o  When the system doesn't supply interface indices, generate
     our ones.
1999-08-03 19:30:20 +00:00
Martin Mares
913f7dc9f2 Added functions for parsing and formatting of dates. 1999-08-03 19:29:27 +00:00
Martin Mares
bd7f1081f2 Grrr, the "obvious fix" to multicasting code from yesterday was
fundamentally wrong. Reversed.
1999-06-01 15:31:43 +00:00
Martin Mares
c7208da0b7 Fix potential multicasting bug. 1999-05-31 20:28:46 +00:00
Martin Mares
bb027be1e2 Added extra argument to rt_update hook which contains a pointer to the
temporary attribute list.
1999-05-31 18:55:35 +00:00
Martin Mares
1c3c9dceb3 Removed one unused structure field. 1999-05-21 14:29:23 +00:00
Martin Mares
4f1a6d27b9 Kill remaining master_table relics in KRT code.
Make all protocols pass routing table to rte_update and rte_discard.
1999-05-17 20:16:53 +00:00
Martin Mares
9a158361da I rewrote the interface handling code, so that it supports multiple
addresses per interface (needed for example for IPv6 support).

Visible changes:

o  struct iface now contains a list of all interface addresses (represented
   by struct ifa), iface->addr points to the primary address (if any).
o  Interface has IF_UP set iff it's up and it has a primary address.
o  IF_UP is now independent on IF_IGNORED (i.e., you need to test IF_IGNORED
   in the protocols; I've added this, but please check).
o  The if_notify_change hook has been simplified (only one interface pointer
   etc.).
o  Introduced a ifa_notify_change hook. (For now, only the Direct protocol
   does use it -- it's wise to just listen to device routes in all other
   protocols.)
o  Removed IF_CHANGE_FLAGS notifier flag (it was meaningless anyway).
o  Updated all the code except netlink (I'll look at it tomorrow) to match
   the new semantics (please look at your code to ensure I did it right).

Things to fix:

o  Netlink.
o  Make krt-iface interpret "eth0:1"-type aliases as secondary addresses.
1999-05-06 21:38:11 +00:00
Martin Mares
4c5e5e3a1c Multicasts once again: When using SO_BINDTODEVICE, don't specify IP address
of the interface.
1999-04-14 12:29:47 +00:00
Martin Mares
1b50a1e4be Next attempt to get SO_BINDTODEVICE work :) 1999-04-14 11:39:07 +00:00
Martin Mares
36154beb70 Use SO_BINDTODEVICE if we're using old multicast API (i.e., struct ip_mreq
and not ip_mreqn). This should get multicasts on unnumbered PtP links work.
1999-04-14 11:21:02 +00:00
Martin Mares
01bd7759b2 Ignore alias interfaces (some day, we will treat them as pure secondary
interface addresses).
1999-04-12 18:07:05 +00:00
Martin Mares
08e2d6259a Removed TOS support. This simplifies many things a lot. 1999-04-12 18:01:07 +00:00
Martin Mares
61fb537c62 Use struct ip_mreqn' instead of struct ip_mreq' for multicast
operations on 2.1/2.2 kernels. This allows passing of real interface
indexes instead of referencing interfaces by their IP addresses which
fails badly in presence of unnumbered interfaces.

Unfortunately, this structure is not visible with glibc 2.0 as it provides
its own networking headers :-(  Both libc5 and glibc 2.1 should be OK.
1999-04-12 15:27:56 +00:00
Martin Mares
5a99ade413 Fixed a couple of bugs in handling of multicast sockets.
See comments in lib/socket.h for a detailed guide on how to use them.
1999-04-12 14:57:46 +00:00
Martin Mares
49ed70b48e Portability fixes. 1999-04-07 14:25:56 +00:00
Martin Mares
c10421d3d4 More changes to the kernel syncer.
o  Now compatible with filtering.
o  Learning of kernel routes supported only on CONFIG_SELF_CONSCIOUS
   systems (on the others it's impossible to get it semantically correct).
o  Learning now stores all of its routes in a separate fib and selects
   the ones the kernel really uses for forwarding packets.
o  Better treatment of CONFIG_AUTO_ROUTES ports.
o  Lots of internal changes.
1999-04-03 13:05:18 +00:00
Martin Mares
fe662dfd78 Fixed `too many interfaces' cases. 1999-04-02 13:38:54 +00:00
Pavel Machek
0498d92f95 Believe it or not, printf()'s does not work too much without this one. 1999-04-02 11:45:55 +00:00
Martin Mares
8cda9cdbcf Argh, the fix was wrong. 1999-04-01 19:23:59 +00:00
Martin Mares
e4241f24f2 Portability fixes. 1999-04-01 15:35:15 +00:00
Martin Mares
abae6e9cd3 First few FreeBSD portability fixes. 1999-04-01 15:33:52 +00:00
Martin Mares
5bc512aa3a Clarify resource dumps and include them in the main debugging dump. 1999-03-29 20:14:33 +00:00
Martin Mares
3f2a21fd34 Don't try to delete interface routes on CONFIG_AUTO_ROUTES systems. 1999-03-29 20:14:00 +00:00
Martin Mares
f54801ffed Moved all system-dependent #include's containing endianity conversion
functions to sysdep header endian.h.
1999-03-29 19:14:43 +00:00
Martin Mares
7e5f5ffdda Moved to a much more systematic way of configuring kernel protocols.
o  Nothing is configured automatically. You _need_ to specify
     the kernel syncer in config file in order to get it started.
  o  Syncing has been split to route syncer (protocol "Kernel") and
     interface syncer (protocol "Device"), device routes are generated
     by protocol "Direct" (now can exist in multiple instances, so that
     it will be possible to feed different device routes to different
     routing tables once multiple tables get supported).

See doc/bird.conf.example for a living example of these shiny features.
1999-03-26 21:44:38 +00:00
Martin Mares
111213f0b6 Fixed processing of !krt_capable() routes. Converted device route decisions
to the krt_capable mechanism as well.
1999-03-04 19:00:31 +00:00
Martin Mares
e16155ae4a KRT: Implemented asynchronous route / interface state notifications
(via Netlink). Tweaked kernel synchronization rules a bit. Discovered
locking bug in kernel Netlink :-)

Future plans: Hunt all the bugs and solve all the FIXME's.
1999-03-04 18:36:18 +00:00
Martin Mares
7a2105becd Use dmalloc instead of EFence when available (dmalloc has lot of improvements
over EFence and also hopefully smaller memory overhead, but sadly it's non-free
for commercial use).

If the DMALLOC_OPTIONS environment variable is not set, switch on `reasonable'
checks by default.

Also introduced mb_allocz() for cleared mb_alloc().
1999-03-04 11:36:26 +00:00
Martin Mares
53b7a2982a Fix several things I broke today. 1999-03-03 20:55:35 +00:00
Martin Mares
2d14045224 Rewrote the kernel syncer. The old layering was horrible.
The new kernel syncer is cleanly split between generic UNIX module
and OS dependent submodules:

  -  krt.c (the generic part)
  -  krt-iface (low-level functions for interface handling)
  -  krt-scan (low-level functions for routing table scanning)
  -  krt-set (low-level functions for setting of kernel routes)

krt-set and krt-iface are common for all BSD-like Unices, krt-scan is heavily
system dependent (most Unices require /dev/kmem parsing, Linux uses /proc),
Netlink substitues all three modules.

We expect each UNIX port supports kernel routing table scanning, kernel
interface table scanning, kernel route manipulation and possibly also
asynchronous event notifications (new route, interface state change;
not implemented yet) and build the KRT protocol on the top of these
primitive operations.
1999-03-03 19:49:56 +00:00
Martin Mares
e35ef181a4 o The if_change_too_big_p change was too high-spirited. Fixed.
o  Introduced if_find_by_index()
o  Recognizing two types of interface updates: full update (starting with
   if_start_update(), ending with if_end_update(), guaranteed to see
   all existing interfaces) and a partial update (only if_update(),
   usually due to asynchronous interface notifications).
1999-03-02 18:36:09 +00:00
Martin Mares
bcbd8cc3be Interface logic changes:
o  Introduced IF_LINK_UP flag corresponding to real link state.
o  Allowed addressless interfaces.
o  IF_UP is now automatically calculated and set iff the interface
   is administratively up, has link up and has an IP address assigned.
   It may be IF_IGNORED, though (as in case of the loopback).
o  Any changes which include up/down transition are considered small
   enough to not provoke artificial upping and downing of the interface.
o  When an interface disappears (i.e., it wasn't seen in the last scan),
   we announce this change only once.
o  IF_LOOPBACK implies IF_IGNORE.
1999-03-02 17:28:06 +00:00
Martin Mares
b4b3b39e20 Added SK_MAGIC type sockets for internal use by system dependent code,
especially for netlink communication.
1999-03-01 22:30:33 +00:00
Martin Mares
025d14cd5a Use traditional Unix route/iface interface only when CONFIG_NETLINK
is not defined. Also moved declarations of Unix iface logic to krt.h.
1999-03-01 19:05:58 +00:00
Martin Mares
013a9b91fe When shutting down, remove all routes (except for RTS_INHERIT and RTS_DEVICE
routes) from kernel routing tables unless the "persist" switch is set.
1999-02-13 20:46:03 +00:00
Martin Mares
0a2e9d9f56 Moved sanity check of protocol state during annoucements to rte_announce. 1999-02-13 20:19:24 +00:00
Martin Mares
f4aabcee62 Perform gracious shutdown upon receipt of SIGTERM. Finally we can
test the whole protocol shutdown code... :)
1999-02-13 20:15:36 +00:00
Martin Mares
4c9dd1e4b9 Synchronize signals to the main select/event/timer loop.
Parse command line options.
1999-02-13 19:43:21 +00:00
Martin Mares
4e9498cbb1 config->router_id works again. 1999-02-13 18:42:00 +00:00
Martin Mares
14dea0ed25 Run the event queue before writing SIGUSR dumps. 1999-02-11 22:51:15 +00:00
Martin Mares
e8f73195fa Added simple event scheduling system to avoid recursive calling
of various callbacks.

Events are just another resource type objects (thus automatically freed
and unlinked when the protocol using them shuts down). Each event can
be linked in at most one event list. For most purposes, just use the
global event list handled by the following functions:

	ev_schedule	Schedule event to be called at the next event
			scheduling point. If the event was already
			scheduled, it's just re-linked to the end of the list.
	ev_postpone	Postpone an already scheduled event, so that it
			won't get called. Postponed events can be scheduled
			again by ev_schedule().

You can also create custom event lists to build your own synchronization
primitives. Just use:

	ev_init_list	to initialize an event list
	ev_enqueue	to schedule event on specified event list
	ev_postpone	works as well for custom lists
	ev_run_list	to run all events on your custom list
	ev_run		to run a specific event and dequeue it
1999-02-11 21:18:26 +00:00
Martin Mares
10d807d000 Synced kernel interface to new interface. 1999-02-05 21:38:50 +00:00
Martin Mares
31b3e1bbf5 Implemented new configuration/reconfiguration interface and defined protocol
state machines. Full explanation will follow soon.
1999-02-05 21:37:34 +00:00
Pavel Machek
ca3d562b24 filters_init() renamed to filters_postconfig(). 1999-01-15 18:13:55 +00:00
Pavel Machek
b9d70dc84e Filters, second try. This time they have their own directory. 1999-01-15 16:49:17 +00:00
Pavel Machek
41183888ee Properly initialize filters. Also bumped version to 0.0.0 as it
actually does something.
1999-01-15 14:40:50 +00:00
Martin Mares
08c69a7720 die() -> bug() where appropriate. 1998-12-20 14:27:37 +00:00
Martin Mares
98e87c8628 Finer grained logging levels:
#define L_DEBUG "\001"   /* Debugging messages */
#define L_INFO "\002"    /* Informational messages */
#define L_WARN "\003"    /* Warnings */
#define L_ERR "\004"     /* Errors */
#define L_AUTH "\005"    /* Authorization failed etc. */
#define L_FATAL "\006"   /* Fatal errors */
#define L_TRACE "\002"   /* Protocol tracing */
#define L_INFO "\003"    /* Informational messages */
#define L_REMOTE "\004"  /* Remote protocol errors */
#define L_WARN "\004"    /* Local warnings */
#define L_ERR "\005"     /* Local errors */
#define L_AUTH "\006"    /* Authorization failed etc. */
#define L_FATAL "\007"   /* Fatal errors */
#define L_BUG "\010"     /* BIRD bugs */

Introduced bug() which is like die(), but with level L_BUG. Protocols
should _never_ call die() as it should be used only during initialization
and on irrecoverable catastrophic events like out of memory.

Also introduced ASSERT() which behaves like normal assert(), but it calls
bug() when assertion fails. When !defined(DEBUGGING), it gets ignored.
1998-12-20 14:24:35 +00:00
Martin Mares
8e66a0ebb9 Hopefully finished kernel syncer (krt) rewrite:
o  Interface syncing is now a part of krt and it can have configurable
     parameters. Actually, the only one is scan rate now :)
  o  Kernel routing table syncing is now synchronized with interface
     syncing (we need the most recent version of the interface list
     to prevent lots of routes to non-existent destinations from
     appearing). Instead of its own timer, we just check if it's
     route scan time after each iface list scan.
  o  Syncing of device routes implemented.
  o  CONFIG_AUTO_ROUTES should control syncing of automatic device routes.
  o  Rewrote krt_remove_route() to really remove routes :)
  o  Better diagnostics.
  o  Fixed a couple of bugs.
1998-12-08 18:37:58 +00:00
Martin Mares
f39e4713c2 Rewritten kernel syncer. Now uses the rta trickery I've introduced yesterday
and does things "the right way". Few things are still missing (device
routes etc.), I'll add them later in the evening.
1998-12-08 16:20:13 +00:00
Martin Mares
12df4d909b KRF_* flags moved to krt.h as they are internal to kernel syncer,
fib->pad0,pad1 renamed to x0,x1 and in case of struct net x0 is reserved
for kernel syncing as well.
1998-12-07 10:15:42 +00:00
Martin Mares
980ffedbb0 Kernel syncer is now configurable. It will probably need some more
options, but at least basic tuning is possible now.
1998-12-06 17:40:42 +00:00
Martin Mares
c74c0e3cdf First attempt at protocol configuration (now done only for RIP). 1998-11-27 21:09:57 +00:00
Martin Mares
70591fa064 Compile and use the new configuration code by default. 1998-11-27 19:37:07 +00:00
Martin Mares
9158ca99f7 Complain loudly if the logging buffer would overflow. 1998-11-16 21:41:21 +00:00
Martin Mares
7d83290780 Generate router_id automatically if possible (standard "smallest of local
regular interface addresses" rule).

Protocols should NOT rely on router_id existence -- when router ID is not
available, the router_id variable is set to zero and protocols requiring
valid router ID should just refuse to start, reporting such error to the log.
1998-10-19 18:13:36 +00:00
Martin Mares
0804525255 Basic kernel routing table syncing implemented. Learning of routes installed
by other programs or the kernel itself is not supported yet, but it's not
needed for development of other protocols.
1998-10-19 17:52:29 +00:00
Martin Mares
567e6c6220 Use (SOCK_DGRAM,IPPROTO_IP) socket instead of (SOCK_STREAM,IPPROTO_TCP).
This is exactly what Linux ifconfig does and seems to be the preferred way.
1998-10-19 17:48:45 +00:00
Martin Mares
4cf45766ba Exporting fill_in_sockaddr() for use by other unix-dependent code. 1998-10-19 17:47:50 +00:00
Martin Mares
7e7790c61f Since almost every UNIX system requires different techniques for reading
the kernel routing table as opposed to modifying it which is approximately
the same on non-netlink systems, I've split the kernel routing table
routines to read and write parts. To be implemented later ;-)
1998-10-18 12:50:43 +00:00
Martin Mares
0432c0173b Split protocol init to building of protocol list and real protocol init.
Added kernel route table syncer skeleton.
1998-10-18 11:53:21 +00:00
Martin Mares
47b793064c Solve chicken-and-egg problems with protocol startup. We now queue all inactive
protocols and don't send route/interface updates to them and when they come up,
we resend the whole route/interface tables privately.

Removed the "scan interface list after protocol start" work-around.
1998-10-17 11:05:18 +00:00
Martin Mares
93f1c532e9 Moved scanning of interfaces, so that they get initialized after all
routing protocol instances.
1998-10-14 13:38:17 +00:00
Martin Mares
c93214d442 o There are cases when SIOCGIFINDEX is defined, but it doesn't work. When
this happens, don't reject the whole interface, just mark it as index 0.
o  Removed Pavel's comment about EFAULT and SIGSEGV. EFAULT is a valid return
   code for cases where the buffer is too small.
o  Commented out the smart interface list size logic temporarily as it seems
   Linux 2.0 SIOCGIFCONF doesn't react to ifc_req==NULL sanely. Replaced it
   by exponential stepping.
1998-10-13 19:57:33 +00:00
Pavel Machek
fdf33cde1c Strange, on atrey ioctl() does not fill structure, and bird segfaults
on it. Now we "only" die().
1998-10-13 14:59:46 +00:00
Martin Mares
c25e90efed Added comment explaining `now'. 1998-07-15 19:42:23 +00:00
Martin Mares
28a9a189d7 Replaced remaining references of clock_t by bird_clock_t. 1998-07-10 08:32:18 +00:00
Pavel Machek
86b0023033 Making SIGUSR1 dump also all protocols. 1998-07-09 19:37:39 +00:00