From: Keiichi KII <k-keiichi@bx.jp.nec.com>
To: Matt Mackall <mpm@selenic.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Miller <davem@davemloft.net>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [RFC][PATCH -mm take5 5/7] switch function of netpoll
Date: Wed, 13 Jun 2007 19:30:02 +0900 [thread overview]
Message-ID: <466FC72A.3090508@bx.jp.nec.com> (raw)
In-Reply-To: <466FC455.5060001@bx.jp.nec.com>
From: Keiichi KII <k-keiichi@bx.jp.nec.com>
This patch contains switch function of netpoll.
If "enabled" attribute of certain port is '1', this port is used
and the configurations of this port are unable to change.
If "enabled" attribute of certain port is '0', this port isn't used
and the configurations of this port are able to change.
-+- /sys/class/misc/
|-+- netconsole/
|-+- port1/
| |--- id [r--r--r--] id
| |--- enabled [rw-r--r--] 0: disable 1: enable, writable
| ...
|--- port2/
...
Signed-off-by: Keiichi KII <k-keiichi@bx.jp.nec.com>
Signed-off-by: Takayoshi Kochi <t-kochi@bq.jp.nec.com>
---
Index: mm/drivers/net/netconsole.c
===================================================================
--- mm.orig/drivers/net/netconsole.c
+++ mm/drivers/net/netconsole.c
@@ -71,6 +71,7 @@ struct netconsole_target {
struct list_head list;
struct kobject obj;
int id;
+ int enabled;
struct netpoll np;
};
@@ -121,9 +122,16 @@ static ssize_t show_remote_mac(struct ne
nt->np.remote_mac[4], nt->np.remote_mac[5]);
}
+static ssize_t show_enabled(struct netconsole_target *nt, char *buf)
+{
+ return sprintf(buf, "%d\n", nt->enabled);
+}
+
static ssize_t store_local_port(struct netconsole_target *nt, const char *buf,
size_t count)
{
+ if (nt->enabled)
+ return -EINVAL;
nt->np.local_port = simple_strtol(buf, NULL, 10);
return count;
@@ -132,6 +140,8 @@ static ssize_t store_local_port(struct n
static ssize_t store_remote_port(struct netconsole_target *nt, const char *buf,
size_t count)
{
+ if (nt->enabled)
+ return -EINVAL;
nt->np.remote_port = simple_strtol(buf, NULL, 10);
return count;
@@ -140,6 +150,8 @@ static ssize_t store_remote_port(struct
static ssize_t store_local_ip(struct netconsole_target *nt, const char *buf,
size_t count)
{
+ if (nt->enabled)
+ return -EINVAL;
nt->np.local_ip = ntohl(in_aton(buf));
return count;
@@ -148,6 +160,8 @@ static ssize_t store_local_ip(struct net
static ssize_t store_remote_ip(struct netconsole_target *nt, const char *buf,
size_t count)
{
+ if (nt->enabled)
+ return -EINVAL;
nt->np.remote_ip = ntohl(in_aton(buf));
return count;
@@ -166,13 +180,34 @@ static ssize_t store_remote_mac(struct n
cur++;
input_mac[i++] = simple_strtol(cur, NULL, 16);
}
- if (i != ETH_ALEN)
+ if (i != ETH_ALEN || nt->enabled)
return -EINVAL;
memcpy(nt->np.remote_mac, input_mac, ETH_ALEN);
return count;
}
+static ssize_t store_enabled(struct netconsole_target *nt, const char *buf,
+ size_t count)
+{
+ int enabled = 0;
+
+ if (count >= 2 && (count != 2 || buf[count - 1] != '\n')) {
+ printk(KERN_ERR "netconsole: invalid argument: %s\n", buf);
+ return -EINVAL;
+ } else if (buf[0] == '1')
+ enabled = 1;
+ else if (buf[0] == '0')
+ enabled = 0;
+ else {
+ printk(KERN_ERR "netconsole: invalid argument: %s\n", buf);
+ return -EINVAL;
+ }
+ nt->enabled = enabled;
+
+ return count;
+}
+
struct target_attr {
struct attribute attr;
ssize_t (*show)(struct netconsole_target*, char*);
@@ -196,6 +231,8 @@ static NETCON_CLASS_ATTR(remote_ip, S_IR
static NETCON_CLASS_ATTR(local_mac, S_IRUGO, show_local_mac, NULL);
static NETCON_CLASS_ATTR(remote_mac, S_IRUGO | S_IWUSR,
show_remote_mac, store_remote_mac);
+static NETCON_CLASS_ATTR(enabled, S_IRUGO | S_IWUSR,
+ show_enabled, store_enabled);
static struct attribute *target_attrs[] = {
&target_attr_id.attr,
@@ -205,6 +242,7 @@ static struct attribute *target_attrs[]
&target_attr_remote_ip.attr,
&target_attr_local_mac.attr,
&target_attr_remote_mac.attr,
+ &target_attr_enabled.attr,
NULL
};
@@ -336,6 +374,7 @@ static int add_target(char* target_confi
}
new_target->id = atomic_inc_return(&target_count);
+ new_target->enabled = 1;
printk(KERN_INFO "netconsole: add target: "
"remote ip_addr=%d.%d.%d.%d remote port=%d\n",
@@ -420,7 +459,8 @@ static void write_msg(struct console *co
for (left = len; left; ) {
frag = min(left, MAX_PRINT_CHUNK);
list_for_each_entry(target, &target_list, list)
- netpoll_send_udp(&target->np, msg, frag);
+ if (target->enabled)
+ netpoll_send_udp(&target->np, msg, frag);
msg += frag;
left -= frag;
}
--
next prev parent reply other threads:[~2007-06-13 10:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-13 10:17 [RFC][PATCH -mm take5 0/7] proposal for dynamic configurable netconsole Keiichi KII
2007-06-13 10:25 ` [RFC][PATCH -mm take5 1/7] marking __init Keiichi KII
2007-06-13 14:34 ` Matt Mackall
2007-06-13 10:27 ` [RFC][PATCH -mm take5 2/7] support multiple logging Keiichi KII
2007-06-13 15:30 ` Satyam Sharma
2007-06-13 10:28 ` [RFC][PATCH -mm take5 3/7] add interface for netconsole using sysfs Keiichi KII
2007-06-13 15:49 ` Satyam Sharma
2007-06-19 10:03 ` Keiichi KII
2007-06-13 10:29 ` [RFC][PATCH -mm take5 4/7] using symlink for the net_device Keiichi KII
2007-06-13 16:49 ` Satyam Sharma
2007-06-13 19:03 ` Satyam Sharma
2007-06-19 10:04 ` Keiichi KII
2007-06-19 14:40 ` Satyam Sharma
2007-06-21 9:24 ` Keiichi KII
2007-06-19 10:03 ` Keiichi KII
2007-06-19 14:21 ` Satyam Sharma
2007-06-13 10:30 ` Keiichi KII [this message]
2007-06-13 17:04 ` [RFC][PATCH -mm take5 5/7] switch function of netpoll Satyam Sharma
2007-06-13 10:31 ` [RFC][PATCH -mm take5 6/7] add ioctls for adding/removing target Keiichi KII
2007-06-13 20:41 ` Satyam Sharma
2007-06-19 10:04 ` Keiichi KII
2007-06-19 15:09 ` Satyam Sharma
2007-06-21 9:24 ` Keiichi KII
2007-06-21 10:09 ` Satyam Sharma
2007-06-13 10:31 ` [RFC][PATCH -mm take5 7/7] update documentation Keiichi KII
2007-06-13 17:17 ` Satyam Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=466FC72A.3090508@bx.jp.nec.com \
--to=k-keiichi@bx.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).