From patchwork Thu Apr 7 10:09:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 607333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qgdcx6pFYz9t5q for ; Thu, 7 Apr 2016 20:10:09 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3qgdcx4HlczDqDv for ; Thu, 7 Apr 2016 20:10:09 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3qgdcp2lXVzDq6b for ; Thu, 7 Apr 2016 20:10:02 +1000 (AEST) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98B057F359; Thu, 7 Apr 2016 10:10:00 +0000 (UTC) Received: from thh440s.fritz.box (vpn1-6-254.ams2.redhat.com [10.36.6.254]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u37A9tew024003; Thu, 7 Apr 2016 06:09:59 -0400 From: Thomas Huth To: slof@lists.ozlabs.org Date: Thu, 7 Apr 2016 12:09:54 +0200 Message-Id: <1460023795-27136-3-git-send-email-thuth@redhat.com> In-Reply-To: <1460023795-27136-1-git-send-email-thuth@redhat.com> References: <1460023795-27136-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Subject: [SLOF] [PATCH 2/3] ipv6: send_ipv6() has to return after doing NDP X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" The send_ipv6() function should return after doing NDP, since either the queued packet got send out during handle_na() already, or it has been stored to be sent out later (once the neighbor advertisment has been received). If we don't return here, the code runs into the final send_ether() here later, which then sends out the packet a second time. Signed-off-by: Thomas Huth Reviewed-by: Nikunj A Dadhania --- Note: The code flow is now similar to the arp handling in send_ipv4() clients/net-snk/app/netlib/icmpv6.c | 2 +- clients/net-snk/app/netlib/ipv6.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clients/net-snk/app/netlib/icmpv6.c b/clients/net-snk/app/netlib/icmpv6.c index c104f70..ad3f994 100644 --- a/clients/net-snk/app/netlib/icmpv6.c +++ b/clients/net-snk/app/netlib/icmpv6.c @@ -336,7 +336,7 @@ handle_na (int fd, uint8_t *packet) return 0; } else { memcpy (&(n->mac), &(headers.ethh->src_mac[0]), 6); - + n->status = NB_REACHABLE; if (n->eth_len > 0) { struct ethhdr * ethh = (struct ethhdr *) &(n->eth_frame); memcpy(ethh->dest_mac, &(n->mac), 6); diff --git a/clients/net-snk/app/netlib/ipv6.c b/clients/net-snk/app/netlib/ipv6.c index 5a307ca..00912ca 100644 --- a/clients/net-snk/app/netlib/ipv6.c +++ b/clients/net-snk/app/netlib/ipv6.c @@ -478,8 +478,10 @@ static unsigned short ip6_checksum(struct ip6hdr *ip6h, unsigned short *packet, * @param fd socket fd * @param ip6_packet Pointer to IPv6 header in packet * @param packetsize Size of IPv6 packet - * @return -1 == ERRROR - * return of handle_udp() or handle_icmp6() + * @return -1 : Some error occured + * 0 : packet stored (NDP request sent - packet will be sent if + * NDP response is received) + * >0 : packet sent (number of transmitted bytes is returned) * * @see receive_ether * @see ip6hdr @@ -562,7 +564,10 @@ int send_ipv6(int fd, void* buffer, int len) set_timer(TICKS_SEC); do { receive_ether(fd); + if (n->status == NB_REACHABLE) + return len; } while (get_timer() > 0); + return 0; } } }