Merge lp://staging/~cviethen/hipl/pisa-pairing-tng into lp://staging/hipl
Status: | Needs review |
---|---|
Proposed branch: | lp://staging/~cviethen/hipl/pisa-pairing-tng |
Merge into: | lp://staging/hipl |
Diff against target: |
370 lines (+216/-4) 8 files modified
hipd/hadb.c (+36/-0) hipd/hadb.h (+5/-0) hipd/netdev.c (+49/-2) hipd/netdev.h (+1/-0) hipd/user.c (+4/-0) lib/core/builder.c (+1/-0) lib/core/conf.c (+119/-2) lib/core/icomm.h (+1/-0) |
To merge this branch: | bzr merge lp://staging/~cviethen/hipl/pisa-pairing-tng |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stefan Götz (community) | Needs Fixing | ||
Miika Komu | Needs Fixing | ||
Diego Biurrun | Needs Fixing | ||
Review via email: mp+87876@code.staging.launchpad.net |
Description of the change
Here's a new incarnation of my patch to enable triggering an opportunistic base exchange from hipconf. I made it a new branch to have it correspond closely to the current state of HIPL.
This functionality is necessary for performing the pairing procedure in PiSA, but since it may be
quite useful for other purposes as well, no explicit reference to PiSA is made within the code.
I tried to take into account feedback I got from my previous version a couple months ago, focusing especially on minimizing code duplication and, accordingly, on re-using as many bits and pieces as already available.
It - almost - perfectly worked: I had to introduce a new message type that hipconf will send to hipd since the available message type (HIP_MSG_
Additional advantage is that, when receiving such a message, the code can be sure an opportunistic base exchange was intended, so I could add an additional check for an already-existing host association with the desired target:
In case that association exists in ESTABLISHED state, it's not a good idea to try and send another I1 message to the opposing host - it will respond with an R1, containing full source and destination HITs, but that one will be rejected by the local host since there's already an established host association. As a consequence, the newly created HA would be stuck in I1_SENT state. To prevent this, opportunistic base exchanges are not sent to hosts with which we already have an established association.
Thank you!
Unmerged revisions
- 6235. By Christoph Viethen
-
Misc. code cleanup and cosmetics - no change in functionality. Many thanks
to Christof and Diego for their input. - 6234. By Christoph Viethen
-
Fix a little bug concerning Doxygen.
- 6233. By Christoph Viethen
-
Submit an updated version of patch, based on current HIPL. This one will enable
using the command "hipconf daemon trigger bex <ip-addr>" to trigger an
opportunistic base exchange with the given host.To achieve this, a few places in HIPL are touched:
1) Add functionality to hipconf, using a new message type
(HIP_MSG_TRIGGER_ OPP_BEX) and an appropriate handling function
(conf_handle_ trigger_ bex()) (lib/core/ builder. c, lib/core/conf.c,
lib/core/icomm.h).2) Enable hipd to handle such a message (hipd/user.c), adding a new function
called hip_netdev_trigger_ opp_bex_ msg() (hipd/netdev.c). 3) That new function which will check for an already-existing host
association before calling a function that will perform the actual
opportunistic base exchange; check will prevent creating associations that
will get stuck in I1_SENT state. (Add helper function to hipd/hadb.c.)4) Patch netdev_
trigger_ bex() slightly to not error out if encountering an
pseudo HIT as a target, and use this function for the actual base exchange
(hipd/netdev.c).
Good work concerning functionality! Some remarks below.
On 08.01.2012 18:55, Christoph Viethen wrote:
> === modified file 'hipd/hadb.c'
> --- hipd/hadb.c 2011-12-30 23:20:44 +0000
> +++ hipd/hadb.c 2012-01-08 17:54:25 +0000
> @@ -1400,6 +1400,45 @@
> }
>
> /**
> + * This function searches for a<tt> struct hip_hadb_state</tt> entry from the
> + * @c hadb_hit by the given tuple (source hit, dest. ip, dest. port).
Use ::hip_hadb_state and ::hadb_hit rather than syntactic markup, so
that doxygen can generate cross-references in html output.
> +struct hip_hadb_state *hip_hadb_ find_by_ srchit_ destip_ port(hip_ hit_t *src_hit,
> + const struct in6_addr *dst_ip,
> + in_port_t dst_port)
src_hit can be const.
> +{ each_safe( item, aux, hadb_hit, i) cmp(&tmp- >hit_our, src_hit)) { addr_cmp( &tmp->peer_ addr, dst_ip)) {
> + LHASH_NODE *item, *aux;
> + struct hip_hadb_state *tmp;
> + int i;
> +
> + list_for_
> + {
> + tmp = list_entry(item);
> + if (ipv6_addr_
> + continue;
> + } else if (!ipv6_
> + if (tmp->peer_udp_port == dst_port) {
> + return tmp;
> + } else {
> + continue;
> + }
> + } else {
> + continue;
> + }
Would the following do the trick?
list_for_ each_safe( item, aux, hadb_hit, i)
{
tmp = list_entry(item);
const bool ok = !ipv6_addr_ cmp(&tmp- >hit_our, src_hit) &&
!ipv6_addr_ cmp(&tmp- >peer_addr, dst_ip) &&
tmp->peer_ udp_port == dst_port;
if(ok) {
return tmp;
}
}
Extra bool indirection because our policy of keeping the opening brace
on the same line as the closing paren makes multi-line conditions very
hard to comprehend IMHO, but feel free to inline if you're fine with it.
> === modified file 'hipd/hadb.h' default_ hit(&our_ hit)< 0) {
> --- hipd/hadb.h 2011-11-25 17:56:24 +0000
> +++ hipd/hadb.h 2012-01-08 17:54:25 +0000
> @@ -1094,6 +1093,56 @@
> + /* Find out: 1. our own hit, */
> + if (hip_get_
> + return -1;
> + }
You should run uncrustify again.
> @@ -2424,6 +2433,111 @@
> }
>
> /**
> + * Handles the<tt> hipconf daemon trigger bex</tt> command.
Same as above
> + if (ai_err == 0) { >ai_addr- >sa_family == AF_INET) { IPV6_MAP( &((struct sockaddr_in *) ai_res- >ai_addr) ->sin_addr, &ipv6_addr) ; >ai_addr- >sa_family == AF_INET6) { &ipv6_addr, &((struct sockaddr_in6 *) ai_res- >ai_addr) ->sin6_ addr, sizeof(struct in6_addr));
> + int done = 0;
> + const struct addrinfo *ai_res = addrinfo_result;
> +
> + while (done == 0&& ai_res != NULL) {
> + if (ai_res-
> + /* turn address into an IPv4-mapped IPv6 address
> + * (RFC 4291, 2.5.5.2.) */
> + IPV4_TO_
> + done = 1;
> + }
> + if (ai_res-
> + memcpy(
> + done = 1;
> + }
These lines can be shortened without much hassle. Also, are you sure
t...