Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB88BC43381 for ; Tue, 5 Mar 2019 00:27:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA25C20830 for ; Tue, 5 Mar 2019 00:27:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ba5/AueO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbfCEA11 (ORCPT ); Mon, 4 Mar 2019 19:27:27 -0500 Received: from mail-ot1-f74.google.com ([209.85.210.74]:39927 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726106AbfCEA11 (ORCPT ); Mon, 4 Mar 2019 19:27:27 -0500 Received: by mail-ot1-f74.google.com with SMTP id j13so2720722otl.6 for ; Mon, 04 Mar 2019 16:27:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=BVyJfoUG25PnpGxAzZuBa7h/t4D6jKROOEVPal9R2qk=; b=ba5/AueO/s74elyzDC46I+ZGRMw6DtbIn8cnmmWX03LYjdSX0mWfR7MpeOCRI12QTZ 6SBhFjjkRs+0iHYClWr0G+CX5/IJr7e9sJqD+ZN7luk1BD5m4oo1O7FE2hKMHpoLEjLa 0T5FiQX1xXXHYPSGRAjVk1V7ZKy1kivDzLi8FvtGGnw9Zf2N1SChFiDceP5ZeUJhqCrM x8dX+pmih0cwgHTMm9TRYM7QhfL3MIkJGYwzeTuchVzA4uMo9y9UCDqh/W3xdSR2WHUf wlpePFv2UHX9S8OhTrO93AjU/0lv/ceYJ4k6HfPbuMiHawUZT030VnSwHtUK/6pbllgn nqog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BVyJfoUG25PnpGxAzZuBa7h/t4D6jKROOEVPal9R2qk=; b=NQWNADXYb/OKpDzdAnxFrv2xCVmzJv47fduQIyKzISTbiRylo24SwDkU0fqeFwR/VI A16d26G19TGFkmNMUIl0TIdiFu6ckX8W9THx7d5CCHuA0NbsZYxHzQKgZNYaHAf3MHf0 sx7bqnegv3hU98P3zfarA6Z0jNQ0dnEgh+yKoUJ/NZzskdfbbmn56TEqKRXlTHfuoyfw qv236iPk79tFjCRRWyuH4Dw8Nrgt4/XnPDkXQ4EA1gNLZr2sBY24BcpK6cpGHUdvlxGI nFEN9JDRln+R+7tSYTcziB5uBsdzm6z8V3sMHcP4UvdRCHCplq7A+uq/k+kpUCbthwi9 /BWw== X-Gm-Message-State: APjAAAUf8ee8NguQERI8129tsswRT3yjzXmwESIth3X1t31qq/2budp7 PmLxOKVEhgW01aQHqK4dpsJMX6i6 X-Google-Smtp-Source: APXvYqxsLnz6dPJWmiFl4r6tgkjGcvY6B8lJGIj/UmUAmHg3AckUu2b9cAzB6cgRJDsWgUWAaOAgaqNH X-Received: by 2002:a9d:6c02:: with SMTP id f2mr13080055otq.73.1551745646169; Mon, 04 Mar 2019 16:27:26 -0800 (PST) Date: Mon, 4 Mar 2019 16:27:09 -0800 In-Reply-To: <20190305002709.156137-1-posk@google.com> Message-Id: <20190305002709.156137-3-posk@google.com> Mime-Version: 1.0 References: <20190305002709.156137-1-posk@google.com> X-Mailer: git-send-email 2.21.0.352.gf09ad66450-goog Subject: [PATCH net-next (fix) 2/2] selftests/bpf: test that GSO works in lwt_ip_encap From: Peter Oskolkov To: David Miller , netdev@vger.kernel.org, Willem de Bruijn Cc: Peter Oskolkov , David Ahern , Peter Oskolkov Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a test on egress that a large TCP packet successfully goes through the lwt+bpf encap tunnel. Although there is no direct evidence that GSO worked, as opposed to e.g. TCP segmentation or IP fragmentation (maybe a kernel stats counter should be added to track the number of failed GSO attempts?), without the previous patch in the patchset this test fails, and printk-debugging showed that software-based GSO succeeded here (veth is not compatible with SKB_GSO_DODGY, so GSO happens in the software stack). Also removed an unnecessary nodad and added a missed failed flag. Signed-off-by: Peter Oskolkov --- .../selftests/bpf/test_lwt_ip_encap.sh | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/test_lwt_ip_encap.sh b/tools/testing/selftests/bpf/test_lwt_ip_encap.sh index 612632c1425f..d4d3391cc13a 100755 --- a/tools/testing/selftests/bpf/test_lwt_ip_encap.sh +++ b/tools/testing/selftests/bpf/test_lwt_ip_encap.sh @@ -78,6 +78,8 @@ TEST_STATUS=0 TESTS_SUCCEEDED=0 TESTS_FAILED=0 +TMPFILE="" + process_test_results() { if [[ "${TEST_STATUS}" -eq 0 ]] ; then @@ -147,7 +149,6 @@ setup() ip -netns ${NS2} -6 addr add ${IPv6_7}/128 nodad dev veth7 ip -netns ${NS3} -6 addr add ${IPv6_8}/128 nodad dev veth8 - ip -netns ${NS1} link set dev veth1 up ip -netns ${NS2} link set dev veth2 up ip -netns ${NS2} link set dev veth3 up @@ -205,7 +206,7 @@ setup() # configure IPv4 GRE device in NS3, and a route to it via the "bottom" route ip -netns ${NS3} tunnel add gre_dev mode gre remote ${IPv4_1} local ${IPv4_GRE} ttl 255 ip -netns ${NS3} link set gre_dev up - ip -netns ${NS3} addr add ${IPv4_GRE} nodad dev gre_dev + ip -netns ${NS3} addr add ${IPv4_GRE} dev gre_dev ip -netns ${NS1} route add ${IPv4_GRE}/32 dev veth5 via ${IPv4_6} ip -netns ${NS2} route add ${IPv4_GRE}/32 dev veth7 via ${IPv4_8} @@ -222,12 +223,18 @@ setup() ip netns exec ${NS2} sysctl -wq net.ipv4.conf.all.rp_filter=0 ip netns exec ${NS3} sysctl -wq net.ipv4.conf.all.rp_filter=0 + TMPFILE=$(mktemp /tmp/test_lwt_ip_encap.XXXXXX) + sleep 1 # reduce flakiness set +e } cleanup() { + if [ -f ${TMPFILE} ] ; then + rm ${TMPFILE} + fi + ip netns del ${NS1} 2> /dev/null ip netns del ${NS2} 2> /dev/null ip netns del ${NS3} 2> /dev/null @@ -278,6 +285,46 @@ test_ping() fi } +test_gso() +{ + local readonly PROTO=$1 + local readonly PKT_SZ=5000 + local IP_DST="" + : > ${TMPFILE} # trim the capture file + + # check that nc is present + command -v nc >/dev/null 2>&1 || \ + { echo >&2 "nc is not available: skipping TSO tests"; return; } + + # listen on IPv*_DST, capture TCP into $TMPFILE + if [ "${PROTO}" == "IPv4" ] ; then + IP_DST=${IPv4_DST} + ip netns exec ${NS3} bash -c \ + "nc -4 -l -s ${IPv4_DST} -p 9000 > ${TMPFILE} &" + elif [ "${PROTO}" == "IPv6" ] ; then + IP_DST=${IPv6_DST} + ip netns exec ${NS3} bash -c \ + "nc -6 -l -s ${IPv6_DST} -p 9000 > ${TMPFILE} &" + RET=$? + else + echo " test_gso: unknown PROTO: ${PROTO}" + TEST_STATUS=1 + fi + sleep 1 # let nc start listening + + # send a packet larger than MTU + ip netns exec ${NS1} bash -c \ + "dd if=/dev/zero bs=$PKT_SZ count=1 > /dev/tcp/${IP_DST}/9000 2>/dev/null" + sleep 2 # let the packet get delivered + + # verify we received all expected bytes + SZ=$(stat -c %s ${TMPFILE}) + if [ "$SZ" != "$PKT_SZ" ] ; then + echo " test_gso failed: ${PROTO}" + TEST_STATUS=1 + fi +} + test_egress() { local readonly ENCAP=$1 @@ -307,6 +354,8 @@ test_egress() fi test_ping IPv4 0 test_ping IPv6 0 + test_gso IPv4 + test_gso IPv6 # a negative test: remove routes to GRE devices: ping fails remove_routes_to_gredev @@ -350,6 +399,7 @@ test_ingress() ip -netns ${NS2} -6 route add ${IPv6_DST} encap bpf in obj test_lwt_ip_encap.o sec encap_gre6 dev veth2 else echo "FAIL: unknown encap ${ENCAP}" + TEST_STATUS=1 fi test_ping IPv4 0 test_ping IPv6 0 -- 2.21.0.352.gf09ad66450-goog