|
@@ -29,7 +29,7 @@
|
|
* Specify, after how many hundredths of a second the queue should be
|
|
* Specify, after how many hundredths of a second the queue should be
|
|
* flushed even if it is not full yet.
|
|
* flushed even if it is not full yet.
|
|
*/
|
|
*/
|
|
-
|
|
|
|
|
|
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/socket.h>
|
|
#include <linux/socket.h>
|
|
@@ -56,8 +56,6 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NFLOG);
|
|
#define ULOG_NL_EVENT 111 /* Harald's favorite number */
|
|
#define ULOG_NL_EVENT 111 /* Harald's favorite number */
|
|
#define ULOG_MAXNLGROUPS 32 /* numer of nlgroups */
|
|
#define ULOG_MAXNLGROUPS 32 /* numer of nlgroups */
|
|
|
|
|
|
-#define PRINTR(format, args...) do { if (net_ratelimit()) printk(format , ## args); } while (0)
|
|
|
|
-
|
|
|
|
static unsigned int nlbufsiz = NLMSG_GOODSIZE;
|
|
static unsigned int nlbufsiz = NLMSG_GOODSIZE;
|
|
module_param(nlbufsiz, uint, 0400);
|
|
module_param(nlbufsiz, uint, 0400);
|
|
MODULE_PARM_DESC(nlbufsiz, "netlink buffer size");
|
|
MODULE_PARM_DESC(nlbufsiz, "netlink buffer size");
|
|
@@ -90,12 +88,12 @@ static void ulog_send(unsigned int nlgroupnum)
|
|
ulog_buff_t *ub = &ulog_buffers[nlgroupnum];
|
|
ulog_buff_t *ub = &ulog_buffers[nlgroupnum];
|
|
|
|
|
|
if (timer_pending(&ub->timer)) {
|
|
if (timer_pending(&ub->timer)) {
|
|
- pr_debug("ipt_ULOG: ulog_send: timer was pending, deleting\n");
|
|
|
|
|
|
+ pr_debug("ulog_send: timer was pending, deleting\n");
|
|
del_timer(&ub->timer);
|
|
del_timer(&ub->timer);
|
|
}
|
|
}
|
|
|
|
|
|
if (!ub->skb) {
|
|
if (!ub->skb) {
|
|
- pr_debug("ipt_ULOG: ulog_send: nothing to send\n");
|
|
|
|
|
|
+ pr_debug("ulog_send: nothing to send\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -104,7 +102,7 @@ static void ulog_send(unsigned int nlgroupnum)
|
|
ub->lastnlh->nlmsg_type = NLMSG_DONE;
|
|
ub->lastnlh->nlmsg_type = NLMSG_DONE;
|
|
|
|
|
|
NETLINK_CB(ub->skb).dst_group = nlgroupnum + 1;
|
|
NETLINK_CB(ub->skb).dst_group = nlgroupnum + 1;
|
|
- pr_debug("ipt_ULOG: throwing %d packets to netlink group %u\n",
|
|
|
|
|
|
+ pr_debug("throwing %d packets to netlink group %u\n",
|
|
ub->qlen, nlgroupnum + 1);
|
|
ub->qlen, nlgroupnum + 1);
|
|
netlink_broadcast(nflognl, ub->skb, 0, nlgroupnum + 1, GFP_ATOMIC);
|
|
netlink_broadcast(nflognl, ub->skb, 0, nlgroupnum + 1, GFP_ATOMIC);
|
|
|
|
|
|
@@ -117,7 +115,7 @@ static void ulog_send(unsigned int nlgroupnum)
|
|
/* timer function to flush queue in flushtimeout time */
|
|
/* timer function to flush queue in flushtimeout time */
|
|
static void ulog_timer(unsigned long data)
|
|
static void ulog_timer(unsigned long data)
|
|
{
|
|
{
|
|
- pr_debug("ipt_ULOG: timer function called, calling ulog_send\n");
|
|
|
|
|
|
+ pr_debug("timer function called, calling ulog_send\n");
|
|
|
|
|
|
/* lock to protect against somebody modifying our structure
|
|
/* lock to protect against somebody modifying our structure
|
|
* from ipt_ulog_target at the same time */
|
|
* from ipt_ulog_target at the same time */
|
|
@@ -138,7 +136,7 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size)
|
|
n = max(size, nlbufsiz);
|
|
n = max(size, nlbufsiz);
|
|
skb = alloc_skb(n, GFP_ATOMIC);
|
|
skb = alloc_skb(n, GFP_ATOMIC);
|
|
if (!skb) {
|
|
if (!skb) {
|
|
- PRINTR("ipt_ULOG: can't alloc whole buffer %ub!\n", n);
|
|
|
|
|
|
+ pr_debug("cannot alloc whole buffer %ub!\n", n);
|
|
|
|
|
|
if (n > size) {
|
|
if (n > size) {
|
|
/* try to allocate only as much as we need for
|
|
/* try to allocate only as much as we need for
|
|
@@ -146,8 +144,7 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size)
|
|
|
|
|
|
skb = alloc_skb(size, GFP_ATOMIC);
|
|
skb = alloc_skb(size, GFP_ATOMIC);
|
|
if (!skb)
|
|
if (!skb)
|
|
- PRINTR("ipt_ULOG: can't even allocate %ub\n",
|
|
|
|
- size);
|
|
|
|
|
|
+ pr_debug("cannot even allocate %ub\n", size);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -198,8 +195,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
|
|
goto alloc_failure;
|
|
goto alloc_failure;
|
|
}
|
|
}
|
|
|
|
|
|
- pr_debug("ipt_ULOG: qlen %d, qthreshold %Zu\n", ub->qlen,
|
|
|
|
- loginfo->qthreshold);
|
|
|
|
|
|
+ pr_debug("qlen %d, qthreshold %Zu\n", ub->qlen, loginfo->qthreshold);
|
|
|
|
|
|
/* NLMSG_PUT contains a hidden goto nlmsg_failure !!! */
|
|
/* NLMSG_PUT contains a hidden goto nlmsg_failure !!! */
|
|
nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT,
|
|
nlh = NLMSG_PUT(ub->skb, 0, ub->qlen, ULOG_NL_EVENT,
|
|
@@ -272,11 +268,9 @@ static void ipt_ulog_packet(unsigned int hooknum,
|
|
return;
|
|
return;
|
|
|
|
|
|
nlmsg_failure:
|
|
nlmsg_failure:
|
|
- PRINTR("ipt_ULOG: error during NLMSG_PUT\n");
|
|
|
|
-
|
|
|
|
|
|
+ pr_debug("error during NLMSG_PUT\n");
|
|
alloc_failure:
|
|
alloc_failure:
|
|
- PRINTR("ipt_ULOG: Error building netlink message\n");
|
|
|
|
-
|
|
|
|
|
|
+ pr_debug("Error building netlink message\n");
|
|
spin_unlock_bh(&ulog_lock);
|
|
spin_unlock_bh(&ulog_lock);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -318,12 +312,11 @@ static bool ulog_tg_check(const struct xt_tgchk_param *par)
|
|
const struct ipt_ulog_info *loginfo = par->targinfo;
|
|
const struct ipt_ulog_info *loginfo = par->targinfo;
|
|
|
|
|
|
if (loginfo->prefix[sizeof(loginfo->prefix) - 1] != '\0') {
|
|
if (loginfo->prefix[sizeof(loginfo->prefix) - 1] != '\0') {
|
|
- pr_debug("ipt_ULOG: prefix term %i\n",
|
|
|
|
- loginfo->prefix[sizeof(loginfo->prefix) - 1]);
|
|
|
|
|
|
+ pr_debug("prefix not null-terminated\n");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
if (loginfo->qthreshold > ULOG_MAX_QLEN) {
|
|
if (loginfo->qthreshold > ULOG_MAX_QLEN) {
|
|
- pr_debug("ipt_ULOG: queue threshold %Zu > MAX_QLEN\n",
|
|
|
|
|
|
+ pr_debug("queue threshold %Zu > MAX_QLEN\n",
|
|
loginfo->qthreshold);
|
|
loginfo->qthreshold);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -389,10 +382,10 @@ static int __init ulog_tg_init(void)
|
|
{
|
|
{
|
|
int ret, i;
|
|
int ret, i;
|
|
|
|
|
|
- pr_debug("ipt_ULOG: init module\n");
|
|
|
|
|
|
+ pr_debug("init module\n");
|
|
|
|
|
|
if (nlbufsiz > 128*1024) {
|
|
if (nlbufsiz > 128*1024) {
|
|
- printk("Netlink buffer has to be <= 128kB\n");
|
|
|
|
|
|
+ pr_warning("Netlink buffer has to be <= 128kB\n");
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -422,7 +415,7 @@ static void __exit ulog_tg_exit(void)
|
|
ulog_buff_t *ub;
|
|
ulog_buff_t *ub;
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- pr_debug("ipt_ULOG: cleanup_module\n");
|
|
|
|
|
|
+ pr_debug("cleanup_module\n");
|
|
|
|
|
|
if (nflog)
|
|
if (nflog)
|
|
nf_log_unregister(&ipt_ulog_logger);
|
|
nf_log_unregister(&ipt_ulog_logger);
|