From 353729f513aa6a1f9e7f66083a0f9d2117fe2be5 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 11 Feb 2010 10:23:35 +0100 Subject: Temporary OSPF commit - socket changes. --- proto/ospf/hello.c | 53 +++++++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) (limited to 'proto/ospf/hello.c') diff --git a/proto/ospf/hello.c b/proto/ospf/hello.c index 738748d..eaf7d23 100644 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@ -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; -- cgit v1.2.3 From e7b76b976084006e430543f4b872f624326dbfe6 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 11 Mar 2010 18:07:24 +0100 Subject: Temoporary OSPF commit - socket changes. --- proto/ospf/hello.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'proto/ospf/hello.c') diff --git a/proto/ospf/hello.c b/proto/ospf/hello.c index eaf7d23..9f174df 100644 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@ -258,7 +258,7 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn) p->name, ifa->iface->name); /* Now we should send a hello packet */ - pkt = ospf_tx_buffer(); + pkt = ospf_tx_buffer(ifa); op = &pkt->ospf_packet; /* Now fill ospf_hello header */ -- cgit v1.2.3 From 0aad2b9292f8e5ff32d048378faf80d2d0bfbb80 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sun, 14 Mar 2010 16:36:59 +0100 Subject: Temporary OSPF commit - sockets. --- proto/ospf/hello.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'proto/ospf/hello.c') diff --git a/proto/ospf/hello.c b/proto/ospf/hello.c index 7fe8280..fedc523 100644 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@ -254,8 +254,8 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn) return; /* Don't send any packet on stub iface */ p = (struct proto *) (ifa->oa->po); - DBG("%s: Hello/Poll timer fired on interface %s.\n", - p->name, ifa->iface->name); + DBG("%s: Hello/Poll timer fired on interface %s with IP %I\n", + p->name, ifa->iface->name, ifa->addr->ip); /* Now we should send a hello packet */ pkt = ospf_tx_buffer(ifa); -- cgit v1.2.3