From patchwork Fri Apr 9 18:06:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 418652 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.8 required=3.0 tests=BAYES_00, 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 EFB49C433B4 for ; Fri, 9 Apr 2021 18:06:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6D646115C for ; Fri, 9 Apr 2021 18:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234427AbhDISGi (ORCPT ); Fri, 9 Apr 2021 14:06:38 -0400 Received: from mail-ed1-f50.google.com ([209.85.208.50]:40956 "EHLO mail-ed1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233332AbhDISGh (ORCPT ); Fri, 9 Apr 2021 14:06:37 -0400 Received: by mail-ed1-f50.google.com with SMTP id w23so7565257edx.7; Fri, 09 Apr 2021 11:06:23 -0700 (PDT) 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=HY433txR2TPxtfhAmq6V4OY/PH9A7hXTvBzJvxSGgpo=; b=ue/P7d95FaSn8T6Si7V3Av7Gj+pCN5FoDIUNXcp7UctA1Sp1mNNoX9gYad+o2ePCo0 hQN+SN8EPAXm9mPfoR6e+bNglehCIXHZvXmN+R+JwZgFyxZqO7RX2mZrrRdVatCQh69R Pq8aSjPZUblQqw0QL5f+7zrfLiMOufvc6BqIAAP2ONY4MgHHEm15v1GjWLYVfmSPIlwx RzsG3FDIvFkgVUdVBE0ujBVwyZshXzcqr6TPBgyMOFRoCyBeq980bV9Z3uAlsmKrDCcD J+nBsvpsD3WULp55OcyJwyazvWDqYl0GoxFBB6FqjRMZEQymVHQI/x7ipDFlFM5x71j+ dDtw== X-Gm-Message-State: AOAM533f/8dIipzQA0NfqkJ1DKk5LdwRO4ZX/j2/VP7Ka5AI2RWgmbHk M68XUiDLQ3+iXD1URtudaH9p4cWKIAk= X-Google-Smtp-Source: ABdhPJzU4XeBiIcjIs2Hwgf+96KOFrMiJI/+rgHKP0RCyXVVu3JT8Q2fM4K9UF49RQzylEe0IHzFOw== X-Received: by 2002:a50:e887:: with SMTP id f7mr18211092edn.107.1617991582918; Fri, 09 Apr 2021 11:06:22 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-93-66-21-119.cust.vodafonedsl.it. [93.66.21.119]) by smtp.gmail.com with ESMTPSA id k26sm1571383ejc.23.2021.04.09.11.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Apr 2021 11:06:22 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Julia Lawall Subject: [PATCH net-next 1/3] skbuff: add helper to walk over the fraglist Date: Fri, 9 Apr 2021 20:06:03 +0200 Message-Id: <20210409180605.78599-2-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210409180605.78599-1-mcroce@linux.microsoft.com> References: <20210409180605.78599-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Matteo Croce Add an skb_for_each_frag() macro to iterate on SKB fragments. Signed-off-by: Matteo Croce --- include/linux/skbuff.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index dbf820a50a39..a8d4ccacdda5 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1528,6 +1528,10 @@ static inline void skb_mark_not_on_list(struct sk_buff *skb) for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \ (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL) +/* Iterate through skb fragments. */ +#define skb_for_each_frag(skb, __i) \ + for (__i = 0; __i < skb_shinfo(skb)->nr_frags; __i++) + static inline void skb_list_del_init(struct sk_buff *skb) { __list_del_entry(&skb->list);