aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
commitaecdc33e111b2c447b622e287c6003726daa1426 (patch)
tree3e7657eae4b785e1a1fb5dfb225dbae0b2f0cfc6 /include/net
parenta20acf99f75e49271381d65db097c9763060a1e8 (diff)
parenta3a6cab5ea10cca64d036851fe0d932448f2fe4f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller: 1) GRE now works over ipv6, from Dmitry Kozlov. 2) Make SCTP more network namespace aware, from Eric Biederman. 3) TEAM driver now works with non-ethernet devices, from Jiri Pirko. 4) Make openvswitch network namespace aware, from Pravin B Shelar. 5) IPV6 NAT implementation, from Patrick McHardy. 6) Server side support for TCP Fast Open, from Jerry Chu and others. 7) Packet BPF filter supports MOD and XOR, from Eric Dumazet and Daniel Borkmann. 8) Increate the loopback default MTU to 64K, from Eric Dumazet. 9) Use a per-task rather than per-socket page fragment allocator for outgoing networking traffic. This benefits processes that have very many mostly idle sockets, which is quite common. From Eric Dumazet. 10) Use up to 32K for page fragment allocations, with fallbacks to smaller sizes when higher order page allocations fail. Benefits are a) less segments for driver to process b) less calls to page allocator c) less waste of space. From Eric Dumazet. 11) Allow GRO to be used on GRE tunnels, from Eric Dumazet. 12) VXLAN device driver, one way to handle VLAN issues such as the limitation of 4096 VLAN IDs yet still have some level of isolation. From Stephen Hemminger. 13) As usual there is a large boatload of driver changes, with the scale perhaps tilted towards the wireless side this time around. Fix up various fairly trivial conflicts, mostly caused by the user namespace changes. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1012 commits) hyperv: Add buffer for extended info after the RNDIS response message. hyperv: Report actual status in receive completion packet hyperv: Remove extra allocated space for recv_pkt_list elements hyperv: Fix page buffer handling in rndis_filter_send_request() hyperv: Fix the missing return value in rndis_filter_set_packet_filter() hyperv: Fix the max_xfer_size in RNDIS initialization vxlan: put UDP socket in correct namespace vxlan: Depend on CONFIG_INET sfc: Fix the reported priorities of different filter types sfc: Remove EFX_FILTER_FLAG_RX_OVERRIDE_IP sfc: Fix loopback self-test with separate_tx_channels=1 sfc: Fix MCDI structure field lookup sfc: Add parentheses around use of bitfield macro arguments sfc: Fix null function pointer in efx_sriov_channel_type vxlan: virtual extensible lan igmp: export symbol ip_mc_leave_group netlink: add attributes to fdb interface tg3: unconditionally select HWMON support when tg3 is enabled. Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT" gre: fix sparse warning ...
Diffstat (limited to 'include/net')
-rw-r--r--include/net/addrconf.h2
-rw-r--r--include/net/arp.h3
-rw-r--r--include/net/bluetooth/bluetooth.h10
-rw-r--r--include/net/bluetooth/hci.h32
-rw-r--r--include/net/bluetooth/hci_core.h48
-rw-r--r--include/net/bluetooth/l2cap.h20
-rw-r--r--include/net/bluetooth/mgmt.h16
-rw-r--r--include/net/bluetooth/smp.h8
-rw-r--r--include/net/cfg80211.h68
-rw-r--r--include/net/checksum.h3
-rw-r--r--include/net/dst.h10
-rw-r--r--include/net/genetlink.h34
-rw-r--r--include/net/gro_cells.h103
-rw-r--r--include/net/ieee80211_radiotap.h11
-rw-r--r--include/net/inet_ecn.h76
-rw-r--r--include/net/inet_frag.h4
-rw-r--r--include/net/inet_sock.h4
-rw-r--r--include/net/ip.h2
-rw-r--r--include/net/ip6_fib.h1
-rw-r--r--include/net/ip6_tunnel.h41
-rw-r--r--include/net/ip_vs.h16
-rw-r--r--include/net/ipip.h3
-rw-r--r--include/net/ipv6.h33
-rw-r--r--include/net/llc.h1
-rw-r--r--include/net/mac80211.h99
-rw-r--r--include/net/ndisc.h3
-rw-r--r--include/net/neighbour.h14
-rw-r--r--include/net/net_namespace.h15
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h32
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h2
-rw-r--r--include/net/netfilter/nf_conntrack_timeout.h20
-rw-r--r--include/net/netfilter/nf_nat.h6
-rw-r--r--include/net/netfilter/nf_nat_core.h5
-rw-r--r--include/net/netfilter/nf_nat_helper.h11
-rw-r--r--include/net/netfilter/nf_nat_l3proto.h52
-rw-r--r--include/net/netfilter/nf_nat_l4proto.h72
-rw-r--r--include/net/netfilter/nf_nat_protocol.h67
-rw-r--r--include/net/netfilter/nf_nat_rule.h15
-rw-r--r--include/net/netlink.h124
-rw-r--r--include/net/netns/conntrack.h4
-rw-r--r--include/net/netns/ipv4.h2
-rw-r--r--include/net/netns/ipv6.h9
-rw-r--r--include/net/netns/packet.h4
-rw-r--r--include/net/netns/sctp.h131
-rw-r--r--include/net/nfc/hci.h21
-rw-r--r--include/net/nfc/llc.h54
-rw-r--r--include/net/nfc/nci.h29
-rw-r--r--include/net/nfc/nci_core.h5
-rw-r--r--include/net/nfc/nfc.h4
-rw-r--r--include/net/nfc/shdlc.h107
-rw-r--r--include/net/request_sock.h49
-rw-r--r--include/net/scm.h25
-rw-r--r--include/net/sctp/sctp.h69
-rw-r--r--include/net/sctp/sm.h8
-rw-r--r--include/net/sctp/structs.h154
-rw-r--r--include/net/snmp.h10
-rw-r--r--include/net/sock.h29
-rw-r--r--include/net/tcp.h90
-rw-r--r--include/net/xfrm.h8
59 files changed, 1307 insertions, 591 deletions
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 089a09d001d..9e63e76b20e 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -78,7 +78,7 @@ extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
78 int strict); 78 int strict);
79 79
80extern int ipv6_dev_get_saddr(struct net *net, 80extern int ipv6_dev_get_saddr(struct net *net,
81 struct net_device *dev, 81 const struct net_device *dev,
82 const struct in6_addr *daddr, 82 const struct in6_addr *daddr,
83 unsigned int srcprefs, 83 unsigned int srcprefs,
84 struct in6_addr *saddr); 84 struct in6_addr *saddr);
diff --git a/include/net/arp.h b/include/net/arp.h
index 7f7df93f37c..b630dae0341 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -3,6 +3,7 @@
3#define _ARP_H 3#define _ARP_H
4 4
5#include <linux/if_arp.h> 5#include <linux/if_arp.h>
6#include <linux/hash.h>
6#include <net/neighbour.h> 7#include <net/neighbour.h>
7 8
8 9
@@ -10,7 +11,7 @@ extern struct neigh_table arp_tbl;
10 11
11static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) 12static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd)
12{ 13{
13 u32 val = key ^ dev->ifindex; 14 u32 val = key ^ hash32_ptr(dev);
14 15
15 return val * hash_rnd; 16 return val * hash_rnd;
16} 17}
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 565d4bee1e4..ede036977ae 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -27,6 +27,7 @@
27 27
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <net/sock.h> 29#include <net/sock.h>
30#include <linux/seq_file.h>
30 31
31#ifndef AF_BLUETOOTH 32#ifndef AF_BLUETOOTH
32#define AF_BLUETOOTH 31 33#define AF_BLUETOOTH 31
@@ -202,6 +203,10 @@ enum {
202struct bt_sock_list { 203struct bt_sock_list {
203 struct hlist_head head; 204 struct hlist_head head;
204 rwlock_t lock; 205 rwlock_t lock;
206#ifdef CONFIG_PROC_FS
207 struct file_operations fops;
208 int (* custom_seq_show)(struct seq_file *, void *);
209#endif
205}; 210};
206 211
207int bt_sock_register(int proto, const struct net_proto_family *ops); 212int bt_sock_register(int proto, const struct net_proto_family *ops);
@@ -292,6 +297,11 @@ extern void hci_sock_cleanup(void);
292extern int bt_sysfs_init(void); 297extern int bt_sysfs_init(void);
293extern void bt_sysfs_cleanup(void); 298extern void bt_sysfs_cleanup(void);
294 299
300extern int bt_procfs_init(struct module* module, struct net *net, const char *name,
301 struct bt_sock_list* sk_list,
302 int (* seq_show)(struct seq_file *, void *));
303extern void bt_procfs_cleanup(struct net *net, const char *name);
304
295extern struct dentry *bt_debugfs; 305extern struct dentry *bt_debugfs;
296 306
297int l2cap_init(void); 307int l2cap_init(void);
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ccd723e0f78..76b2b6bdcf3 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -62,6 +62,15 @@
62/* First BR/EDR Controller shall have ID = 0 */ 62/* First BR/EDR Controller shall have ID = 0 */
63#define HCI_BREDR_ID 0 63#define HCI_BREDR_ID 0
64 64
65/* AMP controller status */
66#define AMP_CTRL_POWERED_DOWN 0x00
67#define AMP_CTRL_BLUETOOTH_ONLY 0x01
68#define AMP_CTRL_NO_CAPACITY 0x02
69#define AMP_CTRL_LOW_CAPACITY 0x03
70#define AMP_CTRL_MEDIUM_CAPACITY 0x04
71#define AMP_CTRL_HIGH_CAPACITY 0x05
72#define AMP_CTRL_FULL_CAPACITY 0x06
73
65/* HCI device quirks */ 74/* HCI device quirks */
66enum { 75enum {
67 HCI_QUIRK_RESET_ON_CLOSE, 76 HCI_QUIRK_RESET_ON_CLOSE,
@@ -293,8 +302,11 @@ enum {
293 302
294/* ---- HCI Error Codes ---- */ 303/* ---- HCI Error Codes ---- */
295#define HCI_ERROR_AUTH_FAILURE 0x05 304#define HCI_ERROR_AUTH_FAILURE 0x05
305#define HCI_ERROR_CONNECTION_TIMEOUT 0x08
296#define HCI_ERROR_REJ_BAD_ADDR 0x0f 306#define HCI_ERROR_REJ_BAD_ADDR 0x0f
297#define HCI_ERROR_REMOTE_USER_TERM 0x13 307#define HCI_ERROR_REMOTE_USER_TERM 0x13
308#define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14
309#define HCI_ERROR_REMOTE_POWER_OFF 0x15
298#define HCI_ERROR_LOCAL_HOST_TERM 0x16 310#define HCI_ERROR_LOCAL_HOST_TERM 0x16
299#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 311#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18
300 312
@@ -1237,6 +1249,24 @@ struct hci_ev_simple_pair_complete {
1237 bdaddr_t bdaddr; 1249 bdaddr_t bdaddr;
1238} __packed; 1250} __packed;
1239 1251
1252#define HCI_EV_USER_PASSKEY_NOTIFY 0x3b
1253struct hci_ev_user_passkey_notify {
1254 bdaddr_t bdaddr;
1255 __le32 passkey;
1256} __packed;
1257
1258#define HCI_KEYPRESS_STARTED 0
1259#define HCI_KEYPRESS_ENTERED 1
1260#define HCI_KEYPRESS_ERASED 2
1261#define HCI_KEYPRESS_CLEARED 3
1262#define HCI_KEYPRESS_COMPLETED 4
1263
1264#define HCI_EV_KEYPRESS_NOTIFY 0x3c
1265struct hci_ev_keypress_notify {
1266 bdaddr_t bdaddr;
1267 __u8 type;
1268} __packed;
1269
1240#define HCI_EV_REMOTE_HOST_FEATURES 0x3d 1270#define HCI_EV_REMOTE_HOST_FEATURES 0x3d
1241struct hci_ev_remote_host_features { 1271struct hci_ev_remote_host_features {
1242 bdaddr_t bdaddr; 1272 bdaddr_t bdaddr;
@@ -1295,6 +1325,8 @@ struct hci_ev_num_comp_blocks {
1295} __packed; 1325} __packed;
1296 1326
1297/* Low energy meta events */ 1327/* Low energy meta events */
1328#define LE_CONN_ROLE_MASTER 0x00
1329
1298#define HCI_EV_LE_CONN_COMPLETE 0x01 1330#define HCI_EV_LE_CONN_COMPLETE 0x01
1299struct hci_ev_le_conn_complete { 1331struct hci_ev_le_conn_complete {
1300 __u8 status; 1332 __u8 status;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 475b8c04ba5..e7d45460988 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -115,12 +115,6 @@ struct oob_data {
115 u8 randomizer[16]; 115 u8 randomizer[16];
116}; 116};
117 117
118struct adv_entry {
119 struct list_head list;
120 bdaddr_t bdaddr;
121 u8 bdaddr_type;
122};
123
124struct le_scan_params { 118struct le_scan_params {
125 u8 type; 119 u8 type;
126 u16 interval; 120 u16 interval;
@@ -309,6 +303,8 @@ struct hci_conn {
309 __u8 pin_length; 303 __u8 pin_length;
310 __u8 enc_key_size; 304 __u8 enc_key_size;
311 __u8 io_capability; 305 __u8 io_capability;
306 __u32 passkey_notify;
307 __u8 passkey_entered;
312 __u16 disc_timeout; 308 __u16 disc_timeout;
313 unsigned long flags; 309 unsigned long flags;
314 310
@@ -356,16 +352,16 @@ extern rwlock_t hci_cb_list_lock;
356 352
357/* ----- HCI interface to upper protocols ----- */ 353/* ----- HCI interface to upper protocols ----- */
358extern int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); 354extern int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
359extern int l2cap_connect_cfm(struct hci_conn *hcon, u8 status); 355extern void l2cap_connect_cfm(struct hci_conn *hcon, u8 status);
360extern int l2cap_disconn_ind(struct hci_conn *hcon); 356extern int l2cap_disconn_ind(struct hci_conn *hcon);
361extern int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); 357extern void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason);
362extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); 358extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt);
363extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, 359extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb,
364 u16 flags); 360 u16 flags);
365 361
366extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); 362extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
367extern int sco_connect_cfm(struct hci_conn *hcon, __u8 status); 363extern void sco_connect_cfm(struct hci_conn *hcon, __u8 status);
368extern int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason); 364extern void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason);
369extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); 365extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);
370 366
371/* ----- Inquiry cache ----- */ 367/* ----- Inquiry cache ----- */
@@ -434,15 +430,6 @@ static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
434 test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); 430 test_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
435} 431}
436 432
437static inline void hci_conn_hash_init(struct hci_dev *hdev)
438{
439 struct hci_conn_hash *h = &hdev->conn_hash;
440 INIT_LIST_HEAD(&h->list);
441 h->acl_num = 0;
442 h->sco_num = 0;
443 h->le_num = 0;
444}
445
446static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) 433static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
447{ 434{
448 struct hci_conn_hash *h = &hdev->conn_hash; 435 struct hci_conn_hash *h = &hdev->conn_hash;
@@ -557,9 +544,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
557 return NULL; 544 return NULL;
558} 545}
559 546
560void hci_acl_connect(struct hci_conn *conn);
561void hci_acl_disconn(struct hci_conn *conn, __u8 reason); 547void hci_acl_disconn(struct hci_conn *conn, __u8 reason);
562void hci_add_sco(struct hci_conn *conn, __u16 handle);
563void hci_setup_sync(struct hci_conn *conn, __u16 handle); 548void hci_setup_sync(struct hci_conn *conn, __u16 handle);
564void hci_sco_setup(struct hci_conn *conn, __u8 status); 549void hci_sco_setup(struct hci_conn *conn, __u8 status);
565 550
@@ -569,7 +554,7 @@ void hci_conn_hash_flush(struct hci_dev *hdev);
569void hci_conn_check_pending(struct hci_dev *hdev); 554void hci_conn_check_pending(struct hci_dev *hdev);
570 555
571struct hci_chan *hci_chan_create(struct hci_conn *conn); 556struct hci_chan *hci_chan_create(struct hci_conn *conn);
572int hci_chan_del(struct hci_chan *chan); 557void hci_chan_del(struct hci_chan *chan);
573void hci_chan_list_flush(struct hci_conn *conn); 558void hci_chan_list_flush(struct hci_conn *conn);
574 559
575struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, 560struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
@@ -587,8 +572,7 @@ void hci_conn_put_device(struct hci_conn *conn);
587 572
588static inline void hci_conn_hold(struct hci_conn *conn) 573static inline void hci_conn_hold(struct hci_conn *conn)
589{ 574{
590 BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt), 575 BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt));
591 atomic_read(&conn->refcnt) + 1);
592 576
593 atomic_inc(&conn->refcnt); 577 atomic_inc(&conn->refcnt);
594 cancel_delayed_work(&conn->disc_work); 578 cancel_delayed_work(&conn->disc_work);
@@ -596,8 +580,7 @@ static inline void hci_conn_hold(struct hci_conn *conn)
596 580
597static inline void hci_conn_put(struct hci_conn *conn) 581static inline void hci_conn_put(struct hci_conn *conn)
598{ 582{
599 BT_DBG("hcon %p refcnt %d -> %d", conn, atomic_read(&conn->refcnt), 583 BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt));
600 atomic_read(&conn->refcnt) - 1);
601 584
602 if (atomic_dec_and_test(&conn->refcnt)) { 585 if (atomic_dec_and_test(&conn->refcnt)) {
603 unsigned long timeo; 586 unsigned long timeo;
@@ -622,11 +605,17 @@ static inline void hci_conn_put(struct hci_conn *conn)
622/* ----- HCI Devices ----- */ 605/* ----- HCI Devices ----- */
623static inline void hci_dev_put(struct hci_dev *d) 606static inline void hci_dev_put(struct hci_dev *d)
624{ 607{
608 BT_DBG("%s orig refcnt %d", d->name,
609 atomic_read(&d->dev.kobj.kref.refcount));
610
625 put_device(&d->dev); 611 put_device(&d->dev);
626} 612}
627 613
628static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) 614static inline struct hci_dev *hci_dev_hold(struct hci_dev *d)
629{ 615{
616 BT_DBG("%s orig refcnt %d", d->name,
617 atomic_read(&d->dev.kobj.kref.refcount));
618
630 get_device(&d->dev); 619 get_device(&d->dev);
631 return d; 620 return d;
632} 621}
@@ -1012,7 +1001,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1012 u8 addr_type, u32 flags, u8 *name, u8 name_len, 1001 u8 addr_type, u32 flags, u8 *name, u8 name_len,
1013 u8 *dev_class); 1002 u8 *dev_class);
1014int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, 1003int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
1015 u8 link_type, u8 addr_type); 1004 u8 link_type, u8 addr_type, u8 reason);
1016int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, 1005int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
1017 u8 link_type, u8 addr_type, u8 status); 1006 u8 link_type, u8 addr_type, u8 status);
1018int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1007int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
@@ -1035,6 +1024,9 @@ int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
1035 u8 link_type, u8 addr_type, u8 status); 1024 u8 link_type, u8 addr_type, u8 status);
1036int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 1025int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
1037 u8 link_type, u8 addr_type, u8 status); 1026 u8 link_type, u8 addr_type, u8 status);
1027int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr,
1028 u8 link_type, u8 addr_type, u32 passkey,
1029 u8 entered);
1038int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1030int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1039 u8 addr_type, u8 status); 1031 u8 addr_type, u8 status);
1040int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); 1032int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status);
@@ -1056,7 +1048,7 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering);
1056int mgmt_interleaved_discovery(struct hci_dev *hdev); 1048int mgmt_interleaved_discovery(struct hci_dev *hdev);
1057int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 1049int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
1058int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 1050int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
1059 1051bool mgmt_valid_hdev(struct hci_dev *hdev);
1060int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); 1052int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent);
1061 1053
1062/* HCI info for socket */ 1054/* HCI info for socket */
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index a7679f8913d..7ed8e356425 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -433,11 +433,10 @@ struct l2cap_chan {
433 struct sock *sk; 433 struct sock *sk;
434 434
435 struct l2cap_conn *conn; 435 struct l2cap_conn *conn;
436 struct kref kref;
436 437
437 __u8 state; 438 __u8 state;
438 439
439 atomic_t refcnt;
440
441 __le16 psm; 440 __le16 psm;
442 __u16 dcid; 441 __u16 dcid;
443 __u16 scid; 442 __u16 scid;
@@ -671,20 +670,8 @@ enum {
671 L2CAP_EV_RECV_FRAME, 670 L2CAP_EV_RECV_FRAME,
672}; 671};
673 672
674static inline void l2cap_chan_hold(struct l2cap_chan *c) 673void l2cap_chan_hold(struct l2cap_chan *c);
675{ 674void l2cap_chan_put(struct l2cap_chan *c);
676 BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
677
678 atomic_inc(&c->refcnt);
679}
680
681static inline void l2cap_chan_put(struct l2cap_chan *c)
682{
683 BT_DBG("chan %p orig refcnt %d", c, atomic_read(&c->refcnt));
684
685 if (atomic_dec_and_test(&c->refcnt))
686 kfree(c);
687}
688 675
689static inline void l2cap_chan_lock(struct l2cap_chan *chan) 676static inline void l2cap_chan_lock(struct l2cap_chan *chan)
690{ 677{
@@ -771,7 +758,6 @@ int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
771 758
772struct l2cap_chan *l2cap_chan_create(void); 759struct l2cap_chan *l2cap_chan_create(void);
773void l2cap_chan_close(struct l2cap_chan *chan, int reason); 760void l2cap_chan_close(struct l2cap_chan *chan, int reason);
774void l2cap_chan_destroy(struct l2cap_chan *chan);
775int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, 761int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
776 bdaddr_t *dst, u8 dst_type); 762 bdaddr_t *dst, u8 dst_type);
777int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, 763int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 4348ee8bda6..22980a7c387 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -405,7 +405,16 @@ struct mgmt_ev_device_connected {
405 __u8 eir[0]; 405 __u8 eir[0];
406} __packed; 406} __packed;
407 407
408#define MGMT_DEV_DISCONN_UNKNOWN 0x00
409#define MGMT_DEV_DISCONN_TIMEOUT 0x01
410#define MGMT_DEV_DISCONN_LOCAL_HOST 0x02
411#define MGMT_DEV_DISCONN_REMOTE 0x03
412
408#define MGMT_EV_DEVICE_DISCONNECTED 0x000C 413#define MGMT_EV_DEVICE_DISCONNECTED 0x000C
414struct mgmt_ev_device_disconnected {
415 struct mgmt_addr_info addr;
416 __u8 reason;
417} __packed;
409 418
410#define MGMT_EV_CONNECT_FAILED 0x000D 419#define MGMT_EV_CONNECT_FAILED 0x000D
411struct mgmt_ev_connect_failed { 420struct mgmt_ev_connect_failed {
@@ -469,3 +478,10 @@ struct mgmt_ev_device_unblocked {
469struct mgmt_ev_device_unpaired { 478struct mgmt_ev_device_unpaired {
470 struct mgmt_addr_info addr; 479 struct mgmt_addr_info addr;
471} __packed; 480} __packed;
481
482#define MGMT_EV_PASSKEY_NOTIFY 0x0017
483struct mgmt_ev_passkey_notify {
484 struct mgmt_addr_info addr;
485 __le32 passkey;
486 __u8 entered;
487} __packed;
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h
index 8b27927b2a5..f8ba07f3e5f 100644
--- a/include/net/bluetooth/smp.h
+++ b/include/net/bluetooth/smp.h
@@ -108,8 +108,8 @@ struct smp_cmd_security_req {
108#define SMP_CONFIRM_FAILED 0x04 108#define SMP_CONFIRM_FAILED 0x04
109#define SMP_PAIRING_NOTSUPP 0x05 109#define SMP_PAIRING_NOTSUPP 0x05
110#define SMP_ENC_KEY_SIZE 0x06 110#define SMP_ENC_KEY_SIZE 0x06
111#define SMP_CMD_NOTSUPP 0x07 111#define SMP_CMD_NOTSUPP 0x07
112#define SMP_UNSPECIFIED 0x08 112#define SMP_UNSPECIFIED 0x08
113#define SMP_REPEATED_ATTEMPTS 0x09 113#define SMP_REPEATED_ATTEMPTS 0x09
114 114
115#define SMP_MIN_ENC_KEY_SIZE 7 115#define SMP_MIN_ENC_KEY_SIZE 7
@@ -123,8 +123,8 @@ struct smp_chan {
123 struct l2cap_conn *conn; 123 struct l2cap_conn *conn;
124 u8 preq[7]; /* SMP Pairing Request */ 124 u8 preq[7]; /* SMP Pairing Request */
125 u8 prsp[7]; /* SMP Pairing Response */ 125 u8 prsp[7]; /* SMP Pairing Response */
126 u8 prnd[16]; /* SMP Pairing Random (local) */ 126 u8 prnd[16]; /* SMP Pairing Random (local) */
127 u8 rrnd[16]; /* SMP Pairing Random (remote) */ 127 u8 rrnd[16]; /* SMP Pairing Random (remote) */
128 u8 pcnf[16]; /* SMP Pairing Confirm */ 128 u8 pcnf[16]; /* SMP Pairing Confirm */
129 u8 tk[16]; /* SMP Temporary Key */ 129 u8 tk[16]; /* SMP Temporary Key */
130 u8 enc_key_size; 130 u8 enc_key_size;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 3d254e10ff3..1b498908224 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -245,6 +245,7 @@ struct ieee80211_sta_vht_cap {
245 * rates" IE, i.e. CCK rates first, then OFDM. 245 * rates" IE, i.e. CCK rates first, then OFDM.
246 * @n_bitrates: Number of bitrates in @bitrates 246 * @n_bitrates: Number of bitrates in @bitrates
247 * @ht_cap: HT capabilities in this band 247 * @ht_cap: HT capabilities in this band
248 * @vht_cap: VHT capabilities in this band
248 */ 249 */
249struct ieee80211_supported_band { 250struct ieee80211_supported_band {
250 struct ieee80211_channel *channels; 251 struct ieee80211_channel *channels;
@@ -1439,7 +1440,8 @@ struct cfg80211_gtk_rekey_data {
1439 * @add_virtual_intf: create a new virtual interface with the given name, 1440 * @add_virtual_intf: create a new virtual interface with the given name,
1440 * must set the struct wireless_dev's iftype. Beware: You must create 1441 * must set the struct wireless_dev's iftype. Beware: You must create
1441 * the new netdev in the wiphy's network namespace! Returns the struct 1442 * the new netdev in the wiphy's network namespace! Returns the struct
1442 * wireless_dev, or an ERR_PTR. 1443 * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
1444 * also set the address member in the wdev.
1443 * 1445 *
1444 * @del_virtual_intf: remove the virtual interface 1446 * @del_virtual_intf: remove the virtual interface
1445 * 1447 *
@@ -1578,9 +1580,7 @@ struct cfg80211_gtk_rekey_data {
1578 * @set_cqm_txe_config: Configure connection quality monitor TX error 1580 * @set_cqm_txe_config: Configure connection quality monitor TX error
1579 * thresholds. 1581 * thresholds.
1580 * @sched_scan_start: Tell the driver to start a scheduled scan. 1582 * @sched_scan_start: Tell the driver to start a scheduled scan.
1581 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled 1583 * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan.
1582 * scan. The driver_initiated flag specifies whether the driver
1583 * itself has informed that the scan has stopped.
1584 * 1584 *
1585 * @mgmt_frame_register: Notify driver that a management frame type was 1585 * @mgmt_frame_register: Notify driver that a management frame type was
1586 * registered. Note that this callback may not sleep, and cannot run 1586 * registered. Note that this callback may not sleep, and cannot run
@@ -1618,6 +1618,9 @@ struct cfg80211_gtk_rekey_data {
1618 * @get_channel: Get the current operating channel for the virtual interface. 1618 * @get_channel: Get the current operating channel for the virtual interface.
1619 * For monitor interfaces, it should return %NULL unless there's a single 1619 * For monitor interfaces, it should return %NULL unless there's a single
1620 * current monitoring channel. 1620 * current monitoring channel.
1621 *
1622 * @start_p2p_device: Start the given P2P device.
1623 * @stop_p2p_device: Stop the given P2P device.
1621 */ 1624 */
1622struct cfg80211_ops { 1625struct cfg80211_ops {
1623 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); 1626 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -1625,7 +1628,7 @@ struct cfg80211_ops {
1625 void (*set_wakeup)(struct wiphy *wiphy, bool enabled); 1628 void (*set_wakeup)(struct wiphy *wiphy, bool enabled);
1626 1629
1627 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy, 1630 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
1628 char *name, 1631 const char *name,
1629 enum nl80211_iftype type, 1632 enum nl80211_iftype type,
1630 u32 *flags, 1633 u32 *flags,
1631 struct vif_params *params); 1634 struct vif_params *params);
@@ -1834,6 +1837,11 @@ struct cfg80211_ops {
1834 (*get_channel)(struct wiphy *wiphy, 1837 (*get_channel)(struct wiphy *wiphy,
1835 struct wireless_dev *wdev, 1838 struct wireless_dev *wdev,
1836 enum nl80211_channel_type *type); 1839 enum nl80211_channel_type *type);
1840
1841 int (*start_p2p_device)(struct wiphy *wiphy,
1842 struct wireless_dev *wdev);
1843 void (*stop_p2p_device)(struct wiphy *wiphy,
1844 struct wireless_dev *wdev);
1837}; 1845};
1838 1846
1839/* 1847/*
@@ -2397,6 +2405,8 @@ struct cfg80211_cached_keys;
2397 * @cleanup_work: work struct used for cleanup that can't be done directly 2405 * @cleanup_work: work struct used for cleanup that can't be done directly
2398 * @beacon_interval: beacon interval used on this device for transmitting 2406 * @beacon_interval: beacon interval used on this device for transmitting
2399 * beacons, 0 when not valid 2407 * beacons, 0 when not valid
2408 * @address: The address for this device, valid only if @netdev is %NULL
2409 * @p2p_started: true if this is a P2P Device that has been started
2400 */ 2410 */
2401struct wireless_dev { 2411struct wireless_dev {
2402 struct wiphy *wiphy; 2412 struct wiphy *wiphy;
@@ -2415,7 +2425,9 @@ struct wireless_dev {
2415 2425
2416 struct work_struct cleanup_work; 2426 struct work_struct cleanup_work;
2417 2427
2418 bool use_4addr; 2428 bool use_4addr, p2p_started;
2429
2430 u8 address[ETH_ALEN] __aligned(sizeof(u16));
2419 2431
2420 /* currently used for IBSS and SME - might be rearranged later */ 2432 /* currently used for IBSS and SME - might be rearranged later */
2421 u8 ssid[IEEE80211_MAX_SSID_LEN]; 2433 u8 ssid[IEEE80211_MAX_SSID_LEN];
@@ -2445,7 +2457,7 @@ struct wireless_dev {
2445 2457
2446 int beacon_interval; 2458 int beacon_interval;
2447 2459
2448 u32 ap_unexpected_nlpid; 2460 u32 ap_unexpected_nlportid;
2449 2461
2450#ifdef CONFIG_CFG80211_WEXT 2462#ifdef CONFIG_CFG80211_WEXT
2451 /* wext data */ 2463 /* wext data */
@@ -2463,6 +2475,13 @@ struct wireless_dev {
2463#endif 2475#endif
2464}; 2476};
2465 2477
2478static inline u8 *wdev_address(struct wireless_dev *wdev)
2479{
2480 if (wdev->netdev)
2481 return wdev->netdev->dev_addr;
2482 return wdev->address;
2483}
2484
2466/** 2485/**
2467 * wdev_priv - return wiphy priv from wireless_dev 2486 * wdev_priv - return wiphy priv from wireless_dev
2468 * 2487 *
@@ -3342,6 +3361,25 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr,
3342void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); 3361void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp);
3343 3362
3344/** 3363/**
3364 * cfg80211_conn_failed - connection request failed notification
3365 *
3366 * @dev: the netdev
3367 * @mac_addr: the station's address
3368 * @reason: the reason for connection failure
3369 * @gfp: allocation flags
3370 *
3371 * Whenever a station tries to connect to an AP and if the station
3372 * could not connect to the AP as the AP has rejected the connection
3373 * for some reasons, this function is called.
3374 *
3375 * The reason for connection failure can be any of the value from
3376 * nl80211_connect_failed_reason enum
3377 */
3378void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr,
3379 enum nl80211_connect_failed_reason reason,
3380 gfp_t gfp);
3381
3382/**
3345 * cfg80211_rx_mgmt - notification of received, unprocessed management frame 3383 * cfg80211_rx_mgmt - notification of received, unprocessed management frame
3346 * @wdev: wireless device receiving the frame 3384 * @wdev: wireless device receiving the frame
3347 * @freq: Frequency on which the frame was received in MHz 3385 * @freq: Frequency on which the frame was received in MHz
@@ -3530,6 +3568,22 @@ void cfg80211_ch_switch_notify(struct net_device *dev, int freq,
3530 */ 3568 */
3531u32 cfg80211_calculate_bitrate(struct rate_info *rate); 3569u32 cfg80211_calculate_bitrate(struct rate_info *rate);
3532 3570
3571/**
3572 * cfg80211_unregister_wdev - remove the given wdev
3573 * @wdev: struct wireless_dev to remove
3574 *
3575 * Call this function only for wdevs that have no netdev assigned,
3576 * e.g. P2P Devices. It removes the device from the list so that
3577 * it can no longer be used. It is necessary to call this function
3578 * even when cfg80211 requests the removal of the interface by
3579 * calling the del_virtual_intf() callback. The function must also
3580 * be called when the driver wishes to unregister the wdev, e.g.
3581 * when the device is unbound from the driver.
3582 *
3583 * Requires the RTNL to be held.
3584 */
3585void cfg80211_unregister_wdev(struct wireless_dev *wdev);
3586
3533/* Logging, debugging and troubleshooting/diagnostic helpers. */ 3587/* Logging, debugging and troubleshooting/diagnostic helpers. */
3534 3588
3535/* wiphy_printk helpers, similar to dev_printk */ 3589/* wiphy_printk helpers, similar to dev_printk */
diff --git a/include/net/checksum.h b/include/net/checksum.h
index ba55d8b8c87..600d1d705bb 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -109,6 +109,9 @@ static inline void csum_replace2(__sum16 *sum, __be16 from, __be16 to)
109struct sk_buff; 109struct sk_buff;
110extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, 110extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
111 __be32 from, __be32 to, int pseudohdr); 111 __be32 from, __be32 to, int pseudohdr);
112extern void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
113 const __be32 *from, const __be32 *to,
114 int pseudohdr);
112 115
113static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, 116static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb,
114 __be16 from, __be16 to, 117 __be16 from, __be16 to,
diff --git a/include/net/dst.h b/include/net/dst.h
index 621e3513ef5..9a7881066fb 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -396,11 +396,15 @@ static inline void dst_confirm(struct dst_entry *dst)
396static inline int dst_neigh_output(struct dst_entry *dst, struct neighbour *n, 396static inline int dst_neigh_output(struct dst_entry *dst, struct neighbour *n,
397 struct sk_buff *skb) 397 struct sk_buff *skb)
398{ 398{
399 struct hh_cache *hh; 399 const struct hh_cache *hh;
400
401 if (dst->pending_confirm) {
402 unsigned long now = jiffies;
400 403
401 if (unlikely(dst->pending_confirm)) {
402 n->confirmed = jiffies;
403 dst->pending_confirm = 0; 404 dst->pending_confirm = 0;
405 /* avoid dirtying neighbour */
406 if (n->confirmed != now)
407 n->confirmed = now;
404 } 408 }
405 409
406 hh = &n->hh; 410 hh = &n->hh;
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 48905cd3884..bdfbe68c1c3 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -65,7 +65,7 @@ struct genl_family {
65/** 65/**
66 * struct genl_info - receiving information 66 * struct genl_info - receiving information
67 * @snd_seq: sending sequence number 67 * @snd_seq: sending sequence number
68 * @snd_pid: netlink pid of sender 68 * @snd_portid: netlink portid of sender
69 * @nlhdr: netlink message header 69 * @nlhdr: netlink message header
70 * @genlhdr: generic netlink message header 70 * @genlhdr: generic netlink message header
71 * @userhdr: user specific header 71 * @userhdr: user specific header
@@ -75,7 +75,7 @@ struct genl_family {
75 */ 75 */
76struct genl_info { 76struct genl_info {
77 u32 snd_seq; 77 u32 snd_seq;
78 u32 snd_pid; 78 u32 snd_portid;
79 struct nlmsghdr * nlhdr; 79 struct nlmsghdr * nlhdr;
80 struct genlmsghdr * genlhdr; 80 struct genlmsghdr * genlhdr;
81 void * userhdr; 81 void * userhdr;
@@ -130,10 +130,10 @@ extern int genl_register_mc_group(struct genl_family *family,
130 struct genl_multicast_group *grp); 130 struct genl_multicast_group *grp);
131extern void genl_unregister_mc_group(struct genl_family *family, 131extern void genl_unregister_mc_group(struct genl_family *family,
132 struct genl_multicast_group *grp); 132 struct genl_multicast_group *grp);
133extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, 133extern void genl_notify(struct sk_buff *skb, struct net *net, u32 portid,
134 u32 group, struct nlmsghdr *nlh, gfp_t flags); 134 u32 group, struct nlmsghdr *nlh, gfp_t flags);
135 135
136void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, 136void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
137 struct genl_family *family, int flags, u8 cmd); 137 struct genl_family *family, int flags, u8 cmd);
138 138
139/** 139/**
@@ -183,7 +183,7 @@ static inline void *genlmsg_put_reply(struct sk_buff *skb,
183 struct genl_family *family, 183 struct genl_family *family,
184 int flags, u8 cmd) 184 int flags, u8 cmd)
185{ 185{
186 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family, 186 return genlmsg_put(skb, info->snd_portid, info->snd_seq, family,
187 flags, cmd); 187 flags, cmd);
188} 188}
189 189
@@ -212,49 +212,49 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr)
212 * genlmsg_multicast_netns - multicast a netlink message to a specific netns 212 * genlmsg_multicast_netns - multicast a netlink message to a specific netns
213 * @net: the net namespace 213 * @net: the net namespace
214 * @skb: netlink message as socket buffer 214 * @skb: netlink message as socket buffer
215 * @pid: own netlink pid to avoid sending to yourself 215 * @portid: own netlink portid to avoid sending to yourself
216 * @group: multicast group id 216 * @group: multicast group id
217 * @flags: allocation flags 217 * @flags: allocation flags
218 */ 218 */
219static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb, 219static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb,
220 u32 pid, unsigned int group, gfp_t flags) 220 u32 portid, unsigned int group, gfp_t flags)
221{ 221{
222 return nlmsg_multicast(net->genl_sock, skb, pid, group, flags); 222 return nlmsg_multicast(net->genl_sock, skb, portid, group, flags);
223} 223}
224 224
225/** 225/**
226 * genlmsg_multicast - multicast a netlink message to the default netns 226 * genlmsg_multicast - multicast a netlink message to the default netns
227 * @skb: netlink message as socket buffer 227 * @skb: netlink message as socket buffer
228 * @pid: own netlink pid to avoid sending to yourself 228 * @portid: own netlink portid to avoid sending to yourself
229 * @group: multicast group id 229 * @group: multicast group id
230 * @flags: allocation flags 230 * @flags: allocation flags
231 */ 231 */
232static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid, 232static inline int genlmsg_multicast(struct sk_buff *skb, u32 portid,
233 unsigned int group, gfp_t flags) 233 unsigned int group, gfp_t flags)
234{ 234{
235 return genlmsg_multicast_netns(&init_net, skb, pid, group, flags); 235 return genlmsg_multicast_netns(&init_net, skb, portid, group, flags);
236} 236}
237 237
238/** 238/**
239 * genlmsg_multicast_allns - multicast a netlink message to all net namespaces 239 * genlmsg_multicast_allns - multicast a netlink message to all net namespaces
240 * @skb: netlink message as socket buffer 240 * @skb: netlink message as socket buffer
241 * @pid: own netlink pid to avoid sending to yourself 241 * @portid: own netlink portid to avoid sending to yourself
242 * @group: multicast group id 242 * @group: multicast group id
243 * @flags: allocation flags 243 * @flags: allocation flags
244 * 244 *
245 * This function must hold the RTNL or rcu_read_lock(). 245 * This function must hold the RTNL or rcu_read_lock().
246 */ 246 */
247int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, 247int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid,
248 unsigned int group, gfp_t flags); 248 unsigned int group, gfp_t flags);
249 249
250/** 250/**
251 * genlmsg_unicast - unicast a netlink message 251 * genlmsg_unicast - unicast a netlink message
252 * @skb: netlink message as socket buffer 252 * @skb: netlink message as socket buffer
253 * @pid: netlink pid of the destination socket 253 * @portid: netlink portid of the destination socket
254 */ 254 */
255static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 pid) 255static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 portid)
256{ 256{
257 return nlmsg_unicast(net->genl_sock, skb, pid); 257 return nlmsg_unicast(net->genl_sock, skb, portid);
258} 258}
259 259
260/** 260/**
@@ -264,7 +264,7 @@ static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 pid)
264 */ 264 */
265static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) 265static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
266{ 266{
267 return genlmsg_unicast(genl_info_net(info), skb, info->snd_pid); 267 return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid);
268} 268}
269 269
270/** 270/**
diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
new file mode 100644
index 00000000000..4fd8a4b4b7e
--- /dev/null
+++ b/include/net/gro_cells.h
@@ -0,0 +1,103 @@
1#ifndef _NET_GRO_CELLS_H
2#define _NET_GRO_CELLS_H
3
4#include <linux/skbuff.h>
5#include <linux/slab.h>
6#include <linux/netdevice.h>
7
8struct gro_cell {
9 struct sk_buff_head napi_skbs;
10 struct napi_struct napi;
11} ____cacheline_aligned_in_smp;
12
13struct gro_cells {
14 unsigned int gro_cells_mask;
15 struct gro_cell *cells;
16};
17
18static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
19{
20 unsigned long flags;
21 struct gro_cell *cell = gcells->cells;
22 struct net_device *dev = skb->dev;
23
24 if (!cell || skb_cloned(skb) || !(dev->features & NETIF_F_GRO)) {
25 netif_rx(skb);
26 return;
27 }
28
29 if (skb_rx_queue_recorded(skb))
30 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
31
32 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
33 atomic_long_inc(&dev->rx_dropped);
34 kfree_skb(skb);
35 return;
36 }
37
38 spin_lock_irqsave(&cell->napi_skbs.lock, flags);
39
40 __skb_queue_tail(&cell->napi_skbs, skb);
41 if (skb_queue_len(&cell->napi_skbs) == 1)
42 napi_schedule(&cell->napi);
43
44 spin_unlock_irqrestore(&cell->napi_skbs.lock, flags);
45}
46
47static inline int gro_cell_poll(struct napi_struct *napi, int budget)
48{
49 struct gro_cell *cell = container_of(napi, struct gro_cell, napi);
50 struct sk_buff *skb;
51 int work_done = 0;
52
53 while (work_done < budget) {
54 skb = skb_dequeue(&cell->napi_skbs);
55 if (!skb)
56 break;
57
58 napi_gro_receive(napi, skb);
59 work_done++;
60 }
61
62 if (work_done < budget)
63 napi_complete(napi);
64 return work_done;
65}
66
67static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *dev)
68{
69 int i;
70
71 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72 gcells->cells = kcalloc(sizeof(struct gro_cell),
73 gcells->gro_cells_mask + 1,
74 GFP_KERNEL);
75 if (!gcells->cells)
76 return -ENOMEM;
77
78 for (i = 0; i <= gcells->gro_cells_mask; i++) {
79 struct gro_cell *cell = gcells->cells + i;
80
81 skb_queue_head_init(&cell->napi_skbs);
82 netif_napi_add(dev, &cell->napi, gro_cell_poll, 64);
83 napi_enable(&cell->napi);
84 }
85 return 0;
86}
87
88static inline void gro_cells_destroy(struct gro_cells *gcells)
89{
90 struct gro_cell *cell = gcells->cells;
91 int i;
92
93 if (!cell)
94 return;
95 for (i = 0; i <= gcells->gro_cells_mask; i++,cell++) {
96 netif_napi_del(&cell->napi);
97 skb_queue_purge(&cell->napi_skbs);
98 }
99 kfree(gcells->cells);
100 gcells->cells = NULL;
101}
102
103#endif
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index 71392545d0a..7f0df133d11 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -183,6 +183,9 @@ struct ieee80211_radiotap_header {
183 * Contains a bitmap of known fields/flags, the flags, and 183 * Contains a bitmap of known fields/flags, the flags, and
184 * the MCS index. 184 * the MCS index.
185 * 185 *
186 * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitless
187 *
188 * Contains the AMPDU information for the subframe.
186 */ 189 */
187enum ieee80211_radiotap_type { 190enum ieee80211_radiotap_type {
188 IEEE80211_RADIOTAP_TSFT = 0, 191 IEEE80211_RADIOTAP_TSFT = 0,
@@ -205,6 +208,7 @@ enum ieee80211_radiotap_type {
205 IEEE80211_RADIOTAP_DATA_RETRIES = 17, 208 IEEE80211_RADIOTAP_DATA_RETRIES = 17,
206 209
207 IEEE80211_RADIOTAP_MCS = 19, 210 IEEE80211_RADIOTAP_MCS = 19,
211 IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
208 212
209 /* valid in every it_present bitmap, even vendor namespaces */ 213 /* valid in every it_present bitmap, even vendor namespaces */
210 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, 214 IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
@@ -270,6 +274,13 @@ enum ieee80211_radiotap_type {
270#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 274#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08
271#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 275#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
272 276
277/* For IEEE80211_RADIOTAP_AMPDU_STATUS */
278#define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001
279#define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002
280#define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004
281#define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008
282#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010
283#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020
273 284
274/* helpers */ 285/* helpers */
275static inline int ieee80211_get_radiotap_len(unsigned char *data) 286static inline int ieee80211_get_radiotap_len(unsigned char *data)
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index 2fa14691869..aab73757bc4 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -15,6 +15,8 @@ enum {
15 INET_ECN_MASK = 3, 15 INET_ECN_MASK = 3,
16}; 16};
17 17
18extern int sysctl_tunnel_ecn_log;
19
18static inline int INET_ECN_is_ce(__u8 dsfield) 20static inline int INET_ECN_is_ce(__u8 dsfield)
19{ 21{
20 return (dsfield & INET_ECN_MASK) == INET_ECN_CE; 22 return (dsfield & INET_ECN_MASK) == INET_ECN_CE;
@@ -145,4 +147,78 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
145 return 0; 147 return 0;
146} 148}
147 149
150/*
151 * RFC 6080 4.2
152 * To decapsulate the inner header at the tunnel egress, a compliant
153 * tunnel egress MUST set the outgoing ECN field to the codepoint at the
154 * intersection of the appropriate arriving inner header (row) and outer
155 * header (column) in Figure 4
156 *
157 * +---------+------------------------------------------------+
158 * |Arriving | Arriving Outer Header |
159 * | Inner +---------+------------+------------+------------+
160 * | Header | Not-ECT | ECT(0) | ECT(1) | CE |
161 * +---------+---------+------------+------------+------------+
162 * | Not-ECT | Not-ECT |Not-ECT(!!!)|Not-ECT(!!!)| <drop>(!!!)|
163 * | ECT(0) | ECT(0) | ECT(0) | ECT(1) | CE |
164 * | ECT(1) | ECT(1) | ECT(1) (!) | ECT(1) | CE |
165 * | CE | CE | CE | CE(!!!)| CE |
166 * +---------+---------+------------+------------+------------+
167 *
168 * Figure 4: New IP in IP Decapsulation Behaviour
169 *
170 * returns 0 on success
171 * 1 if something is broken and should be logged (!!! above)
172 * 2 if packet should be dropped
173 */
174static inline int INET_ECN_decapsulate(struct sk_buff *skb,
175 __u8 outer, __u8 inner)
176{
177 if (INET_ECN_is_not_ect(inner)) {
178 switch (outer & INET_ECN_MASK) {
179 case INET_ECN_NOT_ECT:
180 return 0;
181 case INET_ECN_ECT_0:
182 case INET_ECN_ECT_1:
183 return 1;
184 case INET_ECN_CE:
185 return 2;
186 }
187 }
188
189 if (INET_ECN_is_ce(outer))
190 INET_ECN_set_ce(skb);
191
192 return 0;
193}
194
195static inline int IP_ECN_decapsulate(const struct iphdr *oiph,
196 struct sk_buff *skb)
197{
198 __u8 inner;
199
200 if (skb->protocol == htons(ETH_P_IP))
201 inner = ip_hdr(skb)->tos;
202 else if (skb->protocol == htons(ETH_P_IPV6))
203 inner = ipv6_get_dsfield(ipv6_hdr(skb));
204 else
205 return 0;
206
207 return INET_ECN_decapsulate(skb, oiph->tos, inner);
208}
209
210static inline int IP6_ECN_decapsulate(const struct ipv6hdr *oipv6h,
211 struct sk_buff *skb)
212{
213 __u8 inner;
214
215 if (skb->protocol == htons(ETH_P_IP))
216 inner = ip_hdr(skb)->tos;
217 else if (skb->protocol == htons(ETH_P_IPV6))
218 inner = ipv6_get_dsfield(ipv6_hdr(skb));
219 else
220 return 0;
221
222 return INET_ECN_decapsulate(skb, ipv6_get_dsfield(oipv6h), inner);
223}
148#endif 224#endif
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 2431cf83aec..32786a04471 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -29,6 +29,8 @@ struct inet_frag_queue {
29#define INET_FRAG_COMPLETE 4 29#define INET_FRAG_COMPLETE 4
30#define INET_FRAG_FIRST_IN 2 30#define INET_FRAG_FIRST_IN 2
31#define INET_FRAG_LAST_IN 1 31#define INET_FRAG_LAST_IN 1
32
33 u16 max_size;
32}; 34};
33 35
34#define INETFRAGS_HASHSZ 64 36#define INETFRAGS_HASHSZ 64
@@ -59,7 +61,7 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
59void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); 61void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
60void inet_frag_destroy(struct inet_frag_queue *q, 62void inet_frag_destroy(struct inet_frag_queue *q,
61 struct inet_frags *f, int *work); 63 struct inet_frags *f, int *work);
62int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f); 64int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force);
63struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, 65struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
64 struct inet_frags *f, void *key, unsigned int hash) 66 struct inet_frags *f, void *key, unsigned int hash)
65 __releases(&f->lock); 67 __releases(&f->lock);
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 613cfa40167..256c1ed2d69 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -101,10 +101,8 @@ struct inet_cork {
101 __be32 addr; 101 __be32 addr;
102 struct ip_options *opt; 102 struct ip_options *opt;
103 unsigned int fragsize; 103 unsigned int fragsize;
104 struct dst_entry *dst;
105 int length; /* Total length of all frames */ 104 int length; /* Total length of all frames */
106 struct page *page; 105 struct dst_entry *dst;
107 u32 off;
108 u8 tx_flags; 106 u8 tx_flags;
109}; 107};
110 108
diff --git a/include/net/ip.h b/include/net/ip.h
index 5a5d84d3d2c..0707fb9551a 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -42,6 +42,8 @@ struct inet_skb_parm {
42#define IPSKB_XFRM_TRANSFORMED 4 42#define IPSKB_XFRM_TRANSFORMED 4
43#define IPSKB_FRAG_COMPLETE 8 43#define IPSKB_FRAG_COMPLETE 8
44#define IPSKB_REROUTED 16 44#define IPSKB_REROUTED 16
45
46 u16 frag_max_size;
45}; 47};
46 48
47static inline unsigned int ip_hdrlen(const struct sk_buff *skb) 49static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 9fc7114159e..8a2a203eb15 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -37,6 +37,7 @@ struct fib6_config {
37 int fc_ifindex; 37 int fc_ifindex;
38 u32 fc_flags; 38 u32 fc_flags;
39 u32 fc_protocol; 39 u32 fc_protocol;
40 u32 fc_type; /* only 8 bits are used */
40 41
41 struct in6_addr fc_dst; 42 struct in6_addr fc_dst;
42 struct in6_addr fc_src; 43 struct in6_addr fc_src;
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index 358fb86f57e..e03047f7090 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -5,6 +5,8 @@
5#include <linux/netdevice.h> 5#include <linux/netdevice.h>
6#include <linux/ip6_tunnel.h> 6#include <linux/ip6_tunnel.h>
7 7
8#define IP6TUNNEL_ERR_TIMEO (30*HZ)
9
8/* capable of sending packets */ 10/* capable of sending packets */
9#define IP6_TNL_F_CAP_XMIT 0x10000 11#define IP6_TNL_F_CAP_XMIT 0x10000
10/* capable of receiving packets */ 12/* capable of receiving packets */
@@ -12,15 +14,40 @@
12/* determine capability on a per-packet basis */ 14/* determine capability on a per-packet basis */
13#define IP6_TNL_F_CAP_PER_PACKET 0x40000 15#define IP6_TNL_F_CAP_PER_PACKET 0x40000
14 16
15/* IPv6 tunnel */ 17struct __ip6_tnl_parm {
18 char name[IFNAMSIZ]; /* name of tunnel device */
19 int link; /* ifindex of underlying L2 interface */
20 __u8 proto; /* tunnel protocol */
21 __u8 encap_limit; /* encapsulation limit for tunnel */
22 __u8 hop_limit; /* hop limit for tunnel */
23 __be32 flowinfo; /* traffic class and flowlabel for tunnel */
24 __u32 flags; /* tunnel flags */
25 struct in6_addr laddr; /* local tunnel end-point address */
26 struct in6_addr raddr; /* remote tunnel end-point address */
27
28 __be16 i_flags;
29 __be16 o_flags;
30 __be32 i_key;
31 __be32 o_key;
32};
16 33
34/* IPv6 tunnel */
17struct ip6_tnl { 35struct ip6_tnl {
18 struct ip6_tnl __rcu *next; /* next tunnel in list */ 36 struct ip6_tnl __rcu *next; /* next tunnel in list */
19 struct net_device *dev; /* virtual device associated with tunnel */ 37 struct net_device *dev; /* virtual device associated with tunnel */
20 struct ip6_tnl_parm parms; /* tunnel configuration parameters */ 38 struct __ip6_tnl_parm parms; /* tunnel configuration parameters */
21 struct flowi fl; /* flowi template for xmit */ 39 struct flowi fl; /* flowi template for xmit */
22 struct dst_entry *dst_cache; /* cached dst */ 40 struct dst_entry *dst_cache; /* cached dst */
23 u32 dst_cookie; 41 u32 dst_cookie;
42
43 int err_count;
44 unsigned long err_time;
45
46 /* These fields used only by GRE */
47 __u32 i_seqno; /* The last seen seqno */
48 __u32 o_seqno; /* The last output seqno */
49 int hlen; /* Precalculated GRE header length */
50 int mlink;
24}; 51};
25 52
26/* Tunnel encapsulation limit destination sub-option */ 53/* Tunnel encapsulation limit destination sub-option */
@@ -31,4 +58,14 @@ struct ipv6_tlv_tnl_enc_lim {
31 __u8 encap_limit; /* tunnel encapsulation limit */ 58 __u8 encap_limit; /* tunnel encapsulation limit */
32} __packed; 59} __packed;
33 60
61struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t);
62void ip6_tnl_dst_reset(struct ip6_tnl *t);
63void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst);
64int ip6_tnl_rcv_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
65 const struct in6_addr *raddr);
66int ip6_tnl_xmit_ctl(struct ip6_tnl *t);
67__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
68__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
69 const struct in6_addr *raddr);
70
34#endif 71#endif
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 95374d1696a..ee75ccdf518 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -808,8 +808,6 @@ struct netns_ipvs {
808 struct list_head rs_table[IP_VS_RTAB_SIZE]; 808 struct list_head rs_table[IP_VS_RTAB_SIZE];
809 /* ip_vs_app */ 809 /* ip_vs_app */
810 struct list_head app_list; 810 struct list_head app_list;
811 /* ip_vs_ftp */
812 struct ip_vs_app *ftp_app;
813 /* ip_vs_proto */ 811 /* ip_vs_proto */
814 #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */ 812 #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
815 struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE]; 813 struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
@@ -890,6 +888,7 @@ struct netns_ipvs {
890 unsigned int sysctl_sync_refresh_period; 888 unsigned int sysctl_sync_refresh_period;
891 int sysctl_sync_retries; 889 int sysctl_sync_retries;
892 int sysctl_nat_icmp_send; 890 int sysctl_nat_icmp_send;
891 int sysctl_pmtu_disc;
893 892
894 /* ip_vs_lblc */ 893 /* ip_vs_lblc */
895 int sysctl_lblc_expiration; 894 int sysctl_lblc_expiration;
@@ -976,6 +975,11 @@ static inline int sysctl_sync_sock_size(struct netns_ipvs *ipvs)
976 return ipvs->sysctl_sync_sock_size; 975 return ipvs->sysctl_sync_sock_size;
977} 976}
978 977
978static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
979{
980 return ipvs->sysctl_pmtu_disc;
981}
982
979#else 983#else
980 984
981static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) 985static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
@@ -1018,6 +1022,11 @@ static inline int sysctl_sync_sock_size(struct netns_ipvs *ipvs)
1018 return 0; 1022 return 0;
1019} 1023}
1020 1024
1025static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
1026{
1027 return 1;
1028}
1029
1021#endif 1030#endif
1022 1031
1023/* 1032/*
@@ -1179,7 +1188,8 @@ extern void ip_vs_service_net_cleanup(struct net *net);
1179 * (from ip_vs_app.c) 1188 * (from ip_vs_app.c)
1180 */ 1189 */
1181#define IP_VS_APP_MAX_PORTS 8 1190#define IP_VS_APP_MAX_PORTS 8
1182extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app); 1191extern struct ip_vs_app *register_ip_vs_app(struct net *net,
1192 struct ip_vs_app *app);
1183extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app); 1193extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app);
1184extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); 1194extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
1185extern void ip_vs_unbind_app(struct ip_vs_conn *cp); 1195extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
diff --git a/include/net/ipip.h b/include/net/ipip.h
index a93cf6d7e94..ddc077c51f3 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -2,6 +2,7 @@
2#define __NET_IPIP_H 1 2#define __NET_IPIP_H 1
3 3
4#include <linux/if_tunnel.h> 4#include <linux/if_tunnel.h>
5#include <net/gro_cells.h>
5#include <net/ip.h> 6#include <net/ip.h>
6 7
7/* Keep error state on tunnel for 30 sec */ 8/* Keep error state on tunnel for 30 sec */
@@ -36,6 +37,8 @@ struct ip_tunnel {
36#endif 37#endif
37 struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ 38 struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */
38 unsigned int prl_count; /* # of entries in PRL */ 39 unsigned int prl_count; /* # of entries in PRL */
40
41 struct gro_cells gro_cells;
39}; 42};
40 43
41struct ip_tunnel_prl_entry { 44struct ip_tunnel_prl_entry {
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index c8a202436e0..979bf6c1314 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -34,6 +34,7 @@
34#define NEXTHDR_IPV6 41 /* IPv6 in IPv6 */ 34#define NEXTHDR_IPV6 41 /* IPv6 in IPv6 */
35#define NEXTHDR_ROUTING 43 /* Routing header. */ 35#define NEXTHDR_ROUTING 43 /* Routing header. */
36#define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */ 36#define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */
37#define NEXTHDR_GRE 47 /* GRE header. */
37#define NEXTHDR_ESP 50 /* Encapsulating security payload. */ 38#define NEXTHDR_ESP 50 /* Encapsulating security payload. */
38#define NEXTHDR_AUTH 51 /* Authentication header. */ 39#define NEXTHDR_AUTH 51 /* Authentication header. */
39#define NEXTHDR_ICMP 58 /* ICMP for IPv6. */ 40#define NEXTHDR_ICMP 58 /* ICMP for IPv6. */
@@ -270,8 +271,17 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
270 271
271extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb); 272extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb);
272 273
273int ip6_frag_nqueues(struct net *net); 274#if IS_ENABLED(CONFIG_IPV6)
274int ip6_frag_mem(struct net *net); 275static inline int ip6_frag_nqueues(struct net *net)
276{
277 return net->ipv6.frags.nqueues;
278}
279
280static inline int ip6_frag_mem(struct net *net)
281{
282 return atomic_read(&net->ipv6.frags.mem);
283}
284#endif
275 285
276#define IPV6_FRAG_HIGH_THRESH (256 * 1024) /* 262144 */ 286#define IPV6_FRAG_HIGH_THRESH (256 * 1024) /* 262144 */
277#define IPV6_FRAG_LOW_THRESH (192 * 1024) /* 196608 */ 287#define IPV6_FRAG_LOW_THRESH (192 * 1024) /* 196608 */
@@ -410,6 +420,25 @@ struct ip6_create_arg {
410void ip6_frag_init(struct inet_frag_queue *q, void *a); 420void ip6_frag_init(struct inet_frag_queue *q, void *a);
411bool ip6_frag_match(struct inet_frag_queue *q, void *a); 421bool ip6_frag_match(struct inet_frag_queue *q, void *a);
412 422
423/*
424 * Equivalent of ipv4 struct ip
425 */
426struct frag_queue {
427 struct inet_frag_queue q;
428
429 __be32 id; /* fragment id */
430 u32 user;
431 struct in6_addr saddr;
432 struct in6_addr daddr;
433
434 int iif;
435 unsigned int csum;
436 __u16 nhoffset;
437};
438
439void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq,
440 struct inet_frags *frags);
441
413static inline bool ipv6_addr_any(const struct in6_addr *a) 442static inline bool ipv6_addr_any(const struct in6_addr *a)
414{ 443{
415#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 444#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
diff --git a/include/net/llc.h b/include/net/llc.h
index f2d0fc57052..9e7d7f08ef7 100644
--- a/include/net/llc.h
+++ b/include/net/llc.h
@@ -151,7 +151,6 @@ extern int sysctl_llc2_ack_timeout;
151extern int sysctl_llc2_busy_timeout; 151extern int sysctl_llc2_busy_timeout;
152extern int sysctl_llc2_p_timeout; 152extern int sysctl_llc2_p_timeout;
153extern int sysctl_llc2_rej_timeout; 153extern int sysctl_llc2_rej_timeout;
154extern int sysctl_llc_station_ack_timeout;
155#else 154#else
156#define llc_sysctl_init() (0) 155#define llc_sysctl_init() (0)
157#define llc_sysctl_exit() do { } while(0) 156#define llc_sysctl_exit() do { } while(0)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index bb86aa6f98d..82558c8decf 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -171,6 +171,7 @@ struct ieee80211_low_level_stats {
171 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. 171 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface.
172 * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) 172 * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode)
173 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) 173 * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode)
174 * @BSS_CHANGED_PS: PS changed for this BSS (STA mode)
174 */ 175 */
175enum ieee80211_bss_change { 176enum ieee80211_bss_change {
176 BSS_CHANGED_ASSOC = 1<<0, 177 BSS_CHANGED_ASSOC = 1<<0,
@@ -190,6 +191,7 @@ enum ieee80211_bss_change {
190 BSS_CHANGED_IDLE = 1<<14, 191 BSS_CHANGED_IDLE = 1<<14,
191 BSS_CHANGED_SSID = 1<<15, 192 BSS_CHANGED_SSID = 1<<15,
192 BSS_CHANGED_AP_PROBE_RESP = 1<<16, 193 BSS_CHANGED_AP_PROBE_RESP = 1<<16,
194 BSS_CHANGED_PS = 1<<17,
193 195
194 /* when adding here, make sure to change ieee80211_reconfig */ 196 /* when adding here, make sure to change ieee80211_reconfig */
195}; 197};
@@ -266,6 +268,8 @@ enum ieee80211_rssi_event {
266 * @idle: This interface is idle. There's also a global idle flag in the 268 * @idle: This interface is idle. There's also a global idle flag in the
267 * hardware config which may be more appropriate depending on what 269 * hardware config which may be more appropriate depending on what
268 * your driver/device needs to do. 270 * your driver/device needs to do.
271 * @ps: power-save mode (STA only). This flag is NOT affected by
272 * offchannel/dynamic_ps operations.
269 * @ssid: The SSID of the current vif. Only valid in AP-mode. 273 * @ssid: The SSID of the current vif. Only valid in AP-mode.
270 * @ssid_len: Length of SSID given in @ssid. 274 * @ssid_len: Length of SSID given in @ssid.
271 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode. 275 * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode.
@@ -296,6 +300,7 @@ struct ieee80211_bss_conf {
296 bool arp_filter_enabled; 300 bool arp_filter_enabled;
297 bool qos; 301 bool qos;
298 bool idle; 302 bool idle;
303 bool ps;
299 u8 ssid[IEEE80211_MAX_SSID_LEN]; 304 u8 ssid[IEEE80211_MAX_SSID_LEN];
300 size_t ssid_len; 305 size_t ssid_len;
301 bool hidden_ssid; 306 bool hidden_ssid;
@@ -522,9 +527,6 @@ struct ieee80211_tx_rate {
522 * (2) driver internal use (if applicable) 527 * (2) driver internal use (if applicable)
523 * (3) TX status information - driver tells mac80211 what happened 528 * (3) TX status information - driver tells mac80211 what happened
524 * 529 *
525 * The TX control's sta pointer is only valid during the ->tx call,
526 * it may be NULL.
527 *
528 * @flags: transmit info flags, defined above 530 * @flags: transmit info flags, defined above
529 * @band: the band to transmit on (use for checking for races) 531 * @band: the band to transmit on (use for checking for races)
530 * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC 532 * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC
@@ -555,6 +557,7 @@ struct ieee80211_tx_info {
555 struct ieee80211_tx_rate rates[ 557 struct ieee80211_tx_rate rates[
556 IEEE80211_TX_MAX_RATES]; 558 IEEE80211_TX_MAX_RATES];
557 s8 rts_cts_rate_idx; 559 s8 rts_cts_rate_idx;
560 /* 3 bytes free */
558 }; 561 };
559 /* only needed before rate control */ 562 /* only needed before rate control */
560 unsigned long jiffies; 563 unsigned long jiffies;
@@ -562,7 +565,7 @@ struct ieee80211_tx_info {
562 /* NB: vif can be NULL for injected frames */ 565 /* NB: vif can be NULL for injected frames */
563 struct ieee80211_vif *vif; 566 struct ieee80211_vif *vif;
564 struct ieee80211_key_conf *hw_key; 567 struct ieee80211_key_conf *hw_key;
565 struct ieee80211_sta *sta; 568 /* 8 bytes free */
566 } control; 569 } control;
567 struct { 570 struct {
568 struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES]; 571 struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES];
@@ -673,21 +676,41 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
673 * @RX_FLAG_HT_GF: This frame was received in a HT-greenfield transmission, if 676 * @RX_FLAG_HT_GF: This frame was received in a HT-greenfield transmission, if
674 * the driver fills this value it should add %IEEE80211_RADIOTAP_MCS_HAVE_FMT 677 * the driver fills this value it should add %IEEE80211_RADIOTAP_MCS_HAVE_FMT
675 * to hw.radiotap_mcs_details to advertise that fact 678 * to hw.radiotap_mcs_details to advertise that fact
679 * @RX_FLAG_AMPDU_DETAILS: A-MPDU details are known, in particular the reference
680 * number (@ampdu_reference) must be populated and be a distinct number for
681 * each A-MPDU
682 * @RX_FLAG_AMPDU_REPORT_ZEROLEN: driver reports 0-length subframes
683 * @RX_FLAG_AMPDU_IS_ZEROLEN: This is a zero-length subframe, for
684 * monitoring purposes only
685 * @RX_FLAG_AMPDU_LAST_KNOWN: last subframe is known, should be set on all
686 * subframes of a single A-MPDU
687 * @RX_FLAG_AMPDU_IS_LAST: this subframe is the last subframe of the A-MPDU
688 * @RX_FLAG_AMPDU_DELIM_CRC_ERROR: A delimiter CRC error has been detected
689 * on this subframe
690 * @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC
691 * is stored in the @ampdu_delimiter_crc field)
676 */ 692 */
677enum mac80211_rx_flags { 693enum mac80211_rx_flags {
678 RX_FLAG_MMIC_ERROR = 1<<0, 694 RX_FLAG_MMIC_ERROR = BIT(0),
679 RX_FLAG_DECRYPTED = 1<<1, 695 RX_FLAG_DECRYPTED = BIT(1),
680 RX_FLAG_MMIC_STRIPPED = 1<<3, 696 RX_FLAG_MMIC_STRIPPED = BIT(3),
681 RX_FLAG_IV_STRIPPED = 1<<4, 697 RX_FLAG_IV_STRIPPED = BIT(4),
682 RX_FLAG_FAILED_FCS_CRC = 1<<5, 698 RX_FLAG_FAILED_FCS_CRC = BIT(5),
683 RX_FLAG_FAILED_PLCP_CRC = 1<<6, 699 RX_FLAG_FAILED_PLCP_CRC = BIT(6),
684 RX_FLAG_MACTIME_MPDU = 1<<7, 700 RX_FLAG_MACTIME_MPDU = BIT(7),
685 RX_FLAG_SHORTPRE = 1<<8, 701 RX_FLAG_SHORTPRE = BIT(8),
686 RX_FLAG_HT = 1<<9, 702 RX_FLAG_HT = BIT(9),
687 RX_FLAG_40MHZ = 1<<10, 703 RX_FLAG_40MHZ = BIT(10),
688 RX_FLAG_SHORT_GI = 1<<11, 704 RX_FLAG_SHORT_GI = BIT(11),
689 RX_FLAG_NO_SIGNAL_VAL = 1<<12, 705 RX_FLAG_NO_SIGNAL_VAL = BIT(12),
690 RX_FLAG_HT_GF = 1<<13, 706 RX_FLAG_HT_GF = BIT(13),
707 RX_FLAG_AMPDU_DETAILS = BIT(14),
708 RX_FLAG_AMPDU_REPORT_ZEROLEN = BIT(15),
709 RX_FLAG_AMPDU_IS_ZEROLEN = BIT(16),
710 RX_FLAG_AMPDU_LAST_KNOWN = BIT(17),
711 RX_FLAG_AMPDU_IS_LAST = BIT(18),
712 RX_FLAG_AMPDU_DELIM_CRC_ERROR = BIT(19),
713 RX_FLAG_AMPDU_DELIM_CRC_KNOWN = BIT(20),
691}; 714};
692 715
693/** 716/**
@@ -711,17 +734,22 @@ enum mac80211_rx_flags {
711 * HT rates are use (RX_FLAG_HT) 734 * HT rates are use (RX_FLAG_HT)
712 * @flag: %RX_FLAG_* 735 * @flag: %RX_FLAG_*
713 * @rx_flags: internal RX flags for mac80211 736 * @rx_flags: internal RX flags for mac80211
737 * @ampdu_reference: A-MPDU reference number, must be a different value for
738 * each A-MPDU but the same for each subframe within one A-MPDU
739 * @ampdu_delimiter_crc: A-MPDU delimiter CRC
714 */ 740 */
715struct ieee80211_rx_status { 741struct ieee80211_rx_status {
716 u64 mactime; 742 u64 mactime;
717 u32 device_timestamp; 743 u32 device_timestamp;
718 u16 flag; 744 u32 ampdu_reference;
745 u32 flag;
719 u16 freq; 746 u16 freq;
720 u8 rate_idx; 747 u8 rate_idx;
721 u8 rx_flags; 748 u8 rx_flags;
722 u8 band; 749 u8 band;
723 u8 antenna; 750 u8 antenna;
724 s8 signal; 751 s8 signal;
752 u8 ampdu_delimiter_crc;
725}; 753};
726 754
727/** 755/**
@@ -945,21 +973,29 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
945 * generation in software. 973 * generation in software.
946 * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates 974 * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates
947 * that the key is pairwise rather then a shared key. 975 * that the key is pairwise rather then a shared key.
948 * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a 976 * @IEEE80211_KEY_FLAG_SW_MGMT_TX: This flag should be set by the driver for a
949 * CCMP key if it requires CCMP encryption of management frames (MFP) to 977 * CCMP key if it requires CCMP encryption of management frames (MFP) to
950 * be done in software. 978 * be done in software.
951 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver 979 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
952 * if space should be prepared for the IV, but the IV 980 * if space should be prepared for the IV, but the IV
953 * itself should not be generated. Do not set together with 981 * itself should not be generated. Do not set together with
954 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. 982 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key.
983 * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received
984 * management frames. The flag can help drivers that have a hardware
985 * crypto implementation that doesn't deal with management frames
986 * properly by allowing them to not upload the keys to hardware and
987 * fall back to software crypto. Note that this flag deals only with
988 * RX, if your crypto engine can't deal with TX you can also set the
989 * %IEEE80211_KEY_FLAG_SW_MGMT_TX flag to encrypt such frames in SW.
955 */ 990 */
956enum ieee80211_key_flags { 991enum ieee80211_key_flags {
957 IEEE80211_KEY_FLAG_WMM_STA = 1<<0, 992 IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
958 IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, 993 IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
959 IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, 994 IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
960 IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, 995 IEEE80211_KEY_FLAG_PAIRWISE = 1<<3,
961 IEEE80211_KEY_FLAG_SW_MGMT = 1<<4, 996 IEEE80211_KEY_FLAG_SW_MGMT_TX = 1<<4,
962 IEEE80211_KEY_FLAG_PUT_IV_SPACE = 1<<5, 997 IEEE80211_KEY_FLAG_PUT_IV_SPACE = 1<<5,
998 IEEE80211_KEY_FLAG_RX_MGMT = 1<<6,
963}; 999};
964 1000
965/** 1001/**
@@ -1074,6 +1110,16 @@ enum sta_notify_cmd {
1074}; 1110};
1075 1111
1076/** 1112/**
1113 * struct ieee80211_tx_control - TX control data
1114 *
1115 * @sta: station table entry, this sta pointer may be NULL and
1116 * it is not allowed to copy the pointer, due to RCU.
1117 */
1118struct ieee80211_tx_control {
1119 struct ieee80211_sta *sta;
1120};
1121
1122/**
1077 * enum ieee80211_hw_flags - hardware flags 1123 * enum ieee80211_hw_flags - hardware flags
1078 * 1124 *
1079 * These flags are used to indicate hardware capabilities to 1125 * These flags are used to indicate hardware capabilities to
@@ -1203,6 +1249,10 @@ enum sta_notify_cmd {
1203 * queue mapping in order to use different queues (not just one per AC) 1249 * queue mapping in order to use different queues (not just one per AC)
1204 * for different virtual interfaces. See the doc section on HW queue 1250 * for different virtual interfaces. See the doc section on HW queue
1205 * control for more details. 1251 * control for more details.
1252 *
1253 * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any
1254 * P2P Interface. This will be honoured even if more than one interface
1255 * is supported.
1206 */ 1256 */
1207enum ieee80211_hw_flags { 1257enum ieee80211_hw_flags {
1208 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, 1258 IEEE80211_HW_HAS_RATE_CONTROL = 1<<0,
@@ -1230,6 +1280,7 @@ enum ieee80211_hw_flags {
1230 IEEE80211_HW_AP_LINK_PS = 1<<22, 1280 IEEE80211_HW_AP_LINK_PS = 1<<22,
1231 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, 1281 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23,
1232 IEEE80211_HW_SCAN_WHILE_IDLE = 1<<24, 1282 IEEE80211_HW_SCAN_WHILE_IDLE = 1<<24,
1283 IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25,
1233}; 1284};
1234 1285
1235/** 1286/**
@@ -1884,10 +1935,14 @@ enum ieee80211_frame_release_type {
1884 * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit 1935 * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit
1885 * to this station changed. 1936 * to this station changed.
1886 * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed. 1937 * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed.
1938 * @IEEE80211_RC_SUPP_RATES_CHANGED: The supported rate set of this peer
1939 * changed (in IBSS mode) due to discovering more information about
1940 * the peer.
1887 */ 1941 */
1888enum ieee80211_rate_control_changed { 1942enum ieee80211_rate_control_changed {
1889 IEEE80211_RC_BW_CHANGED = BIT(0), 1943 IEEE80211_RC_BW_CHANGED = BIT(0),
1890 IEEE80211_RC_SMPS_CHANGED = BIT(1), 1944 IEEE80211_RC_SMPS_CHANGED = BIT(1),
1945 IEEE80211_RC_SUPP_RATES_CHANGED = BIT(2),
1891}; 1946};
1892 1947
1893/** 1948/**
@@ -2264,7 +2319,9 @@ enum ieee80211_rate_control_changed {
2264 * The callback is optional and can (should!) sleep. 2319 * The callback is optional and can (should!) sleep.
2265 */ 2320 */
2266struct ieee80211_ops { 2321struct ieee80211_ops {
2267 void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); 2322 void (*tx)(struct ieee80211_hw *hw,
2323 struct ieee80211_tx_control *control,
2324 struct sk_buff *skb);
2268 int (*start)(struct ieee80211_hw *hw); 2325 int (*start)(struct ieee80211_hw *hw);
2269 void (*stop)(struct ieee80211_hw *hw); 2326 void (*stop)(struct ieee80211_hw *hw);
2270#ifdef CONFIG_PM 2327#ifdef CONFIG_PM
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 96a3b5c03e3..980d263765c 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -49,6 +49,7 @@ enum {
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/if_arp.h> 50#include <linux/if_arp.h>
51#include <linux/netdevice.h> 51#include <linux/netdevice.h>
52#include <linux/hash.h>
52 53
53#include <net/neighbour.h> 54#include <net/neighbour.h>
54 55
@@ -134,7 +135,7 @@ static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, _
134{ 135{
135 const u32 *p32 = pkey; 136 const u32 *p32 = pkey;
136 137
137 return (((p32[0] ^ dev->ifindex) * hash_rnd[0]) + 138 return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
138 (p32[1] * hash_rnd[1]) + 139 (p32[1] * hash_rnd[1]) +
139 (p32[2] * hash_rnd[2]) + 140 (p32[2] * hash_rnd[2]) +
140 (p32[3] * hash_rnd[3])); 141 (p32[3] * hash_rnd[3]));
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 344d8988842..0dab173e27d 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -334,18 +334,22 @@ static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb)
334} 334}
335#endif 335#endif
336 336
337static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb) 337static inline int neigh_hh_output(const struct hh_cache *hh, struct sk_buff *skb)
338{ 338{
339 unsigned int seq; 339 unsigned int seq;
340 int hh_len; 340 int hh_len;
341 341
342 do { 342 do {
343 int hh_alen;
344
345 seq = read_seqbegin(&hh->hh_lock); 343 seq = read_seqbegin(&hh->hh_lock);
346 hh_len = hh->hh_len; 344 hh_len = hh->hh_len;
347 hh_alen = HH_DATA_ALIGN(hh_len); 345 if (likely(hh_len <= HH_DATA_MOD)) {
348 memcpy(skb->data - hh_alen, hh->hh_data, hh_alen); 346 /* this is inlined by gcc */
347 memcpy(skb->data - HH_DATA_MOD, hh->hh_data, HH_DATA_MOD);
348 } else {
349 int hh_alen = HH_DATA_ALIGN(hh_len);
350
351 memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
352 }
349 } while (read_seqretry(&hh->hh_lock, seq)); 353 } while (read_seqretry(&hh->hh_lock, seq));
350 354
351 skb_push(skb, hh_len); 355 skb_push(skb, hh_len);
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index fd87963a0ea..4faf6612eca 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -15,6 +15,7 @@
15#include <net/netns/packet.h> 15#include <net/netns/packet.h>
16#include <net/netns/ipv4.h> 16#include <net/netns/ipv4.h>
17#include <net/netns/ipv6.h> 17#include <net/netns/ipv6.h>
18#include <net/netns/sctp.h>
18#include <net/netns/dccp.h> 19#include <net/netns/dccp.h>
19#include <net/netns/x_tables.h> 20#include <net/netns/x_tables.h>
20#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 21#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
@@ -66,6 +67,7 @@ struct net {
66 struct hlist_head *dev_name_head; 67 struct hlist_head *dev_name_head;
67 struct hlist_head *dev_index_head; 68 struct hlist_head *dev_index_head;
68 unsigned int dev_base_seq; /* protected by rtnl_mutex */ 69 unsigned int dev_base_seq; /* protected by rtnl_mutex */
70 int ifindex;
69 71
70 /* core fib_rules */ 72 /* core fib_rules */
71 struct list_head rules_ops; 73 struct list_head rules_ops;
@@ -80,6 +82,9 @@ struct net {
80#if IS_ENABLED(CONFIG_IPV6) 82#if IS_ENABLED(CONFIG_IPV6)
81 struct netns_ipv6 ipv6; 83 struct netns_ipv6 ipv6;
82#endif 84#endif
85#if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
86 struct netns_sctp sctp;
87#endif
83#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) 88#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
84 struct netns_dccp dccp; 89 struct netns_dccp dccp;
85#endif 90#endif
@@ -88,6 +93,9 @@ struct net {
88#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 93#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
89 struct netns_ct ct; 94 struct netns_ct ct;
90#endif 95#endif
96#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
97 struct netns_nf_frag nf_frag;
98#endif
91 struct sock *nfnl; 99 struct sock *nfnl;
92 struct sock *nfnl_stash; 100 struct sock *nfnl_stash;
93#endif 101#endif
@@ -105,6 +113,13 @@ struct net {
105 atomic_t rt_genid; 113 atomic_t rt_genid;
106}; 114};
107 115
116/*
117 * ifindex generation is per-net namespace, and loopback is
118 * always the 1st device in ns (see net_dev_init), thus any
119 * loopback device should get ifindex 1
120 */
121
122#define LOOPBACK_IFINDEX 1
108 123
109#include <linux/seq_file_net.h> 124#include <linux/seq_file_net.h>
110 125
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index 4a045cda9c6..5654d292efd 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -17,7 +17,7 @@ struct nf_conntrack_ecache {
17 unsigned long missed; /* missed events */ 17 unsigned long missed; /* missed events */
18 u16 ctmask; /* bitmask of ct events to be delivered */ 18 u16 ctmask; /* bitmask of ct events to be delivered */
19 u16 expmask; /* bitmask of expect events to be delivered */ 19 u16 expmask; /* bitmask of expect events to be delivered */
20 u32 pid; /* netlink pid of destroyer */ 20 u32 portid; /* netlink portid of destroyer */
21 struct timer_list timeout; 21 struct timer_list timeout;
22}; 22};
23 23
@@ -60,7 +60,7 @@ nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp)
60/* This structure is passed to event handler */ 60/* This structure is passed to event handler */
61struct nf_ct_event { 61struct nf_ct_event {
62 struct nf_conn *ct; 62 struct nf_conn *ct;
63 u32 pid; 63 u32 portid;
64 int report; 64 int report;
65}; 65};
66 66
@@ -92,7 +92,7 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
92static inline int 92static inline int
93nf_conntrack_eventmask_report(unsigned int eventmask, 93nf_conntrack_eventmask_report(unsigned int eventmask,
94 struct nf_conn *ct, 94 struct nf_conn *ct,
95 u32 pid, 95 u32 portid,
96 int report) 96 int report)
97{ 97{
98 int ret = 0; 98 int ret = 0;
@@ -112,11 +112,11 @@ nf_conntrack_eventmask_report(unsigned int eventmask,
112 if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { 112 if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) {
113 struct nf_ct_event item = { 113 struct nf_ct_event item = {
114 .ct = ct, 114 .ct = ct,
115 .pid = e->pid ? e->pid : pid, 115 .portid = e->portid ? e->portid : portid,
116 .report = report 116 .report = report
117 }; 117 };
118 /* This is a resent of a destroy event? If so, skip missed */ 118 /* This is a resent of a destroy event? If so, skip missed */
119 unsigned long missed = e->pid ? 0 : e->missed; 119 unsigned long missed = e->portid ? 0 : e->missed;
120 120
121 if (!((eventmask | missed) & e->ctmask)) 121 if (!((eventmask | missed) & e->ctmask))
122 goto out_unlock; 122 goto out_unlock;
@@ -126,11 +126,11 @@ nf_conntrack_eventmask_report(unsigned int eventmask,
126 spin_lock_bh(&ct->lock); 126 spin_lock_bh(&ct->lock);
127 if (ret < 0) { 127 if (ret < 0) {
128 /* This is a destroy event that has been 128 /* This is a destroy event that has been
129 * triggered by a process, we store the PID 129 * triggered by a process, we store the PORTID
130 * to include it in the retransmission. */ 130 * to include it in the retransmission. */
131 if (eventmask & (1 << IPCT_DESTROY) && 131 if (eventmask & (1 << IPCT_DESTROY) &&
132 e->pid == 0 && pid != 0) 132 e->portid == 0 && portid != 0)
133 e->pid = pid; 133 e->portid = portid;
134 else 134 else
135 e->missed |= eventmask; 135 e->missed |= eventmask;
136 } else 136 } else
@@ -145,9 +145,9 @@ out_unlock:
145 145
146static inline int 146static inline int
147nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct, 147nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct,
148 u32 pid, int report) 148 u32 portid, int report)
149{ 149{
150 return nf_conntrack_eventmask_report(1 << event, ct, pid, report); 150 return nf_conntrack_eventmask_report(1 << event, ct, portid, report);
151} 151}
152 152
153static inline int 153static inline int
@@ -158,7 +158,7 @@ nf_conntrack_event(enum ip_conntrack_events event, struct nf_conn *ct)
158 158
159struct nf_exp_event { 159struct nf_exp_event {
160 struct nf_conntrack_expect *exp; 160 struct nf_conntrack_expect *exp;
161 u32 pid; 161 u32 portid;
162 int report; 162 int report;
163}; 163};
164 164
@@ -172,7 +172,7 @@ extern void nf_ct_expect_unregister_notifier(struct net *net, struct nf_exp_even
172static inline void 172static inline void
173nf_ct_expect_event_report(enum ip_conntrack_expect_events event, 173nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
174 struct nf_conntrack_expect *exp, 174 struct nf_conntrack_expect *exp,
175 u32 pid, 175 u32 portid,
176 int report) 176 int report)
177{ 177{
178 struct net *net = nf_ct_exp_net(exp); 178 struct net *net = nf_ct_exp_net(exp);
@@ -191,7 +191,7 @@ nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
191 if (e->expmask & (1 << event)) { 191 if (e->expmask & (1 << event)) {
192 struct nf_exp_event item = { 192 struct nf_exp_event item = {
193 .exp = exp, 193 .exp = exp,
194 .pid = pid, 194 .portid = portid,
195 .report = report 195 .report = report
196 }; 196 };
197 notify->fcn(1 << event, &item); 197 notify->fcn(1 << event, &item);
@@ -216,20 +216,20 @@ static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
216 struct nf_conn *ct) {} 216 struct nf_conn *ct) {}
217static inline int nf_conntrack_eventmask_report(unsigned int eventmask, 217static inline int nf_conntrack_eventmask_report(unsigned int eventmask,
218 struct nf_conn *ct, 218 struct nf_conn *ct,
219 u32 pid, 219 u32 portid,
220 int report) { return 0; } 220 int report) { return 0; }
221static inline int nf_conntrack_event(enum ip_conntrack_events event, 221static inline int nf_conntrack_event(enum ip_conntrack_events event,
222 struct nf_conn *ct) { return 0; } 222 struct nf_conn *ct) { return 0; }
223static inline int nf_conntrack_event_report(enum ip_conntrack_events event, 223static inline int nf_conntrack_event_report(enum ip_conntrack_events event,
224 struct nf_conn *ct, 224 struct nf_conn *ct,
225 u32 pid, 225 u32 portid,
226 int report) { return 0; } 226 int report) { return 0; }
227static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {} 227static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
228static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event, 228static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
229 struct nf_conntrack_expect *exp) {} 229 struct nf_conntrack_expect *exp) {}
230static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e, 230static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
231 struct nf_conntrack_expect *exp, 231 struct nf_conntrack_expect *exp,
232 u32 pid, 232 u32 portid,
233 int report) {} 233 int report) {}
234 234
235static inline int nf_conntrack_ecache_init(struct net *net) 235static inline int nf_conntrack_ecache_init(struct net *net)
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index 983f0026324..cc13f377a70 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -43,7 +43,7 @@ struct nf_conntrack_expect {
43 unsigned int class; 43 unsigned int class;
44 44
45#ifdef CONFIG_NF_NAT_NEEDED 45#ifdef CONFIG_NF_NAT_NEEDED
46 __be32 saved_ip; 46 union nf_inet_addr saved_addr;
47 /* This is the original per-proto part, used to map the 47 /* This is the original per-proto part, used to map the
48 * expected connection the way the recipient expects. */ 48 * expected connection the way the recipient expects. */
49 union nf_conntrack_man_proto saved_proto; 49 union nf_conntrack_man_proto saved_proto;
diff --git a/include/net/netfilter/nf_conntrack_timeout.h b/include/net/netfilter/nf_conntrack_timeout.h
index 34ec89f8dbf..e41e472d08f 100644
--- a/include/net/netfilter/nf_conntrack_timeout.h
+++ b/include/net/netfilter/nf_conntrack_timeout.h
@@ -55,6 +55,26 @@ struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct,
55#endif 55#endif
56}; 56};
57 57
58static inline unsigned int *
59nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
60 struct nf_conntrack_l4proto *l4proto)
61{
62#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
63 struct nf_conn_timeout *timeout_ext;
64 unsigned int *timeouts;
65
66 timeout_ext = nf_ct_timeout_find(ct);
67 if (timeout_ext)
68 timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext);
69 else
70 timeouts = l4proto->get_timeouts(net);
71
72 return timeouts;
73#else
74 return l4proto->get_timeouts(net);
75#endif
76}
77
58#ifdef CONFIG_NF_CONNTRACK_TIMEOUT 78#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
59extern int nf_conntrack_timeout_init(struct net *net); 79extern int nf_conntrack_timeout_init(struct net *net);
60extern void nf_conntrack_timeout_fini(struct net *net); 80extern void nf_conntrack_timeout_fini(struct net *net);
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
index b4de990b55f..bd8eea720f2 100644
--- a/include/net/netfilter/nf_nat.h
+++ b/include/net/netfilter/nf_nat.h
@@ -43,14 +43,16 @@ struct nf_conn_nat {
43 struct nf_conn *ct; 43 struct nf_conn *ct;
44 union nf_conntrack_nat_help help; 44 union nf_conntrack_nat_help help;
45#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ 45#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
46 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) 46 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) || \
47 defined(CONFIG_IP6_NF_TARGET_MASQUERADE) || \
48 defined(CONFIG_IP6_NF_TARGET_MASQUERADE_MODULE)
47 int masq_index; 49 int masq_index;
48#endif 50#endif
49}; 51};
50 52
51/* Set up the info structure to map into this range. */ 53/* Set up the info structure to map into this range. */
52extern unsigned int nf_nat_setup_info(struct nf_conn *ct, 54extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
53 const struct nf_nat_ipv4_range *range, 55 const struct nf_nat_range *range,
54 enum nf_nat_manip_type maniptype); 56 enum nf_nat_manip_type maniptype);
55 57
56/* Is this tuple already taken? (not by us)*/ 58/* Is this tuple already taken? (not by us)*/
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h
index b13d8d18d59..972e1e47ec7 100644
--- a/include/net/netfilter/nf_nat_core.h
+++ b/include/net/netfilter/nf_nat_core.h
@@ -12,10 +12,7 @@ extern unsigned int nf_nat_packet(struct nf_conn *ct,
12 unsigned int hooknum, 12 unsigned int hooknum,
13 struct sk_buff *skb); 13 struct sk_buff *skb);
14 14
15extern int nf_nat_icmp_reply_translation(struct nf_conn *ct, 15extern int nf_xfrm_me_harder(struct sk_buff *skb, unsigned int family);
16 enum ip_conntrack_info ctinfo,
17 unsigned int hooknum,
18 struct sk_buff *skb);
19 16
20static inline int nf_nat_initialized(struct nf_conn *ct, 17static inline int nf_nat_initialized(struct nf_conn *ct,
21 enum nf_nat_manip_type manip) 18 enum nf_nat_manip_type manip)
diff --git a/include/net/netfilter/nf_nat_helper.h b/include/net/netfilter/nf_nat_helper.h
index 7d8fb7b46c4..b4d6bfc2af0 100644
--- a/include/net/netfilter/nf_nat_helper.h
+++ b/include/net/netfilter/nf_nat_helper.h
@@ -10,6 +10,7 @@ struct sk_buff;
10extern int __nf_nat_mangle_tcp_packet(struct sk_buff *skb, 10extern int __nf_nat_mangle_tcp_packet(struct sk_buff *skb,
11 struct nf_conn *ct, 11 struct nf_conn *ct,
12 enum ip_conntrack_info ctinfo, 12 enum ip_conntrack_info ctinfo,
13 unsigned int protoff,
13 unsigned int match_offset, 14 unsigned int match_offset,
14 unsigned int match_len, 15 unsigned int match_len,
15 const char *rep_buffer, 16 const char *rep_buffer,
@@ -18,12 +19,13 @@ extern int __nf_nat_mangle_tcp_packet(struct sk_buff *skb,
18static inline int nf_nat_mangle_tcp_packet(struct sk_buff *skb, 19static inline int nf_nat_mangle_tcp_packet(struct sk_buff *skb,
19 struct nf_conn *ct, 20 struct nf_conn *ct,
20 enum ip_conntrack_info ctinfo, 21 enum ip_conntrack_info ctinfo,
22 unsigned int protoff,
21 unsigned int match_offset, 23 unsigned int match_offset,
22 unsigned int match_len, 24 unsigned int match_len,
23 const char *rep_buffer, 25 const char *rep_buffer,
24 unsigned int rep_len) 26 unsigned int rep_len)
25{ 27{
26 return __nf_nat_mangle_tcp_packet(skb, ct, ctinfo, 28 return __nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff,
27 match_offset, match_len, 29 match_offset, match_len,
28 rep_buffer, rep_len, true); 30 rep_buffer, rep_len, true);
29} 31}
@@ -31,6 +33,7 @@ static inline int nf_nat_mangle_tcp_packet(struct sk_buff *skb,
31extern int nf_nat_mangle_udp_packet(struct sk_buff *skb, 33extern int nf_nat_mangle_udp_packet(struct sk_buff *skb,
32 struct nf_conn *ct, 34 struct nf_conn *ct,
33 enum ip_conntrack_info ctinfo, 35 enum ip_conntrack_info ctinfo,
36 unsigned int protoff,
34 unsigned int match_offset, 37 unsigned int match_offset,
35 unsigned int match_len, 38 unsigned int match_len,
36 const char *rep_buffer, 39 const char *rep_buffer,
@@ -41,10 +44,12 @@ extern void nf_nat_set_seq_adjust(struct nf_conn *ct,
41 __be32 seq, s16 off); 44 __be32 seq, s16 off);
42extern int nf_nat_seq_adjust(struct sk_buff *skb, 45extern int nf_nat_seq_adjust(struct sk_buff *skb,
43 struct nf_conn *ct, 46 struct nf_conn *ct,
44 enum ip_conntrack_info ctinfo); 47 enum ip_conntrack_info ctinfo,
48 unsigned int protoff);
45extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb, 49extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb,
46 struct nf_conn *ct, 50 struct nf_conn *ct,
47 enum ip_conntrack_info ctinfo); 51 enum ip_conntrack_info ctinfo,
52 unsigned int protoff);
48 53
49/* Setup NAT on this expected conntrack so it follows master, but goes 54/* Setup NAT on this expected conntrack so it follows master, but goes
50 * to port ct->master->saved_proto. */ 55 * to port ct->master->saved_proto. */
diff --git a/include/net/netfilter/nf_nat_l3proto.h b/include/net/netfilter/nf_nat_l3proto.h
new file mode 100644
index 00000000000..bd3b97e02c8
--- /dev/null
+++ b/include/net/netfilter/nf_nat_l3proto.h
@@ -0,0 +1,52 @@
1#ifndef _NF_NAT_L3PROTO_H
2#define _NF_NAT_L3PROTO_H
3
4struct nf_nat_l4proto;
5struct nf_nat_l3proto {
6 u8 l3proto;
7
8 bool (*in_range)(const struct nf_conntrack_tuple *t,
9 const struct nf_nat_range *range);
10
11 u32 (*secure_port)(const struct nf_conntrack_tuple *t, __be16);
12
13 bool (*manip_pkt)(struct sk_buff *skb,
14 unsigned int iphdroff,
15 const struct nf_nat_l4proto *l4proto,
16 const struct nf_conntrack_tuple *target,
17 enum nf_nat_manip_type maniptype);
18
19 void (*csum_update)(struct sk_buff *skb, unsigned int iphdroff,
20 __sum16 *check,
21 const struct nf_conntrack_tuple *t,
22 enum nf_nat_manip_type maniptype);
23
24 void (*csum_recalc)(struct sk_buff *skb, u8 proto,
25 void *data, __sum16 *check,
26 int datalen, int oldlen);
27
28 void (*decode_session)(struct sk_buff *skb,
29 const struct nf_conn *ct,
30 enum ip_conntrack_dir dir,
31 unsigned long statusbit,
32 struct flowi *fl);
33
34 int (*nlattr_to_range)(struct nlattr *tb[],
35 struct nf_nat_range *range);
36};
37
38extern int nf_nat_l3proto_register(const struct nf_nat_l3proto *);
39extern void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *);
40extern const struct nf_nat_l3proto *__nf_nat_l3proto_find(u8 l3proto);
41
42extern int nf_nat_icmp_reply_translation(struct sk_buff *skb,
43 struct nf_conn *ct,
44 enum ip_conntrack_info ctinfo,
45 unsigned int hooknum);
46extern int nf_nat_icmpv6_reply_translation(struct sk_buff *skb,
47 struct nf_conn *ct,
48 enum ip_conntrack_info ctinfo,
49 unsigned int hooknum,
50 unsigned int hdrlen);
51
52#endif /* _NF_NAT_L3PROTO_H */
diff --git a/include/net/netfilter/nf_nat_l4proto.h b/include/net/netfilter/nf_nat_l4proto.h
new file mode 100644
index 00000000000..24feb68d1bc
--- /dev/null
+++ b/include/net/netfilter/nf_nat_l4proto.h
@@ -0,0 +1,72 @@
1/* Header for use in defining a given protocol. */
2#ifndef _NF_NAT_L4PROTO_H
3#define _NF_NAT_L4PROTO_H
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter/nfnetlink_conntrack.h>
6
7struct nf_nat_range;
8struct nf_nat_l3proto;
9
10struct nf_nat_l4proto {
11 /* Protocol number. */
12 u8 l4proto;
13
14 /* Translate a packet to the target according to manip type.
15 * Return true if succeeded.
16 */
17 bool (*manip_pkt)(struct sk_buff *skb,
18 const struct nf_nat_l3proto *l3proto,
19 unsigned int iphdroff, unsigned int hdroff,
20 const struct nf_conntrack_tuple *tuple,
21 enum nf_nat_manip_type maniptype);
22
23 /* Is the manipable part of the tuple between min and max incl? */
24 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
25 enum nf_nat_manip_type maniptype,
26 const union nf_conntrack_man_proto *min,
27 const union nf_conntrack_man_proto *max);
28
29 /* Alter the per-proto part of the tuple (depending on
30 * maniptype), to give a unique tuple in the given range if
31 * possible. Per-protocol part of tuple is initialized to the
32 * incoming packet.
33 */
34 void (*unique_tuple)(const struct nf_nat_l3proto *l3proto,
35 struct nf_conntrack_tuple *tuple,
36 const struct nf_nat_range *range,
37 enum nf_nat_manip_type maniptype,
38 const struct nf_conn *ct);
39
40 int (*nlattr_to_range)(struct nlattr *tb[],
41 struct nf_nat_range *range);
42};
43
44/* Protocol registration. */
45extern int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto);
46extern void nf_nat_l4proto_unregister(u8 l3proto, const struct nf_nat_l4proto *l4proto);
47
48extern const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto);
49
50/* Built-in protocols. */
51extern const struct nf_nat_l4proto nf_nat_l4proto_tcp;
52extern const struct nf_nat_l4proto nf_nat_l4proto_udp;
53extern const struct nf_nat_l4proto nf_nat_l4proto_icmp;
54extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6;
55extern const struct nf_nat_l4proto nf_nat_l4proto_unknown;
56
57extern bool nf_nat_l4proto_in_range(const struct nf_conntrack_tuple *tuple,
58 enum nf_nat_manip_type maniptype,
59 const union nf_conntrack_man_proto *min,
60 const union nf_conntrack_man_proto *max);
61
62extern void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto,
63 struct nf_conntrack_tuple *tuple,
64 const struct nf_nat_range *range,
65 enum nf_nat_manip_type maniptype,
66 const struct nf_conn *ct,
67 u16 *rover);
68
69extern int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[],
70 struct nf_nat_range *range);
71
72#endif /*_NF_NAT_L4PROTO_H*/
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
deleted file mode 100644
index 7b0b51165f7..00000000000
--- a/include/net/netfilter/nf_nat_protocol.h
+++ /dev/null
@@ -1,67 +0,0 @@
1/* Header for use in defining a given protocol. */
2#ifndef _NF_NAT_PROTOCOL_H
3#define _NF_NAT_PROTOCOL_H
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter/nfnetlink_conntrack.h>
6
7struct nf_nat_ipv4_range;
8
9struct nf_nat_protocol {
10 /* Protocol number. */
11 unsigned int protonum;
12
13 /* Translate a packet to the target according to manip type.
14 Return true if succeeded. */
15 bool (*manip_pkt)(struct sk_buff *skb,
16 unsigned int iphdroff,
17 const struct nf_conntrack_tuple *tuple,
18 enum nf_nat_manip_type maniptype);
19
20 /* Is the manipable part of the tuple between min and max incl? */
21 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
22 enum nf_nat_manip_type maniptype,
23 const union nf_conntrack_man_proto *min,
24 const union nf_conntrack_man_proto *max);
25
26 /* Alter the per-proto part of the tuple (depending on
27 maniptype), to give a unique tuple in the given range if
28 possible. Per-protocol part of tuple is initialized to the
29 incoming packet. */
30 void (*unique_tuple)(struct nf_conntrack_tuple *tuple,
31 const struct nf_nat_ipv4_range *range,
32 enum nf_nat_manip_type maniptype,
33 const struct nf_conn *ct);
34
35 int (*nlattr_to_range)(struct nlattr *tb[],
36 struct nf_nat_ipv4_range *range);
37};
38
39/* Protocol registration. */
40extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
41extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
42
43/* Built-in protocols. */
44extern const struct nf_nat_protocol nf_nat_protocol_tcp;
45extern const struct nf_nat_protocol nf_nat_protocol_udp;
46extern const struct nf_nat_protocol nf_nat_protocol_icmp;
47extern const struct nf_nat_protocol nf_nat_unknown_protocol;
48
49extern int init_protocols(void) __init;
50extern void cleanup_protocols(void);
51extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
52
53extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
54 enum nf_nat_manip_type maniptype,
55 const union nf_conntrack_man_proto *min,
56 const union nf_conntrack_man_proto *max);
57
58extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
59 const struct nf_nat_ipv4_range *range,
60 enum nf_nat_manip_type maniptype,
61 const struct nf_conn *ct,
62 u_int16_t *rover);
63
64extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
65 struct nf_nat_ipv4_range *range);
66
67#endif /*_NF_NAT_PROTO_H*/
diff --git a/include/net/netfilter/nf_nat_rule.h b/include/net/netfilter/nf_nat_rule.h
deleted file mode 100644
index 2890bdc4cd9..00000000000
--- a/include/net/netfilter/nf_nat_rule.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _NF_NAT_RULE_H
2#define _NF_NAT_RULE_H
3#include <net/netfilter/nf_conntrack.h>
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter_ipv4/ip_tables.h>
6
7extern int nf_nat_rule_init(void) __init;
8extern void nf_nat_rule_cleanup(void);
9extern int nf_nat_rule_find(struct sk_buff *skb,
10 unsigned int hooknum,
11 const struct net_device *in,
12 const struct net_device *out,
13 struct nf_conn *ct);
14
15#endif /* _NF_NAT_RULE_H */
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 785f37a3b44..9690b0f6698 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -98,6 +98,10 @@
98 * nla_put_u16(skb, type, value) add u16 attribute to skb 98 * nla_put_u16(skb, type, value) add u16 attribute to skb
99 * nla_put_u32(skb, type, value) add u32 attribute to skb 99 * nla_put_u32(skb, type, value) add u32 attribute to skb
100 * nla_put_u64(skb, type, value) add u64 attribute to skb 100 * nla_put_u64(skb, type, value) add u64 attribute to skb
101 * nla_put_s8(skb, type, value) add s8 attribute to skb
102 * nla_put_s16(skb, type, value) add s16 attribute to skb
103 * nla_put_s32(skb, type, value) add s32 attribute to skb
104 * nla_put_s64(skb, type, value) add s64 attribute to skb
101 * nla_put_string(skb, type, str) add string attribute to skb 105 * nla_put_string(skb, type, str) add string attribute to skb
102 * nla_put_flag(skb, type) add flag attribute to skb 106 * nla_put_flag(skb, type) add flag attribute to skb
103 * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb 107 * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb
@@ -121,6 +125,10 @@
121 * nla_get_u16(nla) get payload for a u16 attribute 125 * nla_get_u16(nla) get payload for a u16 attribute
122 * nla_get_u32(nla) get payload for a u32 attribute 126 * nla_get_u32(nla) get payload for a u32 attribute
123 * nla_get_u64(nla) get payload for a u64 attribute 127 * nla_get_u64(nla) get payload for a u64 attribute
128 * nla_get_s8(nla) get payload for a s8 attribute
129 * nla_get_s16(nla) get payload for a s16 attribute
130 * nla_get_s32(nla) get payload for a s32 attribute
131 * nla_get_s64(nla) get payload for a s64 attribute
124 * nla_get_flag(nla) return 1 if flag is true 132 * nla_get_flag(nla) return 1 if flag is true
125 * nla_get_msecs(nla) get payload for a msecs attribute 133 * nla_get_msecs(nla) get payload for a msecs attribute
126 * 134 *
@@ -160,6 +168,10 @@ enum {
160 NLA_NESTED_COMPAT, 168 NLA_NESTED_COMPAT,
161 NLA_NUL_STRING, 169 NLA_NUL_STRING,
162 NLA_BINARY, 170 NLA_BINARY,
171 NLA_S8,
172 NLA_S16,
173 NLA_S32,
174 NLA_S64,
163 __NLA_TYPE_MAX, 175 __NLA_TYPE_MAX,
164}; 176};
165 177
@@ -183,6 +195,8 @@ enum {
183 * NLA_NESTED_COMPAT Minimum length of structure payload 195 * NLA_NESTED_COMPAT Minimum length of structure payload
184 * NLA_U8, NLA_U16, 196 * NLA_U8, NLA_U16,
185 * NLA_U32, NLA_U64, 197 * NLA_U32, NLA_U64,
198 * NLA_S8, NLA_S16,
199 * NLA_S32, NLA_S64,
186 * NLA_MSECS Leaving the length field zero will verify the 200 * NLA_MSECS Leaving the length field zero will verify the
187 * given type fits, using it verifies minimum length 201 * given type fits, using it verifies minimum length
188 * just like "All other" 202 * just like "All other"
@@ -203,19 +217,19 @@ struct nla_policy {
203/** 217/**
204 * struct nl_info - netlink source information 218 * struct nl_info - netlink source information
205 * @nlh: Netlink message header of original request 219 * @nlh: Netlink message header of original request
206 * @pid: Netlink PID of requesting application 220 * @portid: Netlink PORTID of requesting application
207 */ 221 */
208struct nl_info { 222struct nl_info {
209 struct nlmsghdr *nlh; 223 struct nlmsghdr *nlh;
210 struct net *nl_net; 224 struct net *nl_net;
211 u32 pid; 225 u32 portid;
212}; 226};
213 227
214extern int netlink_rcv_skb(struct sk_buff *skb, 228extern int netlink_rcv_skb(struct sk_buff *skb,
215 int (*cb)(struct sk_buff *, 229 int (*cb)(struct sk_buff *,
216 struct nlmsghdr *)); 230 struct nlmsghdr *));
217extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, 231extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb,
218 u32 pid, unsigned int group, int report, 232 u32 portid, unsigned int group, int report,
219 gfp_t flags); 233 gfp_t flags);
220 234
221extern int nla_validate(const struct nlattr *head, 235extern int nla_validate(const struct nlattr *head,
@@ -430,7 +444,7 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh)
430/** 444/**
431 * nlmsg_put - Add a new netlink message to an skb 445 * nlmsg_put - Add a new netlink message to an skb
432 * @skb: socket buffer to store message in 446 * @skb: socket buffer to store message in
433 * @pid: netlink process id 447 * @portid: netlink process id
434 * @seq: sequence number of message 448 * @seq: sequence number of message
435 * @type: message type 449 * @type: message type
436 * @payload: length of message payload 450 * @payload: length of message payload
@@ -439,13 +453,13 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh)
439 * Returns NULL if the tailroom of the skb is insufficient to store 453 * Returns NULL if the tailroom of the skb is insufficient to store
440 * the message header and payload. 454 * the message header and payload.
441 */ 455 */
442static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, 456static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
443 int type, int payload, int flags) 457 int type, int payload, int flags)
444{ 458{
445 if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload))) 459 if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload)))
446 return NULL; 460 return NULL;
447 461
448 return __nlmsg_put(skb, pid, seq, type, payload, flags); 462 return __nlmsg_put(skb, portid, seq, type, payload, flags);
449} 463}
450 464
451/** 465/**
@@ -464,7 +478,7 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb,
464 int type, int payload, 478 int type, int payload,
465 int flags) 479 int flags)
466{ 480{
467 return nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, 481 return nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
468 type, payload, flags); 482 type, payload, flags);
469} 483}
470 484
@@ -549,18 +563,18 @@ static inline void nlmsg_free(struct sk_buff *skb)
549 * nlmsg_multicast - multicast a netlink message 563 * nlmsg_multicast - multicast a netlink message
550 * @sk: netlink socket to spread messages to 564 * @sk: netlink socket to spread messages to
551 * @skb: netlink message as socket buffer 565 * @skb: netlink message as socket buffer
552 * @pid: own netlink pid to avoid sending to yourself 566 * @portid: own netlink portid to avoid sending to yourself
553 * @group: multicast group id 567 * @group: multicast group id
554 * @flags: allocation flags 568 * @flags: allocation flags
555 */ 569 */
556static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, 570static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb,
557 u32 pid, unsigned int group, gfp_t flags) 571 u32 portid, unsigned int group, gfp_t flags)
558{ 572{
559 int err; 573 int err;
560 574
561 NETLINK_CB(skb).dst_group = group; 575 NETLINK_CB(skb).dst_group = group;
562 576
563 err = netlink_broadcast(sk, skb, pid, group, flags); 577 err = netlink_broadcast(sk, skb, portid, group, flags);
564 if (err > 0) 578 if (err > 0)
565 err = 0; 579 err = 0;
566 580
@@ -571,13 +585,13 @@ static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb,
571 * nlmsg_unicast - unicast a netlink message 585 * nlmsg_unicast - unicast a netlink message
572 * @sk: netlink socket to spread message to 586 * @sk: netlink socket to spread message to
573 * @skb: netlink message as socket buffer 587 * @skb: netlink message as socket buffer
574 * @pid: netlink pid of the destination socket 588 * @portid: netlink portid of the destination socket
575 */ 589 */
576static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 pid) 590static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 portid)
577{ 591{
578 int err; 592 int err;
579 593
580 err = netlink_unicast(sk, skb, pid, MSG_DONTWAIT); 594 err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT);
581 if (err > 0) 595 if (err > 0)
582 err = 0; 596 err = 0;
583 597
@@ -879,6 +893,50 @@ static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value)
879} 893}
880 894
881/** 895/**
896 * nla_put_s8 - Add a s8 netlink attribute to a socket buffer
897 * @skb: socket buffer to add attribute to
898 * @attrtype: attribute type
899 * @value: numeric value
900 */
901static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value)
902{
903 return nla_put(skb, attrtype, sizeof(s8), &value);
904}
905
906/**
907 * nla_put_s16 - Add a s16 netlink attribute to a socket buffer
908 * @skb: socket buffer to add attribute to
909 * @attrtype: attribute type
910 * @value: numeric value
911 */
912static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value)
913{
914 return nla_put(skb, attrtype, sizeof(s16), &value);
915}
916
917/**
918 * nla_put_s32 - Add a s32 netlink attribute to a socket buffer
919 * @skb: socket buffer to add attribute to
920 * @attrtype: attribute type
921 * @value: numeric value
922 */
923static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value)
924{
925 return nla_put(skb, attrtype, sizeof(s32), &value);
926}
927
928/**
929 * nla_put_s64 - Add a s64 netlink attribute to a socket buffer
930 * @skb: socket buffer to add attribute to
931 * @attrtype: attribute type
932 * @value: numeric value
933 */
934static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value)
935{
936 return nla_put(skb, attrtype, sizeof(s64), &value);
937}
938
939/**
882 * nla_put_string - Add a string netlink attribute to a socket buffer 940 * nla_put_string - Add a string netlink attribute to a socket buffer
883 * @skb: socket buffer to add attribute to 941 * @skb: socket buffer to add attribute to
884 * @attrtype: attribute type 942 * @attrtype: attribute type
@@ -994,6 +1052,46 @@ static inline __be64 nla_get_be64(const struct nlattr *nla)
994} 1052}
995 1053
996/** 1054/**
1055 * nla_get_s32 - return payload of s32 attribute
1056 * @nla: s32 netlink attribute
1057 */
1058static inline s32 nla_get_s32(const struct nlattr *nla)
1059{
1060 return *(s32 *) nla_data(nla);
1061}
1062
1063/**
1064 * nla_get_s16 - return payload of s16 attribute
1065 * @nla: s16 netlink attribute
1066 */
1067static inline s16 nla_get_s16(const struct nlattr *nla)
1068{
1069 return *(s16 *) nla_data(nla);
1070}
1071
1072/**
1073 * nla_get_s8 - return payload of s8 attribute
1074 * @nla: s8 netlink attribute
1075 */
1076static inline s8 nla_get_s8(const struct nlattr *nla)
1077{
1078 return *(s8 *) nla_data(nla);
1079}
1080
1081/**
1082 * nla_get_s64 - return payload of s64 attribute
1083 * @nla: s64 netlink attribute
1084 */
1085static inline s64 nla_get_s64(const struct nlattr *nla)
1086{
1087 s64 tmp;
1088
1089 nla_memcpy(&tmp, nla, sizeof(tmp));
1090
1091 return tmp;
1092}
1093
1094/**
997 * nla_get_flag - return payload of flag attribute 1095 * nla_get_flag - return payload of flag attribute
998 * @nla: flag netlink attribute 1096 * @nla: flag netlink attribute
999 */ 1097 */
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
index 3aecdc7a84f..a1d83cc8bf8 100644
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -83,6 +83,10 @@ struct netns_ct {
83 int sysctl_auto_assign_helper; 83 int sysctl_auto_assign_helper;
84 bool auto_assign_helper_warned; 84 bool auto_assign_helper_warned;
85 struct nf_ip_net nf_ct_proto; 85 struct nf_ip_net nf_ct_proto;
86#ifdef CONFIG_NF_NAT_NEEDED
87 struct hlist_head *nat_bysource;
88 unsigned int nat_htable_size;
89#endif
86#ifdef CONFIG_SYSCTL 90#ifdef CONFIG_SYSCTL
87 struct ctl_table_header *sysctl_header; 91 struct ctl_table_header *sysctl_header;
88 struct ctl_table_header *acct_sysctl_header; 92 struct ctl_table_header *acct_sysctl_header;
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 69e50c789d9..2ae2b8372cf 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -52,8 +52,6 @@ struct netns_ipv4 {
52 struct xt_table *iptable_security; 52 struct xt_table *iptable_security;
53#endif 53#endif
54 struct xt_table *nat_table; 54 struct xt_table *nat_table;
55 struct hlist_head *nat_bysource;
56 unsigned int nat_htable_size;
57#endif 55#endif
58 56
59 int sysctl_icmp_echo_ignore_all; 57 int sysctl_icmp_echo_ignore_all;
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index df0a5456a3f..214cb0a5335 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -42,6 +42,7 @@ struct netns_ipv6 {
42#ifdef CONFIG_SECURITY 42#ifdef CONFIG_SECURITY
43 struct xt_table *ip6table_security; 43 struct xt_table *ip6table_security;
44#endif 44#endif
45 struct xt_table *ip6table_nat;
45#endif 46#endif
46 struct rt6_info *ip6_null_entry; 47 struct rt6_info *ip6_null_entry;
47 struct rt6_statistics *rt6_stats; 48 struct rt6_statistics *rt6_stats;
@@ -70,4 +71,12 @@ struct netns_ipv6 {
70#endif 71#endif
71#endif 72#endif
72}; 73};
74
75#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
76struct netns_nf_frag {
77 struct netns_sysctl_ipv6 sysctl;
78 struct netns_frags frags;
79};
80#endif
81
73#endif 82#endif
diff --git a/include/net/netns/packet.h b/include/net/netns/packet.h
index cb4e894c0f8..17ec2b95c06 100644
--- a/include/net/netns/packet.h
+++ b/include/net/netns/packet.h
@@ -5,10 +5,10 @@
5#define __NETNS_PACKET_H__ 5#define __NETNS_PACKET_H__
6 6
7#include <linux/rculist.h> 7#include <linux/rculist.h>
8#include <linux/spinlock.h> 8#include <linux/mutex.h>
9 9
10struct netns_packet { 10struct netns_packet {
11 spinlock_t sklist_lock; 11 struct mutex sklist_lock;
12 struct hlist_head sklist; 12 struct hlist_head sklist;
13}; 13};
14 14
diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
new file mode 100644
index 00000000000..5e5eb1f9f14
--- /dev/null
+++ b/include/net/netns/sctp.h
@@ -0,0 +1,131 @@
1#ifndef __NETNS_SCTP_H__
2#define __NETNS_SCTP_H__
3
4struct sock;
5struct proc_dir_entry;
6struct sctp_mib;
7struct ctl_table_header;
8
9struct netns_sctp {
10 DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics);
11
12#ifdef CONFIG_PROC_FS
13 struct proc_dir_entry *proc_net_sctp;
14#endif
15#ifdef CONFIG_SYSCTL
16 struct ctl_table_header *sysctl_header;
17#endif
18 /* This is the global socket data structure used for responding to
19 * the Out-of-the-blue (OOTB) packets. A control sock will be created
20 * for this socket at the initialization time.
21 */
22 struct sock *ctl_sock;
23
24 /* This is the global local address list.
25 * We actively maintain this complete list of addresses on
26 * the system by catching address add/delete events.
27 *
28 * It is a list of sctp_sockaddr_entry.
29 */
30 struct list_head local_addr_list;
31 struct list_head addr_waitq;
32 struct timer_list addr_wq_timer;
33 struct list_head auto_asconf_splist;
34 spinlock_t addr_wq_lock;
35
36 /* Lock that protects the local_addr_list writers */
37 spinlock_t local_addr_lock;
38
39 /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
40 *
41 * The following protocol parameters are RECOMMENDED:
42 *
43 * RTO.Initial - 3 seconds
44 * RTO.Min - 1 second
45 * RTO.Max - 60 seconds
46 * RTO.Alpha - 1/8 (3 when converted to right shifts.)
47 * RTO.Beta - 1/4 (2 when converted to right shifts.)
48 */
49 unsigned int rto_initial;
50 unsigned int rto_min;
51 unsigned int rto_max;
52
53 /* Note: rto_alpha and rto_beta are really defined as inverse
54 * powers of two to facilitate integer operations.
55 */
56 int rto_alpha;
57 int rto_beta;
58
59 /* Max.Burst - 4 */
60 int max_burst;
61
62 /* Whether Cookie Preservative is enabled(1) or not(0) */
63 int cookie_preserve_enable;
64
65 /* Valid.Cookie.Life - 60 seconds */
66 unsigned int valid_cookie_life;
67
68 /* Delayed SACK timeout 200ms default*/
69 unsigned int sack_timeout;
70
71 /* HB.interval - 30 seconds */
72 unsigned int hb_interval;
73
74 /* Association.Max.Retrans - 10 attempts
75 * Path.Max.Retrans - 5 attempts (per destination address)
76 * Max.Init.Retransmits - 8 attempts
77 */
78 int max_retrans_association;
79 int max_retrans_path;
80 int max_retrans_init;
81 /* Potentially-Failed.Max.Retrans sysctl value
82 * taken from:
83 * http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05
84 */
85 int pf_retrans;
86
87 /*
88 * Policy for preforming sctp/socket accounting
89 * 0 - do socket level accounting, all assocs share sk_sndbuf
90 * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
91 */
92 int sndbuf_policy;
93
94 /*
95 * Policy for preforming sctp/socket accounting
96 * 0 - do socket level accounting, all assocs share sk_rcvbuf
97 * 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes
98 */
99 int rcvbuf_policy;
100
101 int default_auto_asconf;
102
103 /* Flag to indicate if addip is enabled. */
104 int addip_enable;
105 int addip_noauth;
106
107 /* Flag to indicate if PR-SCTP is enabled. */
108 int prsctp_enable;
109
110 /* Flag to idicate if SCTP-AUTH is enabled */
111 int auth_enable;
112
113 /*
114 * Policy to control SCTP IPv4 address scoping
115 * 0 - Disable IPv4 address scoping
116 * 1 - Enable IPv4 address scoping
117 * 2 - Selectively allow only IPv4 private addresses
118 * 3 - Selectively allow only IPv4 link local address
119 */
120 int scope_policy;
121
122 /* Threshold for rwnd update SACKS. Receive buffer shifted this many
123 * bits is an indicator of when to send and window update SACK.
124 */
125 int rwnd_upd_shift;
126
127 /* Threshold for autoclose timeout, in seconds. */
128 unsigned long max_autoclose;
129};
130
131#endif /* __NETNS_SCTP_H__ */
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h
index f5169b04f08..e900072950c 100644
--- a/include/net/nfc/hci.h
+++ b/include/net/nfc/hci.h
@@ -30,6 +30,11 @@ struct nfc_hci_ops {
30 int (*open) (struct nfc_hci_dev *hdev); 30 int (*open) (struct nfc_hci_dev *hdev);
31 void (*close) (struct nfc_hci_dev *hdev); 31 void (*close) (struct nfc_hci_dev *hdev);
32 int (*hci_ready) (struct nfc_hci_dev *hdev); 32 int (*hci_ready) (struct nfc_hci_dev *hdev);
33 /*
34 * xmit must always send the complete buffer before
35 * returning. Returned result must be 0 for success
36 * or negative for failure.
37 */
33 int (*xmit) (struct nfc_hci_dev *hdev, struct sk_buff *skb); 38 int (*xmit) (struct nfc_hci_dev *hdev, struct sk_buff *skb);
34 int (*start_poll) (struct nfc_hci_dev *hdev, 39 int (*start_poll) (struct nfc_hci_dev *hdev,
35 u32 im_protocols, u32 tm_protocols); 40 u32 im_protocols, u32 tm_protocols);
@@ -38,8 +43,8 @@ struct nfc_hci_ops {
38 int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate, 43 int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate,
39 struct nfc_target *target); 44 struct nfc_target *target);
40 int (*data_exchange) (struct nfc_hci_dev *hdev, 45 int (*data_exchange) (struct nfc_hci_dev *hdev,
41 struct nfc_target *target, 46 struct nfc_target *target, struct sk_buff *skb,
42 struct sk_buff *skb, struct sk_buff **res_skb); 47 data_exchange_cb_t cb, void *cb_context);
43 int (*check_presence)(struct nfc_hci_dev *hdev, 48 int (*check_presence)(struct nfc_hci_dev *hdev,
44 struct nfc_target *target); 49 struct nfc_target *target);
45}; 50};
@@ -74,7 +79,6 @@ struct nfc_hci_dev {
74 79
75 struct list_head msg_tx_queue; 80 struct list_head msg_tx_queue;
76 81
77 struct workqueue_struct *msg_tx_wq;
78 struct work_struct msg_tx_work; 82 struct work_struct msg_tx_work;
79 83
80 struct timer_list cmd_timer; 84 struct timer_list cmd_timer;
@@ -82,13 +86,14 @@ struct nfc_hci_dev {
82 86
83 struct sk_buff_head rx_hcp_frags; 87 struct sk_buff_head rx_hcp_frags;
84 88
85 struct workqueue_struct *msg_rx_wq;
86 struct work_struct msg_rx_work; 89 struct work_struct msg_rx_work;
87 90
88 struct sk_buff_head msg_rx_queue; 91 struct sk_buff_head msg_rx_queue;
89 92
90 struct nfc_hci_ops *ops; 93 struct nfc_hci_ops *ops;
91 94
95 struct nfc_llc *llc;
96
92 struct nfc_hci_init_data init_data; 97 struct nfc_hci_init_data init_data;
93 98
94 void *clientdata; 99 void *clientdata;
@@ -105,12 +110,17 @@ struct nfc_hci_dev {
105 u8 hw_mpw; 110 u8 hw_mpw;
106 u8 hw_software; 111 u8 hw_software;
107 u8 hw_bsid; 112 u8 hw_bsid;
113
114 int async_cb_type;
115 data_exchange_cb_t async_cb;
116 void *async_cb_context;
108}; 117};
109 118
110/* hci device allocation */ 119/* hci device allocation */
111struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, 120struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops,
112 struct nfc_hci_init_data *init_data, 121 struct nfc_hci_init_data *init_data,
113 u32 protocols, 122 u32 protocols,
123 const char *llc_name,
114 int tx_headroom, 124 int tx_headroom,
115 int tx_tailroom, 125 int tx_tailroom,
116 int max_link_payload); 126 int max_link_payload);
@@ -202,6 +212,9 @@ int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx,
202 const u8 *param, size_t param_len); 212 const u8 *param, size_t param_len);
203int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, 213int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
204 const u8 *param, size_t param_len, struct sk_buff **skb); 214 const u8 *param, size_t param_len, struct sk_buff **skb);
215int nfc_hci_send_cmd_async(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
216 const u8 *param, size_t param_len,
217 data_exchange_cb_t cb, void *cb_context);
205int nfc_hci_send_response(struct nfc_hci_dev *hdev, u8 gate, u8 response, 218int nfc_hci_send_response(struct nfc_hci_dev *hdev, u8 gate, u8 response,
206 const u8 *param, size_t param_len); 219 const u8 *param, size_t param_len);
207int nfc_hci_send_event(struct nfc_hci_dev *hdev, u8 gate, u8 event, 220int nfc_hci_send_event(struct nfc_hci_dev *hdev, u8 gate, u8 event,
diff --git a/include/net/nfc/llc.h b/include/net/nfc/llc.h
new file mode 100644
index 00000000000..400ab7ae749
--- /dev/null
+++ b/include/net/nfc/llc.h
@@ -0,0 +1,54 @@
1/*
2 * Link Layer Control manager public interface
3 *
4 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#ifndef __NFC_LLC_H_
22#define __NFC_LLC_H_
23
24#include <net/nfc/hci.h>
25#include <linux/skbuff.h>
26
27#define LLC_NOP_NAME "nop"
28#define LLC_SHDLC_NAME "shdlc"
29
30typedef void (*rcv_to_hci_t) (struct nfc_hci_dev *hdev, struct sk_buff *skb);
31typedef int (*xmit_to_drv_t) (struct nfc_hci_dev *hdev, struct sk_buff *skb);
32typedef void (*llc_failure_t) (struct nfc_hci_dev *hdev, int err);
33
34struct nfc_llc;
35
36struct nfc_llc *nfc_llc_allocate(const char *name, struct nfc_hci_dev *hdev,
37 xmit_to_drv_t xmit_to_drv,
38 rcv_to_hci_t rcv_to_hci, int tx_headroom,
39 int tx_tailroom, llc_failure_t llc_failure);
40void nfc_llc_free(struct nfc_llc *llc);
41
42void nfc_llc_get_rx_head_tail_room(struct nfc_llc *llc, int *rx_headroom,
43 int *rx_tailroom);
44
45
46int nfc_llc_start(struct nfc_llc *llc);
47int nfc_llc_stop(struct nfc_llc *llc);
48void nfc_llc_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb);
49int nfc_llc_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb);
50
51int nfc_llc_init(void);
52void nfc_llc_exit(void);
53
54#endif /* __NFC_LLC_H_ */
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h
index 276094b91d7..88785e5c6b2 100644
--- a/include/net/nfc/nci.h
+++ b/include/net/nfc/nci.h
@@ -32,6 +32,7 @@
32#define NCI_MAX_NUM_MAPPING_CONFIGS 10 32#define NCI_MAX_NUM_MAPPING_CONFIGS 10
33#define NCI_MAX_NUM_RF_CONFIGS 10 33#define NCI_MAX_NUM_RF_CONFIGS 10
34#define NCI_MAX_NUM_CONN 10 34#define NCI_MAX_NUM_CONN 10
35#define NCI_MAX_PARAM_LEN 251
35 36
36/* NCI Status Codes */ 37/* NCI Status Codes */
37#define NCI_STATUS_OK 0x00 38#define NCI_STATUS_OK 0x00
@@ -102,6 +103,9 @@
102#define NCI_RF_INTERFACE_ISO_DEP 0x02 103#define NCI_RF_INTERFACE_ISO_DEP 0x02
103#define NCI_RF_INTERFACE_NFC_DEP 0x03 104#define NCI_RF_INTERFACE_NFC_DEP 0x03
104 105
106/* NCI Configuration Parameter Tags */
107#define NCI_PN_ATR_REQ_GEN_BYTES 0x29
108
105/* NCI Reset types */ 109/* NCI Reset types */
106#define NCI_RESET_TYPE_KEEP_CONFIG 0x00 110#define NCI_RESET_TYPE_KEEP_CONFIG 0x00
107#define NCI_RESET_TYPE_RESET_CONFIG 0x01 111#define NCI_RESET_TYPE_RESET_CONFIG 0x01
@@ -188,6 +192,18 @@ struct nci_core_reset_cmd {
188 192
189#define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) 193#define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01)
190 194
195#define NCI_OP_CORE_SET_CONFIG_CMD nci_opcode_pack(NCI_GID_CORE, 0x02)
196struct set_config_param {
197 __u8 id;
198 __u8 len;
199 __u8 val[NCI_MAX_PARAM_LEN];
200} __packed;
201
202struct nci_core_set_config_cmd {
203 __u8 num_params;
204 struct set_config_param param; /* support 1 param per cmd is enough */
205} __packed;
206
191#define NCI_OP_RF_DISCOVER_MAP_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) 207#define NCI_OP_RF_DISCOVER_MAP_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x00)
192struct disc_map_config { 208struct disc_map_config {
193 __u8 rf_protocol; 209 __u8 rf_protocol;
@@ -252,6 +268,13 @@ struct nci_core_init_rsp_2 {
252 __le32 manufact_specific_info; 268 __le32 manufact_specific_info;
253} __packed; 269} __packed;
254 270
271#define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02)
272struct nci_core_set_config_rsp {
273 __u8 status;
274 __u8 num_params;
275 __u8 params_id[0]; /* variable size array */
276} __packed;
277
255#define NCI_OP_RF_DISCOVER_MAP_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) 278#define NCI_OP_RF_DISCOVER_MAP_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x00)
256 279
257#define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) 280#define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
@@ -328,6 +351,11 @@ struct activation_params_nfcb_poll_iso_dep {
328 __u8 attrib_res[50]; 351 __u8 attrib_res[50];
329}; 352};
330 353
354struct activation_params_poll_nfc_dep {
355 __u8 atr_res_len;
356 __u8 atr_res[63];
357};
358
331struct nci_rf_intf_activated_ntf { 359struct nci_rf_intf_activated_ntf {
332 __u8 rf_discovery_id; 360 __u8 rf_discovery_id;
333 __u8 rf_interface; 361 __u8 rf_interface;
@@ -351,6 +379,7 @@ struct nci_rf_intf_activated_ntf {
351 union { 379 union {
352 struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep; 380 struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep;
353 struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep; 381 struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep;
382 struct activation_params_poll_nfc_dep poll_nfc_dep;
354 } activation_params; 383 } activation_params;
355 384
356} __packed; 385} __packed;
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index feba74027ff..d705d867494 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -54,6 +54,7 @@ enum nci_state {
54/* NCI timeouts */ 54/* NCI timeouts */
55#define NCI_RESET_TIMEOUT 5000 55#define NCI_RESET_TIMEOUT 5000
56#define NCI_INIT_TIMEOUT 5000 56#define NCI_INIT_TIMEOUT 5000
57#define NCI_SET_CONFIG_TIMEOUT 5000
57#define NCI_RF_DISC_TIMEOUT 5000 58#define NCI_RF_DISC_TIMEOUT 5000
58#define NCI_RF_DISC_SELECT_TIMEOUT 5000 59#define NCI_RF_DISC_SELECT_TIMEOUT 5000
59#define NCI_RF_DEACTIVATE_TIMEOUT 30000 60#define NCI_RF_DEACTIVATE_TIMEOUT 30000
@@ -137,6 +138,10 @@ struct nci_dev {
137 data_exchange_cb_t data_exchange_cb; 138 data_exchange_cb_t data_exchange_cb;
138 void *data_exchange_cb_context; 139 void *data_exchange_cb_context;
139 struct sk_buff *rx_data_reassembly; 140 struct sk_buff *rx_data_reassembly;
141
142 /* stored during intf_activated_ntf */
143 __u8 remote_gb[NFC_MAX_GT_LEN];
144 __u8 remote_gb_len;
140}; 145};
141 146
142/* ----- NCI Devices ----- */ 147/* ----- NCI Devices ----- */
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 6431f5e3902..f05b10682c9 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -72,6 +72,7 @@ struct nfc_ops {
72 72
73#define NFC_TARGET_IDX_ANY -1 73#define NFC_TARGET_IDX_ANY -1
74#define NFC_MAX_GT_LEN 48 74#define NFC_MAX_GT_LEN 48
75#define NFC_ATR_RES_GT_OFFSET 15
75 76
76struct nfc_target { 77struct nfc_target {
77 u32 idx; 78 u32 idx;
@@ -89,7 +90,7 @@ struct nfc_target {
89}; 90};
90 91
91struct nfc_genl_data { 92struct nfc_genl_data {
92 u32 poll_req_pid; 93 u32 poll_req_portid;
93 struct mutex genl_data_mutex; 94 struct mutex genl_data_mutex;
94}; 95};
95 96
@@ -112,7 +113,6 @@ struct nfc_dev {
112 int tx_tailroom; 113 int tx_tailroom;
113 114
114 struct timer_list check_pres_timer; 115 struct timer_list check_pres_timer;
115 struct workqueue_struct *check_pres_wq;
116 struct work_struct check_pres_work; 116 struct work_struct check_pres_work;
117 117
118 struct nfc_ops *ops; 118 struct nfc_ops *ops;
diff --git a/include/net/nfc/shdlc.h b/include/net/nfc/shdlc.h
deleted file mode 100644
index 35e930d2f63..00000000000
--- a/include/net/nfc/shdlc.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#ifndef __NFC_SHDLC_H
21#define __NFC_SHDLC_H
22
23struct nfc_shdlc;
24
25struct nfc_shdlc_ops {
26 int (*open) (struct nfc_shdlc *shdlc);
27 void (*close) (struct nfc_shdlc *shdlc);
28 int (*hci_ready) (struct nfc_shdlc *shdlc);
29 int (*xmit) (struct nfc_shdlc *shdlc, struct sk_buff *skb);
30 int (*start_poll) (struct nfc_shdlc *shdlc,
31 u32 im_protocols, u32 tm_protocols);
32 int (*target_from_gate) (struct nfc_shdlc *shdlc, u8 gate,
33 struct nfc_target *target);
34 int (*complete_target_discovered) (struct nfc_shdlc *shdlc, u8 gate,
35 struct nfc_target *target);
36 int (*data_exchange) (struct nfc_shdlc *shdlc,
37 struct nfc_target *target,
38 struct sk_buff *skb, struct sk_buff **res_skb);
39 int (*check_presence)(struct nfc_shdlc *shdlc,
40 struct nfc_target *target);
41};
42
43enum shdlc_state {
44 SHDLC_DISCONNECTED = 0,
45 SHDLC_CONNECTING = 1,
46 SHDLC_NEGOCIATING = 2,
47 SHDLC_CONNECTED = 3
48};
49
50struct nfc_shdlc {
51 struct mutex state_mutex;
52 enum shdlc_state state;
53 int hard_fault;
54
55 struct nfc_hci_dev *hdev;
56
57 wait_queue_head_t *connect_wq;
58 int connect_tries;
59 int connect_result;
60 struct timer_list connect_timer;/* aka T3 in spec 10.6.1 */
61
62 u8 w; /* window size */
63 bool srej_support;
64
65 struct timer_list t1_timer; /* send ack timeout */
66 bool t1_active;
67
68 struct timer_list t2_timer; /* guard/retransmit timeout */
69 bool t2_active;
70
71 int ns; /* next seq num for send */
72 int nr; /* next expected seq num for receive */
73 int dnr; /* oldest sent unacked seq num */
74
75 struct sk_buff_head rcv_q;
76
77 struct sk_buff_head send_q;
78 bool rnr; /* other side is not ready to receive */
79
80 struct sk_buff_head ack_pending_q;
81
82 struct workqueue_struct *sm_wq;
83 struct work_struct sm_work;
84
85 struct nfc_shdlc_ops *ops;
86
87 int client_headroom;
88 int client_tailroom;
89
90 void *clientdata;
91};
92
93void nfc_shdlc_recv_frame(struct nfc_shdlc *shdlc, struct sk_buff *skb);
94
95struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,
96 struct nfc_hci_init_data *init_data,
97 u32 protocols,
98 int tx_headroom, int tx_tailroom,
99 int max_link_payload, const char *devname);
100
101void nfc_shdlc_free(struct nfc_shdlc *shdlc);
102
103void nfc_shdlc_set_clientdata(struct nfc_shdlc *shdlc, void *clientdata);
104void *nfc_shdlc_get_clientdata(struct nfc_shdlc *shdlc);
105struct nfc_hci_dev *nfc_shdlc_get_hci_dev(struct nfc_shdlc *shdlc);
106
107#endif /* __NFC_SHDLC_H */
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 4c0766e201e..b01d8dd9ee7 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -106,6 +106,34 @@ struct listen_sock {
106 struct request_sock *syn_table[0]; 106 struct request_sock *syn_table[0];
107}; 107};
108 108
109/*
110 * For a TCP Fast Open listener -
111 * lock - protects the access to all the reqsk, which is co-owned by
112 * the listener and the child socket.
113 * qlen - pending TFO requests (still in TCP_SYN_RECV).
114 * max_qlen - max TFO reqs allowed before TFO is disabled.
115 *
116 * XXX (TFO) - ideally these fields can be made as part of "listen_sock"
117 * structure above. But there is some implementation difficulty due to
118 * listen_sock being part of request_sock_queue hence will be freed when
119 * a listener is stopped. But TFO related fields may continue to be
120 * accessed even after a listener is closed, until its sk_refcnt drops
121 * to 0 implying no more outstanding TFO reqs. One solution is to keep
122 * listen_opt around until sk_refcnt drops to 0. But there is some other
123 * complexity that needs to be resolved. E.g., a listener can be disabled
124 * temporarily through shutdown()->tcp_disconnect(), and re-enabled later.
125 */
126struct fastopen_queue {
127 struct request_sock *rskq_rst_head; /* Keep track of past TFO */
128 struct request_sock *rskq_rst_tail; /* requests that caused RST.
129 * This is part of the defense
130 * against spoofing attack.
131 */
132 spinlock_t lock;
133 int qlen; /* # of pending (TCP_SYN_RECV) reqs */
134 int max_qlen; /* != 0 iff TFO is currently enabled */
135};
136
109/** struct request_sock_queue - queue of request_socks 137/** struct request_sock_queue - queue of request_socks
110 * 138 *
111 * @rskq_accept_head - FIFO head of established children 139 * @rskq_accept_head - FIFO head of established children
@@ -129,6 +157,12 @@ struct request_sock_queue {
129 u8 rskq_defer_accept; 157 u8 rskq_defer_accept;
130 /* 3 bytes hole, try to pack */ 158 /* 3 bytes hole, try to pack */
131 struct listen_sock *listen_opt; 159 struct listen_sock *listen_opt;
160 struct fastopen_queue *fastopenq; /* This is non-NULL iff TFO has been
161 * enabled on this listener. Check
162 * max_qlen != 0 in fastopen_queue
163 * to determine if TFO is enabled
164 * right at this moment.
165 */
132}; 166};
133 167
134extern int reqsk_queue_alloc(struct request_sock_queue *queue, 168extern int reqsk_queue_alloc(struct request_sock_queue *queue,
@@ -136,6 +170,8 @@ extern int reqsk_queue_alloc(struct request_sock_queue *queue,
136 170
137extern void __reqsk_queue_destroy(struct request_sock_queue *queue); 171extern void __reqsk_queue_destroy(struct request_sock_queue *queue);
138extern void reqsk_queue_destroy(struct request_sock_queue *queue); 172extern void reqsk_queue_destroy(struct request_sock_queue *queue);
173extern void reqsk_fastopen_remove(struct sock *sk,
174 struct request_sock *req, bool reset);
139 175
140static inline struct request_sock * 176static inline struct request_sock *
141 reqsk_queue_yank_acceptq(struct request_sock_queue *queue) 177 reqsk_queue_yank_acceptq(struct request_sock_queue *queue)
@@ -190,19 +226,6 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue
190 return req; 226 return req;
191} 227}
192 228
193static inline struct sock *reqsk_queue_get_child(struct request_sock_queue *queue,
194 struct sock *parent)
195{
196 struct request_sock *req = reqsk_queue_remove(queue);
197 struct sock *child = req->sk;
198
199 WARN_ON(child == NULL);
200
201 sk_acceptq_removed(parent);
202 __reqsk_free(req);
203 return child;
204}
205
206static inline int reqsk_queue_removed(struct request_sock_queue *queue, 229static inline int reqsk_queue_removed(struct request_sock_queue *queue,
207 struct request_sock *req) 230 struct request_sock *req)
208{ 231{
diff --git a/include/net/scm.h b/include/net/scm.h
index 7dc0854f0b3..975cca01048 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -12,6 +12,12 @@
12 */ 12 */
13#define SCM_MAX_FD 253 13#define SCM_MAX_FD 253
14 14
15struct scm_creds {
16 u32 pid;
17 kuid_t uid;
18 kgid_t gid;
19};
20
15struct scm_fp_list { 21struct scm_fp_list {
16 short count; 22 short count;
17 short max; 23 short max;
@@ -22,7 +28,7 @@ struct scm_cookie {
22 struct pid *pid; /* Skb credentials */ 28 struct pid *pid; /* Skb credentials */
23 const struct cred *cred; 29 const struct cred *cred;
24 struct scm_fp_list *fp; /* Passed files */ 30 struct scm_fp_list *fp; /* Passed files */
25 struct ucred creds; /* Skb credentials */ 31 struct scm_creds creds; /* Skb credentials */
26#ifdef CONFIG_SECURITY_NETWORK 32#ifdef CONFIG_SECURITY_NETWORK
27 u32 secid; /* Passed security ID */ 33 u32 secid; /* Passed security ID */
28#endif 34#endif
@@ -49,7 +55,9 @@ static __inline__ void scm_set_cred(struct scm_cookie *scm,
49{ 55{
50 scm->pid = get_pid(pid); 56 scm->pid = get_pid(pid);
51 scm->cred = cred ? get_cred(cred) : NULL; 57 scm->cred = cred ? get_cred(cred) : NULL;
52 cred_to_ucred(pid, cred, &scm->creds); 58 scm->creds.pid = pid_vnr(pid);
59 scm->creds.uid = cred ? cred->euid : INVALID_UID;
60 scm->creds.gid = cred ? cred->egid : INVALID_GID;
53} 61}
54 62
55static __inline__ void scm_destroy_cred(struct scm_cookie *scm) 63static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
@@ -65,7 +73,7 @@ static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
65static __inline__ void scm_destroy(struct scm_cookie *scm) 73static __inline__ void scm_destroy(struct scm_cookie *scm)
66{ 74{
67 scm_destroy_cred(scm); 75 scm_destroy_cred(scm);
68 if (scm && scm->fp) 76 if (scm->fp)
69 __scm_destroy(scm); 77 __scm_destroy(scm);
70} 78}
71 79
@@ -112,8 +120,15 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg,
112 return; 120 return;
113 } 121 }
114 122
115 if (test_bit(SOCK_PASSCRED, &sock->flags)) 123 if (test_bit(SOCK_PASSCRED, &sock->flags)) {
116 put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(scm->creds), &scm->creds); 124 struct user_namespace *current_ns = current_user_ns();
125 struct ucred ucreds = {
126 .pid = scm->creds.pid,
127 .uid = from_kuid_munged(current_ns, scm->creds.uid),
128 .gid = from_kgid_munged(current_ns, scm->creds.gid),
129 };
130 put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(ucreds), &ucreds);
131 }
117 132
118 scm_destroy_cred(scm); 133 scm_destroy_cred(scm);
119 134
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index ff499640528..9c6414f553f 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -114,13 +114,12 @@
114/* 114/*
115 * sctp/protocol.c 115 * sctp/protocol.c
116 */ 116 */
117extern struct sock *sctp_get_ctl_sock(void); 117extern int sctp_copy_local_addr_list(struct net *, struct sctp_bind_addr *,
118extern int sctp_copy_local_addr_list(struct sctp_bind_addr *,
119 sctp_scope_t, gfp_t gfp, 118 sctp_scope_t, gfp_t gfp,
120 int flags); 119 int flags);
121extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); 120extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
122extern int sctp_register_pf(struct sctp_pf *, sa_family_t); 121extern int sctp_register_pf(struct sctp_pf *, sa_family_t);
123extern void sctp_addr_wq_mgmt(struct sctp_sockaddr_entry *, int); 122extern void sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int);
124 123
125/* 124/*
126 * sctp/socket.c 125 * sctp/socket.c
@@ -140,12 +139,12 @@ extern int sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *);
140/* 139/*
141 * sctp/primitive.c 140 * sctp/primitive.c
142 */ 141 */
143int sctp_primitive_ASSOCIATE(struct sctp_association *, void *arg); 142int sctp_primitive_ASSOCIATE(struct net *, struct sctp_association *, void *arg);
144int sctp_primitive_SHUTDOWN(struct sctp_association *, void *arg); 143int sctp_primitive_SHUTDOWN(struct net *, struct sctp_association *, void *arg);
145int sctp_primitive_ABORT(struct sctp_association *, void *arg); 144int sctp_primitive_ABORT(struct net *, struct sctp_association *, void *arg);
146int sctp_primitive_SEND(struct sctp_association *, void *arg); 145int sctp_primitive_SEND(struct net *, struct sctp_association *, void *arg);
147int sctp_primitive_REQUESTHEARTBEAT(struct sctp_association *, void *arg); 146int sctp_primitive_REQUESTHEARTBEAT(struct net *, struct sctp_association *, void *arg);
148int sctp_primitive_ASCONF(struct sctp_association *, void *arg); 147int sctp_primitive_ASCONF(struct net *, struct sctp_association *, void *arg);
149 148
150/* 149/*
151 * sctp/input.c 150 * sctp/input.c
@@ -156,7 +155,7 @@ void sctp_hash_established(struct sctp_association *);
156void sctp_unhash_established(struct sctp_association *); 155void sctp_unhash_established(struct sctp_association *);
157void sctp_hash_endpoint(struct sctp_endpoint *); 156void sctp_hash_endpoint(struct sctp_endpoint *);
158void sctp_unhash_endpoint(struct sctp_endpoint *); 157void sctp_unhash_endpoint(struct sctp_endpoint *);
159struct sock *sctp_err_lookup(int family, struct sk_buff *, 158struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *,
160 struct sctphdr *, struct sctp_association **, 159 struct sctphdr *, struct sctp_association **,
161 struct sctp_transport **); 160 struct sctp_transport **);
162void sctp_err_finish(struct sock *, struct sctp_association *); 161void sctp_err_finish(struct sock *, struct sctp_association *);
@@ -173,14 +172,14 @@ void sctp_backlog_migrate(struct sctp_association *assoc,
173/* 172/*
174 * sctp/proc.c 173 * sctp/proc.c
175 */ 174 */
176int sctp_snmp_proc_init(void); 175int sctp_snmp_proc_init(struct net *net);
177void sctp_snmp_proc_exit(void); 176void sctp_snmp_proc_exit(struct net *net);
178int sctp_eps_proc_init(void); 177int sctp_eps_proc_init(struct net *net);
179void sctp_eps_proc_exit(void); 178void sctp_eps_proc_exit(struct net *net);
180int sctp_assocs_proc_init(void); 179int sctp_assocs_proc_init(struct net *net);
181void sctp_assocs_proc_exit(void); 180void sctp_assocs_proc_exit(struct net *net);
182int sctp_remaddr_proc_init(void); 181int sctp_remaddr_proc_init(struct net *net);
183void sctp_remaddr_proc_exit(void); 182void sctp_remaddr_proc_exit(struct net *net);
184 183
185 184
186/* 185/*
@@ -222,11 +221,10 @@ extern struct kmem_cache *sctp_bucket_cachep __read_mostly;
222#define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk) 221#define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk)
223 222
224/* SCTP SNMP MIB stats handlers */ 223/* SCTP SNMP MIB stats handlers */
225DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics); 224#define SCTP_INC_STATS(net, field) SNMP_INC_STATS((net)->sctp.sctp_statistics, field)
226#define SCTP_INC_STATS(field) SNMP_INC_STATS(sctp_statistics, field) 225#define SCTP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->sctp.sctp_statistics, field)
227#define SCTP_INC_STATS_BH(field) SNMP_INC_STATS_BH(sctp_statistics, field) 226#define SCTP_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->sctp.sctp_statistics, field)
228#define SCTP_INC_STATS_USER(field) SNMP_INC_STATS_USER(sctp_statistics, field) 227#define SCTP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->sctp.sctp_statistics, field)
229#define SCTP_DEC_STATS(field) SNMP_DEC_STATS(sctp_statistics, field)
230 228
231#endif /* !TEST_FRAME */ 229#endif /* !TEST_FRAME */
232 230
@@ -361,25 +359,29 @@ atomic_t sctp_dbg_objcnt_## name = ATOMIC_INIT(0)
361#define SCTP_DBG_OBJCNT_ENTRY(name) \ 359#define SCTP_DBG_OBJCNT_ENTRY(name) \
362{.label= #name, .counter= &sctp_dbg_objcnt_## name} 360{.label= #name, .counter= &sctp_dbg_objcnt_## name}
363 361
364void sctp_dbg_objcnt_init(void); 362void sctp_dbg_objcnt_init(struct net *);
365void sctp_dbg_objcnt_exit(void); 363void sctp_dbg_objcnt_exit(struct net *);
366 364
367#else 365#else
368 366
369#define SCTP_DBG_OBJCNT_INC(name) 367#define SCTP_DBG_OBJCNT_INC(name)
370#define SCTP_DBG_OBJCNT_DEC(name) 368#define SCTP_DBG_OBJCNT_DEC(name)
371 369
372static inline void sctp_dbg_objcnt_init(void) { return; } 370static inline void sctp_dbg_objcnt_init(struct net *net) { return; }
373static inline void sctp_dbg_objcnt_exit(void) { return; } 371static inline void sctp_dbg_objcnt_exit(struct net *net) { return; }
374 372
375#endif /* CONFIG_SCTP_DBG_OBJCOUNT */ 373#endif /* CONFIG_SCTP_DBG_OBJCOUNT */
376 374
377#if defined CONFIG_SYSCTL 375#if defined CONFIG_SYSCTL
378void sctp_sysctl_register(void); 376void sctp_sysctl_register(void);
379void sctp_sysctl_unregister(void); 377void sctp_sysctl_unregister(void);
378int sctp_sysctl_net_register(struct net *net);
379void sctp_sysctl_net_unregister(struct net *net);
380#else 380#else
381static inline void sctp_sysctl_register(void) { return; } 381static inline void sctp_sysctl_register(void) { return; }
382static inline void sctp_sysctl_unregister(void) { return; } 382static inline void sctp_sysctl_unregister(void) { return; }
383static inline int sctp_sysctl_net_register(struct net *net) { return 0; }
384static inline void sctp_sysctl_net_unregister(struct net *net) { return; }
383#endif 385#endif
384 386
385/* Size of Supported Address Parameter for 'x' address types. */ 387/* Size of Supported Address Parameter for 'x' address types. */
@@ -586,7 +588,6 @@ for (pos = chunk->subh.fwdtsn_hdr->skip;\
586 588
587extern struct proto sctp_prot; 589extern struct proto sctp_prot;
588extern struct proto sctpv6_prot; 590extern struct proto sctpv6_prot;
589extern struct proc_dir_entry *proc_net_sctp;
590void sctp_put_port(struct sock *sk); 591void sctp_put_port(struct sock *sk);
591 592
592extern struct idr sctp_assocs_id; 593extern struct idr sctp_assocs_id;
@@ -632,21 +633,21 @@ static inline int sctp_sanity_check(void)
632 633
633/* Warning: The following hash functions assume a power of two 'size'. */ 634/* Warning: The following hash functions assume a power of two 'size'. */
634/* This is the hash function for the SCTP port hash table. */ 635/* This is the hash function for the SCTP port hash table. */
635static inline int sctp_phashfn(__u16 lport) 636static inline int sctp_phashfn(struct net *net, __u16 lport)
636{ 637{
637 return lport & (sctp_port_hashsize - 1); 638 return (net_hash_mix(net) + lport) & (sctp_port_hashsize - 1);
638} 639}
639 640
640/* This is the hash function for the endpoint hash table. */ 641/* This is the hash function for the endpoint hash table. */
641static inline int sctp_ep_hashfn(__u16 lport) 642static inline int sctp_ep_hashfn(struct net *net, __u16 lport)
642{ 643{
643 return lport & (sctp_ep_hashsize - 1); 644 return (net_hash_mix(net) + lport) & (sctp_ep_hashsize - 1);
644} 645}
645 646
646/* This is the hash function for the association hash table. */ 647/* This is the hash function for the association hash table. */
647static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport) 648static inline int sctp_assoc_hashfn(struct net *net, __u16 lport, __u16 rport)
648{ 649{
649 int h = (lport << 16) + rport; 650 int h = (lport << 16) + rport + net_hash_mix(net);
650 h ^= h>>8; 651 h ^= h>>8;
651 return h & (sctp_assoc_hashsize - 1); 652 return h & (sctp_assoc_hashsize - 1);
652} 653}
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 9148632b820..b5887e1677e 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -77,7 +77,8 @@ typedef struct {
77 int action; 77 int action;
78} sctp_sm_command_t; 78} sctp_sm_command_t;
79 79
80typedef sctp_disposition_t (sctp_state_fn_t) (const struct sctp_endpoint *, 80typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,
81 const struct sctp_endpoint *,
81 const struct sctp_association *, 82 const struct sctp_association *,
82 const sctp_subtype_t type, 83 const sctp_subtype_t type,
83 void *arg, 84 void *arg,
@@ -178,7 +179,8 @@ sctp_state_fn_t sctp_sf_autoclose_timer_expire;
178 179
179/* Prototypes for utility support functions. */ 180/* Prototypes for utility support functions. */
180__u8 sctp_get_chunk_type(struct sctp_chunk *chunk); 181__u8 sctp_get_chunk_type(struct sctp_chunk *chunk);
181const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t, 182const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *,
183 sctp_event_t,
182 sctp_state_t, 184 sctp_state_t,
183 sctp_subtype_t); 185 sctp_subtype_t);
184int sctp_chunk_iif(const struct sctp_chunk *); 186int sctp_chunk_iif(const struct sctp_chunk *);
@@ -268,7 +270,7 @@ void sctp_chunk_assign_ssn(struct sctp_chunk *);
268 270
269/* Prototypes for statetable processing. */ 271/* Prototypes for statetable processing. */
270 272
271int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, 273int sctp_do_sm(struct net *net, sctp_event_t event_type, sctp_subtype_t subtype,
272 sctp_state_t state, 274 sctp_state_t state,
273 struct sctp_endpoint *, 275 struct sctp_endpoint *,
274 struct sctp_association *asoc, 276 struct sctp_association *asoc,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index fc5e60016e3..0fef00f5d3c 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -102,6 +102,7 @@ struct sctp_bind_bucket {
102 unsigned short fastreuse; 102 unsigned short fastreuse;
103 struct hlist_node node; 103 struct hlist_node node;
104 struct hlist_head owner; 104 struct hlist_head owner;
105 struct net *net;
105}; 106};
106 107
107struct sctp_bind_hashbucket { 108struct sctp_bind_hashbucket {
@@ -118,69 +119,6 @@ struct sctp_hashbucket {
118 119
119/* The SCTP globals structure. */ 120/* The SCTP globals structure. */
120extern struct sctp_globals { 121extern struct sctp_globals {
121 /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
122 *
123 * The following protocol parameters are RECOMMENDED:
124 *
125 * RTO.Initial - 3 seconds
126 * RTO.Min - 1 second
127 * RTO.Max - 60 seconds
128 * RTO.Alpha - 1/8 (3 when converted to right shifts.)
129 * RTO.Beta - 1/4 (2 when converted to right shifts.)
130 */
131 unsigned int rto_initial;
132 unsigned int rto_min;
133 unsigned int rto_max;
134
135 /* Note: rto_alpha and rto_beta are really defined as inverse
136 * powers of two to facilitate integer operations.
137 */
138 int rto_alpha;
139 int rto_beta;
140
141 /* Max.Burst - 4 */
142 int max_burst;
143
144 /* Whether Cookie Preservative is enabled(1) or not(0) */
145 int cookie_preserve_enable;
146
147 /* Valid.Cookie.Life - 60 seconds */
148 unsigned int valid_cookie_life;
149
150 /* Delayed SACK timeout 200ms default*/
151 unsigned int sack_timeout;
152
153 /* HB.interval - 30 seconds */
154 unsigned int hb_interval;
155
156 /* Association.Max.Retrans - 10 attempts
157 * Path.Max.Retrans - 5 attempts (per destination address)
158 * Max.Init.Retransmits - 8 attempts
159 */
160 int max_retrans_association;
161 int max_retrans_path;
162 int max_retrans_init;
163
164 /* Potentially-Failed.Max.Retrans sysctl value
165 * taken from:
166 * http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05
167 */
168 int pf_retrans;
169
170 /*
171 * Policy for preforming sctp/socket accounting
172 * 0 - do socket level accounting, all assocs share sk_sndbuf
173 * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
174 */
175 int sndbuf_policy;
176
177 /*
178 * Policy for preforming sctp/socket accounting
179 * 0 - do socket level accounting, all assocs share sk_rcvbuf
180 * 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes
181 */
182 int rcvbuf_policy;
183
184 /* The following variables are implementation specific. */ 122 /* The following variables are implementation specific. */
185 123
186 /* Default initialization values to be applied to new associations. */ 124 /* Default initialization values to be applied to new associations. */
@@ -204,70 +142,11 @@ extern struct sctp_globals {
204 int port_hashsize; 142 int port_hashsize;
205 struct sctp_bind_hashbucket *port_hashtable; 143 struct sctp_bind_hashbucket *port_hashtable;
206 144
207 /* This is the global local address list.
208 * We actively maintain this complete list of addresses on
209 * the system by catching address add/delete events.
210 *
211 * It is a list of sctp_sockaddr_entry.
212 */
213 struct list_head local_addr_list;
214 int default_auto_asconf;
215 struct list_head addr_waitq;
216 struct timer_list addr_wq_timer;
217 struct list_head auto_asconf_splist;
218 spinlock_t addr_wq_lock;
219
220 /* Lock that protects the local_addr_list writers */
221 spinlock_t addr_list_lock;
222
223 /* Flag to indicate if addip is enabled. */
224 int addip_enable;
225 int addip_noauth_enable;
226
227 /* Flag to indicate if PR-SCTP is enabled. */
228 int prsctp_enable;
229
230 /* Flag to idicate if SCTP-AUTH is enabled */
231 int auth_enable;
232
233 /*
234 * Policy to control SCTP IPv4 address scoping
235 * 0 - Disable IPv4 address scoping
236 * 1 - Enable IPv4 address scoping
237 * 2 - Selectively allow only IPv4 private addresses
238 * 3 - Selectively allow only IPv4 link local address
239 */
240 int ipv4_scope_policy;
241
242 /* Flag to indicate whether computing and verifying checksum 145 /* Flag to indicate whether computing and verifying checksum
243 * is disabled. */ 146 * is disabled. */
244 bool checksum_disable; 147 bool checksum_disable;
245
246 /* Threshold for rwnd update SACKS. Receive buffer shifted this many
247 * bits is an indicator of when to send and window update SACK.
248 */
249 int rwnd_update_shift;
250
251 /* Threshold for autoclose timeout, in seconds. */
252 unsigned long max_autoclose;
253} sctp_globals; 148} sctp_globals;
254 149
255#define sctp_rto_initial (sctp_globals.rto_initial)
256#define sctp_rto_min (sctp_globals.rto_min)
257#define sctp_rto_max (sctp_globals.rto_max)
258#define sctp_rto_alpha (sctp_globals.rto_alpha)
259#define sctp_rto_beta (sctp_globals.rto_beta)
260#define sctp_max_burst (sctp_globals.max_burst)
261#define sctp_valid_cookie_life (sctp_globals.valid_cookie_life)
262#define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable)
263#define sctp_max_retrans_association (sctp_globals.max_retrans_association)
264#define sctp_sndbuf_policy (sctp_globals.sndbuf_policy)
265#define sctp_rcvbuf_policy (sctp_globals.rcvbuf_policy)
266#define sctp_max_retrans_path (sctp_globals.max_retrans_path)
267#define sctp_pf_retrans (sctp_globals.pf_retrans)
268#define sctp_max_retrans_init (sctp_globals.max_retrans_init)
269#define sctp_sack_timeout (sctp_globals.sack_timeout)
270#define sctp_hb_interval (sctp_globals.hb_interval)
271#define sctp_max_instreams (sctp_globals.max_instreams) 150#define sctp_max_instreams (sctp_globals.max_instreams)
272#define sctp_max_outstreams (sctp_globals.max_outstreams) 151#define sctp_max_outstreams (sctp_globals.max_outstreams)
273#define sctp_address_families (sctp_globals.address_families) 152#define sctp_address_families (sctp_globals.address_families)
@@ -277,21 +156,7 @@ extern struct sctp_globals {
277#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) 156#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
278#define sctp_port_hashsize (sctp_globals.port_hashsize) 157#define sctp_port_hashsize (sctp_globals.port_hashsize)
279#define sctp_port_hashtable (sctp_globals.port_hashtable) 158#define sctp_port_hashtable (sctp_globals.port_hashtable)
280#define sctp_local_addr_list (sctp_globals.local_addr_list)
281#define sctp_local_addr_lock (sctp_globals.addr_list_lock)
282#define sctp_auto_asconf_splist (sctp_globals.auto_asconf_splist)
283#define sctp_addr_waitq (sctp_globals.addr_waitq)
284#define sctp_addr_wq_timer (sctp_globals.addr_wq_timer)
285#define sctp_addr_wq_lock (sctp_globals.addr_wq_lock)
286#define sctp_default_auto_asconf (sctp_globals.default_auto_asconf)
287#define sctp_scope_policy (sctp_globals.ipv4_scope_policy)
288#define sctp_addip_enable (sctp_globals.addip_enable)
289#define sctp_addip_noauth (sctp_globals.addip_noauth_enable)
290#define sctp_prsctp_enable (sctp_globals.prsctp_enable)
291#define sctp_auth_enable (sctp_globals.auth_enable)
292#define sctp_checksum_disable (sctp_globals.checksum_disable) 159#define sctp_checksum_disable (sctp_globals.checksum_disable)
293#define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift)
294#define sctp_max_autoclose (sctp_globals.max_autoclose)
295 160
296/* SCTP Socket type: UDP or TCP style. */ 161/* SCTP Socket type: UDP or TCP style. */
297typedef enum { 162typedef enum {
@@ -1085,7 +950,7 @@ struct sctp_transport {
1085 __u64 hb_nonce; 950 __u64 hb_nonce;
1086}; 951};
1087 952
1088struct sctp_transport *sctp_transport_new(const union sctp_addr *, 953struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *,
1089 gfp_t); 954 gfp_t);
1090void sctp_transport_set_owner(struct sctp_transport *, 955void sctp_transport_set_owner(struct sctp_transport *,
1091 struct sctp_association *); 956 struct sctp_association *);
@@ -1240,7 +1105,7 @@ struct sctp_bind_addr {
1240 1105
1241void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port); 1106void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port);
1242void sctp_bind_addr_free(struct sctp_bind_addr *); 1107void sctp_bind_addr_free(struct sctp_bind_addr *);
1243int sctp_bind_addr_copy(struct sctp_bind_addr *dest, 1108int sctp_bind_addr_copy(struct net *net, struct sctp_bind_addr *dest,
1244 const struct sctp_bind_addr *src, 1109 const struct sctp_bind_addr *src,
1245 sctp_scope_t scope, gfp_t gfp, 1110 sctp_scope_t scope, gfp_t gfp,
1246 int flags); 1111 int flags);
@@ -1267,7 +1132,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
1267 __u16 port, gfp_t gfp); 1132 __u16 port, gfp_t gfp);
1268 1133
1269sctp_scope_t sctp_scope(const union sctp_addr *); 1134sctp_scope_t sctp_scope(const union sctp_addr *);
1270int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); 1135int sctp_in_scope(struct net *net, const union sctp_addr *addr, const sctp_scope_t scope);
1271int sctp_is_any(struct sock *sk, const union sctp_addr *addr); 1136int sctp_is_any(struct sock *sk, const union sctp_addr *addr);
1272int sctp_addr_is_valid(const union sctp_addr *addr); 1137int sctp_addr_is_valid(const union sctp_addr *addr);
1273int sctp_is_ep_boundall(struct sock *sk); 1138int sctp_is_ep_boundall(struct sock *sk);
@@ -1425,13 +1290,13 @@ struct sctp_association *sctp_endpoint_lookup_assoc(
1425int sctp_endpoint_is_peeled_off(struct sctp_endpoint *, 1290int sctp_endpoint_is_peeled_off(struct sctp_endpoint *,
1426 const union sctp_addr *); 1291 const union sctp_addr *);
1427struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *, 1292struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *,
1428 const union sctp_addr *); 1293 struct net *, const union sctp_addr *);
1429int sctp_has_association(const union sctp_addr *laddr, 1294int sctp_has_association(struct net *net, const union sctp_addr *laddr,
1430 const union sctp_addr *paddr); 1295 const union sctp_addr *paddr);
1431 1296
1432int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, 1297int sctp_verify_init(struct net *net, const struct sctp_association *asoc,
1433 sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk, 1298 sctp_cid_t, sctp_init_chunk_t *peer_init,
1434 struct sctp_chunk **err_chunk); 1299 struct sctp_chunk *chunk, struct sctp_chunk **err_chunk);
1435int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk, 1300int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk,
1436 const union sctp_addr *peer, 1301 const union sctp_addr *peer,
1437 sctp_init_chunk_t *init, gfp_t gfp); 1302 sctp_init_chunk_t *init, gfp_t gfp);
@@ -2013,6 +1878,7 @@ void sctp_assoc_control_transport(struct sctp_association *,
2013 sctp_transport_cmd_t, sctp_sn_error_t); 1878 sctp_transport_cmd_t, sctp_sn_error_t);
2014struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32); 1879struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32);
2015struct sctp_transport *sctp_assoc_is_match(struct sctp_association *, 1880struct sctp_transport *sctp_assoc_is_match(struct sctp_association *,
1881 struct net *,
2016 const union sctp_addr *, 1882 const union sctp_addr *,
2017 const union sctp_addr *); 1883 const union sctp_addr *);
2018void sctp_assoc_migrate(struct sctp_association *, struct sock *); 1884void sctp_assoc_migrate(struct sctp_association *, struct sock *);
diff --git a/include/net/snmp.h b/include/net/snmp.h
index 0147b901e79..71596261fa9 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -154,13 +154,15 @@ struct linux_xfrm_mib {
154 */ 154 */
155#define SNMP_UPD_PO_STATS(mib, basefield, addend) \ 155#define SNMP_UPD_PO_STATS(mib, basefield, addend) \
156 do { \ 156 do { \
157 this_cpu_inc(mib[0]->mibs[basefield##PKTS]); \ 157 __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \
158 this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend); \ 158 this_cpu_inc(ptr[basefield##PKTS]); \
159 this_cpu_add(ptr[basefield##OCTETS], addend); \
159 } while (0) 160 } while (0)
160#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ 161#define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \
161 do { \ 162 do { \
162 __this_cpu_inc(mib[0]->mibs[basefield##PKTS]); \ 163 __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \
163 __this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend); \ 164 __this_cpu_inc(ptr[basefield##PKTS]); \
165 __this_cpu_add(ptr[basefield##OCTETS], addend); \
164 } while (0) 166 } while (0)
165 167
166 168
diff --git a/include/net/sock.h b/include/net/sock.h
index 0d7e9834d9b..c945fba4f54 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -247,8 +247,7 @@ struct cg_proto;
247 * @sk_stamp: time stamp of last packet received 247 * @sk_stamp: time stamp of last packet received
248 * @sk_socket: Identd and reporting IO signals 248 * @sk_socket: Identd and reporting IO signals
249 * @sk_user_data: RPC layer private data 249 * @sk_user_data: RPC layer private data
250 * @sk_sndmsg_page: cached page for sendmsg 250 * @sk_frag: cached page frag
251 * @sk_sndmsg_off: cached offset for sendmsg
252 * @sk_peek_off: current peek_offset value 251 * @sk_peek_off: current peek_offset value
253 * @sk_send_head: front of stuff to transmit 252 * @sk_send_head: front of stuff to transmit
254 * @sk_security: used by security modules 253 * @sk_security: used by security modules
@@ -362,9 +361,8 @@ struct sock {
362 ktime_t sk_stamp; 361 ktime_t sk_stamp;
363 struct socket *sk_socket; 362 struct socket *sk_socket;
364 void *sk_user_data; 363 void *sk_user_data;
365 struct page *sk_sndmsg_page; 364 struct page_frag sk_frag;
366 struct sk_buff *sk_send_head; 365 struct sk_buff *sk_send_head;
367 __u32 sk_sndmsg_off;
368 __s32 sk_peek_off; 366 __s32 sk_peek_off;
369 int sk_write_pending; 367 int sk_write_pending;
370#ifdef CONFIG_SECURITY 368#ifdef CONFIG_SECURITY
@@ -2026,18 +2024,23 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
2026 2024
2027struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp); 2025struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
2028 2026
2029static inline struct page *sk_stream_alloc_page(struct sock *sk) 2027/**
2028 * sk_page_frag - return an appropriate page_frag
2029 * @sk: socket
2030 *
2031 * If socket allocation mode allows current thread to sleep, it means its
2032 * safe to use the per task page_frag instead of the per socket one.
2033 */
2034static inline struct page_frag *sk_page_frag(struct sock *sk)
2030{ 2035{
2031 struct page *page = NULL; 2036 if (sk->sk_allocation & __GFP_WAIT)
2037 return &current->task_frag;
2032 2038
2033 page = alloc_pages(sk->sk_allocation, 0); 2039 return &sk->sk_frag;
2034 if (!page) {
2035 sk_enter_memory_pressure(sk);
2036 sk_stream_moderate_sndbuf(sk);
2037 }
2038 return page;
2039} 2040}
2040 2041
2042extern bool sk_page_frag_refill(struct sock *sk, struct page_frag *pfrag);
2043
2041/* 2044/*
2042 * Default write policy as shown to user space via poll/select/SIGIO 2045 * Default write policy as shown to user space via poll/select/SIGIO
2043 */ 2046 */
@@ -2218,8 +2221,6 @@ extern int net_msg_warn;
2218extern __u32 sysctl_wmem_max; 2221extern __u32 sysctl_wmem_max;
2219extern __u32 sysctl_rmem_max; 2222extern __u32 sysctl_rmem_max;
2220 2223
2221extern void sk_init(void);
2222
2223extern int sysctl_optmem_max; 2224extern int sysctl_optmem_max;
2224 2225
2225extern __u32 sysctl_wmem_default; 2226extern __u32 sysctl_wmem_default;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 9a0021d16d9..6feeccd83dd 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -98,11 +98,21 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
98 * 15 is ~13-30min depending on RTO. 98 * 15 is ~13-30min depending on RTO.
99 */ 99 */
100 100
101#define TCP_SYN_RETRIES 5 /* number of times to retry active opening a 101#define TCP_SYN_RETRIES 6 /* This is how many retries are done
102 * connection: ~180sec is RFC minimum */ 102 * when active opening a connection.
103 * RFC1122 says the minimum retry MUST
104 * be at least 180secs. Nevertheless
105 * this value is corresponding to
106 * 63secs of retransmission with the
107 * current initial RTO.
108 */
103 109
104#define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a 110#define TCP_SYNACK_RETRIES 5 /* This is how may retries are done
105 * connection: ~180sec is RFC minimum */ 111 * when passive opening a connection.
112 * This is corresponding to 31secs of
113 * retransmission with the current
114 * initial RTO.
115 */
106 116
107#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT 117#define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT
108 * state, about 60 seconds */ 118 * state, about 60 seconds */
@@ -214,8 +224,24 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
214 224
215/* Bit Flags for sysctl_tcp_fastopen */ 225/* Bit Flags for sysctl_tcp_fastopen */
216#define TFO_CLIENT_ENABLE 1 226#define TFO_CLIENT_ENABLE 1
227#define TFO_SERVER_ENABLE 2
217#define TFO_CLIENT_NO_COOKIE 4 /* Data in SYN w/o cookie option */ 228#define TFO_CLIENT_NO_COOKIE 4 /* Data in SYN w/o cookie option */
218 229
230/* Process SYN data but skip cookie validation */
231#define TFO_SERVER_COOKIE_NOT_CHKED 0x100
232/* Accept SYN data w/o any cookie option */
233#define TFO_SERVER_COOKIE_NOT_REQD 0x200
234
235/* Force enable TFO on all listeners, i.e., not requiring the
236 * TCP_FASTOPEN socket option. SOCKOPT1/2 determine how to set max_qlen.
237 */
238#define TFO_SERVER_WO_SOCKOPT1 0x400
239#define TFO_SERVER_WO_SOCKOPT2 0x800
240/* Always create TFO child sockets on a TFO listener even when
241 * cookie/data not present. (For testing purpose!)
242 */
243#define TFO_SERVER_ALWAYS 0x1000
244
219extern struct inet_timewait_death_row tcp_death_row; 245extern struct inet_timewait_death_row tcp_death_row;
220 246
221/* sysctl variables for tcp */ 247/* sysctl variables for tcp */
@@ -398,7 +424,8 @@ extern enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *
398 const struct tcphdr *th); 424 const struct tcphdr *th);
399extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, 425extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb,
400 struct request_sock *req, 426 struct request_sock *req,
401 struct request_sock **prev); 427 struct request_sock **prev,
428 bool fastopen);
402extern int tcp_child_process(struct sock *parent, struct sock *child, 429extern int tcp_child_process(struct sock *parent, struct sock *child,
403 struct sk_buff *skb); 430 struct sk_buff *skb);
404extern bool tcp_use_frto(struct sock *sk); 431extern bool tcp_use_frto(struct sock *sk);
@@ -411,12 +438,6 @@ extern void tcp_metrics_init(void);
411extern bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst, bool paws_check); 438extern bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst, bool paws_check);
412extern bool tcp_remember_stamp(struct sock *sk); 439extern bool tcp_remember_stamp(struct sock *sk);
413extern bool tcp_tw_remember_stamp(struct inet_timewait_sock *tw); 440extern bool tcp_tw_remember_stamp(struct inet_timewait_sock *tw);
414extern void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
415 struct tcp_fastopen_cookie *cookie,
416 int *syn_loss, unsigned long *last_syn_loss);
417extern void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
418 struct tcp_fastopen_cookie *cookie,
419 bool syn_lost);
420extern void tcp_fetch_timewait_stamp(struct sock *sk, struct dst_entry *dst); 441extern void tcp_fetch_timewait_stamp(struct sock *sk, struct dst_entry *dst);
421extern void tcp_disable_fack(struct tcp_sock *tp); 442extern void tcp_disable_fack(struct tcp_sock *tp);
422extern void tcp_close(struct sock *sk, long timeout); 443extern void tcp_close(struct sock *sk, long timeout);
@@ -458,7 +479,8 @@ extern int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
458extern int tcp_connect(struct sock *sk); 479extern int tcp_connect(struct sock *sk);
459extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, 480extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
460 struct request_sock *req, 481 struct request_sock *req,
461 struct request_values *rvp); 482 struct request_values *rvp,
483 struct tcp_fastopen_cookie *foc);
462extern int tcp_disconnect(struct sock *sk, int flags); 484extern int tcp_disconnect(struct sock *sk, int flags);
463 485
464void tcp_connect_init(struct sock *sk); 486void tcp_connect_init(struct sock *sk);
@@ -527,6 +549,7 @@ extern void tcp_send_delayed_ack(struct sock *sk);
527extern void tcp_cwnd_application_limited(struct sock *sk); 549extern void tcp_cwnd_application_limited(struct sock *sk);
528extern void tcp_resume_early_retransmit(struct sock *sk); 550extern void tcp_resume_early_retransmit(struct sock *sk);
529extern void tcp_rearm_rto(struct sock *sk); 551extern void tcp_rearm_rto(struct sock *sk);
552extern void tcp_reset(struct sock *sk);
530 553
531/* tcp_timer.c */ 554/* tcp_timer.c */
532extern void tcp_init_xmit_timers(struct sock *); 555extern void tcp_init_xmit_timers(struct sock *);
@@ -576,6 +599,7 @@ extern int tcp_mtu_to_mss(struct sock *sk, int pmtu);
576extern int tcp_mss_to_mtu(struct sock *sk, int mss); 599extern int tcp_mss_to_mtu(struct sock *sk, int mss);
577extern void tcp_mtup_init(struct sock *sk); 600extern void tcp_mtup_init(struct sock *sk);
578extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt); 601extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt);
602extern void tcp_init_buffer_space(struct sock *sk);
579 603
580static inline void tcp_bound_rto(const struct sock *sk) 604static inline void tcp_bound_rto(const struct sock *sk)
581{ 605{
@@ -889,15 +913,21 @@ static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)
889 return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH; 913 return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH;
890} 914}
891 915
916static inline bool tcp_in_cwnd_reduction(const struct sock *sk)
917{
918 return (TCPF_CA_CWR | TCPF_CA_Recovery) &
919 (1 << inet_csk(sk)->icsk_ca_state);
920}
921
892/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. 922/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
893 * The exception is rate halving phase, when cwnd is decreasing towards 923 * The exception is cwnd reduction phase, when cwnd is decreasing towards
894 * ssthresh. 924 * ssthresh.
895 */ 925 */
896static inline __u32 tcp_current_ssthresh(const struct sock *sk) 926static inline __u32 tcp_current_ssthresh(const struct sock *sk)
897{ 927{
898 const struct tcp_sock *tp = tcp_sk(sk); 928 const struct tcp_sock *tp = tcp_sk(sk);
899 929
900 if ((1 << inet_csk(sk)->icsk_ca_state) & (TCPF_CA_CWR | TCPF_CA_Recovery)) 930 if (tcp_in_cwnd_reduction(sk))
901 return tp->snd_ssthresh; 931 return tp->snd_ssthresh;
902 else 932 else
903 return max(tp->snd_ssthresh, 933 return max(tp->snd_ssthresh,
@@ -1094,6 +1124,8 @@ static inline void tcp_openreq_init(struct request_sock *req,
1094 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ 1124 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */
1095 req->cookie_ts = 0; 1125 req->cookie_ts = 0;
1096 tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq; 1126 tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
1127 tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
1128 tcp_rsk(req)->snt_synack = 0;
1097 req->mss = rx_opt->mss_clamp; 1129 req->mss = rx_opt->mss_clamp;
1098 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; 1130 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;
1099 ireq->tstamp_ok = rx_opt->tstamp_ok; 1131 ireq->tstamp_ok = rx_opt->tstamp_ok;
@@ -1106,6 +1138,15 @@ static inline void tcp_openreq_init(struct request_sock *req,
1106 ireq->loc_port = tcp_hdr(skb)->dest; 1138 ireq->loc_port = tcp_hdr(skb)->dest;
1107} 1139}
1108 1140
1141/* Compute time elapsed between SYNACK and the ACK completing 3WHS */
1142static inline void tcp_synack_rtt_meas(struct sock *sk,
1143 struct request_sock *req)
1144{
1145 if (tcp_rsk(req)->snt_synack)
1146 tcp_valid_rtt_meas(sk,
1147 tcp_time_stamp - tcp_rsk(req)->snt_synack);
1148}
1149
1109extern void tcp_enter_memory_pressure(struct sock *sk); 1150extern void tcp_enter_memory_pressure(struct sock *sk);
1110 1151
1111static inline int keepalive_intvl_when(const struct tcp_sock *tp) 1152static inline int keepalive_intvl_when(const struct tcp_sock *tp)
@@ -1298,15 +1339,34 @@ extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, const struct sk_buff
1298extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, 1339extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp,
1299 const struct tcp_md5sig_key *key); 1340 const struct tcp_md5sig_key *key);
1300 1341
1342/* From tcp_fastopen.c */
1343extern void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
1344 struct tcp_fastopen_cookie *cookie,
1345 int *syn_loss, unsigned long *last_syn_loss);
1346extern void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
1347 struct tcp_fastopen_cookie *cookie,
1348 bool syn_lost);
1301struct tcp_fastopen_request { 1349struct tcp_fastopen_request {
1302 /* Fast Open cookie. Size 0 means a cookie request */ 1350 /* Fast Open cookie. Size 0 means a cookie request */
1303 struct tcp_fastopen_cookie cookie; 1351 struct tcp_fastopen_cookie cookie;
1304 struct msghdr *data; /* data in MSG_FASTOPEN */ 1352 struct msghdr *data; /* data in MSG_FASTOPEN */
1305 u16 copied; /* queued in tcp_connect() */ 1353 u16 copied; /* queued in tcp_connect() */
1306}; 1354};
1307
1308void tcp_free_fastopen_req(struct tcp_sock *tp); 1355void tcp_free_fastopen_req(struct tcp_sock *tp);
1309 1356
1357extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx;
1358int tcp_fastopen_reset_cipher(void *key, unsigned int len);
1359void tcp_fastopen_cookie_gen(__be32 addr, struct tcp_fastopen_cookie *foc);
1360
1361#define TCP_FASTOPEN_KEY_LENGTH 16
1362
1363/* Fastopen key context */
1364struct tcp_fastopen_context {
1365 struct crypto_cipher __rcu *tfm;
1366 __u8 key[TCP_FASTOPEN_KEY_LENGTH];
1367 struct rcu_head rcu;
1368};
1369
1310/* write queue abstraction */ 1370/* write queue abstraction */
1311static inline void tcp_write_queue_purge(struct sock *sk) 1371static inline void tcp_write_queue_purge(struct sock *sk)
1312{ 1372{
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 411d83c9821..6f0ba01afe7 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -263,7 +263,7 @@ struct km_event {
263 } data; 263 } data;
264 264
265 u32 seq; 265 u32 seq;
266 u32 pid; 266 u32 portid;
267 u32 event; 267 u32 event;
268 struct net *net; 268 struct net *net;
269}; 269};
@@ -313,7 +313,7 @@ extern void km_state_notify(struct xfrm_state *x, const struct km_event *c);
313 313
314struct xfrm_tmpl; 314struct xfrm_tmpl;
315extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); 315extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol);
316extern void km_state_expired(struct xfrm_state *x, int hard, u32 pid); 316extern void km_state_expired(struct xfrm_state *x, int hard, u32 portid);
317extern int __xfrm_state_delete(struct xfrm_state *x); 317extern int __xfrm_state_delete(struct xfrm_state *x);
318 318
319struct xfrm_state_afinfo { 319struct xfrm_state_afinfo {
@@ -576,7 +576,7 @@ struct xfrm_mgr {
576 struct list_head list; 576 struct list_head list;
577 char *id; 577 char *id;
578 int (*notify)(struct xfrm_state *x, const struct km_event *c); 578 int (*notify)(struct xfrm_state *x, const struct km_event *c);
579 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); 579 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp);
580 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir); 580 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir);
581 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); 581 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
582 int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c); 582 int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c);
@@ -1558,7 +1558,7 @@ extern int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
1558#endif 1558#endif
1559 1559
1560extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); 1560extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
1561extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid); 1561extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 portid);
1562extern int km_report(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 1562extern int km_report(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
1563 1563
1564extern void xfrm_input_init(void); 1564extern void xfrm_input_init(void);