summaryrefslogtreecommitdiff
path: root/sysdep
diff options
context:
space:
mode:
Diffstat (limited to 'sysdep')
-rw-r--r--sysdep/bsd/krt-iface.h8
-rw-r--r--sysdep/bsd/krt-scan.h1
-rw-r--r--sysdep/bsd/krt-sock.h8
-rw-r--r--sysdep/linux/netlink/krt-iface.h1
-rw-r--r--sysdep/linux/netlink/krt-scan.h3
-rw-r--r--sysdep/linux/netlink/krt-set.h1
-rw-r--r--sysdep/unix/krt-iface.h3
-rw-r--r--sysdep/unix/krt-set.h1
-rw-r--r--sysdep/unix/krt.Y4
-rw-r--r--sysdep/unix/krt.c32
-rw-r--r--sysdep/unix/krt.h2
11 files changed, 54 insertions, 10 deletions
diff --git a/sysdep/bsd/krt-iface.h b/sysdep/bsd/krt-iface.h
index 7d96fe88..7f0d52bd 100644
--- a/sysdep/bsd/krt-iface.h
+++ b/sysdep/bsd/krt-iface.h
@@ -12,6 +12,14 @@
/*
* We don't have split iface/scan/set parts. See krt-sock.h.
*/
+
+struct krt_if_params {
+};
+
+struct krt_if_status {
+};
+
static inline int kif_params_same(struct krt_if_params *old UNUSED, struct krt_if_params *new UNUSED) { return 1; }
+static inline void kif_copy_params(struct krt_if_params *dest UNUSED, struct krt_if_params *src UNUSED) { }
#endif
diff --git a/sysdep/bsd/krt-scan.h b/sysdep/bsd/krt-scan.h
index 284df5ea..19cd930d 100644
--- a/sysdep/bsd/krt-scan.h
+++ b/sysdep/bsd/krt-scan.h
@@ -17,5 +17,6 @@ struct krt_scan_status {
};
static inline int krt_scan_params_same(struct krt_scan_params *o UNUSED, struct krt_scan_params *n UNUSED) { return 1; }
+static inline void krt_scan_copy_params(struct krt_scan_params *d UNUSED, struct krt_scan_params *s UNUSED) { }
#endif
diff --git a/sysdep/bsd/krt-sock.h b/sysdep/bsd/krt-sock.h
index d2a7efbc..aab639c4 100644
--- a/sysdep/bsd/krt-sock.h
+++ b/sysdep/bsd/krt-sock.h
@@ -34,13 +34,9 @@ struct krt_set_params {
struct krt_set_status {
};
-struct krt_if_params {
-};
-
-struct krt_if_status {
-};
-
static inline int krt_set_params_same(struct krt_set_params *o UNUSED, struct krt_set_params *n UNUSED) { return 1; }
+static inline void krt_set_copy_params(struct krt_set_params *d UNUSED, struct krt_set_params *s UNUSED) { }
+
void krt_read_msg(struct proto *p, struct ks_msg *msg, int scan);
#endif
diff --git a/sysdep/linux/netlink/krt-iface.h b/sysdep/linux/netlink/krt-iface.h
index f44ca27f..770c6e2e 100644
--- a/sysdep/linux/netlink/krt-iface.h
+++ b/sysdep/linux/netlink/krt-iface.h
@@ -24,5 +24,6 @@ static inline void krt_if_shutdown(struct kif_proto *p UNUSED) { };
static inline void krt_if_io_init(void) { };
static inline int kif_params_same(struct krt_if_params *old UNUSED, struct krt_if_params *new UNUSED) { return 1; }
+static inline void kif_copy_params(struct krt_if_params *dest UNUSED, struct krt_if_params *src UNUSED) { }
#endif
diff --git a/sysdep/linux/netlink/krt-scan.h b/sysdep/linux/netlink/krt-scan.h
index 7885f078..9b5e075b 100644
--- a/sysdep/linux/netlink/krt-scan.h
+++ b/sysdep/linux/netlink/krt-scan.h
@@ -30,4 +30,7 @@ static inline int krt_scan_params_same(struct krt_scan_params *o, struct krt_sca
return o->table_id == n->table_id;
}
+static inline void krt_scan_copy_params(struct krt_scan_params *d UNUSED, struct krt_scan_params *s UNUSED) { }
+/* table_id copied in krt_copy_config() */
+
#endif
diff --git a/sysdep/linux/netlink/krt-set.h b/sysdep/linux/netlink/krt-set.h
index 83d082d0..4a08217b 100644
--- a/sysdep/linux/netlink/krt-set.h
+++ b/sysdep/linux/netlink/krt-set.h
@@ -23,5 +23,6 @@ static inline void krt_set_construct(struct krt_config *c UNUSED) { };
static inline void krt_set_start(struct krt_proto *p UNUSED, int first UNUSED) { };
static inline void krt_set_shutdown(struct krt_proto *p UNUSED, int last UNUSED) { };
static inline int krt_set_params_same(struct krt_set_params *o UNUSED, struct krt_set_params *n UNUSED) { return 1; }
+static inline void krt_set_copy_params(struct krt_set_params *d UNUSED, struct krt_set_params *s UNUSED) { }
#endif
diff --git a/sysdep/unix/krt-iface.h b/sysdep/unix/krt-iface.h
index 48075d6b..9e12bcc3 100644
--- a/sysdep/unix/krt-iface.h
+++ b/sysdep/unix/krt-iface.h
@@ -17,6 +17,7 @@ struct krt_if_status {
extern int if_scan_sock;
-static inline int kif_params_same(struct krt_if_params *old, struct krt_if_params *new) { return 1; }
+static inline int kif_params_same(struct krt_if_params *old UNUSED, struct krt_if_params *new UNUSED) { return 1; }
+static inline void kif_copy_params(struct krt_if_params *dest UNUSED, struct krt_if_params *src UNUSED) { }
#endif
diff --git a/sysdep/unix/krt-set.h b/sysdep/unix/krt-set.h
index 5d0b2134..87cffcfc 100644
--- a/sysdep/unix/krt-set.h
+++ b/sysdep/unix/krt-set.h
@@ -16,5 +16,6 @@ struct krt_set_status {
};
static inline int krt_set_params_same(struct krt_set_params *o UNUSED, struct krt_set_params *n UNUSED) { return 1; }
+static inline void krt_set_copy_params(struct krt_set_params *d UNUSED, struct krt_set_params *s UNUSED) { }
#endif
diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y
index 0375a13b..86081966 100644
--- a/sysdep/unix/krt.Y
+++ b/sysdep/unix/krt.Y
@@ -30,7 +30,7 @@ kern_proto_start: proto_start KERNEL {
if (cf_krt)
cf_error("Kernel protocol already defined");
#endif
- cf_krt = this_proto = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config));
+ cf_krt = this_proto = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config), $1);
this_proto->preference = DEF_PREF_INHERITED;
THIS_KRT->scan_time = 60;
THIS_KRT->learn = THIS_KRT->persist = 0;
@@ -66,7 +66,7 @@ CF_ADDTO(proto, kif_proto '}')
kif_proto_start: proto_start DEVICE {
if (cf_kif)
cf_error("Kernel device protocol already defined");
- cf_kif = this_proto = proto_config_new(&proto_unix_iface, sizeof(struct kif_config));
+ cf_kif = this_proto = proto_config_new(&proto_unix_iface, sizeof(struct kif_config), $1);
this_proto->preference = DEF_PREF_DIRECT;
THIS_KIF->scan_time = 60;
init_list(&THIS_KIF->primary);
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 70570703..e5a8ce17 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -216,6 +216,23 @@ kif_reconfigure(struct proto *p, struct proto_config *new)
return 1;
}
+static void
+kif_copy_config(struct proto_config *dest, struct proto_config *src)
+{
+ struct kif_config *d = (struct kif_config *) dest;
+ struct kif_config *s = (struct kif_config *) src;
+
+ /* Shallow copy of everything (just scan_time currently) */
+ proto_copy_rest(dest, src, sizeof(struct krt_config));
+
+ /* Copy primary addr list */
+ cfg_copy_list(&d->primary, &s->primary, sizeof(struct kif_primary_item));
+
+ /* Fix sysdep parts */
+ kif_copy_params(&d->iface, &s->iface);
+}
+
+
struct protocol proto_unix_iface = {
name: "Device",
template: "device%d",
@@ -224,6 +241,7 @@ struct protocol proto_unix_iface = {
start: kif_start,
shutdown: kif_shutdown,
reconfigure: kif_reconfigure,
+ copy_config: kif_copy_config
};
/*
@@ -908,6 +926,19 @@ krt_reconfigure(struct proto *p, struct proto_config *new)
;
}
+static void
+krt_copy_config(struct proto_config *dest, struct proto_config *src)
+{
+ struct krt_config *d = (struct krt_config *) dest;
+ struct krt_config *s = (struct krt_config *) src;
+
+ /* Shallow copy of everything */
+ proto_copy_rest(dest, src, sizeof(struct krt_config));
+
+ /* Fix sysdep parts */
+ krt_set_copy_params(&d->set, &s->set);
+ krt_scan_copy_params(&d->scan, &s->scan);
+}
static int
krt_get_attr(eattr * a, byte * buf, int buflen UNUSED)
@@ -936,6 +967,7 @@ struct protocol proto_unix_kernel = {
start: krt_start,
shutdown: krt_shutdown,
reconfigure: krt_reconfigure,
+ copy_config: krt_copy_config,
get_attr: krt_get_attr,
#ifdef KRT_ALLOW_LEARN
dump: krt_dump,
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
index f83e6ee6..7bb4fe70 100644
--- a/sysdep/unix/krt.h
+++ b/sysdep/unix/krt.h
@@ -100,7 +100,7 @@ struct kif_config {
struct proto_config c;
struct krt_if_params iface;
int scan_time; /* How often we re-scan interfaces */
- list primary; /* Preferences for primary addresses */
+ list primary; /* Preferences for primary addresses (struct kif_primary_item) */
};
struct kif_proto {