Netdev List
 help / color / mirror / Atom feed
* [RFC v4 06/11] snet: introduce snet_netlink
From: y @ 2011-05-05 13:59 UTC (permalink / raw)
  To: linux-security-module
  Cc: linux-kernel, netdev, netfilter-devel, jamal, Patrick McHardy,
	Grzegorz Nosek, Samir Bellabes
In-Reply-To: <1304603961-2517-1-git-send-email-y>

From: Samir Bellabes <sam@synack.fr>

this patch adds the snet communication's subsystem.

snet_netlink is using genetlink for sending/receiving messages to/from userspace.
the genetlink operations permit to receive orders to manage the list of events
- events are values [syscall, protocol] - which is used to know which syscall
and protocol have to be protected. genl operations are also used to manage
communication of events to userspace, and to receive the related verdict

Signed-off-by: Samir Bellabes <sam@synack.fr>
---
 security/snet/snet_netlink.c        |  442 +++++++++++++++++++++++++++++++++++
 security/snet/snet_netlink.h        |   17 ++
 security/snet/snet_netlink_helper.c |  220 +++++++++++++++++
 security/snet/snet_netlink_helper.h |    7 +
 4 files changed, 686 insertions(+), 0 deletions(-)
 create mode 100644 security/snet/snet_netlink.c
 create mode 100644 security/snet/snet_netlink.h
 create mode 100644 security/snet/snet_netlink_helper.c
 create mode 100644 security/snet/snet_netlink_helper.h

diff --git a/security/snet/snet_netlink.c b/security/snet/snet_netlink.c
new file mode 100644
index 0000000..0d6cd8b
--- /dev/null
+++ b/security/snet/snet_netlink.c
@@ -0,0 +1,442 @@
+#include <linux/sched.h>
+#include <net/genetlink.h>
+#include <linux/in6.h>
+#include <linux/snet.h>
+#include "snet_netlink.h"
+#include "snet_netlink_helper.h"
+#include "snet_verdict.h"
+#include "snet_event.h"
+#include "snet_utils.h"
+
+atomic_t snet_nl_seq = ATOMIC_INIT(0);
+uint32_t snet_nl_pid;
+static struct genl_family snet_genl_family;
+
+/*
+ * snet genetlink
+ */
+int snet_nl_send_event(struct snet_info *info)
+{
+	struct sk_buff *skb_rsp;
+	void *msg_head;
+	int ret = 0, sbs = -1;
+	size_t size = 0;
+
+	sbs = snet_nl_size_by_syscall(info);
+	if (sbs < 0)
+		return -EINVAL;
+
+	size =  sbs +
+		2 * nla_total_size(sizeof(u8)) +
+		1 * nla_total_size(sizeof(u16)) +
+		(info->verdict_id ? 3 : 2) * nla_total_size(sizeof(u32));
+
+	skb_rsp = genlmsg_new(size, GFP_KERNEL);
+	if (skb_rsp == NULL)
+		return -ENOMEM;
+
+	msg_head = genlmsg_put(skb_rsp, snet_nl_pid,
+			       atomic_inc_return(&snet_nl_seq),
+			       &snet_genl_family, 0, SNET_C_VERDICT);
+	if (msg_head == NULL)
+		goto nla_put_failure;
+
+	pr_debug("verdict_id=0x%x syscall=%s protocol=%u "
+		 "family=%u uid=%u pid=%u\n",
+		 info->verdict_id, snet_syscall_name(info->syscall),
+		 info->protocol, info->family, current_uid(), current->pid);
+
+	if (info->verdict_id)
+		NLA_PUT_U32(skb_rsp, SNET_A_VERDICT_ID, info->verdict_id);
+	NLA_PUT_U16(skb_rsp, SNET_A_SYSCALL, info->syscall);
+	NLA_PUT_U8(skb_rsp, SNET_A_PROTOCOL, info->protocol);
+	NLA_PUT_U8(skb_rsp, SNET_A_FAMILY, info->family);
+	NLA_PUT_U32(skb_rsp, SNET_A_UID, current_uid());
+	NLA_PUT_U32(skb_rsp, SNET_A_PID, current->pid);
+
+	ret = snet_nl_fill_by_syscall(skb_rsp, info);
+	if (ret != 0)
+		goto nla_put_failure;
+
+	ret = genlmsg_end(skb_rsp, msg_head);
+	if (ret < 0)
+		goto nla_put_failure;
+
+	return genlmsg_unicast(&init_net, skb_rsp, snet_nl_pid);
+
+nla_put_failure:
+	kfree_skb(skb_rsp);
+	return -ECONNABORTED;
+}
+
+/*
+ * snet genetlink functions
+ */
+
+static struct genl_family snet_genl_family = {
+	.id		= GENL_ID_GENERATE,
+	.hdrsize	= 0,
+	.name		= SNET_GENL_NAME,
+	.version	= SNET_GENL_VERSION,
+	.maxattr	= SNET_A_MAX,
+};
+
+static const struct nla_policy snet_genl_policy[SNET_A_MAX + 1] = {
+	[SNET_A_VERSION]		= { .type = NLA_U32 },
+	[SNET_A_VERDICT_ID]		= { .type = NLA_U32 },
+	[SNET_A_FAMILY]			= { .type = NLA_U8 },
+	[SNET_A_SYSCALL]		= { .type = NLA_U16 },
+	[SNET_A_PROTOCOL]		= { .type = NLA_U8 },
+	[SNET_A_UID]			= { .type = NLA_U32 },
+	[SNET_A_PID]			= { .type = NLA_U32 },
+	[SNET_A_TYPE]			= { .type = NLA_U32 },
+	[SNET_A_IPV4SADDR]		= { .type = NLA_BINARY,
+					    .len = sizeof(struct in_addr) },
+	[SNET_A_IPV6SADDR]		= { .type = NLA_BINARY,
+					    .len = sizeof(struct in6_addr) },
+	[SNET_A_IPV4DADDR]		= { .type = NLA_BINARY,
+					    .len = sizeof(struct in_addr) },
+	[SNET_A_IPV6DADDR]		= { .type = NLA_BINARY,
+					    .len = sizeof(struct in6_addr) },
+	[SNET_A_SPORT]			= { .type = NLA_U16 },
+	[SNET_A_DPORT]			= { .type = NLA_U16 },
+	[SNET_A_VERDICT]		= { .type = NLA_U8 },
+	[SNET_A_VERDICT_DELAY]		= { .type = NLA_U32 },
+	[SNET_A_TICKET_DELAY]		= { .type = NLA_U32 },
+	[SNET_A_TICKET_MODE]		= { .type = NLA_U8 },
+};
+
+/**
+ * snet_nl_version - Handle a VERSION message
+ * @skb: the NETLINK buffer
+ * @info: the Generic NETLINK info block
+ *
+ * Description:
+ * Process a user generated VERSION message and respond accordingly.
+ * Returns zero on success, negative values on failure.
+ */
+static int snet_nl_version(struct sk_buff *skb, struct genl_info *info)
+{
+	int ret = 0;
+	struct sk_buff *skb_rsp = NULL;
+	void *msg_head;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	skb_rsp = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (skb_rsp == NULL)
+		return -ENOMEM;
+	msg_head = genlmsg_put_reply(skb_rsp, info, &snet_genl_family,
+				     0, SNET_C_VERSION);
+	if (msg_head == NULL)
+		goto nla_put_failure;
+
+	NLA_PUT_U32(skb_rsp, SNET_A_VERSION, SNET_VERSION);
+
+	ret = genlmsg_end(skb_rsp, msg_head);
+	if (ret < 0)
+		goto nla_put_failure;
+
+	ret = genlmsg_reply(skb_rsp, info);
+	if (ret != 0)
+		goto nla_put_failure;
+	return 0;
+
+nla_put_failure:
+	kfree_skb(skb_rsp);
+	return ret;
+}
+
+/**
+ * snet_nl_register - Handle a REGISTER message
+ * @skb: the NETLINK buffer
+ * @info: the Generic NETLINK info block
+ *
+ * Description:
+ * Notify the kernel that an application is listening for events.
+ * Returns zero on success, negative values on failure.
+ */
+static int snet_nl_register(struct sk_buff *skb, struct genl_info *info)
+{
+	int ret = 0;
+	u32 version = 0;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	if (!info->attrs[SNET_A_VERSION]) {
+		ret = -EINVAL;
+		goto out;
+	}
+	version = nla_get_u32(info->attrs[SNET_A_VERSION]);
+
+	if (version != SNET_VERSION) {
+		ret = -EPERM;
+		goto out;
+	}
+
+	if (snet_nl_pid > 0) {
+		ret = -ECONNREFUSED;
+		goto out;
+	}
+	snet_nl_pid = info->snd_pid;
+	pr_debug("pid=%u\n", snet_nl_pid);
+out:
+	return ret;
+}
+
+/**
+ * snet_nl_unregister - Handle a UNREGISTER message
+ * @skb: the NETLINK buffer
+ * @info: the Generic NETLINK info block
+ *
+ * Description:
+ * Notify the kernel that the application is no more listening for events.
+ * Returns zero on success, negative values on failure.
+ */
+static int snet_nl_unregister(struct sk_buff *skb, struct genl_info *info)
+{
+	int ret = 0;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	if (snet_nl_pid == 0) {
+		ret = -ENOTCONN;
+		goto out;
+	}
+
+	snet_nl_pid = 0;
+	pr_debug("pid=%u\n", snet_nl_pid);
+out:
+	return ret;
+}
+
+/**
+ * snet_nl_insert - Handle a INSERT message
+ * @skb: the NETLINK buffer
+ * @info: the Generic NETLINK info block
+ *
+ * Description:
+ * Insert a new event to the events' hashtable. Returns zero on success,
+ * negative values on failure.
+ */
+static int snet_nl_insert(struct sk_buff *skb, struct genl_info *info)
+{
+	int ret = 0;
+	enum snet_syscall syscall;
+	u8 protocol;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	if (!info->attrs[SNET_A_SYSCALL] || !info->attrs[SNET_A_PROTOCOL]) {
+		ret =  -EINVAL;
+		goto out;
+	}
+	syscall = nla_get_u16(info->attrs[SNET_A_SYSCALL]);
+	protocol = nla_get_u8(info->attrs[SNET_A_PROTOCOL]);
+	ret = snet_event_insert(syscall, protocol);
+	pr_debug("syscall=%s protocol=%u insert=%s\n",
+		 snet_syscall_name(syscall), protocol,
+		 (ret == 0) ? "success" : "failed");
+out:
+	return ret;
+}
+
+/**
+ * snet_nl_remove - Handle a REMOVE message
+ * @skb: the NETLINK buffer
+ * @info: the Generic NETLINK info block
+ *
+ * Description:
+ * Remove a event from the events' hastable. Returns zero on success,
+ * negative values on failure.
+ */
+static int snet_nl_remove(struct sk_buff *skb, struct genl_info *info)
+{
+	int ret = 0;
+	enum snet_syscall syscall;
+	u8 protocol;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	if (!info->attrs[SNET_A_SYSCALL] || !info->attrs[SNET_A_PROTOCOL]) {
+		ret = -EINVAL;
+		goto out;
+	}
+	syscall = nla_get_u16(info->attrs[SNET_A_SYSCALL]);
+	protocol = nla_get_u8(info->attrs[SNET_A_PROTOCOL]);
+	ret = snet_event_remove(syscall, protocol);
+	pr_debug("syscall=%s protocol=%u remove=%s\n",
+		 snet_syscall_name(syscall), protocol,
+		 (ret == 0) ? "success" : "failed");
+out:
+	return ret;
+}
+
+/**
+ * snet_nl_flush - Handle a FLUSH message
+ * @skb: the NETLINK buffer
+ * @info: the Generic NETLINK info block
+ *
+ * Description:
+ * Remove all events from the hashtable. Returns zero on success,
+ * negative values on failure.
+ */
+static int snet_nl_flush(struct sk_buff *skb, struct genl_info *info)
+{
+	atomic_set(&snet_nl_seq, info->snd_seq);
+	snet_event_flush();
+	return 0;
+}
+
+int snet_nl_list_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
+			   u32 flags, u8 protocol, enum snet_syscall syscall)
+{
+	void *hdr;
+
+	hdr = genlmsg_put(skb, pid, seq, &snet_genl_family, flags, SNET_C_LIST);
+	if (hdr == NULL)
+		return -1;
+
+	NLA_PUT_U16(skb, SNET_A_SYSCALL, syscall);
+	NLA_PUT_U8(skb, SNET_A_PROTOCOL, protocol);
+
+	return genlmsg_end(skb, hdr);
+
+nla_put_failure:
+	genlmsg_cancel(skb, hdr);
+	return -EMSGSIZE;
+}
+/**
+ * snet_nl_list - Handle a LIST message
+ * @skb: the NETLINK buffer
+ * @cb:
+ *
+ * Description:
+ * Process a user LIST message and respond. Returns zero on success,
+ * and negative values on error.
+ */
+static int snet_nl_list(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	unsigned int len = 0;
+
+	atomic_set(&snet_nl_seq, cb->nlh->nlmsg_seq);
+	len = snet_event_fill_info(skb, cb);
+	return len;
+}
+
+/**
+ * snet_nl_verdict - Handle a VERDICT message
+ * @skb: the NETLINK buffer
+ * @info the Generic NETLINK info block
+ *
+ * Description:
+ * Provides userspace with a VERDICT message, ie we are sending informations
+ * with this command. Userspace is sending the appropriate verdict for the
+ * event. Returns zero on success,and negative values on error.
+ */
+static int snet_nl_verdict(struct sk_buff *skb, struct genl_info *info)
+{
+	int ret = 0;
+	u32 verdict_id;
+	enum snet_verdict verdict;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	if (snet_nl_pid == 0) {
+		ret = -ENOTCONN;
+		goto out;
+	}
+
+	if (!info->attrs[SNET_A_VERDICT_ID] || !info->attrs[SNET_A_VERDICT]) {
+		ret = -EINVAL;
+		goto out;
+	}
+	verdict_id = nla_get_u32(info->attrs[SNET_A_VERDICT_ID]);
+	verdict = nla_get_u8(info->attrs[SNET_A_VERDICT]);
+	ret = snet_verdict_set(verdict_id, verdict);
+out:
+	return ret;
+}
+
+static int snet_nl_config(struct sk_buff *skb,
+			  struct genl_info *info)
+{
+	int ret = 0;
+
+	atomic_set(&snet_nl_seq, info->snd_seq);
+
+	if (info->attrs[SNET_A_VERDICT_DELAY]) {
+		unsigned int new = nla_get_u32(info->attrs[SNET_A_VERDICT_DELAY]);
+		if (new == 0) {
+			ret = -EINVAL;
+			goto out;
+		}
+		snet_verdict_delay = new;
+		pr_debug("snet_nl_config: verdict_delay=%u\n", snet_verdict_delay);
+	}
+	if (info->attrs[SNET_A_TICKET_DELAY]) {
+		unsigned int new = nla_get_u32(info->attrs[SNET_A_TICKET_DELAY]);
+		if (new == 0) {
+			ret = -EINVAL;
+			goto out;
+		}
+		snet_ticket_delay = new;
+		pr_debug("snet_nl_config: ticket_delay=%u\n", snet_ticket_delay);
+	}
+	if (info->attrs[SNET_A_TICKET_MODE]) {
+		unsigned int new = nla_get_u32(info->attrs[SNET_A_TICKET_MODE]);
+		if (new >= SNET_TICKET_INVALID) {
+			ret = -EINVAL;
+			goto out;
+		}
+		snet_ticket_mode = new;
+		pr_debug("snet_nl_config: ticket_mode=%u\n", snet_ticket_mode);
+	}
+out:
+	return ret;
+}
+
+#define SNET_GENL_OPS(_cmd, _flags, _policy, _op, _opname)	\
+	{							\
+		.cmd	= _cmd,					\
+		.flags	= _flags,				\
+		.policy	= _policy,				\
+		._op	= snet_nl_##_opname,			\
+	}
+
+static struct genl_ops snet_genl_ops[] = {
+	SNET_GENL_OPS(SNET_C_VERSION, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, version),
+	SNET_GENL_OPS(SNET_C_REGISTER, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, register),
+	SNET_GENL_OPS(SNET_C_UNREGISTER, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, unregister),
+	SNET_GENL_OPS(SNET_C_INSERT, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, insert),
+	SNET_GENL_OPS(SNET_C_REMOVE, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, remove),
+	SNET_GENL_OPS(SNET_C_FLUSH, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, flush),
+	SNET_GENL_OPS(SNET_C_LIST, GENL_ADMIN_PERM, snet_genl_policy,
+		      dumpit, list),
+	SNET_GENL_OPS(SNET_C_VERDICT, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, verdict),
+	SNET_GENL_OPS(SNET_C_CONFIG, GENL_ADMIN_PERM, snet_genl_policy,
+		      doit, config),
+};
+
+#undef SNET_GENL_OPS
+
+static __init int snet_netlink_init(void)
+{
+	return genl_register_family_with_ops(&snet_genl_family,
+					     snet_genl_ops,
+					     ARRAY_SIZE(snet_genl_ops));
+}
+
+void snet_netlink_exit(void)
+{
+	genl_unregister_family(&snet_genl_family);
+}
+
+__initcall(snet_netlink_init);
diff --git a/security/snet/snet_netlink.h b/security/snet/snet_netlink.h
new file mode 100644
index 0000000..5e80d7b
--- /dev/null
+++ b/security/snet/snet_netlink.h
@@ -0,0 +1,17 @@
+#ifndef _SNET_NETLINK_H
+#define _SNET_NETLINK_H
+
+#include <linux/in6.h>
+
+extern unsigned int snet_verdict_delay;
+extern unsigned int snet_ticket_delay;
+extern unsigned int snet_ticket_mode;
+
+int snet_nl_send_event(struct snet_info *info);
+
+int snet_nl_list_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
+			   u32 flags, u8 protocol, enum snet_syscall syscall);
+
+void snet_netlink_exit(void);
+
+#endif /* _SNET_NETLINK_H */
diff --git a/security/snet/snet_netlink_helper.c b/security/snet/snet_netlink_helper.c
new file mode 100644
index 0000000..d7d743c
--- /dev/null
+++ b/security/snet/snet_netlink_helper.c
@@ -0,0 +1,220 @@
+#include <net/netlink.h>
+#include <net/genetlink.h>
+#include <linux/in6.h>
+#include <linux/snet.h>
+
+static int fill_src(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+	switch (info->family) {
+	case PF_INET:
+		ret = nla_put(skb_rsp, SNET_A_IPV4SADDR,
+			      sizeof(struct in_addr), &(info->src.u3.ip));
+		if (ret != 0)
+			goto out;
+		break;
+	case PF_INET6:
+		ret = nla_put(skb_rsp, SNET_A_IPV6SADDR,
+			      sizeof(struct in6_addr), &(info->src.u3.ip6));
+		if (ret != 0)
+			goto out;
+		break;
+	default:
+		break;
+	}
+	ret = nla_put_u16(skb_rsp, SNET_A_SPORT, info->src.u.port);
+out:
+	return ret;
+
+}
+
+static int fill_dst(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+	switch (info->family) {
+	case PF_INET:
+		ret = nla_put(skb_rsp, SNET_A_IPV4DADDR,
+			      sizeof(struct in_addr), &(info->dst.u3.ip));
+		if (ret != 0)
+			goto out;
+		break;
+	case PF_INET6:
+		ret = nla_put(skb_rsp, SNET_A_IPV6DADDR,
+			      sizeof(struct in6_addr), &(info->dst.u3.ip6));
+		if (ret != 0)
+			goto out;
+		break;
+	default:
+		break;
+	}
+	ret = nla_put_u16(skb_rsp, SNET_A_DPORT, info->dst.u.port);
+out:
+	return ret;
+}
+
+static int snet_fill_create(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+	ret = nla_put_u8(skb_rsp, SNET_A_TYPE, info->type);
+	return ret;
+}
+
+static int snet_fill_bind(struct sk_buff *skb_rsp,  struct snet_info *info)
+{
+	return fill_src(skb_rsp, info);
+}
+
+static int snet_fill_connect(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+
+	ret = fill_src(skb_rsp, info);
+	if (ret != 0)
+		goto out;
+	ret = fill_dst(skb_rsp, info);
+out:
+	return ret;
+}
+
+static int snet_fill_listen(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	return fill_src(skb_rsp, info);
+}
+
+static int snet_fill_accept(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	return fill_src(skb_rsp, info);
+}
+
+static int snet_fill_post_accept(struct sk_buff *skb_rsp,
+				 struct snet_info *info)
+{
+	int ret;
+
+	ret = fill_src(skb_rsp, info);
+	if (ret != 0)
+		goto out;
+	ret = fill_dst(skb_rsp, info);
+out:
+	return ret;
+}
+
+static int snet_fill_sendmsg(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+
+	ret = fill_src(skb_rsp, info);
+	if (ret != 0)
+		goto out;
+	ret = fill_dst(skb_rsp, info);
+out:
+	return ret;
+}
+
+static int snet_fill_recvmsg(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+
+	ret = fill_src(skb_rsp, info);
+	if (ret != 0)
+		goto out;
+	ret = fill_dst(skb_rsp, info);
+out:
+	return ret;
+}
+
+static int snet_fill_sock_rcv_skb(struct sk_buff *skb_rsp,
+				  struct snet_info *info)
+{
+	int ret;
+
+	ret = fill_src(skb_rsp, info);
+	if (ret != 0)
+		goto out;
+	ret = fill_dst(skb_rsp, info);
+out:
+	return ret;
+}
+
+static int snet_fill_close(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	int ret;
+
+	ret = fill_src(skb_rsp, info);
+	if (ret != 0)
+		goto out;
+	ret = fill_dst(skb_rsp, info);
+out:
+	return ret;
+}
+
+int snet_nl_fill_by_syscall(struct sk_buff *skb_rsp, struct snet_info *info)
+{
+	static int (*snet_df[])(struct sk_buff *, struct snet_info *) = {
+		[SNET_SOCKET_CREATE]		= &snet_fill_create,
+		[SNET_SOCKET_BIND]		= &snet_fill_bind,
+		[SNET_SOCKET_CONNECT]		= &snet_fill_connect,
+		[SNET_SOCKET_LISTEN]		= &snet_fill_listen,
+		[SNET_SOCKET_ACCEPT]		= &snet_fill_accept,
+		[SNET_SOCKET_POST_ACCEPT]	= &snet_fill_post_accept,
+		[SNET_SOCKET_SENDMSG]		= &snet_fill_sendmsg,
+		[SNET_SOCKET_RECVMSG]		= &snet_fill_recvmsg,
+		[SNET_SOCKET_SOCK_RCV_SKB]	= &snet_fill_sock_rcv_skb,
+		[SNET_SOCKET_CLOSE]		= &snet_fill_close,
+	};
+
+	if (info->syscall >= SNET_NR_SOCKET_TYPES)
+		return -EINVAL;
+	else
+		return snet_df[info->syscall](skb_rsp, info);
+}
+
+int snet_nl_size_by_syscall(struct snet_info *info)
+{
+	unsigned int size_addr4_port = nla_total_size(sizeof(struct in_addr)) +
+				       nla_total_size(sizeof(u16));
+	unsigned int size_addr6_port = nla_total_size(sizeof(struct in6_addr)) +
+				       nla_total_size(sizeof(u16));
+
+	unsigned int sbs4[] = {
+		[SNET_SOCKET_CREATE]		= nla_total_size(sizeof(u8)),
+		[SNET_SOCKET_BIND]		= size_addr4_port,
+		[SNET_SOCKET_CONNECT]		= 2 * size_addr4_port,
+		[SNET_SOCKET_LISTEN]		= size_addr4_port,
+		[SNET_SOCKET_ACCEPT]		= size_addr4_port,
+		[SNET_SOCKET_POST_ACCEPT]	= 2 * size_addr4_port,
+		[SNET_SOCKET_SENDMSG]		= 2 * size_addr4_port,
+		[SNET_SOCKET_RECVMSG]		= 2 * size_addr4_port,
+		[SNET_SOCKET_SOCK_RCV_SKB]	= 2 * size_addr4_port,
+		[SNET_SOCKET_CLOSE]		= 2 * size_addr4_port,
+	};
+
+	unsigned int sbs6[] = {
+		[SNET_SOCKET_CREATE]		= nla_total_size(sizeof(u8)),
+		[SNET_SOCKET_BIND]		= size_addr6_port,
+		[SNET_SOCKET_CONNECT]		= 2 * size_addr6_port,
+		[SNET_SOCKET_LISTEN]		= size_addr6_port,
+		[SNET_SOCKET_ACCEPT]		= size_addr6_port,
+		[SNET_SOCKET_POST_ACCEPT]	= 2 * size_addr6_port,
+		[SNET_SOCKET_SENDMSG]		= 2 * size_addr6_port,
+		[SNET_SOCKET_RECVMSG]		= 2 * size_addr6_port,
+		[SNET_SOCKET_SOCK_RCV_SKB]	= 2 * size_addr6_port,
+		[SNET_SOCKET_CLOSE]		= 2 * size_addr6_port,
+	};
+
+	if (info->syscall >= SNET_NR_SOCKET_TYPES)
+		return -EINVAL;
+	else {
+		switch (info->family) {
+		case AF_INET:
+			return sbs4[info->syscall];
+			break;
+		case AF_INET6:
+			return sbs6[info->syscall];
+			break;
+		default:
+			return -EINVAL;
+			break;
+		}
+	}
+}
diff --git a/security/snet/snet_netlink_helper.h b/security/snet/snet_netlink_helper.h
new file mode 100644
index 0000000..d12e563
--- /dev/null
+++ b/security/snet/snet_netlink_helper.h
@@ -0,0 +1,7 @@
+#ifndef _SNET_NETLINK_HELPER_H
+#define _SNET_NETLINK_HELPER_H
+
+int snet_nl_fill_by_syscall(struct sk_buff *skb_rsp, struct snet_info *info);
+int snet_nl_size_by_syscall(struct snet_info *info);
+
+#endif /* SNET_NETLINK_HELPER_H */
-- 
1.7.4.1


^ permalink raw reply related

* [RFC v4 05/11] snet: introduce snet_hooks
From: y @ 2011-05-05 13:59 UTC (permalink / raw)
  To: linux-security-module
  Cc: linux-kernel, netdev, netfilter-devel, jamal, Patrick McHardy,
	Grzegorz Nosek, Samir Bellabes
In-Reply-To: <1304603961-2517-1-git-send-email-y>

From: Samir Bellabes <sam@synack.fr>

This patch adds the snet LSM's subsystem

snet_hooks provides the security hook's functions and the security_operations
structure. Currently hook functions are only related to network stack.

For each hook function, there is a generic mecanism:
 0. check if the event [syscall, protocol] is registered
 1. prepare informations for userspace
 2. send informations to userspace (snet_netlink)
 3. wait for verdict from userspace (snet_verdict)
 4. apply verdict for the syscall

steps 3 and 4 are only valid for LSM hooks which are returning a value (a way to
'filter' the syscall). For hooks returning 'void', steps 3 and 4 don't exist,
but snet sends security informations to userspace (step 2) to update the global
security policy.

Signed-off-by: Samir Bellabes <sam@synack.fr>
---
 security/snet/snet_hooks.c |  764 ++++++++++++++++++++++++++++++++++++++++++++
 security/snet/snet_hooks.h |   10 +
 2 files changed, 774 insertions(+), 0 deletions(-)
 create mode 100644 security/snet/snet_hooks.c
 create mode 100644 security/snet/snet_hooks.h

diff --git a/security/snet/snet_hooks.c b/security/snet/snet_hooks.c
new file mode 100644
index 0000000..1d2f9b1
--- /dev/null
+++ b/security/snet/snet_hooks.c
@@ -0,0 +1,764 @@
+/*
+ * snet_hook.c
+ *
+ * here are interesting informations which can be picked up from hooks.
+ *
+ *
+ * SOCKET_CREATE:
+ *	family, type, protocol
+ * SOCKET_BIND:
+ *	family, protocol, saddr, sport
+ * SOCKET_CONNECT:
+ *	family, protocol, saddr, sport, daddr, dport
+ * SOCKET_LISTEN:
+ *	family, protocol, saddr, sport
+ * SOCKET_ACCEPT:
+ *	family, protocol, saddr, sport
+ *
+ * SOCKET_SENDMSG:
+ * SOCKET_RECVMSG:
+ * SOCKET_SOCK_RCV_SKB:
+ *
+ *
+ */
+
+#include <linux/skbuff.h>
+#include <linux/security.h>
+#include <linux/net.h>
+#include <net/sock.h>
+#include <linux/in.h>
+#include <linux/in6.h>
+#include <net/inet_sock.h>
+#include <linux/ipv6.h>
+#include <linux/snet.h>
+#include <linux/uio.h>
+#include "snet_hooks.h"
+#include "snet_verdict.h"
+#include "snet_netlink.h"
+#include "snet_event.h"
+#include "snet_ticket.h"
+#include "snet_stats.h"
+
+static inline void  snet_pr_tuple(struct snet_info *info)
+{
+	switch (info->family) {
+	case AF_INET:
+		pr_debug("%pI4:%u->%pI4:%u\n",
+			 &info->src.u3.ip, info->src.u.port,
+			 &info->dst.u3.ip, info->dst.u.port);
+		break;
+	case AF_INET6:
+		pr_debug("%pI6:%u->%pI6:%u\n",
+			 &info->src.u3.ip6, info->src.u.port,
+			 &info->dst.u3.ip6, info->dst.u.port);
+		break;
+	default:
+		break;
+	}
+	return;
+}
+
+static inline int snet_check_listeners(enum snet_verdict *verdict)
+{
+	if (snet_nl_pid == 0 || snet_nl_pid == current->pid ) {
+		if (verdict != NULL)
+			*verdict = SNET_VERDICT_GRANT;
+		return -1;
+	}
+	return 0;
+}
+
+static void snet_do_verdict(enum snet_verdict *verdict, struct snet_info *info)
+{
+	if (info->verdict_id == 0)
+		return;
+	/* sending networking informations to userspace */
+	if (snet_nl_send_event(info) == 0)
+		/* waiting for userspace reply or timeout */
+		*verdict = snet_verdict_wait(info->verdict_id);
+	/* removing verdict */
+	snet_verdict_remove(info->verdict_id);
+	return;
+}
+
+static int snet_do_send_event(struct snet_info *info)
+{
+	return snet_nl_send_event(info);
+}
+
+/*
+ * security operations helper functions
+ */
+
+/*
+ * security operations functions members
+ */
+
+static int snet_socket_create(int family, int type, int protocol, int kern)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+
+	/* if (kern) */
+	/*	;		/\* do something smart *\/ */
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_CREATE);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	if (snet_event_is_registered(SNET_SOCKET_CREATE, protocol)) {
+		struct snet_info info;
+
+		/* inserting verdict PENDING */
+		info.verdict_id = snet_verdict_insert();
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_CREATE;
+		info.protocol = protocol;
+		info.family = family;
+		info.type = type;
+
+		pr_debug("family=%u type=%u protocol=%u kern=%u\n",
+			 family, type, protocol, kern);
+
+		snet_do_verdict(&verdict, &info);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_CREATE);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_CREATE);
+	}
+
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+
+out:
+	return verdict;
+}
+
+static int snet_socket_bind(struct socket *sock,
+			    struct sockaddr *address, int addrlen)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_BIND);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_BIND, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+		struct sockaddr_in *a = (struct sockaddr_in *) address;
+		struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) address;
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_BIND;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = a->sin_addr.s_addr;
+			info.dst.u3.ip = inet->inet_daddr;
+			info.src.u.port = ntohs(a->sin_port);
+			/* check tickets */
+			verdict = snet_ticket_check(&info) ;
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&a6->sin6_addr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			info.src.u.port = ntohs(a6->sin6_port);
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		snet_do_verdict(&verdict, &info);
+		/* create ticket */
+		snet_ticket_create(&info, verdict);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_BIND);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_BIND);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static int snet_socket_connect(struct socket *sock,
+			       struct sockaddr *address, int addrlen)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_CONNECT);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_CONNECT, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+		struct sockaddr_in *a = (struct sockaddr_in *) address;
+		struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) address;
+
+		/* prepare networking informations for userspace */
+		memset(&info, 0, sizeof(struct  snet_info));
+		info.syscall = SNET_SOCKET_CONNECT;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.src.u.port = ntohs(inet->inet_sport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = a->sin_addr.s_addr;
+			info.dst.u.port = ntohs(a->sin_port);
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&a6->sin6_addr,
+			       sizeof(info.dst.u3.ip6));
+			info.dst.u.port = ntohs(a6->sin6_port);
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		snet_do_verdict(&verdict, &info);
+		/* create ticket */
+		snet_ticket_create(&info, verdict);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_CONNECT);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_CONNECT);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static int snet_socket_listen(struct socket *sock, int backlog)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_LISTEN);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_LISTEN, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+
+		/* prepare networking informations for userspace */
+		memset(&info, 0, sizeof(struct  snet_info));
+		info.syscall = SNET_SOCKET_LISTEN;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		snet_do_verdict(&verdict, &info);
+		/* create ticket */
+		snet_ticket_create(&info, verdict);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_LISTEN);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_LISTEN);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static int snet_socket_accept(struct socket *sock, struct socket *newsock)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_ACCEPT);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_ACCEPT, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_ACCEPT;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		snet_do_verdict(&verdict, &info);
+		/* create ticket */
+		snet_ticket_create(&info, verdict);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_ACCEPT);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_ACCEPT);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static void snet_socket_post_accept(struct socket *sock, struct socket *newsock)
+{
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_POST_ACCEPT);
+
+	if (snet_check_listeners(NULL)  < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_POST_ACCEPT, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(newsock->sk);
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_POST_ACCEPT;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.verdict_id = 0;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			break;
+#endif
+		default:
+			goto out;
+			break;
+		}
+		snet_pr_tuple(&info);
+		if (snet_do_send_event(&info) < 0)
+			SNET_STATS_INC(SNET_STATS_REG_ERROR,
+				       SNET_SOCKET_POST_ACCEPT);
+		else
+			SNET_STATS_INC(SNET_STATS_REG_GRANT,
+				       SNET_SOCKET_POST_ACCEPT);
+	}
+out:
+	return;
+}
+
+static int snet_socket_sendmsg(struct socket *sock,
+			       struct msghdr *msg, int size)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_SENDMSG);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_SENDMSG, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_SENDMSG;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		snet_do_verdict(&verdict, &info);
+		/* create ticket */
+		snet_ticket_create(&info, verdict);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_SENDMSG);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_SENDMSG);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static int snet_socket_recvmsg(struct socket *sock,
+			       struct msghdr *msg, int size, int flags)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_RECVMSG);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_RECVMSG, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_RECVMSG;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
+				goto out;
+			/* inserting verdict PENDING */
+			info.verdict_id = snet_verdict_insert();
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		snet_do_verdict(&verdict, &info);
+		/* create ticket */
+		snet_ticket_create(&info, verdict);
+		snet_stats_inc_reg(verdict, SNET_SOCKET_RECVMSG);
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_RECVMSG);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static int snet_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	u8 protocol = 0;
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_SOCK_RCV_SKB);
+
+	if (snet_check_listeners(&verdict) < 0)
+		goto out;
+
+	protocol = sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_SOCK_RCV_SKB, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sk);
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_SOCK_RCV_SKB;
+		info.protocol = protocol;
+		info.family = sk->sk_family;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sk->sk_family) {
+		case PF_INET:
+			/* inserting verdict PENDING  */
+			/* info.verdict_id = snet_verdict_insert(); */
+
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			/* inserting verdict PENDING  */
+			/* info.verdict_id = snet_verdict_insert(); */
+
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			break;
+#endif
+		default:
+			verdict = SNET_VERDICT_NONE;
+			goto skip_send_wait;
+			break;
+		}
+		snet_pr_tuple(&info);
+		/* SNET_DOC_VERDICT(info); */
+	} else {
+		verdict = SNET_VERDICT_GRANT;
+		SNET_STATS_INC(SNET_STATS_UNREG, SNET_SOCKET_SOCK_RCV_SKB);
+	}
+
+skip_send_wait:
+	if (verdict == SNET_VERDICT_NONE)
+		verdict = snet_verdict_policy;
+out:
+	return verdict;
+}
+
+static void snet_socket_close(struct socket *sock)
+{
+	u8 protocol = 0;
+
+	if (sock == NULL || sock->sk == NULL) {
+		goto out;
+	}
+
+	SNET_STATS_INC(SNET_STATS_EXEC, SNET_SOCKET_CLOSE);
+
+	if (snet_check_listeners(NULL)  < 0)
+		goto out;
+
+	protocol = sock->sk->sk_protocol;
+
+	if (snet_event_is_registered(SNET_SOCKET_CLOSE, protocol)) {
+		struct snet_info info;
+		struct inet_sock *inet = inet_sk(sock->sk);
+
+		/* prepare networking informations for userspace */
+		info.syscall = SNET_SOCKET_CLOSE;
+		info.protocol = protocol;
+		info.family = sock->sk->sk_family;
+		info.verdict_id = 0;
+		info.src.u.port = ntohs(inet->inet_sport);
+		info.dst.u.port = ntohs(inet->inet_dport);
+
+		switch (sock->sk->sk_family) {
+		case PF_INET:
+			info.src.u3.ip = inet->inet_saddr;
+			info.dst.u3.ip = inet->inet_daddr;
+			break;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+		case PF_INET6:
+			memcpy(&info.src.u3.ip6, (void *)&inet->pinet6->saddr,
+			       sizeof(info.src.u3.ip6));
+			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
+			       sizeof(info.dst.u3.ip6));
+			break;
+#endif
+		default:
+			goto out;
+			break;
+		}
+		snet_pr_tuple(&info);
+		if (snet_do_send_event(&info) < 0)
+			SNET_STATS_INC(SNET_STATS_REG_ERROR, SNET_SOCKET_CLOSE);
+		else
+			SNET_STATS_INC(SNET_STATS_REG_GRANT, SNET_SOCKET_CLOSE);
+	}
+out:
+	return;
+}
+
+static struct security_operations snet_security_ops = {
+	.name			= "snet",
+
+	.socket_create		= snet_socket_create,
+	.socket_bind		= snet_socket_bind,
+	.socket_connect		= snet_socket_connect,
+	.socket_listen		= snet_socket_listen,
+	.socket_accept		= snet_socket_accept,
+	.socket_post_accept	= snet_socket_post_accept,
+	.socket_sendmsg		= snet_socket_sendmsg,
+	.socket_recvmsg		= snet_socket_recvmsg,
+	.socket_sock_rcv_skb	= snet_socket_sock_rcv_skb,
+	.socket_close		= snet_socket_close,
+
+	.cred_prepare		= snet_prepare_creds,
+	.cred_free		= snet_cred_free,
+};
+
+int snet_hooks_init(void)
+{
+	if (!security_module_enable(&snet_security_ops))
+		return 0;
+
+	if (register_security(&snet_security_ops))
+		panic("snet: failed to register security_ops\n");
+
+	return 0;
+}
diff --git a/security/snet/snet_hooks.h b/security/snet/snet_hooks.h
new file mode 100644
index 0000000..05fe5e8
--- /dev/null
+++ b/security/snet/snet_hooks.h
@@ -0,0 +1,10 @@
+#ifndef _SNET_HOOKS_H
+#define _SNET_HOOKS_H
+
+extern uint32_t snet_nl_pid;
+extern unsigned int snet_verdict_policy;
+
+/* init function */
+int snet_hooks_init(void);
+
+#endif /* _SNET_HOOK_H */
-- 
1.7.4.1


^ permalink raw reply related

* [RFC v4 07/11] snet: introduce snet_verdict
From: y @ 2011-05-05 13:59 UTC (permalink / raw)
  To: linux-security-module
  Cc: linux-kernel, netdev, netfilter-devel, jamal, Patrick McHardy,
	Grzegorz Nosek, Samir Bellabes
In-Reply-To: <1304603961-2517-1-git-send-email-y>

From: Samir Bellabes <sam@synack.fr>

This patch adds the snet's subsystem responsive of managing verdicts

snet is using the word 'verdict' for the returning value of LSM hooks.
Different states exist (grant/deny/pending/none).

This patch introduces a hashtable 'verdict_hash' and operations (set/get/search..)
in order to manage verdicts. Syscalls are waiting, inside a classical waitqueue,
for theirs verdicts or for a timeout. Timeout value and the default verdict
policy are configurable at boot or by the snet_netlink subsystem.
With the help of the communication's subsystem, verdicts are coming from userspace

Signed-off-by: Samir Bellabes <sam@synack.fr>
---
 security/snet/snet_verdict.c |  203 ++++++++++++++++++++++++++++++++++++++++++
 security/snet/snet_verdict.h |   23 +++++
 2 files changed, 226 insertions(+), 0 deletions(-)
 create mode 100644 security/snet/snet_verdict.c
 create mode 100644 security/snet/snet_verdict.h

diff --git a/security/snet/snet_verdict.c b/security/snet/snet_verdict.c
new file mode 100644
index 0000000..b0811ac
--- /dev/null
+++ b/security/snet/snet_verdict.c
@@ -0,0 +1,203 @@
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/random.h>
+#include <linux/wait.h>
+#include <asm/atomic.h>
+#include <linux/snet.h>
+#include <linux/slab.h>
+#include "snet_verdict.h"
+
+static struct list_head *snet_vdh;
+static rwlock_t snet_vdh_lock = __RW_LOCK_UNLOCKED();
+
+struct snet_verdict_entry {
+	struct list_head list;
+	u32 verdict_id;
+	enum snet_verdict verdict;
+};
+
+static atomic_t value = ATOMIC_INIT(1);
+
+/* when waiting for a verdict, process is added to this queue */
+static DECLARE_WAIT_QUEUE_HEAD(snet_wq);
+
+static struct kmem_cache *snet_verdict_entry_cachep;
+
+/* lookup for a verdict - before using this function, lock snet_vdh_lock */
+static struct snet_verdict_entry *__snet_verdict_lookup(const u32 verdict_id)
+{
+	unsigned int h = 0;
+	struct list_head *l = NULL;
+	struct snet_verdict_entry *s = NULL;
+
+	h = verdict_id % snet_vdh_size;
+	l = &snet_vdh[h];
+
+	list_for_each_entry(s, l, list) {
+		if (s->verdict_id == verdict_id) {
+			return s;
+		}
+	}
+	return NULL;
+}
+
+const enum snet_verdict snet_verdict_wait(const u32 verdict_id)
+{
+	enum snet_verdict verdict = SNET_VERDICT_NONE;
+	long ret = 0;
+
+	ret = wait_event_timeout(snet_wq,
+				 (verdict = snet_verdict_get(verdict_id))
+				 != SNET_VERDICT_PENDING,
+				 snet_verdict_delay * HZ);
+	if (ret)
+		return snet_verdict_get(verdict_id);
+	else
+		return SNET_VERDICT_NONE;
+}
+
+const enum snet_verdict snet_verdict_get(const u32 verdict_id)
+{
+	enum snet_verdict v = SNET_VERDICT_NONE;
+	struct snet_verdict_entry *data = NULL;
+
+	read_lock_bh(&snet_vdh_lock);
+	data = __snet_verdict_lookup(verdict_id);
+	if (data != NULL)
+		v = data->verdict;
+
+	read_unlock_bh(&snet_vdh_lock);
+	return v;
+}
+
+int snet_verdict_set(const u32 verdict_id, const enum snet_verdict verdict)
+{
+	struct snet_verdict_entry *data = NULL;
+	int ret = -EINVAL;
+
+	if (verdict >= SNET_NR_VERDICT_TYPES)
+		goto out;
+
+	write_lock_bh(&snet_vdh_lock);
+	data = __snet_verdict_lookup(verdict_id);
+	if (data != NULL) {
+		/* if verdict is already set because of
+		   timeout, we won't modify it */
+		if (data->verdict == SNET_VERDICT_PENDING) {
+			data->verdict = verdict;
+			ret = 0;
+		}
+	}
+	write_unlock_bh(&snet_vdh_lock);
+	wake_up(&snet_wq);
+out:
+	return ret;
+}
+
+int snet_verdict_remove(const u32 verdict_id)
+{
+	struct snet_verdict_entry *data = NULL;
+
+	write_lock_bh(&snet_vdh_lock);
+	data = __snet_verdict_lookup(verdict_id);
+	if (data == NULL) {
+		write_unlock_bh(&snet_vdh_lock);
+		return -EINVAL;
+	}
+	pr_debug("(verdict_id=%u)\n", data->verdict_id);
+	list_del(&data->list);
+	write_unlock_bh(&snet_vdh_lock);
+	kmem_cache_free(snet_verdict_entry_cachep, data);
+	return 0;
+}
+
+int snet_verdict_insert(void)
+{
+	struct snet_verdict_entry *data = NULL;
+	unsigned int h = 0;
+	u32 verdict_id = 0;
+
+	data = kmem_cache_zalloc(snet_verdict_entry_cachep, GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	do {
+		verdict_id = atomic_inc_return(&value);
+	} while (verdict_id == 0);
+
+	data->verdict_id = verdict_id;
+	data->verdict = SNET_VERDICT_PENDING;
+	INIT_LIST_HEAD(&(data->list));
+	h = data->verdict_id % snet_vdh_size;
+
+	write_lock_bh(&snet_vdh_lock);
+	list_add_tail(&data->list, &snet_vdh[h]);
+	pr_debug("[%u]=(verdict_id=%u)\n", h, data->verdict_id);
+	write_unlock_bh(&snet_vdh_lock);
+
+	return verdict_id;
+}
+
+void snet_verdict_flush(void)
+{
+	unsigned int i = 0;
+
+	write_lock_bh(&snet_vdh_lock);
+	for (i = 0; i < snet_vdh_size; i++) {
+		struct snet_verdict_entry *data, *tmp;
+		list_for_each_entry_safe(data, tmp, &snet_vdh[i], list) {
+			list_del(&data->list);
+			kmem_cache_free(snet_verdict_entry_cachep, data);
+		}
+	}
+	write_unlock_bh(&snet_vdh_lock);
+	return;
+}
+
+/* init function */
+int snet_verdict_init(void)
+{
+	int err = 0, i = 0;
+
+	if (snet_vdh_size == 0) {
+		printk(KERN_ERR "snet: bad snet_vdh_size value\n");
+		err = -EINVAL;
+		goto out;
+	}
+
+	if (snet_verdict_delay == 0) {
+		printk(KERN_ERR "snet: bad snet_verdict_delay value\n");
+		err = -EINVAL;
+		goto out;
+	}
+
+	snet_vdh = kzalloc(sizeof(struct list_head) * snet_vdh_size,
+			  GFP_KERNEL);
+	if (!snet_vdh) {
+		printk(KERN_WARNING
+		       "snet: can't alloc memory for verdict\n");
+		err = -ENOMEM;
+		goto out;
+	}
+
+	for (i = 0; i < snet_vdh_size; i++)
+		INIT_LIST_HEAD(&snet_vdh[i]);
+
+	/* snet_verdict_entry_cachep is not destroyed */
+	snet_verdict_entry_cachep = kmem_cache_create("snet_verdict_entry",
+						      sizeof(struct snet_verdict_entry),
+						      0, SLAB_PANIC, NULL);
+out:
+	return err;
+}
+
+/* exit function */
+void snet_verdict_exit(void)
+{
+	if (snet_vdh) {
+		kfree(snet_vdh);
+		snet_vdh = NULL;
+	}
+
+	return;
+}
diff --git a/security/snet/snet_verdict.h b/security/snet/snet_verdict.h
new file mode 100644
index 0000000..07e8638
--- /dev/null
+++ b/security/snet/snet_verdict.h
@@ -0,0 +1,23 @@
+#ifndef _SNET_VERDICT_H
+#define _SNET_VERDICT_H
+
+extern unsigned int snet_vdh_size;
+extern unsigned int snet_verdict_delay;
+
+/* helper functions */
+const enum snet_verdict snet_verdict_wait(const u32 verdict_id);
+
+/* manipulate the verdicts hash table */
+const enum snet_verdict snet_verdict_get(const u32 verdict_id);
+int snet_verdict_set(const u32 verdict_id, const enum snet_verdict verdict);
+int snet_verdict_insert(void);
+int snet_verdict_remove(const u32 verdict_id);
+int snet_verdict_insert(void);
+void snet_verdict_flush(void);
+
+/* init function */
+int snet_verdict_init(void);
+/* exit function */
+void snet_verdict_exit(void);
+
+#endif /* _SNET_VERDICT_H */
-- 
1.7.4.1


^ permalink raw reply related

* [RFC v4 09/11] snet: introduce snet_utils
From: y @ 2011-05-05 13:59 UTC (permalink / raw)
  To: linux-security-module
  Cc: linux-kernel, netdev, netfilter-devel, jamal, Patrick McHardy,
	Grzegorz Nosek, Samir Bellabes
In-Reply-To: <1304603961-2517-1-git-send-email-y>

From: Samir Bellabes <sam@synack.fr>

This patch provides helper functions for other subsystems

Signed-off-by: Samir Bellabes <sam@synack.fr>
---
 security/snet/snet_utils.c |   39 +++++++++++++++++++++++++++++++++++++++
 security/snet/snet_utils.h |    9 +++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
 create mode 100644 security/snet/snet_utils.c
 create mode 100644 security/snet/snet_utils.h

diff --git a/security/snet/snet_utils.c b/security/snet/snet_utils.c
new file mode 100644
index 0000000..4e80263
--- /dev/null
+++ b/security/snet/snet_utils.c
@@ -0,0 +1,39 @@
+#include <linux/types.h>
+#include <linux/snet.h>
+
+const char *snet_verdict_name(const enum snet_verdict cmd)
+{
+	static const char *const verdict_name[] = {
+		[SNET_VERDICT_GRANT]	= "Grant",
+		[SNET_VERDICT_DENY]	= "Deny",
+		[SNET_VERDICT_PENDING]	= "Pending",
+		[SNET_VERDICT_NONE]	= "None",
+		[SNET_VERDICT_INVALID]	= "Invalid",
+	};
+
+	if (cmd >= SNET_NR_VERDICT_TYPES)
+		return "ERROR";
+	else
+		return verdict_name[cmd];
+}
+
+const char *snet_syscall_name(const enum snet_syscall sys)
+{
+	static const char *const syscall_name[] = {
+		[SNET_SOCKET_CREATE]		= "Create",
+		[SNET_SOCKET_BIND]		= "Bind",
+		[SNET_SOCKET_CONNECT]		= "Connect",
+		[SNET_SOCKET_LISTEN]		= "Listen",
+		[SNET_SOCKET_ACCEPT]		= "Accept",
+		[SNET_SOCKET_POST_ACCEPT]	= "Post Accept",
+		[SNET_SOCKET_SENDMSG]		= "Sendmsg",
+		[SNET_SOCKET_RECVMSG]		= "Recvmsg",
+		[SNET_SOCKET_SOCK_RCV_SKB]	= "Sock Rcv Skb",
+		[SNET_SOCKET_CLOSE]		= "Close",
+	};
+
+	if (sys >= SNET_NR_SOCKET_TYPES)
+		return "ERROR";
+	else
+		return syscall_name[sys];
+}
diff --git a/security/snet/snet_utils.h b/security/snet/snet_utils.h
new file mode 100644
index 0000000..01e515f
--- /dev/null
+++ b/security/snet/snet_utils.h
@@ -0,0 +1,9 @@
+#ifndef _SNET_UTILS_H
+#define _SNET_UTILS_H
+
+#include <linux/skbuff.h>
+
+const char *snet_verdict_name(const enum snet_verdict cmd);
+const char *snet_syscall_name(const enum snet_syscall sys);
+
+#endif	/* _SNET_UTILS_H */
-- 
1.7.4.1


^ permalink raw reply related

* [RFC v4 02/11] lsm: reintroduce security_socket_post_accept()
From: y @ 2011-05-05 13:59 UTC (permalink / raw)
  To: linux-security-module
  Cc: linux-kernel, netdev, netfilter-devel, jamal, Patrick McHardy,
	Grzegorz Nosek, Samir Bellabes
In-Reply-To: <1304603961-2517-1-git-send-email-y>

From: Samir Bellabes <sam@synack.fr>

snet needs to reintroduce this hook, as it was designed to be: a hook for
updating security informations on objects.

Originally, This was a direct revert of commit
8651d5c0b1f874c5b8307ae2b858bc40f9f02482.

But from the comment of Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> :

> Please move security_socket_post_accept() to before fd_install().
> Otherwise, other threads which share fd tables can use
> security-informations-not-yet-updated accept()ed sockets.

Signed-off-by: Samir Bellabes <sam@synack.fr>
Acked-by: Serge Hallyn <serue@us.ibm.com>
---
 include/linux/security.h |   13 +++++++++++++
 net/socket.c             |    2 ++
 security/capability.c    |    5 +++++
 security/security.c      |    5 +++++
 4 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/include/linux/security.h b/include/linux/security.h
index da0d59e..02effe5 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -875,6 +875,11 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *	@sock contains the listening socket structure.
  *	@newsock contains the newly created server socket for connection.
  *	Return 0 if permission is granted.
+ * @socket_post_accept:
+ *	This hook allows a security module to copy security
+ *	information into the newly created socket's inode.
+ *	@sock contains the listening socket structure.
+ *	@newsock contains the newly created server socket for connection.
  * @socket_sendmsg:
  *	Check permission before transmitting a message to another socket.
  *	@sock contains the socket structure.
@@ -1587,6 +1592,8 @@ struct security_operations {
 			       struct sockaddr *address, int addrlen);
 	int (*socket_listen) (struct socket *sock, int backlog);
 	int (*socket_accept) (struct socket *sock, struct socket *newsock);
+	void (*socket_post_accept) (struct socket *sock,
+				    struct socket *newsock);
 	int (*socket_sendmsg) (struct socket *sock,
 			       struct msghdr *msg, int size);
 	int (*socket_recvmsg) (struct socket *sock,
@@ -2555,6 +2562,7 @@ int security_socket_bind(struct socket *sock, struct sockaddr *address, int addr
 int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
 int security_socket_listen(struct socket *sock, int backlog);
 int security_socket_accept(struct socket *sock, struct socket *newsock);
+void security_socket_post_accept(struct socket *sock, struct socket *newsock);
 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
 int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
 			    int size, int flags);
@@ -2640,6 +2648,11 @@ static inline int security_socket_accept(struct socket *sock,
 	return 0;
 }
 
+static inline void security_socket_post_accept(struct socket *sock,
+					       struct socket *newsock)
+{
+}
+
 static inline int security_socket_sendmsg(struct socket *sock,
 					  struct msghdr *msg, int size)
 {
diff --git a/net/socket.c b/net/socket.c
index d588e9e..7807904 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1535,6 +1535,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
 			goto out_fd;
 	}
 
+	security_socket_post_accept(sock, newsock);
+
 	/* File flags are not inherited via accept() unlike another OSes. */
 
 	fd_install(newfd, newfile);
diff --git a/security/capability.c b/security/capability.c
index 1f8bbe2..da68c60 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -593,6 +593,10 @@ static int cap_socket_accept(struct socket *sock, struct socket *newsock)
 	return 0;
 }
 
+static void cap_socket_post_accept(struct socket *sock, struct socket *newsock)
+{
+}
+
 static int cap_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size)
 {
 	return 0;
@@ -1022,6 +1026,7 @@ void __init security_fixup_ops(struct security_operations *ops)
 	set_to_cap_if_null(ops, socket_connect);
 	set_to_cap_if_null(ops, socket_listen);
 	set_to_cap_if_null(ops, socket_accept);
+	set_to_cap_if_null(ops, socket_post_accept);
 	set_to_cap_if_null(ops, socket_sendmsg);
 	set_to_cap_if_null(ops, socket_recvmsg);
 	set_to_cap_if_null(ops, socket_getsockname);
diff --git a/security/security.c b/security/security.c
index 84187d8..eda2b75 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1038,6 +1038,11 @@ int security_socket_accept(struct socket *sock, struct socket *newsock)
 	return security_ops->socket_accept(sock, newsock);
 }
 
+void security_socket_post_accept(struct socket *sock, struct socket *newsock)
+{
+	security_ops->socket_post_accept(sock, newsock);
+}
+
 int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size)
 {
 	return security_ops->socket_sendmsg(sock, msg, size);
-- 
1.7.4.1


^ permalink raw reply related

* Re: ARM, AF_PACKET: caching problems on Marvell Kirkwood
From: Phil Sutter @ 2011-05-05 14:11 UTC (permalink / raw)
  To: linux-arm-kernel, netdev, ne
  Cc: Johann Baudy, Lennert Buytenhek, Nicolas Pitre
In-Reply-To: <20110408130643.GA8730@orbit.nwl.cc>

Hi,

Hasn't anyone experienced this bug but me? Can anyone reproduce the
described behaviour on his Kirkwood-based (or even generic ARM) machine?
I am still not sure if this is a problem of just my CPU or common
amongst Kirkwood/VIPT/ARM machines.

My workaround looks like this:
| diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
| index b5362e9..0672f50 100644
| --- a/net/packet/af_packet.c
| +++ b/net/packet/af_packet.c
| @@ -1298,10 +1298,13 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
|  {
|         struct sock *sk = sock->sk;
|         struct packet_sock *po = pkt_sk(sk);
| -       if (po->tx_ring.pg_vec)
| -               return tpacket_snd(po, msg);
| -       else
| -               return packet_snd(sock, msg, len);
| +       int rc;
| +
| +       flush_cache_all();
| +       rc = po->tx_ring.pg_vec ? tpacket_snd(po, msg) :
| +                       packet_snd(sock, msg, len);
| +       flush_cache_all();
| +       return rc;
|  }
|  
|  /*

Greetings, Phil

(Full-quoting here because I've added the TX ring author and the Kirkwood
maintainers to Cc.)

On Fri, Apr 08, 2011 at 03:06:43PM +0200, Phil Sutter wrote:
> Dear lists,
> 
> I am experiencing severe caching issues using the TX_RING feature of
> AF_PACKET on a Kirkwood-based system (i.e., OpenRD). This may likely be
> a bug of the CPU/SoC itself, at least it reacts a bit picky when using
> the preload data instruction (pld) in rather useless cases (but that's a
> different story).
> 
> There is simple testing code at the end of this email, effectively just
> preparing a packet in the TX_RING and triggering it's delivery once per
> second. The experienced symptom is that sporadically nothing goes out in
> one iteration, and two packets in the following one.
> 
> It looks like the kernel doesn't get the changed value of tp_status in
> time, although userspace sees the correct value. Note that moving the
> sleep(1) from the end of the loop to just before calling sendto() fixes
> the problem.
> 
> Another (more useful) workaround is to call flush_cache_all() at the
> beginning of packet_sendmsg() in net/packet/af_packet.c. I was not able
> to fix this with some more specific flushing at that place. Anyway, the
> call to flush_dcache_page() from __packet_get_status() in the same
> source file is meant to do the trick I guess. But somehow doesn't.
> 
> Feedback regardles of which kind is highly appreciated, of course!
> 
> Greetings, Phil
> 
> ------------------[start of packet_mmap_test.c]--------------------
> #include <stdint.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <linux/if_ether.h>
> #include <linux/if_packet.h>
> #include <net/if.h>
> #include <sys/ioctl.h>
> #include <sys/mman.h>
> #include <sys/socket.h>
> #include <sys/types.h>
> 
> #define PERROR_EXIT(rc, mesg) { \
> 	perror(mesg); \
> 	return rc; \
> }
> 
> int main(void)
> {
> 	uint32_t size;
> 	struct sockaddr_ll sa;
> 	struct ifreq ifr;
> 	int index;
> 	int tmp;
> 	int fd;
> 	struct tpacket_req packet_req;
> 	struct tpacket2_hdr * ps_header_start, *ps_header;
> 
> 	if ((fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL))) < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "socket");
> 
> 	/* retrieve eth0's interface index number */
> 	strncpy (ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));
> 	if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "ioctl(SIOCGIFINDEX)");
> 
> 	/* set sockaddr info */
> 	memset(&sa, 0, sizeof(sa));
> 	sa.sll_family = AF_PACKET;
> 	sa.sll_protocol = ETH_P_ALL;
> 	sa.sll_ifindex = ifr.ifr_ifindex;
> 
> 	/* bind port */
> 	if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "bind()");
> 
> 	tmp = TPACKET_V2;
> 	if (setsockopt(fd, SOL_PACKET, PACKET_VERSION, &tmp, sizeof(tmp)) < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "setsockopt(PACKET_VERSION)");
> 
> 	/* set packet loss option */
> 	tmp = 1;
> 	if (setsockopt(fd, SOL_PACKET, PACKET_LOSS, &tmp, sizeof(tmp)) < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "setsockopt(PACKET_LOSS)");
> 
> 	/* prepare Tx ring request */
> 	packet_req.tp_block_size = 1024 * 8;
> 	packet_req.tp_frame_size = 1024 * 8;
> 	packet_req.tp_block_nr = 1024;
> 	packet_req.tp_frame_nr = 1024;
> 
> 	/* send TX ring request */
> 	if (setsockopt(fd, SOL_PACKET, PACKET_TX_RING,
> 	               &packet_req, sizeof(packet_req)) < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "setsockopt: PACKET_TX_RING");
> 
> 	/* calculate memory to mmap in the kernel */
> 	size = packet_req.tp_block_size * packet_req.tp_block_nr;
> 
> 	/* mmap Tx ring buffers memory */
> 	ps_header_start = mmap(0, size,
> 			PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
> 	if (ps_header_start < 0)
> 		PERROR_EXIT(EXIT_FAILURE, "mmap");
> 
> 	/* fill peer sockaddr for SOCK_DGRAM */
> 	sa.sll_family = AF_PACKET;
> 	sa.sll_protocol = htons(ETH_P_IP);
> 	sa.sll_ifindex = ifr.ifr_ifindex;
> 	sa.sll_halen = ETH_ALEN;
> 	memset(&sa.sll_addr, 0xff, ETH_ALEN);
> 
> 	ps_header = ps_header_start;
> 	while (1) {
> 		int sendlen, j;
> 
> 		char *data = (void*)ps_header + TPACKET_HDRLEN
> 		              - sizeof(struct sockaddr_ll);
> 
> 		switch((volatile uint32_t)ps_header->tp_status)
> 		{
> 		case TP_STATUS_AVAILABLE:
> 			memset(data, 0x23, 150);
> 			break;
> 
> 		case TP_STATUS_WRONG_FORMAT:
> 			printf("An error has occured during transfer\n");
> 			exit(EXIT_FAILURE);
> 			break;
> 
> 		default:
> 			printf("Buffer is not available, aborting\n");
> 			exit(1);
> 			break;
> 		}
> 		ps_header->tp_len = 150;
> 		ps_header->tp_status = TP_STATUS_SEND_REQUEST;
> 
> 		sendlen = sendto(fd, NULL, 0, 0,
> 				(struct sockaddr *)&sa, sizeof(sa));
> 		if (sendlen < 0)
> 			perror("sendto");
> 		else if (sendlen == 0)
> 			printf("sendto(): nothing sent!\n");
> 		else
> 			printf("sendto(): sent %d bytes out\n", sendlen);
> 
> #define ST_IS(x) ((volatile uint32_t)ps_header->tp_status == x)
> 		printf("tp_status after sending: %s\n",
> 				ST_IS(TP_STATUS_AVAILABLE) ? "AVAILABLE" :
> 				ST_IS(TP_STATUS_SEND_REQUEST) ? "SEND_REQUEST" :
> 				ST_IS(TP_STATUS_WRONG_FORMAT) ? "WRONG_FORMAT" :
> 				"unknown");
> #undef ST_IS
> 
> 		ps_header = (void *)ps_header + packet_req.tp_frame_size;
> 		if (ps_header >= ps_header_start + size)
> 			ps_header = ps_header_start;
> 
> 		sleep(1);
> 	}
> 	return 0;
> }
> --------------------[end of packet_mmap_test.c]--------------------
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [RFC v3 02/10] Revert "lsm: Remove the socket_post_accept() hook"
From: Paul Moore @ 2011-05-05 14:11 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: sam, linux-security-module, linux-kernel, netdev, netfilter-devel,
	hadi, kaber, zbr, root
In-Reply-To: <201105041128.BAB13061.LMHVtOSOQOFFJF@I-love.SAKURA.ne.jp>

On Tuesday, May 03, 2011 10:28:24 PM Tetsuo Handa wrote:
> Paul Moore wrote:
> > On Tuesday, May 03, 2011 10:24:15 AM Samir Bellabes wrote:
> > > snet needs to reintroduce this hook, as it was designed to be: a hook
> > > for updating security informations on objects.
> > 
> > Looking at this and 5/10 again, it seems that you should be able to do
> > what you need with the sock_graft() hook.  Am I missing something?
> > 
> > My apologies if we've already discussed this approach previously ...
> 
> static void snet_socket_post_accept(struct socket *sock, struct socket
> *newsock) {
> 	static void snet_do_send_event(struct snet_info *info)
> 	{
> 		int snet_nl_send_event(struct snet_info *info)
> 		{
> 			skb_rsp = genlmsg_new(size, GFP_KERNEL);
> 			genlmsg_unicast()
> 		}
> 	}
> }
> 
> First problem with using snet_do_send_event() from security_sock_graft() is
> that we have to use GFP_ATOMIC rather than GFP_KERNEL because we are inside
> write_lock_bh()/write_unlock_bh().

I guess I don't see that as being a blocker ...

> static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32
> pid) {
> 	static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32
> pid) {
> 		int netlink_unicast(struct sock *ssk, struct sk_buff *skb,
> 			u32 pid, MSG_DONTWAIT)
> 		{
> 			int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
> 				      long *timeo, struct sock *ssk)
> 			{
> 				if (!*timeo) {
> 					return -EAGAIN;
> 			}
> 		}
> 	}
> }
> 
> Second problem is that genlmsg_unicast() might return -EAGAIN because we
> can't sleep inside write_lock_bh()/write_unlock_bh().

Ah yes, the real problem.  I forgot that snet relied on a user space tool.  I 
tend to agree with others who have suggested this is not the right approach, 
but I understand why you want the post_accept() hook; thanks for reminding me.

--
paul moore
linux @ hp

^ permalink raw reply

* Re: ath5k regression associating with APs in 2.6.38
From: Nick Kossifidis @ 2011-05-05 14:30 UTC (permalink / raw)
  To: Nick Kossifidis, John W. Linville, Jiri Slaby, Luis R. Rodriguez,
	Bob Copeland
In-Reply-To: <20110505135207.GA13727@thinkpad-t410>

2011/5/5 Seth Forshee <seth.forshee@canonical.com>:
> On Wed, May 04, 2011 at 11:09:03PM +0300, Nick Kossifidis wrote:
>> 2011/5/4 Seth Forshee <seth.forshee@canonical.com>:
>> > On Wed, May 04, 2011 at 01:27:17PM -0400, John W. Linville wrote:
>> >> On Wed, May 04, 2011 at 10:38:19AM -0500, Seth Forshee wrote:
>> >> > I've been investigating some reports of a regression in associating with
>> >> > APs with AR2413 in 2.6.38. Association repeatedly fails with some
>> >> > "direct probe to x timed out" messages (see syslog excerpt below),
>> >> > although it will generally associate eventually, after many tries.
>> >> >
>> >> > Bisection identifies 8aec7af (ath5k: Support synth-only channel change
>> >> > for AR2413/AR5413) as offending commit. Prior to this commit there are
>> >> > no direct probe messages at all in the logs. I've also found that
>> >> > forcing fast to false at the top of ath5k_hw_reset() fixes the issue.
>> >> > I'm not sure what the connection is between this commit and the
>> >> > timeouts. Any suggestions?
>> >>
>> >> Have you tried reverting that commit on top of 2.6.38?  Can you
>> >> recreate the issue with 2.6.39-rc6 (or later)?
>> >
>> > I started to revert that commit, but it wasn't straight-forward due to
>> > later changes. Forcing fast to false in ath5k_hw_reset() acts as a
>> > functional revert of sorts since that should force it back to a full
>> > reset for all channel changes, and it's much simpler than working out
>> > the right way to revert the commit. I think the results suggest strongly
>> > that a revert is likely to fix the problem. I can finish the work to
>> > revert if you'd still like to see the results.
>> >
>> > Testing a previous .39-rc kernel still exhibited the failure. I don't
>> > recall which one it was and apparently forgot to make note of it. I'll
>> > request testing against rc6.
>> >
>> > Thanks,
>> > Seth
>> >
>>
>> Do you get scan results ?
>> Can you enable ATH5K_DEBUG_RESET and see what you get ?
>
> 2.6.39-rc6 still fails. A more comprehensive log with ATH5K_DEBUG_RESET
> enabled is below.
>
> Scanning looks to be failing according to this log. I was thinking that
> I saw successfull scans in some of the previous logs, but I'll have to
> go back and check to be sure.
>
> Thanks,
> Seth
>
>
> kernel: [   23.421242] ath5k 0000:06:02.0: PCI INT A -> GSI 22 (level, low) -> IRQ 22
> kernel: [   23.421312] ath5k 0000:06:02.0: registered as 'phy0'
> kernel: [   24.132959] ath: EEPROM regdomain: 0x63
> kernel: [   24.132962] ath: EEPROM indicates we should expect a direct regpair map
> kernel: [   24.132967] ath: Country alpha2 being used: 00
> kernel: [   24.132969] ath: Regpair used: 0x63
> kernel: [   24.136125] cfg80211: Updating information on frequency 2412 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136131] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136134] cfg80211: Updating information on frequency 2417 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136137] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136140] cfg80211: Updating information on frequency 2422 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136143] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136146] cfg80211: Updating information on frequency 2427 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136149] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136151] cfg80211: Updating information on frequency 2432 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136155] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136157] cfg80211: Updating information on frequency 2437 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136160] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136163] cfg80211: Updating information on frequency 2442 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136166] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136168] cfg80211: Updating information on frequency 2447 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136172] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136174] cfg80211: Updating information on frequency 2452 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136177] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136180] cfg80211: Updating information on frequency 2457 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136183] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136186] cfg80211: Updating information on frequency 2462 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136189] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136191] cfg80211: Updating information on frequency 2467 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136195] cfg80211: 2457000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136197] cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
> kernel: [   24.136200] cfg80211: 2457000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
> kernel: [   24.136203] cfg80211: Disabling freq 2484 MHz as custom regd has no rule that fits a 20 MHz wide channel
> kernel: [   24.136404] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
> kernel: [   24.393924] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
> kernel: [   24.394588] ath5k phy0: Atheros AR2413 chip found (MAC: 0x78, PHY: 0x45)
> ...
> NetworkManager[725]: <info> (wlan0): driver supports SSID scans (scan_capa 0x01).
> NetworkManager[725]: <info> (wlan0): new 802.11 WiFi device (driver: 'ath5k' ifindex: 3)
> NetworkManager[725]: <info> (wlan0): exported as /org/freedesktop/NetworkManager/Devices/1
> NetworkManager[725]: <info> (wlan0): now managed
> NetworkManager[725]: <info> (wlan0): device state change: 1 -> 2 (reason 2)
> NetworkManager[725]: <info> (wlan0): bringing up device.
> NetworkManager[725]: <info> (wlan0): preparing device.
> NetworkManager[725]: <info> (wlan0): deactivating device (reason: 2).
> NetworkManager[725]: supplicant_interface_acquire: assertion `mgr_state == NM_SUPPLICANT_MANAGER_STATE_IDLE' failed
> kernel: [   25.149294] ADDRCONF(NETDEV_UP): wlan0: link is not ready
> ...
> NetworkManager[725]: <info> Trying to start the supplicant...
> ...
> NetworkManager[725]: <info> (wlan0): supplicant manager state:  down -> idle
> NetworkManager[725]: <info> (wlan0): device state change: 2 -> 3 (reason 0)
> NetworkManager[725]: <info> (wlan0): supplicant interface state:  starting -> ready
> ...
> NetworkManager[725]: <info> (wlan0): device state change: 3 -> 2 (reason 0)
> NetworkManager[725]: <info> (wlan0): deactivating device (reason: 0).
> NetworkManager[725]: <info> (wlan0): taking down device.
> NetworkManager[725]: <info> (wlan0): bringing up device.
> kernel: [  104.430292] ath5k phy0: (ath5k_init_hw:2522): mode 2
> kernel: [  104.430297] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
> kernel: [  104.431000] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  104.434475] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  104.434683] ath5k phy0: (ath5k_rfkill_disable:42): rfkill disable (gpio:0 polarity:0)
> kernel: [  104.435759] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2412 MHz)
> kernel: [  104.435762] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  104.436845] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  104.437191] ath5k phy0: (ath5k_conf_tx:602): Configure tx [queue 0],  aifs: 2, cw_min: 7, cw_max: 15, txop: 102
> kernel: [  104.437212] ath5k phy0: (ath5k_conf_tx:602): Configure tx [queue 1],  aifs: 2, cw_min: 15, cw_max: 31, txop: 188
> kernel: [  104.438337] ADDRCONF(NETDEV_UP): wlan0: link is not ready
> NetworkManager[725]: <info> (wlan0): supplicant interface state:  starting -> ready
> NetworkManager[725]: <info> (wlan0): device state change: 2 -> 3 (reason 42)
> wpa_supplicant[745]: Failed to initiate AP scan.
> kernel: [  125.188087] net_ratelimit: 41 callbacks suppressed
> kernel: [  125.188100] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  125.188109] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  125.291007] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  125.344076] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  125.344090] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  125.447014] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  125.500078] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  125.500091] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  125.602999] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  125.656070] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> kernel: [  155.188052] net_ratelimit: 29 callbacks suppressed
> kernel: [  155.188058] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  155.188061] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  155.290844] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  155.344032] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  155.344038] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  155.446810] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  155.500031] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  155.500036] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  155.602811] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  155.656033] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> kernel: [  195.184088] net_ratelimit: 29 callbacks suppressed
> kernel: [  195.184102] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  195.184110] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  195.287022] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  195.340066] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  195.340079] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  195.442967] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  195.496076] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  195.496088] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  195.599009] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  195.652078] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> kernel: [  245.188077] net_ratelimit: 29 callbacks suppressed
> kernel: [  245.188091] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  245.188100] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  245.290997] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  245.344084] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  245.344092] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  245.446882] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  245.500053] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  245.500058] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  245.602808] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  245.656046] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> kernel: [  305.188050] net_ratelimit: 29 callbacks suppressed
> kernel: [  305.188063] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  305.188071] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  305.290945] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  305.344070] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  305.344082] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  305.446943] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  305.500047] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  305.500058] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  305.602967] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  305.656090] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> NetworkManager[725]: <info> (wlan0): device state change: 3 -> 2 (reason 0)
> NetworkManager[725]: <info> (wlan0): deactivating device (reason: 0).
> NetworkManager[725]: <info> (wlan0): taking down device.
> kernel: [  310.887530] net_ratelimit: 29 callbacks suppressed
> kernel: [  310.887535] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
> kernel: [  310.990264] ath5k phy0: (ath5k_stop_hw:2619): putting device to sleep
> kernel: [  310.990554] ath5k phy0: (ath5k_rfkill_enable:51): rfkill enable (gpio:0 polarity:0)
> NetworkManager[725]: <info> (wlan0): bringing up device.
> kernel: [  315.755891] ath5k phy0: (ath5k_init_hw:2522): mode 2
> kernel: [  315.755903] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
> kernel: [  315.756624] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  315.760236] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  315.760474] ath5k phy0: (ath5k_rfkill_disable:42): rfkill disable (gpio:0 polarity:0)
> kernel: [  315.762566] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2412 MHz)
> kernel: [  315.762574] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  315.764972] ADDRCONF(NETDEV_UP): wlan0: link is not ready
> NetworkManager[725]: <info> (wlan0): supplicant interface state:  starting -> ready
> NetworkManager[725]: <info> (wlan0): device state change: 2 -> 3 (reason 42)
> wpa_supplicant[745]: Failed to initiate AP scan.
> kernel: [  316.036068] net_ratelimit: 8 callbacks suppressed
> kernel: [  316.036080] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  316.036089] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  316.140039] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  316.196067] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  316.196079] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  316.298940] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  316.352063] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> kernel: [  316.352071] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  316.455003] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  316.508080] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2432 -> 2437 MHz)
> kernel: [  336.188067] net_ratelimit: 26 callbacks suppressed
> kernel: [  336.188080] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  336.188088] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  336.290966] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  336.344059] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  336.344068] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  336.446912] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  336.500068] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  336.500077] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  336.602937] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  336.656058] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
> kernel: [  366.188084] net_ratelimit: 29 callbacks suppressed
> kernel: [  366.188097] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
> kernel: [  366.188105] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  366.290999] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  366.344099] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
> kernel: [  366.344112] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  366.447030] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  366.500094] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
> kernel: [  366.500106] ath5k phy0: (ath5k_reset:2648): resetting
> kernel: [  366.603008] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
> kernel: [  366.656103] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 -> 2432 MHz)
>
>

Hmm I don't see any errors from reset/phy code, can you disable
Network Manager/wpa-supplicant and test connection on an open network
using iw ? It 'll give us a better picture...

If iw doesn't return any scan results we are probably hitting a PHY/RF
error specific to your device (not all vendors follow the reference
design). Maybe we should follow a blacklist/whitelist approach for
this feature.

-- 
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick

^ permalink raw reply

* Re: ath5k regression associating with APs in 2.6.38
From: Seth Forshee @ 2011-05-05 14:54 UTC (permalink / raw)
  To: Nick Kossifidis
  Cc: John W. Linville, Jiri Slaby, Luis R. Rodriguez, Bob Copeland,
	linux-wireless, ath5k-devel, netdev, linux-kernel
In-Reply-To: <BANLkTinkiTQU2k7vBEc0JPGa01AUVCvp2Q@mail.gmail.com>

On Thu, May 05, 2011 at 05:30:42PM +0300, Nick Kossifidis wrote:
> Hmm I don't see any errors from reset/phy code, can you disable
> Network Manager/wpa-supplicant and test connection on an open network
> using iw ? It 'll give us a better picture...
> 
> If iw doesn't return any scan results we are probably hitting a PHY/RF
> error specific to your device (not all vendors follow the reference
> design). Maybe we should follow a blacklist/whitelist approach for
> this feature.

Will do. I just got another log from my tester, which is more typical of
what he's been getting. I've pasted a portion of it below. The full log
can be viewed at

https://launchpadlibrarian.net/71137619/20110504_020639rc6%23201105050227_boot4_syslog

Thanks,
Seth


May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): new 802.11 WiFi device (driver: 'ath5k' ifindex: 3)
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): exported as /org/freedesktop/NetworkManager/Devices/1
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): now managed
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 1 -> 2 (reason 2)
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): bringing up device.
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): preparing device.
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): deactivating device (reason: 2).
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: supplicant_interface_acquire: assertion `mgr_state == NM_SUPPLICANT_MANAGER_STATE_IDLE' failed
May  5 08:57:16 AcerAspire5100 kernel: [   25.844302] ADDRCONF(NETDEV_UP): wlan0: link is not ready
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> modem-manager is now available
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <warn> bluez error getting default adapter: The name org.bluez was not provided by any .service files
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> Trying to start the supplicant...
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant manager state:  down -> idle
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 2 -> 3 (reason 0)
May  5 08:57:16 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant interface state:  starting -> ready
...
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) starting connection 'Auto aureola'
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 3 -> 4 (reason 0)
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 4 -> 5 (reason 0)
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0/wireless): access point 'Auto aureola' has security, but secrets are required.
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 5 -> 6 (reason 0)
May  5 08:57:38 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 6 -> 4 (reason 0)
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> (wlan0): device state change: 4 -> 5 (reason 0)
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0/wireless): connection 'Auto aureola' has security, and secrets exist.  No new secrets needed.
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Config: added 'ssid' value 'aureola'
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Config: added 'scan_ssid' value '1'
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Config: added 'key_mgmt' value 'WPA-PSK'
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Config: added 'psk' value '<omitted>'
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: nm_setting_802_1x_get_pkcs11_engine_path: assertion `NM_IS_SETTING_802_1X (setting)' failed
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: nm_setting_802_1x_get_pkcs11_module_path: assertion `NM_IS_SETTING_802_1X (setting)' failed
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> Config: set interface ap_scan to 1
May  5 08:57:39 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant connection state:  inactive -> scanning
May  5 08:57:41 AcerAspire5100 wpa_supplicant[734]: Trying to associate with c0:3f:0e:b9:f3:b2 (SSID='aureola' freq=2452 MHz)
May  5 08:57:41 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant connection state:  scanning -> associating
May  5 08:57:41 AcerAspire5100 kernel: [   51.261113] wlan0: direct probe to c0:3f:0e:b9:f3:b2 (try 1/3)
May  5 08:57:41 AcerAspire5100 kernel: [   51.460049] wlan0: direct probe to c0:3f:0e:b9:f3:b2 (try 2/3)
May  5 08:57:41 AcerAspire5100 kernel: [   51.660091] wlan0: direct probe to c0:3f:0e:b9:f3:b2 (try 3/3)
May  5 08:57:42 AcerAspire5100 kernel: [   51.860048] wlan0: direct probe to c0:3f:0e:b9:f3:b2 timed out
May  5 08:57:51 AcerAspire5100 wpa_supplicant[734]: Authentication with c0:3f:0e:b9:f3:b2 timed out.
May  5 08:57:51 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant connection state:  associating -> disconnected
May  5 08:57:51 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant connection state:  disconnected -> scanning
May  5 08:57:51 AcerAspire5100 kernel: [   61.396045] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2452 -> 2412 MHz)
May  5 08:57:51 AcerAspire5100 kernel: [   61.396051] ath5k phy0: (ath5k_reset:2648): resetting
May  5 08:57:51 AcerAspire5100 kernel: [   61.397135] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
May  5 08:57:51 AcerAspire5100 kernel: [   61.452053] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 -> 2417 MHz)
May  5 08:57:51 AcerAspire5100 kernel: [   61.452059] ath5k phy0: (ath5k_reset:2648): resetting
May  5 08:57:51 AcerAspire5100 kernel: [   61.453143] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
May  5 08:57:51 AcerAspire5100 kernel: [   61.508053] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 -> 2422 MHz)
May  5 08:57:51 AcerAspire5100 kernel: [   61.508059] ath5k phy0: (ath5k_reset:2648): resetting
May  5 08:57:51 AcerAspire5100 kernel: [   61.509143] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
May  5 08:57:51 AcerAspire5100 kernel: [   61.564045] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 -> 2427 MHz)
May  5 08:57:52 AcerAspire5100 wpa_supplicant[734]: Trying to associate with c0:3f:0e:b9:f3:b2 (SSID='aureola' freq=2452 MHz)
May  5 08:57:52 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant connection state:  scanning -> associating
May  5 08:57:52 AcerAspire5100 kernel: [   62.364741] wlan0: direct probe to c0:3f:0e:b9:f3:b2 (try 1/3)
May  5 08:57:52 AcerAspire5100 kernel: [   62.564061] wlan0: direct probe to c0:3f:0e:b9:f3:b2 (try 2/3)
May  5 08:57:53 AcerAspire5100 kernel: [   62.764058] wlan0: direct probe to c0:3f:0e:b9:f3:b2 (try 3/3)
May  5 08:57:53 AcerAspire5100 kernel: [   62.964061] wlan0: direct probe to c0:3f:0e:b9:f3:b2 timed out
May  5 08:58:02 AcerAspire5100 wpa_supplicant[734]: Authentication with c0:3f:0e:b9:f3:b2 timed out.
May  5 08:58:02 AcerAspire5100 NetworkManager[703]: <info> (wlan0): supplicant connection state:  associating -> disconnected

^ permalink raw reply

* Re: ARM, AF_PACKET: caching problems on Marvell Kirkwood
From: Eric Dumazet @ 2011-05-05 14:56 UTC (permalink / raw)
  To: Phil Sutter
  Cc: linux-arm-kernel, netdev, ne, Johann Baudy, Lennert Buytenhek,
	Nicolas Pitre
In-Reply-To: <20110505141107.GC30443@orbit.nwl.cc>

Le jeudi 05 mai 2011 à 16:11 +0200, Phil Sutter a écrit :
> Hi,
> 
> Hasn't anyone experienced this bug but me? Can anyone reproduce the
> described behaviour on his Kirkwood-based (or even generic ARM) machine?
> I am still not sure if this is a problem of just my CPU or common
> amongst Kirkwood/VIPT/ARM machines.
> 
> My workaround looks like this:
> | diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> | index b5362e9..0672f50 100644
> | --- a/net/packet/af_packet.c
> | +++ b/net/packet/af_packet.c
> | @@ -1298,10 +1298,13 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
> |  {
> |         struct sock *sk = sock->sk;
> |         struct packet_sock *po = pkt_sk(sk);
> | -       if (po->tx_ring.pg_vec)
> | -               return tpacket_snd(po, msg);
> | -       else
> | -               return packet_snd(sock, msg, len);
> | +       int rc;
> | +
> | +       flush_cache_all();
> | +       rc = po->tx_ring.pg_vec ? tpacket_snd(po, msg) :
> | +                       packet_snd(sock, msg, len);
> | +       flush_cache_all();
> | +       return rc;
> |  }
> |  
> |  /*
> 
> Greetings, Phil
> 
> (Full-quoting here because I've added the TX ring author and the Kirkwood
> maintainers to Cc.)
> 
> On Fri, Apr 08, 2011 at 03:06:43PM +0200, Phil Sutter wrote:
> > Dear lists,
> > 
> > I am experiencing severe caching issues using the TX_RING feature of
> > AF_PACKET on a Kirkwood-based system (i.e., OpenRD). This may likely be
> > a bug of the CPU/SoC itself, at least it reacts a bit picky when using
> > the preload data instruction (pld) in rather useless cases (but that's a
> > different story).
> > 
> > There is simple testing code at the end of this email, effectively just
> > preparing a packet in the TX_RING and triggering it's delivery once per
> > second. The experienced symptom is that sporadically nothing goes out in
> > one iteration, and two packets in the following one.
> > 
> > It looks like the kernel doesn't get the changed value of tp_status in
> > time, although userspace sees the correct value. Note that moving the
> > sleep(1) from the end of the loop to just before calling sendto() fixes
> > the problem.
> > 
> > Another (more useful) workaround is to call flush_cache_all() at the
> > beginning of packet_sendmsg() in net/packet/af_packet.c. I was not able
> > to fix this with some more specific flushing at that place. Anyway, the
> > call to flush_dcache_page() from __packet_get_status() in the same
> > source file is meant to do the trick I guess. But somehow doesn't.
> > 
> > Feedback regardles of which kind is highly appreciated, of course!
> > 
> > Greetings, Phil
> > 
> > ------------------[start of packet_mmap_test.c]--------------------
> > #include <stdint.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <string.h>
> > #include <linux/if_ether.h>
> > #include <linux/if_packet.h>
> > #include <net/if.h>
> > #include <sys/ioctl.h>
> > #include <sys/mman.h>
> > #include <sys/socket.h>
> > #include <sys/types.h>
> > 
> > #define PERROR_EXIT(rc, mesg) { \
> > 	perror(mesg); \
> > 	return rc; \
> > }
> > 
> > int main(void)
> > {
> > 	uint32_t size;
> > 	struct sockaddr_ll sa;
> > 	struct ifreq ifr;
> > 	int index;
> > 	int tmp;
> > 	int fd;
> > 	struct tpacket_req packet_req;
> > 	struct tpacket2_hdr * ps_header_start, *ps_header;
> > 
> > 	if ((fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL))) < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "socket");
> > 
> > 	/* retrieve eth0's interface index number */
> > 	strncpy (ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));
> > 	if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "ioctl(SIOCGIFINDEX)");
> > 
> > 	/* set sockaddr info */
> > 	memset(&sa, 0, sizeof(sa));
> > 	sa.sll_family = AF_PACKET;
> > 	sa.sll_protocol = ETH_P_ALL;
> > 	sa.sll_ifindex = ifr.ifr_ifindex;
> > 
> > 	/* bind port */
> > 	if (bind(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "bind()");
> > 
> > 	tmp = TPACKET_V2;
> > 	if (setsockopt(fd, SOL_PACKET, PACKET_VERSION, &tmp, sizeof(tmp)) < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "setsockopt(PACKET_VERSION)");
> > 
> > 	/* set packet loss option */
> > 	tmp = 1;
> > 	if (setsockopt(fd, SOL_PACKET, PACKET_LOSS, &tmp, sizeof(tmp)) < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "setsockopt(PACKET_LOSS)");
> > 
> > 	/* prepare Tx ring request */
> > 	packet_req.tp_block_size = 1024 * 8;
> > 	packet_req.tp_frame_size = 1024 * 8;
> > 	packet_req.tp_block_nr = 1024;
> > 	packet_req.tp_frame_nr = 1024;
> > 
> > 	/* send TX ring request */
> > 	if (setsockopt(fd, SOL_PACKET, PACKET_TX_RING,
> > 	               &packet_req, sizeof(packet_req)) < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "setsockopt: PACKET_TX_RING");
> > 
> > 	/* calculate memory to mmap in the kernel */
> > 	size = packet_req.tp_block_size * packet_req.tp_block_nr;
> > 
> > 	/* mmap Tx ring buffers memory */
> > 	ps_header_start = mmap(0, size,
> > 			PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
> > 	if (ps_header_start < 0)
> > 		PERROR_EXIT(EXIT_FAILURE, "mmap");
> > 
> > 	/* fill peer sockaddr for SOCK_DGRAM */
> > 	sa.sll_family = AF_PACKET;
> > 	sa.sll_protocol = htons(ETH_P_IP);
> > 	sa.sll_ifindex = ifr.ifr_ifindex;
> > 	sa.sll_halen = ETH_ALEN;
> > 	memset(&sa.sll_addr, 0xff, ETH_ALEN);
> > 
> > 	ps_header = ps_header_start;
> > 	while (1) {
> > 		int sendlen, j;
> > 
> > 		char *data = (void*)ps_header + TPACKET_HDRLEN
> > 		              - sizeof(struct sockaddr_ll);
> > 
> > 		switch((volatile uint32_t)ps_header->tp_status)
> > 		{
> > 		case TP_STATUS_AVAILABLE:
> > 			memset(data, 0x23, 150);
> > 			break;
> > 
> > 		case TP_STATUS_WRONG_FORMAT:
> > 			printf("An error has occured during transfer\n");
> > 			exit(EXIT_FAILURE);
> > 			break;
> > 
> > 		default:
> > 			printf("Buffer is not available, aborting\n");
> > 			exit(1);
> > 			break;
> > 		}
> > 		ps_header->tp_len = 150;
> > 		ps_header->tp_status = TP_STATUS_SEND_REQUEST;
> > 
> > 		sendlen = sendto(fd, NULL, 0, 0,
> > 				(struct sockaddr *)&sa, sizeof(sa));
> > 		if (sendlen < 0)
> > 			perror("sendto");
> > 		else if (sendlen == 0)
> > 			printf("sendto(): nothing sent!\n");
> > 		else
> > 			printf("sendto(): sent %d bytes out\n", sendlen);
> > 
> > #define ST_IS(x) ((volatile uint32_t)ps_header->tp_status == x)
> > 		printf("tp_status after sending: %s\n",
> > 				ST_IS(TP_STATUS_AVAILABLE) ? "AVAILABLE" :
> > 				ST_IS(TP_STATUS_SEND_REQUEST) ? "SEND_REQUEST" :
> > 				ST_IS(TP_STATUS_WRONG_FORMAT) ? "WRONG_FORMAT" :
> > 				"unknown");
> > #undef ST_IS
> > 
> > 		ps_header = (void *)ps_header + packet_req.tp_frame_size;
> > 		if (ps_header >= ps_header_start + size)
> > 			ps_header = ps_header_start;
> > 
> > 		sleep(1);
> > 	}
> > 	return 0;
> > }
> > --------------------[end of packet_mmap_test.c]--------------------

Hi Phil

I assume you use latest linux-2.6 or net-next-2.6 ?

Could you try to force vmalloc() use ?

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index b5362e9..0b5a89c 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2383,7 +2383,7 @@ static inline char *alloc_one_pg_vec_page(unsigned long order)
 	gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP |
 			  __GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY;
 
-	buffer = (char *) __get_free_pages(gfp_flags, order);
+	buffer = NULL;
 
 	if (buffer)
 		return buffer;



^ permalink raw reply related

* Re: ath5k regression associating with APs in 2.6.38
From: Justin P. Mattock @ 2011-05-05 15:01 UTC (permalink / raw)
  To: Nick Kossifidis
  Cc: John W. Linville, Jiri Slaby, Luis R. Rodriguez, Bob Copeland,
	linux-wireless, ath5k-devel, netdev, linux-kernel
In-Reply-To: <BANLkTinkiTQU2k7vBEc0JPGa01AUVCvp2Q@mail.gmail.com>

On 05/05/2011 07:30 AM, Nick Kossifidis wrote:
> 2011/5/5 Seth Forshee<seth.forshee@canonical.com>:
>> On Wed, May 04, 2011 at 11:09:03PM +0300, Nick Kossifidis wrote:
>>> 2011/5/4 Seth Forshee<seth.forshee@canonical.com>:
>>>> On Wed, May 04, 2011 at 01:27:17PM -0400, John W. Linville wrote:
>>>>> On Wed, May 04, 2011 at 10:38:19AM -0500, Seth Forshee wrote:
>>>>>> I've been investigating some reports of a regression in associating with
>>>>>> APs with AR2413 in 2.6.38. Association repeatedly fails with some
>>>>>> "direct probe to x timed out" messages (see syslog excerpt below),
>>>>>> although it will generally associate eventually, after many tries.
>>>>>>
>>>>>> Bisection identifies 8aec7af (ath5k: Support synth-only channel change
>>>>>> for AR2413/AR5413) as offending commit. Prior to this commit there are
>>>>>> no direct probe messages at all in the logs. I've also found that
>>>>>> forcing fast to false at the top of ath5k_hw_reset() fixes the issue.
>>>>>> I'm not sure what the connection is between this commit and the
>>>>>> timeouts. Any suggestions?
>>>>>
>>>>> Have you tried reverting that commit on top of 2.6.38?  Can you
>>>>> recreate the issue with 2.6.39-rc6 (or later)?
>>>>
>>>> I started to revert that commit, but it wasn't straight-forward due to
>>>> later changes. Forcing fast to false in ath5k_hw_reset() acts as a
>>>> functional revert of sorts since that should force it back to a full
>>>> reset for all channel changes, and it's much simpler than working out
>>>> the right way to revert the commit. I think the results suggest strongly
>>>> that a revert is likely to fix the problem. I can finish the work to
>>>> revert if you'd still like to see the results.
>>>>
>>>> Testing a previous .39-rc kernel still exhibited the failure. I don't
>>>> recall which one it was and apparently forgot to make note of it. I'll
>>>> request testing against rc6.
>>>>
>>>> Thanks,
>>>> Seth
>>>>
>>>
>>> Do you get scan results ?
>>> Can you enable ATH5K_DEBUG_RESET and see what you get ?
>>
>> 2.6.39-rc6 still fails. A more comprehensive log with ATH5K_DEBUG_RESET
>> enabled is below.
>>
>> Scanning looks to be failing according to this log. I was thinking that
>> I saw successfull scans in some of the previous logs, but I'll have to
>> go back and check to be sure.
>>
>> Thanks,
>> Seth
>>
>>
>> kernel: [   23.421242] ath5k 0000:06:02.0: PCI INT A ->  GSI 22 (level, low) ->  IRQ 22
>> kernel: [   23.421312] ath5k 0000:06:02.0: registered as 'phy0'
>> kernel: [   24.132959] ath: EEPROM regdomain: 0x63
>> kernel: [   24.132962] ath: EEPROM indicates we should expect a direct regpair map
>> kernel: [   24.132967] ath: Country alpha2 being used: 00
>> kernel: [   24.132969] ath: Regpair used: 0x63
>> kernel: [   24.136125] cfg80211: Updating information on frequency 2412 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136131] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136134] cfg80211: Updating information on frequency 2417 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136137] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136140] cfg80211: Updating information on frequency 2422 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136143] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136146] cfg80211: Updating information on frequency 2427 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136149] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136151] cfg80211: Updating information on frequency 2432 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136155] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136157] cfg80211: Updating information on frequency 2437 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136160] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136163] cfg80211: Updating information on frequency 2442 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136166] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136168] cfg80211: Updating information on frequency 2447 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136172] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136174] cfg80211: Updating information on frequency 2452 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136177] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136180] cfg80211: Updating information on frequency 2457 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136183] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136186] cfg80211: Updating information on frequency 2462 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136189] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136191] cfg80211: Updating information on frequency 2467 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136195] cfg80211: 2457000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136197] cfg80211: Updating information on frequency 2472 MHz for a 20 MHz width channel with regulatory rule:
>> kernel: [   24.136200] cfg80211: 2457000 KHz - 2482000 KHz @  KHz), (N/A mBi, 2000 mBm)
>> kernel: [   24.136203] cfg80211: Disabling freq 2484 MHz as custom regd has no rule that fits a 20 MHz wide channel
>> kernel: [   24.136404] cfg80211: Ignoring regulatory request Set by core since the driver uses its own custom regulatory domain
>> kernel: [   24.393924] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
>> kernel: [   24.394588] ath5k phy0: Atheros AR2413 chip found (MAC: 0x78, PHY: 0x45)
>> ...
>> NetworkManager[725]:<info>  (wlan0): driver supports SSID scans (scan_capa 0x01).
>> NetworkManager[725]:<info>  (wlan0): new 802.11 WiFi device (driver: 'ath5k' ifindex: 3)
>> NetworkManager[725]:<info>  (wlan0): exported as /org/freedesktop/NetworkManager/Devices/1
>> NetworkManager[725]:<info>  (wlan0): now managed
>> NetworkManager[725]:<info>  (wlan0): device state change: 1 ->  2 (reason 2)
>> NetworkManager[725]:<info>  (wlan0): bringing up device.
>> NetworkManager[725]:<info>  (wlan0): preparing device.
>> NetworkManager[725]:<info>  (wlan0): deactivating device (reason: 2).
>> NetworkManager[725]: supplicant_interface_acquire: assertion `mgr_state == NM_SUPPLICANT_MANAGER_STATE_IDLE' failed
>> kernel: [   25.149294] ADDRCONF(NETDEV_UP): wlan0: link is not ready
>> ...
>> NetworkManager[725]:<info>  Trying to start the supplicant...
>> ...
>> NetworkManager[725]:<info>  (wlan0): supplicant manager state:  down ->  idle
>> NetworkManager[725]:<info>  (wlan0): device state change: 2 ->  3 (reason 0)
>> NetworkManager[725]:<info>  (wlan0): supplicant interface state:  starting ->  ready
>> ...
>> NetworkManager[725]:<info>  (wlan0): device state change: 3 ->  2 (reason 0)
>> NetworkManager[725]:<info>  (wlan0): deactivating device (reason: 0).
>> NetworkManager[725]:<info>  (wlan0): taking down device.
>> NetworkManager[725]:<info>  (wlan0): bringing up device.
>> kernel: [  104.430292] ath5k phy0: (ath5k_init_hw:2522): mode 2
>> kernel: [  104.430297] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
>> kernel: [  104.431000] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  104.434475] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  104.434683] ath5k phy0: (ath5k_rfkill_disable:42): rfkill disable (gpio:0 polarity:0)
>> kernel: [  104.435759] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2412 MHz)
>> kernel: [  104.435762] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  104.436845] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  104.437191] ath5k phy0: (ath5k_conf_tx:602): Configure tx [queue 0],  aifs: 2, cw_min: 7, cw_max: 15, txop: 102
>> kernel: [  104.437212] ath5k phy0: (ath5k_conf_tx:602): Configure tx [queue 1],  aifs: 2, cw_min: 15, cw_max: 31, txop: 188
>> kernel: [  104.438337] ADDRCONF(NETDEV_UP): wlan0: link is not ready
>> NetworkManager[725]:<info>  (wlan0): supplicant interface state:  starting ->  ready
>> NetworkManager[725]:<info>  (wlan0): device state change: 2 ->  3 (reason 42)
>> wpa_supplicant[745]: Failed to initiate AP scan.
>> kernel: [  125.188087] net_ratelimit: 41 callbacks suppressed
>> kernel: [  125.188100] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  125.188109] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  125.291007] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  125.344076] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  125.344090] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  125.447014] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  125.500078] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  125.500091] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  125.602999] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  125.656070] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> kernel: [  155.188052] net_ratelimit: 29 callbacks suppressed
>> kernel: [  155.188058] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  155.188061] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  155.290844] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  155.344032] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  155.344038] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  155.446810] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  155.500031] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  155.500036] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  155.602811] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  155.656033] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> kernel: [  195.184088] net_ratelimit: 29 callbacks suppressed
>> kernel: [  195.184102] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  195.184110] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  195.287022] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  195.340066] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  195.340079] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  195.442967] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  195.496076] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  195.496088] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  195.599009] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  195.652078] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> kernel: [  245.188077] net_ratelimit: 29 callbacks suppressed
>> kernel: [  245.188091] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  245.188100] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  245.290997] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  245.344084] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  245.344092] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  245.446882] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  245.500053] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  245.500058] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  245.602808] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  245.656046] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> kernel: [  305.188050] net_ratelimit: 29 callbacks suppressed
>> kernel: [  305.188063] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  305.188071] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  305.290945] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  305.344070] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  305.344082] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  305.446943] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  305.500047] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  305.500058] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  305.602967] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  305.656090] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> NetworkManager[725]:<info>  (wlan0): device state change: 3 ->  2 (reason 0)
>> NetworkManager[725]:<info>  (wlan0): deactivating device (reason: 0).
>> NetworkManager[725]:<info>  (wlan0): taking down device.
>> kernel: [  310.887530] net_ratelimit: 29 callbacks suppressed
>> kernel: [  310.887535] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
>> kernel: [  310.990264] ath5k phy0: (ath5k_stop_hw:2619): putting device to sleep
>> kernel: [  310.990554] ath5k phy0: (ath5k_rfkill_enable:51): rfkill enable (gpio:0 polarity:0)
>> NetworkManager[725]:<info>  (wlan0): bringing up device.
>> kernel: [  315.755891] ath5k phy0: (ath5k_init_hw:2522): mode 2
>> kernel: [  315.755903] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
>> kernel: [  315.756624] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  315.760236] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  315.760474] ath5k phy0: (ath5k_rfkill_disable:42): rfkill disable (gpio:0 polarity:0)
>> kernel: [  315.762566] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2412 MHz)
>> kernel: [  315.762574] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  315.764972] ADDRCONF(NETDEV_UP): wlan0: link is not ready
>> NetworkManager[725]:<info>  (wlan0): supplicant interface state:  starting ->  ready
>> NetworkManager[725]:<info>  (wlan0): device state change: 2 ->  3 (reason 42)
>> wpa_supplicant[745]: Failed to initiate AP scan.
>> kernel: [  316.036068] net_ratelimit: 8 callbacks suppressed
>> kernel: [  316.036080] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  316.036089] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  316.140039] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  316.196067] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  316.196079] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  316.298940] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  316.352063] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> kernel: [  316.352071] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  316.455003] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  316.508080] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2432 ->  2437 MHz)
>> kernel: [  336.188067] net_ratelimit: 26 callbacks suppressed
>> kernel: [  336.188080] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  336.188088] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  336.290966] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  336.344059] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  336.344068] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  336.446912] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  336.500068] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  336.500077] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  336.602937] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  336.656058] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>> kernel: [  366.188084] net_ratelimit: 29 callbacks suppressed
>> kernel: [  366.188097] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2412 ->  2417 MHz)
>> kernel: [  366.188105] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  366.290999] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  366.344099] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2417 ->  2422 MHz)
>> kernel: [  366.344112] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  366.447030] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  366.500094] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2422 ->  2427 MHz)
>> kernel: [  366.500106] ath5k phy0: (ath5k_reset:2648): resetting
>> kernel: [  366.603008] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32 rx_bufsize 2368
>> kernel: [  366.656103] ath5k phy0: (ath5k_chan_set:434): channel set, resetting (2427 ->  2432 MHz)
>>
>>
>
> Hmm I don't see any errors from reset/phy code, can you disable
> Network Manager/wpa-supplicant and test connection on an open network
> using iw ? It 'll give us a better picture...
>
> If iw doesn't return any scan results we are probably hitting a PHY/RF
> error specific to your device (not all vendors follow the reference
> design). Maybe we should follow a blacklist/whitelist approach for
> this feature.
>

yeah Im getting this over here with my macbook pro. all of a sudden 
internet craps out, unable to reconnect.. reboot is the only way to get 
back online.
dmesg here:
http://fpaste.org/mwGn/

I can try bisecting, but might take a while due to this occuring every 
few days or so.

Justin P. Mattock

^ permalink raw reply

* [PATCH 0/3] virtio and vhost-net performance enhancements
From: Michael S. Tsirkin @ 2011-05-05 15:07 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rusty Russell, Carsten Otte, Christian Borntraeger, linux390,
	Martin Schwidefsky, Heiko Carstens, Shirley Ma, lguest,
	linux-kernel, virtualization, netdev, linux-s390, kvm,
	Krishna Kumar, Tom Lendacky, steved, habanero
In-Reply-To: <cover.1304541918.git.mst@redhat.com>

Here are a couple of minor fixes suggested on list.
Applies on top of the previous patchset.

As before result pushed here:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost-net-next-event-idx-v1

Michael S. Tsirkin (3):
  virtio: fix avail event support
  virtio_ring: check used_event offset
  virtio_ring: need_event api comment fix

 drivers/virtio/virtio_ring.c |    2 +-
 include/linux/virtio_ring.h  |   10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

-- 
1.7.5.53.gc233e

^ permalink raw reply

* [PATCH 1/3] virtio: fix avail event support
From: Michael S. Tsirkin @ 2011-05-05 15:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rusty Russell, Carsten Otte, Christian Borntraeger, linux390,
	Martin Schwidefsky, Heiko Carstens, Shirley Ma, lguest,
	linux-kernel, virtualization, netdev, linux-s390, kvm,
	Krishna Kumar, Tom Lendacky, steved, habanero
In-Reply-To: <cover.1304605816.git.mst@redhat.com>

make valid flag false, not true, on overrun

Reported-by: Tom Lendacky <tahm@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/virtio/virtio_ring.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 57bf9d5..0ea0781 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -242,7 +242,7 @@ add_head:
 	 * kicked_avail index we stored. TODO: make sure all drivers
 	 * kick at least once in 2^16 and remove this. */
 	if (unlikely(vq->vring.avail->idx == vq->kicked_avail))
-		vq->kicked_avail_valid = true;
+		vq->kicked_avail_valid = false;
 
 	pr_debug("Added buffer head %i to %p\n", head, vq);
 	END_USE(vq);
-- 
1.7.5.53.gc233e

^ permalink raw reply related

* [PATCH 2/3] virtio_ring: check used_event offset
From: Michael S. Tsirkin @ 2011-05-05 15:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rusty Russell, Carsten Otte, Christian Borntraeger, linux390,
	Martin Schwidefsky, Heiko Carstens, Shirley Ma, lguest,
	linux-kernel, virtualization, netdev, linux-s390, kvm,
	Krishna Kumar, Tom Lendacky, steved, habanero
In-Reply-To: <cover.1304605816.git.mst@redhat.com>

Nothing's wrong with vring_size as is, but it's nice
to check that the new field in the avail ring
won't overlow into the used ring.

Reported-by: Tom Lendacky <tahm@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/linux/virtio_ring.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 2a3b0ea..089cbf2 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -119,7 +119,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
 
 static inline unsigned vring_size(unsigned int num, unsigned long align)
 {
-	return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
+#ifdef __KERNEL__
+	/* Older versions did not have used_event field at the end of the
+	 * avail ring. Used ring offset must be compatible with such devices. */
+	size_t s = sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num);
+	BUG_ON(ALIGN(s, align) != ALIGN(s + sizeof(__u16), align));
+#endif
+	return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
 		 + align - 1) & ~(align - 1))
 		+ sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
 }
-- 
1.7.5.53.gc233e

^ permalink raw reply related

* [PATCH 3/3] virtio_ring: need_event api comment fix
From: Michael S. Tsirkin @ 2011-05-05 15:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rusty Russell, Carsten Otte, Christian Borntraeger, linux390,
	Martin Schwidefsky, Heiko Carstens, Shirley Ma, lguest,
	linux-kernel, virtualization, netdev, linux-s390, kvm,
	Krishna Kumar, Tom Lendacky, steved, habanero
In-Reply-To: <cover.1304605816.git.mst@redhat.com>

fix typo in a comment: size -> side

Reported-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/linux/virtio_ring.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 089cbf2..0a45c6e 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -131,7 +131,7 @@ static inline unsigned vring_size(unsigned int num, unsigned long align)
 }
 
 /* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */
-/* Assuming a given event_idx value from the other size, if
+/* Assuming a given event_idx value from the other side, if
  * we have just incremented index from old to new_idx,
  * should we trigger an event? */
 static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
-- 
1.7.5.53.gc233e

^ permalink raw reply related

* Re: ath5k regression associating with APs in 2.6.38
From: Nick Kossifidis @ 2011-05-05 15:15 UTC (permalink / raw)
  To: Justin P. Mattock
  Cc: John W. Linville, Jiri Slaby, Luis R. Rodriguez, Bob Copeland,
	linux-wireless, ath5k-devel, netdev, linux-kernel
In-Reply-To: <4DC2BBBE.1090607@gmail.com>

2011/5/5 Justin P. Mattock <justinmattock@gmail.com>:
> On 05/05/2011 07:30 AM, Nick Kossifidis wrote:
>>
>> 2011/5/5 Seth Forshee<seth.forshee@canonical.com>:
>>>
>>> On Wed, May 04, 2011 at 11:09:03PM +0300, Nick Kossifidis wrote:
>>>>
>>>> 2011/5/4 Seth Forshee<seth.forshee@canonical.com>:
>>>>>
>>>>> On Wed, May 04, 2011 at 01:27:17PM -0400, John W. Linville wrote:
>>>>>>
>>>>>> On Wed, May 04, 2011 at 10:38:19AM -0500, Seth Forshee wrote:
>>>>>>>
>>>>>>> I've been investigating some reports of a regression in associating
>>>>>>> with
>>>>>>> APs with AR2413 in 2.6.38. Association repeatedly fails with some
>>>>>>> "direct probe to x timed out" messages (see syslog excerpt below),
>>>>>>> although it will generally associate eventually, after many tries.
>>>>>>>
>>>>>>> Bisection identifies 8aec7af (ath5k: Support synth-only channel
>>>>>>> change
>>>>>>> for AR2413/AR5413) as offending commit. Prior to this commit there
>>>>>>> are
>>>>>>> no direct probe messages at all in the logs. I've also found that
>>>>>>> forcing fast to false at the top of ath5k_hw_reset() fixes the issue.
>>>>>>> I'm not sure what the connection is between this commit and the
>>>>>>> timeouts. Any suggestions?
>>>>>>
>>>>>> Have you tried reverting that commit on top of 2.6.38?  Can you
>>>>>> recreate the issue with 2.6.39-rc6 (or later)?
>>>>>
>>>>> I started to revert that commit, but it wasn't straight-forward due to
>>>>> later changes. Forcing fast to false in ath5k_hw_reset() acts as a
>>>>> functional revert of sorts since that should force it back to a full
>>>>> reset for all channel changes, and it's much simpler than working out
>>>>> the right way to revert the commit. I think the results suggest
>>>>> strongly
>>>>> that a revert is likely to fix the problem. I can finish the work to
>>>>> revert if you'd still like to see the results.
>>>>>
>>>>> Testing a previous .39-rc kernel still exhibited the failure. I don't
>>>>> recall which one it was and apparently forgot to make note of it. I'll
>>>>> request testing against rc6.
>>>>>
>>>>> Thanks,
>>>>> Seth
>>>>>
>>>>
>>>> Do you get scan results ?
>>>> Can you enable ATH5K_DEBUG_RESET and see what you get ?
>>>
>>> 2.6.39-rc6 still fails. A more comprehensive log with ATH5K_DEBUG_RESET
>>> enabled is below.
>>>
>>> Scanning looks to be failing according to this log. I was thinking that
>>> I saw successfull scans in some of the previous logs, but I'll have to
>>> go back and check to be sure.
>>>
>>> Thanks,
>>> Seth
>>>
>>>
>>> kernel: [   23.421242] ath5k 0000:06:02.0: PCI INT A ->  GSI 22 (level,
>>> low) ->  IRQ 22
>>> kernel: [   23.421312] ath5k 0000:06:02.0: registered as 'phy0'
>>> kernel: [   24.132959] ath: EEPROM regdomain: 0x63
>>> kernel: [   24.132962] ath: EEPROM indicates we should expect a direct
>>> regpair map
>>> kernel: [   24.132967] ath: Country alpha2 being used: 00
>>> kernel: [   24.132969] ath: Regpair used: 0x63
>>> kernel: [   24.136125] cfg80211: Updating information on frequency 2412
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136131] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136134] cfg80211: Updating information on frequency 2417
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136137] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136140] cfg80211: Updating information on frequency 2422
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136143] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136146] cfg80211: Updating information on frequency 2427
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136149] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136151] cfg80211: Updating information on frequency 2432
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136155] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136157] cfg80211: Updating information on frequency 2437
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136160] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136163] cfg80211: Updating information on frequency 2442
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136166] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136168] cfg80211: Updating information on frequency 2447
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136172] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136174] cfg80211: Updating information on frequency 2452
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136177] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136180] cfg80211: Updating information on frequency 2457
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136183] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136186] cfg80211: Updating information on frequency 2462
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136189] cfg80211: 2402000 KHz - 2472000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136191] cfg80211: Updating information on frequency 2467
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136195] cfg80211: 2457000 KHz - 2482000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136197] cfg80211: Updating information on frequency 2472
>>> MHz for a 20 MHz width channel with regulatory rule:
>>> kernel: [   24.136200] cfg80211: 2457000 KHz - 2482000 KHz @  KHz), (N/A
>>> mBi, 2000 mBm)
>>> kernel: [   24.136203] cfg80211: Disabling freq 2484 MHz as custom regd
>>> has no rule that fits a 20 MHz wide channel
>>> kernel: [   24.136404] cfg80211: Ignoring regulatory request Set by core
>>> since the driver uses its own custom regulatory domain
>>> kernel: [   24.393924] ieee80211 phy0: Selected rate control algorithm
>>> 'minstrel_ht'
>>> kernel: [   24.394588] ath5k phy0: Atheros AR2413 chip found (MAC: 0x78,
>>> PHY: 0x45)
>>> ...
>>> NetworkManager[725]:<info>  (wlan0): driver supports SSID scans
>>> (scan_capa 0x01).
>>> NetworkManager[725]:<info>  (wlan0): new 802.11 WiFi device (driver:
>>> 'ath5k' ifindex: 3)
>>> NetworkManager[725]:<info>  (wlan0): exported as
>>> /org/freedesktop/NetworkManager/Devices/1
>>> NetworkManager[725]:<info>  (wlan0): now managed
>>> NetworkManager[725]:<info>  (wlan0): device state change: 1 ->  2 (reason
>>> 2)
>>> NetworkManager[725]:<info>  (wlan0): bringing up device.
>>> NetworkManager[725]:<info>  (wlan0): preparing device.
>>> NetworkManager[725]:<info>  (wlan0): deactivating device (reason: 2).
>>> NetworkManager[725]: supplicant_interface_acquire: assertion `mgr_state
>>> == NM_SUPPLICANT_MANAGER_STATE_IDLE' failed
>>> kernel: [   25.149294] ADDRCONF(NETDEV_UP): wlan0: link is not ready
>>> ...
>>> NetworkManager[725]:<info>  Trying to start the supplicant...
>>> ...
>>> NetworkManager[725]:<info>  (wlan0): supplicant manager state:  down ->
>>>  idle
>>> NetworkManager[725]:<info>  (wlan0): device state change: 2 ->  3 (reason
>>> 0)
>>> NetworkManager[725]:<info>  (wlan0): supplicant interface state:
>>>  starting ->  ready
>>> ...
>>> NetworkManager[725]:<info>  (wlan0): device state change: 3 ->  2 (reason
>>> 0)
>>> NetworkManager[725]:<info>  (wlan0): deactivating device (reason: 0).
>>> NetworkManager[725]:<info>  (wlan0): taking down device.
>>> NetworkManager[725]:<info>  (wlan0): bringing up device.
>>> kernel: [  104.430292] ath5k phy0: (ath5k_init_hw:2522): mode 2
>>> kernel: [  104.430297] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
>>> kernel: [  104.431000] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  104.434475] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  104.434683] ath5k phy0: (ath5k_rfkill_disable:42): rfkill
>>> disable (gpio:0 polarity:0)
>>> kernel: [  104.435759] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2412 MHz)
>>> kernel: [  104.435762] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  104.436845] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  104.437191] ath5k phy0: (ath5k_conf_tx:602): Configure tx
>>> [queue 0],  aifs: 2, cw_min: 7, cw_max: 15, txop: 102
>>> kernel: [  104.437212] ath5k phy0: (ath5k_conf_tx:602): Configure tx
>>> [queue 1],  aifs: 2, cw_min: 15, cw_max: 31, txop: 188
>>> kernel: [  104.438337] ADDRCONF(NETDEV_UP): wlan0: link is not ready
>>> NetworkManager[725]:<info>  (wlan0): supplicant interface state:
>>>  starting ->  ready
>>> NetworkManager[725]:<info>  (wlan0): device state change: 2 ->  3 (reason
>>> 42)
>>> wpa_supplicant[745]: Failed to initiate AP scan.
>>> kernel: [  125.188087] net_ratelimit: 41 callbacks suppressed
>>> kernel: [  125.188100] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  125.188109] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  125.291007] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  125.344076] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  125.344090] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  125.447014] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  125.500078] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  125.500091] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  125.602999] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  125.656070] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> kernel: [  155.188052] net_ratelimit: 29 callbacks suppressed
>>> kernel: [  155.188058] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  155.188061] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  155.290844] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  155.344032] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  155.344038] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  155.446810] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  155.500031] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  155.500036] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  155.602811] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  155.656033] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> kernel: [  195.184088] net_ratelimit: 29 callbacks suppressed
>>> kernel: [  195.184102] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  195.184110] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  195.287022] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  195.340066] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  195.340079] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  195.442967] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  195.496076] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  195.496088] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  195.599009] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  195.652078] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> kernel: [  245.188077] net_ratelimit: 29 callbacks suppressed
>>> kernel: [  245.188091] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  245.188100] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  245.290997] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  245.344084] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  245.344092] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  245.446882] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  245.500053] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  245.500058] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  245.602808] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  245.656046] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> kernel: [  305.188050] net_ratelimit: 29 callbacks suppressed
>>> kernel: [  305.188063] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  305.188071] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  305.290945] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  305.344070] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  305.344082] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  305.446943] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  305.500047] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  305.500058] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  305.602967] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  305.656090] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> NetworkManager[725]:<info>  (wlan0): device state change: 3 ->  2 (reason
>>> 0)
>>> NetworkManager[725]:<info>  (wlan0): deactivating device (reason: 0).
>>> NetworkManager[725]:<info>  (wlan0): taking down device.
>>> kernel: [  310.887530] net_ratelimit: 29 callbacks suppressed
>>> kernel: [  310.887535] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
>>> kernel: [  310.990264] ath5k phy0: (ath5k_stop_hw:2619): putting device
>>> to sleep
>>> kernel: [  310.990554] ath5k phy0: (ath5k_rfkill_enable:51): rfkill
>>> enable (gpio:0 polarity:0)
>>> NetworkManager[725]:<info>  (wlan0): bringing up device.
>>> kernel: [  315.755891] ath5k phy0: (ath5k_init_hw:2522): mode 2
>>> kernel: [  315.755903] ath5k phy0: (ath5k_stop_locked:2481): invalid 0
>>> kernel: [  315.756624] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  315.760236] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  315.760474] ath5k phy0: (ath5k_rfkill_disable:42): rfkill
>>> disable (gpio:0 polarity:0)
>>> kernel: [  315.762566] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2412 MHz)
>>> kernel: [  315.762574] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  315.764972] ADDRCONF(NETDEV_UP): wlan0: link is not ready
>>> NetworkManager[725]:<info>  (wlan0): supplicant interface state:
>>>  starting ->  ready
>>> NetworkManager[725]:<info>  (wlan0): device state change: 2 ->  3 (reason
>>> 42)
>>> wpa_supplicant[745]: Failed to initiate AP scan.
>>> kernel: [  316.036068] net_ratelimit: 8 callbacks suppressed
>>> kernel: [  316.036080] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  316.036089] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  316.140039] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  316.196067] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  316.196079] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  316.298940] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  316.352063] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> kernel: [  316.352071] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  316.455003] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  316.508080] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2432 ->  2437 MHz)
>>> kernel: [  336.188067] net_ratelimit: 26 callbacks suppressed
>>> kernel: [  336.188080] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  336.188088] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  336.290966] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  336.344059] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  336.344068] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  336.446912] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  336.500068] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  336.500077] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  336.602937] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  336.656058] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>> kernel: [  366.188084] net_ratelimit: 29 callbacks suppressed
>>> kernel: [  366.188097] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2412 ->  2417 MHz)
>>> kernel: [  366.188105] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  366.290999] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  366.344099] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2417 ->  2422 MHz)
>>> kernel: [  366.344112] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  366.447030] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  366.500094] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2422 ->  2427 MHz)
>>> kernel: [  366.500106] ath5k phy0: (ath5k_reset:2648): resetting
>>> kernel: [  366.603008] ath5k phy0: (ath5k_rx_start:1099): cachelsz 32
>>> rx_bufsize 2368
>>> kernel: [  366.656103] ath5k phy0: (ath5k_chan_set:434): channel set,
>>> resetting (2427 ->  2432 MHz)
>>>
>>>
>>
>> Hmm I don't see any errors from reset/phy code, can you disable
>> Network Manager/wpa-supplicant and test connection on an open network
>> using iw ? It 'll give us a better picture...
>>
>> If iw doesn't return any scan results we are probably hitting a PHY/RF
>> error specific to your device (not all vendors follow the reference
>> design). Maybe we should follow a blacklist/whitelist approach for
>> this feature.
>>
>
> yeah Im getting this over here with my macbook pro. all of a sudden internet
> craps out, unable to reconnect.. reboot is the only way to get back online.
> dmesg here:
> http://fpaste.org/mwGn/
>
> I can try bisecting, but might take a while due to this occuring every few
> days or so.
>
> Justin P. Mattock
>

[   26.219909] ath9k 0000:03:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17

Different card, different driver...

-- 
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick

^ permalink raw reply

* Re: [PATCH 0/4] [RFC] virtio-net: Improve small packet performance
From: Krishna Kumar2 @ 2011-05-05 15:27 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: davem, eric.dumazet, kvm, netdev, rusty
In-Reply-To: <20110505090439.GD17647@redhat.com>

"Michael S. Tsirkin" <mst@redhat.com> wrote on 05/05/2011 02:34:39 PM:

> > Do I need to apply all the patches and simply test?
> >
> > Thanks,
> >
> > - KK
>
> Exactly. You can also try to tune the threshold
> for interrupts as well.

I haven't tuned the threshhold, it is left it at 3/4. I ran
the new qemu/vhost/guest, and the results for 1K, 2K and 16K
are below. Note this is a different kernel version from my
earlier test results. So, f.e., BW1 represents 2.6.39-rc2,
the original kernel; while BW2 represents 2.6.37-rc5 (MST's
kernel). This also isn't with the fixes you have sent just
now. I will get a run with that either late tonight or
tomorrow.

________________________________________________________
                   I/O size: 1K
#     BW1     BW2 (%)        SD1       SD2 (%)
________________________________________________________
1     1723    3016 (75.0)    4.7       2.6 (-44.6)
2     3223    6712 (108.2)   18.0      7.1 (-60.5)
4     7223    8258 (14.3)    36.5      24.3 (-33.4)
8     8689    7943 (-8.5)    131.5     101.6 (-22.7)
16    8059    7398 (-8.2)    578.3     406.4 (-29.7)
32    7758    7208 (-7.0)    2281.4    1574.7 (-30.9)
64    7503    7155 (-4.6)    9734.0    6368.0 (-34.5)
96    7496    7078 (-5.5)    21980.9   15477.6 (-29.5)
128   7389    6900 (-6.6)    40467.5   26031.9 (-35.6)
________________________________________________________
Summary:     BW: (4.4)     SD: (-33.5)

________________________________________________________
                 I/O size: 2K
#     BW1     BW2 (%)        SD1       SD2 (%)
________________________________________________________
1     1608    4968 (208.9)   5.0       1.3 (-74.0)
2     3354    6974 (107.9)   18.6      4.9 (-73.6)
4     8234    8344 (1.3)     35.6      17.9 (-49.7)
8     8427    7818 (-7.2)    103.5     71.2 (-31.2)
16    7995    7491 (-6.3)    410.1     273.9 (-33.2)
32    7863    7149 (-9.0)    1678.6    1080.4 (-35.6)
64    7661    7092 (-7.4)    7245.3    4717.2 (-34.8)
96    7517    6984 (-7.0)    15711.2   9838.9 (-37.3)
128   7389    6851 (-7.2)    27121.6   18255.7 (-32.6)
________________________________________________________
Summary:     BW: (6.0)     SD: (-34.5)

________________________________________________________
                  I/O size: 16K
#     BW1     BW2 (%)        SD1       SD2 (%)
________________________________________________________
1     6684    7019 (5.0)     1.1       1.1 (0)
2     7674    7196 (-6.2)    5.0       4.8 (-4.0)
4     7358    8032 (9.1)     21.3      20.4 (-4.2)
8     7393    8015 (8.4)     82.7      82.0 (-.8)
16    7958    8366 (5.1)     283.2     310.7 (9.7)
32    7792    8113 (4.1)     1257.5    1363.0 (8.3)
64    7673    8040 (4.7)     5723.1    5812.4 (1.5)
96    7462    7883 (5.6)     12731.8   12119.8 (-4.8)
128   7338    7800 (6.2)     21331.7   21094.7 (-1.1)
________________________________________________________
Summary:     BW: (4.6)     SD: (-1.5)

Thanks,

- KK


^ permalink raw reply

* Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG
From: Michał Mirosław @ 2011-05-05 15:26 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: netdev, Ben Hutchings, herbert
In-Reply-To: <20110504181813.GA17547@redhat.com>

On Wed, May 04, 2011 at 09:18:14PM +0300, Michael S. Tsirkin wrote:
> BTW, I just noticed that net-next spits out
> many of the following when I run any VMs:
[...]
> tap0: Features changed: 0x40004040 -> 0x401b4849

Before this message, userspace called ioctl(TIOCSETOFFLOAD)
turning offloads on.

> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Features changed: 0x401b4849 -> 0x40004040

And then it probably called ioctl(TIOCSETOFFLOAD) again, disabling them.

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: [PATCH 0/4] [RFC] virtio-net: Improve small packet performance
From: Krishna Kumar2 @ 2011-05-05 15:36 UTC (permalink / raw)
  To: Krishna Kumar2
  Cc: davem, eric.dumazet, kvm, Michael S. Tsirkin, netdev,
	netdev-owner, rusty
In-Reply-To: <OFB1ACC9EB.4567C1B1-ON65257887.0050044B-65257887.0054A5CE@in.ibm.com>

Krishna Kumar wrote on 05/05/2011 08:57:13 PM:

Oops, I sent my patch's test results for the 16K case.
The correct one is:

________________________________________________________
                  I/O size: 16K
#       BW1     BW2 (%)         SD1     SD2 (%)
________________________________________________________
1       6684    6670 (-.2)      1.1     .6 (-45.4)
2       7674    7859 (2.4)      5.0     2.6 (-48.0)
4       7358    7421 (.8)       21.3    11.6 (-45.5)
8       7393    7289 (-1.4)     82.7    44.8 (-45.8)
16      7958    7280 (-8.5)     283.2   166.3 (-41.2)
32      7792    7163 (-8.0)     1257.5  692.4 (-44.9)
64      7673    7096 (-7.5)     5723.1  2870.3 (-49.8)
96      7462    6963 (-6.6)     12731.8 6475.6 (-49.1)
128     7338    6919 (-5.7)     21331.7 12345.7 (-42.1)
________________________________________________________
Summary:    BW: (-3.9)      SD: (-45.4)

Sorry for the confusion.

Regards,

- KK

> ________________________________________________________
>                   I/O size: 16K
> #     BW1     BW2 (%)        SD1       SD2 (%)
> ________________________________________________________
> 1     6684    7019 (5.0)     1.1       1.1 (0)
> 2     7674    7196 (-6.2)    5.0       4.8 (-4.0)
> 4     7358    8032 (9.1)     21.3      20.4 (-4.2)
> 8     7393    8015 (8.4)     82.7      82.0 (-.8)
> 16    7958    8366 (5.1)     283.2     310.7 (9.7)
> 32    7792    8113 (4.1)     1257.5    1363.0 (8.3)
> 64    7673    8040 (4.7)     5723.1    5812.4 (1.5)
> 96    7462    7883 (5.6)     12731.8   12119.8 (-4.8)
> 128   7338    7800 (6.2)     21331.7   21094.7 (-1.1)
> ________________________________________________________
> Summary:     BW: (4.6)     SD: (-1.5)


^ permalink raw reply

* Re: [PATCH 0/4] [RFC] virtio-net: Improve small packet performance
From: Michael S. Tsirkin @ 2011-05-05 15:34 UTC (permalink / raw)
  To: Krishna Kumar2; +Cc: davem, eric.dumazet, kvm, netdev, rusty
In-Reply-To: <OFB1ACC9EB.4567C1B1-ON65257887.0050044B-65257887.0054A5CE@in.ibm.com>

On Thu, May 05, 2011 at 08:57:13PM +0530, Krishna Kumar2 wrote:
> "Michael S. Tsirkin" <mst@redhat.com> wrote on 05/05/2011 02:34:39 PM:
> 
> > > Do I need to apply all the patches and simply test?
> > >
> > > Thanks,
> > >
> > > - KK
> >
> > Exactly. You can also try to tune the threshold
> > for interrupts as well.
> 
> I haven't tuned the threshhold, it is left it at 3/4. I ran
> the new qemu/vhost/guest, and the results for 1K, 2K and 16K
> are below. Note this is a different kernel version from my
> earlier test results. So, f.e., BW1 represents 2.6.39-rc2,
> the original kernel; while BW2 represents 2.6.37-rc5 (MST's
> kernel).

Weird. My kernel is actually 2.6.39-rc2. So which is which?

> This also isn't with the fixes you have sent just
> now. I will get a run with that either late tonight or
> tomorrow.

Shouldn't affect anything performance-wise.

> ________________________________________________________
>                    I/O size: 1K
> #     BW1     BW2 (%)        SD1       SD2 (%)
> ________________________________________________________
> 1     1723    3016 (75.0)    4.7       2.6 (-44.6)
> 2     3223    6712 (108.2)   18.0      7.1 (-60.5)
> 4     7223    8258 (14.3)    36.5      24.3 (-33.4)
> 8     8689    7943 (-8.5)    131.5     101.6 (-22.7)
> 16    8059    7398 (-8.2)    578.3     406.4 (-29.7)
> 32    7758    7208 (-7.0)    2281.4    1574.7 (-30.9)
> 64    7503    7155 (-4.6)    9734.0    6368.0 (-34.5)
> 96    7496    7078 (-5.5)    21980.9   15477.6 (-29.5)
> 128   7389    6900 (-6.6)    40467.5   26031.9 (-35.6)
> ________________________________________________________
> Summary:     BW: (4.4)     SD: (-33.5)
> 
> ________________________________________________________
>                  I/O size: 2K
> #     BW1     BW2 (%)        SD1       SD2 (%)
> ________________________________________________________
> 1     1608    4968 (208.9)   5.0       1.3 (-74.0)
> 2     3354    6974 (107.9)   18.6      4.9 (-73.6)
> 4     8234    8344 (1.3)     35.6      17.9 (-49.7)
> 8     8427    7818 (-7.2)    103.5     71.2 (-31.2)
> 16    7995    7491 (-6.3)    410.1     273.9 (-33.2)
> 32    7863    7149 (-9.0)    1678.6    1080.4 (-35.6)
> 64    7661    7092 (-7.4)    7245.3    4717.2 (-34.8)
> 96    7517    6984 (-7.0)    15711.2   9838.9 (-37.3)
> 128   7389    6851 (-7.2)    27121.6   18255.7 (-32.6)
> ________________________________________________________
> Summary:     BW: (6.0)     SD: (-34.5)
> 
> ________________________________________________________
>                   I/O size: 16K
> #     BW1     BW2 (%)        SD1       SD2 (%)
> ________________________________________________________
> 1     6684    7019 (5.0)     1.1       1.1 (0)
> 2     7674    7196 (-6.2)    5.0       4.8 (-4.0)
> 4     7358    8032 (9.1)     21.3      20.4 (-4.2)
> 8     7393    8015 (8.4)     82.7      82.0 (-.8)
> 16    7958    8366 (5.1)     283.2     310.7 (9.7)
> 32    7792    8113 (4.1)     1257.5    1363.0 (8.3)
> 64    7673    8040 (4.7)     5723.1    5812.4 (1.5)
> 96    7462    7883 (5.6)     12731.8   12119.8 (-4.8)
> 128   7338    7800 (6.2)     21331.7   21094.7 (-1.1)
> ________________________________________________________
> Summary:     BW: (4.6)     SD: (-1.5)
> 
> Thanks,
> 
> - KK

^ permalink raw reply

* Re: [PATCH 0/4] [RFC] virtio-net: Improve small packet performance
From: Michael S. Tsirkin @ 2011-05-05 15:37 UTC (permalink / raw)
  To: Krishna Kumar2; +Cc: davem, eric.dumazet, kvm, netdev, netdev-owner, rusty
In-Reply-To: <OF32D1B981.C4616456-ON65257887.00552498-65257887.00555A3C@in.ibm.com>

On Thu, May 05, 2011 at 09:06:00PM +0530, Krishna Kumar2 wrote:
> Krishna Kumar wrote on 05/05/2011 08:57:13 PM:
> 
> Oops, I sent my patch's test results for the 16K case.
> The correct one is:
> 
> ________________________________________________________
>                   I/O size: 16K
> #       BW1     BW2 (%)         SD1     SD2 (%)
> ________________________________________________________
> 1       6684    6670 (-.2)      1.1     .6 (-45.4)
> 2       7674    7859 (2.4)      5.0     2.6 (-48.0)
> 4       7358    7421 (.8)       21.3    11.6 (-45.5)
> 8       7393    7289 (-1.4)     82.7    44.8 (-45.8)
> 16      7958    7280 (-8.5)     283.2   166.3 (-41.2)
> 32      7792    7163 (-8.0)     1257.5  692.4 (-44.9)
> 64      7673    7096 (-7.5)     5723.1  2870.3 (-49.8)
> 96      7462    6963 (-6.6)     12731.8 6475.6 (-49.1)
> 128     7338    6919 (-5.7)     21331.7 12345.7 (-42.1)
> ________________________________________________________
> Summary:    BW: (-3.9)      SD: (-45.4)
> 
> Sorry for the confusion.
> 
> Regards,
> 
> - KK

Interesting. So which is which?
> > ________________________________________________________
> >                   I/O size: 16K
> > #     BW1     BW2 (%)        SD1       SD2 (%)
> > ________________________________________________________
> > 1     6684    7019 (5.0)     1.1       1.1 (0)
> > 2     7674    7196 (-6.2)    5.0       4.8 (-4.0)
> > 4     7358    8032 (9.1)     21.3      20.4 (-4.2)
> > 8     7393    8015 (8.4)     82.7      82.0 (-.8)
> > 16    7958    8366 (5.1)     283.2     310.7 (9.7)
> > 32    7792    8113 (4.1)     1257.5    1363.0 (8.3)
> > 64    7673    8040 (4.7)     5723.1    5812.4 (1.5)
> > 96    7462    7883 (5.6)     12731.8   12119.8 (-4.8)
> > 128   7338    7800 (6.2)     21331.7   21094.7 (-1.1)
> > ________________________________________________________
> > Summary:     BW: (4.6)     SD: (-1.5)

^ permalink raw reply

* Re: [PATCH 0/4] [RFC] virtio-net: Improve small packet performance
From: Michael S. Tsirkin @ 2011-05-05 15:42 UTC (permalink / raw)
  To: Krishna Kumar2; +Cc: davem, eric.dumazet, kvm, netdev, rusty
In-Reply-To: <OFB1ACC9EB.4567C1B1-ON65257887.0050044B-65257887.0054A5CE@in.ibm.com>

On Thu, May 05, 2011 at 08:57:13PM +0530, Krishna Kumar2 wrote:
> "Michael S. Tsirkin" <mst@redhat.com> wrote on 05/05/2011 02:34:39 PM:
> 
> > > Do I need to apply all the patches and simply test?
> > >
> > > Thanks,
> > >
> > > - KK
> >
> > Exactly. You can also try to tune the threshold
> > for interrupts as well.
> 
> I haven't tuned the threshhold, it is left it at 3/4. I ran
> the new qemu/vhost/guest, and the results for 1K, 2K and 16K
> are below. Note this is a different kernel version from my
> earlier test results. So, f.e., BW1 represents 2.6.39-rc2,
> the original kernel; while BW2 represents 2.6.37-rc5 (MST's
> kernel). This also isn't with the fixes you have sent just
> now. I will get a run with that either late tonight or
> tomorrow.

One thing I'd suggest is merging v2.6.39-rc6 into that tree.
rc2 is still pretty early, reason I use it is because that is
what net-next is.

-- 
MST

^ permalink raw reply

* Re: [PATCH] mlx4_en: Setting RSS hash result to skb->rxhash field
From: David Miller @ 2011-05-05 17:34 UTC (permalink / raw)
  To: eric.dumazet; +Cc: yevgenyp, bhutchings, netdev
In-Reply-To: <1304578518.32152.794.camel@edumazet-laptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 05 May 2011 08:55:18 +0200

> Really, we better use the linux/software full 32bit rxhash in this case,
> and wait for your 32bit full support.

Agreed.

^ permalink raw reply

* Re: [PATCH] usbnet: runtime pm: fix out of memory
From: David Miller @ 2011-05-05 17:39 UTC (permalink / raw)
  To: oneukum-l3A5Bk7waGM
  Cc: tom.leiming-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <201105040926.12355.oneukum-l3A5Bk7waGM@public.gmane.org>

From: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
Date: Wed, 4 May 2011 09:26:12 +0200

> Am Mittwoch, 4. Mai 2011, 08:59:41 schrieb Ming Lei:
>> Hi,
>> 
>> 2011/5/3 Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>:
>> 
>> > Do the devices in question use cdc_ether?
>> 
>> No, the device is smsc95xx, which is compound device and is
>> integrated into pandaboard.
> 
> OK,
> 
> in this case:
> 
> Acked-by: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH] stmmac: removed not used definitions
From: David Miller @ 2011-05-05 17:43 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev
In-Reply-To: <1304590250-9434-1-git-send-email-peppe.cavallaro@st.com>

From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
Date: Thu,  5 May 2011 12:10:50 +0200

> Reported-by: Karim Hamiti <karim.hamiti@st.com>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied to net-next-2.6, thanks.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox