From 88871b1d1ea8150ddf3d8f66fe77323770ba0f9f Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 15 Jun 2006 11:41:19 +0000 Subject: [ospfd] suppres mostly uninteresting debug message unless debug is set 2006-05-30 Paul Jakma * ospf_packet.c: (ospf_read) Debug message about packets received on unenabled interfaces should be conditional on debug being set. --- ospfd/ospf_packet.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index d6aca719..a842ca68 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -2363,9 +2363,10 @@ ospf_read (struct thread *thread) { if ((oi = ospf_associate_packet_vl (ospf, ifp, iph, ospfh)) == NULL) { - zlog_debug ("Packet from [%s] received on link %s" - " but no ospf_interface", - inet_ntoa (iph->ip_src), ifp->name); + if (IS_DEBUG_OSPF_EVENT) + zlog_debug ("Packet from [%s] received on link %s" + " but no ospf_interface", + inet_ntoa (iph->ip_src), ifp->name); return 0; } } -- cgit v1.2.3 From 429ac78cc64e0e29bab7cbc00ee991abcdec3f81 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 15 Jun 2006 18:40:49 +0000 Subject: [ospfd] Fix multicast membership drop bug 2006-06-15 Paul Jakma * Reported by Milan Koci * ospf_interface.h: (struct ospf_if_info) Add reference counts for multicast group memberships. Add various macros to help manipulate/check membership state. * ospf_interface.c: (ospf_if_set_multicast) Maintain the ospf_if_info reference counts, and only actually drop memberships if it hits 0, to avoid losing membership when OSPF is disabled on an interface with multiple active OSPF interfaces. * ospf_packet.c: (ospf_{hello,read}) Use the new macros to check/set multicast membership. * ospf_vty.c: (show_ip_ospf_interface_sub) ditto. --- ospfd/ospf_packet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index a842ca68..569f2513 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -768,7 +768,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, if (iph->ip_dst.s_addr == htonl(OSPF_ALLSPFROUTERS)) { /* Try to fix multicast membership. */ - SET_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS); + OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS); ospf_if_set_multicast(oi); } return; @@ -2390,9 +2390,9 @@ ospf_read (struct thread *thread) ifp->name, if_flag_dump(ifp->flags)); /* Fix multicast memberships? */ if (iph->ip_dst.s_addr == htonl(OSPF_ALLSPFROUTERS)) - SET_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS); + OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS); else if (iph->ip_dst.s_addr == htonl(OSPF_ALLDROUTERS)) - SET_FLAG(oi->multicast_memberships, MEMBER_DROUTERS); + OI_MEMBER_JOINED(oi, MEMBER_DROUTERS); if (oi->multicast_memberships) ospf_if_set_multicast(oi); return 0; -- cgit v1.2.3 From 13cd3dc1e8281cc6fdc576fb0b62e71a9e170cae Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 11 Jul 2006 01:50:30 +0000 Subject: [ospfd] Improve Hello NetworkMask mismatch warning to give more info 2006-07-10 Andrew J. Schorr * ospf_packet.c: (ospf_hello) Improve NetworkMask mismatch warning message to include interface name and conflicting prefix lengths. --- ospfd/ospf_packet.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 569f2513..788daba3 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -785,8 +785,9 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, && oi->type != OSPF_IFTYPE_VIRTUALLINK) if (oi->address->prefixlen != p.prefixlen) { - zlog_warn ("Packet %s [Hello:RECV]: NetworkMask mismatch.", - inet_ntoa (ospfh->router_id)); + zlog_warn ("Packet %s [Hello:RECV]: NetworkMask mismatch on %s (configured prefix length is %d, but hello packet indicates %d).", + inet_ntoa(ospfh->router_id), IF_NAME(oi), + (int)oi->address->prefixlen, (int)p.prefixlen); return; } -- cgit v1.2.3 From 1fe6ed38cd0136c514aabae01389653beab27fb9 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Wed, 26 Jul 2006 09:37:26 +0000 Subject: [ospfd] Allow ospf_lsa_unlock to NULL out callers' LSA pointers upon free 2006-07-26 Paul Jakma * ospf_lsa.{c,h}: (ospf_lsa_unlock) Change to take a double pointer to the LSA to be 'unlocked', so that, if the LSA is freed, the callers pointer to the LSA can be NULLed out, allowing any further use of that pointer to provoke a crash sooner rather than later. * ospf_*.c: (general) Adjust callers of ospf_lsa_unlock to match previous. Try annotate 'locking' somewhat to show which 'locks' are protecting what LSA reference, if not obvious. * ospf_opaque.c: (ospf_opaque_lsa_install) Trivial: remove useless goto, replace with return. * ospf_packet.c: (ospf_make_ls_ack) Trivial: merge two list loops, the dual-loop predated the delete-safe list-loop macro. --- ospfd/ospf_packet.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 788daba3..44dca181 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -2764,7 +2764,7 @@ ospf_make_ls_req_func (struct stream *s, u_int16_t *length, stream_put_ipv4 (s, lsa->data->id.s_addr); stream_put_ipv4 (s, lsa->data->adv_router.s_addr); - ospf_lsa_unlock (nbr->ls_req_last); + ospf_lsa_unlock (&nbr->ls_req_last); nbr->ls_req_last = ospf_lsa_lock (lsa); *length += 12; @@ -2860,7 +2860,7 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream count++; list_delete_node (update, node); - ospf_lsa_unlock (lsa); + ospf_lsa_unlock (&lsa); /* oi->ls_upd_queue */ } /* Now set #LSAs. */ @@ -2874,17 +2874,13 @@ ospf_make_ls_upd (struct ospf_interface *oi, struct list *update, struct stream static int ospf_make_ls_ack (struct ospf_interface *oi, struct list *ack, struct stream *s) { - struct list *rm_list; - struct listnode *node; + struct listnode *node, *nnode; u_int16_t length = OSPF_LS_ACK_MIN_SIZE; unsigned long delta = stream_get_endp(s) + 24; struct ospf_lsa *lsa; - rm_list = list_new (); - - for (ALL_LIST_ELEMENTS_RO (ack, node, lsa)) + for (ALL_LIST_ELEMENTS (ack, node, nnode, lsa)) { - lsa = listgetdata (node); assert (lsa); if (length + delta > ospf_packet_max (oi)) @@ -2893,21 +2889,10 @@ ospf_make_ls_ack (struct ospf_interface *oi, struct list *ack, struct stream *s) stream_put (s, lsa->data, OSPF_LSA_HEADER_SIZE); length += OSPF_LSA_HEADER_SIZE; - listnode_add (rm_list, lsa); - } - - /* Remove LSA from LS-Ack list. */ - /* XXX: this loop should be removed and the list move done in previous - * loop - */ - for (ALL_LIST_ELEMENTS_RO (rm_list, node, lsa)) - { listnode_delete (ack, lsa); - ospf_lsa_unlock (lsa); + ospf_lsa_unlock (&lsa); /* oi->ls_ack_direct.ls_ack */ } - list_delete (rm_list); - return length; } @@ -3396,10 +3381,7 @@ ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag) rn->info = list_new (); for (ALL_LIST_ELEMENTS_RO (update, node, lsa)) - { - ospf_lsa_lock (lsa); - listnode_add (rn->info, lsa); - } + listnode_add (rn->info, ospf_lsa_lock (lsa)); /* oi->ls_upd_queue */ if (oi->t_ls_upd_event == NULL) oi->t_ls_upd_event = -- cgit v1.2.3 From 8dd24ee6d7302ccd9515123d4364122ade277e02 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 27 Aug 2006 06:29:30 +0000 Subject: [ospfd] Raise ExchangeDone earlier, avoid often needless round of DD packets 2006-08-03 Paul Jakma * ospf_packet.c: (ospf_make_db_desc) Unset the DD More bit after constructing the packet, if appropriate. (ospf_db_desc_proc) Speed up Exchange, slave should raise ExchangeDone earlier, as RFC mandates, by forming its reply before deciding whether both sides are done, avoids a needless round of empty DD packet exchanges at the end of Exchange, hence speeding up ExchangeDone. (ospf_db_desc) use UNSET_FLAG macro. --- ospfd/ospf_packet.c | 61 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 19 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 44dca181..74caaa77 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -1055,11 +1055,11 @@ ospf_db_desc_proc (struct stream *s, struct ospf_interface *oi, if (IS_SET_DD_MS (nbr->dd_flags)) { nbr->dd_seqnum++; - /* Entire DD packet sent. */ + + /* Both sides have no More, then we're done with Exchange */ if (!IS_SET_DD_M (dd->flags) && !IS_SET_DD_M (nbr->dd_flags)) OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_ExchangeDone); else - /* Send new DD packet. */ ospf_db_desc_send (nbr); } /* Slave */ @@ -1067,17 +1067,21 @@ ospf_db_desc_proc (struct stream *s, struct ospf_interface *oi, { nbr->dd_seqnum = ntohl (dd->dd_seqnum); - /* When master's more flags is not set. */ - if (!IS_SET_DD_M (dd->flags) && ospf_db_summary_isempty (nbr)) - { - nbr->dd_flags &= ~(OSPF_DD_FLAG_M); - OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_ExchangeDone); - } - - /* Send DD packet in reply. */ + /* Send DD packet in reply. + * + * Must be done to acknowledge the Master's DD, regardless of + * whether we have more LSAs ourselves to describe. + * + * This function will clear the 'More' bit, if after this DD + * we have no more LSAs to describe to the master.. + */ ospf_db_desc_send (nbr); + + /* Slave can raise ExchangeDone now, if master is also done */ + if (!IS_SET_DD_M (dd->flags) && !IS_SET_DD_M (nbr->dd_flags)) + OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_ExchangeDone); } - + /* Save received neighbor values from DD. */ ospf_db_desc_save_current (nbr, dd); } @@ -1200,7 +1204,9 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh, zlog_info ("Packet[DD]: Neighbor %s Negotiation done (Slave).", inet_ntoa(nbr->router_id)); nbr->dd_seqnum = ntohl (dd->dd_seqnum); - nbr->dd_flags &= ~(OSPF_DD_FLAG_MS|OSPF_DD_FLAG_I); /* Reset I/MS */ + + /* Reset I/MS */ + UNSET_FLAG (nbr->dd_flags, (OSPF_DD_FLAG_MS|OSPF_DD_FLAG_I)); } else { @@ -1217,7 +1223,8 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh, { zlog_info ("Packet[DD]: Neighbor %s Negotiation done (Master).", inet_ntoa(nbr->router_id)); - nbr->dd_flags &= ~OSPF_DD_FLAG_I; + /* Reset I, leaving MS */ + UNSET_FLAG (nbr->dd_flags, OSPF_DD_FLAG_I); } else { @@ -2676,7 +2683,7 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr, #endif /* HAVE_OPAQUE_LSA */ stream_putc (s, options); - /* Keep pointer to flags. */ + /* DD flags */ pp = stream_get_endp (s); stream_putc (s, nbr->dd_flags); @@ -2685,12 +2692,21 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr, if (ospf_db_summary_isempty (nbr)) { + /* Sanity check: + * + * Must be here either: + * - Initial DBD (ospf_nsm.c) + * - M must be set + * or + * - finishing Exchange, and DB-Summary list empty + * - from ospf_db_desc_proc() + * - M must not be set + */ if (nbr->state >= NSM_Exchange) - { - nbr->dd_flags &= ~OSPF_DD_FLAG_M; - /* Set DD flags again */ - stream_putc_at (s, pp, nbr->dd_flags); - } + assert (!IS_SET_DD_M(nbr->dd_flags)); + else + assert (IS_SET_DD_M(nbr->dd_flags)); + return length; } @@ -2744,6 +2760,13 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr, } } + /* Update 'More' bit */ + if (ospf_db_summary_isempty (nbr)) + { + UNSET_FLAG (nbr->dd_flags, OSPF_DD_FLAG_M); + /* Rewrite DD flags */ + stream_putc_at (s, pp, nbr->dd_flags); + } return length; } -- cgit v1.2.3 From f0894cf8c323a25053e1f5e82be3ea5d88c2aacb Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 27 Aug 2006 06:40:04 +0000 Subject: [ospfd] draft-ogier-ospf-dbex-opt DB-exchange optimisation 2006-08-03 Paul Jakma * ospf_packet.c: (ospf_make_db_desc) Implement draft-ogier-ospf-dbex-opt DB-exchange optimisation. --- ospfd/ospf_packet.c | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 74caaa77..6449e63a 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -1035,20 +1035,40 @@ ospf_db_desc_proc (struct stream *s, struct ospf_interface *oi, /* Lookup received LSA, then add LS request list. */ find = ospf_lsa_lookup_by_header (oi->area, lsah); - if (!find || ospf_lsa_more_recent (find, new) < 0) - { - ospf_ls_request_add (nbr, new); - ospf_lsa_discard (new); - } - else - { - /* Received LSA is not recent. */ - if (IS_DEBUG_OSPF_EVENT) - zlog_debug ("Packet [DD:RECV]: LSA received Type %d, " - "ID %s is not recent.", lsah->type, inet_ntoa (lsah->id)); - ospf_lsa_discard (new); - continue; - } + + /* ospf_lsa_more_recent is fine with NULL pointers */ + switch (ospf_lsa_more_recent (find, new)) + { + case -1: + /* Neighbour has a more recent LSA, we must request it */ + ospf_ls_request_add (nbr, new); + case 0: + /* If we have a copy of this LSA, it's either less recent + * and we're requesting it from neighbour (the case above), or + * it's as recent and we both have same copy (this case). + * + * In neither of these two cases is there any point in + * describing our copy of the LSA to the neighbour in a + * DB-Summary packet, if we're still intending to do so. + * + * See: draft-ogier-ospf-dbex-opt-00.txt, describing the + * backward compatible optimisation to OSPF DB Exchange / + * DB Description process implemented here. + */ + if (find) + ospf_lsdb_delete (&nbr->db_sum, find); + ospf_lsa_discard (new); + break; + default: + /* We have the more recent copy, nothing specific to do: + * - no need to request neighbours stale copy + * - must leave DB summary list copy alone + */ + if (IS_DEBUG_OSPF_EVENT) + zlog_debug ("Packet [DD:RECV]: LSA received Type %d, " + "ID %s is not recent.", lsah->type, inet_ntoa (lsah->id)); + ospf_lsa_discard (new); + } } /* Master */ -- cgit v1.2.3 From 2518efd15b75687d4791a5eb4b0d7febc36cffbc Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 27 Aug 2006 06:49:29 +0000 Subject: [ospfd] Bug #134, ospfd should be more robust to backward time change 2006-08-25 Paul Jakma * (general) Bug #134. Be more robust to backward time changes, use the newly added libzebra time functions. In most cases: recent_time -> recent_relative_time() gettimeofday -> quagga_gettime (QUAGGA_CLK_MONOTONIC, ..) time -> quagga_time. (ospf_make_md5_digest) time() call deliberately not changed. (ospf_external_lsa_refresh) remove useless gettimeofday, LSA tv_orig time was already set in ospf_lsa_new, called via ospf_external_lsa_new. --- ospfd/ospf_packet.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 6449e63a..d7a35645 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -337,7 +337,9 @@ ospf_make_md5_digest (struct ospf_interface *oi, struct ospf_packet *op) return 0; /* We do this here so when we dup a packet, we don't have to - waste CPU rewriting other headers. */ + waste CPU rewriting other headers. + + Note that quagga_time /deliberately/ is not used here */ t = (time(NULL) & 0xFFFFFFFF); if (t > oi->crypt_seqnum) oi->crypt_seqnum = t; @@ -444,7 +446,7 @@ ospf_ls_upd_timer (struct thread *thread) fired. This is a small tweak to what is in the RFC, but it will cut out out a lot of retransmit traffic - MAG */ - if (tv_cmp (tv_sub (recent_time, lsa->tv_recv), + if (tv_cmp (tv_sub (recent_relative_time (), lsa->tv_recv), int2tv (retransmit_interval)) >= 0) listnode_add (update, rn->info); } @@ -1363,7 +1365,7 @@ ospf_db_desc (struct ip *iph, struct ospf_header *ospfh, else { struct timeval t, now; - gettimeofday (&now, NULL); + quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); t = tv_sub (now, nbr->last_send_ts); if (tv_cmp (t, int2tv (nbr->v_inactivity)) < 0) { @@ -1948,7 +1950,7 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh, { struct timeval now; - gettimeofday (&now, NULL); + quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); if (tv_cmp (tv_sub (now, current->tv_orig), int2tv (OSPF_MIN_LS_ARRIVAL)) > 0) @@ -3158,7 +3160,7 @@ ospf_db_desc_send (struct ospf_neighbor *nbr) if (nbr->last_send) ospf_packet_free (nbr->last_send); nbr->last_send = ospf_packet_dup (op); - gettimeofday (&nbr->last_send_ts, NULL); + quagga_gettime (QUAGGA_CLK_MONOTONIC, &nbr->last_send_ts); } /* Re-send Database Description. */ -- cgit v1.2.3 From b5aeb4410ae3722a5f331850acbc84c39e3fcd9f Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Wed, 30 Aug 2006 18:47:37 +0000 Subject: [ospfd] Fix assertion in DB-exchange fix, hit by ogier-db-ex-opt commit 2006-08-28 Andy Gay * ospf_packet.c: (ospf_make_db_desc) Assert added with More-bit fixes does not hold up with addition of Ogier DB-Exchange optimisation, which can empty the db-summary list in between sent DD packets. Remove assert, update More-bit always when in Exchange. --- ospfd/ospf_packet.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index d7a35645..91527395 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -2712,25 +2712,9 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr, /* Set DD Sequence Number. */ stream_putl (s, nbr->dd_seqnum); + /* shortcut unneeded walk of (empty) summary LSDBs */ if (ospf_db_summary_isempty (nbr)) - { - /* Sanity check: - * - * Must be here either: - * - Initial DBD (ospf_nsm.c) - * - M must be set - * or - * - finishing Exchange, and DB-Summary list empty - * - from ospf_db_desc_proc() - * - M must not be set - */ - if (nbr->state >= NSM_Exchange) - assert (!IS_SET_DD_M(nbr->dd_flags)); - else - assert (IS_SET_DD_M(nbr->dd_flags)); - - return length; - } + goto empty; /* Describe LSA Header from Database Summary List. */ lsdb = &nbr->db_sum; @@ -2785,9 +2769,17 @@ ospf_make_db_desc (struct ospf_interface *oi, struct ospf_neighbor *nbr, /* Update 'More' bit */ if (ospf_db_summary_isempty (nbr)) { - UNSET_FLAG (nbr->dd_flags, OSPF_DD_FLAG_M); - /* Rewrite DD flags */ - stream_putc_at (s, pp, nbr->dd_flags); +empty: + if (nbr->state >= NSM_Exchange) + { + UNSET_FLAG (nbr->dd_flags, OSPF_DD_FLAG_M); + /* Rewrite DD flags */ + stream_putc_at (s, pp, nbr->dd_flags); + } + else + { + assert (IS_SET_DD_M(nbr->dd_flags)); + } } return length; } -- cgit v1.2.3 From 08c8367197cb847eb88942e5d7273cf3352d967f Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Mon, 25 Sep 2006 13:26:14 +0000 Subject: [ospfd] Improve some warning messages. 2006-09-25 Andrew J. Schorr * ospf_packet.c: (ospf_packet_dup, ospf_make_md5_digest) Fix zlog_warn messages to eliminate compiler warnings. (ospf_hello) Improve warning messages to show why we are complaining. --- ospfd/ospf_packet.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 91527395..ce90430d 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -216,8 +216,9 @@ ospf_packet_dup (struct ospf_packet *op) struct ospf_packet *new; if (stream_get_endp(op->s) != op->length) - zlog_warn ("ospf_packet_dup stream %ld ospf_packet %d size mismatch", - STREAM_SIZE(op->s), op->length); + /* XXX size_t */ + zlog_warn ("ospf_packet_dup stream %lu ospf_packet %u size mismatch", + (u_long)STREAM_SIZE(op->s), op->length); /* Reserve space for MD5 authentication that may be added later. */ new = ospf_packet_new (stream_get_endp(op->s) + OSPF_AUTH_MD5_SIZE); @@ -371,7 +372,9 @@ ospf_make_md5_digest (struct ospf_interface *oi, struct ospf_packet *op) op->length = ntohs (ospfh->length) + OSPF_AUTH_MD5_SIZE; if (stream_get_endp(op->s) != op->length) - zlog_warn("ospf_make_md5_digest: length mismatch stream %ld ospf_packet %d", stream_get_endp(op->s), op->length); + /* XXX size_t */ + zlog_warn("ospf_make_md5_digest: length mismatch stream %lu ospf_packet %u", + (u_long)stream_get_endp(op->s), op->length); return OSPF_AUTH_MD5_SIZE; } @@ -796,8 +799,10 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, /* Compare Router Dead Interval. */ if (OSPF_IF_PARAM (oi, v_wait) != ntohl (hello->dead_interval)) { - zlog_warn ("Packet %s [Hello:RECV]: RouterDeadInterval mismatch.", - inet_ntoa (ospfh->router_id)); + zlog_warn ("Packet %s [Hello:RECV]: RouterDeadInterval mismatch " + "(expected %u, but received %u).", + inet_ntoa(ospfh->router_id), + OSPF_IF_PARAM(oi, v_wait), ntohl(hello->dead_interval)); return; } @@ -806,8 +811,10 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, { if (OSPF_IF_PARAM (oi, v_hello) != ntohs (hello->hello_interval)) { - zlog_warn ("Packet %s [Hello:RECV]: HelloInterval mismatch.", - inet_ntoa (ospfh->router_id)); + zlog_warn ("Packet %s [Hello:RECV]: HelloInterval mismatch " + "(expected %u, but received %u).", + inet_ntoa(ospfh->router_id), + OSPF_IF_PARAM(oi, v_hello), ntohs(hello->hello_interval)); return; } } -- cgit v1.2.3 From 7ffa8fa2322fb759cf1f93730cde2cee3d4ad8ee Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Sun, 22 Oct 2006 20:07:53 +0000 Subject: [ospfd] Add passive-interface default support 2006-10-22 Yar Tikhiy * (general) Add support for passive-interface default (with minor edits by Paul Jakma). * ospf_interface.h: Add OSPF_IF_PASSIVE_STATUS macro, looking at configured value, or the global 'default' value, as required. * ospf_interface.c: (ospf_if_new_hook) Leave passive unconfigured per default, allowing global 'default' to take effect for unconfigured interfaces. * ospf_packet.c: (various) use OSPF_IF_PASSIVE_STATUS * ospf_vty.c: (ospf_passive_interface_default) new function, unset passive from all interfaces if default is enabled, as the per-iface settings become redundant. (ospf_passive_interface_update) new func, update passive setting taking global default into account. ({no,}ospf_passive_interface_addr_cmd) Add support for 'default' variant of command. (show_ip_ospf_interface_sub) Update to take global default into account when printing passive status. (ospf_config_write) ditto. * ospfd.c: (ospf_new) set global passive-interface default. * ospfd.h: (struct ospf) Add field for global passive-interface. --- ospfd/ospf_packet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index ce90430d..2addc497 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -762,7 +762,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, } /* If incoming interface is passive one, ignore Hello. */ - if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_PASSIVE) { + if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE) { char buf[3][INET_ADDRSTRLEN]; zlog_debug ("ignoring HELLO from router %s sent to %s, " "received on a passive interface, %s", @@ -2978,7 +2978,7 @@ ospf_poll_send (struct ospf_nbr_nbma *nbr_nbma) assert(oi); /* If this is passive interface, do not send OSPF Hello. */ - if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_PASSIVE) + if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE) return; if (oi->type != OSPF_IFTYPE_NBMA) @@ -3046,7 +3046,7 @@ ospf_hello_send (struct ospf_interface *oi) u_int16_t length = OSPF_HEADER_SIZE; /* If this is passive interface, do not send OSPF Hello. */ - if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_PASSIVE) + if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE) return; op = ospf_packet_new (oi->ifp->mtu); -- cgit v1.2.3 From 6f0e3f6e17687eb25b7b77c4fdc8324837d4700f Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 10 May 2007 02:38:51 +0000 Subject: [autoconf] bugs 162,303,178: Fix 'present but can not be compiled' warnings 2007-05-09 Paul Jakma * configure.ac: sys/conf.h depends on sys/param.h, at least on FBSD 6.2. (bug #363) Should check for in_pktinfo for IRDP 2006-05-27 Paul Jakma * configure.ac: General cleanup of header and type checks, introducing an internal define, QUAGGA_INCLUDES, to build up a list of stuff to include so as to avoid 'present but cant be compiled' warnings. Misc additional checks of things missing according to autoscan. Add LIBM, for bgpd's use of libm, so as to avoid burdening LIBS, and all the binaries, with libm linkage. Remove the bad practice of using m4 changequote(), just quote the []'s in the case statements properly. This should fix bugs 162, 303 and 178. * */*.{c,h}: Update all HAVE_* to the standard autoconf namespaced HAVE_* defines. I.e. HAVE_SA_LEN -> HAVE_STRUCT_SOCKADDR_SA_LEN, * bgpd/Makefile.am: Add LIBM to bgpd's LDADD, for pow(). --- ospfd/ospf_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 2addc497..4735f99b 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -628,9 +628,9 @@ ospf_write (struct thread *thread) memset (&sa_dst, 0, sizeof (sa_dst)); sa_dst.sin_family = AF_INET; -#ifdef HAVE_SIN_LEN +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sa_dst.sin_len = sizeof(sa_dst); -#endif /* HAVE_SIN_LEN */ +#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ sa_dst.sin_addr = op->dst; sa_dst.sin_port = htons (0); -- cgit v1.2.3 From b7fe4141123c6fc26fffec68d0db62ecf474c074 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 21 Aug 2007 16:32:56 +0000 Subject: Bug #362 is fixed now. --- ospfd/ospf_packet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 4735f99b..a778a50b 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -602,8 +602,12 @@ ospf_write (struct thread *thread) ipid = (time(NULL) & 0xffff); #endif /* WANT_OSPF_WRITE_FRAGMENT */ - /* convenience - max OSPF data per packet */ - maxdatasize = oi->ifp->mtu - sizeof (struct ip); + /* convenience - max OSPF data per packet, + * and reliability - not more data, than our + * socket can accept + */ + maxdatasize = MIN (oi->ifp->mtu, ospf->maxsndbuflen) - + sizeof (struct ip); /* Get one packet from queue. */ op = ospf_fifo_head (oi->obuf); -- cgit v1.2.3 From 53d0deceeb855493aa03c59477f8af7f6bb75140 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Fri, 30 May 2008 16:04:39 +0200 Subject: Set destination for PtP links to OSPF_ALLSPFROUTERS. Update ospf_db_desc_send(), ospf_ls_upd_queue_send() and ospf_ls_req_send() to always use OSPF_ALLSPFROUTERS for PtP links. See RFC 2328, chap 8.1 for details: "The IP destination address for the packet is selected as follows. On physical point-to-point networks, the IP destination is always set to the address AllSPFRouters." Without this, it won't be possible to establish adjacencies on multiple unnumbered links to the same router. ChangeLog: 2008-07-25 Joakim Tjernlund * ospfd/ospf_packet.c: Set destination for PtP links to OSPF_ALLSPFROUTERS. --- ospfd/ospf_packet.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index a778a50b..ed342e7f 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -3151,7 +3151,10 @@ ospf_db_desc_send (struct ospf_neighbor *nbr) op->length = length; /* Decide destination address. */ - op->dst = nbr->address.u.prefix4; + if (oi->type == OSPF_IFTYPE_POINTOPOINT) + op->dst.s_addr = htonl (OSPF_ALLSPFROUTERS); + else + op->dst = nbr->address.u.prefix4; /* Add packet to the interface output queue. */ ospf_packet_add (oi, op); @@ -3210,7 +3213,10 @@ ospf_ls_req_send (struct ospf_neighbor *nbr) op->length = length; /* Decide destination address. */ - op->dst = nbr->address.u.prefix4; + if (oi->type == OSPF_IFTYPE_POINTOPOINT) + op->dst.s_addr = htonl (OSPF_ALLSPFROUTERS); + else + op->dst = nbr->address.u.prefix4; /* Add packet to the interface output queue. */ ospf_packet_add (oi, op); @@ -3326,7 +3332,10 @@ ospf_ls_upd_queue_send (struct ospf_interface *oi, struct list *update, op->length = length; /* Decide destination address. */ - op->dst.s_addr = addr.s_addr; + if (oi->type == OSPF_IFTYPE_POINTOPOINT) + op->dst.s_addr = htonl (OSPF_ALLSPFROUTERS); + else + op->dst.s_addr = addr.s_addr; /* Add packet to the interface output queue. */ ospf_packet_add (oi, op); @@ -3403,13 +3412,12 @@ ospf_ls_upd_send (struct ospf_neighbor *nbr, struct list *update, int flag) /* Decide destination address. */ if (oi->type == OSPF_IFTYPE_VIRTUALLINK) p.prefix = oi->vl_data->peer_addr; + else if (oi->type == OSPF_IFTYPE_POINTOPOINT) + p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS); else if (flag == OSPF_SEND_PACKET_DIRECT) p.prefix = nbr->address.u.prefix4; else if (oi->state == ISM_DR || oi->state == ISM_Backup) p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS); - else if ((oi->type == OSPF_IFTYPE_POINTOPOINT) - && (flag == OSPF_SEND_PACKET_INDIRECT)) - p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS); else if (oi->type == OSPF_IFTYPE_POINTOMULTIPOINT) p.prefix.s_addr = htonl (OSPF_ALLSPFROUTERS); else -- cgit v1.2.3 From 491eddc20ec072b05607d5a90513e3fffc0d85c2 Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Wed, 24 Sep 2008 17:03:59 +0100 Subject: [ospfd] Move passive interface check * ospf_packet.c: Apply passive check and drop for all packages and not just Hellos. Signed-off-by: Paul Jakma --- ospfd/ospf_packet.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'ospfd/ospf_packet.c') diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index ed342e7f..5f0d99da 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -765,24 +765,6 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh, return; } - /* If incoming interface is passive one, ignore Hello. */ - if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE) { - char buf[3][INET_ADDRSTRLEN]; - zlog_debug ("ignoring HELLO from router %s sent to %s, " - "received on a passive interface, %s", - inet_ntop(AF_INET, &ospfh->router_id, buf[0], sizeof(buf[0])), - inet_ntop(AF_INET, &iph->ip_dst, buf[1], sizeof(buf[1])), - inet_ntop(AF_INET, &oi->address->u.prefix4, - buf[2], sizeof(buf[2]))); - if (iph->ip_dst.s_addr == htonl(OSPF_ALLSPFROUTERS)) - { - /* Try to fix multicast membership. */ - OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS); - ospf_if_set_multicast(oi); - } - return; - } - /* get neighbor prefix. */ p.family = AF_INET; p.prefixlen = ip_masklen (hello->network_mask); @@ -2393,6 +2375,32 @@ ospf_read (struct thread *thread) /* associate packet with ospf interface */ oi = ospf_if_lookup_recv_if (ospf, iph->ip_src); + /* If incoming interface is passive one, ignore it. */ + if (oi && OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_PASSIVE) + { + char buf[3][INET_ADDRSTRLEN]; + + if (IS_DEBUG_OSPF_EVENT) + zlog_debug ("ignoring packet from router %s sent to %s, " + "received on a passive interface, %s", + inet_ntop(AF_INET, &ospfh->router_id, buf[0], sizeof(buf[0])), + inet_ntop(AF_INET, &iph->ip_dst, buf[1], sizeof(buf[1])), + inet_ntop(AF_INET, &oi->address->u.prefix4, + buf[2], sizeof(buf[2]))); + + if (iph->ip_dst.s_addr == htonl(OSPF_ALLSPFROUTERS)) + { + /* Try to fix multicast membership. + * Some OS:es may have problems in this area, + * make sure it is removed. + */ + OI_MEMBER_JOINED(oi, MEMBER_ALLROUTERS); + ospf_if_set_multicast(oi); + } + return 0; + } + + /* if no local ospf_interface, * or header area is backbone but ospf_interface is not * check for VLINK interface -- cgit v1.2.3