Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3030975rwb; Mon, 15 Aug 2022 16:30:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR6evZ67X8rQaBQM9kI15nMkrYtQaFYXbm/UObtM17OMSMpKkWMEFE2bjI+4jGqlWgu64lAl X-Received: by 2002:a17:907:94d2:b0:730:87c1:e86d with SMTP id dn18-20020a17090794d200b0073087c1e86dmr12235896ejc.37.1660606213485; Mon, 15 Aug 2022 16:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606213; cv=none; d=google.com; s=arc-20160816; b=04gcXrNVgDbQTDXLkA2/ry0Qif5UOrFbAuTeEE/uNyNM7txYgBXd9nbJ8YIXp0eGog qTvOFx0wst2VASdBvn8zpWs481BvevHcF/LCpC53UOMnue47n/OsM3QlCuwRkQwMNLf9 3J3yqcUxAZ0drSHWalnhrlV/9M/B/RZWTWEhpYfjn1I0Cc2VK29j+yh89HxZh8ET930B J2yYEeVq9W/7rf0RzRzK1k9A4Gn8r1wek1lSv8curGIehaP6Q4J9HGa2EWMAUF4Lm4T8 /dQaOW5sR/8WEyJQhO3zWeg9udGUpsRi9hSxztbwNDTRL/ESj4cjOZImYxbAiUUuu4gE NDUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m1MlGmd77BfgSWgqcA9CLq5ny4MwvumWUp28IWZyA7o=; b=QXvbaXu0elJgaFyi4Xn652VyCHXiQrp1/g5vNPbiouyBZFo0uEehHDVTOCzcSps/tR hcyRBa0YnB6izJUWBNAmdAbLJqoSK32vv+Qlk7b6/b12ji1zSEWV41ThJA3ZOxdEd23h BKay6rwSJ514shaOFWJH6J340ETiGoOPYEjisDF+N6AQEEHwP9FXq6UhfBwfgVRKD4IA nr4YcAh6fYUmqYA2cmXZyOvix7JfufQtqy8VmKTkp/VHNpLFMRCzZTIYyFS+nqK3RdYs a+5hfJ6a8o99sM596bF7WUb3mLwe2+HSnqMQEmiWuqCBDwlt5+SmMro35nwNvQSdr5ZZ NX7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r2h0W4tw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp5-20020a1709073e0500b0073182a31719si9886086ejc.37.2022.08.15.16.29.34; Mon, 15 Aug 2022 16:30:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r2h0W4tw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240321AbiHOXXY (ORCPT + 99 others); Mon, 15 Aug 2022 19:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241347AbiHOXRC (ORCPT ); Mon, 15 Aug 2022 19:17:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4C077CB58; Mon, 15 Aug 2022 13:03:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 23E1DB810C5; Mon, 15 Aug 2022 20:03:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DFEEC433D6; Mon, 15 Aug 2022 20:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593816; bh=u+YTZMnI+mHY8ePME3H/NiQfW4K6V1KRiwc+uCFjTLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2h0W4twkyg0RcPuzV6b7UGIyznxmqBq9PVOw54aDTeRQwJTZa8ZEgTKrF2mHa55j 762DJTGyL34B/c5grCZ62p48qPTa7b9KzlS2FOWnJPC/upSZrIttqded+mfcBvggNj k/Liu3TvvqGrK74gE2CxwAUENeC5kYVtQ5UTivQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.19 0330/1157] sample: bpf: xdp_router_ipv4: Allow the kernel to send arp requests Date: Mon, 15 Aug 2022 19:54:46 +0200 Message-Id: <20220815180452.870580758@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit 200a89e3e88786b52bc1dd5f26a310c097f4c6a7 ] Forward the packet to the kernel if the gw router mac address is missing in to trigger ARP discovery. Fixes: 85bf1f51691c ("samples: bpf: Convert xdp_router_ipv4 to XDP samples helper") Signed-off-by: Lorenzo Bianconi Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/60bde5496d108089080504f58199bcf1143ea938.1653471558.git.lorenzo@kernel.org Signed-off-by: Sasha Levin --- samples/bpf/xdp_router_ipv4.bpf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/samples/bpf/xdp_router_ipv4.bpf.c b/samples/bpf/xdp_router_ipv4.bpf.c index 248119ca7938..0643330d1d2e 100644 --- a/samples/bpf/xdp_router_ipv4.bpf.c +++ b/samples/bpf/xdp_router_ipv4.bpf.c @@ -150,6 +150,15 @@ int xdp_router_ipv4_prog(struct xdp_md *ctx) dest_mac = bpf_map_lookup_elem(&arp_table, &prefix_value->gw); + if (!dest_mac) { + /* Forward the packet to the kernel in + * order to trigger ARP discovery for + * the default gw. + */ + if (rec) + NO_TEAR_INC(rec->xdp_pass); + return XDP_PASS; + } } } -- 2.35.1