All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace
@ 2008-05-17 15:28 Tomasz Grobelny
  2008-05-21 12:06   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
                   ` (38 more replies)
  0 siblings, 39 replies; 77+ messages in thread
From: Tomasz Grobelny @ 2008-05-17 15:28 UTC (permalink / raw)
  To: dccp

Since packets with invalid cmsg parameters can be rejected by kernel there
is a need to allow applications to access information on available policies
and their respective cmsg parameters at runtime. This patch simplifies
maintaining compatibility between userspace applications and DCCP code.

Signed-off-by: Tomasz Grobelny <tomasz@grobelny.oswiecenia.net>
---
 include/linux/dccp.h |    5 +++
 net/dccp/dccp.h      |    4 +++
 net/dccp/proto.c     |    2 +
 net/dccp/qpolicy.c   |   67 +++++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 5c27e27..950ecd5 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -226,6 +226,11 @@ enum dccp_packet_dequeueing_policy {
 #define DCCP_SOCKOPT_CCID_RX_INFO	128
 #define DCCP_SOCKOPT_CCID_TX_INFO	192
 
+#define DCCP_SOCKOPT_QPOLICY_MIN	256
+#define DCCP_SOCKOPT_QPOLICY_AVAILABLE	256
+#define DCCP_SOCKOPT_QPOLICY_PARAMS	257
+#define DCCP_SOCKOPT_QPOLICY_MAX	512
+
 /* maximum number of services provided on the same listening port */
 #define DCCP_SERVICE_LIST_MAX_LEN      32
 /* maximum number of CCID preferences that can be registered at one time */
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index c6e1a9c..1610807 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -223,6 +223,10 @@ extern bool		dccp_qpolicy_full(struct sock *sk);
 extern void		dccp_qpolicy_drop(struct sock *sk, struct sk_buff *skb);
 extern struct sk_buff	*dccp_qpolicy_top(struct sock *sk);
 extern struct sk_buff	*dccp_qpolicy_pop(struct sock *sk);
+extern int		dccp_qpolicy_getsockopt(struct sock *sk, int len,
+						int optname,
+						char __user *optval,
+						int __user *optlen);
 
 /*
  * TX Packet Output and TX Timers
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index bdc4126..c9596ff 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -669,6 +669,8 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
 	case 192 ... 255:
 		return ccid_hc_tx_getsockopt(dp->dccps_hc_tx_ccid, sk, optname,
 					     len, (u32 __user *)optval, optlen);
+	case DCCP_SOCKOPT_QPOLICY_MIN ... DCCP_SOCKOPT_QPOLICY_MAX:
+		return dccp_qpolicy_getsockopt(sk, len, optname, optval, optlen);
 	default:
 		return -ENOPROTOOPT;
 	}
diff --git a/net/dccp/qpolicy.c b/net/dccp/qpolicy.c
index 4270c7f..ba4f6a1 100644
--- a/net/dccp/qpolicy.c
+++ b/net/dccp/qpolicy.c
@@ -9,6 +9,7 @@
  *  modify it under the terms of the GNU General Public License v2
  *  as published by the Free Software Foundation.
  */
+#include <linux/dccp.h>
 #include <asm/unaligned.h>
 #include "dccp.h"
 
@@ -64,6 +65,28 @@ static bool qpolicy_prio_full(struct sock *sk)
 	return false;
 }
 
+static int put_table(u32 *table, int psize, int len,
+				char __user *optval, int __user *optlen)
+{
+	if (len < psize)
+		return -EINVAL;
+	if (put_user(psize, optlen) || copy_to_user(optval, table, psize))
+		return -EFAULT;
+	return 0;
+}
+
+static int prio_params[] = {
+	DCCP_SCM_PRIORITY,
+};
+
+static int qpolicy_prio_getsockopt(struct sock *sk, int len, int optname,
+				char __user *optval, int __user *optlen)
+{
+	if (optname != DCCP_SOCKOPT_QPOLICY_PARAMS)
+		return -ENOPROTOOPT;
+	return put_table(prio_params, sizeof(prio_params), len, optval, optlen);
+}
+
 /**
  * struct dccp_qpolicy_operations  -  TX Packet Dequeueing Interface
  * @push: add a new @skb with possibly a struct dccp_packet_info
@@ -71,20 +94,24 @@ static bool qpolicy_prio_full(struct sock *sk)
  * @top:  peeks at whatever the queueing policy defines as its top
  */
 static struct dccp_qpolicy_operations {
-	void		(*push)	(struct sock *sk, struct sk_buff *skb);
-	bool		(*full) (struct sock *sk);
-	struct sk_buff*	(*top)  (struct sock *sk);
+	void		(*push)	     (struct sock *sk, struct sk_buff *skb);
+	bool		(*full)	     (struct sock *sk);
+	struct sk_buff*	(*top)	     (struct sock *sk);
+	int		(*getsockopt)(struct sock *sk, int len, int optname,
+				      char __user *optval, int __user *optlen);
 
 } qpol_table[DCCPQ_POLICY_MAX] = {
 	[DCCPQ_POLICY_SIMPLE] = {
-		.push = qpolicy_simple_push,
-		.full = qpolicy_simple_full,
-		.top  = qpolicy_simple_top,
+		.push		= qpolicy_simple_push,
+		.full		= qpolicy_simple_full,
+		.top		= qpolicy_simple_top,
+		.getsockopt	= NULL,
 	},
 	[DCCPQ_POLICY_PRIO] = {
-		.push = qpolicy_simple_push,
-		.full = qpolicy_prio_full,
-		.top  = qpolicy_prio_best_skb,
+		.push		= qpolicy_simple_push,
+		.full		= qpolicy_prio_full,
+		.top		= qpolicy_prio_best_skb,
+		.getsockopt	= qpolicy_prio_getsockopt,
 	},
 };
 
@@ -125,3 +152,25 @@ struct sk_buff *dccp_qpolicy_pop(struct sock *sk)
 		skb_unlink(skb, &sk->sk_write_queue);
 	return skb;
 }
+
+static int qpolicy_numbers[] = {
+	DCCPQ_POLICY_SIMPLE,
+	DCCPQ_POLICY_PRIO,
+};
+
+int dccp_qpolicy_getsockopt(struct sock *sk, int len, int optname,
+				char __user *optval, int __user *optlen)
+{
+	switch (optname) {
+	case DCCP_SOCKOPT_QPOLICY_AVAILABLE:
+		return put_table(qpolicy_numbers, sizeof(qpolicy_numbers),
+							len, optval, optlen);
+	default:
+		if ( qpol_table[dccp_sk(sk)->dccps_qpolicy].getsockopt != NULL)
+			return qpol_table[dccp_sk(sk)->dccps_qpolicy].getsockopt
+				(sk, len, optname, optval, optlen);
+		else
+			return -ENOPROTOOPT;
+	}
+	return 0;
+}
-- 
1.5.4.5


^ permalink raw reply related	[flat|nested] 77+ messages in thread

end of thread, other threads:[~2008-08-08 16:59 UTC | newest]

Thread overview: 77+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-17 15:28 [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Tomasz Grobelny
2008-05-21 12:06 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-05-21 12:06   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-05-22  0:35 ` Tomasz Grobelny
2008-05-22  0:35   ` Tomasz Grobelny
2008-05-22 10:02 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-05-22 10:02   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-05-22 17:48 ` Tomasz Grobelny
2008-05-22 17:48   ` Tomasz Grobelny
2008-05-26 14:22 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-05-26 14:22   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-05-26 21:40 ` Tomasz Grobelny
2008-05-26 21:40   ` Tomasz Grobelny
2008-06-01 17:48 ` Tomasz Grobelny
2008-06-01 17:48   ` Tomasz Grobelny
2008-06-02 10:21 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-02 10:21   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-02 21:56 ` Tomasz Grobelny
2008-06-02 21:56   ` Tomasz Grobelny
2008-06-04 15:09 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-04 15:09   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-08 12:21 ` Tomasz Grobelny
2008-06-08 12:21   ` Tomasz Grobelny
2008-06-08 15:53 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace through procfs Tomasz Grobelny
2008-06-10 11:49 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-10 11:49   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-11 17:43 ` Tomasz Grobelny
2008-06-11 17:43   ` Tomasz Grobelny
2008-06-12  9:07 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-12  9:07   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-14 23:58 ` Tomasz Grobelny
2008-06-14 23:58   ` Tomasz Grobelny
2008-06-17 11:16 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-17 11:16   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-17 20:28 ` Tomasz Grobelny
2008-06-17 20:28   ` Tomasz Grobelny
2008-06-17 20:47 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Randy.Dunlap
2008-06-17 20:47   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Randy.Dunlap
     [not found]   ` <cfd18e0f0806180207x783d83d0j3d5e42987be24ea6@mail.gmail.com>
     [not found]     ` <20080618092707.GC23684@gerrit.erg.abdn.ac.uk>
     [not found]       ` <cfd18e0f0806180248g35bec32n7977c46cbcf4142@mail.gmail.com>
     [not found]         ` <cfd18e0f0806180248g35bec32n7977c46cbcf4142-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-06-24 13:36           ` [manpages]: First stab at a udplite(7) manpage Gerrit Renker
     [not found]             ` <20080624133625.GA16424-w6qhtmnlW2CgJ32XgR7WtTYRy0cijUJx@public.gmane.org>
2008-06-27  9:03               ` Michael Kerrisk
     [not found]                 ` <cfd18e0f0806270203p4305cd2jae9cb8a79d7c33e9-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-06-30 11:27                   ` Gerrit Renker
     [not found]                     ` <20080630112751.GB5040-w6qhtmnlW2CgJ32XgR7WtTYRy0cijUJx@public.gmane.org>
2008-06-30 13:03                       ` Michael Kerrisk
     [not found]                         ` <cfd18e0f0806300603g38cc4222r37996404390dfcbf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-16 15:10                           ` Michael Kerrisk
     [not found]                             ` <cfd18e0f0807160810p7d40e3bbpe150d695aca8c5ea-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-07-18 11:09                               ` Gerrit Renker
     [not found]                                 ` <20080718110923.GA12919-w6qhtmnlW2CgJ32XgR7WtTYRy0cijUJx@public.gmane.org>
2008-07-23 15:40                                   ` [manpages]: Version 2 of " Gerrit Renker
     [not found]                                     ` <20080723154017.GA14244-w6qhtmnlW2CgJ32XgR7WtTYRy0cijUJx@public.gmane.org>
2008-08-07 13:34                                       ` Michael Kerrisk
     [not found]                                         ` <57217.148.187.160.35.1218193536.squirrel@148.187.160.35>
     [not found]                                           ` <57217.148.187.160.35.1218193536.squirrel-Uy33jJmzxvb8W20QDElj1A@public.gmane.org>
2008-08-08 16:59                                             ` Michael Kerrisk
2008-06-18  9:40 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-18  9:40   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-18 20:46 ` Tomasz Grobelny
2008-06-18 20:46   ` Tomasz Grobelny
2008-06-19  7:05 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-19  7:05   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-20 21:03 ` Tomasz Grobelny
2008-06-20 21:03   ` Tomasz Grobelny
2008-06-23 16:58 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-23 16:58   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-24  8:02 ` Tomasz Grobelny
2008-06-24  8:02   ` Tomasz Grobelny
2008-06-25 18:05 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-25 18:05   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-06-25 20:15 ` Tomasz Grobelny
2008-06-25 20:15   ` Tomasz Grobelny
2008-06-30 12:39 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-06-30 12:39   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Gerrit Renker
2008-07-01 12:38 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Tomasz Grobelny
2008-07-01 12:38   ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Tomasz Grobelny
2008-07-02  9:42 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-07-02 12:19 ` Tomasz Grobelny
2008-07-03 11:48 ` Gerrit Renker
2008-07-05 16:42 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Tomasz Grobelny
2008-07-07 15:08 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-07-08  9:26 ` Gerrit Renker
2008-07-08 19:47 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Tomasz Grobelny
2008-07-14 12:58 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker
2008-07-14 20:57 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies available to userspace Tomasz Grobelny
2008-07-21 16:24 ` [PATCH 1/1] [DCCP][QPOLICY]: Make information about qpolicies Gerrit Renker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.