KRT: Remove KRF_SYNC_ERROR flag
This info is now stored in an internal bmap. Unfortunately, net.flags is still needed for temporary kernel data.
This commit is contained in:
parent
90a9c97e38
commit
cc75b3e1dc
6 changed files with 40 additions and 14 deletions
|
@ -348,6 +348,7 @@ struct rt_show_data {
|
|||
struct proto *export_protocol;
|
||||
struct channel *export_channel;
|
||||
struct config *running_on_config;
|
||||
struct krt_proto *kernel;
|
||||
int export_mode, primary_only, filtered, stats, show_for;
|
||||
|
||||
int table_open; /* Iteration (fit) is open */
|
||||
|
@ -452,9 +453,6 @@ typedef struct rta {
|
|||
#define RTD_PROHIBIT 4 /* Administratively prohibited */
|
||||
#define RTD_MAX 5
|
||||
|
||||
/* Flags for net->n.flags, used by kernel syncer */
|
||||
#define KRF_SYNC_ERROR 0x40 /* Error during kernel table synchronization */
|
||||
|
||||
#define RTAF_CACHED 1 /* This is a cached rta */
|
||||
|
||||
#define IGP_METRIC_UNKNOWN 0x80000000 /* Default igp_metric used when no other
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "nest/cli.h"
|
||||
#include "nest/iface.h"
|
||||
#include "filter/filter.h"
|
||||
#include "sysdep/unix/krt.h"
|
||||
|
||||
static void
|
||||
rt_show_table(struct cli *c, struct rt_show_data *d)
|
||||
|
@ -28,13 +29,20 @@ rt_show_table(struct cli *c, struct rt_show_data *d)
|
|||
d->last_table = d->tab;
|
||||
}
|
||||
|
||||
static inline struct krt_proto *
|
||||
rt_show_get_kernel(struct rt_show_data *d)
|
||||
{
|
||||
struct proto_config *krt = d->tab->table->config->krt_attached;
|
||||
return krt ? (struct krt_proto *) krt->proto : NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, int primary)
|
||||
{
|
||||
byte from[IPA_MAX_TEXT_LENGTH+8];
|
||||
byte tm[TM_DATETIME_BUFFER_SIZE], info[256];
|
||||
rta *a = e->attrs;
|
||||
int sync_error = (e->net->n.flags & KRF_SYNC_ERROR);
|
||||
int sync_error = d->kernel ? krt_get_sync_error(d->kernel, e) : 0;
|
||||
void (*get_route_info)(struct rte *, byte *buf);
|
||||
struct nexthop *nh;
|
||||
|
||||
|
@ -230,6 +238,7 @@ rt_show_cont(struct cli *c)
|
|||
FIB_ITERATE_INIT(&d->fit, &d->tab->table->fib);
|
||||
d->table_open = 1;
|
||||
d->table_counter++;
|
||||
d->kernel = rt_show_get_kernel(d);
|
||||
|
||||
d->show_counter_last = d->show_counter;
|
||||
d->rt_counter_last = d->rt_counter;
|
||||
|
@ -260,6 +269,7 @@ rt_show_cont(struct cli *c)
|
|||
d->net_counter - d->net_counter_last, d->tab->table->name);
|
||||
}
|
||||
|
||||
d->kernel = NULL;
|
||||
d->table_open = 0;
|
||||
d->tab = NODE_NEXT(d->tab);
|
||||
|
||||
|
@ -403,6 +413,7 @@ rt_show(struct rt_show_data *d)
|
|||
WALK_LIST(tab, d->tables)
|
||||
{
|
||||
d->tab = tab;
|
||||
d->kernel = rt_show_get_kernel(d);
|
||||
|
||||
if (d->show_for)
|
||||
n = net_route(tab->table, d->addr);
|
||||
|
|
|
@ -357,10 +357,13 @@ krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old)
|
|||
if (new)
|
||||
err = krt_send_route(p, RTM_ADD, new);
|
||||
|
||||
if (err < 0)
|
||||
n->n.flags |= KRF_SYNC_ERROR;
|
||||
else
|
||||
n->n.flags &= ~KRF_SYNC_ERROR;
|
||||
if (new)
|
||||
{
|
||||
if (err < 0)
|
||||
bmap_clear(&p->sync_map, new->id);
|
||||
else
|
||||
bmap_set(&p->sync_map, new->id);
|
||||
}
|
||||
}
|
||||
|
||||
#define SKIP(ARG...) do { DBG("KRT: Ignoring route - " ARG); return; } while(0)
|
||||
|
|
|
@ -1399,7 +1399,7 @@ nl_replace_rte(struct krt_proto *p, rte *e)
|
|||
|
||||
|
||||
void
|
||||
krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old)
|
||||
krt_replace_rte(struct krt_proto *p, net *n UNUSED, rte *new, rte *old)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
|
@ -1428,10 +1428,13 @@ krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old)
|
|||
err = nl_add_rte(p, new);
|
||||
}
|
||||
|
||||
if (err < 0)
|
||||
n->n.flags |= KRF_SYNC_ERROR;
|
||||
else
|
||||
n->n.flags &= ~KRF_SYNC_ERROR;
|
||||
if (new)
|
||||
{
|
||||
if (err < 0)
|
||||
bmap_clear(&p->sync_map, new->id);
|
||||
else
|
||||
bmap_set(&p->sync_map, new->id);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -677,7 +677,7 @@ krt_got_route(struct krt_proto *p, rte *e)
|
|||
|
||||
if (!new)
|
||||
verdict = KRF_DELETE;
|
||||
else if ((net->n.flags & KRF_SYNC_ERROR) || !krt_same_dest(e, new))
|
||||
else if (!bmap_test(&p->sync_map, new->id) || !krt_same_dest(e, new))
|
||||
verdict = KRF_UPDATE;
|
||||
else
|
||||
verdict = KRF_SEEN;
|
||||
|
@ -1094,6 +1094,7 @@ krt_start(struct proto *P)
|
|||
default: log(L_ERR "KRT: Tried to start with strange net type: %d", p->p.net_type); return PS_START; break;
|
||||
}
|
||||
|
||||
bmap_init(&p->sync_map, p->p.pool, 1024);
|
||||
add_tail(&krt_proto_list, &p->krt_node);
|
||||
|
||||
#ifdef KRT_ALLOW_LEARN
|
||||
|
@ -1133,6 +1134,7 @@ krt_shutdown(struct proto *P)
|
|||
|
||||
krt_sys_shutdown(p);
|
||||
rem_node(&p->krt_node);
|
||||
bmap_free(&p->sync_map);
|
||||
|
||||
return PS_DOWN;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ struct krt_proto {
|
|||
timer *scan_timer;
|
||||
#endif
|
||||
|
||||
struct bmap sync_map; /* Keeps track which exported routes were successfully written to kernel */
|
||||
node krt_node; /* Node in krt_proto_list */
|
||||
byte af; /* Kernel address family (AF_*) */
|
||||
byte ready; /* Initial feed has been finished */
|
||||
|
@ -86,6 +87,14 @@ void kif_request_scan(void);
|
|||
void krt_got_route(struct krt_proto *p, struct rte *e);
|
||||
void krt_got_route_async(struct krt_proto *p, struct rte *e, int new);
|
||||
|
||||
static inline int
|
||||
krt_get_sync_error(struct krt_proto *p, struct rte *e)
|
||||
{
|
||||
return (p->p.proto_state == PS_UP) &&
|
||||
bmap_test(&p->p.main_channel->export_map, e->id) &&
|
||||
!bmap_test(&p->sync_map, e->id);
|
||||
}
|
||||
|
||||
/* Values for rte->u.krt_sync.src */
|
||||
#define KRT_SRC_UNKNOWN -1 /* Nobody knows */
|
||||
#define KRT_SRC_BIRD 0 /* Our route (not passed in async mode) */
|
||||
|
|
Loading…
Reference in a new issue