net/lwip: change the place of exception handling
Validation of hop limit for NS message is working at the ipv6 header level.
And there's no need to process if it's not valid so it should be processed ASAP
@@ -356,6 +356,14 @@ void nd6_input(struct pbuf *p, struct netif *inp)
return;
}
+ if (IP6H_HOPLIM(ip6_current_header()) != 255) {
+ /* silently discard a NS messsage with invalid hop limit */
+ pbuf_free(p);
+ ND6_STATS_INC(nd6.proterr);
+ ND6_STATS_INC(nd6.drop);
+ return;
+ }
+
ns_hdr = (struct ns_header *)p->payload;
if (ND6H_CODE(ns_hdr) != 0) {
@@ -390,14 +398,6 @@ void nd6_input(struct pbuf *p, struct netif *inp)
return;
}
- if (IP6H_HOPLIM(ip6_current_header()) != 255) {
- /* silently discard a NS messsage with invalid hop limit */
- pbuf_free(p);
- ND6_STATS_INC(nd6.proterr);
- ND6_STATS_INC(nd6.drop);
- return;
- }
-
/* Check for ANY address in src (DAD algorithm). */
if (ip6_addr_isany(ip6_current_src_addr())) {
if (ip6_addr_ismulticast(ip6_current_dest_addr())) {
