aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorGao feng <gaofeng@cn.fujitsu.com>2013-03-24 19:50:40 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-04-05 14:12:54 -0400
commit30e0c6a6bee24db0166b7ca709277cd693e179f2 (patch)
tree264a13fcbf0d76de9e1b3f076ac7f8b045c6c5d5 /net/ipv4
parentf3c1a44a2208d14b061ad665d9549c9b321f38e5 (diff)
netfilter: nf_log: prepare net namespace support for loggers
This patch adds netns support to nf_log and it prepares netns support for existing loggers. It is composed of four major changes. 1) nf_log_register has been split to two functions: nf_log_register and nf_log_set. The new nf_log_register is used to globally register the nf_logger and nf_log_set is used for enabling pernet support from nf_loggers. Per netns is not yet complete after this patch, it comes in separate follow up patches. 2) Add net as a parameter of nf_log_bind_pf. Per netns is not yet complete after this patch, it only allows to bind the nf_logger to the protocol family from init_net and it skips other cases. 3) Adapt all nf_log_packet callers to pass netns as parameter. After this patch, this function only works for init_net. 4) Make the sysctl net/netfilter/nf_log pernet. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/ip_tables.c3
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c8
2 files changed, 6 insertions, 5 deletions
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 1b433aac2663..e391db1f056d 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -258,6 +258,7 @@ static void trace_packet(const struct sk_buff *skb,
258 const char *hookname, *chainname, *comment; 258 const char *hookname, *chainname, *comment;
259 const struct ipt_entry *iter; 259 const struct ipt_entry *iter;
260 unsigned int rulenum = 0; 260 unsigned int rulenum = 0;
261 struct net *net = dev_net(in ? in : out);
261 262
262 table_base = private->entries[smp_processor_id()]; 263 table_base = private->entries[smp_processor_id()];
263 root = get_entry(table_base, private->hook_entry[hook]); 264 root = get_entry(table_base, private->hook_entry[hook]);
@@ -270,7 +271,7 @@ static void trace_packet(const struct sk_buff *skb,
270 &chainname, &comment, &rulenum) != 0) 271 &chainname, &comment, &rulenum) != 0)
271 break; 272 break;
272 273
273 nf_log_packet(AF_INET, hook, skb, in, out, &trace_loginfo, 274 nf_log_packet(net, AF_INET, hook, skb, in, out, &trace_loginfo,
274 "TRACE: %s:%s:%s:%u ", 275 "TRACE: %s:%s:%s:%u ",
275 tablename, chainname, comment, rulenum); 276 tablename, chainname, comment, rulenum);
276} 277}
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index 5241d997ab75..c2cd63d2d892 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -187,8 +187,8 @@ icmp_error(struct net *net, struct nf_conn *tmpl,
187 icmph = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_ih), &_ih); 187 icmph = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_ih), &_ih);
188 if (icmph == NULL) { 188 if (icmph == NULL) {
189 if (LOG_INVALID(net, IPPROTO_ICMP)) 189 if (LOG_INVALID(net, IPPROTO_ICMP))
190 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 190 nf_log_packet(net, PF_INET, 0, skb, NULL, NULL,
191 "nf_ct_icmp: short packet "); 191 NULL, "nf_ct_icmp: short packet ");
192 return -NF_ACCEPT; 192 return -NF_ACCEPT;
193 } 193 }
194 194
@@ -196,7 +196,7 @@ icmp_error(struct net *net, struct nf_conn *tmpl,
196 if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING && 196 if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
197 nf_ip_checksum(skb, hooknum, dataoff, 0)) { 197 nf_ip_checksum(skb, hooknum, dataoff, 0)) {
198 if (LOG_INVALID(net, IPPROTO_ICMP)) 198 if (LOG_INVALID(net, IPPROTO_ICMP))
199 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 199 nf_log_packet(net, PF_INET, 0, skb, NULL, NULL, NULL,
200 "nf_ct_icmp: bad HW ICMP checksum "); 200 "nf_ct_icmp: bad HW ICMP checksum ");
201 return -NF_ACCEPT; 201 return -NF_ACCEPT;
202 } 202 }
@@ -209,7 +209,7 @@ icmp_error(struct net *net, struct nf_conn *tmpl,
209 */ 209 */
210 if (icmph->type > NR_ICMP_TYPES) { 210 if (icmph->type > NR_ICMP_TYPES) {
211 if (LOG_INVALID(net, IPPROTO_ICMP)) 211 if (LOG_INVALID(net, IPPROTO_ICMP))
212 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 212 nf_log_packet(net, PF_INET, 0, skb, NULL, NULL, NULL,
213 "nf_ct_icmp: invalid ICMP type "); 213 "nf_ct_icmp: invalid ICMP type ");
214 return -NF_ACCEPT; 214 return -NF_ACCEPT;
215 } 215 }