mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 01:10:04 +00:00
![Pablo Neira Ayuso](/assets/img/avatar_default.png)
Connection tracking helpers have to drop packets under exceptional situations. Currently, the user gets the following logging message in case that happens: nf_ct_%s: dropping packet ... However, depending on the helper, there are different reasons why a packet can be dropped. This patch modifies the existing code to provide more specific error message in the scope of each helper to help users to debug the reason why the packet has been dropped, ie: nf_ct_%s: dropping packet: reason ... Thanks to Joe Perches for many formatting suggestions. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
52 lines
1.4 KiB
C
52 lines
1.4 KiB
C
/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/udp.h>
|
|
|
|
#include <net/netfilter/nf_conntrack_helper.h>
|
|
#include <net/netfilter/nf_conntrack_expect.h>
|
|
#include <net/netfilter/nf_nat_helper.h>
|
|
#include <linux/netfilter/nf_conntrack_tftp.h>
|
|
|
|
MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
|
|
MODULE_DESCRIPTION("TFTP NAT helper");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("ip_nat_tftp");
|
|
|
|
static unsigned int help(struct sk_buff *skb,
|
|
enum ip_conntrack_info ctinfo,
|
|
struct nf_conntrack_expect *exp)
|
|
{
|
|
const struct nf_conn *ct = exp->master;
|
|
|
|
exp->saved_proto.udp.port
|
|
= ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port;
|
|
exp->dir = IP_CT_DIR_REPLY;
|
|
exp->expectfn = nf_nat_follow_master;
|
|
if (nf_ct_expect_related(exp) != 0) {
|
|
nf_ct_helper_log(skb, exp->master, "cannot add expectation");
|
|
return NF_DROP;
|
|
}
|
|
return NF_ACCEPT;
|
|
}
|
|
|
|
static void __exit nf_nat_tftp_fini(void)
|
|
{
|
|
RCU_INIT_POINTER(nf_nat_tftp_hook, NULL);
|
|
synchronize_rcu();
|
|
}
|
|
|
|
static int __init nf_nat_tftp_init(void)
|
|
{
|
|
BUG_ON(nf_nat_tftp_hook != NULL);
|
|
RCU_INIT_POINTER(nf_nat_tftp_hook, help);
|
|
return 0;
|
|
}
|
|
|
|
module_init(nf_nat_tftp_init);
|
|
module_exit(nf_nat_tftp_fini);
|