Merge pull request #12512 from miri64/gnrc_ipv6/fix/i11980
gnrc_ipv6: fix SEGFAULT when multicasting with multiple interfaces
This commit is contained in:
commit
8b2f697f8c
@ -563,28 +563,33 @@ static void _send_multicast(gnrc_pktsnip_t *pkt, bool prep_hdr,
|
|||||||
gnrc_pktbuf_hold(pkt, ifnum - 1);
|
gnrc_pktbuf_hold(pkt, ifnum - 1);
|
||||||
|
|
||||||
while ((netif = gnrc_netif_iter(netif))) {
|
while ((netif = gnrc_netif_iter(netif))) {
|
||||||
|
gnrc_pktsnip_t *send_pkt = pkt;
|
||||||
|
/* for !prep_hdr just use pkt as we don't duplicate IPv6 header as
|
||||||
|
* it is already filled and thus isn't filled with potentially
|
||||||
|
* interface-specific data */
|
||||||
if (prep_hdr) {
|
if (prep_hdr) {
|
||||||
DEBUG("ipv6: prepare IPv6 header for sending\n");
|
DEBUG("ipv6: prepare IPv6 header for sending\n");
|
||||||
/* need to get second write access (duplication) to fill IPv6
|
/* need to get second write access (duplication) to fill IPv6
|
||||||
* header interface-local */
|
* header with interface-specific data */
|
||||||
gnrc_pktsnip_t *tmp = gnrc_pktbuf_start_write(pkt);
|
send_pkt = gnrc_pktbuf_start_write(pkt);
|
||||||
|
|
||||||
if (tmp == NULL) {
|
if (send_pkt == NULL) {
|
||||||
DEBUG("ipv6: unable to get write access to IPv6 header, "
|
DEBUG("ipv6: unable to get write access to IPv6 header, "
|
||||||
"for interface %" PRIkernel_pid "\n", netif->pid);
|
"for interface %" PRIkernel_pid "\n", netif->pid);
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_fill_ipv6_hdr(netif, tmp) < 0) {
|
if (_fill_ipv6_hdr(netif, send_pkt) < 0) {
|
||||||
/* error on filling up header */
|
/* error on filling up header */
|
||||||
if (tmp != pkt) {
|
if (send_pkt != pkt) {
|
||||||
gnrc_pktbuf_release(tmp);
|
gnrc_pktbuf_release(send_pkt);
|
||||||
}
|
}
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_send_multicast_over_iface(pkt, prep_hdr, netif, netif_hdr_flags);
|
_send_multicast_over_iface(send_pkt, prep_hdr, netif,
|
||||||
|
netif_hdr_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user