Skip to content
Closed
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
5 changes: 5 additions & 0 deletions sys/include/net/gnrc/netif.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ extern "C" {
#define GNRC_NETIF_NUMOF (1)
#endif

/**
* @brief Identifier of the loopback interface
*/
#define GNRC_NETIF_LOOPBACK_PID (-1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd rather have it a positive number (maybe KERNEL_PID_MAX?), since I think there might be checks for >= KERNEL_PID_UNDEF in the code.

@OlegHahm OlegHahm Jan 15, 2017

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, -1 was your proposal:
#5247 (comment)

KERNEL_PID_LAST + 1 would work for me, too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mh, then I trust past me for now. Let's test this :D

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

assertion fails at gnrc_ipv6.c:817 when pinging ::1 or one of the node's unicast link local addresses in the gnrc_networking application.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Considering that I chose -1 as NETIF_INVALID in #6413, I would actually prefer KERNEL_PID_LAST + 1 now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ping?


/**
* @brief The add/remove operation to set network layer protocol
* specific options for an interface.
Expand Down
13 changes: 13 additions & 0 deletions sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,19 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr)
gnrc_pktbuf_release(pkt);

DEBUG("ipv6: packet is addressed to myself => loopback\n");
ptr = gnrc_netif_hdr_build(NULL, 0, NULL, 0);

if (ptr == NULL) {
DEBUG("ipv6: error on interface header allocation, dropping packet\n");
gnrc_pktbuf_release(rcv_pkt);
return;
}

gnrc_netif_hdr_t *netif_hdr = (gnrc_netif_hdr_t*) ptr;
netif_hdr->if_pid = GNRC_NETIF_LOOPBACK_PID;

/* add netif to front of the pkt list */
rcv_pkt->next = ptr;

if (gnrc_netapi_receive(gnrc_ipv6_pid, rcv_pkt) < 1) {
DEBUG("ipv6: unable to deliver packet\n");
Expand Down