summaryrefslogtreecommitdiffstats
path: root/sysdep/unix
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2010-02-26 10:55:58 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2010-02-26 10:55:58 +0100
commitff2857b03db854f99902766ad842aaa5fa29ec3c (patch)
tree8484bfcabaa9805fab2ae188a6855314192d92e1 /sysdep/unix
parente81b440f6878605edd19ed62441648ac71260881 (diff)
downloadbird-ff2857b03db854f99902766ad842aaa5fa29ec3c.tar
bird-ff2857b03db854f99902766ad842aaa5fa29ec3c.zip
Many changes in (mainly) kernel syncers.
- BSD kernel syncer is now self-conscious and can learn alien routes - important bugfix in BSD kernel syncer (crash after protocol restart) - many minor changes and bugfixes in kernel syncers and neighbor cache - direct protocol does not generate host and link local routes - min_scope check is removed, all routes have SCOPE_UNIVERSE by default - also fixes some remaining compiler warnings
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c2
-rw-r--r--sysdep/unix/krt.c40
-rw-r--r--sysdep/unix/krt.h1
-rw-r--r--sysdep/unix/unix.h4
4 files changed, 27 insertions, 20 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 915baf4..02d59ab 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -663,7 +663,6 @@ get_sockaddr(struct sockaddr_in *sa, ip_addr *a, unsigned *port, int check)
static char *
sk_set_ttl_int(sock *s)
{
- int one = 1;
#ifdef IPV6
if (setsockopt(s->fd, SOL_IPV6, IPV6_UNICAST_HOPS, &s->ttl, sizeof(s->ttl)) < 0)
return "IPV6_UNICAST_HOPS";
@@ -671,6 +670,7 @@ sk_set_ttl_int(sock *s)
if (setsockopt(s->fd, SOL_IP, IP_TTL, &s->ttl, sizeof(s->ttl)) < 0)
return "IP_TTL";
#ifdef CONFIG_UNIX_DONTROUTE
+ int one = 1;
if (s->ttl == 1 && setsockopt(s->fd, SOL_SOCKET, SO_DONTROUTE, &one, sizeof(one)) < 0)
return "SO_DONTROUTE";
#endif
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 6d94cad..47b9621 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -558,32 +558,30 @@ krt_got_route(struct krt_proto *p, rte *e)
rte *old;
net *net = e->net;
int verdict;
-#ifdef KRT_ALLOW_LEARN
- int src = e->u.krt.src;
-#endif
-#ifdef CONFIG_AUTO_ROUTES
- if (e->attrs->dest == RTD_DEVICE)
+#ifdef KRT_ALLOW_LEARN
+ switch (e->u.krt.src)
{
- /* It's a device route. Probably a kernel-generated one. */
+ case KRT_SRC_KERNEL:
verdict = KRF_IGNORE;
goto sentenced;
- }
-#endif
-#ifdef KRT_ALLOW_LEARN
- if (src == KRT_SRC_ALIEN)
- {
+ case KRT_SRC_REDIRECT:
+ verdict = KRF_DELETE;
+ goto sentenced;
+
+ case KRT_SRC_ALIEN:
if (KRT_CF->learn)
krt_learn_scan(p, e);
else
{
- krt_trace_in_rl(&rl_alien_ignored, p, e, "alien route, ignored");
+ krt_trace_in_rl(&rl_alien_ignored, p, e, "[alien] ignored");
rte_free(e);
}
return;
}
#endif
+ /* The rest is for KRT_SRC_BIRD (or KRT_SRC_UNKNOWN) */
if (net->n.flags & KRF_VERDICT_MASK)
{
@@ -605,7 +603,7 @@ krt_got_route(struct krt_proto *p, rte *e)
else
verdict = KRF_DELETE;
-sentenced:
+ sentenced:
krt_trace_in(p, e, ((char *[]) { "?", "seen", "will be updated", "will be removed", "ignored" }) [verdict]);
net->n.flags = (net->n.flags & ~KRF_VERDICT_MASK) | verdict;
if (verdict == KRF_UPDATE || verdict == KRF_DELETE)
@@ -680,19 +678,24 @@ krt_prune(struct krt_proto *p)
}
void
-krt_got_route_async(struct krt_proto *p, rte *e, int new UNUSED)
+krt_got_route_async(struct krt_proto *p, rte *e, int new)
{
net *net = e->net;
- int src = e->u.krt.src;
- switch (src)
+ switch (e->u.krt.src)
{
case KRT_SRC_BIRD:
ASSERT(0); /* Should be filtered by the back end */
+
case KRT_SRC_REDIRECT:
- DBG("It's a redirect, kill him! Kill! Kill!\n");
- krt_set_notify(p, net, NULL, e);
+ if (new)
+ {
+ krt_trace_in(p, e, "[redirect] deleting");
+ krt_set_notify(p, net, NULL, e);
+ }
+ /* If !new, it is probably echo of our deletion */
break;
+
#ifdef KRT_ALLOW_LEARN
case KRT_SRC_ALIEN:
if (KRT_CF->learn)
@@ -878,7 +881,6 @@ krt_init(struct proto_config *c)
p->p.accept_ra_types = RA_OPTIMAL;
p->p.rt_notify = krt_notify;
- p->p.min_scope = SCOPE_HOST;
return &p->p;
}
diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h
index 607e699..1d9e144 100644
--- a/sysdep/unix/krt.h
+++ b/sysdep/unix/krt.h
@@ -83,6 +83,7 @@ void krt_got_route_async(struct krt_proto *p, struct rte *e, int new);
#define KRT_SRC_BIRD 0 /* Our route (not passed in async mode) */
#define KRT_SRC_REDIRECT 1 /* Redirect route, delete it */
#define KRT_SRC_ALIEN 2 /* Route installed by someone else */
+#define KRT_SRC_KERNEL 3 /* Kernel routes, are ignored by krt syncer */
extern struct protocol proto_unix_iface;
diff --git a/sysdep/unix/unix.h b/sysdep/unix/unix.h
index 1a461ee..0b179e0 100644
--- a/sysdep/unix/unix.h
+++ b/sysdep/unix/unix.h
@@ -9,6 +9,8 @@
#ifndef _BIRD_UNIX_H_
#define _BIRD_UNIX_H_
+#include <sys/socket.h>
+
struct pool;
/* main.c */
@@ -29,10 +31,12 @@ volatile int async_shutdown_flag;
#define BIRD_PF PF_INET6
#define BIRD_AF AF_INET6
typedef struct sockaddr_in6 sockaddr;
+static inline int sa_family_check(sockaddr *sa) { return sa->sin6_family == AF_INET6; }
#else
#define BIRD_PF PF_INET
#define BIRD_AF AF_INET
typedef struct sockaddr_in sockaddr;
+static inline int sa_family_check(sockaddr *sa) { return sa->sin_family == AF_INET; }
#endif
#ifndef SUN_LEN