From: Ondrej Zajicek Date: Wed, 22 May 2013 22:16:19 +0000 (+0200) Subject: Merge commit '8df02847e8af29863c325b7297e3a2b2ed5f961c' into integrated X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c91df94801365691d7636b5bc08822d0048f51d;p=thirdparty%2Fbird.git Merge commit '8df02847e8af29863c325b7297e3a2b2ed5f961c' into integrated Conflicts: proto/ospf/config.Y proto/ospf/hello.c proto/ospf/iface.c proto/ospf/ospf.h --- 1c91df94801365691d7636b5bc08822d0048f51d diff --cc proto/ospf/config.Y index 3325a5de7,2cc0b9634..2f1ee624e --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@@ -279,7 -289,8 +279,8 @@@ ospf_iface_item | TYPE PTP { OSPF_PATT->type = OSPF_IT_PTP ; } | TYPE POINTOMULTIPOINT { OSPF_PATT->type = OSPF_IT_PTMP ; } | TYPE PTMP { OSPF_PATT->type = OSPF_IT_PTMP ; } - | REAL BROADCAST bool { OSPF_PATT->real_bcast = $3; if (OSPF_VERSION != 2) cf_error("Real broadcast option requires OSPFv2"); } - | PTP NETMASK bool { OSPF_PATT->ptp_netmask = $3; if (OSPF_VERSION != 2) cf_error("Real netmask option requires OSPFv2"); } + | REAL BROADCAST bool { OSPF_PATT->real_bcast = $3; if (!ospf_cfg_is_v2()) cf_error("Real broadcast option requires OSPFv2"); } ++ | PTP NETMASK bool { OSPF_PATT->ptp_netmask = $3; if (!ospf_cfg_is_v2()) cf_error("Real netmask option requires OSPFv2"); } | TRANSMIT DELAY expr { OSPF_PATT->inftransdelay = $3 ; if (($3<=0) || ($3>65535)) cf_error("Transmit delay must be in range 1-65535"); } | PRIORITY expr { OSPF_PATT->priority = $2 ; if (($2<0) || ($2>255)) cf_error("Priority must be in range 0-255"); } | STRICT NONBROADCAST bool { OSPF_PATT->strictnbma = $3 ; } diff --cc proto/ospf/hello.c index c25187087,d5aa1b95e..8f2e497f2 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@@ -258,55 -242,52 +258,56 @@@ ospf_hello_send(struct ospf_iface *ifa 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); - op = &pkt->ospf_packet; - - /* Now fill ospf_hello header */ ospf_pkt_fill_hdr(ifa, pkt, HELLO_P); -#ifdef OSPFv2 - pkt->netmask = ipa_mkmask(ifa->addr->pxlen); - ipa_hton(pkt->netmask); - if ((ifa->type == OSPF_IT_VLINK) || - ((ifa->type == OSPF_IT_PTP) && !ifa->ptp_netmask)) - pkt->netmask = IPA_NONE; -#endif - - pkt->helloint = ntohs(ifa->helloint); - pkt->priority = ifa->priority; - -#ifdef OSPFv3 - pkt->iface_id = htonl(ifa->iface_id); - - pkt->options3 = ifa->oa->options >> 16; - pkt->options2 = ifa->oa->options >> 8; -#endif - pkt->options = ifa->oa->options; - -#ifdef OSPFv2 - pkt->deadint = htonl(ifa->deadint); - pkt->dr = htonl(ipa_to_u32(ifa->drip)); - pkt->bdr = htonl(ipa_to_u32(ifa->bdrip)); -#else /* OSPFv3 */ - pkt->deadint = htons(ifa->deadint); - pkt->dr = htonl(ifa->drid); - pkt->bdr = htonl(ifa->bdrid); -#endif + if (ospf_is_v2(po)) + { + struct ospf_hello2_packet *ps = (void *) pkt; + + ps->netmask = htonl(u32_mkmask(ifa->addr->pxlen)); + - if ((ifa->type == OSPF_IT_VLINK) || (ifa->type == OSPF_IT_PTP)) ++ if ((ifa->type == OSPF_IT_VLINK) || ++ ((ifa->type == OSPF_IT_PTP) && !ifa->ptp_netmask)) + ps->netmask = 0; + + ps->helloint = ntohs(ifa->helloint); + ps->options = ifa->oa->options; + ps->priority = ifa->priority; + ps->deadint = htonl(ifa->deadint); + ps->dr = htonl(ipa_to_u32(ifa->drip)); + ps->bdr = htonl(ipa_to_u32(ifa->bdrip)); + + length = sizeof(struct ospf_hello2_packet); + neighbors = ps->neighbors; + } + else + { + struct ospf_hello3_packet *ps = (void *) pkt; + + ps->iface_id = htonl(ifa->iface_id); + ps->priority = ifa->priority; + ps->options3 = ifa->oa->options >> 16; + ps->options2 = ifa->oa->options >> 8; + ps->options = ifa->oa->options; + ps->helloint = ntohs(ifa->helloint); + ps->deadint = htons(ifa->deadint); + ps->dr = htonl(ifa->drid); + ps->bdr = htonl(ifa->bdrid); + + length = sizeof(struct ospf_hello3_packet); + neighbors = ps->neighbors; + } - /* Fill all neighbors */ i = 0; + max = (ospf_pkt_bufsize(ifa) - length) / sizeof(u32); + /* Fill all neighbors */ if (kind != OHS_SHUTDOWN) { - u32 *pp = (u32 *) (((u8 *) pkt) + sizeof(struct ospf_hello_packet)); WALK_LIST(neigh, ifa->neigh_list) { - if ((i+1) * sizeof(u32) + sizeof(struct ospf_hello_packet) > ospf_pkt_bufsize(ifa)) + if (i == max) { log(L_WARN "%s: Too many neighbors on interface %s", p->name, ifa->iface->name); break; diff --cc proto/ospf/iface.c index 8613ec851,9050f7b10..19f4c585f --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@@ -534,10 -533,19 +534,14 @@@ ospf_iface_new(struct ospf_area *oa, st ifa->rxbuf = ip->rxbuf; ifa->check_link = ip->check_link; ifa->ecmp_weight = ip->ecmp_weight; - -#ifdef OSPFv2 ifa->autype = ip->autype; ifa->passwords = ip->passwords; + ifa->instance_id = ip->instance_id; + + ifa->ptp_netmask = !(addr->flags & IA_PEER); + if (ip->ptp_netmask < 2) + ifa->ptp_netmask = ip->ptp_netmask; -#endif - -#ifdef OSPFv3 - ifa->instance_id = ip->instance_id; -#endif + ifa->type = ospf_iface_classify(ip->type, addr); /* Check validity of interface type */ diff --cc proto/ospf/ospf.h index 146d07f61,d924e6574..1c411a71c --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@@ -749,8 -811,15 +750,9 @@@ struct ospf_iface_pat u8 check_link; u8 ecmp_weight; u8 real_bcast; /* Not really used in OSPFv3 */ - list *passwords; + u8 ptp_netmask; /* bool but 2 for unspecified */ - -#ifdef OSPFv2 - list *passwords; -#endif - -#ifdef OSPFv3 u8 instance_id; -#endif ++ list *passwords; }; int ospf_import_control(struct proto *p, rte **new, ea_list **attrs,