diff options
author | Avik Sil <aviksil@linux.vnet.ibm.com> | 2014-01-16 17:27:54 +0530 |
---|---|---|
committer | Avik Sil <aviksil@linux.vnet.ibm.com> | 2014-01-20 17:19:47 +0530 |
commit | 0852f3807fac91cc336a62f62558d1f3a08db1a2 (patch) | |
tree | 37e78294087829207d3b6df87e9bc0d1ca7da998 | |
parent | 673997ee749f8e8d0659a9864b8bfa8b069bf400 (diff) | |
download | SLOF-0852f3807fac91cc336a62f62558d1f3a08db1a2.zip SLOF-0852f3807fac91cc336a62f62558d1f3a08db1a2.tar.gz SLOF-0852f3807fac91cc336a62f62558d1f3a08db1a2.tar.bz2 |
Handle router advertisement message properly
process_ra_options was going through infinite loop due to improper handling of option_length.
Also introduction of is_ra_received() makes booting time faster since it returns as soon as
router advertisement mesage is received.
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
-rw-r--r-- | clients/net-snk/app/netlib/icmpv6.c | 18 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/icmpv6.h | 1 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/ipv6.c | 9 |
3 files changed, 20 insertions, 8 deletions
diff --git a/clients/net-snk/app/netlib/icmpv6.c b/clients/net-snk/app/netlib/icmpv6.c index 6aabfe3..8cf0e2d 100644 --- a/clients/net-snk/app/netlib/icmpv6.c +++ b/clients/net-snk/app/netlib/icmpv6.c @@ -21,6 +21,8 @@ #include <netlib/ndp.h> #include <netlib/dhcpv6.h> +static int ra_received = 0; + /** * NET: * @@ -126,16 +128,16 @@ process_ra_options (uint8_t *option, int32_t option_length, struct router *r) switch (*option) { case ND_OPTION_SOURCE_LL_ADDR: handle_source_lladdr ((struct option_ll_address *) option, r); - //option+1 is the length field. length is in units of 8 bytes - option = option + (*(option+1) * 8); - option_length = option_length - (*(option+1) * 8); break; case ND_OPTION_PREFIX_INFO: handle_prefixoption(option); - option = option + (*(option+1) * 8); - option_length = option_length - (*(option+1) * 8); + break; + default: break; } + //option+1 is the length field. length is in units of 8 bytes + option_length = option_length - (*(option+1) * 8); + option = option + (*(option+1) * 8); } return; @@ -181,6 +183,12 @@ handle_ra (struct icmp6hdr *icmp6h, uint8_t *ip6_packet) option_length = (uint8_t *) icmp6h + ip6h->pl - first_option; process_ra_options( (uint8_t *) first_option, option_length, rtr); + ra_received = 1; +} + +int is_ra_received(void) +{ + return ra_received; } /** diff --git a/clients/net-snk/app/netlib/icmpv6.h b/clients/net-snk/app/netlib/icmpv6.h index f080047..280df1f 100644 --- a/clients/net-snk/app/netlib/icmpv6.h +++ b/clients/net-snk/app/netlib/icmpv6.h @@ -50,6 +50,7 @@ int8_t handle_icmpv6 (struct ethhdr *etherhdr, uint8_t *ip6_packet); void send_neighbour_solicitation( ip6_addr_t *target_ip6); void send_router_solicitation(void); +int is_ra_received(void); /* Prefix information */ struct option_prefix { diff --git a/clients/net-snk/app/netlib/ipv6.c b/clients/net-snk/app/netlib/ipv6.c index 46b8110..4d37498 100644 --- a/clients/net-snk/app/netlib/ipv6.c +++ b/clients/net-snk/app/netlib/ipv6.c @@ -364,10 +364,13 @@ ipv6_init () last_neighbor = first_neighbor; send_router_solicitation (); - for(i=0; i < 4; i++) { + for(i=0; i < 4 && !is_ra_received(); i++) { set_timer(TICKS_SEC); - while (get_timer() > 0); - receive_ether(); + do { + receive_ether(); + if (is_ra_received()) + break; + } while (get_timer() > 0); } } |