Commit d9f330c5 authored by Martin Mareš's avatar Martin Mareš

Protocol hooks. All of them may be NULL.

parent 7f4a3988
...@@ -130,7 +130,8 @@ neigh_if_up(struct iface *i) ...@@ -130,7 +130,8 @@ neigh_if_up(struct iface *i)
n->sibling = i->neigh; n->sibling = i->neigh;
i->neigh = n; i->neigh = n;
DBG("Waking up sticky neighbor %08x\n", _I(n->addr)); DBG("Waking up sticky neighbor %08x\n", _I(n->addr));
n->proto->neigh_notify(n); if (n->proto->neigh_notify)
n->proto->neigh_notify(n);
} }
} }
...@@ -144,7 +145,8 @@ neigh_if_down(struct iface *i) ...@@ -144,7 +145,8 @@ neigh_if_down(struct iface *i)
m = n->sibling; m = n->sibling;
DBG("Flushing neighbor %08x on %s\n", _I(n->addr), n->iface->name); DBG("Flushing neighbor %08x on %s\n", _I(n->addr), n->iface->name);
n->iface = NULL; n->iface = NULL;
n->proto->neigh_notify(n); if (n->proto->neigh_notify)
n->proto->neigh_notify(n);
if (!(n->flags & NEF_STICKY)) if (!(n->flags & NEF_STICKY))
{ {
rem_node(&n->n); rem_node(&n->n);
...@@ -241,6 +243,8 @@ if_changed(struct iface *i, struct iface *j) ...@@ -241,6 +243,8 @@ if_changed(struct iface *i, struct iface *j)
static void static void
if_notify_change(unsigned c, struct iface *old, struct iface *new) if_notify_change(unsigned c, struct iface *old, struct iface *new)
{ {
struct proto *p;
debug("Interface change notification (%x) for %s\n", c, new->name); debug("Interface change notification (%x) for %s\n", c, new->name);
if (old) if (old)
if_dump(old); if_dump(old);
...@@ -250,7 +254,9 @@ if_notify_change(unsigned c, struct iface *old, struct iface *new) ...@@ -250,7 +254,9 @@ if_notify_change(unsigned c, struct iface *old, struct iface *new)
if (c & IF_CHANGE_UP) if (c & IF_CHANGE_UP)
neigh_if_up(new); neigh_if_up(new);
/* FIXME: Notify protocols here */ WALK_LIST(p, proto_list)
if (p->if_notify)
p->if_notify(p, c, old, new);
if (c & IF_CHANGE_DOWN) if (c & IF_CHANGE_DOWN)
neigh_if_down(old); neigh_if_down(old);
......
...@@ -62,7 +62,7 @@ rta_same(rta *x, rta *y) ...@@ -62,7 +62,7 @@ rta_same(rta *x, rta *y)
ipa_equal(x->from, y->from) && ipa_equal(x->from, y->from) &&
x->iface == y->iface && x->iface == y->iface &&
ea_same(x->attrs, y->attrs) && ea_same(x->attrs, y->attrs) &&
x->proto->rta_same(x, y)); (!x->proto->rta_same || x->proto->rta_same(x, y)));
} }
static inline ea_list * static inline ea_list *
......
...@@ -85,6 +85,8 @@ rte_get_temp(rta *a) ...@@ -85,6 +85,8 @@ rte_get_temp(rta *a)
static int /* Actually better or at least as good as */ static int /* Actually better or at least as good as */
rte_better(rte *new, rte *old) rte_better(rte *new, rte *old)
{ {
int (*better)(rte *, rte *);
if (!old) if (!old)
return 1; return 1;
if (new->pref > old->pref) if (new->pref > old->pref)
...@@ -96,7 +98,9 @@ rte_better(rte *new, rte *old) ...@@ -96,7 +98,9 @@ rte_better(rte *new, rte *old)
/* FIXME!!! */ /* FIXME!!! */
die("Different protocols, but identical preferences => oops"); die("Different protocols, but identical preferences => oops");
} }
return new->attrs->proto->rte_better(new, old); if (better = new->attrs->proto->rte_better)
return better(new, old);
return 0;
} }
void void
...@@ -106,7 +110,8 @@ rte_announce(rte *new, rte *old) ...@@ -106,7 +110,8 @@ rte_announce(rte *new, rte *old)
WALK_LIST(p, proto_list) WALK_LIST(p, proto_list)
if (!new || new->attrs->proto != p) if (!new || new->attrs->proto != p)
p->rt_notify(p, new, old); if (p->rt_notify)
p->rt_notify(p, new, old);
} }
static inline void static inline void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment