Skip to content

Commit

Permalink
Merge branch 'master' of git://1984.lsi.us.es/nf-next
Browse files Browse the repository at this point in the history
Pablo Neira Ayuso says:

====================
This batch contains netfilter updates for you net-next tree, they are:

* The new connlabel extension for x_tables, that allows us to attach
  labels to each conntrack flow. The kernel implementation uses a
  bitmask and there's a file in user-space that maps the bits with the
  corresponding string for each existing label. By now, you can attach
  up to 128 overlapping labels. From Florian Westphal.

* A new round of improvements for the netns support for conntrack.
  Gao feng has moved many of the initialization code of each module
  of the netns init path. He also made several code refactoring, that
  code looks cleaner to me now.

* Added documentation for all possible tweaks for nf_conntrack via
  sysctl, from Jiri Pirko.

* Cisco 7941/7945 IP phone support for our SIP conntrack helper,
  from Kevin Cernekee.

* Missing header file in the snmp helper, from Stephen Hemminger.

* Finally, a couple of fixes to resolve minor issues with these
  changes, from myself.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 27, 2013
2 parents 93b9c1d + 5f9f946 commit b640bee
Show file tree
Hide file tree
Showing 43 changed files with 1,305 additions and 429 deletions.
176 changes: 176 additions & 0 deletions Documentation/networking/nf_conntrack-sysctl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/proc/sys/net/netfilter/nf_conntrack_* Variables:

nf_conntrack_acct - BOOLEAN
0 - disabled (default)
not 0 - enabled

Enable connection tracking flow accounting. 64-bit byte and packet
counters per flow are added.

nf_conntrack_buckets - INTEGER (read-only)
Size of hash table. If not specified as parameter during module
loading, the default size is calculated by dividing total memory
by 16384 to determine the number of buckets but the hash table will
never have fewer than 32 or more than 16384 buckets.

nf_conntrack_checksum - BOOLEAN
0 - disabled
not 0 - enabled (default)

Verify checksum of incoming packets. Packets with bad checksums are
in INVALID state. If this is enabled, such packets will not be
considered for connection tracking.

nf_conntrack_count - INTEGER (read-only)
Number of currently allocated flow entries.

nf_conntrack_events - BOOLEAN
0 - disabled
not 0 - enabled (default)

If this option is enabled, the connection tracking code will
provide userspace with connection tracking events via ctnetlink.

nf_conntrack_events_retry_timeout - INTEGER (seconds)
default 15

This option is only relevant when "reliable connection tracking
events" are used. Normally, ctnetlink is "lossy", that is,
events are normally dropped when userspace listeners can't keep up.

Userspace can request "reliable event mode". When this mode is
active, the conntrack will only be destroyed after the event was
delivered. If event delivery fails, the kernel periodically
re-tries to send the event to userspace.

This is the maximum interval the kernel should use when re-trying
to deliver the destroy event.

A higher number means there will be fewer delivery retries and it
will take longer for a backlog to be processed.

nf_conntrack_expect_max - INTEGER
Maximum size of expectation table. Default value is
nf_conntrack_buckets / 256. Minimum is 1.

nf_conntrack_frag6_high_thresh - INTEGER
default 262144

Maximum memory used to reassemble IPv6 fragments. When
nf_conntrack_frag6_high_thresh bytes of memory is allocated for this
purpose, the fragment handler will toss packets until
nf_conntrack_frag6_low_thresh is reached.

nf_conntrack_frag6_low_thresh - INTEGER
default 196608

See nf_conntrack_frag6_low_thresh

nf_conntrack_frag6_timeout - INTEGER (seconds)
default 60

Time to keep an IPv6 fragment in memory.

nf_conntrack_generic_timeout - INTEGER (seconds)
default 600

Default for generic timeout. This refers to layer 4 unknown/unsupported
protocols.

nf_conntrack_helper - BOOLEAN
0 - disabled
not 0 - enabled (default)

Enable automatic conntrack helper assignment.

nf_conntrack_icmp_timeout - INTEGER (seconds)
default 30

Default for ICMP timeout.

nf_conntrack_icmpv6_timeout - INTEGER (seconds)
default 30

Default for ICMP6 timeout.

nf_conntrack_log_invalid - INTEGER
0 - disable (default)
1 - log ICMP packets
6 - log TCP packets
17 - log UDP packets
33 - log DCCP packets
41 - log ICMPv6 packets
136 - log UDPLITE packets
255 - log packets of any protocol

Log invalid packets of a type specified by value.

nf_conntrack_max - INTEGER
Size of connection tracking table. Default value is
nf_conntrack_buckets value * 4.

nf_conntrack_tcp_be_liberal - BOOLEAN
0 - disabled (default)
not 0 - enabled

Be conservative in what you do, be liberal in what you accept from others.
If it's non-zero, we mark only out of window RST segments as INVALID.

nf_conntrack_tcp_loose - BOOLEAN
0 - disabled
not 0 - enabled (default)

If it is set to zero, we disable picking up already established
connections.

nf_conntrack_tcp_max_retrans - INTEGER
default 3

Maximum number of packets that can be retransmitted without
received an (acceptable) ACK from the destination. If this number
is reached, a shorter timer will be started.

nf_conntrack_tcp_timeout_close - INTEGER (seconds)
default 10

nf_conntrack_tcp_timeout_close_wait - INTEGER (seconds)
default 60

nf_conntrack_tcp_timeout_established - INTEGER (seconds)
default 432000 (5 days)

nf_conntrack_tcp_timeout_fin_wait - INTEGER (seconds)
default 120

nf_conntrack_tcp_timeout_last_ack - INTEGER (seconds)
default 30

nf_conntrack_tcp_timeout_max_retrans - INTEGER (seconds)
default 300

nf_conntrack_tcp_timeout_syn_recv - INTEGER (seconds)
default 60

nf_conntrack_tcp_timeout_syn_sent - INTEGER (seconds)
default 120

nf_conntrack_tcp_timeout_time_wait - INTEGER (seconds)
default 120

nf_conntrack_tcp_timeout_unacknowledged - INTEGER (seconds)
default 300

nf_conntrack_timestamp - BOOLEAN
0 - disabled (default)
not 0 - enabled

Enable connection tracking flow timestamping.

nf_conntrack_udp_timeout - INTEGER (seconds)
default 30

nf_conntrack_udp_timeout_stream2 - INTEGER (seconds)
default 180

This extended timeout will be used in case there is an UDP stream
detected.
3 changes: 3 additions & 0 deletions include/linux/netfilter/nf_conntrack_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

#include <net/netfilter/nf_conntrack_expect.h>

#include <linux/types.h>

#define SIP_PORT 5060
#define SIP_TIMEOUT 3600

struct nf_ct_sip_master {
unsigned int register_cseq;
unsigned int invite_cseq;
__be16 forced_dport;
};

enum sip_expectation_classes {
Expand Down
6 changes: 4 additions & 2 deletions include/net/netfilter/nf_conntrack_acct.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ static inline void nf_ct_set_acct(struct net *net, bool enable)
net->ct.sysctl_acct = enable;
}

extern int nf_conntrack_acct_init(struct net *net);
extern void nf_conntrack_acct_fini(struct net *net);
extern int nf_conntrack_acct_pernet_init(struct net *net);
extern void nf_conntrack_acct_pernet_fini(struct net *net);

extern int nf_conntrack_acct_init(void);
extern void nf_conntrack_acct_fini(void);
#endif /* _NF_CONNTRACK_ACCT_H */
15 changes: 11 additions & 4 deletions include/net/netfilter/nf_conntrack_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ extern unsigned int nf_conntrack_in(struct net *net,
unsigned int hooknum,
struct sk_buff *skb);

extern int nf_conntrack_init(struct net *net);
extern void nf_conntrack_cleanup(struct net *net);
extern int nf_conntrack_init_net(struct net *net);
extern void nf_conntrack_cleanup_net(struct net *net);

extern int nf_conntrack_proto_init(struct net *net);
extern void nf_conntrack_proto_fini(struct net *net);
extern int nf_conntrack_proto_pernet_init(struct net *net);
extern void nf_conntrack_proto_pernet_fini(struct net *net);

extern int nf_conntrack_proto_init(void);
extern void nf_conntrack_proto_fini(void);

extern int nf_conntrack_init_start(void);
extern void nf_conntrack_cleanup_start(void);

extern void nf_conntrack_init_end(void);
extern void nf_conntrack_cleanup_end(void);

extern bool
Expand Down
19 changes: 15 additions & 4 deletions include/net/netfilter/nf_conntrack_ecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ nf_ct_expect_event(enum ip_conntrack_expect_events event,
nf_ct_expect_event_report(event, exp, 0, 0);
}

extern int nf_conntrack_ecache_init(struct net *net);
extern void nf_conntrack_ecache_fini(struct net *net);
extern int nf_conntrack_ecache_pernet_init(struct net *net);
extern void nf_conntrack_ecache_pernet_fini(struct net *net);

extern int nf_conntrack_ecache_init(void);
extern void nf_conntrack_ecache_fini(void);
#else /* CONFIG_NF_CONNTRACK_EVENTS */

static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
Expand All @@ -232,12 +234,21 @@ static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
u32 portid,
int report) {}

static inline int nf_conntrack_ecache_init(struct net *net)
static inline int nf_conntrack_ecache_pernet_init(struct net *net)
{
return 0;
}

static inline void nf_conntrack_ecache_fini(struct net *net)
static inline void nf_conntrack_ecache_pernet_fini(struct net *net)
{
}

static inline int nf_conntrack_ecache_init(void)
{
return 0;
}

static inline void nf_conntrack_ecache_fini(void)
{
}
#endif /* CONFIG_NF_CONNTRACK_EVENTS */
Expand Down
7 changes: 5 additions & 2 deletions include/net/netfilter/nf_conntrack_expect.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ struct nf_conntrack_expect_policy {

#define NF_CT_EXPECT_CLASS_DEFAULT 0

int nf_conntrack_expect_init(struct net *net);
void nf_conntrack_expect_fini(struct net *net);
int nf_conntrack_expect_pernet_init(struct net *net);
void nf_conntrack_expect_pernet_fini(struct net *net);

int nf_conntrack_expect_init(void);
void nf_conntrack_expect_fini(void);

struct nf_conntrack_expect *
__nf_ct_expect_find(struct net *net, u16 zone,
Expand Down
4 changes: 4 additions & 0 deletions include/net/netfilter/nf_conntrack_extend.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ enum nf_ct_ext_id {
#endif
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
NF_CT_EXT_TIMEOUT,
#endif
#ifdef CONFIG_NF_CONNTRACK_LABELS
NF_CT_EXT_LABELS,
#endif
NF_CT_EXT_NUM,
};
Expand All @@ -33,6 +36,7 @@ enum nf_ct_ext_id {
#define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone
#define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp
#define NF_CT_EXT_TIMEOUT_TYPE struct nf_conn_timeout
#define NF_CT_EXT_LABELS_TYPE struct nf_conn_labels

/* Extensions: optional stuff which isn't permanently in struct. */
struct nf_ct_ext {
Expand Down
7 changes: 5 additions & 2 deletions include/net/netfilter/nf_conntrack_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ static inline void *nfct_help_data(const struct nf_conn *ct)
return (void *)help->data;
}

extern int nf_conntrack_helper_init(struct net *net);
extern void nf_conntrack_helper_fini(struct net *net);
extern int nf_conntrack_helper_pernet_init(struct net *net);
extern void nf_conntrack_helper_pernet_fini(struct net *net);

extern int nf_conntrack_helper_init(void);
extern void nf_conntrack_helper_fini(void);

extern int nf_conntrack_broadcast_help(struct sk_buff *skb,
unsigned int protoff,
Expand Down
11 changes: 8 additions & 3 deletions include/net/netfilter/nf_conntrack_l3proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@ struct nf_conntrack_l3proto {

extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX];

/* Protocol registration. */
extern int nf_conntrack_l3proto_register(struct net *net,
/* Protocol pernet registration. */
extern int nf_ct_l3proto_pernet_register(struct net *net,
struct nf_conntrack_l3proto *proto);
extern void nf_conntrack_l3proto_unregister(struct net *net,
extern void nf_ct_l3proto_pernet_unregister(struct net *net,
struct nf_conntrack_l3proto *proto);

/* Protocol global registration. */
extern int nf_ct_l3proto_register(struct nf_conntrack_l3proto *proto);
extern void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto *proto);

extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto);
extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);

Expand Down
10 changes: 7 additions & 3 deletions include/net/netfilter/nf_conntrack_l4proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ extern struct nf_conntrack_l4proto *
nf_ct_l4proto_find_get(u_int16_t l3proto, u_int8_t l4proto);
extern void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p);

/* Protocol registration. */
extern int nf_conntrack_l4proto_register(struct net *net,
/* Protocol pernet registration. */
extern int nf_ct_l4proto_pernet_register(struct net *net,
struct nf_conntrack_l4proto *proto);
extern void nf_conntrack_l4proto_unregister(struct net *net,
extern void nf_ct_l4proto_pernet_unregister(struct net *net,
struct nf_conntrack_l4proto *proto);

/* Protocol global registration. */
extern int nf_ct_l4proto_register(struct nf_conntrack_l4proto *proto);
extern void nf_ct_l4proto_unregister(struct nf_conntrack_l4proto *proto);

static inline void nf_ct_kfree_compat_sysctl_table(struct nf_proto_net *pn)
{
#if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
Expand Down
Loading

0 comments on commit b640bee

Please sign in to comment.