From: "Maciej Żenczykowski" <zenczykowski@gmail.com>
To: "Maciej Żenczykowski" <maze@google.com>
Cc: netdev@vger.kernel.org, "Maciej Żenczykowski" <maze@google.com>
Subject: [PATCH] netconsole: implement ipv4 tos support
Date: Wed, 30 Nov 2011 17:18:50 -0800 [thread overview]
Message-ID: <1322702330-31325-1-git-send-email-zenczykowski@gmail.com> (raw)
From: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
Documentation/networking/netconsole.txt | 1 +
drivers/net/netconsole.c | 28 ++++++++++++++++++++++++++++
include/linux/netpoll.h | 1 +
net/core/netpoll.c | 4 +++-
4 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/Documentation/networking/netconsole.txt b/Documentation/networking/netconsole.txt
index 8d02207..a02374f 100644
--- a/Documentation/networking/netconsole.txt
+++ b/Documentation/networking/netconsole.txt
@@ -94,6 +94,7 @@ The interface exposes these parameters of a netconsole target to userspace:
remote_ip Remote agent's IP address (read-write)
local_mac Local interface's MAC address (read-only)
remote_mac Remote agent's MAC address (read-write)
+ tos TOS byte value to utilize (read-write)
The "enabled" attribute is also used to control whether the parameters of
a target can be updated or not -- you can modify the parameters of only
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e888202..d24d5df 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -90,6 +90,7 @@ static DEFINE_SPINLOCK(target_list_lock);
* remote_ip (read-write)
* local_mac (read-only)
* remote_mac (read-write)
+ * tos (read-write)
*/
struct netconsole_target {
struct list_head list;
@@ -221,6 +222,7 @@ static void free_param_target(struct netconsole_target *nt)
* | remote_ip
* | local_mac
* | remote_mac
+ * | tos
* |
* <target>/...
*/
@@ -288,6 +290,11 @@ static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac);
}
+static ssize_t show_tos(struct netconsole_target *nt, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.tos);
+}
+
/*
* This one is special -- targets created through the configfs interface
* are not enabled (and the corresponding netpoll activated) by default.
@@ -451,6 +458,25 @@ static ssize_t store_remote_mac(struct netconsole_target *nt,
return strnlen(buf, count);
}
+static ssize_t store_tos(struct netconsole_target *nt,
+ const char *buf,
+ size_t count)
+{
+ int rv;
+
+ if (nt->enabled) {
+ printk(KERN_ERR "netconsole: target (%s) is enabled, "
+ "disable to update parameters\n",
+ config_item_name(&nt->item));
+ return -EINVAL;
+ }
+
+ rv = kstrtou8(buf, 10, &nt->np.tos);
+ if (rv < 0)
+ return rv;
+ return strnlen(buf, count);
+}
+
/*
* Attribute definitions for netconsole_target.
*/
@@ -471,6 +497,7 @@ NETCONSOLE_TARGET_ATTR_RW(local_ip);
NETCONSOLE_TARGET_ATTR_RW(remote_ip);
NETCONSOLE_TARGET_ATTR_RO(local_mac);
NETCONSOLE_TARGET_ATTR_RW(remote_mac);
+NETCONSOLE_TARGET_ATTR_RW(tos);
static struct configfs_attribute *netconsole_target_attrs[] = {
&netconsole_target_enabled.attr,
@@ -481,6 +508,7 @@ static struct configfs_attribute *netconsole_target_attrs[] = {
&netconsole_target_remote_ip.attr,
&netconsole_target_local_mac.attr,
&netconsole_target_remote_mac.attr,
+ &netconsole_target_tos.attr,
NULL,
};
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 5dfa091..d659c8b 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -21,6 +21,7 @@ struct netpoll {
__be32 local_ip, remote_ip;
u16 local_port, remote_port;
u8 remote_mac[ETH_ALEN];
+ u8 tos;
struct list_head rx; /* rx_np list element */
};
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 0d38808..b01ce07 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -388,7 +388,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
/* iph->version = 4; iph->ihl = 5; */
put_unaligned(0x45, (unsigned char *)iph);
- iph->tos = 0;
+ iph->tos = np->tos;
put_unaligned(htons(ip_len), &(iph->tot_len));
iph->id = 0;
iph->frag_off = 0;
@@ -639,6 +639,8 @@ void netpoll_print_options(struct netpoll *np)
np->name, &np->remote_ip);
printk(KERN_INFO "%s: remote ethernet address %pM\n",
np->name, np->remote_mac);
+ printk(KERN_INFO "%s: tos value %d (0x%02x)\n",
+ np->name, np->tos, np->tos);
}
EXPORT_SYMBOL(netpoll_print_options);
--
1.7.3.1
next reply other threads:[~2011-12-01 1:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-01 1:18 Maciej Żenczykowski [this message]
2011-12-01 1:34 ` [PATCH] netconsole: implement ipv4 tos support Stephen Hemminger
2011-12-01 2:11 ` Maciej Żenczykowski
2011-12-01 2:27 ` Stephen Hemminger
2011-12-01 8:59 ` Maciej Żenczykowski
2011-12-01 9:25 ` Maciej Żenczykowski
2011-12-01 3:50 ` Eric Dumazet
2011-12-01 9:07 ` Maciej Żenczykowski
2011-12-01 3:37 ` David Miller
2011-12-01 9:04 ` Maciej Żenczykowski
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=1322702330-31325-1-git-send-email-zenczykowski@gmail.com \
--to=zenczykowski@gmail.com \
--cc=maze@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.