Skip to content

Commit df180e3

Browse files
Satyam SharmaDavid S. Miller
authored andcommitted
[NET] netconsole: Introduce netconsole_target
Based upon initial work by Keiichi Kii <k-keiichi@bx.jp.nec.com>. Introduce a wrapper structure over netpoll to represent logging targets configured in netconsole. This will get extended with other members in further patches. This is done independent of the (to-be-introduced) NETCONSOLE_DYNAMIC config option so that we're able to drastically cut down on the #ifdef complexity of final netconsole.c. Also, struct netconsole_target would be required for multiple targets support also, and not just dynamic reconfigurability. Signed-off-by: Satyam Sharma <satyam@infradead.org> Signed-off-by: Keiichi Kii <k-keiichi@bx.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8d4ef88 commit df180e3

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

‎drivers/net/netconsole.c‎

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,35 @@ static int __init option_setup(char *opt)
6262
__setup("netconsole=", option_setup);
6363
#endif /* MODULE */
6464

65-
static struct netpoll np = {
66-
.name = "netconsole",
67-
.dev_name = "eth0",
68-
.local_port = 6665,
69-
.remote_port = 6666,
70-
.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
65+
/**
66+
* struct netconsole_target - Represents a configured netconsole target.
67+
* @np: The netpoll structure for this target.
68+
*/
69+
struct netconsole_target {
70+
struct netpoll np;
71+
};
72+
73+
static struct netconsole_target default_target = {
74+
.np = {
75+
.name = "netconsole",
76+
.dev_name = "eth0",
77+
.local_port = 6665,
78+
.remote_port = 6666,
79+
.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
80+
},
7181
};
7282

7383
static void write_msg(struct console *con, const char *msg, unsigned int len)
7484
{
7585
int frag, left;
7686
unsigned long flags;
87+
struct netconsole_target *nt = &default_target;
7788

78-
if (netif_running(np.dev)) {
89+
if (netif_running(nt->np.dev)) {
7990
local_irq_save(flags);
8091
for (left = len; left;) {
8192
frag = min(left, MAX_PRINT_CHUNK);
82-
netpoll_send_udp(&np, msg, frag);
93+
netpoll_send_udp(&nt->np, msg, frag);
8394
msg += frag;
8495
left -= frag;
8596
}
@@ -96,17 +107,18 @@ static struct console netconsole = {
96107
static int __init init_netconsole(void)
97108
{
98109
int err = 0;
110+
struct netconsole_target *nt = &default_target;
99111

100112
if (!strnlen(config, MAX_PARAM_LENGTH)) {
101113
printk(KERN_INFO "netconsole: not configured, aborting\n");
102114
goto out;
103115
}
104116

105-
err = netpoll_parse_options(&np, config);
117+
err = netpoll_parse_options(&nt->np, config);
106118
if (err)
107119
goto out;
108120

109-
err = netpoll_setup(&np);
121+
err = netpoll_setup(&nt->np);
110122
if (err)
111123
goto out;
112124

@@ -119,8 +131,10 @@ static int __init init_netconsole(void)
119131

120132
static void __exit cleanup_netconsole(void)
121133
{
134+
struct netconsole_target *nt = &default_target;
135+
122136
unregister_console(&netconsole);
123-
netpoll_cleanup(&np);
137+
netpoll_cleanup(&nt->np);
124138
}
125139

126140
module_init(init_netconsole);

0 commit comments

Comments
 (0)