diff mbox series

[net-next] netlink: add nlmsg_consume() and use it in devlink compat

Message ID 20240403202259.1978707-1-kuba@kernel.org (mailing list archive)
State Accepted
Commit 8e69b3459ca1ed4f6f7bd0b0a11962ddb3e7d34a
Delegated to: Netdev Maintainers
Headers show
Series [net-next] netlink: add nlmsg_consume() and use it in devlink compat | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 3684 this patch: 3684
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1005 this patch: 1005
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: 3876 this patch: 3876
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 40 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 96 this patch: 96
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-06--12-00 (tests: 955)

Commit Message

Jakub Kicinski April 3, 2024, 8:22 p.m. UTC
devlink_compat_running_version() sticks out when running
netdevsim tests and watching dropped skbs. Add nlmsg_consume()
for cases were we want to free a netlink skb but it is expected,
rather than a drop. af_netlink code uses consume_skb() directly,
which is fine, but some may prefer the symmetry of nlmsg_new() /
nlmsg_consume().

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jiri@resnulli.us
---
 include/net/netlink.h | 14 ++++++++++++--
 net/devlink/dev.c     |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 6, 2024, 5:30 p.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed,  3 Apr 2024 13:22:59 -0700 you wrote:
> devlink_compat_running_version() sticks out when running
> netdevsim tests and watching dropped skbs. Add nlmsg_consume()
> for cases were we want to free a netlink skb but it is expected,
> rather than a drop. af_netlink code uses consume_skb() directly,
> which is fine, but some may prefer the symmetry of nlmsg_new() /
> nlmsg_consume().
> 
> [...]

Here is the summary with links:
  - [net-next] netlink: add nlmsg_consume() and use it in devlink compat
    https://git.kernel.org/netdev/net-next/c/8e69b3459ca1

You are awesome, thank you!
diff mbox series

Patch

diff --git a/include/net/netlink.h b/include/net/netlink.h
index 1d2bbcc50212..61cef3bd2d31 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -41,7 +41,8 @@ 
  *   nlmsg_get_pos()			return current position in message
  *   nlmsg_trim()			trim part of message
  *   nlmsg_cancel()			cancel message construction
- *   nlmsg_free()			free a netlink message
+ *   nlmsg_consume()			free a netlink message (expected)
+ *   nlmsg_free()			free a netlink message (drop)
  *
  * Message Sending:
  *   nlmsg_multicast()			multicast message to several groups
@@ -1082,7 +1083,7 @@  static inline void nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh)
 }
 
 /**
- * nlmsg_free - free a netlink message
+ * nlmsg_free - drop a netlink message
  * @skb: socket buffer of netlink message
  */
 static inline void nlmsg_free(struct sk_buff *skb)
@@ -1090,6 +1091,15 @@  static inline void nlmsg_free(struct sk_buff *skb)
 	kfree_skb(skb);
 }
 
+/**
+ * nlmsg_consume - free a netlink message
+ * @skb: socket buffer of netlink message
+ */
+static inline void nlmsg_consume(struct sk_buff *skb)
+{
+	consume_skb(skb);
+}
+
 /**
  * nlmsg_multicast_filtered - multicast a netlink message with filter function
  * @sk: netlink socket to spread messages to
diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index c609deb42e88..13c73f50da3d 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -1214,7 +1214,7 @@  static void __devlink_compat_running_version(struct devlink *devlink,
 		}
 	}
 free_msg:
-	nlmsg_free(msg);
+	nlmsg_consume(msg);
 }
 
 void devlink_compat_running_version(struct devlink *devlink,