From patchwork Tue Mar 23 00:38:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 12156467 X-Patchwork-Delegate: bpf@iogearbox.net 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 75F03C433E0 for ; Tue, 23 Mar 2021 00:39:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A530619B1 for ; Tue, 23 Mar 2021 00:39:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbhCWAi7 (ORCPT ); Mon, 22 Mar 2021 20:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbhCWAid (ORCPT ); Mon, 22 Mar 2021 20:38:33 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 538DAC061574; Mon, 22 Mar 2021 17:38:33 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id a11so13824933qto.2; Mon, 22 Mar 2021 17:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cio+qgcDvmruwG8aqOjWedfunYy04m3r9xm+A6tj84M=; b=SoMmBYaYtkk1KN69z5WwbB8MT/noBpcPN1pTUi/j41fRbpaqzIsToALvOdUqEb//6h J9NtygfsEclltiHRx3jVHvYl78/qCzo1bZgdcJHqmYT4HdPhfJJFfP9d5BSLgRvhcBRJ rFLeTaPYmQPuvwr6qXHJQH5pz17lTq4j3kL8iHChOvXOby8te2cNyltZIjbCLgtj1ejI 59QrB8UdIylzL7jfNk8nvGEu9WF3JjNba62aEo/vCcvRyfoernXe5qdClMm1a8uRg7U3 19qIBi9/dIhYX70IHoqE2Frdv8emJ9CvoG0L3lekGFvRmSduOX4h1XOj+gyB7nTGFWvk mKfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cio+qgcDvmruwG8aqOjWedfunYy04m3r9xm+A6tj84M=; b=itzeqrQMU91q0I9iRT5EY1vCnS7w4+NzW4L1axTJR2wl/c1QYL/h66ilMWY5pRUxia rUOkmqL2IzfbB3aZqALRaVmyio7MO831HbzzYGhQh2Tw3FYjp6EAqGtG7Be1rPVchdpT LB52uL1mX0iBTA7NZ2Rpy75pUxdSc+2Rrlm4HKQNufptCALcY536UIWFtWrDTm6GmUem bq2g8rTGmIQfzXKgKrdVou08auF28YRBIUtCYV+CwzwYSj/RhnjvBwQPoi94KU6d2GM7 0HGv+js3HMbvfIQPXSmDwrdR9pnUrONRrsj1QYBLGRN9pCn0I8NdaflnB1i2zkc3jpST J0vQ== X-Gm-Message-State: AOAM530HT57DcAiPSpcXmZpPqH0Sqq+gmmT3rAZbBqc0KEFvLSIkN9PK 5cvQ3NqYpvrRzpHWvZVw6orUgrEGKx4ecA== X-Google-Smtp-Source: ABdhPJxW5WQ7Nkthq8IfYNQ0vV9grQMwn/HOus8Bkv+6anATYj3yI1SddCuuyYqME/78bmI9afI2jw== X-Received: by 2002:ac8:4809:: with SMTP id g9mr2298634qtq.295.1616459912454; Mon, 22 Mar 2021 17:38:32 -0700 (PDT) Received: from unknown.attlocal.net ([2600:1700:65a0:ab60:fda6:6522:f108:7bd8]) by smtp.gmail.com with ESMTPSA id 184sm12356403qki.97.2021.03.22.17.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 17:38:32 -0700 (PDT) From: Cong Wang To: netdev@vger.kernel.org Cc: bpf@vger.kernel.org, duanxiongchun@bytedance.com, wangdongdong.6@bytedance.com, jiang.wang@bytedance.com, Cong Wang , John Fastabend , Daniel Borkmann , Jakub Sitnicki , Lorenz Bauer Subject: [Patch bpf-next v6 11/12] sock_map: update sock type checks for UDP Date: Mon, 22 Mar 2021 17:38:07 -0700 Message-Id: <20210323003808.16074-12-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323003808.16074-1-xiyou.wangcong@gmail.com> References: <20210323003808.16074-1-xiyou.wangcong@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Cong Wang Now UDP supports sockmap and redirection, we can safely update the sock type checks for it accordingly. Cc: John Fastabend Cc: Daniel Borkmann Cc: Jakub Sitnicki Cc: Lorenz Bauer Signed-off-by: Cong Wang --- net/core/sock_map.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/core/sock_map.c b/net/core/sock_map.c index d04b98fc8104..9ed040c7d9e7 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -549,7 +549,10 @@ static bool sk_is_udp(const struct sock *sk) static bool sock_map_redirect_allowed(const struct sock *sk) { - return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN; + if (sk_is_tcp(sk)) + return sk->sk_state != TCP_LISTEN; + else + return sk->sk_state == TCP_ESTABLISHED; } static bool sock_map_sk_is_suitable(const struct sock *sk)