diff mbox series

[net-next,2/4] net/sched: add helper to check if a notification is needed

Message ID 20231201204314.220543-3-pctammela@mojatatu.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net/sched: conditional notification of events for cls and act | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1170 this patch: 1170
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1143 this patch: 1143
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1224 this patch: 1224
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pedro Tammela Dec. 1, 2023, 8:43 p.m. UTC
From: Victor Nogueira <victor@mojatatu.com>

Building on the rtnl_has_listeners helper, add the tc_should_notify
helper to check if we can bail out early in the tc notification
routines.

Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
---
 include/net/pkt_cls.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jakub Kicinski Dec. 2, 2023, 7:18 p.m. UTC | #1
On Fri,  1 Dec 2023 17:43:12 -0300 Pedro Tammela wrote:
> +static inline bool tc_should_notify(const struct net *net, u16 nlflags)

nit: tc_notify_needed() ? doesn't matter

> +{
> +	return (nlflags & NLM_F_ECHO) || rtnl_has_listeners(net, RTNLGRP_TC);

I think it'd be nice to have an rtnl_* helper which looks at the flags
as well. With a proper kdoc. Maybe someone will notice that and remember
to implement F_ECHO for their command?
Pedro Tammela Dec. 4, 2023, 2:50 p.m. UTC | #2
On 02/12/2023 16:18, Jakub Kicinski wrote:
>> +{
>> +	return (nlflags & NLM_F_ECHO) || rtnl_has_listeners(net, RTNLGRP_TC);
> 
> I think it'd be nice to have an rtnl_* helper which looks at the flags
> as well. With a proper kdoc. Maybe someone will notice that and remember
> to implement F_ECHO for their command?

Ack, will change this to a generic rtnl helper
diff mbox series

Patch

diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index a76c9171db0e..39c24cf30984 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -1065,4 +1065,9 @@  static inline void tc_skb_ext_tc_disable(void) { }
 #define tc_skb_ext_tc_enabled() false
 #endif
 
+static inline bool tc_should_notify(const struct net *net, u16 nlflags)
+{
+	return (nlflags & NLM_F_ECHO) || rtnl_has_listeners(net, RTNLGRP_TC);
+}
+
 #endif