netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: tgraf@suug.ch
Cc: Patrick McHardy <kaber@trash.net>,
	netfilter-devel@vger.kernel.org, philipc@snapgear.com
Subject: [LIBNL 06/09]: nfnetlink_log: support NUFLA_GID attribute
Date: Fri, 18 Jan 2008 17:55:55 +0100 (MET)	[thread overview]
Message-ID: <20080118165522.13385.72025.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080118165514.13385.44695.sendpatchset@localhost.localdomain>

commit 2c2e8051726fb34980d1e7b72c15d0a6eba4cfc0
Author: Patrick McHardy <kaber@trash.net>
Date:   Fri Jan 18 17:44:52 2008 +0100

    [LIBNL]: nfnetlink_log: support NUFLA_GID attribute
    
    The NUFLA_GID attribute (currently only in net-2.6.25) contains the
    gid of the sending process for locally generated packets.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/linux/netfilter/nfnetlink_log.h b/include/linux/netfilter/nfnetlink_log.h
index 2de5df9..38fafc1 100644
--- a/include/linux/netfilter/nfnetlink_log.h
+++ b/include/linux/netfilter/nfnetlink_log.h
@@ -51,6 +51,7 @@ enum nfulnl_attr_type {
 	NFULA_UID,			/* user id of socket */
 	NFULA_SEQ,			/* instance-local sequence number */
 	NFULA_SEQ_GLOBAL,		/* global sequence number */
+	NFULA_GID,			/* group id of socket */
 
 	__NFULA_MAX
 };
diff --git a/include/netlink-types.h b/include/netlink-types.h
index f7bddca..cbf903e 100644
--- a/include/netlink-types.h
+++ b/include/netlink-types.h
@@ -751,6 +751,7 @@ struct nfnl_log {
 	int			log_payload_len;
 	char *			log_prefix;
 	uint32_t		log_uid;
+	uint32_t		log_gid;
 	uint32_t		log_seq;
 	uint32_t		log_seq_global;
 };
diff --git a/include/netlink/netfilter/log.h b/include/netlink/netfilter/log.h
index e65cc58..817de2d 100644
--- a/include/netlink/netfilter/log.h
+++ b/include/netlink/netfilter/log.h
@@ -89,6 +89,10 @@ extern void		nfnl_log_set_uid(struct nfnl_log *, uint32_t);
 extern int		nfnl_log_test_uid(const struct nfnl_log *);
 extern uint32_t		nfnl_log_get_uid(const struct nfnl_log *);
 
+extern void		nfnl_log_set_gid(struct nfnl_log *, uint32_t);
+extern int		nfnl_log_test_gid(const struct nfnl_log *);
+extern uint32_t		nfnl_log_get_gid(const struct nfnl_log *);
+
 extern void		nfnl_log_set_seq(struct nfnl_log *, uint32_t);
 extern int		nfnl_log_test_seq(const struct nfnl_log *);
 extern uint32_t		nfnl_log_get_seq(const struct nfnl_log *);
diff --git a/lib/netfilter/log.c b/lib/netfilter/log.c
index a900927..8d70e7f 100644
--- a/lib/netfilter/log.c
+++ b/lib/netfilter/log.c
@@ -58,6 +58,7 @@ static struct nla_policy log_policy[NFULA_MAX+1] = {
 	//[NFULA_PAYLOAD]
 	[NFULA_PREFIX]			= { .type = NLA_STRING, },
 	[NFULA_UID]			= { .type = NLA_U32 },
+	[NFULA_GID]			= { .type = NLA_U32 },
 	[NFULA_SEQ]			= { .type = NLA_U32 },
 	[NFULA_SEQ_GLOBAL]		= { .type = NLA_U32 },
 };
@@ -146,6 +147,10 @@ struct nfnl_log *nfnlmsg_log_parse(struct nlmsghdr *nlh)
 	if (attr)
 		nfnl_log_set_uid(log, ntohl(nla_get_u32(attr)));
 
+	attr = tb[NFULA_GID];
+	if (attr)
+		nfnl_log_set_gid(log, ntohl(nla_get_u32(attr)));
+
 	attr = tb[NFULA_SEQ];
 	if (attr)
 		nfnl_log_set_seq(log, ntohl(nla_get_u32(attr)));
diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c
index c3adc51..0e4411e 100644
--- a/lib/netfilter/log_obj.c
+++ b/lib/netfilter/log_obj.c
@@ -29,8 +29,9 @@
 #define LOG_ATTR_PAYLOAD		(1UL << 10)
 #define LOG_ATTR_PREFIX			(1UL << 11)
 #define LOG_ATTR_UID			(1UL << 12)
-#define LOG_ATTR_SEQ			(1UL << 13)
-#define LOG_ATTR_SEQ_GLOBAL		(1UL << 14)
+#define LOG_ATTR_GID			(1UL << 13)
+#define LOG_ATTR_SEQ			(1UL << 14)
+#define LOG_ATTR_SEQ_GLOBAL		(1UL << 15)
 /** @endcond */
 
 static void log_free_data(struct nl_object *c)
@@ -144,6 +145,12 @@ static int log_dump(struct nl_object *a, struct nl_dump_params *p)
 	if (log->ce_mask & LOG_ATTR_PAYLOAD)
 		dp_dump(p, "PAYLOADLEN=%d ", log->log_payload_len);
 
+	if (log->ce_mask & LOG_ATTR_UID)
+		dp_dump(p, "UID=%u ", log->log_uid);
+
+	if (log->ce_mask & LOG_ATTR_GID)
+		dp_dump(p, "GID=%u ", log->log_gid);
+
 	if (log->ce_mask & LOG_ATTR_SEQ)
 		dp_dump(p, "SEQ=%d ", log->log_seq);
 
@@ -378,6 +385,23 @@ uint32_t nfnl_log_get_uid(const struct nfnl_log *log)
 	return log->log_uid;
 }
 
+void nfnl_log_set_gid(struct nfnl_log *log, uint32_t gid)
+{
+	log->log_gid = gid;
+	log->ce_mask |= LOG_ATTR_GID;
+}
+
+int nfnl_log_test_gid(const struct nfnl_log *log)
+{
+	return !!(log->ce_mask & LOG_ATTR_GID);
+}
+
+uint32_t nfnl_log_get_gid(const struct nfnl_log *log)
+{
+	return log->log_gid;
+}
+
+
 void nfnl_log_set_seq(struct nfnl_log *log, uint32_t seq)
 {
 	log->log_seq = seq;

  parent reply	other threads:[~2008-01-18 16:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-18 16:55 [LIBNL 00/09]: Netfilter update + minor fixes Patrick McHardy
2008-01-18 16:55 ` [LIBNL 01/09]: Add if_vlan.h Patrick McHardy
2008-02-07 11:50   ` Thomas Graf
2008-01-18 16:55 ` [LIBNL 02/09]: Fix minor memleaks on exit Patrick McHardy
2008-02-07 11:52   ` Thomas Graf
2008-01-18 16:55 ` [LIBNL 03/09]: Generic netfilter stuff Patrick McHardy
2008-02-07 11:54   ` Thomas Graf
2008-01-18 16:55 ` [LIBNL 04/09]: Add nfnetlink_queue support Patrick McHardy
2008-02-07 12:00   ` Thomas Graf
2008-01-18 16:55 ` [LIBNL 05/09]: nfnetlink_log: only set hwproto if not zero Patrick McHardy
2008-02-07 12:01   ` Thomas Graf
2008-01-18 16:55 ` Patrick McHardy [this message]
2008-02-07 12:03   ` [LIBNL 06/09]: nfnetlink_log: support NUFLA_GID attribute Thomas Graf
2008-01-18 16:55 ` [LIBNL 07/09]: Split up nfnetlink_log into log and msg objects Patrick McHardy
2008-01-21  8:05   ` Philip Craig
2008-01-21  9:45     ` Patrick McHardy
2008-02-07 12:11   ` Thomas Graf
2008-01-18 16:55 ` [LIBNL 08/09]: Support conntrack add/delete/query requests Patrick McHardy
2008-01-21  8:39   ` Philip Craig
2008-01-21  9:46     ` Patrick McHardy
2008-01-21 10:53       ` Philip Craig
2008-01-21 10:55         ` Patrick McHardy
2008-02-07 12:14   ` Thomas Graf
2008-02-19 12:32     ` Patrick McHardy
2008-01-18 16:56 ` [LIBNL 09/09]: Install netfilter headers Patrick McHardy
2008-02-07 12:16   ` Thomas Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080118165522.13385.72025.sendpatchset@localhost.localdomain \
    --to=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=philipc@snapgear.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).