diff options
Diffstat (limited to 'include/net')
80 files changed, 1969 insertions, 983 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h index 68b4eaf7719d..565eed8fe496 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h | |||
@@ -89,7 +89,7 @@ struct tc_action_ops { | |||
89 | int (*dump)(struct sk_buff *, struct tc_action *, int, int); | 89 | int (*dump)(struct sk_buff *, struct tc_action *, int, int); |
90 | int (*cleanup)(struct tc_action *, int bind); | 90 | int (*cleanup)(struct tc_action *, int bind); |
91 | int (*lookup)(struct tc_action *, u32); | 91 | int (*lookup)(struct tc_action *, u32); |
92 | int (*init)(struct rtattr *, struct rtattr *, struct tc_action *, int , int); | 92 | int (*init)(struct nlattr *, struct nlattr *, struct tc_action *, int , int); |
93 | int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *); | 93 | int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *); |
94 | }; | 94 | }; |
95 | 95 | ||
@@ -104,7 +104,7 @@ extern u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo); | |||
104 | extern int tcf_hash_search(struct tc_action *a, u32 index); | 104 | extern int tcf_hash_search(struct tc_action *a, u32 index); |
105 | extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, | 105 | extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, |
106 | int bind, struct tcf_hashinfo *hinfo); | 106 | int bind, struct tcf_hashinfo *hinfo); |
107 | extern struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, | 107 | extern struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, |
108 | struct tc_action *a, int size, | 108 | struct tc_action *a, int size, |
109 | int bind, u32 *idx_gen, | 109 | int bind, u32 *idx_gen, |
110 | struct tcf_hashinfo *hinfo); | 110 | struct tcf_hashinfo *hinfo); |
@@ -114,8 +114,8 @@ extern int tcf_register_action(struct tc_action_ops *a); | |||
114 | extern int tcf_unregister_action(struct tc_action_ops *a); | 114 | extern int tcf_unregister_action(struct tc_action_ops *a); |
115 | extern void tcf_action_destroy(struct tc_action *a, int bind); | 115 | extern void tcf_action_destroy(struct tc_action *a, int bind); |
116 | extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res); | 116 | extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res); |
117 | extern struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est, char *n, int ovr, int bind, int *err); | 117 | extern struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind); |
118 | extern struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, char *n, int ovr, int bind, int *err); | 118 | extern struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind); |
119 | extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int); | 119 | extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int); |
120 | extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); | 120 | extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); |
121 | extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); | 121 | extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); |
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 33b593e17441..496503c03846 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #define IPV6_MAX_ADDRESSES 16 | 18 | #define IPV6_MAX_ADDRESSES 16 |
19 | 19 | ||
20 | #include <linux/in.h> | ||
20 | #include <linux/in6.h> | 21 | #include <linux/in6.h> |
21 | 22 | ||
22 | struct prefix_info { | 23 | struct prefix_info { |
@@ -58,15 +59,20 @@ extern int addrconf_add_ifaddr(void __user *arg); | |||
58 | extern int addrconf_del_ifaddr(void __user *arg); | 59 | extern int addrconf_del_ifaddr(void __user *arg); |
59 | extern int addrconf_set_dstaddr(void __user *arg); | 60 | extern int addrconf_set_dstaddr(void __user *arg); |
60 | 61 | ||
61 | extern int ipv6_chk_addr(struct in6_addr *addr, | 62 | extern int ipv6_chk_addr(struct net *net, |
63 | struct in6_addr *addr, | ||
62 | struct net_device *dev, | 64 | struct net_device *dev, |
63 | int strict); | 65 | int strict); |
66 | |||
64 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) | 67 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
65 | extern int ipv6_chk_home_addr(struct in6_addr *addr); | 68 | extern int ipv6_chk_home_addr(struct net *net, |
69 | struct in6_addr *addr); | ||
66 | #endif | 70 | #endif |
67 | extern struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr, | 71 | extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, |
68 | struct net_device *dev, | 72 | struct in6_addr *addr, |
69 | int strict); | 73 | struct net_device *dev, |
74 | int strict); | ||
75 | |||
70 | extern int ipv6_get_saddr(struct dst_entry *dst, | 76 | extern int ipv6_get_saddr(struct dst_entry *dst, |
71 | struct in6_addr *daddr, | 77 | struct in6_addr *daddr, |
72 | struct in6_addr *saddr); | 78 | struct in6_addr *saddr); |
@@ -84,6 +90,14 @@ extern void addrconf_leave_solict(struct inet6_dev *idev, | |||
84 | struct in6_addr *addr); | 90 | struct in6_addr *addr); |
85 | 91 | ||
86 | /* | 92 | /* |
93 | * IPv6 Address Label subsystem (addrlabel.c) | ||
94 | */ | ||
95 | extern int ipv6_addr_label_init(void); | ||
96 | extern void ipv6_addr_label_rtnl_register(void); | ||
97 | extern u32 ipv6_addr_label(const struct in6_addr *addr, | ||
98 | int type, int ifindex); | ||
99 | |||
100 | /* | ||
87 | * multicast prototypes (mcast.c) | 101 | * multicast prototypes (mcast.c) |
88 | */ | 102 | */ |
89 | extern int ipv6_sock_mc_join(struct sock *sk, int ifindex, | 103 | extern int ipv6_sock_mc_join(struct sock *sk, int ifindex, |
@@ -241,6 +255,26 @@ static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) | |||
241 | addr->s6_addr32[3] == htonl(0x00000002)); | 255 | addr->s6_addr32[3] == htonl(0x00000002)); |
242 | } | 256 | } |
243 | 257 | ||
258 | static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr) | ||
259 | { | ||
260 | eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) || | ||
261 | ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) || | ||
262 | ipv4_is_private_172(addr) || ipv4_is_test_192(addr) || | ||
263 | ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) || | ||
264 | ipv4_is_test_198(addr) || ipv4_is_multicast(addr) || | ||
265 | ipv4_is_lbcast(addr)) ? 0x00 : 0x02; | ||
266 | eui[1] = 0; | ||
267 | eui[2] = 0x5E; | ||
268 | eui[3] = 0xFE; | ||
269 | memcpy (eui+4, &addr, 4); | ||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) | ||
274 | { | ||
275 | return ((addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE)); | ||
276 | } | ||
277 | |||
244 | #ifdef CONFIG_PROC_FS | 278 | #ifdef CONFIG_PROC_FS |
245 | extern int if6_proc_init(void); | 279 | extern int if6_proc_init(void); |
246 | extern void if6_proc_exit(void); | 280 | extern void if6_proc_exit(void); |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 0864a775de24..2dfa96b0575e 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -12,7 +12,7 @@ extern void unix_gc(void); | |||
12 | 12 | ||
13 | #define UNIX_HASH_SIZE 256 | 13 | #define UNIX_HASH_SIZE 256 |
14 | 14 | ||
15 | extern atomic_t unix_tot_inflight; | 15 | extern unsigned int unix_tot_inflight; |
16 | 16 | ||
17 | struct unix_address { | 17 | struct unix_address { |
18 | atomic_t refcnt; | 18 | atomic_t refcnt; |
@@ -59,12 +59,11 @@ struct unix_sock { | |||
59 | #define unix_sk(__sk) ((struct unix_sock *)__sk) | 59 | #define unix_sk(__sk) ((struct unix_sock *)__sk) |
60 | 60 | ||
61 | #ifdef CONFIG_SYSCTL | 61 | #ifdef CONFIG_SYSCTL |
62 | extern int sysctl_unix_max_dgram_qlen; | 62 | extern int unix_sysctl_register(struct net *net); |
63 | extern void unix_sysctl_register(void); | 63 | extern void unix_sysctl_unregister(struct net *net); |
64 | extern void unix_sysctl_unregister(void); | ||
65 | #else | 64 | #else |
66 | static inline void unix_sysctl_register(void) {} | 65 | static inline int unix_sysctl_register(struct net *net) { return 0; } |
67 | static inline void unix_sysctl_unregister(void) {} | 66 | static inline void unix_sysctl_unregister(struct net *net) {} |
68 | #endif | 67 | #endif |
69 | #endif | 68 | #endif |
70 | #endif | 69 | #endif |
diff --git a/include/net/arp.h b/include/net/arp.h index f02664568600..c236270ec95e 100644 --- a/include/net/arp.h +++ b/include/net/arp.h | |||
@@ -5,24 +5,25 @@ | |||
5 | #include <linux/if_arp.h> | 5 | #include <linux/if_arp.h> |
6 | #include <net/neighbour.h> | 6 | #include <net/neighbour.h> |
7 | 7 | ||
8 | #define HAVE_ARP_CREATE | ||
9 | 8 | ||
10 | extern struct neigh_table arp_tbl; | 9 | extern struct neigh_table arp_tbl; |
11 | 10 | ||
12 | extern void arp_init(void); | 11 | extern void arp_init(void); |
13 | extern int arp_find(unsigned char *haddr, struct sk_buff *skb); | 12 | extern int arp_find(unsigned char *haddr, struct sk_buff *skb); |
14 | extern int arp_ioctl(unsigned int cmd, void __user *arg); | 13 | extern int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg); |
15 | extern void arp_send(int type, int ptype, __be32 dest_ip, | 14 | extern void arp_send(int type, int ptype, __be32 dest_ip, |
16 | struct net_device *dev, __be32 src_ip, | 15 | struct net_device *dev, __be32 src_ip, |
17 | unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th); | 16 | const unsigned char *dest_hw, |
17 | const unsigned char *src_hw, const unsigned char *th); | ||
18 | extern int arp_bind_neighbour(struct dst_entry *dst); | 18 | extern int arp_bind_neighbour(struct dst_entry *dst); |
19 | extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); | 19 | extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); |
20 | extern void arp_ifdown(struct net_device *dev); | 20 | extern void arp_ifdown(struct net_device *dev); |
21 | 21 | ||
22 | extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, | 22 | extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, |
23 | struct net_device *dev, __be32 src_ip, | 23 | struct net_device *dev, __be32 src_ip, |
24 | unsigned char *dest_hw, unsigned char *src_hw, | 24 | const unsigned char *dest_hw, |
25 | unsigned char *target_hw); | 25 | const unsigned char *src_hw, |
26 | const unsigned char *target_hw); | ||
26 | extern void arp_xmit(struct sk_buff *skb); | 27 | extern void arp_xmit(struct sk_buff *skb); |
27 | 28 | ||
28 | extern struct neigh_ops arp_broken_ops; | 29 | extern struct neigh_ops arp_broken_ops; |
diff --git a/include/net/ax25.h b/include/net/ax25.h index 4e3cd93f81fc..32a57e1dee3a 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h | |||
@@ -35,7 +35,7 @@ | |||
35 | #define AX25_P_ATALK 0xca /* Appletalk */ | 35 | #define AX25_P_ATALK 0xca /* Appletalk */ |
36 | #define AX25_P_ATALK_ARP 0xcb /* Appletalk ARP */ | 36 | #define AX25_P_ATALK_ARP 0xcb /* Appletalk ARP */ |
37 | #define AX25_P_IP 0xcc /* ARPA Internet Protocol */ | 37 | #define AX25_P_IP 0xcc /* ARPA Internet Protocol */ |
38 | #define AX25_P_ARP 0xcd /* ARPA Adress Resolution */ | 38 | #define AX25_P_ARP 0xcd /* ARPA Address Resolution */ |
39 | #define AX25_P_FLEXNET 0xce /* FlexNet */ | 39 | #define AX25_P_FLEXNET 0xce /* FlexNet */ |
40 | #define AX25_P_NETROM 0xcf /* NET/ROM */ | 40 | #define AX25_P_NETROM 0xcf /* NET/ROM */ |
41 | #define AX25_P_TEXT 0xF0 /* No layer 3 protocol impl. */ | 41 | #define AX25_P_TEXT 0xF0 /* No layer 3 protocol impl. */ |
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h index 25aa575db807..98ec7a320689 100644 --- a/include/net/bluetooth/rfcomm.h +++ b/include/net/bluetooth/rfcomm.h | |||
@@ -252,8 +252,8 @@ static inline void rfcomm_dlc_put(struct rfcomm_dlc *d) | |||
252 | rfcomm_dlc_free(d); | 252 | rfcomm_dlc_free(d); |
253 | } | 253 | } |
254 | 254 | ||
255 | extern void FASTCALL(__rfcomm_dlc_throttle(struct rfcomm_dlc *d)); | 255 | extern void __rfcomm_dlc_throttle(struct rfcomm_dlc *d); |
256 | extern void FASTCALL(__rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)); | 256 | extern void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d); |
257 | 257 | ||
258 | static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d) | 258 | static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d) |
259 | { | 259 | { |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index d30960e1755c..bcc480b8892a 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -49,6 +49,120 @@ extern int ieee80211_radiotap_iterator_next( | |||
49 | struct ieee80211_radiotap_iterator *iterator); | 49 | struct ieee80211_radiotap_iterator *iterator); |
50 | 50 | ||
51 | 51 | ||
52 | /** | ||
53 | * struct key_params - key information | ||
54 | * | ||
55 | * Information about a key | ||
56 | * | ||
57 | * @key: key material | ||
58 | * @key_len: length of key material | ||
59 | * @cipher: cipher suite selector | ||
60 | * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used | ||
61 | * with the get_key() callback, must be in little endian, | ||
62 | * length given by @seq_len. | ||
63 | */ | ||
64 | struct key_params { | ||
65 | u8 *key; | ||
66 | u8 *seq; | ||
67 | int key_len; | ||
68 | int seq_len; | ||
69 | u32 cipher; | ||
70 | }; | ||
71 | |||
72 | /** | ||
73 | * struct beacon_parameters - beacon parameters | ||
74 | * | ||
75 | * Used to configure the beacon for an interface. | ||
76 | * | ||
77 | * @head: head portion of beacon (before TIM IE) | ||
78 | * or %NULL if not changed | ||
79 | * @tail: tail portion of beacon (after TIM IE) | ||
80 | * or %NULL if not changed | ||
81 | * @interval: beacon interval or zero if not changed | ||
82 | * @dtim_period: DTIM period or zero if not changed | ||
83 | * @head_len: length of @head | ||
84 | * @tail_len: length of @tail | ||
85 | */ | ||
86 | struct beacon_parameters { | ||
87 | u8 *head, *tail; | ||
88 | int interval, dtim_period; | ||
89 | int head_len, tail_len; | ||
90 | }; | ||
91 | |||
92 | /** | ||
93 | * enum station_flags - station flags | ||
94 | * | ||
95 | * Station capability flags. Note that these must be the bits | ||
96 | * according to the nl80211 flags. | ||
97 | * | ||
98 | * @STATION_FLAG_CHANGED: station flags were changed | ||
99 | * @STATION_FLAG_AUTHORIZED: station is authorized to send frames (802.1X) | ||
100 | * @STATION_FLAG_SHORT_PREAMBLE: station is capable of receiving frames | ||
101 | * with short preambles | ||
102 | * @STATION_FLAG_WME: station is WME/QoS capable | ||
103 | */ | ||
104 | enum station_flags { | ||
105 | STATION_FLAG_CHANGED = 1<<0, | ||
106 | STATION_FLAG_AUTHORIZED = 1<<NL80211_STA_FLAG_AUTHORIZED, | ||
107 | STATION_FLAG_SHORT_PREAMBLE = 1<<NL80211_STA_FLAG_SHORT_PREAMBLE, | ||
108 | STATION_FLAG_WME = 1<<NL80211_STA_FLAG_WME, | ||
109 | }; | ||
110 | |||
111 | /** | ||
112 | * struct station_parameters - station parameters | ||
113 | * | ||
114 | * Used to change and create a new station. | ||
115 | * | ||
116 | * @vlan: vlan interface station should belong to | ||
117 | * @supported_rates: supported rates in IEEE 802.11 format | ||
118 | * (or NULL for no change) | ||
119 | * @supported_rates_len: number of supported rates | ||
120 | * @station_flags: station flags (see &enum station_flags) | ||
121 | * @listen_interval: listen interval or -1 for no change | ||
122 | * @aid: AID or zero for no change | ||
123 | */ | ||
124 | struct station_parameters { | ||
125 | u8 *supported_rates; | ||
126 | struct net_device *vlan; | ||
127 | u32 station_flags; | ||
128 | int listen_interval; | ||
129 | u16 aid; | ||
130 | u8 supported_rates_len; | ||
131 | }; | ||
132 | |||
133 | /** | ||
134 | * enum station_stats_flags - station statistics flags | ||
135 | * | ||
136 | * Used by the driver to indicate which info in &struct station_stats | ||
137 | * it has filled in during get_station(). | ||
138 | * | ||
139 | * @STATION_STAT_INACTIVE_TIME: @inactive_time filled | ||
140 | * @STATION_STAT_RX_BYTES: @rx_bytes filled | ||
141 | * @STATION_STAT_TX_BYTES: @tx_bytes filled | ||
142 | */ | ||
143 | enum station_stats_flags { | ||
144 | STATION_STAT_INACTIVE_TIME = 1<<0, | ||
145 | STATION_STAT_RX_BYTES = 1<<1, | ||
146 | STATION_STAT_TX_BYTES = 1<<2, | ||
147 | }; | ||
148 | |||
149 | /** | ||
150 | * struct station_stats - station statistics | ||
151 | * | ||
152 | * Station information filled by driver for get_station(). | ||
153 | * | ||
154 | * @filled: bitflag of flags from &enum station_stats_flags | ||
155 | * @inactive_time: time since last station activity (tx/rx) in milliseconds | ||
156 | * @rx_bytes: bytes received from this station | ||
157 | * @tx_bytes: bytes transmitted to this station | ||
158 | */ | ||
159 | struct station_stats { | ||
160 | u32 filled; | ||
161 | u32 inactive_time; | ||
162 | u32 rx_bytes; | ||
163 | u32 tx_bytes; | ||
164 | }; | ||
165 | |||
52 | /* from net/wireless.h */ | 166 | /* from net/wireless.h */ |
53 | struct wiphy; | 167 | struct wiphy; |
54 | 168 | ||
@@ -71,6 +185,31 @@ struct wiphy; | |||
71 | * | 185 | * |
72 | * @change_virtual_intf: change type of virtual interface | 186 | * @change_virtual_intf: change type of virtual interface |
73 | * | 187 | * |
188 | * @add_key: add a key with the given parameters. @mac_addr will be %NULL | ||
189 | * when adding a group key. | ||
190 | * | ||
191 | * @get_key: get information about the key with the given parameters. | ||
192 | * @mac_addr will be %NULL when requesting information for a group | ||
193 | * key. All pointers given to the @callback function need not be valid | ||
194 | * after it returns. | ||
195 | * | ||
196 | * @del_key: remove a key given the @mac_addr (%NULL for a group key) | ||
197 | * and @key_index | ||
198 | * | ||
199 | * @set_default_key: set the default key on an interface | ||
200 | * | ||
201 | * @add_beacon: Add a beacon with given parameters, @head, @interval | ||
202 | * and @dtim_period will be valid, @tail is optional. | ||
203 | * @set_beacon: Change the beacon parameters for an access point mode | ||
204 | * interface. This should reject the call when no beacon has been | ||
205 | * configured. | ||
206 | * @del_beacon: Remove beacon configuration and stop sending the beacon. | ||
207 | * | ||
208 | * @add_station: Add a new station. | ||
209 | * | ||
210 | * @del_station: Remove a station; @mac may be NULL to remove all stations. | ||
211 | * | ||
212 | * @change_station: Modify a given station. | ||
74 | */ | 213 | */ |
75 | struct cfg80211_ops { | 214 | struct cfg80211_ops { |
76 | int (*add_virtual_intf)(struct wiphy *wiphy, char *name, | 215 | int (*add_virtual_intf)(struct wiphy *wiphy, char *name, |
@@ -78,6 +217,34 @@ struct cfg80211_ops { | |||
78 | int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex); | 217 | int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex); |
79 | int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex, | 218 | int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex, |
80 | enum nl80211_iftype type); | 219 | enum nl80211_iftype type); |
220 | |||
221 | int (*add_key)(struct wiphy *wiphy, struct net_device *netdev, | ||
222 | u8 key_index, u8 *mac_addr, | ||
223 | struct key_params *params); | ||
224 | int (*get_key)(struct wiphy *wiphy, struct net_device *netdev, | ||
225 | u8 key_index, u8 *mac_addr, void *cookie, | ||
226 | void (*callback)(void *cookie, struct key_params*)); | ||
227 | int (*del_key)(struct wiphy *wiphy, struct net_device *netdev, | ||
228 | u8 key_index, u8 *mac_addr); | ||
229 | int (*set_default_key)(struct wiphy *wiphy, | ||
230 | struct net_device *netdev, | ||
231 | u8 key_index); | ||
232 | |||
233 | int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev, | ||
234 | struct beacon_parameters *info); | ||
235 | int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev, | ||
236 | struct beacon_parameters *info); | ||
237 | int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev); | ||
238 | |||
239 | |||
240 | int (*add_station)(struct wiphy *wiphy, struct net_device *dev, | ||
241 | u8 *mac, struct station_parameters *params); | ||
242 | int (*del_station)(struct wiphy *wiphy, struct net_device *dev, | ||
243 | u8 *mac); | ||
244 | int (*change_station)(struct wiphy *wiphy, struct net_device *dev, | ||
245 | u8 *mac, struct station_parameters *params); | ||
246 | int (*get_station)(struct wiphy *wiphy, struct net_device *dev, | ||
247 | u8 *mac, struct station_stats *stats); | ||
81 | }; | 248 | }; |
82 | 249 | ||
83 | #endif /* __NET_CFG80211_H */ | 250 | #endif /* __NET_CFG80211_H */ |
diff --git a/include/net/checksum.h b/include/net/checksum.h index 124246172a88..07602b7fa218 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h | |||
@@ -93,4 +93,29 @@ static inline __wsum csum_unfold(__sum16 n) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | #define CSUM_MANGLED_0 ((__force __sum16)0xffff) | 95 | #define CSUM_MANGLED_0 ((__force __sum16)0xffff) |
96 | |||
97 | static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to) | ||
98 | { | ||
99 | __be32 diff[] = { ~from, to }; | ||
100 | |||
101 | *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum))); | ||
102 | } | ||
103 | |||
104 | static inline void csum_replace2(__sum16 *sum, __be16 from, __be16 to) | ||
105 | { | ||
106 | csum_replace4(sum, (__force __be32)from, (__force __be32)to); | ||
107 | } | ||
108 | |||
109 | struct sk_buff; | ||
110 | extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | ||
111 | __be32 from, __be32 to, int pseudohdr); | ||
112 | |||
113 | static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, | ||
114 | __be16 from, __be16 to, | ||
115 | int pseudohdr) | ||
116 | { | ||
117 | inet_proto_csum_replace4(sum, skb, (__force __be32)from, | ||
118 | (__force __be32)to, pseudohdr); | ||
119 | } | ||
120 | |||
96 | #endif | 121 | #endif |
diff --git a/include/net/dsfield.h b/include/net/dsfield.h index eb65bf2e2502..8a8d4e06900d 100644 --- a/include/net/dsfield.h +++ b/include/net/dsfield.h | |||
@@ -12,15 +12,15 @@ | |||
12 | #include <asm/byteorder.h> | 12 | #include <asm/byteorder.h> |
13 | 13 | ||
14 | 14 | ||
15 | static inline __u8 ipv4_get_dsfield(struct iphdr *iph) | 15 | static inline __u8 ipv4_get_dsfield(const struct iphdr *iph) |
16 | { | 16 | { |
17 | return iph->tos; | 17 | return iph->tos; |
18 | } | 18 | } |
19 | 19 | ||
20 | 20 | ||
21 | static inline __u8 ipv6_get_dsfield(struct ipv6hdr *ipv6h) | 21 | static inline __u8 ipv6_get_dsfield(const struct ipv6hdr *ipv6h) |
22 | { | 22 | { |
23 | return ntohs(*(__be16 *) ipv6h) >> 4; | 23 | return ntohs(*(const __be16 *)ipv6h) >> 4; |
24 | } | 24 | } |
25 | 25 | ||
26 | 26 | ||
diff --git a/include/net/dst.h b/include/net/dst.h index e9ff4a4caef9..e3ac7d0fc4e1 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -50,14 +50,17 @@ struct dst_entry | |||
50 | unsigned long expires; | 50 | unsigned long expires; |
51 | 51 | ||
52 | unsigned short header_len; /* more space at head required */ | 52 | unsigned short header_len; /* more space at head required */ |
53 | unsigned short nfheader_len; /* more non-fragment space at head required */ | ||
54 | unsigned short trailer_len; /* space to reserve at tail */ | 53 | unsigned short trailer_len; /* space to reserve at tail */ |
55 | 54 | ||
56 | u32 metrics[RTAX_MAX]; | 55 | u32 metrics[RTAX_MAX]; |
57 | struct dst_entry *path; | 56 | struct dst_entry *path; |
58 | 57 | ||
59 | unsigned long rate_last; /* rate limiting for ICMP */ | 58 | unsigned long rate_last; /* rate limiting for ICMP */ |
60 | unsigned long rate_tokens; | 59 | unsigned int rate_tokens; |
60 | |||
61 | #ifdef CONFIG_NET_CLS_ROUTE | ||
62 | __u32 tclassid; | ||
63 | #endif | ||
61 | 64 | ||
62 | struct neighbour *neighbour; | 65 | struct neighbour *neighbour; |
63 | struct hh_cache *hh; | 66 | struct hh_cache *hh; |
@@ -66,10 +69,6 @@ struct dst_entry | |||
66 | int (*input)(struct sk_buff*); | 69 | int (*input)(struct sk_buff*); |
67 | int (*output)(struct sk_buff*); | 70 | int (*output)(struct sk_buff*); |
68 | 71 | ||
69 | #ifdef CONFIG_NET_CLS_ROUTE | ||
70 | __u32 tclassid; | ||
71 | #endif | ||
72 | |||
73 | struct dst_ops *ops; | 72 | struct dst_ops *ops; |
74 | 73 | ||
75 | unsigned long lastuse; | 74 | unsigned long lastuse; |
@@ -81,7 +80,6 @@ struct dst_entry | |||
81 | struct rt6_info *rt6_next; | 80 | struct rt6_info *rt6_next; |
82 | struct dn_route *dn_next; | 81 | struct dn_route *dn_next; |
83 | }; | 82 | }; |
84 | char info[0]; | ||
85 | }; | 83 | }; |
86 | 84 | ||
87 | 85 | ||
@@ -91,7 +89,7 @@ struct dst_ops | |||
91 | __be16 protocol; | 89 | __be16 protocol; |
92 | unsigned gc_thresh; | 90 | unsigned gc_thresh; |
93 | 91 | ||
94 | int (*gc)(void); | 92 | int (*gc)(struct dst_ops *ops); |
95 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); | 93 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); |
96 | void (*destroy)(struct dst_entry *); | 94 | void (*destroy)(struct dst_entry *); |
97 | void (*ifdown)(struct dst_entry *, | 95 | void (*ifdown)(struct dst_entry *, |
@@ -99,10 +97,12 @@ struct dst_ops | |||
99 | struct dst_entry * (*negative_advice)(struct dst_entry *); | 97 | struct dst_entry * (*negative_advice)(struct dst_entry *); |
100 | void (*link_failure)(struct sk_buff *); | 98 | void (*link_failure)(struct sk_buff *); |
101 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); | 99 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); |
100 | int (*local_out)(struct sk_buff *skb); | ||
102 | int entry_size; | 101 | int entry_size; |
103 | 102 | ||
104 | atomic_t entries; | 103 | atomic_t entries; |
105 | struct kmem_cache *kmem_cachep; | 104 | struct kmem_cache *kmem_cachep; |
105 | struct net *dst_net; | ||
106 | }; | 106 | }; |
107 | 107 | ||
108 | #ifdef __KERNEL__ | 108 | #ifdef __KERNEL__ |
@@ -143,6 +143,13 @@ static inline void dst_hold(struct dst_entry * dst) | |||
143 | atomic_inc(&dst->__refcnt); | 143 | atomic_inc(&dst->__refcnt); |
144 | } | 144 | } |
145 | 145 | ||
146 | static inline void dst_use(struct dst_entry *dst, unsigned long time) | ||
147 | { | ||
148 | dst_hold(dst); | ||
149 | dst->__use++; | ||
150 | dst->lastuse = time; | ||
151 | } | ||
152 | |||
146 | static inline | 153 | static inline |
147 | struct dst_entry * dst_clone(struct dst_entry * dst) | 154 | struct dst_entry * dst_clone(struct dst_entry * dst) |
148 | { | 155 | { |
@@ -173,6 +180,7 @@ static inline struct dst_entry *dst_pop(struct dst_entry *dst) | |||
173 | return child; | 180 | return child; |
174 | } | 181 | } |
175 | 182 | ||
183 | extern int dst_discard(struct sk_buff *skb); | ||
176 | extern void * dst_alloc(struct dst_ops * ops); | 184 | extern void * dst_alloc(struct dst_ops * ops); |
177 | extern void __dst_free(struct dst_entry * dst); | 185 | extern void __dst_free(struct dst_entry * dst); |
178 | extern struct dst_entry *dst_destroy(struct dst_entry * dst); | 186 | extern struct dst_entry *dst_destroy(struct dst_entry * dst); |
@@ -257,6 +265,12 @@ static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie) | |||
257 | 265 | ||
258 | extern void dst_init(void); | 266 | extern void dst_init(void); |
259 | 267 | ||
268 | /* Flags for xfrm_lookup flags argument. */ | ||
269 | enum { | ||
270 | XFRM_LOOKUP_WAIT = 1 << 0, | ||
271 | XFRM_LOOKUP_ICMP = 1 << 1, | ||
272 | }; | ||
273 | |||
260 | struct flowi; | 274 | struct flowi; |
261 | #ifndef CONFIG_XFRM | 275 | #ifndef CONFIG_XFRM |
262 | static inline int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, | 276 | static inline int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, |
diff --git a/include/net/esp.h b/include/net/esp.h index c1bc529809da..d58451331dbd 100644 --- a/include/net/esp.h +++ b/include/net/esp.h | |||
@@ -1,58 +1,20 @@ | |||
1 | #ifndef _NET_ESP_H | 1 | #ifndef _NET_ESP_H |
2 | #define _NET_ESP_H | 2 | #define _NET_ESP_H |
3 | 3 | ||
4 | #include <linux/crypto.h> | 4 | #include <linux/skbuff.h> |
5 | #include <net/xfrm.h> | ||
6 | #include <asm/scatterlist.h> | ||
7 | 5 | ||
8 | #define ESP_NUM_FAST_SG 4 | 6 | struct crypto_aead; |
9 | 7 | ||
10 | struct esp_data | 8 | struct esp_data { |
11 | { | 9 | /* 0..255 */ |
12 | struct scatterlist sgbuf[ESP_NUM_FAST_SG]; | 10 | int padlen; |
13 | 11 | ||
14 | /* Confidentiality */ | 12 | /* Confidentiality & Integrity */ |
15 | struct { | 13 | struct crypto_aead *aead; |
16 | int padlen; /* 0..255 */ | ||
17 | /* ivlen is offset from enc_data, where encrypted data start. | ||
18 | * It is logically different of crypto_tfm_alg_ivsize(tfm). | ||
19 | * We assume that it is either zero (no ivec), or | ||
20 | * >= crypto_tfm_alg_ivsize(tfm). */ | ||
21 | int ivlen; | ||
22 | int ivinitted; | ||
23 | u8 *ivec; /* ivec buffer */ | ||
24 | struct crypto_blkcipher *tfm; /* crypto handle */ | ||
25 | } conf; | ||
26 | |||
27 | /* Integrity. It is active when icv_full_len != 0 */ | ||
28 | struct { | ||
29 | u8 *work_icv; | ||
30 | int icv_full_len; | ||
31 | int icv_trunc_len; | ||
32 | struct crypto_hash *tfm; | ||
33 | } auth; | ||
34 | }; | 14 | }; |
35 | 15 | ||
36 | extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); | 16 | extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); |
37 | 17 | ||
38 | static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb, | ||
39 | int offset, int len) | ||
40 | { | ||
41 | struct hash_desc desc; | ||
42 | int err; | ||
43 | |||
44 | desc.tfm = esp->auth.tfm; | ||
45 | desc.flags = 0; | ||
46 | |||
47 | err = crypto_hash_init(&desc); | ||
48 | if (unlikely(err)) | ||
49 | return err; | ||
50 | err = skb_icv_walk(skb, &desc, offset, len, crypto_hash_update); | ||
51 | if (unlikely(err)) | ||
52 | return err; | ||
53 | return crypto_hash_final(&desc, esp->auth.work_icv); | ||
54 | } | ||
55 | |||
56 | struct ip_esp_hdr; | 18 | struct ip_esp_hdr; |
57 | 19 | ||
58 | static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb) | 20 | static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb) |
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h index 017aebd90683..34349f9f4331 100644 --- a/include/net/fib_rules.h +++ b/include/net/fib_rules.h | |||
@@ -22,6 +22,7 @@ struct fib_rule | |||
22 | u32 target; | 22 | u32 target; |
23 | struct fib_rule * ctarget; | 23 | struct fib_rule * ctarget; |
24 | struct rcu_head rcu; | 24 | struct rcu_head rcu; |
25 | struct net * fr_net; | ||
25 | }; | 26 | }; |
26 | 27 | ||
27 | struct fib_lookup_arg | 28 | struct fib_lookup_arg |
@@ -56,7 +57,7 @@ struct fib_rules_ops | |||
56 | int (*fill)(struct fib_rule *, struct sk_buff *, | 57 | int (*fill)(struct fib_rule *, struct sk_buff *, |
57 | struct nlmsghdr *, | 58 | struct nlmsghdr *, |
58 | struct fib_rule_hdr *); | 59 | struct fib_rule_hdr *); |
59 | u32 (*default_pref)(void); | 60 | u32 (*default_pref)(struct fib_rules_ops *ops); |
60 | size_t (*nlmsg_payload)(struct fib_rule *); | 61 | size_t (*nlmsg_payload)(struct fib_rule *); |
61 | 62 | ||
62 | /* Called after modifications to the rules set, must flush | 63 | /* Called after modifications to the rules set, must flush |
@@ -67,6 +68,7 @@ struct fib_rules_ops | |||
67 | const struct nla_policy *policy; | 68 | const struct nla_policy *policy; |
68 | struct list_head rules_list; | 69 | struct list_head rules_list; |
69 | struct module *owner; | 70 | struct module *owner; |
71 | struct net *fro_net; | ||
70 | }; | 72 | }; |
71 | 73 | ||
72 | #define FRA_GENERIC_POLICY \ | 74 | #define FRA_GENERIC_POLICY \ |
@@ -101,10 +103,14 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla) | |||
101 | return frh->table; | 103 | return frh->table; |
102 | } | 104 | } |
103 | 105 | ||
104 | extern int fib_rules_register(struct fib_rules_ops *); | 106 | extern int fib_rules_register(struct fib_rules_ops *); |
105 | extern int fib_rules_unregister(struct fib_rules_ops *); | 107 | extern void fib_rules_unregister(struct fib_rules_ops *); |
108 | extern void fib_rules_cleanup_ops(struct fib_rules_ops *); | ||
106 | 109 | ||
107 | extern int fib_rules_lookup(struct fib_rules_ops *, | 110 | extern int fib_rules_lookup(struct fib_rules_ops *, |
108 | struct flowi *, int flags, | 111 | struct flowi *, int flags, |
109 | struct fib_lookup_arg *); | 112 | struct fib_lookup_arg *); |
113 | extern int fib_default_rule_add(struct fib_rules_ops *, | ||
114 | u32 pref, u32 table, | ||
115 | u32 flags); | ||
110 | #endif | 116 | #endif |
diff --git a/include/net/flow.h b/include/net/flow.h index af59fa5cc1f8..ad16e0076c89 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -48,7 +48,6 @@ struct flowi { | |||
48 | 48 | ||
49 | __u8 proto; | 49 | __u8 proto; |
50 | __u8 flags; | 50 | __u8 flags; |
51 | #define FLOWI_FLAG_MULTIPATHOLDROUTE 0x01 | ||
52 | union { | 51 | union { |
53 | struct { | 52 | struct { |
54 | __be16 sport; | 53 | __be16 sport; |
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h index 0b95cf031d6e..8cd8185fa2ed 100644 --- a/include/net/gen_stats.h +++ b/include/net/gen_stats.h | |||
@@ -10,7 +10,7 @@ struct gnet_dump | |||
10 | { | 10 | { |
11 | spinlock_t * lock; | 11 | spinlock_t * lock; |
12 | struct sk_buff * skb; | 12 | struct sk_buff * skb; |
13 | struct rtattr * tail; | 13 | struct nlattr * tail; |
14 | 14 | ||
15 | /* Backward compatability */ | 15 | /* Backward compatability */ |
16 | int compat_tc_stats; | 16 | int compat_tc_stats; |
@@ -39,11 +39,11 @@ extern int gnet_stats_finish_copy(struct gnet_dump *d); | |||
39 | 39 | ||
40 | extern int gen_new_estimator(struct gnet_stats_basic *bstats, | 40 | extern int gen_new_estimator(struct gnet_stats_basic *bstats, |
41 | struct gnet_stats_rate_est *rate_est, | 41 | struct gnet_stats_rate_est *rate_est, |
42 | spinlock_t *stats_lock, struct rtattr *opt); | 42 | spinlock_t *stats_lock, struct nlattr *opt); |
43 | extern void gen_kill_estimator(struct gnet_stats_basic *bstats, | 43 | extern void gen_kill_estimator(struct gnet_stats_basic *bstats, |
44 | struct gnet_stats_rate_est *rate_est); | 44 | struct gnet_stats_rate_est *rate_est); |
45 | extern int gen_replace_estimator(struct gnet_stats_basic *bstats, | 45 | extern int gen_replace_estimator(struct gnet_stats_basic *bstats, |
46 | struct gnet_stats_rate_est *rate_est, | 46 | struct gnet_stats_rate_est *rate_est, |
47 | spinlock_t *stats_lock, struct rtattr *opt); | 47 | spinlock_t *stats_lock, struct nlattr *opt); |
48 | 48 | ||
49 | #endif | 49 | #endif |
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h index 164d13211165..285b2adfa648 100644 --- a/include/net/ieee80211.h +++ b/include/net/ieee80211.h | |||
@@ -115,8 +115,16 @@ extern u32 ieee80211_debug_level; | |||
115 | do { if (ieee80211_debug_level & (level)) \ | 115 | do { if (ieee80211_debug_level & (level)) \ |
116 | printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ | 116 | printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ |
117 | in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) | 117 | in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) |
118 | static inline bool ieee80211_ratelimit_debug(u32 level) | ||
119 | { | ||
120 | return (ieee80211_debug_level & level) && net_ratelimit(); | ||
121 | } | ||
118 | #else | 122 | #else |
119 | #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) | 123 | #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) |
124 | static inline bool ieee80211_ratelimit_debug(u32 level) | ||
125 | { | ||
126 | return false; | ||
127 | } | ||
120 | #endif /* CONFIG_IEEE80211_DEBUG */ | 128 | #endif /* CONFIG_IEEE80211_DEBUG */ |
121 | 129 | ||
122 | /* escape_essid() is intended to be used in debug (and possibly error) | 130 | /* escape_essid() is intended to be used in debug (and possibly error) |
@@ -669,7 +677,7 @@ struct ieee80211_probe_request { | |||
669 | 677 | ||
670 | struct ieee80211_probe_response { | 678 | struct ieee80211_probe_response { |
671 | struct ieee80211_hdr_3addr header; | 679 | struct ieee80211_hdr_3addr header; |
672 | u32 time_stamp[2]; | 680 | __le32 time_stamp[2]; |
673 | __le16 beacon_interval; | 681 | __le16 beacon_interval; |
674 | __le16 capability; | 682 | __le16 capability; |
675 | /* SSID, supported rates, FH params, DS params, | 683 | /* SSID, supported rates, FH params, DS params, |
@@ -710,8 +718,8 @@ struct ieee80211_txb { | |||
710 | u8 encrypted; | 718 | u8 encrypted; |
711 | u8 rts_included; | 719 | u8 rts_included; |
712 | u8 reserved; | 720 | u8 reserved; |
713 | __le16 frag_size; | 721 | u16 frag_size; |
714 | __le16 payload_size; | 722 | u16 payload_size; |
715 | struct sk_buff *fragments[0]; | 723 | struct sk_buff *fragments[0]; |
716 | }; | 724 | }; |
717 | 725 | ||
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h index 448eccb20638..b24508abb850 100644 --- a/include/net/if_inet6.h +++ b/include/net/if_inet6.h | |||
@@ -269,18 +269,21 @@ static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf) | |||
269 | buf[0] = 0x00; | 269 | buf[0] = 0x00; |
270 | } | 270 | } |
271 | 271 | ||
272 | static inline void ipv6_ib_mc_map(struct in6_addr *addr, char *buf) | 272 | static inline void ipv6_ib_mc_map(const struct in6_addr *addr, |
273 | const unsigned char *broadcast, char *buf) | ||
273 | { | 274 | { |
275 | unsigned char scope = broadcast[5] & 0xF; | ||
276 | |||
274 | buf[0] = 0; /* Reserved */ | 277 | buf[0] = 0; /* Reserved */ |
275 | buf[1] = 0xff; /* Multicast QPN */ | 278 | buf[1] = 0xff; /* Multicast QPN */ |
276 | buf[2] = 0xff; | 279 | buf[2] = 0xff; |
277 | buf[3] = 0xff; | 280 | buf[3] = 0xff; |
278 | buf[4] = 0xff; | 281 | buf[4] = 0xff; |
279 | buf[5] = 0x12; /* link local scope */ | 282 | buf[5] = 0x10 | scope; /* scope from broadcast address */ |
280 | buf[6] = 0x60; /* IPv6 signature */ | 283 | buf[6] = 0x60; /* IPv6 signature */ |
281 | buf[7] = 0x1b; | 284 | buf[7] = 0x1b; |
282 | buf[8] = 0; /* P_Key */ | 285 | buf[8] = broadcast[8]; /* P_Key */ |
283 | buf[9] = 0; | 286 | buf[9] = broadcast[9]; |
284 | memcpy(buf + 10, addr->s6_addr + 6, 10); | 287 | memcpy(buf + 10, addr->s6_addr + 6, 10); |
285 | } | 288 | } |
286 | #endif | 289 | #endif |
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 668056b4bb0b..fdff630708ce 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -57,34 +57,37 @@ extern void __inet6_hash(struct inet_hashinfo *hashinfo, struct sock *sk); | |||
57 | * | 57 | * |
58 | * The sockhash lock must be held as a reader here. | 58 | * The sockhash lock must be held as a reader here. |
59 | */ | 59 | */ |
60 | extern struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, | 60 | extern struct sock *__inet6_lookup_established(struct net *net, |
61 | struct inet_hashinfo *hashinfo, | ||
61 | const struct in6_addr *saddr, | 62 | const struct in6_addr *saddr, |
62 | const __be16 sport, | 63 | const __be16 sport, |
63 | const struct in6_addr *daddr, | 64 | const struct in6_addr *daddr, |
64 | const u16 hnum, | 65 | const u16 hnum, |
65 | const int dif); | 66 | const int dif); |
66 | 67 | ||
67 | extern struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | 68 | extern struct sock *inet6_lookup_listener(struct net *net, |
69 | struct inet_hashinfo *hashinfo, | ||
68 | const struct in6_addr *daddr, | 70 | const struct in6_addr *daddr, |
69 | const unsigned short hnum, | 71 | const unsigned short hnum, |
70 | const int dif); | 72 | const int dif); |
71 | 73 | ||
72 | static inline struct sock *__inet6_lookup(struct inet_hashinfo *hashinfo, | 74 | static inline struct sock *__inet6_lookup(struct net *net, |
75 | struct inet_hashinfo *hashinfo, | ||
73 | const struct in6_addr *saddr, | 76 | const struct in6_addr *saddr, |
74 | const __be16 sport, | 77 | const __be16 sport, |
75 | const struct in6_addr *daddr, | 78 | const struct in6_addr *daddr, |
76 | const u16 hnum, | 79 | const u16 hnum, |
77 | const int dif) | 80 | const int dif) |
78 | { | 81 | { |
79 | struct sock *sk = __inet6_lookup_established(hashinfo, saddr, sport, | 82 | struct sock *sk = __inet6_lookup_established(net, hashinfo, saddr, |
80 | daddr, hnum, dif); | 83 | sport, daddr, hnum, dif); |
81 | if (sk) | 84 | if (sk) |
82 | return sk; | 85 | return sk; |
83 | 86 | ||
84 | return inet6_lookup_listener(hashinfo, daddr, hnum, dif); | 87 | return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif); |
85 | } | 88 | } |
86 | 89 | ||
87 | extern struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, | 90 | extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, |
88 | const struct in6_addr *saddr, const __be16 sport, | 91 | const struct in6_addr *saddr, const __be16 sport, |
89 | const struct in6_addr *daddr, const __be16 dport, | 92 | const struct in6_addr *daddr, const __be16 dport, |
90 | const int dif); | 93 | const int dif); |
diff --git a/include/net/inet_common.h b/include/net/inet_common.h index 227adcbdfec8..38d5a1e9980d 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h | |||
@@ -13,9 +13,6 @@ struct sock; | |||
13 | struct sockaddr; | 13 | struct sockaddr; |
14 | struct socket; | 14 | struct socket; |
15 | 15 | ||
16 | extern void inet_remove_sock(struct sock *sk1); | ||
17 | extern void inet_put_sock(unsigned short num, | ||
18 | struct sock *sk); | ||
19 | extern int inet_release(struct socket *sock); | 16 | extern int inet_release(struct socket *sock); |
20 | extern int inet_stream_connect(struct socket *sock, | 17 | extern int inet_stream_connect(struct socket *sock, |
21 | struct sockaddr * uaddr, | 18 | struct sockaddr * uaddr, |
@@ -30,7 +27,6 @@ extern int inet_sendmsg(struct kiocb *iocb, | |||
30 | struct msghdr *msg, | 27 | struct msghdr *msg, |
31 | size_t size); | 28 | size_t size); |
32 | extern int inet_shutdown(struct socket *sock, int how); | 29 | extern int inet_shutdown(struct socket *sock, int how); |
33 | extern unsigned int inet_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait); | ||
34 | extern int inet_listen(struct socket *sock, int backlog); | 30 | extern int inet_listen(struct socket *sock, int backlog); |
35 | 31 | ||
36 | extern void inet_sock_destruct(struct sock *sk); | 32 | extern void inet_sock_destruct(struct sock *sk); |
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index de8399a79774..ba33db053854 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h | |||
@@ -83,9 +83,9 @@ static inline void IP_ECN_clear(struct iphdr *iph) | |||
83 | iph->tos &= ~INET_ECN_MASK; | 83 | iph->tos &= ~INET_ECN_MASK; |
84 | } | 84 | } |
85 | 85 | ||
86 | static inline void ipv4_copy_dscp(struct iphdr *outer, struct iphdr *inner) | 86 | static inline void ipv4_copy_dscp(unsigned int dscp, struct iphdr *inner) |
87 | { | 87 | { |
88 | u32 dscp = ipv4_get_dsfield(outer) & ~INET_ECN_MASK; | 88 | dscp &= ~INET_ECN_MASK; |
89 | ipv4_change_dsfield(inner, INET_ECN_MASK, dscp); | 89 | ipv4_change_dsfield(inner, INET_ECN_MASK, dscp); |
90 | } | 90 | } |
91 | 91 | ||
@@ -104,9 +104,9 @@ static inline void IP6_ECN_clear(struct ipv6hdr *iph) | |||
104 | *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20); | 104 | *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20); |
105 | } | 105 | } |
106 | 106 | ||
107 | static inline void ipv6_copy_dscp(struct ipv6hdr *outer, struct ipv6hdr *inner) | 107 | static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner) |
108 | { | 108 | { |
109 | u32 dscp = ipv6_get_dsfield(outer) & ~INET_ECN_MASK; | 109 | dscp &= ~INET_ECN_MASK; |
110 | ipv6_change_dsfield(inner, INET_ECN_MASK, dscp); | 110 | ipv6_change_dsfield(inner, INET_ECN_MASK, dscp); |
111 | } | 111 | } |
112 | 112 | ||
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 954def408975..7374251b9787 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h | |||
@@ -1,8 +1,20 @@ | |||
1 | #ifndef __NET_FRAG_H__ | 1 | #ifndef __NET_FRAG_H__ |
2 | #define __NET_FRAG_H__ | 2 | #define __NET_FRAG_H__ |
3 | 3 | ||
4 | struct netns_frags { | ||
5 | int nqueues; | ||
6 | atomic_t mem; | ||
7 | struct list_head lru_list; | ||
8 | |||
9 | /* sysctls */ | ||
10 | int timeout; | ||
11 | int high_thresh; | ||
12 | int low_thresh; | ||
13 | }; | ||
14 | |||
4 | struct inet_frag_queue { | 15 | struct inet_frag_queue { |
5 | struct hlist_node list; | 16 | struct hlist_node list; |
17 | struct netns_frags *net; | ||
6 | struct list_head lru_list; /* lru list member */ | 18 | struct list_head lru_list; /* lru list member */ |
7 | spinlock_t lock; | 19 | spinlock_t lock; |
8 | atomic_t refcnt; | 20 | atomic_t refcnt; |
@@ -20,23 +32,13 @@ struct inet_frag_queue { | |||
20 | 32 | ||
21 | #define INETFRAGS_HASHSZ 64 | 33 | #define INETFRAGS_HASHSZ 64 |
22 | 34 | ||
23 | struct inet_frags_ctl { | ||
24 | int high_thresh; | ||
25 | int low_thresh; | ||
26 | int timeout; | ||
27 | int secret_interval; | ||
28 | }; | ||
29 | |||
30 | struct inet_frags { | 35 | struct inet_frags { |
31 | struct list_head lru_list; | ||
32 | struct hlist_head hash[INETFRAGS_HASHSZ]; | 36 | struct hlist_head hash[INETFRAGS_HASHSZ]; |
33 | rwlock_t lock; | 37 | rwlock_t lock; |
34 | u32 rnd; | 38 | u32 rnd; |
35 | int nqueues; | ||
36 | int qsize; | 39 | int qsize; |
37 | atomic_t mem; | 40 | int secret_interval; |
38 | struct timer_list secret_timer; | 41 | struct timer_list secret_timer; |
39 | struct inet_frags_ctl *ctl; | ||
40 | 42 | ||
41 | unsigned int (*hashfn)(struct inet_frag_queue *); | 43 | unsigned int (*hashfn)(struct inet_frag_queue *); |
42 | void (*constructor)(struct inet_frag_queue *q, | 44 | void (*constructor)(struct inet_frag_queue *q, |
@@ -51,12 +53,15 @@ struct inet_frags { | |||
51 | void inet_frags_init(struct inet_frags *); | 53 | void inet_frags_init(struct inet_frags *); |
52 | void inet_frags_fini(struct inet_frags *); | 54 | void inet_frags_fini(struct inet_frags *); |
53 | 55 | ||
56 | void inet_frags_init_net(struct netns_frags *nf); | ||
57 | void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f); | ||
58 | |||
54 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); | 59 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); |
55 | void inet_frag_destroy(struct inet_frag_queue *q, | 60 | void inet_frag_destroy(struct inet_frag_queue *q, |
56 | struct inet_frags *f, int *work); | 61 | struct inet_frags *f, int *work); |
57 | int inet_frag_evictor(struct inet_frags *f); | 62 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f); |
58 | struct inet_frag_queue *inet_frag_find(struct inet_frags *f, void *key, | 63 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, |
59 | unsigned int hash); | 64 | struct inet_frags *f, void *key, unsigned int hash); |
60 | 65 | ||
61 | static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f) | 66 | static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f) |
62 | { | 67 | { |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 4427dcd1e53a..c23c4ed30724 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/wait.h> | 25 | #include <linux/wait.h> |
26 | #include <linux/vmalloc.h> | ||
26 | 27 | ||
27 | #include <net/inet_connection_sock.h> | 28 | #include <net/inet_connection_sock.h> |
28 | #include <net/inet_sock.h> | 29 | #include <net/inet_sock.h> |
@@ -37,7 +38,6 @@ | |||
37 | * I'll experiment with dynamic table growth later. | 38 | * I'll experiment with dynamic table growth later. |
38 | */ | 39 | */ |
39 | struct inet_ehash_bucket { | 40 | struct inet_ehash_bucket { |
40 | rwlock_t lock; | ||
41 | struct hlist_head chain; | 41 | struct hlist_head chain; |
42 | struct hlist_head twchain; | 42 | struct hlist_head twchain; |
43 | }; | 43 | }; |
@@ -74,6 +74,7 @@ struct inet_ehash_bucket { | |||
74 | * ports are created in O(1) time? I thought so. ;-) -DaveM | 74 | * ports are created in O(1) time? I thought so. ;-) -DaveM |
75 | */ | 75 | */ |
76 | struct inet_bind_bucket { | 76 | struct inet_bind_bucket { |
77 | struct net *ib_net; | ||
77 | unsigned short port; | 78 | unsigned short port; |
78 | signed short fastreuse; | 79 | signed short fastreuse; |
79 | struct hlist_node node; | 80 | struct hlist_node node; |
@@ -100,6 +101,9 @@ struct inet_hashinfo { | |||
100 | * TIME_WAIT sockets use a separate chain (twchain). | 101 | * TIME_WAIT sockets use a separate chain (twchain). |
101 | */ | 102 | */ |
102 | struct inet_ehash_bucket *ehash; | 103 | struct inet_ehash_bucket *ehash; |
104 | rwlock_t *ehash_locks; | ||
105 | unsigned int ehash_size; | ||
106 | unsigned int ehash_locks_mask; | ||
103 | 107 | ||
104 | /* Ok, let's try this, I give up, we do need a local binding | 108 | /* Ok, let's try this, I give up, we do need a local binding |
105 | * TCP hash as well as the others for fast bind/connect. | 109 | * TCP hash as well as the others for fast bind/connect. |
@@ -107,7 +111,7 @@ struct inet_hashinfo { | |||
107 | struct inet_bind_hashbucket *bhash; | 111 | struct inet_bind_hashbucket *bhash; |
108 | 112 | ||
109 | unsigned int bhash_size; | 113 | unsigned int bhash_size; |
110 | unsigned int ehash_size; | 114 | /* Note : 4 bytes padding on 64 bit arches */ |
111 | 115 | ||
112 | /* All sockets in TCP_LISTEN state will be in here. This is the only | 116 | /* All sockets in TCP_LISTEN state will be in here. This is the only |
113 | * table where wildcard'd TCP sockets can exist. Hash function here | 117 | * table where wildcard'd TCP sockets can exist. Hash function here |
@@ -134,8 +138,64 @@ static inline struct inet_ehash_bucket *inet_ehash_bucket( | |||
134 | return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)]; | 138 | return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)]; |
135 | } | 139 | } |
136 | 140 | ||
141 | static inline rwlock_t *inet_ehash_lockp( | ||
142 | struct inet_hashinfo *hashinfo, | ||
143 | unsigned int hash) | ||
144 | { | ||
145 | return &hashinfo->ehash_locks[hash & hashinfo->ehash_locks_mask]; | ||
146 | } | ||
147 | |||
148 | static inline int inet_ehash_locks_alloc(struct inet_hashinfo *hashinfo) | ||
149 | { | ||
150 | unsigned int i, size = 256; | ||
151 | #if defined(CONFIG_PROVE_LOCKING) | ||
152 | unsigned int nr_pcpus = 2; | ||
153 | #else | ||
154 | unsigned int nr_pcpus = num_possible_cpus(); | ||
155 | #endif | ||
156 | if (nr_pcpus >= 4) | ||
157 | size = 512; | ||
158 | if (nr_pcpus >= 8) | ||
159 | size = 1024; | ||
160 | if (nr_pcpus >= 16) | ||
161 | size = 2048; | ||
162 | if (nr_pcpus >= 32) | ||
163 | size = 4096; | ||
164 | if (sizeof(rwlock_t) != 0) { | ||
165 | #ifdef CONFIG_NUMA | ||
166 | if (size * sizeof(rwlock_t) > PAGE_SIZE) | ||
167 | hashinfo->ehash_locks = vmalloc(size * sizeof(rwlock_t)); | ||
168 | else | ||
169 | #endif | ||
170 | hashinfo->ehash_locks = kmalloc(size * sizeof(rwlock_t), | ||
171 | GFP_KERNEL); | ||
172 | if (!hashinfo->ehash_locks) | ||
173 | return ENOMEM; | ||
174 | for (i = 0; i < size; i++) | ||
175 | rwlock_init(&hashinfo->ehash_locks[i]); | ||
176 | } | ||
177 | hashinfo->ehash_locks_mask = size - 1; | ||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static inline void inet_ehash_locks_free(struct inet_hashinfo *hashinfo) | ||
182 | { | ||
183 | if (hashinfo->ehash_locks) { | ||
184 | #ifdef CONFIG_NUMA | ||
185 | unsigned int size = (hashinfo->ehash_locks_mask + 1) * | ||
186 | sizeof(rwlock_t); | ||
187 | if (size > PAGE_SIZE) | ||
188 | vfree(hashinfo->ehash_locks); | ||
189 | else | ||
190 | #endif | ||
191 | kfree(hashinfo->ehash_locks); | ||
192 | hashinfo->ehash_locks = NULL; | ||
193 | } | ||
194 | } | ||
195 | |||
137 | extern struct inet_bind_bucket * | 196 | extern struct inet_bind_bucket * |
138 | inet_bind_bucket_create(struct kmem_cache *cachep, | 197 | inet_bind_bucket_create(struct kmem_cache *cachep, |
198 | struct net *net, | ||
139 | struct inet_bind_hashbucket *head, | 199 | struct inet_bind_hashbucket *head, |
140 | const unsigned short snum); | 200 | const unsigned short snum); |
141 | extern void inet_bind_bucket_destroy(struct kmem_cache *cachep, | 201 | extern void inet_bind_bucket_destroy(struct kmem_cache *cachep, |
@@ -206,37 +266,14 @@ static inline void inet_listen_unlock(struct inet_hashinfo *hashinfo) | |||
206 | wake_up(&hashinfo->lhash_wait); | 266 | wake_up(&hashinfo->lhash_wait); |
207 | } | 267 | } |
208 | 268 | ||
209 | static inline void __inet_hash(struct inet_hashinfo *hashinfo, | 269 | extern void __inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk); |
210 | struct sock *sk, const int listen_possible) | 270 | extern void __inet_hash_nolisten(struct inet_hashinfo *hinfo, struct sock *sk); |
211 | { | ||
212 | struct hlist_head *list; | ||
213 | rwlock_t *lock; | ||
214 | |||
215 | BUG_TRAP(sk_unhashed(sk)); | ||
216 | if (listen_possible && sk->sk_state == TCP_LISTEN) { | ||
217 | list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; | ||
218 | lock = &hashinfo->lhash_lock; | ||
219 | inet_listen_wlock(hashinfo); | ||
220 | } else { | ||
221 | struct inet_ehash_bucket *head; | ||
222 | sk->sk_hash = inet_sk_ehashfn(sk); | ||
223 | head = inet_ehash_bucket(hashinfo, sk->sk_hash); | ||
224 | list = &head->chain; | ||
225 | lock = &head->lock; | ||
226 | write_lock(lock); | ||
227 | } | ||
228 | __sk_add_node(sk, list); | ||
229 | sock_prot_inc_use(sk->sk_prot); | ||
230 | write_unlock(lock); | ||
231 | if (listen_possible && sk->sk_state == TCP_LISTEN) | ||
232 | wake_up(&hashinfo->lhash_wait); | ||
233 | } | ||
234 | 271 | ||
235 | static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk) | 272 | static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk) |
236 | { | 273 | { |
237 | if (sk->sk_state != TCP_CLOSE) { | 274 | if (sk->sk_state != TCP_CLOSE) { |
238 | local_bh_disable(); | 275 | local_bh_disable(); |
239 | __inet_hash(hashinfo, sk, 1); | 276 | __inet_hash(hashinfo, sk); |
240 | local_bh_enable(); | 277 | local_bh_enable(); |
241 | } | 278 | } |
242 | } | 279 | } |
@@ -253,27 +290,29 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk) | |||
253 | inet_listen_wlock(hashinfo); | 290 | inet_listen_wlock(hashinfo); |
254 | lock = &hashinfo->lhash_lock; | 291 | lock = &hashinfo->lhash_lock; |
255 | } else { | 292 | } else { |
256 | lock = &inet_ehash_bucket(hashinfo, sk->sk_hash)->lock; | 293 | lock = inet_ehash_lockp(hashinfo, sk->sk_hash); |
257 | write_lock_bh(lock); | 294 | write_lock_bh(lock); |
258 | } | 295 | } |
259 | 296 | ||
260 | if (__sk_del_node_init(sk)) | 297 | if (__sk_del_node_init(sk)) |
261 | sock_prot_dec_use(sk->sk_prot); | 298 | sock_prot_inuse_add(sk->sk_prot, -1); |
262 | write_unlock_bh(lock); | 299 | write_unlock_bh(lock); |
263 | out: | 300 | out: |
264 | if (sk->sk_state == TCP_LISTEN) | 301 | if (sk->sk_state == TCP_LISTEN) |
265 | wake_up(&hashinfo->lhash_wait); | 302 | wake_up(&hashinfo->lhash_wait); |
266 | } | 303 | } |
267 | 304 | ||
268 | extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo, | 305 | extern struct sock *__inet_lookup_listener(struct net *net, |
306 | struct inet_hashinfo *hashinfo, | ||
269 | const __be32 daddr, | 307 | const __be32 daddr, |
270 | const unsigned short hnum, | 308 | const unsigned short hnum, |
271 | const int dif); | 309 | const int dif); |
272 | 310 | ||
273 | static inline struct sock *inet_lookup_listener(struct inet_hashinfo *hashinfo, | 311 | static inline struct sock *inet_lookup_listener(struct net *net, |
274 | __be32 daddr, __be16 dport, int dif) | 312 | struct inet_hashinfo *hashinfo, |
313 | __be32 daddr, __be16 dport, int dif) | ||
275 | { | 314 | { |
276 | return __inet_lookup_listener(hashinfo, daddr, ntohs(dport), dif); | 315 | return __inet_lookup_listener(net, hashinfo, daddr, ntohs(dport), dif); |
277 | } | 316 | } |
278 | 317 | ||
279 | /* Socket demux engine toys. */ | 318 | /* Socket demux engine toys. */ |
@@ -307,26 +346,26 @@ typedef __u64 __bitwise __addrpair; | |||
307 | (((__force __u64)(__be32)(__daddr)) << 32) | \ | 346 | (((__force __u64)(__be32)(__daddr)) << 32) | \ |
308 | ((__force __u64)(__be32)(__saddr))); | 347 | ((__force __u64)(__be32)(__saddr))); |
309 | #endif /* __BIG_ENDIAN */ | 348 | #endif /* __BIG_ENDIAN */ |
310 | #define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ | 349 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
311 | (((__sk)->sk_hash == (__hash)) && \ | 350 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
312 | ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ | 351 | ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ |
313 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 352 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
314 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 353 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
315 | #define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ | 354 | #define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
316 | (((__sk)->sk_hash == (__hash)) && \ | 355 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
317 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ | 356 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ |
318 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 357 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
319 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 358 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
320 | #else /* 32-bit arch */ | 359 | #else /* 32-bit arch */ |
321 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) | 360 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) |
322 | #define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ | 361 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ |
323 | (((__sk)->sk_hash == (__hash)) && \ | 362 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
324 | (inet_sk(__sk)->daddr == (__saddr)) && \ | 363 | (inet_sk(__sk)->daddr == (__saddr)) && \ |
325 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ | 364 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ |
326 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 365 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
327 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 366 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
328 | #define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ | 367 | #define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ |
329 | (((__sk)->sk_hash == (__hash)) && \ | 368 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
330 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | 369 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ |
331 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ | 370 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ |
332 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 371 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
@@ -339,65 +378,36 @@ typedef __u64 __bitwise __addrpair; | |||
339 | * | 378 | * |
340 | * Local BH must be disabled here. | 379 | * Local BH must be disabled here. |
341 | */ | 380 | */ |
342 | static inline struct sock * | 381 | extern struct sock * __inet_lookup_established(struct net *net, |
343 | __inet_lookup_established(struct inet_hashinfo *hashinfo, | 382 | struct inet_hashinfo *hashinfo, |
344 | const __be32 saddr, const __be16 sport, | 383 | const __be32 saddr, const __be16 sport, |
345 | const __be32 daddr, const u16 hnum, | 384 | const __be32 daddr, const u16 hnum, const int dif); |
346 | const int dif) | ||
347 | { | ||
348 | INET_ADDR_COOKIE(acookie, saddr, daddr) | ||
349 | const __portpair ports = INET_COMBINED_PORTS(sport, hnum); | ||
350 | struct sock *sk; | ||
351 | const struct hlist_node *node; | ||
352 | /* Optimize here for direct hit, only listening connections can | ||
353 | * have wildcards anyways. | ||
354 | */ | ||
355 | unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport); | ||
356 | struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); | ||
357 | |||
358 | prefetch(head->chain.first); | ||
359 | read_lock(&head->lock); | ||
360 | sk_for_each(sk, node, &head->chain) { | ||
361 | if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) | ||
362 | goto hit; /* You sunk my battleship! */ | ||
363 | } | ||
364 | |||
365 | /* Must check for a TIME_WAIT'er before going to listener hash. */ | ||
366 | sk_for_each(sk, node, &head->twchain) { | ||
367 | if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) | ||
368 | goto hit; | ||
369 | } | ||
370 | sk = NULL; | ||
371 | out: | ||
372 | read_unlock(&head->lock); | ||
373 | return sk; | ||
374 | hit: | ||
375 | sock_hold(sk); | ||
376 | goto out; | ||
377 | } | ||
378 | 385 | ||
379 | static inline struct sock * | 386 | static inline struct sock * |
380 | inet_lookup_established(struct inet_hashinfo *hashinfo, | 387 | inet_lookup_established(struct net *net, struct inet_hashinfo *hashinfo, |
381 | const __be32 saddr, const __be16 sport, | 388 | const __be32 saddr, const __be16 sport, |
382 | const __be32 daddr, const __be16 dport, | 389 | const __be32 daddr, const __be16 dport, |
383 | const int dif) | 390 | const int dif) |
384 | { | 391 | { |
385 | return __inet_lookup_established(hashinfo, saddr, sport, daddr, | 392 | return __inet_lookup_established(net, hashinfo, saddr, sport, daddr, |
386 | ntohs(dport), dif); | 393 | ntohs(dport), dif); |
387 | } | 394 | } |
388 | 395 | ||
389 | static inline struct sock *__inet_lookup(struct inet_hashinfo *hashinfo, | 396 | static inline struct sock *__inet_lookup(struct net *net, |
397 | struct inet_hashinfo *hashinfo, | ||
390 | const __be32 saddr, const __be16 sport, | 398 | const __be32 saddr, const __be16 sport, |
391 | const __be32 daddr, const __be16 dport, | 399 | const __be32 daddr, const __be16 dport, |
392 | const int dif) | 400 | const int dif) |
393 | { | 401 | { |
394 | u16 hnum = ntohs(dport); | 402 | u16 hnum = ntohs(dport); |
395 | struct sock *sk = __inet_lookup_established(hashinfo, saddr, sport, daddr, | 403 | struct sock *sk = __inet_lookup_established(net, hashinfo, |
396 | hnum, dif); | 404 | saddr, sport, daddr, hnum, dif); |
397 | return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif); | 405 | |
406 | return sk ? : __inet_lookup_listener(net, hashinfo, daddr, hnum, dif); | ||
398 | } | 407 | } |
399 | 408 | ||
400 | static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, | 409 | static inline struct sock *inet_lookup(struct net *net, |
410 | struct inet_hashinfo *hashinfo, | ||
401 | const __be32 saddr, const __be16 sport, | 411 | const __be32 saddr, const __be16 sport, |
402 | const __be32 daddr, const __be16 dport, | 412 | const __be32 daddr, const __be16 dport, |
403 | const int dif) | 413 | const int dif) |
@@ -405,12 +415,17 @@ static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, | |||
405 | struct sock *sk; | 415 | struct sock *sk; |
406 | 416 | ||
407 | local_bh_disable(); | 417 | local_bh_disable(); |
408 | sk = __inet_lookup(hashinfo, saddr, sport, daddr, dport, dif); | 418 | sk = __inet_lookup(net, hashinfo, saddr, sport, daddr, dport, dif); |
409 | local_bh_enable(); | 419 | local_bh_enable(); |
410 | 420 | ||
411 | return sk; | 421 | return sk; |
412 | } | 422 | } |
413 | 423 | ||
424 | extern int __inet_hash_connect(struct inet_timewait_death_row *death_row, | ||
425 | struct sock *sk, | ||
426 | int (*check_established)(struct inet_timewait_death_row *, | ||
427 | struct sock *, __u16, struct inet_timewait_sock **), | ||
428 | void (*hash)(struct inet_hashinfo *, struct sock *)); | ||
414 | extern int inet_hash_connect(struct inet_timewait_death_row *death_row, | 429 | extern int inet_hash_connect(struct inet_timewait_death_row *death_row, |
415 | struct sock *sk); | 430 | struct sock *sk); |
416 | #endif /* _INET_HASHTABLES_H */ | 431 | #endif /* _INET_HASHTABLES_H */ |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index abaff0597270..67e925065aae 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -193,19 +193,7 @@ static inline __be32 inet_rcv_saddr(const struct sock *sk) | |||
193 | inet_sk(sk)->rcv_saddr : inet_twsk(sk)->tw_rcv_saddr; | 193 | inet_sk(sk)->rcv_saddr : inet_twsk(sk)->tw_rcv_saddr; |
194 | } | 194 | } |
195 | 195 | ||
196 | static inline void inet_twsk_put(struct inet_timewait_sock *tw) | 196 | extern void inet_twsk_put(struct inet_timewait_sock *tw); |
197 | { | ||
198 | if (atomic_dec_and_test(&tw->tw_refcnt)) { | ||
199 | struct module *owner = tw->tw_prot->owner; | ||
200 | twsk_destructor((struct sock *)tw); | ||
201 | #ifdef SOCK_REFCNT_DEBUG | ||
202 | printk(KERN_DEBUG "%s timewait_sock %p released\n", | ||
203 | tw->tw_prot->name, tw); | ||
204 | #endif | ||
205 | kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw); | ||
206 | module_put(owner); | ||
207 | } | ||
208 | } | ||
209 | 197 | ||
210 | extern struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, | 198 | extern struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, |
211 | const int state); | 199 | const int state); |
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index aa10a8178e70..ad8404b56113 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h | |||
@@ -22,7 +22,7 @@ struct inet_peer | |||
22 | __be32 v4daddr; /* peer's address */ | 22 | __be32 v4daddr; /* peer's address */ |
23 | __u16 avl_height; | 23 | __u16 avl_height; |
24 | __u16 ip_id_count; /* IP ID for the next packet */ | 24 | __u16 ip_id_count; /* IP ID for the next packet */ |
25 | struct inet_peer *unused_next, **unused_prevp; | 25 | struct list_head unused; |
26 | __u32 dtime; /* the time of last use of not | 26 | __u32 dtime; /* the time of last use of not |
27 | * referenced entries */ | 27 | * referenced entries */ |
28 | atomic_t refcnt; | 28 | atomic_t refcnt; |
diff --git a/include/net/ip.h b/include/net/ip.h index 840dd91b513b..9f50d4f1f157 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -82,8 +82,6 @@ struct packet_type; | |||
82 | struct rtable; | 82 | struct rtable; |
83 | struct sockaddr; | 83 | struct sockaddr; |
84 | 84 | ||
85 | extern void ip_mc_dropsocket(struct sock *); | ||
86 | extern void ip_mc_dropdevice(struct net_device *dev); | ||
87 | extern int igmp_mc_proc_init(void); | 85 | extern int igmp_mc_proc_init(void); |
88 | 86 | ||
89 | /* | 87 | /* |
@@ -102,6 +100,8 @@ extern int ip_mc_output(struct sk_buff *skb); | |||
102 | extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); | 100 | extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); |
103 | extern int ip_do_nat(struct sk_buff *skb); | 101 | extern int ip_do_nat(struct sk_buff *skb); |
104 | extern void ip_send_check(struct iphdr *ip); | 102 | extern void ip_send_check(struct iphdr *ip); |
103 | extern int __ip_local_out(struct sk_buff *skb); | ||
104 | extern int ip_local_out(struct sk_buff *skb); | ||
105 | extern int ip_queue_xmit(struct sk_buff *skb, int ipfragok); | 105 | extern int ip_queue_xmit(struct sk_buff *skb, int ipfragok); |
106 | extern void ip_init(void); | 106 | extern void ip_init(void); |
107 | extern int ip_append_data(struct sock *sk, | 107 | extern int ip_append_data(struct sock *sk, |
@@ -169,7 +169,7 @@ DECLARE_SNMP_STAT(struct linux_mib, net_statistics); | |||
169 | #define NET_ADD_STATS_USER(field, adnd) SNMP_ADD_STATS_USER(net_statistics, field, adnd) | 169 | #define NET_ADD_STATS_USER(field, adnd) SNMP_ADD_STATS_USER(net_statistics, field, adnd) |
170 | 170 | ||
171 | extern unsigned long snmp_fold_field(void *mib[], int offt); | 171 | extern unsigned long snmp_fold_field(void *mib[], int offt); |
172 | extern int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign); | 172 | extern int snmp_mib_init(void *ptr[2], size_t mibsize); |
173 | extern void snmp_mib_free(void *ptr[2]); | 173 | extern void snmp_mib_free(void *ptr[2]); |
174 | 174 | ||
175 | extern void inet_get_local_port_range(int *low, int *high); | 175 | extern void inet_get_local_port_range(int *low, int *high); |
@@ -177,10 +177,7 @@ extern void inet_get_local_port_range(int *low, int *high); | |||
177 | extern int sysctl_ip_default_ttl; | 177 | extern int sysctl_ip_default_ttl; |
178 | extern int sysctl_ip_nonlocal_bind; | 178 | extern int sysctl_ip_nonlocal_bind; |
179 | 179 | ||
180 | /* From ip_fragment.c */ | 180 | extern struct ctl_path net_ipv4_ctl_path[]; |
181 | struct inet_frags_ctl; | ||
182 | extern struct inet_frags_ctl ip4_frags_ctl; | ||
183 | extern int sysctl_ipfrag_max_dist; | ||
184 | 181 | ||
185 | /* From inetpeer.c */ | 182 | /* From inetpeer.c */ |
186 | extern int inet_peer_threshold; | 183 | extern int inet_peer_threshold; |
@@ -266,20 +263,22 @@ static inline void ip_eth_mc_map(__be32 naddr, char *buf) | |||
266 | * Leave P_Key as 0 to be filled in by driver. | 263 | * Leave P_Key as 0 to be filled in by driver. |
267 | */ | 264 | */ |
268 | 265 | ||
269 | static inline void ip_ib_mc_map(__be32 naddr, char *buf) | 266 | static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf) |
270 | { | 267 | { |
271 | __u32 addr; | 268 | __u32 addr; |
269 | unsigned char scope = broadcast[5] & 0xF; | ||
270 | |||
272 | buf[0] = 0; /* Reserved */ | 271 | buf[0] = 0; /* Reserved */ |
273 | buf[1] = 0xff; /* Multicast QPN */ | 272 | buf[1] = 0xff; /* Multicast QPN */ |
274 | buf[2] = 0xff; | 273 | buf[2] = 0xff; |
275 | buf[3] = 0xff; | 274 | buf[3] = 0xff; |
276 | addr = ntohl(naddr); | 275 | addr = ntohl(naddr); |
277 | buf[4] = 0xff; | 276 | buf[4] = 0xff; |
278 | buf[5] = 0x12; /* link local scope */ | 277 | buf[5] = 0x10 | scope; /* scope from broadcast address */ |
279 | buf[6] = 0x40; /* IPv4 signature */ | 278 | buf[6] = 0x40; /* IPv4 signature */ |
280 | buf[7] = 0x1b; | 279 | buf[7] = 0x1b; |
281 | buf[8] = 0; /* P_Key */ | 280 | buf[8] = broadcast[8]; /* P_Key */ |
282 | buf[9] = 0; | 281 | buf[9] = broadcast[9]; |
283 | buf[10] = 0; | 282 | buf[10] = 0; |
284 | buf[11] = 0; | 283 | buf[11] = 0; |
285 | buf[12] = 0; | 284 | buf[12] = 0; |
@@ -317,7 +316,7 @@ static __inline__ void inet_reset_saddr(struct sock *sk) | |||
317 | extern int ip_call_ra_chain(struct sk_buff *skb); | 316 | extern int ip_call_ra_chain(struct sk_buff *skb); |
318 | 317 | ||
319 | /* | 318 | /* |
320 | * Functions provided by ip_fragment.o | 319 | * Functions provided by ip_fragment.c |
321 | */ | 320 | */ |
322 | 321 | ||
323 | enum ip_defrag_users | 322 | enum ip_defrag_users |
@@ -332,15 +331,14 @@ enum ip_defrag_users | |||
332 | }; | 331 | }; |
333 | 332 | ||
334 | int ip_defrag(struct sk_buff *skb, u32 user); | 333 | int ip_defrag(struct sk_buff *skb, u32 user); |
335 | int ip_frag_mem(void); | 334 | int ip_frag_mem(struct net *net); |
336 | int ip_frag_nqueues(void); | 335 | int ip_frag_nqueues(struct net *net); |
337 | 336 | ||
338 | /* | 337 | /* |
339 | * Functions provided by ip_forward.c | 338 | * Functions provided by ip_forward.c |
340 | */ | 339 | */ |
341 | 340 | ||
342 | extern int ip_forward(struct sk_buff *skb); | 341 | extern int ip_forward(struct sk_buff *skb); |
343 | extern int ip_net_unreachable(struct sk_buff *skb); | ||
344 | 342 | ||
345 | /* | 343 | /* |
346 | * Functions provided by ip_options.c | 344 | * Functions provided by ip_options.c |
@@ -391,6 +389,4 @@ int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen, | |||
391 | extern int ip_misc_proc_init(void); | 389 | extern int ip_misc_proc_init(void); |
392 | #endif | 390 | #endif |
393 | 391 | ||
394 | extern struct ctl_table ipv4_table[]; | ||
395 | |||
396 | #endif /* _IP_H */ | 392 | #endif /* _IP_H */ |
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index 857821360bb6..d8d85b13364d 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h | |||
@@ -99,16 +99,21 @@ struct rt6_info | |||
99 | u32 rt6i_flags; | 99 | u32 rt6i_flags; |
100 | u32 rt6i_metric; | 100 | u32 rt6i_metric; |
101 | atomic_t rt6i_ref; | 101 | atomic_t rt6i_ref; |
102 | struct fib6_table *rt6i_table; | ||
103 | 102 | ||
104 | struct rt6key rt6i_dst; | 103 | /* more non-fragment space at head required */ |
105 | struct rt6key rt6i_src; | 104 | unsigned short rt6i_nfheader_len; |
106 | 105 | ||
107 | u8 rt6i_protocol; | 106 | u8 rt6i_protocol; |
108 | 107 | ||
108 | struct fib6_table *rt6i_table; | ||
109 | |||
110 | struct rt6key rt6i_dst; | ||
111 | |||
109 | #ifdef CONFIG_XFRM | 112 | #ifdef CONFIG_XFRM |
110 | u32 rt6i_flow_cache_genid; | 113 | u32 rt6i_flow_cache_genid; |
111 | #endif | 114 | #endif |
115 | |||
116 | struct rt6key rt6i_src; | ||
112 | }; | 117 | }; |
113 | 118 | ||
114 | static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) | 119 | static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) |
@@ -219,10 +224,20 @@ extern void fib6_run_gc(unsigned long dummy); | |||
219 | 224 | ||
220 | extern void fib6_gc_cleanup(void); | 225 | extern void fib6_gc_cleanup(void); |
221 | 226 | ||
222 | extern void fib6_init(void); | 227 | extern int fib6_init(void); |
223 | 228 | ||
224 | extern void fib6_rules_init(void); | 229 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
230 | extern int fib6_rules_init(void); | ||
225 | extern void fib6_rules_cleanup(void); | 231 | extern void fib6_rules_cleanup(void); |
226 | 232 | #else | |
233 | static inline int fib6_rules_init(void) | ||
234 | { | ||
235 | return 0; | ||
236 | } | ||
237 | static inline void fib6_rules_cleanup(void) | ||
238 | { | ||
239 | return ; | ||
240 | } | ||
241 | #endif | ||
227 | #endif | 242 | #endif |
228 | #endif | 243 | #endif |
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 5456fdd6d047..faac0eee1ef3 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h | |||
@@ -43,14 +43,12 @@ extern struct rt6_info ip6_prohibit_entry; | |||
43 | extern struct rt6_info ip6_blk_hole_entry; | 43 | extern struct rt6_info ip6_blk_hole_entry; |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | extern int ip6_rt_gc_interval; | ||
47 | |||
48 | extern void ip6_route_input(struct sk_buff *skb); | 46 | extern void ip6_route_input(struct sk_buff *skb); |
49 | 47 | ||
50 | extern struct dst_entry * ip6_route_output(struct sock *sk, | 48 | extern struct dst_entry * ip6_route_output(struct sock *sk, |
51 | struct flowi *fl); | 49 | struct flowi *fl); |
52 | 50 | ||
53 | extern void ip6_route_init(void); | 51 | extern int ip6_route_init(void); |
54 | extern void ip6_route_cleanup(void); | 52 | extern void ip6_route_cleanup(void); |
55 | 53 | ||
56 | extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg); | 54 | extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg); |
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h index 29c9da707c7a..c17fa1fdc356 100644 --- a/include/net/ip6_tunnel.h +++ b/include/net/ip6_tunnel.h | |||
@@ -23,7 +23,7 @@ struct ip6_tnl { | |||
23 | struct net_device *dev; /* virtual device associated with tunnel */ | 23 | struct net_device *dev; /* virtual device associated with tunnel */ |
24 | struct net_device_stats stat; /* statistics for tunnel device */ | 24 | struct net_device_stats stat; /* statistics for tunnel device */ |
25 | int recursion; /* depth of hard_start_xmit recursion */ | 25 | int recursion; /* depth of hard_start_xmit recursion */ |
26 | struct ip6_tnl_parm parms; /* tunnel configuration paramters */ | 26 | struct ip6_tnl_parm parms; /* tunnel configuration parameters */ |
27 | struct flowi fl; /* flowi template for xmit */ | 27 | struct flowi fl; /* flowi template for xmit */ |
28 | struct dst_entry *dst_cache; /* cached dst */ | 28 | struct dst_entry *dst_cache; /* cached dst */ |
29 | u32 dst_cookie; | 29 | u32 dst_cookie; |
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 8cadc77c7df4..90d1175f63de 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
@@ -69,6 +69,7 @@ struct fib_nh { | |||
69 | struct fib_info { | 69 | struct fib_info { |
70 | struct hlist_node fib_hash; | 70 | struct hlist_node fib_hash; |
71 | struct hlist_node fib_lhash; | 71 | struct hlist_node fib_lhash; |
72 | struct net *fib_net; | ||
72 | int fib_treeref; | 73 | int fib_treeref; |
73 | atomic_t fib_clntref; | 74 | atomic_t fib_clntref; |
74 | int fib_dead; | 75 | int fib_dead; |
@@ -125,11 +126,15 @@ struct fib_result_nl { | |||
125 | #define FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel]) | 126 | #define FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel]) |
126 | #define FIB_RES_RESET(res) ((res).nh_sel = 0) | 127 | #define FIB_RES_RESET(res) ((res).nh_sel = 0) |
127 | 128 | ||
129 | #define FIB_TABLE_HASHSZ 2 | ||
130 | |||
128 | #else /* CONFIG_IP_ROUTE_MULTIPATH */ | 131 | #else /* CONFIG_IP_ROUTE_MULTIPATH */ |
129 | 132 | ||
130 | #define FIB_RES_NH(res) ((res).fi->fib_nh[0]) | 133 | #define FIB_RES_NH(res) ((res).fi->fib_nh[0]) |
131 | #define FIB_RES_RESET(res) | 134 | #define FIB_RES_RESET(res) |
132 | 135 | ||
136 | #define FIB_TABLE_HASHSZ 256 | ||
137 | |||
133 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ | 138 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ |
134 | 139 | ||
135 | #define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) | 140 | #define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) |
@@ -141,6 +146,7 @@ struct fib_table { | |||
141 | struct hlist_node tb_hlist; | 146 | struct hlist_node tb_hlist; |
142 | u32 tb_id; | 147 | u32 tb_id; |
143 | unsigned tb_stamp; | 148 | unsigned tb_stamp; |
149 | int tb_default; | ||
144 | int (*tb_lookup)(struct fib_table *tb, const struct flowi *flp, struct fib_result *res); | 150 | int (*tb_lookup)(struct fib_table *tb, const struct flowi *flp, struct fib_result *res); |
145 | int (*tb_insert)(struct fib_table *, struct fib_config *); | 151 | int (*tb_insert)(struct fib_table *, struct fib_config *); |
146 | int (*tb_delete)(struct fib_table *, struct fib_config *); | 152 | int (*tb_delete)(struct fib_table *, struct fib_config *); |
@@ -155,44 +161,51 @@ struct fib_table { | |||
155 | 161 | ||
156 | #ifndef CONFIG_IP_MULTIPLE_TABLES | 162 | #ifndef CONFIG_IP_MULTIPLE_TABLES |
157 | 163 | ||
158 | extern struct fib_table *ip_fib_local_table; | 164 | #define TABLE_LOCAL_INDEX 0 |
159 | extern struct fib_table *ip_fib_main_table; | 165 | #define TABLE_MAIN_INDEX 1 |
160 | 166 | ||
161 | static inline struct fib_table *fib_get_table(u32 id) | 167 | static inline struct fib_table *fib_get_table(struct net *net, u32 id) |
162 | { | 168 | { |
163 | if (id != RT_TABLE_LOCAL) | 169 | struct hlist_head *ptr; |
164 | return ip_fib_main_table; | ||
165 | return ip_fib_local_table; | ||
166 | } | ||
167 | 170 | ||
168 | static inline struct fib_table *fib_new_table(u32 id) | 171 | ptr = id == RT_TABLE_LOCAL ? |
169 | { | 172 | &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX] : |
170 | return fib_get_table(id); | 173 | &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX]; |
174 | return hlist_entry(ptr->first, struct fib_table, tb_hlist); | ||
171 | } | 175 | } |
172 | 176 | ||
173 | static inline int fib_lookup(const struct flowi *flp, struct fib_result *res) | 177 | static inline struct fib_table *fib_new_table(struct net *net, u32 id) |
174 | { | 178 | { |
175 | if (ip_fib_local_table->tb_lookup(ip_fib_local_table, flp, res) && | 179 | return fib_get_table(net, id); |
176 | ip_fib_main_table->tb_lookup(ip_fib_main_table, flp, res)) | ||
177 | return -ENETUNREACH; | ||
178 | return 0; | ||
179 | } | 180 | } |
180 | 181 | ||
181 | static inline void fib_select_default(const struct flowi *flp, struct fib_result *res) | 182 | static inline int fib_lookup(struct net *net, const struct flowi *flp, |
183 | struct fib_result *res) | ||
182 | { | 184 | { |
183 | if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) | 185 | struct fib_table *table; |
184 | ip_fib_main_table->tb_select_default(ip_fib_main_table, flp, res); | 186 | |
187 | table = fib_get_table(net, RT_TABLE_LOCAL); | ||
188 | if (!table->tb_lookup(table, flp, res)) | ||
189 | return 0; | ||
190 | |||
191 | table = fib_get_table(net, RT_TABLE_MAIN); | ||
192 | if (!table->tb_lookup(table, flp, res)) | ||
193 | return 0; | ||
194 | return -ENETUNREACH; | ||
185 | } | 195 | } |
186 | 196 | ||
187 | #else /* CONFIG_IP_MULTIPLE_TABLES */ | 197 | #else /* CONFIG_IP_MULTIPLE_TABLES */ |
188 | #define ip_fib_local_table fib_get_table(RT_TABLE_LOCAL) | 198 | extern int __net_init fib4_rules_init(struct net *net); |
189 | #define ip_fib_main_table fib_get_table(RT_TABLE_MAIN) | 199 | extern void __net_exit fib4_rules_exit(struct net *net); |
190 | 200 | ||
191 | extern int fib_lookup(struct flowi *flp, struct fib_result *res); | 201 | #ifdef CONFIG_NET_CLS_ROUTE |
202 | extern u32 fib_rules_tclass(struct fib_result *res); | ||
203 | #endif | ||
192 | 204 | ||
193 | extern struct fib_table *fib_new_table(u32 id); | 205 | extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); |
194 | extern struct fib_table *fib_get_table(u32 id); | 206 | |
195 | extern void fib_select_default(const struct flowi *flp, struct fib_result *res); | 207 | extern struct fib_table *fib_new_table(struct net *net, u32 id); |
208 | extern struct fib_table *fib_get_table(struct net *net, u32 id); | ||
196 | 209 | ||
197 | #endif /* CONFIG_IP_MULTIPLE_TABLES */ | 210 | #endif /* CONFIG_IP_MULTIPLE_TABLES */ |
198 | 211 | ||
@@ -201,27 +214,20 @@ extern const struct nla_policy rtm_ipv4_policy[]; | |||
201 | extern void ip_fib_init(void); | 214 | extern void ip_fib_init(void); |
202 | extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, | 215 | extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, |
203 | struct net_device *dev, __be32 *spec_dst, u32 *itag); | 216 | struct net_device *dev, __be32 *spec_dst, u32 *itag); |
204 | extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); | 217 | extern void fib_select_default(struct net *net, const struct flowi *flp, |
205 | 218 | struct fib_result *res); | |
206 | struct rtentry; | ||
207 | 219 | ||
208 | /* Exported by fib_semantics.c */ | 220 | /* Exported by fib_semantics.c */ |
209 | extern int ip_fib_check_default(__be32 gw, struct net_device *dev); | 221 | extern int ip_fib_check_default(__be32 gw, struct net_device *dev); |
210 | extern int fib_sync_down(__be32 local, struct net_device *dev, int force); | 222 | extern int fib_sync_down_dev(struct net_device *dev, int force); |
223 | extern int fib_sync_down_addr(struct net *net, __be32 local); | ||
211 | extern int fib_sync_up(struct net_device *dev); | 224 | extern int fib_sync_up(struct net_device *dev); |
212 | extern __be32 __fib_res_prefsrc(struct fib_result *res); | 225 | extern __be32 __fib_res_prefsrc(struct fib_result *res); |
226 | extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); | ||
213 | 227 | ||
214 | /* Exported by fib_hash.c */ | 228 | /* Exported by fib_{hash|trie}.c */ |
215 | extern struct fib_table *fib_hash_init(u32 id); | 229 | extern void fib_hash_init(void); |
216 | 230 | extern struct fib_table *fib_hash_table(u32 id); | |
217 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
218 | extern void __init fib4_rules_init(void); | ||
219 | |||
220 | #ifdef CONFIG_NET_CLS_ROUTE | ||
221 | extern u32 fib_rules_tclass(struct fib_result *res); | ||
222 | #endif | ||
223 | |||
224 | #endif | ||
225 | 231 | ||
226 | static inline void fib_combine_itag(u32 *itag, struct fib_result *res) | 232 | static inline void fib_combine_itag(u32 *itag, struct fib_result *res) |
227 | { | 233 | { |
@@ -258,8 +264,8 @@ static inline void fib_res_put(struct fib_result *res) | |||
258 | } | 264 | } |
259 | 265 | ||
260 | #ifdef CONFIG_PROC_FS | 266 | #ifdef CONFIG_PROC_FS |
261 | extern int fib_proc_init(void); | 267 | extern int __net_init fib_proc_init(struct net *net); |
262 | extern void fib_proc_exit(void); | 268 | extern void __net_exit fib_proc_exit(struct net *net); |
263 | #endif | 269 | #endif |
264 | 270 | ||
265 | #endif /* _NET_FIB_H */ | 271 | #endif /* _NET_FIB_H */ |
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 41870564df8e..56f3c94ae620 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -9,6 +9,8 @@ | |||
9 | #include <asm/types.h> /* For __uXX types */ | 9 | #include <asm/types.h> /* For __uXX types */ |
10 | #include <linux/types.h> /* For __beXX types in userland */ | 10 | #include <linux/types.h> /* For __beXX types in userland */ |
11 | 11 | ||
12 | #include <linux/sysctl.h> /* For ctl_path */ | ||
13 | |||
12 | #define IP_VS_VERSION_CODE 0x010201 | 14 | #define IP_VS_VERSION_CODE 0x010201 |
13 | #define NVERSION(version) \ | 15 | #define NVERSION(version) \ |
14 | (version >> 16) & 0xFF, \ | 16 | (version >> 16) & 0xFF, \ |
@@ -328,40 +330,6 @@ extern int ip_vs_get_debug_level(void); | |||
328 | #define FTPDATA __constant_htons(20) | 330 | #define FTPDATA __constant_htons(20) |
329 | 331 | ||
330 | /* | 332 | /* |
331 | * IPVS sysctl variables under the /proc/sys/net/ipv4/vs/ | ||
332 | */ | ||
333 | #define NET_IPV4_VS 21 | ||
334 | |||
335 | enum { | ||
336 | NET_IPV4_VS_DEBUG_LEVEL=1, | ||
337 | NET_IPV4_VS_AMEMTHRESH=2, | ||
338 | NET_IPV4_VS_AMDROPRATE=3, | ||
339 | NET_IPV4_VS_DROP_ENTRY=4, | ||
340 | NET_IPV4_VS_DROP_PACKET=5, | ||
341 | NET_IPV4_VS_SECURE_TCP=6, | ||
342 | NET_IPV4_VS_TO_ES=7, | ||
343 | NET_IPV4_VS_TO_SS=8, | ||
344 | NET_IPV4_VS_TO_SR=9, | ||
345 | NET_IPV4_VS_TO_FW=10, | ||
346 | NET_IPV4_VS_TO_TW=11, | ||
347 | NET_IPV4_VS_TO_CL=12, | ||
348 | NET_IPV4_VS_TO_CW=13, | ||
349 | NET_IPV4_VS_TO_LA=14, | ||
350 | NET_IPV4_VS_TO_LI=15, | ||
351 | NET_IPV4_VS_TO_SA=16, | ||
352 | NET_IPV4_VS_TO_UDP=17, | ||
353 | NET_IPV4_VS_TO_ICMP=18, | ||
354 | NET_IPV4_VS_LBLC_EXPIRE=19, | ||
355 | NET_IPV4_VS_LBLCR_EXPIRE=20, | ||
356 | NET_IPV4_VS_CACHE_BYPASS=22, | ||
357 | NET_IPV4_VS_EXPIRE_NODEST_CONN=23, | ||
358 | NET_IPV4_VS_SYNC_THRESHOLD=24, | ||
359 | NET_IPV4_VS_NAT_ICMP_SEND=25, | ||
360 | NET_IPV4_VS_EXPIRE_QUIESCENT_TEMPLATE=26, | ||
361 | NET_IPV4_VS_LAST | ||
362 | }; | ||
363 | |||
364 | /* | ||
365 | * TCP State Values | 333 | * TCP State Values |
366 | */ | 334 | */ |
367 | enum { | 335 | enum { |
@@ -520,6 +488,10 @@ struct ip_vs_conn { | |||
520 | spinlock_t lock; /* lock for state transition */ | 488 | spinlock_t lock; /* lock for state transition */ |
521 | volatile __u16 flags; /* status flags */ | 489 | volatile __u16 flags; /* status flags */ |
522 | volatile __u16 state; /* state info */ | 490 | volatile __u16 state; /* state info */ |
491 | volatile __u16 old_state; /* old state, to be used for | ||
492 | * state transition triggerd | ||
493 | * synchronization | ||
494 | */ | ||
523 | 495 | ||
524 | /* Control members */ | 496 | /* Control members */ |
525 | struct ip_vs_conn *control; /* Master control connection */ | 497 | struct ip_vs_conn *control; /* Master control connection */ |
@@ -706,7 +678,6 @@ extern const char *ip_vs_proto_name(unsigned proto); | |||
706 | extern void ip_vs_init_hash_table(struct list_head *table, int rows); | 678 | extern void ip_vs_init_hash_table(struct list_head *table, int rows); |
707 | #define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table(t, sizeof(t)/sizeof(t[0])) | 679 | #define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table(t, sizeof(t)/sizeof(t[0])) |
708 | 680 | ||
709 | #define IP_VS_APP_TYPE_UNSPEC 0 | ||
710 | #define IP_VS_APP_TYPE_FTP 1 | 681 | #define IP_VS_APP_TYPE_FTP 1 |
711 | 682 | ||
712 | /* | 683 | /* |
@@ -765,7 +736,6 @@ extern const char * ip_vs_state_name(__u16 proto, int state); | |||
765 | 736 | ||
766 | extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); | 737 | extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); |
767 | extern int ip_vs_check_template(struct ip_vs_conn *ct); | 738 | extern int ip_vs_check_template(struct ip_vs_conn *ct); |
768 | extern void ip_vs_secure_tcp_set(int on); | ||
769 | extern void ip_vs_random_dropentry(void); | 739 | extern void ip_vs_random_dropentry(void); |
770 | extern int ip_vs_conn_init(void); | 740 | extern int ip_vs_conn_init(void); |
771 | extern void ip_vs_conn_cleanup(void); | 741 | extern void ip_vs_conn_cleanup(void); |
@@ -886,6 +856,7 @@ extern int sysctl_ip_vs_expire_quiescent_template; | |||
886 | extern int sysctl_ip_vs_sync_threshold[2]; | 856 | extern int sysctl_ip_vs_sync_threshold[2]; |
887 | extern int sysctl_ip_vs_nat_icmp_send; | 857 | extern int sysctl_ip_vs_nat_icmp_send; |
888 | extern struct ip_vs_stats ip_vs_stats; | 858 | extern struct ip_vs_stats ip_vs_stats; |
859 | extern struct ctl_path net_vs_ctl_path[]; | ||
889 | 860 | ||
890 | extern struct ip_vs_service * | 861 | extern struct ip_vs_service * |
891 | ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport); | 862 | ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport); |
@@ -901,6 +872,10 @@ extern int ip_vs_use_count_inc(void); | |||
901 | extern void ip_vs_use_count_dec(void); | 872 | extern void ip_vs_use_count_dec(void); |
902 | extern int ip_vs_control_init(void); | 873 | extern int ip_vs_control_init(void); |
903 | extern void ip_vs_control_cleanup(void); | 874 | extern void ip_vs_control_cleanup(void); |
875 | extern struct ip_vs_dest * | ||
876 | ip_vs_find_dest(__be32 daddr, __be16 dport, | ||
877 | __be32 vaddr, __be16 vport, __u16 protocol); | ||
878 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | ||
904 | 879 | ||
905 | 880 | ||
906 | /* | 881 | /* |
diff --git a/include/net/ipip.h b/include/net/ipip.h index 7cdc914322f0..549e132bca9c 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __NET_IPIP_H 1 | 2 | #define __NET_IPIP_H 1 |
3 | 3 | ||
4 | #include <linux/if_tunnel.h> | 4 | #include <linux/if_tunnel.h> |
5 | #include <net/ip.h> | ||
5 | 6 | ||
6 | /* Keep error state on tunnel for 30 sec */ | 7 | /* Keep error state on tunnel for 30 sec */ |
7 | #define IPTUNNEL_ERR_TIMEO (30*HZ) | 8 | #define IPTUNNEL_ERR_TIMEO (30*HZ) |
@@ -30,11 +31,9 @@ struct ip_tunnel | |||
30 | int pkt_len = skb->len; \ | 31 | int pkt_len = skb->len; \ |
31 | \ | 32 | \ |
32 | skb->ip_summed = CHECKSUM_NONE; \ | 33 | skb->ip_summed = CHECKSUM_NONE; \ |
33 | iph->tot_len = htons(skb->len); \ | ||
34 | ip_select_ident(iph, &rt->u.dst, NULL); \ | 34 | ip_select_ident(iph, &rt->u.dst, NULL); \ |
35 | ip_send_check(iph); \ | ||
36 | \ | 35 | \ |
37 | err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);\ | 36 | err = ip_local_out(skb); \ |
38 | if (net_xmit_eval(err) == 0) { \ | 37 | if (net_xmit_eval(err) == 0) { \ |
39 | stats->tx_bytes += pkt_len; \ | 38 | stats->tx_bytes += pkt_len; \ |
40 | stats->tx_packets++; \ | 39 | stats->tx_packets++; \ |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index ae328b680ff2..fa80ea48639d 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -109,9 +109,10 @@ struct frag_hdr { | |||
109 | #include <net/sock.h> | 109 | #include <net/sock.h> |
110 | 110 | ||
111 | /* sysctls */ | 111 | /* sysctls */ |
112 | extern int sysctl_ipv6_bindv6only; | ||
113 | extern int sysctl_mld_max_msf; | 112 | extern int sysctl_mld_max_msf; |
114 | 113 | ||
114 | extern struct ctl_path net_ipv6_ctl_path[]; | ||
115 | |||
115 | #define _DEVINC(statname, modifier, idev, field) \ | 116 | #define _DEVINC(statname, modifier, idev, field) \ |
116 | ({ \ | 117 | ({ \ |
117 | struct inet6_dev *_idev = (idev); \ | 118 | struct inet6_dev *_idev = (idev); \ |
@@ -143,14 +144,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); | |||
143 | #define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field) | 144 | #define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field) |
144 | #define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field) | 145 | #define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field) |
145 | 146 | ||
146 | #define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \ | ||
147 | struct inet6_dev *_idev = idev; \ | ||
148 | __typeof__(offset) _offset = (offset); \ | ||
149 | if (likely(_idev != NULL)) \ | ||
150 | SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \ | ||
151 | SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \ | ||
152 | }) | ||
153 | |||
154 | #define ICMP6MSGOUT_INC_STATS(idev, field) \ | 147 | #define ICMP6MSGOUT_INC_STATS(idev, field) \ |
155 | _DEVINC(icmpv6msg, , idev, field +256) | 148 | _DEVINC(icmpv6msg, , idev, field +256) |
156 | #define ICMP6MSGOUT_INC_STATS_BH(idev, field) \ | 149 | #define ICMP6MSGOUT_INC_STATS_BH(idev, field) \ |
@@ -164,15 +157,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); | |||
164 | #define ICMP6MSGIN_INC_STATS_USER(idev, field) \ | 157 | #define ICMP6MSGIN_INC_STATS_USER(idev, field) \ |
165 | _DEVINC(icmpv6msg, _USER, idev, field) | 158 | _DEVINC(icmpv6msg, _USER, idev, field) |
166 | 159 | ||
167 | DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); | ||
168 | DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6); | ||
169 | #define UDP6_INC_STATS_BH(field, is_udplite) do { \ | ||
170 | if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \ | ||
171 | else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0) | ||
172 | #define UDP6_INC_STATS_USER(field, is_udplite) do { \ | ||
173 | if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \ | ||
174 | else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0) | ||
175 | |||
176 | struct ip6_ra_chain | 160 | struct ip6_ra_chain |
177 | { | 161 | { |
178 | struct ip6_ra_chain *next; | 162 | struct ip6_ra_chain *next; |
@@ -236,7 +220,7 @@ extern struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_spac | |||
236 | struct ipv6_txoptions * fopt); | 220 | struct ipv6_txoptions * fopt); |
237 | extern void fl6_free_socklist(struct sock *sk); | 221 | extern void fl6_free_socklist(struct sock *sk); |
238 | extern int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); | 222 | extern int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); |
239 | extern void ip6_flowlabel_init(void); | 223 | extern int ip6_flowlabel_init(void); |
240 | extern void ip6_flowlabel_cleanup(void); | 224 | extern void ip6_flowlabel_cleanup(void); |
241 | 225 | ||
242 | static inline void fl6_sock_release(struct ip6_flowlabel *fl) | 226 | static inline void fl6_sock_release(struct ip6_flowlabel *fl) |
@@ -261,8 +245,8 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, | |||
261 | 245 | ||
262 | extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); | 246 | extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); |
263 | 247 | ||
264 | int ip6_frag_nqueues(void); | 248 | int ip6_frag_nqueues(struct net *net); |
265 | int ip6_frag_mem(void); | 249 | int ip6_frag_mem(struct net *net); |
266 | 250 | ||
267 | #define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */ | 251 | #define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */ |
268 | 252 | ||
@@ -509,6 +493,9 @@ extern int ip6_forward(struct sk_buff *skb); | |||
509 | extern int ip6_input(struct sk_buff *skb); | 493 | extern int ip6_input(struct sk_buff *skb); |
510 | extern int ip6_mc_input(struct sk_buff *skb); | 494 | extern int ip6_mc_input(struct sk_buff *skb); |
511 | 495 | ||
496 | extern int __ip6_local_out(struct sk_buff *skb); | ||
497 | extern int ip6_local_out(struct sk_buff *skb); | ||
498 | |||
512 | /* | 499 | /* |
513 | * Extension header (options) processing | 500 | * Extension header (options) processing |
514 | */ | 501 | */ |
@@ -559,7 +546,7 @@ extern int compat_ipv6_getsockopt(struct sock *sk, | |||
559 | char __user *optval, | 546 | char __user *optval, |
560 | int __user *optlen); | 547 | int __user *optlen); |
561 | 548 | ||
562 | extern void ipv6_packet_init(void); | 549 | extern int ipv6_packet_init(void); |
563 | 550 | ||
564 | extern void ipv6_packet_cleanup(void); | 551 | extern void ipv6_packet_cleanup(void); |
565 | 552 | ||
@@ -585,9 +572,6 @@ extern int inet6_hash_connect(struct inet_timewait_death_row *death_row, | |||
585 | /* | 572 | /* |
586 | * reassembly.c | 573 | * reassembly.c |
587 | */ | 574 | */ |
588 | struct inet_frags_ctl; | ||
589 | extern struct inet_frags_ctl ip6_frags_ctl; | ||
590 | |||
591 | extern const struct proto_ops inet6_stream_ops; | 575 | extern const struct proto_ops inet6_stream_ops; |
592 | extern const struct proto_ops inet6_dgram_ops; | 576 | extern const struct proto_ops inet6_dgram_ops; |
593 | 577 | ||
@@ -602,6 +586,9 @@ extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf, | |||
602 | int __user *optlen); | 586 | int __user *optlen); |
603 | 587 | ||
604 | #ifdef CONFIG_PROC_FS | 588 | #ifdef CONFIG_PROC_FS |
589 | extern struct ctl_table *ipv6_icmp_sysctl_init(struct net *net); | ||
590 | extern struct ctl_table *ipv6_route_sysctl_init(struct net *net); | ||
591 | |||
605 | extern int ac6_proc_init(void); | 592 | extern int ac6_proc_init(void); |
606 | extern void ac6_proc_exit(void); | 593 | extern void ac6_proc_exit(void); |
607 | extern int raw6_proc_init(void); | 594 | extern int raw6_proc_init(void); |
@@ -631,10 +618,10 @@ static inline int snmp6_unregister_dev(struct inet6_dev *idev) | |||
631 | #endif | 618 | #endif |
632 | 619 | ||
633 | #ifdef CONFIG_SYSCTL | 620 | #ifdef CONFIG_SYSCTL |
634 | extern ctl_table ipv6_route_table[]; | 621 | extern ctl_table ipv6_route_table_template[]; |
635 | extern ctl_table ipv6_icmp_table[]; | 622 | extern ctl_table ipv6_icmp_table_template[]; |
636 | 623 | ||
637 | extern void ipv6_sysctl_register(void); | 624 | extern int ipv6_sysctl_register(void); |
638 | extern void ipv6_sysctl_unregister(void); | 625 | extern void ipv6_sysctl_unregister(void); |
639 | #endif | 626 | #endif |
640 | 627 | ||
diff --git a/include/net/irda/discovery.h b/include/net/irda/discovery.h index eb0f9de47294..e4efad1f9eff 100644 --- a/include/net/irda/discovery.h +++ b/include/net/irda/discovery.h | |||
@@ -80,7 +80,7 @@ typedef struct discovery_t { | |||
80 | irda_queue_t q; /* Must be first! */ | 80 | irda_queue_t q; /* Must be first! */ |
81 | 81 | ||
82 | discinfo_t data; /* Basic discovery information */ | 82 | discinfo_t data; /* Basic discovery information */ |
83 | int name_len; /* Lenght of nickname */ | 83 | int name_len; /* Length of nickname */ |
84 | 84 | ||
85 | LAP_REASON condition; /* More info about the discovery */ | 85 | LAP_REASON condition; /* More info about the discovery */ |
86 | int gen_addr_bit; /* Need to generate a new device | 86 | int gen_addr_bit; /* Need to generate a new device |
diff --git a/include/net/irda/irda_device.h b/include/net/irda/irda_device.h index bca19ca7bdd4..f70e9b39ebaf 100644 --- a/include/net/irda/irda_device.h +++ b/include/net/irda/irda_device.h | |||
@@ -228,21 +228,8 @@ static inline int irda_device_txqueue_empty(const struct net_device *dev) | |||
228 | int irda_device_set_raw_mode(struct net_device* self, int status); | 228 | int irda_device_set_raw_mode(struct net_device* self, int status); |
229 | struct net_device *alloc_irdadev(int sizeof_priv); | 229 | struct net_device *alloc_irdadev(int sizeof_priv); |
230 | 230 | ||
231 | /* Dongle interface */ | ||
232 | void irda_device_unregister_dongle(struct dongle_reg *dongle); | ||
233 | int irda_device_register_dongle(struct dongle_reg *dongle); | ||
234 | dongle_t *irda_device_dongle_init(struct net_device *dev, int type); | ||
235 | int irda_device_dongle_cleanup(dongle_t *dongle); | ||
236 | |||
237 | void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode); | 231 | void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode); |
238 | 232 | ||
239 | void irda_task_delete(struct irda_task *task); | ||
240 | struct irda_task *irda_task_execute(void *instance, | ||
241 | IRDA_TASK_CALLBACK function, | ||
242 | IRDA_TASK_CALLBACK finished, | ||
243 | struct irda_task *parent, void *param); | ||
244 | void irda_task_next_state(struct irda_task *task, IRDA_TASK_STATE state); | ||
245 | |||
246 | /* | 233 | /* |
247 | * Function irda_get_mtt (skb) | 234 | * Function irda_get_mtt (skb) |
248 | * | 235 | * |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 5fcc4c104340..9083bafb63ca 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -139,17 +139,54 @@ enum ieee80211_phymode { | |||
139 | }; | 139 | }; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * struct ieee80211_ht_info - describing STA's HT capabilities | ||
143 | * | ||
144 | * This structure describes most essential parameters needed | ||
145 | * to describe 802.11n HT capabilities for an STA. | ||
146 | * | ||
147 | * @ht_supported: is HT supported by STA, 0: no, 1: yes | ||
148 | * @cap: HT capabilities map as described in 802.11n spec | ||
149 | * @ampdu_factor: Maximum A-MPDU length factor | ||
150 | * @ampdu_density: Minimum A-MPDU spacing | ||
151 | * @supp_mcs_set: Supported MCS set as described in 802.11n spec | ||
152 | */ | ||
153 | struct ieee80211_ht_info { | ||
154 | u8 ht_supported; | ||
155 | u16 cap; /* use IEEE80211_HT_CAP_ */ | ||
156 | u8 ampdu_factor; | ||
157 | u8 ampdu_density; | ||
158 | u8 supp_mcs_set[16]; | ||
159 | }; | ||
160 | |||
161 | /** | ||
162 | * struct ieee80211_ht_bss_info - describing BSS's HT characteristics | ||
163 | * | ||
164 | * This structure describes most essential parameters needed | ||
165 | * to describe 802.11n HT characteristics in a BSS | ||
166 | * | ||
167 | * @primary_channel: channel number of primery channel | ||
168 | * @bss_cap: 802.11n's general BSS capabilities (e.g. channel width) | ||
169 | * @bss_op_mode: 802.11n's BSS operation modes (e.g. HT protection) | ||
170 | */ | ||
171 | struct ieee80211_ht_bss_info { | ||
172 | u8 primary_channel; | ||
173 | u8 bss_cap; /* use IEEE80211_HT_IE_CHA_ */ | ||
174 | u8 bss_op_mode; /* use IEEE80211_HT_IE_ */ | ||
175 | }; | ||
176 | |||
177 | /** | ||
142 | * struct ieee80211_hw_mode - PHY mode definition | 178 | * struct ieee80211_hw_mode - PHY mode definition |
143 | * | 179 | * |
144 | * This structure describes the capabilities supported by the device | 180 | * This structure describes the capabilities supported by the device |
145 | * in a single PHY mode. | 181 | * in a single PHY mode. |
146 | * | 182 | * |
183 | * @list: internal | ||
184 | * @channels: pointer to array of supported channels | ||
185 | * @rates: pointer to array of supported bitrates | ||
147 | * @mode: the PHY mode for this definition | 186 | * @mode: the PHY mode for this definition |
148 | * @num_channels: number of supported channels | 187 | * @num_channels: number of supported channels |
149 | * @channels: pointer to array of supported channels | ||
150 | * @num_rates: number of supported bitrates | 188 | * @num_rates: number of supported bitrates |
151 | * @rates: pointer to array of supported bitrates | 189 | * @ht_info: PHY's 802.11n HT abilities for this mode |
152 | * @list: internal | ||
153 | */ | 190 | */ |
154 | struct ieee80211_hw_mode { | 191 | struct ieee80211_hw_mode { |
155 | struct list_head list; | 192 | struct list_head list; |
@@ -158,6 +195,7 @@ struct ieee80211_hw_mode { | |||
158 | enum ieee80211_phymode mode; | 195 | enum ieee80211_phymode mode; |
159 | int num_channels; | 196 | int num_channels; |
160 | int num_rates; | 197 | int num_rates; |
198 | struct ieee80211_ht_info ht_info; | ||
161 | }; | 199 | }; |
162 | 200 | ||
163 | /** | 201 | /** |
@@ -237,11 +275,49 @@ struct ieee80211_low_level_stats { | |||
237 | unsigned int dot11RTSSuccessCount; | 275 | unsigned int dot11RTSSuccessCount; |
238 | }; | 276 | }; |
239 | 277 | ||
278 | /** | ||
279 | * enum ieee80211_bss_change - BSS change notification flags | ||
280 | * | ||
281 | * These flags are used with the bss_info_changed() callback | ||
282 | * to indicate which BSS parameter changed. | ||
283 | * | ||
284 | * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated), | ||
285 | * also implies a change in the AID. | ||
286 | * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed | ||
287 | * @BSS_CHANGED_ERP_PREAMBLE: preamble changed | ||
288 | */ | ||
289 | enum ieee80211_bss_change { | ||
290 | BSS_CHANGED_ASSOC = 1<<0, | ||
291 | BSS_CHANGED_ERP_CTS_PROT = 1<<1, | ||
292 | BSS_CHANGED_ERP_PREAMBLE = 1<<2, | ||
293 | }; | ||
294 | |||
295 | /** | ||
296 | * struct ieee80211_bss_conf - holds the BSS's changing parameters | ||
297 | * | ||
298 | * This structure keeps information about a BSS (and an association | ||
299 | * to that BSS) that can change during the lifetime of the BSS. | ||
300 | * | ||
301 | * @assoc: association status | ||
302 | * @aid: association ID number, valid only when @assoc is true | ||
303 | * @use_cts_prot: use CTS protection | ||
304 | * @use_short_preamble: use 802.11b short preamble | ||
305 | */ | ||
306 | struct ieee80211_bss_conf { | ||
307 | /* association related data */ | ||
308 | bool assoc; | ||
309 | u16 aid; | ||
310 | /* erp related data */ | ||
311 | bool use_cts_prot; | ||
312 | bool use_short_preamble; | ||
313 | }; | ||
314 | |||
240 | /* Transmit control fields. This data structure is passed to low-level driver | 315 | /* Transmit control fields. This data structure is passed to low-level driver |
241 | * with each TX frame. The low-level driver is responsible for configuring | 316 | * with each TX frame. The low-level driver is responsible for configuring |
242 | * the hardware to use given values (depending on what is supported). */ | 317 | * the hardware to use given values (depending on what is supported). */ |
243 | 318 | ||
244 | struct ieee80211_tx_control { | 319 | struct ieee80211_tx_control { |
320 | struct ieee80211_vif *vif; | ||
245 | int tx_rate; /* Transmit rate, given as the hw specific value for the | 321 | int tx_rate; /* Transmit rate, given as the hw specific value for the |
246 | * rate (from struct ieee80211_rate) */ | 322 | * rate (from struct ieee80211_rate) */ |
247 | int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw | 323 | int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw |
@@ -269,6 +345,9 @@ struct ieee80211_tx_control { | |||
269 | * using the through | 345 | * using the through |
270 | * set_retry_limit configured | 346 | * set_retry_limit configured |
271 | * long retry value */ | 347 | * long retry value */ |
348 | #define IEEE80211_TXCTL_EAPOL_FRAME (1<<11) /* internal to mac80211 */ | ||
349 | #define IEEE80211_TXCTL_SEND_AFTER_DTIM (1<<12) /* send this frame after DTIM | ||
350 | * beacon */ | ||
272 | u32 flags; /* tx control flags defined | 351 | u32 flags; /* tx control flags defined |
273 | * above */ | 352 | * above */ |
274 | u8 key_idx; /* keyidx from hw->set_key(), undefined if | 353 | u8 key_idx; /* keyidx from hw->set_key(), undefined if |
@@ -291,7 +370,6 @@ struct ieee80211_tx_control { | |||
291 | * packet dropping when probing higher rates, if hw | 370 | * packet dropping when probing higher rates, if hw |
292 | * supports multiple retry rates. -1 = not used */ | 371 | * supports multiple retry rates. -1 = not used */ |
293 | int type; /* internal */ | 372 | int type; /* internal */ |
294 | int ifindex; /* internal */ | ||
295 | }; | 373 | }; |
296 | 374 | ||
297 | 375 | ||
@@ -312,6 +390,8 @@ struct ieee80211_tx_control { | |||
312 | * the frame. | 390 | * the frame. |
313 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on | 391 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on |
314 | * the frame. | 392 | * the frame. |
393 | * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) | ||
394 | * is valid. | ||
315 | */ | 395 | */ |
316 | enum mac80211_rx_flags { | 396 | enum mac80211_rx_flags { |
317 | RX_FLAG_MMIC_ERROR = 1<<0, | 397 | RX_FLAG_MMIC_ERROR = 1<<0, |
@@ -321,6 +401,7 @@ enum mac80211_rx_flags { | |||
321 | RX_FLAG_IV_STRIPPED = 1<<4, | 401 | RX_FLAG_IV_STRIPPED = 1<<4, |
322 | RX_FLAG_FAILED_FCS_CRC = 1<<5, | 402 | RX_FLAG_FAILED_FCS_CRC = 1<<5, |
323 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, | 403 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, |
404 | RX_FLAG_TSFT = 1<<7, | ||
324 | }; | 405 | }; |
325 | 406 | ||
326 | /** | 407 | /** |
@@ -406,11 +487,12 @@ struct ieee80211_tx_status { | |||
406 | * | 487 | * |
407 | * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time | 488 | * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time |
408 | * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported) | 489 | * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported) |
409 | * | 490 | * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported) |
410 | */ | 491 | */ |
411 | enum ieee80211_conf_flags { | 492 | enum ieee80211_conf_flags { |
412 | IEEE80211_CONF_SHORT_SLOT_TIME = 1<<0, | 493 | IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0), |
413 | IEEE80211_CONF_RADIOTAP = 1<<1, | 494 | IEEE80211_CONF_RADIOTAP = (1<<1), |
495 | IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2), | ||
414 | }; | 496 | }; |
415 | 497 | ||
416 | /** | 498 | /** |
@@ -434,6 +516,8 @@ enum ieee80211_conf_flags { | |||
434 | * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, | 516 | * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, |
435 | * 1/2: antenna 0/1 | 517 | * 1/2: antenna 0/1 |
436 | * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx | 518 | * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx |
519 | * @ht_conf: describes current self configuration of 802.11n HT capabilies | ||
520 | * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters | ||
437 | */ | 521 | */ |
438 | struct ieee80211_conf { | 522 | struct ieee80211_conf { |
439 | int channel; /* IEEE 802.11 channel number */ | 523 | int channel; /* IEEE 802.11 channel number */ |
@@ -452,6 +536,9 @@ struct ieee80211_conf { | |||
452 | u8 antenna_max; | 536 | u8 antenna_max; |
453 | u8 antenna_sel_tx; | 537 | u8 antenna_sel_tx; |
454 | u8 antenna_sel_rx; | 538 | u8 antenna_sel_rx; |
539 | |||
540 | struct ieee80211_ht_info ht_conf; | ||
541 | struct ieee80211_ht_bss_info ht_bss_conf; | ||
455 | }; | 542 | }; |
456 | 543 | ||
457 | /** | 544 | /** |
@@ -480,13 +567,27 @@ enum ieee80211_if_types { | |||
480 | }; | 567 | }; |
481 | 568 | ||
482 | /** | 569 | /** |
570 | * struct ieee80211_vif - per-interface data | ||
571 | * | ||
572 | * Data in this structure is continually present for driver | ||
573 | * use during the life of a virtual interface. | ||
574 | * | ||
575 | * @type: type of this virtual interface | ||
576 | * @drv_priv: data area for driver use, will always be aligned to | ||
577 | * sizeof(void *). | ||
578 | */ | ||
579 | struct ieee80211_vif { | ||
580 | enum ieee80211_if_types type; | ||
581 | /* must be last */ | ||
582 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); | ||
583 | }; | ||
584 | |||
585 | /** | ||
483 | * struct ieee80211_if_init_conf - initial configuration of an interface | 586 | * struct ieee80211_if_init_conf - initial configuration of an interface |
484 | * | 587 | * |
485 | * @if_id: internal interface ID. This number has no particular meaning to | 588 | * @vif: pointer to a driver-use per-interface structure. The pointer |
486 | * drivers and the only allowed usage is to pass it to | 589 | * itself is also used for various functions including |
487 | * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions. | 590 | * ieee80211_beacon_get() and ieee80211_get_buffered_bc(). |
488 | * This field is not valid for monitor interfaces | ||
489 | * (interfaces of %IEEE80211_IF_TYPE_MNTR type). | ||
490 | * @type: one of &enum ieee80211_if_types constants. Determines the type of | 591 | * @type: one of &enum ieee80211_if_types constants. Determines the type of |
491 | * added/removed interface. | 592 | * added/removed interface. |
492 | * @mac_addr: pointer to MAC address of the interface. This pointer is valid | 593 | * @mac_addr: pointer to MAC address of the interface. This pointer is valid |
@@ -503,8 +604,8 @@ enum ieee80211_if_types { | |||
503 | * in pure monitor mode. | 604 | * in pure monitor mode. |
504 | */ | 605 | */ |
505 | struct ieee80211_if_init_conf { | 606 | struct ieee80211_if_init_conf { |
506 | int if_id; | ||
507 | enum ieee80211_if_types type; | 607 | enum ieee80211_if_types type; |
608 | struct ieee80211_vif *vif; | ||
508 | void *mac_addr; | 609 | void *mac_addr; |
509 | }; | 610 | }; |
510 | 611 | ||
@@ -597,9 +698,6 @@ struct ieee80211_key_conf { | |||
597 | u8 key[0]; | 698 | u8 key[0]; |
598 | }; | 699 | }; |
599 | 700 | ||
600 | #define IEEE80211_SEQ_COUNTER_RX 0 | ||
601 | #define IEEE80211_SEQ_COUNTER_TX 1 | ||
602 | |||
603 | /** | 701 | /** |
604 | * enum set_key_cmd - key command | 702 | * enum set_key_cmd - key command |
605 | * | 703 | * |
@@ -706,15 +804,24 @@ enum ieee80211_hw_flags { | |||
706 | * | 804 | * |
707 | * @queues: number of available hardware transmit queues for | 805 | * @queues: number of available hardware transmit queues for |
708 | * data packets. WMM/QoS requires at least four. | 806 | * data packets. WMM/QoS requires at least four. |
807 | * | ||
808 | * @rate_control_algorithm: rate control algorithm for this hardware. | ||
809 | * If unset (NULL), the default algorithm will be used. Must be | ||
810 | * set before calling ieee80211_register_hw(). | ||
811 | * | ||
812 | * @vif_data_size: size (in bytes) of the drv_priv data area | ||
813 | * within &struct ieee80211_vif. | ||
709 | */ | 814 | */ |
710 | struct ieee80211_hw { | 815 | struct ieee80211_hw { |
711 | struct ieee80211_conf conf; | 816 | struct ieee80211_conf conf; |
712 | struct wiphy *wiphy; | 817 | struct wiphy *wiphy; |
713 | struct workqueue_struct *workqueue; | 818 | struct workqueue_struct *workqueue; |
819 | const char *rate_control_algorithm; | ||
714 | void *priv; | 820 | void *priv; |
715 | u32 flags; | 821 | u32 flags; |
716 | unsigned int extra_tx_headroom; | 822 | unsigned int extra_tx_headroom; |
717 | int channel_change_time; | 823 | int channel_change_time; |
824 | int vif_data_size; | ||
718 | u8 queues; | 825 | u8 queues; |
719 | s8 max_rssi; | 826 | s8 max_rssi; |
720 | s8 max_signal; | 827 | s8 max_signal; |
@@ -854,19 +961,18 @@ enum ieee80211_filter_flags { | |||
854 | }; | 961 | }; |
855 | 962 | ||
856 | /** | 963 | /** |
857 | * enum ieee80211_erp_change_flags - erp change flags | 964 | * enum ieee80211_ampdu_mlme_action - A-MPDU actions |
858 | * | 965 | * |
859 | * These flags are used with the erp_ie_changed() callback in | 966 | * These flags are used with the ampdu_action() callback in |
860 | * &struct ieee80211_ops to indicate which parameter(s) changed. | 967 | * &struct ieee80211_ops to indicate which action is needed. |
861 | * @IEEE80211_ERP_CHANGE_PROTECTION: protection changed | 968 | * @IEEE80211_AMPDU_RX_START: start Rx aggregation |
862 | * @IEEE80211_ERP_CHANGE_PREAMBLE: barker preamble mode changed | 969 | * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation |
863 | */ | 970 | */ |
864 | enum ieee80211_erp_change_flags { | 971 | enum ieee80211_ampdu_mlme_action { |
865 | IEEE80211_ERP_CHANGE_PROTECTION = 1<<0, | 972 | IEEE80211_AMPDU_RX_START, |
866 | IEEE80211_ERP_CHANGE_PREAMBLE = 1<<1, | 973 | IEEE80211_AMPDU_RX_STOP, |
867 | }; | 974 | }; |
868 | 975 | ||
869 | |||
870 | /** | 976 | /** |
871 | * struct ieee80211_ops - callbacks from mac80211 to the driver | 977 | * struct ieee80211_ops - callbacks from mac80211 to the driver |
872 | * | 978 | * |
@@ -922,6 +1028,14 @@ enum ieee80211_erp_change_flags { | |||
922 | * @config_interface: Handler for configuration requests related to interfaces | 1028 | * @config_interface: Handler for configuration requests related to interfaces |
923 | * (e.g. BSSID changes.) | 1029 | * (e.g. BSSID changes.) |
924 | * | 1030 | * |
1031 | * @bss_info_changed: Handler for configuration requests related to BSS | ||
1032 | * parameters that may vary during BSS's lifespan, and may affect low | ||
1033 | * level driver (e.g. assoc/disassoc status, erp parameters). | ||
1034 | * This function should not be used if no BSS has been set, unless | ||
1035 | * for association indication. The @changed parameter indicates which | ||
1036 | * of the bss parameters has changed when a call is made. This callback | ||
1037 | * has to be atomic. | ||
1038 | * | ||
925 | * @configure_filter: Configure the device's RX filter. | 1039 | * @configure_filter: Configure the device's RX filter. |
926 | * See the section "Frame filtering" for more information. | 1040 | * See the section "Frame filtering" for more information. |
927 | * This callback must be implemented and atomic. | 1041 | * This callback must be implemented and atomic. |
@@ -936,30 +1050,14 @@ enum ieee80211_erp_change_flags { | |||
936 | * and remove_interface calls, i.e. while the interface with the | 1050 | * and remove_interface calls, i.e. while the interface with the |
937 | * given local_address is enabled. | 1051 | * given local_address is enabled. |
938 | * | 1052 | * |
939 | * @set_ieee8021x: Enable/disable IEEE 802.1X. This item requests wlan card | ||
940 | * to pass unencrypted EAPOL-Key frames even when encryption is | ||
941 | * configured. If the wlan card does not require such a configuration, | ||
942 | * this function pointer can be set to NULL. | ||
943 | * | ||
944 | * @set_port_auth: Set port authorization state (IEEE 802.1X PAE) to be | ||
945 | * authorized (@authorized=1) or unauthorized (=0). This function can be | ||
946 | * used if the wlan hardware or low-level driver implements PAE. | ||
947 | * mac80211 will filter frames based on authorization state in any case, | ||
948 | * so this function pointer can be NULL if low-level driver does not | ||
949 | * require event notification about port state changes. | ||
950 | * | ||
951 | * @hw_scan: Ask the hardware to service the scan request, no need to start | 1053 | * @hw_scan: Ask the hardware to service the scan request, no need to start |
952 | * the scan state machine in stack. | 1054 | * the scan state machine in stack. |
953 | * | 1055 | * |
954 | * @get_stats: return low-level statistics | 1056 | * @get_stats: return low-level statistics |
955 | * | 1057 | * |
956 | * @set_privacy_invoked: For devices that generate their own beacons and probe | 1058 | * @get_tkip_seq: If your device implements TKIP encryption in hardware this |
957 | * response or association responses this updates the state of privacy_invoked | 1059 | * callback should be provided to read the TKIP transmit IVs (both IV32 |
958 | * returns 0 for success or an error number. | 1060 | * and IV16) for the given key from hardware. |
959 | * | ||
960 | * @get_sequence_counter: For devices that have internal sequence counters this | ||
961 | * callback allows mac80211 to access the current value of a counter. | ||
962 | * This callback seems not well-defined, tell us if you need it. | ||
963 | * | 1061 | * |
964 | * @set_rts_threshold: Configuration of RTS threshold (if device needs it) | 1062 | * @set_rts_threshold: Configuration of RTS threshold (if device needs it) |
965 | * | 1063 | * |
@@ -972,8 +1070,6 @@ enum ieee80211_erp_change_flags { | |||
972 | * @sta_notify: Notifies low level driver about addition or removal | 1070 | * @sta_notify: Notifies low level driver about addition or removal |
973 | * of assocaited station or AP. | 1071 | * of assocaited station or AP. |
974 | * | 1072 | * |
975 | * @erp_ie_changed: Handle ERP IE change notifications. Must be atomic. | ||
976 | * | ||
977 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), | 1073 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), |
978 | * bursting) for a hardware TX queue. The @queue parameter uses the | 1074 | * bursting) for a hardware TX queue. The @queue parameter uses the |
979 | * %IEEE80211_TX_QUEUE_* constants. Must be atomic. | 1075 | * %IEEE80211_TX_QUEUE_* constants. Must be atomic. |
@@ -1008,6 +1104,14 @@ enum ieee80211_erp_change_flags { | |||
1008 | * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us. | 1104 | * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us. |
1009 | * This is needed only for IBSS mode and the result of this function is | 1105 | * This is needed only for IBSS mode and the result of this function is |
1010 | * used to determine whether to reply to Probe Requests. | 1106 | * used to determine whether to reply to Probe Requests. |
1107 | * | ||
1108 | * @conf_ht: Configures low level driver with 802.11n HT data. Must be atomic. | ||
1109 | * | ||
1110 | * @ampdu_action: Perform a certain A-MPDU action | ||
1111 | * The RA/TID combination determines the destination and TID we want | ||
1112 | * the ampdu action to be performed for. The action is defined through | ||
1113 | * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) | ||
1114 | * is the first frame we expect to perform the action on. | ||
1011 | */ | 1115 | */ |
1012 | struct ieee80211_ops { | 1116 | struct ieee80211_ops { |
1013 | int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, | 1117 | int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, |
@@ -1020,7 +1124,12 @@ struct ieee80211_ops { | |||
1020 | struct ieee80211_if_init_conf *conf); | 1124 | struct ieee80211_if_init_conf *conf); |
1021 | int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); | 1125 | int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); |
1022 | int (*config_interface)(struct ieee80211_hw *hw, | 1126 | int (*config_interface)(struct ieee80211_hw *hw, |
1023 | int if_id, struct ieee80211_if_conf *conf); | 1127 | struct ieee80211_vif *vif, |
1128 | struct ieee80211_if_conf *conf); | ||
1129 | void (*bss_info_changed)(struct ieee80211_hw *hw, | ||
1130 | struct ieee80211_vif *vif, | ||
1131 | struct ieee80211_bss_conf *info, | ||
1132 | u32 changed); | ||
1024 | void (*configure_filter)(struct ieee80211_hw *hw, | 1133 | void (*configure_filter)(struct ieee80211_hw *hw, |
1025 | unsigned int changed_flags, | 1134 | unsigned int changed_flags, |
1026 | unsigned int *total_flags, | 1135 | unsigned int *total_flags, |
@@ -1029,25 +1138,17 @@ struct ieee80211_ops { | |||
1029 | int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, | 1138 | int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
1030 | const u8 *local_address, const u8 *address, | 1139 | const u8 *local_address, const u8 *address, |
1031 | struct ieee80211_key_conf *key); | 1140 | struct ieee80211_key_conf *key); |
1032 | int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x); | ||
1033 | int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr, | ||
1034 | int authorized); | ||
1035 | int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); | 1141 | int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); |
1036 | int (*get_stats)(struct ieee80211_hw *hw, | 1142 | int (*get_stats)(struct ieee80211_hw *hw, |
1037 | struct ieee80211_low_level_stats *stats); | 1143 | struct ieee80211_low_level_stats *stats); |
1038 | int (*set_privacy_invoked)(struct ieee80211_hw *hw, | 1144 | void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, |
1039 | int privacy_invoked); | 1145 | u32 *iv32, u16 *iv16); |
1040 | int (*get_sequence_counter)(struct ieee80211_hw *hw, | ||
1041 | u8* addr, u8 keyidx, u8 txrx, | ||
1042 | u32* iv32, u16* iv16); | ||
1043 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); | 1146 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); |
1044 | int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); | 1147 | int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); |
1045 | int (*set_retry_limit)(struct ieee80211_hw *hw, | 1148 | int (*set_retry_limit)(struct ieee80211_hw *hw, |
1046 | u32 short_retry, u32 long_retr); | 1149 | u32 short_retry, u32 long_retr); |
1047 | void (*sta_notify)(struct ieee80211_hw *hw, int if_id, | 1150 | void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1048 | enum sta_notify_cmd, const u8 *addr); | 1151 | enum sta_notify_cmd, const u8 *addr); |
1049 | void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes, | ||
1050 | int cts_protection, int preamble); | ||
1051 | int (*conf_tx)(struct ieee80211_hw *hw, int queue, | 1152 | int (*conf_tx)(struct ieee80211_hw *hw, int queue, |
1052 | const struct ieee80211_tx_queue_params *params); | 1153 | const struct ieee80211_tx_queue_params *params); |
1053 | int (*get_tx_stats)(struct ieee80211_hw *hw, | 1154 | int (*get_tx_stats)(struct ieee80211_hw *hw, |
@@ -1058,6 +1159,10 @@ struct ieee80211_ops { | |||
1058 | struct sk_buff *skb, | 1159 | struct sk_buff *skb, |
1059 | struct ieee80211_tx_control *control); | 1160 | struct ieee80211_tx_control *control); |
1060 | int (*tx_last_beacon)(struct ieee80211_hw *hw); | 1161 | int (*tx_last_beacon)(struct ieee80211_hw *hw); |
1162 | int (*conf_ht)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); | ||
1163 | int (*ampdu_action)(struct ieee80211_hw *hw, | ||
1164 | enum ieee80211_ampdu_mlme_action action, | ||
1165 | const u8 *ra, u16 tid, u16 ssn); | ||
1061 | }; | 1166 | }; |
1062 | 1167 | ||
1063 | /** | 1168 | /** |
@@ -1089,6 +1194,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw); | |||
1089 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); | 1194 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); |
1090 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); | 1195 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); |
1091 | extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); | 1196 | extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); |
1197 | extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); | ||
1092 | #endif | 1198 | #endif |
1093 | /** | 1199 | /** |
1094 | * ieee80211_get_tx_led_name - get name of TX LED | 1200 | * ieee80211_get_tx_led_name - get name of TX LED |
@@ -1128,6 +1234,16 @@ static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw) | |||
1128 | #endif | 1234 | #endif |
1129 | } | 1235 | } |
1130 | 1236 | ||
1237 | /** | ||
1238 | * ieee80211_get_assoc_led_name - get name of association LED | ||
1239 | * | ||
1240 | * mac80211 creates a association LED trigger for each wireless hardware | ||
1241 | * that can be used to drive LEDs if your driver registers a LED device. | ||
1242 | * This function returns the name (or %NULL if not configured for LEDs) | ||
1243 | * of the trigger so you can automatically link the LED device. | ||
1244 | * | ||
1245 | * @hw: the hardware to get the LED trigger name for | ||
1246 | */ | ||
1131 | static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) | 1247 | static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) |
1132 | { | 1248 | { |
1133 | #ifdef CONFIG_MAC80211_LEDS | 1249 | #ifdef CONFIG_MAC80211_LEDS |
@@ -1137,6 +1253,24 @@ static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) | |||
1137 | #endif | 1253 | #endif |
1138 | } | 1254 | } |
1139 | 1255 | ||
1256 | /** | ||
1257 | * ieee80211_get_radio_led_name - get name of radio LED | ||
1258 | * | ||
1259 | * mac80211 creates a radio change LED trigger for each wireless hardware | ||
1260 | * that can be used to drive LEDs if your driver registers a LED device. | ||
1261 | * This function returns the name (or %NULL if not configured for LEDs) | ||
1262 | * of the trigger so you can automatically link the LED device. | ||
1263 | * | ||
1264 | * @hw: the hardware to get the LED trigger name for | ||
1265 | */ | ||
1266 | static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw) | ||
1267 | { | ||
1268 | #ifdef CONFIG_MAC80211_LEDS | ||
1269 | return __ieee80211_get_radio_led_name(hw); | ||
1270 | #else | ||
1271 | return NULL; | ||
1272 | #endif | ||
1273 | } | ||
1140 | 1274 | ||
1141 | /* Register a new hardware PHYMODE capability to the stack. */ | 1275 | /* Register a new hardware PHYMODE capability to the stack. */ |
1142 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, | 1276 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, |
@@ -1226,7 +1360,7 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, | |||
1226 | /** | 1360 | /** |
1227 | * ieee80211_beacon_get - beacon generation function | 1361 | * ieee80211_beacon_get - beacon generation function |
1228 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 1362 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1229 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1363 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1230 | * @control: will be filled with information needed to send this beacon. | 1364 | * @control: will be filled with information needed to send this beacon. |
1231 | * | 1365 | * |
1232 | * If the beacon frames are generated by the host system (i.e., not in | 1366 | * If the beacon frames are generated by the host system (i.e., not in |
@@ -1237,13 +1371,13 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, | |||
1237 | * is responsible of freeing it. | 1371 | * is responsible of freeing it. |
1238 | */ | 1372 | */ |
1239 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | 1373 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, |
1240 | int if_id, | 1374 | struct ieee80211_vif *vif, |
1241 | struct ieee80211_tx_control *control); | 1375 | struct ieee80211_tx_control *control); |
1242 | 1376 | ||
1243 | /** | 1377 | /** |
1244 | * ieee80211_rts_get - RTS frame generation function | 1378 | * ieee80211_rts_get - RTS frame generation function |
1245 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 1379 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1246 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1380 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1247 | * @frame: pointer to the frame that is going to be protected by the RTS. | 1381 | * @frame: pointer to the frame that is going to be protected by the RTS. |
1248 | * @frame_len: the frame length (in octets). | 1382 | * @frame_len: the frame length (in octets). |
1249 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | 1383 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
@@ -1254,7 +1388,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1254 | * the next RTS frame from the 802.11 code. The low-level is responsible | 1388 | * the next RTS frame from the 802.11 code. The low-level is responsible |
1255 | * for calling this function before and RTS frame is needed. | 1389 | * for calling this function before and RTS frame is needed. |
1256 | */ | 1390 | */ |
1257 | void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, | 1391 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1258 | const void *frame, size_t frame_len, | 1392 | const void *frame, size_t frame_len, |
1259 | const struct ieee80211_tx_control *frame_txctl, | 1393 | const struct ieee80211_tx_control *frame_txctl, |
1260 | struct ieee80211_rts *rts); | 1394 | struct ieee80211_rts *rts); |
@@ -1262,7 +1396,7 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, | |||
1262 | /** | 1396 | /** |
1263 | * ieee80211_rts_duration - Get the duration field for an RTS frame | 1397 | * ieee80211_rts_duration - Get the duration field for an RTS frame |
1264 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 1398 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1265 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1399 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1266 | * @frame_len: the length of the frame that is going to be protected by the RTS. | 1400 | * @frame_len: the length of the frame that is going to be protected by the RTS. |
1267 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | 1401 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
1268 | * | 1402 | * |
@@ -1270,14 +1404,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, | |||
1270 | * the duration field, the low-level driver uses this function to receive | 1404 | * the duration field, the low-level driver uses this function to receive |
1271 | * the duration field value in little-endian byteorder. | 1405 | * the duration field value in little-endian byteorder. |
1272 | */ | 1406 | */ |
1273 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, | 1407 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, |
1274 | size_t frame_len, | 1408 | struct ieee80211_vif *vif, size_t frame_len, |
1275 | const struct ieee80211_tx_control *frame_txctl); | 1409 | const struct ieee80211_tx_control *frame_txctl); |
1276 | 1410 | ||
1277 | /** | 1411 | /** |
1278 | * ieee80211_ctstoself_get - CTS-to-self frame generation function | 1412 | * ieee80211_ctstoself_get - CTS-to-self frame generation function |
1279 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 1413 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1280 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1414 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1281 | * @frame: pointer to the frame that is going to be protected by the CTS-to-self. | 1415 | * @frame: pointer to the frame that is going to be protected by the CTS-to-self. |
1282 | * @frame_len: the frame length (in octets). | 1416 | * @frame_len: the frame length (in octets). |
1283 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | 1417 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
@@ -1288,7 +1422,8 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, | |||
1288 | * the next CTS-to-self frame from the 802.11 code. The low-level is responsible | 1422 | * the next CTS-to-self frame from the 802.11 code. The low-level is responsible |
1289 | * for calling this function before and CTS-to-self frame is needed. | 1423 | * for calling this function before and CTS-to-self frame is needed. |
1290 | */ | 1424 | */ |
1291 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, | 1425 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, |
1426 | struct ieee80211_vif *vif, | ||
1292 | const void *frame, size_t frame_len, | 1427 | const void *frame, size_t frame_len, |
1293 | const struct ieee80211_tx_control *frame_txctl, | 1428 | const struct ieee80211_tx_control *frame_txctl, |
1294 | struct ieee80211_cts *cts); | 1429 | struct ieee80211_cts *cts); |
@@ -1296,7 +1431,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, | |||
1296 | /** | 1431 | /** |
1297 | * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame | 1432 | * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame |
1298 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 1433 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1299 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1434 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1300 | * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. | 1435 | * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. |
1301 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | 1436 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
1302 | * | 1437 | * |
@@ -1304,28 +1439,30 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, | |||
1304 | * the duration field, the low-level driver uses this function to receive | 1439 | * the duration field, the low-level driver uses this function to receive |
1305 | * the duration field value in little-endian byteorder. | 1440 | * the duration field value in little-endian byteorder. |
1306 | */ | 1441 | */ |
1307 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, | 1442 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, |
1443 | struct ieee80211_vif *vif, | ||
1308 | size_t frame_len, | 1444 | size_t frame_len, |
1309 | const struct ieee80211_tx_control *frame_txctl); | 1445 | const struct ieee80211_tx_control *frame_txctl); |
1310 | 1446 | ||
1311 | /** | 1447 | /** |
1312 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame | 1448 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame |
1313 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 1449 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1314 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1450 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1315 | * @frame_len: the length of the frame. | 1451 | * @frame_len: the length of the frame. |
1316 | * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. | 1452 | * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. |
1317 | * | 1453 | * |
1318 | * Calculate the duration field of some generic frame, given its | 1454 | * Calculate the duration field of some generic frame, given its |
1319 | * length and transmission rate (in 100kbps). | 1455 | * length and transmission rate (in 100kbps). |
1320 | */ | 1456 | */ |
1321 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, | 1457 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, |
1458 | struct ieee80211_vif *vif, | ||
1322 | size_t frame_len, | 1459 | size_t frame_len, |
1323 | int rate); | 1460 | int rate); |
1324 | 1461 | ||
1325 | /** | 1462 | /** |
1326 | * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames | 1463 | * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames |
1327 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | 1464 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
1328 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | 1465 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
1329 | * @control: will be filled with information needed to send returned frame. | 1466 | * @control: will be filled with information needed to send returned frame. |
1330 | * | 1467 | * |
1331 | * Function for accessing buffered broadcast and multicast frames. If | 1468 | * Function for accessing buffered broadcast and multicast frames. If |
@@ -1344,7 +1481,7 @@ __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, | |||
1344 | * use common code for all beacons. | 1481 | * use common code for all beacons. |
1345 | */ | 1482 | */ |
1346 | struct sk_buff * | 1483 | struct sk_buff * |
1347 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | 1484 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1348 | struct ieee80211_tx_control *control); | 1485 | struct ieee80211_tx_control *control); |
1349 | 1486 | ||
1350 | /** | 1487 | /** |
@@ -1422,4 +1559,19 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw); | |||
1422 | */ | 1559 | */ |
1423 | void ieee80211_scan_completed(struct ieee80211_hw *hw); | 1560 | void ieee80211_scan_completed(struct ieee80211_hw *hw); |
1424 | 1561 | ||
1562 | /** | ||
1563 | * ieee80211_iterate_active_interfaces - iterate active interfaces | ||
1564 | * | ||
1565 | * This function iterates over the interfaces associated with a given | ||
1566 | * hardware that are currently active and calls the callback for them. | ||
1567 | * | ||
1568 | * @hw: the hardware struct of which the interfaces should be iterated over | ||
1569 | * @iterator: the iterator function to call, cannot sleep | ||
1570 | * @data: first argument of the iterator function | ||
1571 | */ | ||
1572 | void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, | ||
1573 | void (*iterator)(void *data, u8 *mac, | ||
1574 | struct ieee80211_vif *vif), | ||
1575 | void *data); | ||
1576 | |||
1425 | #endif /* MAC80211_H */ | 1577 | #endif /* MAC80211_H */ |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index a4f26187fc1a..ebbfb509822e 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -26,6 +26,10 @@ | |||
26 | #include <linux/sysctl.h> | 26 | #include <linux/sysctl.h> |
27 | #include <net/rtnetlink.h> | 27 | #include <net/rtnetlink.h> |
28 | 28 | ||
29 | /* | ||
30 | * NUD stands for "neighbor unreachability detection" | ||
31 | */ | ||
32 | |||
29 | #define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE) | 33 | #define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE) |
30 | #define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY) | 34 | #define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY) |
31 | #define NUD_CONNECTED (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE) | 35 | #define NUD_CONNECTED (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE) |
@@ -34,6 +38,7 @@ struct neighbour; | |||
34 | 38 | ||
35 | struct neigh_parms | 39 | struct neigh_parms |
36 | { | 40 | { |
41 | struct net *net; | ||
37 | struct net_device *dev; | 42 | struct net_device *dev; |
38 | struct neigh_parms *next; | 43 | struct neigh_parms *next; |
39 | int (*neigh_setup)(struct neighbour *); | 44 | int (*neigh_setup)(struct neighbour *); |
@@ -126,7 +131,8 @@ struct neigh_ops | |||
126 | struct pneigh_entry | 131 | struct pneigh_entry |
127 | { | 132 | { |
128 | struct pneigh_entry *next; | 133 | struct pneigh_entry *next; |
129 | struct net_device *dev; | 134 | struct net *net; |
135 | struct net_device *dev; | ||
130 | u8 flags; | 136 | u8 flags; |
131 | u8 key[0]; | 137 | u8 key[0]; |
132 | }; | 138 | }; |
@@ -187,6 +193,7 @@ extern struct neighbour * neigh_lookup(struct neigh_table *tbl, | |||
187 | const void *pkey, | 193 | const void *pkey, |
188 | struct net_device *dev); | 194 | struct net_device *dev); |
189 | extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl, | 195 | extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl, |
196 | struct net *net, | ||
190 | const void *pkey); | 197 | const void *pkey); |
191 | extern struct neighbour * neigh_create(struct neigh_table *tbl, | 198 | extern struct neighbour * neigh_create(struct neigh_table *tbl, |
192 | const void *pkey, | 199 | const void *pkey, |
@@ -206,13 +213,12 @@ extern struct neighbour *neigh_event_ns(struct neigh_table *tbl, | |||
206 | 213 | ||
207 | extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); | 214 | extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); |
208 | extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); | 215 | extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); |
209 | extern void neigh_parms_destroy(struct neigh_parms *parms); | ||
210 | extern unsigned long neigh_rand_reach_time(unsigned long base); | 216 | extern unsigned long neigh_rand_reach_time(unsigned long base); |
211 | 217 | ||
212 | extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, | 218 | extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, |
213 | struct sk_buff *skb); | 219 | struct sk_buff *skb); |
214 | extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, const void *key, struct net_device *dev, int creat); | 220 | extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat); |
215 | extern int pneigh_delete(struct neigh_table *tbl, const void *key, struct net_device *dev); | 221 | extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev); |
216 | 222 | ||
217 | extern void neigh_app_ns(struct neighbour *n); | 223 | extern void neigh_app_ns(struct neighbour *n); |
218 | extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); | 224 | extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); |
@@ -220,6 +226,7 @@ extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct n | |||
220 | extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *)); | 226 | extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *)); |
221 | 227 | ||
222 | struct neigh_seq_state { | 228 | struct neigh_seq_state { |
229 | struct seq_net_private p; | ||
223 | struct neigh_table *tbl; | 230 | struct neigh_table *tbl; |
224 | void *(*neigh_sub_iter)(struct neigh_seq_state *state, | 231 | void *(*neigh_sub_iter)(struct neigh_seq_state *state, |
225 | struct neighbour *n, loff_t *pos); | 232 | struct neighbour *n, loff_t *pos); |
@@ -246,12 +253,6 @@ static inline void __neigh_parms_put(struct neigh_parms *parms) | |||
246 | atomic_dec(&parms->refcnt); | 253 | atomic_dec(&parms->refcnt); |
247 | } | 254 | } |
248 | 255 | ||
249 | static inline void neigh_parms_put(struct neigh_parms *parms) | ||
250 | { | ||
251 | if (atomic_dec_and_test(&parms->refcnt)) | ||
252 | neigh_parms_destroy(parms); | ||
253 | } | ||
254 | |||
255 | static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms) | 256 | static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms) |
256 | { | 257 | { |
257 | atomic_inc(&parms->refcnt); | 258 | atomic_inc(&parms->refcnt); |
@@ -288,10 +289,6 @@ static inline int neigh_is_connected(struct neighbour *neigh) | |||
288 | return neigh->nud_state&NUD_CONNECTED; | 289 | return neigh->nud_state&NUD_CONNECTED; |
289 | } | 290 | } |
290 | 291 | ||
291 | static inline int neigh_is_valid(struct neighbour *neigh) | ||
292 | { | ||
293 | return neigh->nud_state&NUD_VALID; | ||
294 | } | ||
295 | 292 | ||
296 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | 293 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) |
297 | { | 294 | { |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 5279466606d2..28738b7d53eb 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -8,8 +8,17 @@ | |||
8 | #include <linux/workqueue.h> | 8 | #include <linux/workqueue.h> |
9 | #include <linux/list.h> | 9 | #include <linux/list.h> |
10 | 10 | ||
11 | #include <net/netns/unix.h> | ||
12 | #include <net/netns/packet.h> | ||
13 | #include <net/netns/ipv4.h> | ||
14 | #include <net/netns/ipv6.h> | ||
15 | #include <net/netns/x_tables.h> | ||
16 | |||
11 | struct proc_dir_entry; | 17 | struct proc_dir_entry; |
12 | struct net_device; | 18 | struct net_device; |
19 | struct sock; | ||
20 | struct ctl_table_header; | ||
21 | |||
13 | struct net { | 22 | struct net { |
14 | atomic_t count; /* To decided when the network | 23 | atomic_t count; /* To decided when the network |
15 | * namespace should be freed. | 24 | * namespace should be freed. |
@@ -24,11 +33,33 @@ struct net { | |||
24 | struct proc_dir_entry *proc_net_stat; | 33 | struct proc_dir_entry *proc_net_stat; |
25 | struct proc_dir_entry *proc_net_root; | 34 | struct proc_dir_entry *proc_net_root; |
26 | 35 | ||
36 | struct list_head sysctl_table_headers; | ||
37 | |||
27 | struct net_device *loopback_dev; /* The loopback */ | 38 | struct net_device *loopback_dev; /* The loopback */ |
28 | 39 | ||
29 | struct list_head dev_base_head; | 40 | struct list_head dev_base_head; |
30 | struct hlist_head *dev_name_head; | 41 | struct hlist_head *dev_name_head; |
31 | struct hlist_head *dev_index_head; | 42 | struct hlist_head *dev_index_head; |
43 | |||
44 | /* core fib_rules */ | ||
45 | struct list_head rules_ops; | ||
46 | spinlock_t rules_mod_lock; | ||
47 | |||
48 | struct sock *rtnl; /* rtnetlink socket */ | ||
49 | |||
50 | /* core sysctls */ | ||
51 | struct ctl_table_header *sysctl_core_hdr; | ||
52 | int sysctl_somaxconn; | ||
53 | |||
54 | struct netns_packet packet; | ||
55 | struct netns_unix unx; | ||
56 | struct netns_ipv4 ipv4; | ||
57 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
58 | struct netns_ipv6 ipv6; | ||
59 | #endif | ||
60 | #ifdef CONFIG_NETFILTER | ||
61 | struct netns_xt xt; | ||
62 | #endif | ||
32 | }; | 63 | }; |
33 | 64 | ||
34 | #ifdef CONFIG_NET | 65 | #ifdef CONFIG_NET |
@@ -51,13 +82,12 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns) | |||
51 | } | 82 | } |
52 | #endif | 83 | #endif |
53 | 84 | ||
85 | #ifdef CONFIG_NET_NS | ||
54 | extern void __put_net(struct net *net); | 86 | extern void __put_net(struct net *net); |
55 | 87 | ||
56 | static inline struct net *get_net(struct net *net) | 88 | static inline struct net *get_net(struct net *net) |
57 | { | 89 | { |
58 | #ifdef CONFIG_NET | ||
59 | atomic_inc(&net->count); | 90 | atomic_inc(&net->count); |
60 | #endif | ||
61 | return net; | 91 | return net; |
62 | } | 92 | } |
63 | 93 | ||
@@ -75,36 +105,56 @@ static inline struct net *maybe_get_net(struct net *net) | |||
75 | 105 | ||
76 | static inline void put_net(struct net *net) | 106 | static inline void put_net(struct net *net) |
77 | { | 107 | { |
78 | #ifdef CONFIG_NET | ||
79 | if (atomic_dec_and_test(&net->count)) | 108 | if (atomic_dec_and_test(&net->count)) |
80 | __put_net(net); | 109 | __put_net(net); |
81 | #endif | ||
82 | } | 110 | } |
83 | 111 | ||
84 | static inline struct net *hold_net(struct net *net) | 112 | static inline struct net *hold_net(struct net *net) |
85 | { | 113 | { |
86 | #ifdef CONFIG_NET | ||
87 | atomic_inc(&net->use_count); | 114 | atomic_inc(&net->use_count); |
88 | #endif | ||
89 | return net; | 115 | return net; |
90 | } | 116 | } |
91 | 117 | ||
92 | static inline void release_net(struct net *net) | 118 | static inline void release_net(struct net *net) |
93 | { | 119 | { |
94 | #ifdef CONFIG_NET | ||
95 | atomic_dec(&net->use_count); | 120 | atomic_dec(&net->use_count); |
96 | #endif | 121 | } |
122 | #else | ||
123 | static inline struct net *get_net(struct net *net) | ||
124 | { | ||
125 | return net; | ||
126 | } | ||
127 | |||
128 | static inline void put_net(struct net *net) | ||
129 | { | ||
97 | } | 130 | } |
98 | 131 | ||
132 | static inline struct net *hold_net(struct net *net) | ||
133 | { | ||
134 | return net; | ||
135 | } | ||
136 | |||
137 | static inline void release_net(struct net *net) | ||
138 | { | ||
139 | } | ||
140 | |||
141 | static inline struct net *maybe_get_net(struct net *net) | ||
142 | { | ||
143 | return net; | ||
144 | } | ||
145 | #endif | ||
146 | |||
99 | #define for_each_net(VAR) \ | 147 | #define for_each_net(VAR) \ |
100 | list_for_each_entry(VAR, &net_namespace_list, list) | 148 | list_for_each_entry(VAR, &net_namespace_list, list) |
101 | 149 | ||
102 | #ifdef CONFIG_NET_NS | 150 | #ifdef CONFIG_NET_NS |
103 | #define __net_init | 151 | #define __net_init |
104 | #define __net_exit | 152 | #define __net_exit |
153 | #define __net_initdata | ||
105 | #else | 154 | #else |
106 | #define __net_init __init | 155 | #define __net_init __init |
107 | #define __net_exit __exit_refok | 156 | #define __net_exit __exit_refok |
157 | #define __net_initdata __initdata | ||
108 | #endif | 158 | #endif |
109 | 159 | ||
110 | struct pernet_operations { | 160 | struct pernet_operations { |
@@ -118,4 +168,11 @@ extern void unregister_pernet_subsys(struct pernet_operations *); | |||
118 | extern int register_pernet_device(struct pernet_operations *); | 168 | extern int register_pernet_device(struct pernet_operations *); |
119 | extern void unregister_pernet_device(struct pernet_operations *); | 169 | extern void unregister_pernet_device(struct pernet_operations *); |
120 | 170 | ||
171 | struct ctl_path; | ||
172 | struct ctl_table; | ||
173 | struct ctl_table_header; | ||
174 | extern struct ctl_table_header *register_net_sysctl_table(struct net *net, | ||
175 | const struct ctl_path *path, struct ctl_table *table); | ||
176 | extern void unregister_net_sysctl_table(struct ctl_table_header *header); | ||
177 | |||
121 | #endif /* __NET_NET_NAMESPACE_H */ | 178 | #endif /* __NET_NET_NAMESPACE_H */ |
diff --git a/include/net/netevent.h b/include/net/netevent.h index e5d216241423..e82b7bab3ff3 100644 --- a/include/net/netevent.h +++ b/include/net/netevent.h | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | #ifdef __KERNEL__ | 13 | #ifdef __KERNEL__ |
14 | 14 | ||
15 | #include <net/dst.h> | 15 | struct dst_entry; |
16 | 16 | ||
17 | struct netevent_redirect { | 17 | struct netevent_redirect { |
18 | struct dst_entry *old; | 18 | struct dst_entry *old; |
diff --git a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h index f703533fb4db..abc55ad75c2b 100644 --- a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h +++ b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h | |||
@@ -16,6 +16,8 @@ extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, | |||
16 | int (*okfn)(struct sk_buff *)); | 16 | int (*okfn)(struct sk_buff *)); |
17 | 17 | ||
18 | struct inet_frags_ctl; | 18 | struct inet_frags_ctl; |
19 | extern struct inet_frags_ctl nf_frags_ctl; | 19 | |
20 | #include <linux/sysctl.h> | ||
21 | extern struct ctl_table nf_ct_ipv6_sysctl_table[]; | ||
20 | 22 | ||
21 | #endif /* _NF_CONNTRACK_IPV6_H*/ | 23 | #endif /* _NF_CONNTRACK_IPV6_H*/ |
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 90fb66d99d0c..90b3e7f5df5f 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -129,6 +129,8 @@ struct nf_conn | |||
129 | 129 | ||
130 | /* Extensions */ | 130 | /* Extensions */ |
131 | struct nf_ct_ext *ext; | 131 | struct nf_ct_ext *ext; |
132 | |||
133 | struct rcu_head rcu; | ||
132 | }; | 134 | }; |
133 | 135 | ||
134 | static inline struct nf_conn * | 136 | static inline struct nf_conn * |
@@ -143,7 +145,7 @@ nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash) | |||
143 | 145 | ||
144 | /* Alter reply tuple (maybe alter helper). */ | 146 | /* Alter reply tuple (maybe alter helper). */ |
145 | extern void | 147 | extern void |
146 | nf_conntrack_alter_reply(struct nf_conn *conntrack, | 148 | nf_conntrack_alter_reply(struct nf_conn *ct, |
147 | const struct nf_conntrack_tuple *newreply); | 149 | const struct nf_conntrack_tuple *newreply); |
148 | 150 | ||
149 | /* Is this tuple taken? (ignoring any belonging to the given | 151 | /* Is this tuple taken? (ignoring any belonging to the given |
@@ -171,13 +173,12 @@ static inline void nf_ct_put(struct nf_conn *ct) | |||
171 | extern int nf_ct_l3proto_try_module_get(unsigned short l3proto); | 173 | extern int nf_ct_l3proto_try_module_get(unsigned short l3proto); |
172 | extern void nf_ct_l3proto_module_put(unsigned short l3proto); | 174 | extern void nf_ct_l3proto_module_put(unsigned short l3proto); |
173 | 175 | ||
174 | extern struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced); | 176 | extern struct hlist_head *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced); |
175 | extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, | 177 | extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, |
176 | int size); | 178 | unsigned int size); |
177 | 179 | ||
178 | extern struct nf_conntrack_tuple_hash * | 180 | extern struct nf_conntrack_tuple_hash * |
179 | __nf_conntrack_find(const struct nf_conntrack_tuple *tuple, | 181 | __nf_conntrack_find(const struct nf_conntrack_tuple *tuple); |
180 | const struct nf_conn *ignored_conntrack); | ||
181 | 182 | ||
182 | extern void nf_conntrack_hash_insert(struct nf_conn *ct); | 183 | extern void nf_conntrack_hash_insert(struct nf_conn *ct); |
183 | 184 | ||
@@ -215,16 +216,14 @@ static inline void nf_ct_refresh(struct nf_conn *ct, | |||
215 | 216 | ||
216 | /* These are for NAT. Icky. */ | 217 | /* These are for NAT. Icky. */ |
217 | /* Update TCP window tracking data when NAT mangles the packet */ | 218 | /* Update TCP window tracking data when NAT mangles the packet */ |
218 | extern void nf_conntrack_tcp_update(struct sk_buff *skb, | 219 | extern void nf_conntrack_tcp_update(const struct sk_buff *skb, |
219 | unsigned int dataoff, | 220 | unsigned int dataoff, |
220 | struct nf_conn *conntrack, | 221 | struct nf_conn *ct, |
221 | int dir); | 222 | int dir); |
222 | 223 | ||
223 | /* Fake conntrack entry for untracked connections */ | 224 | /* Fake conntrack entry for untracked connections */ |
224 | extern struct nf_conn nf_conntrack_untracked; | 225 | extern struct nf_conn nf_conntrack_untracked; |
225 | 226 | ||
226 | extern int nf_ct_no_defrag; | ||
227 | |||
228 | /* Iterate over all conntracks: if iter returns true, it's deleted. */ | 227 | /* Iterate over all conntracks: if iter returns true, it's deleted. */ |
229 | extern void | 228 | extern void |
230 | nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data); | 229 | nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data); |
@@ -249,6 +248,7 @@ static inline int nf_ct_is_untracked(const struct sk_buff *skb) | |||
249 | return (skb->nfct == &nf_conntrack_untracked.ct_general); | 248 | return (skb->nfct == &nf_conntrack_untracked.ct_general); |
250 | } | 249 | } |
251 | 250 | ||
251 | extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp); | ||
252 | extern unsigned int nf_conntrack_htable_size; | 252 | extern unsigned int nf_conntrack_htable_size; |
253 | extern int nf_conntrack_checksum; | 253 | extern int nf_conntrack_checksum; |
254 | extern atomic_t nf_conntrack_count; | 254 | extern atomic_t nf_conntrack_count; |
@@ -263,10 +263,5 @@ do { \ | |||
263 | local_bh_enable(); \ | 263 | local_bh_enable(); \ |
264 | } while (0) | 264 | } while (0) |
265 | 265 | ||
266 | extern int | ||
267 | nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size); | ||
268 | extern void | ||
269 | nf_conntrack_unregister_cache(u_int32_t features); | ||
270 | |||
271 | #endif /* __KERNEL__ */ | 266 | #endif /* __KERNEL__ */ |
272 | #endif /* _NF_CONNTRACK_H */ | 267 | #endif /* _NF_CONNTRACK_H */ |
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h index a532e7b5ed6a..9ee26469c759 100644 --- a/include/net/netfilter/nf_conntrack_core.h +++ b/include/net/netfilter/nf_conntrack_core.h | |||
@@ -30,16 +30,6 @@ extern void nf_conntrack_cleanup(void); | |||
30 | extern int nf_conntrack_proto_init(void); | 30 | extern int nf_conntrack_proto_init(void); |
31 | extern void nf_conntrack_proto_fini(void); | 31 | extern void nf_conntrack_proto_fini(void); |
32 | 32 | ||
33 | extern int nf_conntrack_helper_init(void); | ||
34 | extern void nf_conntrack_helper_fini(void); | ||
35 | |||
36 | struct nf_conntrack_l3proto; | ||
37 | extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf); | ||
38 | /* Like above, but you already have conntrack read lock. */ | ||
39 | extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto); | ||
40 | |||
41 | struct nf_conntrack_l4proto; | ||
42 | |||
43 | extern int | 33 | extern int |
44 | nf_ct_get_tuple(const struct sk_buff *skb, | 34 | nf_ct_get_tuple(const struct sk_buff *skb, |
45 | unsigned int nhoff, | 35 | unsigned int nhoff, |
@@ -76,15 +66,13 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb) | |||
76 | return ret; | 66 | return ret; |
77 | } | 67 | } |
78 | 68 | ||
79 | extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb); | ||
80 | |||
81 | int | 69 | int |
82 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, | 70 | print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, |
83 | struct nf_conntrack_l3proto *l3proto, | 71 | const struct nf_conntrack_l3proto *l3proto, |
84 | struct nf_conntrack_l4proto *proto); | 72 | const struct nf_conntrack_l4proto *proto); |
85 | 73 | ||
86 | extern struct hlist_head *nf_conntrack_hash; | 74 | extern struct hlist_head *nf_conntrack_hash; |
87 | extern rwlock_t nf_conntrack_lock ; | 75 | extern spinlock_t nf_conntrack_lock ; |
88 | extern struct hlist_head unconfirmed; | 76 | extern struct hlist_head unconfirmed; |
89 | 77 | ||
90 | #endif /* _NF_CONNTRACK_CORE_H */ | 78 | #endif /* _NF_CONNTRACK_CORE_H */ |
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h index b47c04f12dbe..cb608a1b44e5 100644 --- a/include/net/netfilter/nf_conntrack_expect.h +++ b/include/net/netfilter/nf_conntrack_expect.h | |||
@@ -49,6 +49,8 @@ struct nf_conntrack_expect | |||
49 | /* Direction relative to the master connection. */ | 49 | /* Direction relative to the master connection. */ |
50 | enum ip_conntrack_dir dir; | 50 | enum ip_conntrack_dir dir; |
51 | #endif | 51 | #endif |
52 | |||
53 | struct rcu_head rcu; | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | #define NF_CT_EXPECT_PERMANENT 0x1 | 56 | #define NF_CT_EXPECT_PERMANENT 0x1 |
@@ -73,8 +75,8 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); | |||
73 | nf_ct_expect_related. You will have to call put afterwards. */ | 75 | nf_ct_expect_related. You will have to call put afterwards. */ |
74 | struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); | 76 | struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); |
75 | void nf_ct_expect_init(struct nf_conntrack_expect *, int, | 77 | void nf_ct_expect_init(struct nf_conntrack_expect *, int, |
76 | union nf_conntrack_address *, | 78 | union nf_inet_addr *, |
77 | union nf_conntrack_address *, | 79 | union nf_inet_addr *, |
78 | u_int8_t, __be16 *, __be16 *); | 80 | u_int8_t, __be16 *, __be16 *); |
79 | void nf_ct_expect_put(struct nf_conntrack_expect *exp); | 81 | void nf_ct_expect_put(struct nf_conntrack_expect *exp); |
80 | int nf_ct_expect_related(struct nf_conntrack_expect *expect); | 82 | int nf_ct_expect_related(struct nf_conntrack_expect *expect); |
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h index d7b2d5483a71..4ca125e9b3ce 100644 --- a/include/net/netfilter/nf_conntrack_helper.h +++ b/include/net/netfilter/nf_conntrack_helper.h | |||
@@ -43,12 +43,8 @@ extern struct nf_conntrack_helper * | |||
43 | __nf_ct_helper_find(const struct nf_conntrack_tuple *tuple); | 43 | __nf_ct_helper_find(const struct nf_conntrack_tuple *tuple); |
44 | 44 | ||
45 | extern struct nf_conntrack_helper * | 45 | extern struct nf_conntrack_helper * |
46 | nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple); | ||
47 | |||
48 | extern struct nf_conntrack_helper * | ||
49 | __nf_conntrack_helper_find_byname(const char *name); | 46 | __nf_conntrack_helper_find_byname(const char *name); |
50 | 47 | ||
51 | extern void nf_ct_helper_put(struct nf_conntrack_helper *helper); | ||
52 | extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); | 48 | extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); |
53 | extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); | 49 | extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); |
54 | 50 | ||
@@ -58,4 +54,8 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct) | |||
58 | { | 54 | { |
59 | return nf_ct_ext_find(ct, NF_CT_EXT_HELPER); | 55 | return nf_ct_ext_find(ct, NF_CT_EXT_HELPER); |
60 | } | 56 | } |
57 | |||
58 | extern int nf_conntrack_helper_init(void); | ||
59 | extern void nf_conntrack_helper_fini(void); | ||
60 | |||
61 | #endif /*_NF_CONNTRACK_HELPER_H*/ | 61 | #endif /*_NF_CONNTRACK_HELPER_H*/ |
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h index 15888fc7b72d..b886e3ae6cad 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h | |||
@@ -42,11 +42,8 @@ struct nf_conntrack_l3proto | |||
42 | int (*print_tuple)(struct seq_file *s, | 42 | int (*print_tuple)(struct seq_file *s, |
43 | const struct nf_conntrack_tuple *); | 43 | const struct nf_conntrack_tuple *); |
44 | 44 | ||
45 | /* Print out the private part of the conntrack. */ | ||
46 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | ||
47 | |||
48 | /* Returns verdict for packet, or -1 for invalid. */ | 45 | /* Returns verdict for packet, or -1 for invalid. */ |
49 | int (*packet)(struct nf_conn *conntrack, | 46 | int (*packet)(struct nf_conn *ct, |
50 | const struct sk_buff *skb, | 47 | const struct sk_buff *skb, |
51 | enum ip_conntrack_info ctinfo); | 48 | enum ip_conntrack_info ctinfo); |
52 | 49 | ||
@@ -54,7 +51,7 @@ struct nf_conntrack_l3proto | |||
54 | * Called when a new connection for this protocol found; | 51 | * Called when a new connection for this protocol found; |
55 | * returns TRUE if it's OK. If so, packet() called next. | 52 | * returns TRUE if it's OK. If so, packet() called next. |
56 | */ | 53 | */ |
57 | int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb); | 54 | int (*new)(struct nf_conn *ct, const struct sk_buff *skb); |
58 | 55 | ||
59 | /* | 56 | /* |
60 | * Called before tracking. | 57 | * Called before tracking. |
@@ -73,7 +70,7 @@ struct nf_conntrack_l3proto | |||
73 | 70 | ||
74 | #ifdef CONFIG_SYSCTL | 71 | #ifdef CONFIG_SYSCTL |
75 | struct ctl_table_header *ctl_table_header; | 72 | struct ctl_table_header *ctl_table_header; |
76 | struct ctl_table *ctl_table_path; | 73 | struct ctl_path *ctl_table_path; |
77 | struct ctl_table *ctl_table; | 74 | struct ctl_table *ctl_table; |
78 | #endif /* CONFIG_SYSCTL */ | 75 | #endif /* CONFIG_SYSCTL */ |
79 | 76 | ||
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index fb50c217ba0a..efc16eccddb1 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h | |||
@@ -23,9 +23,6 @@ struct nf_conntrack_l4proto | |||
23 | /* L4 Protocol number. */ | 23 | /* L4 Protocol number. */ |
24 | u_int8_t l4proto; | 24 | u_int8_t l4proto; |
25 | 25 | ||
26 | /* Protocol name */ | ||
27 | const char *name; | ||
28 | |||
29 | /* Try to fill in the third arg: dataoff is offset past network protocol | 26 | /* Try to fill in the third arg: dataoff is offset past network protocol |
30 | hdr. Return true if possible. */ | 27 | hdr. Return true if possible. */ |
31 | int (*pkt_to_tuple)(const struct sk_buff *skb, | 28 | int (*pkt_to_tuple)(const struct sk_buff *skb, |
@@ -38,15 +35,8 @@ struct nf_conntrack_l4proto | |||
38 | int (*invert_tuple)(struct nf_conntrack_tuple *inverse, | 35 | int (*invert_tuple)(struct nf_conntrack_tuple *inverse, |
39 | const struct nf_conntrack_tuple *orig); | 36 | const struct nf_conntrack_tuple *orig); |
40 | 37 | ||
41 | /* Print out the per-protocol part of the tuple. Return like seq_* */ | ||
42 | int (*print_tuple)(struct seq_file *s, | ||
43 | const struct nf_conntrack_tuple *); | ||
44 | |||
45 | /* Print out the private part of the conntrack. */ | ||
46 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | ||
47 | |||
48 | /* Returns verdict for packet, or -1 for invalid. */ | 38 | /* Returns verdict for packet, or -1 for invalid. */ |
49 | int (*packet)(struct nf_conn *conntrack, | 39 | int (*packet)(struct nf_conn *ct, |
50 | const struct sk_buff *skb, | 40 | const struct sk_buff *skb, |
51 | unsigned int dataoff, | 41 | unsigned int dataoff, |
52 | enum ip_conntrack_info ctinfo, | 42 | enum ip_conntrack_info ctinfo, |
@@ -55,16 +45,23 @@ struct nf_conntrack_l4proto | |||
55 | 45 | ||
56 | /* Called when a new connection for this protocol found; | 46 | /* Called when a new connection for this protocol found; |
57 | * returns TRUE if it's OK. If so, packet() called next. */ | 47 | * returns TRUE if it's OK. If so, packet() called next. */ |
58 | int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb, | 48 | int (*new)(struct nf_conn *ct, const struct sk_buff *skb, |
59 | unsigned int dataoff); | 49 | unsigned int dataoff); |
60 | 50 | ||
61 | /* Called when a conntrack entry is destroyed */ | 51 | /* Called when a conntrack entry is destroyed */ |
62 | void (*destroy)(struct nf_conn *conntrack); | 52 | void (*destroy)(struct nf_conn *ct); |
63 | 53 | ||
64 | int (*error)(struct sk_buff *skb, unsigned int dataoff, | 54 | int (*error)(struct sk_buff *skb, unsigned int dataoff, |
65 | enum ip_conntrack_info *ctinfo, | 55 | enum ip_conntrack_info *ctinfo, |
66 | int pf, unsigned int hooknum); | 56 | int pf, unsigned int hooknum); |
67 | 57 | ||
58 | /* Print out the per-protocol part of the tuple. Return like seq_* */ | ||
59 | int (*print_tuple)(struct seq_file *s, | ||
60 | const struct nf_conntrack_tuple *); | ||
61 | |||
62 | /* Print out the private part of the conntrack. */ | ||
63 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | ||
64 | |||
68 | /* convert protoinfo to nfnetink attributes */ | 65 | /* convert protoinfo to nfnetink attributes */ |
69 | int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, | 66 | int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, |
70 | const struct nf_conn *ct); | 67 | const struct nf_conn *ct); |
@@ -87,6 +84,8 @@ struct nf_conntrack_l4proto | |||
87 | struct ctl_table *ctl_compat_table; | 84 | struct ctl_table *ctl_compat_table; |
88 | #endif | 85 | #endif |
89 | #endif | 86 | #endif |
87 | /* Protocol name */ | ||
88 | const char *name; | ||
90 | 89 | ||
91 | /* Module (if any) which this is connected to. */ | 90 | /* Module (if any) which this is connected to. */ |
92 | struct module *me; | 91 | struct module *me; |
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h index c48e390f4b0f..e69ab2e87597 100644 --- a/include/net/netfilter/nf_conntrack_tuple.h +++ b/include/net/netfilter/nf_conntrack_tuple.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #ifndef _NF_CONNTRACK_TUPLE_H | 10 | #ifndef _NF_CONNTRACK_TUPLE_H |
11 | #define _NF_CONNTRACK_TUPLE_H | 11 | #define _NF_CONNTRACK_TUPLE_H |
12 | 12 | ||
13 | #include <linux/netfilter/x_tables.h> | ||
13 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | 14 | #include <linux/netfilter/nf_conntrack_tuple_common.h> |
14 | 15 | ||
15 | /* A `tuple' is a structure containing the information to uniquely | 16 | /* A `tuple' is a structure containing the information to uniquely |
@@ -20,15 +21,7 @@ | |||
20 | "non-manipulatable" lines, for the benefit of the NAT code. | 21 | "non-manipulatable" lines, for the benefit of the NAT code. |
21 | */ | 22 | */ |
22 | 23 | ||
23 | #define NF_CT_TUPLE_L3SIZE 4 | 24 | #define NF_CT_TUPLE_L3SIZE ARRAY_SIZE(((union nf_inet_addr *)NULL)->all) |
24 | |||
25 | /* The l3 protocol-specific manipulable parts of the tuple: always in | ||
26 | network order! */ | ||
27 | union nf_conntrack_address { | ||
28 | u_int32_t all[NF_CT_TUPLE_L3SIZE]; | ||
29 | __be32 ip; | ||
30 | __be32 ip6[4]; | ||
31 | }; | ||
32 | 25 | ||
33 | /* The protocol-specific manipulable parts of the tuple: always in | 26 | /* The protocol-specific manipulable parts of the tuple: always in |
34 | network order! */ | 27 | network order! */ |
@@ -57,7 +50,7 @@ union nf_conntrack_man_proto | |||
57 | /* The manipulable part of the tuple. */ | 50 | /* The manipulable part of the tuple. */ |
58 | struct nf_conntrack_man | 51 | struct nf_conntrack_man |
59 | { | 52 | { |
60 | union nf_conntrack_address u3; | 53 | union nf_inet_addr u3; |
61 | union nf_conntrack_man_proto u; | 54 | union nf_conntrack_man_proto u; |
62 | /* Layer 3 protocol */ | 55 | /* Layer 3 protocol */ |
63 | u_int16_t l3num; | 56 | u_int16_t l3num; |
@@ -70,7 +63,7 @@ struct nf_conntrack_tuple | |||
70 | 63 | ||
71 | /* These are the parts of the tuple which are fixed. */ | 64 | /* These are the parts of the tuple which are fixed. */ |
72 | struct { | 65 | struct { |
73 | union nf_conntrack_address u3; | 66 | union nf_inet_addr u3; |
74 | union { | 67 | union { |
75 | /* Add other protocols here. */ | 68 | /* Add other protocols here. */ |
76 | __be16 all; | 69 | __be16 all; |
@@ -103,7 +96,7 @@ struct nf_conntrack_tuple | |||
103 | struct nf_conntrack_tuple_mask | 96 | struct nf_conntrack_tuple_mask |
104 | { | 97 | { |
105 | struct { | 98 | struct { |
106 | union nf_conntrack_address u3; | 99 | union nf_inet_addr u3; |
107 | union nf_conntrack_man_proto u; | 100 | union nf_conntrack_man_proto u; |
108 | } src; | 101 | } src; |
109 | }; | 102 | }; |
@@ -139,34 +132,33 @@ struct nf_conntrack_tuple_hash | |||
139 | 132 | ||
140 | #endif /* __KERNEL__ */ | 133 | #endif /* __KERNEL__ */ |
141 | 134 | ||
142 | static inline int nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, | 135 | static inline int __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, |
143 | const struct nf_conntrack_tuple *t2) | 136 | const struct nf_conntrack_tuple *t2) |
144 | { | 137 | { |
145 | return (t1->src.u3.all[0] == t2->src.u3.all[0] && | 138 | return (t1->src.u3.all[0] == t2->src.u3.all[0] && |
146 | t1->src.u3.all[1] == t2->src.u3.all[1] && | 139 | t1->src.u3.all[1] == t2->src.u3.all[1] && |
147 | t1->src.u3.all[2] == t2->src.u3.all[2] && | 140 | t1->src.u3.all[2] == t2->src.u3.all[2] && |
148 | t1->src.u3.all[3] == t2->src.u3.all[3] && | 141 | t1->src.u3.all[3] == t2->src.u3.all[3] && |
149 | t1->src.u.all == t2->src.u.all && | 142 | t1->src.u.all == t2->src.u.all && |
150 | t1->src.l3num == t2->src.l3num && | 143 | t1->src.l3num == t2->src.l3num); |
151 | t1->dst.protonum == t2->dst.protonum); | ||
152 | } | 144 | } |
153 | 145 | ||
154 | static inline int nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, | 146 | static inline int __nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, |
155 | const struct nf_conntrack_tuple *t2) | 147 | const struct nf_conntrack_tuple *t2) |
156 | { | 148 | { |
157 | return (t1->dst.u3.all[0] == t2->dst.u3.all[0] && | 149 | return (t1->dst.u3.all[0] == t2->dst.u3.all[0] && |
158 | t1->dst.u3.all[1] == t2->dst.u3.all[1] && | 150 | t1->dst.u3.all[1] == t2->dst.u3.all[1] && |
159 | t1->dst.u3.all[2] == t2->dst.u3.all[2] && | 151 | t1->dst.u3.all[2] == t2->dst.u3.all[2] && |
160 | t1->dst.u3.all[3] == t2->dst.u3.all[3] && | 152 | t1->dst.u3.all[3] == t2->dst.u3.all[3] && |
161 | t1->dst.u.all == t2->dst.u.all && | 153 | t1->dst.u.all == t2->dst.u.all && |
162 | t1->src.l3num == t2->src.l3num && | ||
163 | t1->dst.protonum == t2->dst.protonum); | 154 | t1->dst.protonum == t2->dst.protonum); |
164 | } | 155 | } |
165 | 156 | ||
166 | static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, | 157 | static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, |
167 | const struct nf_conntrack_tuple *t2) | 158 | const struct nf_conntrack_tuple *t2) |
168 | { | 159 | { |
169 | return nf_ct_tuple_src_equal(t1, t2) && nf_ct_tuple_dst_equal(t1, t2); | 160 | return __nf_ct_tuple_src_equal(t1, t2) && |
161 | __nf_ct_tuple_dst_equal(t1, t2); | ||
170 | } | 162 | } |
171 | 163 | ||
172 | static inline int nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1, | 164 | static inline int nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1, |
@@ -206,7 +198,7 @@ static inline int nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t, | |||
206 | const struct nf_conntrack_tuple_mask *mask) | 198 | const struct nf_conntrack_tuple_mask *mask) |
207 | { | 199 | { |
208 | return nf_ct_tuple_src_mask_cmp(t, tuple, mask) && | 200 | return nf_ct_tuple_src_mask_cmp(t, tuple, mask) && |
209 | nf_ct_tuple_dst_equal(t, tuple); | 201 | __nf_ct_tuple_dst_equal(t, tuple); |
210 | } | 202 | } |
211 | 203 | ||
212 | #endif /* _NF_CONNTRACK_TUPLE_H */ | 204 | #endif /* _NF_CONNTRACK_TUPLE_H */ |
diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h new file mode 100644 index 000000000000..8c6b5ae45534 --- /dev/null +++ b/include/net/netfilter/nf_log.h | |||
@@ -0,0 +1,59 @@ | |||
1 | #ifndef _NF_LOG_H | ||
2 | #define _NF_LOG_H | ||
3 | |||
4 | /* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will | ||
5 | * disappear once iptables is replaced with pkttables. Please DO NOT use them | ||
6 | * for any new code! */ | ||
7 | #define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */ | ||
8 | #define NF_LOG_TCPOPT 0x02 /* Log TCP options */ | ||
9 | #define NF_LOG_IPOPT 0x04 /* Log IP options */ | ||
10 | #define NF_LOG_UID 0x08 /* Log UID owning local socket */ | ||
11 | #define NF_LOG_MASK 0x0f | ||
12 | |||
13 | #define NF_LOG_TYPE_LOG 0x01 | ||
14 | #define NF_LOG_TYPE_ULOG 0x02 | ||
15 | |||
16 | struct nf_loginfo { | ||
17 | u_int8_t type; | ||
18 | union { | ||
19 | struct { | ||
20 | u_int32_t copy_len; | ||
21 | u_int16_t group; | ||
22 | u_int16_t qthreshold; | ||
23 | } ulog; | ||
24 | struct { | ||
25 | u_int8_t level; | ||
26 | u_int8_t logflags; | ||
27 | } log; | ||
28 | } u; | ||
29 | }; | ||
30 | |||
31 | typedef void nf_logfn(unsigned int pf, | ||
32 | unsigned int hooknum, | ||
33 | const struct sk_buff *skb, | ||
34 | const struct net_device *in, | ||
35 | const struct net_device *out, | ||
36 | const struct nf_loginfo *li, | ||
37 | const char *prefix); | ||
38 | |||
39 | struct nf_logger { | ||
40 | struct module *me; | ||
41 | nf_logfn *logfn; | ||
42 | char *name; | ||
43 | }; | ||
44 | |||
45 | /* Function to register/unregister log function. */ | ||
46 | int nf_log_register(int pf, const struct nf_logger *logger); | ||
47 | void nf_log_unregister(const struct nf_logger *logger); | ||
48 | void nf_log_unregister_pf(int pf); | ||
49 | |||
50 | /* Calls the registered backend logging function */ | ||
51 | void nf_log_packet(int pf, | ||
52 | unsigned int hooknum, | ||
53 | const struct sk_buff *skb, | ||
54 | const struct net_device *in, | ||
55 | const struct net_device *out, | ||
56 | const struct nf_loginfo *li, | ||
57 | const char *fmt, ...) __attribute__ ((format(printf,7,8))); | ||
58 | |||
59 | #endif /* _NF_LOG_H */ | ||
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index 6ae52f7c9f55..9dc1039ff78b 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
@@ -12,7 +12,8 @@ enum nf_nat_manip_type | |||
12 | }; | 12 | }; |
13 | 13 | ||
14 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ | 14 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ |
15 | #define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN) | 15 | #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \ |
16 | (hooknum) != NF_INET_LOCAL_IN) | ||
16 | 17 | ||
17 | #define IP_NAT_RANGE_MAP_IPS 1 | 18 | #define IP_NAT_RANGE_MAP_IPS 1 |
18 | #define IP_NAT_RANGE_PROTO_SPECIFIED 2 | 19 | #define IP_NAT_RANGE_PROTO_SPECIFIED 2 |
@@ -79,7 +80,7 @@ struct nf_conn_nat | |||
79 | /* Set up the info structure to map into this range. */ | 80 | /* Set up the info structure to map into this range. */ |
80 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, | 81 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, |
81 | const struct nf_nat_range *range, | 82 | const struct nf_nat_range *range, |
82 | unsigned int hooknum); | 83 | enum nf_nat_manip_type maniptype); |
83 | 84 | ||
84 | /* Is this tuple already taken? (not by us)*/ | 85 | /* Is this tuple already taken? (not by us)*/ |
85 | extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, | 86 | extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, |
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h index 04578bfe23e1..4aa0edbb5b96 100644 --- a/include/net/netfilter/nf_nat_protocol.h +++ b/include/net/netfilter/nf_nat_protocol.h | |||
@@ -46,21 +46,21 @@ struct nf_nat_protocol | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | /* Protocol registration. */ | 48 | /* Protocol registration. */ |
49 | extern int nf_nat_protocol_register(struct nf_nat_protocol *proto); | 49 | extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); |
50 | extern void nf_nat_protocol_unregister(struct nf_nat_protocol *proto); | 50 | extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); |
51 | 51 | ||
52 | extern struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); | 52 | extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); |
53 | extern void nf_nat_proto_put(struct nf_nat_protocol *proto); | 53 | extern void nf_nat_proto_put(const struct nf_nat_protocol *proto); |
54 | 54 | ||
55 | /* Built-in protocols. */ | 55 | /* Built-in protocols. */ |
56 | extern struct nf_nat_protocol nf_nat_protocol_tcp; | 56 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; |
57 | extern struct nf_nat_protocol nf_nat_protocol_udp; | 57 | extern const struct nf_nat_protocol nf_nat_protocol_udp; |
58 | extern struct nf_nat_protocol nf_nat_protocol_icmp; | 58 | extern const struct nf_nat_protocol nf_nat_protocol_icmp; |
59 | extern struct nf_nat_protocol nf_nat_unknown_protocol; | 59 | extern const struct nf_nat_protocol nf_nat_unknown_protocol; |
60 | 60 | ||
61 | extern int init_protocols(void) __init; | 61 | extern int init_protocols(void) __init; |
62 | extern void cleanup_protocols(void); | 62 | extern void cleanup_protocols(void); |
63 | extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); | 63 | extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); |
64 | 64 | ||
65 | extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, | 65 | extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, |
66 | const struct nf_nat_range *range); | 66 | const struct nf_nat_range *range); |
diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h new file mode 100644 index 000000000000..d030044e9235 --- /dev/null +++ b/include/net/netfilter/nf_queue.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _NF_QUEUE_H | ||
2 | #define _NF_QUEUE_H | ||
3 | |||
4 | /* Each queued (to userspace) skbuff has one of these. */ | ||
5 | struct nf_queue_entry { | ||
6 | struct list_head list; | ||
7 | struct sk_buff *skb; | ||
8 | unsigned int id; | ||
9 | |||
10 | struct nf_hook_ops *elem; | ||
11 | int pf; | ||
12 | unsigned int hook; | ||
13 | struct net_device *indev; | ||
14 | struct net_device *outdev; | ||
15 | int (*okfn)(struct sk_buff *); | ||
16 | }; | ||
17 | |||
18 | #define nf_queue_entry_reroute(x) ((void *)x + sizeof(struct nf_queue_entry)) | ||
19 | |||
20 | /* Packet queuing */ | ||
21 | struct nf_queue_handler { | ||
22 | int (*outfn)(struct nf_queue_entry *entry, | ||
23 | unsigned int queuenum); | ||
24 | char *name; | ||
25 | }; | ||
26 | |||
27 | extern int nf_register_queue_handler(int pf, | ||
28 | const struct nf_queue_handler *qh); | ||
29 | extern int nf_unregister_queue_handler(int pf, | ||
30 | const struct nf_queue_handler *qh); | ||
31 | extern void nf_unregister_queue_handlers(const struct nf_queue_handler *qh); | ||
32 | extern void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict); | ||
33 | |||
34 | #endif /* _NF_QUEUE_H */ | ||
diff --git a/include/net/netfilter/xt_rateest.h b/include/net/netfilter/xt_rateest.h new file mode 100644 index 000000000000..65d594dffbff --- /dev/null +++ b/include/net/netfilter/xt_rateest.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _XT_RATEEST_H | ||
2 | #define _XT_RATEEST_H | ||
3 | |||
4 | struct xt_rateest { | ||
5 | struct hlist_node list; | ||
6 | char name[IFNAMSIZ]; | ||
7 | unsigned int refcnt; | ||
8 | spinlock_t lock; | ||
9 | struct gnet_estimator params; | ||
10 | struct gnet_stats_rate_est rstats; | ||
11 | struct gnet_stats_basic bstats; | ||
12 | }; | ||
13 | |||
14 | extern struct xt_rateest *xt_rateest_lookup(const char *name); | ||
15 | extern void xt_rateest_put(struct xt_rateest *est); | ||
16 | |||
17 | #endif /* _XT_RATEEST_H */ | ||
diff --git a/include/net/netlabel.h b/include/net/netlabel.h index 2e5b2f6f9fa0..b3213c7c5309 100644 --- a/include/net/netlabel.h +++ b/include/net/netlabel.h | |||
@@ -67,7 +67,11 @@ | |||
67 | * NetLabel NETLINK protocol | 67 | * NetLabel NETLINK protocol |
68 | */ | 68 | */ |
69 | 69 | ||
70 | #define NETLBL_PROTO_VERSION 1 | 70 | /* NetLabel NETLINK protocol version |
71 | * 1: initial version | ||
72 | * 2: added static labels for unlabeled connections | ||
73 | */ | ||
74 | #define NETLBL_PROTO_VERSION 2 | ||
71 | 75 | ||
72 | /* NetLabel NETLINK types/families */ | 76 | /* NetLabel NETLINK types/families */ |
73 | #define NETLBL_NLTYPE_NONE 0 | 77 | #define NETLBL_NLTYPE_NONE 0 |
@@ -105,17 +109,49 @@ struct netlbl_dom_map; | |||
105 | /* Domain mapping operations */ | 109 | /* Domain mapping operations */ |
106 | int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info); | 110 | int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info); |
107 | 111 | ||
108 | /* LSM security attributes */ | 112 | /* |
113 | * LSM security attributes | ||
114 | */ | ||
115 | |||
116 | /** | ||
117 | * struct netlbl_lsm_cache - NetLabel LSM security attribute cache | ||
118 | * @refcount: atomic reference counter | ||
119 | * @free: LSM supplied function to free the cache data | ||
120 | * @data: LSM supplied cache data | ||
121 | * | ||
122 | * Description: | ||
123 | * This structure is provided for LSMs which wish to make use of the NetLabel | ||
124 | * caching mechanism to store LSM specific data/attributes in the NetLabel | ||
125 | * cache. If the LSM has to perform a lot of translation from the NetLabel | ||
126 | * security attributes into it's own internal representation then the cache | ||
127 | * mechanism can provide a way to eliminate some or all of that translation | ||
128 | * overhead on a cache hit. | ||
129 | * | ||
130 | */ | ||
109 | struct netlbl_lsm_cache { | 131 | struct netlbl_lsm_cache { |
110 | atomic_t refcount; | 132 | atomic_t refcount; |
111 | void (*free) (const void *data); | 133 | void (*free) (const void *data); |
112 | void *data; | 134 | void *data; |
113 | }; | 135 | }; |
114 | /* The catmap bitmap field MUST be a power of two in length and large | 136 | |
137 | /** | ||
138 | * struct netlbl_lsm_secattr_catmap - NetLabel LSM secattr category bitmap | ||
139 | * @startbit: the value of the lowest order bit in the bitmap | ||
140 | * @bitmap: the category bitmap | ||
141 | * @next: pointer to the next bitmap "node" or NULL | ||
142 | * | ||
143 | * Description: | ||
144 | * This structure is used to represent category bitmaps. Due to the large | ||
145 | * number of categories supported by most labeling protocols it is not | ||
146 | * practical to transfer a full bitmap internally so NetLabel adopts a sparse | ||
147 | * bitmap structure modeled after SELinux's ebitmap structure. | ||
148 | * The catmap bitmap field MUST be a power of two in length and large | ||
115 | * enough to hold at least 240 bits. Special care (i.e. check the code!) | 149 | * enough to hold at least 240 bits. Special care (i.e. check the code!) |
116 | * should be used when changing these values as the LSM implementation | 150 | * should be used when changing these values as the LSM implementation |
117 | * probably has functions which rely on the sizes of these types to speed | 151 | * probably has functions which rely on the sizes of these types to speed |
118 | * processing. */ | 152 | * processing. |
153 | * | ||
154 | */ | ||
119 | #define NETLBL_CATMAP_MAPTYPE u64 | 155 | #define NETLBL_CATMAP_MAPTYPE u64 |
120 | #define NETLBL_CATMAP_MAPCNT 4 | 156 | #define NETLBL_CATMAP_MAPCNT 4 |
121 | #define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8) | 157 | #define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8) |
@@ -127,22 +163,48 @@ struct netlbl_lsm_secattr_catmap { | |||
127 | NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT]; | 163 | NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT]; |
128 | struct netlbl_lsm_secattr_catmap *next; | 164 | struct netlbl_lsm_secattr_catmap *next; |
129 | }; | 165 | }; |
166 | |||
167 | /** | ||
168 | * struct netlbl_lsm_secattr - NetLabel LSM security attributes | ||
169 | * @flags: indicate which attributes are contained in this structure | ||
170 | * @type: indicate the NLTYPE of the attributes | ||
171 | * @domain: the NetLabel LSM domain | ||
172 | * @cache: NetLabel LSM specific cache | ||
173 | * @attr.mls: MLS sensitivity label | ||
174 | * @attr.mls.cat: MLS category bitmap | ||
175 | * @attr.mls.lvl: MLS sensitivity level | ||
176 | * @attr.secid: LSM specific secid token | ||
177 | * | ||
178 | * Description: | ||
179 | * This structure is used to pass security attributes between NetLabel and the | ||
180 | * LSM modules. The flags field is used to specify which fields within the | ||
181 | * struct are valid and valid values can be created by bitwise OR'ing the | ||
182 | * NETLBL_SECATTR_* defines. The domain field is typically set by the LSM to | ||
183 | * specify domain specific configuration settings and is not usually used by | ||
184 | * NetLabel itself when returning security attributes to the LSM. | ||
185 | * | ||
186 | */ | ||
130 | #define NETLBL_SECATTR_NONE 0x00000000 | 187 | #define NETLBL_SECATTR_NONE 0x00000000 |
131 | #define NETLBL_SECATTR_DOMAIN 0x00000001 | 188 | #define NETLBL_SECATTR_DOMAIN 0x00000001 |
132 | #define NETLBL_SECATTR_CACHE 0x00000002 | 189 | #define NETLBL_SECATTR_CACHE 0x00000002 |
133 | #define NETLBL_SECATTR_MLS_LVL 0x00000004 | 190 | #define NETLBL_SECATTR_MLS_LVL 0x00000004 |
134 | #define NETLBL_SECATTR_MLS_CAT 0x00000008 | 191 | #define NETLBL_SECATTR_MLS_CAT 0x00000008 |
192 | #define NETLBL_SECATTR_SECID 0x00000010 | ||
135 | #define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \ | 193 | #define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \ |
136 | NETLBL_SECATTR_MLS_CAT) | 194 | NETLBL_SECATTR_MLS_CAT | \ |
195 | NETLBL_SECATTR_SECID) | ||
137 | struct netlbl_lsm_secattr { | 196 | struct netlbl_lsm_secattr { |
138 | u32 flags; | 197 | u32 flags; |
139 | 198 | u32 type; | |
140 | char *domain; | 199 | char *domain; |
141 | |||
142 | u32 mls_lvl; | ||
143 | struct netlbl_lsm_secattr_catmap *mls_cat; | ||
144 | |||
145 | struct netlbl_lsm_cache *cache; | 200 | struct netlbl_lsm_cache *cache; |
201 | union { | ||
202 | struct { | ||
203 | struct netlbl_lsm_secattr_catmap *cat; | ||
204 | u32 lvl; | ||
205 | } mls; | ||
206 | u32 secid; | ||
207 | } attr; | ||
146 | }; | 208 | }; |
147 | 209 | ||
148 | /* | 210 | /* |
@@ -231,10 +293,7 @@ static inline void netlbl_secattr_catmap_free( | |||
231 | */ | 293 | */ |
232 | static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr) | 294 | static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr) |
233 | { | 295 | { |
234 | secattr->flags = 0; | 296 | memset(secattr, 0, sizeof(*secattr)); |
235 | secattr->domain = NULL; | ||
236 | secattr->mls_cat = NULL; | ||
237 | secattr->cache = NULL; | ||
238 | } | 297 | } |
239 | 298 | ||
240 | /** | 299 | /** |
@@ -248,11 +307,11 @@ static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr) | |||
248 | */ | 307 | */ |
249 | static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr) | 308 | static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr) |
250 | { | 309 | { |
251 | if (secattr->cache) | ||
252 | netlbl_secattr_cache_free(secattr->cache); | ||
253 | kfree(secattr->domain); | 310 | kfree(secattr->domain); |
254 | if (secattr->mls_cat) | 311 | if (secattr->flags & NETLBL_SECATTR_CACHE) |
255 | netlbl_secattr_catmap_free(secattr->mls_cat); | 312 | netlbl_secattr_cache_free(secattr->cache); |
313 | if (secattr->flags & NETLBL_SECATTR_MLS_CAT) | ||
314 | netlbl_secattr_catmap_free(secattr->attr.mls.cat); | ||
256 | } | 315 | } |
257 | 316 | ||
258 | /** | 317 | /** |
@@ -300,7 +359,7 @@ int netlbl_secattr_catmap_setrng(struct netlbl_lsm_secattr_catmap *catmap, | |||
300 | gfp_t flags); | 359 | gfp_t flags); |
301 | 360 | ||
302 | /* | 361 | /* |
303 | * LSM protocol operations | 362 | * LSM protocol operations (NetLabel LSM/kernel API) |
304 | */ | 363 | */ |
305 | int netlbl_enabled(void); | 364 | int netlbl_enabled(void); |
306 | int netlbl_sock_setattr(struct sock *sk, | 365 | int netlbl_sock_setattr(struct sock *sk, |
@@ -308,6 +367,7 @@ int netlbl_sock_setattr(struct sock *sk, | |||
308 | int netlbl_sock_getattr(struct sock *sk, | 367 | int netlbl_sock_getattr(struct sock *sk, |
309 | struct netlbl_lsm_secattr *secattr); | 368 | struct netlbl_lsm_secattr *secattr); |
310 | int netlbl_skbuff_getattr(const struct sk_buff *skb, | 369 | int netlbl_skbuff_getattr(const struct sk_buff *skb, |
370 | u16 family, | ||
311 | struct netlbl_lsm_secattr *secattr); | 371 | struct netlbl_lsm_secattr *secattr); |
312 | void netlbl_skbuff_err(struct sk_buff *skb, int error); | 372 | void netlbl_skbuff_err(struct sk_buff *skb, int error); |
313 | 373 | ||
@@ -360,6 +420,7 @@ static inline int netlbl_sock_getattr(struct sock *sk, | |||
360 | return -ENOSYS; | 420 | return -ENOSYS; |
361 | } | 421 | } |
362 | static inline int netlbl_skbuff_getattr(const struct sk_buff *skb, | 422 | static inline int netlbl_skbuff_getattr(const struct sk_buff *skb, |
423 | u16 family, | ||
363 | struct netlbl_lsm_secattr *secattr) | 424 | struct netlbl_lsm_secattr *secattr) |
364 | { | 425 | { |
365 | return -ENOSYS; | 426 | return -ENOSYS; |
diff --git a/include/net/netlink.h b/include/net/netlink.h index 9298218c07f9..a5506c42f03c 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -91,6 +91,7 @@ | |||
91 | * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr | 91 | * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr |
92 | * nla_put(skb, type, len, data) add attribute to skb | 92 | * nla_put(skb, type, len, data) add attribute to skb |
93 | * nla_put_nohdr(skb, len, data) add attribute w/o hdr | 93 | * nla_put_nohdr(skb, len, data) add attribute w/o hdr |
94 | * nla_append(skb, len, data) append data to skb | ||
94 | * | 95 | * |
95 | * Attribute Construction for Basic Types: | 96 | * Attribute Construction for Basic Types: |
96 | * nla_put_u8(skb, type, value) add u8 attribute to skb | 97 | * nla_put_u8(skb, type, value) add u8 attribute to skb |
@@ -217,6 +218,7 @@ struct nla_policy { | |||
217 | */ | 218 | */ |
218 | struct nl_info { | 219 | struct nl_info { |
219 | struct nlmsghdr *nlh; | 220 | struct nlmsghdr *nlh; |
221 | struct net *nl_net; | ||
220 | u32 pid; | 222 | u32 pid; |
221 | }; | 223 | }; |
222 | 224 | ||
@@ -253,6 +255,8 @@ extern int nla_put(struct sk_buff *skb, int attrtype, | |||
253 | int attrlen, const void *data); | 255 | int attrlen, const void *data); |
254 | extern int nla_put_nohdr(struct sk_buff *skb, int attrlen, | 256 | extern int nla_put_nohdr(struct sk_buff *skb, int attrlen, |
255 | const void *data); | 257 | const void *data); |
258 | extern int nla_append(struct sk_buff *skb, int attrlen, | ||
259 | const void *data); | ||
256 | 260 | ||
257 | /************************************************************************** | 261 | /************************************************************************** |
258 | * Netlink Messages | 262 | * Netlink Messages |
@@ -862,7 +866,7 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, | |||
862 | 866 | ||
863 | #define NLA_PUT(skb, attrtype, attrlen, data) \ | 867 | #define NLA_PUT(skb, attrtype, attrlen, data) \ |
864 | do { \ | 868 | do { \ |
865 | if (nla_put(skb, attrtype, attrlen, data) < 0) \ | 869 | if (unlikely(nla_put(skb, attrtype, attrlen, data) < 0)) \ |
866 | goto nla_put_failure; \ | 870 | goto nla_put_failure; \ |
867 | } while(0) | 871 | } while(0) |
868 | 872 | ||
@@ -881,6 +885,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, | |||
881 | #define NLA_PUT_LE16(skb, attrtype, value) \ | 885 | #define NLA_PUT_LE16(skb, attrtype, value) \ |
882 | NLA_PUT_TYPE(skb, __le16, attrtype, value) | 886 | NLA_PUT_TYPE(skb, __le16, attrtype, value) |
883 | 887 | ||
888 | #define NLA_PUT_BE16(skb, attrtype, value) \ | ||
889 | NLA_PUT_TYPE(skb, __be16, attrtype, value) | ||
890 | |||
884 | #define NLA_PUT_U32(skb, attrtype, value) \ | 891 | #define NLA_PUT_U32(skb, attrtype, value) \ |
885 | NLA_PUT_TYPE(skb, u32, attrtype, value) | 892 | NLA_PUT_TYPE(skb, u32, attrtype, value) |
886 | 893 | ||
@@ -927,6 +934,15 @@ static inline u16 nla_get_u16(struct nlattr *nla) | |||
927 | } | 934 | } |
928 | 935 | ||
929 | /** | 936 | /** |
937 | * nla_get_be16 - return payload of __be16 attribute | ||
938 | * @nla: __be16 netlink attribute | ||
939 | */ | ||
940 | static inline __be16 nla_get_be16(struct nlattr *nla) | ||
941 | { | ||
942 | return *(__be16 *) nla_data(nla); | ||
943 | } | ||
944 | |||
945 | /** | ||
930 | * nla_get_le16 - return payload of __le16 attribute | 946 | * nla_get_le16 - return payload of __le16 attribute |
931 | * @nla: __le16 netlink attribute | 947 | * @nla: __le16 netlink attribute |
932 | */ | 948 | */ |
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h new file mode 100644 index 000000000000..a9b4f6086294 --- /dev/null +++ b/include/net/netns/ipv4.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * ipv4 in net namespaces | ||
3 | */ | ||
4 | |||
5 | #ifndef __NETNS_IPV4_H__ | ||
6 | #define __NETNS_IPV4_H__ | ||
7 | |||
8 | #include <net/inet_frag.h> | ||
9 | |||
10 | struct ctl_table_header; | ||
11 | struct ipv4_devconf; | ||
12 | struct fib_rules_ops; | ||
13 | struct hlist_head; | ||
14 | struct sock; | ||
15 | |||
16 | struct netns_ipv4 { | ||
17 | #ifdef CONFIG_SYSCTL | ||
18 | struct ctl_table_header *forw_hdr; | ||
19 | struct ctl_table_header *frags_hdr; | ||
20 | #endif | ||
21 | struct ipv4_devconf *devconf_all; | ||
22 | struct ipv4_devconf *devconf_dflt; | ||
23 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
24 | struct fib_rules_ops *rules_ops; | ||
25 | #endif | ||
26 | struct hlist_head *fib_table_hash; | ||
27 | struct sock *fibnl; | ||
28 | |||
29 | struct netns_frags frags; | ||
30 | #ifdef CONFIG_NETFILTER | ||
31 | struct xt_table *iptable_filter; | ||
32 | struct xt_table *iptable_mangle; | ||
33 | struct xt_table *iptable_raw; | ||
34 | struct xt_table *arptable_filter; | ||
35 | #endif | ||
36 | }; | ||
37 | #endif | ||
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h new file mode 100644 index 000000000000..1dd7de4e4195 --- /dev/null +++ b/include/net/netns/ipv6.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | * ipv6 in net namespaces | ||
3 | */ | ||
4 | |||
5 | #include <net/inet_frag.h> | ||
6 | |||
7 | #ifndef __NETNS_IPV6_H__ | ||
8 | #define __NETNS_IPV6_H__ | ||
9 | |||
10 | struct ctl_table_header; | ||
11 | |||
12 | struct netns_sysctl_ipv6 { | ||
13 | #ifdef CONFIG_SYSCTL | ||
14 | struct ctl_table_header *table; | ||
15 | struct ctl_table_header *frags_hdr; | ||
16 | #endif | ||
17 | int bindv6only; | ||
18 | int flush_delay; | ||
19 | int ip6_rt_max_size; | ||
20 | int ip6_rt_gc_min_interval; | ||
21 | int ip6_rt_gc_timeout; | ||
22 | int ip6_rt_gc_interval; | ||
23 | int ip6_rt_gc_elasticity; | ||
24 | int ip6_rt_mtu_expires; | ||
25 | int ip6_rt_min_advmss; | ||
26 | int icmpv6_time; | ||
27 | }; | ||
28 | |||
29 | struct netns_ipv6 { | ||
30 | struct netns_sysctl_ipv6 sysctl; | ||
31 | struct ipv6_devconf *devconf_all; | ||
32 | struct ipv6_devconf *devconf_dflt; | ||
33 | struct netns_frags frags; | ||
34 | #ifdef CONFIG_NETFILTER | ||
35 | struct xt_table *ip6table_filter; | ||
36 | struct xt_table *ip6table_mangle; | ||
37 | struct xt_table *ip6table_raw; | ||
38 | #endif | ||
39 | }; | ||
40 | #endif | ||
diff --git a/include/net/netns/packet.h b/include/net/netns/packet.h new file mode 100644 index 000000000000..637daf698884 --- /dev/null +++ b/include/net/netns/packet.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Packet network namespace | ||
3 | */ | ||
4 | #ifndef __NETNS_PACKET_H__ | ||
5 | #define __NETNS_PACKET_H__ | ||
6 | |||
7 | #include <linux/list.h> | ||
8 | #include <linux/spinlock.h> | ||
9 | |||
10 | struct netns_packet { | ||
11 | rwlock_t sklist_lock; | ||
12 | struct hlist_head sklist; | ||
13 | }; | ||
14 | |||
15 | #endif /* __NETNS_PACKET_H__ */ | ||
diff --git a/include/net/netns/unix.h b/include/net/netns/unix.h new file mode 100644 index 000000000000..284649d4dfb4 --- /dev/null +++ b/include/net/netns/unix.h | |||
@@ -0,0 +1,13 @@ | |||
1 | /* | ||
2 | * Unix network namespace | ||
3 | */ | ||
4 | #ifndef __NETNS_UNIX_H__ | ||
5 | #define __NETNS_UNIX_H__ | ||
6 | |||
7 | struct ctl_table_header; | ||
8 | struct netns_unix { | ||
9 | int sysctl_max_dgram_qlen; | ||
10 | struct ctl_table_header *ctl; | ||
11 | }; | ||
12 | |||
13 | #endif /* __NETNS_UNIX_H__ */ | ||
diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h new file mode 100644 index 000000000000..0cb63ed2c1fc --- /dev/null +++ b/include/net/netns/x_tables.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __NETNS_X_TABLES_H | ||
2 | #define __NETNS_X_TABLES_H | ||
3 | |||
4 | #include <linux/list.h> | ||
5 | #include <linux/net.h> | ||
6 | |||
7 | struct netns_xt { | ||
8 | struct list_head tables[NPROTO]; | ||
9 | }; | ||
10 | #endif | ||
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index f285de69c615..d349c66ef828 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define __NET_PKT_CLS_H | 2 | #define __NET_PKT_CLS_H |
3 | 3 | ||
4 | #include <linux/pkt_cls.h> | 4 | #include <linux/pkt_cls.h> |
5 | #include <net/net_namespace.h> | ||
6 | #include <net/sch_generic.h> | 5 | #include <net/sch_generic.h> |
7 | #include <net/act_api.h> | 6 | #include <net/act_api.h> |
8 | 7 | ||
@@ -130,16 +129,16 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, | |||
130 | return 0; | 129 | return 0; |
131 | } | 130 | } |
132 | 131 | ||
133 | extern int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, | 132 | extern int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb, |
134 | struct rtattr *rate_tlv, struct tcf_exts *exts, | 133 | struct nlattr *rate_tlv, struct tcf_exts *exts, |
135 | struct tcf_ext_map *map); | 134 | const struct tcf_ext_map *map); |
136 | extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts); | 135 | extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts); |
137 | extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, | 136 | extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, |
138 | struct tcf_exts *src); | 137 | struct tcf_exts *src); |
139 | extern int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, | 138 | extern int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, |
140 | struct tcf_ext_map *map); | 139 | const struct tcf_ext_map *map); |
141 | extern int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts, | 140 | extern int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts, |
142 | struct tcf_ext_map *map); | 141 | const struct tcf_ext_map *map); |
143 | 142 | ||
144 | /** | 143 | /** |
145 | * struct tcf_pkt_info - packet information | 144 | * struct tcf_pkt_info - packet information |
@@ -248,7 +247,7 @@ struct tcf_ematch_ops | |||
248 | 247 | ||
249 | extern int tcf_em_register(struct tcf_ematch_ops *); | 248 | extern int tcf_em_register(struct tcf_ematch_ops *); |
250 | extern int tcf_em_unregister(struct tcf_ematch_ops *); | 249 | extern int tcf_em_unregister(struct tcf_ematch_ops *); |
251 | extern int tcf_em_tree_validate(struct tcf_proto *, struct rtattr *, | 250 | extern int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *, |
252 | struct tcf_ematch_tree *); | 251 | struct tcf_ematch_tree *); |
253 | extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *); | 252 | extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *); |
254 | extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); | 253 | extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); |
@@ -336,10 +335,12 @@ static inline int tcf_valid_offset(const struct sk_buff *skb, | |||
336 | } | 335 | } |
337 | 336 | ||
338 | #ifdef CONFIG_NET_CLS_IND | 337 | #ifdef CONFIG_NET_CLS_IND |
338 | #include <net/net_namespace.h> | ||
339 | |||
339 | static inline int | 340 | static inline int |
340 | tcf_change_indev(struct tcf_proto *tp, char *indev, struct rtattr *indev_tlv) | 341 | tcf_change_indev(struct tcf_proto *tp, char *indev, struct nlattr *indev_tlv) |
341 | { | 342 | { |
342 | if (rtattr_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) | 343 | if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) |
343 | return -EINVAL; | 344 | return -EINVAL; |
344 | return 0; | 345 | return 0; |
345 | } | 346 | } |
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index ab61809a9616..46fb4d80c74a 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h | |||
@@ -77,7 +77,7 @@ extern int unregister_qdisc(struct Qdisc_ops *qops); | |||
77 | extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle); | 77 | extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle); |
78 | extern struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle); | 78 | extern struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle); |
79 | extern struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, | 79 | extern struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, |
80 | struct rtattr *tab); | 80 | struct nlattr *tab); |
81 | extern void qdisc_put_rtab(struct qdisc_rate_table *tab); | 81 | extern void qdisc_put_rtab(struct qdisc_rate_table *tab); |
82 | 82 | ||
83 | extern void __qdisc_run(struct net_device *dev); | 83 | extern void __qdisc_run(struct net_device *dev); |
diff --git a/include/net/protocol.h b/include/net/protocol.h index 1166ffb4b3ec..ad8c584233a6 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h | |||
@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(struct inet_protosw *p); | |||
102 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 102 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
103 | extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); | 103 | extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); |
104 | extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); | 104 | extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); |
105 | extern void inet6_register_protosw(struct inet_protosw *p); | 105 | extern int inet6_register_protosw(struct inet_protosw *p); |
106 | extern void inet6_unregister_protosw(struct inet_protosw *p); | 106 | extern void inet6_unregister_protosw(struct inet_protosw *p); |
107 | #endif | 107 | #endif |
108 | 108 | ||
diff --git a/include/net/raw.h b/include/net/raw.h index e4af59781949..1828f81fe374 100644 --- a/include/net/raw.h +++ b/include/net/raw.h | |||
@@ -22,27 +22,38 @@ | |||
22 | 22 | ||
23 | extern struct proto raw_prot; | 23 | extern struct proto raw_prot; |
24 | 24 | ||
25 | extern void raw_err(struct sock *, struct sk_buff *, u32 info); | 25 | void raw_icmp_error(struct sk_buff *, int, u32); |
26 | extern int raw_rcv(struct sock *, struct sk_buff *); | 26 | int raw_local_deliver(struct sk_buff *, int); |
27 | |||
28 | /* Note: v4 ICMP wants to get at this stuff, if you change the | ||
29 | * hashing mechanism, make sure you update icmp.c as well. | ||
30 | */ | ||
31 | #define RAWV4_HTABLE_SIZE MAX_INET_PROTOS | ||
32 | extern struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE]; | ||
33 | |||
34 | extern rwlock_t raw_v4_lock; | ||
35 | 27 | ||
28 | extern int raw_rcv(struct sock *, struct sk_buff *); | ||
36 | 29 | ||
37 | extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num, | 30 | #define RAW_HTABLE_SIZE MAX_INET_PROTOS |
38 | __be32 raddr, __be32 laddr, | ||
39 | int dif); | ||
40 | 31 | ||
41 | extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash); | 32 | struct raw_hashinfo { |
33 | rwlock_t lock; | ||
34 | struct hlist_head ht[RAW_HTABLE_SIZE]; | ||
35 | }; | ||
42 | 36 | ||
43 | #ifdef CONFIG_PROC_FS | 37 | #ifdef CONFIG_PROC_FS |
44 | extern int raw_proc_init(void); | 38 | extern int raw_proc_init(void); |
45 | extern void raw_proc_exit(void); | 39 | extern void raw_proc_exit(void); |
40 | |||
41 | struct raw_iter_state { | ||
42 | struct seq_net_private p; | ||
43 | int bucket; | ||
44 | struct raw_hashinfo *h; | ||
45 | }; | ||
46 | |||
47 | #define raw_seq_private(seq) ((struct raw_iter_state *)(seq)->private) | ||
48 | void *raw_seq_start(struct seq_file *seq, loff_t *pos); | ||
49 | void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos); | ||
50 | void raw_seq_stop(struct seq_file *seq, void *v); | ||
51 | int raw_seq_open(struct inode *ino, struct file *file, | ||
52 | struct raw_hashinfo *h, const struct seq_operations *ops); | ||
53 | |||
46 | #endif | 54 | #endif |
47 | 55 | ||
56 | void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h); | ||
57 | void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h); | ||
58 | |||
48 | #endif /* _RAW_H */ | 59 | #endif /* _RAW_H */ |
diff --git a/include/net/rawv6.h b/include/net/rawv6.h index a5819891d525..8a22599f26ba 100644 --- a/include/net/rawv6.h +++ b/include/net/rawv6.h | |||
@@ -5,26 +5,13 @@ | |||
5 | 5 | ||
6 | #include <net/protocol.h> | 6 | #include <net/protocol.h> |
7 | 7 | ||
8 | #define RAWV6_HTABLE_SIZE MAX_INET_PROTOS | 8 | void raw6_icmp_error(struct sk_buff *, int nexthdr, |
9 | extern struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; | 9 | int type, int code, int inner_offset, __be32); |
10 | extern rwlock_t raw_v6_lock; | 10 | int raw6_local_deliver(struct sk_buff *, int); |
11 | |||
12 | extern int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr); | ||
13 | |||
14 | extern struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num, | ||
15 | struct in6_addr *loc_addr, struct in6_addr *rmt_addr, | ||
16 | int dif); | ||
17 | 11 | ||
18 | extern int rawv6_rcv(struct sock *sk, | 12 | extern int rawv6_rcv(struct sock *sk, |
19 | struct sk_buff *skb); | 13 | struct sk_buff *skb); |
20 | 14 | ||
21 | |||
22 | extern void rawv6_err(struct sock *sk, | ||
23 | struct sk_buff *skb, | ||
24 | struct inet6_skb_parm *opt, | ||
25 | int type, int code, | ||
26 | int offset, __be32 info); | ||
27 | |||
28 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) | 15 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
29 | int rawv6_mh_filter_register(int (*filter)(struct sock *sock, | 16 | int rawv6_mh_filter_register(int (*filter)(struct sock *sock, |
30 | struct sk_buff *skb)); | 17 | struct sk_buff *skb)); |
diff --git a/include/net/request_sock.h b/include/net/request_sock.h index 7aed02ce2b65..cff4608179c1 100644 --- a/include/net/request_sock.h +++ b/include/net/request_sock.h | |||
@@ -124,23 +124,7 @@ struct request_sock_queue { | |||
124 | extern int reqsk_queue_alloc(struct request_sock_queue *queue, | 124 | extern int reqsk_queue_alloc(struct request_sock_queue *queue, |
125 | unsigned int nr_table_entries); | 125 | unsigned int nr_table_entries); |
126 | 126 | ||
127 | static inline struct listen_sock *reqsk_queue_yank_listen_sk(struct request_sock_queue *queue) | 127 | extern void __reqsk_queue_destroy(struct request_sock_queue *queue); |
128 | { | ||
129 | struct listen_sock *lopt; | ||
130 | |||
131 | write_lock_bh(&queue->syn_wait_lock); | ||
132 | lopt = queue->listen_opt; | ||
133 | queue->listen_opt = NULL; | ||
134 | write_unlock_bh(&queue->syn_wait_lock); | ||
135 | |||
136 | return lopt; | ||
137 | } | ||
138 | |||
139 | static inline void __reqsk_queue_destroy(struct request_sock_queue *queue) | ||
140 | { | ||
141 | kfree(reqsk_queue_yank_listen_sk(queue)); | ||
142 | } | ||
143 | |||
144 | extern void reqsk_queue_destroy(struct request_sock_queue *queue); | 128 | extern void reqsk_queue_destroy(struct request_sock_queue *queue); |
145 | 129 | ||
146 | static inline struct request_sock * | 130 | static inline struct request_sock * |
diff --git a/include/net/route.h b/include/net/route.h index f7ce6259f86f..eadad5901429 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -27,12 +27,14 @@ | |||
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 <linux/in_route.h> | 31 | #include <linux/in_route.h> |
31 | #include <linux/rtnetlink.h> | 32 | #include <linux/rtnetlink.h> |
32 | #include <linux/route.h> | 33 | #include <linux/route.h> |
33 | #include <linux/ip.h> | 34 | #include <linux/ip.h> |
34 | #include <linux/cache.h> | 35 | #include <linux/cache.h> |
35 | #include <linux/security.h> | 36 | #include <linux/security.h> |
37 | #include <net/sock.h> | ||
36 | 38 | ||
37 | #ifndef __KERNEL__ | 39 | #ifndef __KERNEL__ |
38 | #warning This file is not supposed to be used outside of kernel. | 40 | #warning This file is not supposed to be used outside of kernel. |
@@ -60,6 +62,7 @@ struct rtable | |||
60 | 62 | ||
61 | struct in_device *idev; | 63 | struct in_device *idev; |
62 | 64 | ||
65 | int rt_genid; | ||
63 | unsigned rt_flags; | 66 | unsigned rt_flags; |
64 | __u16 rt_type; | 67 | __u16 rt_type; |
65 | 68 | ||
@@ -109,18 +112,18 @@ struct in_device; | |||
109 | extern int ip_rt_init(void); | 112 | extern int ip_rt_init(void); |
110 | extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, | 113 | extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, |
111 | __be32 src, struct net_device *dev); | 114 | __be32 src, struct net_device *dev); |
112 | extern void ip_rt_advice(struct rtable **rp, int advice); | ||
113 | extern void rt_cache_flush(int how); | 115 | extern void rt_cache_flush(int how); |
114 | extern int __ip_route_output_key(struct rtable **, const struct flowi *flp); | 116 | extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp); |
115 | extern int ip_route_output_key(struct rtable **, struct flowi *flp); | 117 | extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); |
116 | extern int ip_route_output_flow(struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); | 118 | extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); |
117 | extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); | 119 | extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); |
118 | extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu); | 120 | extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu); |
119 | extern void ip_rt_send_redirect(struct sk_buff *skb); | 121 | extern void ip_rt_send_redirect(struct sk_buff *skb); |
120 | 122 | ||
121 | extern unsigned inet_addr_type(__be32 addr); | 123 | extern unsigned inet_addr_type(struct net *net, __be32 addr); |
124 | extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); | ||
122 | extern void ip_rt_multicast_event(struct in_device *); | 125 | extern void ip_rt_multicast_event(struct in_device *); |
123 | extern int ip_rt_ioctl(unsigned int cmd, void __user *arg); | 126 | extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); |
124 | extern void ip_rt_get_source(u8 *src, struct rtable *rt); | 127 | extern void ip_rt_get_source(u8 *src, struct rtable *rt); |
125 | extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); | 128 | extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); |
126 | 129 | ||
@@ -148,6 +151,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst, | |||
148 | int flags) | 151 | int flags) |
149 | { | 152 | { |
150 | struct flowi fl = { .oif = oif, | 153 | struct flowi fl = { .oif = oif, |
154 | .mark = sk->sk_mark, | ||
151 | .nl_u = { .ip4_u = { .daddr = dst, | 155 | .nl_u = { .ip4_u = { .daddr = dst, |
152 | .saddr = src, | 156 | .saddr = src, |
153 | .tos = tos } }, | 157 | .tos = tos } }, |
@@ -157,8 +161,9 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst, | |||
157 | .dport = dport } } }; | 161 | .dport = dport } } }; |
158 | 162 | ||
159 | int err; | 163 | int err; |
164 | struct net *net = sk->sk_net; | ||
160 | if (!dst || !src) { | 165 | if (!dst || !src) { |
161 | err = __ip_route_output_key(rp, &fl); | 166 | err = __ip_route_output_key(net, rp, &fl); |
162 | if (err) | 167 | if (err) |
163 | return err; | 168 | return err; |
164 | fl.fl4_dst = (*rp)->rt_dst; | 169 | fl.fl4_dst = (*rp)->rt_dst; |
@@ -167,7 +172,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst, | |||
167 | *rp = NULL; | 172 | *rp = NULL; |
168 | } | 173 | } |
169 | security_sk_classify_flow(sk, &fl); | 174 | security_sk_classify_flow(sk, &fl); |
170 | return ip_route_output_flow(rp, &fl, sk, flags); | 175 | return ip_route_output_flow(net, rp, &fl, sk, flags); |
171 | } | 176 | } |
172 | 177 | ||
173 | static inline int ip_route_newports(struct rtable **rp, u8 protocol, | 178 | static inline int ip_route_newports(struct rtable **rp, u8 protocol, |
@@ -184,7 +189,7 @@ static inline int ip_route_newports(struct rtable **rp, u8 protocol, | |||
184 | ip_rt_put(*rp); | 189 | ip_rt_put(*rp); |
185 | *rp = NULL; | 190 | *rp = NULL; |
186 | security_sk_classify_flow(sk, &fl); | 191 | security_sk_classify_flow(sk, &fl); |
187 | return ip_route_output_flow(rp, &fl, sk, 0); | 192 | return ip_route_output_flow(sk->sk_net, rp, &fl, sk, 0); |
188 | } | 193 | } |
189 | return 0; | 194 | return 0; |
190 | } | 195 | } |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index c9265518a378..ab502ec1c61c 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -66,7 +66,7 @@ struct Qdisc_class_ops | |||
66 | unsigned long (*get)(struct Qdisc *, u32 classid); | 66 | unsigned long (*get)(struct Qdisc *, u32 classid); |
67 | void (*put)(struct Qdisc *, unsigned long); | 67 | void (*put)(struct Qdisc *, unsigned long); |
68 | int (*change)(struct Qdisc *, u32, u32, | 68 | int (*change)(struct Qdisc *, u32, u32, |
69 | struct rtattr **, unsigned long *); | 69 | struct nlattr **, unsigned long *); |
70 | int (*delete)(struct Qdisc *, unsigned long); | 70 | int (*delete)(struct Qdisc *, unsigned long); |
71 | void (*walk)(struct Qdisc *, struct qdisc_walker * arg); | 71 | void (*walk)(struct Qdisc *, struct qdisc_walker * arg); |
72 | 72 | ||
@@ -86,7 +86,7 @@ struct Qdisc_class_ops | |||
86 | struct Qdisc_ops | 86 | struct Qdisc_ops |
87 | { | 87 | { |
88 | struct Qdisc_ops *next; | 88 | struct Qdisc_ops *next; |
89 | struct Qdisc_class_ops *cl_ops; | 89 | const struct Qdisc_class_ops *cl_ops; |
90 | char id[IFNAMSIZ]; | 90 | char id[IFNAMSIZ]; |
91 | int priv_size; | 91 | int priv_size; |
92 | 92 | ||
@@ -95,10 +95,10 @@ struct Qdisc_ops | |||
95 | int (*requeue)(struct sk_buff *, struct Qdisc *); | 95 | int (*requeue)(struct sk_buff *, struct Qdisc *); |
96 | unsigned int (*drop)(struct Qdisc *); | 96 | unsigned int (*drop)(struct Qdisc *); |
97 | 97 | ||
98 | int (*init)(struct Qdisc *, struct rtattr *arg); | 98 | int (*init)(struct Qdisc *, struct nlattr *arg); |
99 | void (*reset)(struct Qdisc *); | 99 | void (*reset)(struct Qdisc *); |
100 | void (*destroy)(struct Qdisc *); | 100 | void (*destroy)(struct Qdisc *); |
101 | int (*change)(struct Qdisc *, struct rtattr *arg); | 101 | int (*change)(struct Qdisc *, struct nlattr *arg); |
102 | 102 | ||
103 | int (*dump)(struct Qdisc *, struct sk_buff *); | 103 | int (*dump)(struct Qdisc *, struct sk_buff *); |
104 | int (*dump_stats)(struct Qdisc *, struct gnet_dump *); | 104 | int (*dump_stats)(struct Qdisc *, struct gnet_dump *); |
@@ -126,7 +126,7 @@ struct tcf_proto_ops | |||
126 | unsigned long (*get)(struct tcf_proto*, u32 handle); | 126 | unsigned long (*get)(struct tcf_proto*, u32 handle); |
127 | void (*put)(struct tcf_proto*, unsigned long); | 127 | void (*put)(struct tcf_proto*, unsigned long); |
128 | int (*change)(struct tcf_proto*, unsigned long, | 128 | int (*change)(struct tcf_proto*, unsigned long, |
129 | u32 handle, struct rtattr **, | 129 | u32 handle, struct nlattr **, |
130 | unsigned long *); | 130 | unsigned long *); |
131 | int (*delete)(struct tcf_proto*, unsigned long); | 131 | int (*delete)(struct tcf_proto*, unsigned long); |
132 | void (*walk)(struct tcf_proto*, struct tcf_walker *arg); | 132 | void (*walk)(struct tcf_proto*, struct tcf_walker *arg); |
@@ -325,7 +325,6 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask) | |||
325 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); | 325 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); |
326 | n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); | 326 | n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); |
327 | n->tc_verd = CLR_TC_MUNGED(n->tc_verd); | 327 | n->tc_verd = CLR_TC_MUNGED(n->tc_verd); |
328 | n->iif = skb->iif; | ||
329 | } | 328 | } |
330 | return n; | 329 | return n; |
331 | } | 330 | } |
diff --git a/include/net/sctp/auth.h b/include/net/sctp/auth.h index 9e8f13b7da5a..5db261a1e85e 100644 --- a/include/net/sctp/auth.h +++ b/include/net/sctp/auth.h | |||
@@ -103,7 +103,7 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc); | |||
103 | void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc, | 103 | void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc, |
104 | struct sctp_hmac_algo_param *hmacs); | 104 | struct sctp_hmac_algo_param *hmacs); |
105 | int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc, | 105 | int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc, |
106 | __u16 hmac_id); | 106 | __be16 hmac_id); |
107 | int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc); | 107 | int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc); |
108 | int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc); | 108 | int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc); |
109 | void sctp_auth_calculate_hmac(const struct sctp_association *asoc, | 109 | void sctp_auth_calculate_hmac(const struct sctp_association *asoc, |
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h new file mode 100644 index 000000000000..ba75c67cb992 --- /dev/null +++ b/include/net/sctp/checksum.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* SCTP kernel reference Implementation | ||
2 | * Copyright (c) 1999-2001 Motorola, Inc. | ||
3 | * Copyright (c) 2001-2003 International Business Machines, Corp. | ||
4 | * | ||
5 | * This file is part of the SCTP kernel reference Implementation | ||
6 | * | ||
7 | * SCTP Checksum functions | ||
8 | * | ||
9 | * The SCTP reference implementation is free software; | ||
10 | * you can redistribute it and/or modify it under the terms of | ||
11 | * the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2, or (at your option) | ||
13 | * any later version. | ||
14 | * | ||
15 | * The SCTP reference implementation is distributed in the hope that it | ||
16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
17 | * ************************ | ||
18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
19 | * See the GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with GNU CC; see the file COPYING. If not, write to | ||
23 | * the Free Software Foundation, 59 Temple Place - Suite 330, | ||
24 | * Boston, MA 02111-1307, USA. | ||
25 | * | ||
26 | * Please send any bug reports or fixes you make to the | ||
27 | * email address(es): | ||
28 | * lksctp developers <lksctp-developers@lists.sourceforge.net> | ||
29 | * | ||
30 | * Or submit a bug report through the following website: | ||
31 | * http://www.sf.net/projects/lksctp | ||
32 | * | ||
33 | * Written or modified by: | ||
34 | * Dinakaran Joseph | ||
35 | * Jon Grimm <jgrimm@us.ibm.com> | ||
36 | * Sridhar Samudrala <sri@us.ibm.com> | ||
37 | * | ||
38 | * Rewritten to use libcrc32c by: | ||
39 | * Vlad Yasevich <vladislav.yasevich@hp.com> | ||
40 | * | ||
41 | * Any bugs reported given to us we will try to fix... any fixes shared will | ||
42 | * be incorporated into the next SCTP release. | ||
43 | */ | ||
44 | |||
45 | #include <linux/types.h> | ||
46 | #include <net/sctp/sctp.h> | ||
47 | #include <linux/crc32c.h> | ||
48 | |||
49 | static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length) | ||
50 | { | ||
51 | __u32 crc = ~(__u32) 0; | ||
52 | __u8 zero[sizeof(__u32)] = {0}; | ||
53 | |||
54 | /* Optimize this routine to be SCTP specific, knowing how | ||
55 | * to skip the checksum field of the SCTP header. | ||
56 | */ | ||
57 | |||
58 | /* Calculate CRC up to the checksum. */ | ||
59 | crc = crc32c(crc, buffer, sizeof(struct sctphdr) - sizeof(__u32)); | ||
60 | |||
61 | /* Skip checksum field of the header. */ | ||
62 | crc = crc32c(crc, zero, sizeof(__u32)); | ||
63 | |||
64 | /* Calculate the rest of the CRC. */ | ||
65 | crc = crc32c(crc, &buffer[sizeof(struct sctphdr)], | ||
66 | length - sizeof(struct sctphdr)); | ||
67 | return crc; | ||
68 | } | ||
69 | |||
70 | static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32) | ||
71 | { | ||
72 | return crc32c(crc32, buffer, length); | ||
73 | } | ||
74 | |||
75 | static inline __u32 sctp_end_cksum(__u32 crc32) | ||
76 | { | ||
77 | return ntohl(~crc32); | ||
78 | } | ||
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h index b8733364557f..c1f797673571 100644 --- a/include/net/sctp/command.h +++ b/include/net/sctp/command.h | |||
@@ -103,6 +103,7 @@ typedef enum { | |||
103 | SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */ | 103 | SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */ |
104 | SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */ | 104 | SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */ |
105 | SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */ | 105 | SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */ |
106 | SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */ | ||
106 | SCTP_CMD_LAST | 107 | SCTP_CMD_LAST |
107 | } sctp_verb_t; | 108 | } sctp_verb_t; |
108 | 109 | ||
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h index da8354e8e33c..fefcba67bd1e 100644 --- a/include/net/sctp/constants.h +++ b/include/net/sctp/constants.h | |||
@@ -186,6 +186,8 @@ typedef enum { | |||
186 | SCTP_IERROR_AUTH_BAD_HMAC, | 186 | SCTP_IERROR_AUTH_BAD_HMAC, |
187 | SCTP_IERROR_AUTH_BAD_KEYID, | 187 | SCTP_IERROR_AUTH_BAD_KEYID, |
188 | SCTP_IERROR_PROTO_VIOLATION, | 188 | SCTP_IERROR_PROTO_VIOLATION, |
189 | SCTP_IERROR_ERROR, | ||
190 | SCTP_IERROR_ABORT, | ||
189 | } sctp_ierror_t; | 191 | } sctp_ierror_t; |
190 | 192 | ||
191 | 193 | ||
@@ -363,36 +365,12 @@ typedef enum { | |||
363 | * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP | 365 | * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP |
364 | * addresses. | 366 | * addresses. |
365 | */ | 367 | */ |
366 | #define IS_IPV4_UNUSABLE_ADDRESS(a) \ | 368 | #define IS_IPV4_UNUSABLE_ADDRESS(a) \ |
367 | ((htonl(INADDR_BROADCAST) == *a) || \ | 369 | ((htonl(INADDR_BROADCAST) == a) || \ |
368 | (MULTICAST(*a)) || \ | 370 | ipv4_is_multicast(a) || \ |
369 | (((unsigned char *)(a))[0] == 0) || \ | 371 | ipv4_is_zeronet(a) || \ |
370 | ((((unsigned char *)(a))[0] == 198) && \ | 372 | ipv4_is_test_198(a) || \ |
371 | (((unsigned char *)(a))[1] == 18) && \ | 373 | ipv4_is_anycast_6to4(a)) |
372 | (((unsigned char *)(a))[2] == 0)) || \ | ||
373 | ((((unsigned char *)(a))[0] == 192) && \ | ||
374 | (((unsigned char *)(a))[1] == 88) && \ | ||
375 | (((unsigned char *)(a))[2] == 99))) | ||
376 | |||
377 | /* IPv4 Link-local addresses: 169.254.0.0/16. */ | ||
378 | #define IS_IPV4_LINK_ADDRESS(a) \ | ||
379 | ((((unsigned char *)(a))[0] == 169) && \ | ||
380 | (((unsigned char *)(a))[1] == 254)) | ||
381 | |||
382 | /* RFC 1918 "Address Allocation for Private Internets" defines the IPv4 | ||
383 | * private address space as the following: | ||
384 | * | ||
385 | * 10.0.0.0 - 10.255.255.255 (10/8 prefix) | ||
386 | * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix) | ||
387 | * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) | ||
388 | */ | ||
389 | #define IS_IPV4_PRIVATE_ADDRESS(a) \ | ||
390 | ((((unsigned char *)(a))[0] == 10) || \ | ||
391 | ((((unsigned char *)(a))[0] == 172) && \ | ||
392 | (((unsigned char *)(a))[1] >= 16) && \ | ||
393 | (((unsigned char *)(a))[1] < 32)) || \ | ||
394 | ((((unsigned char *)(a))[0] == 192) && \ | ||
395 | (((unsigned char *)(a))[1] == 168))) | ||
396 | 374 | ||
397 | /* Flags used for the bind address copy functions. */ | 375 | /* Flags used for the bind address copy functions. */ |
398 | #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by | 376 | #define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by |
@@ -407,6 +385,7 @@ typedef enum { | |||
407 | SCTP_RTXR_T3_RTX, | 385 | SCTP_RTXR_T3_RTX, |
408 | SCTP_RTXR_FAST_RTX, | 386 | SCTP_RTXR_FAST_RTX, |
409 | SCTP_RTXR_PMTUD, | 387 | SCTP_RTXR_PMTUD, |
388 | SCTP_RTXR_T1_RTX, | ||
410 | } sctp_retransmit_reason_t; | 389 | } sctp_retransmit_reason_t; |
411 | 390 | ||
412 | /* Reasons to lower cwnd. */ | 391 | /* Reasons to lower cwnd. */ |
@@ -438,11 +417,14 @@ enum { | |||
438 | SCTP_AUTH_HMAC_ID_RESERVED_0, | 417 | SCTP_AUTH_HMAC_ID_RESERVED_0, |
439 | SCTP_AUTH_HMAC_ID_SHA1, | 418 | SCTP_AUTH_HMAC_ID_SHA1, |
440 | SCTP_AUTH_HMAC_ID_RESERVED_2, | 419 | SCTP_AUTH_HMAC_ID_RESERVED_2, |
441 | SCTP_AUTH_HMAC_ID_SHA256 | 420 | #if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE) |
421 | SCTP_AUTH_HMAC_ID_SHA256, | ||
422 | #endif | ||
423 | __SCTP_AUTH_HMAC_MAX | ||
442 | }; | 424 | }; |
443 | 425 | ||
444 | #define SCTP_AUTH_HMAC_ID_MAX SCTP_AUTH_HMAC_ID_SHA256 | 426 | #define SCTP_AUTH_HMAC_ID_MAX __SCTP_AUTH_HMAC_MAX - 1 |
445 | #define SCTP_AUTH_NUM_HMACS (SCTP_AUTH_HMAC_ID_SHA256 + 1) | 427 | #define SCTP_AUTH_NUM_HMACS __SCTP_AUTH_HMAC_MAX |
446 | #define SCTP_SHA1_SIG_SIZE 20 | 428 | #define SCTP_SHA1_SIG_SIZE 20 |
447 | #define SCTP_SHA256_SIG_SIZE 32 | 429 | #define SCTP_SHA256_SIG_SIZE 32 |
448 | 430 | ||
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 93eb708609e7..4977b0a81535 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -65,7 +65,6 @@ | |||
65 | 65 | ||
66 | 66 | ||
67 | #ifdef TEST_FRAME | 67 | #ifdef TEST_FRAME |
68 | #undef CONFIG_PROC_FS | ||
69 | #undef CONFIG_SCTP_DBG_OBJCNT | 68 | #undef CONFIG_SCTP_DBG_OBJCNT |
70 | #undef CONFIG_SYSCTL | 69 | #undef CONFIG_SYSCTL |
71 | #endif /* TEST_FRAME */ | 70 | #endif /* TEST_FRAME */ |
@@ -151,13 +150,6 @@ int sctp_primitive_REQUESTHEARTBEAT(struct sctp_association *, void *arg); | |||
151 | int sctp_primitive_ASCONF(struct sctp_association *, void *arg); | 150 | int sctp_primitive_ASCONF(struct sctp_association *, void *arg); |
152 | 151 | ||
153 | /* | 152 | /* |
154 | * sctp/crc32c.c | ||
155 | */ | ||
156 | __u32 sctp_start_cksum(__u8 *ptr, __u16 count); | ||
157 | __u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 cksum); | ||
158 | __u32 sctp_end_cksum(__u32 cksum); | ||
159 | |||
160 | /* | ||
161 | * sctp/input.c | 153 | * sctp/input.c |
162 | */ | 154 | */ |
163 | int sctp_rcv(struct sk_buff *skb); | 155 | int sctp_rcv(struct sk_buff *skb); |
@@ -267,6 +259,7 @@ enum | |||
267 | SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS, | 259 | SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS, |
268 | SCTP_MIB_DELAY_SACK_EXPIREDS, | 260 | SCTP_MIB_DELAY_SACK_EXPIREDS, |
269 | SCTP_MIB_AUTOCLOSE_EXPIREDS, | 261 | SCTP_MIB_AUTOCLOSE_EXPIREDS, |
262 | SCTP_MIB_T1_RETRANSMITS, | ||
270 | SCTP_MIB_T3_RETRANSMITS, | 263 | SCTP_MIB_T3_RETRANSMITS, |
271 | SCTP_MIB_PMTUD_RETRANSMITS, | 264 | SCTP_MIB_PMTUD_RETRANSMITS, |
272 | SCTP_MIB_FAST_RETRANSMITS, | 265 | SCTP_MIB_FAST_RETRANSMITS, |
@@ -470,8 +463,7 @@ static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) | |||
470 | skb->destructor = sctp_sock_rfree; | 463 | skb->destructor = sctp_sock_rfree; |
471 | atomic_add(event->rmem_len, &sk->sk_rmem_alloc); | 464 | atomic_add(event->rmem_len, &sk->sk_rmem_alloc); |
472 | /* | 465 | /* |
473 | * This mimics the behavior of | 466 | * This mimics the behavior of skb_set_owner_r |
474 | * sk_stream_set_owner_r | ||
475 | */ | 467 | */ |
476 | sk->sk_forward_alloc -= event->rmem_len; | 468 | sk->sk_forward_alloc -= event->rmem_len; |
477 | } | 469 | } |
@@ -664,6 +656,9 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag) | |||
664 | return (h & (sctp_assoc_hashsize-1)); | 656 | return (h & (sctp_assoc_hashsize-1)); |
665 | } | 657 | } |
666 | 658 | ||
659 | #define sctp_for_each_hentry(epb, node, head) \ | ||
660 | hlist_for_each_entry(epb, node, head, node) | ||
661 | |||
667 | /* Is a socket of this style? */ | 662 | /* Is a socket of this style? */ |
668 | #define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) | 663 | #define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) |
669 | static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style) | 664 | static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style) |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index ef892e00c833..4d591bfce452 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -100,20 +100,19 @@ struct crypto_hash; | |||
100 | struct sctp_bind_bucket { | 100 | struct sctp_bind_bucket { |
101 | unsigned short port; | 101 | unsigned short port; |
102 | unsigned short fastreuse; | 102 | unsigned short fastreuse; |
103 | struct sctp_bind_bucket *next; | 103 | struct hlist_node node; |
104 | struct sctp_bind_bucket **pprev; | ||
105 | struct hlist_head owner; | 104 | struct hlist_head owner; |
106 | }; | 105 | }; |
107 | 106 | ||
108 | struct sctp_bind_hashbucket { | 107 | struct sctp_bind_hashbucket { |
109 | spinlock_t lock; | 108 | spinlock_t lock; |
110 | struct sctp_bind_bucket *chain; | 109 | struct hlist_head chain; |
111 | }; | 110 | }; |
112 | 111 | ||
113 | /* Used for hashing all associations. */ | 112 | /* Used for hashing all associations. */ |
114 | struct sctp_hashbucket { | 113 | struct sctp_hashbucket { |
115 | rwlock_t lock; | 114 | rwlock_t lock; |
116 | struct sctp_ep_common *chain; | 115 | struct hlist_head chain; |
117 | } __attribute__((__aligned__(8))); | 116 | } __attribute__((__aligned__(8))); |
118 | 117 | ||
119 | 118 | ||
@@ -212,6 +211,7 @@ extern struct sctp_globals { | |||
212 | 211 | ||
213 | /* Flag to indicate if addip is enabled. */ | 212 | /* Flag to indicate if addip is enabled. */ |
214 | int addip_enable; | 213 | int addip_enable; |
214 | int addip_noauth_enable; | ||
215 | 215 | ||
216 | /* Flag to indicate if PR-SCTP is enabled. */ | 216 | /* Flag to indicate if PR-SCTP is enabled. */ |
217 | int prsctp_enable; | 217 | int prsctp_enable; |
@@ -249,6 +249,7 @@ extern struct sctp_globals { | |||
249 | #define sctp_local_addr_list (sctp_globals.local_addr_list) | 249 | #define sctp_local_addr_list (sctp_globals.local_addr_list) |
250 | #define sctp_local_addr_lock (sctp_globals.addr_list_lock) | 250 | #define sctp_local_addr_lock (sctp_globals.addr_list_lock) |
251 | #define sctp_addip_enable (sctp_globals.addip_enable) | 251 | #define sctp_addip_enable (sctp_globals.addip_enable) |
252 | #define sctp_addip_noauth (sctp_globals.addip_noauth_enable) | ||
252 | #define sctp_prsctp_enable (sctp_globals.prsctp_enable) | 253 | #define sctp_prsctp_enable (sctp_globals.prsctp_enable) |
253 | #define sctp_auth_enable (sctp_globals.auth_enable) | 254 | #define sctp_auth_enable (sctp_globals.auth_enable) |
254 | 255 | ||
@@ -300,7 +301,7 @@ struct sctp_sock { | |||
300 | /* The default SACK delay timeout for new associations. */ | 301 | /* The default SACK delay timeout for new associations. */ |
301 | __u32 sackdelay; | 302 | __u32 sackdelay; |
302 | 303 | ||
303 | /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ | 304 | /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ |
304 | __u32 param_flags; | 305 | __u32 param_flags; |
305 | 306 | ||
306 | struct sctp_initmsg initmsg; | 307 | struct sctp_initmsg initmsg; |
@@ -450,6 +451,7 @@ union sctp_params { | |||
450 | struct sctp_random_param *random; | 451 | struct sctp_random_param *random; |
451 | struct sctp_chunks_param *chunks; | 452 | struct sctp_chunks_param *chunks; |
452 | struct sctp_hmac_algo_param *hmac_algo; | 453 | struct sctp_hmac_algo_param *hmac_algo; |
454 | struct sctp_addip_param *addip; | ||
453 | }; | 455 | }; |
454 | 456 | ||
455 | /* RFC 2960. Section 3.3.5 Heartbeat. | 457 | /* RFC 2960. Section 3.3.5 Heartbeat. |
@@ -742,6 +744,7 @@ struct sctp_chunk { | |||
742 | __u8 tsn_missing_report; /* Data chunk missing counter. */ | 744 | __u8 tsn_missing_report; /* Data chunk missing counter. */ |
743 | __u8 data_accepted; /* At least 1 chunk in this packet accepted */ | 745 | __u8 data_accepted; /* At least 1 chunk in this packet accepted */ |
744 | __u8 auth; /* IN: was auth'ed | OUT: needs auth */ | 746 | __u8 auth; /* IN: was auth'ed | OUT: needs auth */ |
747 | __u8 has_asconf; /* IN: have seen an asconf before */ | ||
745 | }; | 748 | }; |
746 | 749 | ||
747 | void sctp_chunk_hold(struct sctp_chunk *); | 750 | void sctp_chunk_hold(struct sctp_chunk *); |
@@ -757,12 +760,18 @@ void sctp_init_addrs(struct sctp_chunk *, union sctp_addr *, | |||
757 | union sctp_addr *); | 760 | union sctp_addr *); |
758 | const union sctp_addr *sctp_source(const struct sctp_chunk *chunk); | 761 | const union sctp_addr *sctp_source(const struct sctp_chunk *chunk); |
759 | 762 | ||
763 | enum { | ||
764 | SCTP_ADDR_NEW, /* new address added to assoc/ep */ | ||
765 | SCTP_ADDR_SRC, /* address can be used as source */ | ||
766 | SCTP_ADDR_DEL, /* address about to be deleted */ | ||
767 | }; | ||
768 | |||
760 | /* This is a structure for holding either an IPv6 or an IPv4 address. */ | 769 | /* This is a structure for holding either an IPv6 or an IPv4 address. */ |
761 | struct sctp_sockaddr_entry { | 770 | struct sctp_sockaddr_entry { |
762 | struct list_head list; | 771 | struct list_head list; |
763 | struct rcu_head rcu; | 772 | struct rcu_head rcu; |
764 | union sctp_addr a; | 773 | union sctp_addr a; |
765 | __u8 use_as_src; | 774 | __u8 state; |
766 | __u8 valid; | 775 | __u8 valid; |
767 | }; | 776 | }; |
768 | 777 | ||
@@ -873,10 +882,11 @@ struct sctp_transport { | |||
873 | * address list derived from the INIT or INIT ACK chunk, a | 882 | * address list derived from the INIT or INIT ACK chunk, a |
874 | * number of data elements needs to be maintained including: | 883 | * number of data elements needs to be maintained including: |
875 | */ | 884 | */ |
876 | __u32 rtt; /* This is the most recent RTT. */ | ||
877 | |||
878 | /* RTO : The current retransmission timeout value. */ | 885 | /* RTO : The current retransmission timeout value. */ |
879 | unsigned long rto; | 886 | unsigned long rto; |
887 | unsigned long last_rto; | ||
888 | |||
889 | __u32 rtt; /* This is the most recent RTT. */ | ||
880 | 890 | ||
881 | /* RTTVAR : The current RTT variation. */ | 891 | /* RTTVAR : The current RTT variation. */ |
882 | __u32 rttvar; | 892 | __u32 rttvar; |
@@ -953,7 +963,7 @@ struct sctp_transport { | |||
953 | /* PMTU : The current known path MTU. */ | 963 | /* PMTU : The current known path MTU. */ |
954 | __u32 pathmtu; | 964 | __u32 pathmtu; |
955 | 965 | ||
956 | /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ | 966 | /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ |
957 | __u32 param_flags; | 967 | __u32 param_flags; |
958 | 968 | ||
959 | /* The number of times INIT has been sent on this transport. */ | 969 | /* The number of times INIT has been sent on this transport. */ |
@@ -1182,13 +1192,16 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | |||
1182 | const struct sctp_bind_addr *src, | 1192 | const struct sctp_bind_addr *src, |
1183 | sctp_scope_t scope, gfp_t gfp, | 1193 | sctp_scope_t scope, gfp_t gfp, |
1184 | int flags); | 1194 | int flags); |
1195 | int sctp_bind_addr_dup(struct sctp_bind_addr *dest, | ||
1196 | const struct sctp_bind_addr *src, | ||
1197 | gfp_t gfp); | ||
1185 | int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, | 1198 | int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, |
1186 | __u8 use_as_src, gfp_t gfp); | 1199 | __u8 addr_state, gfp_t gfp); |
1187 | int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *, | 1200 | int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *); |
1188 | void fastcall (*rcu_call)(struct rcu_head *, | ||
1189 | void (*func)(struct rcu_head *))); | ||
1190 | int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, | 1201 | int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, |
1191 | struct sctp_sock *); | 1202 | struct sctp_sock *); |
1203 | int sctp_bind_addr_state(const struct sctp_bind_addr *bp, | ||
1204 | const union sctp_addr *addr); | ||
1192 | union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, | 1205 | union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, |
1193 | const union sctp_addr *addrs, | 1206 | const union sctp_addr *addrs, |
1194 | int addrcnt, | 1207 | int addrcnt, |
@@ -1229,8 +1242,7 @@ typedef enum { | |||
1229 | 1242 | ||
1230 | struct sctp_ep_common { | 1243 | struct sctp_ep_common { |
1231 | /* Fields to help us manage our entries in the hash tables. */ | 1244 | /* Fields to help us manage our entries in the hash tables. */ |
1232 | struct sctp_ep_common *next; | 1245 | struct hlist_node node; |
1233 | struct sctp_ep_common **pprev; | ||
1234 | int hashent; | 1246 | int hashent; |
1235 | 1247 | ||
1236 | /* Runtime type information. What kind of endpoint is this? */ | 1248 | /* Runtime type information. What kind of endpoint is this? */ |
@@ -1541,7 +1553,6 @@ struct sctp_association { | |||
1541 | __u8 asconf_capable; /* Does peer support ADDIP? */ | 1553 | __u8 asconf_capable; /* Does peer support ADDIP? */ |
1542 | __u8 prsctp_capable; /* Can peer do PR-SCTP? */ | 1554 | __u8 prsctp_capable; /* Can peer do PR-SCTP? */ |
1543 | __u8 auth_capable; /* Is peer doing SCTP-AUTH? */ | 1555 | __u8 auth_capable; /* Is peer doing SCTP-AUTH? */ |
1544 | __u8 addip_capable; /* Can peer do ADD-IP */ | ||
1545 | 1556 | ||
1546 | __u32 adaptation_ind; /* Adaptation Code point. */ | 1557 | __u32 adaptation_ind; /* Adaptation Code point. */ |
1547 | 1558 | ||
@@ -1637,7 +1648,7 @@ struct sctp_association { | |||
1637 | */ | 1648 | */ |
1638 | __u32 pathmtu; | 1649 | __u32 pathmtu; |
1639 | 1650 | ||
1640 | /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ | 1651 | /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */ |
1641 | __u32 param_flags; | 1652 | __u32 param_flags; |
1642 | 1653 | ||
1643 | /* SACK delay timeout */ | 1654 | /* SACK delay timeout */ |
@@ -1783,20 +1794,16 @@ struct sctp_association { | |||
1783 | */ | 1794 | */ |
1784 | struct sctp_chunk *addip_last_asconf; | 1795 | struct sctp_chunk *addip_last_asconf; |
1785 | 1796 | ||
1786 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. | 1797 | /* ADDIP Section 5.2 Upon reception of an ASCONF Chunk. |
1787 | * | 1798 | * |
1788 | * IMPLEMENTATION NOTE: As an optimization a receiver may wish | 1799 | * This is needed to implement itmes E1 - E4 of the updated |
1789 | * to save the last ASCONF-ACK for some predetermined period | 1800 | * spec. Here is the justification: |
1790 | * of time and instead of re-processing the ASCONF (with the | ||
1791 | * same serial number) it may just re-transmit the | ||
1792 | * ASCONF-ACK. It may wish to use the arrival of a new serial | ||
1793 | * number to discard the previously saved ASCONF-ACK or any | ||
1794 | * other means it may choose to expire the saved ASCONF-ACK. | ||
1795 | * | 1801 | * |
1796 | * [This is our saved ASCONF-ACK. We invalidate it when a new | 1802 | * Since the peer may bundle multiple ASCONF chunks toward us, |
1797 | * ASCONF serial number arrives.] | 1803 | * we now need the ability to cache multiple ACKs. The section |
1804 | * describes in detail how they are cached and cleaned up. | ||
1798 | */ | 1805 | */ |
1799 | struct sctp_chunk *addip_last_asconf_ack; | 1806 | struct list_head asconf_ack_list; |
1800 | 1807 | ||
1801 | /* These ASCONF chunks are waiting to be sent. | 1808 | /* These ASCONF chunks are waiting to be sent. |
1802 | * | 1809 | * |
@@ -1937,12 +1944,19 @@ void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned); | |||
1937 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned); | 1944 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned); |
1938 | void sctp_assoc_set_primary(struct sctp_association *, | 1945 | void sctp_assoc_set_primary(struct sctp_association *, |
1939 | struct sctp_transport *); | 1946 | struct sctp_transport *); |
1947 | void sctp_assoc_del_nonprimary_peers(struct sctp_association *, | ||
1948 | struct sctp_transport *); | ||
1940 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, | 1949 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, |
1941 | gfp_t); | 1950 | gfp_t); |
1942 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, | 1951 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, |
1943 | struct sctp_cookie*, | 1952 | struct sctp_cookie*, |
1944 | gfp_t gfp); | 1953 | gfp_t gfp); |
1945 | int sctp_assoc_set_id(struct sctp_association *, gfp_t); | 1954 | int sctp_assoc_set_id(struct sctp_association *, gfp_t); |
1955 | void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc); | ||
1956 | struct sctp_chunk *sctp_assoc_lookup_asconf_ack( | ||
1957 | const struct sctp_association *asoc, | ||
1958 | __be32 serial); | ||
1959 | |||
1946 | 1960 | ||
1947 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, | 1961 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, |
1948 | const union sctp_addr *ss2); | 1962 | const union sctp_addr *ss2); |
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index 00848b641f59..954090b1e354 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h | |||
@@ -450,7 +450,7 @@ enum sctp_sn_type { | |||
450 | SCTP_SHUTDOWN_EVENT, | 450 | SCTP_SHUTDOWN_EVENT, |
451 | SCTP_PARTIAL_DELIVERY_EVENT, | 451 | SCTP_PARTIAL_DELIVERY_EVENT, |
452 | SCTP_ADAPTATION_INDICATION, | 452 | SCTP_ADAPTATION_INDICATION, |
453 | SCTP_AUTHENTICATION_EVENT, | 453 | SCTP_AUTHENTICATION_INDICATION, |
454 | }; | 454 | }; |
455 | 455 | ||
456 | /* Notification error codes used to fill up the error fields in some | 456 | /* Notification error codes used to fill up the error fields in some |
diff --git a/include/net/snmp.h b/include/net/snmp.h index ea206bff0dc4..ce2f48507510 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/cache.h> | 24 | #include <linux/cache.h> |
25 | #include <linux/snmp.h> | 25 | #include <linux/snmp.h> |
26 | #include <linux/smp.h> | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * Mibs are stored in array of unsigned long. | 29 | * Mibs are stored in array of unsigned long. |
@@ -117,6 +118,11 @@ struct linux_mib { | |||
117 | unsigned long mibs[LINUX_MIB_MAX]; | 118 | unsigned long mibs[LINUX_MIB_MAX]; |
118 | }; | 119 | }; |
119 | 120 | ||
121 | /* Linux Xfrm */ | ||
122 | #define LINUX_MIB_XFRMMAX __LINUX_MIB_XFRMMAX | ||
123 | struct linux_xfrm_mib { | ||
124 | unsigned long mibs[LINUX_MIB_XFRMMAX]; | ||
125 | }; | ||
120 | 126 | ||
121 | /* | 127 | /* |
122 | * FIXME: On x86 and some other CPUs the split into user and softirq parts | 128 | * FIXME: On x86 and some other CPUs the split into user and softirq parts |
@@ -134,17 +140,27 @@ struct linux_mib { | |||
134 | 140 | ||
135 | #define SNMP_INC_STATS_BH(mib, field) \ | 141 | #define SNMP_INC_STATS_BH(mib, field) \ |
136 | (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++) | 142 | (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++) |
137 | #define SNMP_INC_STATS_OFFSET_BH(mib, field, offset) \ | ||
138 | (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field + (offset)]++) | ||
139 | #define SNMP_INC_STATS_USER(mib, field) \ | 143 | #define SNMP_INC_STATS_USER(mib, field) \ |
140 | (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field]++) | 144 | do { \ |
145 | per_cpu_ptr(mib[1], get_cpu())->mibs[field]++; \ | ||
146 | put_cpu(); \ | ||
147 | } while (0) | ||
141 | #define SNMP_INC_STATS(mib, field) \ | 148 | #define SNMP_INC_STATS(mib, field) \ |
142 | (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++) | 149 | do { \ |
150 | per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]++; \ | ||
151 | put_cpu(); \ | ||
152 | } while (0) | ||
143 | #define SNMP_DEC_STATS(mib, field) \ | 153 | #define SNMP_DEC_STATS(mib, field) \ |
144 | (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--) | 154 | do { \ |
155 | per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]--; \ | ||
156 | put_cpu(); \ | ||
157 | } while (0) | ||
145 | #define SNMP_ADD_STATS_BH(mib, field, addend) \ | 158 | #define SNMP_ADD_STATS_BH(mib, field, addend) \ |
146 | (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend) | 159 | (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend) |
147 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ | 160 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ |
148 | (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field] += addend) | 161 | do { \ |
162 | per_cpu_ptr(mib[1], get_cpu())->mibs[field] += addend; \ | ||
163 | put_cpu(); \ | ||
164 | } while (0) | ||
149 | 165 | ||
150 | #endif | 166 | #endif |
diff --git a/include/net/sock.h b/include/net/sock.h index 43fc3fa50d62..e3fb4c047f4c 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/module.h> | 47 | #include <linux/module.h> |
48 | #include <linux/lockdep.h> | 48 | #include <linux/lockdep.h> |
49 | #include <linux/netdevice.h> | 49 | #include <linux/netdevice.h> |
50 | #include <linux/pcounter.h> | ||
50 | #include <linux/skbuff.h> /* struct sk_buff */ | 51 | #include <linux/skbuff.h> /* struct sk_buff */ |
51 | #include <linux/mm.h> | 52 | #include <linux/mm.h> |
52 | #include <linux/security.h> | 53 | #include <linux/security.h> |
@@ -56,7 +57,6 @@ | |||
56 | #include <asm/atomic.h> | 57 | #include <asm/atomic.h> |
57 | #include <net/dst.h> | 58 | #include <net/dst.h> |
58 | #include <net/checksum.h> | 59 | #include <net/checksum.h> |
59 | #include <net/net_namespace.h> | ||
60 | 60 | ||
61 | /* | 61 | /* |
62 | * This structure really needs to be cleaned up. | 62 | * This structure really needs to be cleaned up. |
@@ -94,6 +94,7 @@ typedef struct { | |||
94 | 94 | ||
95 | struct sock; | 95 | struct sock; |
96 | struct proto; | 96 | struct proto; |
97 | struct net; | ||
97 | 98 | ||
98 | /** | 99 | /** |
99 | * struct sock_common - minimal network layer representation of sockets | 100 | * struct sock_common - minimal network layer representation of sockets |
@@ -145,7 +146,8 @@ struct sock_common { | |||
145 | * @sk_forward_alloc: space allocated forward | 146 | * @sk_forward_alloc: space allocated forward |
146 | * @sk_allocation: allocation mode | 147 | * @sk_allocation: allocation mode |
147 | * @sk_sndbuf: size of send buffer in bytes | 148 | * @sk_sndbuf: size of send buffer in bytes |
148 | * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings | 149 | * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, |
150 | * %SO_OOBINLINE settings | ||
149 | * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets | 151 | * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets |
150 | * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) | 152 | * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) |
151 | * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) | 153 | * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) |
@@ -153,9 +155,12 @@ struct sock_common { | |||
153 | * @sk_backlog: always used with the per-socket spinlock held | 155 | * @sk_backlog: always used with the per-socket spinlock held |
154 | * @sk_callback_lock: used with the callbacks in the end of this struct | 156 | * @sk_callback_lock: used with the callbacks in the end of this struct |
155 | * @sk_error_queue: rarely used | 157 | * @sk_error_queue: rarely used |
156 | * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance) | 158 | * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, |
159 | * IPV6_ADDRFORM for instance) | ||
157 | * @sk_err: last error | 160 | * @sk_err: last error |
158 | * @sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out' | 161 | * @sk_err_soft: errors that don't cause failure but are the cause of a |
162 | * persistent failure not just 'timed out' | ||
163 | * @sk_drops: raw drops counter | ||
159 | * @sk_ack_backlog: current listen backlog | 164 | * @sk_ack_backlog: current listen backlog |
160 | * @sk_max_ack_backlog: listen backlog set in listen() | 165 | * @sk_max_ack_backlog: listen backlog set in listen() |
161 | * @sk_priority: %SO_PRIORITY setting | 166 | * @sk_priority: %SO_PRIORITY setting |
@@ -239,6 +244,7 @@ struct sock { | |||
239 | rwlock_t sk_callback_lock; | 244 | rwlock_t sk_callback_lock; |
240 | int sk_err, | 245 | int sk_err, |
241 | sk_err_soft; | 246 | sk_err_soft; |
247 | atomic_t sk_drops; | ||
242 | unsigned short sk_ack_backlog; | 248 | unsigned short sk_ack_backlog; |
243 | unsigned short sk_max_ack_backlog; | 249 | unsigned short sk_max_ack_backlog; |
244 | __u32 sk_priority; | 250 | __u32 sk_priority; |
@@ -256,6 +262,8 @@ struct sock { | |||
256 | __u32 sk_sndmsg_off; | 262 | __u32 sk_sndmsg_off; |
257 | int sk_write_pending; | 263 | int sk_write_pending; |
258 | void *sk_security; | 264 | void *sk_security; |
265 | __u32 sk_mark; | ||
266 | /* XXX 4 bytes hole on 64 bit */ | ||
259 | void (*sk_state_change)(struct sock *sk); | 267 | void (*sk_state_change)(struct sock *sk); |
260 | void (*sk_data_ready)(struct sock *sk, int bytes); | 268 | void (*sk_data_ready)(struct sock *sk, int bytes); |
261 | void (*sk_write_space)(struct sock *sk); | 269 | void (*sk_write_space)(struct sock *sk); |
@@ -439,7 +447,7 @@ static inline int sk_acceptq_is_full(struct sock *sk) | |||
439 | */ | 447 | */ |
440 | static inline int sk_stream_min_wspace(struct sock *sk) | 448 | static inline int sk_stream_min_wspace(struct sock *sk) |
441 | { | 449 | { |
442 | return sk->sk_wmem_queued / 2; | 450 | return sk->sk_wmem_queued >> 1; |
443 | } | 451 | } |
444 | 452 | ||
445 | static inline int sk_stream_wspace(struct sock *sk) | 453 | static inline int sk_stream_wspace(struct sock *sk) |
@@ -454,25 +462,6 @@ static inline int sk_stream_memory_free(struct sock *sk) | |||
454 | return sk->sk_wmem_queued < sk->sk_sndbuf; | 462 | return sk->sk_wmem_queued < sk->sk_sndbuf; |
455 | } | 463 | } |
456 | 464 | ||
457 | extern void sk_stream_rfree(struct sk_buff *skb); | ||
458 | |||
459 | static inline void sk_stream_set_owner_r(struct sk_buff *skb, struct sock *sk) | ||
460 | { | ||
461 | skb->sk = sk; | ||
462 | skb->destructor = sk_stream_rfree; | ||
463 | atomic_add(skb->truesize, &sk->sk_rmem_alloc); | ||
464 | sk->sk_forward_alloc -= skb->truesize; | ||
465 | } | ||
466 | |||
467 | static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb) | ||
468 | { | ||
469 | skb_truesize_check(skb); | ||
470 | sock_set_flag(sk, SOCK_QUEUE_SHRUNK); | ||
471 | sk->sk_wmem_queued -= skb->truesize; | ||
472 | sk->sk_forward_alloc += skb->truesize; | ||
473 | __kfree_skb(skb); | ||
474 | } | ||
475 | |||
476 | /* The per-socket spinlock must be held here. */ | 465 | /* The per-socket spinlock must be held here. */ |
477 | static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb) | 466 | static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb) |
478 | { | 467 | { |
@@ -560,6 +549,11 @@ struct proto { | |||
560 | void (*unhash)(struct sock *sk); | 549 | void (*unhash)(struct sock *sk); |
561 | int (*get_port)(struct sock *sk, unsigned short snum); | 550 | int (*get_port)(struct sock *sk, unsigned short snum); |
562 | 551 | ||
552 | /* Keeping track of sockets in use */ | ||
553 | #ifdef CONFIG_PROC_FS | ||
554 | struct pcounter inuse; | ||
555 | #endif | ||
556 | |||
563 | /* Memory pressure */ | 557 | /* Memory pressure */ |
564 | void (*enter_memory_pressure)(void); | 558 | void (*enter_memory_pressure)(void); |
565 | atomic_t *memory_allocated; /* Current allocated memory. */ | 559 | atomic_t *memory_allocated; /* Current allocated memory. */ |
@@ -567,7 +561,7 @@ struct proto { | |||
567 | /* | 561 | /* |
568 | * Pressure flag: try to collapse. | 562 | * Pressure flag: try to collapse. |
569 | * Technical note: it is used by multiple contexts non atomically. | 563 | * Technical note: it is used by multiple contexts non atomically. |
570 | * All the sk_stream_mem_schedule() is of this nature: accounting | 564 | * All the __sk_mem_schedule() is of this nature: accounting |
571 | * is strict, actions are advisory and have some latency. | 565 | * is strict, actions are advisory and have some latency. |
572 | */ | 566 | */ |
573 | int *memory_pressure; | 567 | int *memory_pressure; |
@@ -592,10 +586,6 @@ struct proto { | |||
592 | #ifdef SOCK_REFCNT_DEBUG | 586 | #ifdef SOCK_REFCNT_DEBUG |
593 | atomic_t socks; | 587 | atomic_t socks; |
594 | #endif | 588 | #endif |
595 | struct { | ||
596 | int inuse; | ||
597 | u8 __pad[SMP_CACHE_BYTES - sizeof(int)]; | ||
598 | } stats[NR_CPUS]; | ||
599 | }; | 589 | }; |
600 | 590 | ||
601 | extern int proto_register(struct proto *prot, int alloc_slab); | 591 | extern int proto_register(struct proto *prot, int alloc_slab); |
@@ -626,16 +616,42 @@ static inline void sk_refcnt_debug_release(const struct sock *sk) | |||
626 | #define sk_refcnt_debug_release(sk) do { } while (0) | 616 | #define sk_refcnt_debug_release(sk) do { } while (0) |
627 | #endif /* SOCK_REFCNT_DEBUG */ | 617 | #endif /* SOCK_REFCNT_DEBUG */ |
628 | 618 | ||
619 | |||
620 | #ifdef CONFIG_PROC_FS | ||
621 | # define DEFINE_PROTO_INUSE(NAME) DEFINE_PCOUNTER(NAME) | ||
622 | # define REF_PROTO_INUSE(NAME) PCOUNTER_MEMBER_INITIALIZER(NAME, .inuse) | ||
629 | /* Called with local bh disabled */ | 623 | /* Called with local bh disabled */ |
630 | static __inline__ void sock_prot_inc_use(struct proto *prot) | 624 | static inline void sock_prot_inuse_add(struct proto *prot, int inc) |
631 | { | 625 | { |
632 | prot->stats[smp_processor_id()].inuse++; | 626 | pcounter_add(&prot->inuse, inc); |
633 | } | 627 | } |
634 | 628 | static inline int sock_prot_inuse_init(struct proto *proto) | |
635 | static __inline__ void sock_prot_dec_use(struct proto *prot) | 629 | { |
630 | return pcounter_alloc(&proto->inuse); | ||
631 | } | ||
632 | static inline int sock_prot_inuse_get(struct proto *proto) | ||
633 | { | ||
634 | return pcounter_getval(&proto->inuse); | ||
635 | } | ||
636 | static inline void sock_prot_inuse_free(struct proto *proto) | ||
637 | { | ||
638 | pcounter_free(&proto->inuse); | ||
639 | } | ||
640 | #else | ||
641 | # define DEFINE_PROTO_INUSE(NAME) | ||
642 | # define REF_PROTO_INUSE(NAME) | ||
643 | static void inline sock_prot_inuse_add(struct proto *prot, int inc) | ||
644 | { | ||
645 | } | ||
646 | static int inline sock_prot_inuse_init(struct proto *proto) | ||
636 | { | 647 | { |
637 | prot->stats[smp_processor_id()].inuse--; | 648 | return 0; |
638 | } | 649 | } |
650 | static void inline sock_prot_inuse_free(struct proto *proto) | ||
651 | { | ||
652 | } | ||
653 | #endif | ||
654 | |||
639 | 655 | ||
640 | /* With per-bucket locks this operation is not-atomic, so that | 656 | /* With per-bucket locks this operation is not-atomic, so that |
641 | * this version is not worse. | 657 | * this version is not worse. |
@@ -699,32 +715,81 @@ static inline struct inode *SOCK_INODE(struct socket *socket) | |||
699 | return &container_of(socket, struct socket_alloc, socket)->vfs_inode; | 715 | return &container_of(socket, struct socket_alloc, socket)->vfs_inode; |
700 | } | 716 | } |
701 | 717 | ||
702 | extern void __sk_stream_mem_reclaim(struct sock *sk); | 718 | /* |
703 | extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind); | 719 | * Functions for memory accounting |
720 | */ | ||
721 | extern int __sk_mem_schedule(struct sock *sk, int size, int kind); | ||
722 | extern void __sk_mem_reclaim(struct sock *sk); | ||
704 | 723 | ||
705 | #define SK_STREAM_MEM_QUANTUM ((int)PAGE_SIZE) | 724 | #define SK_MEM_QUANTUM ((int)PAGE_SIZE) |
725 | #define SK_MEM_QUANTUM_SHIFT ilog2(SK_MEM_QUANTUM) | ||
726 | #define SK_MEM_SEND 0 | ||
727 | #define SK_MEM_RECV 1 | ||
706 | 728 | ||
707 | static inline int sk_stream_pages(int amt) | 729 | static inline int sk_mem_pages(int amt) |
708 | { | 730 | { |
709 | return DIV_ROUND_UP(amt, SK_STREAM_MEM_QUANTUM); | 731 | return (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT; |
710 | } | 732 | } |
711 | 733 | ||
712 | static inline void sk_stream_mem_reclaim(struct sock *sk) | 734 | static inline int sk_has_account(struct sock *sk) |
713 | { | 735 | { |
714 | if (sk->sk_forward_alloc >= SK_STREAM_MEM_QUANTUM) | 736 | /* return true if protocol supports memory accounting */ |
715 | __sk_stream_mem_reclaim(sk); | 737 | return !!sk->sk_prot->memory_allocated; |
716 | } | 738 | } |
717 | 739 | ||
718 | static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb) | 740 | static inline int sk_wmem_schedule(struct sock *sk, int size) |
719 | { | 741 | { |
720 | return (int)skb->truesize <= sk->sk_forward_alloc || | 742 | if (!sk_has_account(sk)) |
721 | sk_stream_mem_schedule(sk, skb->truesize, 1); | 743 | return 1; |
744 | return size <= sk->sk_forward_alloc || | ||
745 | __sk_mem_schedule(sk, size, SK_MEM_SEND); | ||
722 | } | 746 | } |
723 | 747 | ||
724 | static inline int sk_stream_wmem_schedule(struct sock *sk, int size) | 748 | static inline int sk_rmem_schedule(struct sock *sk, int size) |
725 | { | 749 | { |
750 | if (!sk_has_account(sk)) | ||
751 | return 1; | ||
726 | return size <= sk->sk_forward_alloc || | 752 | return size <= sk->sk_forward_alloc || |
727 | sk_stream_mem_schedule(sk, size, 0); | 753 | __sk_mem_schedule(sk, size, SK_MEM_RECV); |
754 | } | ||
755 | |||
756 | static inline void sk_mem_reclaim(struct sock *sk) | ||
757 | { | ||
758 | if (!sk_has_account(sk)) | ||
759 | return; | ||
760 | if (sk->sk_forward_alloc >= SK_MEM_QUANTUM) | ||
761 | __sk_mem_reclaim(sk); | ||
762 | } | ||
763 | |||
764 | static inline void sk_mem_reclaim_partial(struct sock *sk) | ||
765 | { | ||
766 | if (!sk_has_account(sk)) | ||
767 | return; | ||
768 | if (sk->sk_forward_alloc > SK_MEM_QUANTUM) | ||
769 | __sk_mem_reclaim(sk); | ||
770 | } | ||
771 | |||
772 | static inline void sk_mem_charge(struct sock *sk, int size) | ||
773 | { | ||
774 | if (!sk_has_account(sk)) | ||
775 | return; | ||
776 | sk->sk_forward_alloc -= size; | ||
777 | } | ||
778 | |||
779 | static inline void sk_mem_uncharge(struct sock *sk, int size) | ||
780 | { | ||
781 | if (!sk_has_account(sk)) | ||
782 | return; | ||
783 | sk->sk_forward_alloc += size; | ||
784 | } | ||
785 | |||
786 | static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb) | ||
787 | { | ||
788 | skb_truesize_check(skb); | ||
789 | sock_set_flag(sk, SOCK_QUEUE_SHRUNK); | ||
790 | sk->sk_wmem_queued -= skb->truesize; | ||
791 | sk_mem_uncharge(sk, skb->truesize); | ||
792 | __kfree_skb(skb); | ||
728 | } | 793 | } |
729 | 794 | ||
730 | /* Used by processes to "lock" a socket state, so that | 795 | /* Used by processes to "lock" a socket state, so that |
@@ -761,14 +826,14 @@ do { \ | |||
761 | lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \ | 826 | lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \ |
762 | } while (0) | 827 | } while (0) |
763 | 828 | ||
764 | extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass)); | 829 | extern void lock_sock_nested(struct sock *sk, int subclass); |
765 | 830 | ||
766 | static inline void lock_sock(struct sock *sk) | 831 | static inline void lock_sock(struct sock *sk) |
767 | { | 832 | { |
768 | lock_sock_nested(sk, 0); | 833 | lock_sock_nested(sk, 0); |
769 | } | 834 | } |
770 | 835 | ||
771 | extern void FASTCALL(release_sock(struct sock *sk)); | 836 | extern void release_sock(struct sock *sk); |
772 | 837 | ||
773 | /* BH context may only use the following locking interface. */ | 838 | /* BH context may only use the following locking interface. */ |
774 | #define bh_lock_sock(__sk) spin_lock(&((__sk)->sk_lock.slock)) | 839 | #define bh_lock_sock(__sk) spin_lock(&((__sk)->sk_lock.slock)) |
@@ -779,7 +844,7 @@ extern void FASTCALL(release_sock(struct sock *sk)); | |||
779 | 844 | ||
780 | extern struct sock *sk_alloc(struct net *net, int family, | 845 | extern struct sock *sk_alloc(struct net *net, int family, |
781 | gfp_t priority, | 846 | gfp_t priority, |
782 | struct proto *prot, int zero_it); | 847 | struct proto *prot); |
783 | extern void sk_free(struct sock *sk); | 848 | extern void sk_free(struct sock *sk); |
784 | extern struct sock *sk_clone(const struct sock *sk, | 849 | extern struct sock *sk_clone(const struct sock *sk, |
785 | const gfp_t priority); | 850 | const gfp_t priority); |
@@ -893,7 +958,7 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb) | |||
893 | return err; | 958 | return err; |
894 | 959 | ||
895 | rcu_read_lock_bh(); | 960 | rcu_read_lock_bh(); |
896 | filter = sk->sk_filter; | 961 | filter = rcu_dereference(sk->sk_filter); |
897 | if (filter) { | 962 | if (filter) { |
898 | unsigned int pkt_len = sk_run_filter(skb, filter->insns, | 963 | unsigned int pkt_len = sk_run_filter(skb, filter->insns, |
899 | filter->len); | 964 | filter->len); |
@@ -993,20 +1058,6 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) | |||
993 | write_unlock_bh(&sk->sk_callback_lock); | 1058 | write_unlock_bh(&sk->sk_callback_lock); |
994 | } | 1059 | } |
995 | 1060 | ||
996 | static inline void sock_copy(struct sock *nsk, const struct sock *osk) | ||
997 | { | ||
998 | #ifdef CONFIG_SECURITY_NETWORK | ||
999 | void *sptr = nsk->sk_security; | ||
1000 | #endif | ||
1001 | |||
1002 | memcpy(nsk, osk, osk->sk_prot->obj_size); | ||
1003 | get_net(nsk->sk_net); | ||
1004 | #ifdef CONFIG_SECURITY_NETWORK | ||
1005 | nsk->sk_security = sptr; | ||
1006 | security_sk_clone(osk, nsk); | ||
1007 | #endif | ||
1008 | } | ||
1009 | |||
1010 | extern int sock_i_uid(struct sock *sk); | 1061 | extern int sock_i_uid(struct sock *sk); |
1011 | extern unsigned long sock_i_ino(struct sock *sk); | 1062 | extern unsigned long sock_i_ino(struct sock *sk); |
1012 | 1063 | ||
@@ -1076,12 +1127,6 @@ static inline int sk_can_gso(const struct sock *sk) | |||
1076 | 1127 | ||
1077 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); | 1128 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); |
1078 | 1129 | ||
1079 | static inline void sk_charge_skb(struct sock *sk, struct sk_buff *skb) | ||
1080 | { | ||
1081 | sk->sk_wmem_queued += skb->truesize; | ||
1082 | sk->sk_forward_alloc -= skb->truesize; | ||
1083 | } | ||
1084 | |||
1085 | static inline int skb_copy_to_page(struct sock *sk, char __user *from, | 1130 | static inline int skb_copy_to_page(struct sock *sk, char __user *from, |
1086 | struct sk_buff *skb, struct page *page, | 1131 | struct sk_buff *skb, struct page *page, |
1087 | int off, int copy) | 1132 | int off, int copy) |
@@ -1101,7 +1146,7 @@ static inline int skb_copy_to_page(struct sock *sk, char __user *from, | |||
1101 | skb->data_len += copy; | 1146 | skb->data_len += copy; |
1102 | skb->truesize += copy; | 1147 | skb->truesize += copy; |
1103 | sk->sk_wmem_queued += copy; | 1148 | sk->sk_wmem_queued += copy; |
1104 | sk->sk_forward_alloc -= copy; | 1149 | sk_mem_charge(sk, copy); |
1105 | return 0; | 1150 | return 0; |
1106 | } | 1151 | } |
1107 | 1152 | ||
@@ -1127,6 +1172,7 @@ static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk) | |||
1127 | skb->sk = sk; | 1172 | skb->sk = sk; |
1128 | skb->destructor = sock_rfree; | 1173 | skb->destructor = sock_rfree; |
1129 | atomic_add(skb->truesize, &sk->sk_rmem_alloc); | 1174 | atomic_add(skb->truesize, &sk->sk_rmem_alloc); |
1175 | sk_mem_charge(sk, skb->truesize); | ||
1130 | } | 1176 | } |
1131 | 1177 | ||
1132 | extern void sk_reset_timer(struct sock *sk, struct timer_list* timer, | 1178 | extern void sk_reset_timer(struct sock *sk, struct timer_list* timer, |
@@ -1188,40 +1234,12 @@ static inline void sk_wake_async(struct sock *sk, int how, int band) | |||
1188 | static inline void sk_stream_moderate_sndbuf(struct sock *sk) | 1234 | static inline void sk_stream_moderate_sndbuf(struct sock *sk) |
1189 | { | 1235 | { |
1190 | if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) { | 1236 | if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) { |
1191 | sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued / 2); | 1237 | sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued >> 1); |
1192 | sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF); | 1238 | sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF); |
1193 | } | 1239 | } |
1194 | } | 1240 | } |
1195 | 1241 | ||
1196 | static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, | 1242 | struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp); |
1197 | int size, int mem, | ||
1198 | gfp_t gfp) | ||
1199 | { | ||
1200 | struct sk_buff *skb; | ||
1201 | int hdr_len; | ||
1202 | |||
1203 | hdr_len = SKB_DATA_ALIGN(sk->sk_prot->max_header); | ||
1204 | skb = alloc_skb_fclone(size + hdr_len, gfp); | ||
1205 | if (skb) { | ||
1206 | skb->truesize += mem; | ||
1207 | if (sk_stream_wmem_schedule(sk, skb->truesize)) { | ||
1208 | skb_reserve(skb, hdr_len); | ||
1209 | return skb; | ||
1210 | } | ||
1211 | __kfree_skb(skb); | ||
1212 | } else { | ||
1213 | sk->sk_prot->enter_memory_pressure(); | ||
1214 | sk_stream_moderate_sndbuf(sk); | ||
1215 | } | ||
1216 | return NULL; | ||
1217 | } | ||
1218 | |||
1219 | static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk, | ||
1220 | int size, | ||
1221 | gfp_t gfp) | ||
1222 | { | ||
1223 | return sk_stream_alloc_pskb(sk, size, 0, gfp); | ||
1224 | } | ||
1225 | 1243 | ||
1226 | static inline struct page *sk_stream_alloc_page(struct sock *sk) | 1244 | static inline struct page *sk_stream_alloc_page(struct sock *sk) |
1227 | { | 1245 | { |
@@ -1240,7 +1258,7 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk) | |||
1240 | */ | 1258 | */ |
1241 | static inline int sock_writeable(const struct sock *sk) | 1259 | static inline int sock_writeable(const struct sock *sk) |
1242 | { | 1260 | { |
1243 | return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2); | 1261 | return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf >> 1); |
1244 | } | 1262 | } |
1245 | 1263 | ||
1246 | static inline gfp_t gfp_any(void) | 1264 | static inline gfp_t gfp_any(void) |
@@ -1349,23 +1367,11 @@ extern int net_msg_warn; | |||
1349 | lock_sock(sk); \ | 1367 | lock_sock(sk); \ |
1350 | } | 1368 | } |
1351 | 1369 | ||
1352 | static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool) | ||
1353 | { | ||
1354 | if (valbool) | ||
1355 | sock_set_flag(sk, bit); | ||
1356 | else | ||
1357 | sock_reset_flag(sk, bit); | ||
1358 | } | ||
1359 | |||
1360 | extern __u32 sysctl_wmem_max; | 1370 | extern __u32 sysctl_wmem_max; |
1361 | extern __u32 sysctl_rmem_max; | 1371 | extern __u32 sysctl_rmem_max; |
1362 | 1372 | ||
1363 | extern void sk_init(void); | 1373 | extern void sk_init(void); |
1364 | 1374 | ||
1365 | #ifdef CONFIG_SYSCTL | ||
1366 | extern struct ctl_table core_table[]; | ||
1367 | #endif | ||
1368 | |||
1369 | extern int sysctl_optmem_max; | 1375 | extern int sysctl_optmem_max; |
1370 | 1376 | ||
1371 | extern __u32 sysctl_wmem_default; | 1377 | extern __u32 sysctl_wmem_default; |
diff --git a/include/net/tcp.h b/include/net/tcp.h index d695cea7730d..7de4ea3a04d9 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -309,6 +309,9 @@ extern int tcp_twsk_unique(struct sock *sk, | |||
309 | 309 | ||
310 | extern void tcp_twsk_destructor(struct sock *sk); | 310 | extern void tcp_twsk_destructor(struct sock *sk); |
311 | 311 | ||
312 | extern ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos, | ||
313 | struct pipe_inode_info *pipe, size_t len, unsigned int flags); | ||
314 | |||
312 | static inline void tcp_dec_quickack_mode(struct sock *sk, | 315 | static inline void tcp_dec_quickack_mode(struct sock *sk, |
313 | const unsigned int pkts) | 316 | const unsigned int pkts) |
314 | { | 317 | { |
@@ -575,10 +578,6 @@ struct tcp_skb_cb { | |||
575 | #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ | 578 | #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ |
576 | #define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) | 579 | #define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) |
577 | 580 | ||
578 | #define TCPCB_URG 0x20 /* Urgent pointer advanced here */ | ||
579 | |||
580 | #define TCPCB_AT_TAIL (TCPCB_URG) | ||
581 | |||
582 | __u16 urg_ptr; /* Valid w/URG flags is set. */ | 581 | __u16 urg_ptr; /* Valid w/URG flags is set. */ |
583 | __u32 ack_seq; /* Sequence number ACK'd */ | 582 | __u32 ack_seq; /* Sequence number ACK'd */ |
584 | }; | 583 | }; |
@@ -649,7 +648,7 @@ struct tcp_congestion_ops { | |||
649 | /* lower bound for congestion window (optional) */ | 648 | /* lower bound for congestion window (optional) */ |
650 | u32 (*min_cwnd)(const struct sock *sk); | 649 | u32 (*min_cwnd)(const struct sock *sk); |
651 | /* do new cwnd calculation (required) */ | 650 | /* do new cwnd calculation (required) */ |
652 | void (*cong_avoid)(struct sock *sk, u32 ack, u32 in_flight, int good_ack); | 651 | void (*cong_avoid)(struct sock *sk, u32 ack, u32 in_flight); |
653 | /* call before changing ca_state (optional) */ | 652 | /* call before changing ca_state (optional) */ |
654 | void (*set_state)(struct sock *sk, u8 new_state); | 653 | void (*set_state)(struct sock *sk, u8 new_state); |
655 | /* call when cwnd event occurs (optional) */ | 654 | /* call when cwnd event occurs (optional) */ |
@@ -680,7 +679,7 @@ extern void tcp_slow_start(struct tcp_sock *tp); | |||
680 | 679 | ||
681 | extern struct tcp_congestion_ops tcp_init_congestion_ops; | 680 | extern struct tcp_congestion_ops tcp_init_congestion_ops; |
682 | extern u32 tcp_reno_ssthresh(struct sock *sk); | 681 | extern u32 tcp_reno_ssthresh(struct sock *sk); |
683 | extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight, int flag); | 682 | extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight); |
684 | extern u32 tcp_reno_min_cwnd(const struct sock *sk); | 683 | extern u32 tcp_reno_min_cwnd(const struct sock *sk); |
685 | extern struct tcp_congestion_ops tcp_reno; | 684 | extern struct tcp_congestion_ops tcp_reno; |
686 | 685 | ||
@@ -782,26 +781,12 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp) | |||
782 | return 3; | 781 | return 3; |
783 | } | 782 | } |
784 | 783 | ||
785 | /* RFC2861 Check whether we are limited by application or congestion window | 784 | /* Returns end sequence number of the receiver's advertised window */ |
786 | * This is the inverse of cwnd check in tcp_tso_should_defer | 785 | static inline u32 tcp_wnd_end(const struct tcp_sock *tp) |
787 | */ | ||
788 | static inline int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight) | ||
789 | { | 786 | { |
790 | const struct tcp_sock *tp = tcp_sk(sk); | 787 | return tp->snd_una + tp->snd_wnd; |
791 | u32 left; | ||
792 | |||
793 | if (in_flight >= tp->snd_cwnd) | ||
794 | return 1; | ||
795 | |||
796 | if (!sk_can_gso(sk)) | ||
797 | return 0; | ||
798 | |||
799 | left = tp->snd_cwnd - in_flight; | ||
800 | if (sysctl_tcp_tso_win_divisor) | ||
801 | return left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd; | ||
802 | else | ||
803 | return left <= tcp_max_burst(tp); | ||
804 | } | 788 | } |
789 | extern int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight); | ||
805 | 790 | ||
806 | static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, | 791 | static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, |
807 | const struct sk_buff *skb) | 792 | const struct sk_buff *skb) |
@@ -921,40 +906,7 @@ static const char *statename[]={ | |||
921 | "Close Wait","Last ACK","Listen","Closing" | 906 | "Close Wait","Last ACK","Listen","Closing" |
922 | }; | 907 | }; |
923 | #endif | 908 | #endif |
924 | 909 | extern void tcp_set_state(struct sock *sk, int state); | |
925 | static inline void tcp_set_state(struct sock *sk, int state) | ||
926 | { | ||
927 | int oldstate = sk->sk_state; | ||
928 | |||
929 | switch (state) { | ||
930 | case TCP_ESTABLISHED: | ||
931 | if (oldstate != TCP_ESTABLISHED) | ||
932 | TCP_INC_STATS(TCP_MIB_CURRESTAB); | ||
933 | break; | ||
934 | |||
935 | case TCP_CLOSE: | ||
936 | if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED) | ||
937 | TCP_INC_STATS(TCP_MIB_ESTABRESETS); | ||
938 | |||
939 | sk->sk_prot->unhash(sk); | ||
940 | if (inet_csk(sk)->icsk_bind_hash && | ||
941 | !(sk->sk_userlocks & SOCK_BINDPORT_LOCK)) | ||
942 | inet_put_port(&tcp_hashinfo, sk); | ||
943 | /* fall through */ | ||
944 | default: | ||
945 | if (oldstate==TCP_ESTABLISHED) | ||
946 | TCP_DEC_STATS(TCP_MIB_CURRESTAB); | ||
947 | } | ||
948 | |||
949 | /* Change state AFTER socket is unhashed to avoid closed | ||
950 | * socket sitting in hash tables. | ||
951 | */ | ||
952 | sk->sk_state = state; | ||
953 | |||
954 | #ifdef STATE_TRACE | ||
955 | SOCK_DEBUG(sk, "TCP sk=%p, State %s -> %s\n",sk, statename[oldstate],statename[state]); | ||
956 | #endif | ||
957 | } | ||
958 | 910 | ||
959 | extern void tcp_done(struct sock *sk); | 911 | extern void tcp_done(struct sock *sk); |
960 | 912 | ||
@@ -1078,7 +1030,6 @@ static inline void tcp_clear_retrans_hints_partial(struct tcp_sock *tp) | |||
1078 | static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) | 1030 | static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) |
1079 | { | 1031 | { |
1080 | tcp_clear_retrans_hints_partial(tp); | 1032 | tcp_clear_retrans_hints_partial(tp); |
1081 | tp->fastpath_skb_hint = NULL; | ||
1082 | } | 1033 | } |
1083 | 1034 | ||
1084 | /* MD5 Signature */ | 1035 | /* MD5 Signature */ |
@@ -1153,7 +1104,8 @@ extern int tcp_v4_calc_md5_hash(char *md5_hash, | |||
1153 | struct dst_entry *dst, | 1104 | struct dst_entry *dst, |
1154 | struct request_sock *req, | 1105 | struct request_sock *req, |
1155 | struct tcphdr *th, | 1106 | struct tcphdr *th, |
1156 | int protocol, int tcplen); | 1107 | int protocol, |
1108 | unsigned int tcplen); | ||
1157 | extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, | 1109 | extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, |
1158 | struct sock *addr_sk); | 1110 | struct sock *addr_sk); |
1159 | 1111 | ||
@@ -1193,8 +1145,8 @@ static inline void tcp_write_queue_purge(struct sock *sk) | |||
1193 | struct sk_buff *skb; | 1145 | struct sk_buff *skb; |
1194 | 1146 | ||
1195 | while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) | 1147 | while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) |
1196 | sk_stream_free_skb(sk, skb); | 1148 | sk_wmem_free_skb(sk, skb); |
1197 | sk_stream_mem_reclaim(sk); | 1149 | sk_mem_reclaim(sk); |
1198 | } | 1150 | } |
1199 | 1151 | ||
1200 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) | 1152 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) |
@@ -1227,6 +1179,11 @@ static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_bu | |||
1227 | for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\ | 1179 | for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\ |
1228 | skb = skb->next) | 1180 | skb = skb->next) |
1229 | 1181 | ||
1182 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ | ||
1183 | for (tmp = skb->next; \ | ||
1184 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ | ||
1185 | skb = tmp, tmp = skb->next) | ||
1186 | |||
1230 | static inline struct sk_buff *tcp_send_head(struct sock *sk) | 1187 | static inline struct sk_buff *tcp_send_head(struct sock *sk) |
1231 | { | 1188 | { |
1232 | return sk->sk_send_head; | 1189 | return sk->sk_send_head; |
@@ -1234,14 +1191,9 @@ static inline struct sk_buff *tcp_send_head(struct sock *sk) | |||
1234 | 1191 | ||
1235 | static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) | 1192 | static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) |
1236 | { | 1193 | { |
1237 | struct tcp_sock *tp = tcp_sk(sk); | ||
1238 | |||
1239 | sk->sk_send_head = skb->next; | 1194 | sk->sk_send_head = skb->next; |
1240 | if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) | 1195 | if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) |
1241 | sk->sk_send_head = NULL; | 1196 | sk->sk_send_head = NULL; |
1242 | /* Don't override Nagle indefinately with F-RTO */ | ||
1243 | if (tp->frto_counter == 2) | ||
1244 | tp->frto_counter = 3; | ||
1245 | } | 1197 | } |
1246 | 1198 | ||
1247 | static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) | 1199 | static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) |
@@ -1265,8 +1217,12 @@ static inline void tcp_add_write_queue_tail(struct sock *sk, struct sk_buff *skb | |||
1265 | __tcp_add_write_queue_tail(sk, skb); | 1217 | __tcp_add_write_queue_tail(sk, skb); |
1266 | 1218 | ||
1267 | /* Queue it, remembering where we must start sending. */ | 1219 | /* Queue it, remembering where we must start sending. */ |
1268 | if (sk->sk_send_head == NULL) | 1220 | if (sk->sk_send_head == NULL) { |
1269 | sk->sk_send_head = skb; | 1221 | sk->sk_send_head = skb; |
1222 | |||
1223 | if (tcp_sk(sk)->highest_sack == NULL) | ||
1224 | tcp_sk(sk)->highest_sack = skb; | ||
1225 | } | ||
1270 | } | 1226 | } |
1271 | 1227 | ||
1272 | static inline void __tcp_add_write_queue_head(struct sock *sk, struct sk_buff *skb) | 1228 | static inline void __tcp_add_write_queue_head(struct sock *sk, struct sk_buff *skb) |
@@ -1288,6 +1244,9 @@ static inline void tcp_insert_write_queue_before(struct sk_buff *new, | |||
1288 | struct sock *sk) | 1244 | struct sock *sk) |
1289 | { | 1245 | { |
1290 | __skb_insert(new, skb->prev, skb, &sk->sk_write_queue); | 1246 | __skb_insert(new, skb->prev, skb, &sk->sk_write_queue); |
1247 | |||
1248 | if (sk->sk_send_head == skb) | ||
1249 | sk->sk_send_head = new; | ||
1291 | } | 1250 | } |
1292 | 1251 | ||
1293 | static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk) | 1252 | static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk) |
@@ -1306,6 +1265,45 @@ static inline int tcp_write_queue_empty(struct sock *sk) | |||
1306 | return skb_queue_empty(&sk->sk_write_queue); | 1265 | return skb_queue_empty(&sk->sk_write_queue); |
1307 | } | 1266 | } |
1308 | 1267 | ||
1268 | /* Start sequence of the highest skb with SACKed bit, valid only if | ||
1269 | * sacked > 0 or when the caller has ensured validity by itself. | ||
1270 | */ | ||
1271 | static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp) | ||
1272 | { | ||
1273 | if (!tp->sacked_out) | ||
1274 | return tp->snd_una; | ||
1275 | |||
1276 | if (tp->highest_sack == NULL) | ||
1277 | return tp->snd_nxt; | ||
1278 | |||
1279 | return TCP_SKB_CB(tp->highest_sack)->seq; | ||
1280 | } | ||
1281 | |||
1282 | static inline void tcp_advance_highest_sack(struct sock *sk, struct sk_buff *skb) | ||
1283 | { | ||
1284 | tcp_sk(sk)->highest_sack = tcp_skb_is_last(sk, skb) ? NULL : | ||
1285 | tcp_write_queue_next(sk, skb); | ||
1286 | } | ||
1287 | |||
1288 | static inline struct sk_buff *tcp_highest_sack(struct sock *sk) | ||
1289 | { | ||
1290 | return tcp_sk(sk)->highest_sack; | ||
1291 | } | ||
1292 | |||
1293 | static inline void tcp_highest_sack_reset(struct sock *sk) | ||
1294 | { | ||
1295 | tcp_sk(sk)->highest_sack = tcp_write_queue_head(sk); | ||
1296 | } | ||
1297 | |||
1298 | /* Called when old skb is about to be deleted (to be combined with new skb) */ | ||
1299 | static inline void tcp_highest_sack_combine(struct sock *sk, | ||
1300 | struct sk_buff *old, | ||
1301 | struct sk_buff *new) | ||
1302 | { | ||
1303 | if (tcp_sk(sk)->sacked_out && (old == tcp_sk(sk)->highest_sack)) | ||
1304 | tcp_sk(sk)->highest_sack = new; | ||
1305 | } | ||
1306 | |||
1309 | /* /proc */ | 1307 | /* /proc */ |
1310 | enum tcp_seq_states { | 1308 | enum tcp_seq_states { |
1311 | TCP_SEQ_STATE_LISTENING, | 1309 | TCP_SEQ_STATE_LISTENING, |
@@ -1356,7 +1354,8 @@ struct tcp_sock_af_ops { | |||
1356 | struct dst_entry *dst, | 1354 | struct dst_entry *dst, |
1357 | struct request_sock *req, | 1355 | struct request_sock *req, |
1358 | struct tcphdr *th, | 1356 | struct tcphdr *th, |
1359 | int protocol, int len); | 1357 | int protocol, |
1358 | unsigned int len); | ||
1360 | int (*md5_add) (struct sock *sk, | 1359 | int (*md5_add) (struct sock *sk, |
1361 | struct sock *addr_sk, | 1360 | struct sock *addr_sk, |
1362 | u8 *newkey, | 1361 | u8 *newkey, |
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h index 409da3a9a455..27394e0447d8 100644 --- a/include/net/transp_v6.h +++ b/include/net/transp_v6.h | |||
@@ -17,16 +17,20 @@ extern struct proto tcpv6_prot; | |||
17 | struct flowi; | 17 | struct flowi; |
18 | 18 | ||
19 | /* extention headers */ | 19 | /* extention headers */ |
20 | extern void ipv6_rthdr_init(void); | 20 | extern int ipv6_exthdrs_init(void); |
21 | extern void ipv6_frag_init(void); | 21 | extern void ipv6_exthdrs_exit(void); |
22 | extern void ipv6_nodata_init(void); | 22 | extern int ipv6_frag_init(void); |
23 | extern void ipv6_destopt_init(void); | 23 | extern void ipv6_frag_exit(void); |
24 | 24 | ||
25 | /* transport protocols */ | 25 | /* transport protocols */ |
26 | extern void rawv6_init(void); | 26 | extern int rawv6_init(void); |
27 | extern void udpv6_init(void); | 27 | extern void rawv6_exit(void); |
28 | extern void udplitev6_init(void); | 28 | extern int udpv6_init(void); |
29 | extern void tcpv6_init(void); | 29 | extern void udpv6_exit(void); |
30 | extern int udplitev6_init(void); | ||
31 | extern void udplitev6_exit(void); | ||
32 | extern int tcpv6_init(void); | ||
33 | extern void tcpv6_exit(void); | ||
30 | 34 | ||
31 | extern int udpv6_connect(struct sock *sk, | 35 | extern int udpv6_connect(struct sock *sk, |
32 | struct sockaddr *uaddr, | 36 | struct sockaddr *uaddr, |
diff --git a/include/net/udp.h b/include/net/udp.h index 98755ebaf163..c6669c0a74c7 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
@@ -65,6 +65,13 @@ extern rwlock_t udp_hash_lock; | |||
65 | 65 | ||
66 | extern struct proto udp_prot; | 66 | extern struct proto udp_prot; |
67 | 67 | ||
68 | extern atomic_t udp_memory_allocated; | ||
69 | |||
70 | /* sysctl variables for udp */ | ||
71 | extern int sysctl_udp_mem[3]; | ||
72 | extern int sysctl_udp_rmem_min; | ||
73 | extern int sysctl_udp_wmem_min; | ||
74 | |||
68 | struct sk_buff; | 75 | struct sk_buff; |
69 | 76 | ||
70 | /* | 77 | /* |
@@ -108,7 +115,7 @@ static inline void udp_lib_unhash(struct sock *sk) | |||
108 | write_lock_bh(&udp_hash_lock); | 115 | write_lock_bh(&udp_hash_lock); |
109 | if (sk_del_node_init(sk)) { | 116 | if (sk_del_node_init(sk)) { |
110 | inet_sk(sk)->num = 0; | 117 | inet_sk(sk)->num = 0; |
111 | sock_prot_dec_use(sk->sk_prot); | 118 | sock_prot_inuse_add(sk->sk_prot, -1); |
112 | } | 119 | } |
113 | write_unlock_bh(&udp_hash_lock); | 120 | write_unlock_bh(&udp_hash_lock); |
114 | } | 121 | } |
@@ -139,6 +146,12 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
139 | int (*push_pending_frames)(struct sock *)); | 146 | int (*push_pending_frames)(struct sock *)); |
140 | 147 | ||
141 | DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); | 148 | DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); |
149 | DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); | ||
150 | |||
151 | /* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */ | ||
152 | DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics); | ||
153 | DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6); | ||
154 | |||
142 | /* | 155 | /* |
143 | * SNMP statistics for UDP and UDP-Lite | 156 | * SNMP statistics for UDP and UDP-Lite |
144 | */ | 157 | */ |
@@ -149,6 +162,25 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); | |||
149 | if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \ | 162 | if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \ |
150 | else SNMP_INC_STATS_BH(udp_statistics, field); } while(0) | 163 | else SNMP_INC_STATS_BH(udp_statistics, field); } while(0) |
151 | 164 | ||
165 | #define UDP6_INC_STATS_BH(field, is_udplite) do { \ | ||
166 | if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \ | ||
167 | else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0) | ||
168 | #define UDP6_INC_STATS_USER(field, is_udplite) do { \ | ||
169 | if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \ | ||
170 | else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0) | ||
171 | |||
172 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
173 | #define UDPX_INC_STATS_BH(sk, field) \ | ||
174 | do { \ | ||
175 | if ((sk)->sk_family == AF_INET) \ | ||
176 | UDP_INC_STATS_BH(field, 0); \ | ||
177 | else \ | ||
178 | UDP6_INC_STATS_BH(field, 0); \ | ||
179 | } while (0); | ||
180 | #else | ||
181 | #define UDPX_INC_STATS_BH(sk, field) UDP_INC_STATS_BH(field, 0) | ||
182 | #endif | ||
183 | |||
152 | /* /proc */ | 184 | /* /proc */ |
153 | struct udp_seq_afinfo { | 185 | struct udp_seq_afinfo { |
154 | struct module *owner; | 186 | struct module *owner; |
@@ -173,4 +205,6 @@ extern void udp_proc_unregister(struct udp_seq_afinfo *afinfo); | |||
173 | extern int udp4_proc_init(void); | 205 | extern int udp4_proc_init(void); |
174 | extern void udp4_proc_exit(void); | 206 | extern void udp4_proc_exit(void); |
175 | #endif | 207 | #endif |
208 | |||
209 | extern void udp_init(void); | ||
176 | #endif /* _UDP_H */ | 210 | #endif /* _UDP_H */ |
diff --git a/include/net/udplite.h b/include/net/udplite.h index 635b0eafca95..b76b2e377af4 100644 --- a/include/net/udplite.h +++ b/include/net/udplite.h | |||
@@ -13,9 +13,6 @@ | |||
13 | extern struct proto udplite_prot; | 13 | extern struct proto udplite_prot; |
14 | extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; | 14 | extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; |
15 | 15 | ||
16 | /* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */ | ||
17 | DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics); | ||
18 | |||
19 | /* | 16 | /* |
20 | * Checksum computation is all in software, hence simpler getfrag. | 17 | * Checksum computation is all in software, hence simpler getfrag. |
21 | */ | 18 | */ |
diff --git a/include/net/veth.h b/include/net/veth.h deleted file mode 100644 index 3354c1eb424e..000000000000 --- a/include/net/veth.h +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | #ifndef __NET_VETH_H_ | ||
2 | #define __NET_VETH_H_ | ||
3 | |||
4 | enum { | ||
5 | VETH_INFO_UNSPEC, | ||
6 | VETH_INFO_PEER, | ||
7 | |||
8 | __VETH_INFO_MAX | ||
9 | #define VETH_INFO_MAX (__VETH_INFO_MAX - 1) | ||
10 | }; | ||
11 | |||
12 | #endif | ||
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 58dfa82889aa..ac72116636ca 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -19,6 +19,9 @@ | |||
19 | #include <net/route.h> | 19 | #include <net/route.h> |
20 | #include <net/ipv6.h> | 20 | #include <net/ipv6.h> |
21 | #include <net/ip6_fib.h> | 21 | #include <net/ip6_fib.h> |
22 | #ifdef CONFIG_XFRM_STATISTICS | ||
23 | #include <net/snmp.h> | ||
24 | #endif | ||
22 | 25 | ||
23 | #define XFRM_PROTO_ESP 50 | 26 | #define XFRM_PROTO_ESP 50 |
24 | #define XFRM_PROTO_AH 51 | 27 | #define XFRM_PROTO_AH 51 |
@@ -34,6 +37,17 @@ | |||
34 | #define MODULE_ALIAS_XFRM_TYPE(family, proto) \ | 37 | #define MODULE_ALIAS_XFRM_TYPE(family, proto) \ |
35 | MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto)) | 38 | MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto)) |
36 | 39 | ||
40 | #ifdef CONFIG_XFRM_STATISTICS | ||
41 | DECLARE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); | ||
42 | #define XFRM_INC_STATS(field) SNMP_INC_STATS(xfrm_statistics, field) | ||
43 | #define XFRM_INC_STATS_BH(field) SNMP_INC_STATS_BH(xfrm_statistics, field) | ||
44 | #define XFRM_INC_STATS_USER(field) SNMP_INC_STATS_USER(xfrm_statistics, field) | ||
45 | #else | ||
46 | #define XFRM_INC_STATS(field) | ||
47 | #define XFRM_INC_STATS_BH(field) | ||
48 | #define XFRM_INC_STATS_USER(field) | ||
49 | #endif | ||
50 | |||
37 | extern struct sock *xfrm_nl; | 51 | extern struct sock *xfrm_nl; |
38 | extern u32 sysctl_xfrm_aevent_etime; | 52 | extern u32 sysctl_xfrm_aevent_etime; |
39 | extern u32 sysctl_xfrm_aevent_rseqth; | 53 | extern u32 sysctl_xfrm_aevent_rseqth; |
@@ -145,6 +159,7 @@ struct xfrm_state | |||
145 | struct xfrm_algo *aalg; | 159 | struct xfrm_algo *aalg; |
146 | struct xfrm_algo *ealg; | 160 | struct xfrm_algo *ealg; |
147 | struct xfrm_algo *calg; | 161 | struct xfrm_algo *calg; |
162 | struct xfrm_algo_aead *aead; | ||
148 | 163 | ||
149 | /* Data for encapsulator */ | 164 | /* Data for encapsulator */ |
150 | struct xfrm_encap_tmpl *encap; | 165 | struct xfrm_encap_tmpl *encap; |
@@ -183,11 +198,11 @@ struct xfrm_state | |||
183 | struct timer_list timer; | 198 | struct timer_list timer; |
184 | 199 | ||
185 | /* Last used time */ | 200 | /* Last used time */ |
186 | u64 lastused; | 201 | unsigned long lastused; |
187 | 202 | ||
188 | /* Reference to data common to all the instances of this | 203 | /* Reference to data common to all the instances of this |
189 | * transformer. */ | 204 | * transformer. */ |
190 | struct xfrm_type *type; | 205 | const struct xfrm_type *type; |
191 | struct xfrm_mode *inner_mode; | 206 | struct xfrm_mode *inner_mode; |
192 | struct xfrm_mode *outer_mode; | 207 | struct xfrm_mode *outer_mode; |
193 | 208 | ||
@@ -227,22 +242,26 @@ struct km_event | |||
227 | u32 event; | 242 | u32 event; |
228 | }; | 243 | }; |
229 | 244 | ||
245 | struct net_device; | ||
230 | struct xfrm_type; | 246 | struct xfrm_type; |
231 | struct xfrm_dst; | 247 | struct xfrm_dst; |
232 | struct xfrm_policy_afinfo { | 248 | struct xfrm_policy_afinfo { |
233 | unsigned short family; | 249 | unsigned short family; |
234 | struct dst_ops *dst_ops; | 250 | struct dst_ops *dst_ops; |
235 | void (*garbage_collect)(void); | 251 | void (*garbage_collect)(void); |
236 | int (*dst_lookup)(struct xfrm_dst **dst, struct flowi *fl); | 252 | struct dst_entry *(*dst_lookup)(int tos, xfrm_address_t *saddr, |
253 | xfrm_address_t *daddr); | ||
237 | int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); | 254 | int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); |
238 | struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); | 255 | struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); |
239 | int (*bundle_create)(struct xfrm_policy *policy, | ||
240 | struct xfrm_state **xfrm, | ||
241 | int nx, | ||
242 | struct flowi *fl, | ||
243 | struct dst_entry **dst_p); | ||
244 | void (*decode_session)(struct sk_buff *skb, | 256 | void (*decode_session)(struct sk_buff *skb, |
245 | struct flowi *fl); | 257 | struct flowi *fl, |
258 | int reverse); | ||
259 | int (*get_tos)(struct flowi *fl); | ||
260 | int (*init_path)(struct xfrm_dst *path, | ||
261 | struct dst_entry *dst, | ||
262 | int nfheader_len); | ||
263 | int (*fill_dst)(struct xfrm_dst *xdst, | ||
264 | struct net_device *dev); | ||
246 | }; | 265 | }; |
247 | 266 | ||
248 | extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); | 267 | extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); |
@@ -257,8 +276,10 @@ extern int __xfrm_state_delete(struct xfrm_state *x); | |||
257 | 276 | ||
258 | struct xfrm_state_afinfo { | 277 | struct xfrm_state_afinfo { |
259 | unsigned int family; | 278 | unsigned int family; |
279 | unsigned int proto; | ||
280 | unsigned int eth_proto; | ||
260 | struct module *owner; | 281 | struct module *owner; |
261 | struct xfrm_type *type_map[IPPROTO_MAX]; | 282 | const struct xfrm_type *type_map[IPPROTO_MAX]; |
262 | struct xfrm_mode *mode_map[XFRM_MODE_MAX]; | 283 | struct xfrm_mode *mode_map[XFRM_MODE_MAX]; |
263 | int (*init_flags)(struct xfrm_state *x); | 284 | int (*init_flags)(struct xfrm_state *x); |
264 | void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, | 285 | void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, |
@@ -267,6 +288,12 @@ struct xfrm_state_afinfo { | |||
267 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); | 288 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); |
268 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); | 289 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); |
269 | int (*output)(struct sk_buff *skb); | 290 | int (*output)(struct sk_buff *skb); |
291 | int (*extract_input)(struct xfrm_state *x, | ||
292 | struct sk_buff *skb); | ||
293 | int (*extract_output)(struct xfrm_state *x, | ||
294 | struct sk_buff *skb); | ||
295 | int (*transport_finish)(struct sk_buff *skb, | ||
296 | int async); | ||
270 | }; | 297 | }; |
271 | 298 | ||
272 | extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); | 299 | extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); |
@@ -282,6 +309,8 @@ struct xfrm_type | |||
282 | __u8 flags; | 309 | __u8 flags; |
283 | #define XFRM_TYPE_NON_FRAGMENT 1 | 310 | #define XFRM_TYPE_NON_FRAGMENT 1 |
284 | #define XFRM_TYPE_REPLAY_PROT 2 | 311 | #define XFRM_TYPE_REPLAY_PROT 2 |
312 | #define XFRM_TYPE_LOCAL_COADDR 4 | ||
313 | #define XFRM_TYPE_REMOTE_COADDR 8 | ||
285 | 314 | ||
286 | int (*init_state)(struct xfrm_state *x); | 315 | int (*init_state)(struct xfrm_state *x); |
287 | void (*destructor)(struct xfrm_state *); | 316 | void (*destructor)(struct xfrm_state *); |
@@ -289,16 +318,35 @@ struct xfrm_type | |||
289 | int (*output)(struct xfrm_state *, struct sk_buff *pskb); | 318 | int (*output)(struct xfrm_state *, struct sk_buff *pskb); |
290 | int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); | 319 | int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); |
291 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); | 320 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); |
292 | xfrm_address_t *(*local_addr)(struct xfrm_state *, xfrm_address_t *); | ||
293 | xfrm_address_t *(*remote_addr)(struct xfrm_state *, xfrm_address_t *); | ||
294 | /* Estimate maximal size of result of transformation of a dgram */ | 321 | /* Estimate maximal size of result of transformation of a dgram */ |
295 | u32 (*get_mtu)(struct xfrm_state *, int size); | 322 | u32 (*get_mtu)(struct xfrm_state *, int size); |
296 | }; | 323 | }; |
297 | 324 | ||
298 | extern int xfrm_register_type(struct xfrm_type *type, unsigned short family); | 325 | extern int xfrm_register_type(const struct xfrm_type *type, unsigned short family); |
299 | extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family); | 326 | extern int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family); |
300 | 327 | ||
301 | struct xfrm_mode { | 328 | struct xfrm_mode { |
329 | /* | ||
330 | * Remove encapsulation header. | ||
331 | * | ||
332 | * The IP header will be moved over the top of the encapsulation | ||
333 | * header. | ||
334 | * | ||
335 | * On entry, the transport header shall point to where the IP header | ||
336 | * should be and the network header shall be set to where the IP | ||
337 | * header currently is. skb->data shall point to the start of the | ||
338 | * payload. | ||
339 | */ | ||
340 | int (*input2)(struct xfrm_state *x, struct sk_buff *skb); | ||
341 | |||
342 | /* | ||
343 | * This is the actual input entry point. | ||
344 | * | ||
345 | * For transport mode and equivalent this would be identical to | ||
346 | * input2 (which does not need to be set). While tunnel mode | ||
347 | * and equivalent would set this to the tunnel encapsulation function | ||
348 | * xfrm4_prepare_input that would in turn call input2. | ||
349 | */ | ||
302 | int (*input)(struct xfrm_state *x, struct sk_buff *skb); | 350 | int (*input)(struct xfrm_state *x, struct sk_buff *skb); |
303 | 351 | ||
304 | /* | 352 | /* |
@@ -312,7 +360,18 @@ struct xfrm_mode { | |||
312 | * header. The value of the network header will always point | 360 | * header. The value of the network header will always point |
313 | * to the top IP header while skb->data will point to the payload. | 361 | * to the top IP header while skb->data will point to the payload. |
314 | */ | 362 | */ |
315 | int (*output)(struct xfrm_state *x,struct sk_buff *skb); | 363 | int (*output2)(struct xfrm_state *x,struct sk_buff *skb); |
364 | |||
365 | /* | ||
366 | * This is the actual output entry point. | ||
367 | * | ||
368 | * For transport mode and equivalent this would be identical to | ||
369 | * output2 (which does not need to be set). While tunnel mode | ||
370 | * and equivalent would set this to a tunnel encapsulation function | ||
371 | * (xfrm4_prepare_output or xfrm6_prepare_output) that would in turn | ||
372 | * call output2. | ||
373 | */ | ||
374 | int (*output)(struct xfrm_state *x, struct sk_buff *skb); | ||
316 | 375 | ||
317 | struct xfrm_state_afinfo *afinfo; | 376 | struct xfrm_state_afinfo *afinfo; |
318 | struct module *owner; | 377 | struct module *owner; |
@@ -454,6 +513,51 @@ struct xfrm_skb_cb { | |||
454 | 513 | ||
455 | #define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0])) | 514 | #define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0])) |
456 | 515 | ||
516 | /* | ||
517 | * This structure is used by the afinfo prepare_input/prepare_output functions | ||
518 | * to transmit header information to the mode input/output functions. | ||
519 | */ | ||
520 | struct xfrm_mode_skb_cb { | ||
521 | union { | ||
522 | struct inet_skb_parm h4; | ||
523 | struct inet6_skb_parm h6; | ||
524 | } header; | ||
525 | |||
526 | /* Copied from header for IPv4, always set to zero and DF for IPv6. */ | ||
527 | __be16 id; | ||
528 | __be16 frag_off; | ||
529 | |||
530 | /* TOS for IPv4, class for IPv6. */ | ||
531 | u8 tos; | ||
532 | |||
533 | /* TTL for IPv4, hop limitfor IPv6. */ | ||
534 | u8 ttl; | ||
535 | |||
536 | /* Protocol for IPv4, NH for IPv6. */ | ||
537 | u8 protocol; | ||
538 | |||
539 | /* Used by IPv6 only, zero for IPv4. */ | ||
540 | u8 flow_lbl[3]; | ||
541 | }; | ||
542 | |||
543 | #define XFRM_MODE_SKB_CB(__skb) ((struct xfrm_mode_skb_cb *)&((__skb)->cb[0])) | ||
544 | |||
545 | /* | ||
546 | * This structure is used by the input processing to locate the SPI and | ||
547 | * related information. | ||
548 | */ | ||
549 | struct xfrm_spi_skb_cb { | ||
550 | union { | ||
551 | struct inet_skb_parm h4; | ||
552 | struct inet6_skb_parm h6; | ||
553 | } header; | ||
554 | |||
555 | unsigned int daddroff; | ||
556 | unsigned int family; | ||
557 | }; | ||
558 | |||
559 | #define XFRM_SPI_SKB_CB(__skb) ((struct xfrm_spi_skb_cb *)&((__skb)->cb[0])) | ||
560 | |||
457 | /* Audit Information */ | 561 | /* Audit Information */ |
458 | struct xfrm_audit | 562 | struct xfrm_audit |
459 | { | 563 | { |
@@ -462,41 +566,59 @@ struct xfrm_audit | |||
462 | }; | 566 | }; |
463 | 567 | ||
464 | #ifdef CONFIG_AUDITSYSCALL | 568 | #ifdef CONFIG_AUDITSYSCALL |
465 | static inline struct audit_buffer *xfrm_audit_start(u32 auid, u32 sid) | 569 | static inline struct audit_buffer *xfrm_audit_start(const char *op) |
466 | { | 570 | { |
467 | struct audit_buffer *audit_buf = NULL; | 571 | struct audit_buffer *audit_buf = NULL; |
468 | char *secctx; | ||
469 | u32 secctx_len; | ||
470 | 572 | ||
573 | if (audit_enabled == 0) | ||
574 | return NULL; | ||
471 | audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, | 575 | audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, |
472 | AUDIT_MAC_IPSEC_EVENT); | 576 | AUDIT_MAC_IPSEC_EVENT); |
473 | if (audit_buf == NULL) | 577 | if (audit_buf == NULL) |
474 | return NULL; | 578 | return NULL; |
579 | audit_log_format(audit_buf, "op=%s", op); | ||
580 | return audit_buf; | ||
581 | } | ||
475 | 582 | ||
476 | audit_log_format(audit_buf, "auid=%u", auid); | 583 | static inline void xfrm_audit_helper_usrinfo(u32 auid, u32 secid, |
584 | struct audit_buffer *audit_buf) | ||
585 | { | ||
586 | char *secctx; | ||
587 | u32 secctx_len; | ||
477 | 588 | ||
478 | if (sid != 0 && | 589 | audit_log_format(audit_buf, " auid=%u", auid); |
479 | security_secid_to_secctx(sid, &secctx, &secctx_len) == 0) { | 590 | if (secid != 0 && |
591 | security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) { | ||
480 | audit_log_format(audit_buf, " subj=%s", secctx); | 592 | audit_log_format(audit_buf, " subj=%s", secctx); |
481 | security_release_secctx(secctx, secctx_len); | 593 | security_release_secctx(secctx, secctx_len); |
482 | } else | 594 | } else |
483 | audit_log_task_context(audit_buf); | 595 | audit_log_task_context(audit_buf); |
484 | return audit_buf; | ||
485 | } | 596 | } |
486 | 597 | ||
487 | extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, | 598 | extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, |
488 | u32 auid, u32 sid); | 599 | u32 auid, u32 secid); |
489 | extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, | 600 | extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, |
490 | u32 auid, u32 sid); | 601 | u32 auid, u32 secid); |
491 | extern void xfrm_audit_state_add(struct xfrm_state *x, int result, | 602 | extern void xfrm_audit_state_add(struct xfrm_state *x, int result, |
492 | u32 auid, u32 sid); | 603 | u32 auid, u32 secid); |
493 | extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, | 604 | extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, |
494 | u32 auid, u32 sid); | 605 | u32 auid, u32 secid); |
606 | extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, | ||
607 | struct sk_buff *skb); | ||
608 | extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); | ||
609 | extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, | ||
610 | __be32 net_spi, __be32 net_seq); | ||
611 | extern void xfrm_audit_state_icvfail(struct xfrm_state *x, | ||
612 | struct sk_buff *skb, u8 proto); | ||
495 | #else | 613 | #else |
496 | #define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) | 614 | #define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) |
497 | #define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) | 615 | #define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) |
498 | #define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) | 616 | #define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) |
499 | #define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) | 617 | #define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) |
618 | #define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0) | ||
619 | #define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0) | ||
620 | #define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0) | ||
621 | #define xfrm_audit_state_icvfail(x, s, p) do { ; } while (0) | ||
500 | #endif /* CONFIG_AUDITSYSCALL */ | 622 | #endif /* CONFIG_AUDITSYSCALL */ |
501 | 623 | ||
502 | static inline void xfrm_pol_hold(struct xfrm_policy *policy) | 624 | static inline void xfrm_pol_hold(struct xfrm_policy *policy) |
@@ -505,12 +627,12 @@ static inline void xfrm_pol_hold(struct xfrm_policy *policy) | |||
505 | atomic_inc(&policy->refcnt); | 627 | atomic_inc(&policy->refcnt); |
506 | } | 628 | } |
507 | 629 | ||
508 | extern void __xfrm_policy_destroy(struct xfrm_policy *policy); | 630 | extern void xfrm_policy_destroy(struct xfrm_policy *policy); |
509 | 631 | ||
510 | static inline void xfrm_pol_put(struct xfrm_policy *policy) | 632 | static inline void xfrm_pol_put(struct xfrm_policy *policy) |
511 | { | 633 | { |
512 | if (atomic_dec_and_test(&policy->refcnt)) | 634 | if (atomic_dec_and_test(&policy->refcnt)) |
513 | __xfrm_policy_destroy(policy); | 635 | xfrm_policy_destroy(policy); |
514 | } | 636 | } |
515 | 637 | ||
516 | #ifdef CONFIG_XFRM_SUB_POLICY | 638 | #ifdef CONFIG_XFRM_SUB_POLICY |
@@ -757,17 +879,25 @@ xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short | |||
757 | } | 879 | } |
758 | 880 | ||
759 | #ifdef CONFIG_XFRM | 881 | #ifdef CONFIG_XFRM |
760 | |||
761 | extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); | 882 | extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); |
762 | 883 | ||
763 | static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) | 884 | static inline int __xfrm_policy_check2(struct sock *sk, int dir, |
885 | struct sk_buff *skb, | ||
886 | unsigned int family, int reverse) | ||
764 | { | 887 | { |
888 | int ndir = dir | (reverse ? XFRM_POLICY_MASK + 1 : 0); | ||
889 | |||
765 | if (sk && sk->sk_policy[XFRM_POLICY_IN]) | 890 | if (sk && sk->sk_policy[XFRM_POLICY_IN]) |
766 | return __xfrm_policy_check(sk, dir, skb, family); | 891 | return __xfrm_policy_check(sk, ndir, skb, family); |
767 | 892 | ||
768 | return (!xfrm_policy_count[dir] && !skb->sp) || | 893 | return (!xfrm_policy_count[dir] && !skb->sp) || |
769 | (skb->dst->flags & DST_NOPOLICY) || | 894 | (skb->dst->flags & DST_NOPOLICY) || |
770 | __xfrm_policy_check(sk, dir, skb, family); | 895 | __xfrm_policy_check(sk, ndir, skb, family); |
896 | } | ||
897 | |||
898 | static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) | ||
899 | { | ||
900 | return __xfrm_policy_check2(sk, dir, skb, family, 0); | ||
771 | } | 901 | } |
772 | 902 | ||
773 | static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) | 903 | static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) |
@@ -780,7 +910,34 @@ static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *s | |||
780 | return xfrm_policy_check(sk, dir, skb, AF_INET6); | 910 | return xfrm_policy_check(sk, dir, skb, AF_INET6); |
781 | } | 911 | } |
782 | 912 | ||
783 | extern int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, unsigned short family); | 913 | static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir, |
914 | struct sk_buff *skb) | ||
915 | { | ||
916 | return __xfrm_policy_check2(sk, dir, skb, AF_INET, 1); | ||
917 | } | ||
918 | |||
919 | static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir, | ||
920 | struct sk_buff *skb) | ||
921 | { | ||
922 | return __xfrm_policy_check2(sk, dir, skb, AF_INET6, 1); | ||
923 | } | ||
924 | |||
925 | extern int __xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, | ||
926 | unsigned int family, int reverse); | ||
927 | |||
928 | static inline int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, | ||
929 | unsigned int family) | ||
930 | { | ||
931 | return __xfrm_decode_session(skb, fl, family, 0); | ||
932 | } | ||
933 | |||
934 | static inline int xfrm_decode_session_reverse(struct sk_buff *skb, | ||
935 | struct flowi *fl, | ||
936 | unsigned int family) | ||
937 | { | ||
938 | return __xfrm_decode_session(skb, fl, family, 1); | ||
939 | } | ||
940 | |||
784 | extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); | 941 | extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); |
785 | 942 | ||
786 | static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) | 943 | static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) |
@@ -841,6 +998,22 @@ static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *sk | |||
841 | { | 998 | { |
842 | return 1; | 999 | return 1; |
843 | } | 1000 | } |
1001 | static inline int xfrm_decode_session_reverse(struct sk_buff *skb, | ||
1002 | struct flowi *fl, | ||
1003 | unsigned int family) | ||
1004 | { | ||
1005 | return -ENOSYS; | ||
1006 | } | ||
1007 | static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir, | ||
1008 | struct sk_buff *skb) | ||
1009 | { | ||
1010 | return 1; | ||
1011 | } | ||
1012 | static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir, | ||
1013 | struct sk_buff *skb) | ||
1014 | { | ||
1015 | return 1; | ||
1016 | } | ||
844 | #endif | 1017 | #endif |
845 | 1018 | ||
846 | static __inline__ | 1019 | static __inline__ |
@@ -936,6 +1109,10 @@ static inline int xfrm_id_proto_match(u8 proto, u8 userproto) | |||
936 | /* | 1109 | /* |
937 | * xfrm algorithm information | 1110 | * xfrm algorithm information |
938 | */ | 1111 | */ |
1112 | struct xfrm_algo_aead_info { | ||
1113 | u16 icv_truncbits; | ||
1114 | }; | ||
1115 | |||
939 | struct xfrm_algo_auth_info { | 1116 | struct xfrm_algo_auth_info { |
940 | u16 icv_truncbits; | 1117 | u16 icv_truncbits; |
941 | u16 icv_fullbits; | 1118 | u16 icv_fullbits; |
@@ -955,6 +1132,7 @@ struct xfrm_algo_desc { | |||
955 | char *compat; | 1132 | char *compat; |
956 | u8 available:1; | 1133 | u8 available:1; |
957 | union { | 1134 | union { |
1135 | struct xfrm_algo_aead_info aead; | ||
958 | struct xfrm_algo_auth_info auth; | 1136 | struct xfrm_algo_auth_info auth; |
959 | struct xfrm_algo_encr_info encr; | 1137 | struct xfrm_algo_encr_info encr; |
960 | struct xfrm_algo_comp_info comp; | 1138 | struct xfrm_algo_comp_info comp; |
@@ -981,12 +1159,27 @@ struct xfrm6_tunnel { | |||
981 | 1159 | ||
982 | extern void xfrm_init(void); | 1160 | extern void xfrm_init(void); |
983 | extern void xfrm4_init(void); | 1161 | extern void xfrm4_init(void); |
984 | extern void xfrm6_init(void); | ||
985 | extern void xfrm6_fini(void); | ||
986 | extern void xfrm_state_init(void); | 1162 | extern void xfrm_state_init(void); |
987 | extern void xfrm4_state_init(void); | 1163 | extern void xfrm4_state_init(void); |
988 | extern void xfrm6_state_init(void); | 1164 | #ifdef CONFIG_XFRM |
1165 | extern int xfrm6_init(void); | ||
1166 | extern void xfrm6_fini(void); | ||
1167 | extern int xfrm6_state_init(void); | ||
989 | extern void xfrm6_state_fini(void); | 1168 | extern void xfrm6_state_fini(void); |
1169 | #else | ||
1170 | static inline int xfrm6_init(void) | ||
1171 | { | ||
1172 | return 0; | ||
1173 | } | ||
1174 | static inline void xfrm6_fini(void) | ||
1175 | { | ||
1176 | ; | ||
1177 | } | ||
1178 | #endif | ||
1179 | |||
1180 | #ifdef CONFIG_XFRM_STATISTICS | ||
1181 | extern int xfrm_proc_init(void); | ||
1182 | #endif | ||
990 | 1183 | ||
991 | extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); | 1184 | extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); |
992 | extern struct xfrm_state *xfrm_state_alloc(void); | 1185 | extern struct xfrm_state *xfrm_state_alloc(void); |
@@ -1045,14 +1238,23 @@ extern int xfrm_state_delete(struct xfrm_state *x); | |||
1045 | extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); | 1238 | extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); |
1046 | extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si); | 1239 | extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si); |
1047 | extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si); | 1240 | extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si); |
1048 | extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); | 1241 | extern int xfrm_replay_check(struct xfrm_state *x, |
1242 | struct sk_buff *skb, __be32 seq); | ||
1049 | extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); | 1243 | extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); |
1050 | extern void xfrm_replay_notify(struct xfrm_state *x, int event); | 1244 | extern void xfrm_replay_notify(struct xfrm_state *x, int event); |
1051 | extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); | 1245 | extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); |
1052 | extern int xfrm_init_state(struct xfrm_state *x); | 1246 | extern int xfrm_init_state(struct xfrm_state *x); |
1247 | extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); | ||
1248 | extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, | ||
1249 | int encap_type); | ||
1250 | extern int xfrm_input_resume(struct sk_buff *skb, int nexthdr); | ||
1251 | extern int xfrm_output_resume(struct sk_buff *skb, int err); | ||
1053 | extern int xfrm_output(struct sk_buff *skb); | 1252 | extern int xfrm_output(struct sk_buff *skb); |
1253 | extern int xfrm4_extract_header(struct sk_buff *skb); | ||
1254 | extern int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb); | ||
1054 | extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, | 1255 | extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, |
1055 | int encap_type); | 1256 | int encap_type); |
1257 | extern int xfrm4_transport_finish(struct sk_buff *skb, int async); | ||
1056 | extern int xfrm4_rcv(struct sk_buff *skb); | 1258 | extern int xfrm4_rcv(struct sk_buff *skb); |
1057 | 1259 | ||
1058 | static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | 1260 | static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) |
@@ -1060,10 +1262,15 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | |||
1060 | return xfrm4_rcv_encap(skb, nexthdr, spi, 0); | 1262 | return xfrm4_rcv_encap(skb, nexthdr, spi, 0); |
1061 | } | 1263 | } |
1062 | 1264 | ||
1265 | extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1266 | extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1063 | extern int xfrm4_output(struct sk_buff *skb); | 1267 | extern int xfrm4_output(struct sk_buff *skb); |
1064 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); | 1268 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); |
1065 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); | 1269 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); |
1270 | extern int xfrm6_extract_header(struct sk_buff *skb); | ||
1271 | extern int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb); | ||
1066 | extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); | 1272 | extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); |
1273 | extern int xfrm6_transport_finish(struct sk_buff *skb, int async); | ||
1067 | extern int xfrm6_rcv(struct sk_buff *skb); | 1274 | extern int xfrm6_rcv(struct sk_buff *skb); |
1068 | extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, | 1275 | extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, |
1069 | xfrm_address_t *saddr, u8 proto); | 1276 | xfrm_address_t *saddr, u8 proto); |
@@ -1072,6 +1279,8 @@ extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short | |||
1072 | extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); | 1279 | extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); |
1073 | extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); | 1280 | extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); |
1074 | extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); | 1281 | extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); |
1282 | extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1283 | extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1075 | extern int xfrm6_output(struct sk_buff *skb); | 1284 | extern int xfrm6_output(struct sk_buff *skb); |
1076 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | 1285 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
1077 | u8 **prevhdr); | 1286 | u8 **prevhdr); |
@@ -1079,7 +1288,6 @@ extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | |||
1079 | #ifdef CONFIG_XFRM | 1288 | #ifdef CONFIG_XFRM |
1080 | extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); | 1289 | extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); |
1081 | extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen); | 1290 | extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen); |
1082 | extern int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family); | ||
1083 | #else | 1291 | #else |
1084 | static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) | 1292 | static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) |
1085 | { | 1293 | { |
@@ -1092,11 +1300,6 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) | |||
1092 | kfree_skb(skb); | 1300 | kfree_skb(skb); |
1093 | return 0; | 1301 | return 0; |
1094 | } | 1302 | } |
1095 | |||
1096 | static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family) | ||
1097 | { | ||
1098 | return -EINVAL; | ||
1099 | } | ||
1100 | #endif | 1303 | #endif |
1101 | 1304 | ||
1102 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); | 1305 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); |
@@ -1113,11 +1316,9 @@ extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); | |||
1113 | struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, | 1316 | struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, |
1114 | xfrm_address_t *daddr, xfrm_address_t *saddr, | 1317 | xfrm_address_t *daddr, xfrm_address_t *saddr, |
1115 | int create, unsigned short family); | 1318 | int create, unsigned short family); |
1116 | extern int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info); | ||
1117 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); | 1319 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); |
1118 | extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, | 1320 | extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, |
1119 | struct flowi *fl, int family, int strict); | 1321 | struct flowi *fl, int family, int strict); |
1120 | extern void xfrm_init_pmtu(struct dst_entry *dst); | ||
1121 | 1322 | ||
1122 | #ifdef CONFIG_XFRM_MIGRATE | 1323 | #ifdef CONFIG_XFRM_MIGRATE |
1123 | extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | 1324 | extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, |
@@ -1148,6 +1349,8 @@ extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id); | |||
1148 | extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe); | 1349 | extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe); |
1149 | extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe); | 1350 | extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe); |
1150 | extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe); | 1351 | extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe); |
1352 | extern struct xfrm_algo_desc *xfrm_aead_get_byname(char *name, int icv_len, | ||
1353 | int probe); | ||
1151 | 1354 | ||
1152 | struct hash_desc; | 1355 | struct hash_desc; |
1153 | struct scatterlist; | 1356 | struct scatterlist; |
@@ -1188,10 +1391,15 @@ static inline int xfrm_aevent_is_on(void) | |||
1188 | return ret; | 1391 | return ret; |
1189 | } | 1392 | } |
1190 | 1393 | ||
1394 | static inline int xfrm_alg_len(struct xfrm_algo *alg) | ||
1395 | { | ||
1396 | return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); | ||
1397 | } | ||
1398 | |||
1191 | #ifdef CONFIG_XFRM_MIGRATE | 1399 | #ifdef CONFIG_XFRM_MIGRATE |
1192 | static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) | 1400 | static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) |
1193 | { | 1401 | { |
1194 | return (struct xfrm_algo *)kmemdup(orig, sizeof(*orig) + orig->alg_key_len, GFP_KERNEL); | 1402 | return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); |
1195 | } | 1403 | } |
1196 | 1404 | ||
1197 | static inline void xfrm_states_put(struct xfrm_state **states, int n) | 1405 | static inline void xfrm_states_put(struct xfrm_state **states, int n) |
@@ -1209,4 +1417,9 @@ static inline void xfrm_states_delete(struct xfrm_state **states, int n) | |||
1209 | } | 1417 | } |
1210 | #endif | 1418 | #endif |
1211 | 1419 | ||
1420 | static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb) | ||
1421 | { | ||
1422 | return skb->sp->xvec[skb->sp->len - 1]; | ||
1423 | } | ||
1424 | |||
1212 | #endif /* _NET_XFRM_H */ | 1425 | #endif /* _NET_XFRM_H */ |