summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-25 14:24:35 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2015-11-25 14:24:35 +0100
commit04ae8ddaa15b72c265dc7cf038b733d235198754 (patch)
treeeadc4dfee9a0f0eba3446538129608dffbde4625 /sysdep/unix
parentd44e686e9bcae5850115c0e1adfe24523dce61ee (diff)
parent33b4f40acce02c90b4b7766c5c94ebf2d22765c6 (diff)
Merge branch 'master' into int-new
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c15
-rw-r--r--sysdep/unix/krt.c13
-rw-r--r--sysdep/unix/krt.h5
-rw-r--r--sysdep/unix/main.c2
4 files changed, 30 insertions, 5 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 0724667d..b636e799 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1328,6 +1328,18 @@ sk_passive_connected(sock *s, int type)
log(L_WARN "SOCK: Cannot get remote IP address for TCP<");
}
+ if (fd >= FD_SETSIZE)
+ {
+ /* FIXME: Call err_hook instead ? */
+ log(L_ERR "SOCK: Incoming connection from %I%J (port %d) %s",
+ t->daddr, ipa_is_link_local(t->daddr) ? t->iface : NULL,
+ t->dport, "rejected due to FD_SETSIZE limit");
+ close(fd);
+ t->fd = -1;
+ rfree(t);
+ return 1;
+ }
+
if (sk_setup(t) < 0)
{
/* FIXME: Call err_hook instead ? */
@@ -1404,6 +1416,9 @@ sk_open(sock *s)
if (fd < 0)
ERR("socket");
+ if (fd >= FD_SETSIZE)
+ ERR2("FD_SETSIZE limit reached");
+
s->af = af;
s->fd = fd;
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 5db682ca..63fc1c34 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -77,14 +77,15 @@ krt_io_init(void)
krt_pool = rp_new(&root_pool, "Kernel Syncer");
krt_filter_lp = lp_new(krt_pool, 4080);
init_list(&krt_proto_list);
+ krt_sys_io_init();
}
/*
* Interfaces
*/
+struct kif_proto *kif_proto;
static struct kif_config *kif_cf;
-static struct kif_proto *kif_proto;
static timer *kif_scan_timer;
static bird_clock_t kif_last_shot;
@@ -1126,7 +1127,11 @@ krt_start(struct proto *P)
krt_learn_init(p);
#endif
- krt_sys_start(p);
+ if (!krt_sys_start(p))
+ {
+ rem_node(&p->krt_node);
+ return PS_START;
+ }
krt_scan_timer_start(p);
@@ -1150,8 +1155,10 @@ krt_shutdown(struct proto *P)
p->ready = 0;
p->initialized = 0;
- krt_sys_shutdown(p);
+ if (p->p.proto_state == PS_START)
+ return PS_DOWN;
+ krt_sys_shutdown(p);
rem_node(&p->krt_node);
return PS_DOWN;
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
index 9d5d4e8c..d4a8717e 100644
--- a/sysdep/unix/krt.h
+++ b/sysdep/unix/krt.h
@@ -112,6 +112,8 @@ struct kif_proto {
struct kif_state sys; /* Sysdep state */
};
+struct kif_proto *kif_proto;
+
#define KIF_CF ((struct kif_config *)p->p.cf)
struct proto_config * krt_init_config(int class);
@@ -119,8 +121,9 @@ struct proto_config * krt_init_config(int class);
/* krt sysdep */
+void krt_sys_io_init(void);
void krt_sys_init(struct krt_proto *);
-void krt_sys_start(struct krt_proto *);
+int krt_sys_start(struct krt_proto *);
void krt_sys_shutdown(struct krt_proto *);
int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n, struct krt_config *o);
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index e31471da..24d34f60 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -96,7 +96,7 @@ drop_gid(gid_t gid)
static inline void
add_num_const(char *name, int val)
{
- struct symbol *s = cf_find_symbol(name);
+ struct symbol *s = cf_get_symbol(name);
s->class = SYM_CONSTANT | T_INT;
s->def = cfg_allocz(sizeof(struct f_val));
SYM_TYPE(s) = T_INT;