aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 12:00:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-15 12:00:47 -0400
commit6c373ca89399c5a3f7ef210ad8f63dc3437da345 (patch)
tree74d1ec65087df1da1021b43ac51acc1ee8601809 /include
parentbb0fd7ab0986105765d11baa82e619c618a235aa (diff)
parent9f9151412dd7aae0e3f51a89ae4a1f8755fdb4d0 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: 1) Add BQL support to via-rhine, from Tino Reichardt. 2) Integrate SWITCHDEV layer support into the DSA layer, so DSA drivers can support hw switch offloading. From Floria Fainelli. 3) Allow 'ip address' commands to initiate multicast group join/leave, from Madhu Challa. 4) Many ipv4 FIB lookup optimizations from Alexander Duyck. 5) Support EBPF in cls_bpf classifier and act_bpf action, from Daniel Borkmann. 6) Remove the ugly compat support in ARP for ugly layers like ax25, rose, etc. And use this to clean up the neigh layer, then use it to implement MPLS support. All from Eric Biederman. 7) Support L3 forwarding offloading in switches, from Scott Feldman. 8) Collapse the LOCAL and MAIN ipv4 FIB tables when possible, to speed up route lookups even further. From Alexander Duyck. 9) Many improvements and bug fixes to the rhashtable implementation, from Herbert Xu and Thomas Graf. In particular, in the case where an rhashtable user bulk adds a large number of items into an empty table, we expand the table much more sanely. 10) Don't make the tcp_metrics hash table per-namespace, from Eric Biederman. 11) Extend EBPF to access SKB fields, from Alexei Starovoitov. 12) Split out new connection request sockets so that they can be established in the main hash table. Much less false sharing since hash lookups go direct to the request sockets instead of having to go first to the listener then to the request socks hashed underneath. From Eric Dumazet. 13) Add async I/O support for crytpo AF_ALG sockets, from Tadeusz Struk. 14) Support stable privacy address generation for RFC7217 in IPV6. From Hannes Frederic Sowa. 15) Hash network namespace into IP frag IDs, also from Hannes Frederic Sowa. 16) Convert PTP get/set methods to use 64-bit time, from Richard Cochran. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1816 commits) fm10k: Bump driver version to 0.15.2 fm10k: corrected VF multicast update fm10k: mbx_update_max_size does not drop all oversized messages fm10k: reset head instead of calling update_max_size fm10k: renamed mbx_tx_dropped to mbx_tx_oversized fm10k: update xcast mode before synchronizing multicast addresses fm10k: start service timer on probe fm10k: fix function header comment fm10k: comment next_vf_mbx flow fm10k: don't handle mailbox events in iov_event path and always process mailbox fm10k: use separate workqueue for fm10k driver fm10k: Set PF queues to unlimited bandwidth during virtualization fm10k: expose tx_timeout_count as an ethtool stat fm10k: only increment tx_timeout_count in Tx hang path fm10k: remove extraneous "Reset interface" message fm10k: separate PF only stats so that VF does not display them fm10k: use hw->mac.max_queues for stats fm10k: only show actual queues, not the maximum in hardware fm10k: allow creation of VLAN on default vid fm10k: fix unused warnings ...
Diffstat (limited to 'include')
-rw-r--r--include/crypto/if_alg.h4
-rw-r--r--include/linux/bcma/bcma.h21
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h11
-rw-r--r--include/linux/bcma/bcma_driver_gmac_cmn.h6
-rw-r--r--include/linux/bcma/bcma_driver_mips.h15
-rw-r--r--include/linux/bcma/bcma_driver_pci.h12
-rw-r--r--include/linux/bcma/bcma_driver_pcie2.h4
-rw-r--r--include/linux/bpf.h47
-rw-r--r--include/linux/brcmphy.h2
-rw-r--r--include/linux/can/dev.h2
-rw-r--r--include/linux/can/led.h6
-rw-r--r--include/linux/can/skb.h7
-rw-r--r--include/linux/dccp.h4
-rw-r--r--include/linux/etherdevice.h1
-rw-r--r--include/linux/filter.h7
-rw-r--r--include/linux/ieee802154.h14
-rw-r--r--include/linux/if_bridge.h1
-rw-r--r--include/linux/if_link.h1
-rw-r--r--include/linux/if_pppox.h2
-rw-r--r--include/linux/if_vlan.h67
-rw-r--r--include/linux/inet_diag.h43
-rw-r--r--include/linux/ipv6.h4
-rw-r--r--include/linux/jhash.h17
-rw-r--r--include/linux/mlx4/cmd.h26
-rw-r--r--include/linux/mlx4/device.h40
-rw-r--r--include/linux/mlx4/qp.h18
-rw-r--r--include/linux/mlx5/cmd.h2
-rw-r--r--include/linux/mlx5/cq.h7
-rw-r--r--include/linux/mlx5/device.h2
-rw-r--r--include/linux/mlx5/doorbell.h2
-rw-r--r--include/linux/mlx5/driver.h16
-rw-r--r--include/linux/mlx5/mlx5_ifc.h2
-rw-r--r--include/linux/mlx5/qp.h2
-rw-r--r--include/linux/mlx5/srq.h2
-rw-r--r--include/linux/mmc/sdio_ids.h2
-rw-r--r--include/linux/net.h12
-rw-r--r--include/linux/netdevice.h140
-rw-r--r--include/linux/netfilter.h103
-rw-r--r--include/linux/netfilter/ipset/ip_set.h5
-rw-r--r--include/linux/netfilter_arp/arp_tables.h3
-rw-r--r--include/linux/netfilter_bridge.h100
-rw-r--r--include/linux/netfilter_bridge/ebtables.h3
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h3
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h3
-rw-r--r--include/linux/netlink.h2
-rw-r--r--include/linux/of_mdio.h7
-rw-r--r--include/linux/of_net.h8
-rw-r--r--include/linux/phy_fixed.h9
-rw-r--r--include/linux/platform_data/nxp-nci.h27
-rw-r--r--include/linux/ptp_clock_kernel.h12
-rw-r--r--include/linux/rhashtable.h527
-rw-r--r--include/linux/rtnetlink.h15
-rw-r--r--include/linux/security.h8
-rw-r--r--include/linux/skbuff.h13
-rw-r--r--include/linux/sock_diag.h4
-rw-r--r--include/linux/socket.h8
-rw-r--r--include/linux/spi/at86rf230.h1
-rw-r--r--include/linux/spi/cc2520.h1
-rw-r--r--include/linux/tcp.h5
-rw-r--r--include/linux/udp.h2
-rw-r--r--include/net/af_vsock.h4
-rw-r--r--include/net/arp.h20
-rw-r--r--include/net/ax25.h5
-rw-r--r--include/net/bluetooth/bluetooth.h45
-rw-r--r--include/net/bluetooth/hci.h59
-rw-r--r--include/net/bluetooth/hci_core.h233
-rw-r--r--include/net/bluetooth/mgmt.h101
-rw-r--r--include/net/bond_3ad.h29
-rw-r--r--include/net/cfg80211.h127
-rw-r--r--include/net/compat.h2
-rw-r--r--include/net/dcbnl.h3
-rw-r--r--include/net/dn_neigh.h5
-rw-r--r--include/net/dsa.h27
-rw-r--r--include/net/dst_ops.h1
-rw-r--r--include/net/fib_rules.h11
-rw-r--r--include/net/genetlink.h4
-rw-r--r--include/net/if_inet6.h4
-rw-r--r--include/net/inet6_connection_sock.h3
-rw-r--r--include/net/inet6_hashtables.h2
-rw-r--r--include/net/inet_common.h7
-rw-r--r--include/net/inet_connection_sock.h28
-rw-r--r--include/net/inet_hashtables.h36
-rw-r--r--include/net/inet_sock.h30
-rw-r--r--include/net/inet_timewait_sock.h108
-rw-r--r--include/net/inetpeer.h3
-rw-r--r--include/net/ip.h15
-rw-r--r--include/net/ip6_route.h3
-rw-r--r--include/net/ip6_tunnel.h6
-rw-r--r--include/net/ip_fib.h70
-rw-r--r--include/net/ip_tunnels.h1
-rw-r--r--include/net/ip_vs.h69
-rw-r--r--include/net/ipv6.h14
-rw-r--r--include/net/iw_handler.h22
-rw-r--r--include/net/mac80211.h251
-rw-r--r--include/net/mac802154.h13
-rw-r--r--include/net/ndisc.h19
-rw-r--r--include/net/neighbour.h67
-rw-r--r--include/net/net_namespace.h58
-rw-r--r--include/net/netfilter/ipv4/nf_reject.h8
-rw-r--r--include/net/netfilter/ipv6/nf_reject.h13
-rw-r--r--include/net/netfilter/nf_conntrack.h5
-rw-r--r--include/net/netfilter/nf_nat_l3proto.h48
-rw-r--r--include/net/netfilter/nf_queue.h6
-rw-r--r--include/net/netfilter/nf_tables.h621
-rw-r--r--include/net/netfilter/nf_tables_core.h3
-rw-r--r--include/net/netfilter/nf_tables_ipv4.h5
-rw-r--r--include/net/netfilter/nf_tables_ipv6.h5
-rw-r--r--include/net/netfilter/nft_meta.h4
-rw-r--r--include/net/netlink.h50
-rw-r--r--include/net/netns/hash.h4
-rw-r--r--include/net/netns/ipv4.h13
-rw-r--r--include/net/netns/ipv6.h3
-rw-r--r--include/net/netns/mpls.h17
-rw-r--r--include/net/netns/x_tables.h1
-rw-r--r--include/net/nfc/hci.h4
-rw-r--r--include/net/nfc/nci_core.h5
-rw-r--r--include/net/nfc/nfc.h2
-rw-r--r--include/net/ping.h7
-rw-r--r--include/net/request_sock.h140
-rw-r--r--include/net/rtnetlink.h2
-rw-r--r--include/net/sch_generic.h4
-rw-r--r--include/net/sctp/sctp.h3
-rw-r--r--include/net/sock.h63
-rw-r--r--include/net/switchdev.h55
-rw-r--r--include/net/tc_act/tc_bpf.h6
-rw-r--r--include/net/tcp.h122
-rw-r--r--include/net/tcp_states.h4
-rw-r--r--include/net/udp.h24
-rw-r--r--include/net/udp_tunnel.h5
-rw-r--r--include/net/vxlan.h4
-rw-r--r--include/net/xfrm.h22
-rw-r--r--include/rxrpc/packet.h3
-rw-r--r--include/uapi/linux/bpf.h58
-rw-r--r--include/uapi/linux/can/raw.h1
-rw-r--r--include/uapi/linux/dcbnl.h66
-rw-r--r--include/uapi/linux/filter.h3
-rw-r--r--include/uapi/linux/fou.h1
-rw-r--r--include/uapi/linux/if_addr.h2
-rw-r--r--include/uapi/linux/if_link.h14
-rw-r--r--include/uapi/linux/if_packet.h1
-rw-r--r--include/uapi/linux/ip_vs.h7
-rw-r--r--include/uapi/linux/ipv6.h1
-rw-r--r--include/uapi/linux/neighbour.h1
-rw-r--r--include/uapi/linux/netfilter/nf_tables.h80
-rw-r--r--include/uapi/linux/netfilter_bridge/ebtables.h2
-rw-r--r--include/uapi/linux/nl80211.h34
-rw-r--r--include/uapi/linux/pkt_cls.h2
-rw-r--r--include/uapi/linux/rtnetlink.h16
-rw-r--r--include/uapi/linux/tc_act/tc_bpf.h2
-rw-r--r--include/uapi/linux/tipc_netlink.h9
-rw-r--r--include/uapi/linux/xfrm.h2
151 files changed, 3209 insertions, 1319 deletions
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
index 178525e5f430..018afb264ac2 100644
--- a/include/crypto/if_alg.h
+++ b/include/crypto/if_alg.h
@@ -58,8 +58,9 @@ struct af_alg_type {
58}; 58};
59 59
60struct af_alg_sgl { 60struct af_alg_sgl {
61 struct scatterlist sg[ALG_MAX_PAGES]; 61 struct scatterlist sg[ALG_MAX_PAGES + 1];
62 struct page *pages[ALG_MAX_PAGES]; 62 struct page *pages[ALG_MAX_PAGES];
63 unsigned int npages;
63}; 64};
64 65
65int af_alg_register_type(const struct af_alg_type *type); 66int af_alg_register_type(const struct af_alg_type *type);
@@ -70,6 +71,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock);
70 71
71int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len); 72int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len);
72void af_alg_free_sg(struct af_alg_sgl *sgl); 73void af_alg_free_sg(struct af_alg_sgl *sgl);
74void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new);
73 75
74int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con); 76int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con);
75 77
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 994739da827f..e34f906647d3 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -434,6 +434,27 @@ static inline struct bcma_device *bcma_find_core(struct bcma_bus *bus,
434 return bcma_find_core_unit(bus, coreid, 0); 434 return bcma_find_core_unit(bus, coreid, 0);
435} 435}
436 436
437#ifdef CONFIG_BCMA_HOST_PCI
438extern void bcma_host_pci_up(struct bcma_bus *bus);
439extern void bcma_host_pci_down(struct bcma_bus *bus);
440extern int bcma_host_pci_irq_ctl(struct bcma_bus *bus,
441 struct bcma_device *core, bool enable);
442#else
443static inline void bcma_host_pci_up(struct bcma_bus *bus)
444{
445}
446static inline void bcma_host_pci_down(struct bcma_bus *bus)
447{
448}
449static inline int bcma_host_pci_irq_ctl(struct bcma_bus *bus,
450 struct bcma_device *core, bool enable)
451{
452 if (bus->hosttype == BCMA_HOSTTYPE_PCI)
453 return -ENOTSUPP;
454 return 0;
455}
456#endif
457
437extern bool bcma_core_is_enabled(struct bcma_device *core); 458extern bool bcma_core_is_enabled(struct bcma_device *core);
438extern void bcma_core_disable(struct bcma_device *core, u32 flags); 459extern void bcma_core_disable(struct bcma_device *core, u32 flags);
439extern int bcma_core_enable(struct bcma_device *core, u32 flags); 460extern int bcma_core_enable(struct bcma_device *core, u32 flags);
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index db6fa217f98b..6cceedf65ca2 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -663,14 +663,6 @@ struct bcma_drv_cc_b {
663#define bcma_cc_maskset32(cc, offset, mask, set) \ 663#define bcma_cc_maskset32(cc, offset, mask, set) \
664 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set)) 664 bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
665 665
666extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
667extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
668
669extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
670extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
671
672void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
673
674extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks); 666extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
675 667
676extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc); 668extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
@@ -690,9 +682,6 @@ u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
690u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value); 682u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
691 683
692/* PMU support */ 684/* PMU support */
693extern void bcma_pmu_init(struct bcma_drv_cc *cc);
694extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
695
696extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, 685extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
697 u32 value); 686 u32 value);
698extern void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset, 687extern void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset,
diff --git a/include/linux/bcma/bcma_driver_gmac_cmn.h b/include/linux/bcma/bcma_driver_gmac_cmn.h
index 4dd1f33e36a2..4354d4ea6713 100644
--- a/include/linux/bcma/bcma_driver_gmac_cmn.h
+++ b/include/linux/bcma/bcma_driver_gmac_cmn.h
@@ -91,10 +91,4 @@ struct bcma_drv_gmac_cmn {
91#define gmac_cmn_write16(gc, offset, val) bcma_write16((gc)->core, offset, val) 91#define gmac_cmn_write16(gc, offset, val) bcma_write16((gc)->core, offset, val)
92#define gmac_cmn_write32(gc, offset, val) bcma_write32((gc)->core, offset, val) 92#define gmac_cmn_write32(gc, offset, val) bcma_write32((gc)->core, offset, val)
93 93
94#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
95extern void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
96#else
97static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) { }
98#endif
99
100#endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */ 94#endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */
diff --git a/include/linux/bcma/bcma_driver_mips.h b/include/linux/bcma/bcma_driver_mips.h
index 0b3b32aeeb8a..8eea7f9e33b4 100644
--- a/include/linux/bcma/bcma_driver_mips.h
+++ b/include/linux/bcma/bcma_driver_mips.h
@@ -39,21 +39,6 @@ struct bcma_drv_mips {
39 u8 early_setup_done:1; 39 u8 early_setup_done:1;
40}; 40};
41 41
42#ifdef CONFIG_BCMA_DRIVER_MIPS
43extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
44extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
45
46extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
47#else
48static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
49static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
50
51static inline unsigned int bcma_core_mips_irq(struct bcma_device *dev)
52{
53 return 0;
54}
55#endif
56
57extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore); 42extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
58 43
59#endif /* LINUX_BCMA_DRIVER_MIPS_H_ */ 44#endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h
index 3f809ae372c4..5ba6918ca20b 100644
--- a/include/linux/bcma/bcma_driver_pci.h
+++ b/include/linux/bcma/bcma_driver_pci.h
@@ -238,13 +238,13 @@ struct bcma_drv_pci {
238#define pcicore_write16(pc, offset, val) bcma_write16((pc)->core, offset, val) 238#define pcicore_write16(pc, offset, val) bcma_write16((pc)->core, offset, val)
239#define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val) 239#define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
240 240
241extern void bcma_core_pci_early_init(struct bcma_drv_pci *pc); 241#ifdef CONFIG_BCMA_DRIVER_PCI
242extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
243extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
244 struct bcma_device *core, bool enable);
245extern void bcma_core_pci_up(struct bcma_bus *bus);
246extern void bcma_core_pci_down(struct bcma_bus *bus);
247extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up); 242extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
243#else
244static inline void bcma_core_pci_power_save(struct bcma_bus *bus, bool up)
245{
246}
247#endif
248 248
249extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev); 249extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
250extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev); 250extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
diff --git a/include/linux/bcma/bcma_driver_pcie2.h b/include/linux/bcma/bcma_driver_pcie2.h
index 5988b05781c3..31e6d17ab798 100644
--- a/include/linux/bcma/bcma_driver_pcie2.h
+++ b/include/linux/bcma/bcma_driver_pcie2.h
@@ -143,6 +143,8 @@
143 143
144struct bcma_drv_pcie2 { 144struct bcma_drv_pcie2 {
145 struct bcma_device *core; 145 struct bcma_device *core;
146
147 u16 reqsize;
146}; 148};
147 149
148#define pcie2_read16(pcie2, offset) bcma_read16((pcie2)->core, offset) 150#define pcie2_read16(pcie2, offset) bcma_read16((pcie2)->core, offset)
@@ -153,6 +155,4 @@ struct bcma_drv_pcie2 {
153#define pcie2_set32(pcie2, offset, set) bcma_set32((pcie2)->core, offset, set) 155#define pcie2_set32(pcie2, offset, set) bcma_set32((pcie2)->core, offset, set)
154#define pcie2_mask32(pcie2, offset, mask) bcma_mask32((pcie2)->core, offset, mask) 156#define pcie2_mask32(pcie2, offset, mask) bcma_mask32((pcie2)->core, offset, mask)
155 157
156void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
157
158#endif /* LINUX_BCMA_DRIVER_PCIE2_H_ */ 158#endif /* LINUX_BCMA_DRIVER_PCIE2_H_ */
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c2e21113ecc0..d5cda067115a 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -32,23 +32,19 @@ struct bpf_map {
32 u32 key_size; 32 u32 key_size;
33 u32 value_size; 33 u32 value_size;
34 u32 max_entries; 34 u32 max_entries;
35 struct bpf_map_ops *ops; 35 const struct bpf_map_ops *ops;
36 struct work_struct work; 36 struct work_struct work;
37}; 37};
38 38
39struct bpf_map_type_list { 39struct bpf_map_type_list {
40 struct list_head list_node; 40 struct list_head list_node;
41 struct bpf_map_ops *ops; 41 const struct bpf_map_ops *ops;
42 enum bpf_map_type type; 42 enum bpf_map_type type;
43}; 43};
44 44
45void bpf_register_map_type(struct bpf_map_type_list *tl);
46void bpf_map_put(struct bpf_map *map);
47struct bpf_map *bpf_map_get(struct fd f);
48
49/* function argument constraints */ 45/* function argument constraints */
50enum bpf_arg_type { 46enum bpf_arg_type {
51 ARG_ANYTHING = 0, /* any argument is ok */ 47 ARG_DONTCARE = 0, /* unused argument in helper function */
52 48
53 /* the following constraints used to prototype 49 /* the following constraints used to prototype
54 * bpf_map_lookup/update/delete_elem() functions 50 * bpf_map_lookup/update/delete_elem() functions
@@ -62,6 +58,9 @@ enum bpf_arg_type {
62 */ 58 */
63 ARG_PTR_TO_STACK, /* any pointer to eBPF program stack */ 59 ARG_PTR_TO_STACK, /* any pointer to eBPF program stack */
64 ARG_CONST_STACK_SIZE, /* number of bytes accessed from stack */ 60 ARG_CONST_STACK_SIZE, /* number of bytes accessed from stack */
61
62 ARG_PTR_TO_CTX, /* pointer to context */
63 ARG_ANYTHING, /* any (initialized) argument is ok */
65}; 64};
66 65
67/* type of values returned from helper functions */ 66/* type of values returned from helper functions */
@@ -105,11 +104,14 @@ struct bpf_verifier_ops {
105 * with 'type' (read or write) is allowed 104 * with 'type' (read or write) is allowed
106 */ 105 */
107 bool (*is_valid_access)(int off, int size, enum bpf_access_type type); 106 bool (*is_valid_access)(int off, int size, enum bpf_access_type type);
107
108 u32 (*convert_ctx_access)(int dst_reg, int src_reg, int ctx_off,
109 struct bpf_insn *insn);
108}; 110};
109 111
110struct bpf_prog_type_list { 112struct bpf_prog_type_list {
111 struct list_head list_node; 113 struct list_head list_node;
112 struct bpf_verifier_ops *ops; 114 const struct bpf_verifier_ops *ops;
113 enum bpf_prog_type type; 115 enum bpf_prog_type type;
114}; 116};
115 117
@@ -117,20 +119,25 @@ struct bpf_prog;
117 119
118struct bpf_prog_aux { 120struct bpf_prog_aux {
119 atomic_t refcnt; 121 atomic_t refcnt;
120 bool is_gpl_compatible;
121 enum bpf_prog_type prog_type;
122 struct bpf_verifier_ops *ops;
123 struct bpf_map **used_maps;
124 u32 used_map_cnt; 122 u32 used_map_cnt;
123 const struct bpf_verifier_ops *ops;
124 struct bpf_map **used_maps;
125 struct bpf_prog *prog; 125 struct bpf_prog *prog;
126 struct work_struct work; 126 struct work_struct work;
127}; 127};
128 128
129#ifdef CONFIG_BPF_SYSCALL 129#ifdef CONFIG_BPF_SYSCALL
130void bpf_register_prog_type(struct bpf_prog_type_list *tl); 130void bpf_register_prog_type(struct bpf_prog_type_list *tl);
131void bpf_register_map_type(struct bpf_map_type_list *tl);
131 132
132void bpf_prog_put(struct bpf_prog *prog);
133struct bpf_prog *bpf_prog_get(u32 ufd); 133struct bpf_prog *bpf_prog_get(u32 ufd);
134void bpf_prog_put(struct bpf_prog *prog);
135
136struct bpf_map *bpf_map_get(struct fd f);
137void bpf_map_put(struct bpf_map *map);
138
139/* verify correctness of eBPF program */
140int bpf_check(struct bpf_prog **fp, union bpf_attr *attr);
134#else 141#else
135static inline void bpf_register_prog_type(struct bpf_prog_type_list *tl) 142static inline void bpf_register_prog_type(struct bpf_prog_type_list *tl)
136{ 143{
@@ -144,14 +151,14 @@ static inline struct bpf_prog *bpf_prog_get(u32 ufd)
144static inline void bpf_prog_put(struct bpf_prog *prog) 151static inline void bpf_prog_put(struct bpf_prog *prog)
145{ 152{
146} 153}
147#endif 154#endif /* CONFIG_BPF_SYSCALL */
148
149/* verify correctness of eBPF program */
150int bpf_check(struct bpf_prog *fp, union bpf_attr *attr);
151 155
152/* verifier prototypes for helper functions called from eBPF programs */ 156/* verifier prototypes for helper functions called from eBPF programs */
153extern struct bpf_func_proto bpf_map_lookup_elem_proto; 157extern const struct bpf_func_proto bpf_map_lookup_elem_proto;
154extern struct bpf_func_proto bpf_map_update_elem_proto; 158extern const struct bpf_func_proto bpf_map_update_elem_proto;
155extern struct bpf_func_proto bpf_map_delete_elem_proto; 159extern const struct bpf_func_proto bpf_map_delete_elem_proto;
160
161extern const struct bpf_func_proto bpf_get_prandom_u32_proto;
162extern const struct bpf_func_proto bpf_get_smp_processor_id_proto;
156 163
157#endif /* _LINUX_BPF_H */ 164#endif /* _LINUX_BPF_H */
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index 7ccd928cc1f2..ae2982c0f7a6 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -11,6 +11,7 @@
11#define PHY_ID_BCM5421 0x002060e0 11#define PHY_ID_BCM5421 0x002060e0
12#define PHY_ID_BCM5464 0x002060b0 12#define PHY_ID_BCM5464 0x002060b0
13#define PHY_ID_BCM5461 0x002060c0 13#define PHY_ID_BCM5461 0x002060c0
14#define PHY_ID_BCM54616S 0x03625d10
14#define PHY_ID_BCM57780 0x03625d90 15#define PHY_ID_BCM57780 0x03625d90
15 16
16#define PHY_ID_BCM7250 0xae025280 17#define PHY_ID_BCM7250 0xae025280
@@ -19,6 +20,7 @@
19#define PHY_ID_BCM7425 0x03625e60 20#define PHY_ID_BCM7425 0x03625e60
20#define PHY_ID_BCM7429 0x600d8730 21#define PHY_ID_BCM7429 0x600d8730
21#define PHY_ID_BCM7439 0x600d8480 22#define PHY_ID_BCM7439 0x600d8480
23#define PHY_ID_BCM7439_2 0xae025080
22#define PHY_ID_BCM7445 0x600d8510 24#define PHY_ID_BCM7445 0x600d8510
23 25
24#define PHY_BCM_OUI_MASK 0xfffffc00 26#define PHY_BCM_OUI_MASK 0xfffffc00
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index c05ff0f9f9a5..c3a9c8fc60fa 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -61,6 +61,8 @@ struct can_priv {
61 char tx_led_trig_name[CAN_LED_NAME_SZ]; 61 char tx_led_trig_name[CAN_LED_NAME_SZ];
62 struct led_trigger *rx_led_trig; 62 struct led_trigger *rx_led_trig;
63 char rx_led_trig_name[CAN_LED_NAME_SZ]; 63 char rx_led_trig_name[CAN_LED_NAME_SZ];
64 struct led_trigger *rxtx_led_trig;
65 char rxtx_led_trig_name[CAN_LED_NAME_SZ];
64#endif 66#endif
65}; 67};
66 68
diff --git a/include/linux/can/led.h b/include/linux/can/led.h
index e0475c5cbb92..146de4506d21 100644
--- a/include/linux/can/led.h
+++ b/include/linux/can/led.h
@@ -21,8 +21,10 @@ enum can_led_event {
21 21
22#ifdef CONFIG_CAN_LEDS 22#ifdef CONFIG_CAN_LEDS
23 23
24/* keep space for interface name + "-tx"/"-rx" suffix and null terminator */ 24/* keep space for interface name + "-tx"/"-rx"/"-rxtx"
25#define CAN_LED_NAME_SZ (IFNAMSIZ + 4) 25 * suffix and null terminator
26 */
27#define CAN_LED_NAME_SZ (IFNAMSIZ + 6)
26 28
27void can_led_event(struct net_device *netdev, enum can_led_event event); 29void can_led_event(struct net_device *netdev, enum can_led_event event);
28void devm_can_led_init(struct net_device *netdev); 30void devm_can_led_init(struct net_device *netdev);
diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
index cc00d15c6107..b6a52a4b457a 100644
--- a/include/linux/can/skb.h
+++ b/include/linux/can/skb.h
@@ -44,16 +44,11 @@ static inline void can_skb_reserve(struct sk_buff *skb)
44 skb_reserve(skb, sizeof(struct can_skb_priv)); 44 skb_reserve(skb, sizeof(struct can_skb_priv));
45} 45}
46 46
47static inline void can_skb_destructor(struct sk_buff *skb)
48{
49 sock_put(skb->sk);
50}
51
52static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk) 47static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
53{ 48{
54 if (sk) { 49 if (sk) {
55 sock_hold(sk); 50 sock_hold(sk);
56 skb->destructor = can_skb_destructor; 51 skb->destructor = sock_efree;
57 skb->sk = sk; 52 skb->sk = sk;
58 } 53 }
59} 54}
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 439ff698000a..221025423e6c 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -43,6 +43,7 @@ enum dccp_state {
43 DCCP_CLOSING = TCP_CLOSING, 43 DCCP_CLOSING = TCP_CLOSING,
44 DCCP_TIME_WAIT = TCP_TIME_WAIT, 44 DCCP_TIME_WAIT = TCP_TIME_WAIT,
45 DCCP_CLOSED = TCP_CLOSE, 45 DCCP_CLOSED = TCP_CLOSE,
46 DCCP_NEW_SYN_RECV = TCP_NEW_SYN_RECV,
46 DCCP_PARTOPEN = TCP_MAX_STATES, 47 DCCP_PARTOPEN = TCP_MAX_STATES,
47 DCCP_PASSIVE_CLOSEREQ, /* clients receiving CloseReq */ 48 DCCP_PASSIVE_CLOSEREQ, /* clients receiving CloseReq */
48 DCCP_MAX_STATES 49 DCCP_MAX_STATES
@@ -57,6 +58,7 @@ enum {
57 DCCPF_CLOSING = TCPF_CLOSING, 58 DCCPF_CLOSING = TCPF_CLOSING,
58 DCCPF_TIME_WAIT = TCPF_TIME_WAIT, 59 DCCPF_TIME_WAIT = TCPF_TIME_WAIT,
59 DCCPF_CLOSED = TCPF_CLOSE, 60 DCCPF_CLOSED = TCPF_CLOSE,
61 DCCPF_NEW_SYN_RECV = TCPF_NEW_SYN_RECV,
60 DCCPF_PARTOPEN = (1 << DCCP_PARTOPEN), 62 DCCPF_PARTOPEN = (1 << DCCP_PARTOPEN),
61}; 63};
62 64
@@ -317,6 +319,6 @@ static inline const char *dccp_role(const struct sock *sk)
317 return NULL; 319 return NULL;
318} 320}
319 321
320extern void dccp_syn_ack_timeout(struct sock *sk, struct request_sock *req); 322extern void dccp_syn_ack_timeout(const struct request_sock *req);
321 323
322#endif /* _LINUX_DCCP_H */ 324#endif /* _LINUX_DCCP_H */
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 1d869d185a0d..606563ef8a72 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -35,7 +35,6 @@ extern const struct header_ops eth_header_ops;
35 35
36int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, 36int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
37 const void *daddr, const void *saddr, unsigned len); 37 const void *daddr, const void *saddr, unsigned len);
38int eth_rebuild_header(struct sk_buff *skb);
39int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); 38int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
40int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh, 39int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh,
41 __be16 type); 40 __be16 type);
diff --git a/include/linux/filter.h b/include/linux/filter.h
index caac2087a4d5..fa11b3a367be 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -145,8 +145,6 @@ struct bpf_prog_aux;
145 .off = 0, \ 145 .off = 0, \
146 .imm = ((__u64) (IMM)) >> 32 }) 146 .imm = ((__u64) (IMM)) >> 32 })
147 147
148#define BPF_PSEUDO_MAP_FD 1
149
150/* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ 148/* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
151#define BPF_LD_MAP_FD(DST, MAP_FD) \ 149#define BPF_LD_MAP_FD(DST, MAP_FD) \
152 BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD) 150 BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD)
@@ -310,9 +308,11 @@ struct bpf_binary_header {
310struct bpf_prog { 308struct bpf_prog {
311 u16 pages; /* Number of allocated pages */ 309 u16 pages; /* Number of allocated pages */
312 bool jited; /* Is our filter JIT'ed? */ 310 bool jited; /* Is our filter JIT'ed? */
311 bool gpl_compatible; /* Is our filter GPL compatible? */
313 u32 len; /* Number of filter blocks */ 312 u32 len; /* Number of filter blocks */
314 struct sock_fprog_kern *orig_prog; /* Original BPF program */ 313 enum bpf_prog_type type; /* Type of BPF program */
315 struct bpf_prog_aux *aux; /* Auxiliary fields */ 314 struct bpf_prog_aux *aux; /* Auxiliary fields */
315 struct sock_fprog_kern *orig_prog; /* Original BPF program */
316 unsigned int (*bpf_func)(const struct sk_buff *skb, 316 unsigned int (*bpf_func)(const struct sk_buff *skb,
317 const struct bpf_insn *filter); 317 const struct bpf_insn *filter);
318 /* Instructions for interpreter */ 318 /* Instructions for interpreter */
@@ -454,6 +454,7 @@ static inline u16 bpf_anc_helper(const struct sock_filter *ftest)
454 BPF_ANCILLARY(VLAN_TAG_PRESENT); 454 BPF_ANCILLARY(VLAN_TAG_PRESENT);
455 BPF_ANCILLARY(PAY_OFFSET); 455 BPF_ANCILLARY(PAY_OFFSET);
456 BPF_ANCILLARY(RANDOM); 456 BPF_ANCILLARY(RANDOM);
457 BPF_ANCILLARY(VLAN_TPID);
457 } 458 }
458 /* Fallthrough. */ 459 /* Fallthrough. */
459 default: 460 default:
diff --git a/include/linux/ieee802154.h b/include/linux/ieee802154.h
index 6e82d888287c..8872ca103d06 100644
--- a/include/linux/ieee802154.h
+++ b/include/linux/ieee802154.h
@@ -28,7 +28,9 @@
28#include <asm/byteorder.h> 28#include <asm/byteorder.h>
29 29
30#define IEEE802154_MTU 127 30#define IEEE802154_MTU 127
31#define IEEE802154_MIN_PSDU_LEN 5 31#define IEEE802154_ACK_PSDU_LEN 5
32#define IEEE802154_MIN_PSDU_LEN 9
33#define IEEE802154_FCS_LEN 2
32 34
33#define IEEE802154_PAN_ID_BROADCAST 0xffff 35#define IEEE802154_PAN_ID_BROADCAST 0xffff
34#define IEEE802154_ADDR_SHORT_BROADCAST 0xffff 36#define IEEE802154_ADDR_SHORT_BROADCAST 0xffff
@@ -38,6 +40,7 @@
38 40
39#define IEEE802154_LIFS_PERIOD 40 41#define IEEE802154_LIFS_PERIOD 40
40#define IEEE802154_SIFS_PERIOD 12 42#define IEEE802154_SIFS_PERIOD 12
43#define IEEE802154_MAX_SIFS_FRAME_SIZE 18
41 44
42#define IEEE802154_MAX_CHANNEL 26 45#define IEEE802154_MAX_CHANNEL 26
43#define IEEE802154_MAX_PAGE 31 46#define IEEE802154_MAX_PAGE 31
@@ -204,11 +207,18 @@ enum {
204 207
205/** 208/**
206 * ieee802154_is_valid_psdu_len - check if psdu len is valid 209 * ieee802154_is_valid_psdu_len - check if psdu len is valid
210 * available lengths:
211 * 0-4 Reserved
212 * 5 MPDU (Acknowledgment)
213 * 6-8 Reserved
214 * 9-127 MPDU
215 *
207 * @len: psdu len with (MHR + payload + MFR) 216 * @len: psdu len with (MHR + payload + MFR)
208 */ 217 */
209static inline bool ieee802154_is_valid_psdu_len(const u8 len) 218static inline bool ieee802154_is_valid_psdu_len(const u8 len)
210{ 219{
211 return (len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU); 220 return (len == IEEE802154_ACK_PSDU_LEN ||
221 (len >= IEEE802154_MIN_PSDU_LEN && len <= IEEE802154_MTU));
212} 222}
213 223
214/** 224/**
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
index a57bca2ea97e..dad8b00beed2 100644
--- a/include/linux/if_bridge.h
+++ b/include/linux/if_bridge.h
@@ -44,6 +44,7 @@ struct br_ip_list {
44#define BR_PROMISC BIT(7) 44#define BR_PROMISC BIT(7)
45#define BR_PROXYARP BIT(8) 45#define BR_PROXYARP BIT(8)
46#define BR_LEARNING_SYNC BIT(9) 46#define BR_LEARNING_SYNC BIT(9)
47#define BR_PROXYARP_WIFI BIT(10)
47 48
48extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *)); 49extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
49 50
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 119130e9298b..da4929927f69 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -14,5 +14,6 @@ struct ifla_vf_info {
14 __u32 linkstate; 14 __u32 linkstate;
15 __u32 min_tx_rate; 15 __u32 min_tx_rate;
16 __u32 max_tx_rate; 16 __u32 max_tx_rate;
17 __u32 rss_query_en;
17}; 18};
18#endif /* _LINUX_IF_LINK_H */ 19#endif /* _LINUX_IF_LINK_H */
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index aff7ad8a4ea3..66a7d7600f43 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -19,6 +19,7 @@
19#include <linux/netdevice.h> 19#include <linux/netdevice.h>
20#include <linux/ppp_channel.h> 20#include <linux/ppp_channel.h>
21#include <linux/skbuff.h> 21#include <linux/skbuff.h>
22#include <linux/workqueue.h>
22#include <uapi/linux/if_pppox.h> 23#include <uapi/linux/if_pppox.h>
23 24
24static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb) 25static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
@@ -32,6 +33,7 @@ struct pppoe_opt {
32 struct pppoe_addr pa; /* what this socket is bound to*/ 33 struct pppoe_addr pa; /* what this socket is bound to*/
33 struct sockaddr_pppox relay; /* what socket data will be 34 struct sockaddr_pppox relay; /* what socket data will be
34 relayed to (PPPoE relaying) */ 35 relayed to (PPPoE relaying) */
36 struct work_struct padt_work;/* Work item for handling PADT */
35}; 37};
36 38
37struct pptp_opt { 39struct pptp_opt {
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index b11b28a30b9e..920e4457ce6e 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -561,4 +561,71 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb,
561 skb->protocol = htons(ETH_P_802_2); 561 skb->protocol = htons(ETH_P_802_2);
562} 562}
563 563
564/**
565 * skb_vlan_tagged - check if skb is vlan tagged.
566 * @skb: skbuff to query
567 *
568 * Returns true if the skb is tagged, regardless of whether it is hardware
569 * accelerated or not.
570 */
571static inline bool skb_vlan_tagged(const struct sk_buff *skb)
572{
573 if (!skb_vlan_tag_present(skb) &&
574 likely(skb->protocol != htons(ETH_P_8021Q) &&
575 skb->protocol != htons(ETH_P_8021AD)))
576 return false;
577
578 return true;
579}
580
581/**
582 * skb_vlan_tagged_multi - check if skb is vlan tagged with multiple headers.
583 * @skb: skbuff to query
584 *
585 * Returns true if the skb is tagged with multiple vlan headers, regardless
586 * of whether it is hardware accelerated or not.
587 */
588static inline bool skb_vlan_tagged_multi(const struct sk_buff *skb)
589{
590 __be16 protocol = skb->protocol;
591
592 if (!skb_vlan_tag_present(skb)) {
593 struct vlan_ethhdr *veh;
594
595 if (likely(protocol != htons(ETH_P_8021Q) &&
596 protocol != htons(ETH_P_8021AD)))
597 return false;
598
599 veh = (struct vlan_ethhdr *)skb->data;
600 protocol = veh->h_vlan_encapsulated_proto;
601 }
602
603 if (protocol != htons(ETH_P_8021Q) && protocol != htons(ETH_P_8021AD))
604 return false;
605
606 return true;
607}
608
609/**
610 * vlan_features_check - drop unsafe features for skb with multiple tags.
611 * @skb: skbuff to query
612 * @features: features to be checked
613 *
614 * Returns features without unsafe ones if the skb has multiple tags.
615 */
616static inline netdev_features_t vlan_features_check(const struct sk_buff *skb,
617 netdev_features_t features)
618{
619 if (skb_vlan_tagged_multi(skb))
620 features = netdev_intersect_features(features,
621 NETIF_F_SG |
622 NETIF_F_HIGHDMA |
623 NETIF_F_FRAGLIST |
624 NETIF_F_GEN_CSUM |
625 NETIF_F_HW_VLAN_CTAG_TX |
626 NETIF_F_HW_VLAN_STAG_TX);
627
628 return features;
629}
630
564#endif /* !(_LINUX_IF_VLAN_H_) */ 631#endif /* !(_LINUX_IF_VLAN_H_) */
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 46da02410a09..ac48b10c9395 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -11,33 +11,34 @@ struct sk_buff;
11struct netlink_callback; 11struct netlink_callback;
12 12
13struct inet_diag_handler { 13struct inet_diag_handler {
14 void (*dump)(struct sk_buff *skb, 14 void (*dump)(struct sk_buff *skb,
15 struct netlink_callback *cb, 15 struct netlink_callback *cb,
16 struct inet_diag_req_v2 *r, 16 const struct inet_diag_req_v2 *r,
17 struct nlattr *bc); 17 struct nlattr *bc);
18 18
19 int (*dump_one)(struct sk_buff *in_skb, 19 int (*dump_one)(struct sk_buff *in_skb,
20 const struct nlmsghdr *nlh, 20 const struct nlmsghdr *nlh,
21 struct inet_diag_req_v2 *req); 21 const struct inet_diag_req_v2 *req);
22 22
23 void (*idiag_get_info)(struct sock *sk, 23 void (*idiag_get_info)(struct sock *sk,
24 struct inet_diag_msg *r, 24 struct inet_diag_msg *r,
25 void *info); 25 void *info);
26 __u16 idiag_type; 26 __u16 idiag_type;
27}; 27};
28 28
29struct inet_connection_sock; 29struct inet_connection_sock;
30int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, 30int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
31 struct sk_buff *skb, struct inet_diag_req_v2 *req, 31 struct sk_buff *skb, const struct inet_diag_req_v2 *req,
32 struct user_namespace *user_ns, 32 struct user_namespace *user_ns,
33 u32 pid, u32 seq, u16 nlmsg_flags, 33 u32 pid, u32 seq, u16 nlmsg_flags,
34 const struct nlmsghdr *unlh); 34 const struct nlmsghdr *unlh);
35void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb, 35void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
36 struct netlink_callback *cb, struct inet_diag_req_v2 *r, 36 struct netlink_callback *cb,
37 struct nlattr *bc); 37 const struct inet_diag_req_v2 *r,
38 struct nlattr *bc);
38int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, 39int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
39 struct sk_buff *in_skb, const struct nlmsghdr *nlh, 40 struct sk_buff *in_skb, const struct nlmsghdr *nlh,
40 struct inet_diag_req_v2 *req); 41 const struct inet_diag_req_v2 *req);
41 42
42int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk); 43int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
43 44
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 4d5169f5d7d1..82806c60aa42 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -53,6 +53,10 @@ struct ipv6_devconf {
53 __s32 ndisc_notify; 53 __s32 ndisc_notify;
54 __s32 suppress_frag_ndisc; 54 __s32 suppress_frag_ndisc;
55 __s32 accept_ra_mtu; 55 __s32 accept_ra_mtu;
56 struct ipv6_stable_secret {
57 bool initialized;
58 struct in6_addr secret;
59 } stable_secret;
56 void *sysctl; 60 void *sysctl;
57}; 61};
58 62
diff --git a/include/linux/jhash.h b/include/linux/jhash.h
index 47cb09edec1a..348c6f47e4cc 100644
--- a/include/linux/jhash.h
+++ b/include/linux/jhash.h
@@ -145,11 +145,11 @@ static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
145} 145}
146 146
147 147
148/* jhash_3words - hash exactly 3, 2 or 1 word(s) */ 148/* __jhash_nwords - hash exactly 3, 2 or 1 word(s) */
149static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval) 149static inline u32 __jhash_nwords(u32 a, u32 b, u32 c, u32 initval)
150{ 150{
151 a += JHASH_INITVAL; 151 a += initval;
152 b += JHASH_INITVAL; 152 b += initval;
153 c += initval; 153 c += initval;
154 154
155 __jhash_final(a, b, c); 155 __jhash_final(a, b, c);
@@ -157,14 +157,19 @@ static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
157 return c; 157 return c;
158} 158}
159 159
160static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
161{
162 return __jhash_nwords(a, b, c, initval + JHASH_INITVAL + (3 << 2));
163}
164
160static inline u32 jhash_2words(u32 a, u32 b, u32 initval) 165static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
161{ 166{
162 return jhash_3words(a, b, 0, initval); 167 return __jhash_nwords(a, b, 0, initval + JHASH_INITVAL + (2 << 2));
163} 168}
164 169
165static inline u32 jhash_1word(u32 a, u32 initval) 170static inline u32 jhash_1word(u32 a, u32 initval)
166{ 171{
167 return jhash_3words(a, 0, 0, initval); 172 return __jhash_nwords(a, 0, 0, initval + JHASH_INITVAL + (1 << 2));
168} 173}
169 174
170#endif /* _LINUX_JHASH_H */ 175#endif /* _LINUX_JHASH_H */
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h
index 7b6d4e9ff603..f62e7cf227c6 100644
--- a/include/linux/mlx4/cmd.h
+++ b/include/linux/mlx4/cmd.h
@@ -68,6 +68,8 @@ enum {
68 MLX4_CMD_UNMAP_ICM_AUX = 0xffb, 68 MLX4_CMD_UNMAP_ICM_AUX = 0xffb,
69 MLX4_CMD_SET_ICM_SIZE = 0xffd, 69 MLX4_CMD_SET_ICM_SIZE = 0xffd,
70 MLX4_CMD_ACCESS_REG = 0x3b, 70 MLX4_CMD_ACCESS_REG = 0x3b,
71 MLX4_CMD_ALLOCATE_VPP = 0x80,
72 MLX4_CMD_SET_VPORT_QOS = 0x81,
71 73
72 /*master notify fw on finish for slave's flr*/ 74 /*master notify fw on finish for slave's flr*/
73 MLX4_CMD_INFORM_FLR_DONE = 0x5b, 75 MLX4_CMD_INFORM_FLR_DONE = 0x5b,
@@ -163,6 +165,9 @@ enum {
163 MLX4_QP_FLOW_STEERING_ATTACH = 0x65, 165 MLX4_QP_FLOW_STEERING_ATTACH = 0x65,
164 MLX4_QP_FLOW_STEERING_DETACH = 0x66, 166 MLX4_QP_FLOW_STEERING_DETACH = 0x66,
165 MLX4_FLOW_STEERING_IB_UC_QP_RANGE = 0x64, 167 MLX4_FLOW_STEERING_IB_UC_QP_RANGE = 0x64,
168
169 /* Update and read QCN parameters */
170 MLX4_CMD_CONGESTION_CTRL_OPCODE = 0x68,
166}; 171};
167 172
168enum { 173enum {
@@ -183,7 +188,14 @@ enum {
183}; 188};
184 189
185enum { 190enum {
186 /* set port opcode modifiers */ 191 /* Set port opcode modifiers */
192 MLX4_SET_PORT_IB_OPCODE = 0x0,
193 MLX4_SET_PORT_ETH_OPCODE = 0x1,
194 MLX4_SET_PORT_BEACON_OPCODE = 0x4,
195};
196
197enum {
198 /* Set port Ethernet input modifiers */
187 MLX4_SET_PORT_GENERAL = 0x0, 199 MLX4_SET_PORT_GENERAL = 0x0,
188 MLX4_SET_PORT_RQP_CALC = 0x1, 200 MLX4_SET_PORT_RQP_CALC = 0x1,
189 MLX4_SET_PORT_MAC_TABLE = 0x2, 201 MLX4_SET_PORT_MAC_TABLE = 0x2,
@@ -233,6 +245,16 @@ struct mlx4_config_dev_params {
233 u8 rx_csum_flags_port_2; 245 u8 rx_csum_flags_port_2;
234}; 246};
235 247
248enum mlx4_en_congestion_control_algorithm {
249 MLX4_CTRL_ALGO_802_1_QAU_REACTION_POINT = 0,
250};
251
252enum mlx4_en_congestion_control_opmod {
253 MLX4_CONGESTION_CONTROL_GET_PARAMS,
254 MLX4_CONGESTION_CONTROL_GET_STATISTICS,
255 MLX4_CONGESTION_CONTROL_SET_PARAMS = 4,
256};
257
236struct mlx4_dev; 258struct mlx4_dev;
237 259
238struct mlx4_cmd_mailbox { 260struct mlx4_cmd_mailbox {
@@ -281,6 +303,8 @@ void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbo
281u32 mlx4_comm_get_version(void); 303u32 mlx4_comm_get_version(void);
282int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac); 304int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac);
283int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos); 305int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos);
306int mlx4_set_vf_rate(struct mlx4_dev *dev, int port, int vf, int min_tx_rate,
307 int max_tx_rate);
284int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting); 308int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting);
285int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_info *ivf); 309int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_info *ivf);
286int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int link_state); 310int mlx4_set_vf_link_state(struct mlx4_dev *dev, int port, int vf, int link_state);
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index e4ebff7e9d02..f9ce34bec45b 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -49,8 +49,6 @@
49#define MSIX_LEGACY_SZ 4 49#define MSIX_LEGACY_SZ 4
50#define MIN_MSIX_P_PORT 5 50#define MIN_MSIX_P_PORT 5
51 51
52#define MLX4_NUM_UP 8
53#define MLX4_NUM_TC 8
54#define MLX4_MAX_100M_UNITS_VAL 255 /* 52#define MLX4_MAX_100M_UNITS_VAL 255 /*
55 * work around: can't set values 53 * work around: can't set values
56 * greater then this value when 54 * greater then this value when
@@ -174,6 +172,7 @@ enum {
174 MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41, 172 MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41,
175 MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42, 173 MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42,
176 MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48, 174 MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48,
175 MLX4_DEV_CAP_FLAG_RSS_IP_FRAG = 1LL << 52,
177 MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 1LL << 53, 176 MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 1LL << 53,
178 MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55, 177 MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55,
179 MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59, 178 MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59,
@@ -203,7 +202,14 @@ enum {
203 MLX4_DEV_CAP_FLAG2_80_VFS = 1LL << 18, 202 MLX4_DEV_CAP_FLAG2_80_VFS = 1LL << 18,
204 MLX4_DEV_CAP_FLAG2_FS_A0 = 1LL << 19, 203 MLX4_DEV_CAP_FLAG2_FS_A0 = 1LL << 19,
205 MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 20, 204 MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT = 1LL << 20,
206 MLX4_DEV_CAP_FLAG2_PORT_REMAP = 1LL << 21 205 MLX4_DEV_CAP_FLAG2_PORT_REMAP = 1LL << 21,
206 MLX4_DEV_CAP_FLAG2_QCN = 1LL << 22,
207 MLX4_DEV_CAP_FLAG2_QP_RATE_LIMIT = 1LL << 23,
208 MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN = 1LL << 24,
209 MLX4_DEV_CAP_FLAG2_QOS_VPP = 1LL << 25,
210 MLX4_DEV_CAP_FLAG2_ETS_CFG = 1LL << 26,
211 MLX4_DEV_CAP_FLAG2_PORT_BEACON = 1LL << 27,
212 MLX4_DEV_CAP_FLAG2_IGNORE_FCS = 1LL << 28,
207}; 213};
208 214
209enum { 215enum {
@@ -449,6 +455,21 @@ enum mlx4_module_id {
449 MLX4_MODULE_ID_QSFP28 = 0x11, 455 MLX4_MODULE_ID_QSFP28 = 0x11,
450}; 456};
451 457
458enum { /* rl */
459 MLX4_QP_RATE_LIMIT_NONE = 0,
460 MLX4_QP_RATE_LIMIT_KBS = 1,
461 MLX4_QP_RATE_LIMIT_MBS = 2,
462 MLX4_QP_RATE_LIMIT_GBS = 3
463};
464
465struct mlx4_rate_limit_caps {
466 u16 num_rates; /* Number of different rates */
467 u8 min_unit;
468 u16 min_val;
469 u8 max_unit;
470 u16 max_val;
471};
472
452static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor) 473static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
453{ 474{
454 return (major << 32) | (minor << 16) | subminor; 475 return (major << 32) | (minor << 16) | subminor;
@@ -564,6 +585,7 @@ struct mlx4_caps {
564 u32 dmfs_high_rate_qpn_base; 585 u32 dmfs_high_rate_qpn_base;
565 u32 dmfs_high_rate_qpn_range; 586 u32 dmfs_high_rate_qpn_range;
566 u32 vf_caps; 587 u32 vf_caps;
588 struct mlx4_rate_limit_caps rl_caps;
567}; 589};
568 590
569struct mlx4_buf_list { 591struct mlx4_buf_list {
@@ -982,6 +1004,11 @@ static inline int mlx4_is_slave(struct mlx4_dev *dev)
982 return dev->flags & MLX4_FLAG_SLAVE; 1004 return dev->flags & MLX4_FLAG_SLAVE;
983} 1005}
984 1006
1007static inline int mlx4_is_eth(struct mlx4_dev *dev, int port)
1008{
1009 return dev->caps.port_type[port] == MLX4_PORT_TYPE_IB ? 0 : 1;
1010}
1011
985int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, 1012int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
986 struct mlx4_buf *buf, gfp_t gfp); 1013 struct mlx4_buf *buf, gfp_t gfp);
987void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); 1014void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf);
@@ -1282,14 +1309,13 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
1282void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac); 1309void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
1283int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port); 1310int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port);
1284int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac); 1311int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
1285void mlx4_set_stats_bitmap(struct mlx4_dev *dev, u64 *stats_bitmap);
1286int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, 1312int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
1287 u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); 1313 u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
1288int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, 1314int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
1289 u8 promisc); 1315 u8 promisc);
1290int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc); 1316int mlx4_SET_PORT_BEACON(struct mlx4_dev *dev, u8 port, u16 time);
1291int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw, 1317int mlx4_SET_PORT_fcs_check(struct mlx4_dev *dev, u8 port,
1292 u8 *pg, u16 *ratelimit); 1318 u8 ignore_fcs_value);
1293int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable); 1319int mlx4_SET_PORT_VXLAN(struct mlx4_dev *dev, u8 port, u8 steering, int enable);
1294int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx); 1320int mlx4_find_cached_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *idx);
1295int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 1321int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
index 551f85456c11..6fed539e5456 100644
--- a/include/linux/mlx4/qp.h
+++ b/include/linux/mlx4/qp.h
@@ -207,14 +207,17 @@ struct mlx4_qp_context {
207 __be32 msn; 207 __be32 msn;
208 __be16 rq_wqe_counter; 208 __be16 rq_wqe_counter;
209 __be16 sq_wqe_counter; 209 __be16 sq_wqe_counter;
210 u32 reserved3[2]; 210 u32 reserved3;
211 __be16 rate_limit_params;
212 u8 reserved4;
213 u8 qos_vport;
211 __be32 param3; 214 __be32 param3;
212 __be32 nummmcpeers_basemkey; 215 __be32 nummmcpeers_basemkey;
213 u8 log_page_size; 216 u8 log_page_size;
214 u8 reserved4[2]; 217 u8 reserved5[2];
215 u8 mtt_base_addr_h; 218 u8 mtt_base_addr_h;
216 __be32 mtt_base_addr_l; 219 __be32 mtt_base_addr_l;
217 u32 reserved5[10]; 220 u32 reserved6[10];
218}; 221};
219 222
220struct mlx4_update_qp_context { 223struct mlx4_update_qp_context {
@@ -229,6 +232,8 @@ struct mlx4_update_qp_context {
229enum { 232enum {
230 MLX4_UPD_QP_MASK_PM_STATE = 32, 233 MLX4_UPD_QP_MASK_PM_STATE = 32,
231 MLX4_UPD_QP_MASK_VSD = 33, 234 MLX4_UPD_QP_MASK_VSD = 33,
235 MLX4_UPD_QP_MASK_QOS_VPP = 34,
236 MLX4_UPD_QP_MASK_RATE_LIMIT = 35,
232}; 237};
233 238
234enum { 239enum {
@@ -428,7 +433,9 @@ struct mlx4_wqe_inline_seg {
428enum mlx4_update_qp_attr { 433enum mlx4_update_qp_attr {
429 MLX4_UPDATE_QP_SMAC = 1 << 0, 434 MLX4_UPDATE_QP_SMAC = 1 << 0,
430 MLX4_UPDATE_QP_VSD = 1 << 1, 435 MLX4_UPDATE_QP_VSD = 1 << 1,
431 MLX4_UPDATE_QP_SUPPORTED_ATTRS = (1 << 2) - 1 436 MLX4_UPDATE_QP_RATE_LIMIT = 1 << 2,
437 MLX4_UPDATE_QP_QOS_VPORT = 1 << 3,
438 MLX4_UPDATE_QP_SUPPORTED_ATTRS = (1 << 4) - 1
432}; 439};
433 440
434enum mlx4_update_qp_params_flags { 441enum mlx4_update_qp_params_flags {
@@ -437,7 +444,10 @@ enum mlx4_update_qp_params_flags {
437 444
438struct mlx4_update_qp_params { 445struct mlx4_update_qp_params {
439 u8 smac_index; 446 u8 smac_index;
447 u8 qos_vport;
440 u32 flags; 448 u32 flags;
449 u16 rate_unit;
450 u16 rate_val;
441}; 451};
442 452
443int mlx4_update_qp(struct mlx4_dev *dev, u32 qpn, 453int mlx4_update_qp(struct mlx4_dev *dev, u32 qpn,
diff --git a/include/linux/mlx5/cmd.h b/include/linux/mlx5/cmd.h
index 2826a4b6071e..68cd08f02c2f 100644
--- a/include/linux/mlx5/cmd.h
+++ b/include/linux/mlx5/cmd.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/include/linux/mlx5/cq.h b/include/linux/mlx5/cq.h
index f6b17ac601bd..2695ced222df 100644
--- a/include/linux/mlx5/cq.h
+++ b/include/linux/mlx5/cq.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -137,14 +137,15 @@ enum {
137 137
138static inline void mlx5_cq_arm(struct mlx5_core_cq *cq, u32 cmd, 138static inline void mlx5_cq_arm(struct mlx5_core_cq *cq, u32 cmd,
139 void __iomem *uar_page, 139 void __iomem *uar_page,
140 spinlock_t *doorbell_lock) 140 spinlock_t *doorbell_lock,
141 u32 cons_index)
141{ 142{
142 __be32 doorbell[2]; 143 __be32 doorbell[2];
143 u32 sn; 144 u32 sn;
144 u32 ci; 145 u32 ci;
145 146
146 sn = cq->arm_sn & 3; 147 sn = cq->arm_sn & 3;
147 ci = cq->cons_index & 0xffffff; 148 ci = cons_index & 0xffffff;
148 149
149 *cq->arm_db = cpu_to_be32(sn << 28 | cmd | ci); 150 *cq->arm_db = cpu_to_be32(sn << 28 | cmd | ci);
150 151
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 4e5bd813bb9a..abf65c790421 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/include/linux/mlx5/doorbell.h b/include/linux/mlx5/doorbell.h
index 163a818411e7..afc78a3f4462 100644
--- a/include/linux/mlx5/doorbell.h
+++ b/include/linux/mlx5/doorbell.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 166d9315fe4b..9a90e7523dc2 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -232,6 +232,9 @@ struct mlx5_cmd_stats {
232}; 232};
233 233
234struct mlx5_cmd { 234struct mlx5_cmd {
235 void *cmd_alloc_buf;
236 dma_addr_t alloc_dma;
237 int alloc_size;
235 void *cmd_buf; 238 void *cmd_buf;
236 dma_addr_t dma; 239 dma_addr_t dma;
237 u16 cmdif_rev; 240 u16 cmdif_rev;
@@ -407,7 +410,7 @@ struct mlx5_core_srq {
407struct mlx5_eq_table { 410struct mlx5_eq_table {
408 void __iomem *update_ci; 411 void __iomem *update_ci;
409 void __iomem *update_arm_ci; 412 void __iomem *update_arm_ci;
410 struct list_head *comp_eq_head; 413 struct list_head comp_eqs_list;
411 struct mlx5_eq pages_eq; 414 struct mlx5_eq pages_eq;
412 struct mlx5_eq async_eq; 415 struct mlx5_eq async_eq;
413 struct mlx5_eq cmd_eq; 416 struct mlx5_eq cmd_eq;
@@ -722,6 +725,7 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
722int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq); 725int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
723int mlx5_start_eqs(struct mlx5_core_dev *dev); 726int mlx5_start_eqs(struct mlx5_core_dev *dev);
724int mlx5_stop_eqs(struct mlx5_core_dev *dev); 727int mlx5_stop_eqs(struct mlx5_core_dev *dev);
728int mlx5_vector2eqn(struct mlx5_core_dev *dev, int vector, int *eqn, int *irqn);
725int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn); 729int mlx5_core_attach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
726int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn); 730int mlx5_core_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid, u32 qpn);
727 731
@@ -777,14 +781,22 @@ enum {
777 MAX_MR_CACHE_ENTRIES = 16, 781 MAX_MR_CACHE_ENTRIES = 16,
778}; 782};
779 783
784enum {
785 MLX5_INTERFACE_PROTOCOL_IB = 0,
786 MLX5_INTERFACE_PROTOCOL_ETH = 1,
787};
788
780struct mlx5_interface { 789struct mlx5_interface {
781 void * (*add)(struct mlx5_core_dev *dev); 790 void * (*add)(struct mlx5_core_dev *dev);
782 void (*remove)(struct mlx5_core_dev *dev, void *context); 791 void (*remove)(struct mlx5_core_dev *dev, void *context);
783 void (*event)(struct mlx5_core_dev *dev, void *context, 792 void (*event)(struct mlx5_core_dev *dev, void *context,
784 enum mlx5_dev_event event, unsigned long param); 793 enum mlx5_dev_event event, unsigned long param);
794 void * (*get_dev)(void *context);
795 int protocol;
785 struct list_head list; 796 struct list_head list;
786}; 797};
787 798
799void *mlx5_get_protocol_dev(struct mlx5_core_dev *mdev, int protocol);
788int mlx5_register_interface(struct mlx5_interface *intf); 800int mlx5_register_interface(struct mlx5_interface *intf);
789void mlx5_unregister_interface(struct mlx5_interface *intf); 801void mlx5_unregister_interface(struct mlx5_interface *intf);
790 802
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 5f48b8f592c5..cb3ad17edd1f 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2014, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h
index 61f7a342d1bf..310b5f7fd6ae 100644
--- a/include/linux/mlx5/qp.h
+++ b/include/linux/mlx5/qp.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/include/linux/mlx5/srq.h b/include/linux/mlx5/srq.h
index e1a363a33663..f43ed054a3e0 100644
--- a/include/linux/mlx5/srq.h
+++ b/include/linux/mlx5/srq.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2013, Mellanox Technologies inc. All rights reserved. 2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h
index 996807963716..83430f2ea757 100644
--- a/include/linux/mmc/sdio_ids.h
+++ b/include/linux/mmc/sdio_ids.h
@@ -33,6 +33,8 @@
33#define SDIO_DEVICE_ID_BROADCOM_43341 0xa94d 33#define SDIO_DEVICE_ID_BROADCOM_43341 0xa94d
34#define SDIO_DEVICE_ID_BROADCOM_4335_4339 0x4335 34#define SDIO_DEVICE_ID_BROADCOM_4335_4339 0x4335
35#define SDIO_DEVICE_ID_BROADCOM_43362 0xa962 35#define SDIO_DEVICE_ID_BROADCOM_43362 0xa962
36#define SDIO_DEVICE_ID_BROADCOM_43430 0xa9a6
37#define SDIO_DEVICE_ID_BROADCOM_4345 0x4345
36#define SDIO_DEVICE_ID_BROADCOM_4354 0x4354 38#define SDIO_DEVICE_ID_BROADCOM_4354 0x4354
37 39
38#define SDIO_VENDOR_ID_INTEL 0x0089 40#define SDIO_VENDOR_ID_INTEL 0x0089
diff --git a/include/linux/net.h b/include/linux/net.h
index 17d83393afcc..738ea48be889 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -120,7 +120,6 @@ struct socket {
120 120
121struct vm_area_struct; 121struct vm_area_struct;
122struct page; 122struct page;
123struct kiocb;
124struct sockaddr; 123struct sockaddr;
125struct msghdr; 124struct msghdr;
126struct module; 125struct module;
@@ -162,8 +161,8 @@ struct proto_ops {
162 int (*compat_getsockopt)(struct socket *sock, int level, 161 int (*compat_getsockopt)(struct socket *sock, int level,
163 int optname, char __user *optval, int __user *optlen); 162 int optname, char __user *optval, int __user *optlen);
164#endif 163#endif
165 int (*sendmsg) (struct kiocb *iocb, struct socket *sock, 164 int (*sendmsg) (struct socket *sock, struct msghdr *m,
166 struct msghdr *m, size_t total_len); 165 size_t total_len);
167 /* Notes for implementing recvmsg: 166 /* Notes for implementing recvmsg:
168 * =============================== 167 * ===============================
169 * msg->msg_namelen should get updated by the recvmsg handlers 168 * msg->msg_namelen should get updated by the recvmsg handlers
@@ -172,9 +171,8 @@ struct proto_ops {
172 * handlers can assume that msg.msg_name is either NULL or has 171 * handlers can assume that msg.msg_name is either NULL or has
173 * a minimum size of sizeof(struct sockaddr_storage). 172 * a minimum size of sizeof(struct sockaddr_storage).
174 */ 173 */
175 int (*recvmsg) (struct kiocb *iocb, struct socket *sock, 174 int (*recvmsg) (struct socket *sock, struct msghdr *m,
176 struct msghdr *m, size_t total_len, 175 size_t total_len, int flags);
177 int flags);
178 int (*mmap) (struct file *file, struct socket *sock, 176 int (*mmap) (struct file *file, struct socket *sock,
179 struct vm_area_struct * vma); 177 struct vm_area_struct * vma);
180 ssize_t (*sendpage) (struct socket *sock, struct page *page, 178 ssize_t (*sendpage) (struct socket *sock, struct page *page,
@@ -213,7 +211,7 @@ int sock_create(int family, int type, int proto, struct socket **res);
213int sock_create_kern(int family, int type, int proto, struct socket **res); 211int sock_create_kern(int family, int type, int proto, struct socket **res);
214int sock_create_lite(int family, int type, int proto, struct socket **res); 212int sock_create_lite(int family, int type, int proto, struct socket **res);
215void sock_release(struct socket *sock); 213void sock_release(struct socket *sock);
216int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len); 214int sock_sendmsg(struct socket *sock, struct msghdr *msg);
217int sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, 215int sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
218 int flags); 216 int flags);
219struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname); 217struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 278738873703..b5679aed660b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -261,7 +261,6 @@ struct header_ops {
261 unsigned short type, const void *daddr, 261 unsigned short type, const void *daddr,
262 const void *saddr, unsigned int len); 262 const void *saddr, unsigned int len);
263 int (*parse)(const struct sk_buff *skb, unsigned char *haddr); 263 int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
264 int (*rebuild)(struct sk_buff *skb);
265 int (*cache)(const struct neighbour *neigh, struct hh_cache *hh, __be16 type); 264 int (*cache)(const struct neighbour *neigh, struct hh_cache *hh, __be16 type);
266 void (*cache_update)(struct hh_cache *hh, 265 void (*cache_update)(struct hh_cache *hh,
267 const struct net_device *dev, 266 const struct net_device *dev,
@@ -588,6 +587,7 @@ struct netdev_queue {
588#ifdef CONFIG_BQL 587#ifdef CONFIG_BQL
589 struct dql dql; 588 struct dql dql;
590#endif 589#endif
590 unsigned long tx_maxrate;
591} ____cacheline_aligned_in_smp; 591} ____cacheline_aligned_in_smp;
592 592
593static inline int netdev_queue_numa_node_read(const struct netdev_queue *q) 593static inline int netdev_queue_numa_node_read(const struct netdev_queue *q)
@@ -795,7 +795,10 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
795 * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb, 795 * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb,
796 * struct net_device *dev); 796 * struct net_device *dev);
797 * Called when a packet needs to be transmitted. 797 * Called when a packet needs to be transmitted.
798 * Must return NETDEV_TX_OK , NETDEV_TX_BUSY. 798 * Returns NETDEV_TX_OK. Can return NETDEV_TX_BUSY, but you should stop
799 * the queue before that can happen; it's for obsolete devices and weird
800 * corner cases, but the stack really does a non-trivial amount
801 * of useless work if you return NETDEV_TX_BUSY.
799 * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX) 802 * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
800 * Required can not be NULL. 803 * Required can not be NULL.
801 * 804 *
@@ -875,6 +878,11 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
875 * int (*ndo_set_vf_link_state)(struct net_device *dev, int vf, int link_state); 878 * int (*ndo_set_vf_link_state)(struct net_device *dev, int vf, int link_state);
876 * int (*ndo_set_vf_port)(struct net_device *dev, int vf, 879 * int (*ndo_set_vf_port)(struct net_device *dev, int vf,
877 * struct nlattr *port[]); 880 * struct nlattr *port[]);
881 *
882 * Enable or disable the VF ability to query its RSS Redirection Table and
883 * Hash Key. This is needed since on some devices VF share this information
884 * with PF and querying it may adduce a theoretical security risk.
885 * int (*ndo_set_vf_rss_query_en)(struct net_device *dev, int vf, bool setting);
878 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); 886 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb);
879 * int (*ndo_setup_tc)(struct net_device *dev, u8 tc) 887 * int (*ndo_setup_tc)(struct net_device *dev, u8 tc)
880 * Called to setup 'tc' number of traffic classes in the net device. This 888 * Called to setup 'tc' number of traffic classes in the net device. This
@@ -1026,15 +1034,12 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
1026 * be otherwise expressed by feature flags. The check is called with 1034 * be otherwise expressed by feature flags. The check is called with
1027 * the set of features that the stack has calculated and it returns 1035 * the set of features that the stack has calculated and it returns
1028 * those the driver believes to be appropriate. 1036 * those the driver believes to be appropriate.
1029 * 1037 * int (*ndo_set_tx_maxrate)(struct net_device *dev,
1030 * int (*ndo_switch_parent_id_get)(struct net_device *dev, 1038 * int queue_index, u32 maxrate);
1031 * struct netdev_phys_item_id *psid); 1039 * Called when a user wants to set a max-rate limitation of specific
1032 * Called to get an ID of the switch chip this port is part of. 1040 * TX queue.
1033 * If driver implements this, it indicates that it represents a port 1041 * int (*ndo_get_iflink)(const struct net_device *dev);
1034 * of a switch chip. 1042 * Called to get the iflink value of this device.
1035 * int (*ndo_switch_port_stp_update)(struct net_device *dev, u8 state);
1036 * Called to notify switch device port of bridge port STP
1037 * state change.
1038 */ 1043 */
1039struct net_device_ops { 1044struct net_device_ops {
1040 int (*ndo_init)(struct net_device *dev); 1045 int (*ndo_init)(struct net_device *dev);
@@ -1099,6 +1104,9 @@ struct net_device_ops {
1099 struct nlattr *port[]); 1104 struct nlattr *port[]);
1100 int (*ndo_get_vf_port)(struct net_device *dev, 1105 int (*ndo_get_vf_port)(struct net_device *dev,
1101 int vf, struct sk_buff *skb); 1106 int vf, struct sk_buff *skb);
1107 int (*ndo_set_vf_rss_query_en)(
1108 struct net_device *dev,
1109 int vf, bool setting);
1102 int (*ndo_setup_tc)(struct net_device *dev, u8 tc); 1110 int (*ndo_setup_tc)(struct net_device *dev, u8 tc);
1103#if IS_ENABLED(CONFIG_FCOE) 1111#if IS_ENABLED(CONFIG_FCOE)
1104 int (*ndo_fcoe_enable)(struct net_device *dev); 1112 int (*ndo_fcoe_enable)(struct net_device *dev);
@@ -1172,6 +1180,8 @@ struct net_device_ops {
1172 bool new_carrier); 1180 bool new_carrier);
1173 int (*ndo_get_phys_port_id)(struct net_device *dev, 1181 int (*ndo_get_phys_port_id)(struct net_device *dev,
1174 struct netdev_phys_item_id *ppid); 1182 struct netdev_phys_item_id *ppid);
1183 int (*ndo_get_phys_port_name)(struct net_device *dev,
1184 char *name, size_t len);
1175 void (*ndo_add_vxlan_port)(struct net_device *dev, 1185 void (*ndo_add_vxlan_port)(struct net_device *dev,
1176 sa_family_t sa_family, 1186 sa_family_t sa_family,
1177 __be16 port); 1187 __be16 port);
@@ -1191,12 +1201,10 @@ struct net_device_ops {
1191 netdev_features_t (*ndo_features_check) (struct sk_buff *skb, 1201 netdev_features_t (*ndo_features_check) (struct sk_buff *skb,
1192 struct net_device *dev, 1202 struct net_device *dev,
1193 netdev_features_t features); 1203 netdev_features_t features);
1194#ifdef CONFIG_NET_SWITCHDEV 1204 int (*ndo_set_tx_maxrate)(struct net_device *dev,
1195 int (*ndo_switch_parent_id_get)(struct net_device *dev, 1205 int queue_index,
1196 struct netdev_phys_item_id *psid); 1206 u32 maxrate);
1197 int (*ndo_switch_port_stp_update)(struct net_device *dev, 1207 int (*ndo_get_iflink)(const struct net_device *dev);
1198 u8 state);
1199#endif
1200}; 1208};
1201 1209
1202/** 1210/**
@@ -1305,6 +1313,8 @@ enum netdev_priv_flags {
1305 * @base_addr: Device I/O address 1313 * @base_addr: Device I/O address
1306 * @irq: Device IRQ number 1314 * @irq: Device IRQ number
1307 * 1315 *
1316 * @carrier_changes: Stats to monitor carrier on<->off transitions
1317 *
1308 * @state: Generic network queuing layer state, see netdev_state_t 1318 * @state: Generic network queuing layer state, see netdev_state_t
1309 * @dev_list: The global list of network devices 1319 * @dev_list: The global list of network devices
1310 * @napi_list: List entry, that is used for polling napi devices 1320 * @napi_list: List entry, that is used for polling napi devices
@@ -1328,7 +1338,7 @@ enum netdev_priv_flags {
1328 * @mpls_features: Mask of features inheritable by MPLS 1338 * @mpls_features: Mask of features inheritable by MPLS
1329 * 1339 *
1330 * @ifindex: interface index 1340 * @ifindex: interface index
1331 * @iflink: unique device identifier 1341 * @group: The group, that the device belongs to
1332 * 1342 *
1333 * @stats: Statistics struct, which was left as a legacy, use 1343 * @stats: Statistics struct, which was left as a legacy, use
1334 * rtnl_link_stats64 instead 1344 * rtnl_link_stats64 instead
@@ -1338,8 +1348,6 @@ enum netdev_priv_flags {
1338 * @tx_dropped: Dropped packets by core network, 1348 * @tx_dropped: Dropped packets by core network,
1339 * do not use this in drivers 1349 * do not use this in drivers
1340 * 1350 *
1341 * @carrier_changes: Stats to monitor carrier on<->off transitions
1342 *
1343 * @wireless_handlers: List of functions to handle Wireless Extensions, 1351 * @wireless_handlers: List of functions to handle Wireless Extensions,
1344 * instead of ioctl, 1352 * instead of ioctl,
1345 * see <net/iw_handler.h> for details. 1353 * see <net/iw_handler.h> for details.
@@ -1348,8 +1356,7 @@ enum netdev_priv_flags {
1348 * @netdev_ops: Includes several pointers to callbacks, 1356 * @netdev_ops: Includes several pointers to callbacks,
1349 * if one wants to override the ndo_*() functions 1357 * if one wants to override the ndo_*() functions
1350 * @ethtool_ops: Management operations 1358 * @ethtool_ops: Management operations
1351 * @fwd_ops: Management operations 1359 * @header_ops: Includes callbacks for creating,parsing,caching,etc
1352 * @header_ops: Includes callbacks for creating,parsing,rebuilding,etc
1353 * of Layer 2 headers. 1360 * of Layer 2 headers.
1354 * 1361 *
1355 * @flags: Interface flags (a la BSD) 1362 * @flags: Interface flags (a la BSD)
@@ -1383,14 +1390,14 @@ enum netdev_priv_flags {
1383 * @dev_port: Used to differentiate devices that share 1390 * @dev_port: Used to differentiate devices that share
1384 * the same function 1391 * the same function
1385 * @addr_list_lock: XXX: need comments on this one 1392 * @addr_list_lock: XXX: need comments on this one
1386 * @uc: unicast mac addresses
1387 * @mc: multicast mac addresses
1388 * @dev_addrs: list of device hw addresses
1389 * @queues_kset: Group of all Kobjects in the Tx and RX queues
1390 * @uc_promisc: Counter, that indicates, that promiscuous mode 1393 * @uc_promisc: Counter, that indicates, that promiscuous mode
1391 * has been enabled due to the need to listen to 1394 * has been enabled due to the need to listen to
1392 * additional unicast addresses in a device that 1395 * additional unicast addresses in a device that
1393 * does not implement ndo_set_rx_mode() 1396 * does not implement ndo_set_rx_mode()
1397 * @uc: unicast mac addresses
1398 * @mc: multicast mac addresses
1399 * @dev_addrs: list of device hw addresses
1400 * @queues_kset: Group of all Kobjects in the Tx and RX queues
1394 * @promiscuity: Number of times, the NIC is told to work in 1401 * @promiscuity: Number of times, the NIC is told to work in
1395 * Promiscuous mode, if it becomes 0 the NIC will 1402 * Promiscuous mode, if it becomes 0 the NIC will
1396 * exit from working in Promiscuous mode 1403 * exit from working in Promiscuous mode
@@ -1420,6 +1427,12 @@ enum netdev_priv_flags {
1420 * @ingress_queue: XXX: need comments on this one 1427 * @ingress_queue: XXX: need comments on this one
1421 * @broadcast: hw bcast address 1428 * @broadcast: hw bcast address
1422 * 1429 *
1430 * @rx_cpu_rmap: CPU reverse-mapping for RX completion interrupts,
1431 * indexed by RX queue number. Assigned by driver.
1432 * This must only be set if the ndo_rx_flow_steer
1433 * operation is defined
1434 * @index_hlist: Device index hash chain
1435 *
1423 * @_tx: Array of TX queues 1436 * @_tx: Array of TX queues
1424 * @num_tx_queues: Number of TX queues allocated at alloc_netdev_mq() time 1437 * @num_tx_queues: Number of TX queues allocated at alloc_netdev_mq() time
1425 * @real_num_tx_queues: Number of TX queues currently active in device 1438 * @real_num_tx_queues: Number of TX queues currently active in device
@@ -1429,11 +1442,6 @@ enum netdev_priv_flags {
1429 * 1442 *
1430 * @xps_maps: XXX: need comments on this one 1443 * @xps_maps: XXX: need comments on this one
1431 * 1444 *
1432 * @rx_cpu_rmap: CPU reverse-mapping for RX completion interrupts,
1433 * indexed by RX queue number. Assigned by driver.
1434 * This must only be set if the ndo_rx_flow_steer
1435 * operation is defined
1436 *
1437 * @trans_start: Time (in jiffies) of last Tx 1445 * @trans_start: Time (in jiffies) of last Tx
1438 * @watchdog_timeo: Represents the timeout that is used by 1446 * @watchdog_timeo: Represents the timeout that is used by
1439 * the watchdog ( see dev_watchdog() ) 1447 * the watchdog ( see dev_watchdog() )
@@ -1441,7 +1449,6 @@ enum netdev_priv_flags {
1441 * 1449 *
1442 * @pcpu_refcnt: Number of references to this device 1450 * @pcpu_refcnt: Number of references to this device
1443 * @todo_list: Delayed register/unregister 1451 * @todo_list: Delayed register/unregister
1444 * @index_hlist: Device index hash chain
1445 * @link_watch_list: XXX: need comments on this one 1452 * @link_watch_list: XXX: need comments on this one
1446 * 1453 *
1447 * @reg_state: Register/unregister state machine 1454 * @reg_state: Register/unregister state machine
@@ -1489,7 +1496,6 @@ enum netdev_priv_flags {
1489 * 1496 *
1490 * @qdisc_tx_busylock: XXX: need comments on this one 1497 * @qdisc_tx_busylock: XXX: need comments on this one
1491 * 1498 *
1492 * @group: The group, that the device belongs to
1493 * @pm_qos_req: Power Management QoS object 1499 * @pm_qos_req: Power Management QoS object
1494 * 1500 *
1495 * FIXME: cleanup struct net_device such that network protocol info 1501 * FIXME: cleanup struct net_device such that network protocol info
@@ -1509,6 +1515,8 @@ struct net_device {
1509 unsigned long base_addr; 1515 unsigned long base_addr;
1510 int irq; 1516 int irq;
1511 1517
1518 atomic_t carrier_changes;
1519
1512 /* 1520 /*
1513 * Some hardware also needs these fields (state,dev_list, 1521 * Some hardware also needs these fields (state,dev_list,
1514 * napi_list,unreg_list,close_list) but they are not 1522 * napi_list,unreg_list,close_list) but they are not
@@ -1542,22 +1550,22 @@ struct net_device {
1542 netdev_features_t mpls_features; 1550 netdev_features_t mpls_features;
1543 1551
1544 int ifindex; 1552 int ifindex;
1545 int iflink; 1553 int group;
1546 1554
1547 struct net_device_stats stats; 1555 struct net_device_stats stats;
1548 1556
1549 atomic_long_t rx_dropped; 1557 atomic_long_t rx_dropped;
1550 atomic_long_t tx_dropped; 1558 atomic_long_t tx_dropped;
1551 1559
1552 atomic_t carrier_changes;
1553
1554#ifdef CONFIG_WIRELESS_EXT 1560#ifdef CONFIG_WIRELESS_EXT
1555 const struct iw_handler_def * wireless_handlers; 1561 const struct iw_handler_def * wireless_handlers;
1556 struct iw_public_data * wireless_data; 1562 struct iw_public_data * wireless_data;
1557#endif 1563#endif
1558 const struct net_device_ops *netdev_ops; 1564 const struct net_device_ops *netdev_ops;
1559 const struct ethtool_ops *ethtool_ops; 1565 const struct ethtool_ops *ethtool_ops;
1560 const struct forwarding_accel_ops *fwd_ops; 1566#ifdef CONFIG_NET_SWITCHDEV
1567 const struct swdev_ops *swdev_ops;
1568#endif
1561 1569
1562 const struct header_ops *header_ops; 1570 const struct header_ops *header_ops;
1563 1571
@@ -1588,6 +1596,8 @@ struct net_device {
1588 unsigned short dev_id; 1596 unsigned short dev_id;
1589 unsigned short dev_port; 1597 unsigned short dev_port;
1590 spinlock_t addr_list_lock; 1598 spinlock_t addr_list_lock;
1599 unsigned char name_assign_type;
1600 bool uc_promisc;
1591 struct netdev_hw_addr_list uc; 1601 struct netdev_hw_addr_list uc;
1592 struct netdev_hw_addr_list mc; 1602 struct netdev_hw_addr_list mc;
1593 struct netdev_hw_addr_list dev_addrs; 1603 struct netdev_hw_addr_list dev_addrs;
@@ -1595,10 +1605,6 @@ struct net_device {
1595#ifdef CONFIG_SYSFS 1605#ifdef CONFIG_SYSFS
1596 struct kset *queues_kset; 1606 struct kset *queues_kset;
1597#endif 1607#endif
1598
1599 unsigned char name_assign_type;
1600
1601 bool uc_promisc;
1602 unsigned int promiscuity; 1608 unsigned int promiscuity;
1603 unsigned int allmulti; 1609 unsigned int allmulti;
1604 1610
@@ -1645,7 +1651,10 @@ struct net_device {
1645 1651
1646 struct netdev_queue __rcu *ingress_queue; 1652 struct netdev_queue __rcu *ingress_queue;
1647 unsigned char broadcast[MAX_ADDR_LEN]; 1653 unsigned char broadcast[MAX_ADDR_LEN];
1648 1654#ifdef CONFIG_RFS_ACCEL
1655 struct cpu_rmap *rx_cpu_rmap;
1656#endif
1657 struct hlist_node index_hlist;
1649 1658
1650/* 1659/*
1651 * Cache lines mostly used on transmit path 1660 * Cache lines mostly used on transmit path
@@ -1656,13 +1665,11 @@ struct net_device {
1656 struct Qdisc *qdisc; 1665 struct Qdisc *qdisc;
1657 unsigned long tx_queue_len; 1666 unsigned long tx_queue_len;
1658 spinlock_t tx_global_lock; 1667 spinlock_t tx_global_lock;
1668 int watchdog_timeo;
1659 1669
1660#ifdef CONFIG_XPS 1670#ifdef CONFIG_XPS
1661 struct xps_dev_maps __rcu *xps_maps; 1671 struct xps_dev_maps __rcu *xps_maps;
1662#endif 1672#endif
1663#ifdef CONFIG_RFS_ACCEL
1664 struct cpu_rmap *rx_cpu_rmap;
1665#endif
1666 1673
1667 /* These may be needed for future network-power-down code. */ 1674 /* These may be needed for future network-power-down code. */
1668 1675
@@ -1672,13 +1679,11 @@ struct net_device {
1672 */ 1679 */
1673 unsigned long trans_start; 1680 unsigned long trans_start;
1674 1681
1675 int watchdog_timeo;
1676 struct timer_list watchdog_timer; 1682 struct timer_list watchdog_timer;
1677 1683
1678 int __percpu *pcpu_refcnt; 1684 int __percpu *pcpu_refcnt;
1679 struct list_head todo_list; 1685 struct list_head todo_list;
1680 1686
1681 struct hlist_node index_hlist;
1682 struct list_head link_watch_list; 1687 struct list_head link_watch_list;
1683 1688
1684 enum { NETREG_UNINITIALIZED=0, 1689 enum { NETREG_UNINITIALIZED=0,
@@ -1702,9 +1707,7 @@ struct net_device {
1702 struct netpoll_info __rcu *npinfo; 1707 struct netpoll_info __rcu *npinfo;
1703#endif 1708#endif
1704 1709
1705#ifdef CONFIG_NET_NS 1710 possible_net_t nd_net;
1706 struct net *nd_net;
1707#endif
1708 1711
1709 /* mid-layer private */ 1712 /* mid-layer private */
1710 union { 1713 union {
@@ -1745,8 +1748,6 @@ struct net_device {
1745#endif 1748#endif
1746 struct phy_device *phydev; 1749 struct phy_device *phydev;
1747 struct lock_class_key *qdisc_tx_busylock; 1750 struct lock_class_key *qdisc_tx_busylock;
1748 int group;
1749 struct pm_qos_request pm_qos_req;
1750}; 1751};
1751#define to_net_dev(d) container_of(d, struct net_device, dev) 1752#define to_net_dev(d) container_of(d, struct net_device, dev)
1752 1753
@@ -1844,10 +1845,7 @@ struct net *dev_net(const struct net_device *dev)
1844static inline 1845static inline
1845void dev_net_set(struct net_device *dev, struct net *net) 1846void dev_net_set(struct net_device *dev, struct net *net)
1846{ 1847{
1847#ifdef CONFIG_NET_NS 1848 write_pnet(&dev->nd_net, net);
1848 release_net(dev->nd_net);
1849 dev->nd_net = hold_net(net);
1850#endif
1851} 1849}
1852 1850
1853static inline bool netdev_uses_dsa(struct net_device *dev) 1851static inline bool netdev_uses_dsa(struct net_device *dev)
@@ -2159,6 +2157,7 @@ void __dev_remove_pack(struct packet_type *pt);
2159void dev_add_offload(struct packet_offload *po); 2157void dev_add_offload(struct packet_offload *po);
2160void dev_remove_offload(struct packet_offload *po); 2158void dev_remove_offload(struct packet_offload *po);
2161 2159
2160int dev_get_iflink(const struct net_device *dev);
2162struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, 2161struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags,
2163 unsigned short mask); 2162 unsigned short mask);
2164struct net_device *dev_get_by_name(struct net *net, const char *name); 2163struct net_device *dev_get_by_name(struct net *net, const char *name);
@@ -2167,9 +2166,14 @@ struct net_device *__dev_get_by_name(struct net *net, const char *name);
2167int dev_alloc_name(struct net_device *dev, const char *name); 2166int dev_alloc_name(struct net_device *dev, const char *name);
2168int dev_open(struct net_device *dev); 2167int dev_open(struct net_device *dev);
2169int dev_close(struct net_device *dev); 2168int dev_close(struct net_device *dev);
2169int dev_close_many(struct list_head *head, bool unlink);
2170void dev_disable_lro(struct net_device *dev); 2170void dev_disable_lro(struct net_device *dev);
2171int dev_loopback_xmit(struct sk_buff *newskb); 2171int dev_loopback_xmit(struct sock *sk, struct sk_buff *newskb);
2172int dev_queue_xmit(struct sk_buff *skb); 2172int dev_queue_xmit_sk(struct sock *sk, struct sk_buff *skb);
2173static inline int dev_queue_xmit(struct sk_buff *skb)
2174{
2175 return dev_queue_xmit_sk(skb->sk, skb);
2176}
2173int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv); 2177int dev_queue_xmit_accel(struct sk_buff *skb, void *accel_priv);
2174int register_netdevice(struct net_device *dev); 2178int register_netdevice(struct net_device *dev);
2175void unregister_netdevice_queue(struct net_device *dev, struct list_head *head); 2179void unregister_netdevice_queue(struct net_device *dev, struct list_head *head);
@@ -2409,15 +2413,6 @@ static inline int dev_parse_header(const struct sk_buff *skb,
2409 return dev->header_ops->parse(skb, haddr); 2413 return dev->header_ops->parse(skb, haddr);
2410} 2414}
2411 2415
2412static inline int dev_rebuild_header(struct sk_buff *skb)
2413{
2414 const struct net_device *dev = skb->dev;
2415
2416 if (!dev->header_ops || !dev->header_ops->rebuild)
2417 return 0;
2418 return dev->header_ops->rebuild(skb);
2419}
2420
2421typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); 2416typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
2422int register_gifconf(unsigned int family, gifconf_func_t *gifconf); 2417int register_gifconf(unsigned int family, gifconf_func_t *gifconf);
2423static inline int unregister_gifconf(unsigned int family) 2418static inline int unregister_gifconf(unsigned int family)
@@ -2939,7 +2934,11 @@ static inline void dev_consume_skb_any(struct sk_buff *skb)
2939 2934
2940int netif_rx(struct sk_buff *skb); 2935int netif_rx(struct sk_buff *skb);
2941int netif_rx_ni(struct sk_buff *skb); 2936int netif_rx_ni(struct sk_buff *skb);
2942int netif_receive_skb(struct sk_buff *skb); 2937int netif_receive_skb_sk(struct sock *sk, struct sk_buff *skb);
2938static inline int netif_receive_skb(struct sk_buff *skb)
2939{
2940 return netif_receive_skb_sk(skb->sk, skb);
2941}
2943gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb); 2942gro_result_t napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb);
2944void napi_gro_flush(struct napi_struct *napi, bool flush_old); 2943void napi_gro_flush(struct napi_struct *napi, bool flush_old);
2945struct sk_buff *napi_get_frags(struct napi_struct *napi); 2944struct sk_buff *napi_get_frags(struct napi_struct *napi);
@@ -2975,6 +2974,8 @@ int dev_set_mac_address(struct net_device *, struct sockaddr *);
2975int dev_change_carrier(struct net_device *, bool new_carrier); 2974int dev_change_carrier(struct net_device *, bool new_carrier);
2976int dev_get_phys_port_id(struct net_device *dev, 2975int dev_get_phys_port_id(struct net_device *dev,
2977 struct netdev_phys_item_id *ppid); 2976 struct netdev_phys_item_id *ppid);
2977int dev_get_phys_port_name(struct net_device *dev,
2978 char *name, size_t len);
2978struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev); 2979struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev);
2979struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2980struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2980 struct netdev_queue *txq, int *ret); 2981 struct netdev_queue *txq, int *ret);
@@ -3679,6 +3680,9 @@ void netdev_change_features(struct net_device *dev);
3679void netif_stacked_transfer_operstate(const struct net_device *rootdev, 3680void netif_stacked_transfer_operstate(const struct net_device *rootdev,
3680 struct net_device *dev); 3681 struct net_device *dev);
3681 3682
3683netdev_features_t passthru_features_check(struct sk_buff *skb,
3684 struct net_device *dev,
3685 netdev_features_t features);
3682netdev_features_t netif_skb_features(struct sk_buff *skb); 3686netdev_features_t netif_skb_features(struct sk_buff *skb);
3683 3687
3684static inline bool net_gso_ok(netdev_features_t features, int gso_type) 3688static inline bool net_gso_ok(netdev_features_t features, int gso_type)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 2517ece98820..63560d0a8dfe 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -44,11 +44,39 @@ int netfilter_init(void);
44struct sk_buff; 44struct sk_buff;
45 45
46struct nf_hook_ops; 46struct nf_hook_ops;
47
48struct sock;
49
50struct nf_hook_state {
51 unsigned int hook;
52 int thresh;
53 u_int8_t pf;
54 struct net_device *in;
55 struct net_device *out;
56 struct sock *sk;
57 int (*okfn)(struct sock *, struct sk_buff *);
58};
59
60static inline void nf_hook_state_init(struct nf_hook_state *p,
61 unsigned int hook,
62 int thresh, u_int8_t pf,
63 struct net_device *indev,
64 struct net_device *outdev,
65 struct sock *sk,
66 int (*okfn)(struct sock *, struct sk_buff *))
67{
68 p->hook = hook;
69 p->thresh = thresh;
70 p->pf = pf;
71 p->in = indev;
72 p->out = outdev;
73 p->sk = sk;
74 p->okfn = okfn;
75}
76
47typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops, 77typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
48 struct sk_buff *skb, 78 struct sk_buff *skb,
49 const struct net_device *in, 79 const struct nf_hook_state *state);
50 const struct net_device *out,
51 int (*okfn)(struct sk_buff *));
52 80
53struct nf_hook_ops { 81struct nf_hook_ops {
54 struct list_head list; 82 struct list_head list;
@@ -118,9 +146,7 @@ static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook)
118} 146}
119#endif 147#endif
120 148
121int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb, 149int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state);
122 struct net_device *indev, struct net_device *outdev,
123 int (*okfn)(struct sk_buff *), int thresh);
124 150
125/** 151/**
126 * nf_hook_thresh - call a netfilter hook 152 * nf_hook_thresh - call a netfilter hook
@@ -130,21 +156,29 @@ int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
130 * value indicates the packet has been consumed by the hook. 156 * value indicates the packet has been consumed by the hook.
131 */ 157 */
132static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook, 158static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
159 struct sock *sk,
133 struct sk_buff *skb, 160 struct sk_buff *skb,
134 struct net_device *indev, 161 struct net_device *indev,
135 struct net_device *outdev, 162 struct net_device *outdev,
136 int (*okfn)(struct sk_buff *), int thresh) 163 int (*okfn)(struct sock *, struct sk_buff *),
164 int thresh)
137{ 165{
138 if (nf_hooks_active(pf, hook)) 166 if (nf_hooks_active(pf, hook)) {
139 return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh); 167 struct nf_hook_state state;
168
169 nf_hook_state_init(&state, hook, thresh, pf,
170 indev, outdev, sk, okfn);
171 return nf_hook_slow(skb, &state);
172 }
140 return 1; 173 return 1;
141} 174}
142 175
143static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb, 176static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
144 struct net_device *indev, struct net_device *outdev, 177 struct sk_buff *skb, struct net_device *indev,
145 int (*okfn)(struct sk_buff *)) 178 struct net_device *outdev,
179 int (*okfn)(struct sock *, struct sk_buff *))
146{ 180{
147 return nf_hook_thresh(pf, hook, skb, indev, outdev, okfn, INT_MIN); 181 return nf_hook_thresh(pf, hook, sk, skb, indev, outdev, okfn, INT_MIN);
148} 182}
149 183
150/* Activate hook; either okfn or kfree_skb called, unless a hook 184/* Activate hook; either okfn or kfree_skb called, unless a hook
@@ -165,35 +199,36 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
165*/ 199*/
166 200
167static inline int 201static inline int
168NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb, 202NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk,
169 struct net_device *in, struct net_device *out, 203 struct sk_buff *skb, struct net_device *in,
170 int (*okfn)(struct sk_buff *), int thresh) 204 struct net_device *out,
205 int (*okfn)(struct sock *, struct sk_buff *), int thresh)
171{ 206{
172 int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh); 207 int ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, thresh);
173 if (ret == 1) 208 if (ret == 1)
174 ret = okfn(skb); 209 ret = okfn(sk, skb);
175 return ret; 210 return ret;
176} 211}
177 212
178static inline int 213static inline int
179NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sk_buff *skb, 214NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk,
180 struct net_device *in, struct net_device *out, 215 struct sk_buff *skb, struct net_device *in, struct net_device *out,
181 int (*okfn)(struct sk_buff *), bool cond) 216 int (*okfn)(struct sock *, struct sk_buff *), bool cond)
182{ 217{
183 int ret; 218 int ret;
184 219
185 if (!cond || 220 if (!cond ||
186 ((ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, INT_MIN)) == 1)) 221 ((ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, INT_MIN)) == 1))
187 ret = okfn(skb); 222 ret = okfn(sk, skb);
188 return ret; 223 return ret;
189} 224}
190 225
191static inline int 226static inline int
192NF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb, 227NF_HOOK(uint8_t pf, unsigned int hook, struct sock *sk, struct sk_buff *skb,
193 struct net_device *in, struct net_device *out, 228 struct net_device *in, struct net_device *out,
194 int (*okfn)(struct sk_buff *)) 229 int (*okfn)(struct sock *, struct sk_buff *))
195{ 230{
196 return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, INT_MIN); 231 return NF_HOOK_THRESH(pf, hook, sk, skb, in, out, okfn, INT_MIN);
197} 232}
198 233
199/* Call setsockopt() */ 234/* Call setsockopt() */
@@ -293,19 +328,21 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
293} 328}
294 329
295#else /* !CONFIG_NETFILTER */ 330#else /* !CONFIG_NETFILTER */
296#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb) 331#define NF_HOOK(pf, hook, sk, skb, indev, outdev, okfn) (okfn)(sk, skb)
297#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb) 332#define NF_HOOK_COND(pf, hook, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb)
298static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook, 333static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
334 struct sock *sk,
299 struct sk_buff *skb, 335 struct sk_buff *skb,
300 struct net_device *indev, 336 struct net_device *indev,
301 struct net_device *outdev, 337 struct net_device *outdev,
302 int (*okfn)(struct sk_buff *), int thresh) 338 int (*okfn)(struct sock *sk, struct sk_buff *), int thresh)
303{ 339{
304 return okfn(skb); 340 return okfn(sk, skb);
305} 341}
306static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb, 342static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
307 struct net_device *indev, struct net_device *outdev, 343 struct sk_buff *skb, struct net_device *indev,
308 int (*okfn)(struct sk_buff *)) 344 struct net_device *outdev,
345 int (*okfn)(struct sock *, struct sk_buff *))
309{ 346{
310 return 1; 347 return 1;
311} 348}
diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
index f1606fa6132d..34b172301558 100644
--- a/include/linux/netfilter/ipset/ip_set.h
+++ b/include/linux/netfilter/ipset/ip_set.h
@@ -483,7 +483,7 @@ static inline int nla_put_ipaddr4(struct sk_buff *skb, int type, __be32 ipaddr)
483 483
484 if (!__nested) 484 if (!__nested)
485 return -EMSGSIZE; 485 return -EMSGSIZE;
486 ret = nla_put_net32(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr); 486 ret = nla_put_in_addr(skb, IPSET_ATTR_IPADDR_IPV4, ipaddr);
487 if (!ret) 487 if (!ret)
488 ipset_nest_end(skb, __nested); 488 ipset_nest_end(skb, __nested);
489 return ret; 489 return ret;
@@ -497,8 +497,7 @@ static inline int nla_put_ipaddr6(struct sk_buff *skb, int type,
497 497
498 if (!__nested) 498 if (!__nested)
499 return -EMSGSIZE; 499 return -EMSGSIZE;
500 ret = nla_put(skb, IPSET_ATTR_IPADDR_IPV6, 500 ret = nla_put_in6_addr(skb, IPSET_ATTR_IPADDR_IPV6, ipaddrptr);
501 sizeof(struct in6_addr), ipaddrptr);
502 if (!ret) 501 if (!ret)
503 ipset_nest_end(skb, __nested); 502 ipset_nest_end(skb, __nested);
504 return ret; 503 return ret;
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index cfb7191e6efa..c22a7fb8d0df 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -54,8 +54,7 @@ extern struct xt_table *arpt_register_table(struct net *net,
54extern void arpt_unregister_table(struct xt_table *table); 54extern void arpt_unregister_table(struct xt_table *table);
55extern unsigned int arpt_do_table(struct sk_buff *skb, 55extern unsigned int arpt_do_table(struct sk_buff *skb,
56 unsigned int hook, 56 unsigned int hook,
57 const struct net_device *in, 57 const struct nf_hook_state *state,
58 const struct net_device *out,
59 struct xt_table *table); 58 struct xt_table *table);
60 59
61#ifdef CONFIG_COMPAT 60#ifdef CONFIG_COMPAT
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index c755e4971fa3..ab8f76dba668 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -2,7 +2,7 @@
2#define __LINUX_BRIDGE_NETFILTER_H 2#define __LINUX_BRIDGE_NETFILTER_H
3 3
4#include <uapi/linux/netfilter_bridge.h> 4#include <uapi/linux/netfilter_bridge.h>
5 5#include <linux/skbuff.h>
6 6
7enum nf_br_hook_priorities { 7enum nf_br_hook_priorities {
8 NF_BR_PRI_FIRST = INT_MIN, 8 NF_BR_PRI_FIRST = INT_MIN,
@@ -17,110 +17,48 @@ enum nf_br_hook_priorities {
17 17
18#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) 18#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
19 19
20#define BRNF_PKT_TYPE 0x01
21#define BRNF_BRIDGED_DNAT 0x02 20#define BRNF_BRIDGED_DNAT 0x02
22#define BRNF_BRIDGED 0x04
23#define BRNF_NF_BRIDGE_PREROUTING 0x08 21#define BRNF_NF_BRIDGE_PREROUTING 0x08
24#define BRNF_8021Q 0x10
25#define BRNF_PPPoE 0x20
26 22
27static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb) 23static inline unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
28{ 24{
29 switch (skb->protocol) { 25 if (skb->nf_bridge->orig_proto == BRNF_PROTO_PPPOE)
30 case __cpu_to_be16(ETH_P_8021Q):
31 return VLAN_HLEN;
32 case __cpu_to_be16(ETH_P_PPP_SES):
33 return PPPOE_SES_HLEN; 26 return PPPOE_SES_HLEN;
34 default: 27 return 0;
35 return 0;
36 }
37} 28}
38 29
39static inline void nf_bridge_update_protocol(struct sk_buff *skb) 30int br_handle_frame_finish(struct sock *sk, struct sk_buff *skb);
40{
41 if (skb->nf_bridge->mask & BRNF_8021Q)
42 skb->protocol = htons(ETH_P_8021Q);
43 else if (skb->nf_bridge->mask & BRNF_PPPoE)
44 skb->protocol = htons(ETH_P_PPP_SES);
45}
46 31
47/* Fill in the header for fragmented IP packets handled by 32static inline void br_drop_fake_rtable(struct sk_buff *skb)
48 * the IPv4 connection tracking code.
49 *
50 * Only used in br_forward.c
51 */
52static inline int nf_bridge_copy_header(struct sk_buff *skb)
53{ 33{
54 int err; 34 struct dst_entry *dst = skb_dst(skb);
55 unsigned int header_size;
56
57 nf_bridge_update_protocol(skb);
58 header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);
59 err = skb_cow_head(skb, header_size);
60 if (err)
61 return err;
62 35
63 skb_copy_to_linear_data_offset(skb, -header_size, 36 if (dst && (dst->flags & DST_FAKE_RTABLE))
64 skb->nf_bridge->data, header_size); 37 skb_dst_drop(skb);
65 __skb_push(skb, nf_bridge_encap_header_len(skb));
66 return 0;
67} 38}
68 39
69static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb) 40static inline int nf_bridge_get_physinif(const struct sk_buff *skb)
70{ 41{
71 if (skb->nf_bridge && 42 return skb->nf_bridge ? skb->nf_bridge->physindev->ifindex : 0;
72 skb->nf_bridge->mask & (BRNF_BRIDGED | BRNF_BRIDGED_DNAT))
73 return nf_bridge_copy_header(skb);
74 return 0;
75} 43}
76 44
77static inline unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb) 45static inline int nf_bridge_get_physoutif(const struct sk_buff *skb)
78{ 46{
79 if (unlikely(skb->nf_bridge->mask & BRNF_PPPoE)) 47 return skb->nf_bridge ? skb->nf_bridge->physoutdev->ifindex : 0;
80 return PPPOE_SES_HLEN;
81 return 0;
82} 48}
83 49
84int br_handle_frame_finish(struct sk_buff *skb); 50static inline struct net_device *
85/* Only used in br_device.c */ 51nf_bridge_get_physindev(const struct sk_buff *skb)
86static inline int br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)
87{ 52{
88 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 53 return skb->nf_bridge ? skb->nf_bridge->physindev : NULL;
89
90 skb_pull(skb, ETH_HLEN);
91 nf_bridge->mask ^= BRNF_BRIDGED_DNAT;
92 skb_copy_to_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN),
93 skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);
94 skb->dev = nf_bridge->physindev;
95 return br_handle_frame_finish(skb);
96} 54}
97 55
98/* This is called by the IP fragmenting code and it ensures there is 56static inline struct net_device *
99 * enough room for the encapsulating header (if there is one). */ 57nf_bridge_get_physoutdev(const struct sk_buff *skb)
100static inline unsigned int nf_bridge_pad(const struct sk_buff *skb)
101{ 58{
102 if (skb->nf_bridge) 59 return skb->nf_bridge ? skb->nf_bridge->physoutdev : NULL;
103 return nf_bridge_encap_header_len(skb);
104 return 0;
105} 60}
106
107struct bridge_skb_cb {
108 union {
109 __be32 ipv4;
110 } daddr;
111};
112
113static inline void br_drop_fake_rtable(struct sk_buff *skb)
114{
115 struct dst_entry *dst = skb_dst(skb);
116
117 if (dst && (dst->flags & DST_FAKE_RTABLE))
118 skb_dst_drop(skb);
119}
120
121#else 61#else
122#define nf_bridge_maybe_copy_header(skb) (0)
123#define nf_bridge_pad(skb) (0)
124#define br_drop_fake_rtable(skb) do { } while (0) 62#define br_drop_fake_rtable(skb) do { } while (0)
125#endif /* CONFIG_BRIDGE_NETFILTER */ 63#endif /* CONFIG_BRIDGE_NETFILTER */
126 64
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 34e7a2b7f867..f1bd3962e6b6 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -12,9 +12,10 @@
12#ifndef __LINUX_BRIDGE_EFF_H 12#ifndef __LINUX_BRIDGE_EFF_H
13#define __LINUX_BRIDGE_EFF_H 13#define __LINUX_BRIDGE_EFF_H
14 14
15#include <linux/if.h>
16#include <linux/if_ether.h>
15#include <uapi/linux/netfilter_bridge/ebtables.h> 17#include <uapi/linux/netfilter_bridge/ebtables.h>
16 18
17
18/* return values for match() functions */ 19/* return values for match() functions */
19#define EBT_MATCH 0 20#define EBT_MATCH 0
20#define EBT_NOMATCH 1 21#define EBT_NOMATCH 1
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 901e84db847d..4073510da485 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -65,8 +65,7 @@ struct ipt_error {
65extern void *ipt_alloc_initial_table(const struct xt_table *); 65extern void *ipt_alloc_initial_table(const struct xt_table *);
66extern unsigned int ipt_do_table(struct sk_buff *skb, 66extern unsigned int ipt_do_table(struct sk_buff *skb,
67 unsigned int hook, 67 unsigned int hook,
68 const struct net_device *in, 68 const struct nf_hook_state *state,
69 const struct net_device *out,
70 struct xt_table *table); 69 struct xt_table *table);
71 70
72#ifdef CONFIG_COMPAT 71#ifdef CONFIG_COMPAT
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 610208b18c05..b40d2b635778 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -31,8 +31,7 @@ extern struct xt_table *ip6t_register_table(struct net *net,
31extern void ip6t_unregister_table(struct net *net, struct xt_table *table); 31extern void ip6t_unregister_table(struct net *net, struct xt_table *table);
32extern unsigned int ip6t_do_table(struct sk_buff *skb, 32extern unsigned int ip6t_do_table(struct sk_buff *skb,
33 unsigned int hook, 33 unsigned int hook,
34 const struct net_device *in, 34 const struct nf_hook_state *state,
35 const struct net_device *out,
36 struct xt_table *table); 35 struct xt_table *table);
37 36
38/* Check for an extension */ 37/* Check for an extension */
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 02fc86d2348e..6835c1279df7 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -134,7 +134,7 @@ struct netlink_callback {
134 134
135struct netlink_notify { 135struct netlink_notify {
136 struct net *net; 136 struct net *net;
137 int portid; 137 u32 portid;
138 int protocol; 138 int protocol;
139}; 139};
140 140
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index d449018d0726..8f2237eb3485 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -24,6 +24,7 @@ struct phy_device *of_phy_attach(struct net_device *dev,
24 phy_interface_t iface); 24 phy_interface_t iface);
25 25
26extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); 26extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
27extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
27 28
28#else /* CONFIG_OF */ 29#else /* CONFIG_OF */
29static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) 30static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
@@ -60,6 +61,12 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np)
60{ 61{
61 return NULL; 62 return NULL;
62} 63}
64
65static inline int of_mdio_parse_addr(struct device *dev,
66 const struct device_node *np)
67{
68 return -ENOSYS;
69}
63#endif /* CONFIG_OF */ 70#endif /* CONFIG_OF */
64 71
65#if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) 72#if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY)
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index 34597c8c1a4c..9cd72aab76fe 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -9,8 +9,11 @@
9 9
10#ifdef CONFIG_OF_NET 10#ifdef CONFIG_OF_NET
11#include <linux/of.h> 11#include <linux/of.h>
12
13struct net_device;
12extern int of_get_phy_mode(struct device_node *np); 14extern int of_get_phy_mode(struct device_node *np);
13extern const void *of_get_mac_address(struct device_node *np); 15extern const void *of_get_mac_address(struct device_node *np);
16extern struct net_device *of_find_net_device_by_node(struct device_node *np);
14#else 17#else
15static inline int of_get_phy_mode(struct device_node *np) 18static inline int of_get_phy_mode(struct device_node *np)
16{ 19{
@@ -21,6 +24,11 @@ static inline const void *of_get_mac_address(struct device_node *np)
21{ 24{
22 return NULL; 25 return NULL;
23} 26}
27
28static inline struct net_device *of_find_net_device_by_node(struct device_node *np)
29{
30 return NULL;
31}
24#endif 32#endif
25 33
26#endif /* __LINUX_OF_NET_H */ 34#endif /* __LINUX_OF_NET_H */
diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h
index 7e75bfe37cc7..fe5732d53eda 100644
--- a/include/linux/phy_fixed.h
+++ b/include/linux/phy_fixed.h
@@ -21,6 +21,9 @@ extern void fixed_phy_del(int phy_addr);
21extern int fixed_phy_set_link_update(struct phy_device *phydev, 21extern int fixed_phy_set_link_update(struct phy_device *phydev,
22 int (*link_update)(struct net_device *, 22 int (*link_update)(struct net_device *,
23 struct fixed_phy_status *)); 23 struct fixed_phy_status *));
24extern int fixed_phy_update_state(struct phy_device *phydev,
25 const struct fixed_phy_status *status,
26 const struct fixed_phy_status *changed);
24#else 27#else
25static inline int fixed_phy_add(unsigned int irq, int phy_id, 28static inline int fixed_phy_add(unsigned int irq, int phy_id,
26 struct fixed_phy_status *status) 29 struct fixed_phy_status *status)
@@ -43,6 +46,12 @@ static inline int fixed_phy_set_link_update(struct phy_device *phydev,
43{ 46{
44 return -ENODEV; 47 return -ENODEV;
45} 48}
49static inline int fixed_phy_update_state(struct phy_device *phydev,
50 const struct fixed_phy_status *status,
51 const struct fixed_phy_status *changed)
52{
53 return -ENODEV;
54}
46#endif /* CONFIG_FIXED_PHY */ 55#endif /* CONFIG_FIXED_PHY */
47 56
48#endif /* __PHY_FIXED_H */ 57#endif /* __PHY_FIXED_H */
diff --git a/include/linux/platform_data/nxp-nci.h b/include/linux/platform_data/nxp-nci.h
new file mode 100644
index 000000000000..d6ed28679bb2
--- /dev/null
+++ b/include/linux/platform_data/nxp-nci.h
@@ -0,0 +1,27 @@
1/*
2 * Generic platform data for the NXP NCI NFC chips.
3 *
4 * Copyright (C) 2014 NXP Semiconductors All rights reserved.
5 *
6 * Authors: Clément Perrochaud <clement.perrochaud@nxp.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#ifndef _NXP_NCI_H_
19#define _NXP_NCI_H_
20
21struct nxp_nci_nfc_platform_data {
22 unsigned int gpio_en;
23 unsigned int gpio_fw;
24 unsigned int irq;
25};
26
27#endif /* _NXP_NCI_H_ */
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index 0d8ff3fb84ba..b8b73066d137 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -64,11 +64,11 @@ struct ptp_clock_request {
64 * @adjtime: Shifts the time of the hardware clock. 64 * @adjtime: Shifts the time of the hardware clock.
65 * parameter delta: Desired change in nanoseconds. 65 * parameter delta: Desired change in nanoseconds.
66 * 66 *
67 * @gettime: Reads the current time from the hardware clock. 67 * @gettime64: Reads the current time from the hardware clock.
68 * parameter ts: Holds the result. 68 * parameter ts: Holds the result.
69 * 69 *
70 * @settime: Set the current time on the hardware clock. 70 * @settime64: Set the current time on the hardware clock.
71 * parameter ts: Time value to set. 71 * parameter ts: Time value to set.
72 * 72 *
73 * @enable: Request driver to enable or disable an ancillary feature. 73 * @enable: Request driver to enable or disable an ancillary feature.
74 * parameter request: Desired resource to enable or disable. 74 * parameter request: Desired resource to enable or disable.
@@ -104,8 +104,8 @@ struct ptp_clock_info {
104 struct ptp_pin_desc *pin_config; 104 struct ptp_pin_desc *pin_config;
105 int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta); 105 int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
106 int (*adjtime)(struct ptp_clock_info *ptp, s64 delta); 106 int (*adjtime)(struct ptp_clock_info *ptp, s64 delta);
107 int (*gettime)(struct ptp_clock_info *ptp, struct timespec *ts); 107 int (*gettime64)(struct ptp_clock_info *ptp, struct timespec64 *ts);
108 int (*settime)(struct ptp_clock_info *ptp, const struct timespec *ts); 108 int (*settime64)(struct ptp_clock_info *p, const struct timespec64 *ts);
109 int (*enable)(struct ptp_clock_info *ptp, 109 int (*enable)(struct ptp_clock_info *ptp,
110 struct ptp_clock_request *request, int on); 110 struct ptp_clock_request *request, int on);
111 int (*verify)(struct ptp_clock_info *ptp, unsigned int pin, 111 int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h
index d438eeb08bff..e23d242d1230 100644
--- a/include/linux/rhashtable.h
+++ b/include/linux/rhashtable.h
@@ -1,14 +1,13 @@
1/* 1/*
2 * Resizable, Scalable, Concurrent Hash Table 2 * Resizable, Scalable, Concurrent Hash Table
3 * 3 *
4 * Copyright (c) 2014 Thomas Graf <tgraf@suug.ch> 4 * Copyright (c) 2015 Herbert Xu <herbert@gondor.apana.org.au>
5 * Copyright (c) 2014-2015 Thomas Graf <tgraf@suug.ch>
5 * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net> 6 * Copyright (c) 2008-2014 Patrick McHardy <kaber@trash.net>
6 * 7 *
7 * Based on the following paper by Josh Triplett, Paul E. McKenney
8 * and Jonathan Walpole:
9 * https://www.usenix.org/legacy/event/atc11/tech/final_files/Triplett.pdf
10 *
11 * Code partially derived from nft_hash 8 * Code partially derived from nft_hash
9 * Rewritten with rehash code from br_multicast plus single list
10 * pointer as suggested by Josh Triplett
12 * 11 *
13 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
@@ -19,9 +18,12 @@
19#define _LINUX_RHASHTABLE_H 18#define _LINUX_RHASHTABLE_H
20 19
21#include <linux/compiler.h> 20#include <linux/compiler.h>
21#include <linux/errno.h>
22#include <linux/jhash.h>
22#include <linux/list_nulls.h> 23#include <linux/list_nulls.h>
23#include <linux/workqueue.h> 24#include <linux/workqueue.h>
24#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/rcupdate.h>
25 27
26/* 28/*
27 * The end of the chain is marked with a special nulls marks which has 29 * The end of the chain is marked with a special nulls marks which has
@@ -42,6 +44,9 @@
42#define RHT_HASH_BITS 27 44#define RHT_HASH_BITS 27
43#define RHT_BASE_SHIFT RHT_HASH_BITS 45#define RHT_BASE_SHIFT RHT_HASH_BITS
44 46
47/* Base bits plus 1 bit for nulls marker */
48#define RHT_HASH_RESERVED_SPACE (RHT_BASE_BITS + 1)
49
45struct rhash_head { 50struct rhash_head {
46 struct rhash_head __rcu *next; 51 struct rhash_head __rcu *next;
47}; 52};
@@ -49,20 +54,43 @@ struct rhash_head {
49/** 54/**
50 * struct bucket_table - Table of hash buckets 55 * struct bucket_table - Table of hash buckets
51 * @size: Number of hash buckets 56 * @size: Number of hash buckets
57 * @rehash: Current bucket being rehashed
58 * @hash_rnd: Random seed to fold into hash
52 * @locks_mask: Mask to apply before accessing locks[] 59 * @locks_mask: Mask to apply before accessing locks[]
53 * @locks: Array of spinlocks protecting individual buckets 60 * @locks: Array of spinlocks protecting individual buckets
61 * @walkers: List of active walkers
62 * @rcu: RCU structure for freeing the table
63 * @future_tbl: Table under construction during rehashing
54 * @buckets: size * hash buckets 64 * @buckets: size * hash buckets
55 */ 65 */
56struct bucket_table { 66struct bucket_table {
57 size_t size; 67 unsigned int size;
68 unsigned int rehash;
69 u32 hash_rnd;
58 unsigned int locks_mask; 70 unsigned int locks_mask;
59 spinlock_t *locks; 71 spinlock_t *locks;
72 struct list_head walkers;
73 struct rcu_head rcu;
74
75 struct bucket_table __rcu *future_tbl;
60 76
61 struct rhash_head __rcu *buckets[] ____cacheline_aligned_in_smp; 77 struct rhash_head __rcu *buckets[] ____cacheline_aligned_in_smp;
62}; 78};
63 79
80/**
81 * struct rhashtable_compare_arg - Key for the function rhashtable_compare
82 * @ht: Hash table
83 * @key: Key to compare against
84 */
85struct rhashtable_compare_arg {
86 struct rhashtable *ht;
87 const void *key;
88};
89
64typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed); 90typedef u32 (*rht_hashfn_t)(const void *data, u32 len, u32 seed);
65typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 seed); 91typedef u32 (*rht_obj_hashfn_t)(const void *data, u32 len, u32 seed);
92typedef int (*rht_obj_cmpfn_t)(struct rhashtable_compare_arg *arg,
93 const void *obj);
66 94
67struct rhashtable; 95struct rhashtable;
68 96
@@ -72,60 +100,62 @@ struct rhashtable;
72 * @key_len: Length of key 100 * @key_len: Length of key
73 * @key_offset: Offset of key in struct to be hashed 101 * @key_offset: Offset of key in struct to be hashed
74 * @head_offset: Offset of rhash_head in struct to be hashed 102 * @head_offset: Offset of rhash_head in struct to be hashed
75 * @hash_rnd: Seed to use while hashing 103 * @max_size: Maximum size while expanding
76 * @max_shift: Maximum number of shifts while expanding 104 * @min_size: Minimum size while shrinking
77 * @min_shift: Minimum number of shifts while shrinking
78 * @nulls_base: Base value to generate nulls marker 105 * @nulls_base: Base value to generate nulls marker
106 * @insecure_elasticity: Set to true to disable chain length checks
107 * @automatic_shrinking: Enable automatic shrinking of tables
79 * @locks_mul: Number of bucket locks to allocate per cpu (default: 128) 108 * @locks_mul: Number of bucket locks to allocate per cpu (default: 128)
80 * @hashfn: Function to hash key 109 * @hashfn: Hash function (default: jhash2 if !(key_len % 4), or jhash)
81 * @obj_hashfn: Function to hash object 110 * @obj_hashfn: Function to hash object
111 * @obj_cmpfn: Function to compare key with object
82 */ 112 */
83struct rhashtable_params { 113struct rhashtable_params {
84 size_t nelem_hint; 114 size_t nelem_hint;
85 size_t key_len; 115 size_t key_len;
86 size_t key_offset; 116 size_t key_offset;
87 size_t head_offset; 117 size_t head_offset;
88 u32 hash_rnd; 118 unsigned int max_size;
89 size_t max_shift; 119 unsigned int min_size;
90 size_t min_shift;
91 u32 nulls_base; 120 u32 nulls_base;
121 bool insecure_elasticity;
122 bool automatic_shrinking;
92 size_t locks_mul; 123 size_t locks_mul;
93 rht_hashfn_t hashfn; 124 rht_hashfn_t hashfn;
94 rht_obj_hashfn_t obj_hashfn; 125 rht_obj_hashfn_t obj_hashfn;
126 rht_obj_cmpfn_t obj_cmpfn;
95}; 127};
96 128
97/** 129/**
98 * struct rhashtable - Hash table handle 130 * struct rhashtable - Hash table handle
99 * @tbl: Bucket table 131 * @tbl: Bucket table
100 * @future_tbl: Table under construction during expansion/shrinking
101 * @nelems: Number of elements in table 132 * @nelems: Number of elements in table
102 * @shift: Current size (1 << shift) 133 * @key_len: Key length for hashfn
134 * @elasticity: Maximum chain length before rehash
103 * @p: Configuration parameters 135 * @p: Configuration parameters
104 * @run_work: Deferred worker to expand/shrink asynchronously 136 * @run_work: Deferred worker to expand/shrink asynchronously
105 * @mutex: Mutex to protect current/future table swapping 137 * @mutex: Mutex to protect current/future table swapping
106 * @walkers: List of active walkers 138 * @lock: Spin lock to protect walker list
107 * @being_destroyed: True if table is set up for destruction
108 */ 139 */
109struct rhashtable { 140struct rhashtable {
110 struct bucket_table __rcu *tbl; 141 struct bucket_table __rcu *tbl;
111 struct bucket_table __rcu *future_tbl;
112 atomic_t nelems; 142 atomic_t nelems;
113 atomic_t shift; 143 unsigned int key_len;
144 unsigned int elasticity;
114 struct rhashtable_params p; 145 struct rhashtable_params p;
115 struct work_struct run_work; 146 struct work_struct run_work;
116 struct mutex mutex; 147 struct mutex mutex;
117 struct list_head walkers; 148 spinlock_t lock;
118 bool being_destroyed;
119}; 149};
120 150
121/** 151/**
122 * struct rhashtable_walker - Hash table walker 152 * struct rhashtable_walker - Hash table walker
123 * @list: List entry on list of walkers 153 * @list: List entry on list of walkers
124 * @resize: Resize event occured 154 * @tbl: The table that we were walking over
125 */ 155 */
126struct rhashtable_walker { 156struct rhashtable_walker {
127 struct list_head list; 157 struct list_head list;
128 bool resize; 158 struct bucket_table *tbl;
129}; 159};
130 160
131/** 161/**
@@ -162,6 +192,118 @@ static inline unsigned long rht_get_nulls_value(const struct rhash_head *ptr)
162 return ((unsigned long) ptr) >> 1; 192 return ((unsigned long) ptr) >> 1;
163} 193}
164 194
195static inline void *rht_obj(const struct rhashtable *ht,
196 const struct rhash_head *he)
197{
198 return (char *)he - ht->p.head_offset;
199}
200
201static inline unsigned int rht_bucket_index(const struct bucket_table *tbl,
202 unsigned int hash)
203{
204 return (hash >> RHT_HASH_RESERVED_SPACE) & (tbl->size - 1);
205}
206
207static inline unsigned int rht_key_hashfn(
208 struct rhashtable *ht, const struct bucket_table *tbl,
209 const void *key, const struct rhashtable_params params)
210{
211 unsigned int hash;
212
213 /* params must be equal to ht->p if it isn't constant. */
214 if (!__builtin_constant_p(params.key_len))
215 hash = ht->p.hashfn(key, ht->key_len, tbl->hash_rnd);
216 else if (params.key_len) {
217 unsigned int key_len = params.key_len;
218
219 if (params.hashfn)
220 hash = params.hashfn(key, key_len, tbl->hash_rnd);
221 else if (key_len & (sizeof(u32) - 1))
222 hash = jhash(key, key_len, tbl->hash_rnd);
223 else
224 hash = jhash2(key, key_len / sizeof(u32),
225 tbl->hash_rnd);
226 } else {
227 unsigned int key_len = ht->p.key_len;
228
229 if (params.hashfn)
230 hash = params.hashfn(key, key_len, tbl->hash_rnd);
231 else
232 hash = jhash(key, key_len, tbl->hash_rnd);
233 }
234
235 return rht_bucket_index(tbl, hash);
236}
237
238static inline unsigned int rht_head_hashfn(
239 struct rhashtable *ht, const struct bucket_table *tbl,
240 const struct rhash_head *he, const struct rhashtable_params params)
241{
242 const char *ptr = rht_obj(ht, he);
243
244 return likely(params.obj_hashfn) ?
245 rht_bucket_index(tbl, params.obj_hashfn(ptr, params.key_len ?:
246 ht->p.key_len,
247 tbl->hash_rnd)) :
248 rht_key_hashfn(ht, tbl, ptr + params.key_offset, params);
249}
250
251/**
252 * rht_grow_above_75 - returns true if nelems > 0.75 * table-size
253 * @ht: hash table
254 * @tbl: current table
255 */
256static inline bool rht_grow_above_75(const struct rhashtable *ht,
257 const struct bucket_table *tbl)
258{
259 /* Expand table when exceeding 75% load */
260 return atomic_read(&ht->nelems) > (tbl->size / 4 * 3) &&
261 (!ht->p.max_size || tbl->size < ht->p.max_size);
262}
263
264/**
265 * rht_shrink_below_30 - returns true if nelems < 0.3 * table-size
266 * @ht: hash table
267 * @tbl: current table
268 */
269static inline bool rht_shrink_below_30(const struct rhashtable *ht,
270 const struct bucket_table *tbl)
271{
272 /* Shrink table beneath 30% load */
273 return atomic_read(&ht->nelems) < (tbl->size * 3 / 10) &&
274 tbl->size > ht->p.min_size;
275}
276
277/**
278 * rht_grow_above_100 - returns true if nelems > table-size
279 * @ht: hash table
280 * @tbl: current table
281 */
282static inline bool rht_grow_above_100(const struct rhashtable *ht,
283 const struct bucket_table *tbl)
284{
285 return atomic_read(&ht->nelems) > tbl->size;
286}
287
288/* The bucket lock is selected based on the hash and protects mutations
289 * on a group of hash buckets.
290 *
291 * A maximum of tbl->size/2 bucket locks is allocated. This ensures that
292 * a single lock always covers both buckets which may both contains
293 * entries which link to the same bucket of the old table during resizing.
294 * This allows to simplify the locking as locking the bucket in both
295 * tables during resize always guarantee protection.
296 *
297 * IMPORTANT: When holding the bucket lock of both the old and new table
298 * during expansions and shrinking, the old bucket lock must always be
299 * acquired first.
300 */
301static inline spinlock_t *rht_bucket_lock(const struct bucket_table *tbl,
302 unsigned int hash)
303{
304 return &tbl->locks[hash & tbl->locks_mask];
305}
306
165#ifdef CONFIG_PROVE_LOCKING 307#ifdef CONFIG_PROVE_LOCKING
166int lockdep_rht_mutex_is_held(struct rhashtable *ht); 308int lockdep_rht_mutex_is_held(struct rhashtable *ht);
167int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash); 309int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, u32 hash);
@@ -178,23 +320,13 @@ static inline int lockdep_rht_bucket_is_held(const struct bucket_table *tbl,
178} 320}
179#endif /* CONFIG_PROVE_LOCKING */ 321#endif /* CONFIG_PROVE_LOCKING */
180 322
181int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params); 323int rhashtable_init(struct rhashtable *ht,
182 324 const struct rhashtable_params *params);
183void rhashtable_insert(struct rhashtable *ht, struct rhash_head *node);
184bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *node);
185
186int rhashtable_expand(struct rhashtable *ht);
187int rhashtable_shrink(struct rhashtable *ht);
188 325
189void *rhashtable_lookup(struct rhashtable *ht, const void *key); 326int rhashtable_insert_slow(struct rhashtable *ht, const void *key,
190void *rhashtable_lookup_compare(struct rhashtable *ht, const void *key, 327 struct rhash_head *obj,
191 bool (*compare)(void *, void *), void *arg); 328 struct bucket_table *old_tbl);
192 329int rhashtable_insert_rehash(struct rhashtable *ht);
193bool rhashtable_lookup_insert(struct rhashtable *ht, struct rhash_head *obj);
194bool rhashtable_lookup_compare_insert(struct rhashtable *ht,
195 struct rhash_head *obj,
196 bool (*compare)(void *, void *),
197 void *arg);
198 330
199int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter); 331int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter);
200void rhashtable_walk_exit(struct rhashtable_iter *iter); 332void rhashtable_walk_exit(struct rhashtable_iter *iter);
@@ -202,6 +334,9 @@ int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU);
202void *rhashtable_walk_next(struct rhashtable_iter *iter); 334void *rhashtable_walk_next(struct rhashtable_iter *iter);
203void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU); 335void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU);
204 336
337void rhashtable_free_and_destroy(struct rhashtable *ht,
338 void (*free_fn)(void *ptr, void *arg),
339 void *arg);
205void rhashtable_destroy(struct rhashtable *ht); 340void rhashtable_destroy(struct rhashtable *ht);
206 341
207#define rht_dereference(p, ht) \ 342#define rht_dereference(p, ht) \
@@ -352,4 +487,316 @@ void rhashtable_destroy(struct rhashtable *ht);
352 rht_for_each_entry_rcu_continue(tpos, pos, (tbl)->buckets[hash],\ 487 rht_for_each_entry_rcu_continue(tpos, pos, (tbl)->buckets[hash],\
353 tbl, hash, member) 488 tbl, hash, member)
354 489
490static inline int rhashtable_compare(struct rhashtable_compare_arg *arg,
491 const void *obj)
492{
493 struct rhashtable *ht = arg->ht;
494 const char *ptr = obj;
495
496 return memcmp(ptr + ht->p.key_offset, arg->key, ht->p.key_len);
497}
498
499/**
500 * rhashtable_lookup_fast - search hash table, inlined version
501 * @ht: hash table
502 * @key: the pointer to the key
503 * @params: hash table parameters
504 *
505 * Computes the hash value for the key and traverses the bucket chain looking
506 * for a entry with an identical key. The first matching entry is returned.
507 *
508 * Returns the first entry on which the compare function returned true.
509 */
510static inline void *rhashtable_lookup_fast(
511 struct rhashtable *ht, const void *key,
512 const struct rhashtable_params params)
513{
514 struct rhashtable_compare_arg arg = {
515 .ht = ht,
516 .key = key,
517 };
518 const struct bucket_table *tbl;
519 struct rhash_head *he;
520 unsigned int hash;
521
522 rcu_read_lock();
523
524 tbl = rht_dereference_rcu(ht->tbl, ht);
525restart:
526 hash = rht_key_hashfn(ht, tbl, key, params);
527 rht_for_each_rcu(he, tbl, hash) {
528 if (params.obj_cmpfn ?
529 params.obj_cmpfn(&arg, rht_obj(ht, he)) :
530 rhashtable_compare(&arg, rht_obj(ht, he)))
531 continue;
532 rcu_read_unlock();
533 return rht_obj(ht, he);
534 }
535
536 /* Ensure we see any new tables. */
537 smp_rmb();
538
539 tbl = rht_dereference_rcu(tbl->future_tbl, ht);
540 if (unlikely(tbl))
541 goto restart;
542 rcu_read_unlock();
543
544 return NULL;
545}
546
547/* Internal function, please use rhashtable_insert_fast() instead */
548static inline int __rhashtable_insert_fast(
549 struct rhashtable *ht, const void *key, struct rhash_head *obj,
550 const struct rhashtable_params params)
551{
552 struct rhashtable_compare_arg arg = {
553 .ht = ht,
554 .key = key,
555 };
556 struct bucket_table *tbl, *new_tbl;
557 struct rhash_head *head;
558 spinlock_t *lock;
559 unsigned int elasticity;
560 unsigned int hash;
561 int err;
562
563restart:
564 rcu_read_lock();
565
566 tbl = rht_dereference_rcu(ht->tbl, ht);
567
568 /* All insertions must grab the oldest table containing
569 * the hashed bucket that is yet to be rehashed.
570 */
571 for (;;) {
572 hash = rht_head_hashfn(ht, tbl, obj, params);
573 lock = rht_bucket_lock(tbl, hash);
574 spin_lock_bh(lock);
575
576 if (tbl->rehash <= hash)
577 break;
578
579 spin_unlock_bh(lock);
580 tbl = rht_dereference_rcu(tbl->future_tbl, ht);
581 }
582
583 new_tbl = rht_dereference_rcu(tbl->future_tbl, ht);
584 if (unlikely(new_tbl)) {
585 err = rhashtable_insert_slow(ht, key, obj, new_tbl);
586 if (err == -EAGAIN)
587 goto slow_path;
588 goto out;
589 }
590
591 if (unlikely(rht_grow_above_100(ht, tbl))) {
592slow_path:
593 spin_unlock_bh(lock);
594 err = rhashtable_insert_rehash(ht);
595 rcu_read_unlock();
596 if (err)
597 return err;
598
599 goto restart;
600 }
601
602 err = -EEXIST;
603 elasticity = ht->elasticity;
604 rht_for_each(head, tbl, hash) {
605 if (key &&
606 unlikely(!(params.obj_cmpfn ?
607 params.obj_cmpfn(&arg, rht_obj(ht, head)) :
608 rhashtable_compare(&arg, rht_obj(ht, head)))))
609 goto out;
610 if (!--elasticity)
611 goto slow_path;
612 }
613
614 err = 0;
615
616 head = rht_dereference_bucket(tbl->buckets[hash], tbl, hash);
617
618 RCU_INIT_POINTER(obj->next, head);
619
620 rcu_assign_pointer(tbl->buckets[hash], obj);
621
622 atomic_inc(&ht->nelems);
623 if (rht_grow_above_75(ht, tbl))
624 schedule_work(&ht->run_work);
625
626out:
627 spin_unlock_bh(lock);
628 rcu_read_unlock();
629
630 return err;
631}
632
633/**
634 * rhashtable_insert_fast - insert object into hash table
635 * @ht: hash table
636 * @obj: pointer to hash head inside object
637 * @params: hash table parameters
638 *
639 * Will take a per bucket spinlock to protect against mutual mutations
640 * on the same bucket. Multiple insertions may occur in parallel unless
641 * they map to the same bucket lock.
642 *
643 * It is safe to call this function from atomic context.
644 *
645 * Will trigger an automatic deferred table resizing if the size grows
646 * beyond the watermark indicated by grow_decision() which can be passed
647 * to rhashtable_init().
648 */
649static inline int rhashtable_insert_fast(
650 struct rhashtable *ht, struct rhash_head *obj,
651 const struct rhashtable_params params)
652{
653 return __rhashtable_insert_fast(ht, NULL, obj, params);
654}
655
656/**
657 * rhashtable_lookup_insert_fast - lookup and insert object into hash table
658 * @ht: hash table
659 * @obj: pointer to hash head inside object
660 * @params: hash table parameters
661 *
662 * Locks down the bucket chain in both the old and new table if a resize
663 * is in progress to ensure that writers can't remove from the old table
664 * and can't insert to the new table during the atomic operation of search
665 * and insertion. Searches for duplicates in both the old and new table if
666 * a resize is in progress.
667 *
668 * This lookup function may only be used for fixed key hash table (key_len
669 * parameter set). It will BUG() if used inappropriately.
670 *
671 * It is safe to call this function from atomic context.
672 *
673 * Will trigger an automatic deferred table resizing if the size grows
674 * beyond the watermark indicated by grow_decision() which can be passed
675 * to rhashtable_init().
676 */
677static inline int rhashtable_lookup_insert_fast(
678 struct rhashtable *ht, struct rhash_head *obj,
679 const struct rhashtable_params params)
680{
681 const char *key = rht_obj(ht, obj);
682
683 BUG_ON(ht->p.obj_hashfn);
684
685 return __rhashtable_insert_fast(ht, key + ht->p.key_offset, obj,
686 params);
687}
688
689/**
690 * rhashtable_lookup_insert_key - search and insert object to hash table
691 * with explicit key
692 * @ht: hash table
693 * @key: key
694 * @obj: pointer to hash head inside object
695 * @params: hash table parameters
696 *
697 * Locks down the bucket chain in both the old and new table if a resize
698 * is in progress to ensure that writers can't remove from the old table
699 * and can't insert to the new table during the atomic operation of search
700 * and insertion. Searches for duplicates in both the old and new table if
701 * a resize is in progress.
702 *
703 * Lookups may occur in parallel with hashtable mutations and resizing.
704 *
705 * Will trigger an automatic deferred table resizing if the size grows
706 * beyond the watermark indicated by grow_decision() which can be passed
707 * to rhashtable_init().
708 *
709 * Returns zero on success.
710 */
711static inline int rhashtable_lookup_insert_key(
712 struct rhashtable *ht, const void *key, struct rhash_head *obj,
713 const struct rhashtable_params params)
714{
715 BUG_ON(!ht->p.obj_hashfn || !key);
716
717 return __rhashtable_insert_fast(ht, key, obj, params);
718}
719
720/* Internal function, please use rhashtable_remove_fast() instead */
721static inline int __rhashtable_remove_fast(
722 struct rhashtable *ht, struct bucket_table *tbl,
723 struct rhash_head *obj, const struct rhashtable_params params)
724{
725 struct rhash_head __rcu **pprev;
726 struct rhash_head *he;
727 spinlock_t * lock;
728 unsigned int hash;
729 int err = -ENOENT;
730
731 hash = rht_head_hashfn(ht, tbl, obj, params);
732 lock = rht_bucket_lock(tbl, hash);
733
734 spin_lock_bh(lock);
735
736 pprev = &tbl->buckets[hash];
737 rht_for_each(he, tbl, hash) {
738 if (he != obj) {
739 pprev = &he->next;
740 continue;
741 }
742
743 rcu_assign_pointer(*pprev, obj->next);
744 err = 0;
745 break;
746 }
747
748 spin_unlock_bh(lock);
749
750 return err;
751}
752
753/**
754 * rhashtable_remove_fast - remove object from hash table
755 * @ht: hash table
756 * @obj: pointer to hash head inside object
757 * @params: hash table parameters
758 *
759 * Since the hash chain is single linked, the removal operation needs to
760 * walk the bucket chain upon removal. The removal operation is thus
761 * considerable slow if the hash table is not correctly sized.
762 *
763 * Will automatically shrink the table via rhashtable_expand() if the
764 * shrink_decision function specified at rhashtable_init() returns true.
765 *
766 * Returns zero on success, -ENOENT if the entry could not be found.
767 */
768static inline int rhashtable_remove_fast(
769 struct rhashtable *ht, struct rhash_head *obj,
770 const struct rhashtable_params params)
771{
772 struct bucket_table *tbl;
773 int err;
774
775 rcu_read_lock();
776
777 tbl = rht_dereference_rcu(ht->tbl, ht);
778
779 /* Because we have already taken (and released) the bucket
780 * lock in old_tbl, if we find that future_tbl is not yet
781 * visible then that guarantees the entry to still be in
782 * the old tbl if it exists.
783 */
784 while ((err = __rhashtable_remove_fast(ht, tbl, obj, params)) &&
785 (tbl = rht_dereference_rcu(tbl->future_tbl, ht)))
786 ;
787
788 if (err)
789 goto out;
790
791 atomic_dec(&ht->nelems);
792 if (unlikely(ht->p.automatic_shrinking &&
793 rht_shrink_below_30(ht, tbl)))
794 schedule_work(&ht->run_work);
795
796out:
797 rcu_read_unlock();
798
799 return err;
800}
801
355#endif /* _LINUX_RHASHTABLE_H */ 802#endif /* _LINUX_RHASHTABLE_H */
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 5db76a32fcab..2da5d1081ad9 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -77,7 +77,20 @@ static inline struct netdev_queue *dev_ingress_queue(struct net_device *dev)
77 return rtnl_dereference(dev->ingress_queue); 77 return rtnl_dereference(dev->ingress_queue);
78} 78}
79 79
80extern struct netdev_queue *dev_ingress_queue_create(struct net_device *dev); 80struct netdev_queue *dev_ingress_queue_create(struct net_device *dev);
81
82#ifdef CONFIG_NET_CLS_ACT
83void net_inc_ingress_queue(void);
84void net_dec_ingress_queue(void);
85#else
86static inline void net_inc_ingress_queue(void)
87{
88}
89
90static inline void net_dec_ingress_queue(void)
91{
92}
93#endif
81 94
82extern void rtnetlink_init(void); 95extern void rtnetlink_init(void);
83extern void __rtnl_unlock(void); 96extern void __rtnl_unlock(void);
diff --git a/include/linux/security.h b/include/linux/security.h
index 4e14e3d6309f..18264ea9e314 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1716,7 +1716,6 @@ struct security_operations {
1716 int (*tun_dev_attach_queue) (void *security); 1716 int (*tun_dev_attach_queue) (void *security);
1717 int (*tun_dev_attach) (struct sock *sk, void *security); 1717 int (*tun_dev_attach) (struct sock *sk, void *security);
1718 int (*tun_dev_open) (void *security); 1718 int (*tun_dev_open) (void *security);
1719 void (*skb_owned_by) (struct sk_buff *skb, struct sock *sk);
1720#endif /* CONFIG_SECURITY_NETWORK */ 1719#endif /* CONFIG_SECURITY_NETWORK */
1721 1720
1722#ifdef CONFIG_SECURITY_NETWORK_XFRM 1721#ifdef CONFIG_SECURITY_NETWORK_XFRM
@@ -2734,8 +2733,6 @@ int security_tun_dev_attach_queue(void *security);
2734int security_tun_dev_attach(struct sock *sk, void *security); 2733int security_tun_dev_attach(struct sock *sk, void *security);
2735int security_tun_dev_open(void *security); 2734int security_tun_dev_open(void *security);
2736 2735
2737void security_skb_owned_by(struct sk_buff *skb, struct sock *sk);
2738
2739#else /* CONFIG_SECURITY_NETWORK */ 2736#else /* CONFIG_SECURITY_NETWORK */
2740static inline int security_unix_stream_connect(struct sock *sock, 2737static inline int security_unix_stream_connect(struct sock *sock,
2741 struct sock *other, 2738 struct sock *other,
@@ -2927,11 +2924,6 @@ static inline int security_tun_dev_open(void *security)
2927{ 2924{
2928 return 0; 2925 return 0;
2929} 2926}
2930
2931static inline void security_skb_owned_by(struct sk_buff *skb, struct sock *sk)
2932{
2933}
2934
2935#endif /* CONFIG_SECURITY_NETWORK */ 2927#endif /* CONFIG_SECURITY_NETWORK */
2936 2928
2937#ifdef CONFIG_SECURITY_NETWORK_XFRM 2929#ifdef CONFIG_SECURITY_NETWORK_XFRM
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f54d6659713a..0991259643d6 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -166,10 +166,16 @@ struct nf_conntrack {
166#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) 166#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
167struct nf_bridge_info { 167struct nf_bridge_info {
168 atomic_t use; 168 atomic_t use;
169 enum {
170 BRNF_PROTO_UNCHANGED,
171 BRNF_PROTO_8021Q,
172 BRNF_PROTO_PPPOE
173 } orig_proto;
174 bool pkt_otherhost;
169 unsigned int mask; 175 unsigned int mask;
170 struct net_device *physindev; 176 struct net_device *physindev;
171 struct net_device *physoutdev; 177 struct net_device *physoutdev;
172 unsigned long data[32 / sizeof(unsigned long)]; 178 char neigh_header[8];
173}; 179};
174#endif 180#endif
175 181
@@ -492,7 +498,6 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
492 * @napi_id: id of the NAPI struct this skb came from 498 * @napi_id: id of the NAPI struct this skb came from
493 * @secmark: security marking 499 * @secmark: security marking
494 * @mark: Generic packet mark 500 * @mark: Generic packet mark
495 * @dropcount: total number of sk_receive_queue overflows
496 * @vlan_proto: vlan encapsulation protocol 501 * @vlan_proto: vlan encapsulation protocol
497 * @vlan_tci: vlan tag control information 502 * @vlan_tci: vlan tag control information
498 * @inner_protocol: Protocol (encapsulation) 503 * @inner_protocol: Protocol (encapsulation)
@@ -641,7 +646,6 @@ struct sk_buff {
641#endif 646#endif
642 union { 647 union {
643 __u32 mark; 648 __u32 mark;
644 __u32 dropcount;
645 __u32 reserved_tailroom; 649 __u32 reserved_tailroom;
646 }; 650 };
647 651
@@ -870,8 +874,7 @@ unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
870void skb_abort_seq_read(struct skb_seq_state *st); 874void skb_abort_seq_read(struct skb_seq_state *st);
871 875
872unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, 876unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
873 unsigned int to, struct ts_config *config, 877 unsigned int to, struct ts_config *config);
874 struct ts_state *state);
875 878
876/* 879/*
877 * Packet hash types specify the type of hash in skb_set_hash. 880 * Packet hash types specify the type of hash in skb_set_hash.
diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
index 46cca4c06848..083ac388098e 100644
--- a/include/linux/sock_diag.h
+++ b/include/linux/sock_diag.h
@@ -19,8 +19,8 @@ void sock_diag_unregister(const struct sock_diag_handler *h);
19void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)); 19void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh));
20void sock_diag_unregister_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)); 20void sock_diag_unregister_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh));
21 21
22int sock_diag_check_cookie(void *sk, __u32 *cookie); 22int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie);
23void sock_diag_save_cookie(void *sk, __u32 *cookie); 23void sock_diag_save_cookie(struct sock *sk, __u32 *cookie);
24 24
25int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr); 25int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr);
26int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk, 26int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 5c19cba34dce..5bf59c8493b7 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -51,6 +51,7 @@ struct msghdr {
51 void *msg_control; /* ancillary data */ 51 void *msg_control; /* ancillary data */
52 __kernel_size_t msg_controllen; /* ancillary data buffer length */ 52 __kernel_size_t msg_controllen; /* ancillary data buffer length */
53 unsigned int msg_flags; /* flags on received message */ 53 unsigned int msg_flags; /* flags on received message */
54 struct kiocb *msg_iocb; /* ptr to iocb for async requests */
54}; 55};
55 56
56struct user_msghdr { 57struct user_msghdr {
@@ -138,6 +139,11 @@ static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr
138 return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); 139 return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
139} 140}
140 141
142static inline size_t msg_data_left(struct msghdr *msg)
143{
144 return iov_iter_count(&msg->msg_iter);
145}
146
141/* "Socket"-level control message types: */ 147/* "Socket"-level control message types: */
142 148
143#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ 149#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */
@@ -181,6 +187,7 @@ struct ucred {
181#define AF_WANPIPE 25 /* Wanpipe API Sockets */ 187#define AF_WANPIPE 25 /* Wanpipe API Sockets */
182#define AF_LLC 26 /* Linux LLC */ 188#define AF_LLC 26 /* Linux LLC */
183#define AF_IB 27 /* Native InfiniBand address */ 189#define AF_IB 27 /* Native InfiniBand address */
190#define AF_MPLS 28 /* MPLS */
184#define AF_CAN 29 /* Controller Area Network */ 191#define AF_CAN 29 /* Controller Area Network */
185#define AF_TIPC 30 /* TIPC sockets */ 192#define AF_TIPC 30 /* TIPC sockets */
186#define AF_BLUETOOTH 31 /* Bluetooth sockets */ 193#define AF_BLUETOOTH 31 /* Bluetooth sockets */
@@ -226,6 +233,7 @@ struct ucred {
226#define PF_WANPIPE AF_WANPIPE 233#define PF_WANPIPE AF_WANPIPE
227#define PF_LLC AF_LLC 234#define PF_LLC AF_LLC
228#define PF_IB AF_IB 235#define PF_IB AF_IB
236#define PF_MPLS AF_MPLS
229#define PF_CAN AF_CAN 237#define PF_CAN AF_CAN
230#define PF_TIPC AF_TIPC 238#define PF_TIPC AF_TIPC
231#define PF_BLUETOOTH AF_BLUETOOTH 239#define PF_BLUETOOTH AF_BLUETOOTH
diff --git a/include/linux/spi/at86rf230.h b/include/linux/spi/at86rf230.h
index cd519a11c2c6..b63fe6f5fdc8 100644
--- a/include/linux/spi/at86rf230.h
+++ b/include/linux/spi/at86rf230.h
@@ -22,6 +22,7 @@ struct at86rf230_platform_data {
22 int rstn; 22 int rstn;
23 int slp_tr; 23 int slp_tr;
24 int dig2; 24 int dig2;
25 u8 xtal_trim;
25}; 26};
26 27
27#endif 28#endif
diff --git a/include/linux/spi/cc2520.h b/include/linux/spi/cc2520.h
index 85b8ee67e937..e741e8baad92 100644
--- a/include/linux/spi/cc2520.h
+++ b/include/linux/spi/cc2520.h
@@ -21,6 +21,7 @@ struct cc2520_platform_data {
21 int sfd; 21 int sfd;
22 int reset; 22 int reset;
23 int vreg; 23 int vreg;
24 bool amplified;
24}; 25};
25 26
26#endif 27#endif
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 1a7adb411647..0caa3a2d4106 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -58,6 +58,7 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb)
58struct tcp_fastopen_cookie { 58struct tcp_fastopen_cookie {
59 s8 len; 59 s8 len;
60 u8 val[TCP_FASTOPEN_COOKIE_MAX]; 60 u8 val[TCP_FASTOPEN_COOKIE_MAX];
61 bool exp; /* In RFC6994 experimental option format */
61}; 62};
62 63
63/* This defines a selective acknowledgement block. */ 64/* This defines a selective acknowledgement block. */
@@ -111,7 +112,7 @@ struct tcp_request_sock_ops;
111struct tcp_request_sock { 112struct tcp_request_sock {
112 struct inet_request_sock req; 113 struct inet_request_sock req;
113 const struct tcp_request_sock_ops *af_specific; 114 const struct tcp_request_sock_ops *af_specific;
114 struct sock *listener; /* needed for TFO */ 115 bool tfo_listener;
115 u32 rcv_isn; 116 u32 rcv_isn;
116 u32 snt_isn; 117 u32 snt_isn;
117 u32 snt_synack; /* synack sent time */ 118 u32 snt_synack; /* synack sent time */
@@ -188,6 +189,7 @@ struct tcp_sock {
188 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */ 189 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */
189 syn_data:1, /* SYN includes data */ 190 syn_data:1, /* SYN includes data */
190 syn_fastopen:1, /* SYN includes Fast Open option */ 191 syn_fastopen:1, /* SYN includes Fast Open option */
192 syn_fastopen_exp:1,/* SYN includes Fast Open exp. option */
191 syn_data_acked:1,/* data in SYN is acked by SYN-ACK */ 193 syn_data_acked:1,/* data in SYN is acked by SYN-ACK */
192 is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */ 194 is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */
193 u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */ 195 u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */
@@ -236,7 +238,6 @@ struct tcp_sock {
236 u32 lost_out; /* Lost packets */ 238 u32 lost_out; /* Lost packets */
237 u32 sacked_out; /* SACK'd packets */ 239 u32 sacked_out; /* SACK'd packets */
238 u32 fackets_out; /* FACK'd packets */ 240 u32 fackets_out; /* FACK'd packets */
239 u32 tso_deferred;
240 241
241 /* from STCP, retrans queue hinting */ 242 /* from STCP, retrans queue hinting */
242 struct sk_buff* lost_skb_hint; 243 struct sk_buff* lost_skb_hint;
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 247cfdcc4b08..87c094961bd5 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -34,7 +34,7 @@ static inline struct udphdr *inner_udp_hdr(const struct sk_buff *skb)
34 34
35#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256) 35#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256)
36 36
37static inline int udp_hashfn(struct net *net, unsigned num, unsigned mask) 37static inline u32 udp_hashfn(const struct net *net, u32 num, u32 mask)
38{ 38{
39 return (num + net_hash_mix(net)) & mask; 39 return (num + net_hash_mix(net)) & mask;
40} 40}
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 0d87674fb775..172632dd9930 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -100,8 +100,8 @@ struct vsock_transport {
100 100
101 /* DGRAM. */ 101 /* DGRAM. */
102 int (*dgram_bind)(struct vsock_sock *, struct sockaddr_vm *); 102 int (*dgram_bind)(struct vsock_sock *, struct sockaddr_vm *);
103 int (*dgram_dequeue)(struct kiocb *kiocb, struct vsock_sock *vsk, 103 int (*dgram_dequeue)(struct vsock_sock *vsk, struct msghdr *msg,
104 struct msghdr *msg, size_t len, int flags); 104 size_t len, int flags);
105 int (*dgram_enqueue)(struct vsock_sock *, struct sockaddr_vm *, 105 int (*dgram_enqueue)(struct vsock_sock *, struct sockaddr_vm *,
106 struct msghdr *, size_t len); 106 struct msghdr *, size_t len);
107 bool (*dgram_allow)(u32 cid, u32 port); 107 bool (*dgram_allow)(u32 cid, u32 port);
diff --git a/include/net/arp.h b/include/net/arp.h
index 73c49864076b..5e0f891d476c 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -9,28 +9,17 @@
9 9
10extern struct neigh_table arp_tbl; 10extern struct neigh_table arp_tbl;
11 11
12static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) 12static inline u32 arp_hashfn(const void *pkey, const struct net_device *dev, u32 *hash_rnd)
13{ 13{
14 u32 key = *(const u32 *)pkey;
14 u32 val = key ^ hash32_ptr(dev); 15 u32 val = key ^ hash32_ptr(dev);
15 16
16 return val * hash_rnd; 17 return val * hash_rnd[0];
17} 18}
18 19
19static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) 20static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key)
20{ 21{
21 struct neigh_hash_table *nht = rcu_dereference_bh(arp_tbl.nht); 22 return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev);
22 struct neighbour *n;
23 u32 hash_val;
24
25 hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift);
26 for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
27 n != NULL;
28 n = rcu_dereference_bh(n->next)) {
29 if (n->dev == dev && *(u32 *)n->primary_key == key)
30 return n;
31 }
32
33 return NULL;
34} 23}
35 24
36static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) 25static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key)
@@ -47,7 +36,6 @@ static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32
47} 36}
48 37
49void arp_init(void); 38void arp_init(void);
50int arp_find(unsigned char *haddr, struct sk_buff *skb);
51int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg); 39int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
52void arp_send(int type, int ptype, __be32 dest_ip, 40void arp_send(int type, int ptype, __be32 dest_ip,
53 struct net_device *dev, __be32 src_ip, 41 struct net_device *dev, __be32 src_ip,
diff --git a/include/net/ax25.h b/include/net/ax25.h
index bf0396e9a5d3..16a923a3a43a 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -12,6 +12,7 @@
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/atomic.h> 14#include <linux/atomic.h>
15#include <net/neighbour.h>
15 16
16#define AX25_T1CLAMPLO 1 17#define AX25_T1CLAMPLO 1
17#define AX25_T1CLAMPHI (30 * HZ) 18#define AX25_T1CLAMPHI (30 * HZ)
@@ -366,9 +367,7 @@ int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *,
366 struct net_device *); 367 struct net_device *);
367 368
368/* ax25_ip.c */ 369/* ax25_ip.c */
369int ax25_hard_header(struct sk_buff *, struct net_device *, unsigned short, 370netdev_tx_t ax25_ip_xmit(struct sk_buff *skb);
370 const void *, const void *, unsigned int);
371int ax25_rebuild_header(struct sk_buff *);
372extern const struct header_ops ax25_header_ops; 371extern const struct header_ops ax25_header_ops;
373 372
374/* ax25_out.c */ 373/* ax25_out.c */
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index e00455aab18c..7dba80546f16 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -245,10 +245,10 @@ int bt_sock_register(int proto, const struct net_proto_family *ops);
245void bt_sock_unregister(int proto); 245void bt_sock_unregister(int proto);
246void bt_sock_link(struct bt_sock_list *l, struct sock *s); 246void bt_sock_link(struct bt_sock_list *l, struct sock *s);
247void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); 247void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
248int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, 248int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
249 struct msghdr *msg, size_t len, int flags); 249 int flags);
250int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, 250int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
251 struct msghdr *msg, size_t len, int flags); 251 size_t len, int flags);
252uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait); 252uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
253int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 253int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
254int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); 254int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
@@ -269,29 +269,34 @@ struct l2cap_ctrl {
269 __u16 reqseq; 269 __u16 reqseq;
270 __u16 txseq; 270 __u16 txseq;
271 __u8 retries; 271 __u8 retries;
272 __le16 psm;
273 bdaddr_t bdaddr;
274 struct l2cap_chan *chan;
272}; 275};
273 276
274struct hci_dev; 277struct hci_dev;
275 278
276typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode); 279typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
277 280typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
278struct hci_req_ctrl { 281 u16 opcode, struct sk_buff *skb);
279 bool start; 282
280 u8 event; 283struct req_ctrl {
281 hci_req_complete_t complete; 284 bool start;
285 u8 event;
286 hci_req_complete_t complete;
287 hci_req_complete_skb_t complete_skb;
282}; 288};
283 289
284struct bt_skb_cb { 290struct bt_skb_cb {
285 __u8 pkt_type; 291 __u8 pkt_type;
286 __u8 incoming; 292 __u8 force_active;
287 __u16 opcode; 293 __u16 opcode;
288 __u16 expect; 294 __u16 expect;
289 __u8 force_active; 295 __u8 incoming:1;
290 struct l2cap_chan *chan; 296 union {
291 struct l2cap_ctrl control; 297 struct l2cap_ctrl l2cap;
292 struct hci_req_ctrl req; 298 struct req_ctrl req;
293 bdaddr_t bdaddr; 299 };
294 __le16 psm;
295}; 300};
296#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) 301#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
297 302
@@ -339,6 +344,11 @@ out:
339 344
340int bt_to_errno(__u16 code); 345int bt_to_errno(__u16 code);
341 346
347void hci_sock_set_flag(struct sock *sk, int nr);
348void hci_sock_clear_flag(struct sock *sk, int nr);
349int hci_sock_test_flag(struct sock *sk, int nr);
350unsigned short hci_sock_get_channel(struct sock *sk);
351
342int hci_sock_init(void); 352int hci_sock_init(void);
343void hci_sock_cleanup(void); 353void hci_sock_cleanup(void);
344 354
@@ -358,6 +368,9 @@ void l2cap_exit(void);
358int sco_init(void); 368int sco_init(void);
359void sco_exit(void); 369void sco_exit(void);
360 370
371int mgmt_init(void);
372void mgmt_exit(void);
373
361void bt_sock_reclassify_lock(struct sock *sk, int proto); 374void bt_sock_reclassify_lock(struct sock *sk, int proto);
362 375
363#endif /* __BLUETOOTH_H */ 376#endif /* __BLUETOOTH_H */
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 8e54f825153c..d95da83cb1b0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -160,6 +160,14 @@ enum {
160 * during the hdev->setup vendor callback. 160 * during the hdev->setup vendor callback.
161 */ 161 */
162 HCI_QUIRK_STRICT_DUPLICATE_FILTER, 162 HCI_QUIRK_STRICT_DUPLICATE_FILTER,
163
164 /* When this quirk is set, LE scan and BR/EDR inquiry is done
165 * simultaneously, otherwise it's interleaved.
166 *
167 * This quirk can be set before hci_register_dev is called or
168 * during the hdev->setup vendor callback.
169 */
170 HCI_QUIRK_SIMULTANEOUS_DISCOVERY,
163}; 171};
164 172
165/* HCI device flags */ 173/* HCI device flags */
@@ -179,13 +187,14 @@ enum {
179 HCI_RESET, 187 HCI_RESET,
180}; 188};
181 189
182/* BR/EDR and/or LE controller flags: the flags defined here should represent 190/* HCI socket flags */
183 * states configured via debugfs for debugging and testing purposes only.
184 */
185enum { 191enum {
186 HCI_DUT_MODE, 192 HCI_SOCK_TRUSTED,
187 HCI_FORCE_BREDR_SMP, 193 HCI_MGMT_INDEX_EVENTS,
188 HCI_FORCE_STATIC_ADDR, 194 HCI_MGMT_UNCONF_INDEX_EVENTS,
195 HCI_MGMT_EXT_INDEX_EVENTS,
196 HCI_MGMT_GENERIC_EVENTS,
197 HCI_MGMT_OOB_DATA_EVENTS,
189}; 198};
190 199
191/* 200/*
@@ -217,6 +226,8 @@ enum {
217 HCI_HS_ENABLED, 226 HCI_HS_ENABLED,
218 HCI_LE_ENABLED, 227 HCI_LE_ENABLED,
219 HCI_ADVERTISING, 228 HCI_ADVERTISING,
229 HCI_ADVERTISING_CONNECTABLE,
230 HCI_ADVERTISING_INSTANCE,
220 HCI_CONNECTABLE, 231 HCI_CONNECTABLE,
221 HCI_DISCOVERABLE, 232 HCI_DISCOVERABLE,
222 HCI_LIMITED_DISCOVERABLE, 233 HCI_LIMITED_DISCOVERABLE,
@@ -225,13 +236,13 @@ enum {
225 HCI_FAST_CONNECTABLE, 236 HCI_FAST_CONNECTABLE,
226 HCI_BREDR_ENABLED, 237 HCI_BREDR_ENABLED,
227 HCI_LE_SCAN_INTERRUPTED, 238 HCI_LE_SCAN_INTERRUPTED,
228};
229 239
230/* A mask for the flags that are supposed to remain when a reset happens 240 HCI_DUT_MODE,
231 * or the HCI device is closed. 241 HCI_FORCE_BREDR_SMP,
232 */ 242 HCI_FORCE_STATIC_ADDR,
233#define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \ 243
234 BIT(HCI_FAST_CONNECTABLE) | BIT(HCI_LE_ADV)) 244 __HCI_NUM_FLAGS,
245};
235 246
236/* HCI timeouts */ 247/* HCI timeouts */
237#define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ 248#define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
@@ -363,6 +374,7 @@ enum {
363/* LE features */ 374/* LE features */
364#define HCI_LE_ENCRYPTION 0x01 375#define HCI_LE_ENCRYPTION 0x01
365#define HCI_LE_CONN_PARAM_REQ_PROC 0x02 376#define HCI_LE_CONN_PARAM_REQ_PROC 0x02
377#define HCI_LE_SLAVE_FEATURES 0x08
366#define HCI_LE_PING 0x10 378#define HCI_LE_PING 0x10
367#define HCI_LE_DATA_LEN_EXT 0x20 379#define HCI_LE_DATA_LEN_EXT 0x20
368#define HCI_LE_EXT_SCAN_POLICY 0x80 380#define HCI_LE_EXT_SCAN_POLICY 0x80
@@ -452,9 +464,16 @@ enum {
452#define EIR_NAME_COMPLETE 0x09 /* complete local name */ 464#define EIR_NAME_COMPLETE 0x09 /* complete local name */
453#define EIR_TX_POWER 0x0A /* transmit power level */ 465#define EIR_TX_POWER 0x0A /* transmit power level */
454#define EIR_CLASS_OF_DEV 0x0D /* Class of Device */ 466#define EIR_CLASS_OF_DEV 0x0D /* Class of Device */
455#define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */ 467#define EIR_SSP_HASH_C192 0x0E /* Simple Pairing Hash C-192 */
456#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */ 468#define EIR_SSP_RAND_R192 0x0F /* Simple Pairing Randomizer R-192 */
457#define EIR_DEVICE_ID 0x10 /* device ID */ 469#define EIR_DEVICE_ID 0x10 /* device ID */
470#define EIR_APPEARANCE 0x19 /* Device appearance */
471#define EIR_LE_BDADDR 0x1B /* LE Bluetooth device address */
472#define EIR_LE_ROLE 0x1C /* LE role */
473#define EIR_SSP_HASH_C256 0x1D /* Simple Pairing Hash C-256 */
474#define EIR_SSP_RAND_R256 0x1E /* Simple Pairing Rand R-256 */
475#define EIR_LE_SC_CONFIRM 0x22 /* LE SC Confirmation Value */
476#define EIR_LE_SC_RANDOM 0x23 /* LE SC Random Value */
458 477
459/* Low Energy Advertising Flags */ 478/* Low Energy Advertising Flags */
460#define LE_AD_LIMITED 0x01 /* Limited Discoverable */ 479#define LE_AD_LIMITED 0x01 /* Limited Discoverable */
@@ -1358,6 +1377,11 @@ struct hci_cp_le_conn_update {
1358 __le16 max_ce_len; 1377 __le16 max_ce_len;
1359} __packed; 1378} __packed;
1360 1379
1380#define HCI_OP_LE_READ_REMOTE_FEATURES 0x2016
1381struct hci_cp_le_read_remote_features {
1382 __le16 handle;
1383} __packed;
1384
1361#define HCI_OP_LE_START_ENC 0x2019 1385#define HCI_OP_LE_START_ENC 0x2019
1362struct hci_cp_le_start_enc { 1386struct hci_cp_le_start_enc {
1363 __le16 handle; 1387 __le16 handle;
@@ -1850,6 +1874,13 @@ struct hci_ev_le_conn_update_complete {
1850 __le16 supervision_timeout; 1874 __le16 supervision_timeout;
1851} __packed; 1875} __packed;
1852 1876
1877#define HCI_EV_LE_REMOTE_FEAT_COMPLETE 0x04
1878struct hci_ev_le_remote_feat_complete {
1879 __u8 status;
1880 __le16 handle;
1881 __u8 features[8];
1882} __packed;
1883
1853#define HCI_EV_LE_LTK_REQ 0x05 1884#define HCI_EV_LE_LTK_REQ 0x05
1854struct hci_ev_le_ltk_req { 1885struct hci_ev_le_ltk_req {
1855 __le16 handle; 1886 __le16 handle;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 52863c3e0b13..a056c2bfeb81 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -76,6 +76,7 @@ struct discovery_state {
76 u8 last_adv_data[HCI_MAX_AD_LENGTH]; 76 u8 last_adv_data[HCI_MAX_AD_LENGTH];
77 u8 last_adv_data_len; 77 u8 last_adv_data_len;
78 bool report_invalid_rssi; 78 bool report_invalid_rssi;
79 bool result_filtering;
79 s8 rssi; 80 s8 rssi;
80 u16 uuid_count; 81 u16 uuid_count;
81 u8 (*uuids)[16]; 82 u8 (*uuids)[16];
@@ -108,7 +109,7 @@ struct bt_uuid {
108struct smp_csrk { 109struct smp_csrk {
109 bdaddr_t bdaddr; 110 bdaddr_t bdaddr;
110 u8 bdaddr_type; 111 u8 bdaddr_type;
111 u8 master; 112 u8 type;
112 u8 val[16]; 113 u8 val[16];
113}; 114};
114 115
@@ -154,6 +155,17 @@ struct oob_data {
154 u8 rand256[16]; 155 u8 rand256[16];
155}; 156};
156 157
158struct adv_info {
159 struct delayed_work timeout_exp;
160 __u8 instance;
161 __u32 flags;
162 __u16 timeout;
163 __u16 adv_data_len;
164 __u8 adv_data[HCI_MAX_AD_LENGTH];
165 __u16 scan_rsp_len;
166 __u8 scan_rsp_data[HCI_MAX_AD_LENGTH];
167};
168
157#define HCI_MAX_SHORT_NAME_LENGTH 10 169#define HCI_MAX_SHORT_NAME_LENGTH 10
158 170
159/* Default LE RPA expiry time, 15 minutes */ 171/* Default LE RPA expiry time, 15 minutes */
@@ -173,7 +185,6 @@ struct amp_assoc {
173 185
174#define HCI_MAX_PAGES 3 186#define HCI_MAX_PAGES 3
175 187
176#define NUM_REASSEMBLY 4
177struct hci_dev { 188struct hci_dev {
178 struct list_head list; 189 struct list_head list;
179 struct mutex lock; 190 struct mutex lock;
@@ -314,14 +325,13 @@ struct hci_dev {
314 struct sk_buff_head raw_q; 325 struct sk_buff_head raw_q;
315 struct sk_buff_head cmd_q; 326 struct sk_buff_head cmd_q;
316 327
317 struct sk_buff *recv_evt;
318 struct sk_buff *sent_cmd; 328 struct sk_buff *sent_cmd;
319 struct sk_buff *reassembly[NUM_REASSEMBLY];
320 329
321 struct mutex req_lock; 330 struct mutex req_lock;
322 wait_queue_head_t req_wait_q; 331 wait_queue_head_t req_wait_q;
323 __u32 req_status; 332 __u32 req_status;
324 __u32 req_result; 333 __u32 req_result;
334 struct sk_buff *req_skb;
325 335
326 void *smp_data; 336 void *smp_data;
327 void *smp_bredr_data; 337 void *smp_bredr_data;
@@ -352,8 +362,7 @@ struct hci_dev {
352 362
353 struct rfkill *rfkill; 363 struct rfkill *rfkill;
354 364
355 unsigned long dbg_flags; 365 DECLARE_BITMAP(dev_flags, __HCI_NUM_FLAGS);
356 unsigned long dev_flags;
357 366
358 struct delayed_work le_scan_disable; 367 struct delayed_work le_scan_disable;
359 struct delayed_work le_scan_restart; 368 struct delayed_work le_scan_restart;
@@ -364,6 +373,8 @@ struct hci_dev {
364 __u8 scan_rsp_data[HCI_MAX_AD_LENGTH]; 373 __u8 scan_rsp_data[HCI_MAX_AD_LENGTH];
365 __u8 scan_rsp_data_len; 374 __u8 scan_rsp_data_len;
366 375
376 struct adv_info adv_instance;
377
367 __u8 irk[16]; 378 __u8 irk[16];
368 __u32 rpa_timeout; 379 __u32 rpa_timeout;
369 struct delayed_work rpa_expired; 380 struct delayed_work rpa_expired;
@@ -373,6 +384,7 @@ struct hci_dev {
373 int (*close)(struct hci_dev *hdev); 384 int (*close)(struct hci_dev *hdev);
374 int (*flush)(struct hci_dev *hdev); 385 int (*flush)(struct hci_dev *hdev);
375 int (*setup)(struct hci_dev *hdev); 386 int (*setup)(struct hci_dev *hdev);
387 int (*shutdown)(struct hci_dev *hdev);
376 int (*send)(struct hci_dev *hdev, struct sk_buff *skb); 388 int (*send)(struct hci_dev *hdev, struct sk_buff *skb);
377 void (*notify)(struct hci_dev *hdev, unsigned int evt); 389 void (*notify)(struct hci_dev *hdev, unsigned int evt);
378 void (*hw_error)(struct hci_dev *hdev, u8 code); 390 void (*hw_error)(struct hci_dev *hdev, u8 code);
@@ -498,19 +510,29 @@ struct hci_conn_params {
498extern struct list_head hci_dev_list; 510extern struct list_head hci_dev_list;
499extern struct list_head hci_cb_list; 511extern struct list_head hci_cb_list;
500extern rwlock_t hci_dev_list_lock; 512extern rwlock_t hci_dev_list_lock;
501extern rwlock_t hci_cb_list_lock; 513extern struct mutex hci_cb_list_lock;
514
515#define hci_dev_set_flag(hdev, nr) set_bit((nr), (hdev)->dev_flags)
516#define hci_dev_clear_flag(hdev, nr) clear_bit((nr), (hdev)->dev_flags)
517#define hci_dev_change_flag(hdev, nr) change_bit((nr), (hdev)->dev_flags)
518#define hci_dev_test_flag(hdev, nr) test_bit((nr), (hdev)->dev_flags)
519#define hci_dev_test_and_set_flag(hdev, nr) test_and_set_bit((nr), (hdev)->dev_flags)
520#define hci_dev_test_and_clear_flag(hdev, nr) test_and_clear_bit((nr), (hdev)->dev_flags)
521#define hci_dev_test_and_change_flag(hdev, nr) test_and_change_bit((nr), (hdev)->dev_flags)
522
523#define hci_dev_clear_volatile_flags(hdev) \
524 do { \
525 hci_dev_clear_flag(hdev, HCI_LE_SCAN); \
526 hci_dev_clear_flag(hdev, HCI_LE_ADV); \
527 hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); \
528 } while (0)
502 529
503/* ----- HCI interface to upper protocols ----- */ 530/* ----- HCI interface to upper protocols ----- */
504int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); 531int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
505void l2cap_connect_cfm(struct hci_conn *hcon, u8 status);
506int l2cap_disconn_ind(struct hci_conn *hcon); 532int l2cap_disconn_ind(struct hci_conn *hcon);
507void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason);
508int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt);
509int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags); 533int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags);
510 534
511int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); 535int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags);
512void sco_connect_cfm(struct hci_conn *hcon, __u8 status);
513void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason);
514int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); 536int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);
515 537
516/* ----- Inquiry cache ----- */ 538/* ----- Inquiry cache ----- */
@@ -529,6 +551,7 @@ static inline void discovery_init(struct hci_dev *hdev)
529 551
530static inline void hci_discovery_filter_clear(struct hci_dev *hdev) 552static inline void hci_discovery_filter_clear(struct hci_dev *hdev)
531{ 553{
554 hdev->discovery.result_filtering = false;
532 hdev->discovery.report_invalid_rssi = true; 555 hdev->discovery.report_invalid_rssi = true;
533 hdev->discovery.rssi = HCI_RSSI_INVALID; 556 hdev->discovery.rssi = HCI_RSSI_INVALID;
534 hdev->discovery.uuid_count = 0; 557 hdev->discovery.uuid_count = 0;
@@ -538,6 +561,11 @@ static inline void hci_discovery_filter_clear(struct hci_dev *hdev)
538 hdev->discovery.scan_duration = 0; 561 hdev->discovery.scan_duration = 0;
539} 562}
540 563
564static inline void adv_info_init(struct hci_dev *hdev)
565{
566 memset(&hdev->adv_instance, 0, sizeof(struct adv_info));
567}
568
541bool hci_discovery_active(struct hci_dev *hdev); 569bool hci_discovery_active(struct hci_dev *hdev);
542 570
543void hci_discovery_set_state(struct hci_dev *hdev, int state); 571void hci_discovery_set_state(struct hci_dev *hdev, int state);
@@ -584,7 +612,6 @@ enum {
584 HCI_CONN_SC_ENABLED, 612 HCI_CONN_SC_ENABLED,
585 HCI_CONN_AES_CCM, 613 HCI_CONN_AES_CCM,
586 HCI_CONN_POWER_SAVE, 614 HCI_CONN_POWER_SAVE,
587 HCI_CONN_REMOTE_OOB,
588 HCI_CONN_FLUSH_KEY, 615 HCI_CONN_FLUSH_KEY,
589 HCI_CONN_ENCRYPT, 616 HCI_CONN_ENCRYPT,
590 HCI_CONN_AUTH, 617 HCI_CONN_AUTH,
@@ -600,14 +627,14 @@ enum {
600static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) 627static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
601{ 628{
602 struct hci_dev *hdev = conn->hdev; 629 struct hci_dev *hdev = conn->hdev;
603 return test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && 630 return hci_dev_test_flag(hdev, HCI_SSP_ENABLED) &&
604 test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); 631 test_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
605} 632}
606 633
607static inline bool hci_conn_sc_enabled(struct hci_conn *conn) 634static inline bool hci_conn_sc_enabled(struct hci_conn *conn)
608{ 635{
609 struct hci_dev *hdev = conn->hdev; 636 struct hci_dev *hdev = conn->hdev;
610 return test_bit(HCI_SC_ENABLED, &hdev->dev_flags) && 637 return hci_dev_test_flag(hdev, HCI_SC_ENABLED) &&
611 test_bit(HCI_CONN_SC_ENABLED, &conn->flags); 638 test_bit(HCI_CONN_SC_ENABLED, &conn->flags);
612} 639}
613 640
@@ -969,6 +996,8 @@ struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr,
969void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type); 996void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type);
970void hci_smp_irks_clear(struct hci_dev *hdev); 997void hci_smp_irks_clear(struct hci_dev *hdev);
971 998
999bool hci_bdaddr_is_paired(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
1000
972void hci_remote_oob_data_clear(struct hci_dev *hdev); 1001void hci_remote_oob_data_clear(struct hci_dev *hdev);
973struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, 1002struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
974 bdaddr_t *bdaddr, u8 bdaddr_type); 1003 bdaddr_t *bdaddr, u8 bdaddr_type);
@@ -981,7 +1010,6 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
981void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 1010void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
982 1011
983int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb); 1012int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb);
984int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
985 1013
986void hci_init_sysfs(struct hci_dev *hdev); 1014void hci_init_sysfs(struct hci_dev *hdev);
987void hci_conn_init_sysfs(struct hci_conn *conn); 1015void hci_conn_init_sysfs(struct hci_conn *conn);
@@ -1025,10 +1053,10 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
1025#define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) 1053#define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE))
1026#define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) 1054#define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR))
1027 1055
1028#define hdev_is_powered(hdev) (test_bit(HCI_UP, &hdev->flags) && \ 1056#define hdev_is_powered(dev) (test_bit(HCI_UP, &(dev)->flags) && \
1029 !test_bit(HCI_AUTO_OFF, &hdev->dev_flags)) 1057 !hci_dev_test_flag(dev, HCI_AUTO_OFF))
1030#define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \ 1058#define bredr_sc_enabled(dev) (lmp_sc_capable(dev) && \
1031 test_bit(HCI_SC_ENABLED, &(dev)->dev_flags)) 1059 hci_dev_test_flag(dev, HCI_SC_ENABLED))
1032 1060
1033/* ----- HCI protocols ----- */ 1061/* ----- HCI protocols ----- */
1034#define HCI_PROTO_DEFER 0x01 1062#define HCI_PROTO_DEFER 0x01
@@ -1050,28 +1078,6 @@ static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
1050 } 1078 }
1051} 1079}
1052 1080
1053static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status)
1054{
1055 switch (conn->type) {
1056 case ACL_LINK:
1057 case LE_LINK:
1058 l2cap_connect_cfm(conn, status);
1059 break;
1060
1061 case SCO_LINK:
1062 case ESCO_LINK:
1063 sco_connect_cfm(conn, status);
1064 break;
1065
1066 default:
1067 BT_ERR("unknown link type %d", conn->type);
1068 break;
1069 }
1070
1071 if (conn->connect_cfm_cb)
1072 conn->connect_cfm_cb(conn, status);
1073}
1074
1075static inline int hci_proto_disconn_ind(struct hci_conn *conn) 1081static inline int hci_proto_disconn_ind(struct hci_conn *conn)
1076{ 1082{
1077 if (conn->type != ACL_LINK && conn->type != LE_LINK) 1083 if (conn->type != ACL_LINK && conn->type != LE_LINK)
@@ -1080,91 +1086,69 @@ static inline int hci_proto_disconn_ind(struct hci_conn *conn)
1080 return l2cap_disconn_ind(conn); 1086 return l2cap_disconn_ind(conn);
1081} 1087}
1082 1088
1083static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) 1089/* ----- HCI callbacks ----- */
1084{ 1090struct hci_cb {
1085 switch (conn->type) { 1091 struct list_head list;
1086 case ACL_LINK:
1087 case LE_LINK:
1088 l2cap_disconn_cfm(conn, reason);
1089 break;
1090
1091 case SCO_LINK:
1092 case ESCO_LINK:
1093 sco_disconn_cfm(conn, reason);
1094 break;
1095
1096 /* L2CAP would be handled for BREDR chan */
1097 case AMP_LINK:
1098 break;
1099 1092
1100 default: 1093 char *name;
1101 BT_ERR("unknown link type %d", conn->type);
1102 break;
1103 }
1104 1094
1105 if (conn->disconn_cfm_cb) 1095 void (*connect_cfm) (struct hci_conn *conn, __u8 status);
1106 conn->disconn_cfm_cb(conn, reason); 1096 void (*disconn_cfm) (struct hci_conn *conn, __u8 status);
1107} 1097 void (*security_cfm) (struct hci_conn *conn, __u8 status,
1098 __u8 encrypt);
1099 void (*key_change_cfm) (struct hci_conn *conn, __u8 status);
1100 void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role);
1101};
1108 1102
1109static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) 1103static inline void hci_connect_cfm(struct hci_conn *conn, __u8 status)
1110{ 1104{
1111 __u8 encrypt; 1105 struct hci_cb *cb;
1112
1113 if (conn->type != ACL_LINK && conn->type != LE_LINK)
1114 return;
1115
1116 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
1117 return;
1118 1106
1119 encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00; 1107 mutex_lock(&hci_cb_list_lock);
1120 l2cap_security_cfm(conn, status, encrypt); 1108 list_for_each_entry(cb, &hci_cb_list, list) {
1109 if (cb->connect_cfm)
1110 cb->connect_cfm(conn, status);
1111 }
1112 mutex_unlock(&hci_cb_list_lock);
1121 1113
1122 if (conn->security_cfm_cb) 1114 if (conn->connect_cfm_cb)
1123 conn->security_cfm_cb(conn, status); 1115 conn->connect_cfm_cb(conn, status);
1124} 1116}
1125 1117
1126static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, 1118static inline void hci_disconn_cfm(struct hci_conn *conn, __u8 reason)
1127 __u8 encrypt)
1128{ 1119{
1129 if (conn->type != ACL_LINK && conn->type != LE_LINK) 1120 struct hci_cb *cb;
1130 return;
1131 1121
1132 l2cap_security_cfm(conn, status, encrypt); 1122 mutex_lock(&hci_cb_list_lock);
1123 list_for_each_entry(cb, &hci_cb_list, list) {
1124 if (cb->disconn_cfm)
1125 cb->disconn_cfm(conn, reason);
1126 }
1127 mutex_unlock(&hci_cb_list_lock);
1133 1128
1134 if (conn->security_cfm_cb) 1129 if (conn->disconn_cfm_cb)
1135 conn->security_cfm_cb(conn, status); 1130 conn->disconn_cfm_cb(conn, reason);
1136} 1131}
1137 1132
1138/* ----- HCI callbacks ----- */
1139struct hci_cb {
1140 struct list_head list;
1141
1142 char *name;
1143
1144 void (*security_cfm) (struct hci_conn *conn, __u8 status,
1145 __u8 encrypt);
1146 void (*key_change_cfm) (struct hci_conn *conn, __u8 status);
1147 void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role);
1148};
1149
1150static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) 1133static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
1151{ 1134{
1152 struct hci_cb *cb; 1135 struct hci_cb *cb;
1153 __u8 encrypt; 1136 __u8 encrypt;
1154 1137
1155 hci_proto_auth_cfm(conn, status);
1156
1157 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) 1138 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
1158 return; 1139 return;
1159 1140
1160 encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00; 1141 encrypt = test_bit(HCI_CONN_ENCRYPT, &conn->flags) ? 0x01 : 0x00;
1161 1142
1162 read_lock(&hci_cb_list_lock); 1143 mutex_lock(&hci_cb_list_lock);
1163 list_for_each_entry(cb, &hci_cb_list, list) { 1144 list_for_each_entry(cb, &hci_cb_list, list) {
1164 if (cb->security_cfm) 1145 if (cb->security_cfm)
1165 cb->security_cfm(conn, status, encrypt); 1146 cb->security_cfm(conn, status, encrypt);
1166 } 1147 }
1167 read_unlock(&hci_cb_list_lock); 1148 mutex_unlock(&hci_cb_list_lock);
1149
1150 if (conn->security_cfm_cb)
1151 conn->security_cfm_cb(conn, status);
1168} 1152}
1169 1153
1170static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, 1154static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
@@ -1178,26 +1162,27 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
1178 if (conn->pending_sec_level > conn->sec_level) 1162 if (conn->pending_sec_level > conn->sec_level)
1179 conn->sec_level = conn->pending_sec_level; 1163 conn->sec_level = conn->pending_sec_level;
1180 1164
1181 hci_proto_encrypt_cfm(conn, status, encrypt); 1165 mutex_lock(&hci_cb_list_lock);
1182
1183 read_lock(&hci_cb_list_lock);
1184 list_for_each_entry(cb, &hci_cb_list, list) { 1166 list_for_each_entry(cb, &hci_cb_list, list) {
1185 if (cb->security_cfm) 1167 if (cb->security_cfm)
1186 cb->security_cfm(conn, status, encrypt); 1168 cb->security_cfm(conn, status, encrypt);
1187 } 1169 }
1188 read_unlock(&hci_cb_list_lock); 1170 mutex_unlock(&hci_cb_list_lock);
1171
1172 if (conn->security_cfm_cb)
1173 conn->security_cfm_cb(conn, status);
1189} 1174}
1190 1175
1191static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) 1176static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status)
1192{ 1177{
1193 struct hci_cb *cb; 1178 struct hci_cb *cb;
1194 1179
1195 read_lock(&hci_cb_list_lock); 1180 mutex_lock(&hci_cb_list_lock);
1196 list_for_each_entry(cb, &hci_cb_list, list) { 1181 list_for_each_entry(cb, &hci_cb_list, list) {
1197 if (cb->key_change_cfm) 1182 if (cb->key_change_cfm)
1198 cb->key_change_cfm(conn, status); 1183 cb->key_change_cfm(conn, status);
1199 } 1184 }
1200 read_unlock(&hci_cb_list_lock); 1185 mutex_unlock(&hci_cb_list_lock);
1201} 1186}
1202 1187
1203static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, 1188static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
@@ -1205,12 +1190,12 @@ static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
1205{ 1190{
1206 struct hci_cb *cb; 1191 struct hci_cb *cb;
1207 1192
1208 read_lock(&hci_cb_list_lock); 1193 mutex_lock(&hci_cb_list_lock);
1209 list_for_each_entry(cb, &hci_cb_list, list) { 1194 list_for_each_entry(cb, &hci_cb_list, list) {
1210 if (cb->role_switch_cfm) 1195 if (cb->role_switch_cfm)
1211 cb->role_switch_cfm(conn, status, role); 1196 cb->role_switch_cfm(conn, status, role);
1212 } 1197 }
1213 read_unlock(&hci_cb_list_lock); 1198 mutex_unlock(&hci_cb_list_lock);
1214} 1199}
1215 1200
1216static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) 1201static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type)
@@ -1296,8 +1281,6 @@ static inline int hci_check_conn_params(u16 min, u16 max, u16 latency,
1296int hci_register_cb(struct hci_cb *hcb); 1281int hci_register_cb(struct hci_cb *hcb);
1297int hci_unregister_cb(struct hci_cb *hcb); 1282int hci_unregister_cb(struct hci_cb *hcb);
1298 1283
1299bool hci_req_pending(struct hci_dev *hdev);
1300
1301struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 1284struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
1302 const void *param, u32 timeout); 1285 const void *param, u32 timeout);
1303struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, 1286struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
@@ -1312,11 +1295,35 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode);
1312 1295
1313/* ----- HCI Sockets ----- */ 1296/* ----- HCI Sockets ----- */
1314void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); 1297void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb);
1315void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); 1298void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
1299 int flag, struct sock *skip_sk);
1316void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); 1300void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb);
1317 1301
1318void hci_sock_dev_event(struct hci_dev *hdev, int event); 1302void hci_sock_dev_event(struct hci_dev *hdev, int event);
1319 1303
1304#define HCI_MGMT_VAR_LEN BIT(0)
1305#define HCI_MGMT_NO_HDEV BIT(1)
1306#define HCI_MGMT_UNTRUSTED BIT(2)
1307#define HCI_MGMT_UNCONFIGURED BIT(3)
1308
1309struct hci_mgmt_handler {
1310 int (*func) (struct sock *sk, struct hci_dev *hdev, void *data,
1311 u16 data_len);
1312 size_t data_len;
1313 unsigned long flags;
1314};
1315
1316struct hci_mgmt_chan {
1317 struct list_head list;
1318 unsigned short channel;
1319 size_t handler_count;
1320 const struct hci_mgmt_handler *handlers;
1321 void (*hdev_init) (struct sock *sk, struct hci_dev *hdev);
1322};
1323
1324int hci_mgmt_chan_register(struct hci_mgmt_chan *c);
1325void hci_mgmt_chan_unregister(struct hci_mgmt_chan *c);
1326
1320/* Management interface */ 1327/* Management interface */
1321#define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR)) 1328#define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR))
1322#define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \ 1329#define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \
@@ -1336,7 +1343,6 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event);
1336#define DISCOV_BREDR_INQUIRY_LEN 0x08 1343#define DISCOV_BREDR_INQUIRY_LEN 0x08
1337#define DISCOV_LE_RESTART_DELAY msecs_to_jiffies(200) /* msec */ 1344#define DISCOV_LE_RESTART_DELAY msecs_to_jiffies(200) /* msec */
1338 1345
1339int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
1340int mgmt_new_settings(struct hci_dev *hdev); 1346int mgmt_new_settings(struct hci_dev *hdev);
1341void mgmt_index_added(struct hci_dev *hdev); 1347void mgmt_index_added(struct hci_dev *hdev);
1342void mgmt_index_removed(struct hci_dev *hdev); 1348void mgmt_index_removed(struct hci_dev *hdev);
@@ -1382,9 +1388,6 @@ void mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status);
1382void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, 1388void mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
1383 u8 status); 1389 u8 status);
1384void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); 1390void mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
1385void mgmt_read_local_oob_data_complete(struct hci_dev *hdev, u8 *hash192,
1386 u8 *rand192, u8 *hash256, u8 *rand256,
1387 u8 status);
1388void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1391void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1389 u8 addr_type, u8 *dev_class, s8 rssi, u32 flags, 1392 u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
1390 u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len); 1393 u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len);
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index e218a30f2061..b831242d48a4 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -43,6 +43,8 @@
43#define MGMT_STATUS_CANCELLED 0x10 43#define MGMT_STATUS_CANCELLED 0x10
44#define MGMT_STATUS_INVALID_INDEX 0x11 44#define MGMT_STATUS_INVALID_INDEX 0x11
45#define MGMT_STATUS_RFKILLED 0x12 45#define MGMT_STATUS_RFKILLED 0x12
46#define MGMT_STATUS_ALREADY_PAIRED 0x13
47#define MGMT_STATUS_PERMISSION_DENIED 0x14
46 48
47struct mgmt_hdr { 49struct mgmt_hdr {
48 __le16 opcode; 50 __le16 opcode;
@@ -98,6 +100,7 @@ struct mgmt_rp_read_index_list {
98#define MGMT_SETTING_DEBUG_KEYS 0x00001000 100#define MGMT_SETTING_DEBUG_KEYS 0x00001000
99#define MGMT_SETTING_PRIVACY 0x00002000 101#define MGMT_SETTING_PRIVACY 0x00002000
100#define MGMT_SETTING_CONFIGURATION 0x00004000 102#define MGMT_SETTING_CONFIGURATION 0x00004000
103#define MGMT_SETTING_STATIC_ADDRESS 0x00008000
101 104
102#define MGMT_OP_READ_INFO 0x0004 105#define MGMT_OP_READ_INFO 0x0004
103#define MGMT_READ_INFO_SIZE 0 106#define MGMT_READ_INFO_SIZE 0
@@ -503,6 +506,71 @@ struct mgmt_cp_start_service_discovery {
503} __packed; 506} __packed;
504#define MGMT_START_SERVICE_DISCOVERY_SIZE 4 507#define MGMT_START_SERVICE_DISCOVERY_SIZE 4
505 508
509#define MGMT_OP_READ_LOCAL_OOB_EXT_DATA 0x003B
510struct mgmt_cp_read_local_oob_ext_data {
511 __u8 type;
512} __packed;
513#define MGMT_READ_LOCAL_OOB_EXT_DATA_SIZE 1
514struct mgmt_rp_read_local_oob_ext_data {
515 __u8 type;
516 __le16 eir_len;
517 __u8 eir[0];
518} __packed;
519
520#define MGMT_OP_READ_EXT_INDEX_LIST 0x003C
521#define MGMT_READ_EXT_INDEX_LIST_SIZE 0
522struct mgmt_rp_read_ext_index_list {
523 __le16 num_controllers;
524 struct {
525 __le16 index;
526 __u8 type;
527 __u8 bus;
528 } entry[0];
529} __packed;
530
531#define MGMT_OP_READ_ADV_FEATURES 0x0003D
532#define MGMT_READ_ADV_FEATURES_SIZE 0
533struct mgmt_rp_read_adv_features {
534 __le32 supported_flags;
535 __u8 max_adv_data_len;
536 __u8 max_scan_rsp_len;
537 __u8 max_instances;
538 __u8 num_instances;
539 __u8 instance[0];
540} __packed;
541
542#define MGMT_OP_ADD_ADVERTISING 0x003E
543struct mgmt_cp_add_advertising {
544 __u8 instance;
545 __le32 flags;
546 __le16 duration;
547 __le16 timeout;
548 __u8 adv_data_len;
549 __u8 scan_rsp_len;
550 __u8 data[0];
551} __packed;
552#define MGMT_ADD_ADVERTISING_SIZE 11
553struct mgmt_rp_add_advertising {
554 __u8 instance;
555} __packed;
556
557#define MGMT_ADV_FLAG_CONNECTABLE BIT(0)
558#define MGMT_ADV_FLAG_DISCOV BIT(1)
559#define MGMT_ADV_FLAG_LIMITED_DISCOV BIT(2)
560#define MGMT_ADV_FLAG_MANAGED_FLAGS BIT(3)
561#define MGMT_ADV_FLAG_TX_POWER BIT(4)
562#define MGMT_ADV_FLAG_APPEARANCE BIT(5)
563#define MGMT_ADV_FLAG_LOCAL_NAME BIT(6)
564
565#define MGMT_OP_REMOVE_ADVERTISING 0x003F
566struct mgmt_cp_remove_advertising {
567 __u8 instance;
568} __packed;
569#define MGMT_REMOVE_ADVERTISING_SIZE 1
570struct mgmt_rp_remove_advertising {
571 __u8 instance;
572} __packed;
573
506#define MGMT_EV_CMD_COMPLETE 0x0001 574#define MGMT_EV_CMD_COMPLETE 0x0001
507struct mgmt_ev_cmd_complete { 575struct mgmt_ev_cmd_complete {
508 __le16 opcode; 576 __le16 opcode;
@@ -647,9 +715,14 @@ struct mgmt_ev_new_irk {
647 struct mgmt_irk_info irk; 715 struct mgmt_irk_info irk;
648} __packed; 716} __packed;
649 717
718#define MGMT_CSRK_LOCAL_UNAUTHENTICATED 0x00
719#define MGMT_CSRK_REMOTE_UNAUTHENTICATED 0x01
720#define MGMT_CSRK_LOCAL_AUTHENTICATED 0x02
721#define MGMT_CSRK_REMOTE_AUTHENTICATED 0x03
722
650struct mgmt_csrk_info { 723struct mgmt_csrk_info {
651 struct mgmt_addr_info addr; 724 struct mgmt_addr_info addr;
652 __u8 master; 725 __u8 type;
653 __u8 val[16]; 726 __u8 val[16];
654} __packed; 727} __packed;
655 728
@@ -685,3 +758,29 @@ struct mgmt_ev_new_conn_param {
685#define MGMT_EV_UNCONF_INDEX_REMOVED 0x001e 758#define MGMT_EV_UNCONF_INDEX_REMOVED 0x001e
686 759
687#define MGMT_EV_NEW_CONFIG_OPTIONS 0x001f 760#define MGMT_EV_NEW_CONFIG_OPTIONS 0x001f
761
762struct mgmt_ev_ext_index {
763 __u8 type;
764 __u8 bus;
765} __packed;
766
767#define MGMT_EV_EXT_INDEX_ADDED 0x0020
768
769#define MGMT_EV_EXT_INDEX_REMOVED 0x0021
770
771#define MGMT_EV_LOCAL_OOB_DATA_UPDATED 0x0022
772struct mgmt_ev_local_oob_data_updated {
773 __u8 type;
774 __le16 eir_len;
775 __u8 eir[0];
776} __packed;
777
778#define MGMT_EV_ADVERTISING_ADDED 0x0023
779struct mgmt_ev_advertising_added {
780 __u8 instance;
781} __packed;
782
783#define MGMT_EV_ADVERTISING_REMOVED 0x0024
784struct mgmt_ev_advertising_removed {
785 __u8 instance;
786} __packed;
diff --git a/include/net/bond_3ad.h b/include/net/bond_3ad.h
index f04cdbb7848e..c2a40a172fcd 100644
--- a/include/net/bond_3ad.h
+++ b/include/net/bond_3ad.h
@@ -82,6 +82,13 @@ typedef enum {
82 AD_TRANSMIT /* tx Machine */ 82 AD_TRANSMIT /* tx Machine */
83} tx_states_t; 83} tx_states_t;
84 84
85/* churn machine states(43.4.17 in the 802.3ad standard) */
86typedef enum {
87 AD_CHURN_MONITOR, /* monitoring for churn */
88 AD_CHURN, /* churn detected (error) */
89 AD_NO_CHURN /* no churn (no error) */
90} churn_state_t;
91
85/* rx indication types */ 92/* rx indication types */
86typedef enum { 93typedef enum {
87 AD_TYPE_LACPDU = 1, /* type lacpdu */ 94 AD_TYPE_LACPDU = 1, /* type lacpdu */
@@ -229,6 +236,12 @@ typedef struct port {
229 u16 sm_mux_timer_counter; /* state machine mux timer counter */ 236 u16 sm_mux_timer_counter; /* state machine mux timer counter */
230 tx_states_t sm_tx_state; /* state machine tx state */ 237 tx_states_t sm_tx_state; /* state machine tx state */
231 u16 sm_tx_timer_counter; /* state machine tx timer counter(allways on - enter to transmit state 3 time per second) */ 238 u16 sm_tx_timer_counter; /* state machine tx timer counter(allways on - enter to transmit state 3 time per second) */
239 u16 sm_churn_actor_timer_counter;
240 u16 sm_churn_partner_timer_counter;
241 u32 churn_actor_count;
242 u32 churn_partner_count;
243 churn_state_t sm_churn_actor_state;
244 churn_state_t sm_churn_partner_state;
232 struct slave *slave; /* pointer to the bond slave that this port belongs to */ 245 struct slave *slave; /* pointer to the bond slave that this port belongs to */
233 struct aggregator *aggregator; /* pointer to an aggregator that this port related to */ 246 struct aggregator *aggregator; /* pointer to an aggregator that this port related to */
234 struct port *next_port_in_aggregator; /* Next port on the linked list of the parent aggregator */ 247 struct port *next_port_in_aggregator; /* Next port on the linked list of the parent aggregator */
@@ -262,6 +275,22 @@ struct ad_slave_info {
262 u16 id; 275 u16 id;
263}; 276};
264 277
278static inline const char *bond_3ad_churn_desc(churn_state_t state)
279{
280 static const char *const churn_description[] = {
281 "monitoring",
282 "churned",
283 "none",
284 "unknown"
285 };
286 int max_size = sizeof(churn_description) / sizeof(churn_description[0]);
287
288 if (state >= max_size)
289 state = max_size - 1;
290
291 return churn_description[state];
292}
293
265/* ========== AD Exported functions to the main bonding code ========== */ 294/* ========== AD Exported functions to the main bonding code ========== */
266void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution); 295void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution);
267void bond_3ad_bind_slave(struct slave *slave); 296void bond_3ad_bind_slave(struct slave *slave);
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 64e09e1e8099..f8d6813cd5b2 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -215,6 +215,39 @@ enum ieee80211_rate_flags {
215}; 215};
216 216
217/** 217/**
218 * enum ieee80211_bss_type - BSS type filter
219 *
220 * @IEEE80211_BSS_TYPE_ESS: Infrastructure BSS
221 * @IEEE80211_BSS_TYPE_PBSS: Personal BSS
222 * @IEEE80211_BSS_TYPE_IBSS: Independent BSS
223 * @IEEE80211_BSS_TYPE_MBSS: Mesh BSS
224 * @IEEE80211_BSS_TYPE_ANY: Wildcard value for matching any BSS type
225 */
226enum ieee80211_bss_type {
227 IEEE80211_BSS_TYPE_ESS,
228 IEEE80211_BSS_TYPE_PBSS,
229 IEEE80211_BSS_TYPE_IBSS,
230 IEEE80211_BSS_TYPE_MBSS,
231 IEEE80211_BSS_TYPE_ANY
232};
233
234/**
235 * enum ieee80211_privacy - BSS privacy filter
236 *
237 * @IEEE80211_PRIVACY_ON: privacy bit set
238 * @IEEE80211_PRIVACY_OFF: privacy bit clear
239 * @IEEE80211_PRIVACY_ANY: Wildcard value for matching any privacy setting
240 */
241enum ieee80211_privacy {
242 IEEE80211_PRIVACY_ON,
243 IEEE80211_PRIVACY_OFF,
244 IEEE80211_PRIVACY_ANY
245};
246
247#define IEEE80211_PRIVACY(x) \
248 ((x) ? IEEE80211_PRIVACY_ON : IEEE80211_PRIVACY_OFF)
249
250/**
218 * struct ieee80211_rate - bitrate definition 251 * struct ieee80211_rate - bitrate definition
219 * 252 *
220 * This structure describes a bitrate that an 802.11 PHY can 253 * This structure describes a bitrate that an 802.11 PHY can
@@ -2423,6 +2456,7 @@ struct cfg80211_ops {
2423 2456
2424 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy, 2457 struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy,
2425 const char *name, 2458 const char *name,
2459 unsigned char name_assign_type,
2426 enum nl80211_iftype type, 2460 enum nl80211_iftype type,
2427 u32 *flags, 2461 u32 *flags,
2428 struct vif_params *params); 2462 struct vif_params *params);
@@ -3183,10 +3217,8 @@ struct wiphy {
3183 const struct ieee80211_ht_cap *ht_capa_mod_mask; 3217 const struct ieee80211_ht_cap *ht_capa_mod_mask;
3184 const struct ieee80211_vht_cap *vht_capa_mod_mask; 3218 const struct ieee80211_vht_cap *vht_capa_mod_mask;
3185 3219
3186#ifdef CONFIG_NET_NS
3187 /* the network namespace this phy lives in currently */ 3220 /* the network namespace this phy lives in currently */
3188 struct net *_net; 3221 possible_net_t _net;
3189#endif
3190 3222
3191#ifdef CONFIG_CFG80211_WEXT 3223#ifdef CONFIG_CFG80211_WEXT
3192 const struct iw_handler_def *wext; 3224 const struct iw_handler_def *wext;
@@ -4012,14 +4044,16 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
4012 struct ieee80211_channel *channel, 4044 struct ieee80211_channel *channel,
4013 const u8 *bssid, 4045 const u8 *bssid,
4014 const u8 *ssid, size_t ssid_len, 4046 const u8 *ssid, size_t ssid_len,
4015 u16 capa_mask, u16 capa_val); 4047 enum ieee80211_bss_type bss_type,
4048 enum ieee80211_privacy);
4016static inline struct cfg80211_bss * 4049static inline struct cfg80211_bss *
4017cfg80211_get_ibss(struct wiphy *wiphy, 4050cfg80211_get_ibss(struct wiphy *wiphy,
4018 struct ieee80211_channel *channel, 4051 struct ieee80211_channel *channel,
4019 const u8 *ssid, size_t ssid_len) 4052 const u8 *ssid, size_t ssid_len)
4020{ 4053{
4021 return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len, 4054 return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len,
4022 WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS); 4055 IEEE80211_BSS_TYPE_IBSS,
4056 IEEE80211_PRIVACY_ANY);
4023} 4057}
4024 4058
4025/** 4059/**
@@ -4260,6 +4294,7 @@ struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
4260 int approxlen); 4294 int approxlen);
4261 4295
4262struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy, 4296struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
4297 struct wireless_dev *wdev,
4263 enum nl80211_commands cmd, 4298 enum nl80211_commands cmd,
4264 enum nl80211_attrs attr, 4299 enum nl80211_attrs attr,
4265 int vendor_event_idx, 4300 int vendor_event_idx,
@@ -4314,6 +4349,7 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
4314/** 4349/**
4315 * cfg80211_vendor_event_alloc - allocate vendor-specific event skb 4350 * cfg80211_vendor_event_alloc - allocate vendor-specific event skb
4316 * @wiphy: the wiphy 4351 * @wiphy: the wiphy
4352 * @wdev: the wireless device
4317 * @event_idx: index of the vendor event in the wiphy's vendor_events 4353 * @event_idx: index of the vendor event in the wiphy's vendor_events
4318 * @approxlen: an upper bound of the length of the data that will 4354 * @approxlen: an upper bound of the length of the data that will
4319 * be put into the skb 4355 * be put into the skb
@@ -4322,16 +4358,20 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
4322 * This function allocates and pre-fills an skb for an event on the 4358 * This function allocates and pre-fills an skb for an event on the
4323 * vendor-specific multicast group. 4359 * vendor-specific multicast group.
4324 * 4360 *
4361 * If wdev != NULL, both the ifindex and identifier of the specified
4362 * wireless device are added to the event message before the vendor data
4363 * attribute.
4364 *
4325 * When done filling the skb, call cfg80211_vendor_event() with the 4365 * When done filling the skb, call cfg80211_vendor_event() with the
4326 * skb to send the event. 4366 * skb to send the event.
4327 * 4367 *
4328 * Return: An allocated and pre-filled skb. %NULL if any errors happen. 4368 * Return: An allocated and pre-filled skb. %NULL if any errors happen.
4329 */ 4369 */
4330static inline struct sk_buff * 4370static inline struct sk_buff *
4331cfg80211_vendor_event_alloc(struct wiphy *wiphy, int approxlen, 4371cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
4332 int event_idx, gfp_t gfp) 4372 int approxlen, int event_idx, gfp_t gfp)
4333{ 4373{
4334 return __cfg80211_alloc_event_skb(wiphy, NL80211_CMD_VENDOR, 4374 return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
4335 NL80211_ATTR_VENDOR_DATA, 4375 NL80211_ATTR_VENDOR_DATA,
4336 event_idx, approxlen, gfp); 4376 event_idx, approxlen, gfp);
4337} 4377}
@@ -4432,7 +4472,7 @@ static inline int cfg80211_testmode_reply(struct sk_buff *skb)
4432static inline struct sk_buff * 4472static inline struct sk_buff *
4433cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp) 4473cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
4434{ 4474{
4435 return __cfg80211_alloc_event_skb(wiphy, NL80211_CMD_TESTMODE, 4475 return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
4436 NL80211_ATTR_TESTDATA, -1, 4476 NL80211_ATTR_TESTDATA, -1,
4437 approxlen, gfp); 4477 approxlen, gfp);
4438} 4478}
@@ -4862,6 +4902,17 @@ void cfg80211_ch_switch_started_notify(struct net_device *dev,
4862bool ieee80211_operating_class_to_band(u8 operating_class, 4902bool ieee80211_operating_class_to_band(u8 operating_class,
4863 enum ieee80211_band *band); 4903 enum ieee80211_band *band);
4864 4904
4905/**
4906 * ieee80211_chandef_to_operating_class - convert chandef to operation class
4907 *
4908 * @chandef: the chandef to convert
4909 * @op_class: a pointer to the resulting operating class
4910 *
4911 * Returns %true if the conversion was successful, %false otherwise.
4912 */
4913bool ieee80211_chandef_to_operating_class(struct cfg80211_chan_def *chandef,
4914 u8 *op_class);
4915
4865/* 4916/*
4866 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation 4917 * cfg80211_tdls_oper_request - request userspace to perform TDLS operation
4867 * @dev: the device on which the operation is requested 4918 * @dev: the device on which the operation is requested
@@ -4950,6 +5001,64 @@ int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
4950 u8 *buf, unsigned int bufsize); 5001 u8 *buf, unsigned int bufsize);
4951 5002
4952/** 5003/**
5004 * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
5005 * @ies: the IE buffer
5006 * @ielen: the length of the IE buffer
5007 * @ids: an array with element IDs that are allowed before
5008 * the split
5009 * @n_ids: the size of the element ID array
5010 * @after_ric: array IE types that come after the RIC element
5011 * @n_after_ric: size of the @after_ric array
5012 * @offset: offset where to start splitting in the buffer
5013 *
5014 * This function splits an IE buffer by updating the @offset
5015 * variable to point to the location where the buffer should be
5016 * split.
5017 *
5018 * It assumes that the given IE buffer is well-formed, this
5019 * has to be guaranteed by the caller!
5020 *
5021 * It also assumes that the IEs in the buffer are ordered
5022 * correctly, if not the result of using this function will not
5023 * be ordered correctly either, i.e. it does no reordering.
5024 *
5025 * The function returns the offset where the next part of the
5026 * buffer starts, which may be @ielen if the entire (remainder)
5027 * of the buffer should be used.
5028 */
5029size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
5030 const u8 *ids, int n_ids,
5031 const u8 *after_ric, int n_after_ric,
5032 size_t offset);
5033
5034/**
5035 * ieee80211_ie_split - split an IE buffer according to ordering
5036 * @ies: the IE buffer
5037 * @ielen: the length of the IE buffer
5038 * @ids: an array with element IDs that are allowed before
5039 * the split
5040 * @n_ids: the size of the element ID array
5041 * @offset: offset where to start splitting in the buffer
5042 *
5043 * This function splits an IE buffer by updating the @offset
5044 * variable to point to the location where the buffer should be
5045 * split.
5046 *
5047 * It assumes that the given IE buffer is well-formed, this
5048 * has to be guaranteed by the caller!
5049 *
5050 * It also assumes that the IEs in the buffer are ordered
5051 * correctly, if not the result of using this function will not
5052 * be ordered correctly either, i.e. it does no reordering.
5053 *
5054 * The function returns the offset where the next part of the
5055 * buffer starts, which may be @ielen if the entire (remainder)
5056 * of the buffer should be used.
5057 */
5058size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
5059 const u8 *ids, int n_ids, size_t offset);
5060
5061/**
4953 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN 5062 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
4954 * @wdev: the wireless device reporting the wakeup 5063 * @wdev: the wireless device reporting the wakeup
4955 * @wakeup: the wakeup report 5064 * @wakeup: the wakeup report
diff --git a/include/net/compat.h b/include/net/compat.h
index 42a9c8431177..48103cf94e97 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -40,7 +40,7 @@ int compat_sock_get_timestampns(struct sock *, struct timespec __user *);
40#define compat_mmsghdr mmsghdr 40#define compat_mmsghdr mmsghdr
41#endif /* defined(CONFIG_COMPAT) */ 41#endif /* defined(CONFIG_COMPAT) */
42 42
43ssize_t get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *, 43int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *,
44 struct sockaddr __user **, struct iovec **); 44 struct sockaddr __user **, struct iovec **);
45asmlinkage long compat_sys_sendmsg(int, struct compat_msghdr __user *, 45asmlinkage long compat_sys_sendmsg(int, struct compat_msghdr __user *,
46 unsigned int); 46 unsigned int);
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 597b88a94332..207d9ba1f92c 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -49,6 +49,9 @@ struct dcbnl_rtnl_ops {
49 int (*ieee_setets) (struct net_device *, struct ieee_ets *); 49 int (*ieee_setets) (struct net_device *, struct ieee_ets *);
50 int (*ieee_getmaxrate) (struct net_device *, struct ieee_maxrate *); 50 int (*ieee_getmaxrate) (struct net_device *, struct ieee_maxrate *);
51 int (*ieee_setmaxrate) (struct net_device *, struct ieee_maxrate *); 51 int (*ieee_setmaxrate) (struct net_device *, struct ieee_maxrate *);
52 int (*ieee_getqcn) (struct net_device *, struct ieee_qcn *);
53 int (*ieee_setqcn) (struct net_device *, struct ieee_qcn *);
54 int (*ieee_getqcnstats) (struct net_device *, struct ieee_qcn_stats *);
52 int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *); 55 int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *);
53 int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *); 56 int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *);
54 int (*ieee_getapp) (struct net_device *, struct dcb_app *); 57 int (*ieee_getapp) (struct net_device *, struct dcb_app *);
diff --git a/include/net/dn_neigh.h b/include/net/dn_neigh.h
index fac4e3f4a6d3..d0424269313f 100644
--- a/include/net/dn_neigh.h
+++ b/include/net/dn_neigh.h
@@ -18,10 +18,11 @@ struct dn_neigh {
18 18
19void dn_neigh_init(void); 19void dn_neigh_init(void);
20void dn_neigh_cleanup(void); 20void dn_neigh_cleanup(void);
21int dn_neigh_router_hello(struct sk_buff *skb); 21int dn_neigh_router_hello(struct sock *sk, struct sk_buff *skb);
22int dn_neigh_endnode_hello(struct sk_buff *skb); 22int dn_neigh_endnode_hello(struct sock *sk, struct sk_buff *skb);
23void dn_neigh_pointopoint_hello(struct sk_buff *skb); 23void dn_neigh_pointopoint_hello(struct sk_buff *skb);
24int dn_neigh_elist(struct net_device *dev, unsigned char *ptr, int n); 24int dn_neigh_elist(struct net_device *dev, unsigned char *ptr, int n);
25int dn_to_neigh_output(struct sock *sk, struct sk_buff *skb);
25 26
26extern struct neigh_table dn_neigh_table; 27extern struct neigh_table dn_neigh_table;
27 28
diff --git a/include/net/dsa.h b/include/net/dsa.h
index ed3c34bbb67a..fbca63ba8f73 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -72,6 +72,7 @@ struct dsa_platform_data {
72 * to the root switch chip of the tree. 72 * to the root switch chip of the tree.
73 */ 73 */
74 struct device *netdev; 74 struct device *netdev;
75 struct net_device *of_netdev;
75 76
76 /* 77 /*
77 * Info structs describing each of the switch chips 78 * Info structs describing each of the switch chips
@@ -128,6 +129,11 @@ struct dsa_switch {
128 int index; 129 int index;
129 130
130 /* 131 /*
132 * Tagging protocol understood by this switch
133 */
134 enum dsa_tag_protocol tag_protocol;
135
136 /*
131 * Configuration data for this switch. 137 * Configuration data for this switch.
132 */ 138 */
133 struct dsa_chip_data *pd; 139 struct dsa_chip_data *pd;
@@ -165,6 +171,11 @@ static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
165 return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port); 171 return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
166} 172}
167 173
174static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
175{
176 return ds->phys_port_mask & (1 << p) && ds->ports[p];
177}
178
168static inline u8 dsa_upstream_port(struct dsa_switch *ds) 179static inline u8 dsa_upstream_port(struct dsa_switch *ds)
169{ 180{
170 struct dsa_switch_tree *dst = ds->dst; 181 struct dsa_switch_tree *dst = ds->dst;
@@ -275,6 +286,22 @@ struct dsa_switch_driver {
275 int (*get_regs_len)(struct dsa_switch *ds, int port); 286 int (*get_regs_len)(struct dsa_switch *ds, int port);
276 void (*get_regs)(struct dsa_switch *ds, int port, 287 void (*get_regs)(struct dsa_switch *ds, int port,
277 struct ethtool_regs *regs, void *p); 288 struct ethtool_regs *regs, void *p);
289
290 /*
291 * Bridge integration
292 */
293 int (*port_join_bridge)(struct dsa_switch *ds, int port,
294 u32 br_port_mask);
295 int (*port_leave_bridge)(struct dsa_switch *ds, int port,
296 u32 br_port_mask);
297 int (*port_stp_update)(struct dsa_switch *ds, int port,
298 u8 state);
299 int (*fdb_add)(struct dsa_switch *ds, int port,
300 const unsigned char *addr, u16 vid);
301 int (*fdb_del)(struct dsa_switch *ds, int port,
302 const unsigned char *addr, u16 vid);
303 int (*fdb_getnext)(struct dsa_switch *ds, int port,
304 unsigned char *addr, bool *is_static);
278}; 305};
279 306
280void register_switch_driver(struct dsa_switch_driver *type); 307void register_switch_driver(struct dsa_switch_driver *type);
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h
index 1f99a1de0e4f..d64253914a6a 100644
--- a/include/net/dst_ops.h
+++ b/include/net/dst_ops.h
@@ -12,7 +12,6 @@ struct sock;
12 12
13struct dst_ops { 13struct dst_ops {
14 unsigned short family; 14 unsigned short family;
15 __be16 protocol;
16 unsigned int gc_thresh; 15 unsigned int gc_thresh;
17 16
18 int (*gc)(struct dst_ops *ops); 17 int (*gc)(struct dst_ops *ops);
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index e584de16e4c3..6d67383a5114 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -58,7 +58,7 @@ struct fib_rules_ops {
58 struct sk_buff *, 58 struct sk_buff *,
59 struct fib_rule_hdr *, 59 struct fib_rule_hdr *,
60 struct nlattr **); 60 struct nlattr **);
61 void (*delete)(struct fib_rule *); 61 int (*delete)(struct fib_rule *);
62 int (*compare)(struct fib_rule *, 62 int (*compare)(struct fib_rule *,
63 struct fib_rule_hdr *, 63 struct fib_rule_hdr *,
64 struct nlattr **); 64 struct nlattr **);
@@ -95,17 +95,10 @@ static inline void fib_rule_get(struct fib_rule *rule)
95 atomic_inc(&rule->refcnt); 95 atomic_inc(&rule->refcnt);
96} 96}
97 97
98static inline void fib_rule_put_rcu(struct rcu_head *head)
99{
100 struct fib_rule *rule = container_of(head, struct fib_rule, rcu);
101 release_net(rule->fr_net);
102 kfree(rule);
103}
104
105static inline void fib_rule_put(struct fib_rule *rule) 98static inline void fib_rule_put(struct fib_rule *rule)
106{ 99{
107 if (atomic_dec_and_test(&rule->refcnt)) 100 if (atomic_dec_and_test(&rule->refcnt))
108 call_rcu(&rule->rcu, fib_rule_put_rcu); 101 kfree_rcu(rule, rcu);
109} 102}
110 103
111static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla) 104static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 0574abd3db86..a9af1cc8c1bc 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -92,9 +92,7 @@ struct genl_info {
92 struct genlmsghdr * genlhdr; 92 struct genlmsghdr * genlhdr;
93 void * userhdr; 93 void * userhdr;
94 struct nlattr ** attrs; 94 struct nlattr ** attrs;
95#ifdef CONFIG_NET_NS 95 possible_net_t _net;
96 struct net * _net;
97#endif
98 void * user_ptr[2]; 96 void * user_ptr[2];
99 struct sock * dst_sk; 97 struct sock * dst_sk;
100}; 98};
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 98e5f9578f86..1c8b6820b694 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -41,18 +41,18 @@ enum {
41struct inet6_ifaddr { 41struct inet6_ifaddr {
42 struct in6_addr addr; 42 struct in6_addr addr;
43 __u32 prefix_len; 43 __u32 prefix_len;
44 44
45 /* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */ 45 /* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
46 __u32 valid_lft; 46 __u32 valid_lft;
47 __u32 prefered_lft; 47 __u32 prefered_lft;
48 atomic_t refcnt; 48 atomic_t refcnt;
49 spinlock_t lock; 49 spinlock_t lock;
50 spinlock_t state_lock;
51 50
52 int state; 51 int state;
53 52
54 __u32 flags; 53 __u32 flags;
55 __u8 dad_probes; 54 __u8 dad_probes;
55 __u8 stable_privacy_retry;
56 56
57 __u16 scope; 57 __u16 scope;
58 58
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h
index 74af137304be..6d539e4e5ba7 100644
--- a/include/net/inet6_connection_sock.h
+++ b/include/net/inet6_connection_sock.h
@@ -28,8 +28,7 @@ int inet6_csk_bind_conflict(const struct sock *sk,
28struct dst_entry *inet6_csk_route_req(struct sock *sk, struct flowi6 *fl6, 28struct dst_entry *inet6_csk_route_req(struct sock *sk, struct flowi6 *fl6,
29 const struct request_sock *req); 29 const struct request_sock *req);
30 30
31struct request_sock *inet6_csk_search_req(const struct sock *sk, 31struct request_sock *inet6_csk_search_req(struct sock *sk,
32 struct request_sock ***prevp,
33 const __be16 rport, 32 const __be16 rport,
34 const struct in6_addr *raddr, 33 const struct in6_addr *raddr,
35 const struct in6_addr *laddr, 34 const struct in6_addr *laddr,
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index 9201afe083fa..7ff588ca6817 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -38,8 +38,6 @@ static inline unsigned int __inet6_ehashfn(const u32 lhash,
38 return jhash_3words(lhash, fhash, ports, initval); 38 return jhash_3words(lhash, fhash, ports, initval);
39} 39}
40 40
41int __inet6_hash(struct sock *sk, struct inet_timewait_sock *twp);
42
43/* 41/*
44 * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so 42 * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so
45 * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM 43 * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index b2828a06a5a6..4a92423eefa5 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -21,12 +21,11 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
21int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, 21int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
22 int addr_len, int flags); 22 int addr_len, int flags);
23int inet_accept(struct socket *sock, struct socket *newsock, int flags); 23int inet_accept(struct socket *sock, struct socket *newsock, int flags);
24int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, 24int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size);
25 size_t size);
26ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, 25ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset,
27 size_t size, int flags); 26 size_t size, int flags);
28int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, 27int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
29 size_t size, int flags); 28 int flags);
30int inet_shutdown(struct socket *sock, int how); 29int inet_shutdown(struct socket *sock, int how);
31int inet_listen(struct socket *sock, int backlog); 30int inet_listen(struct socket *sock, int backlog);
32void inet_sock_destruct(struct sock *sk); 31void inet_sock_destruct(struct sock *sk);
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 5976bdecf58b..7b5887cd1172 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -126,6 +126,8 @@ struct inet_connection_sock {
126 126
127 /* Information on the current probe. */ 127 /* Information on the current probe. */
128 int probe_size; 128 int probe_size;
129
130 u32 probe_timestamp;
129 } icsk_mtup; 131 } icsk_mtup;
130 u32 icsk_ca_priv[16]; 132 u32 icsk_ca_priv[16];
131 u32 icsk_user_timeout; 133 u32 icsk_user_timeout;
@@ -254,8 +256,7 @@ inet_csk_rto_backoff(const struct inet_connection_sock *icsk,
254 256
255struct sock *inet_csk_accept(struct sock *sk, int flags, int *err); 257struct sock *inet_csk_accept(struct sock *sk, int flags, int *err);
256 258
257struct request_sock *inet_csk_search_req(const struct sock *sk, 259struct request_sock *inet_csk_search_req(struct sock *sk,
258 struct request_sock ***prevp,
259 const __be16 rport, 260 const __be16 rport,
260 const __be32 raddr, 261 const __be32 raddr,
261 const __be32 laddr); 262 const __be32 laddr);
@@ -281,15 +282,13 @@ void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,
281static inline void inet_csk_reqsk_queue_removed(struct sock *sk, 282static inline void inet_csk_reqsk_queue_removed(struct sock *sk,
282 struct request_sock *req) 283 struct request_sock *req)
283{ 284{
284 if (reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req) == 0) 285 reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req);
285 inet_csk_delete_keepalive_timer(sk);
286} 286}
287 287
288static inline void inet_csk_reqsk_queue_added(struct sock *sk, 288static inline void inet_csk_reqsk_queue_added(struct sock *sk,
289 const unsigned long timeout) 289 const unsigned long timeout)
290{ 290{
291 if (reqsk_queue_added(&inet_csk(sk)->icsk_accept_queue) == 0) 291 reqsk_queue_added(&inet_csk(sk)->icsk_accept_queue);
292 inet_csk_reset_keepalive_timer(sk, timeout);
293} 292}
294 293
295static inline int inet_csk_reqsk_queue_len(const struct sock *sk) 294static inline int inet_csk_reqsk_queue_len(const struct sock *sk)
@@ -308,26 +307,19 @@ static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
308} 307}
309 308
310static inline void inet_csk_reqsk_queue_unlink(struct sock *sk, 309static inline void inet_csk_reqsk_queue_unlink(struct sock *sk,
311 struct request_sock *req, 310 struct request_sock *req)
312 struct request_sock **prev)
313{ 311{
314 reqsk_queue_unlink(&inet_csk(sk)->icsk_accept_queue, req, prev); 312 reqsk_queue_unlink(&inet_csk(sk)->icsk_accept_queue, req);
315} 313}
316 314
317static inline void inet_csk_reqsk_queue_drop(struct sock *sk, 315static inline void inet_csk_reqsk_queue_drop(struct sock *sk,
318 struct request_sock *req, 316 struct request_sock *req)
319 struct request_sock **prev)
320{ 317{
321 inet_csk_reqsk_queue_unlink(sk, req, prev); 318 inet_csk_reqsk_queue_unlink(sk, req);
322 inet_csk_reqsk_queue_removed(sk, req); 319 inet_csk_reqsk_queue_removed(sk, req);
323 reqsk_free(req); 320 reqsk_put(req);
324} 321}
325 322
326void inet_csk_reqsk_queue_prune(struct sock *parent,
327 const unsigned long interval,
328 const unsigned long timeout,
329 const unsigned long max_rto);
330
331void inet_csk_destroy_sock(struct sock *sk); 323void inet_csk_destroy_sock(struct sock *sk);
332void inet_csk_prepare_forced_close(struct sock *sk); 324void inet_csk_prepare_forced_close(struct sock *sk);
333 325
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index dd1950a7e273..73fe0f9525d9 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -76,9 +76,7 @@ struct inet_ehash_bucket {
76 * ports are created in O(1) time? I thought so. ;-) -DaveM 76 * ports are created in O(1) time? I thought so. ;-) -DaveM
77 */ 77 */
78struct inet_bind_bucket { 78struct inet_bind_bucket {
79#ifdef CONFIG_NET_NS 79 possible_net_t ib_net;
80 struct net *ib_net;
81#endif
82 unsigned short port; 80 unsigned short port;
83 signed char fastreuse; 81 signed char fastreuse;
84 signed char fastreuseport; 82 signed char fastreuseport;
@@ -223,8 +221,8 @@ inet_bind_bucket_create(struct kmem_cache *cachep, struct net *net,
223void inet_bind_bucket_destroy(struct kmem_cache *cachep, 221void inet_bind_bucket_destroy(struct kmem_cache *cachep,
224 struct inet_bind_bucket *tb); 222 struct inet_bind_bucket *tb);
225 223
226static inline int inet_bhashfn(struct net *net, const __u16 lport, 224static inline u32 inet_bhashfn(const struct net *net, const __u16 lport,
227 const int bhash_size) 225 const u32 bhash_size)
228{ 226{
229 return (lport + net_hash_mix(net)) & (bhash_size - 1); 227 return (lport + net_hash_mix(net)) & (bhash_size - 1);
230} 228}
@@ -233,7 +231,7 @@ void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
233 const unsigned short snum); 231 const unsigned short snum);
234 232
235/* These can have wildcards, don't try too hard. */ 233/* These can have wildcards, don't try too hard. */
236static inline int inet_lhashfn(struct net *net, const unsigned short num) 234static inline u32 inet_lhashfn(const struct net *net, const unsigned short num)
237{ 235{
238 return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1); 236 return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1);
239} 237}
@@ -251,6 +249,7 @@ void inet_put_port(struct sock *sk);
251void inet_hashinfo_init(struct inet_hashinfo *h); 249void inet_hashinfo_init(struct inet_hashinfo *h);
252 250
253int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw); 251int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw);
252int __inet_hash(struct sock *sk, struct inet_timewait_sock *tw);
254void inet_hash(struct sock *sk); 253void inet_hash(struct sock *sk);
255void inet_unhash(struct sock *sk); 254void inet_unhash(struct sock *sk);
256 255
@@ -385,13 +384,32 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo,
385 iph->daddr, dport, inet_iif(skb)); 384 iph->daddr, dport, inet_iif(skb));
386} 385}
387 386
387u32 sk_ehashfn(const struct sock *sk);
388u32 inet6_ehashfn(const struct net *net,
389 const struct in6_addr *laddr, const u16 lport,
390 const struct in6_addr *faddr, const __be16 fport);
391
392static inline void sk_daddr_set(struct sock *sk, __be32 addr)
393{
394 sk->sk_daddr = addr; /* alias of inet_daddr */
395#if IS_ENABLED(CONFIG_IPV6)
396 ipv6_addr_set_v4mapped(addr, &sk->sk_v6_daddr);
397#endif
398}
399
400static inline void sk_rcv_saddr_set(struct sock *sk, __be32 addr)
401{
402 sk->sk_rcv_saddr = addr; /* alias of inet_rcv_saddr */
403#if IS_ENABLED(CONFIG_IPV6)
404 ipv6_addr_set_v4mapped(addr, &sk->sk_v6_rcv_saddr);
405#endif
406}
407
388int __inet_hash_connect(struct inet_timewait_death_row *death_row, 408int __inet_hash_connect(struct inet_timewait_death_row *death_row,
389 struct sock *sk, u32 port_offset, 409 struct sock *sk, u32 port_offset,
390 int (*check_established)(struct inet_timewait_death_row *, 410 int (*check_established)(struct inet_timewait_death_row *,
391 struct sock *, __u16, 411 struct sock *, __u16,
392 struct inet_timewait_sock **), 412 struct inet_timewait_sock **));
393 int (*hash)(struct sock *sk,
394 struct inet_timewait_sock *twp));
395 413
396int inet_hash_connect(struct inet_timewait_death_row *death_row, 414int inet_hash_connect(struct inet_timewait_death_row *death_row,
397 struct sock *sk); 415 struct sock *sk);
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index eb16c7beed1e..b6c3737da4e9 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -27,6 +27,7 @@
27#include <net/sock.h> 27#include <net/sock.h>
28#include <net/request_sock.h> 28#include <net/request_sock.h>
29#include <net/netns/hash.h> 29#include <net/netns/hash.h>
30#include <net/tcp_states.h>
30 31
31/** struct ip_options - IP Options 32/** struct ip_options - IP Options
32 * 33 *
@@ -77,6 +78,10 @@ struct inet_request_sock {
77#define ir_v6_rmt_addr req.__req_common.skc_v6_daddr 78#define ir_v6_rmt_addr req.__req_common.skc_v6_daddr
78#define ir_v6_loc_addr req.__req_common.skc_v6_rcv_saddr 79#define ir_v6_loc_addr req.__req_common.skc_v6_rcv_saddr
79#define ir_iif req.__req_common.skc_bound_dev_if 80#define ir_iif req.__req_common.skc_bound_dev_if
81#define ir_cookie req.__req_common.skc_cookie
82#define ireq_net req.__req_common.skc_net
83#define ireq_state req.__req_common.skc_state
84#define ireq_family req.__req_common.skc_family
80 85
81 kmemcheck_bitfield_begin(flags); 86 kmemcheck_bitfield_begin(flags);
82 u16 snd_wscale : 4, 87 u16 snd_wscale : 4,
@@ -88,11 +93,11 @@ struct inet_request_sock {
88 acked : 1, 93 acked : 1,
89 no_srccheck: 1; 94 no_srccheck: 1;
90 kmemcheck_bitfield_end(flags); 95 kmemcheck_bitfield_end(flags);
96 u32 ir_mark;
91 union { 97 union {
92 struct ip_options_rcu *opt; 98 struct ip_options_rcu *opt;
93 struct sk_buff *pktopts; 99 struct sk_buff *pktopts;
94 }; 100 };
95 u32 ir_mark;
96}; 101};
97 102
98static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) 103static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
@@ -100,13 +105,12 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
100 return (struct inet_request_sock *)sk; 105 return (struct inet_request_sock *)sk;
101} 106}
102 107
103static inline u32 inet_request_mark(struct sock *sk, struct sk_buff *skb) 108static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)
104{ 109{
105 if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept) { 110 if (!sk->sk_mark && sock_net(sk)->ipv4.sysctl_tcp_fwmark_accept)
106 return skb->mark; 111 return skb->mark;
107 } else { 112
108 return sk->sk_mark; 113 return sk->sk_mark;
109 }
110} 114}
111 115
112struct inet_cork { 116struct inet_cork {
@@ -239,18 +243,8 @@ static inline unsigned int __inet_ehashfn(const __be32 laddr,
239 initval); 243 initval);
240} 244}
241 245
242static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops) 246struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
243{ 247 struct sock *sk_listener);
244 struct request_sock *req = reqsk_alloc(ops);
245 struct inet_request_sock *ireq = inet_rsk(req);
246
247 if (req != NULL) {
248 kmemcheck_annotate_bitfield(ireq, flags);
249 ireq->opt = NULL;
250 }
251
252 return req;
253}
254 248
255static inline __u8 inet_sk_flowi_flags(const struct sock *sk) 249static inline __u8 inet_sk_flowi_flags(const struct sock *sk)
256{ 250{
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 6c566034e26d..360c4802288d 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -31,67 +31,14 @@
31 31
32struct inet_hashinfo; 32struct inet_hashinfo;
33 33
34#define INET_TWDR_RECYCLE_SLOTS_LOG 5
35#define INET_TWDR_RECYCLE_SLOTS (1 << INET_TWDR_RECYCLE_SLOTS_LOG)
36
37/*
38 * If time > 4sec, it is "slow" path, no recycling is required,
39 * so that we select tick to get range about 4 seconds.
40 */
41#if HZ <= 16 || HZ > 4096
42# error Unsupported: HZ <= 16 or HZ > 4096
43#elif HZ <= 32
44# define INET_TWDR_RECYCLE_TICK (5 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
45#elif HZ <= 64
46# define INET_TWDR_RECYCLE_TICK (6 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
47#elif HZ <= 128
48# define INET_TWDR_RECYCLE_TICK (7 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
49#elif HZ <= 256
50# define INET_TWDR_RECYCLE_TICK (8 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
51#elif HZ <= 512
52# define INET_TWDR_RECYCLE_TICK (9 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
53#elif HZ <= 1024
54# define INET_TWDR_RECYCLE_TICK (10 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
55#elif HZ <= 2048
56# define INET_TWDR_RECYCLE_TICK (11 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
57#else
58# define INET_TWDR_RECYCLE_TICK (12 + 2 - INET_TWDR_RECYCLE_SLOTS_LOG)
59#endif
60
61static inline u32 inet_tw_time_stamp(void)
62{
63 return jiffies;
64}
65
66/* TIME_WAIT reaping mechanism. */
67#define INET_TWDR_TWKILL_SLOTS 8 /* Please keep this a power of 2. */
68
69#define INET_TWDR_TWKILL_QUOTA 100
70
71struct inet_timewait_death_row { 34struct inet_timewait_death_row {
72 /* Short-time timewait calendar */ 35 atomic_t tw_count;
73 int twcal_hand; 36
74 unsigned long twcal_jiffie; 37 struct inet_hashinfo *hashinfo ____cacheline_aligned_in_smp;
75 struct timer_list twcal_timer;
76 struct hlist_head twcal_row[INET_TWDR_RECYCLE_SLOTS];
77
78 spinlock_t death_lock;
79 int tw_count;
80 int period;
81 u32 thread_slots;
82 struct work_struct twkill_work;
83 struct timer_list tw_timer;
84 int slot;
85 struct hlist_head cells[INET_TWDR_TWKILL_SLOTS];
86 struct inet_hashinfo *hashinfo;
87 int sysctl_tw_recycle; 38 int sysctl_tw_recycle;
88 int sysctl_max_tw_buckets; 39 int sysctl_max_tw_buckets;
89}; 40};
90 41
91void inet_twdr_hangman(unsigned long data);
92void inet_twdr_twkill_work(struct work_struct *work);
93void inet_twdr_twcal_tick(unsigned long data);
94
95struct inet_bind_bucket; 42struct inet_bind_bucket;
96 43
97/* 44/*
@@ -122,6 +69,7 @@ struct inet_timewait_sock {
122#define tw_v6_rcv_saddr __tw_common.skc_v6_rcv_saddr 69#define tw_v6_rcv_saddr __tw_common.skc_v6_rcv_saddr
123#define tw_dport __tw_common.skc_dport 70#define tw_dport __tw_common.skc_dport
124#define tw_num __tw_common.skc_num 71#define tw_num __tw_common.skc_num
72#define tw_cookie __tw_common.skc_cookie
125 73
126 int tw_timeout; 74 int tw_timeout;
127 volatile unsigned char tw_substate; 75 volatile unsigned char tw_substate;
@@ -132,52 +80,18 @@ struct inet_timewait_sock {
132 __be16 tw_sport; 80 __be16 tw_sport;
133 kmemcheck_bitfield_begin(flags); 81 kmemcheck_bitfield_begin(flags);
134 /* And these are ours. */ 82 /* And these are ours. */
135 unsigned int tw_pad0 : 1, /* 1 bit hole */ 83 unsigned int tw_kill : 1,
136 tw_transparent : 1, 84 tw_transparent : 1,
137 tw_flowlabel : 20, 85 tw_flowlabel : 20,
138 tw_pad : 2, /* 2 bits hole */ 86 tw_pad : 2, /* 2 bits hole */
139 tw_tos : 8; 87 tw_tos : 8;
140 kmemcheck_bitfield_end(flags); 88 kmemcheck_bitfield_end(flags);
141 u32 tw_ttd; 89 struct timer_list tw_timer;
142 struct inet_bind_bucket *tw_tb; 90 struct inet_bind_bucket *tw_tb;
143 struct hlist_node tw_death_node; 91 struct inet_timewait_death_row *tw_dr;
144}; 92};
145#define tw_tclass tw_tos 93#define tw_tclass tw_tos
146 94
147static inline int inet_twsk_dead_hashed(const struct inet_timewait_sock *tw)
148{
149 return !hlist_unhashed(&tw->tw_death_node);
150}
151
152static inline void inet_twsk_dead_node_init(struct inet_timewait_sock *tw)
153{
154 tw->tw_death_node.pprev = NULL;
155}
156
157static inline void __inet_twsk_del_dead_node(struct inet_timewait_sock *tw)
158{
159 __hlist_del(&tw->tw_death_node);
160 inet_twsk_dead_node_init(tw);
161}
162
163static inline int inet_twsk_del_dead_node(struct inet_timewait_sock *tw)
164{
165 if (inet_twsk_dead_hashed(tw)) {
166 __inet_twsk_del_dead_node(tw);
167 return 1;
168 }
169 return 0;
170}
171
172#define inet_twsk_for_each(tw, node, head) \
173 hlist_nulls_for_each_entry(tw, node, head, tw_node)
174
175#define inet_twsk_for_each_inmate(tw, jail) \
176 hlist_for_each_entry(tw, jail, tw_death_node)
177
178#define inet_twsk_for_each_inmate_safe(tw, safe, jail) \
179 hlist_for_each_entry_safe(tw, safe, jail, tw_death_node)
180
181static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk) 95static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk)
182{ 96{
183 return (struct inet_timewait_sock *)sk; 97 return (struct inet_timewait_sock *)sk;
@@ -192,16 +106,14 @@ int inet_twsk_bind_unhash(struct inet_timewait_sock *tw,
192 struct inet_hashinfo *hashinfo); 106 struct inet_hashinfo *hashinfo);
193 107
194struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, 108struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
109 struct inet_timewait_death_row *dr,
195 const int state); 110 const int state);
196 111
197void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, 112void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
198 struct inet_hashinfo *hashinfo); 113 struct inet_hashinfo *hashinfo);
199 114
200void inet_twsk_schedule(struct inet_timewait_sock *tw, 115void inet_twsk_schedule(struct inet_timewait_sock *tw, const int timeo);
201 struct inet_timewait_death_row *twdr, 116void inet_twsk_deschedule(struct inet_timewait_sock *tw);
202 const int timeo, const int timewait_len);
203void inet_twsk_deschedule(struct inet_timewait_sock *tw,
204 struct inet_timewait_death_row *twdr);
205 117
206void inet_twsk_purge(struct inet_hashinfo *hashinfo, 118void inet_twsk_purge(struct inet_hashinfo *hashinfo,
207 struct inet_timewait_death_row *twdr, int family); 119 struct inet_timewait_death_row *twdr, int family);
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 80479abddf73..d5332ddcea3f 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -19,6 +19,7 @@ struct inetpeer_addr_base {
19 union { 19 union {
20 __be32 a4; 20 __be32 a4;
21 __be32 a6[4]; 21 __be32 a6[4];
22 struct in6_addr in6;
22 }; 23 };
23}; 24};
24 25
@@ -151,7 +152,7 @@ static inline struct inet_peer *inet_getpeer_v6(struct inet_peer_base *base,
151{ 152{
152 struct inetpeer_addr daddr; 153 struct inetpeer_addr daddr;
153 154
154 *(struct in6_addr *)daddr.addr.a6 = *v6daddr; 155 daddr.addr.in6 = *v6daddr;
155 daddr.family = AF_INET6; 156 daddr.family = AF_INET6;
156 return inet_getpeer(base, &daddr, create); 157 return inet_getpeer(base, &daddr, create);
157} 158}
diff --git a/include/net/ip.h b/include/net/ip.h
index 6cc1eafb153a..d14af7edd197 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -108,7 +108,8 @@ int ip_local_deliver(struct sk_buff *skb);
108int ip_mr_input(struct sk_buff *skb); 108int ip_mr_input(struct sk_buff *skb);
109int ip_output(struct sock *sk, struct sk_buff *skb); 109int ip_output(struct sock *sk, struct sk_buff *skb);
110int ip_mc_output(struct sock *sk, struct sk_buff *skb); 110int ip_mc_output(struct sock *sk, struct sk_buff *skb);
111int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); 111int ip_fragment(struct sock *sk, struct sk_buff *skb,
112 int (*output)(struct sock *, struct sk_buff *));
112int ip_do_nat(struct sk_buff *skb); 113int ip_do_nat(struct sk_buff *skb);
113void ip_send_check(struct iphdr *ip); 114void ip_send_check(struct iphdr *ip);
114int __ip_local_out(struct sk_buff *skb); 115int __ip_local_out(struct sk_buff *skb);
@@ -318,9 +319,10 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb)
318} 319}
319 320
320u32 ip_idents_reserve(u32 hash, int segs); 321u32 ip_idents_reserve(u32 hash, int segs);
321void __ip_select_ident(struct iphdr *iph, int segs); 322void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
322 323
323static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, int segs) 324static inline void ip_select_ident_segs(struct net *net, struct sk_buff *skb,
325 struct sock *sk, int segs)
324{ 326{
325 struct iphdr *iph = ip_hdr(skb); 327 struct iphdr *iph = ip_hdr(skb);
326 328
@@ -337,13 +339,14 @@ static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, in
337 iph->id = 0; 339 iph->id = 0;
338 } 340 }
339 } else { 341 } else {
340 __ip_select_ident(iph, segs); 342 __ip_select_ident(net, iph, segs);
341 } 343 }
342} 344}
343 345
344static inline void ip_select_ident(struct sk_buff *skb, struct sock *sk) 346static inline void ip_select_ident(struct net *net, struct sk_buff *skb,
347 struct sock *sk)
345{ 348{
346 ip_select_ident_segs(skb, sk, 1); 349 ip_select_ident_segs(net, skb, sk, 1);
347} 350}
348 351
349static inline __wsum inet_compute_pseudo(struct sk_buff *skb, int proto) 352static inline __wsum inet_compute_pseudo(struct sk_buff *skb, int proto)
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index eda131d179d9..5e192068e6cb 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -170,7 +170,8 @@ static inline bool ipv6_anycast_destination(const struct sk_buff *skb)
170 return rt->rt6i_flags & RTF_ANYCAST; 170 return rt->rt6i_flags & RTF_ANYCAST;
171} 171}
172 172
173int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); 173int ip6_fragment(struct sock *sk, struct sk_buff *skb,
174 int (*output)(struct sock *, struct sk_buff *));
174 175
175static inline int ip6_skb_dst_mtu(struct sk_buff *skb) 176static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
176{ 177{
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index 76c091b53dae..b8529aa1dae7 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -71,14 +71,16 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
71__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr, 71__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
72 const struct in6_addr *raddr); 72 const struct in6_addr *raddr);
73struct net *ip6_tnl_get_link_net(const struct net_device *dev); 73struct net *ip6_tnl_get_link_net(const struct net_device *dev);
74int ip6_tnl_get_iflink(const struct net_device *dev);
74 75
75static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 76static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
77 struct net_device *dev)
76{ 78{
77 struct net_device_stats *stats = &dev->stats; 79 struct net_device_stats *stats = &dev->stats;
78 int pkt_len, err; 80 int pkt_len, err;
79 81
80 pkt_len = skb->len; 82 pkt_len = skb->len;
81 err = ip6_local_out(skb); 83 err = ip6_local_out_sk(sk, skb);
82 84
83 if (net_xmit_eval(err) == 0) { 85 if (net_xmit_eval(err) == 0) {
84 struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); 86 struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 5bd120e4bc0a..54271ed0ed45 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -136,7 +136,7 @@ struct fib_result {
136 u32 tclassid; 136 u32 tclassid;
137 struct fib_info *fi; 137 struct fib_info *fi;
138 struct fib_table *table; 138 struct fib_table *table;
139 struct list_head *fa_head; 139 struct hlist_head *fa_head;
140}; 140};
141 141
142struct fib_result_nl { 142struct fib_result_nl {
@@ -185,7 +185,9 @@ struct fib_table {
185 u32 tb_id; 185 u32 tb_id;
186 int tb_default; 186 int tb_default;
187 int tb_num_default; 187 int tb_num_default;
188 unsigned long tb_data[0]; 188 struct rcu_head rcu;
189 unsigned long *tb_data;
190 unsigned long __data[0];
189}; 191};
190 192
191int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, 193int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
@@ -195,10 +197,10 @@ int fib_table_delete(struct fib_table *, struct fib_config *);
195int fib_table_dump(struct fib_table *table, struct sk_buff *skb, 197int fib_table_dump(struct fib_table *table, struct sk_buff *skb,
196 struct netlink_callback *cb); 198 struct netlink_callback *cb);
197int fib_table_flush(struct fib_table *table); 199int fib_table_flush(struct fib_table *table);
200struct fib_table *fib_trie_unmerge(struct fib_table *main_tb);
201void fib_table_flush_external(struct fib_table *table);
198void fib_free_table(struct fib_table *tb); 202void fib_free_table(struct fib_table *tb);
199 203
200
201
202#ifndef CONFIG_IP_MULTIPLE_TABLES 204#ifndef CONFIG_IP_MULTIPLE_TABLES
203 205
204#define TABLE_LOCAL_INDEX (RT_TABLE_LOCAL & (FIB_TABLE_HASHSZ - 1)) 206#define TABLE_LOCAL_INDEX (RT_TABLE_LOCAL & (FIB_TABLE_HASHSZ - 1))
@@ -206,12 +208,16 @@ void fib_free_table(struct fib_table *tb);
206 208
207static inline struct fib_table *fib_get_table(struct net *net, u32 id) 209static inline struct fib_table *fib_get_table(struct net *net, u32 id)
208{ 210{
211 struct hlist_node *tb_hlist;
209 struct hlist_head *ptr; 212 struct hlist_head *ptr;
210 213
211 ptr = id == RT_TABLE_LOCAL ? 214 ptr = id == RT_TABLE_LOCAL ?
212 &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX] : 215 &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX] :
213 &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX]; 216 &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX];
214 return hlist_entry(ptr->first, struct fib_table, tb_hlist); 217
218 tb_hlist = rcu_dereference_rtnl(hlist_first_rcu(ptr));
219
220 return hlist_entry(tb_hlist, struct fib_table, tb_hlist);
215} 221}
216 222
217static inline struct fib_table *fib_new_table(struct net *net, u32 id) 223static inline struct fib_table *fib_new_table(struct net *net, u32 id)
@@ -222,14 +228,13 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id)
222static inline int fib_lookup(struct net *net, const struct flowi4 *flp, 228static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
223 struct fib_result *res) 229 struct fib_result *res)
224{ 230{
231 struct fib_table *tb;
225 int err = -ENETUNREACH; 232 int err = -ENETUNREACH;
226 233
227 rcu_read_lock(); 234 rcu_read_lock();
228 235
229 if (!fib_table_lookup(fib_get_table(net, RT_TABLE_LOCAL), flp, res, 236 tb = fib_get_table(net, RT_TABLE_MAIN);
230 FIB_LOOKUP_NOREF) || 237 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
231 !fib_table_lookup(fib_get_table(net, RT_TABLE_MAIN), flp, res,
232 FIB_LOOKUP_NOREF))
233 err = 0; 238 err = 0;
234 239
235 rcu_read_unlock(); 240 rcu_read_unlock();
@@ -249,28 +254,29 @@ int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res);
249static inline int fib_lookup(struct net *net, struct flowi4 *flp, 254static inline int fib_lookup(struct net *net, struct flowi4 *flp,
250 struct fib_result *res) 255 struct fib_result *res)
251{ 256{
252 if (!net->ipv4.fib_has_custom_rules) { 257 struct fib_table *tb;
253 int err = -ENETUNREACH; 258 int err;
254 259
255 rcu_read_lock(); 260 if (net->ipv4.fib_has_custom_rules)
256 261 return __fib_lookup(net, flp, res);
257 res->tclassid = 0; 262
258 if ((net->ipv4.fib_local && 263 rcu_read_lock();
259 !fib_table_lookup(net->ipv4.fib_local, flp, res, 264
260 FIB_LOOKUP_NOREF)) || 265 res->tclassid = 0;
261 (net->ipv4.fib_main && 266
262 !fib_table_lookup(net->ipv4.fib_main, flp, res, 267 for (err = 0; !err; err = -ENETUNREACH) {
263 FIB_LOOKUP_NOREF)) || 268 tb = rcu_dereference_rtnl(net->ipv4.fib_main);
264 (net->ipv4.fib_default && 269 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
265 !fib_table_lookup(net->ipv4.fib_default, flp, res, 270 break;
266 FIB_LOOKUP_NOREF))) 271
267 err = 0; 272 tb = rcu_dereference_rtnl(net->ipv4.fib_default);
268 273 if (tb && !fib_table_lookup(tb, flp, res, FIB_LOOKUP_NOREF))
269 rcu_read_unlock(); 274 break;
270
271 return err;
272 } 275 }
273 return __fib_lookup(net, flp, res); 276
277 rcu_read_unlock();
278
279 return err;
274} 280}
275 281
276#endif /* CONFIG_IP_MULTIPLE_TABLES */ 282#endif /* CONFIG_IP_MULTIPLE_TABLES */
@@ -294,6 +300,8 @@ static inline int fib_num_tclassid_users(struct net *net)
294 return 0; 300 return 0;
295} 301}
296#endif 302#endif
303int fib_unmerge(struct net *net);
304void fib_flush_external(struct net *net);
297 305
298/* Exported by fib_semantics.c */ 306/* Exported by fib_semantics.c */
299int ip_fib_check_default(__be32 gw, struct net_device *dev); 307int ip_fib_check_default(__be32 gw, struct net_device *dev);
@@ -304,7 +312,7 @@ void fib_select_multipath(struct fib_result *res);
304 312
305/* Exported by fib_trie.c */ 313/* Exported by fib_trie.c */
306void fib_trie_init(void); 314void fib_trie_init(void);
307struct fib_table *fib_trie_table(u32 id); 315struct fib_table *fib_trie_table(u32 id, struct fib_table *alias);
308 316
309static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) 317static inline void fib_combine_itag(u32 *itag, const struct fib_result *res)
310{ 318{
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 2c47061a6954..d8214cb88bbc 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -142,6 +142,7 @@ int ip_tunnel_init(struct net_device *dev);
142void ip_tunnel_uninit(struct net_device *dev); 142void ip_tunnel_uninit(struct net_device *dev);
143void ip_tunnel_dellink(struct net_device *dev, struct list_head *head); 143void ip_tunnel_dellink(struct net_device *dev, struct list_head *head);
144struct net *ip_tunnel_get_link_net(const struct net_device *dev); 144struct net *ip_tunnel_get_link_net(const struct net_device *dev);
145int ip_tunnel_get_iflink(const struct net_device *dev);
145int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id, 146int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
146 struct rtnl_link_ops *ops, char *devname); 147 struct rtnl_link_ops *ops, char *devname);
147 148
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 615b20b58545..4e3731ee4eac 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -47,13 +47,13 @@ static inline struct net *skb_net(const struct sk_buff *skb)
47 * Start with the most likely hit 47 * Start with the most likely hit
48 * End with BUG 48 * End with BUG
49 */ 49 */
50 if (likely(skb->dev && skb->dev->nd_net)) 50 if (likely(skb->dev && dev_net(skb->dev)))
51 return dev_net(skb->dev); 51 return dev_net(skb->dev);
52 if (skb_dst(skb) && skb_dst(skb)->dev) 52 if (skb_dst(skb) && skb_dst(skb)->dev)
53 return dev_net(skb_dst(skb)->dev); 53 return dev_net(skb_dst(skb)->dev);
54 WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n", 54 WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
55 __func__, __LINE__); 55 __func__, __LINE__);
56 if (likely(skb->sk && skb->sk->sk_net)) 56 if (likely(skb->sk && sock_net(skb->sk)))
57 return sock_net(skb->sk); 57 return sock_net(skb->sk);
58 pr_err("There is no net ptr to find in the skb in %s() line:%d\n", 58 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
59 __func__, __LINE__); 59 __func__, __LINE__);
@@ -71,11 +71,11 @@ static inline struct net *skb_sknet(const struct sk_buff *skb)
71#ifdef CONFIG_NET_NS 71#ifdef CONFIG_NET_NS
72#ifdef CONFIG_IP_VS_DEBUG 72#ifdef CONFIG_IP_VS_DEBUG
73 /* Start with the most likely hit */ 73 /* Start with the most likely hit */
74 if (likely(skb->sk && skb->sk->sk_net)) 74 if (likely(skb->sk && sock_net(skb->sk)))
75 return sock_net(skb->sk); 75 return sock_net(skb->sk);
76 WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n", 76 WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n",
77 __func__, __LINE__); 77 __func__, __LINE__);
78 if (likely(skb->dev && skb->dev->nd_net)) 78 if (likely(skb->dev && dev_net(skb->dev)))
79 return dev_net(skb->dev); 79 return dev_net(skb->dev);
80 pr_err("There is no net ptr to find in the skb in %s() line:%d\n", 80 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
81 __func__, __LINE__); 81 __func__, __LINE__);
@@ -365,15 +365,15 @@ struct ip_vs_seq {
365 365
366/* counters per cpu */ 366/* counters per cpu */
367struct ip_vs_counters { 367struct ip_vs_counters {
368 __u32 conns; /* connections scheduled */ 368 __u64 conns; /* connections scheduled */
369 __u32 inpkts; /* incoming packets */ 369 __u64 inpkts; /* incoming packets */
370 __u32 outpkts; /* outgoing packets */ 370 __u64 outpkts; /* outgoing packets */
371 __u64 inbytes; /* incoming bytes */ 371 __u64 inbytes; /* incoming bytes */
372 __u64 outbytes; /* outgoing bytes */ 372 __u64 outbytes; /* outgoing bytes */
373}; 373};
374/* Stats per cpu */ 374/* Stats per cpu */
375struct ip_vs_cpu_stats { 375struct ip_vs_cpu_stats {
376 struct ip_vs_counters ustats; 376 struct ip_vs_counters cnt;
377 struct u64_stats_sync syncp; 377 struct u64_stats_sync syncp;
378}; 378};
379 379
@@ -383,23 +383,40 @@ struct ip_vs_estimator {
383 383
384 u64 last_inbytes; 384 u64 last_inbytes;
385 u64 last_outbytes; 385 u64 last_outbytes;
386 u32 last_conns; 386 u64 last_conns;
387 u32 last_inpkts; 387 u64 last_inpkts;
388 u32 last_outpkts; 388 u64 last_outpkts;
389 389
390 u32 cps; 390 u64 cps;
391 u32 inpps; 391 u64 inpps;
392 u32 outpps; 392 u64 outpps;
393 u32 inbps; 393 u64 inbps;
394 u32 outbps; 394 u64 outbps;
395};
396
397/*
398 * IPVS statistics object, 64-bit kernel version of struct ip_vs_stats_user
399 */
400struct ip_vs_kstats {
401 u64 conns; /* connections scheduled */
402 u64 inpkts; /* incoming packets */
403 u64 outpkts; /* outgoing packets */
404 u64 inbytes; /* incoming bytes */
405 u64 outbytes; /* outgoing bytes */
406
407 u64 cps; /* current connection rate */
408 u64 inpps; /* current in packet rate */
409 u64 outpps; /* current out packet rate */
410 u64 inbps; /* current in byte rate */
411 u64 outbps; /* current out byte rate */
395}; 412};
396 413
397struct ip_vs_stats { 414struct ip_vs_stats {
398 struct ip_vs_stats_user ustats; /* statistics */ 415 struct ip_vs_kstats kstats; /* kernel statistics */
399 struct ip_vs_estimator est; /* estimator */ 416 struct ip_vs_estimator est; /* estimator */
400 struct ip_vs_cpu_stats __percpu *cpustats; /* per cpu counters */ 417 struct ip_vs_cpu_stats __percpu *cpustats; /* per cpu counters */
401 spinlock_t lock; /* spin lock */ 418 spinlock_t lock; /* spin lock */
402 struct ip_vs_stats_user ustats0; /* reset values */ 419 struct ip_vs_kstats kstats0; /* reset values */
403}; 420};
404 421
405struct dst_entry; 422struct dst_entry;
@@ -924,6 +941,7 @@ struct netns_ipvs {
924 int sysctl_nat_icmp_send; 941 int sysctl_nat_icmp_send;
925 int sysctl_pmtu_disc; 942 int sysctl_pmtu_disc;
926 int sysctl_backup_only; 943 int sysctl_backup_only;
944 int sysctl_conn_reuse_mode;
927 945
928 /* ip_vs_lblc */ 946 /* ip_vs_lblc */
929 int sysctl_lblc_expiration; 947 int sysctl_lblc_expiration;
@@ -1042,6 +1060,11 @@ static inline int sysctl_backup_only(struct netns_ipvs *ipvs)
1042 ipvs->sysctl_backup_only; 1060 ipvs->sysctl_backup_only;
1043} 1061}
1044 1062
1063static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)
1064{
1065 return ipvs->sysctl_conn_reuse_mode;
1066}
1067
1045#else 1068#else
1046 1069
1047static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) 1070static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
@@ -1109,6 +1132,11 @@ static inline int sysctl_backup_only(struct netns_ipvs *ipvs)
1109 return 0; 1132 return 0;
1110} 1133}
1111 1134
1135static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)
1136{
1137 return 1;
1138}
1139
1112#endif 1140#endif
1113 1141
1114/* IPVS core functions 1142/* IPVS core functions
@@ -1388,8 +1416,7 @@ void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp, int pkts);
1388void ip_vs_start_estimator(struct net *net, struct ip_vs_stats *stats); 1416void ip_vs_start_estimator(struct net *net, struct ip_vs_stats *stats);
1389void ip_vs_stop_estimator(struct net *net, struct ip_vs_stats *stats); 1417void ip_vs_stop_estimator(struct net *net, struct ip_vs_stats *stats);
1390void ip_vs_zero_estimator(struct ip_vs_stats *stats); 1418void ip_vs_zero_estimator(struct ip_vs_stats *stats);
1391void ip_vs_read_estimator(struct ip_vs_stats_user *dst, 1419void ip_vs_read_estimator(struct ip_vs_kstats *dst, struct ip_vs_stats *stats);
1392 struct ip_vs_stats *stats);
1393 1420
1394/* Various IPVS packet transmitters (from ip_vs_xmit.c) */ 1421/* Various IPVS packet transmitters (from ip_vs_xmit.c) */
1395int ip_vs_null_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, 1422int ip_vs_null_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 4c9fe224d73b..eec8ad3c9843 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -47,8 +47,6 @@
47 47
48#define NEXTHDR_MAX 255 48#define NEXTHDR_MAX 255
49 49
50
51
52#define IPV6_DEFAULT_HOPLIMIT 64 50#define IPV6_DEFAULT_HOPLIMIT 64
53#define IPV6_DEFAULT_MCASTHOPS 1 51#define IPV6_DEFAULT_MCASTHOPS 1
54 52
@@ -671,8 +669,9 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
671 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr)); 669 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
672} 670}
673 671
674void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt); 672void ipv6_select_ident(struct net *net, struct frag_hdr *fhdr,
675void ipv6_proxy_select_ident(struct sk_buff *skb); 673 struct rt6_info *rt);
674void ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb);
676 675
677int ip6_dst_hoplimit(struct dst_entry *dst); 676int ip6_dst_hoplimit(struct dst_entry *dst);
678 677
@@ -768,7 +767,7 @@ static inline u8 ip6_tclass(__be32 flowinfo)
768int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, 767int ipv6_rcv(struct sk_buff *skb, struct net_device *dev,
769 struct packet_type *pt, struct net_device *orig_dev); 768 struct packet_type *pt, struct net_device *orig_dev);
770 769
771int ip6_rcv_finish(struct sk_buff *skb); 770int ip6_rcv_finish(struct sock *sk, struct sk_buff *skb);
772 771
773/* 772/*
774 * upper-layer output functions 773 * upper-layer output functions
@@ -826,6 +825,7 @@ int ip6_input(struct sk_buff *skb);
826int ip6_mc_input(struct sk_buff *skb); 825int ip6_mc_input(struct sk_buff *skb);
827 826
828int __ip6_local_out(struct sk_buff *skb); 827int __ip6_local_out(struct sk_buff *skb);
828int ip6_local_out_sk(struct sock *sk, struct sk_buff *skb);
829int ip6_local_out(struct sk_buff *skb); 829int ip6_local_out(struct sk_buff *skb);
830 830
831/* 831/*
@@ -940,4 +940,8 @@ int ipv6_sysctl_register(void);
940void ipv6_sysctl_unregister(void); 940void ipv6_sysctl_unregister(void);
941#endif 941#endif
942 942
943int ipv6_sock_mc_join(struct sock *sk, int ifindex,
944 const struct in6_addr *addr);
945int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
946 const struct in6_addr *addr);
943#endif /* _NET_IPV6_H */ 947#endif /* _NET_IPV6_H */
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index a830b01baba4..8f81bbbc38fc 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -519,6 +519,17 @@ iwe_stream_add_event(struct iw_request_info *info, char *stream, char *ends,
519 return stream; 519 return stream;
520} 520}
521 521
522static inline char *
523iwe_stream_add_event_check(struct iw_request_info *info, char *stream,
524 char *ends, struct iw_event *iwe, int event_len)
525{
526 char *res = iwe_stream_add_event(info, stream, ends, iwe, event_len);
527
528 if (res == stream)
529 return ERR_PTR(-E2BIG);
530 return res;
531}
532
522/*------------------------------------------------------------------*/ 533/*------------------------------------------------------------------*/
523/* 534/*
524 * Wrapper to add an short Wireless Event containing a pointer to a 535 * Wrapper to add an short Wireless Event containing a pointer to a
@@ -545,6 +556,17 @@ iwe_stream_add_point(struct iw_request_info *info, char *stream, char *ends,
545 return stream; 556 return stream;
546} 557}
547 558
559static inline char *
560iwe_stream_add_point_check(struct iw_request_info *info, char *stream,
561 char *ends, struct iw_event *iwe, char *extra)
562{
563 char *res = iwe_stream_add_point(info, stream, ends, iwe, extra);
564
565 if (res == stream)
566 return ERR_PTR(-E2BIG);
567 return res;
568}
569
548/*------------------------------------------------------------------*/ 570/*------------------------------------------------------------------*/
549/* 571/*
550 * Wrapper to add a value to a Wireless Event in a stream of events. 572 * Wrapper to add a value to a Wireless Event in a stream of events.
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d52914b75331..b4bef1152c05 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -84,6 +84,39 @@
84 * 84 *
85 */ 85 */
86 86
87/**
88 * DOC: mac80211 software tx queueing
89 *
90 * mac80211 provides an optional intermediate queueing implementation designed
91 * to allow the driver to keep hardware queues short and provide some fairness
92 * between different stations/interfaces.
93 * In this model, the driver pulls data frames from the mac80211 queue instead
94 * of letting mac80211 push them via drv_tx().
95 * Other frames (e.g. control or management) are still pushed using drv_tx().
96 *
97 * Drivers indicate that they use this model by implementing the .wake_tx_queue
98 * driver operation.
99 *
100 * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with a
101 * single per-vif queue for multicast data frames.
102 *
103 * The driver is expected to initialize its private per-queue data for stations
104 * and interfaces in the .add_interface and .sta_add ops.
105 *
106 * The driver can't access the queue directly. To dequeue a frame, it calls
107 * ieee80211_tx_dequeue(). Whenever mac80211 adds a new frame to a queue, it
108 * calls the .wake_tx_queue driver op.
109 *
110 * For AP powersave TIM handling, the driver only needs to indicate if it has
111 * buffered packets in the driver specific data structures by calling
112 * ieee80211_sta_set_buffered(). For frames buffered in the ieee80211_txq
113 * struct, mac80211 sets the appropriate TIM PVB bits and calls
114 * .release_buffered_frames().
115 * In that callback the driver is therefore expected to release its own
116 * buffered frames and afterwards also frames from the ieee80211_txq (obtained
117 * via the usual ieee80211_tx_dequeue).
118 */
119
87struct device; 120struct device;
88 121
89/** 122/**
@@ -301,17 +334,86 @@ enum ieee80211_bss_change {
301#define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4 334#define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4
302 335
303/** 336/**
304 * enum ieee80211_rssi_event - RSSI threshold event 337 * enum ieee80211_event_type - event to be notified to the low level driver
305 * An indicator for when RSSI goes below/above a certain threshold. 338 * @RSSI_EVENT: AP's rssi crossed the a threshold set by the driver.
306 * @RSSI_EVENT_HIGH: AP's rssi crossed the high threshold set by the driver. 339 * @MLME_EVENT: event related to MLME
307 * @RSSI_EVENT_LOW: AP's rssi crossed the low threshold set by the driver.
308 */ 340 */
309enum ieee80211_rssi_event { 341enum ieee80211_event_type {
342 RSSI_EVENT,
343 MLME_EVENT,
344};
345
346/**
347 * enum ieee80211_rssi_event_data - relevant when event type is %RSSI_EVENT
348 * @RSSI_EVENT_HIGH: AP's rssi went below the threshold set by the driver.
349 * @RSSI_EVENT_LOW: AP's rssi went above the threshold set by the driver.
350 */
351enum ieee80211_rssi_event_data {
310 RSSI_EVENT_HIGH, 352 RSSI_EVENT_HIGH,
311 RSSI_EVENT_LOW, 353 RSSI_EVENT_LOW,
312}; 354};
313 355
314/** 356/**
357 * enum ieee80211_rssi_event - data attached to an %RSSI_EVENT
358 * @data: See &enum ieee80211_rssi_event_data
359 */
360struct ieee80211_rssi_event {
361 enum ieee80211_rssi_event_data data;
362};
363
364/**
365 * enum ieee80211_mlme_event_data - relevant when event type is %MLME_EVENT
366 * @AUTH_EVENT: the MLME operation is authentication
367 * @ASSOC_EVENT: the MLME operation is association
368 * @DEAUTH_RX_EVENT: deauth received..
369 * @DEAUTH_TX_EVENT: deauth sent.
370 */
371enum ieee80211_mlme_event_data {
372 AUTH_EVENT,
373 ASSOC_EVENT,
374 DEAUTH_RX_EVENT,
375 DEAUTH_TX_EVENT,
376};
377
378/**
379 * enum ieee80211_mlme_event_status - relevant when event type is %MLME_EVENT
380 * @MLME_SUCCESS: the MLME operation completed successfully.
381 * @MLME_DENIED: the MLME operation was denied by the peer.
382 * @MLME_TIMEOUT: the MLME operation timed out.
383 */
384enum ieee80211_mlme_event_status {
385 MLME_SUCCESS,
386 MLME_DENIED,
387 MLME_TIMEOUT,
388};
389
390/**
391 * enum ieee80211_mlme_event - data attached to an %MLME_EVENT
392 * @data: See &enum ieee80211_mlme_event_data
393 * @status: See &enum ieee80211_mlme_event_status
394 * @reason: the reason code if applicable
395 */
396struct ieee80211_mlme_event {
397 enum ieee80211_mlme_event_data data;
398 enum ieee80211_mlme_event_status status;
399 u16 reason;
400};
401
402/**
403 * struct ieee80211_event - event to be sent to the driver
404 * @type The event itself. See &enum ieee80211_event_type.
405 * @rssi: relevant if &type is %RSSI_EVENT
406 * @mlme: relevant if &type is %AUTH_EVENT
407 */
408struct ieee80211_event {
409 enum ieee80211_event_type type;
410 union {
411 struct ieee80211_rssi_event rssi;
412 struct ieee80211_mlme_event mlme;
413 } u;
414};
415
416/**
315 * struct ieee80211_bss_conf - holds the BSS's changing parameters 417 * struct ieee80211_bss_conf - holds the BSS's changing parameters
316 * 418 *
317 * This structure keeps information about a BSS (and an association 419 * This structure keeps information about a BSS (and an association
@@ -337,12 +439,15 @@ enum ieee80211_rssi_event {
337 * HW flag %IEEE80211_HW_TIMING_BEACON_ONLY is set, then this can 439 * HW flag %IEEE80211_HW_TIMING_BEACON_ONLY is set, then this can
338 * only come from a beacon, but might not become valid until after 440 * only come from a beacon, but might not become valid until after
339 * association when a beacon is received (which is notified with the 441 * association when a beacon is received (which is notified with the
340 * %BSS_CHANGED_DTIM flag.) 442 * %BSS_CHANGED_DTIM flag.). See also sync_dtim_count important notice.
341 * @sync_device_ts: the device timestamp corresponding to the sync_tsf, 443 * @sync_device_ts: the device timestamp corresponding to the sync_tsf,
342 * the driver/device can use this to calculate synchronisation 444 * the driver/device can use this to calculate synchronisation
343 * (see @sync_tsf) 445 * (see @sync_tsf). See also sync_dtim_count important notice.
344 * @sync_dtim_count: Only valid when %IEEE80211_HW_TIMING_BEACON_ONLY 446 * @sync_dtim_count: Only valid when %IEEE80211_HW_TIMING_BEACON_ONLY
345 * is requested, see @sync_tsf/@sync_device_ts. 447 * is requested, see @sync_tsf/@sync_device_ts.
448 * IMPORTANT: These three sync_* parameters would possibly be out of sync
449 * by the time the driver will use them. The synchronized view is currently
450 * guaranteed only in certain callbacks.
346 * @beacon_int: beacon interval 451 * @beacon_int: beacon interval
347 * @assoc_capability: capabilities taken from assoc resp 452 * @assoc_capability: capabilities taken from assoc resp
348 * @basic_rates: bitmap of basic rates, each bit stands for an 453 * @basic_rates: bitmap of basic rates, each bit stands for an
@@ -1234,6 +1339,7 @@ enum ieee80211_vif_flags {
1234 * monitor interface (if that is requested.) 1339 * monitor interface (if that is requested.)
1235 * @drv_priv: data area for driver use, will always be aligned to 1340 * @drv_priv: data area for driver use, will always be aligned to
1236 * sizeof(void *). 1341 * sizeof(void *).
1342 * @txq: the multicast data TX queue (if driver uses the TXQ abstraction)
1237 */ 1343 */
1238struct ieee80211_vif { 1344struct ieee80211_vif {
1239 enum nl80211_iftype type; 1345 enum nl80211_iftype type;
@@ -1245,6 +1351,8 @@ struct ieee80211_vif {
1245 u8 cab_queue; 1351 u8 cab_queue;
1246 u8 hw_queue[IEEE80211_NUM_ACS]; 1352 u8 hw_queue[IEEE80211_NUM_ACS];
1247 1353
1354 struct ieee80211_txq *txq;
1355
1248 struct ieee80211_chanctx_conf __rcu *chanctx_conf; 1356 struct ieee80211_chanctx_conf __rcu *chanctx_conf;
1249 1357
1250 u32 driver_flags; 1358 u32 driver_flags;
@@ -1279,6 +1387,19 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
1279struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev); 1387struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1280 1388
1281/** 1389/**
1390 * ieee80211_vif_to_wdev - return a wdev struct from a vif
1391 * @vif: the vif to get the wdev for
1392 *
1393 * This can be used by mac80211 drivers with direct cfg80211 APIs
1394 * (like the vendor commands) that needs to get the wdev for a vif.
1395 *
1396 * Note that this function may return %NULL if the given wdev isn't
1397 * associated with a vif that the driver knows about (e.g. monitor
1398 * or AP_VLAN interfaces.)
1399 */
1400struct wireless_dev *ieee80211_vif_to_wdev(struct ieee80211_vif *vif);
1401
1402/**
1282 * enum ieee80211_key_flags - key flags 1403 * enum ieee80211_key_flags - key flags
1283 * 1404 *
1284 * These flags are used for communication about keys between the driver 1405 * These flags are used for communication about keys between the driver
@@ -1472,7 +1593,8 @@ struct ieee80211_sta_rates {
1472 * @supp_rates: Bitmap of supported rates (per band) 1593 * @supp_rates: Bitmap of supported rates (per band)
1473 * @ht_cap: HT capabilities of this STA; restricted to our own capabilities 1594 * @ht_cap: HT capabilities of this STA; restricted to our own capabilities
1474 * @vht_cap: VHT capabilities of this STA; restricted to our own capabilities 1595 * @vht_cap: VHT capabilities of this STA; restricted to our own capabilities
1475 * @wme: indicates whether the STA supports QoS/WME. 1596 * @wme: indicates whether the STA supports QoS/WME (if local devices does,
1597 * otherwise always false)
1476 * @drv_priv: data area for driver use, will always be aligned to 1598 * @drv_priv: data area for driver use, will always be aligned to
1477 * sizeof(void *), size is determined in hw information. 1599 * sizeof(void *), size is determined in hw information.
1478 * @uapsd_queues: bitmap of queues configured for uapsd. Only valid 1600 * @uapsd_queues: bitmap of queues configured for uapsd. Only valid
@@ -1488,6 +1610,8 @@ struct ieee80211_sta_rates {
1488 * @tdls: indicates whether the STA is a TDLS peer 1610 * @tdls: indicates whether the STA is a TDLS peer
1489 * @tdls_initiator: indicates the STA is an initiator of the TDLS link. Only 1611 * @tdls_initiator: indicates the STA is an initiator of the TDLS link. Only
1490 * valid if the STA is a TDLS peer in the first place. 1612 * valid if the STA is a TDLS peer in the first place.
1613 * @mfp: indicates whether the STA uses management frame protection or not.
1614 * @txq: per-TID data TX queues (if driver uses the TXQ abstraction)
1491 */ 1615 */
1492struct ieee80211_sta { 1616struct ieee80211_sta {
1493 u32 supp_rates[IEEE80211_NUM_BANDS]; 1617 u32 supp_rates[IEEE80211_NUM_BANDS];
@@ -1504,6 +1628,9 @@ struct ieee80211_sta {
1504 struct ieee80211_sta_rates __rcu *rates; 1628 struct ieee80211_sta_rates __rcu *rates;
1505 bool tdls; 1629 bool tdls;
1506 bool tdls_initiator; 1630 bool tdls_initiator;
1631 bool mfp;
1632
1633 struct ieee80211_txq *txq[IEEE80211_NUM_TIDS];
1507 1634
1508 /* must be last */ 1635 /* must be last */
1509 u8 drv_priv[0] __aligned(sizeof(void *)); 1636 u8 drv_priv[0] __aligned(sizeof(void *));
@@ -1533,6 +1660,27 @@ struct ieee80211_tx_control {
1533}; 1660};
1534 1661
1535/** 1662/**
1663 * struct ieee80211_txq - Software intermediate tx queue
1664 *
1665 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
1666 * @sta: station table entry, %NULL for per-vif queue
1667 * @tid: the TID for this queue (unused for per-vif queue)
1668 * @ac: the AC for this queue
1669 *
1670 * The driver can obtain packets from this queue by calling
1671 * ieee80211_tx_dequeue().
1672 */
1673struct ieee80211_txq {
1674 struct ieee80211_vif *vif;
1675 struct ieee80211_sta *sta;
1676 u8 tid;
1677 u8 ac;
1678
1679 /* must be last */
1680 u8 drv_priv[0] __aligned(sizeof(void *));
1681};
1682
1683/**
1536 * enum ieee80211_hw_flags - hardware flags 1684 * enum ieee80211_hw_flags - hardware flags
1537 * 1685 *
1538 * These flags are used to indicate hardware capabilities to 1686 * These flags are used to indicate hardware capabilities to
@@ -1756,6 +1904,8 @@ enum ieee80211_hw_flags {
1756 * within &struct ieee80211_sta. 1904 * within &struct ieee80211_sta.
1757 * @chanctx_data_size: size (in bytes) of the drv_priv data area 1905 * @chanctx_data_size: size (in bytes) of the drv_priv data area
1758 * within &struct ieee80211_chanctx_conf. 1906 * within &struct ieee80211_chanctx_conf.
1907 * @txq_data_size: size (in bytes) of the drv_priv data area
1908 * within @struct ieee80211_txq.
1759 * 1909 *
1760 * @max_rates: maximum number of alternate rate retry stages the hw 1910 * @max_rates: maximum number of alternate rate retry stages the hw
1761 * can handle. 1911 * can handle.
@@ -1804,6 +1954,9 @@ enum ieee80211_hw_flags {
1804 * @n_cipher_schemes: a size of an array of cipher schemes definitions. 1954 * @n_cipher_schemes: a size of an array of cipher schemes definitions.
1805 * @cipher_schemes: a pointer to an array of cipher scheme definitions 1955 * @cipher_schemes: a pointer to an array of cipher scheme definitions
1806 * supported by HW. 1956 * supported by HW.
1957 *
1958 * @txq_ac_max_pending: maximum number of frames per AC pending in all txq
1959 * entries for a vif.
1807 */ 1960 */
1808struct ieee80211_hw { 1961struct ieee80211_hw {
1809 struct ieee80211_conf conf; 1962 struct ieee80211_conf conf;
@@ -1816,6 +1969,7 @@ struct ieee80211_hw {
1816 int vif_data_size; 1969 int vif_data_size;
1817 int sta_data_size; 1970 int sta_data_size;
1818 int chanctx_data_size; 1971 int chanctx_data_size;
1972 int txq_data_size;
1819 u16 queues; 1973 u16 queues;
1820 u16 max_listen_interval; 1974 u16 max_listen_interval;
1821 s8 max_signal; 1975 s8 max_signal;
@@ -1832,6 +1986,7 @@ struct ieee80211_hw {
1832 u8 uapsd_max_sp_len; 1986 u8 uapsd_max_sp_len;
1833 u8 n_cipher_schemes; 1987 u8 n_cipher_schemes;
1834 const struct ieee80211_cipher_scheme *cipher_schemes; 1988 const struct ieee80211_cipher_scheme *cipher_schemes;
1989 int txq_ac_max_pending;
1835}; 1990};
1836 1991
1837/** 1992/**
@@ -2844,8 +2999,9 @@ enum ieee80211_reconfig_type {
2844 * @set_bitrate_mask: Set a mask of rates to be used for rate control selection 2999 * @set_bitrate_mask: Set a mask of rates to be used for rate control selection
2845 * when transmitting a frame. Currently only legacy rates are handled. 3000 * when transmitting a frame. Currently only legacy rates are handled.
2846 * The callback can sleep. 3001 * The callback can sleep.
2847 * @rssi_callback: Notify driver when the average RSSI goes above/below 3002 * @event_callback: Notify driver about any event in mac80211. See
2848 * thresholds that were registered previously. The callback can sleep. 3003 * &enum ieee80211_event_type for the different types.
3004 * The callback can sleep.
2849 * 3005 *
2850 * @release_buffered_frames: Release buffered frames according to the given 3006 * @release_buffered_frames: Release buffered frames according to the given
2851 * parameters. In the case where the driver buffers some frames for 3007 * parameters. In the case where the driver buffers some frames for
@@ -2993,6 +3149,8 @@ enum ieee80211_reconfig_type {
2993 * response template is provided, together with the location of the 3149 * response template is provided, together with the location of the
2994 * switch-timing IE within the template. The skb can only be used within 3150 * switch-timing IE within the template. The skb can only be used within
2995 * the function call. 3151 * the function call.
3152 *
3153 * @wake_tx_queue: Called when new packets have been added to the queue.
2996 */ 3154 */
2997struct ieee80211_ops { 3155struct ieee80211_ops {
2998 void (*tx)(struct ieee80211_hw *hw, 3156 void (*tx)(struct ieee80211_hw *hw,
@@ -3141,9 +3299,9 @@ struct ieee80211_ops {
3141 bool (*tx_frames_pending)(struct ieee80211_hw *hw); 3299 bool (*tx_frames_pending)(struct ieee80211_hw *hw);
3142 int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 3300 int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3143 const struct cfg80211_bitrate_mask *mask); 3301 const struct cfg80211_bitrate_mask *mask);
3144 void (*rssi_callback)(struct ieee80211_hw *hw, 3302 void (*event_callback)(struct ieee80211_hw *hw,
3145 struct ieee80211_vif *vif, 3303 struct ieee80211_vif *vif,
3146 enum ieee80211_rssi_event rssi_event); 3304 const struct ieee80211_event *event);
3147 3305
3148 void (*allow_buffered_frames)(struct ieee80211_hw *hw, 3306 void (*allow_buffered_frames)(struct ieee80211_hw *hw,
3149 struct ieee80211_sta *sta, 3307 struct ieee80211_sta *sta,
@@ -3224,6 +3382,9 @@ struct ieee80211_ops {
3224 void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw, 3382 void (*tdls_recv_channel_switch)(struct ieee80211_hw *hw,
3225 struct ieee80211_vif *vif, 3383 struct ieee80211_vif *vif,
3226 struct ieee80211_tdls_ch_sw_params *params); 3384 struct ieee80211_tdls_ch_sw_params *params);
3385
3386 void (*wake_tx_queue)(struct ieee80211_hw *hw,
3387 struct ieee80211_txq *txq);
3227}; 3388};
3228 3389
3229/** 3390/**
@@ -4343,13 +4504,33 @@ void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw);
4343 * haven't been re-added to the driver yet. 4504 * haven't been re-added to the driver yet.
4344 * @IEEE80211_IFACE_ITER_RESUME_ALL: During resume, iterate over all 4505 * @IEEE80211_IFACE_ITER_RESUME_ALL: During resume, iterate over all
4345 * interfaces, even if they haven't been re-added to the driver yet. 4506 * interfaces, even if they haven't been re-added to the driver yet.
4507 * @IEEE80211_IFACE_ITER_ACTIVE: Iterate only active interfaces (netdev is up).
4346 */ 4508 */
4347enum ieee80211_interface_iteration_flags { 4509enum ieee80211_interface_iteration_flags {
4348 IEEE80211_IFACE_ITER_NORMAL = 0, 4510 IEEE80211_IFACE_ITER_NORMAL = 0,
4349 IEEE80211_IFACE_ITER_RESUME_ALL = BIT(0), 4511 IEEE80211_IFACE_ITER_RESUME_ALL = BIT(0),
4512 IEEE80211_IFACE_ITER_ACTIVE = BIT(1),
4350}; 4513};
4351 4514
4352/** 4515/**
4516 * ieee80211_iterate_interfaces - iterate interfaces
4517 *
4518 * This function iterates over the interfaces associated with a given
4519 * hardware and calls the callback for them. This includes active as well as
4520 * inactive interfaces. This function allows the iterator function to sleep.
4521 * Will iterate over a new interface during add_interface().
4522 *
4523 * @hw: the hardware struct of which the interfaces should be iterated over
4524 * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags
4525 * @iterator: the iterator function to call
4526 * @data: first argument of the iterator function
4527 */
4528void ieee80211_iterate_interfaces(struct ieee80211_hw *hw, u32 iter_flags,
4529 void (*iterator)(void *data, u8 *mac,
4530 struct ieee80211_vif *vif),
4531 void *data);
4532
4533/**
4353 * ieee80211_iterate_active_interfaces - iterate active interfaces 4534 * ieee80211_iterate_active_interfaces - iterate active interfaces
4354 * 4535 *
4355 * This function iterates over the interfaces associated with a given 4536 * This function iterates over the interfaces associated with a given
@@ -4364,11 +4545,16 @@ enum ieee80211_interface_iteration_flags {
4364 * @iterator: the iterator function to call 4545 * @iterator: the iterator function to call
4365 * @data: first argument of the iterator function 4546 * @data: first argument of the iterator function
4366 */ 4547 */
4367void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, 4548static inline void
4368 u32 iter_flags, 4549ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, u32 iter_flags,
4369 void (*iterator)(void *data, u8 *mac, 4550 void (*iterator)(void *data, u8 *mac,
4370 struct ieee80211_vif *vif), 4551 struct ieee80211_vif *vif),
4371 void *data); 4552 void *data)
4553{
4554 ieee80211_iterate_interfaces(hw,
4555 iter_flags | IEEE80211_IFACE_ITER_ACTIVE,
4556 iterator, data);
4557}
4372 4558
4373/** 4559/**
4374 * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces 4560 * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces
@@ -5194,30 +5380,13 @@ int ieee80211_reserve_tid(struct ieee80211_sta *sta, u8 tid);
5194void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid); 5380void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
5195 5381
5196/** 5382/**
5197 * ieee80211_ie_split - split an IE buffer according to ordering 5383 * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
5198 *
5199 * @ies: the IE buffer
5200 * @ielen: the length of the IE buffer
5201 * @ids: an array with element IDs that are allowed before
5202 * the split
5203 * @n_ids: the size of the element ID array
5204 * @offset: offset where to start splitting in the buffer
5205 *
5206 * This function splits an IE buffer by updating the @offset
5207 * variable to point to the location where the buffer should be
5208 * split.
5209 * 5384 *
5210 * It assumes that the given IE buffer is well-formed, this 5385 * @hw: pointer as obtained from ieee80211_alloc_hw()
5211 * has to be guaranteed by the caller! 5386 * @txq: pointer obtained from station or virtual interface
5212 *
5213 * It also assumes that the IEs in the buffer are ordered
5214 * correctly, if not the result of using this function will not
5215 * be ordered correctly either, i.e. it does no reordering.
5216 * 5387 *
5217 * The function returns the offset where the next part of the 5388 * Returns the skb if successful, %NULL if no frame was available.
5218 * buffer starts, which may be @ielen if the entire (remainder)
5219 * of the buffer should be used.
5220 */ 5389 */
5221size_t ieee80211_ie_split(const u8 *ies, size_t ielen, 5390struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
5222 const u8 *ids, int n_ids, size_t offset); 5391 struct ieee80211_txq *txq);
5223#endif /* MAC80211_H */ 5392#endif /* MAC80211_H */
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 850647811749..e18e7fd43f47 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -19,6 +19,7 @@
19#include <net/af_ieee802154.h> 19#include <net/af_ieee802154.h>
20#include <linux/ieee802154.h> 20#include <linux/ieee802154.h>
21#include <linux/skbuff.h> 21#include <linux/skbuff.h>
22#include <linux/unaligned/memmove.h>
22 23
23#include <net/cfg802154.h> 24#include <net/cfg802154.h>
24 25
@@ -212,7 +213,7 @@ struct ieee802154_ops {
212 int (*set_hw_addr_filt)(struct ieee802154_hw *hw, 213 int (*set_hw_addr_filt)(struct ieee802154_hw *hw,
213 struct ieee802154_hw_addr_filt *filt, 214 struct ieee802154_hw_addr_filt *filt,
214 unsigned long changed); 215 unsigned long changed);
215 int (*set_txpower)(struct ieee802154_hw *hw, int db); 216 int (*set_txpower)(struct ieee802154_hw *hw, s8 dbm);
216 int (*set_lbt)(struct ieee802154_hw *hw, bool on); 217 int (*set_lbt)(struct ieee802154_hw *hw, bool on);
217 int (*set_cca_mode)(struct ieee802154_hw *hw, 218 int (*set_cca_mode)(struct ieee802154_hw *hw,
218 const struct wpan_phy_cca *cca); 219 const struct wpan_phy_cca *cca);
@@ -233,9 +234,7 @@ struct ieee802154_ops {
233 */ 234 */
234static inline void ieee802154_be64_to_le64(void *le64_dst, const void *be64_src) 235static inline void ieee802154_be64_to_le64(void *le64_dst, const void *be64_src)
235{ 236{
236 __le64 tmp = (__force __le64)swab64p(be64_src); 237 __put_unaligned_memmove64(swab64p(be64_src), le64_dst);
237
238 memcpy(le64_dst, &tmp, IEEE802154_EXTENDED_ADDR_LEN);
239} 238}
240 239
241/** 240/**
@@ -245,12 +244,10 @@ static inline void ieee802154_be64_to_le64(void *le64_dst, const void *be64_src)
245 */ 244 */
246static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src) 245static inline void ieee802154_le64_to_be64(void *be64_dst, const void *le64_src)
247{ 246{
248 __be64 tmp = (__force __be64)swab64p(le64_src); 247 __put_unaligned_memmove64(swab64p(le64_src), be64_dst);
249
250 memcpy(be64_dst, &tmp, IEEE802154_EXTENDED_ADDR_LEN);
251} 248}
252 249
253/* Basic interface to register ieee802154 hwice */ 250/* Basic interface to register ieee802154 device */
254struct ieee802154_hw * 251struct ieee802154_hw *
255ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops); 252ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops);
256void ieee802154_free_hw(struct ieee802154_hw *hw); 253void ieee802154_free_hw(struct ieee802154_hw *hw);
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 6bbda34d5e59..b3a7751251b4 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -156,24 +156,7 @@ static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, _
156 156
157static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey) 157static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey)
158{ 158{
159 struct neigh_hash_table *nht; 159 return ___neigh_lookup_noref(&nd_tbl, neigh_key_eq128, ndisc_hashfn, pkey, dev);
160 const u32 *p32 = pkey;
161 struct neighbour *n;
162 u32 hash_val;
163
164 nht = rcu_dereference_bh(nd_tbl.nht);
165 hash_val = ndisc_hashfn(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift);
166 for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
167 n != NULL;
168 n = rcu_dereference_bh(n->next)) {
169 u32 *n32 = (u32 *) n->primary_key;
170 if (n->dev == dev &&
171 ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
172 (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0)
173 return n;
174 }
175
176 return NULL;
177} 160}
178 161
179static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey) 162static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 76f708486aae..bd33e66f49aa 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -42,6 +42,7 @@ enum {
42 NEIGH_VAR_MCAST_PROBES, 42 NEIGH_VAR_MCAST_PROBES,
43 NEIGH_VAR_UCAST_PROBES, 43 NEIGH_VAR_UCAST_PROBES,
44 NEIGH_VAR_APP_PROBES, 44 NEIGH_VAR_APP_PROBES,
45 NEIGH_VAR_MCAST_REPROBES,
45 NEIGH_VAR_RETRANS_TIME, 46 NEIGH_VAR_RETRANS_TIME,
46 NEIGH_VAR_BASE_REACHABLE_TIME, 47 NEIGH_VAR_BASE_REACHABLE_TIME,
47 NEIGH_VAR_DELAY_PROBE_TIME, 48 NEIGH_VAR_DELAY_PROBE_TIME,
@@ -65,9 +66,7 @@ enum {
65}; 66};
66 67
67struct neigh_parms { 68struct neigh_parms {
68#ifdef CONFIG_NET_NS 69 possible_net_t net;
69 struct net *net;
70#endif
71 struct net_device *dev; 70 struct net_device *dev;
72 struct list_head list; 71 struct list_head list;
73 int (*neigh_setup)(struct neighbour *); 72 int (*neigh_setup)(struct neighbour *);
@@ -167,9 +166,7 @@ struct neigh_ops {
167 166
168struct pneigh_entry { 167struct pneigh_entry {
169 struct pneigh_entry *next; 168 struct pneigh_entry *next;
170#ifdef CONFIG_NET_NS 169 possible_net_t net;
171 struct net *net;
172#endif
173 struct net_device *dev; 170 struct net_device *dev;
174 u8 flags; 171 u8 flags;
175 u8 key[0]; 172 u8 key[0];
@@ -193,9 +190,11 @@ struct neigh_table {
193 int family; 190 int family;
194 int entry_size; 191 int entry_size;
195 int key_len; 192 int key_len;
193 __be16 protocol;
196 __u32 (*hash)(const void *pkey, 194 __u32 (*hash)(const void *pkey,
197 const struct net_device *dev, 195 const struct net_device *dev,
198 __u32 *hash_rnd); 196 __u32 *hash_rnd);
197 bool (*key_eq)(const struct neighbour *, const void *pkey);
199 int (*constructor)(struct neighbour *); 198 int (*constructor)(struct neighbour *);
200 int (*pconstructor)(struct pneigh_entry *); 199 int (*pconstructor)(struct pneigh_entry *);
201 void (*pdestructor)(struct pneigh_entry *); 200 void (*pdestructor)(struct pneigh_entry *);
@@ -224,6 +223,7 @@ enum {
224 NEIGH_ND_TABLE = 1, 223 NEIGH_ND_TABLE = 1,
225 NEIGH_DN_TABLE = 2, 224 NEIGH_DN_TABLE = 2,
226 NEIGH_NR_TABLES, 225 NEIGH_NR_TABLES,
226 NEIGH_LINK_TABLE = NEIGH_NR_TABLES /* Pseudo table for neigh_xmit */
227}; 227};
228 228
229static inline int neigh_parms_family(struct neigh_parms *p) 229static inline int neigh_parms_family(struct neigh_parms *p)
@@ -246,6 +246,57 @@ static inline void *neighbour_priv(const struct neighbour *n)
246#define NEIGH_UPDATE_F_ISROUTER 0x40000000 246#define NEIGH_UPDATE_F_ISROUTER 0x40000000
247#define NEIGH_UPDATE_F_ADMIN 0x80000000 247#define NEIGH_UPDATE_F_ADMIN 0x80000000
248 248
249
250static inline bool neigh_key_eq16(const struct neighbour *n, const void *pkey)
251{
252 return *(const u16 *)n->primary_key == *(const u16 *)pkey;
253}
254
255static inline bool neigh_key_eq32(const struct neighbour *n, const void *pkey)
256{
257 return *(const u32 *)n->primary_key == *(const u32 *)pkey;
258}
259
260static inline bool neigh_key_eq128(const struct neighbour *n, const void *pkey)
261{
262 const u32 *n32 = (const u32 *)n->primary_key;
263 const u32 *p32 = pkey;
264
265 return ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
266 (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0;
267}
268
269static inline struct neighbour *___neigh_lookup_noref(
270 struct neigh_table *tbl,
271 bool (*key_eq)(const struct neighbour *n, const void *pkey),
272 __u32 (*hash)(const void *pkey,
273 const struct net_device *dev,
274 __u32 *hash_rnd),
275 const void *pkey,
276 struct net_device *dev)
277{
278 struct neigh_hash_table *nht = rcu_dereference_bh(tbl->nht);
279 struct neighbour *n;
280 u32 hash_val;
281
282 hash_val = hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift);
283 for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
284 n != NULL;
285 n = rcu_dereference_bh(n->next)) {
286 if (n->dev == dev && key_eq(n, pkey))
287 return n;
288 }
289
290 return NULL;
291}
292
293static inline struct neighbour *__neigh_lookup_noref(struct neigh_table *tbl,
294 const void *pkey,
295 struct net_device *dev)
296{
297 return ___neigh_lookup_noref(tbl, tbl->key_eq, tbl->hash, pkey, dev);
298}
299
249void neigh_table_init(int index, struct neigh_table *tbl); 300void neigh_table_init(int index, struct neigh_table *tbl);
250int neigh_table_clear(int index, struct neigh_table *tbl); 301int neigh_table_clear(int index, struct neigh_table *tbl);
251struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey, 302struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey,
@@ -268,7 +319,6 @@ void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
268int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev); 319int neigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
269int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb); 320int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb);
270int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb); 321int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb);
271int neigh_compat_output(struct neighbour *neigh, struct sk_buff *skb);
272int neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb); 322int neigh_direct_output(struct neighbour *neigh, struct sk_buff *skb);
273struct neighbour *neigh_event_ns(struct neigh_table *tbl, 323struct neighbour *neigh_event_ns(struct neigh_table *tbl,
274 u8 *lladdr, void *saddr, 324 u8 *lladdr, void *saddr,
@@ -306,6 +356,7 @@ void neigh_for_each(struct neigh_table *tbl,
306 void (*cb)(struct neighbour *, void *), void *cookie); 356 void (*cb)(struct neighbour *, void *), void *cookie);
307void __neigh_for_each_release(struct neigh_table *tbl, 357void __neigh_for_each_release(struct neigh_table *tbl,
308 int (*cb)(struct neighbour *)); 358 int (*cb)(struct neighbour *));
359int neigh_xmit(int fam, struct net_device *, const void *, struct sk_buff *);
309void pneigh_for_each(struct neigh_table *tbl, 360void pneigh_for_each(struct neigh_table *tbl,
310 void (*cb)(struct pneigh_entry *)); 361 void (*cb)(struct pneigh_entry *));
311 362
@@ -459,4 +510,6 @@ static inline void neigh_ha_snapshot(char *dst, const struct neighbour *n,
459 memcpy(dst, n->ha, dev->addr_len); 510 memcpy(dst, n->ha, dev->addr_len);
460 } while (read_seqretry(&n->ha_lock, seq)); 511 } while (read_seqretry(&n->ha_lock, seq));
461} 512}
513
514
462#endif 515#endif
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 36faf4990c4b..f733656404de 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -26,6 +26,7 @@
26#endif 26#endif
27#include <net/netns/nftables.h> 27#include <net/netns/nftables.h>
28#include <net/netns/xfrm.h> 28#include <net/netns/xfrm.h>
29#include <net/netns/mpls.h>
29#include <linux/ns_common.h> 30#include <linux/ns_common.h>
30 31
31struct user_namespace; 32struct user_namespace;
@@ -48,13 +49,10 @@ struct net {
48 atomic_t count; /* To decided when the network 49 atomic_t count; /* To decided when the network
49 * namespace should be shut down. 50 * namespace should be shut down.
50 */ 51 */
51#ifdef NETNS_REFCNT_DEBUG
52 atomic_t use_count; /* To track references we
53 * destroy on demand
54 */
55#endif
56 spinlock_t rules_mod_lock; 52 spinlock_t rules_mod_lock;
57 53
54 atomic64_t cookie_gen;
55
58 struct list_head list; /* list of network namespaces */ 56 struct list_head list; /* list of network namespaces */
59 struct list_head cleanup_list; /* namespaces on death row */ 57 struct list_head cleanup_list; /* namespaces on death row */
60 struct list_head exit_list; /* Use only net_mutex */ 58 struct list_head exit_list; /* Use only net_mutex */
@@ -130,6 +128,9 @@ struct net {
130#if IS_ENABLED(CONFIG_IP_VS) 128#if IS_ENABLED(CONFIG_IP_VS)
131 struct netns_ipvs *ipvs; 129 struct netns_ipvs *ipvs;
132#endif 130#endif
131#if IS_ENABLED(CONFIG_MPLS)
132 struct netns_mpls mpls;
133#endif
133 struct sock *diag_nlsk; 134 struct sock *diag_nlsk;
134 atomic_t fnhe_genid; 135 atomic_t fnhe_genid;
135}; 136};
@@ -230,48 +231,27 @@ int net_eq(const struct net *net1, const struct net *net2)
230#endif 231#endif
231 232
232 233
233#ifdef NETNS_REFCNT_DEBUG 234typedef struct {
234static inline struct net *hold_net(struct net *net)
235{
236 if (net)
237 atomic_inc(&net->use_count);
238 return net;
239}
240
241static inline void release_net(struct net *net)
242{
243 if (net)
244 atomic_dec(&net->use_count);
245}
246#else
247static inline struct net *hold_net(struct net *net)
248{
249 return net;
250}
251
252static inline void release_net(struct net *net)
253{
254}
255#endif
256
257#ifdef CONFIG_NET_NS 235#ifdef CONFIG_NET_NS
236 struct net *net;
237#endif
238} possible_net_t;
258 239
259static inline void write_pnet(struct net **pnet, struct net *net) 240static inline void write_pnet(possible_net_t *pnet, struct net *net)
260{ 241{
261 *pnet = net; 242#ifdef CONFIG_NET_NS
243 pnet->net = net;
244#endif
262} 245}
263 246
264static inline struct net *read_pnet(struct net * const *pnet) 247static inline struct net *read_pnet(const possible_net_t *pnet)
265{ 248{
266 return *pnet; 249#ifdef CONFIG_NET_NS
267} 250 return pnet->net;
268
269#else 251#else
270 252 return &init_net;
271#define write_pnet(pnet, net) do { (void)(net);} while (0)
272#define read_pnet(pnet) (&init_net)
273
274#endif 253#endif
254}
275 255
276#define for_each_net(VAR) \ 256#define for_each_net(VAR) \
277 list_for_each_entry(VAR, &net_namespace_list, list) 257 list_for_each_entry(VAR, &net_namespace_list, list)
diff --git a/include/net/netfilter/ipv4/nf_reject.h b/include/net/netfilter/ipv4/nf_reject.h
index 03e928a55229..77862c3645f0 100644
--- a/include/net/netfilter/ipv4/nf_reject.h
+++ b/include/net/netfilter/ipv4/nf_reject.h
@@ -5,18 +5,14 @@
5#include <net/ip.h> 5#include <net/ip.h>
6#include <net/icmp.h> 6#include <net/icmp.h>
7 7
8static inline void nf_send_unreach(struct sk_buff *skb_in, int code) 8void nf_send_unreach(struct sk_buff *skb_in, int code, int hook);
9{
10 icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0);
11}
12
13void nf_send_reset(struct sk_buff *oldskb, int hook); 9void nf_send_reset(struct sk_buff *oldskb, int hook);
14 10
15const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb, 11const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
16 struct tcphdr *_oth, int hook); 12 struct tcphdr *_oth, int hook);
17struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb, 13struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
18 const struct sk_buff *oldskb, 14 const struct sk_buff *oldskb,
19 __be16 protocol, int ttl); 15 __u8 protocol, int ttl);
20void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb, 16void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
21 const struct tcphdr *oth); 17 const struct tcphdr *oth);
22 18
diff --git a/include/net/netfilter/ipv6/nf_reject.h b/include/net/netfilter/ipv6/nf_reject.h
index 23216d48abf9..0ea4fa37db16 100644
--- a/include/net/netfilter/ipv6/nf_reject.h
+++ b/include/net/netfilter/ipv6/nf_reject.h
@@ -3,15 +3,8 @@
3 3
4#include <linux/icmpv6.h> 4#include <linux/icmpv6.h>
5 5
6static inline void 6void nf_send_unreach6(struct net *net, struct sk_buff *skb_in, unsigned char code,
7nf_send_unreach6(struct net *net, struct sk_buff *skb_in, unsigned char code, 7 unsigned int hooknum);
8 unsigned int hooknum)
9{
10 if (hooknum == NF_INET_LOCAL_OUT && skb_in->dev == NULL)
11 skb_in->dev = net->loopback_dev;
12
13 icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0);
14}
15 8
16void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook); 9void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook);
17 10
@@ -20,7 +13,7 @@ const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
20 unsigned int *otcplen, int hook); 13 unsigned int *otcplen, int hook);
21struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb, 14struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
22 const struct sk_buff *oldskb, 15 const struct sk_buff *oldskb,
23 __be16 protocol, int hoplimit); 16 __u8 protocol, int hoplimit);
24void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb, 17void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
25 const struct sk_buff *oldskb, 18 const struct sk_buff *oldskb,
26 const struct tcphdr *oth, unsigned int otcplen); 19 const struct tcphdr *oth, unsigned int otcplen);
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 74f271a172dd..095433b8a8b0 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -95,9 +95,8 @@ struct nf_conn {
95 /* Timer function; drops refcnt when it goes off. */ 95 /* Timer function; drops refcnt when it goes off. */
96 struct timer_list timeout; 96 struct timer_list timeout;
97 97
98#ifdef CONFIG_NET_NS 98 possible_net_t ct_net;
99 struct net *ct_net; 99
100#endif
101 /* all members below initialized via memset */ 100 /* all members below initialized via memset */
102 u8 __nfct_init_offset[0]; 101 u8 __nfct_init_offset[0];
103 102
diff --git a/include/net/netfilter/nf_nat_l3proto.h b/include/net/netfilter/nf_nat_l3proto.h
index 340c013795a4..a3127325f624 100644
--- a/include/net/netfilter/nf_nat_l3proto.h
+++ b/include/net/netfilter/nf_nat_l3proto.h
@@ -44,40 +44,32 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
44 unsigned int hooknum); 44 unsigned int hooknum);
45 45
46unsigned int nf_nat_ipv4_in(const struct nf_hook_ops *ops, struct sk_buff *skb, 46unsigned int nf_nat_ipv4_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
47 const struct net_device *in, 47 const struct nf_hook_state *state,
48 const struct net_device *out,
49 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 48 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
50 struct sk_buff *skb, 49 struct sk_buff *skb,
51 const struct net_device *in, 50 const struct nf_hook_state *state,
52 const struct net_device *out,
53 struct nf_conn *ct)); 51 struct nf_conn *ct));
54 52
55unsigned int nf_nat_ipv4_out(const struct nf_hook_ops *ops, struct sk_buff *skb, 53unsigned int nf_nat_ipv4_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
56 const struct net_device *in, 54 const struct nf_hook_state *state,
57 const struct net_device *out,
58 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 55 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
59 struct sk_buff *skb, 56 struct sk_buff *skb,
60 const struct net_device *in, 57 const struct nf_hook_state *state,
61 const struct net_device *out,
62 struct nf_conn *ct)); 58 struct nf_conn *ct));
63 59
64unsigned int nf_nat_ipv4_local_fn(const struct nf_hook_ops *ops, 60unsigned int nf_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
65 struct sk_buff *skb, 61 struct sk_buff *skb,
66 const struct net_device *in, 62 const struct nf_hook_state *state,
67 const struct net_device *out,
68 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 63 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
69 struct sk_buff *skb, 64 struct sk_buff *skb,
70 const struct net_device *in, 65 const struct nf_hook_state *state,
71 const struct net_device *out,
72 struct nf_conn *ct)); 66 struct nf_conn *ct));
73 67
74unsigned int nf_nat_ipv4_fn(const struct nf_hook_ops *ops, struct sk_buff *skb, 68unsigned int nf_nat_ipv4_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
75 const struct net_device *in, 69 const struct nf_hook_state *state,
76 const struct net_device *out,
77 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 70 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
78 struct sk_buff *skb, 71 struct sk_buff *skb,
79 const struct net_device *in, 72 const struct nf_hook_state *state,
80 const struct net_device *out,
81 struct nf_conn *ct)); 73 struct nf_conn *ct));
82 74
83int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct, 75int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
@@ -85,40 +77,32 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
85 unsigned int hooknum, unsigned int hdrlen); 77 unsigned int hooknum, unsigned int hdrlen);
86 78
87unsigned int nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb, 79unsigned int nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
88 const struct net_device *in, 80 const struct nf_hook_state *state,
89 const struct net_device *out,
90 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 81 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
91 struct sk_buff *skb, 82 struct sk_buff *skb,
92 const struct net_device *in, 83 const struct nf_hook_state *state,
93 const struct net_device *out,
94 struct nf_conn *ct)); 84 struct nf_conn *ct));
95 85
96unsigned int nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb, 86unsigned int nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
97 const struct net_device *in, 87 const struct nf_hook_state *state,
98 const struct net_device *out,
99 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 88 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
100 struct sk_buff *skb, 89 struct sk_buff *skb,
101 const struct net_device *in, 90 const struct nf_hook_state *state,
102 const struct net_device *out,
103 struct nf_conn *ct)); 91 struct nf_conn *ct));
104 92
105unsigned int nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops, 93unsigned int nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
106 struct sk_buff *skb, 94 struct sk_buff *skb,
107 const struct net_device *in, 95 const struct nf_hook_state *state,
108 const struct net_device *out,
109 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 96 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
110 struct sk_buff *skb, 97 struct sk_buff *skb,
111 const struct net_device *in, 98 const struct nf_hook_state *state,
112 const struct net_device *out,
113 struct nf_conn *ct)); 99 struct nf_conn *ct));
114 100
115unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb, 101unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
116 const struct net_device *in, 102 const struct nf_hook_state *state,
117 const struct net_device *out,
118 unsigned int (*do_chain)(const struct nf_hook_ops *ops, 103 unsigned int (*do_chain)(const struct nf_hook_ops *ops,
119 struct sk_buff *skb, 104 struct sk_buff *skb,
120 const struct net_device *in, 105 const struct nf_hook_state *state,
121 const struct net_device *out,
122 struct nf_conn *ct)); 106 struct nf_conn *ct));
123 107
124#endif /* _NF_NAT_L3PROTO_H */ 108#endif /* _NF_NAT_L3PROTO_H */
diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h
index 84a53d780306..d81d584157e1 100644
--- a/include/net/netfilter/nf_queue.h
+++ b/include/net/netfilter/nf_queue.h
@@ -12,12 +12,8 @@ struct nf_queue_entry {
12 unsigned int id; 12 unsigned int id;
13 13
14 struct nf_hook_ops *elem; 14 struct nf_hook_ops *elem;
15 u_int8_t pf; 15 struct nf_hook_state state;
16 u16 size; /* sizeof(entry) + saved route keys */ 16 u16 size; /* sizeof(entry) + saved route keys */
17 unsigned int hook;
18 struct net_device *indev;
19 struct net_device *outdev;
20 int (*okfn)(struct sk_buff *);
21 17
22 /* extra space to store route keys */ 18 /* extra space to store route keys */
23}; 19};
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index decb9a095ae7..e6bcf55dcf20 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -1,6 +1,7 @@
1#ifndef _NET_NF_TABLES_H 1#ifndef _NET_NF_TABLES_H
2#define _NET_NF_TABLES_H 2#define _NET_NF_TABLES_H
3 3
4#include <linux/module.h>
4#include <linux/list.h> 5#include <linux/list.h>
5#include <linux/netfilter.h> 6#include <linux/netfilter.h>
6#include <linux/netfilter/nfnetlink.h> 7#include <linux/netfilter/nfnetlink.h>
@@ -26,40 +27,53 @@ struct nft_pktinfo {
26static inline void nft_set_pktinfo(struct nft_pktinfo *pkt, 27static inline void nft_set_pktinfo(struct nft_pktinfo *pkt,
27 const struct nf_hook_ops *ops, 28 const struct nf_hook_ops *ops,
28 struct sk_buff *skb, 29 struct sk_buff *skb,
29 const struct net_device *in, 30 const struct nf_hook_state *state)
30 const struct net_device *out)
31{ 31{
32 pkt->skb = skb; 32 pkt->skb = skb;
33 pkt->in = pkt->xt.in = in; 33 pkt->in = pkt->xt.in = state->in;
34 pkt->out = pkt->xt.out = out; 34 pkt->out = pkt->xt.out = state->out;
35 pkt->ops = ops; 35 pkt->ops = ops;
36 pkt->xt.hooknum = ops->hooknum; 36 pkt->xt.hooknum = ops->hooknum;
37 pkt->xt.family = ops->pf; 37 pkt->xt.family = ops->pf;
38} 38}
39 39
40/**
41 * struct nft_verdict - nf_tables verdict
42 *
43 * @code: nf_tables/netfilter verdict code
44 * @chain: destination chain for NFT_JUMP/NFT_GOTO
45 */
46struct nft_verdict {
47 u32 code;
48 struct nft_chain *chain;
49};
50
40struct nft_data { 51struct nft_data {
41 union { 52 union {
42 u32 data[4]; 53 u32 data[4];
43 struct { 54 struct nft_verdict verdict;
44 u32 verdict;
45 struct nft_chain *chain;
46 };
47 }; 55 };
48} __attribute__((aligned(__alignof__(u64)))); 56} __attribute__((aligned(__alignof__(u64))));
49 57
50static inline int nft_data_cmp(const struct nft_data *d1, 58/**
51 const struct nft_data *d2, 59 * struct nft_regs - nf_tables register set
52 unsigned int len) 60 *
53{ 61 * @data: data registers
54 return memcmp(d1->data, d2->data, len); 62 * @verdict: verdict register
55} 63 *
64 * The first four data registers alias to the verdict register.
65 */
66struct nft_regs {
67 union {
68 u32 data[20];
69 struct nft_verdict verdict;
70 };
71};
56 72
57static inline void nft_data_copy(struct nft_data *dst, 73static inline void nft_data_copy(u32 *dst, const struct nft_data *src,
58 const struct nft_data *src) 74 unsigned int len)
59{ 75{
60 BUILD_BUG_ON(__alignof__(*dst) != __alignof__(u64)); 76 memcpy(dst, src, len);
61 *(u64 *)&dst->data[0] = *(u64 *)&src->data[0];
62 *(u64 *)&dst->data[2] = *(u64 *)&src->data[2];
63} 77}
64 78
65static inline void nft_data_debug(const struct nft_data *data) 79static inline void nft_data_debug(const struct nft_data *data)
@@ -97,7 +111,8 @@ struct nft_data_desc {
97 unsigned int len; 111 unsigned int len;
98}; 112};
99 113
100int nft_data_init(const struct nft_ctx *ctx, struct nft_data *data, 114int nft_data_init(const struct nft_ctx *ctx,
115 struct nft_data *data, unsigned int size,
101 struct nft_data_desc *desc, const struct nlattr *nla); 116 struct nft_data_desc *desc, const struct nlattr *nla);
102void nft_data_uninit(const struct nft_data *data, enum nft_data_types type); 117void nft_data_uninit(const struct nft_data *data, enum nft_data_types type);
103int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data, 118int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data,
@@ -113,12 +128,14 @@ static inline enum nft_registers nft_type_to_reg(enum nft_data_types type)
113 return type == NFT_DATA_VERDICT ? NFT_REG_VERDICT : NFT_REG_1; 128 return type == NFT_DATA_VERDICT ? NFT_REG_VERDICT : NFT_REG_1;
114} 129}
115 130
116int nft_validate_input_register(enum nft_registers reg); 131unsigned int nft_parse_register(const struct nlattr *attr);
117int nft_validate_output_register(enum nft_registers reg); 132int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg);
118int nft_validate_data_load(const struct nft_ctx *ctx, enum nft_registers reg,
119 const struct nft_data *data,
120 enum nft_data_types type);
121 133
134int nft_validate_register_load(enum nft_registers reg, unsigned int len);
135int nft_validate_register_store(const struct nft_ctx *ctx,
136 enum nft_registers reg,
137 const struct nft_data *data,
138 enum nft_data_types type, unsigned int len);
122 139
123/** 140/**
124 * struct nft_userdata - user defined data associated with an object 141 * struct nft_userdata - user defined data associated with an object
@@ -138,19 +155,15 @@ struct nft_userdata {
138/** 155/**
139 * struct nft_set_elem - generic representation of set elements 156 * struct nft_set_elem - generic representation of set elements
140 * 157 *
141 * @cookie: implementation specific element cookie
142 * @key: element key 158 * @key: element key
143 * @data: element data (maps only) 159 * @priv: element private data and extensions
144 * @flags: element flags (end of interval)
145 *
146 * The cookie can be used to store a handle to the element for subsequent
147 * removal.
148 */ 160 */
149struct nft_set_elem { 161struct nft_set_elem {
150 void *cookie; 162 union {
151 struct nft_data key; 163 u32 buf[NFT_DATA_VALUE_MAXLEN / sizeof(u32)];
152 struct nft_data data; 164 struct nft_data val;
153 u32 flags; 165 } key;
166 void *priv;
154}; 167};
155 168
156struct nft_set; 169struct nft_set;
@@ -202,11 +215,16 @@ struct nft_set_estimate {
202 enum nft_set_class class; 215 enum nft_set_class class;
203}; 216};
204 217
218struct nft_set_ext;
219struct nft_expr;
220
205/** 221/**
206 * struct nft_set_ops - nf_tables set operations 222 * struct nft_set_ops - nf_tables set operations
207 * 223 *
208 * @lookup: look up an element within the set 224 * @lookup: look up an element within the set
209 * @insert: insert new element into set 225 * @insert: insert new element into set
226 * @activate: activate new element in the next generation
227 * @deactivate: deactivate element in the next generation
210 * @remove: remove element from set 228 * @remove: remove element from set
211 * @walk: iterate over all set elemeennts 229 * @walk: iterate over all set elemeennts
212 * @privsize: function to return size of set private data 230 * @privsize: function to return size of set private data
@@ -214,16 +232,28 @@ struct nft_set_estimate {
214 * @destroy: destroy private data of set instance 232 * @destroy: destroy private data of set instance
215 * @list: nf_tables_set_ops list node 233 * @list: nf_tables_set_ops list node
216 * @owner: module reference 234 * @owner: module reference
235 * @elemsize: element private size
217 * @features: features supported by the implementation 236 * @features: features supported by the implementation
218 */ 237 */
219struct nft_set_ops { 238struct nft_set_ops {
220 bool (*lookup)(const struct nft_set *set, 239 bool (*lookup)(const struct nft_set *set,
221 const struct nft_data *key, 240 const u32 *key,
222 struct nft_data *data); 241 const struct nft_set_ext **ext);
223 int (*get)(const struct nft_set *set, 242 bool (*update)(struct nft_set *set,
224 struct nft_set_elem *elem); 243 const u32 *key,
244 void *(*new)(struct nft_set *,
245 const struct nft_expr *,
246 struct nft_regs *),
247 const struct nft_expr *expr,
248 struct nft_regs *regs,
249 const struct nft_set_ext **ext);
250
225 int (*insert)(const struct nft_set *set, 251 int (*insert)(const struct nft_set *set,
226 const struct nft_set_elem *elem); 252 const struct nft_set_elem *elem);
253 void (*activate)(const struct nft_set *set,
254 const struct nft_set_elem *elem);
255 void * (*deactivate)(const struct nft_set *set,
256 const struct nft_set_elem *elem);
227 void (*remove)(const struct nft_set *set, 257 void (*remove)(const struct nft_set *set,
228 const struct nft_set_elem *elem); 258 const struct nft_set_elem *elem);
229 void (*walk)(const struct nft_ctx *ctx, 259 void (*walk)(const struct nft_ctx *ctx,
@@ -241,6 +271,7 @@ struct nft_set_ops {
241 271
242 struct list_head list; 272 struct list_head list;
243 struct module *owner; 273 struct module *owner;
274 unsigned int elemsize;
244 u32 features; 275 u32 features;
245}; 276};
246 277
@@ -257,8 +288,12 @@ void nft_unregister_set(struct nft_set_ops *ops);
257 * @dtype: data type (verdict or numeric type defined by userspace) 288 * @dtype: data type (verdict or numeric type defined by userspace)
258 * @size: maximum set size 289 * @size: maximum set size
259 * @nelems: number of elements 290 * @nelems: number of elements
291 * @ndeact: number of deactivated elements queued for removal
292 * @timeout: default timeout value in msecs
293 * @gc_int: garbage collection interval in msecs
260 * @policy: set parameterization (see enum nft_set_policies) 294 * @policy: set parameterization (see enum nft_set_policies)
261 * @ops: set ops 295 * @ops: set ops
296 * @pnet: network namespace
262 * @flags: set flags 297 * @flags: set flags
263 * @klen: key length 298 * @klen: key length
264 * @dlen: data length 299 * @dlen: data length
@@ -271,10 +306,14 @@ struct nft_set {
271 u32 ktype; 306 u32 ktype;
272 u32 dtype; 307 u32 dtype;
273 u32 size; 308 u32 size;
274 u32 nelems; 309 atomic_t nelems;
310 u32 ndeact;
311 u64 timeout;
312 u32 gc_int;
275 u16 policy; 313 u16 policy;
276 /* runtime data below here */ 314 /* runtime data below here */
277 const struct nft_set_ops *ops ____cacheline_aligned; 315 const struct nft_set_ops *ops ____cacheline_aligned;
316 possible_net_t pnet;
278 u16 flags; 317 u16 flags;
279 u8 klen; 318 u8 klen;
280 u8 dlen; 319 u8 dlen;
@@ -287,16 +326,27 @@ static inline void *nft_set_priv(const struct nft_set *set)
287 return (void *)set->data; 326 return (void *)set->data;
288} 327}
289 328
329static inline struct nft_set *nft_set_container_of(const void *priv)
330{
331 return (void *)priv - offsetof(struct nft_set, data);
332}
333
290struct nft_set *nf_tables_set_lookup(const struct nft_table *table, 334struct nft_set *nf_tables_set_lookup(const struct nft_table *table,
291 const struct nlattr *nla); 335 const struct nlattr *nla);
292struct nft_set *nf_tables_set_lookup_byid(const struct net *net, 336struct nft_set *nf_tables_set_lookup_byid(const struct net *net,
293 const struct nlattr *nla); 337 const struct nlattr *nla);
294 338
339static inline unsigned long nft_set_gc_interval(const struct nft_set *set)
340{
341 return set->gc_int ? msecs_to_jiffies(set->gc_int) : HZ;
342}
343
295/** 344/**
296 * struct nft_set_binding - nf_tables set binding 345 * struct nft_set_binding - nf_tables set binding
297 * 346 *
298 * @list: set bindings list node 347 * @list: set bindings list node
299 * @chain: chain containing the rule bound to the set 348 * @chain: chain containing the rule bound to the set
349 * @flags: set action flags
300 * 350 *
301 * A set binding contains all information necessary for validation 351 * A set binding contains all information necessary for validation
302 * of new elements added to a bound set. 352 * of new elements added to a bound set.
@@ -304,6 +354,7 @@ struct nft_set *nf_tables_set_lookup_byid(const struct net *net,
304struct nft_set_binding { 354struct nft_set_binding {
305 struct list_head list; 355 struct list_head list;
306 const struct nft_chain *chain; 356 const struct nft_chain *chain;
357 u32 flags;
307}; 358};
308 359
309int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, 360int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,
@@ -311,6 +362,215 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,
311void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set, 362void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set,
312 struct nft_set_binding *binding); 363 struct nft_set_binding *binding);
313 364
365/**
366 * enum nft_set_extensions - set extension type IDs
367 *
368 * @NFT_SET_EXT_KEY: element key
369 * @NFT_SET_EXT_DATA: mapping data
370 * @NFT_SET_EXT_FLAGS: element flags
371 * @NFT_SET_EXT_TIMEOUT: element timeout
372 * @NFT_SET_EXT_EXPIRATION: element expiration time
373 * @NFT_SET_EXT_USERDATA: user data associated with the element
374 * @NFT_SET_EXT_EXPR: expression assiociated with the element
375 * @NFT_SET_EXT_NUM: number of extension types
376 */
377enum nft_set_extensions {
378 NFT_SET_EXT_KEY,
379 NFT_SET_EXT_DATA,
380 NFT_SET_EXT_FLAGS,
381 NFT_SET_EXT_TIMEOUT,
382 NFT_SET_EXT_EXPIRATION,
383 NFT_SET_EXT_USERDATA,
384 NFT_SET_EXT_EXPR,
385 NFT_SET_EXT_NUM
386};
387
388/**
389 * struct nft_set_ext_type - set extension type
390 *
391 * @len: fixed part length of the extension
392 * @align: alignment requirements of the extension
393 */
394struct nft_set_ext_type {
395 u8 len;
396 u8 align;
397};
398
399extern const struct nft_set_ext_type nft_set_ext_types[];
400
401/**
402 * struct nft_set_ext_tmpl - set extension template
403 *
404 * @len: length of extension area
405 * @offset: offsets of individual extension types
406 */
407struct nft_set_ext_tmpl {
408 u16 len;
409 u8 offset[NFT_SET_EXT_NUM];
410};
411
412/**
413 * struct nft_set_ext - set extensions
414 *
415 * @genmask: generation mask
416 * @offset: offsets of individual extension types
417 * @data: beginning of extension data
418 */
419struct nft_set_ext {
420 u8 genmask;
421 u8 offset[NFT_SET_EXT_NUM];
422 char data[0];
423};
424
425static inline void nft_set_ext_prepare(struct nft_set_ext_tmpl *tmpl)
426{
427 memset(tmpl, 0, sizeof(*tmpl));
428 tmpl->len = sizeof(struct nft_set_ext);
429}
430
431static inline void nft_set_ext_add_length(struct nft_set_ext_tmpl *tmpl, u8 id,
432 unsigned int len)
433{
434 tmpl->len = ALIGN(tmpl->len, nft_set_ext_types[id].align);
435 BUG_ON(tmpl->len > U8_MAX);
436 tmpl->offset[id] = tmpl->len;
437 tmpl->len += nft_set_ext_types[id].len + len;
438}
439
440static inline void nft_set_ext_add(struct nft_set_ext_tmpl *tmpl, u8 id)
441{
442 nft_set_ext_add_length(tmpl, id, 0);
443}
444
445static inline void nft_set_ext_init(struct nft_set_ext *ext,
446 const struct nft_set_ext_tmpl *tmpl)
447{
448 memcpy(ext->offset, tmpl->offset, sizeof(ext->offset));
449}
450
451static inline bool __nft_set_ext_exists(const struct nft_set_ext *ext, u8 id)
452{
453 return !!ext->offset[id];
454}
455
456static inline bool nft_set_ext_exists(const struct nft_set_ext *ext, u8 id)
457{
458 return ext && __nft_set_ext_exists(ext, id);
459}
460
461static inline void *nft_set_ext(const struct nft_set_ext *ext, u8 id)
462{
463 return (void *)ext + ext->offset[id];
464}
465
466static inline struct nft_data *nft_set_ext_key(const struct nft_set_ext *ext)
467{
468 return nft_set_ext(ext, NFT_SET_EXT_KEY);
469}
470
471static inline struct nft_data *nft_set_ext_data(const struct nft_set_ext *ext)
472{
473 return nft_set_ext(ext, NFT_SET_EXT_DATA);
474}
475
476static inline u8 *nft_set_ext_flags(const struct nft_set_ext *ext)
477{
478 return nft_set_ext(ext, NFT_SET_EXT_FLAGS);
479}
480
481static inline u64 *nft_set_ext_timeout(const struct nft_set_ext *ext)
482{
483 return nft_set_ext(ext, NFT_SET_EXT_TIMEOUT);
484}
485
486static inline unsigned long *nft_set_ext_expiration(const struct nft_set_ext *ext)
487{
488 return nft_set_ext(ext, NFT_SET_EXT_EXPIRATION);
489}
490
491static inline struct nft_userdata *nft_set_ext_userdata(const struct nft_set_ext *ext)
492{
493 return nft_set_ext(ext, NFT_SET_EXT_USERDATA);
494}
495
496static inline struct nft_expr *nft_set_ext_expr(const struct nft_set_ext *ext)
497{
498 return nft_set_ext(ext, NFT_SET_EXT_EXPR);
499}
500
501static inline bool nft_set_elem_expired(const struct nft_set_ext *ext)
502{
503 return nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION) &&
504 time_is_before_eq_jiffies(*nft_set_ext_expiration(ext));
505}
506
507static inline struct nft_set_ext *nft_set_elem_ext(const struct nft_set *set,
508 void *elem)
509{
510 return elem + set->ops->elemsize;
511}
512
513void *nft_set_elem_init(const struct nft_set *set,
514 const struct nft_set_ext_tmpl *tmpl,
515 const u32 *key, const u32 *data,
516 u64 timeout, gfp_t gfp);
517void nft_set_elem_destroy(const struct nft_set *set, void *elem);
518
519/**
520 * struct nft_set_gc_batch_head - nf_tables set garbage collection batch
521 *
522 * @rcu: rcu head
523 * @set: set the elements belong to
524 * @cnt: count of elements
525 */
526struct nft_set_gc_batch_head {
527 struct rcu_head rcu;
528 const struct nft_set *set;
529 unsigned int cnt;
530};
531
532#define NFT_SET_GC_BATCH_SIZE ((PAGE_SIZE - \
533 sizeof(struct nft_set_gc_batch_head)) / \
534 sizeof(void *))
535
536/**
537 * struct nft_set_gc_batch - nf_tables set garbage collection batch
538 *
539 * @head: GC batch head
540 * @elems: garbage collection elements
541 */
542struct nft_set_gc_batch {
543 struct nft_set_gc_batch_head head;
544 void *elems[NFT_SET_GC_BATCH_SIZE];
545};
546
547struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set,
548 gfp_t gfp);
549void nft_set_gc_batch_release(struct rcu_head *rcu);
550
551static inline void nft_set_gc_batch_complete(struct nft_set_gc_batch *gcb)
552{
553 if (gcb != NULL)
554 call_rcu(&gcb->head.rcu, nft_set_gc_batch_release);
555}
556
557static inline struct nft_set_gc_batch *
558nft_set_gc_batch_check(const struct nft_set *set, struct nft_set_gc_batch *gcb,
559 gfp_t gfp)
560{
561 if (gcb != NULL) {
562 if (gcb->head.cnt + 1 < ARRAY_SIZE(gcb->elems))
563 return gcb;
564 nft_set_gc_batch_complete(gcb);
565 }
566 return nft_set_gc_batch_alloc(set, gfp);
567}
568
569static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb,
570 void *elem)
571{
572 gcb->elems[gcb->head.cnt++] = elem;
573}
314 574
315/** 575/**
316 * struct nft_expr_type - nf_tables expression type 576 * struct nft_expr_type - nf_tables expression type
@@ -323,6 +583,7 @@ void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set,
323 * @policy: netlink attribute policy 583 * @policy: netlink attribute policy
324 * @maxattr: highest netlink attribute number 584 * @maxattr: highest netlink attribute number
325 * @family: address family for AF-specific types 585 * @family: address family for AF-specific types
586 * @flags: expression type flags
326 */ 587 */
327struct nft_expr_type { 588struct nft_expr_type {
328 const struct nft_expr_ops *(*select_ops)(const struct nft_ctx *, 589 const struct nft_expr_ops *(*select_ops)(const struct nft_ctx *,
@@ -334,8 +595,11 @@ struct nft_expr_type {
334 const struct nla_policy *policy; 595 const struct nla_policy *policy;
335 unsigned int maxattr; 596 unsigned int maxattr;
336 u8 family; 597 u8 family;
598 u8 flags;
337}; 599};
338 600
601#define NFT_EXPR_STATEFUL 0x1
602
339/** 603/**
340 * struct nft_expr_ops - nf_tables expression operations 604 * struct nft_expr_ops - nf_tables expression operations
341 * 605 *
@@ -351,7 +615,7 @@ struct nft_expr_type {
351struct nft_expr; 615struct nft_expr;
352struct nft_expr_ops { 616struct nft_expr_ops {
353 void (*eval)(const struct nft_expr *expr, 617 void (*eval)(const struct nft_expr *expr,
354 struct nft_data data[NFT_REG_MAX + 1], 618 struct nft_regs *regs,
355 const struct nft_pktinfo *pkt); 619 const struct nft_pktinfo *pkt);
356 unsigned int size; 620 unsigned int size;
357 621
@@ -389,6 +653,18 @@ static inline void *nft_expr_priv(const struct nft_expr *expr)
389 return (void *)expr->data; 653 return (void *)expr->data;
390} 654}
391 655
656struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
657 const struct nlattr *nla);
658void nft_expr_destroy(const struct nft_ctx *ctx, struct nft_expr *expr);
659int nft_expr_dump(struct sk_buff *skb, unsigned int attr,
660 const struct nft_expr *expr);
661
662static inline void nft_expr_clone(struct nft_expr *dst, struct nft_expr *src)
663{
664 __module_get(src->ops->type->owner);
665 memcpy(dst, src, src->ops->size);
666}
667
392/** 668/**
393 * struct nft_rule - nf_tables rule 669 * struct nft_rule - nf_tables rule
394 * 670 *
@@ -409,74 +685,6 @@ struct nft_rule {
409 __attribute__((aligned(__alignof__(struct nft_expr)))); 685 __attribute__((aligned(__alignof__(struct nft_expr))));
410}; 686};
411 687
412/**
413 * struct nft_trans - nf_tables object update in transaction
414 *
415 * @list: used internally
416 * @msg_type: message type
417 * @ctx: transaction context
418 * @data: internal information related to the transaction
419 */
420struct nft_trans {
421 struct list_head list;
422 int msg_type;
423 struct nft_ctx ctx;
424 char data[0];
425};
426
427struct nft_trans_rule {
428 struct nft_rule *rule;
429};
430
431#define nft_trans_rule(trans) \
432 (((struct nft_trans_rule *)trans->data)->rule)
433
434struct nft_trans_set {
435 struct nft_set *set;
436 u32 set_id;
437};
438
439#define nft_trans_set(trans) \
440 (((struct nft_trans_set *)trans->data)->set)
441#define nft_trans_set_id(trans) \
442 (((struct nft_trans_set *)trans->data)->set_id)
443
444struct nft_trans_chain {
445 bool update;
446 char name[NFT_CHAIN_MAXNAMELEN];
447 struct nft_stats __percpu *stats;
448 u8 policy;
449};
450
451#define nft_trans_chain_update(trans) \
452 (((struct nft_trans_chain *)trans->data)->update)
453#define nft_trans_chain_name(trans) \
454 (((struct nft_trans_chain *)trans->data)->name)
455#define nft_trans_chain_stats(trans) \
456 (((struct nft_trans_chain *)trans->data)->stats)
457#define nft_trans_chain_policy(trans) \
458 (((struct nft_trans_chain *)trans->data)->policy)
459
460struct nft_trans_table {
461 bool update;
462 bool enable;
463};
464
465#define nft_trans_table_update(trans) \
466 (((struct nft_trans_table *)trans->data)->update)
467#define nft_trans_table_enable(trans) \
468 (((struct nft_trans_table *)trans->data)->enable)
469
470struct nft_trans_elem {
471 struct nft_set *set;
472 struct nft_set_elem elem;
473};
474
475#define nft_trans_elem_set(trans) \
476 (((struct nft_trans_elem *)trans->data)->set)
477#define nft_trans_elem(trans) \
478 (((struct nft_trans_elem *)trans->data)->elem)
479
480static inline struct nft_expr *nft_expr_first(const struct nft_rule *rule) 688static inline struct nft_expr *nft_expr_first(const struct nft_rule *rule)
481{ 689{
482 return (struct nft_expr *)&rule->data[0]; 690 return (struct nft_expr *)&rule->data[0];
@@ -517,7 +725,6 @@ enum nft_chain_flags {
517 * 725 *
518 * @rules: list of rules in the chain 726 * @rules: list of rules in the chain
519 * @list: used internally 727 * @list: used internally
520 * @net: net namespace that this chain belongs to
521 * @table: table that this chain belongs to 728 * @table: table that this chain belongs to
522 * @handle: chain handle 729 * @handle: chain handle
523 * @use: number of jump references to this chain 730 * @use: number of jump references to this chain
@@ -528,7 +735,6 @@ enum nft_chain_flags {
528struct nft_chain { 735struct nft_chain {
529 struct list_head rules; 736 struct list_head rules;
530 struct list_head list; 737 struct list_head list;
531 struct net *net;
532 struct nft_table *table; 738 struct nft_table *table;
533 u64 handle; 739 u64 handle;
534 u32 use; 740 u32 use;
@@ -544,6 +750,25 @@ enum nft_chain_type {
544 NFT_CHAIN_T_MAX 750 NFT_CHAIN_T_MAX
545}; 751};
546 752
753/**
754 * struct nf_chain_type - nf_tables chain type info
755 *
756 * @name: name of the type
757 * @type: numeric identifier
758 * @family: address family
759 * @owner: module owner
760 * @hook_mask: mask of valid hooks
761 * @hooks: hookfn overrides
762 */
763struct nf_chain_type {
764 const char *name;
765 enum nft_chain_type type;
766 int family;
767 struct module *owner;
768 unsigned int hook_mask;
769 nf_hookfn *hooks[NF_MAX_HOOKS];
770};
771
547int nft_chain_validate_dependency(const struct nft_chain *chain, 772int nft_chain_validate_dependency(const struct nft_chain *chain,
548 enum nft_chain_type type); 773 enum nft_chain_type type);
549int nft_chain_validate_hooks(const struct nft_chain *chain, 774int nft_chain_validate_hooks(const struct nft_chain *chain,
@@ -561,6 +786,7 @@ struct nft_stats {
561 * struct nft_base_chain - nf_tables base chain 786 * struct nft_base_chain - nf_tables base chain
562 * 787 *
563 * @ops: netfilter hook ops 788 * @ops: netfilter hook ops
789 * @pnet: net namespace that this chain belongs to
564 * @type: chain type 790 * @type: chain type
565 * @policy: default policy 791 * @policy: default policy
566 * @stats: per-cpu chain stats 792 * @stats: per-cpu chain stats
@@ -568,6 +794,7 @@ struct nft_stats {
568 */ 794 */
569struct nft_base_chain { 795struct nft_base_chain {
570 struct nf_hook_ops ops[NFT_HOOK_OPS_MAX]; 796 struct nf_hook_ops ops[NFT_HOOK_OPS_MAX];
797 possible_net_t pnet;
571 const struct nf_chain_type *type; 798 const struct nf_chain_type *type;
572 u8 policy; 799 u8 policy;
573 struct nft_stats __percpu *stats; 800 struct nft_stats __percpu *stats;
@@ -600,7 +827,7 @@ struct nft_table {
600 u64 hgenerator; 827 u64 hgenerator;
601 u32 use; 828 u32 use;
602 u16 flags; 829 u16 flags;
603 char name[]; 830 char name[NFT_TABLE_MAXNAMELEN];
604}; 831};
605 832
606/** 833/**
@@ -630,25 +857,6 @@ struct nft_af_info {
630int nft_register_afinfo(struct net *, struct nft_af_info *); 857int nft_register_afinfo(struct net *, struct nft_af_info *);
631void nft_unregister_afinfo(struct nft_af_info *); 858void nft_unregister_afinfo(struct nft_af_info *);
632 859
633/**
634 * struct nf_chain_type - nf_tables chain type info
635 *
636 * @name: name of the type
637 * @type: numeric identifier
638 * @family: address family
639 * @owner: module owner
640 * @hook_mask: mask of valid hooks
641 * @hooks: hookfn overrides
642 */
643struct nf_chain_type {
644 const char *name;
645 enum nft_chain_type type;
646 int family;
647 struct module *owner;
648 unsigned int hook_mask;
649 nf_hookfn *hooks[NF_MAX_HOOKS];
650};
651
652int nft_register_chain_type(const struct nf_chain_type *); 860int nft_register_chain_type(const struct nf_chain_type *);
653void nft_unregister_chain_type(const struct nf_chain_type *); 861void nft_unregister_chain_type(const struct nf_chain_type *);
654 862
@@ -673,4 +881,153 @@ void nft_unregister_expr(struct nft_expr_type *);
673#define MODULE_ALIAS_NFT_SET() \ 881#define MODULE_ALIAS_NFT_SET() \
674 MODULE_ALIAS("nft-set") 882 MODULE_ALIAS("nft-set")
675 883
884/*
885 * The gencursor defines two generations, the currently active and the
886 * next one. Objects contain a bitmask of 2 bits specifying the generations
887 * they're active in. A set bit means they're inactive in the generation
888 * represented by that bit.
889 *
890 * New objects start out as inactive in the current and active in the
891 * next generation. When committing the ruleset the bitmask is cleared,
892 * meaning they're active in all generations. When removing an object,
893 * it is set inactive in the next generation. After committing the ruleset,
894 * the objects are removed.
895 */
896static inline unsigned int nft_gencursor_next(const struct net *net)
897{
898 return net->nft.gencursor + 1 == 1 ? 1 : 0;
899}
900
901static inline u8 nft_genmask_next(const struct net *net)
902{
903 return 1 << nft_gencursor_next(net);
904}
905
906static inline u8 nft_genmask_cur(const struct net *net)
907{
908 /* Use ACCESS_ONCE() to prevent refetching the value for atomicity */
909 return 1 << ACCESS_ONCE(net->nft.gencursor);
910}
911
912#define NFT_GENMASK_ANY ((1 << 0) | (1 << 1))
913
914/*
915 * Set element transaction helpers
916 */
917
918static inline bool nft_set_elem_active(const struct nft_set_ext *ext,
919 u8 genmask)
920{
921 return !(ext->genmask & genmask);
922}
923
924static inline void nft_set_elem_change_active(const struct nft_set *set,
925 struct nft_set_ext *ext)
926{
927 ext->genmask ^= nft_genmask_next(read_pnet(&set->pnet));
928}
929
930/*
931 * We use a free bit in the genmask field to indicate the element
932 * is busy, meaning it is currently being processed either by
933 * the netlink API or GC.
934 *
935 * Even though the genmask is only a single byte wide, this works
936 * because the extension structure if fully constant once initialized,
937 * so there are no non-atomic write accesses unless it is already
938 * marked busy.
939 */
940#define NFT_SET_ELEM_BUSY_MASK (1 << 2)
941
942#if defined(__LITTLE_ENDIAN_BITFIELD)
943#define NFT_SET_ELEM_BUSY_BIT 2
944#elif defined(__BIG_ENDIAN_BITFIELD)
945#define NFT_SET_ELEM_BUSY_BIT (BITS_PER_LONG - BITS_PER_BYTE + 2)
946#else
947#error
948#endif
949
950static inline int nft_set_elem_mark_busy(struct nft_set_ext *ext)
951{
952 unsigned long *word = (unsigned long *)ext;
953
954 BUILD_BUG_ON(offsetof(struct nft_set_ext, genmask) != 0);
955 return test_and_set_bit(NFT_SET_ELEM_BUSY_BIT, word);
956}
957
958static inline void nft_set_elem_clear_busy(struct nft_set_ext *ext)
959{
960 unsigned long *word = (unsigned long *)ext;
961
962 clear_bit(NFT_SET_ELEM_BUSY_BIT, word);
963}
964
965/**
966 * struct nft_trans - nf_tables object update in transaction
967 *
968 * @list: used internally
969 * @msg_type: message type
970 * @ctx: transaction context
971 * @data: internal information related to the transaction
972 */
973struct nft_trans {
974 struct list_head list;
975 int msg_type;
976 struct nft_ctx ctx;
977 char data[0];
978};
979
980struct nft_trans_rule {
981 struct nft_rule *rule;
982};
983
984#define nft_trans_rule(trans) \
985 (((struct nft_trans_rule *)trans->data)->rule)
986
987struct nft_trans_set {
988 struct nft_set *set;
989 u32 set_id;
990};
991
992#define nft_trans_set(trans) \
993 (((struct nft_trans_set *)trans->data)->set)
994#define nft_trans_set_id(trans) \
995 (((struct nft_trans_set *)trans->data)->set_id)
996
997struct nft_trans_chain {
998 bool update;
999 char name[NFT_CHAIN_MAXNAMELEN];
1000 struct nft_stats __percpu *stats;
1001 u8 policy;
1002};
1003
1004#define nft_trans_chain_update(trans) \
1005 (((struct nft_trans_chain *)trans->data)->update)
1006#define nft_trans_chain_name(trans) \
1007 (((struct nft_trans_chain *)trans->data)->name)
1008#define nft_trans_chain_stats(trans) \
1009 (((struct nft_trans_chain *)trans->data)->stats)
1010#define nft_trans_chain_policy(trans) \
1011 (((struct nft_trans_chain *)trans->data)->policy)
1012
1013struct nft_trans_table {
1014 bool update;
1015 bool enable;
1016};
1017
1018#define nft_trans_table_update(trans) \
1019 (((struct nft_trans_table *)trans->data)->update)
1020#define nft_trans_table_enable(trans) \
1021 (((struct nft_trans_table *)trans->data)->enable)
1022
1023struct nft_trans_elem {
1024 struct nft_set *set;
1025 struct nft_set_elem elem;
1026};
1027
1028#define nft_trans_elem_set(trans) \
1029 (((struct nft_trans_elem *)trans->data)->set)
1030#define nft_trans_elem(trans) \
1031 (((struct nft_trans_elem *)trans->data)->elem)
1032
676#endif /* _NET_NF_TABLES_H */ 1033#endif /* _NET_NF_TABLES_H */
diff --git a/include/net/netfilter/nf_tables_core.h b/include/net/netfilter/nf_tables_core.h
index a75fc8e27cd6..c6f400cfaac8 100644
--- a/include/net/netfilter/nf_tables_core.h
+++ b/include/net/netfilter/nf_tables_core.h
@@ -31,6 +31,9 @@ void nft_cmp_module_exit(void);
31int nft_lookup_module_init(void); 31int nft_lookup_module_init(void);
32void nft_lookup_module_exit(void); 32void nft_lookup_module_exit(void);
33 33
34int nft_dynset_module_init(void);
35void nft_dynset_module_exit(void);
36
34int nft_bitwise_module_init(void); 37int nft_bitwise_module_init(void);
35void nft_bitwise_module_exit(void); 38void nft_bitwise_module_exit(void);
36 39
diff --git a/include/net/netfilter/nf_tables_ipv4.h b/include/net/netfilter/nf_tables_ipv4.h
index cba143fbd2e4..2df7f96902ee 100644
--- a/include/net/netfilter/nf_tables_ipv4.h
+++ b/include/net/netfilter/nf_tables_ipv4.h
@@ -8,12 +8,11 @@ static inline void
8nft_set_pktinfo_ipv4(struct nft_pktinfo *pkt, 8nft_set_pktinfo_ipv4(struct nft_pktinfo *pkt,
9 const struct nf_hook_ops *ops, 9 const struct nf_hook_ops *ops,
10 struct sk_buff *skb, 10 struct sk_buff *skb,
11 const struct net_device *in, 11 const struct nf_hook_state *state)
12 const struct net_device *out)
13{ 12{
14 struct iphdr *ip; 13 struct iphdr *ip;
15 14
16 nft_set_pktinfo(pkt, ops, skb, in, out); 15 nft_set_pktinfo(pkt, ops, skb, state);
17 16
18 ip = ip_hdr(pkt->skb); 17 ip = ip_hdr(pkt->skb);
19 pkt->tprot = ip->protocol; 18 pkt->tprot = ip->protocol;
diff --git a/include/net/netfilter/nf_tables_ipv6.h b/include/net/netfilter/nf_tables_ipv6.h
index 74d976137658..97db2e3a5e65 100644
--- a/include/net/netfilter/nf_tables_ipv6.h
+++ b/include/net/netfilter/nf_tables_ipv6.h
@@ -8,13 +8,12 @@ static inline int
8nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt, 8nft_set_pktinfo_ipv6(struct nft_pktinfo *pkt,
9 const struct nf_hook_ops *ops, 9 const struct nf_hook_ops *ops,
10 struct sk_buff *skb, 10 struct sk_buff *skb,
11 const struct net_device *in, 11 const struct nf_hook_state *state)
12 const struct net_device *out)
13{ 12{
14 int protohdr, thoff = 0; 13 int protohdr, thoff = 0;
15 unsigned short frag_off; 14 unsigned short frag_off;
16 15
17 nft_set_pktinfo(pkt, ops, skb, in, out); 16 nft_set_pktinfo(pkt, ops, skb, state);
18 17
19 protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL); 18 protohdr = ipv6_find_hdr(pkt->skb, &thoff, -1, &frag_off, NULL);
20 /* If malformed, drop it */ 19 /* If malformed, drop it */
diff --git a/include/net/netfilter/nft_meta.h b/include/net/netfilter/nft_meta.h
index 0ee47c3e2e31..711887a09e91 100644
--- a/include/net/netfilter/nft_meta.h
+++ b/include/net/netfilter/nft_meta.h
@@ -26,11 +26,11 @@ int nft_meta_set_dump(struct sk_buff *skb,
26 const struct nft_expr *expr); 26 const struct nft_expr *expr);
27 27
28void nft_meta_get_eval(const struct nft_expr *expr, 28void nft_meta_get_eval(const struct nft_expr *expr,
29 struct nft_data data[NFT_REG_MAX + 1], 29 struct nft_regs *regs,
30 const struct nft_pktinfo *pkt); 30 const struct nft_pktinfo *pkt);
31 31
32void nft_meta_set_eval(const struct nft_expr *expr, 32void nft_meta_set_eval(const struct nft_expr *expr,
33 struct nft_data data[NFT_REG_MAX + 1], 33 struct nft_regs *regs,
34 const struct nft_pktinfo *pkt); 34 const struct nft_pktinfo *pkt);
35 35
36#endif 36#endif
diff --git a/include/net/netlink.h b/include/net/netlink.h
index e010ee8da41d..2a5dbcc90d1c 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -4,6 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/netlink.h> 5#include <linux/netlink.h>
6#include <linux/jiffies.h> 6#include <linux/jiffies.h>
7#include <linux/in6.h>
7 8
8/* ======================================================================== 9/* ========================================================================
9 * Netlink Messages and Attributes Interface (As Seen On TV) 10 * Netlink Messages and Attributes Interface (As Seen On TV)
@@ -105,6 +106,8 @@
105 * nla_put_string(skb, type, str) add string attribute to skb 106 * nla_put_string(skb, type, str) add string attribute to skb
106 * nla_put_flag(skb, type) add flag attribute to skb 107 * nla_put_flag(skb, type) add flag attribute to skb
107 * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb 108 * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb
109 * nla_put_in_addr(skb, type, addr) add IPv4 address attribute to skb
110 * nla_put_in6_addr(skb, type, addr) add IPv6 address attribute to skb
108 * 111 *
109 * Nested Attributes Construction: 112 * Nested Attributes Construction:
110 * nla_nest_start(skb, type) start a nested attribute 113 * nla_nest_start(skb, type) start a nested attribute
@@ -957,6 +960,32 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
957} 960}
958 961
959/** 962/**
963 * nla_put_in_addr - Add an IPv4 address netlink attribute to a socket
964 * buffer
965 * @skb: socket buffer to add attribute to
966 * @attrtype: attribute type
967 * @addr: IPv4 address
968 */
969static inline int nla_put_in_addr(struct sk_buff *skb, int attrtype,
970 __be32 addr)
971{
972 return nla_put_be32(skb, attrtype, addr);
973}
974
975/**
976 * nla_put_in6_addr - Add an IPv6 address netlink attribute to a socket
977 * buffer
978 * @skb: socket buffer to add attribute to
979 * @attrtype: attribute type
980 * @addr: IPv6 address
981 */
982static inline int nla_put_in6_addr(struct sk_buff *skb, int attrtype,
983 const struct in6_addr *addr)
984{
985 return nla_put(skb, attrtype, sizeof(*addr), addr);
986}
987
988/**
960 * nla_get_u32 - return payload of u32 attribute 989 * nla_get_u32 - return payload of u32 attribute
961 * @nla: u32 netlink attribute 990 * @nla: u32 netlink attribute
962 */ 991 */
@@ -1099,6 +1128,27 @@ static inline unsigned long nla_get_msecs(const struct nlattr *nla)
1099} 1128}
1100 1129
1101/** 1130/**
1131 * nla_get_in_addr - return payload of IPv4 address attribute
1132 * @nla: IPv4 address netlink attribute
1133 */
1134static inline __be32 nla_get_in_addr(const struct nlattr *nla)
1135{
1136 return *(__be32 *) nla_data(nla);
1137}
1138
1139/**
1140 * nla_get_in6_addr - return payload of IPv6 address attribute
1141 * @nla: IPv6 address netlink attribute
1142 */
1143static inline struct in6_addr nla_get_in6_addr(const struct nlattr *nla)
1144{
1145 struct in6_addr tmp;
1146
1147 nla_memcpy(&tmp, nla, sizeof(tmp));
1148 return tmp;
1149}
1150
1151/**
1102 * nla_nest_start - Start a new level of nested attributes 1152 * nla_nest_start - Start a new level of nested attributes
1103 * @skb: socket buffer to add attributes to 1153 * @skb: socket buffer to add attributes to
1104 * @attrtype: attribute type of container 1154 * @attrtype: attribute type of container
diff --git a/include/net/netns/hash.h b/include/net/netns/hash.h
index c06ac58ca107..69a6715d9f3f 100644
--- a/include/net/netns/hash.h
+++ b/include/net/netns/hash.h
@@ -5,7 +5,7 @@
5 5
6struct net; 6struct net;
7 7
8static inline unsigned int net_hash_mix(struct net *net) 8static inline u32 net_hash_mix(const struct net *net)
9{ 9{
10#ifdef CONFIG_NET_NS 10#ifdef CONFIG_NET_NS
11 /* 11 /*
@@ -13,7 +13,7 @@ static inline unsigned int net_hash_mix(struct net *net)
13 * always zeroed 13 * always zeroed
14 */ 14 */
15 15
16 return (unsigned)(((unsigned long)net) >> L1_CACHE_SHIFT); 16 return (u32)(((unsigned long)net) >> L1_CACHE_SHIFT);
17#else 17#else
18 return 0; 18 return 0;
19#endif 19#endif
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index dbe225478adb..614a49be68a9 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -7,6 +7,7 @@
7 7
8#include <linux/uidgid.h> 8#include <linux/uidgid.h>
9#include <net/inet_frag.h> 9#include <net/inet_frag.h>
10#include <linux/rcupdate.h>
10 11
11struct tcpm_hash_bucket; 12struct tcpm_hash_bucket;
12struct ctl_table_header; 13struct ctl_table_header;
@@ -38,21 +39,21 @@ struct netns_ipv4 {
38#ifdef CONFIG_IP_MULTIPLE_TABLES 39#ifdef CONFIG_IP_MULTIPLE_TABLES
39 struct fib_rules_ops *rules_ops; 40 struct fib_rules_ops *rules_ops;
40 bool fib_has_custom_rules; 41 bool fib_has_custom_rules;
41 struct fib_table *fib_local; 42 struct fib_table __rcu *fib_local;
42 struct fib_table *fib_main; 43 struct fib_table __rcu *fib_main;
43 struct fib_table *fib_default; 44 struct fib_table __rcu *fib_default;
44#endif 45#endif
45#ifdef CONFIG_IP_ROUTE_CLASSID 46#ifdef CONFIG_IP_ROUTE_CLASSID
46 int fib_num_tclassid_users; 47 int fib_num_tclassid_users;
47#endif 48#endif
48 struct hlist_head *fib_table_hash; 49 struct hlist_head *fib_table_hash;
50 bool fib_offload_disabled;
49 struct sock *fibnl; 51 struct sock *fibnl;
50 52
51 struct sock * __percpu *icmp_sk; 53 struct sock * __percpu *icmp_sk;
54 struct sock *mc_autojoin_sk;
52 55
53 struct inet_peer_base *peers; 56 struct inet_peer_base *peers;
54 struct tcpm_hash_bucket *tcp_metrics_hash;
55 unsigned int tcp_metrics_hash_log;
56 struct sock * __percpu *tcp_sk; 57 struct sock * __percpu *tcp_sk;
57 struct netns_frags frags; 58 struct netns_frags frags;
58#ifdef CONFIG_NETFILTER 59#ifdef CONFIG_NETFILTER
@@ -84,6 +85,8 @@ struct netns_ipv4 {
84 int sysctl_tcp_fwmark_accept; 85 int sysctl_tcp_fwmark_accept;
85 int sysctl_tcp_mtu_probing; 86 int sysctl_tcp_mtu_probing;
86 int sysctl_tcp_base_mss; 87 int sysctl_tcp_base_mss;
88 int sysctl_tcp_probe_threshold;
89 u32 sysctl_tcp_probe_interval;
87 90
88 struct ping_group_range ping_group_range; 91 struct ping_group_range ping_group_range;
89 92
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index 69ae41f2098c..d2527bf81142 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -32,6 +32,8 @@ struct netns_sysctl_ipv6 {
32 int icmpv6_time; 32 int icmpv6_time;
33 int anycast_src_echo_reply; 33 int anycast_src_echo_reply;
34 int fwmark_reflect; 34 int fwmark_reflect;
35 int idgen_retries;
36 int idgen_delay;
35}; 37};
36 38
37struct netns_ipv6 { 39struct netns_ipv6 {
@@ -67,6 +69,7 @@ struct netns_ipv6 {
67 struct sock *ndisc_sk; 69 struct sock *ndisc_sk;
68 struct sock *tcp_sk; 70 struct sock *tcp_sk;
69 struct sock *igmp_sk; 71 struct sock *igmp_sk;
72 struct sock *mc_autojoin_sk;
70#ifdef CONFIG_IPV6_MROUTE 73#ifdef CONFIG_IPV6_MROUTE
71#ifndef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES 74#ifndef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES
72 struct mr6_table *mrt6; 75 struct mr6_table *mrt6;
diff --git a/include/net/netns/mpls.h b/include/net/netns/mpls.h
new file mode 100644
index 000000000000..d29203651c01
--- /dev/null
+++ b/include/net/netns/mpls.h
@@ -0,0 +1,17 @@
1/*
2 * mpls in net namespaces
3 */
4
5#ifndef __NETNS_MPLS_H__
6#define __NETNS_MPLS_H__
7
8struct mpls_route;
9struct ctl_table_header;
10
11struct netns_mpls {
12 size_t platform_labels;
13 struct mpls_route __rcu * __rcu *platform_label;
14 struct ctl_table_header *ctl;
15};
16
17#endif /* __NETNS_MPLS_H__ */
diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
index c24060ee411e..4d6597ad6067 100644
--- a/include/net/netns/x_tables.h
+++ b/include/net/netns/x_tables.h
@@ -9,6 +9,7 @@ struct ebt_table;
9struct netns_xt { 9struct netns_xt {
10 struct list_head tables[NFPROTO_NUMPROTO]; 10 struct list_head tables[NFPROTO_NUMPROTO];
11 bool notrack_deprecated_warning; 11 bool notrack_deprecated_warning;
12 bool clusterip_deprecated_warning;
12#if defined(CONFIG_BRIDGE_NF_EBTABLES) || \ 13#if defined(CONFIG_BRIDGE_NF_EBTABLES) || \
13 defined(CONFIG_BRIDGE_NF_EBTABLES_MODULE) 14 defined(CONFIG_BRIDGE_NF_EBTABLES_MODULE)
14 struct ebt_table *broute_table; 15 struct ebt_table *broute_table;
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h
index ab672b537dd4..020a814bc8ed 100644
--- a/include/net/nfc/hci.h
+++ b/include/net/nfc/hci.h
@@ -83,6 +83,10 @@ struct nfc_hci_pipe {
83}; 83};
84 84
85#define NFC_HCI_MAX_CUSTOM_GATES 50 85#define NFC_HCI_MAX_CUSTOM_GATES 50
86/*
87 * According to specification 102 622 chapter 4.4 Pipes,
88 * the pipe identifier is 7 bits long.
89 */
86#define NFC_HCI_MAX_PIPES 127 90#define NFC_HCI_MAX_PIPES 127
87struct nfc_hci_init_data { 91struct nfc_hci_init_data {
88 u8 gate_count; 92 u8 gate_count;
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index ff87f8611fa3..d4dcc7199fd7 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -71,6 +71,7 @@ struct nci_ops {
71 int (*close)(struct nci_dev *ndev); 71 int (*close)(struct nci_dev *ndev);
72 int (*send)(struct nci_dev *ndev, struct sk_buff *skb); 72 int (*send)(struct nci_dev *ndev, struct sk_buff *skb);
73 int (*setup)(struct nci_dev *ndev); 73 int (*setup)(struct nci_dev *ndev);
74 int (*fw_download)(struct nci_dev *ndev, const char *firmware_name);
74 __u32 (*get_rfprotocol)(struct nci_dev *ndev, __u8 rf_protocol); 75 __u32 (*get_rfprotocol)(struct nci_dev *ndev, __u8 rf_protocol);
75 int (*discover_se)(struct nci_dev *ndev); 76 int (*discover_se)(struct nci_dev *ndev);
76 int (*disable_se)(struct nci_dev *ndev, u32 se_idx); 77 int (*disable_se)(struct nci_dev *ndev, u32 se_idx);
@@ -137,6 +138,10 @@ struct nci_conn_info {
137#define NCI_HCI_INVALID_HOST 0x80 138#define NCI_HCI_INVALID_HOST 0x80
138 139
139#define NCI_HCI_MAX_CUSTOM_GATES 50 140#define NCI_HCI_MAX_CUSTOM_GATES 50
141/*
142 * According to specification 102 622 chapter 4.4 Pipes,
143 * the pipe identifier is 7 bits long.
144 */
140#define NCI_HCI_MAX_PIPES 127 145#define NCI_HCI_MAX_PIPES 127
141 146
142struct nci_hci_gate { 147struct nci_hci_gate {
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 73190e65d5c1..7ac029c07546 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -157,7 +157,7 @@ struct nfc_evt_transaction {
157 u32 aid_len; 157 u32 aid_len;
158 u8 aid[NFC_MAX_AID_LENGTH]; 158 u8 aid[NFC_MAX_AID_LENGTH];
159 u8 params_len; 159 u8 params_len;
160 u8 params[NFC_MAX_PARAMS_LENGTH]; 160 u8 params[0];
161} __packed; 161} __packed;
162 162
163struct nfc_genl_data { 163struct nfc_genl_data {
diff --git a/include/net/ping.h b/include/net/ping.h
index cc16d413f681..ac80cb45e630 100644
--- a/include/net/ping.h
+++ b/include/net/ping.h
@@ -75,12 +75,11 @@ void ping_err(struct sk_buff *skb, int offset, u32 info);
75int ping_getfrag(void *from, char *to, int offset, int fraglen, int odd, 75int ping_getfrag(void *from, char *to, int offset, int fraglen, int odd,
76 struct sk_buff *); 76 struct sk_buff *);
77 77
78int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 78int ping_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int noblock,
79 size_t len, int noblock, int flags, int *addr_len); 79 int flags, int *addr_len);
80int ping_common_sendmsg(int family, struct msghdr *msg, size_t len, 80int ping_common_sendmsg(int family, struct msghdr *msg, size_t len,
81 void *user_icmph, size_t icmph_len); 81 void *user_icmph, size_t icmph_len);
82int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 82int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
83 size_t len);
84int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); 83int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
85bool ping_rcv(struct sk_buff *skb); 84bool ping_rcv(struct sk_buff *skb);
86 85
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 7f830ff67f08..fe41f3ceb008 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -39,8 +39,7 @@ struct request_sock_ops {
39 void (*send_reset)(struct sock *sk, 39 void (*send_reset)(struct sock *sk,
40 struct sk_buff *skb); 40 struct sk_buff *skb);
41 void (*destructor)(struct request_sock *req); 41 void (*destructor)(struct request_sock *req);
42 void (*syn_ack_timeout)(struct sock *sk, 42 void (*syn_ack_timeout)(const struct request_sock *req);
43 struct request_sock *req);
44}; 43};
45 44
46int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req); 45int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req);
@@ -49,7 +48,11 @@ int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req);
49 */ 48 */
50struct request_sock { 49struct request_sock {
51 struct sock_common __req_common; 50 struct sock_common __req_common;
51#define rsk_refcnt __req_common.skc_refcnt
52#define rsk_hash __req_common.skc_hash
53
52 struct request_sock *dl_next; 54 struct request_sock *dl_next;
55 struct sock *rsk_listener;
53 u16 mss; 56 u16 mss;
54 u8 num_retrans; /* number of retransmits */ 57 u8 num_retrans; /* number of retransmits */
55 u8 cookie_ts:1; /* syncookie: encode tcpopts in timestamp */ 58 u8 cookie_ts:1; /* syncookie: encode tcpopts in timestamp */
@@ -58,32 +61,56 @@ struct request_sock {
58 u32 window_clamp; /* window clamp at creation time */ 61 u32 window_clamp; /* window clamp at creation time */
59 u32 rcv_wnd; /* rcv_wnd offered first time */ 62 u32 rcv_wnd; /* rcv_wnd offered first time */
60 u32 ts_recent; 63 u32 ts_recent;
61 unsigned long expires; 64 struct timer_list rsk_timer;
62 const struct request_sock_ops *rsk_ops; 65 const struct request_sock_ops *rsk_ops;
63 struct sock *sk; 66 struct sock *sk;
64 u32 secid; 67 u32 secid;
65 u32 peer_secid; 68 u32 peer_secid;
66}; 69};
67 70
68static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops) 71static inline struct request_sock *
72reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener)
69{ 73{
70 struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC); 74 struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
71 75
72 if (req != NULL) 76 if (req) {
73 req->rsk_ops = ops; 77 req->rsk_ops = ops;
74 78 sock_hold(sk_listener);
79 req->rsk_listener = sk_listener;
80
81 /* Following is temporary. It is coupled with debugging
82 * helpers in reqsk_put() & reqsk_free()
83 */
84 atomic_set(&req->rsk_refcnt, 0);
85 }
75 return req; 86 return req;
76} 87}
77 88
78static inline void __reqsk_free(struct request_sock *req) 89static inline struct request_sock *inet_reqsk(struct sock *sk)
79{ 90{
80 kmem_cache_free(req->rsk_ops->slab, req); 91 return (struct request_sock *)sk;
92}
93
94static inline struct sock *req_to_sk(struct request_sock *req)
95{
96 return (struct sock *)req;
81} 97}
82 98
83static inline void reqsk_free(struct request_sock *req) 99static inline void reqsk_free(struct request_sock *req)
84{ 100{
101 /* temporary debugging */
102 WARN_ON_ONCE(atomic_read(&req->rsk_refcnt) != 0);
103
85 req->rsk_ops->destructor(req); 104 req->rsk_ops->destructor(req);
86 __reqsk_free(req); 105 if (req->rsk_listener)
106 sock_put(req->rsk_listener);
107 kmem_cache_free(req->rsk_ops->slab, req);
108}
109
110static inline void reqsk_put(struct request_sock *req)
111{
112 if (atomic_dec_and_test(&req->rsk_refcnt))
113 reqsk_free(req);
87} 114}
88 115
89extern int sysctl_max_syn_backlog; 116extern int sysctl_max_syn_backlog;
@@ -93,12 +120,16 @@ extern int sysctl_max_syn_backlog;
93 * @max_qlen_log - log_2 of maximal queued SYNs/REQUESTs 120 * @max_qlen_log - log_2 of maximal queued SYNs/REQUESTs
94 */ 121 */
95struct listen_sock { 122struct listen_sock {
96 u8 max_qlen_log; 123 int qlen_inc; /* protected by listener lock */
124 int young_inc;/* protected by listener lock */
125
126 /* following fields can be updated by timer */
127 atomic_t qlen_dec; /* qlen = qlen_inc - qlen_dec */
128 atomic_t young_dec;
129
130 u8 max_qlen_log ____cacheline_aligned_in_smp;
97 u8 synflood_warned; 131 u8 synflood_warned;
98 /* 2 bytes hole, try to use */ 132 /* 2 bytes hole, try to use */
99 int qlen;
100 int qlen_young;
101 int clock_hand;
102 u32 hash_rnd; 133 u32 hash_rnd;
103 u32 nr_table_entries; 134 u32 nr_table_entries;
104 struct request_sock *syn_table[0]; 135 struct request_sock *syn_table[0];
@@ -142,18 +173,11 @@ struct fastopen_queue {
142 * %syn_wait_lock is necessary only to avoid proc interface having to grab the main 173 * %syn_wait_lock is necessary only to avoid proc interface having to grab the main
143 * lock sock while browsing the listening hash (otherwise it's deadlock prone). 174 * lock sock while browsing the listening hash (otherwise it's deadlock prone).
144 * 175 *
145 * This lock is acquired in read mode only from listening_get_next() seq_file
146 * op and it's acquired in write mode _only_ from code that is actively
147 * changing rskq_accept_head. All readers that are holding the master sock lock
148 * don't need to grab this lock in read mode too as rskq_accept_head. writes
149 * are always protected from the main sock lock.
150 */ 176 */
151struct request_sock_queue { 177struct request_sock_queue {
152 struct request_sock *rskq_accept_head; 178 struct request_sock *rskq_accept_head;
153 struct request_sock *rskq_accept_tail; 179 struct request_sock *rskq_accept_tail;
154 rwlock_t syn_wait_lock;
155 u8 rskq_defer_accept; 180 u8 rskq_defer_accept;
156 /* 3 bytes hole, try to pack */
157 struct listen_sock *listen_opt; 181 struct listen_sock *listen_opt;
158 struct fastopen_queue *fastopenq; /* This is non-NULL iff TFO has been 182 struct fastopen_queue *fastopenq; /* This is non-NULL iff TFO has been
159 * enabled on this listener. Check 183 * enabled on this listener. Check
@@ -161,6 +185,9 @@ struct request_sock_queue {
161 * to determine if TFO is enabled 185 * to determine if TFO is enabled
162 * right at this moment. 186 * right at this moment.
163 */ 187 */
188
189 /* temporary alignment, our goal is to get rid of this lock */
190 spinlock_t syn_wait_lock ____cacheline_aligned_in_smp;
164}; 191};
165 192
166int reqsk_queue_alloc(struct request_sock_queue *queue, 193int reqsk_queue_alloc(struct request_sock_queue *queue,
@@ -186,12 +213,21 @@ static inline int reqsk_queue_empty(struct request_sock_queue *queue)
186} 213}
187 214
188static inline void reqsk_queue_unlink(struct request_sock_queue *queue, 215static inline void reqsk_queue_unlink(struct request_sock_queue *queue,
189 struct request_sock *req, 216 struct request_sock *req)
190 struct request_sock **prev_req)
191{ 217{
192 write_lock(&queue->syn_wait_lock); 218 struct listen_sock *lopt = queue->listen_opt;
193 *prev_req = req->dl_next; 219 struct request_sock **prev;
194 write_unlock(&queue->syn_wait_lock); 220
221 spin_lock(&queue->syn_wait_lock);
222
223 prev = &lopt->syn_table[req->rsk_hash];
224 while (*prev != req)
225 prev = &(*prev)->dl_next;
226 *prev = req->dl_next;
227
228 spin_unlock(&queue->syn_wait_lock);
229 if (del_timer(&req->rsk_timer))
230 reqsk_put(req);
195} 231}
196 232
197static inline void reqsk_queue_add(struct request_sock_queue *queue, 233static inline void reqsk_queue_add(struct request_sock_queue *queue,
@@ -224,57 +260,53 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue
224 return req; 260 return req;
225} 261}
226 262
227static inline int reqsk_queue_removed(struct request_sock_queue *queue, 263static inline void reqsk_queue_removed(struct request_sock_queue *queue,
228 struct request_sock *req) 264 const struct request_sock *req)
229{ 265{
230 struct listen_sock *lopt = queue->listen_opt; 266 struct listen_sock *lopt = queue->listen_opt;
231 267
232 if (req->num_timeout == 0) 268 if (req->num_timeout == 0)
233 --lopt->qlen_young; 269 atomic_inc(&lopt->young_dec);
234 270 atomic_inc(&lopt->qlen_dec);
235 return --lopt->qlen;
236} 271}
237 272
238static inline int reqsk_queue_added(struct request_sock_queue *queue) 273static inline void reqsk_queue_added(struct request_sock_queue *queue)
239{ 274{
240 struct listen_sock *lopt = queue->listen_opt; 275 struct listen_sock *lopt = queue->listen_opt;
241 const int prev_qlen = lopt->qlen;
242 276
243 lopt->qlen_young++; 277 lopt->young_inc++;
244 lopt->qlen++; 278 lopt->qlen_inc++;
245 return prev_qlen;
246} 279}
247 280
248static inline int reqsk_queue_len(const struct request_sock_queue *queue) 281static inline int listen_sock_qlen(const struct listen_sock *lopt)
249{ 282{
250 return queue->listen_opt != NULL ? queue->listen_opt->qlen : 0; 283 return lopt->qlen_inc - atomic_read(&lopt->qlen_dec);
251} 284}
252 285
253static inline int reqsk_queue_len_young(const struct request_sock_queue *queue) 286static inline int listen_sock_young(const struct listen_sock *lopt)
254{ 287{
255 return queue->listen_opt->qlen_young; 288 return lopt->young_inc - atomic_read(&lopt->young_dec);
256} 289}
257 290
258static inline int reqsk_queue_is_full(const struct request_sock_queue *queue) 291static inline int reqsk_queue_len(const struct request_sock_queue *queue)
259{ 292{
260 return queue->listen_opt->qlen >> queue->listen_opt->max_qlen_log; 293 const struct listen_sock *lopt = queue->listen_opt;
294
295 return lopt ? listen_sock_qlen(lopt) : 0;
261} 296}
262 297
263static inline void reqsk_queue_hash_req(struct request_sock_queue *queue, 298static inline int reqsk_queue_len_young(const struct request_sock_queue *queue)
264 u32 hash, struct request_sock *req,
265 unsigned long timeout)
266{ 299{
267 struct listen_sock *lopt = queue->listen_opt; 300 return listen_sock_young(queue->listen_opt);
268 301}
269 req->expires = jiffies + timeout;
270 req->num_retrans = 0;
271 req->num_timeout = 0;
272 req->sk = NULL;
273 req->dl_next = lopt->syn_table[hash];
274 302
275 write_lock(&queue->syn_wait_lock); 303static inline int reqsk_queue_is_full(const struct request_sock_queue *queue)
276 lopt->syn_table[hash] = req; 304{
277 write_unlock(&queue->syn_wait_lock); 305 return reqsk_queue_len(queue) >> queue->listen_opt->max_qlen_log;
278} 306}
279 307
308void reqsk_queue_hash_req(struct request_sock_queue *queue,
309 u32 hash, struct request_sock *req,
310 unsigned long timeout);
311
280#endif /* _REQUEST_SOCK_H */ 312#endif /* _REQUEST_SOCK_H */
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 6c6d5393fc34..343d922d15c2 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -137,7 +137,7 @@ void rtnl_af_register(struct rtnl_af_ops *ops);
137void rtnl_af_unregister(struct rtnl_af_ops *ops); 137void rtnl_af_unregister(struct rtnl_af_ops *ops);
138 138
139struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]); 139struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]);
140struct net_device *rtnl_create_link(struct net *net, char *ifname, 140struct net_device *rtnl_create_link(struct net *net, const char *ifname,
141 unsigned char name_assign_type, 141 unsigned char name_assign_type,
142 const struct rtnl_link_ops *ops, 142 const struct rtnl_link_ops *ops,
143 struct nlattr *tb[]); 143 struct nlattr *tb[]);
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index c605d305c577..6d778efcfdfd 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -213,7 +213,7 @@ struct tcf_proto_ops {
213 const struct tcf_proto *, 213 const struct tcf_proto *,
214 struct tcf_result *); 214 struct tcf_result *);
215 int (*init)(struct tcf_proto*); 215 int (*init)(struct tcf_proto*);
216 void (*destroy)(struct tcf_proto*); 216 bool (*destroy)(struct tcf_proto*, bool);
217 217
218 unsigned long (*get)(struct tcf_proto*, u32 handle); 218 unsigned long (*get)(struct tcf_proto*, u32 handle);
219 int (*change)(struct net *net, struct sk_buff *, 219 int (*change)(struct net *net, struct sk_buff *,
@@ -399,7 +399,7 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
399 const struct Qdisc_ops *ops, u32 parentid); 399 const struct Qdisc_ops *ops, u32 parentid);
400void __qdisc_calculate_pkt_len(struct sk_buff *skb, 400void __qdisc_calculate_pkt_len(struct sk_buff *skb,
401 const struct qdisc_size_table *stab); 401 const struct qdisc_size_table *stab);
402void tcf_destroy(struct tcf_proto *tp); 402bool tcf_destroy(struct tcf_proto *tp, bool force);
403void tcf_destroy_chain(struct tcf_proto __rcu **fl); 403void tcf_destroy_chain(struct tcf_proto __rcu **fl);
404 404
405/* Reset all TX qdiscs greater then index of a device. */ 405/* Reset all TX qdiscs greater then index of a device. */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 856f01cb51dd..c56a438c3a1e 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -166,6 +166,9 @@ void sctp_remaddr_proc_exit(struct net *net);
166 */ 166 */
167extern struct kmem_cache *sctp_chunk_cachep __read_mostly; 167extern struct kmem_cache *sctp_chunk_cachep __read_mostly;
168extern struct kmem_cache *sctp_bucket_cachep __read_mostly; 168extern struct kmem_cache *sctp_bucket_cachep __read_mostly;
169extern long sysctl_sctp_mem[3];
170extern int sysctl_sctp_rmem[3];
171extern int sysctl_sctp_wmem[3];
169 172
170/* 173/*
171 * Section: Macros, externs, and inlines 174 * Section: Macros, externs, and inlines
diff --git a/include/net/sock.h b/include/net/sock.h
index 81c81ead9a35..3a4898ec8c67 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -66,6 +66,7 @@
66#include <linux/atomic.h> 66#include <linux/atomic.h>
67#include <net/dst.h> 67#include <net/dst.h>
68#include <net/checksum.h> 68#include <net/checksum.h>
69#include <net/tcp_states.h>
69#include <linux/net_tstamp.h> 70#include <linux/net_tstamp.h>
70 71
71struct cgroup; 72struct cgroup;
@@ -189,15 +190,15 @@ struct sock_common {
189 struct hlist_nulls_node skc_portaddr_node; 190 struct hlist_nulls_node skc_portaddr_node;
190 }; 191 };
191 struct proto *skc_prot; 192 struct proto *skc_prot;
192#ifdef CONFIG_NET_NS 193 possible_net_t skc_net;
193 struct net *skc_net;
194#endif
195 194
196#if IS_ENABLED(CONFIG_IPV6) 195#if IS_ENABLED(CONFIG_IPV6)
197 struct in6_addr skc_v6_daddr; 196 struct in6_addr skc_v6_daddr;
198 struct in6_addr skc_v6_rcv_saddr; 197 struct in6_addr skc_v6_rcv_saddr;
199#endif 198#endif
200 199
200 atomic64_t skc_cookie;
201
201 /* 202 /*
202 * fields between dontcopy_begin/dontcopy_end 203 * fields between dontcopy_begin/dontcopy_end
203 * are not copied in sock_copy() 204 * are not copied in sock_copy()
@@ -328,6 +329,7 @@ struct sock {
328#define sk_net __sk_common.skc_net 329#define sk_net __sk_common.skc_net
329#define sk_v6_daddr __sk_common.skc_v6_daddr 330#define sk_v6_daddr __sk_common.skc_v6_daddr
330#define sk_v6_rcv_saddr __sk_common.skc_v6_rcv_saddr 331#define sk_v6_rcv_saddr __sk_common.skc_v6_rcv_saddr
332#define sk_cookie __sk_common.skc_cookie
331 333
332 socket_lock_t sk_lock; 334 socket_lock_t sk_lock;
333 struct sk_buff_head sk_receive_queue; 335 struct sk_buff_head sk_receive_queue;
@@ -402,8 +404,8 @@ struct sock {
402 rwlock_t sk_callback_lock; 404 rwlock_t sk_callback_lock;
403 int sk_err, 405 int sk_err,
404 sk_err_soft; 406 sk_err_soft;
405 unsigned short sk_ack_backlog; 407 u32 sk_ack_backlog;
406 unsigned short sk_max_ack_backlog; 408 u32 sk_max_ack_backlog;
407 __u32 sk_priority; 409 __u32 sk_priority;
408#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) 410#if IS_ENABLED(CONFIG_CGROUP_NET_PRIO)
409 __u32 sk_cgrp_prioidx; 411 __u32 sk_cgrp_prioidx;
@@ -957,10 +959,9 @@ struct proto {
957 int (*compat_ioctl)(struct sock *sk, 959 int (*compat_ioctl)(struct sock *sk,
958 unsigned int cmd, unsigned long arg); 960 unsigned int cmd, unsigned long arg);
959#endif 961#endif
960 int (*sendmsg)(struct kiocb *iocb, struct sock *sk, 962 int (*sendmsg)(struct sock *sk, struct msghdr *msg,
961 struct msghdr *msg, size_t len); 963 size_t len);
962 int (*recvmsg)(struct kiocb *iocb, struct sock *sk, 964 int (*recvmsg)(struct sock *sk, struct msghdr *msg,
963 struct msghdr *msg,
964 size_t len, int noblock, int flags, 965 size_t len, int noblock, int flags,
965 int *addr_len); 966 int *addr_len);
966 int (*sendpage)(struct sock *sk, struct page *page, 967 int (*sendpage)(struct sock *sk, struct page *page,
@@ -1561,9 +1562,8 @@ int sock_no_listen(struct socket *, int);
1561int sock_no_shutdown(struct socket *, int); 1562int sock_no_shutdown(struct socket *, int);
1562int sock_no_getsockopt(struct socket *, int , int, char __user *, int __user *); 1563int sock_no_getsockopt(struct socket *, int , int, char __user *, int __user *);
1563int sock_no_setsockopt(struct socket *, int, int, char __user *, unsigned int); 1564int sock_no_setsockopt(struct socket *, int, int, char __user *, unsigned int);
1564int sock_no_sendmsg(struct kiocb *, struct socket *, struct msghdr *, size_t); 1565int sock_no_sendmsg(struct socket *, struct msghdr *, size_t);
1565int sock_no_recvmsg(struct kiocb *, struct socket *, struct msghdr *, size_t, 1566int sock_no_recvmsg(struct socket *, struct msghdr *, size_t, int);
1566 int);
1567int sock_no_mmap(struct file *file, struct socket *sock, 1567int sock_no_mmap(struct file *file, struct socket *sock,
1568 struct vm_area_struct *vma); 1568 struct vm_area_struct *vma);
1569ssize_t sock_no_sendpage(struct socket *sock, struct page *page, int offset, 1569ssize_t sock_no_sendpage(struct socket *sock, struct page *page, int offset,
@@ -1575,8 +1575,8 @@ ssize_t sock_no_sendpage(struct socket *sock, struct page *page, int offset,
1575 */ 1575 */
1576int sock_common_getsockopt(struct socket *sock, int level, int optname, 1576int sock_common_getsockopt(struct socket *sock, int level, int optname,
1577 char __user *optval, int __user *optlen); 1577 char __user *optval, int __user *optlen);
1578int sock_common_recvmsg(struct kiocb *iocb, struct socket *sock, 1578int sock_common_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
1579 struct msghdr *msg, size_t size, int flags); 1579 int flags);
1580int sock_common_setsockopt(struct socket *sock, int level, int optname, 1580int sock_common_setsockopt(struct socket *sock, int level, int optname,
1581 char __user *optval, unsigned int optlen); 1581 char __user *optval, unsigned int optlen);
1582int compat_sock_common_getsockopt(struct socket *sock, int level, 1582int compat_sock_common_getsockopt(struct socket *sock, int level,
@@ -1625,7 +1625,7 @@ static inline void sock_put(struct sock *sk)
1625 sk_free(sk); 1625 sk_free(sk);
1626} 1626}
1627/* Generic version of sock_put(), dealing with all sockets 1627/* Generic version of sock_put(), dealing with all sockets
1628 * (TCP_TIMEWAIT, ESTABLISHED...) 1628 * (TCP_TIMEWAIT, TCP_NEW_SYN_RECV, ESTABLISHED...)
1629 */ 1629 */
1630void sock_gen_put(struct sock *sk); 1630void sock_gen_put(struct sock *sk);
1631 1631
@@ -2079,6 +2079,29 @@ static inline int sock_intr_errno(long timeo)
2079 return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; 2079 return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
2080} 2080}
2081 2081
2082struct sock_skb_cb {
2083 u32 dropcount;
2084};
2085
2086/* Store sock_skb_cb at the end of skb->cb[] so protocol families
2087 * using skb->cb[] would keep using it directly and utilize its
2088 * alignement guarantee.
2089 */
2090#define SOCK_SKB_CB_OFFSET ((FIELD_SIZEOF(struct sk_buff, cb) - \
2091 sizeof(struct sock_skb_cb)))
2092
2093#define SOCK_SKB_CB(__skb) ((struct sock_skb_cb *)((__skb)->cb + \
2094 SOCK_SKB_CB_OFFSET))
2095
2096#define sock_skb_cb_check_size(size) \
2097 BUILD_BUG_ON((size) > SOCK_SKB_CB_OFFSET)
2098
2099static inline void
2100sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
2101{
2102 SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
2103}
2104
2082void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, 2105void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
2083 struct sk_buff *skb); 2106 struct sk_buff *skb);
2084void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, 2107void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
@@ -2181,7 +2204,7 @@ static inline void sk_change_net(struct sock *sk, struct net *net)
2181 2204
2182 if (!net_eq(current_net, net)) { 2205 if (!net_eq(current_net, net)) {
2183 put_net(current_net); 2206 put_net(current_net);
2184 sock_net_set(sk, hold_net(net)); 2207 sock_net_set(sk, net);
2185 } 2208 }
2186} 2209}
2187 2210
@@ -2197,6 +2220,14 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb)
2197 return NULL; 2220 return NULL;
2198} 2221}
2199 2222
2223/* This helper checks if a socket is a full socket,
2224 * ie _not_ a timewait or request socket.
2225 */
2226static inline bool sk_fullsock(const struct sock *sk)
2227{
2228 return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT | TCPF_NEW_SYN_RECV);
2229}
2230
2200void sock_enable_timestamp(struct sock *sk, int flag); 2231void sock_enable_timestamp(struct sock *sk, int flag);
2201int sock_get_timestamp(struct sock *, struct timeval __user *); 2232int sock_get_timestamp(struct sock *, struct timeval __user *);
2202int sock_get_timestampns(struct sock *, struct timespec __user *); 2233int sock_get_timestampns(struct sock *, struct timespec __user *);
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index cfcdac2e5d25..d2e69ee3019a 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * include/net/switchdev.h - Switch device API 2 * include/net/switchdev.h - Switch device API
3 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> 3 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
4 * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -13,6 +14,35 @@
13#include <linux/netdevice.h> 14#include <linux/netdevice.h>
14#include <linux/notifier.h> 15#include <linux/notifier.h>
15 16
17struct fib_info;
18
19/**
20 * struct switchdev_ops - switchdev operations
21 *
22 * @swdev_parent_id_get: Called to get an ID of the switch chip this port
23 * is part of. If driver implements this, it indicates that it
24 * represents a port of a switch chip.
25 *
26 * @swdev_port_stp_update: Called to notify switch device port of bridge
27 * port STP state change.
28 *
29 * @swdev_fib_ipv4_add: Called to add/modify IPv4 route to switch device.
30 *
31 * @swdev_fib_ipv4_del: Called to delete IPv4 route from switch device.
32 */
33struct swdev_ops {
34 int (*swdev_parent_id_get)(struct net_device *dev,
35 struct netdev_phys_item_id *psid);
36 int (*swdev_port_stp_update)(struct net_device *dev, u8 state);
37 int (*swdev_fib_ipv4_add)(struct net_device *dev, __be32 dst,
38 int dst_len, struct fib_info *fi,
39 u8 tos, u8 type, u32 nlflags,
40 u32 tb_id);
41 int (*swdev_fib_ipv4_del)(struct net_device *dev, __be32 dst,
42 int dst_len, struct fib_info *fi,
43 u8 tos, u8 type, u32 tb_id);
44};
45
16enum netdev_switch_notifier_type { 46enum netdev_switch_notifier_type {
17 NETDEV_SWITCH_FDB_ADD = 1, 47 NETDEV_SWITCH_FDB_ADD = 1,
18 NETDEV_SWITCH_FDB_DEL, 48 NETDEV_SWITCH_FDB_DEL,
@@ -51,6 +81,12 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
51 struct nlmsghdr *nlh, u16 flags); 81 struct nlmsghdr *nlh, u16 flags);
52int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, 82int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
53 struct nlmsghdr *nlh, u16 flags); 83 struct nlmsghdr *nlh, u16 flags);
84int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
85 u8 tos, u8 type, u32 nlflags, u32 tb_id);
86int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
87 u8 tos, u8 type, u32 tb_id);
88void netdev_switch_fib_ipv4_abort(struct fib_info *fi);
89
54#else 90#else
55 91
56static inline int netdev_switch_parent_id_get(struct net_device *dev, 92static inline int netdev_switch_parent_id_get(struct net_device *dev,
@@ -109,6 +145,25 @@ static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *
109 return 0; 145 return 0;
110} 146}
111 147
148static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
149 struct fib_info *fi,
150 u8 tos, u8 type,
151 u32 nlflags, u32 tb_id)
152{
153 return 0;
154}
155
156static inline int netdev_switch_fib_ipv4_del(u32 dst, int dst_len,
157 struct fib_info *fi,
158 u8 tos, u8 type, u32 tb_id)
159{
160 return 0;
161}
162
163static inline void netdev_switch_fib_ipv4_abort(struct fib_info *fi)
164{
165}
166
112#endif 167#endif
113 168
114#endif /* _LINUX_SWITCHDEV_H_ */ 169#endif /* _LINUX_SWITCHDEV_H_ */
diff --git a/include/net/tc_act/tc_bpf.h b/include/net/tc_act/tc_bpf.h
index 86a070ffc930..a152e9858b2c 100644
--- a/include/net/tc_act/tc_bpf.h
+++ b/include/net/tc_act/tc_bpf.h
@@ -16,8 +16,12 @@
16struct tcf_bpf { 16struct tcf_bpf {
17 struct tcf_common common; 17 struct tcf_common common;
18 struct bpf_prog *filter; 18 struct bpf_prog *filter;
19 union {
20 u32 bpf_fd;
21 u16 bpf_num_ops;
22 };
19 struct sock_filter *bpf_ops; 23 struct sock_filter *bpf_ops;
20 u16 bpf_num_ops; 24 const char *bpf_name;
21}; 25};
22#define to_bpf(a) \ 26#define to_bpf(a) \
23 container_of(a->priv, struct tcf_bpf, common) 27 container_of(a->priv, struct tcf_bpf, common)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 8d6b983d5099..9598871485ce 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -65,7 +65,13 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
65#define TCP_MIN_MSS 88U 65#define TCP_MIN_MSS 88U
66 66
67/* The least MTU to use for probing */ 67/* The least MTU to use for probing */
68#define TCP_BASE_MSS 512 68#define TCP_BASE_MSS 1024
69
70/* probing interval, default to 10 minutes as per RFC4821 */
71#define TCP_PROBE_INTERVAL 600
72
73/* Specify interval when tcp mtu probing will stop */
74#define TCP_PROBE_THRESHOLD 8
69 75
70/* After receiving this amount of duplicate ACKs fast retransmit starts. */ 76/* After receiving this amount of duplicate ACKs fast retransmit starts. */
71#define TCP_FASTRETRANS_THRESH 3 77#define TCP_FASTRETRANS_THRESH 3
@@ -173,6 +179,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
173#define TCPOPT_SACK 5 /* SACK Block */ 179#define TCPOPT_SACK 5 /* SACK Block */
174#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ 180#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */
175#define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */ 181#define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */
182#define TCPOPT_FASTOPEN 34 /* Fast open (RFC7413) */
176#define TCPOPT_EXP 254 /* Experimental */ 183#define TCPOPT_EXP 254 /* Experimental */
177/* Magic number to be after the option value for sharing TCP 184/* Magic number to be after the option value for sharing TCP
178 * experimental options. See draft-ietf-tcpm-experimental-options-00.txt 185 * experimental options. See draft-ietf-tcpm-experimental-options-00.txt
@@ -188,6 +195,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo);
188#define TCPOLEN_SACK_PERM 2 195#define TCPOLEN_SACK_PERM 2
189#define TCPOLEN_TIMESTAMP 10 196#define TCPOLEN_TIMESTAMP 10
190#define TCPOLEN_MD5SIG 18 197#define TCPOLEN_MD5SIG 18
198#define TCPOLEN_FASTOPEN_BASE 2
191#define TCPOLEN_EXP_FASTOPEN_BASE 4 199#define TCPOLEN_EXP_FASTOPEN_BASE 4
192 200
193/* But this is what stacks really send out. */ 201/* But this is what stacks really send out. */
@@ -349,8 +357,7 @@ void tcp_v4_early_demux(struct sk_buff *skb);
349int tcp_v4_rcv(struct sk_buff *skb); 357int tcp_v4_rcv(struct sk_buff *skb);
350 358
351int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); 359int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw);
352int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 360int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
353 size_t size);
354int tcp_sendpage(struct sock *sk, struct page *page, int offset, size_t size, 361int tcp_sendpage(struct sock *sk, struct page *page, int offset, size_t size,
355 int flags); 362 int flags);
356void tcp_release_cb(struct sock *sk); 363void tcp_release_cb(struct sock *sk);
@@ -401,8 +408,7 @@ enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock *tw,
401 struct sk_buff *skb, 408 struct sk_buff *skb,
402 const struct tcphdr *th); 409 const struct tcphdr *th);
403struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, 410struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
404 struct request_sock *req, struct request_sock **prev, 411 struct request_sock *req, bool fastopen);
405 bool fastopen);
406int tcp_child_process(struct sock *parent, struct sock *child, 412int tcp_child_process(struct sock *parent, struct sock *child,
407 struct sk_buff *skb); 413 struct sk_buff *skb);
408void tcp_enter_loss(struct sock *sk); 414void tcp_enter_loss(struct sock *sk);
@@ -429,9 +435,9 @@ int compat_tcp_getsockopt(struct sock *sk, int level, int optname,
429int compat_tcp_setsockopt(struct sock *sk, int level, int optname, 435int compat_tcp_setsockopt(struct sock *sk, int level, int optname,
430 char __user *optval, unsigned int optlen); 436 char __user *optval, unsigned int optlen);
431void tcp_set_keepalive(struct sock *sk, int val); 437void tcp_set_keepalive(struct sock *sk, int val);
432void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req); 438void tcp_syn_ack_timeout(const struct request_sock *req);
433int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 439int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
434 size_t len, int nonblock, int flags, int *addr_len); 440 int flags, int *addr_len);
435void tcp_parse_options(const struct sk_buff *skb, 441void tcp_parse_options(const struct sk_buff *skb,
436 struct tcp_options_received *opt_rx, 442 struct tcp_options_received *opt_rx,
437 int estab, struct tcp_fastopen_cookie *foc); 443 int estab, struct tcp_fastopen_cookie *foc);
@@ -443,6 +449,7 @@ const u8 *tcp_parse_md5sig_option(const struct tcphdr *th);
443 449
444void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb); 450void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
445void tcp_v4_mtu_reduced(struct sock *sk); 451void tcp_v4_mtu_reduced(struct sock *sk);
452void tcp_req_err(struct sock *sk, u32 seq);
446int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb); 453int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
447struct sock *tcp_create_openreq_child(struct sock *sk, 454struct sock *tcp_create_openreq_child(struct sock *sk,
448 struct request_sock *req, 455 struct request_sock *req,
@@ -524,8 +531,6 @@ int tcp_write_wakeup(struct sock *);
524void tcp_send_fin(struct sock *sk); 531void tcp_send_fin(struct sock *sk);
525void tcp_send_active_reset(struct sock *sk, gfp_t priority); 532void tcp_send_active_reset(struct sock *sk, gfp_t priority);
526int tcp_send_synack(struct sock *); 533int tcp_send_synack(struct sock *);
527bool tcp_syn_flood_action(struct sock *sk, const struct sk_buff *skb,
528 const char *proto);
529void tcp_push_one(struct sock *, unsigned int mss_now); 534void tcp_push_one(struct sock *, unsigned int mss_now);
530void tcp_send_ack(struct sock *sk); 535void tcp_send_ack(struct sock *sk);
531void tcp_send_delayed_ack(struct sock *sk); 536void tcp_send_delayed_ack(struct sock *sk);
@@ -1132,31 +1137,6 @@ static inline int tcp_full_space(const struct sock *sk)
1132 return tcp_win_from_space(sk->sk_rcvbuf); 1137 return tcp_win_from_space(sk->sk_rcvbuf);
1133} 1138}
1134 1139
1135static inline void tcp_openreq_init(struct request_sock *req,
1136 struct tcp_options_received *rx_opt,
1137 struct sk_buff *skb, struct sock *sk)
1138{
1139 struct inet_request_sock *ireq = inet_rsk(req);
1140
1141 req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */
1142 req->cookie_ts = 0;
1143 tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
1144 tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
1145 tcp_rsk(req)->snt_synack = tcp_time_stamp;
1146 tcp_rsk(req)->last_oow_ack_time = 0;
1147 req->mss = rx_opt->mss_clamp;
1148 req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;
1149 ireq->tstamp_ok = rx_opt->tstamp_ok;
1150 ireq->sack_ok = rx_opt->sack_ok;
1151 ireq->snd_wscale = rx_opt->snd_wscale;
1152 ireq->wscale_ok = rx_opt->wscale_ok;
1153 ireq->acked = 0;
1154 ireq->ecn_ok = 0;
1155 ireq->ir_rmt_port = tcp_hdr(skb)->source;
1156 ireq->ir_num = ntohs(tcp_hdr(skb)->dest);
1157 ireq->ir_mark = inet_request_mark(sk, skb);
1158}
1159
1160extern void tcp_openreq_init_rwin(struct request_sock *req, 1140extern void tcp_openreq_init_rwin(struct request_sock *req,
1161 struct sock *sk, struct dst_entry *dst); 1141 struct sock *sk, struct dst_entry *dst);
1162 1142
@@ -1236,36 +1216,8 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt,
1236 return true; 1216 return true;
1237} 1217}
1238 1218
1239/* Return true if we're currently rate-limiting out-of-window ACKs and 1219bool tcp_oow_rate_limited(struct net *net, const struct sk_buff *skb,
1240 * thus shouldn't send a dupack right now. We rate-limit dupacks in 1220 int mib_idx, u32 *last_oow_ack_time);
1241 * response to out-of-window SYNs or ACKs to mitigate ACK loops or DoS
1242 * attacks that send repeated SYNs or ACKs for the same connection. To
1243 * do this, we do not send a duplicate SYNACK or ACK if the remote
1244 * endpoint is sending out-of-window SYNs or pure ACKs at a high rate.
1245 */
1246static inline bool tcp_oow_rate_limited(struct net *net,
1247 const struct sk_buff *skb,
1248 int mib_idx, u32 *last_oow_ack_time)
1249{
1250 /* Data packets without SYNs are not likely part of an ACK loop. */
1251 if ((TCP_SKB_CB(skb)->seq != TCP_SKB_CB(skb)->end_seq) &&
1252 !tcp_hdr(skb)->syn)
1253 goto not_rate_limited;
1254
1255 if (*last_oow_ack_time) {
1256 s32 elapsed = (s32)(tcp_time_stamp - *last_oow_ack_time);
1257
1258 if (0 <= elapsed && elapsed < sysctl_tcp_invalid_ratelimit) {
1259 NET_INC_STATS_BH(net, mib_idx);
1260 return true; /* rate-limited: don't send yet! */
1261 }
1262 }
1263
1264 *last_oow_ack_time = tcp_time_stamp;
1265
1266not_rate_limited:
1267 return false; /* not rate-limited: go ahead, send dupack now! */
1268}
1269 1221
1270static inline void tcp_mib_init(struct net *net) 1222static inline void tcp_mib_init(struct net *net)
1271{ 1223{
@@ -1344,15 +1296,14 @@ struct tcp_md5sig_pool {
1344}; 1296};
1345 1297
1346/* - functions */ 1298/* - functions */
1347int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, 1299int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
1348 const struct sock *sk, const struct request_sock *req, 1300 const struct sock *sk, const struct sk_buff *skb);
1349 const struct sk_buff *skb);
1350int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, 1301int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
1351 int family, const u8 *newkey, u8 newkeylen, gfp_t gfp); 1302 int family, const u8 *newkey, u8 newkeylen, gfp_t gfp);
1352int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, 1303int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
1353 int family); 1304 int family);
1354struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, 1305struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
1355 struct sock *addr_sk); 1306 const struct sock *addr_sk);
1356 1307
1357#ifdef CONFIG_TCP_MD5SIG 1308#ifdef CONFIG_TCP_MD5SIG
1358struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, 1309struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
@@ -1388,7 +1339,8 @@ void tcp_fastopen_cache_get(struct sock *sk, u16 *mss,
1388 struct tcp_fastopen_cookie *cookie, int *syn_loss, 1339 struct tcp_fastopen_cookie *cookie, int *syn_loss,
1389 unsigned long *last_syn_loss); 1340 unsigned long *last_syn_loss);
1390void tcp_fastopen_cache_set(struct sock *sk, u16 mss, 1341void tcp_fastopen_cache_set(struct sock *sk, u16 mss,
1391 struct tcp_fastopen_cookie *cookie, bool syn_lost); 1342 struct tcp_fastopen_cookie *cookie, bool syn_lost,
1343 u16 try_exp);
1392struct tcp_fastopen_request { 1344struct tcp_fastopen_request {
1393 /* Fast Open cookie. Size 0 means a cookie request */ 1345 /* Fast Open cookie. Size 0 means a cookie request */
1394 struct tcp_fastopen_cookie cookie; 1346 struct tcp_fastopen_cookie cookie;
@@ -1663,28 +1615,26 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
1663struct tcp_sock_af_ops { 1615struct tcp_sock_af_ops {
1664#ifdef CONFIG_TCP_MD5SIG 1616#ifdef CONFIG_TCP_MD5SIG
1665 struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, 1617 struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk,
1666 struct sock *addr_sk); 1618 const struct sock *addr_sk);
1667 int (*calc_md5_hash) (char *location, 1619 int (*calc_md5_hash)(char *location,
1668 struct tcp_md5sig_key *md5, 1620 const struct tcp_md5sig_key *md5,
1669 const struct sock *sk, 1621 const struct sock *sk,
1670 const struct request_sock *req, 1622 const struct sk_buff *skb);
1671 const struct sk_buff *skb); 1623 int (*md5_parse)(struct sock *sk,
1672 int (*md5_parse) (struct sock *sk, 1624 char __user *optval,
1673 char __user *optval, 1625 int optlen);
1674 int optlen);
1675#endif 1626#endif
1676}; 1627};
1677 1628
1678struct tcp_request_sock_ops { 1629struct tcp_request_sock_ops {
1679 u16 mss_clamp; 1630 u16 mss_clamp;
1680#ifdef CONFIG_TCP_MD5SIG 1631#ifdef CONFIG_TCP_MD5SIG
1681 struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk, 1632 struct tcp_md5sig_key *(*req_md5_lookup)(struct sock *sk,
1682 struct request_sock *req); 1633 const struct sock *addr_sk);
1683 int (*calc_md5_hash) (char *location, 1634 int (*calc_md5_hash) (char *location,
1684 struct tcp_md5sig_key *md5, 1635 const struct tcp_md5sig_key *md5,
1685 const struct sock *sk, 1636 const struct sock *sk,
1686 const struct request_sock *req, 1637 const struct sk_buff *skb);
1687 const struct sk_buff *skb);
1688#endif 1638#endif
1689 void (*init_req)(struct request_sock *req, struct sock *sk, 1639 void (*init_req)(struct request_sock *req, struct sock *sk,
1690 struct sk_buff *skb); 1640 struct sk_buff *skb);
diff --git a/include/net/tcp_states.h b/include/net/tcp_states.h
index b0b645988bd8..50e78a74d0df 100644
--- a/include/net/tcp_states.h
+++ b/include/net/tcp_states.h
@@ -25,6 +25,7 @@ enum {
25 TCP_LAST_ACK, 25 TCP_LAST_ACK,
26 TCP_LISTEN, 26 TCP_LISTEN,
27 TCP_CLOSING, /* Now a valid state */ 27 TCP_CLOSING, /* Now a valid state */
28 TCP_NEW_SYN_RECV,
28 29
29 TCP_MAX_STATES /* Leave at the end! */ 30 TCP_MAX_STATES /* Leave at the end! */
30}; 31};
@@ -44,7 +45,8 @@ enum {
44 TCPF_CLOSE_WAIT = (1 << 8), 45 TCPF_CLOSE_WAIT = (1 << 8),
45 TCPF_LAST_ACK = (1 << 9), 46 TCPF_LAST_ACK = (1 << 9),
46 TCPF_LISTEN = (1 << 10), 47 TCPF_LISTEN = (1 << 10),
47 TCPF_CLOSING = (1 << 11) 48 TCPF_CLOSING = (1 << 11),
49 TCPF_NEW_SYN_RECV = (1 << 12),
48}; 50};
49 51
50#endif /* _LINUX_TCP_STATES_H */ 52#endif /* _LINUX_TCP_STATES_H */
diff --git a/include/net/udp.h b/include/net/udp.h
index 07f9b70962f6..6d4ed18e1427 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -194,6 +194,8 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
194 int (*)(const struct sock *, const struct sock *), 194 int (*)(const struct sock *, const struct sock *),
195 unsigned int hash2_nulladdr); 195 unsigned int hash2_nulladdr);
196 196
197u32 udp_flow_hashrnd(void);
198
197static inline __be16 udp_flow_src_port(struct net *net, struct sk_buff *skb, 199static inline __be16 udp_flow_src_port(struct net *net, struct sk_buff *skb,
198 int min, int max, bool use_eth) 200 int min, int max, bool use_eth)
199{ 201{
@@ -205,12 +207,19 @@ static inline __be16 udp_flow_src_port(struct net *net, struct sk_buff *skb,
205 } 207 }
206 208
207 hash = skb_get_hash(skb); 209 hash = skb_get_hash(skb);
208 if (unlikely(!hash) && use_eth) { 210 if (unlikely(!hash)) {
209 /* Can't find a normal hash, caller has indicated an Ethernet 211 if (use_eth) {
210 * packet so use that to compute a hash. 212 /* Can't find a normal hash, caller has indicated an
211 */ 213 * Ethernet packet so use that to compute a hash.
212 hash = jhash(skb->data, 2 * ETH_ALEN, 214 */
213 (__force u32) skb->protocol); 215 hash = jhash(skb->data, 2 * ETH_ALEN,
216 (__force u32) skb->protocol);
217 } else {
218 /* Can't derive any sort of hash for the packet, set
219 * to some consistent random value.
220 */
221 hash = udp_flow_hashrnd();
222 }
214 } 223 }
215 224
216 /* Since this is being sent on the wire obfuscate hash a bit 225 /* Since this is being sent on the wire obfuscate hash a bit
@@ -229,8 +238,7 @@ int udp_get_port(struct sock *sk, unsigned short snum,
229 int (*saddr_cmp)(const struct sock *, 238 int (*saddr_cmp)(const struct sock *,
230 const struct sock *)); 239 const struct sock *));
231void udp_err(struct sk_buff *, u32); 240void udp_err(struct sk_buff *, u32);
232int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 241int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);
233 size_t len);
234int udp_push_pending_frames(struct sock *sk); 242int udp_push_pending_frames(struct sock *sk);
235void udp_flush_pending_frames(struct sock *sk); 243void udp_flush_pending_frames(struct sock *sk);
236void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst); 244void udp4_hwcsum(struct sk_buff *skb, __be32 src, __be32 dst);
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index 1a20d33d56bc..c491c1221606 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -77,13 +77,14 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
77 struct udp_tunnel_sock_cfg *sock_cfg); 77 struct udp_tunnel_sock_cfg *sock_cfg);
78 78
79/* Transmit the skb using UDP encapsulation. */ 79/* Transmit the skb using UDP encapsulation. */
80int udp_tunnel_xmit_skb(struct rtable *rt, struct sk_buff *skb, 80int udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
81 __be32 src, __be32 dst, __u8 tos, __u8 ttl, 81 __be32 src, __be32 dst, __u8 tos, __u8 ttl,
82 __be16 df, __be16 src_port, __be16 dst_port, 82 __be16 df, __be16 src_port, __be16 dst_port,
83 bool xnet, bool nocheck); 83 bool xnet, bool nocheck);
84 84
85#if IS_ENABLED(CONFIG_IPV6) 85#if IS_ENABLED(CONFIG_IPV6)
86int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sk_buff *skb, 86int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
87 struct sk_buff *skb,
87 struct net_device *dev, struct in6_addr *saddr, 88 struct net_device *dev, struct in6_addr *saddr,
88 struct in6_addr *daddr, 89 struct in6_addr *daddr,
89 __u8 prio, __u8 ttl, __be16 src_port, 90 __u8 prio, __u8 ttl, __be16 src_port,
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index c73e7abbbaa5..0082b5d33d7d 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -131,7 +131,7 @@ struct vxlan_sock {
131#define VXLAN_F_GBP 0x800 131#define VXLAN_F_GBP 0x800
132#define VXLAN_F_REMCSUM_NOPARTIAL 0x1000 132#define VXLAN_F_REMCSUM_NOPARTIAL 0x1000
133 133
134/* Flags that are used in the receive patch. These flags must match in 134/* Flags that are used in the receive path. These flags must match in
135 * order for a socket to be shareable 135 * order for a socket to be shareable
136 */ 136 */
137#define VXLAN_F_RCV_FLAGS (VXLAN_F_GBP | \ 137#define VXLAN_F_RCV_FLAGS (VXLAN_F_GBP | \
@@ -145,7 +145,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
145 145
146void vxlan_sock_release(struct vxlan_sock *vs); 146void vxlan_sock_release(struct vxlan_sock *vs);
147 147
148int vxlan_xmit_skb(struct rtable *rt, struct sk_buff *skb, 148int vxlan_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
149 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, 149 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
150 __be16 src_port, __be16 dst_port, struct vxlan_metadata *md, 150 __be16 src_port, __be16 dst_port, struct vxlan_metadata *md,
151 bool xnet, u32 vxflags); 151 bool xnet, u32 vxflags);
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index dc4865e90fe4..36ac102c97c7 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -126,9 +126,7 @@ struct xfrm_state_walk {
126 126
127/* Full description of state of transformer. */ 127/* Full description of state of transformer. */
128struct xfrm_state { 128struct xfrm_state {
129#ifdef CONFIG_NET_NS 129 possible_net_t xs_net;
130 struct net *xs_net;
131#endif
132 union { 130 union {
133 struct hlist_node gclist; 131 struct hlist_node gclist;
134 struct hlist_node bydst; 132 struct hlist_node bydst;
@@ -334,7 +332,7 @@ struct xfrm_state_afinfo {
334 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); 332 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
335 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); 333 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
336 int (*output)(struct sock *sk, struct sk_buff *skb); 334 int (*output)(struct sock *sk, struct sk_buff *skb);
337 int (*output_finish)(struct sk_buff *skb); 335 int (*output_finish)(struct sock *sk, struct sk_buff *skb);
338 int (*extract_input)(struct xfrm_state *x, 336 int (*extract_input)(struct xfrm_state *x,
339 struct sk_buff *skb); 337 struct sk_buff *skb);
340 int (*extract_output)(struct xfrm_state *x, 338 int (*extract_output)(struct xfrm_state *x,
@@ -522,9 +520,7 @@ struct xfrm_policy_queue {
522}; 520};
523 521
524struct xfrm_policy { 522struct xfrm_policy {
525#ifdef CONFIG_NET_NS 523 possible_net_t xp_net;
526 struct net *xp_net;
527#endif
528 struct hlist_node bydst; 524 struct hlist_node bydst;
529 struct hlist_node byidx; 525 struct hlist_node byidx;
530 526
@@ -1029,7 +1025,7 @@ xfrm_addr_any(const xfrm_address_t *addr, unsigned short family)
1029 case AF_INET: 1025 case AF_INET:
1030 return addr->a4 == 0; 1026 return addr->a4 == 0;
1031 case AF_INET6: 1027 case AF_INET6:
1032 return ipv6_addr_any((struct in6_addr *)&addr->a6); 1028 return ipv6_addr_any(&addr->in6);
1033 } 1029 }
1034 return 0; 1030 return 0;
1035} 1031}
@@ -1242,8 +1238,8 @@ void xfrm_flowi_addr_get(const struct flowi *fl,
1242 memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); 1238 memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4));
1243 break; 1239 break;
1244 case AF_INET6: 1240 case AF_INET6:
1245 *(struct in6_addr *)saddr->a6 = fl->u.ip6.saddr; 1241 saddr->in6 = fl->u.ip6.saddr;
1246 *(struct in6_addr *)daddr->a6 = fl->u.ip6.daddr; 1242 daddr->in6 = fl->u.ip6.daddr;
1247 break; 1243 break;
1248 } 1244 }
1249} 1245}
@@ -1507,7 +1503,7 @@ int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb);
1507int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type); 1503int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type);
1508int xfrm_input_resume(struct sk_buff *skb, int nexthdr); 1504int xfrm_input_resume(struct sk_buff *skb, int nexthdr);
1509int xfrm_output_resume(struct sk_buff *skb, int err); 1505int xfrm_output_resume(struct sk_buff *skb, int err);
1510int xfrm_output(struct sk_buff *skb); 1506int xfrm_output(struct sock *sk, struct sk_buff *skb);
1511int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb); 1507int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1512void xfrm_local_error(struct sk_buff *skb, int mtu); 1508void xfrm_local_error(struct sk_buff *skb, int mtu);
1513int xfrm4_extract_header(struct sk_buff *skb); 1509int xfrm4_extract_header(struct sk_buff *skb);
@@ -1528,7 +1524,7 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
1528int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); 1524int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1529int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); 1525int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1530int xfrm4_output(struct sock *sk, struct sk_buff *skb); 1526int xfrm4_output(struct sock *sk, struct sk_buff *skb);
1531int xfrm4_output_finish(struct sk_buff *skb); 1527int xfrm4_output_finish(struct sock *sk, struct sk_buff *skb);
1532int xfrm4_rcv_cb(struct sk_buff *skb, u8 protocol, int err); 1528int xfrm4_rcv_cb(struct sk_buff *skb, u8 protocol, int err);
1533int xfrm4_protocol_register(struct xfrm4_protocol *handler, unsigned char protocol); 1529int xfrm4_protocol_register(struct xfrm4_protocol *handler, unsigned char protocol);
1534int xfrm4_protocol_deregister(struct xfrm4_protocol *handler, unsigned char protocol); 1530int xfrm4_protocol_deregister(struct xfrm4_protocol *handler, unsigned char protocol);
@@ -1553,7 +1549,7 @@ __be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr);
1553int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); 1549int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1554int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); 1550int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1555int xfrm6_output(struct sock *sk, struct sk_buff *skb); 1551int xfrm6_output(struct sock *sk, struct sk_buff *skb);
1556int xfrm6_output_finish(struct sk_buff *skb); 1552int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb);
1557int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, 1553int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
1558 u8 **prevhdr); 1554 u8 **prevhdr);
1559 1555
diff --git a/include/rxrpc/packet.h b/include/rxrpc/packet.h
index f2902ef7ab75..4dce116bfd80 100644
--- a/include/rxrpc/packet.h
+++ b/include/rxrpc/packet.h
@@ -47,7 +47,8 @@ struct rxrpc_header {
47#define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */ 47#define RXRPC_PACKET_TYPE_CHALLENGE 6 /* connection security challenge (SRVR->CLNT) */
48#define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */ 48#define RXRPC_PACKET_TYPE_RESPONSE 7 /* connection secutity response (CLNT->SRVR) */
49#define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */ 49#define RXRPC_PACKET_TYPE_DEBUG 8 /* debug info request */
50#define RXRPC_N_PACKET_TYPES 9 /* number of packet types (incl type 0) */ 50#define RXRPC_PACKET_TYPE_VERSION 13 /* version string request */
51#define RXRPC_N_PACKET_TYPES 14 /* number of packet types (incl type 0) */
51 52
52 uint8_t flags; /* packet flags */ 53 uint8_t flags; /* packet flags */
53#define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */ 54#define RXRPC_CLIENT_INITIATED 0x01 /* signifies a packet generated by a client */
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index cc47ef41076a..5c1cee11f777 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -119,8 +119,12 @@ enum bpf_prog_type {
119 BPF_PROG_TYPE_UNSPEC, 119 BPF_PROG_TYPE_UNSPEC,
120 BPF_PROG_TYPE_SOCKET_FILTER, 120 BPF_PROG_TYPE_SOCKET_FILTER,
121 BPF_PROG_TYPE_KPROBE, 121 BPF_PROG_TYPE_KPROBE,
122 BPF_PROG_TYPE_SCHED_CLS,
123 BPF_PROG_TYPE_SCHED_ACT,
122}; 124};
123 125
126#define BPF_PSEUDO_MAP_FD 1
127
124/* flags for BPF_MAP_UPDATE_ELEM command */ 128/* flags for BPF_MAP_UPDATE_ELEM command */
125#define BPF_ANY 0 /* create new element or update existing */ 129#define BPF_ANY 0 /* create new element or update existing */
126#define BPF_NOEXIST 1 /* create new element if it didn't exist */ 130#define BPF_NOEXIST 1 /* create new element if it didn't exist */
@@ -167,7 +171,61 @@ enum bpf_func_id {
167 BPF_FUNC_probe_read, /* int bpf_probe_read(void *dst, int size, void *src) */ 171 BPF_FUNC_probe_read, /* int bpf_probe_read(void *dst, int size, void *src) */
168 BPF_FUNC_ktime_get_ns, /* u64 bpf_ktime_get_ns(void) */ 172 BPF_FUNC_ktime_get_ns, /* u64 bpf_ktime_get_ns(void) */
169 BPF_FUNC_trace_printk, /* int bpf_trace_printk(const char *fmt, int fmt_size, ...) */ 173 BPF_FUNC_trace_printk, /* int bpf_trace_printk(const char *fmt, int fmt_size, ...) */
174 BPF_FUNC_get_prandom_u32, /* u32 prandom_u32(void) */
175 BPF_FUNC_get_smp_processor_id, /* u32 raw_smp_processor_id(void) */
176
177 /**
178 * skb_store_bytes(skb, offset, from, len, flags) - store bytes into packet
179 * @skb: pointer to skb
180 * @offset: offset within packet from skb->data
181 * @from: pointer where to copy bytes from
182 * @len: number of bytes to store into packet
183 * @flags: bit 0 - if true, recompute skb->csum
184 * other bits - reserved
185 * Return: 0 on success
186 */
187 BPF_FUNC_skb_store_bytes,
188
189 /**
190 * l3_csum_replace(skb, offset, from, to, flags) - recompute IP checksum
191 * @skb: pointer to skb
192 * @offset: offset within packet where IP checksum is located
193 * @from: old value of header field
194 * @to: new value of header field
195 * @flags: bits 0-3 - size of header field
196 * other bits - reserved
197 * Return: 0 on success
198 */
199 BPF_FUNC_l3_csum_replace,
200
201 /**
202 * l4_csum_replace(skb, offset, from, to, flags) - recompute TCP/UDP checksum
203 * @skb: pointer to skb
204 * @offset: offset within packet where TCP/UDP checksum is located
205 * @from: old value of header field
206 * @to: new value of header field
207 * @flags: bits 0-3 - size of header field
208 * bit 4 - is pseudo header
209 * other bits - reserved
210 * Return: 0 on success
211 */
212 BPF_FUNC_l4_csum_replace,
170 __BPF_FUNC_MAX_ID, 213 __BPF_FUNC_MAX_ID,
171}; 214};
172 215
216/* user accessible mirror of in-kernel sk_buff.
217 * new fields can only be added to the end of this structure
218 */
219struct __sk_buff {
220 __u32 len;
221 __u32 pkt_type;
222 __u32 mark;
223 __u32 queue_mapping;
224 __u32 protocol;
225 __u32 vlan_present;
226 __u32 vlan_tci;
227 __u32 vlan_proto;
228 __u32 priority;
229};
230
173#endif /* _UAPI__LINUX_BPF_H__ */ 231#endif /* _UAPI__LINUX_BPF_H__ */
diff --git a/include/uapi/linux/can/raw.h b/include/uapi/linux/can/raw.h
index 78ec76fd89a6..8735f1080385 100644
--- a/include/uapi/linux/can/raw.h
+++ b/include/uapi/linux/can/raw.h
@@ -57,6 +57,7 @@ enum {
57 CAN_RAW_LOOPBACK, /* local loopback (default:on) */ 57 CAN_RAW_LOOPBACK, /* local loopback (default:on) */
58 CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */ 58 CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
59 CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */ 59 CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */
60 CAN_RAW_JOIN_FILTERS, /* all filters must match to trigger */
60}; 61};
61 62
62#endif /* !_UAPI_CAN_RAW_H */ 63#endif /* !_UAPI_CAN_RAW_H */
diff --git a/include/uapi/linux/dcbnl.h b/include/uapi/linux/dcbnl.h
index e711f20dc522..6497d7933d5b 100644
--- a/include/uapi/linux/dcbnl.h
+++ b/include/uapi/linux/dcbnl.h
@@ -78,6 +78,70 @@ struct ieee_maxrate {
78 __u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS]; 78 __u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS];
79}; 79};
80 80
81enum dcbnl_cndd_states {
82 DCB_CNDD_RESET = 0,
83 DCB_CNDD_EDGE,
84 DCB_CNDD_INTERIOR,
85 DCB_CNDD_INTERIOR_READY,
86};
87
88/* This structure contains the IEEE 802.1Qau QCN managed object.
89 *
90 *@rpg_enable: enable QCN RP
91 *@rppp_max_rps: maximum number of RPs allowed for this CNPV on this port
92 *@rpg_time_reset: time between rate increases if no CNMs received.
93 * given in u-seconds
94 *@rpg_byte_reset: transmitted data between rate increases if no CNMs received.
95 * given in Bytes
96 *@rpg_threshold: The number of times rpByteStage or rpTimeStage can count
97 * before RP rate control state machine advances states
98 *@rpg_max_rate: the maxinun rate, in Mbits per second,
99 * at which an RP can transmit
100 *@rpg_ai_rate: The rate, in Mbits per second,
101 * used to increase rpTargetRate in the RPR_ACTIVE_INCREASE
102 *@rpg_hai_rate: The rate, in Mbits per second,
103 * used to increase rpTargetRate in the RPR_HYPER_INCREASE state
104 *@rpg_gd: Upon CNM receive, flow rate is limited to (Fb/Gd)*CurrentRate.
105 * rpgGd is given as log2(Gd), where Gd may only be powers of 2
106 *@rpg_min_dec_fac: The minimum factor by which the current transmit rate
107 * can be changed by reception of a CNM.
108 * value is given as percentage (1-100)
109 *@rpg_min_rate: The minimum value, in bits per second, for rate to limit
110 *@cndd_state_machine: The state of the congestion notification domain
111 * defense state machine, as defined by IEEE 802.3Qau
112 * section 32.1.1. In the interior ready state,
113 * the QCN capable hardware may add CN-TAG TLV to the
114 * outgoing traffic, to specifically identify outgoing
115 * flows.
116 */
117
118struct ieee_qcn {
119 __u8 rpg_enable[IEEE_8021QAZ_MAX_TCS];
120 __u32 rppp_max_rps[IEEE_8021QAZ_MAX_TCS];
121 __u32 rpg_time_reset[IEEE_8021QAZ_MAX_TCS];
122 __u32 rpg_byte_reset[IEEE_8021QAZ_MAX_TCS];
123 __u32 rpg_threshold[IEEE_8021QAZ_MAX_TCS];
124 __u32 rpg_max_rate[IEEE_8021QAZ_MAX_TCS];
125 __u32 rpg_ai_rate[IEEE_8021QAZ_MAX_TCS];
126 __u32 rpg_hai_rate[IEEE_8021QAZ_MAX_TCS];
127 __u32 rpg_gd[IEEE_8021QAZ_MAX_TCS];
128 __u32 rpg_min_dec_fac[IEEE_8021QAZ_MAX_TCS];
129 __u32 rpg_min_rate[IEEE_8021QAZ_MAX_TCS];
130 __u32 cndd_state_machine[IEEE_8021QAZ_MAX_TCS];
131};
132
133/* This structure contains the IEEE 802.1Qau QCN statistics.
134 *
135 *@rppp_rp_centiseconds: the number of RP-centiseconds accumulated
136 * by RPs at this priority level on this Port
137 *@rppp_created_rps: number of active RPs(flows) that react to CNMs
138 */
139
140struct ieee_qcn_stats {
141 __u64 rppp_rp_centiseconds[IEEE_8021QAZ_MAX_TCS];
142 __u32 rppp_created_rps[IEEE_8021QAZ_MAX_TCS];
143};
144
81/* This structure contains the IEEE 802.1Qaz PFC managed object 145/* This structure contains the IEEE 802.1Qaz PFC managed object
82 * 146 *
83 * @pfc_cap: Indicates the number of traffic classes on the local device 147 * @pfc_cap: Indicates the number of traffic classes on the local device
@@ -334,6 +398,8 @@ enum ieee_attrs {
334 DCB_ATTR_IEEE_PEER_PFC, 398 DCB_ATTR_IEEE_PEER_PFC,
335 DCB_ATTR_IEEE_PEER_APP, 399 DCB_ATTR_IEEE_PEER_APP,
336 DCB_ATTR_IEEE_MAXRATE, 400 DCB_ATTR_IEEE_MAXRATE,
401 DCB_ATTR_IEEE_QCN,
402 DCB_ATTR_IEEE_QCN_STATS,
337 __DCB_ATTR_IEEE_MAX 403 __DCB_ATTR_IEEE_MAX
338}; 404};
339#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1) 405#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
diff --git a/include/uapi/linux/filter.h b/include/uapi/linux/filter.h
index 47785d5ecf17..34c7936ca114 100644
--- a/include/uapi/linux/filter.h
+++ b/include/uapi/linux/filter.h
@@ -77,7 +77,8 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
77#define SKF_AD_VLAN_TAG_PRESENT 48 77#define SKF_AD_VLAN_TAG_PRESENT 48
78#define SKF_AD_PAY_OFFSET 52 78#define SKF_AD_PAY_OFFSET 52
79#define SKF_AD_RANDOM 56 79#define SKF_AD_RANDOM 56
80#define SKF_AD_MAX 60 80#define SKF_AD_VLAN_TPID 60
81#define SKF_AD_MAX 64
81#define SKF_NET_OFF (-0x100000) 82#define SKF_NET_OFF (-0x100000)
82#define SKF_LL_OFF (-0x200000) 83#define SKF_LL_OFF (-0x200000)
83 84
diff --git a/include/uapi/linux/fou.h b/include/uapi/linux/fou.h
index c303588bb767..d2947c52dc67 100644
--- a/include/uapi/linux/fou.h
+++ b/include/uapi/linux/fou.h
@@ -25,6 +25,7 @@ enum {
25 FOU_CMD_UNSPEC, 25 FOU_CMD_UNSPEC,
26 FOU_CMD_ADD, 26 FOU_CMD_ADD,
27 FOU_CMD_DEL, 27 FOU_CMD_DEL,
28 FOU_CMD_GET,
28 29
29 __FOU_CMD_MAX, 30 __FOU_CMD_MAX,
30}; 31};
diff --git a/include/uapi/linux/if_addr.h b/include/uapi/linux/if_addr.h
index dea10a87dfd1..4318ab1635ce 100644
--- a/include/uapi/linux/if_addr.h
+++ b/include/uapi/linux/if_addr.h
@@ -50,6 +50,8 @@ enum {
50#define IFA_F_PERMANENT 0x80 50#define IFA_F_PERMANENT 0x80
51#define IFA_F_MANAGETEMPADDR 0x100 51#define IFA_F_MANAGETEMPADDR 0x100
52#define IFA_F_NOPREFIXROUTE 0x200 52#define IFA_F_NOPREFIXROUTE 0x200
53#define IFA_F_MCAUTOJOIN 0x400
54#define IFA_F_STABLE_PRIVACY 0x800
53 55
54struct ifa_cacheinfo { 56struct ifa_cacheinfo {
55 __u32 ifa_prefered; 57 __u32 ifa_prefered;
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index dfd0bb22e554..d9cd19214b98 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -147,6 +147,7 @@ enum {
147 IFLA_CARRIER_CHANGES, 147 IFLA_CARRIER_CHANGES,
148 IFLA_PHYS_SWITCH_ID, 148 IFLA_PHYS_SWITCH_ID,
149 IFLA_LINK_NETNSID, 149 IFLA_LINK_NETNSID,
150 IFLA_PHYS_PORT_NAME,
150 __IFLA_MAX 151 __IFLA_MAX
151}; 152};
152 153
@@ -215,6 +216,7 @@ enum {
215enum in6_addr_gen_mode { 216enum in6_addr_gen_mode {
216 IN6_ADDR_GEN_MODE_EUI64, 217 IN6_ADDR_GEN_MODE_EUI64,
217 IN6_ADDR_GEN_MODE_NONE, 218 IN6_ADDR_GEN_MODE_NONE,
219 IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
218}; 220};
219 221
220/* Bridge section */ 222/* Bridge section */
@@ -224,6 +226,9 @@ enum {
224 IFLA_BR_FORWARD_DELAY, 226 IFLA_BR_FORWARD_DELAY,
225 IFLA_BR_HELLO_TIME, 227 IFLA_BR_HELLO_TIME,
226 IFLA_BR_MAX_AGE, 228 IFLA_BR_MAX_AGE,
229 IFLA_BR_AGEING_TIME,
230 IFLA_BR_STP_STATE,
231 IFLA_BR_PRIORITY,
227 __IFLA_BR_MAX, 232 __IFLA_BR_MAX,
228}; 233};
229 234
@@ -247,6 +252,7 @@ enum {
247 IFLA_BRPORT_UNICAST_FLOOD, /* flood unicast traffic */ 252 IFLA_BRPORT_UNICAST_FLOOD, /* flood unicast traffic */
248 IFLA_BRPORT_PROXYARP, /* proxy ARP */ 253 IFLA_BRPORT_PROXYARP, /* proxy ARP */
249 IFLA_BRPORT_LEARNING_SYNC, /* mac learning sync from device */ 254 IFLA_BRPORT_LEARNING_SYNC, /* mac learning sync from device */
255 IFLA_BRPORT_PROXYARP_WIFI, /* proxy ARP for Wi-Fi */
250 __IFLA_BRPORT_MAX 256 __IFLA_BRPORT_MAX
251}; 257};
252#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) 258#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
@@ -459,6 +465,9 @@ enum {
459 IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */ 465 IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */
460 IFLA_VF_LINK_STATE, /* link state enable/disable/auto switch */ 466 IFLA_VF_LINK_STATE, /* link state enable/disable/auto switch */
461 IFLA_VF_RATE, /* Min and Max TX Bandwidth Allocation */ 467 IFLA_VF_RATE, /* Min and Max TX Bandwidth Allocation */
468 IFLA_VF_RSS_QUERY_EN, /* RSS Redirection Table and Hash Key query
469 * on/off switch
470 */
462 __IFLA_VF_MAX, 471 __IFLA_VF_MAX,
463}; 472};
464 473
@@ -503,6 +512,11 @@ struct ifla_vf_link_state {
503 __u32 link_state; 512 __u32 link_state;
504}; 513};
505 514
515struct ifla_vf_rss_query_en {
516 __u32 vf;
517 __u32 setting;
518};
519
506/* VF ports management section 520/* VF ports management section
507 * 521 *
508 * Nested layout of set/get msg is: 522 * Nested layout of set/get msg is:
diff --git a/include/uapi/linux/if_packet.h b/include/uapi/linux/if_packet.h
index da2d668b8cf1..053bd102fbe0 100644
--- a/include/uapi/linux/if_packet.h
+++ b/include/uapi/linux/if_packet.h
@@ -99,6 +99,7 @@ struct tpacket_auxdata {
99#define TP_STATUS_VLAN_VALID (1 << 4) /* auxdata has valid tp_vlan_tci */ 99#define TP_STATUS_VLAN_VALID (1 << 4) /* auxdata has valid tp_vlan_tci */
100#define TP_STATUS_BLK_TMO (1 << 5) 100#define TP_STATUS_BLK_TMO (1 << 5)
101#define TP_STATUS_VLAN_TPID_VALID (1 << 6) /* auxdata has valid tp_vlan_tpid */ 101#define TP_STATUS_VLAN_TPID_VALID (1 << 6) /* auxdata has valid tp_vlan_tpid */
102#define TP_STATUS_CSUM_VALID (1 << 7)
102 103
103/* Tx ring - header status */ 104/* Tx ring - header status */
104#define TP_STATUS_AVAILABLE 0 105#define TP_STATUS_AVAILABLE 0
diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h
index cabe95d5b461..3199243f2028 100644
--- a/include/uapi/linux/ip_vs.h
+++ b/include/uapi/linux/ip_vs.h
@@ -358,6 +358,8 @@ enum {
358 358
359 IPVS_SVC_ATTR_PE_NAME, /* name of ct retriever */ 359 IPVS_SVC_ATTR_PE_NAME, /* name of ct retriever */
360 360
361 IPVS_SVC_ATTR_STATS64, /* nested attribute for service stats */
362
361 __IPVS_SVC_ATTR_MAX, 363 __IPVS_SVC_ATTR_MAX,
362}; 364};
363 365
@@ -387,6 +389,8 @@ enum {
387 389
388 IPVS_DEST_ATTR_ADDR_FAMILY, /* Address family of address */ 390 IPVS_DEST_ATTR_ADDR_FAMILY, /* Address family of address */
389 391
392 IPVS_DEST_ATTR_STATS64, /* nested attribute for dest stats */
393
390 __IPVS_DEST_ATTR_MAX, 394 __IPVS_DEST_ATTR_MAX,
391}; 395};
392 396
@@ -410,7 +414,8 @@ enum {
410/* 414/*
411 * Attributes used to describe service or destination entry statistics 415 * Attributes used to describe service or destination entry statistics
412 * 416 *
413 * Used inside nested attributes IPVS_SVC_ATTR_STATS and IPVS_DEST_ATTR_STATS 417 * Used inside nested attributes IPVS_SVC_ATTR_STATS, IPVS_DEST_ATTR_STATS,
418 * IPVS_SVC_ATTR_STATS64 and IPVS_DEST_ATTR_STATS64.
414 */ 419 */
415enum { 420enum {
416 IPVS_STATS_ATTR_UNSPEC = 0, 421 IPVS_STATS_ATTR_UNSPEC = 0,
diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h
index 437a6a4b125a..5efa54ae567c 100644
--- a/include/uapi/linux/ipv6.h
+++ b/include/uapi/linux/ipv6.h
@@ -170,6 +170,7 @@ enum {
170 DEVCONF_ACCEPT_RA_FROM_LOCAL, 170 DEVCONF_ACCEPT_RA_FROM_LOCAL,
171 DEVCONF_USE_OPTIMISTIC, 171 DEVCONF_USE_OPTIMISTIC,
172 DEVCONF_ACCEPT_RA_MTU, 172 DEVCONF_ACCEPT_RA_MTU,
173 DEVCONF_STABLE_SECRET,
173 DEVCONF_MAX 174 DEVCONF_MAX
174}; 175};
175 176
diff --git a/include/uapi/linux/neighbour.h b/include/uapi/linux/neighbour.h
index 3873a35509aa..2e35c61bbdd1 100644
--- a/include/uapi/linux/neighbour.h
+++ b/include/uapi/linux/neighbour.h
@@ -126,6 +126,7 @@ enum {
126 NDTPA_PROXY_QLEN, /* u32 */ 126 NDTPA_PROXY_QLEN, /* u32 */
127 NDTPA_LOCKTIME, /* u64, msecs */ 127 NDTPA_LOCKTIME, /* u64, msecs */
128 NDTPA_QUEUE_LENBYTES, /* u32 */ 128 NDTPA_QUEUE_LENBYTES, /* u32 */
129 NDTPA_MCAST_REPROBES, /* u32 */
129 __NDTPA_MAX 130 __NDTPA_MAX
130}; 131};
131#define NDTPA_MAX (__NDTPA_MAX - 1) 132#define NDTPA_MAX (__NDTPA_MAX - 1)
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 832bc46db78b..5fa1cd04762e 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -1,19 +1,49 @@
1#ifndef _LINUX_NF_TABLES_H 1#ifndef _LINUX_NF_TABLES_H
2#define _LINUX_NF_TABLES_H 2#define _LINUX_NF_TABLES_H
3 3
4#define NFT_TABLE_MAXNAMELEN 32
4#define NFT_CHAIN_MAXNAMELEN 32 5#define NFT_CHAIN_MAXNAMELEN 32
5#define NFT_USERDATA_MAXLEN 256 6#define NFT_USERDATA_MAXLEN 256
6 7
8/**
9 * enum nft_registers - nf_tables registers
10 *
11 * nf_tables used to have five registers: a verdict register and four data
12 * registers of size 16. The data registers have been changed to 16 registers
13 * of size 4. For compatibility reasons, the NFT_REG_[1-4] registers still
14 * map to areas of size 16, the 4 byte registers are addressed using
15 * NFT_REG32_00 - NFT_REG32_15.
16 */
7enum nft_registers { 17enum nft_registers {
8 NFT_REG_VERDICT, 18 NFT_REG_VERDICT,
9 NFT_REG_1, 19 NFT_REG_1,
10 NFT_REG_2, 20 NFT_REG_2,
11 NFT_REG_3, 21 NFT_REG_3,
12 NFT_REG_4, 22 NFT_REG_4,
13 __NFT_REG_MAX 23 __NFT_REG_MAX,
24
25 NFT_REG32_00 = 8,
26 MFT_REG32_01,
27 NFT_REG32_02,
28 NFT_REG32_03,
29 NFT_REG32_04,
30 NFT_REG32_05,
31 NFT_REG32_06,
32 NFT_REG32_07,
33 NFT_REG32_08,
34 NFT_REG32_09,
35 NFT_REG32_10,
36 NFT_REG32_11,
37 NFT_REG32_12,
38 NFT_REG32_13,
39 NFT_REG32_14,
40 NFT_REG32_15,
14}; 41};
15#define NFT_REG_MAX (__NFT_REG_MAX - 1) 42#define NFT_REG_MAX (__NFT_REG_MAX - 1)
16 43
44#define NFT_REG_SIZE 16
45#define NFT_REG32_SIZE 4
46
17/** 47/**
18 * enum nft_verdicts - nf_tables internal verdicts 48 * enum nft_verdicts - nf_tables internal verdicts
19 * 49 *
@@ -207,12 +237,16 @@ enum nft_rule_compat_attributes {
207 * @NFT_SET_CONSTANT: set contents may not change while bound 237 * @NFT_SET_CONSTANT: set contents may not change while bound
208 * @NFT_SET_INTERVAL: set contains intervals 238 * @NFT_SET_INTERVAL: set contains intervals
209 * @NFT_SET_MAP: set is used as a dictionary 239 * @NFT_SET_MAP: set is used as a dictionary
240 * @NFT_SET_TIMEOUT: set uses timeouts
241 * @NFT_SET_EVAL: set contains expressions for evaluation
210 */ 242 */
211enum nft_set_flags { 243enum nft_set_flags {
212 NFT_SET_ANONYMOUS = 0x1, 244 NFT_SET_ANONYMOUS = 0x1,
213 NFT_SET_CONSTANT = 0x2, 245 NFT_SET_CONSTANT = 0x2,
214 NFT_SET_INTERVAL = 0x4, 246 NFT_SET_INTERVAL = 0x4,
215 NFT_SET_MAP = 0x8, 247 NFT_SET_MAP = 0x8,
248 NFT_SET_TIMEOUT = 0x10,
249 NFT_SET_EVAL = 0x20,
216}; 250};
217 251
218/** 252/**
@@ -251,6 +285,8 @@ enum nft_set_desc_attributes {
251 * @NFTA_SET_POLICY: selection policy (NLA_U32) 285 * @NFTA_SET_POLICY: selection policy (NLA_U32)
252 * @NFTA_SET_DESC: set description (NLA_NESTED) 286 * @NFTA_SET_DESC: set description (NLA_NESTED)
253 * @NFTA_SET_ID: uniquely identifies a set in a transaction (NLA_U32) 287 * @NFTA_SET_ID: uniquely identifies a set in a transaction (NLA_U32)
288 * @NFTA_SET_TIMEOUT: default timeout value (NLA_U64)
289 * @NFTA_SET_GC_INTERVAL: garbage collection interval (NLA_U32)
254 */ 290 */
255enum nft_set_attributes { 291enum nft_set_attributes {
256 NFTA_SET_UNSPEC, 292 NFTA_SET_UNSPEC,
@@ -264,6 +300,8 @@ enum nft_set_attributes {
264 NFTA_SET_POLICY, 300 NFTA_SET_POLICY,
265 NFTA_SET_DESC, 301 NFTA_SET_DESC,
266 NFTA_SET_ID, 302 NFTA_SET_ID,
303 NFTA_SET_TIMEOUT,
304 NFTA_SET_GC_INTERVAL,
267 __NFTA_SET_MAX 305 __NFTA_SET_MAX
268}; 306};
269#define NFTA_SET_MAX (__NFTA_SET_MAX - 1) 307#define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
@@ -283,12 +321,20 @@ enum nft_set_elem_flags {
283 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data) 321 * @NFTA_SET_ELEM_KEY: key value (NLA_NESTED: nft_data)
284 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes) 322 * @NFTA_SET_ELEM_DATA: data value of mapping (NLA_NESTED: nft_data_attributes)
285 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32) 323 * @NFTA_SET_ELEM_FLAGS: bitmask of nft_set_elem_flags (NLA_U32)
324 * @NFTA_SET_ELEM_TIMEOUT: timeout value (NLA_U64)
325 * @NFTA_SET_ELEM_EXPIRATION: expiration time (NLA_U64)
326 * @NFTA_SET_ELEM_USERDATA: user data (NLA_BINARY)
327 * @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)
286 */ 328 */
287enum nft_set_elem_attributes { 329enum nft_set_elem_attributes {
288 NFTA_SET_ELEM_UNSPEC, 330 NFTA_SET_ELEM_UNSPEC,
289 NFTA_SET_ELEM_KEY, 331 NFTA_SET_ELEM_KEY,
290 NFTA_SET_ELEM_DATA, 332 NFTA_SET_ELEM_DATA,
291 NFTA_SET_ELEM_FLAGS, 333 NFTA_SET_ELEM_FLAGS,
334 NFTA_SET_ELEM_TIMEOUT,
335 NFTA_SET_ELEM_EXPIRATION,
336 NFTA_SET_ELEM_USERDATA,
337 NFTA_SET_ELEM_EXPR,
292 __NFTA_SET_ELEM_MAX 338 __NFTA_SET_ELEM_MAX
293}; 339};
294#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1) 340#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
@@ -346,6 +392,9 @@ enum nft_data_attributes {
346}; 392};
347#define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1) 393#define NFTA_DATA_MAX (__NFTA_DATA_MAX - 1)
348 394
395/* Maximum length of a value */
396#define NFT_DATA_VALUE_MAXLEN 64
397
349/** 398/**
350 * enum nft_verdict_attributes - nf_tables verdict netlink attributes 399 * enum nft_verdict_attributes - nf_tables verdict netlink attributes
351 * 400 *
@@ -504,6 +553,35 @@ enum nft_lookup_attributes {
504}; 553};
505#define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1) 554#define NFTA_LOOKUP_MAX (__NFTA_LOOKUP_MAX - 1)
506 555
556enum nft_dynset_ops {
557 NFT_DYNSET_OP_ADD,
558 NFT_DYNSET_OP_UPDATE,
559};
560
561/**
562 * enum nft_dynset_attributes - dynset expression attributes
563 *
564 * @NFTA_DYNSET_SET_NAME: name of set the to add data to (NLA_STRING)
565 * @NFTA_DYNSET_SET_ID: uniquely identifier of the set in the transaction (NLA_U32)
566 * @NFTA_DYNSET_OP: operation (NLA_U32)
567 * @NFTA_DYNSET_SREG_KEY: source register of the key (NLA_U32)
568 * @NFTA_DYNSET_SREG_DATA: source register of the data (NLA_U32)
569 * @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64)
570 * @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes)
571 */
572enum nft_dynset_attributes {
573 NFTA_DYNSET_UNSPEC,
574 NFTA_DYNSET_SET_NAME,
575 NFTA_DYNSET_SET_ID,
576 NFTA_DYNSET_OP,
577 NFTA_DYNSET_SREG_KEY,
578 NFTA_DYNSET_SREG_DATA,
579 NFTA_DYNSET_TIMEOUT,
580 NFTA_DYNSET_EXPR,
581 __NFTA_DYNSET_MAX,
582};
583#define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1)
584
507/** 585/**
508 * enum nft_payload_bases - nf_tables payload expression offset bases 586 * enum nft_payload_bases - nf_tables payload expression offset bases
509 * 587 *
diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h
index ba993360dbe9..773dfe8924c7 100644
--- a/include/uapi/linux/netfilter_bridge/ebtables.h
+++ b/include/uapi/linux/netfilter_bridge/ebtables.h
@@ -12,9 +12,7 @@
12 12
13#ifndef _UAPI__LINUX_BRIDGE_EFF_H 13#ifndef _UAPI__LINUX_BRIDGE_EFF_H
14#define _UAPI__LINUX_BRIDGE_EFF_H 14#define _UAPI__LINUX_BRIDGE_EFF_H
15#include <linux/if.h>
16#include <linux/netfilter_bridge.h> 15#include <linux/netfilter_bridge.h>
17#include <linux/if_ether.h>
18 16
19#define EBT_TABLE_MAXNAMELEN 32 17#define EBT_TABLE_MAXNAMELEN 32
20#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN 18#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 68b294e83944..241220c43e86 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -25,6 +25,19 @@
25 * 25 *
26 */ 26 */
27 27
28/*
29 * This header file defines the userspace API to the wireless stack. Please
30 * be careful not to break things - i.e. don't move anything around or so
31 * unless you can demonstrate that it breaks neither API nor ABI.
32 *
33 * Additions to the API should be accompanied by actual implementations in
34 * an upstream driver, so that example implementations exist in case there
35 * are ever concerns about the precise semantics of the API or changes are
36 * needed, and to ensure that code for dead (no longer implemented) API
37 * can actually be identified and removed.
38 * Nonetheless, semantics should also be documented carefully in this file.
39 */
40
28#include <linux/types.h> 41#include <linux/types.h>
29 42
30#define NL80211_GENL_NAME "nl80211" 43#define NL80211_GENL_NAME "nl80211"
@@ -1684,6 +1697,10 @@ enum nl80211_commands {
1684 * If set during scheduled scan start then the new scan req will be 1697 * If set during scheduled scan start then the new scan req will be
1685 * owned by the netlink socket that created it and the scheduled scan will 1698 * owned by the netlink socket that created it and the scheduled scan will
1686 * be stopped when the socket is closed. 1699 * be stopped when the socket is closed.
1700 * If set during configuration of regulatory indoor operation then the
1701 * regulatory indoor configuration would be owned by the netlink socket
1702 * that configured the indoor setting, and the indoor operation would be
1703 * cleared when the socket is closed.
1687 * 1704 *
1688 * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is 1705 * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
1689 * the TDLS link initiator. 1706 * the TDLS link initiator.
@@ -1737,8 +1754,12 @@ enum nl80211_commands {
1737 * should be contained in the result as the sum of the respective counters 1754 * should be contained in the result as the sum of the respective counters
1738 * over all channels. 1755 * over all channels.
1739 * 1756 *
1740 * @NL80211_ATTR_SCHED_SCAN_DELAY: delay before a scheduled scan (or a 1757 * @NL80211_ATTR_SCHED_SCAN_DELAY: delay before the first cycle of a
1741 * WoWLAN net-detect scan) is started, u32 in seconds. 1758 * scheduled scan (or a WoWLAN net-detect scan) is started, u32
1759 * in seconds.
1760
1761 * @NL80211_ATTR_REG_INDOOR: flag attribute, if set indicates that the device
1762 * is operating in an indoor environment.
1742 * 1763 *
1743 * @NUM_NL80211_ATTR: total number of nl80211_attrs available 1764 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
1744 * @NL80211_ATTR_MAX: highest attribute number currently defined 1765 * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -2107,6 +2128,8 @@ enum nl80211_attrs {
2107 2128
2108 NL80211_ATTR_SCHED_SCAN_DELAY, 2129 NL80211_ATTR_SCHED_SCAN_DELAY,
2109 2130
2131 NL80211_ATTR_REG_INDOOR,
2132
2110 /* add attributes here, update the policy in nl80211.c */ 2133 /* add attributes here, update the policy in nl80211.c */
2111 2134
2112 __NL80211_ATTR_AFTER_LAST, 2135 __NL80211_ATTR_AFTER_LAST,
@@ -3092,7 +3115,8 @@ enum nl80211_mesh_power_mode {
3092 * 3115 *
3093 * @NL80211_MESHCONF_PLINK_TIMEOUT: If no tx activity is seen from a STA we've 3116 * @NL80211_MESHCONF_PLINK_TIMEOUT: If no tx activity is seen from a STA we've
3094 * established peering with for longer than this time (in seconds), then 3117 * established peering with for longer than this time (in seconds), then
3095 * remove it from the STA's list of peers. Default is 30 minutes. 3118 * remove it from the STA's list of peers. You may set this to 0 to disable
3119 * the removal of the STA. Default is 30 minutes.
3096 * 3120 *
3097 * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use 3121 * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
3098 */ 3122 */
@@ -3694,6 +3718,8 @@ struct nl80211_pattern_support {
3694 * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put 3718 * @NL80211_WOWLAN_TRIG_ANY: wake up on any activity, do not really put
3695 * the chip into a special state -- works best with chips that have 3719 * the chip into a special state -- works best with chips that have
3696 * support for low-power operation already (flag) 3720 * support for low-power operation already (flag)
3721 * Note that this mode is incompatible with all of the others, if
3722 * any others are even supported by the device.
3697 * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect 3723 * @NL80211_WOWLAN_TRIG_DISCONNECT: wake up on disconnect, the way disconnect
3698 * is detected is implementation-specific (flag) 3724 * is detected is implementation-specific (flag)
3699 * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed 3725 * @NL80211_WOWLAN_TRIG_MAGIC_PKT: wake up on magic packet (6x 0xff, followed
@@ -4327,11 +4353,13 @@ enum nl80211_feature_flags {
4327 4353
4328/** 4354/**
4329 * enum nl80211_ext_feature_index - bit index of extended features. 4355 * enum nl80211_ext_feature_index - bit index of extended features.
4356 * @NL80211_EXT_FEATURE_VHT_IBSS: This driver supports IBSS with VHT datarates.
4330 * 4357 *
4331 * @NUM_NL80211_EXT_FEATURES: number of extended features. 4358 * @NUM_NL80211_EXT_FEATURES: number of extended features.
4332 * @MAX_NL80211_EXT_FEATURES: highest extended feature index. 4359 * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
4333 */ 4360 */
4334enum nl80211_ext_feature_index { 4361enum nl80211_ext_feature_index {
4362 NL80211_EXT_FEATURE_VHT_IBSS,
4335 4363
4336 /* add new features before the definition below */ 4364 /* add new features before the definition below */
4337 NUM_NL80211_EXT_FEATURES, 4365 NUM_NL80211_EXT_FEATURES,
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 25731dfb3fcc..bf08e76bf505 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -397,6 +397,8 @@ enum {
397 TCA_BPF_CLASSID, 397 TCA_BPF_CLASSID,
398 TCA_BPF_OPS_LEN, 398 TCA_BPF_OPS_LEN,
399 TCA_BPF_OPS, 399 TCA_BPF_OPS,
400 TCA_BPF_FD,
401 TCA_BPF_NAME,
400 __TCA_BPF_MAX, 402 __TCA_BPF_MAX,
401}; 403};
402 404
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index 5cc5d66bf519..974db03f7b1a 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -134,6 +134,8 @@ enum {
134 134
135 RTM_NEWNSID = 88, 135 RTM_NEWNSID = 88,
136#define RTM_NEWNSID RTM_NEWNSID 136#define RTM_NEWNSID RTM_NEWNSID
137 RTM_DELNSID = 89,
138#define RTM_DELNSID RTM_DELNSID
137 RTM_GETNSID = 90, 139 RTM_GETNSID = 90,
138#define RTM_GETNSID RTM_GETNSID 140#define RTM_GETNSID RTM_GETNSID
139 141
@@ -303,6 +305,9 @@ enum rtattr_type_t {
303 RTA_TABLE, 305 RTA_TABLE,
304 RTA_MARK, 306 RTA_MARK,
305 RTA_MFC_STATS, 307 RTA_MFC_STATS,
308 RTA_VIA,
309 RTA_NEWDST,
310 RTA_PREF,
306 __RTA_MAX 311 __RTA_MAX
307}; 312};
308 313
@@ -332,6 +337,7 @@ struct rtnexthop {
332#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */ 337#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
333#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */ 338#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
334#define RTNH_F_ONLINK 4 /* Gateway is forced on link */ 339#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
340#define RTNH_F_EXTERNAL 8 /* Route installed externally */
335 341
336/* Macros to handle hexthops */ 342/* Macros to handle hexthops */
337 343
@@ -344,6 +350,12 @@ struct rtnexthop {
344#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len)) 350#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
345#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0))) 351#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
346 352
353/* RTA_VIA */
354struct rtvia {
355 __kernel_sa_family_t rtvia_family;
356 __u8 rtvia_addr[0];
357};
358
347/* RTM_CACHEINFO */ 359/* RTM_CACHEINFO */
348 360
349struct rta_cacheinfo { 361struct rta_cacheinfo {
@@ -623,6 +635,10 @@ enum rtnetlink_groups {
623#define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF 635#define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
624 RTNLGRP_MDB, 636 RTNLGRP_MDB,
625#define RTNLGRP_MDB RTNLGRP_MDB 637#define RTNLGRP_MDB RTNLGRP_MDB
638 RTNLGRP_MPLS_ROUTE,
639#define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE
640 RTNLGRP_NSID,
641#define RTNLGRP_NSID RTNLGRP_NSID
626 __RTNLGRP_MAX 642 __RTNLGRP_MAX
627}; 643};
628#define RTNLGRP_MAX (__RTNLGRP_MAX - 1) 644#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
diff --git a/include/uapi/linux/tc_act/tc_bpf.h b/include/uapi/linux/tc_act/tc_bpf.h
index 5288bd77e63b..07f17cc70bb3 100644
--- a/include/uapi/linux/tc_act/tc_bpf.h
+++ b/include/uapi/linux/tc_act/tc_bpf.h
@@ -24,6 +24,8 @@ enum {
24 TCA_ACT_BPF_PARMS, 24 TCA_ACT_BPF_PARMS,
25 TCA_ACT_BPF_OPS_LEN, 25 TCA_ACT_BPF_OPS_LEN,
26 TCA_ACT_BPF_OPS, 26 TCA_ACT_BPF_OPS,
27 TCA_ACT_BPF_FD,
28 TCA_ACT_BPF_NAME,
27 __TCA_ACT_BPF_MAX, 29 __TCA_ACT_BPF_MAX,
28}; 30};
29#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1) 31#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h
index 8d723824ad69..d4c8f142ba63 100644
--- a/include/uapi/linux/tipc_netlink.h
+++ b/include/uapi/linux/tipc_netlink.h
@@ -83,11 +83,20 @@ enum {
83 TIPC_NLA_BEARER_NAME, /* string */ 83 TIPC_NLA_BEARER_NAME, /* string */
84 TIPC_NLA_BEARER_PROP, /* nest */ 84 TIPC_NLA_BEARER_PROP, /* nest */
85 TIPC_NLA_BEARER_DOMAIN, /* u32 */ 85 TIPC_NLA_BEARER_DOMAIN, /* u32 */
86 TIPC_NLA_BEARER_UDP_OPTS, /* nest */
86 87
87 __TIPC_NLA_BEARER_MAX, 88 __TIPC_NLA_BEARER_MAX,
88 TIPC_NLA_BEARER_MAX = __TIPC_NLA_BEARER_MAX - 1 89 TIPC_NLA_BEARER_MAX = __TIPC_NLA_BEARER_MAX - 1
89}; 90};
90 91
92enum {
93 TIPC_NLA_UDP_UNSPEC,
94 TIPC_NLA_UDP_LOCAL, /* sockaddr_storage */
95 TIPC_NLA_UDP_REMOTE, /* sockaddr_storage */
96
97 __TIPC_NLA_UDP_MAX,
98 TIPC_NLA_UDP_MAX = __TIPC_NLA_UDP_MAX - 1
99};
91/* Socket info */ 100/* Socket info */
92enum { 101enum {
93 TIPC_NLA_SOCK_UNSPEC, 102 TIPC_NLA_SOCK_UNSPEC,
diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index 02d5125a5ee8..2cd9e608d0d1 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -1,6 +1,7 @@
1#ifndef _LINUX_XFRM_H 1#ifndef _LINUX_XFRM_H
2#define _LINUX_XFRM_H 2#define _LINUX_XFRM_H
3 3
4#include <linux/in6.h>
4#include <linux/types.h> 5#include <linux/types.h>
5 6
6/* All of the structures in this file may not change size as they are 7/* All of the structures in this file may not change size as they are
@@ -13,6 +14,7 @@
13typedef union { 14typedef union {
14 __be32 a4; 15 __be32 a4;
15 __be32 a6[4]; 16 __be32 a6[4];
17 struct in6_addr in6;
16} xfrm_address_t; 18} xfrm_address_t;
17 19
18/* Ident of a specific xfrm_state. It is used on input to lookup 20/* Ident of a specific xfrm_state. It is used on input to lookup