netconsole: allow selection of egress interface via MAC address
Subsystems (9)
v2 cover netconsole: allow selection of egress interface via MAC address
This series adds support for selecting a netconsole egress interface by specifying the MAC address (in place of the interface name) in the boot/module parameter.
Changes since v1 (https://lore.kernel.org/netdev/[email protected]/):
- Add a patch to define and use MAC_ADDR_LEN (Simon Horman)
- Remove ability to use MAC address to select egress interface via
configfs (Breno Leitao)
- Misc style fixes (Simon Horman, Breno Leitao)
---
Uday Shankar (2):
net, treewide: define and use MAC_ADDR_LEN
netconsole: allow selection of egress interface via MAC address
Documentation/networking/netconsole.rst | 6 +++- drivers/net/netconsole.c | 2 +- drivers/nvmem/brcm_nvram.c | 2 +- drivers/nvmem/layouts/u-boot-env.c | 2 +- include/linux/if_ether.h | 3 ++ include/linux/netpoll.h | 6 ++++ lib/net_utils.c | 4 +-- net/core/netpoll.c | 51 +++++++++++++++++++++++++-------- net/mac80211/debugfs_sta.c | 5 ++-- 9 files changed, 60 insertions(+), 21 deletions(-)
---
base-commit: c2933b2befe25309f4c5cfbea0ca80909735fd76
change-id: 20250204-netconsole-4c610e2f871c
Best regards,
Signature · 1 line
Uday Shankar <[email protected]>
PATCH v2 1/2 net, treewide: define and use MAC_ADDR_LEN
There are a few places in the tree which compute the length of the string representation of a MAC address as 3 * ETH_ALEN - 1. Define a constant for this and use it where relevant. No functionality changes are expected.
--- drivers/net/netconsole.c | 2 +- drivers/nvmem/brcm_nvram.c | 2 +- drivers/nvmem/layouts/u-boot-env.c | 2 +- include/linux/if_ether.h | 3 +++ lib/net_utils.c | 4 +--- net/mac80211/debugfs_sta.c | 5 +++-- 6 files changed, 10 insertions(+), 8 deletions(-)
drivers/net/netconsole.c +1 -1
@@ -675,7 +675,7 @@ static ssize_t remote_mac_store(struct config_item *item, const char *buf,if (!mac_pton (buf, remote_mac)) goto out_unlock; -if (buf[3 *ETH_ALEN -1 ] && buf[3 *ETH_ALEN -1 ] !='\n' ) +if (buf[MAC_ADDR_LEN ] && buf[MAC_ADDR_LEN ] !='\n' ) goto out_unlock;memcpy (nt->np.remote_mac, remote_mac,ETH_ALEN );
drivers/nvmem/brcm_nvram.c +1 -1
@@ -100,7 +100,7 @@ static int brcm_nvram_read_post_process_macaddr(void *context, const char *id, i {u8 mac[ETH_ALEN ]; -if (bytes !=3 *ETH_ALEN -1 ) +if (bytes !=MAC_ADDR_LEN )return -EINVAL ;if (!mac_pton (buf, mac))
drivers/nvmem/layouts/u-boot-env.c +1 -1
@@ -37,7 +37,7 @@ static int u_boot_env_read_post_process_ethaddr(void *context, const char *id, i {u8 mac[ETH_ALEN ]; -if (bytes !=3 *ETH_ALEN -1 ) +if (bytes !=MAC_ADDR_LEN )return -EINVAL ;if (!mac_pton (buf, mac))
include/linux/if_ether.h +3 -0
@@ -19,6 +19,9 @@#include <linux/skbuff.h> #include <uapi/linux/if_ether.h> +/* XX:XX:XX:XX:XX:XX */ +#define MAC_ADDR_LEN (3 * ETH_ALEN - 1) +static inline struct ethhdr *eth_hdr (const struct sk_buff *skb) {return (struct ethhdr *)skb_mac_header (skb);
lib/net_utils.c +1 -3
@@ -7,11 +7,9 @@bool mac_pton (const char *s,u8 *mac) { -size_t maxlen =3 *ETH_ALEN -1 ;int i; -/* XX:XX:XX:XX:XX:XX */ -if (strnlen (s, maxlen) < maxlen) +if (strnlen (s,MAC_ADDR_LEN ) <MAC_ADDR_LEN )return false;/* Don't dirty result unless string is valid MAC. */
net/mac80211/debugfs_sta.c +3 -2
@@ -457,11 +457,12 @@ static ssize_t link_sta_addr_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) { struct link_sta_info *link_sta = file->private_data; -u8 mac[3 *ETH_ALEN +1 ]; +u8 mac[MAC_ADDR_LEN +2 ];snprintf (mac,sizeof (mac),"%pM\n" , link_sta->pub->addr); -return simple_read_from_buffer (userbuf, count, ppos, mac,3 *ETH_ALEN ); +return simple_read_from_buffer (userbuf, count, ppos, mac, +MAC_ADDR_LEN +1 ); }LINK_STA_OPS (addr);
Signature · 1 line
2.34.1
Johannes Berg
maintainerRe: [PATCH v2 1/2] net, treewide: define and use MAC_ADDR_LEN
Quoted 4 lines · Uday Shankar
There are a few places in the tree which compute the length of the string representation of a MAC address as 3 *
ETH_ALEN- 1. Define a constant for this and use it where relevant. No functionality changes are expected.
True ... but is "MAC_ADDR_LEN" really an appropriate name for that? Just plain reading the subject, my first thought was why you weren't going to use ETH_ALEN.
Would seem nicer to me, at least, to have something indicating a *string* in there, e.g. MAC_ADDR_STR_LEN or so.
johannes
kernel test robot
build botRe: [PATCH v2 1/2] net, treewide: define and use MAC_ADDR_LEN
In reply to Uday Shankarkernel test robot noticed the following build warnings:
Hi Uday,
kernel test robot noticed the following build warnings:
[auto build test WARNING on c2933b2befe25309f4c5cfbea0ca80909735fd76]
url: https://github.com/intel-lab-lkp/linux/commits/Uday-Shankar/net-treewide-define-and-use-MAC_ADDR_LEN/20250205-054620 base: c2933b2befe25309f4c5cfbea0ca80909735fd76 patch link: https://lore.kernel.org/r/20250204-netconsole-v2-1-5ef5eb5f6056%40purestorage.com patch subject: [PATCH v2 1/2] net, treewide: define and use MAC_ADDR_LEN config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20250206/[email protected]/config) compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/scsi/qla4xxx/ql4_os.c:8:
In file included from include/linux/blkdev.h:9:
In file included from include/linux/blk_types.h:10:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/scsi/qla4xxx/ql4_os.c:15:
>> drivers/scsi/qla4xxx/ql4_def.h:148:9: warning: 'MAC_ADDR_LEN' macro redefined [-Wmacro-redefined]
148 | #define MAC_ADDR_LEN 6 /* in bytes */
| ^
include/linux/if_ether.h:23:9: note: previous definition is here
23 | #define MAC_ADDR_LEN (3 * ETH_ALEN - 1)
| ^ 4 warnings generated.
--
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c:4:
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8188ee/../wifi.h:11:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8188ee/dm.c:8:
>> drivers/net/wireless/realtek/rtlwifi/rtl8188ee/reg.h:1230:9: warning: 'MAC_ADDR_LEN' macro redefined [-Wmacro-redefined]
1230 | #define MAC_ADDR_LEN 6
| ^
include/linux/if_ether.h:23:9: note: previous definition is here
23 | #define MAC_ADDR_LEN (3 * ETH_ALEN - 1)
| ^ 4 warnings generated.
--
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c:4:
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8192ee/../wifi.h:11:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c:8:
>> drivers/net/wireless/realtek/rtlwifi/rtl8192ee/reg.h:1192:9: warning: 'MAC_ADDR_LEN' macro redefined [-Wmacro-redefined]
1192 | #define MAC_ADDR_LEN 6
| ^
include/linux/if_ether.h:23:9: note: previous definition is here
23 | #define MAC_ADDR_LEN (3 * ETH_ALEN - 1)
| ^ 4 warnings generated.
--
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c:4:
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8723ae/../wifi.h:11:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8723ae/dm.c:8:
>> drivers/net/wireless/realtek/rtlwifi/rtl8723ae/reg.h:1194:9: warning: 'MAC_ADDR_LEN' macro redefined [-Wmacro-redefined]
1194 | #define MAC_ADDR_LEN 6
| ^
include/linux/if_ether.h:23:9: note: previous definition is here
23 | #define MAC_ADDR_LEN (3 * ETH_ALEN - 1)
| ^ 4 warnings generated.
--
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c:4:
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8723be/../wifi.h:11:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c:8:
>> drivers/net/wireless/realtek/rtlwifi/rtl8723be/reg.h:1245:9: warning: 'MAC_ADDR_LEN' macro redefined [-Wmacro-redefined]
1245 | #define MAC_ADDR_LEN 6
| ^
include/linux/if_ether.h:23:9: note: previous definition is here
23 | #define MAC_ADDR_LEN (3 * ETH_ALEN - 1)
| ^ 4 warnings generated.
--
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:4:
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8821ae/../wifi.h:11:
In file included from include/linux/etherdevice.h:20:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/x86/include/asm/cacheflush.h:5:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c:8:
>> drivers/net/wireless/realtek/rtlwifi/rtl8821ae/reg.h:1274:9: warning: 'MAC_ADDR_LEN' macro redefined [-Wmacro-redefined]
1274 | #define MAC_ADDR_LEN 6
| ^
include/linux/if_ether.h:23:9: note: previous definition is here
23 | #define MAC_ADDR_LEN (3 * ETH_ALEN - 1)
| ^4 warnings generated.
vim +/MAC_ADDR_LEN +148 drivers/scsi/qla4xxx/ql4_def.h
afaf5a2d341d33 David Somayajulu 2006-09-19 144 afaf5a2d341d33 David Somayajulu 2006-09-19 145 /* afaf5a2d341d33 David Somayajulu 2006-09-19 146 * Misc afaf5a2d341d33 David Somayajulu 2006-09-19 147 */ afaf5a2d341d33 David Somayajulu 2006-09-19 @148 #define MAC_ADDR_LEN 6 /* in bytes */ afaf5a2d341d33 David Somayajulu 2006-09-19 149 #define IP_ADDR_LEN 4 /* in bytes */ 2a49a78ed3c8d7 Vikas Chaudhary 2010-04-28 150 #define IPv6_ADDR_LEN 16 /* IPv6 address size */ afaf5a2d341d33 David Somayajulu 2006-09-19 151 #define DRIVER_NAME "qla4xxx"
afaf5a2d341d33 David Somayajulu 2006-09-19 152
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 2/2 netconsole: allow selection of egress interface via MAC address
In reply to Uday ShankarCurrently, netconsole has two methods of configuration - module parameter and configfs. The former interface allows for netconsole activation earlier during boot (by specifying the module parameter on the kernel command line), so it is preferred for debugging issues which arise before userspace is up/the configfs interface can be used. The module parameter syntax requires specifying the egress interface name. This requirement makes it hard to use for a couple reasons:
- The egress interface name can be hard or impossible to predict. For example, installing a new network card in a system can change the interface names assigned by the kernel.
- When constructing the module parameter, one may have trouble determining the original (kernel-assigned) name of the interface (which is the name that should be given to netconsole) if some stable interface naming scheme is in effect. A human can usually look at kernel logs to determine the original name, but this is very painful if automation is constructing the parameter.
For these reasons, allow selection of the egress interface via MAC address when configuring netconsole using the module parameter. Update the netconsole documentation with an example of the new syntax. Selection of egress interface by MAC address via configfs is far less interesting (since when this interface can be used, one should be able to easily convert between MAC address and interface name), so it is left unimplemented.
--- Documentation/networking/netconsole.rst | 6 +++- include/linux/netpoll.h | 6 ++++ net/core/netpoll.c | 51 +++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 13 deletions(-)
Documentation/networking/netconsole.rst +5 -1
@@ -45,7 +45,7 @@ following format:: r if present, prepend kernel version (release) to the message src-port source for UDP packets (defaults to 6665) src-ip source IP to use (interface address) - dev network interface (eth0) + dev network interface name (eth0) or MAC address tgt-port port for logging agent (6666) tgt-ip IP address for logging agent tgt-macaddr ethernet MAC address for logging agent (broadcast)
@@ -62,6 +62,10 @@ or using IPv6:: insmod netconsole netconsole=@/,@fd00:1:2:3::1/ +or using a MAC address to select the egress interface:: + + linux [email protected]/22:33:44:55:66:77,[email protected]/12:34:56:78:9a:bc + It also supports logging to multiple remote agents by specifying parameters for the multiple agents separated by semicolons and the complete string enclosed in "quotes", thusly::
include/linux/netpoll.h +6 -0
@@ -25,7 +25,13 @@ union inet_addr {struct netpoll {struct net_device *dev;netdevice_tracker dev_tracker; +/* +* Either dev_name or dev_mac can be used to specify the local +* interface - dev_name is used if it is a nonempty string, else +* dev_mac is used. +*/ char dev_name[IFNAMSIZ ]; +u8 dev_mac[ETH_ALEN ];const char *name;union inet_addr local_ip, remote_ip;
net/core/netpoll.c +39 -12
111 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 25 lines · Uday Shankar
Currently, netconsole has two methods of configuration - module parameter and configfs. The former interface allows for netconsole activation earlier during boot (by specifying the module parameter on the kernel command line), so it is preferred for debugging issues which arise before userspace is up/the configfs interface can be used. The module parameter syntax requires specifying the egress interface name. This requirement makes it hard to use for a couple reasons:
- The egress interface name can be hard or impossible to predict. For example, installing a new network card in a system can change the interface names assigned by the kernel.
- When constructing the module parameter, one may have trouble determining the original (kernel-assigned) name of the interface (which is the name that should be given to netconsole) if some stable interface naming scheme is in effect. A human can usually look at kernel logs to determine the original name, but this is very painful if automation is constructing the parameter.For these reasons, allow selection of the egress interface via MAC address when configuring netconsole using the module parameter. Update the netconsole documentation with an example of the new syntax. Selection of egress interface by MAC address via configfs is far less interesting (since when this interface can be used, one should be able to easily convert between MAC address and interface name), so it is left unimplemented.
Quoted 1 line
Signed-off-by Uday Shankar <[email protected]>
Quoted 7 lines
int
netpoll_setup(struct netpoll *np)
{net/core/netpoll.c +2
-0+struct net *net = current->nsproxy->net_ns;struct net_device *ndev =NULL ;bool ip_overwritten = false; +char buf[MAC_ADDR_LEN +1 ];struct in_device *in_dev;
net/core/netpoll.c int __netpoll_setup(struct netpoll *np, struct net_device *ndev) · line 717
Quoted 10 lines
net/core/netpoll.c +3
-3int err;rtnl_lock (); -if (np->dev_name[0 ]) { -struct net *net = current->nsproxy->net_ns; +if (np->dev_name[0 ]) ndev =__dev_get_by_name (net, np->dev_name); - } +else if (is_valid_ether_addr (np->dev_mac)) + ndev =dev_getbyhwaddr_rcu (net,ARPHRD_ETHER , np->dev_mac);
You do not have the RCU read lock here. You have the rtnl(), which is sufficient, but, CONFIG_PROVE_RCU_LIST will show something as:
WARNING: suspicious RCU usage
6.13.0-09701-g6610c7be45bb-dirty #18 Not tainted
-----------------------------
net/core/dev.c:1143 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by swapper/0/1:
#0: ffffffff832795b8 (rtnl_mutex){+.+.}-{4:4}, at: netpoll_setup+0x48/0x540
stack backtrace:
CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-virtme-09701-g6610c7be45bb-dirty #18
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x9f/0xf0
lockdep_rcu_suspicious+0x11a/0x150
dev_getbyhwaddr_rcu+0xb6/0xc0
netpoll_setup+0x8a/0x540
? netpoll_parse_options+0x2bd/0x310This is not a problem per-se, since you have RTNL. We probably need to tell for_each_netdev_rcu() to not comply about "RCU-list traversed in non-reader section" if RTNL is held. Not sure why we didn't hit in the test infrastructure, tho:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
Anyway, no action item for you here. I am talking to Jakub on a way to solve it, and I should send a fix soon.
Thanks for the patch,
--breno
Quoted 25 lines · Breno Leitao
net/core/netpoll.c int __netpoll_setup(struct netpoll *np, struct net_device *ndev) · line 717
Quoted 2 lines
net/core/netpoll.c +2
-0+else if (is_valid_ether_addr (np->dev_mac)) + ndev =dev_getbyhwaddr_rcu (net,ARPHRD_ETHER , np->dev_mac);You do not have the RCU read lock here. You have the
rtnl(), which is sufficient, but,CONFIG_PROVE_RCU_LISTwill show something as:WARNING: suspicious RCU usage 6.13.0-09701-g6610c7be45bb-dirty #18 Not tainted ----------------------------- net/core/dev.c:1143 RCU-list traversed in non-reader section!! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 1 lock held by swapper/0/1: #0: ffffffff832795b8 (rtnl_mutex){+.+.}-{4:4}, at: netpoll_setup+0x48/0x540 stack backtrace: CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-virtme-09701-g6610c7be45bb-dirty #18 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x9f/0xf0 lockdep_rcu_suspicious+0x11a/0x150 dev_getbyhwaddr_rcu+0xb6/0xc0 netpoll_setup+0x8a/0x540 ? netpoll_parse_options+0x2bd/0x310
Quoted 6 lines
This is not a problem per-se, since you have RTNL. We probably need to tell
for_each_netdev_rcu()to not comply about "RCU-list traversed in non-reader section" if RTNL is held. Not sure why we didn't hit in the test infrastructure, tho:https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
I don't think there is an automated test that will hit this path yet. I guess you got this trace from your manual testing?
Quoted 3 lines
Anyway, no action item for you here. I am talking to Jakub on a way to solve it, and I should send a fix soon.
/**
* list_for_each_entry_rcu - iterate over rcu list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_head within the struct.
* @cond: optional lockdep expression if called from non-RCU protection.
*
* This list-traversal primitive may safely run concurrently with
* the _rcu list-mutation primitives such as list_add_rcu()
* as long as the traversal is guarded by rcu_read_lock(). */
#define list_for_each_entry_rcu(pos, head, member, cond...) \ for (__list_check_rcu(dummy, ## cond, 0), \ pos = list_entry_rcu((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
If we do something like
list_for_each_entry_rcu(..., lockdep_rtnl_is_held())
...
I think that code will be okay with being called with either rcu or rtnl held. Of course, we need to plumb it through the net-specific helpers.