diff mbox

[RFC,v2,10/10] snet: introduce snet_utils

Message ID 1267561394-13626-11-git-send-email-sam@synack.fr
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Samir Bellabes March 2, 2010, 8:23 p.m. UTC
This patch provides helper functions for other subsystems

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

Comments

Jan Engelhardt March 3, 2010, 5:55 p.m. UTC | #1
On Tuesday 2010-03-02 21:23, Samir Bellabes wrote:

>This patch provides helper functions for other subsystems

What subsystems would that be? (Just trying to prevent premature code 
bloat.)

> security/snet/snet_utils.c |   38 ++++++++++++++++++++++++++++++++++++++
> security/snet/snet_utils.h |   10 ++++++++++
> 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..e9178d7
>--- /dev/null
>+++ b/security/snet/snet_utils.c
>@@ -0,0 +1,38 @@
>+#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",
>+	};
>+
>+	if (cmd >= SNET_NR_VERDICT_TYPES)
>+		return "INVALID";
>+	else
>+		return verdict_name[cmd];
>+}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Samir Bellabes March 6, 2010, 12:41 p.m. UTC | #2
Jan Engelhardt <jengelh@medozas.de> writes:

> On Tuesday 2010-03-02 21:23, Samir Bellabes wrote:
>
>>This patch provides helper functions for other subsystems
>
> What subsystems would that be? (Just trying to prevent premature code 
> bloat.)

snet_verdict_name() is used in :
 - security/snet/snet_core.c
 - security/snet/snet_ticket_helper.c

snet_syscall_name() is used in :
 - security/snet/snet_event.c
 - security/snet/snet_netlink.c
 - security/snet/snet_ticket_helper.c

this functions are used for debug.

in the same time, I found an unused function declaration in security/snet/snet_utils.h:
int snet_data_fill(struct sk_buff *skb_rsp, struct snet_info *info);
I deleted it.

Thanks Jan,
sam
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/security/snet/snet_utils.c b/security/snet/snet_utils.c
new file mode 100644
index 0000000..e9178d7
--- /dev/null
+++ b/security/snet/snet_utils.c
@@ -0,0 +1,38 @@ 
+#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",
+	};
+
+	if (cmd >= SNET_NR_VERDICT_TYPES)
+		return "INVALID";
+	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 "INVALID";
+	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..4dad18b
--- /dev/null
+++ b/security/snet/snet_utils.h
@@ -0,0 +1,10 @@ 
+#ifndef _SNET_UTILS_H
+#define _SNET_UTILS_H
+
+#include <linux/skbuff.h>
+
+int snet_data_fill(struct sk_buff *skb_rsp, struct snet_info *info);
+const char *snet_verdict_name(const enum snet_verdict cmd);
+const char *snet_syscall_name(const enum snet_syscall sys);
+
+#endif	/* _SNET_UTILS_H */