#define PRINTR(x, args...) do { if (net_ratelimit()) \
printk(x, ## args); } while (0);
-#if 0
-#define UDEBUG(x, args ...) printk(KERN_DEBUG "%s(%d):%s(): " x, \
- __FILE__, __LINE__, __FUNCTION__, \
- ## args)
-#else
-#define UDEBUG(x, ...)
-#endif
-
struct nfulnl_instance {
struct hlist_node hlist; /* global list of instances */
spinlock_t lock;
struct hlist_node *pos;
struct nfulnl_instance *inst;
- UDEBUG("entering (group_num=%u)\n", group_num);
-
head = &instance_table[instance_hashfn(group_num)];
hlist_for_each_entry(inst, pos, head, hlist) {
if (inst->group_num == group_num)
instance_put(struct nfulnl_instance *inst)
{
if (inst && atomic_dec_and_test(&inst->use)) {
- UDEBUG("kfree(inst=%p)\n", inst);
kfree(inst);
module_put(THIS_MODULE);
}
{
struct nfulnl_instance *inst;
- UDEBUG("entering (group_num=%u, pid=%d)\n", group_num,
- pid);
-
write_lock_bh(&instances_lock);
if (__instance_lookup(group_num)) {
inst = NULL;
- UDEBUG("aborting, instance already exists\n");
goto out_unlock;
}
hlist_add_head(&inst->hlist,
&instance_table[instance_hashfn(group_num)]);
- UDEBUG("newly added node: %p, next=%p\n", &inst->hlist,
- inst->hlist.next);
-
write_unlock_bh(&instances_lock);
return inst;
__instance_destroy(struct nfulnl_instance *inst)
{
/* first pull it out of the global list */
- UDEBUG("removing instance %p (queuenum=%u) from hash\n",
- inst, inst->group_num);
-
hlist_del(&inst->hlist);
/* then flush all pending packets from skb */
struct sk_buff *skb;
unsigned int n;
- UDEBUG("entered (%u, %u)\n", inst_size, pkt_size);
-
/* alloc skb which should be big enough for a whole multipart
* message. WARNING: has to be <= 128k due to slab restrictions */
sizeof(struct nfgenmsg));
status = nfnetlink_unicast(inst->skb, inst->peer_pid, MSG_DONTWAIT);
- if (status < 0) {
- UDEBUG("netlink_unicast() failed\n");
- /* FIXME: statistics */
- }
inst->qlen = 0;
inst->skb = NULL;
{
struct nfulnl_instance *inst = (struct nfulnl_instance *)data;
- UDEBUG("timer function called, flushing buffer\n");
-
spin_lock_bh(&inst->lock);
if (inst->skb)
__nfulnl_send(inst);
__be32 tmp_uint;
sk_buff_data_t old_tail = inst->skb->tail;
- UDEBUG("entered\n");
-
nlh = NLMSG_PUT(inst->skb, 0, 0,
NFNL_SUBSYS_ULOG << 8 | NFULNL_MSG_PACKET,
sizeof(struct nfgenmsg));
return 0;
nlmsg_failure:
- UDEBUG("nlmsg_failure\n");
nla_put_failure:
PRINTR(KERN_ERR "nfnetlink_log: error creating log nlmsg\n");
return -1;
+ nla_total_size(sizeof(struct nfulnl_msg_packet_hw))
+ nla_total_size(sizeof(struct nfulnl_msg_packet_timestamp));
- UDEBUG("initial size=%u\n", size);
-
spin_lock_bh(&inst->lock);
if (inst->flags & NFULNL_CFG_F_SEQ)
data_len = inst->copy_range;
size += nla_total_size(data_len);
- UDEBUG("copy_packet, therefore size now %u\n", size);
break;
default:
size > skb_tailroom(inst->skb) - sizeof(struct nfgenmsg)) {
/* either the queue len is too high or we don't have
* enough room in the skb left. flush to userspace. */
- UDEBUG("flushing old skb\n");
-
__nfulnl_flush(inst);
}
goto alloc_failure;
}
- UDEBUG("qlen %d, qthreshold %d\n", inst->qlen, qthreshold);
inst->qlen++;
__build_packet_message(inst, skb, data_len, pf,
return;
alloc_failure:
- UDEBUG("error allocating skb\n");
/* FIXME: statistics */
goto unlock_and_release;
}
struct hlist_head *head = &instance_table[i];
hlist_for_each_entry_safe(inst, tmp, t2, head, hlist) {
- UDEBUG("node = %p\n", inst);
if ((n->net == &init_net) &&
(n->pid == inst->peer_pid))
__instance_destroy(inst);
struct nfulnl_instance *inst;
int ret = 0;
- UDEBUG("entering for msg %u\n", NFNL_MSG_TYPE(nlh->nlmsg_type));
-
inst = instance_lookup_get(group_num);
if (inst && inst->peer_pid != NETLINK_CB(skb).pid) {
ret = -EPERM;
struct nfulnl_msg_config_cmd *cmd;
cmd = nla_data(nfula[NFULA_CFG_CMD]);
- UDEBUG("found CFG_CMD for\n");
switch (cmd->command) {
case NFULNL_CFG_CMD_BIND:
instance_destroy(inst);
goto out;
case NFULNL_CFG_CMD_PF_BIND:
- UDEBUG("registering log handler for pf=%u\n", pf);
ret = nf_log_register(pf, &nfulnl_logger);
break;
case NFULNL_CFG_CMD_PF_UNBIND:
- UDEBUG("unregistering log handler for pf=%u\n", pf);
/* This is a bug and a feature. We cannot unregister
* other handlers, like nfnetlink_inst can */
nf_log_unregister_pf(pf);