summaryrefslogtreecommitdiff
path: root/sysdep/bsd/krt-sock.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2011-10-06 22:48:49 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2011-10-06 22:48:49 +0200
commit32f95476a8d60508ca9d24fe20b09899b72de9d7 (patch)
tree84c2084a43f5c76e5feff07a3b8cafb521d067f1 /sysdep/bsd/krt-sock.c
parent35c875f0d1eb7c72e0b0ab8a90eb32cbcbfdac02 (diff)
Signal problems with route installation to kernel tables.
Diffstat (limited to 'sysdep/bsd/krt-sock.c')
-rw-r--r--sysdep/bsd/krt-sock.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c
index f6bc4a2c..72295906 100644
--- a/sysdep/bsd/krt-sock.c
+++ b/sysdep/bsd/krt-sock.c
@@ -68,7 +68,7 @@ krt_capable(rte *e)
memcpy(p, body, (l > sizeof(*p) ? sizeof(*p) : l));\
body += l;}
-static void
+static int
krt_sock_send(int cmd, rte *e)
{
net *net = e->net;
@@ -160,7 +160,7 @@ krt_sock_send(int cmd, rte *e)
if(!i->addr) {
log(L_ERR "KRT: interface %s has no IP addess", i->name);
- return;
+ return -1;
}
fill_in_sockaddr(&gate, i->addr->ip, 0);
@@ -182,22 +182,27 @@ krt_sock_send(int cmd, rte *e)
if ((l = write(rt_sock, (char *)&msg, l)) < 0) {
log(L_ERR "KRT: Error sending route %I/%d to kernel", net->n.prefix, net->n.pxlen);
+ return -1;
}
+
+ return 0;
}
void
-krt_set_notify(struct krt_proto *p UNUSED, net *net, rte *new, rte *old)
+krt_set_notify(struct krt_proto *p UNUSED, net *n, rte *new, rte *old)
{
+ int err = 0;
+
if (old)
- {
- DBG("krt_remove_route(%I/%d)\n", net->n.prefix, net->n.pxlen);
- krt_sock_send(RTM_DELETE, old);
- }
+ krt_sock_send(RTM_DELETE, old);
+
if (new)
- {
- DBG("krt_add_route(%I/%d)\n", net->n.prefix, net->n.pxlen);
- krt_sock_send(RTM_ADD, new);
- }
+ err = krt_sock_send(RTM_ADD, new);
+
+ if (err < 0)
+ n->n.flags |= KRF_SYNC_ERROR;
+ else
+ n->n.flags &= ~KRF_SYNC_ERROR;
}
static int