> @@ -157,6 +158,41 @@
> }
>
> /**
> + * Verify the validity of the ACK ID of a received Update packet and update the
> + * range in which Update packets will be accepted accordingly.
> + *
> + * @param state The update state of the respective HA.
> + * @param ack_peer_update_id The received ACK ID.
> + *
> + * @return true if received ACK is valid
> + * false else
> + */
> +static bool check_and_update_ack_id_bounds(struct update_state *const state,
> + uint32_t ack_peer_update_id)
const uint32_t ack_peer_update_id would be more const correct.
> +{
> + HIP_ASSERT(state);
> +
> + /* two cases:
> + * oldest not yet acknowledged SEQ <= latest sent Update SEQ
> + * => received ACK must be in those bounds to be valid
> + * oldest not yet acknowledged SEQ > latest sent Update SEQ (counter overflow)
> + * => received ACK must be greater than oldest SEQ or smaller than latest
> + * sent Update ID to be valid
> + */
This comment is hard to understand without knowledge about your internal seq/ack data structure. Please describe how the two fields update_id_out_lower_bound and update_id_out are used in a normal update situation.
Please break this down into a if () ... else if () ... else for higher readability.
> * Check if UPDATE sequence and acknowledgment numbers are as expected.
> *
> * @param packet_type the packet type
> @@ -216,12 +252,12 @@
> HIP_DEBUG("ACK parameter found with peer Update ID %u.\n",
> ack_peer_update_id);
>
> - // we only want acks for our most current update
> - if (ack_peer_update_id != hip_update_get_out_id(localstate)) {
> - HIP_DEBUG("Update ID (%u) in the ACK parameter is not "
> - "equal to the last outgoing Update ID (%u). "
> + if (!check_and_update_ack_id_bounds(localstate, ack_peer_update_id)) {
> + HIP_DEBUG("Update ID (%u) in the ACK parameter is not one of the "
> + "yet to be acknowledged Update IDs (%u-%u). "
Let's call this "current update ID window (%u-%u)".
review needs-fixing
I just have a few comments inline.
On 10.08.2011, at 13:16, David Martin wrote: /code.launchpad .net/~martin- lp/hipl/ update_ ack_handling/ +merge/ 71027
> David Martin has proposed merging lp:~martin-lp/hipl/update_ack_handling into lp:hipl.
>
> Requested reviews:
> HIPL core team (hipl-core)
>
> For more details, see:
> https:/
> === modified file 'modules/ update/ hipd/update. c' update/ hipd/update. c 2011-07-18 16:41:13 +0000 update/ hipd/update. c 2011-08-10 11:16:05 +0000
> --- modules/
> +++ modules/
> @@ -157,6 +158,41 @@ update_ ack_id_ bounds( struct update_state *const state,
> }
>
> /**
> + * Verify the validity of the ACK ID of a received Update packet and update the
> + * range in which Update packets will be accepted accordingly.
> + *
> + * @param state The update state of the respective HA.
> + * @param ack_peer_update_id The received ACK ID.
> + *
> + * @return true if received ACK is valid
> + * false else
> + */
> +static bool check_and_
> + uint32_t ack_peer_update_id)
const uint32_t ack_peer_update_id would be more const correct.
> +{
> + HIP_ASSERT(state);
> +
> + /* two cases:
> + * oldest not yet acknowledged SEQ <= latest sent Update SEQ
> + * => received ACK must be in those bounds to be valid
> + * oldest not yet acknowledged SEQ > latest sent Update SEQ (counter overflow)
> + * => received ACK must be greater than oldest SEQ or smaller than latest
> + * sent Update ID to be valid
> + */
This comment is hard to understand without knowledge about your internal seq/ack data structure. Please describe how the two fields update_ id_out_ lower_bound and update_id_out are used in a normal update situation.
> + if ((state- >update_ id_out_ lower_bound <= hip_update_ get_out_ id(state) && update_ id_out_ lower_bound && get_out_ id(state) ) || >update_ id_out_ lower_bound > hip_update_ get_out_ id(state) && update_ id_out_ lower_bound || get_out_ id(state) ))) { update_ id_out_ lower_bound = ack_peer_update_id;
> + ack_peer_update_id >= state->
> + ack_peer_update_id <= hip_update_
> + (state-
> + (ack_peer_update_id >= state->
> + ack_peer_update_id <= hip_update_
> + state->
> + return true;
> + } else {
> + return false;
> + }
Please break this down into a if () ... else if () ... else for higher readability.
> * Check if UPDATE sequence and acknowledgment numbers are as expected. update_ id); get_out_ id(localstate) ) { and_update_ ack_id_ bounds( localstate, ack_peer_ update_ id)) {
> *
> * @param packet_type the packet type
> @@ -216,12 +252,12 @@
> HIP_DEBUG("ACK parameter found with peer Update ID %u.\n",
> ack_peer_
>
> - // we only want acks for our most current update
> - if (ack_peer_update_id != hip_update_
> - HIP_DEBUG("Update ID (%u) in the ACK parameter is not "
> - "equal to the last outgoing Update ID (%u). "
> + if (!check_
> + HIP_DEBUG("Update ID (%u) in the ACK parameter is not one of the "
> + "yet to be acknowledged Update IDs (%u-%u). "
Let's call this "current update ID window (%u-%u)".
> "Dropping the packet.\n", >update_ id_out_ lower_bound, get_out_ id(localstate) ); state-> update_ state = 0; state-> valid_locators = 0; state-> update_ id_out = 0; state-> update_ id_in = 0; state-> update_ state = 0; state-> valid_locators = 0; state-> update_ id_out = 0; state-> update_ id_out_ lower_bound = 0; state-> update_ id_in = 0; state_item( state, update_state, "update"); update/ hipd/update. h' update/ hipd/update. h 2011-07-28 18:11:17 +0000 update/ hipd/update. h 2011-08-10 11:16:05 +0000
> ack_peer_update_id,
> + localstate-
> hip_update_
> err = -1;
> goto out_err;
> @@ -487,10 +523,11 @@
> return -1;
> }
>
> - update_
> - update_
> - update_
> - update_
> + update_
> + update_
> + update_
> + update_
> + update_
>
> return lmod_add_
> }
>
> === modified file 'modules/
> --- modules/
> +++ modules/
> @@ -83,6 +83,10 @@
>
> /** Stored outgoing UPDATE ID counter. */
> uint32_t update_id_out;
Please update the doxygen comment of update_id_out to better reflect the difference between the two update_id_out* values.
> + /** Stored oldest not yet acknowledged outgoing UPDATE ID counter. */ id_out_ lower_bound;
> + uint32_t update_
-- www.comsys. rwth-aachen. de/team/ rene-hummen/
Dipl.-Inform. Rene Hummen, Ph.D. Student
Chair of Communication and Distributed Systems
RWTH Aachen University, Germany
tel: +49 241 80 20772
web: http://