summaryrefslogtreecommitdiff
path: root/sysdep/unix/krt.Y
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-07 13:06:01 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-07 13:06:01 +0100
commit153f02da3bce1f3f1a99295648679c71327e8319 (patch)
treeb7b7acf8026ba182f3a81f2d6da975b0b1524972 /sysdep/unix/krt.Y
parent4ae3ee1200b386219673c2168eae996c6207b077 (diff)
Nest: Maintain separate IPv4, IPv6 and LLv6 preferred addresses
Also redesign preferred address selection and update protocols to use appropriate preferred address. Based on a previous work by Jan Maria Matejka.
Diffstat (limited to 'sysdep/unix/krt.Y')
-rw-r--r--sysdep/unix/krt.Y44
1 files changed, 38 insertions, 6 deletions
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y
index b261c91e..3bf7da65 100644
--- a/sysdep/unix/krt.Y
+++ b/sysdep/unix/krt.Y
@@ -14,6 +14,7 @@ CF_DEFINES
#define THIS_KRT ((struct krt_config *) this_proto)
#define THIS_KIF ((struct kif_config *) this_proto)
+#define KIF_IFACE ((struct kif_iface_config *) this_ipatt)
static void
krt_set_merge_paths(struct channel_config *cc, uint merge, uint limit)
@@ -25,6 +26,17 @@ krt_set_merge_paths(struct channel_config *cc, uint merge, uint limit)
cc->merge_limit = limit;
}
+static void
+kif_set_preferred(ip_addr ip)
+{
+ if (ipa_is_ip4(ip))
+ KIF_IFACE->pref_v4 = ip;
+ else if (!ipa_is_link_local(ip))
+ KIF_IFACE->pref_v6 = ip;
+ else
+ KIF_IFACE->pref_ll = ip;
+}
+
CF_DECLS
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
@@ -88,18 +100,38 @@ CF_ADDTO(kif_proto, kif_proto kif_item ';')
kif_item:
proto_item
+ | INTERFACE kif_iface
| SCAN TIME expr {
/* Scan time of 0 means scan on startup only */
THIS_KIF->scan_time = $3;
}
- | PRIMARY opttext net_or_ipa {
- struct kif_primary_item *kpi = cfg_alloc(sizeof (struct kif_primary_item));
- kpi->pattern = $2;
- kpi->addr = $3;
- add_tail(&THIS_KIF->primary, &kpi->n);
- }
;
+kif_iface_start:
+{
+ this_ipatt = cfg_allocz(sizeof(struct kif_iface_config));
+ add_tail(&THIS_KIF->iface_list, NODE this_ipatt);
+ init_list(&this_ipatt->ipn_list);
+}
+
+kif_iface_item:
+ PREFERRED ipa { kif_set_preferred($2); }
+ ;
+
+kif_iface_opts:
+ /* empty */
+ | kif_iface_opts kif_iface_item ';'
+ ;
+
+kif_iface_opt_list:
+ /* empty */
+ | '{' kif_iface_opts '}'
+ ;
+
+kif_iface:
+ kif_iface_start iface_patt_list_nopx kif_iface_opt_list;
+
+
CF_ADDTO(dynamic_attr, KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_SOURCE); })
CF_ADDTO(dynamic_attr, KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_METRIC); })