Commit 7e5f5ffd authored by Martin Mares's avatar Martin Mares
Browse files

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.
parent 739ebd8e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ Core
- config: define ipaddr constants?
- config: better default protocol names

- do we really need preconfig?

- counters (according to SNMP MIB?)
- better memory allocators
- default preferences of protocols: prefer BGP over OSPF/RIP external routes?
+6 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
#	debug all
#}

protocol device {
protocol direct {
#	disabled
#	interface "-eth*", "*"
}
@@ -25,13 +25,16 @@ protocol kernel {
#	disabled
#	learn			# Learn all routes from the kernel
	persist			# Don't remove routes on bird shutdown
	scan time 10		# Scan kernel tables every 10 seconds
	route scan time 20	# But routes only every 20 seconds
	scan time 20		# Scan kernel routing table every 20 seconds
#	async off		# Netlink: Disable asynchronous events
#	input filter sink
#	output filter okay
}

protocol device {
	scan time 10		# Scan interfaces every 10 seconds
}

protocol static {
#	disabled
#	route 0.0.0.0/0 via 62.168.0.13
+13 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ void rt_dev_add_iface(char *);

CF_DECLS

CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DEVICE)
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
CF_KEYWORDS(INTERFACE, INPUT, OUTPUT, FILTER)

%type <i> idval
@@ -44,7 +44,7 @@ proto_start: PROTOCOL

proto_name:
   /* EMPTY */ {
     struct symbol *s = cf_default_name(this_proto->proto->name);
     struct symbol *s = cf_default_name(this_proto->proto->name, &this_proto->proto->name_counter);
     s->class = SYM_PROTO;
     s->def = this_proto;
     this_proto->name = s->name;
@@ -71,24 +71,30 @@ proto_item:
 | OUTPUT FILTER filter { this_proto->out_filter = $3; }
 ;

/* Device protocol */
/* Direct device route protocol */

CF_ADDTO(proto, dev_proto '}')

dev_proto_start: proto_start DEVICE {
     if (!(this_proto = cf_dev_proto)) cf_error("Device protocol already defined");
     cf_dev_proto = NULL;
dev_proto_start: proto_start DIRECT {
     struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
     struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));
     this_proto = &p->c;
     p->c.preference = DEF_PREF_DIRECT;
     init_list(&p->iface_list);
     k->pattern = "*";
     add_tail(&p->iface_list, &k->n);
   }
 ;

dev_proto:
   dev_proto_start '{'
   dev_proto_start proto_name '{'
 | dev_proto proto_item ';'
 | dev_proto dev_iface_list ';'
 ;

dev_iface_list:
   INTERFACE TEXT {
     /* FIXME: Beware of obscure semantics. */
     init_list(&((struct rt_dev_config *) this_proto)->iface_list);
     rt_dev_add_iface($2);
   }
+2 −18
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@
#include "conf/conf.h"
#include "lib/resource.h"

struct proto_config *cf_dev_proto;

static void
dev_if_notify(struct proto *p, unsigned c, struct iface *new, struct iface *old)
{
@@ -77,22 +75,8 @@ dev_init(struct proto_config *c)
  return p;
}

static void
dev_preconfig(struct protocol *x, struct config *c)
{
  struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
  struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));

  cf_dev_proto = &p->c;
  p->c.preference = DEF_PREF_DIRECT;
  init_list(&p->iface_list);
  k->pattern = "*";
  add_tail(&p->iface_list, &k->n);
}

struct protocol proto_device = {
  name:		"Device",
  priority:	100,
  preconfig:	dev_preconfig,
  name:		"Direct",
  priority:	90,
  init:		dev_init,
};
+4 −3
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ struct krt_if_params {
struct krt_if_status {
};

static inline void krt_if_preconfig(struct krt_config *c) { };
static inline void krt_if_start(struct krt_proto *p) { };
static inline void krt_if_shutdown(struct krt_proto *p) { };
static inline void krt_if_preconfig(struct kif_config *c) { };
static inline void krt_if_start(struct kif_proto *p) { };
static inline void krt_if_shutdown(struct kif_proto *p) { };
static inline void krt_if_io_init(void) { };

#endif
Loading