mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexey Dobriyan" <adobriyan@gmail.com>
To: "Keiichi KII" <k-keiichi@bx.jp.nec.com>
Cc: mpm@selenic.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [RFC][PATCH -mm take3 6/6][resend] add ioctls for adding/removing target
Date: Tue, 20 Mar 2007 14:50:07 +0200	[thread overview]
Message-ID: <b6fcc0a0703200550p441bb01fkfebb4102ef8e57d@mail.gmail.com> (raw)
In-Reply-To: <45FFD4C1.7000103@bx.jp.nec.com>

On 3/20/07, Keiichi KII <k-keiichi@bx.jp.nec.com> wrote:
> We add ioctls for adding/removing target.
> If we use NETCONSOLE_ADD_TARGET ioctl,
> we can dynamically add netconsole target.
> If we use NETCONSOLE_REMOVE_TARGET ioctl,
> we can dynamically remoe netconsole target.
>
> We attach a sample program for ioctl.

> +static int netconsole_ioctl(struct inode *inode, struct file *file,
> +			    unsigned int cmd, unsigned long arg)
> +{
> +	int id, count;
> +	char config[256];
> +	char *cur;
> +	struct netconsole_request req;
> +	struct netconsole_target *nt, *tmp;
> +	void __user *argp = (void __user *)arg;
> +
> +	switch (cmd) {
> +	case NETCON_ADD_TARGET:
> +		printk(KERN_INFO "netconsole: cmd=NETCON_ADD_TARGET\n");
> +		if (copy_from_user(&req, argp, sizeof(req)))
> +			return -EFAULT;
> +		cur = config;
> +		count = sprintf(cur, "%d@", req.local_port);
> +		cur += count;
> +		if (req.local_ip)
> +			count = sprintf(cur, "%d.%d.%d.%d/",
> +					NIPQUAD(req.local_ip));
> +		else
> +			count = sprintf(cur, "/");
> +		cur += count;
> +		count = sprintf(cur, "%s,", req.netdev_name);
> +		cur += count;
> +		count = sprintf(cur, "%d@", req.remote_port);
> +		cur += count;
> +		count = sprintf(cur, "%d.%d.%d.%d/",
> +				NIPQUAD(req.remote_ip));
> +		cur += count;
> +		count = sprintf(cur, "%02x:%02x:%02x:%02x:%02x:%02x",
> +				req.remote_mac[0], req.remote_mac[1],
> +				req.remote_mac[2], req.remote_mac[3],
> +				req.remote_mac[4], req.remote_mac[5]);
> +		printk(KERN_INFO "count = %d config=[%s]\n", count, config);
> +		if (add_target(config))
> +			return -EINVAL;
> +		break;
> +	case NETCON_REMOVE_TARGET:
> +		printk(KERN_INFO "netconsole: cmd=NETCON_REMOVE_TARGET\n");
> +		if (copy_from_user(&id, argp, sizeof(int)))
> +			return -EFAULT;
> +		printk(KERN_INFO "netconsole: id=%d\n", id);
> +		list_for_each_entry_safe(nt, tmp, &target_list, list) {
> +			if (nt->id == id) {
> +				kobject_unregister(&nt->obj);
> +				break;
> +			}
> +		}
> +		break;
> +	default:
> +		return -ENOTTY;
> +	}
> +
> +	return 0;
> +}

If you go with misc device, then implement ->write method so you, say,
do

     echo "add [same format as with module parameter]" >/dev/netconsole

and avoid all that additional programs and ioctls.

  reply	other threads:[~2007-03-20 12:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-20 12:10 [RFC][PATCH -mm take3 0/6][resend] proposal for dynamic configurable netconsole Keiichi KII
2007-03-20 12:24 ` [RFC][PATCH -mm take3 1/6][resend] marking __init Keiichi KII
2007-03-20 15:36   ` Matt Mackall
2007-03-20 12:26 ` [RFC][PATCH -mm take3 2/6][resend] support multiple logging Keiichi KII
2007-03-20 12:34   ` Alexey Dobriyan
2007-03-22 10:03     ` Keiichi KII
2007-03-20 12:28 ` [RFC][PATCH -mm take3 3/6][resend] add interface for netconsole using sysfs Keiichi KII
2007-03-20 12:30 ` [RFC][PATCH -mm take3 4/6][resend] using symlink for the net_device Keiichi KII
2007-03-20 12:31 ` [RFC][PATCH -mm take3 5/6][resend] switch function of netpoll Keiichi KII
2007-03-20 12:34 ` [RFC][PATCH -mm take3 6/6][resend] add ioctls for adding/removing target Keiichi KII
2007-03-20 12:50   ` Alexey Dobriyan [this message]
2007-03-20 16:59     ` Stephen Hemminger
2007-03-22 10:05   ` Keiichi KII

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=b6fcc0a0703200550p441bb01fkfebb4102ef8e57d@mail.gmail.com \
    --to=adobriyan@gmail.com \
    --cc=k-keiichi@bx.jp.nec.com \
    --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

Powered by JetHome