aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-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
-rw-r--r--include/uapi/linux/netfilter/nf_tables.h4
-rw-r--r--include/uapi/linux/netfilter_bridge/Kbuild1
-rw-r--r--include/uapi/linux/netfilter_bridge/ebt_ulog.h38
-rw-r--r--include/uapi/linux/netfilter_ipv4/Kbuild1
-rw-r--r--include/uapi/linux/netfilter_ipv4/ipt_ULOG.h49
9 files changed, 69 insertions, 152 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;
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 2a88f645a5d8..801bdd1e56e3 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -697,6 +697,8 @@ enum nft_counter_attributes {
697 * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING) 697 * @NFTA_LOG_PREFIX: prefix to prepend to log messages (NLA_STRING)
698 * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32) 698 * @NFTA_LOG_SNAPLEN: length of payload to include in netlink message (NLA_U32)
699 * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32) 699 * @NFTA_LOG_QTHRESHOLD: queue threshold (NLA_U32)
700 * @NFTA_LOG_LEVEL: log level (NLA_U32)
701 * @NFTA_LOG_FLAGS: logging flags (NLA_U32)
700 */ 702 */
701enum nft_log_attributes { 703enum nft_log_attributes {
702 NFTA_LOG_UNSPEC, 704 NFTA_LOG_UNSPEC,
@@ -704,6 +706,8 @@ enum nft_log_attributes {
704 NFTA_LOG_PREFIX, 706 NFTA_LOG_PREFIX,
705 NFTA_LOG_SNAPLEN, 707 NFTA_LOG_SNAPLEN,
706 NFTA_LOG_QTHRESHOLD, 708 NFTA_LOG_QTHRESHOLD,
709 NFTA_LOG_LEVEL,
710 NFTA_LOG_FLAGS,
707 __NFTA_LOG_MAX 711 __NFTA_LOG_MAX
708}; 712};
709#define NFTA_LOG_MAX (__NFTA_LOG_MAX - 1) 713#define NFTA_LOG_MAX (__NFTA_LOG_MAX - 1)
diff --git a/include/uapi/linux/netfilter_bridge/Kbuild b/include/uapi/linux/netfilter_bridge/Kbuild
index 348717c3a22f..0fbad8ef96de 100644
--- a/include/uapi/linux/netfilter_bridge/Kbuild
+++ b/include/uapi/linux/netfilter_bridge/Kbuild
@@ -14,6 +14,5 @@ header-y += ebt_nflog.h
14header-y += ebt_pkttype.h 14header-y += ebt_pkttype.h
15header-y += ebt_redirect.h 15header-y += ebt_redirect.h
16header-y += ebt_stp.h 16header-y += ebt_stp.h
17header-y += ebt_ulog.h
18header-y += ebt_vlan.h 17header-y += ebt_vlan.h
19header-y += ebtables.h 18header-y += ebtables.h
diff --git a/include/uapi/linux/netfilter_bridge/ebt_ulog.h b/include/uapi/linux/netfilter_bridge/ebt_ulog.h
deleted file mode 100644
index 89a6becb5269..000000000000
--- a/include/uapi/linux/netfilter_bridge/ebt_ulog.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef _EBT_ULOG_H
2#define _EBT_ULOG_H
3
4#include <linux/types.h>
5
6#define EBT_ULOG_DEFAULT_NLGROUP 0
7#define EBT_ULOG_DEFAULT_QTHRESHOLD 1
8#define EBT_ULOG_MAXNLGROUPS 32 /* hardcoded netlink max */
9#define EBT_ULOG_PREFIX_LEN 32
10#define EBT_ULOG_MAX_QLEN 50
11#define EBT_ULOG_WATCHER "ulog"
12#define EBT_ULOG_VERSION 1
13
14struct ebt_ulog_info {
15 __u32 nlgroup;
16 unsigned int cprange;
17 unsigned int qthreshold;
18 char prefix[EBT_ULOG_PREFIX_LEN];
19};
20
21typedef struct ebt_ulog_packet_msg {
22 int version;
23 char indev[IFNAMSIZ];
24 char outdev[IFNAMSIZ];
25 char physindev[IFNAMSIZ];
26 char physoutdev[IFNAMSIZ];
27 char prefix[EBT_ULOG_PREFIX_LEN];
28 struct timeval stamp;
29 unsigned long mark;
30 unsigned int hook;
31 size_t data_len;
32 /* The complete packet, including Ethernet header and perhaps
33 * the VLAN header is appended */
34 unsigned char data[0] __attribute__
35 ((aligned (__alignof__(struct ebt_ulog_info))));
36} ebt_ulog_packet_msg_t;
37
38#endif /* _EBT_ULOG_H */
diff --git a/include/uapi/linux/netfilter_ipv4/Kbuild b/include/uapi/linux/netfilter_ipv4/Kbuild
index fb008437dde1..ecb291df390e 100644
--- a/include/uapi/linux/netfilter_ipv4/Kbuild
+++ b/include/uapi/linux/netfilter_ipv4/Kbuild
@@ -5,7 +5,6 @@ header-y += ipt_ECN.h
5header-y += ipt_LOG.h 5header-y += ipt_LOG.h
6header-y += ipt_REJECT.h 6header-y += ipt_REJECT.h
7header-y += ipt_TTL.h 7header-y += ipt_TTL.h
8header-y += ipt_ULOG.h
9header-y += ipt_ah.h 8header-y += ipt_ah.h
10header-y += ipt_ecn.h 9header-y += ipt_ecn.h
11header-y += ipt_ttl.h 10header-y += ipt_ttl.h
diff --git a/include/uapi/linux/netfilter_ipv4/ipt_ULOG.h b/include/uapi/linux/netfilter_ipv4/ipt_ULOG.h
deleted file mode 100644
index 417aad280bcc..000000000000
--- a/include/uapi/linux/netfilter_ipv4/ipt_ULOG.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/* Header file for IP tables userspace logging, Version 1.8
2 *
3 * (C) 2000-2002 by Harald Welte <laforge@gnumonks.org>
4 *
5 * Distributed under the terms of GNU GPL */
6
7#ifndef _IPT_ULOG_H
8#define _IPT_ULOG_H
9
10#ifndef NETLINK_NFLOG
11#define NETLINK_NFLOG 5
12#endif
13
14#define ULOG_DEFAULT_NLGROUP 1
15#define ULOG_DEFAULT_QTHRESHOLD 1
16
17#define ULOG_MAC_LEN 80
18#define ULOG_PREFIX_LEN 32
19
20#define ULOG_MAX_QLEN 50
21/* Why 50? Well... there is a limit imposed by the slab cache 131000
22 * bytes. So the multipart netlink-message has to be < 131000 bytes.
23 * Assuming a standard ethernet-mtu of 1500, we could define this up
24 * to 80... but even 50 seems to be big enough. */
25
26/* private data structure for each rule with a ULOG target */
27struct ipt_ulog_info {
28 unsigned int nl_group;
29 size_t copy_range;
30 size_t qthreshold;
31 char prefix[ULOG_PREFIX_LEN];
32};
33
34/* Format of the ULOG packets passed through netlink */
35typedef struct ulog_packet_msg {
36 unsigned long mark;
37 long timestamp_sec;
38 long timestamp_usec;
39 unsigned int hook;
40 char indev_name[IFNAMSIZ];
41 char outdev_name[IFNAMSIZ];
42 size_t data_len;
43 char prefix[ULOG_PREFIX_LEN];
44 unsigned char mac_len;
45 unsigned char mac[ULOG_MAC_LEN];
46 unsigned char payload[0];
47} ulog_packet_msg_t;
48
49#endif /*_IPT_ULOG_H*/