p->attn = ev_new(p->pool);
p->attn->data = p;
rt_lock_table(p->table);
+
+#ifdef CONFIG_PIPE
+ if (proto_is_pipe(p))
+ rt_lock_table(pipe_get_peer_table(p));
+#endif
}
/**
bzero(&p->stats, sizeof(struct proto_stats));
rt_unlock_table(p->table);
+
+#ifdef CONFIG_PIPE
+ if (proto_is_pipe(p))
+ rt_unlock_table(pipe_get_peer_table(p));
+#endif
+
proto_rethink_goal(p);
}
struct announce_hook *proto_add_announce_hook(struct proto *, struct rtable *);
+/*
+ * Some pipe-specific nest hacks
+ */
+
+#ifdef CONFIG_PIPE
+
+static inline int proto_is_pipe(struct proto *p)
+{ return p->proto == &proto_pipe; }
+
+struct rtable *pipe_get_peer_table(struct proto *p);
+
+#endif
+
+
#endif
* end of the pipe (we need to do this in order to get different
* filters and announce functions and it unfortunately involves
* a couple of magic trickery).
+ *
+ * The phantom protocol is used ONLY in announce hooks and
+ * therefore in do_rte_announce() function.
*/
ph = mb_alloc(P->pool, sizeof(struct pipe_proto));
memcpy(ph, p, sizeof(struct pipe_proto));
*/
a = proto_add_announce_hook(P, p->peer);
a->proto = &ph->p;
- rt_lock_table(p->peer);
return PS_UP;
}
-static int
-pipe_shutdown(struct proto *P)
-{
- struct pipe_proto *p = (struct pipe_proto *) P;
-
- rt_unlock_table(p->peer);
- return PS_DOWN;
-}
-
static struct proto *
pipe_init(struct proto_config *C)
{
return 1;
}
+struct rtable *
+pipe_get_peer_table(struct proto *P)
+{
+ struct pipe_proto *p = (struct pipe_proto *) P;
+ return p->peer;
+}
+
struct protocol proto_pipe = {
name: "Pipe",
template: "pipe%d",
postconfig: pipe_postconfig,
init: pipe_init,
start: pipe_start,
- shutdown: pipe_shutdown,
reconfigure: pipe_reconfigure,
get_status: pipe_get_status,
};