aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
Diffstat (limited to 'include/net')
-rw-r--r--include/net/9p/9p.h18
-rw-r--r--include/net/9p/client.h6
-rw-r--r--include/net/9p/transport.h9
-rw-r--r--include/net/bluetooth/bluetooth.h33
-rw-r--r--include/net/bluetooth/hci.h141
-rw-r--r--include/net/bluetooth/hci_core.h173
-rw-r--r--include/net/bluetooth/l2cap.h53
-rw-r--r--include/net/bluetooth/mgmt.h171
-rw-r--r--include/net/bluetooth/smp.h76
-rw-r--r--include/net/caif/cfcnfg.h2
-rw-r--r--include/net/cfg80211.h19
-rw-r--r--include/net/dcbnl.h9
-rw-r--r--include/net/dn.h6
-rw-r--r--include/net/dn_fib.h8
-rw-r--r--include/net/dn_route.h8
-rw-r--r--include/net/dst.h144
-rw-r--r--include/net/dst_ops.h1
-rw-r--r--include/net/flow.h204
-rw-r--r--include/net/gen_stats.h2
-rw-r--r--include/net/genetlink.h3
-rw-r--r--include/net/icmp.h3
-rw-r--r--include/net/ieee80211_radiotap.h25
-rw-r--r--include/net/if_inet6.h16
-rw-r--r--include/net/inet_sock.h31
-rw-r--r--include/net/inetpeer.h44
-rw-r--r--include/net/ip.h24
-rw-r--r--include/net/ip6_fib.h5
-rw-r--r--include/net/ip6_route.h4
-rw-r--r--include/net/ip_fib.h55
-rw-r--r--include/net/ip_vs.h475
-rw-r--r--include/net/ipv6.h40
-rw-r--r--include/net/irda/ircomm_tty.h6
-rw-r--r--include/net/irda/irlap.h2
-rw-r--r--include/net/irda/wrapper.h2
-rw-r--r--include/net/iucv/iucv.h2
-rw-r--r--include/net/iw_handler.h4
-rw-r--r--include/net/mac80211.h119
-rw-r--r--include/net/net_namespace.h2
-rw-r--r--include/net/netevent.h1
-rw-r--r--include/net/netfilter/nf_conntrack.h23
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h15
-rw-r--r--include/net/netfilter/nf_conntrack_extend.h10
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h6
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h2
-rw-r--r--include/net/netfilter/nf_conntrack_timestamp.h65
-rw-r--r--include/net/netfilter/nf_nat.h6
-rw-r--r--include/net/netfilter/nf_nat_core.h4
-rw-r--r--include/net/netfilter/nf_tproxy_core.h12
-rw-r--r--include/net/netlink.h9
-rw-r--r--include/net/netns/conntrack.h4
-rw-r--r--include/net/netns/ipv4.h2
-rw-r--r--include/net/phonet/pep.h23
-rw-r--r--include/net/phonet/phonet.h1
-rw-r--r--include/net/pkt_sched.h2
-rw-r--r--include/net/protocol.h4
-rw-r--r--include/net/rose.h8
-rw-r--r--include/net/route.h166
-rw-r--r--include/net/sch_generic.h62
-rw-r--r--include/net/sctp/structs.h2
-rw-r--r--include/net/snmp.h4
-rw-r--r--include/net/sock.h13
-rw-r--r--include/net/tcp.h16
-rw-r--r--include/net/transp_v6.h6
-rw-r--r--include/net/udp.h13
-rw-r--r--include/net/udplite.h12
-rw-r--r--include/net/wimax.h2
-rw-r--r--include/net/wpan-phy.h2
-rw-r--r--include/net/xfrm.h236
68 files changed, 2094 insertions, 582 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 071fd7a8d781..d2df55b0c213 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -119,7 +119,7 @@ do { \
119 * @P9_TREAD: request to transfer data from a file or directory 119 * @P9_TREAD: request to transfer data from a file or directory
120 * @P9_RREAD: response with data requested 120 * @P9_RREAD: response with data requested
121 * @P9_TWRITE: reuqest to transfer data to a file 121 * @P9_TWRITE: reuqest to transfer data to a file
122 * @P9_RWRITE: response with out much data was transfered to file 122 * @P9_RWRITE: response with out much data was transferred to file
123 * @P9_TCLUNK: forget about a handle to an entity within the file system 123 * @P9_TCLUNK: forget about a handle to an entity within the file system
124 * @P9_RCLUNK: response when server has forgotten about the handle 124 * @P9_RCLUNK: response when server has forgotten about the handle
125 * @P9_TREMOVE: request to remove an entity from the hierarchy 125 * @P9_TREMOVE: request to remove an entity from the hierarchy
@@ -292,7 +292,7 @@ enum p9_perm_t {
292 * 292 *
293 * QID types are a subset of permissions - they are primarily 293 * QID types are a subset of permissions - they are primarily
294 * used to differentiate semantics for a file system entity via 294 * used to differentiate semantics for a file system entity via
295 * a jump-table. Their value is also the most signifigant 16 bits 295 * a jump-table. Their value is also the most significant 16 bits
296 * of the permission_t 296 * of the permission_t
297 * 297 *
298 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat 298 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
@@ -364,8 +364,8 @@ struct p9_qid {
364/** 364/**
365 * struct p9_stat - file system metadata information 365 * struct p9_stat - file system metadata information
366 * @size: length prefix for this stat structure instance 366 * @size: length prefix for this stat structure instance
367 * @type: the type of the server (equivilent to a major number) 367 * @type: the type of the server (equivalent to a major number)
368 * @dev: the sub-type of the server (equivilent to a minor number) 368 * @dev: the sub-type of the server (equivalent to a minor number)
369 * @qid: unique id from the server of type &p9_qid 369 * @qid: unique id from the server of type &p9_qid
370 * @mode: Plan 9 format permissions of type &p9_perm_t 370 * @mode: Plan 9 format permissions of type &p9_perm_t
371 * @atime: Last access/read time 371 * @atime: Last access/read time
@@ -688,7 +688,11 @@ struct p9_rwstat {
688 * @id: protocol operating identifier of type &p9_msg_t 688 * @id: protocol operating identifier of type &p9_msg_t
689 * @tag: transaction id of the request 689 * @tag: transaction id of the request
690 * @offset: used by marshalling routines to track currentposition in buffer 690 * @offset: used by marshalling routines to track currentposition in buffer
691 * @capacity: used by marshalling routines to track total capacity 691 * @capacity: used by marshalling routines to track total malloc'd capacity
692 * @pubuf: Payload user buffer given by the caller
693 * @pubuf: Payload kernel buffer given by the caller
694 * @pbuf_size: pubuf/pkbuf(only one will be !NULL) size to be read/write.
695 * @private: For transport layer's use.
692 * @sdata: payload 696 * @sdata: payload
693 * 697 *
694 * &p9_fcall represents the structure for all 9P RPC 698 * &p9_fcall represents the structure for all 9P RPC
@@ -705,6 +709,10 @@ struct p9_fcall {
705 709
706 size_t offset; 710 size_t offset;
707 size_t capacity; 711 size_t capacity;
712 char __user *pubuf;
713 char *pkbuf;
714 size_t pbuf_size;
715 void *private;
708 716
709 uint8_t *sdata; 717 uint8_t *sdata;
710}; 718};
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index 83ba6a4d58a3..051a99f79769 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -101,7 +101,7 @@ enum p9_req_status_t {
101 * Transport use an array to track outstanding requests 101 * Transport use an array to track outstanding requests
102 * instead of a list. While this may incurr overhead during initial 102 * instead of a list. While this may incurr overhead during initial
103 * allocation or expansion, it makes request lookup much easier as the 103 * allocation or expansion, it makes request lookup much easier as the
104 * tag id is a index into an array. (We use tag+1 so that we can accomodate 104 * tag id is a index into an array. (We use tag+1 so that we can accommodate
105 * the -1 tag for the T_VERSION request). 105 * the -1 tag for the T_VERSION request).
106 * This also has the nice effect of only having to allocate wait_queues 106 * This also has the nice effect of only having to allocate wait_queues
107 * once, instead of constantly allocating and freeing them. Its possible 107 * once, instead of constantly allocating and freeing them. Its possible
@@ -218,8 +218,8 @@ void p9_client_disconnect(struct p9_client *clnt);
218void p9_client_begin_disconnect(struct p9_client *clnt); 218void p9_client_begin_disconnect(struct p9_client *clnt);
219struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, 219struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
220 char *uname, u32 n_uname, char *aname); 220 char *uname, u32 n_uname, char *aname);
221struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, 221struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
222 int clone); 222 char **wnames, int clone);
223int p9_client_open(struct p9_fid *fid, int mode); 223int p9_client_open(struct p9_fid *fid, int mode);
224int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, 224int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
225 char *extension); 225 char *extension);
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index 6d5886efb102..8f08c736c4c3 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -26,11 +26,19 @@
26#ifndef NET_9P_TRANSPORT_H 26#ifndef NET_9P_TRANSPORT_H
27#define NET_9P_TRANSPORT_H 27#define NET_9P_TRANSPORT_H
28 28
29#define P9_TRANS_PREF_PAYLOAD_MASK 0x1
30
31/* Default. Add Payload to PDU before sending it down to transport layer */
32#define P9_TRANS_PREF_PAYLOAD_DEF 0x0
33/* Send pay load separately to transport layer along with PDU.*/
34#define P9_TRANS_PREF_PAYLOAD_SEP 0x1
35
29/** 36/**
30 * struct p9_trans_module - transport module interface 37 * struct p9_trans_module - transport module interface
31 * @list: used to maintain a list of currently available transports 38 * @list: used to maintain a list of currently available transports
32 * @name: the human-readable name of the transport 39 * @name: the human-readable name of the transport
33 * @maxsize: transport provided maximum packet size 40 * @maxsize: transport provided maximum packet size
41 * @pref: Preferences of this transport
34 * @def: set if this transport should be considered the default 42 * @def: set if this transport should be considered the default
35 * @create: member function to create a new connection on this transport 43 * @create: member function to create a new connection on this transport
36 * @request: member function to issue a request to the transport 44 * @request: member function to issue a request to the transport
@@ -47,6 +55,7 @@ struct p9_trans_module {
47 struct list_head list; 55 struct list_head list;
48 char *name; /* name of transport */ 56 char *name; /* name of transport */
49 int maxsize; /* max message size of transport */ 57 int maxsize; /* max message size of transport */
58 int pref; /* Preferences of this transport */
50 int def; /* this transport should be default */ 59 int def; /* this transport should be default */
51 struct module *owner; 60 struct module *owner;
52 int (*create)(struct p9_client *, const char *, char *); 61 int (*create)(struct p9_client *, const char *, char *);
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 0c5e72503b77..43750439c521 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -64,6 +64,11 @@ struct bt_security {
64 64
65#define BT_DEFER_SETUP 7 65#define BT_DEFER_SETUP 7
66 66
67#define BT_FLUSHABLE 8
68
69#define BT_FLUSHABLE_OFF 0
70#define BT_FLUSHABLE_ON 1
71
67#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg) 72#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
68#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg) 73#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
69#define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg) 74#define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg)
@@ -200,4 +205,32 @@ extern void bt_sysfs_cleanup(void);
200 205
201extern struct dentry *bt_debugfs; 206extern struct dentry *bt_debugfs;
202 207
208#ifdef CONFIG_BT_L2CAP
209int l2cap_init(void);
210void l2cap_exit(void);
211#else
212static inline int l2cap_init(void)
213{
214 return 0;
215}
216
217static inline void l2cap_exit(void)
218{
219}
220#endif
221
222#ifdef CONFIG_BT_SCO
223int sco_init(void);
224void sco_exit(void);
225#else
226static inline int sco_init(void)
227{
228 return 0;
229}
230
231static inline void sco_exit(void)
232{
233}
234#endif
235
203#endif /* __BLUETOOTH_H */ 236#endif /* __BLUETOOTH_H */
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 29a7a8ca0438..2c0d309c7381 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -76,6 +76,16 @@ enum {
76 HCI_INQUIRY, 76 HCI_INQUIRY,
77 77
78 HCI_RAW, 78 HCI_RAW,
79
80 HCI_SETUP,
81 HCI_AUTO_OFF,
82 HCI_MGMT,
83 HCI_PAIRABLE,
84 HCI_SERVICE_CACHE,
85 HCI_LINK_KEYS,
86 HCI_DEBUG_KEYS,
87
88 HCI_RESET,
79}; 89};
80 90
81/* HCI ioctl defines */ 91/* HCI ioctl defines */
@@ -111,6 +121,7 @@ enum {
111#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ 121#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */
112#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ 122#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
113#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ 123#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
124#define HCI_CMD_TIMEOUT (1000) /* 1 seconds */
114 125
115/* HCI data types */ 126/* HCI data types */
116#define HCI_COMMAND_PKT 0x01 127#define HCI_COMMAND_PKT 0x01
@@ -150,6 +161,7 @@ enum {
150#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) 161#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
151 162
152/* ACL flags */ 163/* ACL flags */
164#define ACL_START_NO_FLUSH 0x00
153#define ACL_CONT 0x01 165#define ACL_CONT 0x01
154#define ACL_START 0x02 166#define ACL_START 0x02
155#define ACL_ACTIVE_BCAST 0x04 167#define ACL_ACTIVE_BCAST 0x04
@@ -159,6 +171,8 @@ enum {
159#define SCO_LINK 0x00 171#define SCO_LINK 0x00
160#define ACL_LINK 0x01 172#define ACL_LINK 0x01
161#define ESCO_LINK 0x02 173#define ESCO_LINK 0x02
174/* Low Energy links do not have defined link type. Use invented one */
175#define LE_LINK 0x80
162 176
163/* LMP features */ 177/* LMP features */
164#define LMP_3SLOT 0x01 178#define LMP_3SLOT 0x01
@@ -183,17 +197,25 @@ enum {
183#define LMP_PSCHEME 0x02 197#define LMP_PSCHEME 0x02
184#define LMP_PCONTROL 0x04 198#define LMP_PCONTROL 0x04
185 199
200#define LMP_RSSI_INQ 0x40
186#define LMP_ESCO 0x80 201#define LMP_ESCO 0x80
187 202
188#define LMP_EV4 0x01 203#define LMP_EV4 0x01
189#define LMP_EV5 0x02 204#define LMP_EV5 0x02
205#define LMP_LE 0x40
190 206
191#define LMP_SNIFF_SUBR 0x02 207#define LMP_SNIFF_SUBR 0x02
208#define LMP_PAUSE_ENC 0x04
192#define LMP_EDR_ESCO_2M 0x20 209#define LMP_EDR_ESCO_2M 0x20
193#define LMP_EDR_ESCO_3M 0x40 210#define LMP_EDR_ESCO_3M 0x40
194#define LMP_EDR_3S_ESCO 0x80 211#define LMP_EDR_3S_ESCO 0x80
195 212
213#define LMP_EXT_INQ 0x01
196#define LMP_SIMPLE_PAIR 0x08 214#define LMP_SIMPLE_PAIR 0x08
215#define LMP_NO_FLUSH 0x40
216
217#define LMP_LSTO 0x01
218#define LMP_INQ_TX_PWR 0x02
197 219
198/* Connection modes */ 220/* Connection modes */
199#define HCI_CM_ACTIVE 0x0000 221#define HCI_CM_ACTIVE 0x0000
@@ -225,6 +247,8 @@ enum {
225#define HCI_AT_GENERAL_BONDING_MITM 0x05 247#define HCI_AT_GENERAL_BONDING_MITM 0x05
226 248
227/* ----- HCI Commands ---- */ 249/* ----- HCI Commands ---- */
250#define HCI_OP_NOP 0x0000
251
228#define HCI_OP_INQUIRY 0x0401 252#define HCI_OP_INQUIRY 0x0401
229struct hci_cp_inquiry { 253struct hci_cp_inquiry {
230 __u8 lap[3]; 254 __u8 lap[3];
@@ -292,11 +316,19 @@ struct hci_cp_pin_code_reply {
292 __u8 pin_len; 316 __u8 pin_len;
293 __u8 pin_code[16]; 317 __u8 pin_code[16];
294} __packed; 318} __packed;
319struct hci_rp_pin_code_reply {
320 __u8 status;
321 bdaddr_t bdaddr;
322} __packed;
295 323
296#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e 324#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e
297struct hci_cp_pin_code_neg_reply { 325struct hci_cp_pin_code_neg_reply {
298 bdaddr_t bdaddr; 326 bdaddr_t bdaddr;
299} __packed; 327} __packed;
328struct hci_rp_pin_code_neg_reply {
329 __u8 status;
330 bdaddr_t bdaddr;
331} __packed;
300 332
301#define HCI_OP_CHANGE_CONN_PTYPE 0x040f 333#define HCI_OP_CHANGE_CONN_PTYPE 0x040f
302struct hci_cp_change_conn_ptype { 334struct hci_cp_change_conn_ptype {
@@ -377,6 +409,31 @@ struct hci_cp_reject_sync_conn_req {
377 __u8 reason; 409 __u8 reason;
378} __packed; 410} __packed;
379 411
412#define HCI_OP_IO_CAPABILITY_REPLY 0x042b
413struct hci_cp_io_capability_reply {
414 bdaddr_t bdaddr;
415 __u8 capability;
416 __u8 oob_data;
417 __u8 authentication;
418} __packed;
419
420#define HCI_OP_USER_CONFIRM_REPLY 0x042c
421struct hci_cp_user_confirm_reply {
422 bdaddr_t bdaddr;
423} __packed;
424struct hci_rp_user_confirm_reply {
425 __u8 status;
426 bdaddr_t bdaddr;
427} __packed;
428
429#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
430
431#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
432struct hci_cp_io_capability_neg_reply {
433 bdaddr_t bdaddr;
434 __u8 reason;
435} __packed;
436
380#define HCI_OP_SNIFF_MODE 0x0803 437#define HCI_OP_SNIFF_MODE 0x0803
381struct hci_cp_sniff_mode { 438struct hci_cp_sniff_mode {
382 __le16 handle; 439 __le16 handle;
@@ -474,6 +531,12 @@ struct hci_cp_set_event_flt {
474#define HCI_CONN_SETUP_AUTO_OFF 0x01 531#define HCI_CONN_SETUP_AUTO_OFF 0x01
475#define HCI_CONN_SETUP_AUTO_ON 0x02 532#define HCI_CONN_SETUP_AUTO_ON 0x02
476 533
534#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12
535struct hci_cp_delete_stored_link_key {
536 bdaddr_t bdaddr;
537 __u8 delete_all;
538} __packed;
539
477#define HCI_OP_WRITE_LOCAL_NAME 0x0c13 540#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
478struct hci_cp_write_local_name { 541struct hci_cp_write_local_name {
479 __u8 name[248]; 542 __u8 name[248];
@@ -537,6 +600,8 @@ struct hci_cp_host_buffer_size {
537 __le16 sco_max_pkt; 600 __le16 sco_max_pkt;
538} __packed; 601} __packed;
539 602
603#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
604
540#define HCI_OP_READ_SSP_MODE 0x0c55 605#define HCI_OP_READ_SSP_MODE 0x0c55
541struct hci_rp_read_ssp_mode { 606struct hci_rp_read_ssp_mode {
542 __u8 status; 607 __u8 status;
@@ -548,6 +613,8 @@ struct hci_cp_write_ssp_mode {
548 __u8 mode; 613 __u8 mode;
549} __packed; 614} __packed;
550 615
616#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
617
551#define HCI_OP_READ_LOCAL_VERSION 0x1001 618#define HCI_OP_READ_LOCAL_VERSION 0x1001
552struct hci_rp_read_local_version { 619struct hci_rp_read_local_version {
553 __u8 status; 620 __u8 status;
@@ -593,6 +660,47 @@ struct hci_rp_read_bd_addr {
593 bdaddr_t bdaddr; 660 bdaddr_t bdaddr;
594} __packed; 661} __packed;
595 662
663#define HCI_OP_LE_SET_EVENT_MASK 0x2001
664struct hci_cp_le_set_event_mask {
665 __u8 mask[8];
666} __packed;
667
668#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
669struct hci_rp_le_read_buffer_size {
670 __u8 status;
671 __le16 le_mtu;
672 __u8 le_max_pkt;
673} __packed;
674
675#define HCI_OP_LE_CREATE_CONN 0x200d
676struct hci_cp_le_create_conn {
677 __le16 scan_interval;
678 __le16 scan_window;
679 __u8 filter_policy;
680 __u8 peer_addr_type;
681 bdaddr_t peer_addr;
682 __u8 own_address_type;
683 __le16 conn_interval_min;
684 __le16 conn_interval_max;
685 __le16 conn_latency;
686 __le16 supervision_timeout;
687 __le16 min_ce_len;
688 __le16 max_ce_len;
689} __packed;
690
691#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
692
693#define HCI_OP_LE_CONN_UPDATE 0x2013
694struct hci_cp_le_conn_update {
695 __le16 handle;
696 __le16 conn_interval_min;
697 __le16 conn_interval_max;
698 __le16 conn_latency;
699 __le16 supervision_timeout;
700 __le16 min_ce_len;
701 __le16 max_ce_len;
702} __packed;
703
596/* ---- HCI Events ---- */ 704/* ---- HCI Events ---- */
597#define HCI_EV_INQUIRY_COMPLETE 0x01 705#define HCI_EV_INQUIRY_COMPLETE 0x01
598 706
@@ -833,6 +941,20 @@ struct hci_ev_io_capa_request {
833 bdaddr_t bdaddr; 941 bdaddr_t bdaddr;
834} __packed; 942} __packed;
835 943
944#define HCI_EV_IO_CAPA_REPLY 0x32
945struct hci_ev_io_capa_reply {
946 bdaddr_t bdaddr;
947 __u8 capability;
948 __u8 oob_data;
949 __u8 authentication;
950} __packed;
951
952#define HCI_EV_USER_CONFIRM_REQUEST 0x33
953struct hci_ev_user_confirm_req {
954 bdaddr_t bdaddr;
955 __le32 passkey;
956} __packed;
957
836#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 958#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
837struct hci_ev_simple_pair_complete { 959struct hci_ev_simple_pair_complete {
838 __u8 status; 960 __u8 status;
@@ -845,6 +967,25 @@ struct hci_ev_remote_host_features {
845 __u8 features[8]; 967 __u8 features[8];
846} __packed; 968} __packed;
847 969
970#define HCI_EV_LE_META 0x3e
971struct hci_ev_le_meta {
972 __u8 subevent;
973} __packed;
974
975/* Low energy meta events */
976#define HCI_EV_LE_CONN_COMPLETE 0x01
977struct hci_ev_le_conn_complete {
978 __u8 status;
979 __le16 handle;
980 __u8 role;
981 __u8 bdaddr_type;
982 bdaddr_t bdaddr;
983 __le16 interval;
984 __le16 latency;
985 __le16 supervision_timeout;
986 __u8 clk_accurancy;
987} __packed;
988
848/* Internal events generated by Bluetooth stack */ 989/* Internal events generated by Bluetooth stack */
849#define HCI_EV_STACK_INTERNAL 0xfd 990#define HCI_EV_STACK_INTERNAL 0xfd
850struct hci_ev_stack_internal { 991struct hci_ev_stack_internal {
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d2cf88407690..441dadbf6a89 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -60,12 +60,28 @@ struct hci_conn_hash {
60 spinlock_t lock; 60 spinlock_t lock;
61 unsigned int acl_num; 61 unsigned int acl_num;
62 unsigned int sco_num; 62 unsigned int sco_num;
63 unsigned int le_num;
63}; 64};
64 65
65struct bdaddr_list { 66struct bdaddr_list {
66 struct list_head list; 67 struct list_head list;
67 bdaddr_t bdaddr; 68 bdaddr_t bdaddr;
68}; 69};
70
71struct bt_uuid {
72 struct list_head list;
73 u8 uuid[16];
74 u8 svc_hint;
75};
76
77struct link_key {
78 struct list_head list;
79 bdaddr_t bdaddr;
80 u8 type;
81 u8 val[16];
82 u8 pin_len;
83};
84
69#define NUM_REASSEMBLY 4 85#define NUM_REASSEMBLY 4
70struct hci_dev { 86struct hci_dev {
71 struct list_head list; 87 struct list_head list;
@@ -80,13 +96,18 @@ struct hci_dev {
80 bdaddr_t bdaddr; 96 bdaddr_t bdaddr;
81 __u8 dev_name[248]; 97 __u8 dev_name[248];
82 __u8 dev_class[3]; 98 __u8 dev_class[3];
99 __u8 major_class;
100 __u8 minor_class;
83 __u8 features[8]; 101 __u8 features[8];
84 __u8 commands[64]; 102 __u8 commands[64];
85 __u8 ssp_mode; 103 __u8 ssp_mode;
86 __u8 hci_ver; 104 __u8 hci_ver;
87 __u16 hci_rev; 105 __u16 hci_rev;
106 __u8 lmp_ver;
88 __u16 manufacturer; 107 __u16 manufacturer;
108 __le16 lmp_subver;
89 __u16 voice_setting; 109 __u16 voice_setting;
110 __u8 io_capability;
90 111
91 __u16 pkt_type; 112 __u16 pkt_type;
92 __u16 esco_type; 113 __u16 esco_type;
@@ -102,18 +123,26 @@ struct hci_dev {
102 atomic_t cmd_cnt; 123 atomic_t cmd_cnt;
103 unsigned int acl_cnt; 124 unsigned int acl_cnt;
104 unsigned int sco_cnt; 125 unsigned int sco_cnt;
126 unsigned int le_cnt;
105 127
106 unsigned int acl_mtu; 128 unsigned int acl_mtu;
107 unsigned int sco_mtu; 129 unsigned int sco_mtu;
130 unsigned int le_mtu;
108 unsigned int acl_pkts; 131 unsigned int acl_pkts;
109 unsigned int sco_pkts; 132 unsigned int sco_pkts;
133 unsigned int le_pkts;
110 134
111 unsigned long cmd_last_tx;
112 unsigned long acl_last_tx; 135 unsigned long acl_last_tx;
113 unsigned long sco_last_tx; 136 unsigned long sco_last_tx;
137 unsigned long le_last_tx;
114 138
115 struct workqueue_struct *workqueue; 139 struct workqueue_struct *workqueue;
116 140
141 struct work_struct power_on;
142 struct work_struct power_off;
143 struct timer_list off_timer;
144
145 struct timer_list cmd_timer;
117 struct tasklet_struct cmd_task; 146 struct tasklet_struct cmd_task;
118 struct tasklet_struct rx_task; 147 struct tasklet_struct rx_task;
119 struct tasklet_struct tx_task; 148 struct tasklet_struct tx_task;
@@ -129,12 +158,17 @@ struct hci_dev {
129 wait_queue_head_t req_wait_q; 158 wait_queue_head_t req_wait_q;
130 __u32 req_status; 159 __u32 req_status;
131 __u32 req_result; 160 __u32 req_result;
132 __u16 req_last_cmd; 161
162 __u16 init_last_cmd;
133 163
134 struct inquiry_cache inq_cache; 164 struct inquiry_cache inq_cache;
135 struct hci_conn_hash conn_hash; 165 struct hci_conn_hash conn_hash;
136 struct list_head blacklist; 166 struct list_head blacklist;
137 167
168 struct list_head uuids;
169
170 struct list_head link_keys;
171
138 struct hci_dev_stats stat; 172 struct hci_dev_stats stat;
139 173
140 struct sk_buff_head driver_init; 174 struct sk_buff_head driver_init;
@@ -165,31 +199,37 @@ struct hci_dev {
165struct hci_conn { 199struct hci_conn {
166 struct list_head list; 200 struct list_head list;
167 201
168 atomic_t refcnt; 202 atomic_t refcnt;
169 spinlock_t lock; 203 spinlock_t lock;
170 204
171 bdaddr_t dst; 205 bdaddr_t dst;
172 __u16 handle; 206 __u16 handle;
173 __u16 state; 207 __u16 state;
174 __u8 mode; 208 __u8 mode;
175 __u8 type; 209 __u8 type;
176 __u8 out; 210 __u8 out;
177 __u8 attempt; 211 __u8 attempt;
178 __u8 dev_class[3]; 212 __u8 dev_class[3];
179 __u8 features[8]; 213 __u8 features[8];
180 __u8 ssp_mode; 214 __u8 ssp_mode;
181 __u16 interval; 215 __u16 interval;
182 __u16 pkt_type; 216 __u16 pkt_type;
183 __u16 link_policy; 217 __u16 link_policy;
184 __u32 link_mode; 218 __u32 link_mode;
185 __u8 auth_type; 219 __u8 auth_type;
186 __u8 sec_level; 220 __u8 sec_level;
187 __u8 pending_sec_level; 221 __u8 pending_sec_level;
188 __u8 power_save; 222 __u8 pin_length;
189 __u16 disc_timeout; 223 __u8 io_capability;
190 unsigned long pend; 224 __u8 power_save;
191 225 __u16 disc_timeout;
192 unsigned int sent; 226 unsigned long pend;
227
228 __u8 remote_cap;
229 __u8 remote_oob;
230 __u8 remote_auth;
231
232 unsigned int sent;
193 233
194 struct sk_buff_head data_q; 234 struct sk_buff_head data_q;
195 235
@@ -208,6 +248,10 @@ struct hci_conn {
208 void *priv; 248 void *priv;
209 249
210 struct hci_conn *link; 250 struct hci_conn *link;
251
252 void (*connect_cfm_cb) (struct hci_conn *conn, u8 status);
253 void (*security_cfm_cb) (struct hci_conn *conn, u8 status);
254 void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason);
211}; 255};
212 256
213extern struct hci_proto *hci_proto[]; 257extern struct hci_proto *hci_proto[];
@@ -274,24 +318,40 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
274{ 318{
275 struct hci_conn_hash *h = &hdev->conn_hash; 319 struct hci_conn_hash *h = &hdev->conn_hash;
276 list_add(&c->list, &h->list); 320 list_add(&c->list, &h->list);
277 if (c->type == ACL_LINK) 321 switch (c->type) {
322 case ACL_LINK:
278 h->acl_num++; 323 h->acl_num++;
279 else 324 break;
325 case LE_LINK:
326 h->le_num++;
327 break;
328 case SCO_LINK:
329 case ESCO_LINK:
280 h->sco_num++; 330 h->sco_num++;
331 break;
332 }
281} 333}
282 334
283static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) 335static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
284{ 336{
285 struct hci_conn_hash *h = &hdev->conn_hash; 337 struct hci_conn_hash *h = &hdev->conn_hash;
286 list_del(&c->list); 338 list_del(&c->list);
287 if (c->type == ACL_LINK) 339 switch (c->type) {
340 case ACL_LINK:
288 h->acl_num--; 341 h->acl_num--;
289 else 342 break;
343 case LE_LINK:
344 h->le_num--;
345 break;
346 case SCO_LINK:
347 case ESCO_LINK:
290 h->sco_num--; 348 h->sco_num--;
349 break;
350 }
291} 351}
292 352
293static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, 353static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
294 __u16 handle) 354 __u16 handle)
295{ 355{
296 struct hci_conn_hash *h = &hdev->conn_hash; 356 struct hci_conn_hash *h = &hdev->conn_hash;
297 struct list_head *p; 357 struct list_head *p;
@@ -306,7 +366,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
306} 366}
307 367
308static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, 368static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
309 __u8 type, bdaddr_t *ba) 369 __u8 type, bdaddr_t *ba)
310{ 370{
311 struct hci_conn_hash *h = &hdev->conn_hash; 371 struct hci_conn_hash *h = &hdev->conn_hash;
312 struct list_head *p; 372 struct list_head *p;
@@ -321,7 +381,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev,
321} 381}
322 382
323static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, 383static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
324 __u8 type, __u16 state) 384 __u8 type, __u16 state)
325{ 385{
326 struct hci_conn_hash *h = &hdev->conn_hash; 386 struct hci_conn_hash *h = &hdev->conn_hash;
327 struct list_head *p; 387 struct list_head *p;
@@ -437,6 +497,16 @@ int hci_inquiry(void __user *arg);
437struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); 497struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
438int hci_blacklist_clear(struct hci_dev *hdev); 498int hci_blacklist_clear(struct hci_dev *hdev);
439 499
500int hci_uuids_clear(struct hci_dev *hdev);
501
502int hci_link_keys_clear(struct hci_dev *hdev);
503struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
504int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,
505 u8 *key, u8 type, u8 pin_len);
506int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
507
508void hci_del_off_timer(struct hci_dev *hdev);
509
440void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 510void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
441 511
442int hci_recv_frame(struct sk_buff *skb); 512int hci_recv_frame(struct sk_buff *skb);
@@ -458,6 +528,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
458#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) 528#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
459#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) 529#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
460#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) 530#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
531#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
532#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE)
461 533
462/* ----- HCI protocols ----- */ 534/* ----- HCI protocols ----- */
463struct hci_proto { 535struct hci_proto {
@@ -503,6 +575,9 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status)
503 hp = hci_proto[HCI_PROTO_SCO]; 575 hp = hci_proto[HCI_PROTO_SCO];
504 if (hp && hp->connect_cfm) 576 if (hp && hp->connect_cfm)
505 hp->connect_cfm(conn, status); 577 hp->connect_cfm(conn, status);
578
579 if (conn->connect_cfm_cb)
580 conn->connect_cfm_cb(conn, status);
506} 581}
507 582
508static inline int hci_proto_disconn_ind(struct hci_conn *conn) 583static inline int hci_proto_disconn_ind(struct hci_conn *conn)
@@ -532,6 +607,9 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason)
532 hp = hci_proto[HCI_PROTO_SCO]; 607 hp = hci_proto[HCI_PROTO_SCO];
533 if (hp && hp->disconn_cfm) 608 if (hp && hp->disconn_cfm)
534 hp->disconn_cfm(conn, reason); 609 hp->disconn_cfm(conn, reason);
610
611 if (conn->disconn_cfm_cb)
612 conn->disconn_cfm_cb(conn, reason);
535} 613}
536 614
537static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) 615static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)
@@ -551,6 +629,9 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status)
551 hp = hci_proto[HCI_PROTO_SCO]; 629 hp = hci_proto[HCI_PROTO_SCO];
552 if (hp && hp->security_cfm) 630 if (hp && hp->security_cfm)
553 hp->security_cfm(conn, status, encrypt); 631 hp->security_cfm(conn, status, encrypt);
632
633 if (conn->security_cfm_cb)
634 conn->security_cfm_cb(conn, status);
554} 635}
555 636
556static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt) 637static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt)
@@ -564,6 +645,9 @@ static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u
564 hp = hci_proto[HCI_PROTO_SCO]; 645 hp = hci_proto[HCI_PROTO_SCO];
565 if (hp && hp->security_cfm) 646 if (hp && hp->security_cfm)
566 hp->security_cfm(conn, status, encrypt); 647 hp->security_cfm(conn, status, encrypt);
648
649 if (conn->security_cfm_cb)
650 conn->security_cfm_cb(conn, status);
567} 651}
568 652
569int hci_register_proto(struct hci_proto *hproto); 653int hci_register_proto(struct hci_proto *hproto);
@@ -660,12 +744,29 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode);
660void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); 744void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data);
661 745
662/* ----- HCI Sockets ----- */ 746/* ----- HCI Sockets ----- */
663void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); 747void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb,
748 struct sock *skip_sk);
664 749
665/* Management interface */ 750/* Management interface */
666int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); 751int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
667int mgmt_index_added(u16 index); 752int mgmt_index_added(u16 index);
668int mgmt_index_removed(u16 index); 753int mgmt_index_removed(u16 index);
754int mgmt_powered(u16 index, u8 powered);
755int mgmt_discoverable(u16 index, u8 discoverable);
756int mgmt_connectable(u16 index, u8 connectable);
757int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type);
758int mgmt_connected(u16 index, bdaddr_t *bdaddr);
759int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
760int mgmt_disconnect_failed(u16 index);
761int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);
762int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr);
763int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
764int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
765int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value);
766int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
767int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr,
768 u8 status);
769int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);
669 770
670/* HCI info for socket */ 771/* HCI info for socket */
671#define hci_pi(sk) ((struct hci_pinfo *) sk) 772#define hci_pi(sk) ((struct hci_pinfo *) sk)
@@ -697,4 +798,6 @@ struct hci_sec_filter {
697 798
698void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); 799void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
699 800
801void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
802 u16 latency, u16 to_multiplier);
700#endif /* __HCI_CORE_H */ 803#endif /* __HCI_CORE_H */
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 7ad25ca60ec0..4f4bff1eaed6 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -38,6 +38,7 @@
38#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ 38#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */
39#define L2CAP_DEFAULT_ACK_TO 200 39#define L2CAP_DEFAULT_ACK_TO 200
40#define L2CAP_LOCAL_BUSY_TRIES 12 40#define L2CAP_LOCAL_BUSY_TRIES 12
41#define L2CAP_LE_DEFAULT_MTU 23
41 42
42#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 43#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
43#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ 44#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */
@@ -88,6 +89,8 @@ struct l2cap_conninfo {
88#define L2CAP_ECHO_RSP 0x09 89#define L2CAP_ECHO_RSP 0x09
89#define L2CAP_INFO_REQ 0x0a 90#define L2CAP_INFO_REQ 0x0a
90#define L2CAP_INFO_RSP 0x0b 91#define L2CAP_INFO_RSP 0x0b
92#define L2CAP_CONN_PARAM_UPDATE_REQ 0x12
93#define L2CAP_CONN_PARAM_UPDATE_RSP 0x13
91 94
92/* L2CAP feature mask */ 95/* L2CAP feature mask */
93#define L2CAP_FEAT_FLOWCTL 0x00000001 96#define L2CAP_FEAT_FLOWCTL 0x00000001
@@ -160,6 +163,9 @@ struct l2cap_conn_rsp {
160/* channel indentifier */ 163/* channel indentifier */
161#define L2CAP_CID_SIGNALING 0x0001 164#define L2CAP_CID_SIGNALING 0x0001
162#define L2CAP_CID_CONN_LESS 0x0002 165#define L2CAP_CID_CONN_LESS 0x0002
166#define L2CAP_CID_LE_DATA 0x0004
167#define L2CAP_CID_LE_SIGNALING 0x0005
168#define L2CAP_CID_SMP 0x0006
163#define L2CAP_CID_DYN_START 0x0040 169#define L2CAP_CID_DYN_START 0x0040
164#define L2CAP_CID_DYN_END 0xffff 170#define L2CAP_CID_DYN_END 0xffff
165 171
@@ -255,6 +261,21 @@ struct l2cap_info_rsp {
255#define L2CAP_IR_SUCCESS 0x0000 261#define L2CAP_IR_SUCCESS 0x0000
256#define L2CAP_IR_NOTSUPP 0x0001 262#define L2CAP_IR_NOTSUPP 0x0001
257 263
264struct l2cap_conn_param_update_req {
265 __le16 min;
266 __le16 max;
267 __le16 latency;
268 __le16 to_multiplier;
269} __packed;
270
271struct l2cap_conn_param_update_rsp {
272 __le16 result;
273} __packed;
274
275/* Connection Parameters result */
276#define L2CAP_CONN_PARAM_ACCEPTED 0x0000
277#define L2CAP_CONN_PARAM_REJECTED 0x0001
278
258/* ----- L2CAP connections ----- */ 279/* ----- L2CAP connections ----- */
259struct l2cap_chan_list { 280struct l2cap_chan_list {
260 struct sock *head; 281 struct sock *head;
@@ -327,6 +348,7 @@ struct l2cap_pinfo {
327 __u8 sec_level; 348 __u8 sec_level;
328 __u8 role_switch; 349 __u8 role_switch;
329 __u8 force_reliable; 350 __u8 force_reliable;
351 __u8 flushable;
330 352
331 __u8 conf_req[64]; 353 __u8 conf_req[64];
332 __u8 conf_len; 354 __u8 conf_len;
@@ -423,6 +445,35 @@ static inline int l2cap_tx_window_full(struct sock *sk)
423#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) 445#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE)
424#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) 446#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START)
425 447
426void l2cap_load(void); 448extern int disable_ertm;
449extern const struct proto_ops l2cap_sock_ops;
450extern struct bt_sock_list l2cap_sk_list;
451
452int l2cap_init_sockets(void);
453void l2cap_cleanup_sockets(void);
454
455u8 l2cap_get_ident(struct l2cap_conn *conn);
456void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
457int l2cap_build_conf_req(struct sock *sk, void *data);
458int __l2cap_wait_ack(struct sock *sk);
459
460struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len);
461struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len);
462struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen);
463int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len);
464void l2cap_do_send(struct sock *sk, struct sk_buff *skb);
465void l2cap_streaming_send(struct sock *sk);
466int l2cap_ertm_send(struct sock *sk);
467
468void l2cap_sock_set_timer(struct sock *sk, long timeout);
469void l2cap_sock_clear_timer(struct sock *sk);
470void __l2cap_sock_close(struct sock *sk, int reason);
471void l2cap_sock_kill(struct sock *sk);
472void l2cap_sock_init(struct sock *sk, struct sock *parent);
473struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
474 int proto, gfp_t prio);
475void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err);
476void l2cap_chan_del(struct sock *sk, int err);
477int l2cap_do_connect(struct sock *sk);
427 478
428#endif /* __L2CAP_H */ 479#endif /* __L2CAP_H */
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index ca29c1367ffd..5fabfa886b3e 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -21,11 +21,13 @@
21 SOFTWARE IS DISCLAIMED. 21 SOFTWARE IS DISCLAIMED.
22*/ 22*/
23 23
24#define MGMT_INDEX_NONE 0xFFFF
25
24struct mgmt_hdr { 26struct mgmt_hdr {
25 __le16 opcode; 27 __le16 opcode;
28 __le16 index;
26 __le16 len; 29 __le16 len;
27} __packed; 30} __packed;
28#define MGMT_HDR_SIZE 4
29 31
30#define MGMT_OP_READ_VERSION 0x0001 32#define MGMT_OP_READ_VERSION 0x0001
31struct mgmt_rp_read_version { 33struct mgmt_rp_read_version {
@@ -40,13 +42,10 @@ struct mgmt_rp_read_index_list {
40} __packed; 42} __packed;
41 43
42#define MGMT_OP_READ_INFO 0x0004 44#define MGMT_OP_READ_INFO 0x0004
43struct mgmt_cp_read_info {
44 __le16 index;
45} __packed;
46struct mgmt_rp_read_info { 45struct mgmt_rp_read_info {
47 __le16 index;
48 __u8 type; 46 __u8 type;
49 __u8 powered; 47 __u8 powered;
48 __u8 connectable;
50 __u8 discoverable; 49 __u8 discoverable;
51 __u8 pairable; 50 __u8 pairable;
52 __u8 sec_mode; 51 __u8 sec_mode;
@@ -58,6 +57,116 @@ struct mgmt_rp_read_info {
58 __u16 hci_rev; 57 __u16 hci_rev;
59} __packed; 58} __packed;
60 59
60struct mgmt_mode {
61 __u8 val;
62} __packed;
63
64#define MGMT_OP_SET_POWERED 0x0005
65
66#define MGMT_OP_SET_DISCOVERABLE 0x0006
67
68#define MGMT_OP_SET_CONNECTABLE 0x0007
69
70#define MGMT_OP_SET_PAIRABLE 0x0008
71
72#define MGMT_OP_ADD_UUID 0x0009
73struct mgmt_cp_add_uuid {
74 __u8 uuid[16];
75 __u8 svc_hint;
76} __packed;
77
78#define MGMT_OP_REMOVE_UUID 0x000A
79struct mgmt_cp_remove_uuid {
80 __u8 uuid[16];
81} __packed;
82
83#define MGMT_OP_SET_DEV_CLASS 0x000B
84struct mgmt_cp_set_dev_class {
85 __u8 major;
86 __u8 minor;
87} __packed;
88
89#define MGMT_OP_SET_SERVICE_CACHE 0x000C
90struct mgmt_cp_set_service_cache {
91 __u8 enable;
92} __packed;
93
94struct mgmt_key_info {
95 bdaddr_t bdaddr;
96 u8 type;
97 u8 val[16];
98 u8 pin_len;
99} __packed;
100
101#define MGMT_OP_LOAD_KEYS 0x000D
102struct mgmt_cp_load_keys {
103 __u8 debug_keys;
104 __le16 key_count;
105 struct mgmt_key_info keys[0];
106} __packed;
107
108#define MGMT_OP_REMOVE_KEY 0x000E
109struct mgmt_cp_remove_key {
110 bdaddr_t bdaddr;
111 __u8 disconnect;
112} __packed;
113
114#define MGMT_OP_DISCONNECT 0x000F
115struct mgmt_cp_disconnect {
116 bdaddr_t bdaddr;
117} __packed;
118struct mgmt_rp_disconnect {
119 bdaddr_t bdaddr;
120} __packed;
121
122#define MGMT_OP_GET_CONNECTIONS 0x0010
123struct mgmt_rp_get_connections {
124 __le16 conn_count;
125 bdaddr_t conn[0];
126} __packed;
127
128#define MGMT_OP_PIN_CODE_REPLY 0x0011
129struct mgmt_cp_pin_code_reply {
130 bdaddr_t bdaddr;
131 __u8 pin_len;
132 __u8 pin_code[16];
133} __packed;
134struct mgmt_rp_pin_code_reply {
135 bdaddr_t bdaddr;
136 uint8_t status;
137} __packed;
138
139#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012
140struct mgmt_cp_pin_code_neg_reply {
141 bdaddr_t bdaddr;
142} __packed;
143
144#define MGMT_OP_SET_IO_CAPABILITY 0x0013
145struct mgmt_cp_set_io_capability {
146 __u8 io_capability;
147} __packed;
148
149#define MGMT_OP_PAIR_DEVICE 0x0014
150struct mgmt_cp_pair_device {
151 bdaddr_t bdaddr;
152 __u8 io_cap;
153} __packed;
154struct mgmt_rp_pair_device {
155 bdaddr_t bdaddr;
156 __u8 status;
157} __packed;
158
159#define MGMT_OP_USER_CONFIRM_REPLY 0x0015
160struct mgmt_cp_user_confirm_reply {
161 bdaddr_t bdaddr;
162} __packed;
163struct mgmt_rp_user_confirm_reply {
164 bdaddr_t bdaddr;
165 __u8 status;
166} __packed;
167
168#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016
169
61#define MGMT_EV_CMD_COMPLETE 0x0001 170#define MGMT_EV_CMD_COMPLETE 0x0001
62struct mgmt_ev_cmd_complete { 171struct mgmt_ev_cmd_complete {
63 __le16 opcode; 172 __le16 opcode;
@@ -72,16 +181,56 @@ struct mgmt_ev_cmd_status {
72 181
73#define MGMT_EV_CONTROLLER_ERROR 0x0003 182#define MGMT_EV_CONTROLLER_ERROR 0x0003
74struct mgmt_ev_controller_error { 183struct mgmt_ev_controller_error {
75 __le16 index;
76 __u8 error_code; 184 __u8 error_code;
77} __packed; 185} __packed;
78 186
79#define MGMT_EV_INDEX_ADDED 0x0004 187#define MGMT_EV_INDEX_ADDED 0x0004
80struct mgmt_ev_index_added {
81 __le16 index;
82} __packed;
83 188
84#define MGMT_EV_INDEX_REMOVED 0x0005 189#define MGMT_EV_INDEX_REMOVED 0x0005
85struct mgmt_ev_index_removed { 190
86 __le16 index; 191#define MGMT_EV_POWERED 0x0006
192
193#define MGMT_EV_DISCOVERABLE 0x0007
194
195#define MGMT_EV_CONNECTABLE 0x0008
196
197#define MGMT_EV_PAIRABLE 0x0009
198
199#define MGMT_EV_NEW_KEY 0x000A
200struct mgmt_ev_new_key {
201 struct mgmt_key_info key;
202 __u8 old_key_type;
203} __packed;
204
205#define MGMT_EV_CONNECTED 0x000B
206struct mgmt_ev_connected {
207 bdaddr_t bdaddr;
208} __packed;
209
210#define MGMT_EV_DISCONNECTED 0x000C
211struct mgmt_ev_disconnected {
212 bdaddr_t bdaddr;
213} __packed;
214
215#define MGMT_EV_CONNECT_FAILED 0x000D
216struct mgmt_ev_connect_failed {
217 bdaddr_t bdaddr;
218 __u8 status;
219} __packed;
220
221#define MGMT_EV_PIN_CODE_REQUEST 0x000E
222struct mgmt_ev_pin_code_request {
223 bdaddr_t bdaddr;
224} __packed;
225
226#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
227struct mgmt_ev_user_confirm_request {
228 bdaddr_t bdaddr;
229 __le32 value;
230} __packed;
231
232#define MGMT_EV_AUTH_FAILED 0x0010
233struct mgmt_ev_auth_failed {
234 bdaddr_t bdaddr;
235 __u8 status;
87} __packed; 236} __packed;
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h
new file mode 100644
index 000000000000..8f2edbf979dc
--- /dev/null
+++ b/include/net/bluetooth/smp.h
@@ -0,0 +1,76 @@
1#ifndef __SMP_H
2#define __SMP_H
3
4struct smp_command_hdr {
5 __u8 code;
6} __packed;
7
8#define SMP_CMD_PAIRING_REQ 0x01
9#define SMP_CMD_PAIRING_RSP 0x02
10struct smp_cmd_pairing {
11 __u8 io_capability;
12 __u8 oob_flag;
13 __u8 auth_req;
14 __u8 max_key_size;
15 __u8 init_key_dist;
16 __u8 resp_key_dist;
17} __packed;
18
19#define SMP_CMD_PAIRING_CONFIRM 0x03
20struct smp_cmd_pairing_confirm {
21 __u8 confirm_val[16];
22} __packed;
23
24#define SMP_CMD_PAIRING_RANDOM 0x04
25struct smp_cmd_pairing_random {
26 __u8 rand_val[16];
27} __packed;
28
29#define SMP_CMD_PAIRING_FAIL 0x05
30struct smp_cmd_pairing_fail {
31 __u8 reason;
32} __packed;
33
34#define SMP_CMD_ENCRYPT_INFO 0x06
35struct smp_cmd_encrypt_info {
36 __u8 ltk[16];
37} __packed;
38
39#define SMP_CMD_MASTER_IDENT 0x07
40struct smp_cmd_master_ident {
41 __u16 ediv;
42 __u8 rand[8];
43} __packed;
44
45#define SMP_CMD_IDENT_INFO 0x08
46struct smp_cmd_ident_info {
47 __u8 irk[16];
48} __packed;
49
50#define SMP_CMD_IDENT_ADDR_INFO 0x09
51struct smp_cmd_ident_addr_info {
52 __u8 addr_type;
53 bdaddr_t bdaddr;
54} __packed;
55
56#define SMP_CMD_SIGN_INFO 0x0a
57struct smp_cmd_sign_info {
58 __u8 csrk[16];
59} __packed;
60
61#define SMP_CMD_SECURITY_REQ 0x0b
62struct smp_cmd_security_req {
63 __u8 auth_req;
64} __packed;
65
66#define SMP_PASSKEY_ENTRY_FAILED 0x01
67#define SMP_OOB_NOT_AVAIL 0x02
68#define SMP_AUTH_REQUIREMENTS 0x03
69#define SMP_CONFIRM_FAILED 0x04
70#define SMP_PAIRING_NOTSUPP 0x05
71#define SMP_ENC_KEY_SIZE 0x06
72#define SMP_CMD_NOTSUPP 0x07
73#define SMP_UNSPECIFIED 0x08
74#define SMP_REPEATED_ATTEMPTS 0x09
75
76#endif /* __SMP_H */
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h
index f688478bfb84..f33d36341132 100644
--- a/include/net/caif/cfcnfg.h
+++ b/include/net/caif/cfcnfg.h
@@ -69,7 +69,7 @@ void cfcnfg_remove(struct cfcnfg *cfg);
69 * cfcnfg_add_adapt_layer to specify PHY for the link. 69 * cfcnfg_add_adapt_layer to specify PHY for the link.
70 * @pref: The phy (link layer) preference. 70 * @pref: The phy (link layer) preference.
71 * @fcs: Specify if checksum is used in CAIF Framing Layer. 71 * @fcs: Specify if checksum is used in CAIF Framing Layer.
72 * @stx: Specify if Start Of Frame eXtention is used. 72 * @stx: Specify if Start Of Frame extension is used.
73 */ 73 */
74 74
75void 75void
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1322695beb52..b2b9d28cb4ab 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -413,7 +413,7 @@ struct station_parameters {
413 * @STATION_INFO_PLID: @plid filled 413 * @STATION_INFO_PLID: @plid filled
414 * @STATION_INFO_PLINK_STATE: @plink_state filled 414 * @STATION_INFO_PLINK_STATE: @plink_state filled
415 * @STATION_INFO_SIGNAL: @signal filled 415 * @STATION_INFO_SIGNAL: @signal filled
416 * @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled 416 * @STATION_INFO_TX_BITRATE: @txrate fields are filled
417 * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs) 417 * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs)
418 * @STATION_INFO_RX_PACKETS: @rx_packets filled 418 * @STATION_INFO_RX_PACKETS: @rx_packets filled
419 * @STATION_INFO_TX_PACKETS: @tx_packets filled 419 * @STATION_INFO_TX_PACKETS: @tx_packets filled
@@ -421,6 +421,7 @@ struct station_parameters {
421 * @STATION_INFO_TX_FAILED: @tx_failed filled 421 * @STATION_INFO_TX_FAILED: @tx_failed filled
422 * @STATION_INFO_RX_DROP_MISC: @rx_dropped_misc filled 422 * @STATION_INFO_RX_DROP_MISC: @rx_dropped_misc filled
423 * @STATION_INFO_SIGNAL_AVG: @signal_avg filled 423 * @STATION_INFO_SIGNAL_AVG: @signal_avg filled
424 * @STATION_INFO_RX_BITRATE: @rxrate fields are filled
424 */ 425 */
425enum station_info_flags { 426enum station_info_flags {
426 STATION_INFO_INACTIVE_TIME = 1<<0, 427 STATION_INFO_INACTIVE_TIME = 1<<0,
@@ -437,6 +438,7 @@ enum station_info_flags {
437 STATION_INFO_TX_FAILED = 1<<11, 438 STATION_INFO_TX_FAILED = 1<<11,
438 STATION_INFO_RX_DROP_MISC = 1<<12, 439 STATION_INFO_RX_DROP_MISC = 1<<12,
439 STATION_INFO_SIGNAL_AVG = 1<<13, 440 STATION_INFO_SIGNAL_AVG = 1<<13,
441 STATION_INFO_RX_BITRATE = 1<<14,
440}; 442};
441 443
442/** 444/**
@@ -484,7 +486,8 @@ struct rate_info {
484 * @plink_state: mesh peer link state 486 * @plink_state: mesh peer link state
485 * @signal: signal strength of last received packet in dBm 487 * @signal: signal strength of last received packet in dBm
486 * @signal_avg: signal strength average in dBm 488 * @signal_avg: signal strength average in dBm
487 * @txrate: current unicast bitrate to this station 489 * @txrate: current unicast bitrate from this station
490 * @rxrate: current unicast bitrate to this station
488 * @rx_packets: packets received from this station 491 * @rx_packets: packets received from this station
489 * @tx_packets: packets transmitted to this station 492 * @tx_packets: packets transmitted to this station
490 * @tx_retries: cumulative retry counts 493 * @tx_retries: cumulative retry counts
@@ -506,6 +509,7 @@ struct station_info {
506 s8 signal; 509 s8 signal;
507 s8 signal_avg; 510 s8 signal_avg;
508 struct rate_info txrate; 511 struct rate_info txrate;
512 struct rate_info rxrate;
509 u32 rx_packets; 513 u32 rx_packets;
510 u32 tx_packets; 514 u32 tx_packets;
511 u32 tx_retries; 515 u32 tx_retries;
@@ -1194,6 +1198,10 @@ struct cfg80211_pmksa {
1194 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX). 1198 * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX).
1195 * 1199 *
1196 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant). 1200 * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant).
1201 *
1202 * @set_ringparam: Set tx and rx ring sizes.
1203 *
1204 * @get_ringparam: Get tx and rx ring current and maximum sizes.
1197 */ 1205 */
1198struct cfg80211_ops { 1206struct cfg80211_ops {
1199 int (*suspend)(struct wiphy *wiphy); 1207 int (*suspend)(struct wiphy *wiphy);
@@ -1361,6 +1369,10 @@ struct cfg80211_ops {
1361 1369
1362 int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant); 1370 int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
1363 int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant); 1371 int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
1372
1373 int (*set_ringparam)(struct wiphy *wiphy, u32 tx, u32 rx);
1374 void (*get_ringparam)(struct wiphy *wiphy,
1375 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
1364}; 1376};
1365 1377
1366/* 1378/*
@@ -1790,8 +1802,9 @@ static inline void *wdev_priv(struct wireless_dev *wdev)
1790/** 1802/**
1791 * ieee80211_channel_to_frequency - convert channel number to frequency 1803 * ieee80211_channel_to_frequency - convert channel number to frequency
1792 * @chan: channel number 1804 * @chan: channel number
1805 * @band: band, necessary due to channel number overlap
1793 */ 1806 */
1794extern int ieee80211_channel_to_frequency(int chan); 1807extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band);
1795 1808
1796/** 1809/**
1797 * ieee80211_frequency_to_channel - convert frequency to channel number 1810 * ieee80211_frequency_to_channel - convert frequency to channel number
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index a8e7852b10ab..e5983c9053dc 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -43,6 +43,8 @@ struct dcbnl_rtnl_ops {
43 int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *); 43 int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *);
44 int (*ieee_getapp) (struct net_device *, struct dcb_app *); 44 int (*ieee_getapp) (struct net_device *, struct dcb_app *);
45 int (*ieee_setapp) (struct net_device *, struct dcb_app *); 45 int (*ieee_setapp) (struct net_device *, struct dcb_app *);
46 int (*ieee_peer_getets) (struct net_device *, struct ieee_ets *);
47 int (*ieee_peer_getpfc) (struct net_device *, struct ieee_pfc *);
46 48
47 /* CEE std */ 49 /* CEE std */
48 u8 (*getstate)(struct net_device *); 50 u8 (*getstate)(struct net_device *);
@@ -77,7 +79,14 @@ struct dcbnl_rtnl_ops {
77 u8 (*getdcbx)(struct net_device *); 79 u8 (*getdcbx)(struct net_device *);
78 u8 (*setdcbx)(struct net_device *, u8); 80 u8 (*setdcbx)(struct net_device *, u8);
79 81
82 /* peer apps */
83 int (*peer_getappinfo)(struct net_device *, struct dcb_peer_app_info *,
84 u16 *);
85 int (*peer_getapptable)(struct net_device *, struct dcb_app *);
80 86
87 /* CEE peer */
88 int (*cee_peer_getpg) (struct net_device *, struct cee_pg *);
89 int (*cee_peer_getpfc) (struct net_device *, struct cee_pfc *);
81}; 90};
82 91
83#endif /* __NET_DCBNL_H__ */ 92#endif /* __NET_DCBNL_H__ */
diff --git a/include/net/dn.h b/include/net/dn.h
index a514a3cf4573..298521e0d8a2 100644
--- a/include/net/dn.h
+++ b/include/net/dn.h
@@ -192,10 +192,10 @@ static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
192 ethaddr[5] = (__u8)(a >> 8); 192 ethaddr[5] = (__u8)(a >> 8);
193} 193}
194 194
195static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp) 195static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp)
196{ 196{
197 fl->uli_u.dnports.sport = scp->addrloc; 197 fld->fld_sport = scp->addrloc;
198 fl->uli_u.dnports.dport = scp->addrrem; 198 fld->fld_dport = scp->addrrem;
199} 199}
200 200
201extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); 201extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
diff --git a/include/net/dn_fib.h b/include/net/dn_fib.h
index bbcde3238e58..782ef7cb4930 100644
--- a/include/net/dn_fib.h
+++ b/include/net/dn_fib.h
@@ -98,7 +98,7 @@ struct dn_fib_table {
98 int (*delete)(struct dn_fib_table *t, struct rtmsg *r, 98 int (*delete)(struct dn_fib_table *t, struct rtmsg *r,
99 struct dn_kern_rta *rta, struct nlmsghdr *n, 99 struct dn_kern_rta *rta, struct nlmsghdr *n,
100 struct netlink_skb_parms *req); 100 struct netlink_skb_parms *req);
101 int (*lookup)(struct dn_fib_table *t, const struct flowi *fl, 101 int (*lookup)(struct dn_fib_table *t, const struct flowidn *fld,
102 struct dn_fib_res *res); 102 struct dn_fib_res *res);
103 int (*flush)(struct dn_fib_table *t); 103 int (*flush)(struct dn_fib_table *t);
104 int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb); 104 int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb);
@@ -119,12 +119,12 @@ extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r,
119 struct dn_kern_rta *rta, 119 struct dn_kern_rta *rta,
120 const struct nlmsghdr *nlh, int *errp); 120 const struct nlmsghdr *nlh, int *errp);
121extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi, 121extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi,
122 const struct flowi *fl, 122 const struct flowidn *fld,
123 struct dn_fib_res *res); 123 struct dn_fib_res *res);
124extern void dn_fib_release_info(struct dn_fib_info *fi); 124extern void dn_fib_release_info(struct dn_fib_info *fi);
125extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type); 125extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type);
126extern void dn_fib_flush(void); 126extern void dn_fib_flush(void);
127extern void dn_fib_select_multipath(const struct flowi *fl, 127extern void dn_fib_select_multipath(const struct flowidn *fld,
128 struct dn_fib_res *res); 128 struct dn_fib_res *res);
129 129
130/* 130/*
@@ -141,7 +141,7 @@ extern void dn_fib_table_cleanup(void);
141extern void dn_fib_rules_init(void); 141extern void dn_fib_rules_init(void);
142extern void dn_fib_rules_cleanup(void); 142extern void dn_fib_rules_cleanup(void);
143extern unsigned dnet_addr_type(__le16 addr); 143extern unsigned dnet_addr_type(__le16 addr);
144extern int dn_fib_lookup(struct flowi *fl, struct dn_fib_res *res); 144extern int dn_fib_lookup(struct flowidn *fld, struct dn_fib_res *res);
145 145
146extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb); 146extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb);
147 147
diff --git a/include/net/dn_route.h b/include/net/dn_route.h
index 9b185df265fb..81712cfa1ddf 100644
--- a/include/net/dn_route.h
+++ b/include/net/dn_route.h
@@ -16,7 +16,7 @@
16*******************************************************************************/ 16*******************************************************************************/
17 17
18extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); 18extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri);
19extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); 19extern int dn_route_output_sock(struct dst_entry **pprt, struct flowidn *, struct sock *sk, int flags);
20extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); 20extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb);
21extern void dn_rt_cache_flush(int delay); 21extern void dn_rt_cache_flush(int delay);
22 22
@@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay);
67struct dn_route { 67struct dn_route {
68 struct dst_entry dst; 68 struct dst_entry dst;
69 69
70 struct flowi fl; 70 struct flowidn fld;
71 71
72 __le16 rt_saddr; 72 __le16 rt_saddr;
73 __le16 rt_daddr; 73 __le16 rt_daddr;
@@ -82,12 +82,12 @@ struct dn_route {
82 82
83static inline bool dn_is_input_route(struct dn_route *rt) 83static inline bool dn_is_input_route(struct dn_route *rt)
84{ 84{
85 return rt->fl.iif != 0; 85 return rt->fld.flowidn_iif != 0;
86} 86}
87 87
88static inline bool dn_is_output_route(struct dn_route *rt) 88static inline bool dn_is_output_route(struct dn_route *rt)
89{ 89{
90 return rt->fl.iif == 0; 90 return rt->fld.flowidn_iif == 0;
91} 91}
92 92
93extern void dn_route_init(void); 93extern void dn_route_init(void);
diff --git a/include/net/dst.h b/include/net/dst.h
index 93b0310317be..75b95df4afe7 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -40,24 +40,10 @@ struct dst_entry {
40 struct rcu_head rcu_head; 40 struct rcu_head rcu_head;
41 struct dst_entry *child; 41 struct dst_entry *child;
42 struct net_device *dev; 42 struct net_device *dev;
43 short error; 43 struct dst_ops *ops;
44 short obsolete; 44 unsigned long _metrics;
45 int flags;
46#define DST_HOST 0x0001
47#define DST_NOXFRM 0x0002
48#define DST_NOPOLICY 0x0004
49#define DST_NOHASH 0x0008
50#define DST_NOCACHE 0x0010
51 unsigned long expires; 45 unsigned long expires;
52
53 unsigned short header_len; /* more space at head required */
54 unsigned short trailer_len; /* space to reserve at tail */
55
56 unsigned int rate_tokens;
57 unsigned long rate_last; /* rate limiting for ICMP */
58
59 struct dst_entry *path; 46 struct dst_entry *path;
60
61 struct neighbour *neighbour; 47 struct neighbour *neighbour;
62 struct hh_cache *hh; 48 struct hh_cache *hh;
63#ifdef CONFIG_XFRM 49#ifdef CONFIG_XFRM
@@ -68,17 +54,16 @@ struct dst_entry {
68 int (*input)(struct sk_buff*); 54 int (*input)(struct sk_buff*);
69 int (*output)(struct sk_buff*); 55 int (*output)(struct sk_buff*);
70 56
71 struct dst_ops *ops; 57 short error;
72 58 short obsolete;
73 u32 _metrics[RTAX_MAX]; 59 unsigned short header_len; /* more space at head required */
74 60 unsigned short trailer_len; /* space to reserve at tail */
75#ifdef CONFIG_NET_CLS_ROUTE 61#ifdef CONFIG_IP_ROUTE_CLASSID
76 __u32 tclassid; 62 __u32 tclassid;
77#else 63#else
78 __u32 __pad2; 64 __u32 __pad2;
79#endif 65#endif
80 66
81
82 /* 67 /*
83 * Align __refcnt to a 64 bytes alignment 68 * Align __refcnt to a 64 bytes alignment
84 * (L1_CACHE_SIZE would be too much) 69 * (L1_CACHE_SIZE would be too much)
@@ -93,6 +78,12 @@ struct dst_entry {
93 atomic_t __refcnt; /* client references */ 78 atomic_t __refcnt; /* client references */
94 int __use; 79 int __use;
95 unsigned long lastuse; 80 unsigned long lastuse;
81 int flags;
82#define DST_HOST 0x0001
83#define DST_NOXFRM 0x0002
84#define DST_NOPOLICY 0x0004
85#define DST_NOHASH 0x0008
86#define DST_NOCACHE 0x0010
96 union { 87 union {
97 struct dst_entry *next; 88 struct dst_entry *next;
98 struct rtable __rcu *rt_next; 89 struct rtable __rcu *rt_next;
@@ -103,10 +94,70 @@ struct dst_entry {
103 94
104#ifdef __KERNEL__ 95#ifdef __KERNEL__
105 96
97extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
98extern const u32 dst_default_metrics[RTAX_MAX];
99
100#define DST_METRICS_READ_ONLY 0x1UL
101#define __DST_METRICS_PTR(Y) \
102 ((u32 *)((Y) & ~DST_METRICS_READ_ONLY))
103#define DST_METRICS_PTR(X) __DST_METRICS_PTR((X)->_metrics)
104
105static inline bool dst_metrics_read_only(const struct dst_entry *dst)
106{
107 return dst->_metrics & DST_METRICS_READ_ONLY;
108}
109
110extern void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old);
111
112static inline void dst_destroy_metrics_generic(struct dst_entry *dst)
113{
114 unsigned long val = dst->_metrics;
115 if (!(val & DST_METRICS_READ_ONLY))
116 __dst_destroy_metrics_generic(dst, val);
117}
118
119static inline u32 *dst_metrics_write_ptr(struct dst_entry *dst)
120{
121 unsigned long p = dst->_metrics;
122
123 if (p & DST_METRICS_READ_ONLY)
124 return dst->ops->cow_metrics(dst, p);
125 return __DST_METRICS_PTR(p);
126}
127
128/* This may only be invoked before the entry has reached global
129 * visibility.
130 */
131static inline void dst_init_metrics(struct dst_entry *dst,
132 const u32 *src_metrics,
133 bool read_only)
134{
135 dst->_metrics = ((unsigned long) src_metrics) |
136 (read_only ? DST_METRICS_READ_ONLY : 0);
137}
138
139static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
140{
141 u32 *dst_metrics = dst_metrics_write_ptr(dest);
142
143 if (dst_metrics) {
144 u32 *src_metrics = DST_METRICS_PTR(src);
145
146 memcpy(dst_metrics, src_metrics, RTAX_MAX * sizeof(u32));
147 }
148}
149
150static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
151{
152 return DST_METRICS_PTR(dst);
153}
154
106static inline u32 155static inline u32
107dst_metric_raw(const struct dst_entry *dst, const int metric) 156dst_metric_raw(const struct dst_entry *dst, const int metric)
108{ 157{
109 return dst->_metrics[metric-1]; 158 u32 *p = DST_METRICS_PTR(dst);
159
160 return p[metric-1];
110} 161}
111 162
112static inline u32 163static inline u32
@@ -131,22 +182,10 @@ dst_metric_advmss(const struct dst_entry *dst)
131 182
132static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val) 183static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
133{ 184{
134 dst->_metrics[metric-1] = val; 185 u32 *p = dst_metrics_write_ptr(dst);
135}
136 186
137static inline void dst_import_metrics(struct dst_entry *dst, const u32 *src_metrics) 187 if (p)
138{ 188 p[metric-1] = val;
139 memcpy(dst->_metrics, src_metrics, RTAX_MAX * sizeof(u32));
140}
141
142static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
143{
144 dst_import_metrics(dest, src->_metrics);
145}
146
147static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
148{
149 return dst->_metrics;
150} 189}
151 190
152static inline u32 191static inline u32
@@ -181,8 +220,6 @@ static inline u32
181dst_allfrag(const struct dst_entry *dst) 220dst_allfrag(const struct dst_entry *dst)
182{ 221{
183 int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG); 222 int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG);
184 /* Yes, _exactly_. This is paranoia. */
185 barrier();
186 return ret; 223 return ret;
187} 224}
188 225
@@ -308,14 +345,14 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
308 345
309static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb) 346static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb)
310{ 347{
311 struct dst_entry *child = skb_dst(skb)->child; 348 struct dst_entry *child = dst_clone(skb_dst(skb)->child);
312 349
313 skb_dst_drop(skb); 350 skb_dst_drop(skb);
314 return child; 351 return child;
315} 352}
316 353
317extern int dst_discard(struct sk_buff *skb); 354extern int dst_discard(struct sk_buff *skb);
318extern void * dst_alloc(struct dst_ops * ops); 355extern void *dst_alloc(struct dst_ops * ops, int initial_ref);
319extern void __dst_free(struct dst_entry * dst); 356extern void __dst_free(struct dst_entry * dst);
320extern struct dst_entry *dst_destroy(struct dst_entry * dst); 357extern struct dst_entry *dst_destroy(struct dst_entry * dst);
321 358
@@ -384,27 +421,22 @@ extern void dst_init(void);
384 421
385/* Flags for xfrm_lookup flags argument. */ 422/* Flags for xfrm_lookup flags argument. */
386enum { 423enum {
387 XFRM_LOOKUP_WAIT = 1 << 0, 424 XFRM_LOOKUP_ICMP = 1 << 0,
388 XFRM_LOOKUP_ICMP = 1 << 1,
389}; 425};
390 426
391struct flowi; 427struct flowi;
392#ifndef CONFIG_XFRM 428#ifndef CONFIG_XFRM
393static inline int xfrm_lookup(struct net *net, struct dst_entry **dst_p, 429static inline struct dst_entry *xfrm_lookup(struct net *net,
394 struct flowi *fl, struct sock *sk, int flags) 430 struct dst_entry *dst_orig,
431 const struct flowi *fl, struct sock *sk,
432 int flags)
395{ 433{
396 return 0; 434 return dst_orig;
397} 435}
398static inline int __xfrm_lookup(struct net *net, struct dst_entry **dst_p,
399 struct flowi *fl, struct sock *sk, int flags)
400{
401 return 0;
402}
403#else 436#else
404extern int xfrm_lookup(struct net *net, struct dst_entry **dst_p, 437extern struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
405 struct flowi *fl, struct sock *sk, int flags); 438 const struct flowi *fl, struct sock *sk,
406extern int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, 439 int flags);
407 struct flowi *fl, struct sock *sk, int flags);
408#endif 440#endif
409#endif 441#endif
410 442
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h
index 21a320b8708e..dc0746328947 100644
--- a/include/net/dst_ops.h
+++ b/include/net/dst_ops.h
@@ -18,6 +18,7 @@ struct dst_ops {
18 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); 18 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
19 unsigned int (*default_advmss)(const struct dst_entry *); 19 unsigned int (*default_advmss)(const struct dst_entry *);
20 unsigned int (*default_mtu)(const struct dst_entry *); 20 unsigned int (*default_mtu)(const struct dst_entry *);
21 u32 * (*cow_metrics)(struct dst_entry *, unsigned long);
21 void (*destroy)(struct dst_entry *); 22 void (*destroy)(struct dst_entry *);
22 void (*ifdown)(struct dst_entry *, 23 void (*ifdown)(struct dst_entry *,
23 struct net_device *dev, int how); 24 struct net_device *dev, int how);
diff --git a/include/net/flow.h b/include/net/flow.h
index 240b7f356c71..7fe5a0f9483a 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -10,78 +10,136 @@
10#include <linux/in6.h> 10#include <linux/in6.h>
11#include <asm/atomic.h> 11#include <asm/atomic.h>
12 12
13struct flowi { 13struct flowi_common {
14 int oif; 14 int flowic_oif;
15 int iif; 15 int flowic_iif;
16 __u32 mark; 16 __u32 flowic_mark;
17 __u8 flowic_tos;
18 __u8 flowic_scope;
19 __u8 flowic_proto;
20 __u8 flowic_flags;
21#define FLOWI_FLAG_ANYSRC 0x01
22#define FLOWI_FLAG_PRECOW_METRICS 0x02
23#define FLOWI_FLAG_CAN_SLEEP 0x04
24 __u32 flowic_secid;
25};
17 26
27union flowi_uli {
28 struct {
29 __be16 sport;
30 __be16 dport;
31 } ports;
32
33 struct {
34 __u8 type;
35 __u8 code;
36 } icmpt;
37
38 struct {
39 __le16 sport;
40 __le16 dport;
41 } dnports;
42
43 __be32 spi;
44 __be32 gre_key;
45
46 struct {
47 __u8 type;
48 } mht;
49};
50
51struct flowi4 {
52 struct flowi_common __fl_common;
53#define flowi4_oif __fl_common.flowic_oif
54#define flowi4_iif __fl_common.flowic_iif
55#define flowi4_mark __fl_common.flowic_mark
56#define flowi4_tos __fl_common.flowic_tos
57#define flowi4_scope __fl_common.flowic_scope
58#define flowi4_proto __fl_common.flowic_proto
59#define flowi4_flags __fl_common.flowic_flags
60#define flowi4_secid __fl_common.flowic_secid
61 __be32 daddr;
62 __be32 saddr;
63 union flowi_uli uli;
64#define fl4_sport uli.ports.sport
65#define fl4_dport uli.ports.dport
66#define fl4_icmp_type uli.icmpt.type
67#define fl4_icmp_code uli.icmpt.code
68#define fl4_ipsec_spi uli.spi
69#define fl4_mh_type uli.mht.type
70#define fl4_gre_key uli.gre_key
71};
72
73struct flowi6 {
74 struct flowi_common __fl_common;
75#define flowi6_oif __fl_common.flowic_oif
76#define flowi6_iif __fl_common.flowic_iif
77#define flowi6_mark __fl_common.flowic_mark
78#define flowi6_tos __fl_common.flowic_tos
79#define flowi6_scope __fl_common.flowic_scope
80#define flowi6_proto __fl_common.flowic_proto
81#define flowi6_flags __fl_common.flowic_flags
82#define flowi6_secid __fl_common.flowic_secid
83 struct in6_addr daddr;
84 struct in6_addr saddr;
85 __be32 flowlabel;
86 union flowi_uli uli;
87#define fl6_sport uli.ports.sport
88#define fl6_dport uli.ports.dport
89#define fl6_icmp_type uli.icmpt.type
90#define fl6_icmp_code uli.icmpt.code
91#define fl6_ipsec_spi uli.spi
92#define fl6_mh_type uli.mht.type
93#define fl6_gre_key uli.gre_key
94};
95
96struct flowidn {
97 struct flowi_common __fl_common;
98#define flowidn_oif __fl_common.flowic_oif
99#define flowidn_iif __fl_common.flowic_iif
100#define flowidn_mark __fl_common.flowic_mark
101#define flowidn_scope __fl_common.flowic_scope
102#define flowidn_proto __fl_common.flowic_proto
103#define flowidn_flags __fl_common.flowic_flags
104 __le16 daddr;
105 __le16 saddr;
106 union flowi_uli uli;
107#define fld_sport uli.ports.sport
108#define fld_dport uli.ports.dport
109};
110
111struct flowi {
18 union { 112 union {
19 struct { 113 struct flowi_common __fl_common;
20 __be32 daddr; 114 struct flowi4 ip4;
21 __be32 saddr; 115 struct flowi6 ip6;
22 __u8 tos; 116 struct flowidn dn;
23 __u8 scope; 117 } u;
24 } ip4_u; 118#define flowi_oif u.__fl_common.flowic_oif
25 119#define flowi_iif u.__fl_common.flowic_iif
26 struct { 120#define flowi_mark u.__fl_common.flowic_mark
27 struct in6_addr daddr; 121#define flowi_tos u.__fl_common.flowic_tos
28 struct in6_addr saddr; 122#define flowi_scope u.__fl_common.flowic_scope
29 __be32 flowlabel; 123#define flowi_proto u.__fl_common.flowic_proto
30 } ip6_u; 124#define flowi_flags u.__fl_common.flowic_flags
31 125#define flowi_secid u.__fl_common.flowic_secid
32 struct {
33 __le16 daddr;
34 __le16 saddr;
35 __u8 scope;
36 } dn_u;
37 } nl_u;
38#define fld_dst nl_u.dn_u.daddr
39#define fld_src nl_u.dn_u.saddr
40#define fld_scope nl_u.dn_u.scope
41#define fl6_dst nl_u.ip6_u.daddr
42#define fl6_src nl_u.ip6_u.saddr
43#define fl6_flowlabel nl_u.ip6_u.flowlabel
44#define fl4_dst nl_u.ip4_u.daddr
45#define fl4_src nl_u.ip4_u.saddr
46#define fl4_tos nl_u.ip4_u.tos
47#define fl4_scope nl_u.ip4_u.scope
48
49 __u8 proto;
50 __u8 flags;
51#define FLOWI_FLAG_ANYSRC 0x01
52 union {
53 struct {
54 __be16 sport;
55 __be16 dport;
56 } ports;
57
58 struct {
59 __u8 type;
60 __u8 code;
61 } icmpt;
62
63 struct {
64 __le16 sport;
65 __le16 dport;
66 } dnports;
67
68 __be32 spi;
69 __be32 gre_key;
70
71 struct {
72 __u8 type;
73 } mht;
74 } uli_u;
75#define fl_ip_sport uli_u.ports.sport
76#define fl_ip_dport uli_u.ports.dport
77#define fl_icmp_type uli_u.icmpt.type
78#define fl_icmp_code uli_u.icmpt.code
79#define fl_ipsec_spi uli_u.spi
80#define fl_mh_type uli_u.mht.type
81#define fl_gre_key uli_u.gre_key
82 __u32 secid; /* used by xfrm; see secid.txt */
83} __attribute__((__aligned__(BITS_PER_LONG/8))); 126} __attribute__((__aligned__(BITS_PER_LONG/8)));
84 127
128static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4)
129{
130 return container_of(fl4, struct flowi, u.ip4);
131}
132
133static inline struct flowi *flowi6_to_flowi(struct flowi6 *fl6)
134{
135 return container_of(fl6, struct flowi, u.ip6);
136}
137
138static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn)
139{
140 return container_of(fldn, struct flowi, u.dn);
141}
142
85#define FLOW_DIR_IN 0 143#define FLOW_DIR_IN 0
86#define FLOW_DIR_OUT 1 144#define FLOW_DIR_OUT 1
87#define FLOW_DIR_FWD 2 145#define FLOW_DIR_FWD 2
@@ -101,20 +159,14 @@ struct flow_cache_ops {
101}; 159};
102 160
103typedef struct flow_cache_object *(*flow_resolve_t)( 161typedef struct flow_cache_object *(*flow_resolve_t)(
104 struct net *net, struct flowi *key, u16 family, 162 struct net *net, const struct flowi *key, u16 family,
105 u8 dir, struct flow_cache_object *oldobj, void *ctx); 163 u8 dir, struct flow_cache_object *oldobj, void *ctx);
106 164
107extern struct flow_cache_object *flow_cache_lookup( 165extern struct flow_cache_object *flow_cache_lookup(
108 struct net *net, struct flowi *key, u16 family, 166 struct net *net, const struct flowi *key, u16 family,
109 u8 dir, flow_resolve_t resolver, void *ctx); 167 u8 dir, flow_resolve_t resolver, void *ctx);
110 168
111extern void flow_cache_flush(void); 169extern void flow_cache_flush(void);
112extern atomic_t flow_cache_genid; 170extern atomic_t flow_cache_genid;
113 171
114static inline int flow_cache_uli_match(struct flowi *fl1, struct flowi *fl2)
115{
116 return (fl1->proto == fl2->proto &&
117 !memcmp(&fl1->uli_u, &fl2->uli_u, sizeof(fl1->uli_u)));
118}
119
120#endif 172#endif
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h
index fa157712e982..a79b6cfb02a8 100644
--- a/include/net/gen_stats.h
+++ b/include/net/gen_stats.h
@@ -11,7 +11,7 @@ struct gnet_dump {
11 struct sk_buff * skb; 11 struct sk_buff * skb;
12 struct nlattr * tail; 12 struct nlattr * tail;
13 13
14 /* Backward compatability */ 14 /* Backward compatibility */
15 int compat_tc_stats; 15 int compat_tc_stats;
16 int compat_xstats; 16 int compat_xstats;
17 void * xstats; 17 void * xstats;
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 8a64b811a39a..b4c7c1cbcf40 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -195,7 +195,8 @@ static inline int genlmsg_end(struct sk_buff *skb, void *hdr)
195 */ 195 */
196static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) 196static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr)
197{ 197{
198 nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); 198 if (hdr)
199 nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN);
199} 200}
200 201
201/** 202/**
diff --git a/include/net/icmp.h b/include/net/icmp.h
index 6e991e0d0d6f..f0698b955b73 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -45,7 +45,4 @@ extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
45extern int icmp_init(void); 45extern int icmp_init(void);
46extern void icmp_out_count(struct net *net, unsigned char type); 46extern void icmp_out_count(struct net *net, unsigned char type);
47 47
48/* Move into dst.h ? */
49extern int xrlim_allow(struct dst_entry *dst, int timeout);
50
51#endif /* _ICMP_H */ 48#endif /* _ICMP_H */
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index af49f8ab7f81..b0be5fb9de19 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -178,6 +178,11 @@ struct ieee80211_radiotap_header {
178 * 178 *
179 * Number of unicast retries a transmitted frame used. 179 * Number of unicast retries a transmitted frame used.
180 * 180 *
181 * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless
182 *
183 * Contains a bitmap of known fields/flags, the flags, and
184 * the MCS index.
185 *
181 */ 186 */
182enum ieee80211_radiotap_type { 187enum ieee80211_radiotap_type {
183 IEEE80211_RADIOTAP_TSFT = 0, 188 IEEE80211_RADIOTAP_TSFT = 0,
@@ -199,6 +204,8 @@ enum ieee80211_radiotap_type {
199 IEEE80211_RADIOTAP_RTS_RETRIES = 16, 204 IEEE80211_RADIOTAP_RTS_RETRIES = 16,
200 IEEE80211_RADIOTAP_DATA_RETRIES = 17, 205 IEEE80211_RADIOTAP_DATA_RETRIES = 17,
201 206
207 IEEE80211_RADIOTAP_MCS = 19,
208
202 /* valid in every it_present bitmap, even vendor namespaces */ 209 /* valid in every it_present bitmap, even vendor namespaces */
203 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, 210 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
204 IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, 211 IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
@@ -245,6 +252,24 @@ enum ieee80211_radiotap_type {
245#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ 252#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
246#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ 253#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
247 254
255
256/* For IEEE80211_RADIOTAP_MCS */
257#define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01
258#define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02
259#define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04
260#define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08
261#define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10
262
263#define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03
264#define IEEE80211_RADIOTAP_MCS_BW_20 0
265#define IEEE80211_RADIOTAP_MCS_BW_40 1
266#define IEEE80211_RADIOTAP_MCS_BW_20L 2
267#define IEEE80211_RADIOTAP_MCS_BW_20U 3
268#define IEEE80211_RADIOTAP_MCS_SGI 0x04
269#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08
270#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
271
272
248/* Ugly macro to convert literal channel numbers into their mhz equivalents 273/* Ugly macro to convert literal channel numbers into their mhz equivalents
249 * There are certianly some conditions that will break this (like feeding it '30') 274 * There are certianly some conditions that will break this (like feeding it '30')
250 * but they shouldn't arise since nothing talks on channel 30. */ 275 * but they shouldn't arise since nothing talks on channel 30. */
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 04977eefb0ee..fccc2180c61b 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -286,5 +286,21 @@ static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
286 buf[9] = broadcast[9]; 286 buf[9] = broadcast[9];
287 memcpy(buf + 10, addr->s6_addr + 6, 10); 287 memcpy(buf + 10, addr->s6_addr + 6, 10);
288} 288}
289
290static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
291 const unsigned char *broadcast, char *buf)
292{
293 if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) {
294 memcpy(buf, broadcast, 4);
295 } else {
296 /* v4mapped? */
297 if ((addr->s6_addr32[0] | addr->s6_addr32[1] |
298 (addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0)
299 return -EINVAL;
300 memcpy(buf, &addr->s6_addr32[3], 4);
301 }
302 return 0;
303}
304
289#endif 305#endif
290#endif 306#endif
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 8181498fa96c..7a37369f8ea3 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -86,6 +86,19 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
86 return (struct inet_request_sock *)sk; 86 return (struct inet_request_sock *)sk;
87} 87}
88 88
89struct inet_cork {
90 unsigned int flags;
91 unsigned int fragsize;
92 struct ip_options *opt;
93 struct dst_entry *dst;
94 int length; /* Total length of all frames */
95 __be32 addr;
96 struct flowi fl;
97 struct page *page;
98 u32 off;
99 u8 tx_flags;
100};
101
89struct ip_mc_socklist; 102struct ip_mc_socklist;
90struct ipv6_pinfo; 103struct ipv6_pinfo;
91struct rtable; 104struct rtable;
@@ -143,15 +156,7 @@ struct inet_sock {
143 int mc_index; 156 int mc_index;
144 __be32 mc_addr; 157 __be32 mc_addr;
145 struct ip_mc_socklist __rcu *mc_list; 158 struct ip_mc_socklist __rcu *mc_list;
146 struct { 159 struct inet_cork cork;
147 unsigned int flags;
148 unsigned int fragsize;
149 struct ip_options *opt;
150 struct dst_entry *dst;
151 int length; /* Total length of all frames */
152 __be32 addr;
153 struct flowi fl;
154 } cork;
155}; 160};
156 161
157#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ 162#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */
@@ -219,7 +224,13 @@ static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops
219 224
220static inline __u8 inet_sk_flowi_flags(const struct sock *sk) 225static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
221{ 226{
222 return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0; 227 __u8 flags = 0;
228
229 if (inet_sk(sk)->transparent)
230 flags |= FLOWI_FLAG_ANYSRC;
231 if (sk->sk_protocol == IPPROTO_TCP)
232 flags |= FLOWI_FLAG_PRECOW_METRICS;
233 return flags;
223} 234}
224 235
225#endif /* _INET_SOCK_H */ 236#endif /* _INET_SOCK_H */
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 599d96e74114..e6dd8da6b2ad 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -11,15 +11,20 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/jiffies.h> 12#include <linux/jiffies.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/rtnetlink.h>
14#include <net/ipv6.h> 15#include <net/ipv6.h>
15#include <asm/atomic.h> 16#include <asm/atomic.h>
16 17
17struct inetpeer_addr { 18struct inetpeer_addr_base {
18 union { 19 union {
19 __be32 a4; 20 __be32 a4;
20 __be32 a6[4]; 21 __be32 a6[4];
21 }; 22 };
22 __u16 family; 23};
24
25struct inetpeer_addr {
26 struct inetpeer_addr_base addr;
27 __u16 family;
23}; 28};
24 29
25struct inet_peer { 30struct inet_peer {
@@ -33,15 +38,22 @@ struct inet_peer {
33 atomic_t refcnt; 38 atomic_t refcnt;
34 /* 39 /*
35 * Once inet_peer is queued for deletion (refcnt == -1), following fields 40 * Once inet_peer is queued for deletion (refcnt == -1), following fields
36 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp 41 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp, metrics
37 * We can share memory with rcu_head to keep inet_peer small 42 * We can share memory with rcu_head to help keep inet_peer small.
38 */ 43 */
39 union { 44 union {
40 struct { 45 struct {
41 atomic_t rid; /* Frag reception counter */ 46 atomic_t rid; /* Frag reception counter */
42 atomic_t ip_id_count; /* IP ID for the next packet */ 47 atomic_t ip_id_count; /* IP ID for the next packet */
43 __u32 tcp_ts; 48 __u32 tcp_ts;
44 __u32 tcp_ts_stamp; 49 __u32 tcp_ts_stamp;
50 u32 metrics[RTAX_MAX];
51 u32 rate_tokens; /* rate limiting for ICMP */
52 unsigned long rate_last;
53 unsigned long pmtu_expires;
54 u32 pmtu_orig;
55 u32 pmtu_learned;
56 struct inetpeer_addr_base redirect_learned;
45 }; 57 };
46 struct rcu_head rcu; 58 struct rcu_head rcu;
47 }; 59 };
@@ -49,6 +61,13 @@ struct inet_peer {
49 61
50void inet_initpeers(void) __init; 62void inet_initpeers(void) __init;
51 63
64#define INETPEER_METRICS_NEW (~(u32) 0)
65
66static inline bool inet_metrics_new(const struct inet_peer *p)
67{
68 return p->metrics[RTAX_LOCK-1] == INETPEER_METRICS_NEW;
69}
70
52/* can be called with or without local BH being disabled */ 71/* can be called with or without local BH being disabled */
53struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create); 72struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create);
54 73
@@ -56,7 +75,7 @@ static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create)
56{ 75{
57 struct inetpeer_addr daddr; 76 struct inetpeer_addr daddr;
58 77
59 daddr.a4 = v4daddr; 78 daddr.addr.a4 = v4daddr;
60 daddr.family = AF_INET; 79 daddr.family = AF_INET;
61 return inet_getpeer(&daddr, create); 80 return inet_getpeer(&daddr, create);
62} 81}
@@ -65,13 +84,14 @@ static inline struct inet_peer *inet_getpeer_v6(struct in6_addr *v6daddr, int cr
65{ 84{
66 struct inetpeer_addr daddr; 85 struct inetpeer_addr daddr;
67 86
68 ipv6_addr_copy((struct in6_addr *)daddr.a6, v6daddr); 87 ipv6_addr_copy((struct in6_addr *)daddr.addr.a6, v6daddr);
69 daddr.family = AF_INET6; 88 daddr.family = AF_INET6;
70 return inet_getpeer(&daddr, create); 89 return inet_getpeer(&daddr, create);
71} 90}
72 91
73/* can be called from BH context or outside */ 92/* can be called from BH context or outside */
74extern void inet_putpeer(struct inet_peer *p); 93extern void inet_putpeer(struct inet_peer *p);
94extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout);
75 95
76/* 96/*
77 * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, 97 * temporary check to make sure we dont access rid, ip_id_count, tcp_ts,
diff --git a/include/net/ip.h b/include/net/ip.h
index 67fac78a186b..7c416583b710 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -116,8 +116,24 @@ extern int ip_append_data(struct sock *sk,
116extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb); 116extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb);
117extern ssize_t ip_append_page(struct sock *sk, struct page *page, 117extern ssize_t ip_append_page(struct sock *sk, struct page *page,
118 int offset, size_t size, int flags); 118 int offset, size_t size, int flags);
119extern struct sk_buff *__ip_make_skb(struct sock *sk,
120 struct sk_buff_head *queue,
121 struct inet_cork *cork);
122extern int ip_send_skb(struct sk_buff *skb);
119extern int ip_push_pending_frames(struct sock *sk); 123extern int ip_push_pending_frames(struct sock *sk);
120extern void ip_flush_pending_frames(struct sock *sk); 124extern void ip_flush_pending_frames(struct sock *sk);
125extern struct sk_buff *ip_make_skb(struct sock *sk,
126 int getfrag(void *from, char *to, int offset, int len,
127 int odd, struct sk_buff *skb),
128 void *from, int length, int transhdrlen,
129 struct ipcm_cookie *ipc,
130 struct rtable **rtp,
131 unsigned int flags);
132
133static inline struct sk_buff *ip_finish_skb(struct sock *sk)
134{
135 return __ip_make_skb(sk, &sk->sk_write_queue, &inet_sk(sk)->cork);
136}
121 137
122/* datagram.c */ 138/* datagram.c */
123extern int ip4_datagram_connect(struct sock *sk, 139extern int ip4_datagram_connect(struct sock *sk,
@@ -323,6 +339,14 @@ static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, ch
323 buf[16] = addr & 0x0f; 339 buf[16] = addr & 0x0f;
324} 340}
325 341
342static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
343{
344 if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0)
345 memcpy(buf, broadcast, 4);
346 else
347 memcpy(buf, &naddr, sizeof(naddr));
348}
349
326#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 350#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
327#include <linux/ipv6.h> 351#include <linux/ipv6.h>
328#endif 352#endif
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 708ff7cb8806..bc3cde0a810c 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -108,6 +108,7 @@ struct rt6_info {
108 u32 rt6i_flags; 108 u32 rt6i_flags;
109 struct rt6key rt6i_src; 109 struct rt6key rt6i_src;
110 u32 rt6i_metric; 110 u32 rt6i_metric;
111 u32 rt6i_peer_genid;
111 112
112 struct inet6_dev *rt6i_idev; 113 struct inet6_dev *rt6i_idev;
113 struct inet_peer *rt6i_peer; 114 struct inet_peer *rt6i_peer;
@@ -182,7 +183,7 @@ struct fib6_table {
182 183
183typedef struct rt6_info *(*pol_lookup_t)(struct net *, 184typedef struct rt6_info *(*pol_lookup_t)(struct net *,
184 struct fib6_table *, 185 struct fib6_table *,
185 struct flowi *, int); 186 struct flowi6 *, int);
186 187
187/* 188/*
188 * exported functions 189 * exported functions
@@ -191,7 +192,7 @@ typedef struct rt6_info *(*pol_lookup_t)(struct net *,
191extern struct fib6_table *fib6_get_table(struct net *net, u32 id); 192extern struct fib6_table *fib6_get_table(struct net *net, u32 id);
192extern struct fib6_table *fib6_new_table(struct net *net, u32 id); 193extern struct fib6_table *fib6_new_table(struct net *net, u32 id);
193extern struct dst_entry *fib6_rule_lookup(struct net *net, 194extern struct dst_entry *fib6_rule_lookup(struct net *net,
194 struct flowi *fl, int flags, 195 struct flowi6 *fl6, int flags,
195 pol_lookup_t lookup); 196 pol_lookup_t lookup);
196 197
197extern struct fib6_node *fib6_lookup(struct fib6_node *root, 198extern struct fib6_node *fib6_lookup(struct fib6_node *root,
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 8552f0a2e854..c850e5fb967c 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -70,8 +70,8 @@ static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt)
70extern void ip6_route_input(struct sk_buff *skb); 70extern void ip6_route_input(struct sk_buff *skb);
71 71
72extern struct dst_entry * ip6_route_output(struct net *net, 72extern struct dst_entry * ip6_route_output(struct net *net,
73 struct sock *sk, 73 const struct sock *sk,
74 struct flowi *fl); 74 struct flowi6 *fl6);
75 75
76extern int ip6_route_init(void); 76extern int ip6_route_init(void);
77extern void ip6_route_cleanup(void); 77extern void ip6_route_cleanup(void);
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 07bdb5e9e8ac..e5d66ec88cf6 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -55,11 +55,13 @@ struct fib_nh {
55 int nh_weight; 55 int nh_weight;
56 int nh_power; 56 int nh_power;
57#endif 57#endif
58#ifdef CONFIG_NET_CLS_ROUTE 58#ifdef CONFIG_IP_ROUTE_CLASSID
59 __u32 nh_tclassid; 59 __u32 nh_tclassid;
60#endif 60#endif
61 int nh_oif; 61 int nh_oif;
62 __be32 nh_gw; 62 __be32 nh_gw;
63 __be32 nh_saddr;
64 int nh_saddr_genid;
63}; 65};
64 66
65/* 67/*
@@ -72,12 +74,13 @@ struct fib_info {
72 struct net *fib_net; 74 struct net *fib_net;
73 int fib_treeref; 75 int fib_treeref;
74 atomic_t fib_clntref; 76 atomic_t fib_clntref;
75 int fib_dead;
76 unsigned fib_flags; 77 unsigned fib_flags;
77 int fib_protocol; 78 unsigned char fib_dead;
79 unsigned char fib_protocol;
80 unsigned char fib_scope;
78 __be32 fib_prefsrc; 81 __be32 fib_prefsrc;
79 u32 fib_priority; 82 u32 fib_priority;
80 u32 fib_metrics[RTAX_MAX]; 83 u32 *fib_metrics;
81#define fib_mtu fib_metrics[RTAX_MTU-1] 84#define fib_mtu fib_metrics[RTAX_MTU-1]
82#define fib_window fib_metrics[RTAX_WINDOW-1] 85#define fib_window fib_metrics[RTAX_WINDOW-1]
83#define fib_rtt fib_metrics[RTAX_RTT-1] 86#define fib_rtt fib_metrics[RTAX_RTT-1]
@@ -96,12 +99,15 @@ struct fib_info {
96struct fib_rule; 99struct fib_rule;
97#endif 100#endif
98 101
102struct fib_table;
99struct fib_result { 103struct fib_result {
100 unsigned char prefixlen; 104 unsigned char prefixlen;
101 unsigned char nh_sel; 105 unsigned char nh_sel;
102 unsigned char type; 106 unsigned char type;
103 unsigned char scope; 107 unsigned char scope;
104 struct fib_info *fi; 108 struct fib_info *fi;
109 struct fib_table *table;
110 struct list_head *fa_head;
105#ifdef CONFIG_IP_MULTIPLE_TABLES 111#ifdef CONFIG_IP_MULTIPLE_TABLES
106 struct fib_rule *r; 112 struct fib_rule *r;
107#endif 113#endif
@@ -136,11 +142,20 @@ struct fib_result_nl {
136 142
137#endif /* CONFIG_IP_ROUTE_MULTIPATH */ 143#endif /* CONFIG_IP_ROUTE_MULTIPATH */
138 144
139#define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) 145extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
146
147#define FIB_RES_SADDR(net, res) \
148 ((FIB_RES_NH(res).nh_saddr_genid == \
149 atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
150 FIB_RES_NH(res).nh_saddr : \
151 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
140#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) 152#define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
141#define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) 153#define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev)
142#define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) 154#define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif)
143 155
156#define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \
157 FIB_RES_SADDR(net, res))
158
144struct fib_table { 159struct fib_table {
145 struct hlist_node tb_hlist; 160 struct hlist_node tb_hlist;
146 u32 tb_id; 161 u32 tb_id;
@@ -148,16 +163,13 @@ struct fib_table {
148 unsigned char tb_data[0]; 163 unsigned char tb_data[0];
149}; 164};
150 165
151extern int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, 166extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
152 struct fib_result *res, int fib_flags); 167 struct fib_result *res, int fib_flags);
153extern int fib_table_insert(struct fib_table *, struct fib_config *); 168extern int fib_table_insert(struct fib_table *, struct fib_config *);
154extern int fib_table_delete(struct fib_table *, struct fib_config *); 169extern int fib_table_delete(struct fib_table *, struct fib_config *);
155extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, 170extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
156 struct netlink_callback *cb); 171 struct netlink_callback *cb);
157extern int fib_table_flush(struct fib_table *table); 172extern int fib_table_flush(struct fib_table *table);
158extern void fib_table_select_default(struct fib_table *table,
159 const struct flowi *flp,
160 struct fib_result *res);
161extern void fib_free_table(struct fib_table *tb); 173extern void fib_free_table(struct fib_table *tb);
162 174
163 175
@@ -182,7 +194,7 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id)
182 return fib_get_table(net, id); 194 return fib_get_table(net, id);
183} 195}
184 196
185static inline int fib_lookup(struct net *net, const struct flowi *flp, 197static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
186 struct fib_result *res) 198 struct fib_result *res)
187{ 199{
188 struct fib_table *table; 200 struct fib_table *table;
@@ -201,11 +213,11 @@ static inline int fib_lookup(struct net *net, const struct flowi *flp,
201extern int __net_init fib4_rules_init(struct net *net); 213extern int __net_init fib4_rules_init(struct net *net);
202extern void __net_exit fib4_rules_exit(struct net *net); 214extern void __net_exit fib4_rules_exit(struct net *net);
203 215
204#ifdef CONFIG_NET_CLS_ROUTE 216#ifdef CONFIG_IP_ROUTE_CLASSID
205extern u32 fib_rules_tclass(struct fib_result *res); 217extern u32 fib_rules_tclass(const struct fib_result *res);
206#endif 218#endif
207 219
208extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); 220extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res);
209 221
210extern struct fib_table *fib_new_table(struct net *net, u32 id); 222extern struct fib_table *fib_new_table(struct net *net, u32 id);
211extern struct fib_table *fib_get_table(struct net *net, u32 id); 223extern struct fib_table *fib_get_table(struct net *net, u32 id);
@@ -218,24 +230,23 @@ extern void ip_fib_init(void);
218extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, 230extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
219 struct net_device *dev, __be32 *spec_dst, 231 struct net_device *dev, __be32 *spec_dst,
220 u32 *itag, u32 mark); 232 u32 *itag, u32 mark);
221extern void fib_select_default(struct net *net, const struct flowi *flp, 233extern void fib_select_default(struct fib_result *res);
222 struct fib_result *res);
223 234
224/* Exported by fib_semantics.c */ 235/* Exported by fib_semantics.c */
225extern int ip_fib_check_default(__be32 gw, struct net_device *dev); 236extern int ip_fib_check_default(__be32 gw, struct net_device *dev);
226extern int fib_sync_down_dev(struct net_device *dev, int force); 237extern int fib_sync_down_dev(struct net_device *dev, int force);
227extern int fib_sync_down_addr(struct net *net, __be32 local); 238extern int fib_sync_down_addr(struct net *net, __be32 local);
239extern void fib_update_nh_saddrs(struct net_device *dev);
228extern int fib_sync_up(struct net_device *dev); 240extern int fib_sync_up(struct net_device *dev);
229extern __be32 __fib_res_prefsrc(struct fib_result *res); 241extern void fib_select_multipath(struct fib_result *res);
230extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res);
231 242
232/* Exported by fib_{hash|trie}.c */ 243/* Exported by fib_trie.c */
233extern void fib_hash_init(void); 244extern void fib_trie_init(void);
234extern struct fib_table *fib_hash_table(u32 id); 245extern struct fib_table *fib_trie_table(u32 id);
235 246
236static inline void fib_combine_itag(u32 *itag, struct fib_result *res) 247static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)
237{ 248{
238#ifdef CONFIG_NET_CLS_ROUTE 249#ifdef CONFIG_IP_ROUTE_CLASSID
239#ifdef CONFIG_IP_MULTIPLE_TABLES 250#ifdef CONFIG_IP_MULTIPLE_TABLES
240 u32 rtag; 251 u32 rtag;
241#endif 252#endif
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index b7bbd6c28cfa..d516f00c8e0f 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -28,6 +28,80 @@
28#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 28#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
29#include <net/netfilter/nf_conntrack.h> 29#include <net/netfilter/nf_conntrack.h>
30#endif 30#endif
31#include <net/net_namespace.h> /* Netw namespace */
32
33/*
34 * Generic access of ipvs struct
35 */
36static inline struct netns_ipvs *net_ipvs(struct net* net)
37{
38 return net->ipvs;
39}
40/*
41 * Get net ptr from skb in traffic cases
42 * use skb_sknet when call is from userland (ioctl or netlink)
43 */
44static inline struct net *skb_net(const struct sk_buff *skb)
45{
46#ifdef CONFIG_NET_NS
47#ifdef CONFIG_IP_VS_DEBUG
48 /*
49 * This is used for debug only.
50 * Start with the most likely hit
51 * End with BUG
52 */
53 if (likely(skb->dev && skb->dev->nd_net))
54 return dev_net(skb->dev);
55 if (skb_dst(skb) && skb_dst(skb)->dev)
56 return dev_net(skb_dst(skb)->dev);
57 WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
58 __func__, __LINE__);
59 if (likely(skb->sk && skb->sk->sk_net))
60 return sock_net(skb->sk);
61 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
62 __func__, __LINE__);
63 BUG();
64#else
65 return dev_net(skb->dev ? : skb_dst(skb)->dev);
66#endif
67#else
68 return &init_net;
69#endif
70}
71
72static inline struct net *skb_sknet(const struct sk_buff *skb)
73{
74#ifdef CONFIG_NET_NS
75#ifdef CONFIG_IP_VS_DEBUG
76 /* Start with the most likely hit */
77 if (likely(skb->sk && skb->sk->sk_net))
78 return sock_net(skb->sk);
79 WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n",
80 __func__, __LINE__);
81 if (likely(skb->dev && skb->dev->nd_net))
82 return dev_net(skb->dev);
83 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
84 __func__, __LINE__);
85 BUG();
86#else
87 return sock_net(skb->sk);
88#endif
89#else
90 return &init_net;
91#endif
92}
93/*
94 * This one needed for single_open_net since net is stored directly in
95 * private not as a struct i.e. seq_file_net can't be used.
96 */
97static inline struct net *seq_file_single_net(struct seq_file *seq)
98{
99#ifdef CONFIG_NET_NS
100 return (struct net *)seq->private;
101#else
102 return &init_net;
103#endif
104}
31 105
32/* Connections' size value needed by ip_vs_ctl.c */ 106/* Connections' size value needed by ip_vs_ctl.c */
33extern int ip_vs_conn_tab_size; 107extern int ip_vs_conn_tab_size;
@@ -258,6 +332,23 @@ struct ip_vs_seq {
258 before last resized pkt */ 332 before last resized pkt */
259}; 333};
260 334
335/*
336 * counters per cpu
337 */
338struct ip_vs_counters {
339 __u32 conns; /* connections scheduled */
340 __u32 inpkts; /* incoming packets */
341 __u32 outpkts; /* outgoing packets */
342 __u64 inbytes; /* incoming bytes */
343 __u64 outbytes; /* outgoing bytes */
344};
345/*
346 * Stats per cpu
347 */
348struct ip_vs_cpu_stats {
349 struct ip_vs_counters ustats;
350 struct u64_stats_sync syncp;
351};
261 352
262/* 353/*
263 * IPVS statistics objects 354 * IPVS statistics objects
@@ -279,10 +370,11 @@ struct ip_vs_estimator {
279}; 370};
280 371
281struct ip_vs_stats { 372struct ip_vs_stats {
282 struct ip_vs_stats_user ustats; /* statistics */ 373 struct ip_vs_stats_user ustats; /* statistics */
283 struct ip_vs_estimator est; /* estimator */ 374 struct ip_vs_estimator est; /* estimator */
284 375 struct ip_vs_cpu_stats *cpustats; /* per cpu counters */
285 spinlock_t lock; /* spin lock */ 376 spinlock_t lock; /* spin lock */
377 struct ip_vs_stats_user ustats0; /* reset values */
286}; 378};
287 379
288struct dst_entry; 380struct dst_entry;
@@ -290,6 +382,7 @@ struct iphdr;
290struct ip_vs_conn; 382struct ip_vs_conn;
291struct ip_vs_app; 383struct ip_vs_app;
292struct sk_buff; 384struct sk_buff;
385struct ip_vs_proto_data;
293 386
294struct ip_vs_protocol { 387struct ip_vs_protocol {
295 struct ip_vs_protocol *next; 388 struct ip_vs_protocol *next;
@@ -297,21 +390,22 @@ struct ip_vs_protocol {
297 u16 protocol; 390 u16 protocol;
298 u16 num_states; 391 u16 num_states;
299 int dont_defrag; 392 int dont_defrag;
300 atomic_t appcnt; /* counter of proto app incs */
301 int *timeout_table; /* protocol timeout table */
302 393
303 void (*init)(struct ip_vs_protocol *pp); 394 void (*init)(struct ip_vs_protocol *pp);
304 395
305 void (*exit)(struct ip_vs_protocol *pp); 396 void (*exit)(struct ip_vs_protocol *pp);
306 397
398 void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
399
400 void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
401
307 int (*conn_schedule)(int af, struct sk_buff *skb, 402 int (*conn_schedule)(int af, struct sk_buff *skb,
308 struct ip_vs_protocol *pp, 403 struct ip_vs_proto_data *pd,
309 int *verdict, struct ip_vs_conn **cpp); 404 int *verdict, struct ip_vs_conn **cpp);
310 405
311 struct ip_vs_conn * 406 struct ip_vs_conn *
312 (*conn_in_get)(int af, 407 (*conn_in_get)(int af,
313 const struct sk_buff *skb, 408 const struct sk_buff *skb,
314 struct ip_vs_protocol *pp,
315 const struct ip_vs_iphdr *iph, 409 const struct ip_vs_iphdr *iph,
316 unsigned int proto_off, 410 unsigned int proto_off,
317 int inverse); 411 int inverse);
@@ -319,7 +413,6 @@ struct ip_vs_protocol {
319 struct ip_vs_conn * 413 struct ip_vs_conn *
320 (*conn_out_get)(int af, 414 (*conn_out_get)(int af,
321 const struct sk_buff *skb, 415 const struct sk_buff *skb,
322 struct ip_vs_protocol *pp,
323 const struct ip_vs_iphdr *iph, 416 const struct ip_vs_iphdr *iph,
324 unsigned int proto_off, 417 unsigned int proto_off,
325 int inverse); 418 int inverse);
@@ -337,11 +430,11 @@ struct ip_vs_protocol {
337 430
338 int (*state_transition)(struct ip_vs_conn *cp, int direction, 431 int (*state_transition)(struct ip_vs_conn *cp, int direction,
339 const struct sk_buff *skb, 432 const struct sk_buff *skb,
340 struct ip_vs_protocol *pp); 433 struct ip_vs_proto_data *pd);
341 434
342 int (*register_app)(struct ip_vs_app *inc); 435 int (*register_app)(struct net *net, struct ip_vs_app *inc);
343 436
344 void (*unregister_app)(struct ip_vs_app *inc); 437 void (*unregister_app)(struct net *net, struct ip_vs_app *inc);
345 438
346 int (*app_conn_bind)(struct ip_vs_conn *cp); 439 int (*app_conn_bind)(struct ip_vs_conn *cp);
347 440
@@ -350,14 +443,26 @@ struct ip_vs_protocol {
350 int offset, 443 int offset,
351 const char *msg); 444 const char *msg);
352 445
353 void (*timeout_change)(struct ip_vs_protocol *pp, int flags); 446 void (*timeout_change)(struct ip_vs_proto_data *pd, int flags);
447};
354 448
355 int (*set_state_timeout)(struct ip_vs_protocol *pp, char *sname, int to); 449/*
450 * protocol data per netns
451 */
452struct ip_vs_proto_data {
453 struct ip_vs_proto_data *next;
454 struct ip_vs_protocol *pp;
455 int *timeout_table; /* protocol timeout table */
456 atomic_t appcnt; /* counter of proto app incs. */
457 struct tcp_states_t *tcp_state_table;
356}; 458};
357 459
358extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); 460extern struct ip_vs_protocol *ip_vs_proto_get(unsigned short proto);
461extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net,
462 unsigned short proto);
359 463
360struct ip_vs_conn_param { 464struct ip_vs_conn_param {
465 struct net *net;
361 const union nf_inet_addr *caddr; 466 const union nf_inet_addr *caddr;
362 const union nf_inet_addr *vaddr; 467 const union nf_inet_addr *vaddr;
363 __be16 cport; 468 __be16 cport;
@@ -374,17 +479,20 @@ struct ip_vs_conn_param {
374 * IP_VS structure allocated for each dynamically scheduled connection 479 * IP_VS structure allocated for each dynamically scheduled connection
375 */ 480 */
376struct ip_vs_conn { 481struct ip_vs_conn {
377 struct list_head c_list; /* hashed list heads */ 482 struct hlist_node c_list; /* hashed list heads */
378 483#ifdef CONFIG_NET_NS
484 struct net *net; /* Name space */
485#endif
379 /* Protocol, addresses and port numbers */ 486 /* Protocol, addresses and port numbers */
380 u16 af; /* address family */ 487 u16 af; /* address family */
381 union nf_inet_addr caddr; /* client address */ 488 __be16 cport;
382 union nf_inet_addr vaddr; /* virtual address */ 489 __be16 vport;
383 union nf_inet_addr daddr; /* destination address */ 490 __be16 dport;
384 volatile __u32 flags; /* status flags */ 491 __u32 fwmark; /* Fire wall mark from skb */
385 __be16 cport; 492 union nf_inet_addr caddr; /* client address */
386 __be16 vport; 493 union nf_inet_addr vaddr; /* virtual address */
387 __be16 dport; 494 union nf_inet_addr daddr; /* destination address */
495 volatile __u32 flags; /* status flags */
388 __u16 protocol; /* Which protocol (TCP/UDP) */ 496 __u16 protocol; /* Which protocol (TCP/UDP) */
389 497
390 /* counter and timer */ 498 /* counter and timer */
@@ -422,10 +530,38 @@ struct ip_vs_conn {
422 struct ip_vs_seq in_seq; /* incoming seq. struct */ 530 struct ip_vs_seq in_seq; /* incoming seq. struct */
423 struct ip_vs_seq out_seq; /* outgoing seq. struct */ 531 struct ip_vs_seq out_seq; /* outgoing seq. struct */
424 532
533 const struct ip_vs_pe *pe;
425 char *pe_data; 534 char *pe_data;
426 __u8 pe_data_len; 535 __u8 pe_data_len;
427}; 536};
428 537
538/*
539 * To save some memory in conn table when name space is disabled.
540 */
541static inline struct net *ip_vs_conn_net(const struct ip_vs_conn *cp)
542{
543#ifdef CONFIG_NET_NS
544 return cp->net;
545#else
546 return &init_net;
547#endif
548}
549static inline void ip_vs_conn_net_set(struct ip_vs_conn *cp, struct net *net)
550{
551#ifdef CONFIG_NET_NS
552 cp->net = net;
553#endif
554}
555
556static inline int ip_vs_conn_net_eq(const struct ip_vs_conn *cp,
557 struct net *net)
558{
559#ifdef CONFIG_NET_NS
560 return cp->net == net;
561#else
562 return 1;
563#endif
564}
429 565
430/* 566/*
431 * Extended internal versions of struct ip_vs_service_user and 567 * Extended internal versions of struct ip_vs_service_user and
@@ -485,6 +621,7 @@ struct ip_vs_service {
485 unsigned flags; /* service status flags */ 621 unsigned flags; /* service status flags */
486 unsigned timeout; /* persistent timeout in ticks */ 622 unsigned timeout; /* persistent timeout in ticks */
487 __be32 netmask; /* grouping granularity */ 623 __be32 netmask; /* grouping granularity */
624 struct net *net;
488 625
489 struct list_head destinations; /* real server d-linked list */ 626 struct list_head destinations; /* real server d-linked list */
490 __u32 num_dests; /* number of servers */ 627 __u32 num_dests; /* number of servers */
@@ -510,8 +647,8 @@ struct ip_vs_dest {
510 struct list_head d_list; /* for table with all the dests */ 647 struct list_head d_list; /* for table with all the dests */
511 648
512 u16 af; /* address family */ 649 u16 af; /* address family */
513 union nf_inet_addr addr; /* IP address of the server */
514 __be16 port; /* port number of the server */ 650 __be16 port; /* port number of the server */
651 union nf_inet_addr addr; /* IP address of the server */
515 volatile unsigned flags; /* dest status flags */ 652 volatile unsigned flags; /* dest status flags */
516 atomic_t conn_flags; /* flags to copy to conn */ 653 atomic_t conn_flags; /* flags to copy to conn */
517 atomic_t weight; /* server weight */ 654 atomic_t weight; /* server weight */
@@ -538,8 +675,8 @@ struct ip_vs_dest {
538 /* for virtual service */ 675 /* for virtual service */
539 struct ip_vs_service *svc; /* service it belongs to */ 676 struct ip_vs_service *svc; /* service it belongs to */
540 __u16 protocol; /* which protocol (TCP/UDP) */ 677 __u16 protocol; /* which protocol (TCP/UDP) */
541 union nf_inet_addr vaddr; /* virtual IP address */
542 __be16 vport; /* virtual port number */ 678 __be16 vport; /* virtual port number */
679 union nf_inet_addr vaddr; /* virtual IP address */
543 __u32 vfwmark; /* firewall mark of service */ 680 __u32 vfwmark; /* firewall mark of service */
544}; 681};
545 682
@@ -651,6 +788,169 @@ struct ip_vs_app {
651 void (*timeout_change)(struct ip_vs_app *app, int flags); 788 void (*timeout_change)(struct ip_vs_app *app, int flags);
652}; 789};
653 790
791/* IPVS in network namespace */
792struct netns_ipvs {
793 int gen; /* Generation */
794 /*
795 * Hash table: for real service lookups
796 */
797 #define IP_VS_RTAB_BITS 4
798 #define IP_VS_RTAB_SIZE (1 << IP_VS_RTAB_BITS)
799 #define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1)
800
801 struct list_head rs_table[IP_VS_RTAB_SIZE];
802 /* ip_vs_app */
803 struct list_head app_list;
804
805 /* ip_vs_proto */
806 #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
807 struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
808 /* ip_vs_proto_tcp */
809#ifdef CONFIG_IP_VS_PROTO_TCP
810 #define TCP_APP_TAB_BITS 4
811 #define TCP_APP_TAB_SIZE (1 << TCP_APP_TAB_BITS)
812 #define TCP_APP_TAB_MASK (TCP_APP_TAB_SIZE - 1)
813 struct list_head tcp_apps[TCP_APP_TAB_SIZE];
814 spinlock_t tcp_app_lock;
815#endif
816 /* ip_vs_proto_udp */
817#ifdef CONFIG_IP_VS_PROTO_UDP
818 #define UDP_APP_TAB_BITS 4
819 #define UDP_APP_TAB_SIZE (1 << UDP_APP_TAB_BITS)
820 #define UDP_APP_TAB_MASK (UDP_APP_TAB_SIZE - 1)
821 struct list_head udp_apps[UDP_APP_TAB_SIZE];
822 spinlock_t udp_app_lock;
823#endif
824 /* ip_vs_proto_sctp */
825#ifdef CONFIG_IP_VS_PROTO_SCTP
826 #define SCTP_APP_TAB_BITS 4
827 #define SCTP_APP_TAB_SIZE (1 << SCTP_APP_TAB_BITS)
828 #define SCTP_APP_TAB_MASK (SCTP_APP_TAB_SIZE - 1)
829 /* Hash table for SCTP application incarnations */
830 struct list_head sctp_apps[SCTP_APP_TAB_SIZE];
831 spinlock_t sctp_app_lock;
832#endif
833 /* ip_vs_conn */
834 atomic_t conn_count; /* connection counter */
835
836 /* ip_vs_ctl */
837 struct ip_vs_stats tot_stats; /* Statistics & est. */
838
839 int num_services; /* no of virtual services */
840
841 rwlock_t rs_lock; /* real services table */
842 /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */
843 struct lock_class_key ctl_key; /* ctl_mutex debuging */
844 /* Trash for destinations */
845 struct list_head dest_trash;
846 /* Service counters */
847 atomic_t ftpsvc_counter;
848 atomic_t nullsvc_counter;
849
850#ifdef CONFIG_SYSCTL
851 /* 1/rate drop and drop-entry variables */
852 struct delayed_work defense_work; /* Work handler */
853 int drop_rate;
854 int drop_counter;
855 atomic_t dropentry;
856 /* locks in ctl.c */
857 spinlock_t dropentry_lock; /* drop entry handling */
858 spinlock_t droppacket_lock; /* drop packet handling */
859 spinlock_t securetcp_lock; /* state and timeout tables */
860
861 /* sys-ctl struct */
862 struct ctl_table_header *sysctl_hdr;
863 struct ctl_table *sysctl_tbl;
864#endif
865
866 /* sysctl variables */
867 int sysctl_amemthresh;
868 int sysctl_am_droprate;
869 int sysctl_drop_entry;
870 int sysctl_drop_packet;
871 int sysctl_secure_tcp;
872#ifdef CONFIG_IP_VS_NFCT
873 int sysctl_conntrack;
874#endif
875 int sysctl_snat_reroute;
876 int sysctl_sync_ver;
877 int sysctl_cache_bypass;
878 int sysctl_expire_nodest_conn;
879 int sysctl_expire_quiescent_template;
880 int sysctl_sync_threshold[2];
881 int sysctl_nat_icmp_send;
882
883 /* ip_vs_lblc */
884 int sysctl_lblc_expiration;
885 struct ctl_table_header *lblc_ctl_header;
886 struct ctl_table *lblc_ctl_table;
887 /* ip_vs_lblcr */
888 int sysctl_lblcr_expiration;
889 struct ctl_table_header *lblcr_ctl_header;
890 struct ctl_table *lblcr_ctl_table;
891 /* ip_vs_est */
892 struct list_head est_list; /* estimator list */
893 spinlock_t est_lock;
894 struct timer_list est_timer; /* Estimation timer */
895 /* ip_vs_sync */
896 struct list_head sync_queue;
897 spinlock_t sync_lock;
898 struct ip_vs_sync_buff *sync_buff;
899 spinlock_t sync_buff_lock;
900 struct sockaddr_in sync_mcast_addr;
901 struct task_struct *master_thread;
902 struct task_struct *backup_thread;
903 int send_mesg_maxlen;
904 int recv_mesg_maxlen;
905 volatile int sync_state;
906 volatile int master_syncid;
907 volatile int backup_syncid;
908 /* multicast interface name */
909 char master_mcast_ifn[IP_VS_IFNAME_MAXLEN];
910 char backup_mcast_ifn[IP_VS_IFNAME_MAXLEN];
911 /* net name space ptr */
912 struct net *net; /* Needed by timer routines */
913};
914
915#define DEFAULT_SYNC_THRESHOLD 3
916#define DEFAULT_SYNC_PERIOD 50
917#define DEFAULT_SYNC_VER 1
918
919#ifdef CONFIG_SYSCTL
920
921static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
922{
923 return ipvs->sysctl_sync_threshold[0];
924}
925
926static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
927{
928 return ipvs->sysctl_sync_threshold[1];
929}
930
931static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
932{
933 return ipvs->sysctl_sync_ver;
934}
935
936#else
937
938static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
939{
940 return DEFAULT_SYNC_THRESHOLD;
941}
942
943static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
944{
945 return DEFAULT_SYNC_PERIOD;
946}
947
948static inline int sysctl_sync_ver(struct netns_ipvs *ipvs)
949{
950 return DEFAULT_SYNC_VER;
951}
952
953#endif
654 954
655/* 955/*
656 * IPVS core functions 956 * IPVS core functions
@@ -674,13 +974,14 @@ enum {
674 IP_VS_DIR_LAST, 974 IP_VS_DIR_LAST,
675}; 975};
676 976
677static inline void ip_vs_conn_fill_param(int af, int protocol, 977static inline void ip_vs_conn_fill_param(struct net *net, int af, int protocol,
678 const union nf_inet_addr *caddr, 978 const union nf_inet_addr *caddr,
679 __be16 cport, 979 __be16 cport,
680 const union nf_inet_addr *vaddr, 980 const union nf_inet_addr *vaddr,
681 __be16 vport, 981 __be16 vport,
682 struct ip_vs_conn_param *p) 982 struct ip_vs_conn_param *p)
683{ 983{
984 p->net = net;
684 p->af = af; 985 p->af = af;
685 p->protocol = protocol; 986 p->protocol = protocol;
686 p->caddr = caddr; 987 p->caddr = caddr;
@@ -695,7 +996,6 @@ struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p);
695struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p); 996struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p);
696 997
697struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, 998struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb,
698 struct ip_vs_protocol *pp,
699 const struct ip_vs_iphdr *iph, 999 const struct ip_vs_iphdr *iph,
700 unsigned int proto_off, 1000 unsigned int proto_off,
701 int inverse); 1001 int inverse);
@@ -703,7 +1003,6 @@ struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb,
703struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); 1003struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p);
704 1004
705struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, 1005struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb,
706 struct ip_vs_protocol *pp,
707 const struct ip_vs_iphdr *iph, 1006 const struct ip_vs_iphdr *iph,
708 unsigned int proto_off, 1007 unsigned int proto_off,
709 int inverse); 1008 int inverse);
@@ -719,14 +1018,14 @@ extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport);
719struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p, 1018struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p,
720 const union nf_inet_addr *daddr, 1019 const union nf_inet_addr *daddr,
721 __be16 dport, unsigned flags, 1020 __be16 dport, unsigned flags,
722 struct ip_vs_dest *dest); 1021 struct ip_vs_dest *dest, __u32 fwmark);
723extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); 1022extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp);
724 1023
725extern const char * ip_vs_state_name(__u16 proto, int state); 1024extern const char * ip_vs_state_name(__u16 proto, int state);
726 1025
727extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); 1026extern void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp);
728extern int ip_vs_check_template(struct ip_vs_conn *ct); 1027extern int ip_vs_check_template(struct ip_vs_conn *ct);
729extern void ip_vs_random_dropentry(void); 1028extern void ip_vs_random_dropentry(struct net *net);
730extern int ip_vs_conn_init(void); 1029extern int ip_vs_conn_init(void);
731extern void ip_vs_conn_cleanup(void); 1030extern void ip_vs_conn_cleanup(void);
732 1031
@@ -796,12 +1095,12 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp)
796 * (from ip_vs_app.c) 1095 * (from ip_vs_app.c)
797 */ 1096 */
798#define IP_VS_APP_MAX_PORTS 8 1097#define IP_VS_APP_MAX_PORTS 8
799extern int register_ip_vs_app(struct ip_vs_app *app); 1098extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app);
800extern void unregister_ip_vs_app(struct ip_vs_app *app); 1099extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app);
801extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); 1100extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
802extern void ip_vs_unbind_app(struct ip_vs_conn *cp); 1101extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
803extern int 1102extern int register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app,
804register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port); 1103 __u16 proto, __u16 port);
805extern int ip_vs_app_inc_get(struct ip_vs_app *inc); 1104extern int ip_vs_app_inc_get(struct ip_vs_app *inc);
806extern void ip_vs_app_inc_put(struct ip_vs_app *inc); 1105extern void ip_vs_app_inc_put(struct ip_vs_app *inc);
807 1106
@@ -814,15 +1113,27 @@ void ip_vs_bind_pe(struct ip_vs_service *svc, struct ip_vs_pe *pe);
814void ip_vs_unbind_pe(struct ip_vs_service *svc); 1113void ip_vs_unbind_pe(struct ip_vs_service *svc);
815int register_ip_vs_pe(struct ip_vs_pe *pe); 1114int register_ip_vs_pe(struct ip_vs_pe *pe);
816int unregister_ip_vs_pe(struct ip_vs_pe *pe); 1115int unregister_ip_vs_pe(struct ip_vs_pe *pe);
817extern struct ip_vs_pe *ip_vs_pe_get(const char *name); 1116struct ip_vs_pe *ip_vs_pe_getbyname(const char *name);
818extern void ip_vs_pe_put(struct ip_vs_pe *pe); 1117struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name);
1118
1119static inline void ip_vs_pe_get(const struct ip_vs_pe *pe)
1120{
1121 if (pe && pe->module)
1122 __module_get(pe->module);
1123}
1124
1125static inline void ip_vs_pe_put(const struct ip_vs_pe *pe)
1126{
1127 if (pe && pe->module)
1128 module_put(pe->module);
1129}
819 1130
820/* 1131/*
821 * IPVS protocol functions (from ip_vs_proto.c) 1132 * IPVS protocol functions (from ip_vs_proto.c)
822 */ 1133 */
823extern int ip_vs_protocol_init(void); 1134extern int ip_vs_protocol_init(void);
824extern void ip_vs_protocol_cleanup(void); 1135extern void ip_vs_protocol_cleanup(void);
825extern void ip_vs_protocol_timeout_change(int flags); 1136extern void ip_vs_protocol_timeout_change(struct netns_ipvs *ipvs, int flags);
826extern int *ip_vs_create_timeout_table(int *table, int size); 1137extern int *ip_vs_create_timeout_table(int *table, int size);
827extern int 1138extern int
828ip_vs_set_state_timeout(int *table, int num, const char *const *names, 1139ip_vs_set_state_timeout(int *table, int num, const char *const *names,
@@ -852,26 +1163,23 @@ extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name);
852extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); 1163extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler);
853extern struct ip_vs_conn * 1164extern struct ip_vs_conn *
854ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, 1165ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
855 struct ip_vs_protocol *pp, int *ignored); 1166 struct ip_vs_proto_data *pd, int *ignored);
856extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, 1167extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
857 struct ip_vs_protocol *pp); 1168 struct ip_vs_proto_data *pd);
1169
1170extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg);
858 1171
859 1172
860/* 1173/*
861 * IPVS control data and functions (from ip_vs_ctl.c) 1174 * IPVS control data and functions (from ip_vs_ctl.c)
862 */ 1175 */
863extern int sysctl_ip_vs_cache_bypass;
864extern int sysctl_ip_vs_expire_nodest_conn;
865extern int sysctl_ip_vs_expire_quiescent_template;
866extern int sysctl_ip_vs_sync_threshold[2];
867extern int sysctl_ip_vs_nat_icmp_send;
868extern int sysctl_ip_vs_conntrack;
869extern int sysctl_ip_vs_snat_reroute;
870extern struct ip_vs_stats ip_vs_stats; 1176extern struct ip_vs_stats ip_vs_stats;
871extern const struct ctl_path net_vs_ctl_path[]; 1177extern const struct ctl_path net_vs_ctl_path[];
1178extern int sysctl_ip_vs_sync_ver;
872 1179
1180extern void ip_vs_sync_switch_mode(struct net *net, int mode);
873extern struct ip_vs_service * 1181extern struct ip_vs_service *
874ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, 1182ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol,
875 const union nf_inet_addr *vaddr, __be16 vport); 1183 const union nf_inet_addr *vaddr, __be16 vport);
876 1184
877static inline void ip_vs_service_put(struct ip_vs_service *svc) 1185static inline void ip_vs_service_put(struct ip_vs_service *svc)
@@ -880,7 +1188,7 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc)
880} 1188}
881 1189
882extern struct ip_vs_dest * 1190extern struct ip_vs_dest *
883ip_vs_lookup_real_service(int af, __u16 protocol, 1191ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol,
884 const union nf_inet_addr *daddr, __be16 dport); 1192 const union nf_inet_addr *daddr, __be16 dport);
885 1193
886extern int ip_vs_use_count_inc(void); 1194extern int ip_vs_use_count_inc(void);
@@ -888,8 +1196,9 @@ extern void ip_vs_use_count_dec(void);
888extern int ip_vs_control_init(void); 1196extern int ip_vs_control_init(void);
889extern void ip_vs_control_cleanup(void); 1197extern void ip_vs_control_cleanup(void);
890extern struct ip_vs_dest * 1198extern struct ip_vs_dest *
891ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, 1199ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr,
892 const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol); 1200 __be16 dport, const union nf_inet_addr *vaddr, __be16 vport,
1201 __u16 protocol, __u32 fwmark);
893extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); 1202extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
894 1203
895 1204
@@ -897,14 +1206,12 @@ extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
897 * IPVS sync daemon data and function prototypes 1206 * IPVS sync daemon data and function prototypes
898 * (from ip_vs_sync.c) 1207 * (from ip_vs_sync.c)
899 */ 1208 */
900extern volatile int ip_vs_sync_state; 1209extern int start_sync_thread(struct net *net, int state, char *mcast_ifn,
901extern volatile int ip_vs_master_syncid; 1210 __u8 syncid);
902extern volatile int ip_vs_backup_syncid; 1211extern int stop_sync_thread(struct net *net, int state);
903extern char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN]; 1212extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp);
904extern char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN]; 1213extern int ip_vs_sync_init(void);
905extern int start_sync_thread(int state, char *mcast_ifn, __u8 syncid); 1214extern void ip_vs_sync_cleanup(void);
906extern int stop_sync_thread(int state);
907extern void ip_vs_sync_conn(struct ip_vs_conn *cp);
908 1215
909 1216
910/* 1217/*
@@ -912,9 +1219,11 @@ extern void ip_vs_sync_conn(struct ip_vs_conn *cp);
912 */ 1219 */
913extern int ip_vs_estimator_init(void); 1220extern int ip_vs_estimator_init(void);
914extern void ip_vs_estimator_cleanup(void); 1221extern void ip_vs_estimator_cleanup(void);
915extern void ip_vs_new_estimator(struct ip_vs_stats *stats); 1222extern void ip_vs_start_estimator(struct net *net, struct ip_vs_stats *stats);
916extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); 1223extern void ip_vs_stop_estimator(struct net *net, struct ip_vs_stats *stats);
917extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); 1224extern void ip_vs_zero_estimator(struct ip_vs_stats *stats);
1225extern void ip_vs_read_estimator(struct ip_vs_stats_user *dst,
1226 struct ip_vs_stats *stats);
918 1227
919/* 1228/*
920 * Various IPVS packet transmitters (from ip_vs_xmit.c) 1229 * Various IPVS packet transmitters (from ip_vs_xmit.c)
@@ -947,21 +1256,25 @@ extern int ip_vs_icmp_xmit_v6
947 int offset); 1256 int offset);
948#endif 1257#endif
949 1258
1259#ifdef CONFIG_SYSCTL
950/* 1260/*
951 * This is a simple mechanism to ignore packets when 1261 * This is a simple mechanism to ignore packets when
952 * we are loaded. Just set ip_vs_drop_rate to 'n' and 1262 * we are loaded. Just set ip_vs_drop_rate to 'n' and
953 * we start to drop 1/rate of the packets 1263 * we start to drop 1/rate of the packets
954 */ 1264 */
955extern int ip_vs_drop_rate;
956extern int ip_vs_drop_counter;
957 1265
958static __inline__ int ip_vs_todrop(void) 1266static inline int ip_vs_todrop(struct netns_ipvs *ipvs)
959{ 1267{
960 if (!ip_vs_drop_rate) return 0; 1268 if (!ipvs->drop_rate)
961 if (--ip_vs_drop_counter > 0) return 0; 1269 return 0;
962 ip_vs_drop_counter = ip_vs_drop_rate; 1270 if (--ipvs->drop_counter > 0)
1271 return 0;
1272 ipvs->drop_counter = ipvs->drop_rate;
963 return 1; 1273 return 1;
964} 1274}
1275#else
1276static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; }
1277#endif
965 1278
966/* 1279/*
967 * ip_vs_fwd_tag returns the forwarding tag of the connection 1280 * ip_vs_fwd_tag returns the forwarding tag of the connection
@@ -1031,7 +1344,7 @@ static inline void ip_vs_notrack(struct sk_buff *skb)
1031{ 1344{
1032#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 1345#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1033 enum ip_conntrack_info ctinfo; 1346 enum ip_conntrack_info ctinfo;
1034 struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo); 1347 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
1035 1348
1036 if (!ct || !nf_ct_is_untracked(ct)) { 1349 if (!ct || !nf_ct_is_untracked(ct)) {
1037 nf_reset(skb); 1350 nf_reset(skb);
@@ -1047,9 +1360,13 @@ static inline void ip_vs_notrack(struct sk_buff *skb)
1047 * Netfilter connection tracking 1360 * Netfilter connection tracking
1048 * (from ip_vs_nfct.c) 1361 * (from ip_vs_nfct.c)
1049 */ 1362 */
1050static inline int ip_vs_conntrack_enabled(void) 1363static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs)
1051{ 1364{
1052 return sysctl_ip_vs_conntrack; 1365#ifdef CONFIG_SYSCTL
1366 return ipvs->sysctl_conntrack;
1367#else
1368 return 0;
1369#endif
1053} 1370}
1054 1371
1055extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, 1372extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp,
@@ -1062,7 +1379,7 @@ extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp);
1062 1379
1063#else 1380#else
1064 1381
1065static inline int ip_vs_conntrack_enabled(void) 1382static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs)
1066{ 1383{
1067 return 0; 1384 return 0;
1068} 1385}
@@ -1084,6 +1401,20 @@ static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp)
1084/* CONFIG_IP_VS_NFCT */ 1401/* CONFIG_IP_VS_NFCT */
1085#endif 1402#endif
1086 1403
1404static inline unsigned int
1405ip_vs_dest_conn_overhead(struct ip_vs_dest *dest)
1406{
1407 /*
1408 * We think the overhead of processing active connections is 256
1409 * times higher than that of inactive connections in average. (This
1410 * 256 times might not be accurate, we will change it later) We
1411 * use the following formula to estimate the overhead now:
1412 * dest->activeconns*256 + dest->inactconns
1413 */
1414 return (atomic_read(&dest->activeconns) << 8) +
1415 atomic_read(&dest->inactconns);
1416}
1417
1087#endif /* __KERNEL__ */ 1418#endif /* __KERNEL__ */
1088 1419
1089#endif /* _NET_IP_VS_H */ 1420#endif /* _NET_IP_VS_H */
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 4a3cd2cd2f5e..34200f9e6805 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -89,6 +89,18 @@
89#define IPV6_ADDR_SCOPE_GLOBAL 0x0e 89#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
90 90
91/* 91/*
92 * Addr flags
93 */
94#ifdef __KERNEL__
95#define IPV6_ADDR_MC_FLAG_TRANSIENT(a) \
96 ((a)->s6_addr[1] & 0x10)
97#define IPV6_ADDR_MC_FLAG_PREFIX(a) \
98 ((a)->s6_addr[1] & 0x20)
99#define IPV6_ADDR_MC_FLAG_RENDEZVOUS(a) \
100 ((a)->s6_addr[1] & 0x40)
101#endif
102
103/*
92 * fragmentation header 104 * fragmentation header
93 */ 105 */
94 106
@@ -480,7 +492,7 @@ extern int ip6_rcv_finish(struct sk_buff *skb);
480 */ 492 */
481extern int ip6_xmit(struct sock *sk, 493extern int ip6_xmit(struct sock *sk,
482 struct sk_buff *skb, 494 struct sk_buff *skb,
483 struct flowi *fl, 495 struct flowi6 *fl6,
484 struct ipv6_txoptions *opt); 496 struct ipv6_txoptions *opt);
485 497
486extern int ip6_nd_hdr(struct sock *sk, 498extern int ip6_nd_hdr(struct sock *sk,
@@ -500,7 +512,7 @@ extern int ip6_append_data(struct sock *sk,
500 int hlimit, 512 int hlimit,
501 int tclass, 513 int tclass,
502 struct ipv6_txoptions *opt, 514 struct ipv6_txoptions *opt,
503 struct flowi *fl, 515 struct flowi6 *fl6,
504 struct rt6_info *rt, 516 struct rt6_info *rt,
505 unsigned int flags, 517 unsigned int flags,
506 int dontfrag); 518 int dontfrag);
@@ -511,13 +523,17 @@ extern void ip6_flush_pending_frames(struct sock *sk);
511 523
512extern int ip6_dst_lookup(struct sock *sk, 524extern int ip6_dst_lookup(struct sock *sk,
513 struct dst_entry **dst, 525 struct dst_entry **dst,
514 struct flowi *fl); 526 struct flowi6 *fl6);
515extern int ip6_dst_blackhole(struct sock *sk, 527extern struct dst_entry * ip6_dst_lookup_flow(struct sock *sk,
516 struct dst_entry **dst, 528 struct flowi6 *fl6,
517 struct flowi *fl); 529 const struct in6_addr *final_dst,
518extern int ip6_sk_dst_lookup(struct sock *sk, 530 bool can_sleep);
519 struct dst_entry **dst, 531extern struct dst_entry * ip6_sk_dst_lookup_flow(struct sock *sk,
520 struct flowi *fl); 532 struct flowi6 *fl6,
533 const struct in6_addr *final_dst,
534 bool can_sleep);
535extern struct dst_entry * ip6_blackhole_route(struct net *net,
536 struct dst_entry *orig_dst);
521 537
522/* 538/*
523 * skb processing functions 539 * skb processing functions
@@ -550,7 +566,7 @@ extern int ipv6_ext_hdr(u8 nexthdr);
550 566
551extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type); 567extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type);
552 568
553extern struct in6_addr *fl6_update_dst(struct flowi *fl, 569extern struct in6_addr *fl6_update_dst(struct flowi6 *fl6,
554 const struct ipv6_txoptions *opt, 570 const struct ipv6_txoptions *opt,
555 struct in6_addr *orig); 571 struct in6_addr *orig);
556 572
@@ -584,8 +600,8 @@ extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len);
584extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len); 600extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len);
585extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, 601extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
586 u32 info, u8 *payload); 602 u32 info, u8 *payload);
587extern void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info); 603extern void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info);
588extern void ipv6_local_rxpmtu(struct sock *sk, struct flowi *fl, u32 mtu); 604extern void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu);
589 605
590extern int inet6_release(struct socket *sock); 606extern int inet6_release(struct socket *sock);
591extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr, 607extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr,
diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
index eea2e6152389..59ba38bc400f 100644
--- a/include/net/irda/ircomm_tty.h
+++ b/include/net/irda/ircomm_tty.h
@@ -120,10 +120,10 @@ struct ircomm_tty_cb {
120void ircomm_tty_start(struct tty_struct *tty); 120void ircomm_tty_start(struct tty_struct *tty);
121void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self); 121void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self);
122 122
123extern int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file); 123extern int ircomm_tty_tiocmget(struct tty_struct *tty);
124extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file, 124extern int ircomm_tty_tiocmset(struct tty_struct *tty,
125 unsigned int set, unsigned int clear); 125 unsigned int set, unsigned int clear);
126extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, 126extern int ircomm_tty_ioctl(struct tty_struct *tty,
127 unsigned int cmd, unsigned long arg); 127 unsigned int cmd, unsigned long arg);
128extern void ircomm_tty_set_termios(struct tty_struct *tty, 128extern void ircomm_tty_set_termios(struct tty_struct *tty,
129 struct ktermios *old_termios); 129 struct ktermios *old_termios);
diff --git a/include/net/irda/irlap.h b/include/net/irda/irlap.h
index 17fcd964f9d9..fb4b76d5d7f1 100644
--- a/include/net/irda/irlap.h
+++ b/include/net/irda/irlap.h
@@ -204,7 +204,7 @@ struct irlap_cb {
204 204
205 notify_t notify; /* Callbacks to IrLMP */ 205 notify_t notify; /* Callbacks to IrLMP */
206 206
207 int mtt_required; /* Minumum turnaround time required */ 207 int mtt_required; /* Minimum turnaround time required */
208 int xbofs_delay; /* Nr of XBOF's used to MTT */ 208 int xbofs_delay; /* Nr of XBOF's used to MTT */
209 int bofs_count; /* Negotiated extra BOFs */ 209 int bofs_count; /* Negotiated extra BOFs */
210 int next_bofs; /* Negotiated extra BOFs after next frame */ 210 int next_bofs; /* Negotiated extra BOFs after next frame */
diff --git a/include/net/irda/wrapper.h b/include/net/irda/wrapper.h
index 2942ad6ab932..eef53ebe3d76 100644
--- a/include/net/irda/wrapper.h
+++ b/include/net/irda/wrapper.h
@@ -42,7 +42,7 @@
42 42
43#define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */ 43#define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */
44 44
45/* States for receving a frame in async mode */ 45/* States for receiving a frame in async mode */
46enum { 46enum {
47 OUTSIDE_FRAME, 47 OUTSIDE_FRAME,
48 BEGIN_FRAME, 48 BEGIN_FRAME,
diff --git a/include/net/iucv/iucv.h b/include/net/iucv/iucv.h
index 205a3360156e..1121baa9f695 100644
--- a/include/net/iucv/iucv.h
+++ b/include/net/iucv/iucv.h
@@ -173,7 +173,7 @@ struct iucv_handler {
173 /* 173 /*
174 * The message_pending function is called after an icuv interrupt 174 * The message_pending function is called after an icuv interrupt
175 * type 0x06 or type 0x07 has been received. A new message is 175 * type 0x06 or type 0x07 has been received. A new message is
176 * availabe and can be received with iucv_message_receive. 176 * available and can be received with iucv_message_receive.
177 */ 177 */
178 void (*message_pending)(struct iucv_path *, struct iucv_message *); 178 void (*message_pending)(struct iucv_path *, struct iucv_message *);
179 /* 179 /*
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index 3afdb21cc31d..5d5a6a4732ef 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -91,7 +91,7 @@
91 * -------------------- 91 * --------------------
92 * The implementation goals were as follow : 92 * The implementation goals were as follow :
93 * o Obvious : you should not need a PhD to understand what's happening, 93 * o Obvious : you should not need a PhD to understand what's happening,
94 * the benefit is easier maintainance. 94 * the benefit is easier maintenance.
95 * o Flexible : it should accommodate a wide variety of driver 95 * o Flexible : it should accommodate a wide variety of driver
96 * implementations and be as flexible as the old API. 96 * implementations and be as flexible as the old API.
97 * o Lean : it should be efficient memory wise to minimise the impact 97 * o Lean : it should be efficient memory wise to minimise the impact
@@ -129,7 +129,7 @@
129 * 129 *
130 * Functions prototype uses union iwreq_data 130 * Functions prototype uses union iwreq_data
131 * ----------------------------------------- 131 * -----------------------------------------
132 * Some would have prefered functions defined this way : 132 * Some would have preferred functions defined this way :
133 * static int mydriver_ioctl_setrate(struct net_device *dev, 133 * static int mydriver_ioctl_setrate(struct net_device *dev,
134 * long rate, int auto) 134 * long rate, int auto)
135 * 1) The kernel code doesn't "validate" the content of iwreq_data, and 135 * 1) The kernel code doesn't "validate" the content of iwreq_data, and
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 62c0ce2d1dc8..025d4cc7bbf8 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -341,6 +341,9 @@ struct ieee80211_bss_conf {
341 * the off-channel channel when a remain-on-channel offload is done 341 * the off-channel channel when a remain-on-channel offload is done
342 * in hardware -- normal packets still flow and are expected to be 342 * in hardware -- normal packets still flow and are expected to be
343 * handled properly by the device. 343 * handled properly by the device.
344 * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP
345 * testing. It will be sent out with incorrect Michael MIC key to allow
346 * TKIP countermeasures to be tested.
344 * 347 *
345 * Note: If you have to add new flags to the enumeration, then don't 348 * Note: If you have to add new flags to the enumeration, then don't
346 * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary. 349 * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary.
@@ -370,6 +373,7 @@ enum mac80211_tx_control_flags {
370 IEEE80211_TX_CTL_LDPC = BIT(22), 373 IEEE80211_TX_CTL_LDPC = BIT(22),
371 IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), 374 IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24),
372 IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25), 375 IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25),
376 IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26),
373}; 377};
374 378
375#define IEEE80211_TX_CTL_STBC_SHIFT 23 379#define IEEE80211_TX_CTL_STBC_SHIFT 23
@@ -595,9 +599,10 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
595 * the frame. 599 * the frame.
596 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on 600 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
597 * the frame. 601 * the frame.
598 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) 602 * @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime
599 * is valid. This is useful in monitor mode and necessary for beacon frames 603 * field) is valid and contains the time the first symbol of the MPDU
600 * to enable IBSS merging. 604 * was received. This is useful in monitor mode and for proper IBSS
605 * merging.
601 * @RX_FLAG_SHORTPRE: Short preamble was used for this frame 606 * @RX_FLAG_SHORTPRE: Short preamble was used for this frame
602 * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index 607 * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index
603 * @RX_FLAG_40MHZ: HT40 (40 MHz) was used 608 * @RX_FLAG_40MHZ: HT40 (40 MHz) was used
@@ -610,7 +615,7 @@ enum mac80211_rx_flags {
610 RX_FLAG_IV_STRIPPED = 1<<4, 615 RX_FLAG_IV_STRIPPED = 1<<4,
611 RX_FLAG_FAILED_FCS_CRC = 1<<5, 616 RX_FLAG_FAILED_FCS_CRC = 1<<5,
612 RX_FLAG_FAILED_PLCP_CRC = 1<<6, 617 RX_FLAG_FAILED_PLCP_CRC = 1<<6,
613 RX_FLAG_TSFT = 1<<7, 618 RX_FLAG_MACTIME_MPDU = 1<<7,
614 RX_FLAG_SHORTPRE = 1<<8, 619 RX_FLAG_SHORTPRE = 1<<8,
615 RX_FLAG_HT = 1<<9, 620 RX_FLAG_HT = 1<<9,
616 RX_FLAG_40MHZ = 1<<10, 621 RX_FLAG_40MHZ = 1<<10,
@@ -1069,6 +1074,13 @@ enum ieee80211_tkip_key_type {
1069 * to decrypt group addressed frames, then IBSS RSN support is still 1074 * to decrypt group addressed frames, then IBSS RSN support is still
1070 * possible but software crypto will be used. Advertise the wiphy flag 1075 * possible but software crypto will be used. Advertise the wiphy flag
1071 * only in that case. 1076 * only in that case.
1077 *
1078 * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device
1079 * autonomously manages the PS status of connected stations. When
1080 * this flag is set mac80211 will not trigger PS mode for connected
1081 * stations based on the PM bit of incoming frames.
1082 * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure
1083 * the PS mode of connected stations.
1072 */ 1084 */
1073enum ieee80211_hw_flags { 1085enum ieee80211_hw_flags {
1074 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, 1086 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
@@ -1093,6 +1105,7 @@ enum ieee80211_hw_flags {
1093 IEEE80211_HW_CONNECTION_MONITOR = 1<<19, 1105 IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
1094 IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, 1106 IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20,
1095 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, 1107 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
1108 IEEE80211_HW_AP_LINK_PS = 1<<22,
1096}; 1109};
1097 1110
1098/** 1111/**
@@ -1147,6 +1160,17 @@ enum ieee80211_hw_flags {
1147 * @napi_weight: weight used for NAPI polling. You must specify an 1160 * @napi_weight: weight used for NAPI polling. You must specify an
1148 * appropriate value here if a napi_poll operation is provided 1161 * appropriate value here if a napi_poll operation is provided
1149 * by your driver. 1162 * by your driver.
1163 *
1164 * @max_rx_aggregation_subframes: maximum buffer size (number of
1165 * sub-frames) to be used for A-MPDU block ack receiver
1166 * aggregation.
1167 * This is only relevant if the device has restrictions on the
1168 * number of subframes, if it relies on mac80211 to do reordering
1169 * it shouldn't be set.
1170 *
1171 * @max_tx_aggregation_subframes: maximum number of subframes in an
1172 * aggregate an HT driver will transmit, used by the peer as a
1173 * hint to size its reorder buffer.
1150 */ 1174 */
1151struct ieee80211_hw { 1175struct ieee80211_hw {
1152 struct ieee80211_conf conf; 1176 struct ieee80211_conf conf;
@@ -1165,6 +1189,8 @@ struct ieee80211_hw {
1165 u8 max_rates; 1189 u8 max_rates;
1166 u8 max_report_rates; 1190 u8 max_report_rates;
1167 u8 max_rate_tries; 1191 u8 max_rate_tries;
1192 u8 max_rx_aggregation_subframes;
1193 u8 max_tx_aggregation_subframes;
1168}; 1194};
1169 1195
1170/** 1196/**
@@ -1268,7 +1294,7 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
1268 * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key 1294 * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key
1269 * handler. 1295 * handler.
1270 * The update_tkip_key() call updates the driver with the new phase 1 key. 1296 * The update_tkip_key() call updates the driver with the new phase 1 key.
1271 * This happens everytime the iv16 wraps around (every 65536 packets). The 1297 * This happens every time the iv16 wraps around (every 65536 packets). The
1272 * set_key() call will happen only once for each key (unless the AP did 1298 * set_key() call will happen only once for each key (unless the AP did
1273 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is 1299 * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is
1274 * provided by update_tkip_key only. The trigger that makes mac80211 call this 1300 * provided by update_tkip_key only. The trigger that makes mac80211 call this
@@ -1688,7 +1714,9 @@ enum ieee80211_ampdu_mlme_action {
1688 * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. 1714 * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
1689 * 1715 *
1690 * @sta_notify: Notifies low level driver about power state transition of an 1716 * @sta_notify: Notifies low level driver about power state transition of an
1691 * associated station, AP, IBSS/WDS/mesh peer etc. Must be atomic. 1717 * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating
1718 * in AP mode, this callback will not be called when the flag
1719 * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic.
1692 * 1720 *
1693 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), 1721 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
1694 * bursting) for a hardware TX queue. 1722 * bursting) for a hardware TX queue.
@@ -1723,6 +1751,21 @@ enum ieee80211_ampdu_mlme_action {
1723 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) 1751 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
1724 * is the first frame we expect to perform the action on. Notice 1752 * is the first frame we expect to perform the action on. Notice
1725 * that TX/RX_STOP can pass NULL for this parameter. 1753 * that TX/RX_STOP can pass NULL for this parameter.
1754 * The @buf_size parameter is only valid when the action is set to
1755 * %IEEE80211_AMPDU_TX_OPERATIONAL and indicates the peer's reorder
1756 * buffer size (number of subframes) for this session -- the driver
1757 * may neither send aggregates containing more subframes than this
1758 * nor send aggregates in a way that lost frames would exceed the
1759 * buffer size. If just limiting the aggregate size, this would be
1760 * possible with a buf_size of 8:
1761 * - TX: 1.....7
1762 * - RX: 2....7 (lost frame #1)
1763 * - TX: 8..1...
1764 * which is invalid since #1 was now re-transmitted well past the
1765 * buffer size of 8. Correct ways to retransmit #1 would be:
1766 * - TX: 1 or 18 or 81
1767 * Even "189" would be wrong since 1 could be lost again.
1768 *
1726 * Returns a negative error code on failure. 1769 * Returns a negative error code on failure.
1727 * The callback can sleep. 1770 * The callback can sleep.
1728 * 1771 *
@@ -1767,9 +1810,18 @@ enum ieee80211_ampdu_mlme_action {
1767 * ieee80211_remain_on_channel_expired(). This callback may sleep. 1810 * ieee80211_remain_on_channel_expired(). This callback may sleep.
1768 * @cancel_remain_on_channel: Requests that an ongoing off-channel period is 1811 * @cancel_remain_on_channel: Requests that an ongoing off-channel period is
1769 * aborted before it expires. This callback may sleep. 1812 * aborted before it expires. This callback may sleep.
1813 * @offchannel_tx: Transmit frame on another channel, wait for a response
1814 * and return. Reliable TX status must be reported for the frame. If the
1815 * return value is 1, then the @remain_on_channel will be used with a
1816 * regular transmission (if supported.)
1817 * @offchannel_tx_cancel_wait: cancel wait associated with offchannel TX
1818 *
1819 * @set_ringparam: Set tx and rx ring sizes.
1820 *
1821 * @get_ringparam: Get tx and rx ring current and maximum sizes.
1770 */ 1822 */
1771struct ieee80211_ops { 1823struct ieee80211_ops {
1772 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); 1824 void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
1773 int (*start)(struct ieee80211_hw *hw); 1825 int (*start)(struct ieee80211_hw *hw);
1774 void (*stop)(struct ieee80211_hw *hw); 1826 void (*stop)(struct ieee80211_hw *hw);
1775 int (*add_interface)(struct ieee80211_hw *hw, 1827 int (*add_interface)(struct ieee80211_hw *hw,
@@ -1825,7 +1877,8 @@ struct ieee80211_ops {
1825 int (*ampdu_action)(struct ieee80211_hw *hw, 1877 int (*ampdu_action)(struct ieee80211_hw *hw,
1826 struct ieee80211_vif *vif, 1878 struct ieee80211_vif *vif,
1827 enum ieee80211_ampdu_mlme_action action, 1879 enum ieee80211_ampdu_mlme_action action,
1828 struct ieee80211_sta *sta, u16 tid, u16 *ssn); 1880 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
1881 u8 buf_size);
1829 int (*get_survey)(struct ieee80211_hw *hw, int idx, 1882 int (*get_survey)(struct ieee80211_hw *hw, int idx,
1830 struct survey_info *survey); 1883 struct survey_info *survey);
1831 void (*rfkill_poll)(struct ieee80211_hw *hw); 1884 void (*rfkill_poll)(struct ieee80211_hw *hw);
@@ -1845,6 +1898,14 @@ struct ieee80211_ops {
1845 enum nl80211_channel_type channel_type, 1898 enum nl80211_channel_type channel_type,
1846 int duration); 1899 int duration);
1847 int (*cancel_remain_on_channel)(struct ieee80211_hw *hw); 1900 int (*cancel_remain_on_channel)(struct ieee80211_hw *hw);
1901 int (*offchannel_tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
1902 struct ieee80211_channel *chan,
1903 enum nl80211_channel_type channel_type,
1904 unsigned int wait);
1905 int (*offchannel_tx_cancel_wait)(struct ieee80211_hw *hw);
1906 int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx);
1907 void (*get_ringparam)(struct ieee80211_hw *hw,
1908 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max);
1848}; 1909};
1849 1910
1850/** 1911/**
@@ -2113,6 +2174,48 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
2113 local_bh_enable(); 2174 local_bh_enable();
2114} 2175}
2115 2176
2177/**
2178 * ieee80211_sta_ps_transition - PS transition for connected sta
2179 *
2180 * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS
2181 * flag set, use this function to inform mac80211 about a connected station
2182 * entering/leaving PS mode.
2183 *
2184 * This function may not be called in IRQ context or with softirqs enabled.
2185 *
2186 * Calls to this function for a single hardware must be synchronized against
2187 * each other.
2188 *
2189 * The function returns -EINVAL when the requested PS mode is already set.
2190 *
2191 * @sta: currently connected sta
2192 * @start: start or stop PS
2193 */
2194int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start);
2195
2196/**
2197 * ieee80211_sta_ps_transition_ni - PS transition for connected sta
2198 * (in process context)
2199 *
2200 * Like ieee80211_sta_ps_transition() but can be called in process context
2201 * (internally disables bottom halves). Concurrent call restriction still
2202 * applies.
2203 *
2204 * @sta: currently connected sta
2205 * @start: start or stop PS
2206 */
2207static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta,
2208 bool start)
2209{
2210 int ret;
2211
2212 local_bh_disable();
2213 ret = ieee80211_sta_ps_transition(sta, start);
2214 local_bh_enable();
2215
2216 return ret;
2217}
2218
2116/* 2219/*
2117 * The TX headroom reserved by mac80211 for its own tx_status functions. 2220 * The TX headroom reserved by mac80211 for its own tx_status functions.
2118 * This is enough for the radiotap header. 2221 * This is enough for the radiotap header.
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 1bf812b21fb7..3ae491932bc8 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -27,6 +27,7 @@ struct sock;
27struct ctl_table_header; 27struct ctl_table_header;
28struct net_generic; 28struct net_generic;
29struct sock; 29struct sock;
30struct netns_ipvs;
30 31
31 32
32#define NETDEV_HASHBITS 8 33#define NETDEV_HASHBITS 8
@@ -94,6 +95,7 @@ struct net {
94#ifdef CONFIG_XFRM 95#ifdef CONFIG_XFRM
95 struct netns_xfrm xfrm; 96 struct netns_xfrm xfrm;
96#endif 97#endif
98 struct netns_ipvs *ipvs;
97}; 99};
98 100
99 101
diff --git a/include/net/netevent.h b/include/net/netevent.h
index e82b7bab3ff3..22b239c17eaa 100644
--- a/include/net/netevent.h
+++ b/include/net/netevent.h
@@ -21,7 +21,6 @@ struct netevent_redirect {
21 21
22enum netevent_notif_type { 22enum netevent_notif_type {
23 NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */ 23 NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */
24 NETEVENT_PMTU_UPDATE, /* arg is struct dst_entry ptr */
25 NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */ 24 NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */
26}; 25};
27 26
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index d85cff10e169..d0d13378991e 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -50,11 +50,24 @@ union nf_conntrack_expect_proto {
50/* per conntrack: application helper private data */ 50/* per conntrack: application helper private data */
51union nf_conntrack_help { 51union nf_conntrack_help {
52 /* insert conntrack helper private data (master) here */ 52 /* insert conntrack helper private data (master) here */
53#if defined(CONFIG_NF_CONNTRACK_FTP) || defined(CONFIG_NF_CONNTRACK_FTP_MODULE)
53 struct nf_ct_ftp_master ct_ftp_info; 54 struct nf_ct_ftp_master ct_ftp_info;
55#endif
56#if defined(CONFIG_NF_CONNTRACK_PPTP) || \
57 defined(CONFIG_NF_CONNTRACK_PPTP_MODULE)
54 struct nf_ct_pptp_master ct_pptp_info; 58 struct nf_ct_pptp_master ct_pptp_info;
59#endif
60#if defined(CONFIG_NF_CONNTRACK_H323) || \
61 defined(CONFIG_NF_CONNTRACK_H323_MODULE)
55 struct nf_ct_h323_master ct_h323_info; 62 struct nf_ct_h323_master ct_h323_info;
63#endif
64#if defined(CONFIG_NF_CONNTRACK_SANE) || \
65 defined(CONFIG_NF_CONNTRACK_SANE_MODULE)
56 struct nf_ct_sane_master ct_sane_info; 66 struct nf_ct_sane_master ct_sane_info;
67#endif
68#if defined(CONFIG_NF_CONNTRACK_SIP) || defined(CONFIG_NF_CONNTRACK_SIP_MODULE)
57 struct nf_ct_sip_master ct_sip_info; 69 struct nf_ct_sip_master ct_sip_info;
70#endif
58}; 71};
59 72
60#include <linux/types.h> 73#include <linux/types.h>
@@ -116,14 +129,14 @@ struct nf_conn {
116 u_int32_t secmark; 129 u_int32_t secmark;
117#endif 130#endif
118 131
119 /* Storage reserved for other modules: */
120 union nf_conntrack_proto proto;
121
122 /* Extensions */ 132 /* Extensions */
123 struct nf_ct_ext *ext; 133 struct nf_ct_ext *ext;
124#ifdef CONFIG_NET_NS 134#ifdef CONFIG_NET_NS
125 struct net *ct_net; 135 struct net *ct_net;
126#endif 136#endif
137
138 /* Storage reserved for other modules, must be the last member */
139 union nf_conntrack_proto proto;
127}; 140};
128 141
129static inline struct nf_conn * 142static inline struct nf_conn *
@@ -189,9 +202,9 @@ extern void nf_ct_l3proto_module_put(unsigned short l3proto);
189 * Allocate a hashtable of hlist_head (if nulls == 0), 202 * Allocate a hashtable of hlist_head (if nulls == 0),
190 * or hlist_nulls_head (if nulls == 1) 203 * or hlist_nulls_head (if nulls == 1)
191 */ 204 */
192extern void *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced, int nulls); 205extern void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls);
193 206
194extern void nf_ct_free_hashtable(void *hash, int vmalloced, unsigned int size); 207extern void nf_ct_free_hashtable(void *hash, unsigned int size);
195 208
196extern struct nf_conntrack_tuple_hash * 209extern struct nf_conntrack_tuple_hash *
197__nf_conntrack_find(struct net *net, u16 zone, 210__nf_conntrack_find(struct net *net, u16 zone,
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index 96ba5f7dcab6..4283508b3e18 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -23,12 +23,17 @@ struct nf_conntrack_ecache {
23static inline struct nf_conntrack_ecache * 23static inline struct nf_conntrack_ecache *
24nf_ct_ecache_find(const struct nf_conn *ct) 24nf_ct_ecache_find(const struct nf_conn *ct)
25{ 25{
26#ifdef CONFIG_NF_CONNTRACK_EVENTS
26 return nf_ct_ext_find(ct, NF_CT_EXT_ECACHE); 27 return nf_ct_ext_find(ct, NF_CT_EXT_ECACHE);
28#else
29 return NULL;
30#endif
27} 31}
28 32
29static inline struct nf_conntrack_ecache * 33static inline struct nf_conntrack_ecache *
30nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp) 34nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp)
31{ 35{
36#ifdef CONFIG_NF_CONNTRACK_EVENTS
32 struct net *net = nf_ct_net(ct); 37 struct net *net = nf_ct_net(ct);
33 struct nf_conntrack_ecache *e; 38 struct nf_conntrack_ecache *e;
34 39
@@ -45,6 +50,9 @@ nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp)
45 e->expmask = expmask; 50 e->expmask = expmask;
46 } 51 }
47 return e; 52 return e;
53#else
54 return NULL;
55#endif
48}; 56};
49 57
50#ifdef CONFIG_NF_CONNTRACK_EVENTS 58#ifdef CONFIG_NF_CONNTRACK_EVENTS
@@ -59,7 +67,7 @@ struct nf_ct_event_notifier {
59 int (*fcn)(unsigned int events, struct nf_ct_event *item); 67 int (*fcn)(unsigned int events, struct nf_ct_event *item);
60}; 68};
61 69
62extern struct nf_ct_event_notifier *nf_conntrack_event_cb; 70extern struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb;
63extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); 71extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb);
64extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); 72extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb);
65 73
@@ -77,9 +85,6 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
77 if (e == NULL) 85 if (e == NULL)
78 return; 86 return;
79 87
80 if (!(e->ctmask & (1 << event)))
81 return;
82
83 set_bit(event, &e->cache); 88 set_bit(event, &e->cache);
84} 89}
85 90
@@ -159,7 +164,7 @@ struct nf_exp_event_notifier {
159 int (*fcn)(unsigned int events, struct nf_exp_event *item); 164 int (*fcn)(unsigned int events, struct nf_exp_event *item);
160}; 165};
161 166
162extern struct nf_exp_event_notifier *nf_expect_event_cb; 167extern struct nf_exp_event_notifier __rcu *nf_expect_event_cb;
163extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); 168extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb);
164extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); 169extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb);
165 170
diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h
index 0772d296dfdb..2dcf31703acb 100644
--- a/include/net/netfilter/nf_conntrack_extend.h
+++ b/include/net/netfilter/nf_conntrack_extend.h
@@ -7,10 +7,19 @@
7 7
8enum nf_ct_ext_id { 8enum nf_ct_ext_id {
9 NF_CT_EXT_HELPER, 9 NF_CT_EXT_HELPER,
10#if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
10 NF_CT_EXT_NAT, 11 NF_CT_EXT_NAT,
12#endif
11 NF_CT_EXT_ACCT, 13 NF_CT_EXT_ACCT,
14#ifdef CONFIG_NF_CONNTRACK_EVENTS
12 NF_CT_EXT_ECACHE, 15 NF_CT_EXT_ECACHE,
16#endif
17#ifdef CONFIG_NF_CONNTRACK_ZONES
13 NF_CT_EXT_ZONE, 18 NF_CT_EXT_ZONE,
19#endif
20#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
21 NF_CT_EXT_TSTAMP,
22#endif
14 NF_CT_EXT_NUM, 23 NF_CT_EXT_NUM,
15}; 24};
16 25
@@ -19,6 +28,7 @@ enum nf_ct_ext_id {
19#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter 28#define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter
20#define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache 29#define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache
21#define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone 30#define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone
31#define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp
22 32
23/* Extensions: optional stuff which isn't permanently in struct. */ 33/* Extensions: optional stuff which isn't permanently in struct. */
24struct nf_ct_ext { 34struct nf_ct_ext {
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index 32c305dbdab6..f1c1311adc2c 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -63,4 +63,10 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
63extern int nf_conntrack_helper_init(void); 63extern int nf_conntrack_helper_init(void);
64extern void nf_conntrack_helper_fini(void); 64extern void nf_conntrack_helper_fini(void);
65 65
66extern int nf_conntrack_broadcast_help(struct sk_buff *skb,
67 unsigned int protoff,
68 struct nf_conn *ct,
69 enum ip_conntrack_info ctinfo,
70 unsigned int timeout);
71
66#endif /*_NF_CONNTRACK_HELPER_H*/ 72#endif /*_NF_CONNTRACK_HELPER_H*/
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index a7547611e8f1..e8010f445ae1 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -73,7 +73,7 @@ struct nf_conntrack_l3proto {
73 struct module *me; 73 struct module *me;
74}; 74};
75 75
76extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX]; 76extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX];
77 77
78/* Protocol registration. */ 78/* Protocol registration. */
79extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); 79extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
diff --git a/include/net/netfilter/nf_conntrack_timestamp.h b/include/net/netfilter/nf_conntrack_timestamp.h
new file mode 100644
index 000000000000..fc9c82b1f06b
--- /dev/null
+++ b/include/net/netfilter/nf_conntrack_timestamp.h
@@ -0,0 +1,65 @@
1#ifndef _NF_CONNTRACK_TSTAMP_H
2#define _NF_CONNTRACK_TSTAMP_H
3
4#include <net/net_namespace.h>
5#include <linux/netfilter/nf_conntrack_common.h>
6#include <linux/netfilter/nf_conntrack_tuple_common.h>
7#include <net/netfilter/nf_conntrack.h>
8#include <net/netfilter/nf_conntrack_extend.h>
9
10struct nf_conn_tstamp {
11 u_int64_t start;
12 u_int64_t stop;
13};
14
15static inline
16struct nf_conn_tstamp *nf_conn_tstamp_find(const struct nf_conn *ct)
17{
18#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
19 return nf_ct_ext_find(ct, NF_CT_EXT_TSTAMP);
20#else
21 return NULL;
22#endif
23}
24
25static inline
26struct nf_conn_tstamp *nf_ct_tstamp_ext_add(struct nf_conn *ct, gfp_t gfp)
27{
28#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
29 struct net *net = nf_ct_net(ct);
30
31 if (!net->ct.sysctl_tstamp)
32 return NULL;
33
34 return nf_ct_ext_add(ct, NF_CT_EXT_TSTAMP, gfp);
35#else
36 return NULL;
37#endif
38};
39
40static inline bool nf_ct_tstamp_enabled(struct net *net)
41{
42 return net->ct.sysctl_tstamp != 0;
43}
44
45static inline void nf_ct_set_tstamp(struct net *net, bool enable)
46{
47 net->ct.sysctl_tstamp = enable;
48}
49
50#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
51extern int nf_conntrack_tstamp_init(struct net *net);
52extern void nf_conntrack_tstamp_fini(struct net *net);
53#else
54static inline int nf_conntrack_tstamp_init(struct net *net)
55{
56 return 0;
57}
58
59static inline void nf_conntrack_tstamp_fini(struct net *net)
60{
61 return;
62}
63#endif /* CONFIG_NF_CONNTRACK_TIMESTAMP */
64
65#endif /* _NF_CONNTRACK_TSTAMP_H */
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
index f5f09f032a90..aff80b190c12 100644
--- a/include/net/netfilter/nf_nat.h
+++ b/include/net/netfilter/nf_nat.h
@@ -56,7 +56,9 @@ struct nf_nat_multi_range_compat {
56/* per conntrack: nat application helper private data */ 56/* per conntrack: nat application helper private data */
57union nf_conntrack_nat_help { 57union nf_conntrack_nat_help {
58 /* insert nat helper private data here */ 58 /* insert nat helper private data here */
59#if defined(CONFIG_NF_NAT_PPTP) || defined(CONFIG_NF_NAT_PPTP_MODULE)
59 struct nf_nat_pptp nat_pptp_info; 60 struct nf_nat_pptp nat_pptp_info;
61#endif
60}; 62};
61 63
62struct nf_conn; 64struct nf_conn;
@@ -84,7 +86,11 @@ extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
84 86
85static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) 87static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
86{ 88{
89#if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)
87 return nf_ct_ext_find(ct, NF_CT_EXT_NAT); 90 return nf_ct_ext_find(ct, NF_CT_EXT_NAT);
91#else
92 return NULL;
93#endif
88} 94}
89 95
90#else /* !__KERNEL__: iptables wants this to compile. */ 96#else /* !__KERNEL__: iptables wants this to compile. */
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h
index 33602ab66190..3dc7b98effeb 100644
--- a/include/net/netfilter/nf_nat_core.h
+++ b/include/net/netfilter/nf_nat_core.h
@@ -21,9 +21,9 @@ static inline int nf_nat_initialized(struct nf_conn *ct,
21 enum nf_nat_manip_type manip) 21 enum nf_nat_manip_type manip)
22{ 22{
23 if (manip == IP_NAT_MANIP_SRC) 23 if (manip == IP_NAT_MANIP_SRC)
24 return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status); 24 return ct->status & IPS_SRC_NAT_DONE;
25 else 25 else
26 return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status); 26 return ct->status & IPS_DST_NAT_DONE;
27} 27}
28 28
29struct nlattr; 29struct nlattr;
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h
index cd85b3bc8327..e505358d8999 100644
--- a/include/net/netfilter/nf_tproxy_core.h
+++ b/include/net/netfilter/nf_tproxy_core.h
@@ -201,18 +201,8 @@ nf_tproxy_get_sock_v6(struct net *net, const u8 protocol,
201} 201}
202#endif 202#endif
203 203
204static inline void
205nf_tproxy_put_sock(struct sock *sk)
206{
207 /* TIME_WAIT inet sockets have to be handled differently */
208 if ((sk->sk_protocol == IPPROTO_TCP) && (sk->sk_state == TCP_TIME_WAIT))
209 inet_twsk_put(inet_twsk(sk));
210 else
211 sock_put(sk);
212}
213
214/* assign a socket to the skb -- consumes sk */ 204/* assign a socket to the skb -- consumes sk */
215int 205void
216nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk); 206nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk);
217 207
218#endif 208#endif
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 373f1a900cf4..8a3906a08f5f 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -856,18 +856,27 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
856#define NLA_PUT_BE16(skb, attrtype, value) \ 856#define NLA_PUT_BE16(skb, attrtype, value) \
857 NLA_PUT_TYPE(skb, __be16, attrtype, value) 857 NLA_PUT_TYPE(skb, __be16, attrtype, value)
858 858
859#define NLA_PUT_NET16(skb, attrtype, value) \
860 NLA_PUT_BE16(skb, attrtype | NLA_F_NET_BYTEORDER, value)
861
859#define NLA_PUT_U32(skb, attrtype, value) \ 862#define NLA_PUT_U32(skb, attrtype, value) \
860 NLA_PUT_TYPE(skb, u32, attrtype, value) 863 NLA_PUT_TYPE(skb, u32, attrtype, value)
861 864
862#define NLA_PUT_BE32(skb, attrtype, value) \ 865#define NLA_PUT_BE32(skb, attrtype, value) \
863 NLA_PUT_TYPE(skb, __be32, attrtype, value) 866 NLA_PUT_TYPE(skb, __be32, attrtype, value)
864 867
868#define NLA_PUT_NET32(skb, attrtype, value) \
869 NLA_PUT_BE32(skb, attrtype | NLA_F_NET_BYTEORDER, value)
870
865#define NLA_PUT_U64(skb, attrtype, value) \ 871#define NLA_PUT_U64(skb, attrtype, value) \
866 NLA_PUT_TYPE(skb, u64, attrtype, value) 872 NLA_PUT_TYPE(skb, u64, attrtype, value)
867 873
868#define NLA_PUT_BE64(skb, attrtype, value) \ 874#define NLA_PUT_BE64(skb, attrtype, value) \
869 NLA_PUT_TYPE(skb, __be64, attrtype, value) 875 NLA_PUT_TYPE(skb, __be64, attrtype, value)
870 876
877#define NLA_PUT_NET64(skb, attrtype, value) \
878 NLA_PUT_BE64(skb, attrtype | NLA_F_NET_BYTEORDER, value)
879
871#define NLA_PUT_STRING(skb, attrtype, value) \ 880#define NLA_PUT_STRING(skb, attrtype, value) \
872 NLA_PUT(skb, attrtype, strlen(value) + 1, value) 881 NLA_PUT(skb, attrtype, strlen(value) + 1, value)
873 882
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
index d4958d4c6574..341eb089349e 100644
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -21,15 +21,15 @@ struct netns_ct {
21 int sysctl_events; 21 int sysctl_events;
22 unsigned int sysctl_events_retry_timeout; 22 unsigned int sysctl_events_retry_timeout;
23 int sysctl_acct; 23 int sysctl_acct;
24 int sysctl_tstamp;
24 int sysctl_checksum; 25 int sysctl_checksum;
25 unsigned int sysctl_log_invalid; /* Log invalid packets */ 26 unsigned int sysctl_log_invalid; /* Log invalid packets */
26#ifdef CONFIG_SYSCTL 27#ifdef CONFIG_SYSCTL
27 struct ctl_table_header *sysctl_header; 28 struct ctl_table_header *sysctl_header;
28 struct ctl_table_header *acct_sysctl_header; 29 struct ctl_table_header *acct_sysctl_header;
30 struct ctl_table_header *tstamp_sysctl_header;
29 struct ctl_table_header *event_sysctl_header; 31 struct ctl_table_header *event_sysctl_header;
30#endif 32#endif
31 int hash_vmalloc;
32 int expect_vmalloc;
33 char *slabname; 33 char *slabname;
34}; 34};
35#endif 35#endif
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index d68c3f121774..542195d9469e 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -43,7 +43,6 @@ struct netns_ipv4 {
43 struct xt_table *nat_table; 43 struct xt_table *nat_table;
44 struct hlist_head *nat_bysource; 44 struct hlist_head *nat_bysource;
45 unsigned int nat_htable_size; 45 unsigned int nat_htable_size;
46 int nat_vmalloced;
47#endif 46#endif
48 47
49 int sysctl_icmp_echo_ignore_all; 48 int sysctl_icmp_echo_ignore_all;
@@ -56,6 +55,7 @@ struct netns_ipv4 {
56 int current_rt_cache_rebuild_count; 55 int current_rt_cache_rebuild_count;
57 56
58 atomic_t rt_genid; 57 atomic_t rt_genid;
58 atomic_t dev_addr_genid;
59 59
60#ifdef CONFIG_IP_MROUTE 60#ifdef CONFIG_IP_MROUTE
61#ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES 61#ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
diff --git a/include/net/phonet/pep.h b/include/net/phonet/pep.h
index b60b28c99e87..b669fe6dbc3b 100644
--- a/include/net/phonet/pep.h
+++ b/include/net/phonet/pep.h
@@ -28,7 +28,6 @@ struct pep_sock {
28 28
29 /* XXX: union-ify listening vs connected stuff ? */ 29 /* XXX: union-ify listening vs connected stuff ? */
30 /* Listening socket stuff: */ 30 /* Listening socket stuff: */
31 struct hlist_head ackq;
32 struct hlist_head hlist; 31 struct hlist_head hlist;
33 32
34 /* Connected socket stuff: */ 33 /* Connected socket stuff: */
@@ -45,10 +44,6 @@ struct pep_sock {
45 u8 tx_fc; /* TX flow control */ 44 u8 tx_fc; /* TX flow control */
46 u8 init_enable; /* auto-enable at creation */ 45 u8 init_enable; /* auto-enable at creation */
47 u8 aligned; 46 u8 aligned;
48#ifdef CONFIG_PHONET_PIPECTRLR
49 u8 pipe_state;
50 struct sockaddr_pn remote_pep;
51#endif
52}; 47};
53 48
54static inline struct pep_sock *pep_sk(struct sock *sk) 49static inline struct pep_sock *pep_sk(struct sock *sk)
@@ -158,6 +153,7 @@ enum {
158 PN_LEGACY_FLOW_CONTROL, 153 PN_LEGACY_FLOW_CONTROL,
159 PN_ONE_CREDIT_FLOW_CONTROL, 154 PN_ONE_CREDIT_FLOW_CONTROL,
160 PN_MULTI_CREDIT_FLOW_CONTROL, 155 PN_MULTI_CREDIT_FLOW_CONTROL,
156 PN_MAX_FLOW_CONTROL,
161}; 157};
162 158
163#define pn_flow_safe(fc) ((fc) >> 1) 159#define pn_flow_safe(fc) ((fc) >> 1)
@@ -169,21 +165,4 @@ enum {
169 PEP_IND_READY, 165 PEP_IND_READY,
170}; 166};
171 167
172#ifdef CONFIG_PHONET_PIPECTRLR
173#define PNS_PEP_CONNECT_UTID 0x02
174#define PNS_PIPE_CREATED_IND_UTID 0x04
175#define PNS_PIPE_ENABLE_UTID 0x0A
176#define PNS_PIPE_ENABLED_IND_UTID 0x0C
177#define PNS_PIPE_DISABLE_UTID 0x0F
178#define PNS_PIPE_DISABLED_IND_UTID 0x11
179#define PNS_PEP_DISCONNECT_UTID 0x06
180
181/* Used for tracking state of a pipe */
182enum {
183 PIPE_IDLE,
184 PIPE_DISABLED,
185 PIPE_ENABLED,
186};
187#endif /* CONFIG_PHONET_PIPECTRLR */
188
189#endif 168#endif
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
index 5395e09187df..68e509750caa 100644
--- a/include/net/phonet/phonet.h
+++ b/include/net/phonet/phonet.h
@@ -36,6 +36,7 @@
36struct pn_sock { 36struct pn_sock {
37 struct sock sk; 37 struct sock sk;
38 u16 sobject; 38 u16 sobject;
39 u16 dobject;
39 u8 resource; 40 u8 resource;
40}; 41};
41 42
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index d9549af6929a..65afc4966204 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -32,7 +32,7 @@ static inline void *qdisc_priv(struct Qdisc *q)
32 32
33 The result: [34]86 is not good choice for QoS router :-( 33 The result: [34]86 is not good choice for QoS router :-(
34 34
35 The things are not so bad, because we may use artifical 35 The things are not so bad, because we may use artificial
36 clock evaluated by integration of network data flow 36 clock evaluated by integration of network data flow
37 in the most critical places. 37 in the most critical places.
38 */ 38 */
diff --git a/include/net/protocol.h b/include/net/protocol.h
index dc07495bce4c..6f7eb800974a 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -38,7 +38,7 @@ struct net_protocol {
38 void (*err_handler)(struct sk_buff *skb, u32 info); 38 void (*err_handler)(struct sk_buff *skb, u32 info);
39 int (*gso_send_check)(struct sk_buff *skb); 39 int (*gso_send_check)(struct sk_buff *skb);
40 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 40 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
41 int features); 41 u32 features);
42 struct sk_buff **(*gro_receive)(struct sk_buff **head, 42 struct sk_buff **(*gro_receive)(struct sk_buff **head,
43 struct sk_buff *skb); 43 struct sk_buff *skb);
44 int (*gro_complete)(struct sk_buff *skb); 44 int (*gro_complete)(struct sk_buff *skb);
@@ -57,7 +57,7 @@ struct inet6_protocol {
57 57
58 int (*gso_send_check)(struct sk_buff *skb); 58 int (*gso_send_check)(struct sk_buff *skb);
59 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 59 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
60 int features); 60 u32 features);
61 struct sk_buff **(*gro_receive)(struct sk_buff **head, 61 struct sk_buff **(*gro_receive)(struct sk_buff **head,
62 struct sk_buff *skb); 62 struct sk_buff *skb);
63 int (*gro_complete)(struct sk_buff *skb); 63 int (*gro_complete)(struct sk_buff *skb);
diff --git a/include/net/rose.h b/include/net/rose.h
index 5ba9f02731eb..555dd198aab7 100644
--- a/include/net/rose.h
+++ b/include/net/rose.h
@@ -14,6 +14,12 @@
14 14
15#define ROSE_MIN_LEN 3 15#define ROSE_MIN_LEN 3
16 16
17#define ROSE_CALL_REQ_ADDR_LEN_OFF 3
18#define ROSE_CALL_REQ_ADDR_LEN_VAL 0xAA /* each address is 10 digits */
19#define ROSE_CALL_REQ_DEST_ADDR_OFF 4
20#define ROSE_CALL_REQ_SRC_ADDR_OFF 9
21#define ROSE_CALL_REQ_FACILITIES_OFF 14
22
17#define ROSE_GFI 0x10 23#define ROSE_GFI 0x10
18#define ROSE_Q_BIT 0x80 24#define ROSE_Q_BIT 0x80
19#define ROSE_D_BIT 0x40 25#define ROSE_D_BIT 0x40
@@ -214,7 +220,7 @@ extern void rose_requeue_frames(struct sock *);
214extern int rose_validate_nr(struct sock *, unsigned short); 220extern int rose_validate_nr(struct sock *, unsigned short);
215extern void rose_write_internal(struct sock *, int); 221extern void rose_write_internal(struct sock *, int);
216extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *); 222extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
217extern int rose_parse_facilities(unsigned char *, struct rose_facilities_struct *); 223extern int rose_parse_facilities(unsigned char *, unsigned int, struct rose_facilities_struct *);
218extern void rose_disconnect(struct sock *, int, int, int); 224extern void rose_disconnect(struct sock *, int, int, int);
219 225
220/* rose_timer.c */ 226/* rose_timer.c */
diff --git a/include/net/route.h b/include/net/route.h
index 93e10c453f6b..8fce0621cad1 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -49,36 +49,44 @@
49 49
50struct fib_nh; 50struct fib_nh;
51struct inet_peer; 51struct inet_peer;
52struct fib_info;
52struct rtable { 53struct rtable {
53 struct dst_entry dst; 54 struct dst_entry dst;
54 55
55 /* Cache lookup keys */ 56 /* Lookup key. */
56 struct flowi fl; 57 __be32 rt_key_dst;
58 __be32 rt_key_src;
57 59
58 int rt_genid; 60 int rt_genid;
59 unsigned rt_flags; 61 unsigned rt_flags;
60 __u16 rt_type; 62 __u16 rt_type;
63 __u8 rt_tos;
61 64
62 __be32 rt_dst; /* Path destination */ 65 __be32 rt_dst; /* Path destination */
63 __be32 rt_src; /* Path source */ 66 __be32 rt_src; /* Path source */
67 int rt_route_iif;
64 int rt_iif; 68 int rt_iif;
69 int rt_oif;
70 __u32 rt_mark;
65 71
66 /* Info on neighbour */ 72 /* Info on neighbour */
67 __be32 rt_gateway; 73 __be32 rt_gateway;
68 74
69 /* Miscellaneous cached information */ 75 /* Miscellaneous cached information */
70 __be32 rt_spec_dst; /* RFC1122 specific destination */ 76 __be32 rt_spec_dst; /* RFC1122 specific destination */
77 u32 rt_peer_genid;
71 struct inet_peer *peer; /* long-living peer info */ 78 struct inet_peer *peer; /* long-living peer info */
79 struct fib_info *fi; /* for client ref to shared metrics */
72}; 80};
73 81
74static inline bool rt_is_input_route(struct rtable *rt) 82static inline bool rt_is_input_route(struct rtable *rt)
75{ 83{
76 return rt->fl.iif != 0; 84 return rt->rt_route_iif != 0;
77} 85}
78 86
79static inline bool rt_is_output_route(struct rtable *rt) 87static inline bool rt_is_output_route(struct rtable *rt)
80{ 88{
81 return rt->fl.iif == 0; 89 return rt->rt_route_iif == 0;
82} 90}
83 91
84struct ip_rt_acct { 92struct ip_rt_acct {
@@ -115,9 +123,63 @@ extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw,
115 __be32 src, struct net_device *dev); 123 __be32 src, struct net_device *dev);
116extern void rt_cache_flush(struct net *net, int how); 124extern void rt_cache_flush(struct net *net, int how);
117extern void rt_cache_flush_batch(struct net *net); 125extern void rt_cache_flush_batch(struct net *net);
118extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp); 126extern struct rtable *__ip_route_output_key(struct net *, const struct flowi4 *flp);
119extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); 127extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
120extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); 128 struct sock *sk);
129extern struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig);
130
131static inline struct rtable *ip_route_output_key(struct net *net, struct flowi4 *flp)
132{
133 return ip_route_output_flow(net, flp, NULL);
134}
135
136static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
137 __be32 saddr, u8 tos, int oif)
138{
139 struct flowi4 fl4 = {
140 .flowi4_oif = oif,
141 .daddr = daddr,
142 .saddr = saddr,
143 .flowi4_tos = tos,
144 };
145 return ip_route_output_key(net, &fl4);
146}
147
148static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk,
149 __be32 daddr, __be32 saddr,
150 __be16 dport, __be16 sport,
151 __u8 proto, __u8 tos, int oif)
152{
153 struct flowi4 fl4 = {
154 .flowi4_oif = oif,
155 .flowi4_flags = sk ? inet_sk_flowi_flags(sk) : 0,
156 .flowi4_mark = sk ? sk->sk_mark : 0,
157 .daddr = daddr,
158 .saddr = saddr,
159 .flowi4_tos = tos,
160 .flowi4_proto = proto,
161 .fl4_dport = dport,
162 .fl4_sport = sport,
163 };
164 if (sk)
165 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
166 return ip_route_output_flow(net, &fl4, sk);
167}
168
169static inline struct rtable *ip_route_output_gre(struct net *net,
170 __be32 daddr, __be32 saddr,
171 __be32 gre_key, __u8 tos, int oif)
172{
173 struct flowi4 fl4 = {
174 .flowi4_oif = oif,
175 .daddr = daddr,
176 .saddr = saddr,
177 .flowi4_tos = tos,
178 .flowi4_proto = IPPROTO_GRE,
179 .fl4_gre_key = gre_key,
180 };
181 return ip_route_output_key(net, &fl4);
182}
121 183
122extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, 184extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src,
123 u8 tos, struct net_device *devin, bool noref); 185 u8 tos, struct net_device *devin, bool noref);
@@ -146,6 +208,7 @@ extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb);
146 208
147struct in_ifaddr; 209struct in_ifaddr;
148extern void fib_add_ifaddr(struct in_ifaddr *); 210extern void fib_add_ifaddr(struct in_ifaddr *);
211extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *);
149 212
150static inline void ip_rt_put(struct rtable * rt) 213static inline void ip_rt_put(struct rtable * rt)
151{ 214{
@@ -162,57 +225,68 @@ static inline char rt_tos2priority(u8 tos)
162 return ip_tos2prio[IPTOS_TOS(tos)>>1]; 225 return ip_tos2prio[IPTOS_TOS(tos)>>1];
163} 226}
164 227
165static inline int ip_route_connect(struct rtable **rp, __be32 dst, 228static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos,
166 __be32 src, u32 tos, int oif, u8 protocol, 229 int oif, u8 protocol,
167 __be16 sport, __be16 dport, struct sock *sk, 230 __be16 sport, __be16 dport,
168 int flags) 231 struct sock *sk, bool can_sleep)
169{ 232{
170 struct flowi fl = { .oif = oif, 233 struct flowi4 fl4 = {
171 .mark = sk->sk_mark, 234 .flowi4_oif = oif,
172 .fl4_dst = dst, 235 .flowi4_mark = sk->sk_mark,
173 .fl4_src = src, 236 .daddr = dst,
174 .fl4_tos = tos, 237 .saddr = src,
175 .proto = protocol, 238 .flowi4_tos = tos,
176 .fl_ip_sport = sport, 239 .flowi4_proto = protocol,
177 .fl_ip_dport = dport }; 240 .fl4_sport = sport,
178 int err; 241 .fl4_dport = dport,
242 };
179 struct net *net = sock_net(sk); 243 struct net *net = sock_net(sk);
244 struct rtable *rt;
180 245
181 if (inet_sk(sk)->transparent) 246 if (inet_sk(sk)->transparent)
182 fl.flags |= FLOWI_FLAG_ANYSRC; 247 fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC;
248 if (protocol == IPPROTO_TCP)
249 fl4.flowi4_flags |= FLOWI_FLAG_PRECOW_METRICS;
250 if (can_sleep)
251 fl4.flowi4_flags |= FLOWI_FLAG_CAN_SLEEP;
183 252
184 if (!dst || !src) { 253 if (!dst || !src) {
185 err = __ip_route_output_key(net, rp, &fl); 254 rt = __ip_route_output_key(net, &fl4);
186 if (err) 255 if (IS_ERR(rt))
187 return err; 256 return rt;
188 fl.fl4_dst = (*rp)->rt_dst; 257 fl4.daddr = rt->rt_dst;
189 fl.fl4_src = (*rp)->rt_src; 258 fl4.saddr = rt->rt_src;
190 ip_rt_put(*rp); 259 ip_rt_put(rt);
191 *rp = NULL;
192 } 260 }
193 security_sk_classify_flow(sk, &fl); 261 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
194 return ip_route_output_flow(net, rp, &fl, sk, flags); 262 return ip_route_output_flow(net, &fl4, sk);
195} 263}
196 264
197static inline int ip_route_newports(struct rtable **rp, u8 protocol, 265static inline struct rtable *ip_route_newports(struct rtable *rt,
198 __be16 sport, __be16 dport, struct sock *sk) 266 u8 protocol, __be16 orig_sport,
267 __be16 orig_dport, __be16 sport,
268 __be16 dport, struct sock *sk)
199{ 269{
200 if (sport != (*rp)->fl.fl_ip_sport || 270 if (sport != orig_sport || dport != orig_dport) {
201 dport != (*rp)->fl.fl_ip_dport) { 271 struct flowi4 fl4 = {
202 struct flowi fl; 272 .flowi4_oif = rt->rt_oif,
203 273 .flowi4_mark = rt->rt_mark,
204 memcpy(&fl, &(*rp)->fl, sizeof(fl)); 274 .daddr = rt->rt_dst,
205 fl.fl_ip_sport = sport; 275 .saddr = rt->rt_src,
206 fl.fl_ip_dport = dport; 276 .flowi4_tos = rt->rt_tos,
207 fl.proto = protocol; 277 .flowi4_proto = protocol,
278 .fl4_sport = sport,
279 .fl4_dport = dport
280 };
208 if (inet_sk(sk)->transparent) 281 if (inet_sk(sk)->transparent)
209 fl.flags |= FLOWI_FLAG_ANYSRC; 282 fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC;
210 ip_rt_put(*rp); 283 if (protocol == IPPROTO_TCP)
211 *rp = NULL; 284 fl4.flowi4_flags |= FLOWI_FLAG_PRECOW_METRICS;
212 security_sk_classify_flow(sk, &fl); 285 ip_rt_put(rt);
213 return ip_route_output_flow(sock_net(sk), rp, &fl, sk, 0); 286 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
287 return ip_route_output_flow(sock_net(sk), &fl4, sk);
214 } 288 }
215 return 0; 289 return rt;
216} 290}
217 291
218extern void rt_bind_peer(struct rtable *rt, int create); 292extern void rt_bind_peer(struct rtable *rt, int create);
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 160a407c1963..b931f021d7ab 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -25,16 +25,18 @@ struct qdisc_rate_table {
25enum qdisc_state_t { 25enum qdisc_state_t {
26 __QDISC_STATE_SCHED, 26 __QDISC_STATE_SCHED,
27 __QDISC_STATE_DEACTIVATED, 27 __QDISC_STATE_DEACTIVATED,
28 __QDISC_STATE_THROTTLED,
28}; 29};
29 30
30/* 31/*
31 * following bits are only changed while qdisc lock is held 32 * following bits are only changed while qdisc lock is held
32 */ 33 */
33enum qdisc___state_t { 34enum qdisc___state_t {
34 __QDISC___STATE_RUNNING, 35 __QDISC___STATE_RUNNING = 1,
35}; 36};
36 37
37struct qdisc_size_table { 38struct qdisc_size_table {
39 struct rcu_head rcu;
38 struct list_head list; 40 struct list_head list;
39 struct tc_sizespec szopts; 41 struct tc_sizespec szopts;
40 int refcnt; 42 int refcnt;
@@ -46,14 +48,13 @@ struct Qdisc {
46 struct sk_buff * (*dequeue)(struct Qdisc *dev); 48 struct sk_buff * (*dequeue)(struct Qdisc *dev);
47 unsigned flags; 49 unsigned flags;
48#define TCQ_F_BUILTIN 1 50#define TCQ_F_BUILTIN 1
49#define TCQ_F_THROTTLED 2 51#define TCQ_F_INGRESS 2
50#define TCQ_F_INGRESS 4 52#define TCQ_F_CAN_BYPASS 4
51#define TCQ_F_CAN_BYPASS 8 53#define TCQ_F_MQROOT 8
52#define TCQ_F_MQROOT 16
53#define TCQ_F_WARN_NONWC (1 << 16) 54#define TCQ_F_WARN_NONWC (1 << 16)
54 int padded; 55 int padded;
55 struct Qdisc_ops *ops; 56 struct Qdisc_ops *ops;
56 struct qdisc_size_table *stab; 57 struct qdisc_size_table __rcu *stab;
57 struct list_head list; 58 struct list_head list;
58 u32 handle; 59 u32 handle;
59 u32 parent; 60 u32 parent;
@@ -78,25 +79,44 @@ struct Qdisc {
78 unsigned long state; 79 unsigned long state;
79 struct sk_buff_head q; 80 struct sk_buff_head q;
80 struct gnet_stats_basic_packed bstats; 81 struct gnet_stats_basic_packed bstats;
81 unsigned long __state; 82 unsigned int __state;
82 struct gnet_stats_queue qstats; 83 struct gnet_stats_queue qstats;
83 struct rcu_head rcu_head; 84 struct rcu_head rcu_head;
84 spinlock_t busylock; 85 spinlock_t busylock;
86 u32 limit;
85}; 87};
86 88
87static inline bool qdisc_is_running(struct Qdisc *qdisc) 89static inline bool qdisc_is_running(const struct Qdisc *qdisc)
88{ 90{
89 return test_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 91 return (qdisc->__state & __QDISC___STATE_RUNNING) ? true : false;
90} 92}
91 93
92static inline bool qdisc_run_begin(struct Qdisc *qdisc) 94static inline bool qdisc_run_begin(struct Qdisc *qdisc)
93{ 95{
94 return !__test_and_set_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 96 if (qdisc_is_running(qdisc))
97 return false;
98 qdisc->__state |= __QDISC___STATE_RUNNING;
99 return true;
95} 100}
96 101
97static inline void qdisc_run_end(struct Qdisc *qdisc) 102static inline void qdisc_run_end(struct Qdisc *qdisc)
98{ 103{
99 __clear_bit(__QDISC___STATE_RUNNING, &qdisc->__state); 104 qdisc->__state &= ~__QDISC___STATE_RUNNING;
105}
106
107static inline bool qdisc_is_throttled(const struct Qdisc *qdisc)
108{
109 return test_bit(__QDISC_STATE_THROTTLED, &qdisc->state) ? true : false;
110}
111
112static inline void qdisc_throttled(struct Qdisc *qdisc)
113{
114 set_bit(__QDISC_STATE_THROTTLED, &qdisc->state);
115}
116
117static inline void qdisc_unthrottled(struct Qdisc *qdisc)
118{
119 clear_bit(__QDISC_STATE_THROTTLED, &qdisc->state);
100} 120}
101 121
102struct Qdisc_class_ops { 122struct Qdisc_class_ops {
@@ -199,7 +219,7 @@ struct tcf_proto {
199 219
200struct qdisc_skb_cb { 220struct qdisc_skb_cb {
201 unsigned int pkt_len; 221 unsigned int pkt_len;
202 char data[]; 222 long data[];
203}; 223};
204 224
205static inline int qdisc_qlen(struct Qdisc *q) 225static inline int qdisc_qlen(struct Qdisc *q)
@@ -331,8 +351,8 @@ extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
331 struct Qdisc_ops *ops); 351 struct Qdisc_ops *ops);
332extern struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, 352extern struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
333 struct Qdisc_ops *ops, u32 parentid); 353 struct Qdisc_ops *ops, u32 parentid);
334extern void qdisc_calculate_pkt_len(struct sk_buff *skb, 354extern void __qdisc_calculate_pkt_len(struct sk_buff *skb,
335 struct qdisc_size_table *stab); 355 const struct qdisc_size_table *stab);
336extern void tcf_destroy(struct tcf_proto *tp); 356extern void tcf_destroy(struct tcf_proto *tp);
337extern void tcf_destroy_chain(struct tcf_proto **fl); 357extern void tcf_destroy_chain(struct tcf_proto **fl);
338 358
@@ -411,12 +431,20 @@ enum net_xmit_qdisc_t {
411#define net_xmit_drop_count(e) (1) 431#define net_xmit_drop_count(e) (1)
412#endif 432#endif
413 433
414static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) 434static inline void qdisc_calculate_pkt_len(struct sk_buff *skb,
435 const struct Qdisc *sch)
415{ 436{
416#ifdef CONFIG_NET_SCHED 437#ifdef CONFIG_NET_SCHED
417 if (sch->stab) 438 struct qdisc_size_table *stab = rcu_dereference_bh(sch->stab);
418 qdisc_calculate_pkt_len(skb, sch->stab); 439
440 if (stab)
441 __qdisc_calculate_pkt_len(skb, stab);
419#endif 442#endif
443}
444
445static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
446{
447 qdisc_calculate_pkt_len(skb, sch);
420 return sch->enqueue(skb, sch); 448 return sch->enqueue(skb, sch);
421} 449}
422 450
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index cc9185ca8fd1..0f6e60a9c308 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -422,7 +422,7 @@ struct sctp_cookie {
422 __u32 adaptation_ind; 422 __u32 adaptation_ind;
423 423
424 __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH]; 424 __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH];
425 __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS + 2]; 425 __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS * sizeof(__u16) + 2];
426 __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS]; 426 __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS];
427 427
428 /* This is a shim for my peer's INIT packet, followed by 428 /* This is a shim for my peer's INIT packet, followed by
diff --git a/include/net/snmp.h b/include/net/snmp.h
index 762e2abce889..27461d6dd46f 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -150,7 +150,7 @@ struct linux_xfrm_mib {
150#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ 150#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
151 do { \ 151 do { \
152 __typeof__(*mib[0]) *ptr = \ 152 __typeof__(*mib[0]) *ptr = \
153 __this_cpu_ptr((mib)[!in_softirq()]); \ 153 __this_cpu_ptr((mib)[0]); \
154 ptr->mibs[basefield##PKTS]++; \ 154 ptr->mibs[basefield##PKTS]++; \
155 ptr->mibs[basefield##OCTETS] += addend;\ 155 ptr->mibs[basefield##OCTETS] += addend;\
156 } while (0) 156 } while (0)
@@ -202,7 +202,7 @@ struct linux_xfrm_mib {
202#define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \ 202#define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \
203 do { \ 203 do { \
204 __typeof__(*mib[0]) *ptr; \ 204 __typeof__(*mib[0]) *ptr; \
205 ptr = __this_cpu_ptr((mib)[!in_softirq()]); \ 205 ptr = __this_cpu_ptr((mib)[0]); \
206 u64_stats_update_begin(&ptr->syncp); \ 206 u64_stats_update_begin(&ptr->syncp); \
207 ptr->mibs[basefield##PKTS]++; \ 207 ptr->mibs[basefield##PKTS]++; \
208 ptr->mibs[basefield##OCTETS] += addend; \ 208 ptr->mibs[basefield##OCTETS] += addend; \
diff --git a/include/net/sock.h b/include/net/sock.h
index d884d268c704..01810a3f19df 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -281,7 +281,7 @@ struct sock {
281 int sk_rcvbuf; 281 int sk_rcvbuf;
282 282
283 struct sk_filter __rcu *sk_filter; 283 struct sk_filter __rcu *sk_filter;
284 struct socket_wq *sk_wq; 284 struct socket_wq __rcu *sk_wq;
285 285
286#ifdef CONFIG_NET_DMA 286#ifdef CONFIG_NET_DMA
287 struct sk_buff_head sk_async_wait_queue; 287 struct sk_buff_head sk_async_wait_queue;
@@ -753,6 +753,8 @@ struct proto {
753 int level, 753 int level,
754 int optname, char __user *optval, 754 int optname, char __user *optval,
755 int __user *option); 755 int __user *option);
756 int (*compat_ioctl)(struct sock *sk,
757 unsigned int cmd, unsigned long arg);
756#endif 758#endif
757 int (*sendmsg)(struct kiocb *iocb, struct sock *sk, 759 int (*sendmsg)(struct kiocb *iocb, struct sock *sk,
758 struct msghdr *msg, size_t len); 760 struct msghdr *msg, size_t len);
@@ -1189,7 +1191,7 @@ extern void sk_filter_release_rcu(struct rcu_head *rcu);
1189static inline void sk_filter_release(struct sk_filter *fp) 1191static inline void sk_filter_release(struct sk_filter *fp)
1190{ 1192{
1191 if (atomic_dec_and_test(&fp->refcnt)) 1193 if (atomic_dec_and_test(&fp->refcnt))
1192 call_rcu_bh(&fp->rcu, sk_filter_release_rcu); 1194 call_rcu(&fp->rcu, sk_filter_release_rcu);
1193} 1195}
1194 1196
1195static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp) 1197static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
@@ -1264,7 +1266,8 @@ static inline void sk_set_socket(struct sock *sk, struct socket *sock)
1264 1266
1265static inline wait_queue_head_t *sk_sleep(struct sock *sk) 1267static inline wait_queue_head_t *sk_sleep(struct sock *sk)
1266{ 1268{
1267 return &sk->sk_wq->wait; 1269 BUILD_BUG_ON(offsetof(struct socket_wq, wait) != 0);
1270 return &rcu_dereference_raw(sk->sk_wq)->wait;
1268} 1271}
1269/* Detach socket from process context. 1272/* Detach socket from process context.
1270 * Announce socket dead, detach it from wait queue and inode. 1273 * Announce socket dead, detach it from wait queue and inode.
@@ -1285,7 +1288,7 @@ static inline void sock_orphan(struct sock *sk)
1285static inline void sock_graft(struct sock *sk, struct socket *parent) 1288static inline void sock_graft(struct sock *sk, struct socket *parent)
1286{ 1289{
1287 write_lock_bh(&sk->sk_callback_lock); 1290 write_lock_bh(&sk->sk_callback_lock);
1288 rcu_assign_pointer(sk->sk_wq, parent->wq); 1291 sk->sk_wq = parent->wq;
1289 parent->sk = sk; 1292 parent->sk = sk;
1290 sk_set_socket(sk, parent); 1293 sk_set_socket(sk, parent);
1291 security_sock_graft(sk, parent); 1294 security_sock_graft(sk, parent);
@@ -1746,7 +1749,7 @@ void sock_net_set(struct sock *sk, struct net *net)
1746 1749
1747/* 1750/*
1748 * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace. 1751 * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace.
1749 * They should not hold a referrence to a namespace in order to allow 1752 * They should not hold a reference to a namespace in order to allow
1750 * to stop it. 1753 * to stop it.
1751 * Sockets after sk_change_net should be released using sk_release_kernel 1754 * Sockets after sk_change_net should be released using sk_release_kernel
1752 */ 1755 */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 38509f047382..cda30ea354a2 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -196,6 +196,9 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
196/* TCP thin-stream limits */ 196/* TCP thin-stream limits */
197#define TCP_THIN_LINEAR_RETRIES 6 /* After 6 linear retries, do exp. backoff */ 197#define TCP_THIN_LINEAR_RETRIES 6 /* After 6 linear retries, do exp. backoff */
198 198
199/* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */
200#define TCP_INIT_CWND 10
201
199extern struct inet_timewait_death_row tcp_death_row; 202extern struct inet_timewait_death_row tcp_death_row;
200 203
201/* sysctl variables for tcp */ 204/* sysctl variables for tcp */
@@ -799,15 +802,6 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk)
799/* Use define here intentionally to get WARN_ON location shown at the caller */ 802/* Use define here intentionally to get WARN_ON location shown at the caller */
800#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out) 803#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out)
801 804
802/*
803 * Convert RFC 3390 larger initial window into an equivalent number of packets.
804 * This is based on the numbers specified in RFC 5681, 3.1.
805 */
806static inline u32 rfc3390_bytes_to_packets(const u32 smss)
807{
808 return smss <= 1095 ? 4 : (smss > 2190 ? 2 : 3);
809}
810
811extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); 805extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh);
812extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); 806extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst);
813 807
@@ -1074,8 +1068,6 @@ static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt,
1074 return 1; 1068 return 1;
1075} 1069}
1076 1070
1077#define TCP_CHECK_TIMER(sk) do { } while (0)
1078
1079static inline void tcp_mib_init(struct net *net) 1071static inline void tcp_mib_init(struct net *net)
1080{ 1072{
1081 /* See RFC 2012 */ 1073 /* See RFC 2012 */
@@ -1404,7 +1396,7 @@ extern struct request_sock_ops tcp6_request_sock_ops;
1404extern void tcp_v4_destroy_sock(struct sock *sk); 1396extern void tcp_v4_destroy_sock(struct sock *sk);
1405 1397
1406extern int tcp_v4_gso_send_check(struct sk_buff *skb); 1398extern int tcp_v4_gso_send_check(struct sk_buff *skb);
1407extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features); 1399extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, u32 features);
1408extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, 1400extern struct sk_buff **tcp_gro_receive(struct sk_buff **head,
1409 struct sk_buff *skb); 1401 struct sk_buff *skb);
1410extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, 1402extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head,
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h
index 42a0eb68b7b6..a8122dc56410 100644
--- a/include/net/transp_v6.h
+++ b/include/net/transp_v6.h
@@ -14,9 +14,9 @@ extern struct proto udpv6_prot;
14extern struct proto udplitev6_prot; 14extern struct proto udplitev6_prot;
15extern struct proto tcpv6_prot; 15extern struct proto tcpv6_prot;
16 16
17struct flowi; 17struct flowi6;
18 18
19/* extention headers */ 19/* extension headers */
20extern int ipv6_exthdrs_init(void); 20extern int ipv6_exthdrs_init(void);
21extern void ipv6_exthdrs_exit(void); 21extern void ipv6_exthdrs_exit(void);
22extern int ipv6_frag_init(void); 22extern int ipv6_frag_init(void);
@@ -42,7 +42,7 @@ extern int datagram_recv_ctl(struct sock *sk,
42 42
43extern int datagram_send_ctl(struct net *net, 43extern int datagram_send_ctl(struct net *net,
44 struct msghdr *msg, 44 struct msghdr *msg,
45 struct flowi *fl, 45 struct flowi6 *fl6,
46 struct ipv6_txoptions *opt, 46 struct ipv6_txoptions *opt,
47 int *hlimit, int *tclass, 47 int *hlimit, int *tclass,
48 int *dontfrag); 48 int *dontfrag);
diff --git a/include/net/udp.h b/include/net/udp.h
index bb967dd59bf7..67ea6fcb3ec0 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -144,6 +144,17 @@ static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb)
144 return csum; 144 return csum;
145} 145}
146 146
147static inline __wsum udp_csum(struct sk_buff *skb)
148{
149 __wsum csum = csum_partial(skb_transport_header(skb),
150 sizeof(struct udphdr), skb->csum);
151
152 for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) {
153 csum = csum_add(csum, skb->csum);
154 }
155 return csum;
156}
157
147/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ 158/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
148static inline void udp_lib_hash(struct sock *sk) 159static inline void udp_lib_hash(struct sock *sk)
149{ 160{
@@ -245,5 +256,5 @@ extern void udp4_proc_exit(void);
245extern void udp_init(void); 256extern void udp_init(void);
246 257
247extern int udp4_ufo_send_check(struct sk_buff *skb); 258extern int udp4_ufo_send_check(struct sk_buff *skb);
248extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, int features); 259extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, u32 features);
249#endif /* _UDP_H */ 260#endif /* _UDP_H */
diff --git a/include/net/udplite.h b/include/net/udplite.h
index afdffe607b24..673a024c6b2a 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -115,6 +115,18 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
115 return csum; 115 return csum;
116} 116}
117 117
118static inline __wsum udplite_csum(struct sk_buff *skb)
119{
120 struct sock *sk = skb->sk;
121 int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb));
122 const int off = skb_transport_offset(skb);
123 const int len = skb->len - off;
124
125 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */
126
127 return skb_checksum(skb, off, min(cscov, len), 0);
128}
129
118extern void udplite4_register(void); 130extern void udplite4_register(void);
119extern int udplite_get_port(struct sock *sk, unsigned short snum, 131extern int udplite_get_port(struct sock *sk, unsigned short snum,
120 int (*scmp)(const struct sock *, const struct sock *)); 132 int (*scmp)(const struct sock *, const struct sock *));
diff --git a/include/net/wimax.h b/include/net/wimax.h
index 3461aa1df1e0..c799ba7b708b 100644
--- a/include/net/wimax.h
+++ b/include/net/wimax.h
@@ -286,7 +286,7 @@ struct wimax_dev;
286 * does not disconnect the device from the bus and return 0. 286 * does not disconnect the device from the bus and return 0.
287 * If that fails, it should resort to some sort of cold or bus 287 * If that fails, it should resort to some sort of cold or bus
288 * reset (even if it implies a bus disconnection and device 288 * reset (even if it implies a bus disconnection and device
289 * dissapearance). In that case, -ENODEV should be returned to 289 * disappearance). In that case, -ENODEV should be returned to
290 * indicate the device is gone. 290 * indicate the device is gone.
291 * This operation has to be synchronous, and return only when the 291 * This operation has to be synchronous, and return only when the
292 * reset is complete. In case of having had to resort to bus/cold 292 * reset is complete. In case of having had to resort to bus/cold
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index 85926231c07a..d86fffd3c03c 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -28,7 +28,7 @@ struct wpan_phy {
28 struct mutex pib_lock; 28 struct mutex pib_lock;
29 29
30 /* 30 /*
31 * This is a PIB acording to 802.15.4-2006. 31 * This is a PIB according to 802.15.4-2006.
32 * We do not provide timing-related variables, as they 32 * We do not provide timing-related variables, as they
33 * aren't used outside of driver 33 * aren't used outside of driver
34 */ 34 */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index b9f385da758e..6ae4bc5ce8a7 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -36,6 +36,7 @@
36#define XFRM_PROTO_ROUTING IPPROTO_ROUTING 36#define XFRM_PROTO_ROUTING IPPROTO_ROUTING
37#define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS 37#define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS
38 38
39#define XFRM_ALIGN4(len) (((len) + 3) & ~3)
39#define XFRM_ALIGN8(len) (((len) + 7) & ~7) 40#define XFRM_ALIGN8(len) (((len) + 7) & ~7)
40#define MODULE_ALIAS_XFRM_MODE(family, encap) \ 41#define MODULE_ALIAS_XFRM_MODE(family, encap) \
41 MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap)) 42 MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap))
@@ -185,9 +186,14 @@ struct xfrm_state {
185 186
186 /* State for replay detection */ 187 /* State for replay detection */
187 struct xfrm_replay_state replay; 188 struct xfrm_replay_state replay;
189 struct xfrm_replay_state_esn *replay_esn;
188 190
189 /* Replay detection state at the time we sent the last notification */ 191 /* Replay detection state at the time we sent the last notification */
190 struct xfrm_replay_state preplay; 192 struct xfrm_replay_state preplay;
193 struct xfrm_replay_state_esn *preplay_esn;
194
195 /* The functions for replay detection. */
196 struct xfrm_replay *repl;
191 197
192 /* internal flag that only holds state for delayed aevent at the 198 /* internal flag that only holds state for delayed aevent at the
193 * moment 199 * moment
@@ -258,6 +264,15 @@ struct km_event {
258 struct net *net; 264 struct net *net;
259}; 265};
260 266
267struct xfrm_replay {
268 void (*advance)(struct xfrm_state *x, __be32 net_seq);
269 int (*check)(struct xfrm_state *x,
270 struct sk_buff *skb,
271 __be32 net_seq);
272 void (*notify)(struct xfrm_state *x, int event);
273 int (*overflow)(struct xfrm_state *x, struct sk_buff *skb);
274};
275
261struct net_device; 276struct net_device;
262struct xfrm_type; 277struct xfrm_type;
263struct xfrm_dst; 278struct xfrm_dst;
@@ -266,25 +281,26 @@ struct xfrm_policy_afinfo {
266 struct dst_ops *dst_ops; 281 struct dst_ops *dst_ops;
267 void (*garbage_collect)(struct net *net); 282 void (*garbage_collect)(struct net *net);
268 struct dst_entry *(*dst_lookup)(struct net *net, int tos, 283 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
269 xfrm_address_t *saddr, 284 const xfrm_address_t *saddr,
270 xfrm_address_t *daddr); 285 const xfrm_address_t *daddr);
271 int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr); 286 int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr);
272 void (*decode_session)(struct sk_buff *skb, 287 void (*decode_session)(struct sk_buff *skb,
273 struct flowi *fl, 288 struct flowi *fl,
274 int reverse); 289 int reverse);
275 int (*get_tos)(struct flowi *fl); 290 int (*get_tos)(const struct flowi *fl);
276 int (*init_path)(struct xfrm_dst *path, 291 int (*init_path)(struct xfrm_dst *path,
277 struct dst_entry *dst, 292 struct dst_entry *dst,
278 int nfheader_len); 293 int nfheader_len);
279 int (*fill_dst)(struct xfrm_dst *xdst, 294 int (*fill_dst)(struct xfrm_dst *xdst,
280 struct net_device *dev, 295 struct net_device *dev,
281 struct flowi *fl); 296 const struct flowi *fl);
297 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
282}; 298};
283 299
284extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); 300extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
285extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo); 301extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
286extern void km_policy_notify(struct xfrm_policy *xp, int dir, struct km_event *c); 302extern void km_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c);
287extern void km_state_notify(struct xfrm_state *x, struct km_event *c); 303extern void km_state_notify(struct xfrm_state *x, const struct km_event *c);
288 304
289struct xfrm_tmpl; 305struct xfrm_tmpl;
290extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); 306extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol);
@@ -299,9 +315,12 @@ struct xfrm_state_afinfo {
299 const struct xfrm_type *type_map[IPPROTO_MAX]; 315 const struct xfrm_type *type_map[IPPROTO_MAX];
300 struct xfrm_mode *mode_map[XFRM_MODE_MAX]; 316 struct xfrm_mode *mode_map[XFRM_MODE_MAX];
301 int (*init_flags)(struct xfrm_state *x); 317 int (*init_flags)(struct xfrm_state *x);
302 void (*init_tempsel)(struct xfrm_selector *sel, struct flowi *fl); 318 void (*init_tempsel)(struct xfrm_selector *sel,
303 void (*init_temprop)(struct xfrm_state *x, struct xfrm_tmpl *tmpl, 319 const struct flowi *fl);
304 xfrm_address_t *daddr, xfrm_address_t *saddr); 320 void (*init_temprop)(struct xfrm_state *x,
321 const struct xfrm_tmpl *tmpl,
322 const xfrm_address_t *daddr,
323 const xfrm_address_t *saddr);
305 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); 324 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
306 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); 325 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
307 int (*output)(struct sk_buff *skb); 326 int (*output)(struct sk_buff *skb);
@@ -332,7 +351,8 @@ struct xfrm_type {
332 void (*destructor)(struct xfrm_state *); 351 void (*destructor)(struct xfrm_state *);
333 int (*input)(struct xfrm_state *, struct sk_buff *skb); 352 int (*input)(struct xfrm_state *, struct sk_buff *skb);
334 int (*output)(struct xfrm_state *, struct sk_buff *pskb); 353 int (*output)(struct xfrm_state *, struct sk_buff *pskb);
335 int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); 354 int (*reject)(struct xfrm_state *, struct sk_buff *,
355 const struct flowi *);
336 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); 356 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **);
337 /* Estimate maximal size of result of transformation of a dgram */ 357 /* Estimate maximal size of result of transformation of a dgram */
338 u32 (*get_mtu)(struct xfrm_state *, int size); 358 u32 (*get_mtu)(struct xfrm_state *, int size);
@@ -501,7 +521,7 @@ struct xfrm_policy {
501 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 521 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
502}; 522};
503 523
504static inline struct net *xp_net(struct xfrm_policy *xp) 524static inline struct net *xp_net(const struct xfrm_policy *xp)
505{ 525{
506 return read_pnet(&xp->xp_net); 526 return read_pnet(&xp->xp_net);
507} 527}
@@ -545,13 +565,17 @@ struct xfrm_migrate {
545struct xfrm_mgr { 565struct xfrm_mgr {
546 struct list_head list; 566 struct list_head list;
547 char *id; 567 char *id;
548 int (*notify)(struct xfrm_state *x, struct km_event *c); 568 int (*notify)(struct xfrm_state *x, const struct km_event *c);
549 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); 569 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir);
550 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir); 570 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir);
551 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); 571 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
552 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c); 572 int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c);
553 int (*report)(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 573 int (*report)(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
554 int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles, struct xfrm_kmaddress *k); 574 int (*migrate)(const struct xfrm_selector *sel,
575 u8 dir, u8 type,
576 const struct xfrm_migrate *m,
577 int num_bundles,
578 const struct xfrm_kmaddress *k);
555}; 579};
556 580
557extern int xfrm_register_km(struct xfrm_mgr *km); 581extern int xfrm_register_km(struct xfrm_mgr *km);
@@ -570,8 +594,14 @@ struct xfrm_skb_cb {
570 594
571 /* Sequence number for replay protection. */ 595 /* Sequence number for replay protection. */
572 union { 596 union {
573 u64 output; 597 struct {
574 __be32 input; 598 __u32 low;
599 __u32 hi;
600 } output;
601 struct {
602 __be32 low;
603 __be32 hi;
604 } input;
575 } seq; 605 } seq;
576}; 606};
577 607
@@ -675,6 +705,8 @@ extern void xfrm_audit_state_delete(struct xfrm_state *x, int result,
675 u32 auid, u32 ses, u32 secid); 705 u32 auid, u32 ses, u32 secid);
676extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, 706extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
677 struct sk_buff *skb); 707 struct sk_buff *skb);
708extern void xfrm_audit_state_replay(struct xfrm_state *x,
709 struct sk_buff *skb, __be32 net_seq);
678extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); 710extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family);
679extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, 711extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
680 __be32 net_spi, __be32 net_seq); 712 __be32 net_spi, __be32 net_seq);
@@ -707,6 +739,11 @@ static inline void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
707{ 739{
708} 740}
709 741
742static inline void xfrm_audit_state_replay(struct xfrm_state *x,
743 struct sk_buff *skb, __be32 net_seq)
744{
745}
746
710static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb, 747static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb,
711 u16 family) 748 u16 family)
712{ 749{
@@ -762,10 +799,11 @@ static inline void xfrm_state_hold(struct xfrm_state *x)
762 atomic_inc(&x->refcnt); 799 atomic_inc(&x->refcnt);
763} 800}
764 801
765static __inline__ int addr_match(void *token1, void *token2, int prefixlen) 802static inline bool addr_match(const void *token1, const void *token2,
803 int prefixlen)
766{ 804{
767 __be32 *a1 = token1; 805 const __be32 *a1 = token1;
768 __be32 *a2 = token2; 806 const __be32 *a2 = token2;
769 int pdw; 807 int pdw;
770 int pbi; 808 int pbi;
771 809
@@ -774,7 +812,7 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen)
774 812
775 if (pdw) 813 if (pdw)
776 if (memcmp(a1, a2, pdw << 2)) 814 if (memcmp(a1, a2, pdw << 2))
777 return 0; 815 return false;
778 816
779 if (pbi) { 817 if (pbi) {
780 __be32 mask; 818 __be32 mask;
@@ -782,32 +820,32 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen)
782 mask = htonl((0xffffffff) << (32 - pbi)); 820 mask = htonl((0xffffffff) << (32 - pbi));
783 821
784 if ((a1[pdw] ^ a2[pdw]) & mask) 822 if ((a1[pdw] ^ a2[pdw]) & mask)
785 return 0; 823 return false;
786 } 824 }
787 825
788 return 1; 826 return true;
789} 827}
790 828
791static __inline__ 829static __inline__
792__be16 xfrm_flowi_sport(struct flowi *fl) 830__be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli)
793{ 831{
794 __be16 port; 832 __be16 port;
795 switch(fl->proto) { 833 switch(fl->flowi_proto) {
796 case IPPROTO_TCP: 834 case IPPROTO_TCP:
797 case IPPROTO_UDP: 835 case IPPROTO_UDP:
798 case IPPROTO_UDPLITE: 836 case IPPROTO_UDPLITE:
799 case IPPROTO_SCTP: 837 case IPPROTO_SCTP:
800 port = fl->fl_ip_sport; 838 port = uli->ports.sport;
801 break; 839 break;
802 case IPPROTO_ICMP: 840 case IPPROTO_ICMP:
803 case IPPROTO_ICMPV6: 841 case IPPROTO_ICMPV6:
804 port = htons(fl->fl_icmp_type); 842 port = htons(uli->icmpt.type);
805 break; 843 break;
806 case IPPROTO_MH: 844 case IPPROTO_MH:
807 port = htons(fl->fl_mh_type); 845 port = htons(uli->mht.type);
808 break; 846 break;
809 case IPPROTO_GRE: 847 case IPPROTO_GRE:
810 port = htons(ntohl(fl->fl_gre_key) >> 16); 848 port = htons(ntohl(uli->gre_key) >> 16);
811 break; 849 break;
812 default: 850 default:
813 port = 0; /*XXX*/ 851 port = 0; /*XXX*/
@@ -816,22 +854,22 @@ __be16 xfrm_flowi_sport(struct flowi *fl)
816} 854}
817 855
818static __inline__ 856static __inline__
819__be16 xfrm_flowi_dport(struct flowi *fl) 857__be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli)
820{ 858{
821 __be16 port; 859 __be16 port;
822 switch(fl->proto) { 860 switch(fl->flowi_proto) {
823 case IPPROTO_TCP: 861 case IPPROTO_TCP:
824 case IPPROTO_UDP: 862 case IPPROTO_UDP:
825 case IPPROTO_UDPLITE: 863 case IPPROTO_UDPLITE:
826 case IPPROTO_SCTP: 864 case IPPROTO_SCTP:
827 port = fl->fl_ip_dport; 865 port = uli->ports.dport;
828 break; 866 break;
829 case IPPROTO_ICMP: 867 case IPPROTO_ICMP:
830 case IPPROTO_ICMPV6: 868 case IPPROTO_ICMPV6:
831 port = htons(fl->fl_icmp_code); 869 port = htons(uli->icmpt.code);
832 break; 870 break;
833 case IPPROTO_GRE: 871 case IPPROTO_GRE:
834 port = htons(ntohl(fl->fl_gre_key) & 0xffff); 872 port = htons(ntohl(uli->gre_key) & 0xffff);
835 break; 873 break;
836 default: 874 default:
837 port = 0; /*XXX*/ 875 port = 0; /*XXX*/
@@ -839,7 +877,8 @@ __be16 xfrm_flowi_dport(struct flowi *fl)
839 return port; 877 return port;
840} 878}
841 879
842extern int xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl, 880extern int xfrm_selector_match(const struct xfrm_selector *sel,
881 const struct flowi *fl,
843 unsigned short family); 882 unsigned short family);
844 883
845#ifdef CONFIG_SECURITY_NETWORK_XFRM 884#ifdef CONFIG_SECURITY_NETWORK_XFRM
@@ -947,7 +986,7 @@ secpath_reset(struct sk_buff *skb)
947} 986}
948 987
949static inline int 988static inline int
950xfrm_addr_any(xfrm_address_t *addr, unsigned short family) 989xfrm_addr_any(const xfrm_address_t *addr, unsigned short family)
951{ 990{
952 switch (family) { 991 switch (family) {
953 case AF_INET: 992 case AF_INET:
@@ -959,21 +998,21 @@ xfrm_addr_any(xfrm_address_t *addr, unsigned short family)
959} 998}
960 999
961static inline int 1000static inline int
962__xfrm4_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x) 1001__xfrm4_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x)
963{ 1002{
964 return (tmpl->saddr.a4 && 1003 return (tmpl->saddr.a4 &&
965 tmpl->saddr.a4 != x->props.saddr.a4); 1004 tmpl->saddr.a4 != x->props.saddr.a4);
966} 1005}
967 1006
968static inline int 1007static inline int
969__xfrm6_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x) 1008__xfrm6_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x)
970{ 1009{
971 return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) && 1010 return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) &&
972 ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr)); 1011 ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr));
973} 1012}
974 1013
975static inline int 1014static inline int
976xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short family) 1015xfrm_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x, unsigned short family)
977{ 1016{
978 switch (family) { 1017 switch (family) {
979 case AF_INET: 1018 case AF_INET:
@@ -1126,49 +1165,49 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
1126#endif 1165#endif
1127 1166
1128static __inline__ 1167static __inline__
1129xfrm_address_t *xfrm_flowi_daddr(struct flowi *fl, unsigned short family) 1168xfrm_address_t *xfrm_flowi_daddr(const struct flowi *fl, unsigned short family)
1130{ 1169{
1131 switch (family){ 1170 switch (family){
1132 case AF_INET: 1171 case AF_INET:
1133 return (xfrm_address_t *)&fl->fl4_dst; 1172 return (xfrm_address_t *)&fl->u.ip4.daddr;
1134 case AF_INET6: 1173 case AF_INET6:
1135 return (xfrm_address_t *)&fl->fl6_dst; 1174 return (xfrm_address_t *)&fl->u.ip6.daddr;
1136 } 1175 }
1137 return NULL; 1176 return NULL;
1138} 1177}
1139 1178
1140static __inline__ 1179static __inline__
1141xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family) 1180xfrm_address_t *xfrm_flowi_saddr(const struct flowi *fl, unsigned short family)
1142{ 1181{
1143 switch (family){ 1182 switch (family){
1144 case AF_INET: 1183 case AF_INET:
1145 return (xfrm_address_t *)&fl->fl4_src; 1184 return (xfrm_address_t *)&fl->u.ip4.saddr;
1146 case AF_INET6: 1185 case AF_INET6:
1147 return (xfrm_address_t *)&fl->fl6_src; 1186 return (xfrm_address_t *)&fl->u.ip6.saddr;
1148 } 1187 }
1149 return NULL; 1188 return NULL;
1150} 1189}
1151 1190
1152static __inline__ 1191static __inline__
1153void xfrm_flowi_addr_get(struct flowi *fl, 1192void xfrm_flowi_addr_get(const struct flowi *fl,
1154 xfrm_address_t *saddr, xfrm_address_t *daddr, 1193 xfrm_address_t *saddr, xfrm_address_t *daddr,
1155 unsigned short family) 1194 unsigned short family)
1156{ 1195{
1157 switch(family) { 1196 switch(family) {
1158 case AF_INET: 1197 case AF_INET:
1159 memcpy(&saddr->a4, &fl->fl4_src, sizeof(saddr->a4)); 1198 memcpy(&saddr->a4, &fl->u.ip4.saddr, sizeof(saddr->a4));
1160 memcpy(&daddr->a4, &fl->fl4_dst, sizeof(daddr->a4)); 1199 memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4));
1161 break; 1200 break;
1162 case AF_INET6: 1201 case AF_INET6:
1163 ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->fl6_src); 1202 ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->u.ip6.saddr);
1164 ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->fl6_dst); 1203 ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->u.ip6.daddr);
1165 break; 1204 break;
1166 } 1205 }
1167} 1206}
1168 1207
1169static __inline__ int 1208static __inline__ int
1170__xfrm4_state_addr_check(struct xfrm_state *x, 1209__xfrm4_state_addr_check(const struct xfrm_state *x,
1171 xfrm_address_t *daddr, xfrm_address_t *saddr) 1210 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
1172{ 1211{
1173 if (daddr->a4 == x->id.daddr.a4 && 1212 if (daddr->a4 == x->id.daddr.a4 &&
1174 (saddr->a4 == x->props.saddr.a4 || !saddr->a4 || !x->props.saddr.a4)) 1213 (saddr->a4 == x->props.saddr.a4 || !saddr->a4 || !x->props.saddr.a4))
@@ -1177,8 +1216,8 @@ __xfrm4_state_addr_check(struct xfrm_state *x,
1177} 1216}
1178 1217
1179static __inline__ int 1218static __inline__ int
1180__xfrm6_state_addr_check(struct xfrm_state *x, 1219__xfrm6_state_addr_check(const struct xfrm_state *x,
1181 xfrm_address_t *daddr, xfrm_address_t *saddr) 1220 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
1182{ 1221{
1183 if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) && 1222 if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) &&
1184 (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)|| 1223 (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)||
@@ -1189,8 +1228,8 @@ __xfrm6_state_addr_check(struct xfrm_state *x,
1189} 1228}
1190 1229
1191static __inline__ int 1230static __inline__ int
1192xfrm_state_addr_check(struct xfrm_state *x, 1231xfrm_state_addr_check(const struct xfrm_state *x,
1193 xfrm_address_t *daddr, xfrm_address_t *saddr, 1232 const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1194 unsigned short family) 1233 unsigned short family)
1195{ 1234{
1196 switch (family) { 1235 switch (family) {
@@ -1203,23 +1242,23 @@ xfrm_state_addr_check(struct xfrm_state *x,
1203} 1242}
1204 1243
1205static __inline__ int 1244static __inline__ int
1206xfrm_state_addr_flow_check(struct xfrm_state *x, struct flowi *fl, 1245xfrm_state_addr_flow_check(const struct xfrm_state *x, const struct flowi *fl,
1207 unsigned short family) 1246 unsigned short family)
1208{ 1247{
1209 switch (family) { 1248 switch (family) {
1210 case AF_INET: 1249 case AF_INET:
1211 return __xfrm4_state_addr_check(x, 1250 return __xfrm4_state_addr_check(x,
1212 (xfrm_address_t *)&fl->fl4_dst, 1251 (const xfrm_address_t *)&fl->u.ip4.daddr,
1213 (xfrm_address_t *)&fl->fl4_src); 1252 (const xfrm_address_t *)&fl->u.ip4.saddr);
1214 case AF_INET6: 1253 case AF_INET6:
1215 return __xfrm6_state_addr_check(x, 1254 return __xfrm6_state_addr_check(x,
1216 (xfrm_address_t *)&fl->fl6_dst, 1255 (const xfrm_address_t *)&fl->u.ip6.daddr,
1217 (xfrm_address_t *)&fl->fl6_src); 1256 (const xfrm_address_t *)&fl->u.ip6.saddr);
1218 } 1257 }
1219 return 0; 1258 return 0;
1220} 1259}
1221 1260
1222static inline int xfrm_state_kern(struct xfrm_state *x) 1261static inline int xfrm_state_kern(const struct xfrm_state *x)
1223{ 1262{
1224 return atomic_read(&x->tunnel_users); 1263 return atomic_read(&x->tunnel_users);
1225} 1264}
@@ -1323,8 +1362,10 @@ extern int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk,
1323 int (*func)(struct xfrm_state *, int, void*), void *); 1362 int (*func)(struct xfrm_state *, int, void*), void *);
1324extern void xfrm_state_walk_done(struct xfrm_state_walk *walk); 1363extern void xfrm_state_walk_done(struct xfrm_state_walk *walk);
1325extern struct xfrm_state *xfrm_state_alloc(struct net *net); 1364extern struct xfrm_state *xfrm_state_alloc(struct net *net);
1326extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 1365extern struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr,
1327 struct flowi *fl, struct xfrm_tmpl *tmpl, 1366 const xfrm_address_t *saddr,
1367 const struct flowi *fl,
1368 struct xfrm_tmpl *tmpl,
1328 struct xfrm_policy *pol, int *err, 1369 struct xfrm_policy *pol, int *err,
1329 unsigned short family); 1370 unsigned short family);
1330extern struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark, 1371extern struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark,
@@ -1337,11 +1378,11 @@ extern void xfrm_state_insert(struct xfrm_state *x);
1337extern int xfrm_state_add(struct xfrm_state *x); 1378extern int xfrm_state_add(struct xfrm_state *x);
1338extern int xfrm_state_update(struct xfrm_state *x); 1379extern int xfrm_state_update(struct xfrm_state *x);
1339extern struct xfrm_state *xfrm_state_lookup(struct net *net, u32 mark, 1380extern struct xfrm_state *xfrm_state_lookup(struct net *net, u32 mark,
1340 xfrm_address_t *daddr, __be32 spi, 1381 const xfrm_address_t *daddr, __be32 spi,
1341 u8 proto, unsigned short family); 1382 u8 proto, unsigned short family);
1342extern struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark, 1383extern struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark,
1343 xfrm_address_t *daddr, 1384 const xfrm_address_t *daddr,
1344 xfrm_address_t *saddr, 1385 const xfrm_address_t *saddr,
1345 u8 proto, 1386 u8 proto,
1346 unsigned short family); 1387 unsigned short family);
1347#ifdef CONFIG_XFRM_SUB_POLICY 1388#ifdef CONFIG_XFRM_SUB_POLICY
@@ -1386,11 +1427,10 @@ extern int xfrm_state_delete(struct xfrm_state *x);
1386extern int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info); 1427extern int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info);
1387extern void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si); 1428extern void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si);
1388extern void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); 1429extern void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si);
1389extern int xfrm_replay_check(struct xfrm_state *x, 1430extern u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq);
1390 struct sk_buff *skb, __be32 seq); 1431extern int xfrm_init_replay(struct xfrm_state *x);
1391extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
1392extern void xfrm_replay_notify(struct xfrm_state *x, int event);
1393extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); 1432extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
1433extern int __xfrm_init_state(struct xfrm_state *x, bool init_replay);
1394extern int xfrm_init_state(struct xfrm_state *x); 1434extern int xfrm_init_state(struct xfrm_state *x);
1395extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); 1435extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb);
1396extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, 1436extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi,
@@ -1468,19 +1508,19 @@ u32 xfrm_get_acqseq(void);
1468extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); 1508extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
1469struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark, 1509struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark,
1470 u8 mode, u32 reqid, u8 proto, 1510 u8 mode, u32 reqid, u8 proto,
1471 xfrm_address_t *daddr, 1511 const xfrm_address_t *daddr,
1472 xfrm_address_t *saddr, int create, 1512 const xfrm_address_t *saddr, int create,
1473 unsigned short family); 1513 unsigned short family);
1474extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); 1514extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
1475 1515
1476#ifdef CONFIG_XFRM_MIGRATE 1516#ifdef CONFIG_XFRM_MIGRATE
1477extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1517extern int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
1478 struct xfrm_migrate *m, int num_bundles, 1518 const struct xfrm_migrate *m, int num_bundles,
1479 struct xfrm_kmaddress *k); 1519 const struct xfrm_kmaddress *k);
1480extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m); 1520extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m);
1481extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, 1521extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
1482 struct xfrm_migrate *m); 1522 struct xfrm_migrate *m);
1483extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1523extern int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
1484 struct xfrm_migrate *m, int num_bundles, 1524 struct xfrm_migrate *m, int num_bundles,
1485 struct xfrm_kmaddress *k); 1525 struct xfrm_kmaddress *k);
1486#endif 1526#endif
@@ -1500,10 +1540,10 @@ extern struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx);
1500extern struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id); 1540extern struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id);
1501extern struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id); 1541extern struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id);
1502extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id); 1542extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id);
1503extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe); 1543extern struct xfrm_algo_desc *xfrm_aalg_get_byname(const char *name, int probe);
1504extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe); 1544extern struct xfrm_algo_desc *xfrm_ealg_get_byname(const char *name, int probe);
1505extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe); 1545extern struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe);
1506extern struct xfrm_algo_desc *xfrm_aead_get_byname(char *name, int icv_len, 1546extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len,
1507 int probe); 1547 int probe);
1508 1548
1509struct hash_desc; 1549struct hash_desc;
@@ -1511,7 +1551,8 @@ struct scatterlist;
1511typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *, 1551typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *,
1512 unsigned int); 1552 unsigned int);
1513 1553
1514static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b, 1554static inline int xfrm_addr_cmp(const xfrm_address_t *a,
1555 const xfrm_address_t *b,
1515 int family) 1556 int family)
1516{ 1557{
1517 switch (family) { 1558 switch (family) {
@@ -1544,17 +1585,44 @@ static inline int xfrm_aevent_is_on(struct net *net)
1544} 1585}
1545#endif 1586#endif
1546 1587
1547static inline int xfrm_alg_len(struct xfrm_algo *alg) 1588static inline int xfrm_alg_len(const struct xfrm_algo *alg)
1548{ 1589{
1549 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); 1590 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
1550} 1591}
1551 1592
1552static inline int xfrm_alg_auth_len(struct xfrm_algo_auth *alg) 1593static inline int xfrm_alg_auth_len(const struct xfrm_algo_auth *alg)
1553{ 1594{
1554 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); 1595 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
1555} 1596}
1556 1597
1598static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay_esn)
1599{
1600 return sizeof(*replay_esn) + replay_esn->bmp_len * sizeof(__u32);
1601}
1602
1557#ifdef CONFIG_XFRM_MIGRATE 1603#ifdef CONFIG_XFRM_MIGRATE
1604static inline int xfrm_replay_clone(struct xfrm_state *x,
1605 struct xfrm_state *orig)
1606{
1607 x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn),
1608 GFP_KERNEL);
1609 if (!x->replay_esn)
1610 return -ENOMEM;
1611
1612 x->replay_esn->bmp_len = orig->replay_esn->bmp_len;
1613 x->replay_esn->replay_window = orig->replay_esn->replay_window;
1614
1615 x->preplay_esn = kmemdup(x->replay_esn,
1616 xfrm_replay_state_esn_len(x->replay_esn),
1617 GFP_KERNEL);
1618 if (!x->preplay_esn) {
1619 kfree(x->replay_esn);
1620 return -ENOMEM;
1621 }
1622
1623 return 0;
1624}
1625
1558static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) 1626static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
1559{ 1627{
1560 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); 1628 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
@@ -1597,7 +1665,7 @@ static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)
1597 return m->v & m->m; 1665 return m->v & m->m;
1598} 1666}
1599 1667
1600static inline int xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m) 1668static inline int xfrm_mark_put(struct sk_buff *skb, const struct xfrm_mark *m)
1601{ 1669{
1602 if (m->m | m->v) 1670 if (m->m | m->v)
1603 NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); 1671 NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m);