aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
Diffstat (limited to 'include/net')
-rw-r--r--include/net/9p/9p.h1
-rw-r--r--include/net/9p/transport.h9
-rw-r--r--include/net/bluetooth/hci_core.h3
-rw-r--r--include/net/cfg80211.h89
-rw-r--r--include/net/dsa.h37
-rw-r--r--include/net/flow.h2
-rw-r--r--include/net/ieee80211.h4
-rw-r--r--include/net/inet6_hashtables.h15
-rw-r--r--include/net/inet_connection_sock.h2
-rw-r--r--include/net/inet_hashtables.h18
-rw-r--r--include/net/inet_sock.h20
-rw-r--r--include/net/inet_timewait_sock.h6
-rw-r--r--include/net/ip.h13
-rw-r--r--include/net/ip_vs.h311
-rw-r--r--include/net/ipip.h2
-rw-r--r--include/net/ipv6.h47
-rw-r--r--include/net/mac80211.h239
-rw-r--r--include/net/net_namespace.h6
-rw-r--r--include/net/netfilter/ipv4/nf_defrag_ipv4.h6
-rw-r--r--include/net/netfilter/nf_conntrack.h34
-rw-r--r--include/net/netfilter/nf_conntrack_acct.h10
-rw-r--r--include/net/netfilter/nf_conntrack_core.h11
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h29
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h22
-rw-r--r--include/net/netfilter/nf_conntrack_l4proto.h21
-rw-r--r--include/net/netfilter/nf_log.h8
-rw-r--r--include/net/netfilter/nf_queue.h6
-rw-r--r--include/net/netfilter/nf_tproxy_core.h32
-rw-r--r--include/net/netlink.h84
-rw-r--r--include/net/netns/conntrack.h30
-rw-r--r--include/net/netns/ipv4.h3
-rw-r--r--include/net/netns/mib.h9
-rw-r--r--include/net/phonet/gprs.h38
-rw-r--r--include/net/phonet/pep.h160
-rw-r--r--include/net/phonet/phonet.h112
-rw-r--r--include/net/phonet/pn_dev.h50
-rw-r--r--include/net/pkt_sched.h5
-rw-r--r--include/net/route.h11
-rw-r--r--include/net/sch_generic.h1
-rw-r--r--include/net/sctp/constants.h4
-rw-r--r--include/net/sctp/sctp.h10
-rw-r--r--include/net/sctp/sm.h3
-rw-r--r--include/net/sctp/structs.h34
-rw-r--r--include/net/sctp/tsnmap.h53
-rw-r--r--include/net/sock.h19
-rw-r--r--include/net/tc_act/tc_skbedit.h34
-rw-r--r--include/net/tcp.h52
-rw-r--r--include/net/udp.h21
-rw-r--r--include/net/wireless.h65
-rw-r--r--include/net/xfrm.h104
50 files changed, 1426 insertions, 479 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index b3d3e27c6299..c3626c0ba9d3 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -596,4 +596,5 @@ int p9_idpool_check(int id, struct p9_idpool *p);
596int p9_error_init(void); 596int p9_error_init(void);
597int p9_errstr2errno(char *, int); 597int p9_errstr2errno(char *, int);
598int p9_trans_fd_init(void); 598int p9_trans_fd_init(void);
599void p9_trans_fd_exit(void);
599#endif /* NET_9P_H */ 600#endif /* NET_9P_H */
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index 0db3a4038dc0..3ca737120a90 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -26,6 +26,8 @@
26#ifndef NET_9P_TRANSPORT_H 26#ifndef NET_9P_TRANSPORT_H
27#define NET_9P_TRANSPORT_H 27#define NET_9P_TRANSPORT_H
28 28
29#include <linux/module.h>
30
29/** 31/**
30 * enum p9_trans_status - different states of underlying transports 32 * enum p9_trans_status - different states of underlying transports
31 * @Connected: transport is connected and healthy 33 * @Connected: transport is connected and healthy
@@ -91,9 +93,12 @@ struct p9_trans_module {
91 int maxsize; /* max message size of transport */ 93 int maxsize; /* max message size of transport */
92 int def; /* this transport should be default */ 94 int def; /* this transport should be default */
93 struct p9_trans * (*create)(const char *, char *, int, unsigned char); 95 struct p9_trans * (*create)(const char *, char *, int, unsigned char);
96 struct module *owner;
94}; 97};
95 98
96void v9fs_register_trans(struct p9_trans_module *m); 99void v9fs_register_trans(struct p9_trans_module *m);
97struct p9_trans_module *v9fs_match_trans(const substring_t *name); 100void v9fs_unregister_trans(struct p9_trans_module *m);
98struct p9_trans_module *v9fs_default_trans(void); 101struct p9_trans_module *v9fs_get_trans_by_name(const substring_t *name);
102struct p9_trans_module *v9fs_get_default_trans(void);
103void v9fs_put_trans(struct p9_trans_module *m);
99#endif /* NET_9P_TRANSPORT_H */ 104#endif /* NET_9P_TRANSPORT_H */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index cbf751094688..46a43b721dd6 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -325,7 +325,8 @@ int hci_conn_del(struct hci_conn *conn);
325void hci_conn_hash_flush(struct hci_dev *hdev); 325void hci_conn_hash_flush(struct hci_dev *hdev);
326void hci_conn_check_pending(struct hci_dev *hdev); 326void hci_conn_check_pending(struct hci_dev *hdev);
327 327
328struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *src); 328struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 auth_type);
329int hci_conn_check_link_mode(struct hci_conn *conn);
329int hci_conn_auth(struct hci_conn *conn); 330int hci_conn_auth(struct hci_conn *conn);
330int hci_conn_encrypt(struct hci_conn *conn); 331int hci_conn_encrypt(struct hci_conn *conn);
331int hci_conn_change_link_key(struct hci_conn *conn); 332int hci_conn_change_link_key(struct hci_conn *conn);
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index e00750836ba5..0e85ec39b638 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -152,6 +152,7 @@ struct station_parameters {
152 u16 aid; 152 u16 aid;
153 u8 supported_rates_len; 153 u8 supported_rates_len;
154 u8 plink_action; 154 u8 plink_action;
155 struct ieee80211_ht_cap *ht_capa;
155}; 156};
156 157
157/** 158/**
@@ -268,6 +269,83 @@ struct mpath_info {
268 u8 flags; 269 u8 flags;
269}; 270};
270 271
272/**
273 * struct bss_parameters - BSS parameters
274 *
275 * Used to change BSS parameters (mainly for AP mode).
276 *
277 * @use_cts_prot: Whether to use CTS protection
278 * (0 = no, 1 = yes, -1 = do not change)
279 * @use_short_preamble: Whether the use of short preambles is allowed
280 * (0 = no, 1 = yes, -1 = do not change)
281 * @use_short_slot_time: Whether the use of short slot time is allowed
282 * (0 = no, 1 = yes, -1 = do not change)
283 */
284struct bss_parameters {
285 int use_cts_prot;
286 int use_short_preamble;
287 int use_short_slot_time;
288};
289
290/**
291 * enum reg_set_by - Indicates who is trying to set the regulatory domain
292 * @REGDOM_SET_BY_INIT: regulatory domain was set by initialization. We will be
293 * using a static world regulatory domain by default.
294 * @REGDOM_SET_BY_CORE: Core queried CRDA for a dynamic world regulatory domain.
295 * @REGDOM_SET_BY_USER: User asked the wireless core to set the
296 * regulatory domain.
297 * @REGDOM_SET_BY_DRIVER: a wireless drivers has hinted to the wireless core
298 * it thinks its knows the regulatory domain we should be in.
299 * @REGDOM_SET_BY_COUNTRY_IE: the wireless core has received an 802.11 country
300 * information element with regulatory information it thinks we
301 * should consider.
302 */
303enum reg_set_by {
304 REGDOM_SET_BY_INIT,
305 REGDOM_SET_BY_CORE,
306 REGDOM_SET_BY_USER,
307 REGDOM_SET_BY_DRIVER,
308 REGDOM_SET_BY_COUNTRY_IE,
309};
310
311struct ieee80211_freq_range {
312 u32 start_freq_khz;
313 u32 end_freq_khz;
314 u32 max_bandwidth_khz;
315};
316
317struct ieee80211_power_rule {
318 u32 max_antenna_gain;
319 u32 max_eirp;
320};
321
322struct ieee80211_reg_rule {
323 struct ieee80211_freq_range freq_range;
324 struct ieee80211_power_rule power_rule;
325 u32 flags;
326};
327
328struct ieee80211_regdomain {
329 u32 n_reg_rules;
330 char alpha2[2];
331 struct ieee80211_reg_rule reg_rules[];
332};
333
334#define MHZ_TO_KHZ(freq) (freq * 1000)
335#define KHZ_TO_MHZ(freq) (freq / 1000)
336#define DBI_TO_MBI(gain) (gain * 100)
337#define MBI_TO_DBI(gain) (gain / 100)
338#define DBM_TO_MBM(gain) (gain * 100)
339#define MBM_TO_DBM(gain) (gain / 100)
340
341#define REG_RULE(start, end, bw, gain, eirp, reg_flags) { \
342 .freq_range.start_freq_khz = (start) * 1000, \
343 .freq_range.end_freq_khz = (end) * 1000, \
344 .freq_range.max_bandwidth_khz = (bw) * 1000, \
345 .power_rule.max_antenna_gain = (gain) * 100, \
346 .power_rule.max_eirp = (eirp) * 100, \
347 .flags = reg_flags, \
348 }
271 349
272/* from net/wireless.h */ 350/* from net/wireless.h */
273struct wiphy; 351struct wiphy;
@@ -285,11 +363,13 @@ struct wiphy;
285 * wireless extensions but this is subject to reevaluation as soon as this 363 * wireless extensions but this is subject to reevaluation as soon as this
286 * code is used more widely and we have a first user without wext. 364 * code is used more widely and we have a first user without wext.
287 * 365 *
288 * @add_virtual_intf: create a new virtual interface with the given name 366 * @add_virtual_intf: create a new virtual interface with the given name,
367 * must set the struct wireless_dev's iftype.
289 * 368 *
290 * @del_virtual_intf: remove the virtual interface determined by ifindex. 369 * @del_virtual_intf: remove the virtual interface determined by ifindex.
291 * 370 *
292 * @change_virtual_intf: change type of virtual interface 371 * @change_virtual_intf: change type/configuration of virtual interface,
372 * keep the struct wireless_dev's iftype updated.
293 * 373 *
294 * @add_key: add a key with the given parameters. @mac_addr will be %NULL 374 * @add_key: add a key with the given parameters. @mac_addr will be %NULL
295 * when adding a group key. 375 * when adding a group key.
@@ -318,6 +398,8 @@ struct wiphy;
318 * @change_station: Modify a given station. 398 * @change_station: Modify a given station.
319 * 399 *
320 * @set_mesh_cfg: set mesh parameters (by now, just mesh id) 400 * @set_mesh_cfg: set mesh parameters (by now, just mesh id)
401 *
402 * @change_bss: Modify parameters for a given BSS.
321 */ 403 */
322struct cfg80211_ops { 404struct cfg80211_ops {
323 int (*add_virtual_intf)(struct wiphy *wiphy, char *name, 405 int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
@@ -370,6 +452,9 @@ struct cfg80211_ops {
370 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev, 452 int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev,
371 int idx, u8 *dst, u8 *next_hop, 453 int idx, u8 *dst, u8 *next_hop,
372 struct mpath_info *pinfo); 454 struct mpath_info *pinfo);
455
456 int (*change_bss)(struct wiphy *wiphy, struct net_device *dev,
457 struct bss_parameters *params);
373}; 458};
374 459
375#endif /* __NET_CFG80211_H */ 460#endif /* __NET_CFG80211_H */
diff --git a/include/net/dsa.h b/include/net/dsa.h
new file mode 100644
index 000000000000..52e97bfca5a1
--- /dev/null
+++ b/include/net/dsa.h
@@ -0,0 +1,37 @@
1/*
2 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
3 * Copyright (c) 2008 Marvell Semiconductor
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#ifndef __LINUX_NET_DSA_H
12#define __LINUX_NET_DSA_H
13
14#define DSA_MAX_PORTS 12
15
16struct dsa_platform_data {
17 /*
18 * Reference to a Linux network interface that connects
19 * to the switch chip.
20 */
21 struct device *netdev;
22
23 /*
24 * How to access the switch configuration registers, and
25 * the names of the switch ports (use "cpu" to designate
26 * the switch port that the cpu is connected to).
27 */
28 struct device *mii_bus;
29 int sw_addr;
30 char *port_names[DSA_MAX_PORTS];
31};
32
33extern bool dsa_uses_dsa_tags(void *dsa_ptr);
34extern bool dsa_uses_trailer_tags(void *dsa_ptr);
35
36
37#endif
diff --git a/include/net/flow.h b/include/net/flow.h
index 228b2477ceec..b45a5e4fcadd 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -47,6 +47,8 @@ struct flowi {
47#define fl4_scope nl_u.ip4_u.scope 47#define fl4_scope nl_u.ip4_u.scope
48 48
49 __u8 proto; 49 __u8 proto;
50 __u8 flags;
51#define FLOWI_FLAG_ANYSRC 0x01
50 union { 52 union {
51 struct { 53 struct {
52 __be16 sport; 54 __be16 sport;
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index b31399e1fd83..6048579d0b24 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -190,10 +190,6 @@ const char *escape_essid(const char *essid, u8 essid_len);
190#endif 190#endif
191#include <net/iw_handler.h> /* new driver API */ 191#include <net/iw_handler.h> /* new driver API */
192 192
193#ifndef ETH_P_PAE
194#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
195#endif /* ETH_P_PAE */
196
197#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ 193#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
198 194
199#ifndef ETH_P_80211_RAW 195#ifndef ETH_P_80211_RAW
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index e48989f04c24..f74665d7bea8 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -91,6 +91,21 @@ static inline struct sock *__inet6_lookup(struct net *net,
91 return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif); 91 return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif);
92} 92}
93 93
94static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo,
95 struct sk_buff *skb,
96 const __be16 sport,
97 const __be16 dport)
98{
99 struct sock *sk;
100
101 if (unlikely(sk = skb_steal_sock(skb)))
102 return sk;
103 else return __inet6_lookup(dev_net(skb->dst->dev), hashinfo,
104 &ipv6_hdr(skb)->saddr, sport,
105 &ipv6_hdr(skb)->daddr, ntohs(dport),
106 inet6_iif(skb));
107}
108
94extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, 109extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
95 const struct in6_addr *saddr, const __be16 sport, 110 const struct in6_addr *saddr, const __be16 sport,
96 const struct in6_addr *daddr, const __be16 dport, 111 const struct in6_addr *daddr, const __be16 dport,
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 2ff545a56fb5..03cffd9f64e3 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -51,12 +51,14 @@ struct inet_connection_sock_af_ops {
51 char __user *optval, int optlen); 51 char __user *optval, int optlen);
52 int (*getsockopt)(struct sock *sk, int level, int optname, 52 int (*getsockopt)(struct sock *sk, int level, int optname,
53 char __user *optval, int __user *optlen); 53 char __user *optval, int __user *optlen);
54#ifdef CONFIG_COMPAT
54 int (*compat_setsockopt)(struct sock *sk, 55 int (*compat_setsockopt)(struct sock *sk,
55 int level, int optname, 56 int level, int optname,
56 char __user *optval, int optlen); 57 char __user *optval, int optlen);
57 int (*compat_getsockopt)(struct sock *sk, 58 int (*compat_getsockopt)(struct sock *sk,
58 int level, int optname, 59 int level, int optname,
59 char __user *optval, int __user *optlen); 60 char __user *optval, int __user *optlen);
61#endif
60 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); 62 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
61 int (*bind_conflict)(const struct sock *sk, 63 int (*bind_conflict)(const struct sock *sk,
62 const struct inet_bind_bucket *tb); 64 const struct inet_bind_bucket *tb);
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index bb619d80f2e2..5cc182f9ecae 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -16,6 +16,7 @@
16 16
17 17
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/ip.h>
19#include <linux/ipv6.h> 20#include <linux/ipv6.h>
20#include <linux/list.h> 21#include <linux/list.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
@@ -28,6 +29,7 @@
28#include <net/inet_connection_sock.h> 29#include <net/inet_connection_sock.h>
29#include <net/inet_sock.h> 30#include <net/inet_sock.h>
30#include <net/sock.h> 31#include <net/sock.h>
32#include <net/route.h>
31#include <net/tcp_states.h> 33#include <net/tcp_states.h>
32#include <net/netns/hash.h> 34#include <net/netns/hash.h>
33 35
@@ -371,6 +373,22 @@ static inline struct sock *inet_lookup(struct net *net,
371 return sk; 373 return sk;
372} 374}
373 375
376static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
377 struct sk_buff *skb,
378 const __be16 sport,
379 const __be16 dport)
380{
381 struct sock *sk;
382 const struct iphdr *iph = ip_hdr(skb);
383
384 if (unlikely(sk = skb_steal_sock(skb)))
385 return sk;
386 else
387 return __inet_lookup(dev_net(skb->dst->dev), hashinfo,
388 iph->saddr, sport,
389 iph->daddr, dport, inet_iif(skb));
390}
391
374extern int __inet_hash_connect(struct inet_timewait_death_row *death_row, 392extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
375 struct sock *sk, u32 port_offset, 393 struct sock *sk, u32 port_offset,
376 int (*check_established)(struct inet_timewait_death_row *, 394 int (*check_established)(struct inet_timewait_death_row *,
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 643e26be058e..de0ecc71cf03 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -24,7 +24,6 @@
24#include <net/flow.h> 24#include <net/flow.h>
25#include <net/sock.h> 25#include <net/sock.h>
26#include <net/request_sock.h> 26#include <net/request_sock.h>
27#include <net/route.h>
28#include <net/netns/hash.h> 27#include <net/netns/hash.h>
29 28
30/** struct ip_options - IP Options 29/** struct ip_options - IP Options
@@ -62,8 +61,8 @@ struct inet_request_sock {
62 struct request_sock req; 61 struct request_sock req;
63#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 62#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
64 u16 inet6_rsk_offset; 63 u16 inet6_rsk_offset;
65 /* 2 bytes hole, try to pack */
66#endif 64#endif
65 __be16 loc_port;
67 __be32 loc_addr; 66 __be32 loc_addr;
68 __be32 rmt_addr; 67 __be32 rmt_addr;
69 __be16 rmt_port; 68 __be16 rmt_port;
@@ -73,7 +72,8 @@ struct inet_request_sock {
73 sack_ok : 1, 72 sack_ok : 1,
74 wscale_ok : 1, 73 wscale_ok : 1,
75 ecn_ok : 1, 74 ecn_ok : 1,
76 acked : 1; 75 acked : 1,
76 no_srccheck: 1;
77 struct ip_options *opt; 77 struct ip_options *opt;
78}; 78};
79 79
@@ -129,7 +129,8 @@ struct inet_sock {
129 is_icsk:1, 129 is_icsk:1,
130 freebind:1, 130 freebind:1,
131 hdrincl:1, 131 hdrincl:1,
132 mc_loop:1; 132 mc_loop:1,
133 transparent:1;
133 int mc_index; 134 int mc_index;
134 __be32 mc_addr; 135 __be32 mc_addr;
135 struct ip_mc_socklist *mc_list; 136 struct ip_mc_socklist *mc_list;
@@ -194,12 +195,6 @@ static inline int inet_sk_ehashfn(const struct sock *sk)
194 return inet_ehashfn(net, laddr, lport, faddr, fport); 195 return inet_ehashfn(net, laddr, lport, faddr, fport);
195} 196}
196 197
197
198static inline int inet_iif(const struct sk_buff *skb)
199{
200 return skb->rtable->rt_iif;
201}
202
203static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops) 198static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops)
204{ 199{
205 struct request_sock *req = reqsk_alloc(ops); 200 struct request_sock *req = reqsk_alloc(ops);
@@ -210,4 +205,9 @@ static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops
210 return req; 205 return req;
211} 206}
212 207
208static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
209{
210 return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0;
211}
212
213#endif /* _INET_SOCK_H */ 213#endif /* _INET_SOCK_H */
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 95c660c9719b..80e4977631b8 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -128,7 +128,8 @@ struct inet_timewait_sock {
128 __be16 tw_dport; 128 __be16 tw_dport;
129 __u16 tw_num; 129 __u16 tw_num;
130 /* And these are ours. */ 130 /* And these are ours. */
131 __u8 tw_ipv6only:1; 131 __u8 tw_ipv6only:1,
132 tw_transparent:1;
132 /* 15 bits hole, try to pack */ 133 /* 15 bits hole, try to pack */
133 __u16 tw_ipv6_offset; 134 __u16 tw_ipv6_offset;
134 unsigned long tw_ttd; 135 unsigned long tw_ttd;
@@ -208,6 +209,9 @@ extern void inet_twsk_schedule(struct inet_timewait_sock *tw,
208extern void inet_twsk_deschedule(struct inet_timewait_sock *tw, 209extern void inet_twsk_deschedule(struct inet_timewait_sock *tw,
209 struct inet_timewait_death_row *twdr); 210 struct inet_timewait_death_row *twdr);
210 211
212extern void inet_twsk_purge(struct net *net, struct inet_hashinfo *hashinfo,
213 struct inet_timewait_death_row *twdr, int family);
214
211static inline 215static inline
212struct net *twsk_net(const struct inet_timewait_sock *twsk) 216struct net *twsk_net(const struct inet_timewait_sock *twsk)
213{ 217{
diff --git a/include/net/ip.h b/include/net/ip.h
index 250e6ef025a4..1cbccaf0de3f 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -29,6 +29,7 @@
29 29
30#include <net/inet_sock.h> 30#include <net/inet_sock.h>
31#include <net/snmp.h> 31#include <net/snmp.h>
32#include <net/flow.h>
32 33
33struct sock; 34struct sock;
34 35
@@ -140,12 +141,20 @@ static inline void ip_tr_mc_map(__be32 addr, char *buf)
140 141
141struct ip_reply_arg { 142struct ip_reply_arg {
142 struct kvec iov[1]; 143 struct kvec iov[1];
144 int flags;
143 __wsum csum; 145 __wsum csum;
144 int csumoffset; /* u16 offset of csum in iov[0].iov_base */ 146 int csumoffset; /* u16 offset of csum in iov[0].iov_base */
145 /* -1 if not needed */ 147 /* -1 if not needed */
146 int bound_dev_if; 148 int bound_dev_if;
147}; 149};
148 150
151#define IP_REPLY_ARG_NOSRCCHECK 1
152
153static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg)
154{
155 return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0;
156}
157
149void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg, 158void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg,
150 unsigned int len); 159 unsigned int len);
151 160
@@ -169,6 +178,10 @@ extern unsigned long snmp_fold_field(void *mib[], int offt);
169extern int snmp_mib_init(void *ptr[2], size_t mibsize); 178extern int snmp_mib_init(void *ptr[2], size_t mibsize);
170extern void snmp_mib_free(void *ptr[2]); 179extern void snmp_mib_free(void *ptr[2]);
171 180
181extern struct local_ports {
182 seqlock_t lock;
183 int range[2];
184} sysctl_local_ports;
172extern void inet_get_local_port_range(int *low, int *high); 185extern void inet_get_local_port_range(int *low, int *high);
173 186
174extern int sysctl_ip_default_ttl; 187extern int sysctl_ip_default_ttl;
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 7312c3dd309f..0b2071d9326d 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -21,11 +21,104 @@
21#include <linux/timer.h> 21#include <linux/timer.h>
22 22
23#include <net/checksum.h> 23#include <net/checksum.h>
24#include <linux/netfilter.h> /* for union nf_inet_addr */
25#include <linux/ip.h>
26#include <linux/ipv6.h> /* for struct ipv6hdr */
27#include <net/ipv6.h> /* for ipv6_addr_copy */
28
29struct ip_vs_iphdr {
30 int len;
31 __u8 protocol;
32 union nf_inet_addr saddr;
33 union nf_inet_addr daddr;
34};
35
36static inline void
37ip_vs_fill_iphdr(int af, const void *nh, struct ip_vs_iphdr *iphdr)
38{
39#ifdef CONFIG_IP_VS_IPV6
40 if (af == AF_INET6) {
41 const struct ipv6hdr *iph = nh;
42 iphdr->len = sizeof(struct ipv6hdr);
43 iphdr->protocol = iph->nexthdr;
44 ipv6_addr_copy(&iphdr->saddr.in6, &iph->saddr);
45 ipv6_addr_copy(&iphdr->daddr.in6, &iph->daddr);
46 } else
47#endif
48 {
49 const struct iphdr *iph = nh;
50 iphdr->len = iph->ihl * 4;
51 iphdr->protocol = iph->protocol;
52 iphdr->saddr.ip = iph->saddr;
53 iphdr->daddr.ip = iph->daddr;
54 }
55}
56
57static inline void ip_vs_addr_copy(int af, union nf_inet_addr *dst,
58 const union nf_inet_addr *src)
59{
60#ifdef CONFIG_IP_VS_IPV6
61 if (af == AF_INET6)
62 ipv6_addr_copy(&dst->in6, &src->in6);
63 else
64#endif
65 dst->ip = src->ip;
66}
67
68static inline int ip_vs_addr_equal(int af, const union nf_inet_addr *a,
69 const union nf_inet_addr *b)
70{
71#ifdef CONFIG_IP_VS_IPV6
72 if (af == AF_INET6)
73 return ipv6_addr_equal(&a->in6, &b->in6);
74#endif
75 return a->ip == b->ip;
76}
24 77
25#ifdef CONFIG_IP_VS_DEBUG 78#ifdef CONFIG_IP_VS_DEBUG
26#include <linux/net.h> 79#include <linux/net.h>
27 80
28extern int ip_vs_get_debug_level(void); 81extern int ip_vs_get_debug_level(void);
82
83static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
84 const union nf_inet_addr *addr,
85 int *idx)
86{
87 int len;
88#ifdef CONFIG_IP_VS_IPV6
89 if (af == AF_INET6)
90 len = snprintf(&buf[*idx], buf_len - *idx, "[" NIP6_FMT "]",
91 NIP6(addr->in6)) + 1;
92 else
93#endif
94 len = snprintf(&buf[*idx], buf_len - *idx, NIPQUAD_FMT,
95 NIPQUAD(addr->ip)) + 1;
96
97 *idx += len;
98 BUG_ON(*idx > buf_len + 1);
99 return &buf[*idx - len];
100}
101
102#define IP_VS_DBG_BUF(level, msg...) \
103 do { \
104 char ip_vs_dbg_buf[160]; \
105 int ip_vs_dbg_idx = 0; \
106 if (level <= ip_vs_get_debug_level()) \
107 printk(KERN_DEBUG "IPVS: " msg); \
108 } while (0)
109#define IP_VS_ERR_BUF(msg...) \
110 do { \
111 char ip_vs_dbg_buf[160]; \
112 int ip_vs_dbg_idx = 0; \
113 printk(KERN_ERR "IPVS: " msg); \
114 } while (0)
115
116/* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */
117#define IP_VS_DBG_ADDR(af, addr) \
118 ip_vs_dbg_addr(af, ip_vs_dbg_buf, \
119 sizeof(ip_vs_dbg_buf), addr, \
120 &ip_vs_dbg_idx)
121
29#define IP_VS_DBG(level, msg...) \ 122#define IP_VS_DBG(level, msg...) \
30 do { \ 123 do { \
31 if (level <= ip_vs_get_debug_level()) \ 124 if (level <= ip_vs_get_debug_level()) \
@@ -48,6 +141,8 @@ extern int ip_vs_get_debug_level(void);
48 pp->debug_packet(pp, skb, ofs, msg); \ 141 pp->debug_packet(pp, skb, ofs, msg); \
49 } while (0) 142 } while (0)
50#else /* NO DEBUGGING at ALL */ 143#else /* NO DEBUGGING at ALL */
144#define IP_VS_DBG_BUF(level, msg...) do {} while (0)
145#define IP_VS_ERR_BUF(msg...) do {} while (0)
51#define IP_VS_DBG(level, msg...) do {} while (0) 146#define IP_VS_DBG(level, msg...) do {} while (0)
52#define IP_VS_DBG_RL(msg...) do {} while (0) 147#define IP_VS_DBG_RL(msg...) do {} while (0)
53#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) 148#define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0)
@@ -160,27 +255,10 @@ struct ip_vs_estimator {
160 255
161struct ip_vs_stats 256struct ip_vs_stats
162{ 257{
163 __u32 conns; /* connections scheduled */ 258 struct ip_vs_stats_user ustats; /* statistics */
164 __u32 inpkts; /* incoming packets */ 259 struct ip_vs_estimator est; /* estimator */
165 __u32 outpkts; /* outgoing packets */
166 __u64 inbytes; /* incoming bytes */
167 __u64 outbytes; /* outgoing bytes */
168
169 __u32 cps; /* current connection rate */
170 __u32 inpps; /* current in packet rate */
171 __u32 outpps; /* current out packet rate */
172 __u32 inbps; /* current in byte rate */
173 __u32 outbps; /* current out byte rate */
174
175 /*
176 * Don't add anything before the lock, because we use memcpy() to copy
177 * the members before the lock to struct ip_vs_stats_user in
178 * ip_vs_ctl.c.
179 */
180 260
181 spinlock_t lock; /* spin lock */ 261 spinlock_t lock; /* spin lock */
182
183 struct ip_vs_estimator est; /* estimator */
184}; 262};
185 263
186struct dst_entry; 264struct dst_entry;
@@ -202,21 +280,23 @@ struct ip_vs_protocol {
202 280
203 void (*exit)(struct ip_vs_protocol *pp); 281 void (*exit)(struct ip_vs_protocol *pp);
204 282
205 int (*conn_schedule)(struct sk_buff *skb, 283 int (*conn_schedule)(int af, struct sk_buff *skb,
206 struct ip_vs_protocol *pp, 284 struct ip_vs_protocol *pp,
207 int *verdict, struct ip_vs_conn **cpp); 285 int *verdict, struct ip_vs_conn **cpp);
208 286
209 struct ip_vs_conn * 287 struct ip_vs_conn *
210 (*conn_in_get)(const struct sk_buff *skb, 288 (*conn_in_get)(int af,
289 const struct sk_buff *skb,
211 struct ip_vs_protocol *pp, 290 struct ip_vs_protocol *pp,
212 const struct iphdr *iph, 291 const struct ip_vs_iphdr *iph,
213 unsigned int proto_off, 292 unsigned int proto_off,
214 int inverse); 293 int inverse);
215 294
216 struct ip_vs_conn * 295 struct ip_vs_conn *
217 (*conn_out_get)(const struct sk_buff *skb, 296 (*conn_out_get)(int af,
297 const struct sk_buff *skb,
218 struct ip_vs_protocol *pp, 298 struct ip_vs_protocol *pp,
219 const struct iphdr *iph, 299 const struct ip_vs_iphdr *iph,
220 unsigned int proto_off, 300 unsigned int proto_off,
221 int inverse); 301 int inverse);
222 302
@@ -226,7 +306,8 @@ struct ip_vs_protocol {
226 int (*dnat_handler)(struct sk_buff *skb, 306 int (*dnat_handler)(struct sk_buff *skb,
227 struct ip_vs_protocol *pp, struct ip_vs_conn *cp); 307 struct ip_vs_protocol *pp, struct ip_vs_conn *cp);
228 308
229 int (*csum_check)(struct sk_buff *skb, struct ip_vs_protocol *pp); 309 int (*csum_check)(int af, struct sk_buff *skb,
310 struct ip_vs_protocol *pp);
230 311
231 const char *(*state_name)(int state); 312 const char *(*state_name)(int state);
232 313
@@ -259,9 +340,10 @@ struct ip_vs_conn {
259 struct list_head c_list; /* hashed list heads */ 340 struct list_head c_list; /* hashed list heads */
260 341
261 /* Protocol, addresses and port numbers */ 342 /* Protocol, addresses and port numbers */
262 __be32 caddr; /* client address */ 343 u16 af; /* address family */
263 __be32 vaddr; /* virtual address */ 344 union nf_inet_addr caddr; /* client address */
264 __be32 daddr; /* destination address */ 345 union nf_inet_addr vaddr; /* virtual address */
346 union nf_inet_addr daddr; /* destination address */
265 __be16 cport; 347 __be16 cport;
266 __be16 vport; 348 __be16 vport;
267 __be16 dport; 349 __be16 dport;
@@ -305,6 +387,45 @@ struct ip_vs_conn {
305 387
306 388
307/* 389/*
390 * Extended internal versions of struct ip_vs_service_user and
391 * ip_vs_dest_user for IPv6 support.
392 *
393 * We need these to conveniently pass around service and destination
394 * options, but unfortunately, we also need to keep the old definitions to
395 * maintain userspace backwards compatibility for the setsockopt interface.
396 */
397struct ip_vs_service_user_kern {
398 /* virtual service addresses */
399 u16 af;
400 u16 protocol;
401 union nf_inet_addr addr; /* virtual ip address */
402 u16 port;
403 u32 fwmark; /* firwall mark of service */
404
405 /* virtual service options */
406 char *sched_name;
407 unsigned flags; /* virtual service flags */
408 unsigned timeout; /* persistent timeout in sec */
409 u32 netmask; /* persistent netmask */
410};
411
412
413struct ip_vs_dest_user_kern {
414 /* destination server address */
415 union nf_inet_addr addr;
416 u16 port;
417
418 /* real server options */
419 unsigned conn_flags; /* connection flags */
420 int weight; /* destination weight */
421
422 /* thresholds for active connections */
423 u32 u_threshold; /* upper threshold */
424 u32 l_threshold; /* lower threshold */
425};
426
427
428/*
308 * The information about the virtual service offered to the net 429 * The information about the virtual service offered to the net
309 * and the forwarding entries 430 * and the forwarding entries
310 */ 431 */
@@ -314,8 +435,9 @@ struct ip_vs_service {
314 atomic_t refcnt; /* reference counter */ 435 atomic_t refcnt; /* reference counter */
315 atomic_t usecnt; /* use counter */ 436 atomic_t usecnt; /* use counter */
316 437
438 u16 af; /* address family */
317 __u16 protocol; /* which protocol (TCP/UDP) */ 439 __u16 protocol; /* which protocol (TCP/UDP) */
318 __be32 addr; /* IP address for virtual service */ 440 union nf_inet_addr addr; /* IP address for virtual service */
319 __be16 port; /* port number for the service */ 441 __be16 port; /* port number for the service */
320 __u32 fwmark; /* firewall mark of the service */ 442 __u32 fwmark; /* firewall mark of the service */
321 unsigned flags; /* service status flags */ 443 unsigned flags; /* service status flags */
@@ -342,7 +464,8 @@ struct ip_vs_dest {
342 struct list_head n_list; /* for the dests in the service */ 464 struct list_head n_list; /* for the dests in the service */
343 struct list_head d_list; /* for table with all the dests */ 465 struct list_head d_list; /* for table with all the dests */
344 466
345 __be32 addr; /* IP address of the server */ 467 u16 af; /* address family */
468 union nf_inet_addr addr; /* IP address of the server */
346 __be16 port; /* port number of the server */ 469 __be16 port; /* port number of the server */
347 volatile unsigned flags; /* dest status flags */ 470 volatile unsigned flags; /* dest status flags */
348 atomic_t conn_flags; /* flags to copy to conn */ 471 atomic_t conn_flags; /* flags to copy to conn */
@@ -366,7 +489,7 @@ struct ip_vs_dest {
366 /* for virtual service */ 489 /* for virtual service */
367 struct ip_vs_service *svc; /* service it belongs to */ 490 struct ip_vs_service *svc; /* service it belongs to */
368 __u16 protocol; /* which protocol (TCP/UDP) */ 491 __u16 protocol; /* which protocol (TCP/UDP) */
369 __be32 vaddr; /* virtual IP address */ 492 union nf_inet_addr vaddr; /* virtual IP address */
370 __be16 vport; /* virtual port number */ 493 __be16 vport; /* virtual port number */
371 __u32 vfwmark; /* firewall mark of service */ 494 __u32 vfwmark; /* firewall mark of service */
372}; 495};
@@ -380,6 +503,9 @@ struct ip_vs_scheduler {
380 char *name; /* scheduler name */ 503 char *name; /* scheduler name */
381 atomic_t refcnt; /* reference counter */ 504 atomic_t refcnt; /* reference counter */
382 struct module *module; /* THIS_MODULE/NULL */ 505 struct module *module; /* THIS_MODULE/NULL */
506#ifdef CONFIG_IP_VS_IPV6
507 int supports_ipv6; /* scheduler has IPv6 support */
508#endif
383 509
384 /* scheduler initializing service */ 510 /* scheduler initializing service */
385 int (*init_service)(struct ip_vs_service *svc); 511 int (*init_service)(struct ip_vs_service *svc);
@@ -479,16 +605,8 @@ extern void ip_vs_init_hash_table(struct list_head *table, int rows);
479#ifndef CONFIG_IP_VS_TAB_BITS 605#ifndef CONFIG_IP_VS_TAB_BITS
480#define CONFIG_IP_VS_TAB_BITS 12 606#define CONFIG_IP_VS_TAB_BITS 12
481#endif 607#endif
482/* make sure that IP_VS_CONN_TAB_BITS is located in [8, 20] */ 608
483#if CONFIG_IP_VS_TAB_BITS < 8
484#define IP_VS_CONN_TAB_BITS 8
485#endif
486#if CONFIG_IP_VS_TAB_BITS > 20
487#define IP_VS_CONN_TAB_BITS 20
488#endif
489#if 8 <= CONFIG_IP_VS_TAB_BITS && CONFIG_IP_VS_TAB_BITS <= 20
490#define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS 609#define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS
491#endif
492#define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS) 610#define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS)
493#define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1) 611#define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1)
494 612
@@ -500,11 +618,16 @@ enum {
500}; 618};
501 619
502extern struct ip_vs_conn *ip_vs_conn_in_get 620extern struct ip_vs_conn *ip_vs_conn_in_get
503(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port); 621(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port,
622 const union nf_inet_addr *d_addr, __be16 d_port);
623
504extern struct ip_vs_conn *ip_vs_ct_in_get 624extern struct ip_vs_conn *ip_vs_ct_in_get
505(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port); 625(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port,
626 const union nf_inet_addr *d_addr, __be16 d_port);
627
506extern struct ip_vs_conn *ip_vs_conn_out_get 628extern struct ip_vs_conn *ip_vs_conn_out_get
507(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port); 629(int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port,
630 const union nf_inet_addr *d_addr, __be16 d_port);
508 631
509/* put back the conn without restarting its timer */ 632/* put back the conn without restarting its timer */
510static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) 633static inline void __ip_vs_conn_put(struct ip_vs_conn *cp)
@@ -515,8 +638,9 @@ extern void ip_vs_conn_put(struct ip_vs_conn *cp);
515extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); 638extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport);
516 639
517extern struct ip_vs_conn * 640extern struct ip_vs_conn *
518ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport, 641ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport,
519 __be32 daddr, __be16 dport, unsigned flags, 642 const union nf_inet_addr *vaddr, __be16 vport,
643 const union nf_inet_addr *daddr, __be16 dport, unsigned flags,
520 struct ip_vs_dest *dest); 644 struct ip_vs_dest *dest);
521extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); 645extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp);
522 646
@@ -532,24 +656,32 @@ static inline void ip_vs_control_del(struct ip_vs_conn *cp)
532{ 656{
533 struct ip_vs_conn *ctl_cp = cp->control; 657 struct ip_vs_conn *ctl_cp = cp->control;
534 if (!ctl_cp) { 658 if (!ctl_cp) {
535 IP_VS_ERR("request control DEL for uncontrolled: " 659 IP_VS_ERR_BUF("request control DEL for uncontrolled: "
536 "%d.%d.%d.%d:%d to %d.%d.%d.%d:%d\n", 660 "%s:%d to %s:%d\n",
537 NIPQUAD(cp->caddr),ntohs(cp->cport), 661 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
538 NIPQUAD(cp->vaddr),ntohs(cp->vport)); 662 ntohs(cp->cport),
663 IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
664 ntohs(cp->vport));
665
539 return; 666 return;
540 } 667 }
541 668
542 IP_VS_DBG(7, "DELeting control for: " 669 IP_VS_DBG_BUF(7, "DELeting control for: "
543 "cp.dst=%d.%d.%d.%d:%d ctl_cp.dst=%d.%d.%d.%d:%d\n", 670 "cp.dst=%s:%d ctl_cp.dst=%s:%d\n",
544 NIPQUAD(cp->caddr),ntohs(cp->cport), 671 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
545 NIPQUAD(ctl_cp->caddr),ntohs(ctl_cp->cport)); 672 ntohs(cp->cport),
673 IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr),
674 ntohs(ctl_cp->cport));
546 675
547 cp->control = NULL; 676 cp->control = NULL;
548 if (atomic_read(&ctl_cp->n_control) == 0) { 677 if (atomic_read(&ctl_cp->n_control) == 0) {
549 IP_VS_ERR("BUG control DEL with n=0 : " 678 IP_VS_ERR_BUF("BUG control DEL with n=0 : "
550 "%d.%d.%d.%d:%d to %d.%d.%d.%d:%d\n", 679 "%s:%d to %s:%d\n",
551 NIPQUAD(cp->caddr),ntohs(cp->cport), 680 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
552 NIPQUAD(cp->vaddr),ntohs(cp->vport)); 681 ntohs(cp->cport),
682 IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
683 ntohs(cp->vport));
684
553 return; 685 return;
554 } 686 }
555 atomic_dec(&ctl_cp->n_control); 687 atomic_dec(&ctl_cp->n_control);
@@ -559,17 +691,22 @@ static inline void
559ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) 691ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp)
560{ 692{
561 if (cp->control) { 693 if (cp->control) {
562 IP_VS_ERR("request control ADD for already controlled: " 694 IP_VS_ERR_BUF("request control ADD for already controlled: "
563 "%d.%d.%d.%d:%d to %d.%d.%d.%d:%d\n", 695 "%s:%d to %s:%d\n",
564 NIPQUAD(cp->caddr),ntohs(cp->cport), 696 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
565 NIPQUAD(cp->vaddr),ntohs(cp->vport)); 697 ntohs(cp->cport),
698 IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
699 ntohs(cp->vport));
700
566 ip_vs_control_del(cp); 701 ip_vs_control_del(cp);
567 } 702 }
568 703
569 IP_VS_DBG(7, "ADDing control for: " 704 IP_VS_DBG_BUF(7, "ADDing control for: "
570 "cp.dst=%d.%d.%d.%d:%d ctl_cp.dst=%d.%d.%d.%d:%d\n", 705 "cp.dst=%s:%d ctl_cp.dst=%s:%d\n",
571 NIPQUAD(cp->caddr),ntohs(cp->cport), 706 IP_VS_DBG_ADDR(cp->af, &cp->caddr),
572 NIPQUAD(ctl_cp->caddr),ntohs(ctl_cp->cport)); 707 ntohs(cp->cport),
708 IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr),
709 ntohs(ctl_cp->cport));
573 710
574 cp->control = ctl_cp; 711 cp->control = ctl_cp;
575 atomic_inc(&ctl_cp->n_control); 712 atomic_inc(&ctl_cp->n_control);
@@ -647,7 +784,8 @@ extern struct ip_vs_stats ip_vs_stats;
647extern const struct ctl_path net_vs_ctl_path[]; 784extern const struct ctl_path net_vs_ctl_path[];
648 785
649extern struct ip_vs_service * 786extern struct ip_vs_service *
650ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport); 787ip_vs_service_get(int af, __u32 fwmark, __u16 protocol,
788 const union nf_inet_addr *vaddr, __be16 vport);
651 789
652static inline void ip_vs_service_put(struct ip_vs_service *svc) 790static inline void ip_vs_service_put(struct ip_vs_service *svc)
653{ 791{
@@ -655,14 +793,16 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc)
655} 793}
656 794
657extern struct ip_vs_dest * 795extern struct ip_vs_dest *
658ip_vs_lookup_real_service(__u16 protocol, __be32 daddr, __be16 dport); 796ip_vs_lookup_real_service(int af, __u16 protocol,
797 const union nf_inet_addr *daddr, __be16 dport);
798
659extern int ip_vs_use_count_inc(void); 799extern int ip_vs_use_count_inc(void);
660extern void ip_vs_use_count_dec(void); 800extern void ip_vs_use_count_dec(void);
661extern int ip_vs_control_init(void); 801extern int ip_vs_control_init(void);
662extern void ip_vs_control_cleanup(void); 802extern void ip_vs_control_cleanup(void);
663extern struct ip_vs_dest * 803extern struct ip_vs_dest *
664ip_vs_find_dest(__be32 daddr, __be16 dport, 804ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport,
665 __be32 vaddr, __be16 vport, __u16 protocol); 805 const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol);
666extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); 806extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
667 807
668 808
@@ -683,6 +823,8 @@ extern void ip_vs_sync_conn(struct ip_vs_conn *cp);
683/* 823/*
684 * IPVS rate estimator prototypes (from ip_vs_est.c) 824 * IPVS rate estimator prototypes (from ip_vs_est.c)
685 */ 825 */
826extern int ip_vs_estimator_init(void);
827extern void ip_vs_estimator_cleanup(void);
686extern void ip_vs_new_estimator(struct ip_vs_stats *stats); 828extern void ip_vs_new_estimator(struct ip_vs_stats *stats);
687extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); 829extern void ip_vs_kill_estimator(struct ip_vs_stats *stats);
688extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); 830extern void ip_vs_zero_estimator(struct ip_vs_stats *stats);
@@ -704,6 +846,19 @@ extern int ip_vs_icmp_xmit
704(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset); 846(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset);
705extern void ip_vs_dst_reset(struct ip_vs_dest *dest); 847extern void ip_vs_dst_reset(struct ip_vs_dest *dest);
706 848
849#ifdef CONFIG_IP_VS_IPV6
850extern int ip_vs_bypass_xmit_v6
851(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
852extern int ip_vs_nat_xmit_v6
853(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
854extern int ip_vs_tunnel_xmit_v6
855(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
856extern int ip_vs_dr_xmit_v6
857(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
858extern int ip_vs_icmp_xmit_v6
859(struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp,
860 int offset);
861#endif
707 862
708/* 863/*
709 * This is a simple mechanism to ignore packets when 864 * This is a simple mechanism to ignore packets when
@@ -748,7 +903,12 @@ static inline char ip_vs_fwd_tag(struct ip_vs_conn *cp)
748} 903}
749 904
750extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, 905extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
751 struct ip_vs_conn *cp, int dir); 906 struct ip_vs_conn *cp, int dir);
907
908#ifdef CONFIG_IP_VS_IPV6
909extern void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,
910 struct ip_vs_conn *cp, int dir);
911#endif
752 912
753extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); 913extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);
754 914
@@ -759,6 +919,17 @@ static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)
759 return csum_partial((char *) diff, sizeof(diff), oldsum); 919 return csum_partial((char *) diff, sizeof(diff), oldsum);
760} 920}
761 921
922#ifdef CONFIG_IP_VS_IPV6
923static inline __wsum ip_vs_check_diff16(const __be32 *old, const __be32 *new,
924 __wsum oldsum)
925{
926 __be32 diff[8] = { ~old[3], ~old[2], ~old[1], ~old[0],
927 new[3], new[2], new[1], new[0] };
928
929 return csum_partial((char *) diff, sizeof(diff), oldsum);
930}
931#endif
932
762static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum) 933static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
763{ 934{
764 __be16 diff[2] = { ~old, new }; 935 __be16 diff[2] = { ~old, new };
diff --git a/include/net/ipip.h b/include/net/ipip.h
index a85bda64b852..fdf9bd743705 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -37,7 +37,7 @@ struct ip_tunnel_prl_entry
37 37
38#define IPTUNNEL_XMIT() do { \ 38#define IPTUNNEL_XMIT() do { \
39 int err; \ 39 int err; \
40 int pkt_len = skb->len; \ 40 int pkt_len = skb->len - skb_transport_offset(skb); \
41 \ 41 \
42 skb->ip_summed = CHECKSUM_NONE; \ 42 skb->ip_summed = CHECKSUM_NONE; \
43 ip_select_ident(iph, &rt->u.dst, NULL); \ 43 ip_select_ident(iph, &rt->u.dst, NULL); \
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 113028fb8f66..6d5b58a1c743 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -110,43 +110,42 @@ struct frag_hdr {
110extern int sysctl_mld_max_msf; 110extern int sysctl_mld_max_msf;
111extern struct ctl_path net_ipv6_ctl_path[]; 111extern struct ctl_path net_ipv6_ctl_path[];
112 112
113#define _DEVINC(statname, modifier, idev, field) \ 113#define _DEVINC(net, statname, modifier, idev, field) \
114({ \ 114({ \
115 struct inet6_dev *_idev = (idev); \ 115 struct inet6_dev *_idev = (idev); \
116 if (likely(_idev != NULL)) \ 116 if (likely(_idev != NULL)) \
117 SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \ 117 SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \
118 SNMP_INC_STATS##modifier(statname##_statistics, (field)); \ 118 SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\
119}) 119})
120 120
121#define _DEVADD(statname, modifier, idev, field, val) \ 121#define _DEVADD(net, statname, modifier, idev, field, val) \
122({ \ 122({ \
123 struct inet6_dev *_idev = (idev); \ 123 struct inet6_dev *_idev = (idev); \
124 if (likely(_idev != NULL)) \ 124 if (likely(_idev != NULL)) \
125 SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \ 125 SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \
126 SNMP_ADD_STATS##modifier(statname##_statistics, (field), (val));\ 126 SNMP_ADD_STATS##modifier((net)->mib.statname##_statistics, (field), (val));\
127}) 127})
128 128
129/* MIBs */ 129/* MIBs */
130DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
131 130
132#define IP6_INC_STATS(idev,field) _DEVINC(ipv6, , idev, field) 131#define IP6_INC_STATS(net, idev,field) \
133#define IP6_INC_STATS_BH(idev,field) _DEVINC(ipv6, _BH, idev, field) 132 _DEVINC(net, ipv6, , idev, field)
134#define IP6_ADD_STATS_BH(idev,field,val) _DEVADD(ipv6, _BH, idev, field, val) 133#define IP6_INC_STATS_BH(net, idev,field) \
135 134 _DEVINC(net, ipv6, _BH, idev, field)
136DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); 135#define IP6_ADD_STATS_BH(net, idev,field,val) \
137DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); 136 _DEVADD(net, ipv6, _BH, idev, field, val)
138 137
139#define ICMP6_INC_STATS(idev, field) _DEVINC(icmpv6, , idev, field) 138#define ICMP6_INC_STATS(net, idev, field) \
140#define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field) 139 _DEVINC(net, icmpv6, , idev, field)
141 140#define ICMP6_INC_STATS_BH(net, idev, field) \
142#define ICMP6MSGOUT_INC_STATS(idev, field) \ 141 _DEVINC(net, icmpv6, _BH, idev, field)
143 _DEVINC(icmpv6msg, , idev, field +256) 142
144#define ICMP6MSGOUT_INC_STATS_BH(idev, field) \ 143#define ICMP6MSGOUT_INC_STATS(net, idev, field) \
145 _DEVINC(icmpv6msg, _BH, idev, field +256) 144 _DEVINC(net, icmpv6msg, , idev, field +256)
146#define ICMP6MSGIN_INC_STATS(idev, field) \ 145#define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \
147 _DEVINC(icmpv6msg, , idev, field) 146 _DEVINC(net, icmpv6msg, _BH, idev, field +256)
148#define ICMP6MSGIN_INC_STATS_BH(idev, field) \ 147#define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \
149 _DEVINC(icmpv6msg, _BH, idev, field) 148 _DEVINC(net, icmpv6msg, _BH, idev, field)
150 149
151struct ip6_ra_chain 150struct ip6_ra_chain
152{ 151{
@@ -576,6 +575,8 @@ extern int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf);
576extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf, 575extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
577 struct group_filter __user *optval, 576 struct group_filter __user *optval,
578 int __user *optlen); 577 int __user *optlen);
578extern unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr,
579 const struct in6_addr *daddr, u32 rnd);
579 580
580#ifdef CONFIG_PROC_FS 581#ifdef CONFIG_PROC_FS
581extern int ac6_proc_init(struct net *net); 582extern int ac6_proc_init(struct net *net);
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ff137fd7714f..5617a1613c91 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -158,13 +158,17 @@ struct ieee80211_low_level_stats {
158 * also implies a change in the AID. 158 * also implies a change in the AID.
159 * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed 159 * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
160 * @BSS_CHANGED_ERP_PREAMBLE: preamble changed 160 * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
161 * @BSS_CHANGED_ERP_SLOT: slot timing changed
161 * @BSS_CHANGED_HT: 802.11n parameters changed 162 * @BSS_CHANGED_HT: 802.11n parameters changed
163 * @BSS_CHANGED_BASIC_RATES: Basic rateset changed
162 */ 164 */
163enum ieee80211_bss_change { 165enum ieee80211_bss_change {
164 BSS_CHANGED_ASSOC = 1<<0, 166 BSS_CHANGED_ASSOC = 1<<0,
165 BSS_CHANGED_ERP_CTS_PROT = 1<<1, 167 BSS_CHANGED_ERP_CTS_PROT = 1<<1,
166 BSS_CHANGED_ERP_PREAMBLE = 1<<2, 168 BSS_CHANGED_ERP_PREAMBLE = 1<<2,
169 BSS_CHANGED_ERP_SLOT = 1<<3,
167 BSS_CHANGED_HT = 1<<4, 170 BSS_CHANGED_HT = 1<<4,
171 BSS_CHANGED_BASIC_RATES = 1<<5,
168}; 172};
169 173
170/** 174/**
@@ -177,6 +181,7 @@ enum ieee80211_bss_change {
177 * @aid: association ID number, valid only when @assoc is true 181 * @aid: association ID number, valid only when @assoc is true
178 * @use_cts_prot: use CTS protection 182 * @use_cts_prot: use CTS protection
179 * @use_short_preamble: use 802.11b short preamble 183 * @use_short_preamble: use 802.11b short preamble
184 * @use_short_slot: use short slot time (only relevant for ERP)
180 * @dtim_period: num of beacons before the next DTIM, for PSM 185 * @dtim_period: num of beacons before the next DTIM, for PSM
181 * @timestamp: beacon timestamp 186 * @timestamp: beacon timestamp
182 * @beacon_int: beacon interval 187 * @beacon_int: beacon interval
@@ -184,6 +189,9 @@ enum ieee80211_bss_change {
184 * @assoc_ht: association in HT mode 189 * @assoc_ht: association in HT mode
185 * @ht_conf: ht capabilities 190 * @ht_conf: ht capabilities
186 * @ht_bss_conf: ht extended capabilities 191 * @ht_bss_conf: ht extended capabilities
192 * @basic_rates: bitmap of basic rates, each bit stands for an
193 * index into the rate table configured by the driver in
194 * the current band.
187 */ 195 */
188struct ieee80211_bss_conf { 196struct ieee80211_bss_conf {
189 /* association related data */ 197 /* association related data */
@@ -192,10 +200,12 @@ struct ieee80211_bss_conf {
192 /* erp related data */ 200 /* erp related data */
193 bool use_cts_prot; 201 bool use_cts_prot;
194 bool use_short_preamble; 202 bool use_short_preamble;
203 bool use_short_slot;
195 u8 dtim_period; 204 u8 dtim_period;
196 u16 beacon_int; 205 u16 beacon_int;
197 u16 assoc_capability; 206 u16 assoc_capability;
198 u64 timestamp; 207 u64 timestamp;
208 u64 basic_rates;
199 /* ht related data */ 209 /* ht related data */
200 bool assoc_ht; 210 bool assoc_ht;
201 struct ieee80211_ht_info *ht_conf; 211 struct ieee80211_ht_info *ht_conf;
@@ -282,6 +292,20 @@ enum mac80211_tx_control_flags {
282#define IEEE80211_TX_INFO_DRIVER_DATA_PTRS \ 292#define IEEE80211_TX_INFO_DRIVER_DATA_PTRS \
283 (IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)) 293 (IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *))
284 294
295/* maximum number of alternate rate retry stages */
296#define IEEE80211_TX_MAX_ALTRATE 3
297
298/**
299 * struct ieee80211_tx_altrate - alternate rate selection/status
300 *
301 * @rate_idx: rate index to attempt to send with
302 * @limit: number of retries before fallback
303 */
304struct ieee80211_tx_altrate {
305 s8 rate_idx;
306 u8 limit;
307};
308
285/** 309/**
286 * struct ieee80211_tx_info - skb transmit information 310 * struct ieee80211_tx_info - skb transmit information
287 * 311 *
@@ -290,6 +314,9 @@ enum mac80211_tx_control_flags {
290 * (2) driver internal use (if applicable) 314 * (2) driver internal use (if applicable)
291 * (3) TX status information - driver tells mac80211 what happened 315 * (3) TX status information - driver tells mac80211 what happened
292 * 316 *
317 * The TX control's sta pointer is only valid during the ->tx call,
318 * it may be NULL.
319 *
293 * @flags: transmit info flags, defined above 320 * @flags: transmit info flags, defined above
294 * @band: TBD 321 * @band: TBD
295 * @tx_rate_idx: TBD 322 * @tx_rate_idx: TBD
@@ -317,18 +344,19 @@ struct ieee80211_tx_info {
317 344
318 union { 345 union {
319 struct { 346 struct {
347 /* NB: vif can be NULL for injected frames */
320 struct ieee80211_vif *vif; 348 struct ieee80211_vif *vif;
321 struct ieee80211_key_conf *hw_key; 349 struct ieee80211_key_conf *hw_key;
350 struct ieee80211_sta *sta;
322 unsigned long jiffies; 351 unsigned long jiffies;
323 u16 aid; 352 s8 rts_cts_rate_idx;
324 s8 rts_cts_rate_idx, alt_retry_rate_idx;
325 u8 retry_limit; 353 u8 retry_limit;
326 u8 icv_len; 354 struct ieee80211_tx_altrate retries[IEEE80211_TX_MAX_ALTRATE];
327 u8 iv_len;
328 } control; 355 } control;
329 struct { 356 struct {
330 u64 ampdu_ack_map; 357 u64 ampdu_ack_map;
331 int ack_signal; 358 int ack_signal;
359 struct ieee80211_tx_altrate retries[IEEE80211_TX_MAX_ALTRATE + 1];
332 u8 retry_count; 360 u8 retry_count;
333 bool excessive_retries; 361 bool excessive_retries;
334 u8 ampdu_ack_len; 362 u8 ampdu_ack_len;
@@ -363,6 +391,7 @@ static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb)
363 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) 391 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field)
364 * is valid. This is useful in monitor mode and necessary for beacon frames 392 * is valid. This is useful in monitor mode and necessary for beacon frames
365 * to enable IBSS merging. 393 * to enable IBSS merging.
394 * @RX_FLAG_SHORTPRE: Short preamble was used for this frame
366 */ 395 */
367enum mac80211_rx_flags { 396enum mac80211_rx_flags {
368 RX_FLAG_MMIC_ERROR = 1<<0, 397 RX_FLAG_MMIC_ERROR = 1<<0,
@@ -373,6 +402,7 @@ enum mac80211_rx_flags {
373 RX_FLAG_FAILED_FCS_CRC = 1<<5, 402 RX_FLAG_FAILED_FCS_CRC = 1<<5,
374 RX_FLAG_FAILED_PLCP_CRC = 1<<6, 403 RX_FLAG_FAILED_PLCP_CRC = 1<<6,
375 RX_FLAG_TSFT = 1<<7, 404 RX_FLAG_TSFT = 1<<7,
405 RX_FLAG_SHORTPRE = 1<<8
376}; 406};
377 407
378/** 408/**
@@ -418,6 +448,11 @@ struct ieee80211_rx_status {
418 * @IEEE80211_CONF_PS: Enable 802.11 power save mode 448 * @IEEE80211_CONF_PS: Enable 802.11 power save mode
419 */ 449 */
420enum ieee80211_conf_flags { 450enum ieee80211_conf_flags {
451 /*
452 * TODO: IEEE80211_CONF_SHORT_SLOT_TIME will be removed once drivers
453 * have been converted to use bss_info_changed() for slot time
454 * configuration
455 */
421 IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0), 456 IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0),
422 IEEE80211_CONF_RADIOTAP = (1<<1), 457 IEEE80211_CONF_RADIOTAP = (1<<1),
423 IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2), 458 IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2),
@@ -461,33 +496,6 @@ struct ieee80211_conf {
461}; 496};
462 497
463/** 498/**
464 * enum ieee80211_if_types - types of 802.11 network interfaces
465 *
466 * @IEEE80211_IF_TYPE_INVALID: invalid interface type, not used
467 * by mac80211 itself
468 * @IEEE80211_IF_TYPE_AP: interface in AP mode.
469 * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
470 * daemon. Drivers should never see this type.
471 * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode.
472 * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
473 * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
474 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
475 * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers
476 * will never see this type.
477 * @IEEE80211_IF_TYPE_MESH_POINT: 802.11s mesh point
478 */
479enum ieee80211_if_types {
480 IEEE80211_IF_TYPE_INVALID,
481 IEEE80211_IF_TYPE_AP,
482 IEEE80211_IF_TYPE_STA,
483 IEEE80211_IF_TYPE_IBSS,
484 IEEE80211_IF_TYPE_MESH_POINT,
485 IEEE80211_IF_TYPE_MNTR,
486 IEEE80211_IF_TYPE_WDS,
487 IEEE80211_IF_TYPE_VLAN,
488};
489
490/**
491 * struct ieee80211_vif - per-interface data 499 * struct ieee80211_vif - per-interface data
492 * 500 *
493 * Data in this structure is continually present for driver 501 * Data in this structure is continually present for driver
@@ -498,7 +506,7 @@ enum ieee80211_if_types {
498 * sizeof(void *). 506 * sizeof(void *).
499 */ 507 */
500struct ieee80211_vif { 508struct ieee80211_vif {
501 enum ieee80211_if_types type; 509 enum nl80211_iftype type;
502 /* must be last */ 510 /* must be last */
503 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); 511 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
504}; 512};
@@ -506,7 +514,7 @@ struct ieee80211_vif {
506static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) 514static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
507{ 515{
508#ifdef CONFIG_MAC80211_MESH 516#ifdef CONFIG_MAC80211_MESH
509 return vif->type == IEEE80211_IF_TYPE_MESH_POINT; 517 return vif->type == NL80211_IFTYPE_MESH_POINT;
510#endif 518#endif
511 return false; 519 return false;
512} 520}
@@ -517,7 +525,7 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
517 * @vif: pointer to a driver-use per-interface structure. The pointer 525 * @vif: pointer to a driver-use per-interface structure. The pointer
518 * itself is also used for various functions including 526 * itself is also used for various functions including
519 * ieee80211_beacon_get() and ieee80211_get_buffered_bc(). 527 * ieee80211_beacon_get() and ieee80211_get_buffered_bc().
520 * @type: one of &enum ieee80211_if_types constants. Determines the type of 528 * @type: one of &enum nl80211_iftype constants. Determines the type of
521 * added/removed interface. 529 * added/removed interface.
522 * @mac_addr: pointer to MAC address of the interface. This pointer is valid 530 * @mac_addr: pointer to MAC address of the interface. This pointer is valid
523 * until the interface is removed (i.e. it cannot be used after 531 * until the interface is removed (i.e. it cannot be used after
@@ -533,7 +541,7 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
533 * in pure monitor mode. 541 * in pure monitor mode.
534 */ 542 */
535struct ieee80211_if_init_conf { 543struct ieee80211_if_init_conf {
536 enum ieee80211_if_types type; 544 enum nl80211_iftype type;
537 struct ieee80211_vif *vif; 545 struct ieee80211_vif *vif;
538 void *mac_addr; 546 void *mac_addr;
539}; 547};
@@ -641,6 +649,8 @@ enum ieee80211_key_flags {
641 */ 649 */
642struct ieee80211_key_conf { 650struct ieee80211_key_conf {
643 enum ieee80211_key_alg alg; 651 enum ieee80211_key_alg alg;
652 u8 icv_len;
653 u8 iv_len;
644 u8 hw_key_idx; 654 u8 hw_key_idx;
645 u8 flags; 655 u8 flags;
646 s8 keyidx; 656 s8 keyidx;
@@ -662,6 +672,33 @@ enum set_key_cmd {
662}; 672};
663 673
664/** 674/**
675 * struct ieee80211_sta - station table entry
676 *
677 * A station table entry represents a station we are possibly
678 * communicating with. Since stations are RCU-managed in
679 * mac80211, any ieee80211_sta pointer you get access to must
680 * either be protected by rcu_read_lock() explicitly or implicitly,
681 * or you must take good care to not use such a pointer after a
682 * call to your sta_notify callback that removed it.
683 *
684 * @addr: MAC address
685 * @aid: AID we assigned to the station if we're an AP
686 * @supp_rates: Bitmap of supported rates (per band)
687 * @ht_info: HT capabilities of this STA
688 * @drv_priv: data area for driver use, will always be aligned to
689 * sizeof(void *), size is determined in hw information.
690 */
691struct ieee80211_sta {
692 u64 supp_rates[IEEE80211_NUM_BANDS];
693 u8 addr[ETH_ALEN];
694 u16 aid;
695 struct ieee80211_ht_info ht_info;
696
697 /* must be last */
698 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
699};
700
701/**
665 * enum sta_notify_cmd - sta notify command 702 * enum sta_notify_cmd - sta notify command
666 * 703 *
667 * Used with the sta_notify() callback in &struct ieee80211_ops, this 704 * Used with the sta_notify() callback in &struct ieee80211_ops, this
@@ -805,6 +842,11 @@ enum ieee80211_hw_flags {
805 * 842 *
806 * @vif_data_size: size (in bytes) of the drv_priv data area 843 * @vif_data_size: size (in bytes) of the drv_priv data area
807 * within &struct ieee80211_vif. 844 * within &struct ieee80211_vif.
845 * @sta_data_size: size (in bytes) of the drv_priv data area
846 * within &struct ieee80211_sta.
847 *
848 * @max_altrates: maximum number of alternate rate retry stages
849 * @max_altrate_tries: maximum number of tries for each stage
808 */ 850 */
809struct ieee80211_hw { 851struct ieee80211_hw {
810 struct ieee80211_conf conf; 852 struct ieee80211_conf conf;
@@ -816,12 +858,17 @@ struct ieee80211_hw {
816 unsigned int extra_tx_headroom; 858 unsigned int extra_tx_headroom;
817 int channel_change_time; 859 int channel_change_time;
818 int vif_data_size; 860 int vif_data_size;
861 int sta_data_size;
819 u16 queues; 862 u16 queues;
820 u16 ampdu_queues; 863 u16 ampdu_queues;
821 u16 max_listen_interval; 864 u16 max_listen_interval;
822 s8 max_signal; 865 s8 max_signal;
866 u8 max_altrates;
867 u8 max_altrate_tries;
823}; 868};
824 869
870struct ieee80211_hw *wiphy_to_hw(struct wiphy *wiphy);
871
825/** 872/**
826 * SET_IEEE80211_DEV - set device for 802.11 hardware 873 * SET_IEEE80211_DEV - set device for 802.11 hardware
827 * 874 *
@@ -874,11 +921,11 @@ ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw,
874 921
875static inline struct ieee80211_rate * 922static inline struct ieee80211_rate *
876ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, 923ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
877 const struct ieee80211_tx_info *c) 924 const struct ieee80211_tx_info *c, int idx)
878{ 925{
879 if (c->control.alt_retry_rate_idx < 0) 926 if (c->control.retries[idx].rate_idx < 0)
880 return NULL; 927 return NULL;
881 return &hw->wiphy->bands[c->band]->bitrates[c->control.alt_retry_rate_idx]; 928 return &hw->wiphy->bands[c->band]->bitrates[c->control.retries[idx].rate_idx];
882} 929}
883 930
884/** 931/**
@@ -1097,7 +1144,7 @@ enum ieee80211_ampdu_mlme_action {
1097 * This callback must be implemented and atomic. 1144 * This callback must be implemented and atomic.
1098 * 1145 *
1099 * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit 1146 * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit
1100 * must be set or cleared for a given AID. Must be atomic. 1147 * must be set or cleared for a given STA. Must be atomic.
1101 * 1148 *
1102 * @set_key: See the section "Hardware crypto acceleration" 1149 * @set_key: See the section "Hardware crypto acceleration"
1103 * This callback can sleep, and is only called between add_interface 1150 * This callback can sleep, and is only called between add_interface
@@ -1111,7 +1158,9 @@ enum ieee80211_ampdu_mlme_action {
1111 * @hw_scan: Ask the hardware to service the scan request, no need to start 1158 * @hw_scan: Ask the hardware to service the scan request, no need to start
1112 * the scan state machine in stack. The scan must honour the channel 1159 * the scan state machine in stack. The scan must honour the channel
1113 * configuration done by the regulatory agent in the wiphy's registered 1160 * configuration done by the regulatory agent in the wiphy's registered
1114 * bands. 1161 * bands. When the scan finishes, ieee80211_scan_completed() must be
1162 * called; note that it also must be called when the scan cannot finish
1163 * because the hardware is turned off! Anything else is a bug!
1115 * 1164 *
1116 * @get_stats: return low-level statistics 1165 * @get_stats: return low-level statistics
1117 * 1166 *
@@ -1131,7 +1180,7 @@ enum ieee80211_ampdu_mlme_action {
1131 * of assocaited station or AP. 1180 * of assocaited station or AP.
1132 * 1181 *
1133 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), 1182 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
1134 * bursting) for a hardware TX queue. Must be atomic. 1183 * bursting) for a hardware TX queue.
1135 * 1184 *
1136 * @get_tx_stats: Get statistics of the current TX queue status. This is used 1185 * @get_tx_stats: Get statistics of the current TX queue status. This is used
1137 * to get number of currently queued packets (queue length), maximum queue 1186 * to get number of currently queued packets (queue length), maximum queue
@@ -1181,7 +1230,8 @@ struct ieee80211_ops {
1181 unsigned int changed_flags, 1230 unsigned int changed_flags,
1182 unsigned int *total_flags, 1231 unsigned int *total_flags,
1183 int mc_count, struct dev_addr_list *mc_list); 1232 int mc_count, struct dev_addr_list *mc_list);
1184 int (*set_tim)(struct ieee80211_hw *hw, int aid, int set); 1233 int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
1234 bool set);
1185 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1235 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1186 const u8 *local_address, const u8 *address, 1236 const u8 *local_address, const u8 *address,
1187 struct ieee80211_key_conf *key); 1237 struct ieee80211_key_conf *key);
@@ -1198,7 +1248,7 @@ struct ieee80211_ops {
1198 int (*set_retry_limit)(struct ieee80211_hw *hw, 1248 int (*set_retry_limit)(struct ieee80211_hw *hw,
1199 u32 short_retry, u32 long_retr); 1249 u32 short_retry, u32 long_retr);
1200 void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1250 void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1201 enum sta_notify_cmd, const u8 *addr); 1251 enum sta_notify_cmd, struct ieee80211_sta *sta);
1202 int (*conf_tx)(struct ieee80211_hw *hw, u16 queue, 1252 int (*conf_tx)(struct ieee80211_hw *hw, u16 queue,
1203 const struct ieee80211_tx_queue_params *params); 1253 const struct ieee80211_tx_queue_params *params);
1204 int (*get_tx_stats)(struct ieee80211_hw *hw, 1254 int (*get_tx_stats)(struct ieee80211_hw *hw,
@@ -1208,7 +1258,7 @@ struct ieee80211_ops {
1208 int (*tx_last_beacon)(struct ieee80211_hw *hw); 1258 int (*tx_last_beacon)(struct ieee80211_hw *hw);
1209 int (*ampdu_action)(struct ieee80211_hw *hw, 1259 int (*ampdu_action)(struct ieee80211_hw *hw,
1210 enum ieee80211_ampdu_mlme_action action, 1260 enum ieee80211_ampdu_mlme_action action,
1211 const u8 *addr, u16 tid, u16 *ssn); 1261 struct ieee80211_sta *sta, u16 tid, u16 *ssn);
1212}; 1262};
1213 1263
1214/** 1264/**
@@ -1557,16 +1607,6 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
1557unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); 1607unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
1558 1608
1559/** 1609/**
1560 * ieee80211_get_hdrlen - get header length from frame control
1561 *
1562 * This function returns the 802.11 header length in bytes (not including
1563 * encryption headers.)
1564 *
1565 * @fc: the frame control field (in CPU endianness)
1566 */
1567int ieee80211_get_hdrlen(u16 fc);
1568
1569/**
1570 * ieee80211_hdrlen - get header length in bytes from frame control 1610 * ieee80211_hdrlen - get header length in bytes from frame control
1571 * @fc: frame control field in little-endian format 1611 * @fc: frame control field in little-endian format
1572 */ 1612 */
@@ -1608,6 +1648,16 @@ void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
1608void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue); 1648void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
1609 1649
1610/** 1650/**
1651 * ieee80211_queue_stopped - test status of the queue
1652 * @hw: pointer as obtained from ieee80211_alloc_hw().
1653 * @queue: queue number (counted from zero).
1654 *
1655 * Drivers should use this function instead of netif_stop_queue.
1656 */
1657
1658int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue);
1659
1660/**
1611 * ieee80211_stop_queues - stop all queues 1661 * ieee80211_stop_queues - stop all queues
1612 * @hw: pointer as obtained from ieee80211_alloc_hw(). 1662 * @hw: pointer as obtained from ieee80211_alloc_hw().
1613 * 1663 *
@@ -1758,4 +1808,85 @@ void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra,
1758 */ 1808 */
1759void ieee80211_notify_mac(struct ieee80211_hw *hw, 1809void ieee80211_notify_mac(struct ieee80211_hw *hw,
1760 enum ieee80211_notification_types notif_type); 1810 enum ieee80211_notification_types notif_type);
1811
1812/**
1813 * ieee80211_find_sta - find a station
1814 *
1815 * @hw: pointer as obtained from ieee80211_alloc_hw()
1816 * @addr: station's address
1817 *
1818 * This function must be called under RCU lock and the
1819 * resulting pointer is only valid under RCU lock as well.
1820 */
1821struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_hw *hw,
1822 const u8 *addr);
1823
1824
1825/* Rate control API */
1826/**
1827 * struct rate_selection - rate information for/from rate control algorithms
1828 *
1829 * @rate_idx: selected transmission rate index
1830 * @nonerp_idx: Non-ERP rate to use instead if ERP cannot be used
1831 * @probe_idx: rate for probing (or -1)
1832 * @max_rate_idx: maximum rate index that can be used, this is
1833 * input to the algorithm and will be enforced
1834 */
1835struct rate_selection {
1836 s8 rate_idx, nonerp_idx, probe_idx, max_rate_idx;
1837};
1838
1839struct rate_control_ops {
1840 struct module *module;
1841 const char *name;
1842 void *(*alloc)(struct ieee80211_hw *hw, struct dentry *debugfsdir);
1843 void (*clear)(void *priv);
1844 void (*free)(void *priv);
1845
1846 void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
1847 void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
1848 struct ieee80211_sta *sta, void *priv_sta);
1849 void (*free_sta)(void *priv, struct ieee80211_sta *sta,
1850 void *priv_sta);
1851
1852 void (*tx_status)(void *priv, struct ieee80211_supported_band *sband,
1853 struct ieee80211_sta *sta, void *priv_sta,
1854 struct sk_buff *skb);
1855 void (*get_rate)(void *priv, struct ieee80211_supported_band *sband,
1856 struct ieee80211_sta *sta, void *priv_sta,
1857 struct sk_buff *skb,
1858 struct rate_selection *sel);
1859
1860 void (*add_sta_debugfs)(void *priv, void *priv_sta,
1861 struct dentry *dir);
1862 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
1863};
1864
1865static inline int rate_supported(struct ieee80211_sta *sta,
1866 enum ieee80211_band band,
1867 int index)
1868{
1869 return (sta == NULL || sta->supp_rates[band] & BIT(index));
1870}
1871
1872static inline s8
1873rate_lowest_index(struct ieee80211_supported_band *sband,
1874 struct ieee80211_sta *sta)
1875{
1876 int i;
1877
1878 for (i = 0; i < sband->n_bitrates; i++)
1879 if (rate_supported(sta, sband->band, i))
1880 return i;
1881
1882 /* warn when we cannot find a rate. */
1883 WARN_ON(1);
1884
1885 return 0;
1886}
1887
1888
1889int ieee80211_rate_control_register(struct rate_control_ops *ops);
1890void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
1891
1761#endif /* MAC80211_H */ 1892#endif /* MAC80211_H */
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index a8eb43cf0c7e..708009be88b6 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -16,6 +16,9 @@
16#include <net/netns/ipv6.h> 16#include <net/netns/ipv6.h>
17#include <net/netns/dccp.h> 17#include <net/netns/dccp.h>
18#include <net/netns/x_tables.h> 18#include <net/netns/x_tables.h>
19#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
20#include <net/netns/conntrack.h>
21#endif
19 22
20struct proc_dir_entry; 23struct proc_dir_entry;
21struct net_device; 24struct net_device;
@@ -67,6 +70,9 @@ struct net {
67#endif 70#endif
68#ifdef CONFIG_NETFILTER 71#ifdef CONFIG_NETFILTER
69 struct netns_xt xt; 72 struct netns_xt xt;
73#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
74 struct netns_ct ct;
75#endif
70#endif 76#endif
71 struct net_generic *gen; 77 struct net_generic *gen;
72}; 78};
diff --git a/include/net/netfilter/ipv4/nf_defrag_ipv4.h b/include/net/netfilter/ipv4/nf_defrag_ipv4.h
new file mode 100644
index 000000000000..6b00ea38546b
--- /dev/null
+++ b/include/net/netfilter/ipv4/nf_defrag_ipv4.h
@@ -0,0 +1,6 @@
1#ifndef _NF_DEFRAG_IPV4_H
2#define _NF_DEFRAG_IPV4_H
3
4extern void nf_defrag_ipv4_enable(void);
5
6#endif /* _NF_DEFRAG_IPV4_H */
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 0741ad592da0..b76a8685b5b5 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -123,7 +123,9 @@ struct nf_conn
123 123
124 /* Extensions */ 124 /* Extensions */
125 struct nf_ct_ext *ext; 125 struct nf_ct_ext *ext;
126 126#ifdef CONFIG_NET_NS
127 struct net *ct_net;
128#endif
127 struct rcu_head rcu; 129 struct rcu_head rcu;
128}; 130};
129 131
@@ -147,6 +149,17 @@ static inline u_int8_t nf_ct_protonum(const struct nf_conn *ct)
147/* get master conntrack via master expectation */ 149/* get master conntrack via master expectation */
148#define master_ct(conntr) (conntr->master) 150#define master_ct(conntr) (conntr->master)
149 151
152extern struct net init_net;
153
154static inline struct net *nf_ct_net(const struct nf_conn *ct)
155{
156#ifdef CONFIG_NET_NS
157 return ct->ct_net;
158#else
159 return &init_net;
160#endif
161}
162
150/* Alter reply tuple (maybe alter helper). */ 163/* Alter reply tuple (maybe alter helper). */
151extern void 164extern void
152nf_conntrack_alter_reply(struct nf_conn *ct, 165nf_conntrack_alter_reply(struct nf_conn *ct,
@@ -182,11 +195,11 @@ extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced,
182 unsigned int size); 195 unsigned int size);
183 196
184extern struct nf_conntrack_tuple_hash * 197extern struct nf_conntrack_tuple_hash *
185__nf_conntrack_find(const struct nf_conntrack_tuple *tuple); 198__nf_conntrack_find(struct net *net, const struct nf_conntrack_tuple *tuple);
186 199
187extern void nf_conntrack_hash_insert(struct nf_conn *ct); 200extern void nf_conntrack_hash_insert(struct nf_conn *ct);
188 201
189extern void nf_conntrack_flush(void); 202extern void nf_conntrack_flush(struct net *net);
190 203
191extern bool nf_ct_get_tuplepr(const struct sk_buff *skb, 204extern bool nf_ct_get_tuplepr(const struct sk_buff *skb,
192 unsigned int nhoff, u_int16_t l3num, 205 unsigned int nhoff, u_int16_t l3num,
@@ -248,10 +261,11 @@ extern struct nf_conn nf_conntrack_untracked;
248 261
249/* Iterate over all conntracks: if iter returns true, it's deleted. */ 262/* Iterate over all conntracks: if iter returns true, it's deleted. */
250extern void 263extern void
251nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data); 264nf_ct_iterate_cleanup(struct net *net, int (*iter)(struct nf_conn *i, void *data), void *data);
252extern void nf_conntrack_free(struct nf_conn *ct); 265extern void nf_conntrack_free(struct nf_conn *ct);
253extern struct nf_conn * 266extern struct nf_conn *
254nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, 267nf_conntrack_alloc(struct net *net,
268 const struct nf_conntrack_tuple *orig,
255 const struct nf_conntrack_tuple *repl, 269 const struct nf_conntrack_tuple *repl,
256 gfp_t gfp); 270 gfp_t gfp);
257 271
@@ -273,16 +287,14 @@ static inline int nf_ct_is_untracked(const struct sk_buff *skb)
273 287
274extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp); 288extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
275extern unsigned int nf_conntrack_htable_size; 289extern unsigned int nf_conntrack_htable_size;
276extern int nf_conntrack_checksum;
277extern atomic_t nf_conntrack_count;
278extern int nf_conntrack_max; 290extern int nf_conntrack_max;
279 291
280DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat); 292#define NF_CT_STAT_INC(net, count) \
281#define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++) 293 (per_cpu_ptr((net)->ct.stat, raw_smp_processor_id())->count++)
282#define NF_CT_STAT_INC_ATOMIC(count) \ 294#define NF_CT_STAT_INC_ATOMIC(net, count) \
283do { \ 295do { \
284 local_bh_disable(); \ 296 local_bh_disable(); \
285 __get_cpu_var(nf_conntrack_stat).count++; \ 297 per_cpu_ptr((net)->ct.stat, raw_smp_processor_id())->count++; \
286 local_bh_enable(); \ 298 local_bh_enable(); \
287} while (0) 299} while (0)
288 300
diff --git a/include/net/netfilter/nf_conntrack_acct.h b/include/net/netfilter/nf_conntrack_acct.h
index 5d5ae55d54c4..03e218f0be43 100644
--- a/include/net/netfilter/nf_conntrack_acct.h
+++ b/include/net/netfilter/nf_conntrack_acct.h
@@ -8,6 +8,7 @@
8 8
9#ifndef _NF_CONNTRACK_ACCT_H 9#ifndef _NF_CONNTRACK_ACCT_H
10#define _NF_CONNTRACK_ACCT_H 10#define _NF_CONNTRACK_ACCT_H
11#include <net/net_namespace.h>
11#include <linux/netfilter/nf_conntrack_common.h> 12#include <linux/netfilter/nf_conntrack_common.h>
12#include <linux/netfilter/nf_conntrack_tuple_common.h> 13#include <linux/netfilter/nf_conntrack_tuple_common.h>
13#include <net/netfilter/nf_conntrack.h> 14#include <net/netfilter/nf_conntrack.h>
@@ -18,8 +19,6 @@ struct nf_conn_counter {
18 u_int64_t bytes; 19 u_int64_t bytes;
19}; 20};
20 21
21extern int nf_ct_acct;
22
23static inline 22static inline
24struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct) 23struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct)
25{ 24{
@@ -29,9 +28,10 @@ struct nf_conn_counter *nf_conn_acct_find(const struct nf_conn *ct)
29static inline 28static inline
30struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp) 29struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
31{ 30{
31 struct net *net = nf_ct_net(ct);
32 struct nf_conn_counter *acct; 32 struct nf_conn_counter *acct;
33 33
34 if (!nf_ct_acct) 34 if (!net->ct.sysctl_acct)
35 return NULL; 35 return NULL;
36 36
37 acct = nf_ct_ext_add(ct, NF_CT_EXT_ACCT, gfp); 37 acct = nf_ct_ext_add(ct, NF_CT_EXT_ACCT, gfp);
@@ -45,7 +45,7 @@ struct nf_conn_counter *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
45extern unsigned int 45extern unsigned int
46seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir); 46seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir);
47 47
48extern int nf_conntrack_acct_init(void); 48extern int nf_conntrack_acct_init(struct net *net);
49extern void nf_conntrack_acct_fini(void); 49extern void nf_conntrack_acct_fini(struct net *net);
50 50
51#endif /* _NF_CONNTRACK_ACCT_H */ 51#endif /* _NF_CONNTRACK_ACCT_H */
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index a81771210934..e78afe7f28e3 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -20,12 +20,13 @@
20/* This header is used to share core functionality between the 20/* This header is used to share core functionality between the
21 standalone connection tracking module, and the compatibility layer's use 21 standalone connection tracking module, and the compatibility layer's use
22 of connection tracking. */ 22 of connection tracking. */
23extern unsigned int nf_conntrack_in(int pf, 23extern unsigned int nf_conntrack_in(struct net *net,
24 u_int8_t pf,
24 unsigned int hooknum, 25 unsigned int hooknum,
25 struct sk_buff *skb); 26 struct sk_buff *skb);
26 27
27extern int nf_conntrack_init(void); 28extern int nf_conntrack_init(struct net *net);
28extern void nf_conntrack_cleanup(void); 29extern void nf_conntrack_cleanup(struct net *net);
29 30
30extern int nf_conntrack_proto_init(void); 31extern int nf_conntrack_proto_init(void);
31extern void nf_conntrack_proto_fini(void); 32extern void nf_conntrack_proto_fini(void);
@@ -48,7 +49,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
48 49
49/* Find a connection corresponding to a tuple. */ 50/* Find a connection corresponding to a tuple. */
50extern struct nf_conntrack_tuple_hash * 51extern struct nf_conntrack_tuple_hash *
51nf_conntrack_find_get(const struct nf_conntrack_tuple *tuple); 52nf_conntrack_find_get(struct net *net, const struct nf_conntrack_tuple *tuple);
52 53
53extern int __nf_conntrack_confirm(struct sk_buff *skb); 54extern int __nf_conntrack_confirm(struct sk_buff *skb);
54 55
@@ -71,8 +72,6 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
71 const struct nf_conntrack_l3proto *l3proto, 72 const struct nf_conntrack_l3proto *l3proto,
72 const struct nf_conntrack_l4proto *proto); 73 const struct nf_conntrack_l4proto *proto);
73 74
74extern struct hlist_head *nf_conntrack_hash;
75extern spinlock_t nf_conntrack_lock ; 75extern spinlock_t nf_conntrack_lock ;
76extern struct hlist_head unconfirmed;
77 76
78#endif /* _NF_CONNTRACK_CORE_H */ 77#endif /* _NF_CONNTRACK_CORE_H */
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index f0b9078235c9..1285ff26a014 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -8,6 +8,7 @@
8 8
9#include <linux/notifier.h> 9#include <linux/notifier.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <net/net_namespace.h>
11#include <net/netfilter/nf_conntrack_expect.h> 12#include <net/netfilter/nf_conntrack_expect.h>
12 13
13#ifdef CONFIG_NF_CONNTRACK_EVENTS 14#ifdef CONFIG_NF_CONNTRACK_EVENTS
@@ -15,9 +16,6 @@ struct nf_conntrack_ecache {
15 struct nf_conn *ct; 16 struct nf_conn *ct;
16 unsigned int events; 17 unsigned int events;
17}; 18};
18DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
19
20#define CONNTRACK_ECACHE(x) (__get_cpu_var(nf_conntrack_ecache).x)
21 19
22extern struct atomic_notifier_head nf_conntrack_chain; 20extern struct atomic_notifier_head nf_conntrack_chain;
23extern int nf_conntrack_register_notifier(struct notifier_block *nb); 21extern int nf_conntrack_register_notifier(struct notifier_block *nb);
@@ -25,17 +23,16 @@ extern int nf_conntrack_unregister_notifier(struct notifier_block *nb);
25 23
26extern void nf_ct_deliver_cached_events(const struct nf_conn *ct); 24extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
27extern void __nf_ct_event_cache_init(struct nf_conn *ct); 25extern void __nf_ct_event_cache_init(struct nf_conn *ct);
28extern void nf_ct_event_cache_flush(void); 26extern void nf_ct_event_cache_flush(struct net *net);
29 27
30static inline void 28static inline void
31nf_conntrack_event_cache(enum ip_conntrack_events event, 29nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
32 const struct sk_buff *skb)
33{ 30{
34 struct nf_conn *ct = (struct nf_conn *)skb->nfct; 31 struct net *net = nf_ct_net(ct);
35 struct nf_conntrack_ecache *ecache; 32 struct nf_conntrack_ecache *ecache;
36 33
37 local_bh_disable(); 34 local_bh_disable();
38 ecache = &__get_cpu_var(nf_conntrack_ecache); 35 ecache = per_cpu_ptr(net->ct.ecache, raw_smp_processor_id());
39 if (ct != ecache->ct) 36 if (ct != ecache->ct)
40 __nf_ct_event_cache_init(ct); 37 __nf_ct_event_cache_init(ct);
41 ecache->events |= event; 38 ecache->events |= event;
@@ -60,16 +57,28 @@ nf_ct_expect_event(enum ip_conntrack_expect_events event,
60 atomic_notifier_call_chain(&nf_ct_expect_chain, event, exp); 57 atomic_notifier_call_chain(&nf_ct_expect_chain, event, exp);
61} 58}
62 59
60extern int nf_conntrack_ecache_init(struct net *net);
61extern void nf_conntrack_ecache_fini(struct net *net);
62
63#else /* CONFIG_NF_CONNTRACK_EVENTS */ 63#else /* CONFIG_NF_CONNTRACK_EVENTS */
64 64
65static inline void nf_conntrack_event_cache(enum ip_conntrack_events event, 65static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
66 const struct sk_buff *skb) {} 66 struct nf_conn *ct) {}
67static inline void nf_conntrack_event(enum ip_conntrack_events event, 67static inline void nf_conntrack_event(enum ip_conntrack_events event,
68 struct nf_conn *ct) {} 68 struct nf_conn *ct) {}
69static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {} 69static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
70static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event, 70static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
71 struct nf_conntrack_expect *exp) {} 71 struct nf_conntrack_expect *exp) {}
72static inline void nf_ct_event_cache_flush(void) {} 72static inline void nf_ct_event_cache_flush(struct net *net) {}
73
74static inline int nf_conntrack_ecache_init(struct net *net)
75{
76 return 0;
77}
78
79static inline void nf_conntrack_ecache_fini(struct net *net)
80{
81}
73#endif /* CONFIG_NF_CONNTRACK_EVENTS */ 82#endif /* CONFIG_NF_CONNTRACK_EVENTS */
74 83
75#endif /*_NF_CONNTRACK_ECACHE_H*/ 84#endif /*_NF_CONNTRACK_ECACHE_H*/
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index dfdf4b459475..37a7fc1164b0 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -6,7 +6,6 @@
6#define _NF_CONNTRACK_EXPECT_H 6#define _NF_CONNTRACK_EXPECT_H
7#include <net/netfilter/nf_conntrack.h> 7#include <net/netfilter/nf_conntrack.h>
8 8
9extern struct hlist_head *nf_ct_expect_hash;
10extern unsigned int nf_ct_expect_hsize; 9extern unsigned int nf_ct_expect_hsize;
11extern unsigned int nf_ct_expect_max; 10extern unsigned int nf_ct_expect_max;
12 11
@@ -56,6 +55,15 @@ struct nf_conntrack_expect
56 struct rcu_head rcu; 55 struct rcu_head rcu;
57}; 56};
58 57
58static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
59{
60#ifdef CONFIG_NET_NS
61 return exp->master->ct_net; /* by definition */
62#else
63 return &init_net;
64#endif
65}
66
59struct nf_conntrack_expect_policy 67struct nf_conntrack_expect_policy
60{ 68{
61 unsigned int max_expected; 69 unsigned int max_expected;
@@ -67,17 +75,17 @@ struct nf_conntrack_expect_policy
67#define NF_CT_EXPECT_PERMANENT 0x1 75#define NF_CT_EXPECT_PERMANENT 0x1
68#define NF_CT_EXPECT_INACTIVE 0x2 76#define NF_CT_EXPECT_INACTIVE 0x2
69 77
70int nf_conntrack_expect_init(void); 78int nf_conntrack_expect_init(struct net *net);
71void nf_conntrack_expect_fini(void); 79void nf_conntrack_expect_fini(struct net *net);
72 80
73struct nf_conntrack_expect * 81struct nf_conntrack_expect *
74__nf_ct_expect_find(const struct nf_conntrack_tuple *tuple); 82__nf_ct_expect_find(struct net *net, const struct nf_conntrack_tuple *tuple);
75 83
76struct nf_conntrack_expect * 84struct nf_conntrack_expect *
77nf_ct_expect_find_get(const struct nf_conntrack_tuple *tuple); 85nf_ct_expect_find_get(struct net *net, const struct nf_conntrack_tuple *tuple);
78 86
79struct nf_conntrack_expect * 87struct nf_conntrack_expect *
80nf_ct_find_expectation(const struct nf_conntrack_tuple *tuple); 88nf_ct_find_expectation(struct net *net, const struct nf_conntrack_tuple *tuple);
81 89
82void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); 90void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);
83void nf_ct_remove_expectations(struct nf_conn *ct); 91void nf_ct_remove_expectations(struct nf_conn *ct);
@@ -86,7 +94,7 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
86/* Allocate space for an expectation: this is mandatory before calling 94/* Allocate space for an expectation: this is mandatory before calling
87 nf_ct_expect_related. You will have to call put afterwards. */ 95 nf_ct_expect_related. You will have to call put afterwards. */
88struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); 96struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
89void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, int, 97void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, u_int8_t,
90 const union nf_inet_addr *, 98 const union nf_inet_addr *,
91 const union nf_inet_addr *, 99 const union nf_inet_addr *,
92 u_int8_t, const __be16 *, const __be16 *); 100 u_int8_t, const __be16 *, const __be16 *);
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index 723df9d1cc35..7f2f43c77284 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -39,7 +39,7 @@ struct nf_conntrack_l4proto
39 const struct sk_buff *skb, 39 const struct sk_buff *skb,
40 unsigned int dataoff, 40 unsigned int dataoff,
41 enum ip_conntrack_info ctinfo, 41 enum ip_conntrack_info ctinfo,
42 int pf, 42 u_int8_t pf,
43 unsigned int hooknum); 43 unsigned int hooknum);
44 44
45 /* Called when a new connection for this protocol found; 45 /* Called when a new connection for this protocol found;
@@ -50,9 +50,9 @@ struct nf_conntrack_l4proto
50 /* Called when a conntrack entry is destroyed */ 50 /* Called when a conntrack entry is destroyed */
51 void (*destroy)(struct nf_conn *ct); 51 void (*destroy)(struct nf_conn *ct);
52 52
53 int (*error)(struct sk_buff *skb, unsigned int dataoff, 53 int (*error)(struct net *net, struct sk_buff *skb, unsigned int dataoff,
54 enum ip_conntrack_info *ctinfo, 54 enum ip_conntrack_info *ctinfo,
55 int pf, unsigned int hooknum); 55 u_int8_t pf, unsigned int hooknum);
56 56
57 /* Print out the per-protocol part of the tuple. Return like seq_* */ 57 /* Print out the per-protocol part of the tuple. Return like seq_* */
58 int (*print_tuple)(struct seq_file *s, 58 int (*print_tuple)(struct seq_file *s,
@@ -117,20 +117,19 @@ extern int nf_ct_port_nlattr_to_tuple(struct nlattr *tb[],
117 struct nf_conntrack_tuple *t); 117 struct nf_conntrack_tuple *t);
118extern const struct nla_policy nf_ct_port_nla_policy[]; 118extern const struct nla_policy nf_ct_port_nla_policy[];
119 119
120/* Log invalid packets */
121extern unsigned int nf_ct_log_invalid;
122
123#ifdef CONFIG_SYSCTL 120#ifdef CONFIG_SYSCTL
124#ifdef DEBUG_INVALID_PACKETS 121#ifdef DEBUG_INVALID_PACKETS
125#define LOG_INVALID(proto) \ 122#define LOG_INVALID(net, proto) \
126 (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) 123 ((net)->ct.sysctl_log_invalid == (proto) || \
124 (net)->ct.sysctl_log_invalid == IPPROTO_RAW)
127#else 125#else
128#define LOG_INVALID(proto) \ 126#define LOG_INVALID(net, proto) \
129 ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \ 127 (((net)->ct.sysctl_log_invalid == (proto) || \
128 (net)->ct.sysctl_log_invalid == IPPROTO_RAW) \
130 && net_ratelimit()) 129 && net_ratelimit())
131#endif 130#endif
132#else 131#else
133#define LOG_INVALID(proto) 0 132#define LOG_INVALID(net, proto) 0
134#endif /* CONFIG_SYSCTL */ 133#endif /* CONFIG_SYSCTL */
135 134
136#endif /*_NF_CONNTRACK_PROTOCOL_H*/ 135#endif /*_NF_CONNTRACK_PROTOCOL_H*/
diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h
index 8c6b5ae45534..7182c06974f4 100644
--- a/include/net/netfilter/nf_log.h
+++ b/include/net/netfilter/nf_log.h
@@ -28,7 +28,7 @@ struct nf_loginfo {
28 } u; 28 } u;
29}; 29};
30 30
31typedef void nf_logfn(unsigned int pf, 31typedef void nf_logfn(u_int8_t pf,
32 unsigned int hooknum, 32 unsigned int hooknum,
33 const struct sk_buff *skb, 33 const struct sk_buff *skb,
34 const struct net_device *in, 34 const struct net_device *in,
@@ -43,12 +43,12 @@ struct nf_logger {
43}; 43};
44 44
45/* Function to register/unregister log function. */ 45/* Function to register/unregister log function. */
46int nf_log_register(int pf, const struct nf_logger *logger); 46int nf_log_register(u_int8_t pf, const struct nf_logger *logger);
47void nf_log_unregister(const struct nf_logger *logger); 47void nf_log_unregister(const struct nf_logger *logger);
48void nf_log_unregister_pf(int pf); 48void nf_log_unregister_pf(u_int8_t pf);
49 49
50/* Calls the registered backend logging function */ 50/* Calls the registered backend logging function */
51void nf_log_packet(int pf, 51void nf_log_packet(u_int8_t pf,
52 unsigned int hooknum, 52 unsigned int hooknum,
53 const struct sk_buff *skb, 53 const struct sk_buff *skb,
54 const struct net_device *in, 54 const struct net_device *in,
diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h
index d030044e9235..252fd1010b77 100644
--- a/include/net/netfilter/nf_queue.h
+++ b/include/net/netfilter/nf_queue.h
@@ -8,7 +8,7 @@ struct nf_queue_entry {
8 unsigned int id; 8 unsigned int id;
9 9
10 struct nf_hook_ops *elem; 10 struct nf_hook_ops *elem;
11 int pf; 11 u_int8_t pf;
12 unsigned int hook; 12 unsigned int hook;
13 struct net_device *indev; 13 struct net_device *indev;
14 struct net_device *outdev; 14 struct net_device *outdev;
@@ -24,9 +24,9 @@ struct nf_queue_handler {
24 char *name; 24 char *name;
25}; 25};
26 26
27extern int nf_register_queue_handler(int pf, 27extern int nf_register_queue_handler(u_int8_t pf,
28 const struct nf_queue_handler *qh); 28 const struct nf_queue_handler *qh);
29extern int nf_unregister_queue_handler(int pf, 29extern int nf_unregister_queue_handler(u_int8_t pf,
30 const struct nf_queue_handler *qh); 30 const struct nf_queue_handler *qh);
31extern void nf_unregister_queue_handlers(const struct nf_queue_handler *qh); 31extern void nf_unregister_queue_handlers(const struct nf_queue_handler *qh);
32extern void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict); 32extern void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict);
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h
new file mode 100644
index 000000000000..208b46f4d6d2
--- /dev/null
+++ b/include/net/netfilter/nf_tproxy_core.h
@@ -0,0 +1,32 @@
1#ifndef _NF_TPROXY_CORE_H
2#define _NF_TPROXY_CORE_H
3
4#include <linux/types.h>
5#include <linux/in.h>
6#include <linux/skbuff.h>
7#include <net/sock.h>
8#include <net/inet_sock.h>
9#include <net/tcp.h>
10
11/* look up and get a reference to a matching socket */
12extern struct sock *
13nf_tproxy_get_sock_v4(struct net *net, const u8 protocol,
14 const __be32 saddr, const __be32 daddr,
15 const __be16 sport, const __be16 dport,
16 const struct net_device *in, bool listening);
17
18static inline void
19nf_tproxy_put_sock(struct sock *sk)
20{
21 /* TIME_WAIT inet sockets have to be handled differently */
22 if ((sk->sk_protocol == IPPROTO_TCP) && (sk->sk_state == TCP_TIME_WAIT))
23 inet_twsk_put(inet_twsk(sk));
24 else
25 sock_put(sk);
26}
27
28/* assign a socket to the skb -- consumes sk */
29int
30nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk);
31
32#endif
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 18024b8cecb8..3643bbb8e585 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -119,9 +119,6 @@
119 * Nested Attributes Construction: 119 * Nested Attributes Construction:
120 * nla_nest_start(skb, type) start a nested attribute 120 * nla_nest_start(skb, type) start a nested attribute
121 * nla_nest_end(skb, nla) finalize a nested attribute 121 * nla_nest_end(skb, nla) finalize a nested attribute
122 * nla_nest_compat_start(skb, type, start a nested compat attribute
123 * len, data)
124 * nla_nest_compat_end(skb, type) finalize a nested compat attribute
125 * nla_nest_cancel(skb, nla) cancel nested attribute construction 122 * nla_nest_cancel(skb, nla) cancel nested attribute construction
126 * 123 *
127 * Attribute Length Calculations: 124 * Attribute Length Calculations:
@@ -156,7 +153,6 @@
156 * nla_find_nested() find attribute in nested attributes 153 * nla_find_nested() find attribute in nested attributes
157 * nla_parse() parse and validate stream of attrs 154 * nla_parse() parse and validate stream of attrs
158 * nla_parse_nested() parse nested attribuets 155 * nla_parse_nested() parse nested attribuets
159 * nla_parse_nested_compat() parse nested compat attributes
160 * nla_for_each_attr() loop over all attributes 156 * nla_for_each_attr() loop over all attributes
161 * nla_for_each_nested() loop over the nested attributes 157 * nla_for_each_nested() loop over the nested attributes
162 *========================================================================= 158 *=========================================================================
@@ -702,7 +698,7 @@ static inline int nla_len(const struct nlattr *nla)
702 */ 698 */
703static inline int nla_ok(const struct nlattr *nla, int remaining) 699static inline int nla_ok(const struct nlattr *nla, int remaining)
704{ 700{
705 return remaining >= sizeof(*nla) && 701 return remaining >= (int) sizeof(*nla) &&
706 nla->nla_len >= sizeof(*nla) && 702 nla->nla_len >= sizeof(*nla) &&
707 nla->nla_len <= remaining; 703 nla->nla_len <= remaining;
708} 704}
@@ -752,39 +748,6 @@ static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,
752} 748}
753 749
754/** 750/**
755 * nla_parse_nested_compat - parse nested compat attributes
756 * @tb: destination array with maxtype+1 elements
757 * @maxtype: maximum attribute type to be expected
758 * @nla: attribute containing the nested attributes
759 * @data: pointer to point to contained structure
760 * @len: length of contained structure
761 * @policy: validation policy
762 *
763 * Parse a nested compat attribute. The compat attribute contains a structure
764 * and optionally a set of nested attributes. On success the data pointer
765 * points to the nested data and tb contains the parsed attributes
766 * (see nla_parse).
767 */
768static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype,
769 struct nlattr *nla,
770 const struct nla_policy *policy,
771 int len)
772{
773 int nested_len = nla_len(nla) - NLA_ALIGN(len);
774
775 if (nested_len < 0)
776 return -EINVAL;
777 if (nested_len >= nla_attr_size(0))
778 return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len),
779 nested_len, policy);
780 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
781 return 0;
782}
783
784#define nla_parse_nested_compat(tb, maxtype, nla, policy, data, len) \
785({ data = nla_len(nla) >= len ? nla_data(nla) : NULL; \
786 __nla_parse_nested_compat(tb, maxtype, nla, policy, len); })
787/**
788 * nla_put_u8 - Add a u8 netlink attribute to a socket buffer 751 * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
789 * @skb: socket buffer to add attribute to 752 * @skb: socket buffer to add attribute to
790 * @attrtype: attribute type 753 * @attrtype: attribute type
@@ -1031,51 +994,6 @@ static inline int nla_nest_end(struct sk_buff *skb, struct nlattr *start)
1031} 994}
1032 995
1033/** 996/**
1034 * nla_nest_compat_start - Start a new level of nested compat attributes
1035 * @skb: socket buffer to add attributes to
1036 * @attrtype: attribute type of container
1037 * @attrlen: length of structure
1038 * @data: pointer to structure
1039 *
1040 * Start a nested compat attribute that contains both a structure and
1041 * a set of nested attributes.
1042 *
1043 * Returns the container attribute
1044 */
1045static inline struct nlattr *nla_nest_compat_start(struct sk_buff *skb,
1046 int attrtype, int attrlen,
1047 const void *data)
1048{
1049 struct nlattr *start = (struct nlattr *)skb_tail_pointer(skb);
1050
1051 if (nla_put(skb, attrtype, attrlen, data) < 0)
1052 return NULL;
1053 if (nla_nest_start(skb, attrtype) == NULL) {
1054 nlmsg_trim(skb, start);
1055 return NULL;
1056 }
1057 return start;
1058}
1059
1060/**
1061 * nla_nest_compat_end - Finalize nesting of compat attributes
1062 * @skb: socket buffer the attributes are stored in
1063 * @start: container attribute
1064 *
1065 * Corrects the container attribute header to include the all
1066 * appeneded attributes.
1067 *
1068 * Returns the total data length of the skb.
1069 */
1070static inline int nla_nest_compat_end(struct sk_buff *skb, struct nlattr *start)
1071{
1072 struct nlattr *nest = (void *)start + NLMSG_ALIGN(start->nla_len);
1073
1074 start->nla_len = skb_tail_pointer(skb) - (unsigned char *)start;
1075 return nla_nest_end(skb, nest);
1076}
1077
1078/**
1079 * nla_nest_cancel - Cancel nesting of attributes 997 * nla_nest_cancel - Cancel nesting of attributes
1080 * @skb: socket buffer the message is stored in 998 * @skb: socket buffer the message is stored in
1081 * @start: container attribute 999 * @start: container attribute
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
new file mode 100644
index 000000000000..f4498a62881b
--- /dev/null
+++ b/include/net/netns/conntrack.h
@@ -0,0 +1,30 @@
1#ifndef __NETNS_CONNTRACK_H
2#define __NETNS_CONNTRACK_H
3
4#include <linux/list.h>
5#include <asm/atomic.h>
6
7struct ctl_table_header;
8struct nf_conntrack_ecache;
9
10struct netns_ct {
11 atomic_t count;
12 unsigned int expect_count;
13 struct hlist_head *hash;
14 struct hlist_head *expect_hash;
15 struct hlist_head unconfirmed;
16 struct ip_conntrack_stat *stat;
17#ifdef CONFIG_NF_CONNTRACK_EVENTS
18 struct nf_conntrack_ecache *ecache;
19#endif
20 int sysctl_acct;
21 int sysctl_checksum;
22 unsigned int sysctl_log_invalid; /* Log invalid packets */
23#ifdef CONFIG_SYSCTL
24 struct ctl_table_header *sysctl_header;
25 struct ctl_table_header *acct_sysctl_header;
26#endif
27 int hash_vmalloc;
28 int expect_vmalloc;
29};
30#endif
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index a6ed83853dcc..ece1c926b5d1 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -38,6 +38,9 @@ struct netns_ipv4 {
38 struct xt_table *iptable_raw; 38 struct xt_table *iptable_raw;
39 struct xt_table *arptable_filter; 39 struct xt_table *arptable_filter;
40 struct xt_table *iptable_security; 40 struct xt_table *iptable_security;
41 struct xt_table *nat_table;
42 struct hlist_head *nat_bysource;
43 int nat_vmalloced;
41#endif 44#endif
42 45
43 int sysctl_icmp_echo_ignore_all; 46 int sysctl_icmp_echo_ignore_all;
diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h
index 449147604642..10cb7c336de5 100644
--- a/include/net/netns/mib.h
+++ b/include/net/netns/mib.h
@@ -11,6 +11,15 @@ struct netns_mib {
11 DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); 11 DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics);
12 DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); 12 DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics);
13 DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); 13 DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
14
15#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
16 struct proc_dir_entry *proc_net_devsnmp6;
17 DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);
18 DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
19 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
20 DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
21 DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
22#endif
14}; 23};
15 24
16#endif 25#endif
diff --git a/include/net/phonet/gprs.h b/include/net/phonet/gprs.h
new file mode 100644
index 000000000000..928daf595beb
--- /dev/null
+++ b/include/net/phonet/gprs.h
@@ -0,0 +1,38 @@
1/*
2 * File: pep_gprs.h
3 *
4 * GPRS over Phonet pipe end point socket
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
8 * Author: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */
24
25#ifndef NET_PHONET_GPRS_H
26#define NET_PHONET_GPRS_H
27
28struct sock;
29struct sk_buff;
30
31int pep_writeable(struct sock *sk);
32int pep_write(struct sock *sk, struct sk_buff *skb);
33struct sk_buff *pep_read(struct sock *sk);
34
35int gprs_attach(struct sock *sk);
36void gprs_detach(struct sock *sk);
37
38#endif
diff --git a/include/net/phonet/pep.h b/include/net/phonet/pep.h
new file mode 100644
index 000000000000..fcd793030e4d
--- /dev/null
+++ b/include/net/phonet/pep.h
@@ -0,0 +1,160 @@
1/*
2 * File: pep.h
3 *
4 * Phonet Pipe End Point sockets definitions
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22
23#ifndef NET_PHONET_PEP_H
24#define NET_PHONET_PEP_H
25
26struct pep_sock {
27 struct pn_sock pn_sk;
28
29 /* XXX: union-ify listening vs connected stuff ? */
30 /* Listening socket stuff: */
31 struct hlist_head ackq;
32 struct hlist_head hlist;
33
34 /* Connected socket stuff: */
35 struct sock *listener;
36 struct sk_buff_head ctrlreq_queue;
37#define PNPIPE_CTRLREQ_MAX 10
38 int ifindex;
39 u16 peer_type; /* peer type/subtype */
40 u8 pipe_handle;
41
42 u8 rx_credits;
43 u8 tx_credits;
44 u8 rx_fc; /* RX flow control */
45 u8 tx_fc; /* TX flow control */
46 u8 init_enable; /* auto-enable at creation */
47};
48
49static inline struct pep_sock *pep_sk(struct sock *sk)
50{
51 return (struct pep_sock *)sk;
52}
53
54extern const struct proto_ops phonet_stream_ops;
55
56/* Pipe protocol definitions */
57struct pnpipehdr {
58 u8 utid; /* transaction ID */
59 u8 message_id;
60 u8 pipe_handle;
61 union {
62 u8 state_after_connect; /* connect request */
63 u8 state_after_reset; /* reset request */
64 u8 error_code; /* any response */
65 u8 pep_type; /* status indication */
66 u8 data[1];
67 };
68};
69#define other_pep_type data[1]
70
71static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
72{
73 return (struct pnpipehdr *)skb_transport_header(skb);
74}
75
76#define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
77
78enum {
79 PNS_PIPE_DATA = 0x20,
80
81 PNS_PEP_CONNECT_REQ = 0x40,
82 PNS_PEP_CONNECT_RESP,
83 PNS_PEP_DISCONNECT_REQ,
84 PNS_PEP_DISCONNECT_RESP,
85 PNS_PEP_RESET_REQ,
86 PNS_PEP_RESET_RESP,
87 PNS_PEP_ENABLE_REQ,
88 PNS_PEP_ENABLE_RESP,
89 PNS_PEP_CTRL_REQ,
90 PNS_PEP_CTRL_RESP,
91 PNS_PEP_DISABLE_REQ = 0x4C,
92 PNS_PEP_DISABLE_RESP,
93
94 PNS_PEP_STATUS_IND = 0x60,
95 PNS_PIPE_CREATED_IND,
96 PNS_PIPE_RESET_IND = 0x63,
97 PNS_PIPE_ENABLED_IND,
98 PNS_PIPE_REDIRECTED_IND,
99 PNS_PIPE_DISABLED_IND = 0x66,
100};
101
102#define PN_PIPE_INVALID_HANDLE 0xff
103#define PN_PEP_TYPE_COMMON 0x00
104
105/* Phonet pipe status indication */
106enum {
107 PN_PEP_IND_FLOW_CONTROL,
108 PN_PEP_IND_ID_MCFC_GRANT_CREDITS,
109};
110
111/* Phonet pipe error codes */
112enum {
113 PN_PIPE_NO_ERROR,
114 PN_PIPE_ERR_INVALID_PARAM,
115 PN_PIPE_ERR_INVALID_HANDLE,
116 PN_PIPE_ERR_INVALID_CTRL_ID,
117 PN_PIPE_ERR_NOT_ALLOWED,
118 PN_PIPE_ERR_PEP_IN_USE,
119 PN_PIPE_ERR_OVERLOAD,
120 PN_PIPE_ERR_DEV_DISCONNECTED,
121 PN_PIPE_ERR_TIMEOUT,
122 PN_PIPE_ERR_ALL_PIPES_IN_USE,
123 PN_PIPE_ERR_GENERAL,
124 PN_PIPE_ERR_NOT_SUPPORTED,
125};
126
127/* Phonet pipe states */
128enum {
129 PN_PIPE_DISABLE,
130 PN_PIPE_ENABLE,
131};
132
133/* Phonet pipe sub-block types */
134enum {
135 PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE,
136 PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE,
137 PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE,
138 PN_PIPE_SB_NEGOTIATED_FC,
139 PN_PIPE_SB_REQUIRED_FC_TX,
140 PN_PIPE_SB_PREFERRED_FC_RX,
141};
142
143/* Phonet pipe flow control models */
144enum {
145 PN_NO_FLOW_CONTROL,
146 PN_LEGACY_FLOW_CONTROL,
147 PN_ONE_CREDIT_FLOW_CONTROL,
148 PN_MULTI_CREDIT_FLOW_CONTROL,
149};
150
151#define pn_flow_safe(fc) ((fc) >> 1)
152
153/* Phonet pipe flow control states */
154enum {
155 PEP_IND_EMPTY,
156 PEP_IND_BUSY,
157 PEP_IND_READY,
158};
159
160#endif
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
new file mode 100644
index 000000000000..d4e72508e145
--- /dev/null
+++ b/include/net/phonet/phonet.h
@@ -0,0 +1,112 @@
1/*
2 * File: af_phonet.h
3 *
4 * Phonet sockets kernel definitions
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22
23#ifndef AF_PHONET_H
24#define AF_PHONET_H
25
26/*
27 * The lower layers may not require more space, ever. Make sure it's
28 * enough.
29 */
30#define MAX_PHONET_HEADER 8
31
32/*
33 * Every Phonet* socket has this structure first in its
34 * protocol-specific structure under name c.
35 */
36struct pn_sock {
37 struct sock sk;
38 u16 sobject;
39 u8 resource;
40};
41
42static inline struct pn_sock *pn_sk(struct sock *sk)
43{
44 return (struct pn_sock *)sk;
45}
46
47extern const struct proto_ops phonet_dgram_ops;
48
49struct sock *pn_find_sock_by_sa(const struct sockaddr_pn *sa);
50void phonet_get_local_port_range(int *min, int *max);
51void pn_sock_hash(struct sock *sk);
52void pn_sock_unhash(struct sock *sk);
53int pn_sock_get_port(struct sock *sk, unsigned short sport);
54
55int pn_skb_send(struct sock *sk, struct sk_buff *skb,
56 const struct sockaddr_pn *target);
57
58static inline struct phonethdr *pn_hdr(struct sk_buff *skb)
59{
60 return (struct phonethdr *)skb_network_header(skb);
61}
62
63static inline struct phonetmsg *pn_msg(struct sk_buff *skb)
64{
65 return (struct phonetmsg *)skb_transport_header(skb);
66}
67
68/*
69 * Get the other party's sockaddr from received skb. The skb begins
70 * with a Phonet header.
71 */
72static inline
73void pn_skb_get_src_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
74{
75 struct phonethdr *ph = pn_hdr(skb);
76 u16 obj = pn_object(ph->pn_sdev, ph->pn_sobj);
77
78 sa->spn_family = AF_PHONET;
79 pn_sockaddr_set_object(sa, obj);
80 pn_sockaddr_set_resource(sa, ph->pn_res);
81 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
82}
83
84static inline
85void pn_skb_get_dst_sockaddr(struct sk_buff *skb, struct sockaddr_pn *sa)
86{
87 struct phonethdr *ph = pn_hdr(skb);
88 u16 obj = pn_object(ph->pn_rdev, ph->pn_robj);
89
90 sa->spn_family = AF_PHONET;
91 pn_sockaddr_set_object(sa, obj);
92 pn_sockaddr_set_resource(sa, ph->pn_res);
93 memset(sa->spn_zero, 0, sizeof(sa->spn_zero));
94}
95
96/* Protocols in Phonet protocol family. */
97struct phonet_protocol {
98 const struct proto_ops *ops;
99 struct proto *prot;
100 int sock_type;
101};
102
103int phonet_proto_register(int protocol, struct phonet_protocol *pp);
104void phonet_proto_unregister(int protocol, struct phonet_protocol *pp);
105
106int phonet_sysctl_init(void);
107void phonet_sysctl_exit(void);
108void phonet_netlink_register(void);
109int isi_register(void);
110void isi_unregister(void);
111
112#endif
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h
new file mode 100644
index 000000000000..bbd2a836e04c
--- /dev/null
+++ b/include/net/phonet/pn_dev.h
@@ -0,0 +1,50 @@
1/*
2 * File: pn_dev.h
3 *
4 * Phonet network device
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22
23#ifndef PN_DEV_H
24#define PN_DEV_H
25
26struct phonet_device_list {
27 struct list_head list;
28 spinlock_t lock;
29};
30
31extern struct phonet_device_list pndevs;
32
33struct phonet_device {
34 struct list_head list;
35 struct net_device *netdev;
36 DECLARE_BITMAP(addrs, 64);
37};
38
39void phonet_device_init(void);
40void phonet_device_exit(void);
41struct net_device *phonet_device_get(struct net *net);
42
43int phonet_address_add(struct net_device *dev, u8 addr);
44int phonet_address_del(struct net_device *dev, u8 addr);
45u8 phonet_address_get(struct net_device *dev, u8 addr);
46int phonet_address_lookup(u8 addr);
47
48#define PN_NO_ADDR 0xff
49
50#endif
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index b786a5b09253..4082f39f5079 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -90,10 +90,7 @@ extern void __qdisc_run(struct Qdisc *q);
90 90
91static inline void qdisc_run(struct Qdisc *q) 91static inline void qdisc_run(struct Qdisc *q)
92{ 92{
93 struct netdev_queue *txq = q->dev_queue; 93 if (!test_and_set_bit(__QDISC_STATE_RUNNING, &q->state))
94
95 if (!netif_tx_queue_stopped(txq) &&
96 !test_and_set_bit(__QDISC_STATE_RUNNING, &q->state))
97 __qdisc_run(q); 94 __qdisc_run(q);
98} 95}
99 96
diff --git a/include/net/route.h b/include/net/route.h
index 4f0d8c14736c..4e8cae0e5841 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -27,7 +27,7 @@
27#include <net/dst.h> 27#include <net/dst.h>
28#include <net/inetpeer.h> 28#include <net/inetpeer.h>
29#include <net/flow.h> 29#include <net/flow.h>
30#include <net/sock.h> 30#include <net/inet_sock.h>
31#include <linux/in_route.h> 31#include <linux/in_route.h>
32#include <linux/rtnetlink.h> 32#include <linux/rtnetlink.h>
33#include <linux/route.h> 33#include <linux/route.h>
@@ -161,6 +161,10 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
161 161
162 int err; 162 int err;
163 struct net *net = sock_net(sk); 163 struct net *net = sock_net(sk);
164
165 if (inet_sk(sk)->transparent)
166 fl.flags |= FLOWI_FLAG_ANYSRC;
167
164 if (!dst || !src) { 168 if (!dst || !src) {
165 err = __ip_route_output_key(net, rp, &fl); 169 err = __ip_route_output_key(net, rp, &fl);
166 if (err) 170 if (err)
@@ -204,4 +208,9 @@ static inline struct inet_peer *rt_get_peer(struct rtable *rt)
204 return rt->peer; 208 return rt->peer;
205} 209}
206 210
211static inline int inet_iif(const struct sk_buff *skb)
212{
213 return skb->rtable->rt_iif;
214}
215
207#endif /* _ROUTE_H */ 216#endif /* _ROUTE_H */
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index e5569625d2a5..3fe49d808957 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -53,6 +53,7 @@ struct Qdisc
53 atomic_t refcnt; 53 atomic_t refcnt;
54 unsigned long state; 54 unsigned long state;
55 struct sk_buff *gso_skb; 55 struct sk_buff *gso_skb;
56 struct sk_buff_head requeue;
56 struct sk_buff_head q; 57 struct sk_buff_head q;
57 struct netdev_queue *dev_queue; 58 struct netdev_queue *dev_queue;
58 struct Qdisc *next_sched; 59 struct Qdisc *next_sched;
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index c32ddf0279c8..b05b0557211f 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -261,7 +261,9 @@ enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 };
261 * must be less than 65535 (2^16 - 1), or we will have overflow 261 * must be less than 65535 (2^16 - 1), or we will have overflow
262 * problems creating SACK's. 262 * problems creating SACK's.
263 */ 263 */
264#define SCTP_TSN_MAP_SIZE 2048 264#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG
265#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL
266#define SCTP_TSN_MAP_SIZE 4096
265#define SCTP_TSN_MAX_GAP 65535 267#define SCTP_TSN_MAX_GAP 65535
266 268
267/* We will not record more than this many duplicate TSNs between two 269/* We will not record more than this many duplicate TSNs between two
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 17b932b8a55a..703305d00365 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -406,10 +406,7 @@ struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id);
406 406
407/* A macro to walk a list of skbs. */ 407/* A macro to walk a list of skbs. */
408#define sctp_skb_for_each(pos, head, tmp) \ 408#define sctp_skb_for_each(pos, head, tmp) \
409for (pos = (head)->next;\ 409 skb_queue_walk_safe(head, pos, tmp)
410 tmp = (pos)->next, pos != ((struct sk_buff *)(head));\
411 pos = tmp)
412
413 410
414/* A helper to append an entire skb list (list) to another (head). */ 411/* A helper to append an entire skb list (list) to another (head). */
415static inline void sctp_skb_list_tail(struct sk_buff_head *list, 412static inline void sctp_skb_list_tail(struct sk_buff_head *list,
@@ -420,10 +417,7 @@ static inline void sctp_skb_list_tail(struct sk_buff_head *list,
420 sctp_spin_lock_irqsave(&head->lock, flags); 417 sctp_spin_lock_irqsave(&head->lock, flags);
421 sctp_spin_lock(&list->lock); 418 sctp_spin_lock(&list->lock);
422 419
423 list_splice((struct list_head *)list, (struct list_head *)head->prev); 420 skb_queue_splice_tail_init(list, head);
424
425 head->qlen += list->qlen;
426 list->qlen = 0;
427 421
428 sctp_spin_unlock(&list->lock); 422 sctp_spin_unlock(&list->lock);
429 sctp_spin_unlock_irqrestore(&head->lock, flags); 423 sctp_spin_unlock_irqrestore(&head->lock, flags);
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 24811732bdb2..029a54a02396 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -227,6 +227,9 @@ struct sctp_chunk *sctp_make_abort_violation(const struct sctp_association *,
227 const struct sctp_chunk *, 227 const struct sctp_chunk *,
228 const __u8 *, 228 const __u8 *,
229 const size_t ); 229 const size_t );
230struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *,
231 const struct sctp_chunk *,
232 struct sctp_paramhdr *);
230struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, 233struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *,
231 const struct sctp_transport *, 234 const struct sctp_transport *,
232 const void *payload, 235 const void *payload,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index ab1c472ea753..9661d7b765f0 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -731,20 +731,23 @@ struct sctp_chunk {
731 */ 731 */
732 struct sk_buff *auth_chunk; 732 struct sk_buff *auth_chunk;
733 733
734 __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */ 734#define SCTP_CAN_FRTX 0x0
735 __u8 resent; /* Has this chunk ever been retransmitted. */ 735#define SCTP_NEED_FRTX 0x1
736 __u8 has_tsn; /* Does this chunk have a TSN yet? */ 736#define SCTP_DONT_FRTX 0x2
737 __u8 has_ssn; /* Does this chunk have a SSN yet? */ 737 __u16 rtt_in_progress:1, /* This chunk used for RTT calc? */
738 __u8 singleton; /* Was this the only chunk in the packet? */ 738 resent:1, /* Has this chunk ever been resent. */
739 __u8 end_of_packet; /* Was this the last chunk in the packet? */ 739 has_tsn:1, /* Does this chunk have a TSN yet? */
740 __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */ 740 has_ssn:1, /* Does this chunk have a SSN yet? */
741 __u8 pdiscard; /* Discard the whole packet now? */ 741 singleton:1, /* Only chunk in the packet? */
742 __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */ 742 end_of_packet:1, /* Last chunk in the packet? */
743 __s8 fast_retransmit; /* Is this chunk fast retransmitted? */ 743 ecn_ce_done:1, /* Have we processed the ECN CE bit? */
744 __u8 tsn_missing_report; /* Data chunk missing counter. */ 744 pdiscard:1, /* Discard the whole packet now? */
745 __u8 data_accepted; /* At least 1 chunk in this packet accepted */ 745 tsn_gap_acked:1, /* Is this chunk acked by a GAP ACK? */
746 __u8 auth; /* IN: was auth'ed | OUT: needs auth */ 746 data_accepted:1, /* At least 1 chunk accepted */
747 __u8 has_asconf; /* IN: have seen an asconf before */ 747 auth:1, /* IN: was auth'ed | OUT: needs auth */
748 has_asconf:1, /* IN: have seen an asconf before */
749 tsn_missing_report:2, /* Data chunk missing counter. */
750 fast_retransmit:2; /* Is this chunk fast retransmitted? */
748}; 751};
749 752
750void sctp_chunk_hold(struct sctp_chunk *); 753void sctp_chunk_hold(struct sctp_chunk *);
@@ -1225,7 +1228,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
1225 1228
1226sctp_scope_t sctp_scope(const union sctp_addr *); 1229sctp_scope_t sctp_scope(const union sctp_addr *);
1227int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); 1230int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);
1228int sctp_is_any(const union sctp_addr *addr); 1231int sctp_is_any(struct sock *sk, const union sctp_addr *addr);
1229int sctp_addr_is_valid(const union sctp_addr *addr); 1232int sctp_addr_is_valid(const union sctp_addr *addr);
1230 1233
1231 1234
@@ -1542,7 +1545,6 @@ struct sctp_association {
1542 * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn(). 1545 * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn().
1543 */ 1546 */
1544 struct sctp_tsnmap tsn_map; 1547 struct sctp_tsnmap tsn_map;
1545 __u8 _map[sctp_tsnmap_storage_size(SCTP_TSN_MAP_SIZE)];
1546 1548
1547 /* Ack State : This flag indicates if the next received 1549 /* Ack State : This flag indicates if the next received
1548 * : packet is to be responded to with a 1550 * : packet is to be responded to with a
diff --git a/include/net/sctp/tsnmap.h b/include/net/sctp/tsnmap.h
index 099211bf998d..4aabc5a96cf6 100644
--- a/include/net/sctp/tsnmap.h
+++ b/include/net/sctp/tsnmap.h
@@ -60,18 +60,7 @@ struct sctp_tsnmap {
60 * It points at one of the two buffers with which we will 60 * It points at one of the two buffers with which we will
61 * ping-pong between. 61 * ping-pong between.
62 */ 62 */
63 __u8 *tsn_map; 63 unsigned long *tsn_map;
64
65 /* This marks the tsn which overflows the tsn_map, when the
66 * cumulative ack point reaches this point we know we can switch
67 * maps (tsn_map and overflow_map swap).
68 */
69 __u32 overflow_tsn;
70
71 /* This is the overflow array for tsn_map.
72 * It points at one of the other ping-pong buffers.
73 */
74 __u8 *overflow_map;
75 64
76 /* This is the TSN at tsn_map[0]. */ 65 /* This is the TSN at tsn_map[0]. */
77 __u32 base_tsn; 66 __u32 base_tsn;
@@ -89,15 +78,15 @@ struct sctp_tsnmap {
89 */ 78 */
90 __u32 cumulative_tsn_ack_point; 79 __u32 cumulative_tsn_ack_point;
91 80
81 /* This is the highest TSN we've marked. */
82 __u32 max_tsn_seen;
83
92 /* This is the minimum number of TSNs we can track. This corresponds 84 /* This is the minimum number of TSNs we can track. This corresponds
93 * to the size of tsn_map. Note: the overflow_map allows us to 85 * to the size of tsn_map. Note: the overflow_map allows us to
94 * potentially track more than this quantity. 86 * potentially track more than this quantity.
95 */ 87 */
96 __u16 len; 88 __u16 len;
97 89
98 /* This is the highest TSN we've marked. */
99 __u32 max_tsn_seen;
100
101 /* Data chunks pending receipt. used by SCTP_STATUS sockopt */ 90 /* Data chunks pending receipt. used by SCTP_STATUS sockopt */
102 __u16 pending_data; 91 __u16 pending_data;
103 92
@@ -105,29 +94,19 @@ struct sctp_tsnmap {
105 * every SACK. Store up to SCTP_MAX_DUP_TSNS worth of 94 * every SACK. Store up to SCTP_MAX_DUP_TSNS worth of
106 * information. 95 * information.
107 */ 96 */
108 __be32 dup_tsns[SCTP_MAX_DUP_TSNS];
109 __u16 num_dup_tsns; 97 __u16 num_dup_tsns;
110 98 __be32 dup_tsns[SCTP_MAX_DUP_TSNS];
111 /* Record gap ack block information here. */
112 struct sctp_gap_ack_block gabs[SCTP_MAX_GABS];
113
114 int malloced;
115
116 __u8 raw_map[0];
117}; 99};
118 100
119struct sctp_tsnmap_iter { 101struct sctp_tsnmap_iter {
120 __u32 start; 102 __u32 start;
121}; 103};
122 104
123/* This macro assists in creation of external storage for variable length
124 * internal buffers. We double allocate so the overflow map works.
125 */
126#define sctp_tsnmap_storage_size(count) (sizeof(__u8) * (count) * 2)
127
128/* Initialize a block of memory as a tsnmap. */ 105/* Initialize a block of memory as a tsnmap. */
129struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *, __u16 len, 106struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *, __u16 len,
130 __u32 initial_tsn); 107 __u32 initial_tsn, gfp_t gfp);
108
109void sctp_tsnmap_free(struct sctp_tsnmap *map);
131 110
132/* Test the tracking state of this TSN. 111/* Test the tracking state of this TSN.
133 * Returns: 112 * Returns:
@@ -138,7 +117,7 @@ struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *, __u16 len,
138int sctp_tsnmap_check(const struct sctp_tsnmap *, __u32 tsn); 117int sctp_tsnmap_check(const struct sctp_tsnmap *, __u32 tsn);
139 118
140/* Mark this TSN as seen. */ 119/* Mark this TSN as seen. */
141void sctp_tsnmap_mark(struct sctp_tsnmap *, __u32 tsn); 120int sctp_tsnmap_mark(struct sctp_tsnmap *, __u32 tsn);
142 121
143/* Mark this TSN and all lower as seen. */ 122/* Mark this TSN and all lower as seen. */
144void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn); 123void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn);
@@ -169,24 +148,16 @@ static inline __be32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map)
169} 148}
170 149
171/* How many gap ack blocks do we have recorded? */ 150/* How many gap ack blocks do we have recorded? */
172__u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map); 151__u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map,
152 struct sctp_gap_ack_block *gabs);
173 153
174/* Refresh the count on pending data. */ 154/* Refresh the count on pending data. */
175__u16 sctp_tsnmap_pending(struct sctp_tsnmap *map); 155__u16 sctp_tsnmap_pending(struct sctp_tsnmap *map);
176 156
177/* Return pointer to gap ack blocks as needed by SACK. */
178static inline struct sctp_gap_ack_block *sctp_tsnmap_get_gabs(struct sctp_tsnmap *map)
179{
180 return map->gabs;
181}
182
183/* Is there a gap in the TSN map? */ 157/* Is there a gap in the TSN map? */
184static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map) 158static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map)
185{ 159{
186 int has_gap; 160 return (map->cumulative_tsn_ack_point != map->max_tsn_seen);
187
188 has_gap = (map->cumulative_tsn_ack_point != map->max_tsn_seen);
189 return has_gap;
190} 161}
191 162
192/* Mark a duplicate TSN. Note: limit the storage of duplicate TSN 163/* Mark a duplicate TSN. Note: limit the storage of duplicate TSN
diff --git a/include/net/sock.h b/include/net/sock.h
index 06c5259aff30..ada50c04d09f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -482,6 +482,11 @@ static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
482 skb->next = NULL; 482 skb->next = NULL;
483} 483}
484 484
485static inline int sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
486{
487 return sk->sk_backlog_rcv(sk, skb);
488}
489
485#define sk_wait_event(__sk, __timeo, __condition) \ 490#define sk_wait_event(__sk, __timeo, __condition) \
486 ({ int __rc; \ 491 ({ int __rc; \
487 release_sock(__sk); \ 492 release_sock(__sk); \
@@ -532,6 +537,7 @@ struct proto {
532 int (*getsockopt)(struct sock *sk, int level, 537 int (*getsockopt)(struct sock *sk, int level,
533 int optname, char __user *optval, 538 int optname, char __user *optval,
534 int __user *option); 539 int __user *option);
540#ifdef CONFIG_COMPAT
535 int (*compat_setsockopt)(struct sock *sk, 541 int (*compat_setsockopt)(struct sock *sk,
536 int level, 542 int level,
537 int optname, char __user *optval, 543 int optname, char __user *optval,
@@ -540,6 +546,7 @@ struct proto {
540 int level, 546 int level,
541 int optname, char __user *optval, 547 int optname, char __user *optval,
542 int __user *option); 548 int __user *option);
549#endif
543 int (*sendmsg)(struct kiocb *iocb, struct sock *sk, 550 int (*sendmsg)(struct kiocb *iocb, struct sock *sk,
544 struct msghdr *msg, size_t len); 551 struct msghdr *msg, size_t len);
545 int (*recvmsg)(struct kiocb *iocb, struct sock *sk, 552 int (*recvmsg)(struct kiocb *iocb, struct sock *sk,
@@ -1322,6 +1329,18 @@ static inline void sk_change_net(struct sock *sk, struct net *net)
1322 sock_net_set(sk, hold_net(net)); 1329 sock_net_set(sk, hold_net(net));
1323} 1330}
1324 1331
1332static inline struct sock *skb_steal_sock(struct sk_buff *skb)
1333{
1334 if (unlikely(skb->sk)) {
1335 struct sock *sk = skb->sk;
1336
1337 skb->destructor = NULL;
1338 skb->sk = NULL;
1339 return sk;
1340 }
1341 return NULL;
1342}
1343
1325extern void sock_enable_timestamp(struct sock *sk); 1344extern void sock_enable_timestamp(struct sock *sk);
1326extern int sock_get_timestamp(struct sock *, struct timeval __user *); 1345extern int sock_get_timestamp(struct sock *, struct timeval __user *);
1327extern int sock_get_timestampns(struct sock *, struct timespec __user *); 1346extern int sock_get_timestampns(struct sock *, struct timespec __user *);
diff --git a/include/net/tc_act/tc_skbedit.h b/include/net/tc_act/tc_skbedit.h
new file mode 100644
index 000000000000..6abb3ed3ebf7
--- /dev/null
+++ b/include/net/tc_act/tc_skbedit.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (c) 2008, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Author: Alexander Duyck <alexander.h.duyck@intel.com>
18 */
19
20#ifndef __NET_TC_SKBEDIT_H
21#define __NET_TC_SKBEDIT_H
22
23#include <net/act_api.h>
24
25struct tcf_skbedit {
26 struct tcf_common common;
27 u32 flags;
28 u32 priority;
29 u16 queue_mapping;
30};
31#define to_skbedit(pc) \
32 container_of(pc, struct tcf_skbedit, common)
33
34#endif /* __NET_TC_SKBEDIT_H */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 8983386356a5..438014d57610 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -472,6 +472,8 @@ extern void tcp_send_delayed_ack(struct sock *sk);
472 472
473/* tcp_input.c */ 473/* tcp_input.c */
474extern void tcp_cwnd_application_limited(struct sock *sk); 474extern void tcp_cwnd_application_limited(struct sock *sk);
475extern void tcp_skb_mark_lost_uncond_verify(struct tcp_sock *tp,
476 struct sk_buff *skb);
475 477
476/* tcp_timer.c */ 478/* tcp_timer.c */
477extern void tcp_init_xmit_timers(struct sock *); 479extern void tcp_init_xmit_timers(struct sock *);
@@ -894,7 +896,7 @@ static inline int tcp_prequeue(struct sock *sk, struct sk_buff *skb)
894 BUG_ON(sock_owned_by_user(sk)); 896 BUG_ON(sock_owned_by_user(sk));
895 897
896 while ((skb1 = __skb_dequeue(&tp->ucopy.prequeue)) != NULL) { 898 while ((skb1 = __skb_dequeue(&tp->ucopy.prequeue)) != NULL) {
897 sk->sk_backlog_rcv(sk, skb1); 899 sk_backlog_rcv(sk, skb1);
898 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPPREQUEUEDROPPED); 900 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPPREQUEUEDROPPED);
899 } 901 }
900 902
@@ -974,6 +976,7 @@ static inline void tcp_openreq_init(struct request_sock *req,
974 ireq->acked = 0; 976 ireq->acked = 0;
975 ireq->ecn_ok = 0; 977 ireq->ecn_ok = 0;
976 ireq->rmt_port = tcp_hdr(skb)->source; 978 ireq->rmt_port = tcp_hdr(skb)->source;
979 ireq->loc_port = tcp_hdr(skb)->dest;
977} 980}
978 981
979extern void tcp_enter_memory_pressure(struct sock *sk); 982extern void tcp_enter_memory_pressure(struct sock *sk);
@@ -1039,13 +1042,12 @@ static inline void tcp_clear_retrans_hints_partial(struct tcp_sock *tp)
1039{ 1042{
1040 tp->lost_skb_hint = NULL; 1043 tp->lost_skb_hint = NULL;
1041 tp->scoreboard_skb_hint = NULL; 1044 tp->scoreboard_skb_hint = NULL;
1042 tp->retransmit_skb_hint = NULL;
1043 tp->forward_skb_hint = NULL;
1044} 1045}
1045 1046
1046static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) 1047static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1047{ 1048{
1048 tcp_clear_retrans_hints_partial(tp); 1049 tcp_clear_retrans_hints_partial(tp);
1050 tp->retransmit_skb_hint = NULL;
1049} 1051}
1050 1052
1051/* MD5 Signature */ 1053/* MD5 Signature */
@@ -1180,49 +1182,45 @@ static inline void tcp_write_queue_purge(struct sock *sk)
1180 1182
1181static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) 1183static inline struct sk_buff *tcp_write_queue_head(struct sock *sk)
1182{ 1184{
1183 struct sk_buff *skb = sk->sk_write_queue.next; 1185 return skb_peek(&sk->sk_write_queue);
1184 if (skb == (struct sk_buff *) &sk->sk_write_queue)
1185 return NULL;
1186 return skb;
1187} 1186}
1188 1187
1189static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk) 1188static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk)
1190{ 1189{
1191 struct sk_buff *skb = sk->sk_write_queue.prev; 1190 return skb_peek_tail(&sk->sk_write_queue);
1192 if (skb == (struct sk_buff *) &sk->sk_write_queue)
1193 return NULL;
1194 return skb;
1195} 1191}
1196 1192
1197static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb) 1193static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb)
1198{ 1194{
1199 return skb->next; 1195 return skb_queue_next(&sk->sk_write_queue, skb);
1200} 1196}
1201 1197
1202#define tcp_for_write_queue(skb, sk) \ 1198#define tcp_for_write_queue(skb, sk) \
1203 for (skb = (sk)->sk_write_queue.next; \ 1199 skb_queue_walk(&(sk)->sk_write_queue, skb)
1204 (skb != (struct sk_buff *)&(sk)->sk_write_queue); \
1205 skb = skb->next)
1206 1200
1207#define tcp_for_write_queue_from(skb, sk) \ 1201#define tcp_for_write_queue_from(skb, sk) \
1208 for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\ 1202 skb_queue_walk_from(&(sk)->sk_write_queue, skb)
1209 skb = skb->next)
1210 1203
1211#define tcp_for_write_queue_from_safe(skb, tmp, sk) \ 1204#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
1212 for (tmp = skb->next; \ 1205 skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp)
1213 (skb != (struct sk_buff *)&(sk)->sk_write_queue); \
1214 skb = tmp, tmp = skb->next)
1215 1206
1216static inline struct sk_buff *tcp_send_head(struct sock *sk) 1207static inline struct sk_buff *tcp_send_head(struct sock *sk)
1217{ 1208{
1218 return sk->sk_send_head; 1209 return sk->sk_send_head;
1219} 1210}
1220 1211
1212static inline bool tcp_skb_is_last(const struct sock *sk,
1213 const struct sk_buff *skb)
1214{
1215 return skb_queue_is_last(&sk->sk_write_queue, skb);
1216}
1217
1221static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) 1218static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb)
1222{ 1219{
1223 sk->sk_send_head = skb->next; 1220 if (tcp_skb_is_last(sk, skb))
1224 if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue)
1225 sk->sk_send_head = NULL; 1221 sk->sk_send_head = NULL;
1222 else
1223 sk->sk_send_head = tcp_write_queue_next(sk, skb);
1226} 1224}
1227 1225
1228static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) 1226static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked)
@@ -1267,12 +1265,12 @@ static inline void tcp_insert_write_queue_after(struct sk_buff *skb,
1267 __skb_queue_after(&sk->sk_write_queue, skb, buff); 1265 __skb_queue_after(&sk->sk_write_queue, skb, buff);
1268} 1266}
1269 1267
1270/* Insert skb between prev and next on the write queue of sk. */ 1268/* Insert new before skb on the write queue of sk. */
1271static inline void tcp_insert_write_queue_before(struct sk_buff *new, 1269static inline void tcp_insert_write_queue_before(struct sk_buff *new,
1272 struct sk_buff *skb, 1270 struct sk_buff *skb,
1273 struct sock *sk) 1271 struct sock *sk)
1274{ 1272{
1275 __skb_insert(new, skb->prev, skb, &sk->sk_write_queue); 1273 __skb_queue_before(&sk->sk_write_queue, skb, new);
1276 1274
1277 if (sk->sk_send_head == skb) 1275 if (sk->sk_send_head == skb)
1278 sk->sk_send_head = new; 1276 sk->sk_send_head = new;
@@ -1283,12 +1281,6 @@ static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk)
1283 __skb_unlink(skb, &sk->sk_write_queue); 1281 __skb_unlink(skb, &sk->sk_write_queue);
1284} 1282}
1285 1283
1286static inline int tcp_skb_is_last(const struct sock *sk,
1287 const struct sk_buff *skb)
1288{
1289 return skb->next == (struct sk_buff *)&sk->sk_write_queue;
1290}
1291
1292static inline int tcp_write_queue_empty(struct sock *sk) 1284static inline int tcp_write_queue_empty(struct sock *sk)
1293{ 1285{
1294 return skb_queue_empty(&sk->sk_write_queue); 1286 return skb_queue_empty(&sk->sk_write_queue);
diff --git a/include/net/udp.h b/include/net/udp.h
index addcdc67234c..1e205095ea68 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -148,10 +148,9 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
148 char __user *optval, int optlen, 148 char __user *optval, int optlen,
149 int (*push_pending_frames)(struct sock *)); 149 int (*push_pending_frames)(struct sock *));
150 150
151DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); 151extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
152 152 __be32 daddr, __be16 dport,
153/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */ 153 int dif);
154DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
155 154
156/* 155/*
157 * SNMP statistics for UDP and UDP-Lite 156 * SNMP statistics for UDP and UDP-Lite
@@ -163,12 +162,14 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
163 if (is_udplite) SNMP_INC_STATS_BH((net)->mib.udplite_statistics, field); \ 162 if (is_udplite) SNMP_INC_STATS_BH((net)->mib.udplite_statistics, field); \
164 else SNMP_INC_STATS_BH((net)->mib.udp_statistics, field); } while(0) 163 else SNMP_INC_STATS_BH((net)->mib.udp_statistics, field); } while(0)
165 164
166#define UDP6_INC_STATS_BH(net, field, is_udplite) do { (void)net; \ 165#define UDP6_INC_STATS_BH(net, field, is_udplite) do { \
167 if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \ 166 if (is_udplite) SNMP_INC_STATS_BH((net)->mib.udplite_stats_in6, field);\
168 else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0) 167 else SNMP_INC_STATS_BH((net)->mib.udp_stats_in6, field); \
169#define UDP6_INC_STATS_USER(net, field, is_udplite) do { (void)net; \ 168} while(0)
170 if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \ 169#define UDP6_INC_STATS_USER(net, field, __lite) do { \
171 else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0) 170 if (__lite) SNMP_INC_STATS_USER((net)->mib.udplite_stats_in6, field); \
171 else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \
172} while(0)
172 173
173#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 174#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
174#define UDPX_INC_STATS_BH(sk, field) \ 175#define UDPX_INC_STATS_BH(sk, field) \
diff --git a/include/net/wireless.h b/include/net/wireless.h
index 9324f8dd183e..721efb363db7 100644
--- a/include/net/wireless.h
+++ b/include/net/wireless.h
@@ -60,6 +60,7 @@ enum ieee80211_channel_flags {
60 * with cfg80211. 60 * with cfg80211.
61 * 61 *
62 * @center_freq: center frequency in MHz 62 * @center_freq: center frequency in MHz
63 * @max_bandwidth: maximum allowed bandwidth for this channel, in MHz
63 * @hw_value: hardware-specific value for the channel 64 * @hw_value: hardware-specific value for the channel
64 * @flags: channel flags from &enum ieee80211_channel_flags. 65 * @flags: channel flags from &enum ieee80211_channel_flags.
65 * @orig_flags: channel flags at registration time, used by regulatory 66 * @orig_flags: channel flags at registration time, used by regulatory
@@ -73,6 +74,7 @@ enum ieee80211_channel_flags {
73struct ieee80211_channel { 74struct ieee80211_channel {
74 enum ieee80211_band band; 75 enum ieee80211_band band;
75 u16 center_freq; 76 u16 center_freq;
77 u8 max_bandwidth;
76 u16 hw_value; 78 u16 hw_value;
77 u32 flags; 79 u32 flags;
78 int max_antenna_gain; 80 int max_antenna_gain;
@@ -178,6 +180,7 @@ struct ieee80211_supported_band {
178 * struct wiphy - wireless hardware description 180 * struct wiphy - wireless hardware description
179 * @idx: the wiphy index assigned to this item 181 * @idx: the wiphy index assigned to this item
180 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name> 182 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
183 * @reg_notifier: the driver's regulatory notification callback
181 */ 184 */
182struct wiphy { 185struct wiphy {
183 /* assign these fields before you register the wiphy */ 186 /* assign these fields before you register the wiphy */
@@ -185,6 +188,9 @@ struct wiphy {
185 /* permanent MAC address */ 188 /* permanent MAC address */
186 u8 perm_addr[ETH_ALEN]; 189 u8 perm_addr[ETH_ALEN];
187 190
191 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
192 u16 interface_modes;
193
188 /* If multiple wiphys are registered and you're handed e.g. 194 /* If multiple wiphys are registered and you're handed e.g.
189 * a regular netdev with assigned ieee80211_ptr, you won't 195 * a regular netdev with assigned ieee80211_ptr, you won't
190 * know whether it points to a wiphy your driver has registered 196 * know whether it points to a wiphy your driver has registered
@@ -194,6 +200,9 @@ struct wiphy {
194 200
195 struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS]; 201 struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
196 202
203 /* Lets us get back the wiphy on the callback */
204 int (*reg_notifier)(struct wiphy *wiphy, enum reg_set_by setby);
205
197 /* fields below are read-only, assigned by cfg80211 */ 206 /* fields below are read-only, assigned by cfg80211 */
198 207
199 /* the item in /sys/class/ieee80211/ points to this, 208 /* the item in /sys/class/ieee80211/ points to this,
@@ -214,9 +223,11 @@ struct wiphy {
214 * the netdev.) 223 * the netdev.)
215 * 224 *
216 * @wiphy: pointer to hardware description 225 * @wiphy: pointer to hardware description
226 * @iftype: interface type
217 */ 227 */
218struct wireless_dev { 228struct wireless_dev {
219 struct wiphy *wiphy; 229 struct wiphy *wiphy;
230 enum nl80211_iftype iftype;
220 231
221 /* private to the generic wireless code */ 232 /* private to the generic wireless code */
222 struct list_head list; 233 struct list_head list;
@@ -319,7 +330,6 @@ extern int ieee80211_frequency_to_channel(int freq);
319 */ 330 */
320extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy, 331extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
321 int freq); 332 int freq);
322
323/** 333/**
324 * ieee80211_get_channel - get channel struct from wiphy for specified frequency 334 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
325 */ 335 */
@@ -328,4 +338,57 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq)
328{ 338{
329 return __ieee80211_get_channel(wiphy, freq); 339 return __ieee80211_get_channel(wiphy, freq);
330} 340}
341
342/**
343 * __regulatory_hint - hint to the wireless core a regulatory domain
344 * @wiphy: if a driver is providing the hint this is the driver's very
345 * own &struct wiphy
346 * @alpha2: the ISO/IEC 3166 alpha2 being claimed the regulatory domain
347 * should be in. If @rd is set this should be NULL
348 * @rd: a complete regulatory domain, if passed the caller need not worry
349 * about freeing it
350 *
351 * The Wireless subsystem can use this function to hint to the wireless core
352 * what it believes should be the current regulatory domain by
353 * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
354 * domain should be in or by providing a completely build regulatory domain.
355 *
356 * Returns -EALREADY if *a regulatory domain* has already been set. Note that
357 * this could be by another driver. It is safe for drivers to continue if
358 * -EALREADY is returned, if drivers are not capable of world roaming they
359 * should not register more channels than they support. Right now we only
360 * support listening to the first driver hint. If the driver is capable
361 * of world roaming but wants to respect its own EEPROM mappings for
362 * specific regulatory domains it should register the @reg_notifier callback
363 * on the &struct wiphy. Returns 0 if the hint went through fine or through an
364 * intersection operation. Otherwise a standard error code is returned.
365 *
366 */
367extern int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
368 const char *alpha2, struct ieee80211_regdomain *rd);
369/**
370 * regulatory_hint - driver hint to the wireless core a regulatory domain
371 * @wiphy: the driver's very own &struct wiphy
372 * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
373 * should be in. If @rd is set this should be NULL. Note that if you
374 * set this to NULL you should still set rd->alpha2 to some accepted
375 * alpha2.
376 * @rd: a complete regulatory domain provided by the driver. If passed
377 * the driver does not need to worry about freeing it.
378 *
379 * Wireless drivers can use this function to hint to the wireless core
380 * what it believes should be the current regulatory domain by
381 * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
382 * domain should be in or by providing a completely build regulatory domain.
383 * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
384 * for a regulatory domain structure for the respective country. If
385 * a regulatory domain is build and passed you should set the alpha2
386 * if possible, otherwise set it to the special value of "99" which tells
387 * the wireless core it is unknown. If you pass a built regulatory domain
388 * and we return non zero you are in charge of kfree()'ing the structure.
389 *
390 * See __regulatory_hint() documentation for possible return values.
391 */
392extern int regulatory_hint(struct wiphy *wiphy,
393 const char *alpha2, struct ieee80211_regdomain *rd);
331#endif /* __NET_WIRELESS_H */ 394#endif /* __NET_WIRELESS_H */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 2933d7474a79..11c890ad8ebb 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -117,12 +117,23 @@ extern struct mutex xfrm_cfg_mutex;
117 metrics. Plus, it will be made via sk->sk_dst_cache. Solved. 117 metrics. Plus, it will be made via sk->sk_dst_cache. Solved.
118 */ 118 */
119 119
120struct xfrm_state_walk {
121 struct list_head all;
122 u8 state;
123 union {
124 u8 dying;
125 u8 proto;
126 };
127 u32 seq;
128};
129
120/* Full description of state of transformer. */ 130/* Full description of state of transformer. */
121struct xfrm_state 131struct xfrm_state
122{ 132{
123 /* Note: bydst is re-used during gc */ 133 union {
124 struct list_head all; 134 struct hlist_node gclist;
125 struct hlist_node bydst; 135 struct hlist_node bydst;
136 };
126 struct hlist_node bysrc; 137 struct hlist_node bysrc;
127 struct hlist_node byspi; 138 struct hlist_node byspi;
128 139
@@ -134,12 +145,8 @@ struct xfrm_state
134 145
135 u32 genid; 146 u32 genid;
136 147
137 /* Key manger bits */ 148 /* Key manager bits */
138 struct { 149 struct xfrm_state_walk km;
139 u8 state;
140 u8 dying;
141 u32 seq;
142 } km;
143 150
144 /* Parameters of this state. */ 151 /* Parameters of this state. */
145 struct { 152 struct {
@@ -447,10 +454,20 @@ struct xfrm_tmpl
447 454
448#define XFRM_MAX_DEPTH 6 455#define XFRM_MAX_DEPTH 6
449 456
457struct xfrm_policy_walk_entry {
458 struct list_head all;
459 u8 dead;
460};
461
462struct xfrm_policy_walk {
463 struct xfrm_policy_walk_entry walk;
464 u8 type;
465 u32 seq;
466};
467
450struct xfrm_policy 468struct xfrm_policy
451{ 469{
452 struct xfrm_policy *next; 470 struct xfrm_policy *next;
453 struct list_head bytype;
454 struct hlist_node bydst; 471 struct hlist_node bydst;
455 struct hlist_node byidx; 472 struct hlist_node byidx;
456 473
@@ -465,17 +482,23 @@ struct xfrm_policy
465 struct xfrm_lifetime_cfg lft; 482 struct xfrm_lifetime_cfg lft;
466 struct xfrm_lifetime_cur curlft; 483 struct xfrm_lifetime_cur curlft;
467 struct dst_entry *bundles; 484 struct dst_entry *bundles;
468 u16 family; 485 struct xfrm_policy_walk_entry walk;
469 u8 type; 486 u8 type;
470 u8 action; 487 u8 action;
471 u8 flags; 488 u8 flags;
472 u8 dead;
473 u8 xfrm_nr; 489 u8 xfrm_nr;
474 /* XXX 1 byte hole, try to pack */ 490 u16 family;
475 struct xfrm_sec_ctx *security; 491 struct xfrm_sec_ctx *security;
476 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 492 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
477}; 493};
478 494
495struct xfrm_kmaddress {
496 xfrm_address_t local;
497 xfrm_address_t remote;
498 u32 reserved;
499 u16 family;
500};
501
479struct xfrm_migrate { 502struct xfrm_migrate {
480 xfrm_address_t old_daddr; 503 xfrm_address_t old_daddr;
481 xfrm_address_t old_saddr; 504 xfrm_address_t old_saddr;
@@ -515,7 +538,7 @@ struct xfrm_mgr
515 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); 538 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
516 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c); 539 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c);
517 int (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 540 int (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
518 int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles); 541 int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles, struct xfrm_kmaddress *k);
519}; 542};
520 543
521extern int xfrm_register_km(struct xfrm_mgr *km); 544extern int xfrm_register_km(struct xfrm_mgr *km);
@@ -1243,18 +1266,6 @@ struct xfrm6_tunnel {
1243 int priority; 1266 int priority;
1244}; 1267};
1245 1268
1246struct xfrm_state_walk {
1247 struct xfrm_state *state;
1248 int count;
1249 u8 proto;
1250};
1251
1252struct xfrm_policy_walk {
1253 struct xfrm_policy *policy;
1254 int count;
1255 u8 type, cur_type;
1256};
1257
1258extern void xfrm_init(void); 1269extern void xfrm_init(void);
1259extern void xfrm4_init(void); 1270extern void xfrm4_init(void);
1260extern void xfrm_state_init(void); 1271extern void xfrm_state_init(void);
@@ -1279,23 +1290,10 @@ static inline void xfrm6_fini(void)
1279extern int xfrm_proc_init(void); 1290extern int xfrm_proc_init(void);
1280#endif 1291#endif
1281 1292
1282static inline void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto) 1293extern void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto);
1283{
1284 walk->proto = proto;
1285 walk->state = NULL;
1286 walk->count = 0;
1287}
1288
1289static inline void xfrm_state_walk_done(struct xfrm_state_walk *walk)
1290{
1291 if (walk->state != NULL) {
1292 xfrm_state_put(walk->state);
1293 walk->state = NULL;
1294 }
1295}
1296
1297extern int xfrm_state_walk(struct xfrm_state_walk *walk, 1294extern int xfrm_state_walk(struct xfrm_state_walk *walk,
1298 int (*func)(struct xfrm_state *, int, void*), void *); 1295 int (*func)(struct xfrm_state *, int, void*), void *);
1296extern void xfrm_state_walk_done(struct xfrm_state_walk *walk);
1299extern struct xfrm_state *xfrm_state_alloc(void); 1297extern struct xfrm_state *xfrm_state_alloc(void);
1300extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 1298extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
1301 struct flowi *fl, struct xfrm_tmpl *tmpl, 1299 struct flowi *fl, struct xfrm_tmpl *tmpl,
@@ -1419,24 +1417,10 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
1419 1417
1420struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); 1418struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
1421 1419
1422static inline void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type) 1420extern void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type);
1423{
1424 walk->cur_type = XFRM_POLICY_TYPE_MAIN;
1425 walk->type = type;
1426 walk->policy = NULL;
1427 walk->count = 0;
1428}
1429
1430static inline void xfrm_policy_walk_done(struct xfrm_policy_walk *walk)
1431{
1432 if (walk->policy != NULL) {
1433 xfrm_pol_put(walk->policy);
1434 walk->policy = NULL;
1435 }
1436}
1437
1438extern int xfrm_policy_walk(struct xfrm_policy_walk *walk, 1421extern int xfrm_policy_walk(struct xfrm_policy_walk *walk,
1439 int (*func)(struct xfrm_policy *, int, int, void*), void *); 1422 int (*func)(struct xfrm_policy *, int, int, void*), void *);
1423extern void xfrm_policy_walk_done(struct xfrm_policy_walk *walk);
1440int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); 1424int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
1441struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, 1425struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
1442 struct xfrm_selector *sel, 1426 struct xfrm_selector *sel,
@@ -1455,12 +1439,14 @@ extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
1455 1439
1456#ifdef CONFIG_XFRM_MIGRATE 1440#ifdef CONFIG_XFRM_MIGRATE
1457extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1441extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
1458 struct xfrm_migrate *m, int num_bundles); 1442 struct xfrm_migrate *m, int num_bundles,
1443 struct xfrm_kmaddress *k);
1459extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m); 1444extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m);
1460extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, 1445extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
1461 struct xfrm_migrate *m); 1446 struct xfrm_migrate *m);
1462extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1447extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
1463 struct xfrm_migrate *m, int num_bundles); 1448 struct xfrm_migrate *m, int num_bundles,
1449 struct xfrm_kmaddress *k);
1464#endif 1450#endif
1465 1451
1466extern wait_queue_head_t km_waitq; 1452extern wait_queue_head_t km_waitq;