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.
Unified · Split
| @@ -178,9 +178,9 @@ enum target_state { · 177 unmodified lines | |||
| 178 | * local_ip (read-write) | 178 | * local_ip (read-write) |
| 179 | * remote_ip (read-write) | 179 | * remote_ip (read-write) |
| 180 | * local_mac (read-only) | 180 | * local_mac (read-only) |
| 181 | * remote_mac (read-write) | ||
| 182 | * @local_port: Source UDP port of the target (read-write). | 181 | * @local_port: Source UDP port of the target (read-write). |
| 183 | * @remote_port: Destination UDP port of the target (read-write). | 182 | * @remote_port: Destination UDP port of the target (read-write). |
| 183 | * @remote_mac: Destination ethernet address of the target (read-write). | ||
| 184 | * @buf: The buffer used to send the full msg to the network stack | 184 | * @buf: The buffer used to send the full msg to the network stack |
| 185 | * @resume_wq: Workqueue to resume deactivated target | 185 | * @resume_wq: Workqueue to resume deactivated target |
| 186 | * @skb_pool: Per-target fallback skb pool consulted by find_skb() when | 186 | * @skb_pool: Per-target fallback skb pool consulted by find_skb() when |
| @@ -209,6 +209,7 @@ struct netconsole_target { · 22 unmodified lines | |||
| 209 | bool release; | 209 | bool release; |
| 210 | struct netpoll np; | 210 | struct netpoll np; |
| 211 | u16 local_port, remote_port; | 211 | u16 local_port, remote_port; |
| 212 | u8 remote_mac[ETH_ALEN]; | ||
| 212 | /* protected by target_list_lock; +1 gives scnprintf() room for its | 213 | /* protected by target_list_lock; +1 gives scnprintf() room for its |
| 213 | * NUL terminator so a full MAX_PRINT_CHUNK payload is not truncated | 214 | * NUL terminator so a full MAX_PRINT_CHUNK payload is not truncated |
| 214 | */ | 215 | */ |
| @@ -462,7 +463,7 @@ static struct netconsole_target *alloc_and_init(void) · 247 unmodified lines | |||
| 462 | strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); | 463 | strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); |
| 463 | nt->local_port = 6665; | 464 | nt->local_port = 6665; |
| 464 | nt->remote_port = 6666; | 465 | nt->remote_port = 6666; |
| 465 | eth_broadcast_addr(nt->np.remote_mac); | 466 | eth_broadcast_addr(nt->remote_mac); |
| 466 | nt->state = STATE_DISABLED; | 467 | nt->state = STATE_DISABLED; |
| 467 | INIT_WORK(&nt->resume_wq, process_resume_target); | 468 | INIT_WORK(&nt->resume_wq, process_resume_target); |
| 468 | /* Set up the skb pool primitives once; enabling only refills it. */ | 469 | /* Set up the skb pool primitives once; enabling only refills it. */ |
| @@ -516,7 +517,7 @@ static void netconsole_print_banner(struct netconsole_target *nt) · 47 unmodified lines | |||
| 516 | np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6); | 517 | np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6); |
| 517 | else | 518 | else |
| 518 | np_info(np, "remote IPv4 address %pI4\n", &np->remote_ip.ip); | 519 | np_info(np, "remote IPv4 address %pI4\n", &np->remote_ip.ip); |
| 519 | np_info(np, "remote ethernet address %pM\n", np->remote_mac); | 520 | np_info(np, "remote ethernet address %pM\n", nt->remote_mac); |
| 520 | } | 521 | } |
| 521 | 522 | ||
| 522 | /* Parse the string and populate the `inet_addr` union. Return 0 if IPv4 is | 523 | /* 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) · 149 unmodified lines | |||
| 672 | 673 | ||
| 673 | static ssize_t remote_mac_show(struct config_item *item, char *buf) | 674 | static ssize_t remote_mac_show(struct config_item *item, char *buf) |
| 674 | { | 675 | { |
| 675 | return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac); | 676 | return sysfs_emit(buf, "%pM\n", to_target(item)->remote_mac); |
| 676 | } | 677 | } |
| 677 | 678 | ||
| 678 | static ssize_t transmit_errors_show(struct config_item *item, char *buf) | 679 | 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, · 398 unmodified lines | |||
| 1077 | goto out_unlock; | 1078 | goto out_unlock; |
| 1078 | if (buf[MAC_ADDR_STR_LEN] && buf[MAC_ADDR_STR_LEN] != '\n') | 1079 | if (buf[MAC_ADDR_STR_LEN] && buf[MAC_ADDR_STR_LEN] != '\n') |
| 1079 | goto out_unlock; | 1080 | goto out_unlock; |
| 1080 | memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); | 1081 | memcpy(nt->remote_mac, remote_mac, ETH_ALEN); |
| 1081 | 1082 | ||
| 1082 | ret = count; | 1083 | ret = count; |
| 1083 | out_unlock: | 1084 | out_unlock: |
| @@ -1885,14 +1886,15 @@ static void push_udp(struct netconsole_target *nt, struct sk_buff *skb, int len) · 801 unmodified lines | |||
| 1885 | netpoll_udp_checksum(np, skb, len); | 1886 | netpoll_udp_checksum(np, skb, len); |
| 1886 | } | 1887 | } |
| 1887 | 1888 | ||
| 1888 | static void push_eth(struct netpoll *np, struct sk_buff *skb) | 1889 | static void push_eth(struct netconsole_target *nt, struct sk_buff *skb) |
| 1889 | { | 1890 | { |
| 1891 | struct netpoll *np = &nt->np; | ||
| 1890 | struct ethhdr *eth; | 1892 | struct ethhdr *eth; |
| 1891 | 1893 | ||
| 1892 | eth = skb_push(skb, ETH_HLEN); | 1894 | eth = skb_push(skb, ETH_HLEN); |
| 1893 | skb_reset_mac_header(skb); | 1895 | skb_reset_mac_header(skb); |
| 1894 | ether_addr_copy(eth->h_source, np->dev->dev_addr); | 1896 | ether_addr_copy(eth->h_source, np->dev->dev_addr); |
| 1895 | ether_addr_copy(eth->h_dest, np->remote_mac); | 1897 | ether_addr_copy(eth->h_dest, nt->remote_mac); |
| 1896 | if (np->ipv6) | 1898 | if (np->ipv6) |
| 1897 | eth->h_proto = htons(ETH_P_IPV6); | 1899 | eth->h_proto = htons(ETH_P_IPV6); |
| 1898 | else | 1900 | else |
| @@ -1980,7 +1982,7 @@ static int netpoll_send_udp(struct netconsole_target *nt, const char *msg, · 81 unmodified lines | |||
| 1980 | push_ipv6(np, skb, len); | 1982 | push_ipv6(np, skb, len); |
| 1981 | else | 1983 | else |
| 1982 | push_ipv4(np, skb, len); | 1984 | push_ipv4(np, skb, len); |
| 1983 | push_eth(np, skb); | 1985 | push_eth(nt, skb); |
| 1984 | skb->dev = np->dev; | 1986 | skb->dev = np->dev; |
| 1985 | 1987 | ||
| 1986 | return (int)netpoll_send_skb(np, skb); | 1988 | return (int)netpoll_send_skb(np, skb); |
| @@ -2375,7 +2377,7 @@ static int netconsole_parser_cmdline(struct netconsole_target *nt, char *opt) · 388 unmodified lines | |||
| 2375 | 2377 | ||
| 2376 | if (*cur != 0) { | 2378 | if (*cur != 0) { |
| 2377 | /* MAC address */ | 2379 | /* MAC address */ |
| 2378 | if (!mac_pton(cur, np->remote_mac)) | 2380 | if (!mac_pton(cur, nt->remote_mac)) |
| 2379 | goto parse_failed; | 2381 | goto parse_failed; |
| 2380 | } | 2382 | } |
| 2381 | 2383 | ||
| @@ -35,7 +35,6 @@ struct netpoll { · 34 unmodified lines | |||
| 35 | 35 | ||
| 36 | union inet_addr local_ip, remote_ip; | 36 | union inet_addr local_ip, remote_ip; |
| 37 | bool ipv6; | 37 | bool ipv6; |
| 38 | u8 remote_mac[ETH_ALEN]; | ||
| 39 | }; | 38 | }; |
| 40 | 39 | ||
| 41 | #define np_info(np, fmt, ...) \ | 40 | #define np_info(np, fmt, ...) \ |