Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions sys/net/gnrc/network_layer/icmpv6/echo/gnrc_icmpv6_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ void gnrc_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr,
{
uint8_t *payload = ((uint8_t *)echo) + sizeof(icmpv6_echo_t);
gnrc_pktsnip_t *hdr, *pkt;
gnrc_netreg_entry_t *sendto = NULL;

if ((echo == NULL) || (len < sizeof(icmpv6_echo_t))) {
DEBUG("icmpv6_echo: echo was NULL or len (%" PRIu16
Expand Down Expand Up @@ -103,23 +102,10 @@ void gnrc_icmpv6_echo_req_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6_hdr,

LL_PREPEND(pkt, hdr);

sendto = gnrc_netreg_lookup(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL);

if (sendto == NULL) {
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL,
pkt)) {
DEBUG("icmpv6_echo: no receivers for IPv6 packets\n");
gnrc_pktbuf_release(pkt);
return;
}

/* ICMPv6 is not interested anymore so `- 1` */
gnrc_pktbuf_hold(pkt, gnrc_netreg_num(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL) - 1);

while (sendto != NULL) {
if (gnrc_netapi_send(sendto->pid, pkt) < 1) {
DEBUG("icmpv6_echo: unable to send packet\n");
gnrc_pktbuf_release(pkt);
}
sendto = gnrc_netreg_getnext(sendto);
}
}

Expand Down
22 changes: 3 additions & 19 deletions sys/net/gnrc/network_layer/icmpv6/gnrc_icmpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void gnrc_icmpv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt)
{
gnrc_pktsnip_t *icmpv6, *ipv6;
icmpv6_hdr_t *hdr;
gnrc_netreg_entry_t *sendto;

icmpv6 = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_ICMPV6);

Expand Down Expand Up @@ -127,24 +126,9 @@ void gnrc_icmpv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt)

/* ICMPv6-all will be send in gnrc_ipv6.c so only dispatch of subtypes is
* needed */

sendto = gnrc_netreg_lookup(GNRC_NETTYPE_ICMPV6, hdr->type);

if (sendto == NULL) {
DEBUG("icmpv6: no receivers for ICMPv6 type %u\n", hdr->type);
/* don't release: IPv6 does this */
return;
}

/* IPv6 might still do stuff to the packet, so no `- 1` */
gnrc_pktbuf_hold(pkt, gnrc_netreg_num(GNRC_NETTYPE_ICMPV6, hdr->type));

while (sendto != NULL) {
if (gnrc_netapi_receive(sendto->pid, pkt) < 1) {
DEBUG("icmpv6: unable to deliver packet\n");
gnrc_pktbuf_release(pkt);
}
sendto = gnrc_netreg_getnext(sendto);
if (!gnrc_netapi_dispatch_receive(GNRC_NETTYPE_ICMPV6, hdr->type, pkt)) {
DEBUG("icmpv6: no one interested in type %d\n", hdr->type);
gnrc_pktbuf_release(pkt);
}
}

Expand Down
1 change: 0 additions & 1 deletion sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *current, gnrc_pktsnip_t
case PROTNUM_ICMPV6:
DEBUG("ipv6: handle ICMPv6 packet (nh = %u)\n", nh);
gnrc_icmpv6_demux(iface, pkt);
gnrc_pktbuf_release(pkt);
return;
Copy link
Copy Markdown
Member Author

@miri64 miri64 Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removal was necessary because there isn't the release [hold] we had in https://github.com/RIOT-OS/RIOT/pull/5525/files#diff-9af59eae807169797112fdc7b1ca9504L140. Additionally, this simplifies a lot since we return to the event loop here anyways.

#endif
#ifdef MODULE_GNRC_IPV6_EXT
Expand Down
10 changes: 5 additions & 5 deletions sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ void gnrc_ndp_nbr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
(ipv6_addr_is_unspecified(&ipv6->src) &&
ipv6_addr_is_solicited_node(&ipv6->dst))) {
DEBUG("ndp: neighbor solicitation was invalid.\n");
/* ipv6 releases */
/* icmpv6 releases */
return;
}
if ((tgt = gnrc_ipv6_netif_find_addr(iface, &nbr_sol->tgt)) == NULL) {
DEBUG("ndp: Target address is not to interface %" PRIkernel_pid "\n",
iface);
/* ipv6 releases */
/* icmpv6 releases */
return;
}
sicmpv6_size -= sizeof(ndp_nbr_sol_t);
Expand Down Expand Up @@ -228,14 +228,14 @@ void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
(icmpv6_size < sizeof(ndp_nbr_adv_t)) ||
ipv6_addr_is_multicast(&nbr_adv->tgt)) {
DEBUG("ndp: neighbor advertisement was invalid.\n");
/* ipv6 releases */
/* icmpv6 releases */
return;
}

if (nc_entry == NULL) {
/* see https://tools.ietf.org/html/rfc4861#section-7.2.5 */
DEBUG("ndp: no neighbor cache entry found for advertisement's target\n");
/* ipv6 releases */
/* icmpv6 releases */
return;
}

Expand Down Expand Up @@ -507,7 +507,7 @@ void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t
(ipv6->hl != 255) || (rtr_adv->code != 0) ||
(icmpv6_size < sizeof(ndp_rtr_adv_t))) {
DEBUG("ndp: router advertisement was invalid\n");
/* ipv6 releases */
/* icmpv6 releases */
return;
}
/* get source from default router list */
Expand Down
12 changes: 2 additions & 10 deletions sys/shell/commands/sc_icmpv6_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ int _icmpv6_ping(int argc, char **argv)
ipv6_addr_t addr;
kernel_pid_t src_iface;
msg_t msg;
gnrc_netreg_entry_t *ipv6_entry, my_entry = { NULL, ICMPV6_ECHO_REP,
thread_getpid() };
gnrc_netreg_entry_t my_entry = { NULL, ICMPV6_ECHO_REP, thread_getpid() };
uint32_t min_rtt = UINT32_MAX, max_rtt = 0;
uint64_t sum_rtt = 0;
uint64_t ping_start;
Expand Down Expand Up @@ -231,13 +230,6 @@ int _icmpv6_ping(int argc, char **argv)
return 1;
}

ipv6_entry = gnrc_netreg_lookup(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL);

if (ipv6_entry == NULL) {
puts("error: ipv6 thread missing");
return 1;
}

remaining = count;

ping_start = xtimer_now64();
Expand Down Expand Up @@ -277,7 +269,7 @@ int _icmpv6_ping(int argc, char **argv)
}

start = xtimer_now();
if (gnrc_netapi_send(ipv6_entry->pid, pkt) < 1) {
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) {
puts("error: unable to send ICMPv6 echo request\n");
gnrc_pktbuf_release(pkt);
continue;
Expand Down