aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-07-21 00:01:43 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-21 00:01:43 -0400
commita8138f42d494bcd41a6f7ff301e12fa8d4f330f1 (patch)
tree3ef25c22129c7f72aa0d6667143227b3a62a7708 /include/net
parent6fe82a39e583a50f28f03b294df79c9de9ec0de4 (diff)
parent16ea4c6b9dde2ff44b2bd8bb459daa283cf3a46e (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter updates for net-next The following patchset contains updates for your net-next tree, they are: 1) Use kvfree() helper function from x_tables, from Eric Dumazet. 2) Remove extra timer from the conntrack ecache extension, use a workqueue instead to redeliver lost events to userspace instead, from Florian Westphal. 3) Removal of the ulog targets for ebtables and iptables. The nflog infrastructure superseded this almost 9 years ago, time to get rid of this code. 4) Replace the list of loggers by an array now that we can only have two possible non-overlapping logger flavours, ie. kernel ring buffer and netlink logging. 5) Move Eric Dumazet's log buffer code to nf_log to reuse it from all of the supported per-family loggers. 6) Consolidate nf_log_packet() as an unified interface for packet logging. After this patch, if the struct nf_loginfo is available, it explicitly selects the logger that is used. 7) Move ip and ip6 logging code from xt_LOG to the corresponding per-family loggers. Thus, x_tables and nf_tables share the same code for packet logging. 8) Add generic ARP packet logger, which is used by nf_tables. The format aims to be consistent with the output of xt_LOG. 9) Add generic bridge packet logger. Again, this is used by nf_tables and it routes the packets to the real family loggers. As a result, we get consistent logging format for the bridge family. The ebt_log logging code has been intentionally left in place not to break backward compatibility since the logging output differs from xt_LOG. 10) Update nft_log to explicitly request the required family logger when needed. 11) Finish nft_log so it supports arp, ip, ip6, bridge and inet families. Allowing selection between netlink and kernel buffer ring logging. 12) Several fixes coming after the netfilter core logging changes spotted by robots. 13) Use IS_ENABLED() macros whenever possible in the netfilter tree, from Duan Jiong. 14) Removal of a couple of unnecessary branch before kfree, from Fabian Frederick. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h26
-rw-r--r--include/net/netfilter/nf_log.h42
-rw-r--r--include/net/netfilter/xt_log.h54
-rw-r--r--include/net/netns/conntrack.h6
4 files changed, 65 insertions, 63 deletions
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index 0e3d08e4b1d3..57c880378443 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -18,7 +18,6 @@ struct nf_conntrack_ecache {
18 u16 ctmask; /* bitmask of ct events to be delivered */ 18 u16 ctmask; /* bitmask of ct events to be delivered */
19 u16 expmask; /* bitmask of expect events to be delivered */ 19 u16 expmask; /* bitmask of expect events to be delivered */
20 u32 portid; /* netlink portid of destroyer */ 20 u32 portid; /* netlink portid of destroyer */
21 struct timer_list timeout;
22}; 21};
23 22
24static inline struct nf_conntrack_ecache * 23static inline struct nf_conntrack_ecache *
@@ -216,8 +215,23 @@ void nf_conntrack_ecache_pernet_fini(struct net *net);
216 215
217int nf_conntrack_ecache_init(void); 216int nf_conntrack_ecache_init(void);
218void nf_conntrack_ecache_fini(void); 217void nf_conntrack_ecache_fini(void);
219#else /* CONFIG_NF_CONNTRACK_EVENTS */
220 218
219static inline void nf_conntrack_ecache_delayed_work(struct net *net)
220{
221 if (!delayed_work_pending(&net->ct.ecache_dwork)) {
222 schedule_delayed_work(&net->ct.ecache_dwork, HZ);
223 net->ct.ecache_dwork_pending = true;
224 }
225}
226
227static inline void nf_conntrack_ecache_work(struct net *net)
228{
229 if (net->ct.ecache_dwork_pending) {
230 net->ct.ecache_dwork_pending = false;
231 mod_delayed_work(system_wq, &net->ct.ecache_dwork, 0);
232 }
233}
234#else /* CONFIG_NF_CONNTRACK_EVENTS */
221static inline void nf_conntrack_event_cache(enum ip_conntrack_events event, 235static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
222 struct nf_conn *ct) {} 236 struct nf_conn *ct) {}
223static inline int nf_conntrack_eventmask_report(unsigned int eventmask, 237static inline int nf_conntrack_eventmask_report(unsigned int eventmask,
@@ -255,6 +269,14 @@ static inline int nf_conntrack_ecache_init(void)
255static inline void nf_conntrack_ecache_fini(void) 269static inline void nf_conntrack_ecache_fini(void)
256{ 270{
257} 271}
272
273static inline void nf_conntrack_ecache_delayed_work(struct net *net)
274{
275}
276
277static inline void nf_conntrack_ecache_work(struct net *net)
278{
279}
258#endif /* CONFIG_NF_CONNTRACK_EVENTS */ 280#endif /* CONFIG_NF_CONNTRACK_EVENTS */
259 281
260#endif /*_NF_CONNTRACK_ECACHE_H*/ 282#endif /*_NF_CONNTRACK_ECACHE_H*/
diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h
index 99eac12d040b..534e1f2ac4fc 100644
--- a/include/net/netfilter/nf_log.h
+++ b/include/net/netfilter/nf_log.h
@@ -12,8 +12,11 @@
12#define NF_LOG_UID 0x08 /* Log UID owning local socket */ 12#define NF_LOG_UID 0x08 /* Log UID owning local socket */
13#define NF_LOG_MASK 0x0f 13#define NF_LOG_MASK 0x0f
14 14
15#define NF_LOG_TYPE_LOG 0x01 15enum nf_log_type {
16#define NF_LOG_TYPE_ULOG 0x02 16 NF_LOG_TYPE_LOG = 0,
17 NF_LOG_TYPE_ULOG,
18 NF_LOG_TYPE_MAX
19};
17 20
18struct nf_loginfo { 21struct nf_loginfo {
19 u_int8_t type; 22 u_int8_t type;
@@ -40,10 +43,10 @@ typedef void nf_logfn(struct net *net,
40 const char *prefix); 43 const char *prefix);
41 44
42struct nf_logger { 45struct nf_logger {
43 struct module *me; 46 char *name;
44 nf_logfn *logfn; 47 enum nf_log_type type;
45 char *name; 48 nf_logfn *logfn;
46 struct list_head list[NFPROTO_NUMPROTO]; 49 struct module *me;
47}; 50};
48 51
49/* Function to register/unregister log function. */ 52/* Function to register/unregister log function. */
@@ -58,6 +61,13 @@ int nf_log_bind_pf(struct net *net, u_int8_t pf,
58 const struct nf_logger *logger); 61 const struct nf_logger *logger);
59void nf_log_unbind_pf(struct net *net, u_int8_t pf); 62void nf_log_unbind_pf(struct net *net, u_int8_t pf);
60 63
64int nf_logger_find_get(int pf, enum nf_log_type type);
65void nf_logger_put(int pf, enum nf_log_type type);
66void nf_logger_request_module(int pf, enum nf_log_type type);
67
68#define MODULE_ALIAS_NF_LOGGER(family, type) \
69 MODULE_ALIAS("nf-logger-" __stringify(family) "-" __stringify(type))
70
61/* Calls the registered backend logging function */ 71/* Calls the registered backend logging function */
62__printf(8, 9) 72__printf(8, 9)
63void nf_log_packet(struct net *net, 73void nf_log_packet(struct net *net,
@@ -69,4 +79,24 @@ void nf_log_packet(struct net *net,
69 const struct nf_loginfo *li, 79 const struct nf_loginfo *li,
70 const char *fmt, ...); 80 const char *fmt, ...);
71 81
82struct nf_log_buf;
83
84struct nf_log_buf *nf_log_buf_open(void);
85__printf(2, 3) int nf_log_buf_add(struct nf_log_buf *m, const char *f, ...);
86void nf_log_buf_close(struct nf_log_buf *m);
87
88/* common logging functions */
89int nf_log_dump_udp_header(struct nf_log_buf *m, const struct sk_buff *skb,
90 u8 proto, int fragment, unsigned int offset);
91int nf_log_dump_tcp_header(struct nf_log_buf *m, const struct sk_buff *skb,
92 u8 proto, int fragment, unsigned int offset,
93 unsigned int logflags);
94void nf_log_dump_sk_uid_gid(struct nf_log_buf *m, struct sock *sk);
95void nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,
96 unsigned int hooknum, const struct sk_buff *skb,
97 const struct net_device *in,
98 const struct net_device *out,
99 const struct nf_loginfo *loginfo,
100 const char *prefix);
101
72#endif /* _NF_LOG_H */ 102#endif /* _NF_LOG_H */
diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h
deleted file mode 100644
index 9d9756cca013..000000000000
--- a/include/net/netfilter/xt_log.h
+++ /dev/null
@@ -1,54 +0,0 @@
1#define S_SIZE (1024 - (sizeof(unsigned int) + 1))
2
3struct sbuff {
4 unsigned int count;
5 char buf[S_SIZE + 1];
6};
7static struct sbuff emergency, *emergency_ptr = &emergency;
8
9static __printf(2, 3) int sb_add(struct sbuff *m, const char *f, ...)
10{
11 va_list args;
12 int len;
13
14 if (likely(m->count < S_SIZE)) {
15 va_start(args, f);
16 len = vsnprintf(m->buf + m->count, S_SIZE - m->count, f, args);
17 va_end(args);
18 if (likely(m->count + len < S_SIZE)) {
19 m->count += len;
20 return 0;
21 }
22 }
23 m->count = S_SIZE;
24 printk_once(KERN_ERR KBUILD_MODNAME " please increase S_SIZE\n");
25 return -1;
26}
27
28static struct sbuff *sb_open(void)
29{
30 struct sbuff *m = kmalloc(sizeof(*m), GFP_ATOMIC);
31
32 if (unlikely(!m)) {
33 local_bh_disable();
34 do {
35 m = xchg(&emergency_ptr, NULL);
36 } while (!m);
37 }
38 m->count = 0;
39 return m;
40}
41
42static void sb_close(struct sbuff *m)
43{
44 m->buf[m->count] = 0;
45 printk("%s\n", m->buf);
46
47 if (likely(m != &emergency))
48 kfree(m);
49 else {
50 emergency_ptr = m;
51 local_bh_enable();
52 }
53}
54
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
index 773cce308bc6..29d6a94db54d 100644
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -4,6 +4,7 @@
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/list_nulls.h> 5#include <linux/list_nulls.h>
6#include <linux/atomic.h> 6#include <linux/atomic.h>
7#include <linux/workqueue.h>
7#include <linux/netfilter/nf_conntrack_tcp.h> 8#include <linux/netfilter/nf_conntrack_tcp.h>
8#include <linux/seqlock.h> 9#include <linux/seqlock.h>
9 10
@@ -73,6 +74,10 @@ struct ct_pcpu {
73struct netns_ct { 74struct netns_ct {
74 atomic_t count; 75 atomic_t count;
75 unsigned int expect_count; 76 unsigned int expect_count;
77#ifdef CONFIG_NF_CONNTRACK_EVENTS
78 struct delayed_work ecache_dwork;
79 bool ecache_dwork_pending;
80#endif
76#ifdef CONFIG_SYSCTL 81#ifdef CONFIG_SYSCTL
77 struct ctl_table_header *sysctl_header; 82 struct ctl_table_header *sysctl_header;
78 struct ctl_table_header *acct_sysctl_header; 83 struct ctl_table_header *acct_sysctl_header;
@@ -82,7 +87,6 @@ struct netns_ct {
82#endif 87#endif
83 char *slabname; 88 char *slabname;
84 unsigned int sysctl_log_invalid; /* Log invalid packets */ 89 unsigned int sysctl_log_invalid; /* Log invalid packets */
85 unsigned int sysctl_events_retry_timeout;
86 int sysctl_events; 90 int sysctl_events;
87 int sysctl_acct; 91 int sysctl_acct;
88 int sysctl_auto_assign_helper; 92 int sysctl_auto_assign_helper;