From patchwork Mon Aug 5 12:06:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 11076661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 608D215AC for ; Mon, 5 Aug 2019 12:08:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D2FA205A9 for ; Mon, 5 Aug 2019 12:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 419942835B; Mon, 5 Aug 2019 12:08:07 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 E3720205A9 for ; Mon, 5 Aug 2019 12:08:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728571AbfHEMIG (ORCPT ); Mon, 5 Aug 2019 08:08:06 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:18502 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727259AbfHEMIG (ORCPT ); Mon, 5 Aug 2019 08:08:06 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 58551A018D; Mon, 5 Aug 2019 14:08:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id zqkdr_-kpU67; Mon, 5 Aug 2019 14:07:57 +0200 (CEST) From: Hauke Mehrtens To: backports@vger.kernel.org Cc: johannes@sipsolutions.net, Hauke Mehrtens Subject: [PATCH 07/12] backport: Add genl_callback_extack() function Date: Mon, 5 Aug 2019 14:06:59 +0200 Message-Id: <20190805120704.13128-8-hauke@hauke-m.de> In-Reply-To: <20190805120704.13128-1-hauke@hauke-m.de> References: <20190805120704.13128-1-hauke@hauke-m.de> MIME-Version: 1.0 Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The struct netlink_callback got a new extack attribute in commit 4a19edb60d02 ("netlink: Pass extack to dump handlers") in kernel 4.20. Use a function instead of directly accessing it to return NULL on older kernel versions, the code should handle NULL. Signed-off-by: Hauke Mehrtens --- backport/backport-include/net/genetlink.h | 10 ++++++++++ patches/0078-genl-extack.cocci | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/backport/backport-include/net/genetlink.h b/backport/backport-include/net/genetlink.h index 772f10f0..747b6dac 100644 --- a/backport/backport-include/net/genetlink.h +++ b/backport/backport-include/net/genetlink.h @@ -34,6 +34,16 @@ static inline struct netlink_ext_ack *genl_info_extack(struct genl_info *info) #endif } +/* this is for patches we apply */ +static inline struct netlink_ext_ack *genl_callback_extack(struct netlink_callback *cb) +{ +#if LINUX_VERSION_IS_GEQ(4,20,0) + return cb->extack; +#else + return NULL; +#endif +} + /* this gets put in place of info->userhdr, since we use that above */ static inline void *genl_info_userhdr(struct genl_info *info) { diff --git a/patches/0078-genl-extack.cocci b/patches/0078-genl-extack.cocci index 5560e09d..860d68b4 100644 --- a/patches/0078-genl-extack.cocci +++ b/patches/0078-genl-extack.cocci @@ -9,3 +9,9 @@ struct genl_info *info; @@ -info->userhdr +genl_info_userhdr(info) + +@@ +struct netlink_callback *cb; +@@ +-cb->extack ++genl_callback_extack(cb)