[Devel] [PATCH RHEL10 COMMIT] ve/printk: Add ve_netdev_printk()	helpers
    Konstantin Khorenko 
    khorenko at virtuozzo.com
       
    Fri Oct 10 19:16:49 MSK 2025
    
    
  
The commit is pushed to "branch-rh10-6.12.0-55.13.1.2.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.2.10.vz10
------>
commit f9c25f87c61b06080c2f47161454dee37136f8d5
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Tue Oct 7 16:50:28 2025 +0800
    ve/printk: Add ve_netdev_printk() helpers
    
    We need this to print network device information into ve log.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-106826
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    
    Feature: printk: per-CT virtualization
---
 include/net/net_debug.h |  7 +++++++
 net/core/dev.c          | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)
diff --git a/include/net/net_debug.h b/include/net/net_debug.h
index 1e74684cbbdbc..2ba471ac5895b 100644
--- a/include/net/net_debug.h
+++ b/include/net/net_debug.h
@@ -25,6 +25,13 @@ void netdev_notice(const struct net_device *dev, const char *format, ...);
 __printf(2, 3) __cold
 void netdev_info(const struct net_device *dev, const char *format, ...);
 
+__printf(4, 5) __cold
+void ve_netdev_printk(const int dst, const char *level,
+		      const struct net_device *dev, const char *format, ...);
+__printf(3, 4) __cold
+void ve_netdev_info(const int dst, const struct net_device *dev,
+		    const char *format, ...);
+
 #define netdev_level_once(level, dev, fmt, ...)			\
 do {								\
 	static bool __section(".data.once") __print_once;	\
diff --git a/net/core/dev.c b/net/core/dev.c
index 6c7c55c9b7caf..2adeff25fb9a6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11922,6 +11922,62 @@ define_netdev_printk_level(netdev_warn, KERN_WARNING);
 define_netdev_printk_level(netdev_notice, KERN_NOTICE);
 define_netdev_printk_level(netdev_info, KERN_INFO);
 
+static void __ve_netdev_printk(int dst, const char *level,
+			       const struct net_device *dev,
+			       struct va_format *vaf)
+{
+	if (dev && dev->dev.parent) {
+		ve_dev_printk_emit(dst, level[1] - '0',
+				   dev->dev.parent,
+				   "%s %s %s%s: %pV",
+				   dev_driver_string(dev->dev.parent),
+				   dev_name(dev->dev.parent),
+				   netdev_name(dev), netdev_reg_state(dev),
+				   vaf);
+	} else if (dev) {
+		ve_printk(dst, "%s%s%s: %pV",
+			  level, netdev_name(dev), netdev_reg_state(dev), vaf);
+	} else {
+		ve_printk(dst, "%s(NULL net_device): %pV", level, vaf);
+	}
+}
+
+void ve_netdev_printk(int dst, const char *level, const struct net_device *dev,
+		      const char *format, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, format);
+
+	vaf.fmt = format;
+	vaf.va = &args;
+
+	__ve_netdev_printk(dst, level, dev, &vaf);
+
+	va_end(args);
+}
+EXPORT_SYMBOL(ve_netdev_printk);
+
+#define define_ve_netdev_printk_level(func, level)			\
+void func(int dst, const struct net_device *dev, const char *fmt, ...)	\
+{									\
+	struct va_format vaf;						\
+	va_list args;							\
+									\
+	va_start(args, fmt);						\
+									\
+	vaf.fmt = fmt;							\
+	vaf.va = &args;							\
+									\
+	__ve_netdev_printk(dst, level, dev, &vaf);			\
+									\
+	va_end(args);							\
+}									\
+EXPORT_SYMBOL(func);
+
+define_ve_netdev_printk_level(ve_netdev_info, KERN_INFO);
+
 static void __net_exit netdev_exit(struct net *net)
 {
 	kfree(net->dev_name_head);
    
    
More information about the Devel
mailing list