Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / krt.h @ 153f02da

History | View | Annotate | Download (4.38 KB)

1 7e7790c6 Martin Mares
/*
2 2d140452 Martin Mares
 *        BIRD -- UNIX Kernel Route Syncer
3 7e7790c6 Martin Mares
 *
4 832fa033 Martin Mares
 *        (c) 1998--2000 Martin Mares <mj@ucw.cz>
5 7e7790c6 Martin Mares
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8
9
#ifndef _BIRD_KRT_H_
10
#define _BIRD_KRT_H_
11
12 7de45ba4 Martin Mares
struct config;
13 2d140452 Martin Mares
struct krt_config;
14
struct krt_proto;
15 7e5f5ffd Martin Mares
struct kif_config;
16
struct kif_proto;
17 2d140452 Martin Mares
18 7152e5ef Jan Moskyto Matejka
#include "sysdep/config.h"
19
#include CONFIG_INCLUDE_KRTSYS_H
20 7e7790c6 Martin Mares
21 32f95476 Ondrej Zajicek
/* Flags stored in net->n.flags, rest are in nest/route.h */
22 12df4d90 Martin Mares
23 c10421d3 Martin Mares
#define KRF_VERDICT_MASK 0x0f
24 f39e4713 Martin Mares
#define KRF_CREATE 0                        /* Not seen in kernel table */
25 12df4d90 Martin Mares
#define KRF_SEEN 1                        /* Seen in kernel table during last scan */
26
#define KRF_UPDATE 2                        /* Need to update this entry */
27 f39e4713 Martin Mares
#define KRF_DELETE 3                        /* Should be deleted */
28 c10421d3 Martin Mares
#define KRF_IGNORE 4                        /* To be ignored */
29
30 8d9eef17 Ondrej Zajicek
#define KRT_DEFAULT_ECMP_LIMIT        16
31
32 72aed1a0 Ondrej Zajicek
#define EA_KRT_SOURCE        EA_CODE(EAP_KRT, 0)
33 9ba2798c Ondrej Zajicek
#define EA_KRT_METRIC        EA_CODE(EAP_KRT, 1)
34 71ca7716 Ondrej Zajicek
35 c10421d3 Martin Mares
/* Whenever we recognize our own routes, we allow learing of foreign routes */
36
37
#ifdef CONFIG_SELF_CONSCIOUS
38
#define KRT_ALLOW_LEARN
39
#endif
40 12df4d90 Martin Mares
41 2d140452 Martin Mares
/* krt.c */
42 7e7790c6 Martin Mares
43
extern struct protocol proto_unix_kernel;
44
45 10d807d0 Martin Mares
struct krt_config {
46
  struct proto_config c;
47 396dfa90 Ondrej Zajicek
  struct krt_params sys;        /* Sysdep params */
48 2d140452 Martin Mares
  int persist;                        /* Keep routes when we exit */
49 7e5f5ffd Martin Mares
  int scan_time;                /* How often we re-scan routes */
50 2d140452 Martin Mares
  int learn;                        /* Learn routes from other sources */
51 c429d4a4 Ondrej Zajicek
  int devroutes;                /* Allow export of device routes */
52 0c791f87 Ondrej Zajicek
  int graceful_restart;                /* Regard graceful restart recovery */
53 7e7790c6 Martin Mares
};
54
55 10d807d0 Martin Mares
struct krt_proto {
56
  struct proto p;
57 c6964c30 Ondrej Zajicek
  struct krt_state sys;                /* Sysdep state */
58
59 c10421d3 Martin Mares
#ifdef KRT_ALLOW_LEARN
60
  struct rtable krt_table;        /* Internal table of inherited routes */
61
#endif
62 c6964c30 Ondrej Zajicek
63
#ifndef CONFIG_ALL_TABLES_AT_ONCE
64 7de45ba4 Martin Mares
  timer *scan_timer;
65
#endif
66 c6964c30 Ondrej Zajicek
67
  node krt_node;                /* Node in krt_proto_list */
68 29a64162 Ondrej Zajicek (work)
  byte af;                        /* Kernel address family (AF_*) */
69 0c791f87 Ondrej Zajicek
  byte ready;                        /* Initial feed has been finished */
70
  byte initialized;                /* First scan has been finished */
71 7069fc9e Ondrej Zajicek
  byte reload;                        /* Next scan is doing reload */
72 10d807d0 Martin Mares
};
73
74 7de45ba4 Martin Mares
extern pool *krt_pool;
75 980ffedb Martin Mares
76 2d140452 Martin Mares
#define KRT_CF ((struct krt_config *)p->p.cf)
77
78 832fa033 Martin Mares
#define KRT_TRACE(pr, fl, msg, args...) do {        \
79
  DBG("KRT: " msg "\n" , ## args);                \
80
  if (pr->p.debug & fl)                                \
81
    { log(L_TRACE "%s: " msg, pr->p.name , ## args); } } while(0)
82
83 396dfa90 Ondrej Zajicek
struct proto_config * kif_init_config(int class);
84 09686693 Ondrej Zajicek
void kif_request_scan(void);
85 2d140452 Martin Mares
void krt_got_route(struct krt_proto *p, struct rte *e);
86 e16155ae Martin Mares
void krt_got_route_async(struct krt_proto *p, struct rte *e, int new);
87
88
/* Values for rte->u.krt_sync.src */
89
#define KRT_SRC_UNKNOWN        -1        /* Nobody knows */
90
#define KRT_SRC_BIRD         0        /* Our route (not passed in async mode) */
91
#define KRT_SRC_REDIRECT 1        /* Redirect route, delete it */
92
#define KRT_SRC_ALIEN         2        /* Route installed by someone else */
93 ff2857b0 Ondrej Zajicek
#define KRT_SRC_KERNEL         3        /* Kernel routes, are ignored by krt syncer */
94 2d140452 Martin Mares
95 7e5f5ffd Martin Mares
extern struct protocol proto_unix_iface;
96
97
struct kif_config {
98
  struct proto_config c;
99 396dfa90 Ondrej Zajicek
  struct kif_params sys;        /* Sysdep params */
100 153f02da Ondrej Zajicek (work)
101
  list iface_list;                /* List of iface configs (struct kif_iface_config) */
102 7e5f5ffd Martin Mares
  int scan_time;                /* How often we re-scan interfaces */
103 153f02da Ondrej Zajicek (work)
};
104
105
struct kif_iface_config {
106
  struct iface_patt i;
107
108
  ip_addr pref_v4;
109
  ip_addr pref_v6;
110
  ip_addr pref_ll;
111 7e5f5ffd Martin Mares
};
112
113
struct kif_proto {
114
  struct proto p;
115 c6964c30 Ondrej Zajicek
  struct kif_state sys;                /* Sysdep state */
116 7e5f5ffd Martin Mares
};
117
118 7152e5ef Jan Moskyto Matejka
extern struct kif_proto *kif_proto;
119 1e4891e4 Ondrej Zajicek (work)
120 7e5f5ffd Martin Mares
#define KIF_CF ((struct kif_config *)p->p.cf)
121
122 153f02da Ondrej Zajicek (work)
struct kif_iface_config * kif_get_iface_config(struct iface *iface);
123 396dfa90 Ondrej Zajicek
struct proto_config * krt_init_config(int class);
124
125 7e7790c6 Martin Mares
126 f1aceff5 Ondrej Zajicek
/* krt sysdep */
127 2d140452 Martin Mares
128 9ddbfbdd Jan Moskyto Matejka
void krt_sys_io_init(void);
129 396dfa90 Ondrej Zajicek
void krt_sys_init(struct krt_proto *);
130 9ddbfbdd Jan Moskyto Matejka
int krt_sys_start(struct krt_proto *);
131 c6964c30 Ondrej Zajicek
void krt_sys_shutdown(struct krt_proto *);
132 396dfa90 Ondrej Zajicek
int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n, struct krt_config *o);
133 7e7790c6 Martin Mares
134 396dfa90 Ondrej Zajicek
void krt_sys_preconfig(struct config *);
135
void krt_sys_postconfig(struct krt_config *);
136
void krt_sys_init_config(struct krt_config *);
137
void krt_sys_copy_config(struct krt_config *, struct krt_config *);
138 7e7790c6 Martin Mares
139 396dfa90 Ondrej Zajicek
int  krt_capable(rte *e);
140
void krt_do_scan(struct krt_proto *);
141 7a2c48da Ondrej Zajicek
void krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old, struct ea_list *eattrs);
142 9fdf9d29 Ondrej Zajicek
int krt_sys_get_attr(eattr *a, byte *buf, int buflen);
143 7e7790c6 Martin Mares
144 025d14cd Martin Mares
145 f1aceff5 Ondrej Zajicek
/* kif sysdep */
146 025d14cd Martin Mares
147 396dfa90 Ondrej Zajicek
void kif_sys_init(struct kif_proto *);
148
void kif_sys_start(struct kif_proto *);
149
void kif_sys_shutdown(struct kif_proto *);
150
int kif_sys_reconfigure(struct kif_proto *, struct kif_config *, struct kif_config *);
151
152
void kif_sys_init_config(struct kif_config *);
153
void kif_sys_copy_config(struct kif_config *, struct kif_config *);
154
155
void kif_do_scan(struct kif_proto *);
156 8e66a0eb Martin Mares
157 153f02da Ondrej Zajicek (work)
int kif_update_sysdep_addr(struct iface *i);
158 2d140452 Martin Mares
159 7e7790c6 Martin Mares
#endif