]> granicus.if.org Git - libnl/commitdiff
[LIBNL]: nfnetlink_log: support NUFLA_GID attribute
authorPatrick McHardy <kaber@trash.net>
Fri, 18 Jan 2008 16:55:55 +0000 (17:55 +0100)
committerThomas Graf <tgr@deb.localdomain>
Thu, 7 Feb 2008 12:02:41 +0000 (13:02 +0100)
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>
include/linux/netfilter/nfnetlink_log.h
include/netlink-types.h
include/netlink/netfilter/log.h
lib/netfilter/log.c
lib/netfilter/log_obj.c

index 2de5df98be70e01f9119b1e8105a3ac1274e8ffd..38fafc16329b9f64414a4815446bc53f0e8c3777 100644 (file)
@@ -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
 };
index f7bddcaf135f8744e6ab3f4f8bdfdc8696585823..cbf903eff931ba1b058627c65197aa0d23b8d7d7 100644 (file)
@@ -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;
 };
index e65cc58a58716facdd5c518d0d94f84a37afd431..817de2d78c2167b4dd0a44d3108fc0ecd289113c 100644 (file)
@@ -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 *);
index a9009273e280244d4b38c0ea6a547062201e371b..8d70e7f05ca66f3aac57e756f44a69cc42047353 100644 (file)
@@ -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)));
index c3adc519698b33bd3dece18e95abcefb63d7f62d..0e4411ea0461beb41831e5ab25b01c15604c94ec 100644 (file)
@@ -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;