mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 18:05:00 -04:00
netconsole: move remote_mac from struct netpoll to netconsole_target
The destination ethernet address is netconsole configuration: no other netpoll user (bonding, team, vlan, bridge, macvlan, dsa) references np->remote_mac, only netconsole's ethernet framing and its configfs/cmdline interface do. Move it into struct netconsole_target and convert push_eth() to take the netconsole_target; netconsole_print_banner() and netconsole_parser_cmdline() already take it. The configfs show/store handlers and alloc_and_init() reach the field directly. No functional change; the remote_mac sysfs attribute is unchanged. Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20260710-netconsole_move_more-v3-9-6f63f76b28bc@debian.org Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
3b247a5956
commit
49e03ca583
@@ -178,9 +178,9 @@ enum target_state {
|
||||
* local_ip (read-write)
|
||||
* remote_ip (read-write)
|
||||
* local_mac (read-only)
|
||||
* remote_mac (read-write)
|
||||
* @local_port: Source UDP port of the target (read-write).
|
||||
* @remote_port: Destination UDP port of the target (read-write).
|
||||
* @remote_mac: Destination ethernet address of the target (read-write).
|
||||
* @buf: The buffer used to send the full msg to the network stack
|
||||
* @resume_wq: Workqueue to resume deactivated target
|
||||
* @skb_pool: Per-target fallback skb pool consulted by find_skb() when
|
||||
@@ -209,6 +209,7 @@ struct netconsole_target {
|
||||
bool release;
|
||||
struct netpoll np;
|
||||
u16 local_port, remote_port;
|
||||
u8 remote_mac[ETH_ALEN];
|
||||
/* protected by target_list_lock; +1 gives scnprintf() room for its
|
||||
* NUL terminator so a full MAX_PRINT_CHUNK payload is not truncated
|
||||
*/
|
||||
@@ -462,7 +463,7 @@ static struct netconsole_target *alloc_and_init(void)
|
||||
strscpy(nt->np.dev_name, "eth0", IFNAMSIZ);
|
||||
nt->local_port = 6665;
|
||||
nt->remote_port = 6666;
|
||||
eth_broadcast_addr(nt->np.remote_mac);
|
||||
eth_broadcast_addr(nt->remote_mac);
|
||||
nt->state = STATE_DISABLED;
|
||||
INIT_WORK(&nt->resume_wq, process_resume_target);
|
||||
/* Set up the skb pool primitives once; enabling only refills it. */
|
||||
@@ -516,7 +517,7 @@ static void netconsole_print_banner(struct netconsole_target *nt)
|
||||
np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6);
|
||||
else
|
||||
np_info(np, "remote IPv4 address %pI4\n", &np->remote_ip.ip);
|
||||
np_info(np, "remote ethernet address %pM\n", np->remote_mac);
|
||||
np_info(np, "remote ethernet address %pM\n", nt->remote_mac);
|
||||
}
|
||||
|
||||
/* Parse the string and populate the `inet_addr` union. Return 0 if IPv4 is
|
||||
@@ -672,7 +673,7 @@ static ssize_t local_mac_show(struct config_item *item, char *buf)
|
||||
|
||||
static ssize_t remote_mac_show(struct config_item *item, char *buf)
|
||||
{
|
||||
return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac);
|
||||
return sysfs_emit(buf, "%pM\n", to_target(item)->remote_mac);
|
||||
}
|
||||
|
||||
static ssize_t transmit_errors_show(struct config_item *item, char *buf)
|
||||
@@ -1077,7 +1078,7 @@ static ssize_t remote_mac_store(struct config_item *item, const char *buf,
|
||||
goto out_unlock;
|
||||
if (buf[MAC_ADDR_STR_LEN] && buf[MAC_ADDR_STR_LEN] != '\n')
|
||||
goto out_unlock;
|
||||
memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN);
|
||||
memcpy(nt->remote_mac, remote_mac, ETH_ALEN);
|
||||
|
||||
ret = count;
|
||||
out_unlock:
|
||||
@@ -1885,14 +1886,15 @@ static void push_udp(struct netconsole_target *nt, struct sk_buff *skb, int len)
|
||||
netpoll_udp_checksum(np, skb, len);
|
||||
}
|
||||
|
||||
static void push_eth(struct netpoll *np, struct sk_buff *skb)
|
||||
static void push_eth(struct netconsole_target *nt, struct sk_buff *skb)
|
||||
{
|
||||
struct netpoll *np = &nt->np;
|
||||
struct ethhdr *eth;
|
||||
|
||||
eth = skb_push(skb, ETH_HLEN);
|
||||
skb_reset_mac_header(skb);
|
||||
ether_addr_copy(eth->h_source, np->dev->dev_addr);
|
||||
ether_addr_copy(eth->h_dest, np->remote_mac);
|
||||
ether_addr_copy(eth->h_dest, nt->remote_mac);
|
||||
if (np->ipv6)
|
||||
eth->h_proto = htons(ETH_P_IPV6);
|
||||
else
|
||||
@@ -1980,7 +1982,7 @@ static int netpoll_send_udp(struct netconsole_target *nt, const char *msg,
|
||||
push_ipv6(np, skb, len);
|
||||
else
|
||||
push_ipv4(np, skb, len);
|
||||
push_eth(np, skb);
|
||||
push_eth(nt, skb);
|
||||
skb->dev = np->dev;
|
||||
|
||||
return (int)netpoll_send_skb(np, skb);
|
||||
@@ -2375,7 +2377,7 @@ static int netconsole_parser_cmdline(struct netconsole_target *nt, char *opt)
|
||||
|
||||
if (*cur != 0) {
|
||||
/* MAC address */
|
||||
if (!mac_pton(cur, np->remote_mac))
|
||||
if (!mac_pton(cur, nt->remote_mac))
|
||||
goto parse_failed;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ struct netpoll {
|
||||
|
||||
union inet_addr local_ip, remote_ip;
|
||||
bool ipv6;
|
||||
u8 remote_mac[ETH_ALEN];
|
||||
};
|
||||
|
||||
#define np_info(np, fmt, ...) \
|
||||
|
||||
Reference in New Issue
Block a user