summaryrefslogtreecommitdiffstats
path: root/proto
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-05-06 23:38:11 +0200
committerMartin Mares <mj@ucw.cz>1999-05-06 23:38:11 +0200
commit9a158361da249e0eab1e0f7bd2c7dbe9f32eddfa (patch)
tree4d9dff14fd053aaa2d45be859144148eb8851a4d /proto
parentec8b579e9c9703601bf745745b620103fe2e2477 (diff)
downloadbird-9a158361da249e0eab1e0f7bd2c7dbe9f32eddfa.tar
bird-9a158361da249e0eab1e0f7bd2c7dbe9f32eddfa.zip
I rewrote the interface handling code, so that it supports multiple
addresses per interface (needed for example for IPv6 support). Visible changes: o struct iface now contains a list of all interface addresses (represented by struct ifa), iface->addr points to the primary address (if any). o Interface has IF_UP set iff it's up and it has a primary address. o IF_UP is now independent on IF_IGNORED (i.e., you need to test IF_IGNORED in the protocols; I've added this, but please check). o The if_notify_change hook has been simplified (only one interface pointer etc.). o Introduced a ifa_notify_change hook. (For now, only the Direct protocol does use it -- it's wise to just listen to device routes in all other protocols.) o Removed IF_CHANGE_FLAGS notifier flag (it was meaningless anyway). o Updated all the code except netlink (I'll look at it tomorrow) to match the new semantics (please look at your code to ensure I did it right). Things to fix: o Netlink. o Make krt-iface interpret "eth0:1"-type aliases as secondary addresses.
Diffstat (limited to 'proto')
-rw-r--r--proto/ospf/ospf.c22
-rw-r--r--proto/rip/rip.c20
-rw-r--r--proto/static/static.c8
3 files changed, 26 insertions, 24 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index 6aedb2a..486ddbf 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -155,7 +155,7 @@ wait_timer_hook(timer *timer)
{
debug(" OSPF: Changing state into DR.\n");
ifa->state=OSPF_IS_DR;
- ifa->drip=ifa->iface->ip;
+ ifa->drip=ifa->iface->addr->ip;
/* FIXME: Set ifa->drid */
}
else
@@ -221,7 +221,7 @@ find_iface(struct proto_ospf *p, struct iface *what)
}
void
-ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface *old)
+ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
{
struct ospf_iface *ifa;
sock *mcsk, *newsk;
@@ -231,13 +231,15 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface
c=(struct ospf_config *)(p->cf);
DBG(" OSPF: If notify called\n");
+ if (iface->flags & IF_IGNORE)
+ return;
- if((flags & IF_CHANGE_UP) && is_good_iface(p, new))
+ if((flags & IF_CHANGE_UP) && is_good_iface(p, iface))
{
- debug(" OSPF: using interface %s.\n", new->name);
+ debug(" OSPF: using interface %s.\n", iface->name);
/* FIXME: Latter I'll use config - this is incorrect */
ifa=mb_alloc(p->pool, sizeof(struct ospf_iface));
- ifa->iface=new;
+ ifa->iface=iface;
add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa);
ospf_iface_default(ifa);
/* FIXME: This should read config */
@@ -253,17 +255,17 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface
if(flags & IF_CHANGE_DOWN)
{
- if((ifa=find_iface((struct proto_ospf *)p, old))!=NULL)
+ if((ifa=find_iface((struct proto_ospf *)p, iface))!=NULL)
{
- debug(" OSPF: killing interface %s.\n", old->name);
+ debug(" OSPF: killing interface %s.\n", iface->name);
}
}
if(flags & IF_CHANGE_MTU)
{
- if((ifa=find_iface((struct proto_ospf *)p, old))!=NULL)
+ if((ifa=find_iface((struct proto_ospf *)p, iface))!=NULL)
{
- debug(" OSPF: changing MTU on interface %s.\n", old->name);
+ debug(" OSPF: changing MTU on interface %s.\n", iface->name);
}
}
}
@@ -321,6 +323,4 @@ struct protocol proto_ospf = {
start: ospf_start,
preconfig: ospf_preconfig,
postconfig: ospf_postconfig,
-
};
-
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index 24d2e82..f7978ce 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -491,9 +491,9 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags)
if (want_multicast)
rif->sock->daddr = ipa_from_u32(0x7f000001); /* FIXME: must lookup address in rfc's */
if (flags & IF_BROADCAST)
- rif->sock->daddr = new->brd;
+ rif->sock->daddr = new->addr->brd;
if (flags & IF_UNNUMBERED)
- rif->sock->daddr = new->opposite;
+ rif->sock->daddr = new->addr->opposite;
if (!ipa_nonzero(rif->sock->daddr))
log( L_WARN "RIP: interface %s is too strange for me", rif->iface ? rif->iface->name : "(dummy)" );
@@ -507,24 +507,26 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags)
}
static void
-rip_if_notify(struct proto *p, unsigned c, struct iface *new, struct iface *old)
+rip_if_notify(struct proto *p, unsigned c, struct iface *iface)
{
DBG( "RIP: if notify\n" );
- if (old) {
+ if (iface->flags & IF_IGNORE)
+ return;
+ if (c & IF_CHANGE_DOWN) {
struct rip_interface *i;
- i = find_interface(p, old);
+ i = find_interface(p, iface);
if (i) {
rem_node(NODE i);
kill_iface(p, i);
}
}
- if (new) {
+ if (c & IF_CHANGE_UP) {
struct rip_interface *rif;
- struct iface_patt *k = iface_patt_match(&P_CF->iface_list, new);
+ struct iface_patt *k = iface_patt_match(&P_CF->iface_list, iface);
if (!k) return; /* We are not interested in this interface */
- DBG("adding interface %s\n", new->name );
- rif = new_iface(p, new, new->flags);
+ DBG("adding interface %s\n", iface->name );
+ rif = new_iface(p, iface, iface->flags);
rif->patt = (void *) k;
add_head( &P->interfaces, NODE rif );
}
diff --git a/proto/static/static.c b/proto/static/static.c
index 871438a..b136b31 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -134,7 +134,7 @@ static_dump(struct proto *p)
}
static void
-static_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface *old)
+static_if_notify(struct proto *p, unsigned flags, struct iface *i)
{
struct static_route *r;
struct static_config *c = (void *) p->cf;
@@ -142,13 +142,13 @@ static_if_notify(struct proto *p, unsigned flags, struct iface *new, struct ifac
if (flags & IF_CHANGE_UP)
{
WALK_LIST(r, c->iface_routes)
- if (!strcmp(r->if_name, new->name))
- static_install(p, r, new);
+ if (!strcmp(r->if_name, i->name))
+ static_install(p, r, i);
}
else if (flags & IF_CHANGE_DOWN)
{
WALK_LIST(r, c->iface_routes)
- if (!strcmp(r->if_name, old->name))
+ if (!strcmp(r->if_name, i->name))
static_remove(p, r);
}
}