Commit 353729f5 authored by Ondřej Zajíček's avatar Ondřej Zajíček

Temporary OSPF commit - socket changes.

parent 75f88618
......@@ -34,8 +34,11 @@ typedef struct birdsock {
void (*err_hook)(struct birdsock *, int); /* errno or zero if EOF */
ip_addr faddr; /* For packet protocols: source of current packet */
unsigned fport;
/* Information about received datagrams (UDP, RAW), valid in rx_hook */
ip_addr faddr, laddr; /* src (From) and dst (Local) address of the datagram */
unsigned fport; /* src port of the datagram */
unsigned lifindex; /* local interface that received the datagram */
/* laddr and lifindex are valid only if SKF_LADDR_RX flag is set to request it */
int fd; /* System-dependent data */
node n;
......@@ -73,7 +76,9 @@ sk_send_buffer_empty(sock *sk)
/* Socket flags */
#define SKF_V6ONLY 1 /* Use IPV6_V6ONLY socket option */
#define SKF_V6ONLY 1 /* Use IPV6_V6ONLY socket option */
#define SKF_LADDR_RX 2 /* Report local address for RX packets */
#define SKF_LADDR_TX 4 /* Allow to specify local address for TX packets */
/*
......
......@@ -472,7 +472,7 @@ CF_CLI(RELOAD OUT, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protoc
{ proto_xxable($3, XX_RELOAD_OUT); } ;
CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]])
CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging via BIRD logs]])
CF_CLI(DEBUG, proto_patt debug_mask, (<protocol> | <pattern> | all) (all | off | { states | routes | filters | interfaces | events | packets }), [[Control protocol debugging via BIRD logs]])
{ proto_debug($2, 0, $3); }
;
......
......@@ -93,8 +93,8 @@ ospf_dbdes_send(struct ospf_neighbor *n, int next)
{
case NEIGHBOR_EXSTART: /* Send empty packets */
n->myimms.bit.i = 1;
pkt = (struct ospf_dbdes_packet *) (ifa->sk->tbuf);
op = (struct ospf_packet *) pkt;
pkt = ospf_tx_buffer();
op = &pkt->ospf_packet;
ospf_pkt_fill_hdr(ifa, pkt, DBDES_P);
pkt->iface_mtu = htons(ifa->iface->mtu);
pkt->options = hton_opt(oa->options);
......@@ -185,10 +185,10 @@ ospf_dbdes_send(struct ospf_neighbor *n, int next)
}
/* Copy last sent packet again */
memcpy(ifa->sk->tbuf, n->ldbdes, length);
pkt = ospf_tx_buffer();
memcpy(pkt, n->ldbdes, length);
OSPF_PACKET(ospf_dump_dbdes, (struct ospf_dbdes_packet *) ifa->sk->tbuf,
"DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
OSPF_PACKET(ospf_dump_dbdes, pkt, "DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
ospf_send_to(ifa, n->ip);
if(n->myimms.bit.ms) tm_start(n->rxmt_timer, n->ifa->rxmtint); /* Restart timer */
......
......@@ -47,7 +47,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
{
struct proto_ospf *po = ifa->oa->po;
struct proto *p = &po->proto;
char *beg = "Bad OSPF HELLO packet from ", *rec = " received: ";
char *beg = "OSPF: Bad HELLO packet from ";
unsigned int size, i, twoway, oldpriority, eligible, peers;
u32 olddr, oldbdr, oldiface_id, tmp;
u32 *pnrid;
......@@ -55,7 +55,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
size = ntohs(ps_i->length);
if (size < sizeof(struct ospf_hello_packet))
{
log(L_ERR "%s%I - too short (%u B)", beg, faddr, size);
log(L_ERR "%s%I - too short (%u B)", beg, faddr, size);
return;
}
......@@ -67,38 +67,19 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
#ifdef OSPFv2
ip_addr mask = ps->netmask;
ipa_ntoh(mask);
if (ifa->type != OSPF_IT_VLINK)
{
char *msg = L_WARN "Received HELLO packet %s (%I) is inconsistent "
"with the primary address of interface %s.";
if ((ifa->type != OSPF_IT_PTP) &&
!ipa_equal(mask, ipa_mkmask(ifa->iface->addr->pxlen)))
{
if (!n) log(msg, "netmask", mask, ifa->iface->name);
return;
}
/* This check is not specified in RFC 2328, but it is needed
* to handle the case when there is more IP networks on one
* physical network (which is not handled in RFC 2328).
* We allow OSPF on primary IP address only and ignore HELLO packets
* with secondary addresses (which are sent for example by Quagga.
*/
if ((ifa->iface->addr->flags & IA_UNNUMBERED) ?
!ipa_equal(faddr, ifa->iface->addr->opposite) :
!ipa_equal(ipa_and(faddr,mask), ifa->iface->addr->prefix))
{
if (!n) log(msg, "address", faddr, ifa->iface->name);
return;
}
}
if ((ifa->type != OSPF_IT_VLINK) &&
(ifa->type != OSPF_IT_PTP) &&
!ipa_equal(mask, ipa_mkmask(ifa->addr->pxlen)))
{
log(L_ERR "%s%I - netmask mismatch (%I)", beg, faddr, mask);
return;
}
#endif
tmp = ntohs(ps->helloint);
if (tmp != ifa->helloint)
{
log(L_ERR "%s%I%shello interval mismatch (%d).", beg, faddr, rec, tmp);
log(L_ERR "%s%I - hello interval mismatch (%d)", beg, faddr, tmp);
return;
}
......@@ -109,14 +90,14 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
#endif
if (tmp != ifa->dead)
{
log(L_ERR "%s%I%sdead interval mismatch (%d).", beg, faddr, rec, tmp);
log(L_ERR "%s%I - dead interval mismatch (%d)", beg, faddr, tmp);
return;
}
tmp = !(ps->options & OPT_E);
if (tmp != ifa->oa->stub)
{
log(L_ERR "%s%I%sstub area flag mismatch (%d).", beg, faddr, rec, tmp);
log(L_ERR "%s%I - stub area flag mismatch (%d)", beg, faddr, tmp);
return;
}
......@@ -137,7 +118,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
}
if ((found == 0) && (ifa->strictnbma))
{
log(L_WARN "Ignoring new neighbor: %I on %s.", faddr,
log(L_WARN "Ignoring new neighbor: %I on %s", faddr,
ifa->iface->name);
return;
}
......@@ -153,7 +134,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
}
}
}
OSPF_TRACE(D_EVENTS, "New neighbor found: %I on %s.", faddr,
OSPF_TRACE(D_EVENTS, "New neighbor found: %I on %s", faddr,
ifa->iface->name);
n = ospf_neighbor_new(ifa);
......@@ -277,14 +258,14 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn)
p->name, ifa->iface->name);
/* Now we should send a hello packet */
pkt = (struct ospf_hello_packet *) (ifa->sk->tbuf);
op = (struct ospf_packet *) pkt;
pkt = ospf_tx_buffer();
op = &pkt->ospf_packet;
/* Now fill ospf_hello header */
ospf_pkt_fill_hdr(ifa, pkt, HELLO_P);
#ifdef OSPFv2
pkt->netmask = ipa_mkmask(ifa->iface->addr->pxlen);
pkt->netmask = ipa_mkmask(ifa->addr->pxlen);
ipa_hton(pkt->netmask);
if ((ifa->type == OSPF_IT_VLINK) || (ifa->type == OSPF_IT_PTP))
pkt->netmask = IPA_NONE;
......
......@@ -58,15 +58,15 @@ rxbufsize(struct ospf_iface *ifa)
}
}
static sock *
ospf_open_socket(struct ospf_iface *ifa, int mc)
static int
ospf_sk_open(struct ospf_iface *ifa, int mc)
{
sock *ipsk;
sock *sk;
struct proto *p = &ifa->oa->po->proto;
ipsk = sk_new(p->pool);
ipsk->type = SK_IP;
ipsk->dport = OSPF_PROTO;
sk = sk_new(p->pool);
sk->type = SK_IP;
sk->dport = OSPF_PROTO;
#ifdef OSPFv2
/*
......@@ -76,45 +76,93 @@ ospf_open_socket(struct ospf_iface *ifa, int mc)
*
* We want such filter in the vlink (non-mc) socket.
*/
ipsk->saddr = mc ? IPA_NONE : ifa->iface->addr->ip;
sk->saddr = mc ? IPA_NONE : ifa->addr->ip;
#else /* OSPFv3 */
ipsk->saddr = ifa->lladdr;
sk->saddr = ifa->addr->ip; /* link-local addr */
#endif
ipsk->tos = IP_PREC_INTERNET_CONTROL;
ipsk->ttl = 1;
sk->tos = IP_PREC_INTERNET_CONTROL;
sk->ttl = 1;
if (ifa->type == OSPF_IT_VLINK)
ipsk->ttl = 255;
ipsk->rx_hook = ospf_rx_hook;
ipsk->tx_hook = ospf_tx_hook;
ipsk->err_hook = ospf_err_hook;
ipsk->iface = ifa->iface;
ipsk->rbsize = rxbufsize(ifa);
ipsk->tbsize = ifa->iface->mtu;
ipsk->data = (void *) ifa;
if (sk_open(ipsk) != 0)
sk->ttl = 255;
sk->rx_hook = ospf_rx_hook;
sk->tx_hook = ospf_tx_hook;
sk->err_hook = ospf_err_hook;
sk->iface = ifa->iface;
sk->rbsize = rxbufsize(ifa);
sk->tbsize = ifa->iface->mtu;
sk->data = (void *) ifa;
sk->flags = SKF_LADDR_RX;
if (sk_open(sk) != 0)
goto err;
#ifdef OSPFv3
/* 12 is an offset of the checksum in an OSPF packet */
if (sk_set_ipv6_checksum(ipsk, 12) < 0)
if (sk_set_ipv6_checksum(sk, 12) < 0)
goto err;
#endif
if (mc)
{
if (sk_setup_multicast(ipsk) < 0)
goto err;
if (sk_join_group(ipsk, AllSPFRouters) < 0)
goto err;
}
if (mc && (sk_setup_multicast(sk) < 0))
goto err;
return ipsk;
ifa->sk = sk;
ifa->sk_spf = 0;
ifa->sk_dr = 0;
return 1;
err:
rfree(ipsk);
return NULL;
rfree(sk);
return 0;
}
static inline void
ospf_sk_join_spf(struct ospf_iface *ifa)
{
if (ifa->sk_spf)
return;
sk_join_group(ifa->sk, AllSPFRouters);
ifa->sk_spf = 1;
}
static inline void
ospf_sk_join_dr(struct ospf_iface *ifa)
{
if (ifa->sk_dr)
return;
sk_join_group(ifa->sk, AllDRouters);
ifa->sk_dr = 1;
}
static inline void
ospf_sk_leave_spf(struct ospf_iface *ifa)
{
if (!ifa->sk_spf)
return;
sk_leave_group(ifa->sk, AllSPFRouters);
ifa->sk_spf = 0;
}
static inline void
ospf_sk_leave_dr(struct ospf_iface *ifa)
{
if (!ifa->sk_dr)
return;
sk_leave_group(ifa->sk, AllDRouters);
ifa->sk_dr = 0;
}
static inline void
ospf_sk_close(struct ospf_iface *ifa)
{
ASSERT(ifa->sk);
rfree(ifa->sk);
ifa->sk = NULL;
}
......@@ -144,9 +192,9 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
"Changing state of virtual link %R from \"%s\" into \"%s\".",
ifa->vid, ospf_is[oldstate], ospf_is[state]);
if (state == OSPF_IS_PTP)
{
ifa->sk = ospf_open_socket(ifa, 0);
}
ospf_sk_open(ifa, 0);
if (state == OSPF_IS_DOWN)
ospf_sk_close(ifa);
}
else
{
......@@ -157,19 +205,10 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
{
if ((ifa->type != OSPF_IT_NBMA) && (ifa->ioprob == OSPF_I_OK) &&
((state == OSPF_IS_BACKUP) || (state == OSPF_IS_DR)))
{
if (!ifa->dr_up == 0)
{
/* FIXME some error handing ? */
sk_join_group(ifa->sk, AllDRouters);
ifa->dr_up = 1;
}
}
else if (ifa->dr_up)
{
sk_leave_group(ifa->sk, AllDRouters);
ifa->dr_up = 0;
}
ospf_sk_join_dr(ifa);
else
ospf_sk_leave_dr(ifa);
if ((oldstate == OSPF_IS_DR) && (ifa->net_lsa != NULL))
{
ifa->net_lsa->lsa.age = LSA_MAXAGE;
......@@ -182,6 +221,7 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
ifa->net_lsa = NULL;
}
}
// FIXME flushling of link LSA
}
}
}
......@@ -194,13 +234,15 @@ ospf_iface_down(struct ospf_iface *ifa)
struct proto *p = &po->proto;
struct ospf_iface *iff;
OSPF_TRACE(D_EVENTS, "Removing interface %s", ifa->iface->name);
/* First of all kill all the related vlinks */
if (ifa->type != OSPF_IT_VLINK)
{
WALK_LIST(iff, po->iface_list)
{
if ((iff->type == OSPF_IT_VLINK) && (iff->iface == ifa->iface))
ospf_iface_down(iff);
ospf_iface_sm(iff, ISM_DOWN);
}
}
......@@ -210,9 +252,6 @@ ospf_iface_down(struct ospf_iface *ifa)
ospf_neigh_remove(n);
}
rfree(ifa->sk);
ifa->sk = NULL;
if (ifa->type == OSPF_IT_VLINK)
{
ifa->iface = NULL;
......@@ -220,6 +259,7 @@ ospf_iface_down(struct ospf_iface *ifa)
}
else
{
ospf_sk_close(ifa);
rfree(ifa->wait_timer);
rfree(ifa->hello_timer);
rfree(ifa->poll_timer);
......@@ -294,18 +334,16 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
case ISM_DOWN:
ospf_iface_chstate(ifa, OSPF_IS_DOWN);
ospf_iface_down(ifa);
schedule_link_lsa(ifa);
schedule_rt_lsa(oa);
break;
case ISM_LOOP: /* Useless? */
/*
case ISM_LOOP:
ospf_iface_chstate(ifa, OSPF_IS_LOOP);
ospf_iface_down(ifa);
schedule_rt_lsa(ifa->oa);
break;
case ISM_UNLOOP:
ospf_iface_chstate(ifa, OSPF_IS_DOWN);
schedule_rt_lsa(ifa->oa);
break;
*/
default:
bug("OSPF_I_SM - Unknown event?");
break;
......@@ -313,45 +351,6 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
}
#if 0
static sock *
ospf_open_mc_socket(struct ospf_iface *ifa)
{
sock *mcsk;
struct proto *p = &ifa->oa->po->proto;
mcsk = sk_new(p->pool);
mcsk->type = SK_IP_MC;
mcsk->sport = 0;
mcsk->dport = OSPF_PROTO;
#ifdef OSPFv2
mcsk->saddr = AllSPFRouters;
#else /* OSPFv3 */
// mcsk->saddr = AllSPFRouters;
mcsk->saddr = ifa->lladdr;
#endif
mcsk->daddr = AllSPFRouters;
mcsk->tos = IP_PREC_INTERNET_CONTROL;
mcsk->ttl = 1;
mcsk->rx_hook = ospf_rx_hook;
mcsk->tx_hook = ospf_tx_hook;
mcsk->err_hook = ospf_err_hook;
mcsk->iface = ifa->iface;
mcsk->rbsize = rxbufsize(ifa);
mcsk->tbsize = ifa->iface->mtu;
mcsk->data = (void *) ifa;
if (sk_open(mcsk) != 0)
{
DBG("%s: SK_OPEN: mc open failed.\n", p->name);
return (NULL);
}
DBG("%s: SK_OPEN: mc opened.\n", p->name);
return (mcsk);
}
#endif
u8
ospf_iface_clasify(struct iface * ifa)
{
......@@ -390,12 +389,15 @@ ospf_iface_add(struct object_lock *lock)
ifa->ioprob = OSPF_I_OK;
ifa->sk = ospf_open_socket(ifa, ifa->type != OSPF_IT_NBMA);
if (ifa->sk == NULL)
ospf_sk_open(ifa, 1);
if (ifa->type != OSPF_IT_NBMA)
ospf_sk_join_spf(ifa);
if (0)
{
log("%s: Huh? could not open ip socket on interface %s?", p->name,
log(L_ERR "%s: Huh? could not open ip socket on interface %s?", p->name,
iface->name);
log("%s: Declaring as stub.", p->name);
log(L_ERR "%s: Declaring as stub.", p->name);
ifa->stub = 1;
ifa->ioprob += OSPF_I_IP;
}
......@@ -414,6 +416,9 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
struct object_lock *lock;
struct ospf_area *oa;
if (ip->type != OSPF_IT_VLINK)
OSPF_TRACE(D_EVENTS, "Adding interface %s", iface->name);
ifa = mb_allocz(p->pool, sizeof(struct ospf_iface));
ifa->iface = iface;
......@@ -431,12 +436,13 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
#ifdef OSPFv2
ifa->autype = ip->autype;
ifa->passwords = ip->passwords;
ifa->addr = iface->addr;
#endif
#ifdef OSPFv3
ifa->instance_id = ip->instance_id;
ifa->lladdr = IPA_NONE;
ifa->addr = NULL;
/* Find link-local address */
if (ifa->type != OSPF_IT_VLINK)
......@@ -445,11 +451,11 @@ ospf_iface_new(struct proto_ospf *po, struct iface *iface,
WALK_LIST(a, iface->addrs)
if (a->scope == SCOPE_LINK)
{
ifa->lladdr = a->ip;
ifa->addr = a;
break;
}
if (! ipa_nonzero(ifa->lladdr))
if (! ifa->addr)
log(L_WARN "%s: Missing link local address on interface %s", p->name, iface->name);
}
#endif
......@@ -594,19 +600,13 @@ ospf_iface_notify(struct proto *p, unsigned flags, struct iface *iface)
}
if (ip)
{
OSPF_TRACE(D_EVENTS, "Using interface %s.", iface->name);
ospf_iface_new(po, iface, ac, ip);
}
}
if (flags & IF_CHANGE_DOWN)
{
if ((ifa = ospf_iface_find((struct proto_ospf *) p, iface)) != NULL)
{
OSPF_TRACE(D_EVENTS, "Killing interface %s.", iface->name);
ospf_iface_sm(ifa, ISM_DOWN);
}
}
if (flags & IF_CHANGE_MTU)
......@@ -666,4 +666,5 @@ ospf_iface_shutdown(struct ospf_iface *ifa)
{
init_list(&ifa->neigh_list);
hello_timer_hook(ifa->hello_timer);
ospf_sk_close(ifa);
}
......@@ -66,8 +66,8 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
if (EMPTY_LIST(n->ackl[queue]))
return;
pk = (struct ospf_lsack_packet *) ifa->sk->tbuf;
op = (struct ospf_packet *) ifa->sk->tbuf;
pk = ospf_tx_buffer();
op = &pk->ospf_packet;
ospf_pkt_fill_hdr(n->ifa, pk, LSACK_P);
h = pk->lsh;
......@@ -92,8 +92,7 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
op->length = htons(len);
DBG("Sending and continuing! Len=%u\n", len);
OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) ifa->sk->tbuf,
"LSACK packet sent via %s", ifa->iface->name);
OSPF_PACKET(ospf_dump_lsack, pk, "LSACK packet sent via %s", ifa->iface->name);
if (ifa->type == OSPF_IT_BCAST)
{
......@@ -120,8 +119,7 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
op->length = htons(len);
DBG("Sending! Len=%u\n", len);
OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) ifa->sk->tbuf,
"LSACK packet sent via %s", ifa->iface->name);
OSPF_PACKET(ospf_dump_lsack, pk, "LSACK packet sent via %s", ifa->iface->name);
if (ifa->type == OSPF_IT_BCAST)
{
......
......@@ -44,8 +44,8 @@ ospf_lsreq_send(struct ospf_neighbor *n)
int i, j;
struct proto *p = &n->ifa->oa->po->proto;
pk = (struct ospf_lsreq_packet *) n->ifa->sk->tbuf;
op = (struct ospf_packet *) n->ifa->sk->tbuf;
pk = ospf_tx_buffer();
op = &pk->ospf_packet;
ospf_pkt_fill_hdr(n->ifa, pk, LSREQ_P);
......@@ -82,8 +82,7 @@ ospf_lsreq_send(struct ospf_neighbor *n)
i) * sizeof(struct ospf_lsreq_header);
op->length = htons(length);
OSPF_PACKET(ospf_dump_lsreq, (struct ospf_lsreq_packet *) n->ifa->sk->tbuf,
"LSREQ packet sent to %I via %s", n->ip, n->ifa->iface->name);
OSPF_PACKET(ospf_dump_lsreq, pk, "LSREQ packet sent to %I via %s", n->ip, n->ifa->iface->name);
ospf_send_to(n->ifa, n->ip);
}
......
......@@ -269,8 +269,8 @@ ospf_lsupd_flood(struct proto_ospf *po,
struct ospf_packet *op;
struct ospf_lsa_header *lh;
pk = (struct ospf_lsupd_packet *) ifa->sk->tbuf;
op = (struct ospf_packet *) ifa->sk->tbuf;
pk = ospf_tx_buffer();
op = &pk->ospf_packet;
ospf_pkt_fill_hdr(ifa, pk, LSUPD_P);
pk->lsano = htonl(1);
......@@ -304,8 +304,7 @@ ospf_lsupd_flood(struct proto_ospf *po,
op->length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) ifa->sk->tbuf,
"LSUPD packet flooded via %s", ifa->iface->name);
OSPF_PACKET(ospf_dump_lsupd, pk, "LSUPD packet flooded via %s", ifa->iface->name);
switch (ifa->type)
{
......@@ -349,11 +348,11 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
if (EMPTY_LIST(*l))
return;
pk = (struct ospf_lsupd_packet *) n->ifa->sk->tbuf;
op = (struct ospf_packet *) n->ifa->sk->tbuf;
DBG("LSupd: 1st packet\n");
pk= ospf_tx_buffer();
op = &pk->ospf_packet;
ospf_pkt_fill_hdr(n->ifa, pk, LSUPD_P);
len = sizeof(struct ospf_lsupd_packet);
lsano = 0;
......@@ -374,8 +373,7 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
pk->lsano = htonl(lsano);
op->length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) n->ifa->sk->tbuf,
"LSUPD packet sent to %I via %s", n->ip, n->ifa->iface->name);
OSPF_PACKET(ospf_dump_lsupd, pk, "LSUPD packet sent to %I via %s", n->ip, n->ifa->iface->name);
ospf_send_to(n->ifa, n->ip);
DBG("LSupd: next packet\n");
......@@ -397,8 +395,7 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
pk->lsano = htonl(lsano);
op->length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) n->ifa->sk->tbuf,
"LSUPD packet sent to %I via %s", n->ip, n->ifa->iface->name);
OSPF_PACKET(ospf_dump_lsupd, pk, "LSUPD packet sent to %I via %s", n->ip, n->ifa->iface->name);
ospf_send_to(n->ifa, n->ip);
}
}
......@@ -416,7 +413,7 @@ ospf_lsupd_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
unsigned int size = ntohs(ps_i->length);
if (size < (sizeof(struct ospf_lsupd_packet) + sizeof(struct ospf_lsa_header)))
{
log(L_ERR "Bad OSPF LSUPD packet from %I - too short (%u B)", n->ip, size);
log(L_ERR "OSPF: Bad LSUPD packet from %I - too short (%u B)", n->ip, size);
return;
}
......@@ -537,7 +534,7 @@ ospf_lsupd_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
{
if (!nifa->iface)
continue;
if (ipa_equal(nifa->iface->addr->ip, ipa_from_u32(lsatmp.id)))
if (ipa_equal(nifa->addr->ip, ipa_from_u32(lsatmp.id)))
{
self = 1;
break;
......
......@@ -450,13 +450,12 @@ bdr_election(struct ospf_iface *ifa)
me.state = NEIGHBOR_2WAY;
me.rid = myid;
me.priority = ifa->priority;
me.ip = ifa->addr->ip;
#ifdef OSPFv2
me.ip = ifa->iface->addr->ip;
me.dr = ipa_to_u32(ifa->drip);
me.bdr = ipa_to_u32(ifa->bdrip);
#else /* OSPFv3 */
me.ip = ifa->lladdr;
me.dr = ifa->drid;
me.bdr = ifa->bdrid;
me.iface_id = ifa->iface->index;
......
......@@ -478,7 +478,9 @@ ospf_shutdown(struct proto *p)
OSPF_TRACE(D_EVENTS, "Shutdown requested");
/* And send to all my neighbors 1WAY */
WALK_LIST(ifa, po->iface_list) ospf_iface_shutdown(ifa);
WALK_LIST(ifa, po->iface_list)
if (ifa->state > OSPF_IS_DOWN)
ospf_iface_shutdown(ifa);
return PS_DOWN;
}
......@@ -1209,7 +1211,7 @@ show_lsa_sum_net(struct top_hash_entry *he)
lsa_get_ipv6_prefix(ls->prefix, &ip, &pxlen, &pxopts, &rest);
#endif
cli_msg(-1016, "\t\txnetwork %I/%d", ip, pxlen);
cli_msg(-1016, "\t\txnetwork %I/%d metric %u", ip, pxlen, ls->metric);
}
static inline void
......@@ -1227,7 +1229,7 @@ show_lsa_sum_rt(struct top_hash_entry *he)
options = ls->options & OPTIONS_MASK;
#endif
cli_msg(-1016, "\t\txrouter %R", dst_rid);
cli_msg(-1016, "\t\txrouter %R metric %u", dst_rid, ls->metric);
}
......
......@@ -159,6 +159,7 @@ struct ospf_iface
{
node n;
struct iface *iface; /* Nest's iface */
struct ifa *addr;
struct ospf_area *oa;
struct object_lock *lock;
sock *sk; /* IP socket (for DD ...) */
......@@ -192,7 +193,6 @@ struct ospf_iface
u32 dr_iface_id; /* if drid is valid, this is iface_id of DR (for connecting network) */
u8 instance_id; /* Used to differentiate between more OSPF
instances on one interface */
ip_addr lladdr; /* Used link-local addr */
#endif
u8 type; /* OSPF view of type */
......@@ -237,9 +237,10 @@ struct ospf_iface
#endif
int fadj; /* Number of full adjacent neigh */
list nbma_list;
u8 priority; /* A router priority for DR election */
u8 priority; /* A router priority for DR election */
u8 ioprob;
u8 dr_up; /* Socket is a member of DRouters group */
u8 sk_spf; /* Socket is a member of SPFRouters group */
u8 sk_dr; /* Socket is a member of DRouters group */
u32 rxbuf;
};
......@@ -675,8 +676,8 @@ struct ospf_neighbor