From patchwork Mon Dec 4 20:39:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Tammela X-Patchwork-Id: 13479083 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="ypw5OdG3" Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF456D72 for ; Mon, 4 Dec 2023 12:39:47 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cfabcbda7bso24123275ad.0 for ; Mon, 04 Dec 2023 12:39:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1701722387; x=1702327187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6381YJ0fxKfyYq1VUroGWEYeqoymWgXS4fp6IpGoYHE=; b=ypw5OdG3wVlQJ/B+BoULfdCr12/U/u4eBnK5Ldm/+62j9241JIv91GcfMuS10zSgM6 56rm6eHfmODWh4+GXkSxEI3tPFiges4HJkbrfDjUnq0VSQut/OCc4sH1wbBcpcpF0qx/ UpHAMrg/zYIwex7emyi+ti5kOt4a0/jddM4PCFxdPya/VrIRX5hQBNv+0UwKiaLYUjIW aLFEjoR97I9kgtd6aMK1uisvNnQ4oH+nVQyyU7urZDP7AU/nP+FWUmh6q90VerxutEgj QuJjhgm5m8ZsozmXUOpl/TyrYvthBk6lFwjPR/BKn2fmAQS4s4pXTuU1rGfKpBkCXTsZ BVtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701722387; x=1702327187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6381YJ0fxKfyYq1VUroGWEYeqoymWgXS4fp6IpGoYHE=; b=Z6x642g13ercw0MWsczoyQodQZWHa4yYIvBZOeWOLSr/wY4PSkMTJqiU9D+h0+tlOZ cMCn9kcJ2GoOm7NMlnijDGnFWmRK7UJ24DsEKfpbuCTx0zd/mpLAcL1Q+hhtIdlaHy/4 7pOz8hzGgW3fLzQMXQO+o6b5sPNZm1cS1e0Nzgr8gSe0Q/THcOJZF3+JX7Q0wL8qr30M CV10aOFRi3Qt7EecYH5AGc45lfQBvvmhox+K6wqrCjTFXHIOuAV1SF3JjlVnfJLz4d/m F3iIZ0tnDCK904cYO6LKp+vKZFAyw0gJqAKmqFdOiHh5aTF6m2AM5xkyLa3x1x+wmt8h bOVw== X-Gm-Message-State: AOJu0YzFZRvCH4YOP4Jm7ONSw+o8+C/HPtHxsi6VLhazifXpgXUtAYbd RwpHD1nPXmNWKQPtoMTX8/pp1d+GAAO70x/izJM= X-Google-Smtp-Source: AGHT+IF5yhZcfdAjBNlqbtn76TzLizUPC0kmMNUGLLUpBRRTMwzjLLoGJyPqhP6GTC8Zp1SflGFSSw== X-Received: by 2002:a17:902:c283:b0:1cf:b413:8baa with SMTP id i3-20020a170902c28300b001cfb4138baamr380889pld.25.1701722387120; Mon, 04 Dec 2023 12:39:47 -0800 (PST) Received: from rogue-one.tail33bf8.ts.net ([201.17.86.134]) by smtp.gmail.com with ESMTPSA id f7-20020a170902ce8700b001cf83962743sm2669584plg.250.2023.12.04.12.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:39:46 -0800 (PST) From: Pedro Tammela To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, marcelo.leitner@gmail.com, vladbu@nvidia.com, Pedro Tammela Subject: [PATCH net-next v2 3/5] rtnl: add helper to send if skb is not null Date: Mon, 4 Dec 2023 17:39:05 -0300 Message-Id: <20231204203907.413435-4-pctammela@mojatatu.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204203907.413435-1-pctammela@mojatatu.com> References: <20231204203907.413435-1-pctammela@mojatatu.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This is a convenience helper for routines handling conditional rtnl events, that is code that might send a notification depending on rtnl_has_listeners/rtnl_notify_needed. Instead of: if (skb) rtnetlink_send(...) Use: rtnetlink_maybe_send(...) Signed-off-by: Pedro Tammela Reviewed-by: Jiri Pirko --- include/linux/rtnetlink.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 0cbbbded0331..6a8543b34e2c 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -10,6 +10,13 @@ #include extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); + +static inline int rtnetlink_maybe_send(struct sk_buff *skb, struct net *net, + u32 pid, u32 group, int echo) +{ + return !skb ? 0 : rtnetlink_send(skb, net, pid, group, echo); +} + extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid); extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, const struct nlmsghdr *nlh, gfp_t flags);