From patchwork Mon Aug 21 22:27:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 9913881 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41F28603FF for ; Mon, 21 Aug 2017 22:28:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20BF1286AA for ; Mon, 21 Aug 2017 22:28:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1572C286C5; Mon, 21 Aug 2017 22:28:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92141286B8 for ; Mon, 21 Aug 2017 22:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753869AbdHUW2n (ORCPT ); Mon, 21 Aug 2017 18:28:43 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:48910 "EHLO mx1.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049AbdHUW2m (ORCPT ); Mon, 21 Aug 2017 18:28:42 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 1F5214251F; Tue, 22 Aug 2017 00:28:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id KVHsw8TcweXt; Tue, 22 Aug 2017 00:28:39 +0200 (CEST) From: Hauke Mehrtens To: johannes@sipsolutions.net Cc: backports@vger.kernel.org, Hauke Mehrtens Subject: [PATCH 03/21] header: skbuff: add skb_put_zero(), skb_put_data() and skb_put_u8() Date: Tue, 22 Aug 2017 00:27:59 +0200 Message-Id: <20170821222817.17376-4-hauke@hauke-m.de> In-Reply-To: <20170821222817.17376-1-hauke@hauke-m.de> References: <20170821222817.17376-1-hauke@hauke-m.de> Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These functions were added in kernel 4.13 and are used by many driver now. This was added in the following upsteram comits: e45a79da863c19 ("skbuff/mac80211: introduce and use skb_put_zero()") 59ae1d127ac0ae ("networking: introduce and use skb_put_data()") 634fef61076d64 ("networking: add and use skb_put_u8()") Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/skbuff.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/backport/backport-include/linux/skbuff.h b/backport/backport-include/linux/skbuff.h index dc957487..09894a96 100644 --- a/backport/backport-include/linux/skbuff.h +++ b/backport/backport-include/linux/skbuff.h @@ -315,4 +315,30 @@ __u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb) #endif +#if LINUX_VERSION_IS_LESS(4,13,0) +static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len) +{ + void *tmp = skb_put(skb, len); + + memset(tmp, 0, len); + + return tmp; +} + +static inline void *skb_put_data(struct sk_buff *skb, const void *data, + unsigned int len) +{ + void *tmp = skb_put(skb, len); + + memcpy(tmp, data, len); + + return tmp; +} + +static inline void skb_put_u8(struct sk_buff *skb, u8 val) +{ + *(u8 *)skb_put(skb, 1) = val; +} +#endif + #endif /* __BACKPORT_SKBUFF_H */