summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2012-03-23 00:26:26 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2012-03-23 00:26:26 +0100
commit72aed1a00ba9e18116d6fd907f7e1a36d0a0a583 (patch)
treec753fb8b35af591812c5d64eeccdb6f9c9ff0c30 /sysdep/unix
parent89647357af0d8507652f257f1e8f5679fe9a7078 (diff)
Adds krt_source route attribute.
Thanks Jeremie Dimino for the original patch.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/krt.Y4
-rw-r--r--sysdep/unix/krt.c23
-rw-r--r--sysdep/unix/krt.h5
-rw-r--r--sysdep/unix/main.c2
4 files changed, 30 insertions, 4 deletions
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y
index 18e1e52d..2c45c5fe 100644
--- a/sysdep/unix/krt.Y
+++ b/sysdep/unix/krt.Y
@@ -17,7 +17,7 @@ CF_DEFINES
CF_DECLS
-CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES)
+CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, KRT_SOURCE)
CF_GRAMMAR
@@ -90,6 +90,8 @@ kif_item:
}
;
+CF_ADDTO(dynamic_attr, KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_SOURCE); })
+
CF_CODE
CF_END
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 0fb8c4f9..de1188a1 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -907,12 +907,29 @@ krt_shutdown(struct proto *P)
return PS_DOWN;
}
+struct ea_list *
+krt_make_tmp_attrs(struct rte *rt, struct linpool *pool)
+{
+ struct ea_list *l = lp_alloc(pool, sizeof(struct ea_list) + 1 * sizeof(eattr));
+
+ l->next = NULL;
+ l->flags = EALF_SORTED;
+ l->count = 1;
+ l->attrs[0].id = EA_KRT_SOURCE;
+ l->attrs[0].flags = 0;
+ l->attrs[0].type = EAF_TYPE_INT | EAF_TEMP;
+ l->attrs[0].u.data = rt->u.krt.proto;
+
+ return l;
+}
+
static struct proto *
krt_init(struct proto_config *c)
{
struct krt_proto *p = proto_new(c, sizeof(struct krt_proto));
p->p.accept_ra_types = RA_OPTIMAL;
+ p->p.make_tmp_attrs = krt_make_tmp_attrs;
p->p.import_control = krt_import_control;
p->p.rt_notify = krt_notify;
@@ -952,12 +969,18 @@ krt_get_attr(eattr * a, byte * buf, int buflen UNUSED)
{
switch (a->id)
{
+ case EA_KRT_SOURCE:
+ bsprintf(buf, "source");
+ return GA_NAME;
+
case EA_KRT_PREFSRC:
bsprintf(buf, "prefsrc");
return GA_NAME;
+
case EA_KRT_REALM:
bsprintf(buf, "realm");
return GA_NAME;
+
default:
return GA_UNKNOWN;
}
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
index b0c4dc5e..aa1eccaa 100644
--- a/sysdep/unix/krt.h
+++ b/sysdep/unix/krt.h
@@ -28,8 +28,9 @@ struct kif_proto;
#define KRF_DELETE 3 /* Should be deleted */
#define KRF_IGNORE 4 /* To be ignored */
-#define EA_KRT_PREFSRC EA_CODE(EAP_KRT, 0)
-#define EA_KRT_REALM EA_CODE(EAP_KRT, 1)
+#define EA_KRT_SOURCE EA_CODE(EAP_KRT, 0)
+#define EA_KRT_PREFSRC EA_CODE(EAP_KRT, 1)
+#define EA_KRT_REALM EA_CODE(EAP_KRT, 2)
/* Whenever we recognize our own routes, we allow learing of foreign routes */
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index a4e80154..9219da9b 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -191,7 +191,7 @@ sysdep_preconfig(struct config *c)
init_list(&c->logfiles);
#ifdef PATH_IPROUTE_DIR
- // read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 256);
+ read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 256);
read_iproute_table(PATH_IPROUTE_DIR "/rt_realms", "ipr_", 256);
read_iproute_table(PATH_IPROUTE_DIR "/rt_scopes", "ips_", 256);
read_iproute_table(PATH_IPROUTE_DIR "/rt_tables", "ipt_", 256);