Pull networking fixes from Jakub Kicinski: "Including fixes from bpf, can and netfilter. Current release - regressions: - bpf: do not reject when the stack read size is different from the tracked scalar size - net: fix premature exit from NAPI state polling in napi_disable() - riscv, bpf: fix RV32 broken build, and silence RV64 warning Current release - new code bugs: - net: fix possible NULL deref in sock_reserve_memory - amt: fix error return code in amt_init(); fix stopping the workqueue - ax88796c: use the correct ioctl callback Previous releases - always broken: - bpf: stop caching subprog index in the bpf_pseudo_func insn - security: fixups for the security hooks in sctp - nfc: add necessary privilege flags in netlink layer, limit operations to admin only - vsock: prevent unnecessary refcnt inc for non-blocking connect - net/smc: fix sk_refcnt underflow on link down and fallback - nfnetlink_queue: fix OOB when mac header was cleared - can: j1939: ignore invalid messages per standard - bpf, sockmap: - fix race in ingress receive verdict with redirect to self - fix incorrect sk_skb data_end access when src_reg = dst_reg - strparser, and tls are reusing qdisc_skb_cb and colliding - ethtool: fix ethtool msg len calculation for pause stats - vlan: fix a UAF in vlan_dev_real_dev() when ref-holder tries to access an unregistering real_dev - udp6: make encap_rcv() bump the v6 not v4 stats - drv: prestera: add explicit padding to fix m68k build - drv: felix: fix broken VLAN-tagged PTP under VLAN-aware bridge - drv: mvpp2: fix wrong SerDes reconfiguration order Misc & small latecomers: - ipvs: auto-load ipvs on genl access - mctp: sanity check the struct sockaddr_mctp padding fields - libfs: support RENAME_EXCHANGE in simple_rename() - avoid double accounting for pure zerocopy skbs" * tag 'net-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (123 commits) selftests/net: udpgso_bench_rx: fix port argument net: wwan: iosm: fix compilation warning cxgb4: fix eeprom len when diagnostics not implemented net: fix premature exit from NAPI state polling in napi_disable() net/smc: fix sk_refcnt underflow on linkdown and fallback net/mlx5: Lag, fix a potential Oops with mlx5_lag_create_definer() gve: fix unmatched u64_stats_update_end() net: ethernet: lantiq_etop: Fix compilation error selftests: forwarding: Fix packet matching in mirroring selftests vsock: prevent unnecessary refcnt inc for nonblocking connect net: marvell: mvpp2: Fix wrong SerDes reconfiguration order net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory net: stmmac: allow a tc-taprio base-time of zero selftests: net: test_vxlan_under_vrf: fix HV connectivity test net: hns3: allow configure ETS bandwidth of all TCs net: hns3: remove check VF uc mac exist when set by PF net: hns3: fix some mac statistics is always 0 in device version V2 net: hns3: fix kernel crash when unload VF while it is being reset net: hns3: sync rx ring head in echo common pull net: hns3: fix pfc packet number incorrect after querying pfc parameters ...
Unified · Split
| @@ -1004,13 +1004,11 @@ udp_l3mdev_accept - BOOLEAN · 1003 unmodified lines | |||
| 1004 | udp_mem - vector of 3 INTEGERs: min, pressure, max | 1004 | udp_mem - vector of 3 INTEGERs: min, pressure, max |
| 1005 | Number of pages allowed for queueing by all UDP sockets. | 1005 | Number of pages allowed for queueing by all UDP sockets. |
| 1006 | 1006 | ||
| 1007 | min: Below this number of pages UDP is not bothered about its | 1007 | min: Number of pages allowed for queueing by all UDP sockets. |
| 1008 | memory appetite. When amount of memory allocated by UDP exceeds | ||
| 1009 | this number, UDP starts to moderate memory usage. | ||
| 1010 | 1008 | ||
| 1011 | pressure: This value was introduced to follow format of tcp_mem. | 1009 | pressure: This value was introduced to follow format of tcp_mem. |
| 1012 | 1010 | ||
| 1013 | max: Number of pages allowed for queueing by all UDP sockets. | 1011 | max: This value was introduced to follow format of tcp_mem. |
| 1014 | 1012 | ||
| 1015 | Default is calculated at boot time from amount of available memory. | 1013 | Default is calculated at boot time from amount of available memory. |
| 1016 | 1014 | ||
| @@ -15,10 +15,7 @@ For security module support, three SCTP specific hooks have been implemented:: · 14 unmodified lines | |||
| 15 | security_sctp_assoc_request() | 15 | security_sctp_assoc_request() |
| 16 | security_sctp_bind_connect() | 16 | security_sctp_bind_connect() |
| 17 | security_sctp_sk_clone() | 17 | security_sctp_sk_clone() |
| 18 | 18 | security_sctp_assoc_established() | |
| 19 | Also the following security hook has been utilised:: | ||
| 20 | |||
| 21 | security_inet_conn_established() | ||
| 22 | 19 | ||
| 23 | The usage of these hooks are described below with the SELinux implementation | 20 | The usage of these hooks are described below with the SELinux implementation |
| 24 | described in the `SCTP SELinux Support`_ chapter. | 21 | described in the `SCTP SELinux Support`_ chapter. |
| @@ -26,11 +23,11 @@ described in the `SCTP SELinux Support`_ chapter. · 1 unmodified line | |||
| 26 | 23 | ||
| 27 | security_sctp_assoc_request() | 24 | security_sctp_assoc_request() |
| 28 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 25 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 29 | Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the | 26 | Passes the ``@asoc`` and ``@chunk->skb`` of the association INIT packet to the |
| 30 | security module. Returns 0 on success, error on failure. | 27 | security module. Returns 0 on success, error on failure. |
| 31 | :: | 28 | :: |
| 32 | 29 | ||
| 33 | @ep - pointer to sctp endpoint structure. | 30 | @asoc - pointer to sctp association structure. |
| 34 | @skb - pointer to skbuff of association packet. | 31 | @skb - pointer to skbuff of association packet. |
| 35 | 32 | ||
| 36 | 33 | ||
| @@ -117,16 +114,17 @@ Called whenever a new socket is created by **accept**\(2) · 80 unmodified lines | |||
| 117 | calls **sctp_peeloff**\(3). | 114 | calls **sctp_peeloff**\(3). |
| 118 | :: | 115 | :: |
| 119 | 116 | ||
| 120 | @ep - pointer to current sctp endpoint structure. | 117 | @asoc - pointer to current sctp association structure. |
| 121 | @sk - pointer to current sock structure. | 118 | @sk - pointer to current sock structure. |
| 122 | @sk - pointer to new sock structure. | 119 | @newsk - pointer to new sock structure. |
| 123 | 120 | ||
| 124 | 121 | ||
| 125 | security_inet_conn_established() | 122 | security_sctp_assoc_established() |
| 126 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 123 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 127 | Called when a COOKIE ACK is received:: | 124 | Called when a COOKIE ACK is received, and the peer secid will be |
| 125 | saved into ``@asoc->peer_secid`` for client:: | ||
| 128 | 126 | ||
| 129 | @sk - pointer to sock structure. | 127 | @asoc - pointer to sctp association structure. |
| 130 | @skb - pointer to skbuff of the COOKIE ACK packet. | 128 | @skb - pointer to skbuff of the COOKIE ACK packet. |
| 131 | 129 | ||
| 132 | 130 | ||
| @@ -134,7 +132,7 @@ Security Hooks used for Association Establishment · 1 unmodified line | |||
| 134 | ------------------------------------------------- | 132 | ------------------------------------------------- |
| 135 | 133 | ||
| 136 | The following diagram shows the use of ``security_sctp_bind_connect()``, | 134 | The following diagram shows the use of ``security_sctp_bind_connect()``, |
| 137 | ``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when | 135 | ``security_sctp_assoc_request()``, ``security_sctp_assoc_established()`` when |
| 138 | establishing an association. | 136 | establishing an association. |
| 139 | :: | 137 | :: |
| 140 | 138 | ||
| @@ -151,9 +149,9 @@ establishing an association. · 10 unmodified lines | |||
| 151 | INIT ---------------------------------------------> | 149 | INIT ---------------------------------------------> |
| 152 | sctp_sf_do_5_1B_init() | 150 | sctp_sf_do_5_1B_init() |
| 153 | Respond to an INIT chunk. | 151 | Respond to an INIT chunk. |
| 154 | SCTP peer endpoint "A" is | 152 | SCTP peer endpoint "A" is asking |
| 155 | asking for an association. Call | 153 | for a temporary association. |
| 156 | security_sctp_assoc_request() | 154 | Call security_sctp_assoc_request() |
| 157 | to set the peer label if first | 155 | to set the peer label if first |
| 158 | association. | 156 | association. |
| 159 | If not first association, check | 157 | If not first association, check |
| @@ -163,13 +161,16 @@ establishing an association. · 3 unmodified lines | |||
| 163 | | discard the packet. | 161 | | discard the packet. |
| 164 | | | 162 | | |
| 165 | COOKIE ECHO ------------------------------------------> | 163 | COOKIE ECHO ------------------------------------------> |
| 166 | | | 164 | sctp_sf_do_5_1D_ce() |
| 167 | | | 165 | Respond to an COOKIE ECHO chunk. |
| 168 | | | 166 | Confirm the cookie and create a |
| 167 | permanent association. | ||
| 168 | Call security_sctp_assoc_request() to | ||
| 169 | do the same as for INIT chunk Response. | ||
| 169 | <------------------------------------------- COOKIE ACK | 170 | <------------------------------------------- COOKIE ACK |
| 170 | | | | 171 | | | |
| 171 | sctp_sf_do_5_1E_ca | | 172 | sctp_sf_do_5_1E_ca | |
| 172 | Call security_inet_conn_established() | | 173 | Call security_sctp_assoc_established() | |
| 173 | to set the peer label. | | 174 | to set the peer label. | |
| 174 | | | | 175 | | | |
| 175 | | If SCTP_SOCKET_TCP or peeled off | 176 | | If SCTP_SOCKET_TCP or peeled off |
| @@ -195,27 +196,27 @@ hooks with the SELinux specifics expanded below:: · 19 unmodified lines | |||
| 195 | security_sctp_assoc_request() | 196 | security_sctp_assoc_request() |
| 196 | security_sctp_bind_connect() | 197 | security_sctp_bind_connect() |
| 197 | security_sctp_sk_clone() | 198 | security_sctp_sk_clone() |
| 198 | security_inet_conn_established() | 199 | security_sctp_assoc_established() |
| 199 | 200 | ||
| 200 | 201 | ||
| 201 | security_sctp_assoc_request() | 202 | security_sctp_assoc_request() |
| 202 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 203 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 203 | Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the | 204 | Passes the ``@asoc`` and ``@chunk->skb`` of the association INIT packet to the |
| 204 | security module. Returns 0 on success, error on failure. | 205 | security module. Returns 0 on success, error on failure. |
| 205 | :: | 206 | :: |
| 206 | 207 | ||
| 207 | @ep - pointer to sctp endpoint structure. | 208 | @asoc - pointer to sctp association structure. |
| 208 | @skb - pointer to skbuff of association packet. | 209 | @skb - pointer to skbuff of association packet. |
| 209 | 210 | ||
| 210 | The security module performs the following operations: | 211 | The security module performs the following operations: |
| 211 | IF this is the first association on ``@ep->base.sk``, then set the peer | 212 | IF this is the first association on ``@asoc->base.sk``, then set the peer |
| 212 | sid to that in ``@skb``. This will ensure there is only one peer sid | 213 | sid to that in ``@skb``. This will ensure there is only one peer sid |
| 213 | assigned to ``@ep->base.sk`` that may support multiple associations. | 214 | assigned to ``@asoc->base.sk`` that may support multiple associations. |
| 214 | 215 | ||
| 215 | ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid`` | 216 | ELSE validate the ``@asoc->base.sk peer_sid`` against the ``@skb peer sid`` |
| 216 | to determine whether the association should be allowed or denied. | 217 | to determine whether the association should be allowed or denied. |
| 217 | 218 | ||
| 218 | Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with | 219 | Set the sctp ``@asoc sid`` to socket's sid (from ``asoc->base.sk``) with |
| 219 | MLS portion taken from ``@skb peer sid``. This will be used by SCTP | 220 | MLS portion taken from ``@skb peer sid``. This will be used by SCTP |
| 220 | TCP style sockets and peeled off connections as they cause a new socket | 221 | TCP style sockets and peeled off connections as they cause a new socket |
| 221 | to be generated. | 222 | to be generated. |
| @@ -259,21 +260,21 @@ security_sctp_sk_clone() · 37 unmodified lines | |||
| 259 | Called whenever a new socket is created by **accept**\(2) (i.e. a TCP style | 260 | Called whenever a new socket is created by **accept**\(2) (i.e. a TCP style |
| 260 | socket) or when a socket is 'peeled off' e.g userspace calls | 261 | socket) or when a socket is 'peeled off' e.g userspace calls |
| 261 | **sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new | 262 | **sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new |
| 262 | sockets sid and peer sid to that contained in the ``@ep sid`` and | 263 | sockets sid and peer sid to that contained in the ``@asoc sid`` and |
| 263 | ``@ep peer sid`` respectively. | 264 | ``@asoc peer sid`` respectively. |
| 264 | :: | 265 | :: |
| 265 | 266 | ||
| 266 | @ep - pointer to current sctp endpoint structure. | 267 | @asoc - pointer to current sctp association structure. |
| 267 | @sk - pointer to current sock structure. | 268 | @sk - pointer to current sock structure. |
| 268 | @sk - pointer to new sock structure. | 269 | @newsk - pointer to new sock structure. |
| 269 | 270 | ||
| 270 | 271 | ||
| 271 | security_inet_conn_established() | 272 | security_sctp_assoc_established() |
| 272 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 273 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 273 | Called when a COOKIE ACK is received where it sets the connection's peer sid | 274 | Called when a COOKIE ACK is received where it sets the connection's peer sid |
| 274 | to that in ``@skb``:: | 275 | to that in ``@skb``:: |
| 275 | 276 | ||
| 276 | @sk - pointer to sock structure. | 277 | @asoc - pointer to sctp association structure. |
| 277 | @skb - pointer to skbuff of the COOKIE ACK packet. | 278 | @skb - pointer to skbuff of the COOKIE ACK packet. |
| 278 | 279 | ||
| 279 | 280 | ||
| @@ -872,9 +872,10 @@ F: Documentation/devicetree/bindings/thermal/amazon,al-thermal.txt · 871 unmodified lines | |||
| 872 | F: drivers/thermal/thermal_mmio.c | 872 | F: drivers/thermal/thermal_mmio.c |
| 873 | 873 | ||
| 874 | AMAZON ETHERNET DRIVERS | 874 | AMAZON ETHERNET DRIVERS |
| 875 | M: Netanel Belgazal <netanel@amazon.com> | 875 | M: Shay Agroskin <shayagr@amazon.com> |
| 876 | M: Arthur Kiyanovski <akiyano@amazon.com> | 876 | M: Arthur Kiyanovski <akiyano@amazon.com> |
| 877 | R: Guy Tzalik <gtzalik@amazon.com> | 877 | R: David Arinzon <darinzon@amazon.com> |
| 878 | R: Noam Dagan <ndagan@amazon.com> | ||
| 878 | R: Saeed Bishara <saeedb@amazon.com> | 879 | R: Saeed Bishara <saeedb@amazon.com> |
| 879 | L: netdev@vger.kernel.org | 880 | L: netdev@vger.kernel.org |
| 880 | S: Supported | 881 | S: Supported |
| @@ -11,7 +11,7 @@ · 10 unmodified lines | |||
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/uaccess.h> | 12 | #include <linux/uaccess.h> |
| 13 | 13 | ||
| 14 | #ifdef CONFIG_BPF_JIT | 14 | #if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I) |
| 15 | int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs); | 15 | int rv_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs); |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| @@ -23,7 +23,7 @@ int fixup_exception(struct pt_regs *regs) · 5 unmodified lines | |||
| 23 | if (!fixup) | 23 | if (!fixup) |
| 24 | return 0; | 24 | return 0; |
| 25 | 25 | ||
| 26 | #ifdef CONFIG_BPF_JIT | 26 | #if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I) |
| 27 | if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END) | 27 | if (regs->epc >= BPF_JIT_REGION_START && regs->epc < BPF_JIT_REGION_END) |
| 28 | return rv_bpf_fixup_exception(fixup, regs); | 28 | return rv_bpf_fixup_exception(fixup, regs); |
| 29 | #endif | 29 | #endif |
| @@ -459,6 +459,8 @@ static int emit_call(bool fixed, u64 addr, struct rv_jit_context *ctx) · 458 unmodified lines | |||
| 459 | #define BPF_FIXUP_OFFSET_MASK GENMASK(26, 0) | 459 | #define BPF_FIXUP_OFFSET_MASK GENMASK(26, 0) |
| 460 | #define BPF_FIXUP_REG_MASK GENMASK(31, 27) | 460 | #define BPF_FIXUP_REG_MASK GENMASK(31, 27) |
| 461 | 461 | ||
| 462 | int rv_bpf_fixup_exception(const struct exception_table_entry *ex, | ||
| 463 | struct pt_regs *regs); | ||
| 462 | int rv_bpf_fixup_exception(const struct exception_table_entry *ex, | 464 | int rv_bpf_fixup_exception(const struct exception_table_entry *ex, |
| 463 | struct pt_regs *regs) | 465 | struct pt_regs *regs) |
| 464 | { | 466 | { |
| @@ -294,6 +294,7 @@ config GTP · 293 unmodified lines | |||
| 294 | config AMT | 294 | config AMT |
| 295 | tristate "Automatic Multicast Tunneling (AMT)" | 295 | tristate "Automatic Multicast Tunneling (AMT)" |
| 296 | depends on INET && IP_MULTICAST | 296 | depends on INET && IP_MULTICAST |
| 297 | depends on IPV6 || !IPV6 | ||
| 297 | select NET_UDP_TUNNEL | 298 | select NET_UDP_TUNNEL |
| 298 | help | 299 | help |
| 299 | This allows one to create AMT(Automatic Multicast Tunneling) | 300 | This allows one to create AMT(Automatic Multicast Tunneling) |
| @@ -12,7 +12,6 @@ · 11 unmodified lines | |||
| 12 | #include <linux/igmp.h> | 12 | #include <linux/igmp.h> |
| 13 | #include <linux/workqueue.h> | 13 | #include <linux/workqueue.h> |
| 14 | #include <net/net_namespace.h> | 14 | #include <net/net_namespace.h> |
| 15 | #include <net/protocol.h> | ||
| 16 | #include <net/ip.h> | 15 | #include <net/ip.h> |
| 17 | #include <net/udp.h> | 16 | #include <net/udp.h> |
| 18 | #include <net/udp_tunnel.h> | 17 | #include <net/udp_tunnel.h> |
| @@ -23,7 +22,6 @@ · 4 unmodified lines | |||
| 23 | #include <linux/security.h> | 22 | #include <linux/security.h> |
| 24 | #include <net/gro_cells.h> | 23 | #include <net/gro_cells.h> |
| 25 | #include <net/ipv6.h> | 24 | #include <net/ipv6.h> |
| 26 | #include <net/protocol.h> | ||
| 27 | #include <net/if_inet6.h> | 25 | #include <net/if_inet6.h> |
| 28 | #include <net/ndisc.h> | 26 | #include <net/ndisc.h> |
| 29 | #include <net/addrconf.h> | 27 | #include <net/addrconf.h> |
| @@ -2767,7 +2765,7 @@ static int amt_err_lookup(struct sock *sk, struct sk_buff *skb) · 2737 unmodified lines | |||
| 2767 | rcu_read_lock_bh(); | 2765 | rcu_read_lock_bh(); |
| 2768 | amt = rcu_dereference_sk_user_data(sk); | 2766 | amt = rcu_dereference_sk_user_data(sk); |
| 2769 | if (!amt) | 2767 | if (!amt) |
| 2770 | goto drop; | 2768 | goto out; |
| 2771 | 2769 | ||
| 2772 | if (amt->mode != AMT_MODE_GATEWAY) | 2770 | if (amt->mode != AMT_MODE_GATEWAY) |
| 2773 | goto drop; | 2771 | goto drop; |
| @@ -2789,6 +2787,7 @@ static int amt_err_lookup(struct sock *sk, struct sk_buff *skb) · 15 unmodified lines | |||
| 2789 | default: | 2787 | default: |
| 2790 | goto drop; | 2788 | goto drop; |
| 2791 | } | 2789 | } |
| 2790 | out: | ||
| 2792 | rcu_read_unlock_bh(); | 2791 | rcu_read_unlock_bh(); |
| 2793 | return 0; | 2792 | return 0; |
| 2794 | drop: | 2793 | drop: |
| @@ -3259,8 +3258,10 @@ static int __init amt_init(void) · 464 unmodified lines | |||
| 3259 | goto unregister_notifier; | 3258 | goto unregister_notifier; |
| 3260 | 3259 | ||
| 3261 | amt_wq = alloc_workqueue("amt", WQ_UNBOUND, 1); | 3260 | amt_wq = alloc_workqueue("amt", WQ_UNBOUND, 1); |
| 3262 | if (!amt_wq) | 3261 | if (!amt_wq) { |
| 3262 | err = -ENOMEM; | ||
| 3263 | goto rtnl_unregister; | 3263 | goto rtnl_unregister; |
| 3264 | } | ||
| 3264 | 3265 | ||
| 3265 | spin_lock_init(&source_gc_lock); | 3266 | spin_lock_init(&source_gc_lock); |
| 3266 | spin_lock_bh(&source_gc_lock); | 3267 | spin_lock_bh(&source_gc_lock); |
| @@ -3285,7 +3286,7 @@ static void __exit amt_fini(void) · 18 unmodified lines | |||
| 3285 | { | 3286 | { |
| 3286 | rtnl_link_unregister(&amt_link_ops); | 3287 | rtnl_link_unregister(&amt_link_ops); |
| 3287 | unregister_netdevice_notifier(&amt_notifier_block); | 3288 | unregister_netdevice_notifier(&amt_notifier_block); |
| 3288 | flush_delayed_work(&source_gc_wq); | 3289 | cancel_delayed_work(&source_gc_wq); |
| 3289 | __amt_source_gc_work(); | 3290 | __amt_source_gc_work(); |
| 3290 | destroy_workqueue(amt_wq); | 3291 | destroy_workqueue(amt_wq); |
| 3291 | } | 3292 | } |
| @@ -108,15 +108,15 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf) · 107 unmodified lines | |||
| 108 | } | 108 | } |
| 109 | static SLAVE_ATTR_RO(ad_partner_oper_port_state); | 109 | static SLAVE_ATTR_RO(ad_partner_oper_port_state); |
| 110 | 110 | ||
| 111 | static const struct slave_attribute *slave_attrs[] = { | 111 | static const struct attribute *slave_attrs[] = { |
| 112 | &slave_attr_state, | 112 | &slave_attr_state.attr, |
| 113 | &slave_attr_mii_status, | 113 | &slave_attr_mii_status.attr, |
| 114 | &slave_attr_link_failure_count, | 114 | &slave_attr_link_failure_count.attr, |
| 115 | &slave_attr_perm_hwaddr, | 115 | &slave_attr_perm_hwaddr.attr, |
| 116 | &slave_attr_queue_id, | 116 | &slave_attr_queue_id.attr, |
| 117 | &slave_attr_ad_aggregator_id, | 117 | &slave_attr_ad_aggregator_id.attr, |
| 118 | &slave_attr_ad_actor_oper_port_state, | 118 | &slave_attr_ad_actor_oper_port_state.attr, |
| 119 | &slave_attr_ad_partner_oper_port_state, | 119 | &slave_attr_ad_partner_oper_port_state.attr, |
| 120 | NULL | 120 | NULL |
| 121 | }; | 121 | }; |
| 122 | 122 | ||
| @@ -137,24 +137,10 @@ const struct sysfs_ops slave_sysfs_ops = { · 14 unmodified lines | |||
| 137 | 137 | ||
| 138 | int bond_sysfs_slave_add(struct slave *slave) | 138 | int bond_sysfs_slave_add(struct slave *slave) |
| 139 | { | 139 | { |
| 140 | const struct slave_attribute **a; | 140 | return sysfs_create_files(&slave->kobj, slave_attrs); |
| 141 | int err; | ||
| 142 | |||
| 143 | for (a = slave_attrs; *a; ++a) { | ||
| 144 | err = sysfs_create_file(&slave->kobj, &((*a)->attr)); | ||
| 145 | if (err) { | ||
| 146 | kobject_put(&slave->kobj); | ||
| 147 | return err; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | return 0; | ||
| 152 | } | 141 | } |
| 153 | 142 | ||
| 154 | void bond_sysfs_slave_del(struct slave *slave) | 143 | void bond_sysfs_slave_del(struct slave *slave) |
| 155 | { | 144 | { |
| 156 | const struct slave_attribute **a; | 145 | sysfs_remove_files(&slave->kobj, slave_attrs); |
| 157 | |||
| 158 | for (a = slave_attrs; *a; ++a) | ||
| 159 | sysfs_remove_file(&slave->kobj, &((*a)->attr)); | ||
| 160 | } | 146 | } |
| @@ -1092,7 +1092,7 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv) · 1091 unmodified lines | |||
| 1092 | 1092 | ||
| 1093 | err = mcp251xfd_chip_rx_int_enable(priv); | 1093 | err = mcp251xfd_chip_rx_int_enable(priv); |
| 1094 | if (err) | 1094 | if (err) |
| 1095 | return err; | 1095 | goto out_chip_stop; |
| 1096 | 1096 | ||
| 1097 | err = mcp251xfd_chip_ecc_init(priv); | 1097 | err = mcp251xfd_chip_ecc_init(priv); |
| 1098 | if (err) | 1098 | if (err) |
| @@ -2290,8 +2290,10 @@ static irqreturn_t mcp251xfd_irq(int irq, void *dev_id) · 1191 unmodified lines | |||
| 2290 | * check will fail, too. So leave IRQ handler | 2290 | * check will fail, too. So leave IRQ handler |
| 2291 | * directly. | 2291 | * directly. |
| 2292 | */ | 2292 | */ |
| 2293 | if (priv->can.state == CAN_STATE_BUS_OFF) | 2293 | if (priv->can.state == CAN_STATE_BUS_OFF) { |
| 2294 | can_rx_offload_threaded_irq_finish(&priv->offload); | ||
| 2294 | return IRQ_HANDLED; | 2295 | return IRQ_HANDLED; |
| 2296 | } | ||
| 2295 | } | 2297 | } |
| 2296 | 2298 | ||
| 2297 | handled = IRQ_HANDLED; | 2299 | handled = IRQ_HANDLED; |
| @@ -664,7 +664,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, · 663 unmodified lines | |||
| 664 | struct can_device_stats *can_stats = &can->can_stats; | 664 | struct can_device_stats *can_stats = &can->can_stats; |
| 665 | struct can_frame *cf = NULL; | 665 | struct can_frame *cf = NULL; |
| 666 | struct sk_buff *skb; | 666 | struct sk_buff *skb; |
| 667 | int ret; | 667 | int ret = 0; |
| 668 | 668 | ||
| 669 | if (!netif_running(netdev)) { | 669 | if (!netif_running(netdev)) { |
| 670 | if (net_ratelimit()) | 670 | if (net_ratelimit()) |
| @@ -823,8 +823,6 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, · 152 unmodified lines | |||
| 823 | can->state = CAN_STATE_BUS_OFF; | 823 | can->state = CAN_STATE_BUS_OFF; |
| 824 | can_bus_off(netdev); | 824 | can_bus_off(netdev); |
| 825 | ret = can->do_set_mode(netdev, CAN_MODE_STOP); | 825 | ret = can->do_set_mode(netdev, CAN_MODE_STOP); |
| 826 | if (ret) | ||
| 827 | return ret; | ||
| 828 | } | 826 | } |
| 829 | break; | 827 | break; |
| 830 | 828 | ||
| @@ -881,7 +879,7 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error, · 50 unmodified lines | |||
| 881 | ES58X_EVENT_BUSOFF, timestamp); | 879 | ES58X_EVENT_BUSOFF, timestamp); |
| 882 | } | 880 | } |
| 883 | 881 | ||
| 884 | return 0; | 882 | return ret; |
| 885 | } | 883 | } |
| 886 | 884 | ||
| 887 | /** | 885 | /** |
| @@ -841,14 +841,14 @@ static int pcan_usb_start(struct peak_usb_device *dev) · 840 unmodified lines | |||
| 841 | pdev->bec.rxerr = 0; | 841 | pdev->bec.rxerr = 0; |
| 842 | pdev->bec.txerr = 0; | 842 | pdev->bec.txerr = 0; |
| 843 | 843 | ||
| 844 | /* be notified on error counter changes (if requested by user) */ | 844 | /* always ask the device for BERR reporting, to be able to switch from |
| 845 | if (dev->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) { | 845 | * WARNING to PASSIVE state |
| 846 | err = pcan_usb_set_err_frame(dev, PCAN_USB_BERR_MASK); | 846 | */ |
| 847 | if (err) | 847 | err = pcan_usb_set_err_frame(dev, PCAN_USB_BERR_MASK); |
| 848 | netdev_warn(dev->netdev, | 848 | if (err) |
| 849 | "Asking for BERR reporting error %u\n", | 849 | netdev_warn(dev->netdev, |
| 850 | err); | 850 | "Asking for BERR reporting error %u\n", |
| 851 | } | 851 | err); |
| 852 | 852 | ||
| 853 | /* if revision greater than 3, can put silent mode on/off */ | 853 | /* if revision greater than 3, can put silent mode on/off */ |
| 854 | if (dev->device_rev > 3) { | 854 | if (dev->device_rev > 3) { |
| @@ -883,6 +883,11 @@ static int pcan_usb_init(struct peak_usb_device *dev) · 28 unmodified lines | |||
| 883 | return err; | 883 | return err; |
| 884 | } | 884 | } |
| 885 | 885 | ||
| 886 | dev_info(dev->netdev->dev.parent, | ||
| 887 | "PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n", | ||
| 888 | pcan_usb.name, dev->device_rev, serial_number, | ||
| 889 | pcan_usb.ctrl_count); | ||
| 890 | |||
| 886 | /* Since rev 4.1, PCAN-USB is able to make single-shot as well as | 891 | /* Since rev 4.1, PCAN-USB is able to make single-shot as well as |
| 887 | * looped back frames. | 892 | * looped back frames. |
| 888 | */ | 893 | */ |
| @@ -896,11 +901,6 @@ static int pcan_usb_init(struct peak_usb_device *dev) · 7 unmodified lines | |||
| 896 | "Firmware update available. Please contact support@peak-system.com\n"); | 901 | "Firmware update available. Please contact support@peak-system.com\n"); |
| 897 | } | 902 | } |
| 898 | 903 | ||
| 899 | dev_info(dev->netdev->dev.parent, | ||
| 900 | "PEAK-System %s adapter hwrev %u serial %08X (%u channel)\n", | ||
| 901 | pcan_usb.name, dev->device_rev, serial_number, | ||
| 902 | pcan_usb.ctrl_count); | ||
| 903 | |||
| 904 | return 0; | 904 | return 0; |
| 905 | } | 905 | } |
| 906 | 906 | ||
| @@ -986,7 +986,6 @@ const struct peak_usb_adapter pcan_usb = { · 79 unmodified lines | |||
| 986 | .device_id = PCAN_USB_PRODUCT_ID, | 986 | .device_id = PCAN_USB_PRODUCT_ID, |
| 987 | .ctrl_count = 1, | 987 | .ctrl_count = 1, |
| 988 | .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY | | 988 | .ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY | |
| 989 | CAN_CTRLMODE_BERR_REPORTING | | ||
| 990 | CAN_CTRLMODE_CC_LEN8_DLC, | 989 | CAN_CTRLMODE_CC_LEN8_DLC, |
| 991 | .clock = { | 990 | .clock = { |
| 992 | .freq = PCAN_USB_CRYSTAL_HZ / 2, | 991 | .freq = PCAN_USB_CRYSTAL_HZ / 2, |
| @@ -640,7 +640,10 @@ static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port, · 639 unmodified lines | |||
| 640 | unsigned long *mask, | 640 | unsigned long *mask, |
| 641 | struct phylink_link_state *state) | 641 | struct phylink_link_state *state) |
| 642 | { | 642 | { |
| 643 | if (port == 0 || port == 9 || port == 10) { | 643 | bool is_6191x = |
| 644 | chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X; | ||
| 645 | |||
| 646 | if (((port == 0 || port == 9) && !is_6191x) || port == 10) { | ||
| 644 | phylink_set(mask, 10000baseT_Full); | 647 | phylink_set(mask, 10000baseT_Full); |
| 645 | phylink_set(mask, 10000baseKR_Full); | 648 | phylink_set(mask, 10000baseKR_Full); |
| 646 | phylink_set(mask, 10000baseCR_Full); | 649 | phylink_set(mask, 10000baseCR_Full); |
| @@ -1370,12 +1370,12 @@ out: · 1369 unmodified lines | |||
| 1370 | static bool felix_rxtstamp(struct dsa_switch *ds, int port, | 1370 | static bool felix_rxtstamp(struct dsa_switch *ds, int port, |
| 1371 | struct sk_buff *skb, unsigned int type) | 1371 | struct sk_buff *skb, unsigned int type) |
| 1372 | { | 1372 | { |
| 1373 | u8 *extraction = skb->data - ETH_HLEN - OCELOT_TAG_LEN; | 1373 | u32 tstamp_lo = OCELOT_SKB_CB(skb)->tstamp_lo; |
| 1374 | struct skb_shared_hwtstamps *shhwtstamps; | 1374 | struct skb_shared_hwtstamps *shhwtstamps; |
| 1375 | struct ocelot *ocelot = ds->priv; | 1375 | struct ocelot *ocelot = ds->priv; |
| 1376 | u32 tstamp_lo, tstamp_hi; | ||
| 1377 | struct timespec64 ts; | 1376 | struct timespec64 ts; |
| 1378 | u64 tstamp, val; | 1377 | u32 tstamp_hi; |
| 1378 | u64 tstamp; | ||
| 1379 | 1379 | ||
| 1380 | /* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb | 1380 | /* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb |
| 1381 | * for RX timestamping. Then free it, and poll for its copy through | 1381 | * for RX timestamping. Then free it, and poll for its copy through |
| @@ -1390,9 +1390,6 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port, · 8 unmodified lines | |||
| 1390 | ocelot_ptp_gettime64(&ocelot->ptp_info, &ts); | 1390 | ocelot_ptp_gettime64(&ocelot->ptp_info, &ts); |
| 1391 | tstamp = ktime_set(ts.tv_sec, ts.tv_nsec); | 1391 | tstamp = ktime_set(ts.tv_sec, ts.tv_nsec); |
| 1392 | 1392 | ||
| 1393 | ocelot_xfh_get_rew_val(extraction, &val); | ||
| 1394 | tstamp_lo = (u32)val; | ||
| 1395 | |||
| 1396 | tstamp_hi = tstamp >> 32; | 1393 | tstamp_hi = tstamp >> 32; |
| 1397 | if ((tstamp & 0xffffffff) < tstamp_lo) | 1394 | if ((tstamp & 0xffffffff) < tstamp_lo) |
| 1398 | tstamp_hi--; | 1395 | tstamp_hi--; |
| @@ -1109,6 +1109,14 @@ qca8k_setup(struct dsa_switch *ds) · 1108 unmodified lines | |||
| 1109 | if (ret) | 1109 | if (ret) |
| 1110 | return ret; | 1110 | return ret; |
| 1111 | 1111 | ||
| 1112 | /* Make sure MAC06 is disabled */ | ||
| 1113 | ret = qca8k_reg_clear(priv, QCA8K_REG_PORT0_PAD_CTRL, | ||
| 1114 | QCA8K_PORT0_PAD_MAC06_EXCHANGE_EN); | ||
| 1115 | if (ret) { | ||
| 1116 | dev_err(priv->dev, "failed disabling MAC06 exchange"); | ||
| 1117 | return ret; | ||
| 1118 | } | ||
| 1119 | |||
| 1112 | /* Enable CPU Port */ | 1120 | /* Enable CPU Port */ |
| 1113 | ret = qca8k_reg_set(priv, QCA8K_REG_GLOBAL_FW_CTRL0, | 1121 | ret = qca8k_reg_set(priv, QCA8K_REG_GLOBAL_FW_CTRL0, |
| 1114 | QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN); | 1122 | QCA8K_GLOBAL_FW_CTRL0_CPU_PORT_EN); |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | |||
| 34 | #define QCA8K_MASK_CTRL_DEVICE_ID_MASK GENMASK(15, 8) | 34 | #define QCA8K_MASK_CTRL_DEVICE_ID_MASK GENMASK(15, 8) |
| 35 | #define QCA8K_MASK_CTRL_DEVICE_ID(x) ((x) >> 8) | 35 | #define QCA8K_MASK_CTRL_DEVICE_ID(x) ((x) >> 8) |
| 36 | #define QCA8K_REG_PORT0_PAD_CTRL 0x004 | 36 | #define QCA8K_REG_PORT0_PAD_CTRL 0x004 |
| 37 | #define QCA8K_PORT0_PAD_MAC06_EXCHANGE_EN BIT(31) | ||
| 37 | #define QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE BIT(19) | 38 | #define QCA8K_PORT0_PAD_SGMII_RXCLK_FALLING_EDGE BIT(19) |
| 38 | #define QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE BIT(18) | 39 | #define QCA8K_PORT0_PAD_SGMII_TXCLK_FALLING_EDGE BIT(18) |
| 39 | #define QCA8K_REG_PORT5_PAD_CTRL 0x008 | 40 | #define QCA8K_REG_PORT5_PAD_CTRL 0x008 |
| @@ -934,7 +934,7 @@ static const struct net_device_ops ax88796c_netdev_ops = { · 933 unmodified lines | |||
| 934 | .ndo_stop = ax88796c_close, | 934 | .ndo_stop = ax88796c_close, |
| 935 | .ndo_start_xmit = ax88796c_start_xmit, | 935 | .ndo_start_xmit = ax88796c_start_xmit, |
| 936 | .ndo_get_stats64 = ax88796c_get_stats64, | 936 | .ndo_get_stats64 = ax88796c_get_stats64, |
| 937 | .ndo_do_ioctl = ax88796c_ioctl, | 937 | .ndo_eth_ioctl = ax88796c_ioctl, |
| 938 | .ndo_set_mac_address = eth_mac_addr, | 938 | .ndo_set_mac_address = eth_mac_addr, |
| 939 | .ndo_set_features = ax88796c_set_features, | 939 | .ndo_set_features = ax88796c_set_features, |
| 940 | }; | 940 | }; |
| @@ -1114,11 +1114,13 @@ static int ax88796c_remove(struct spi_device *spi) · 173 unmodified lines | |||
| 1114 | return 0; | 1114 | return 0; |
| 1115 | } | 1115 | } |
| 1116 | 1116 | ||
| 1117 | #ifdef CONFIG_OF | ||
| 1117 | static const struct of_device_id ax88796c_dt_ids[] = { | 1118 | static const struct of_device_id ax88796c_dt_ids[] = { |
| 1118 | { .compatible = "asix,ax88796c" }, | 1119 | { .compatible = "asix,ax88796c" }, |
| 1119 | {}, | 1120 | {}, |
| 1120 | }; | 1121 | }; |
| 1121 | MODULE_DEVICE_TABLE(of, ax88796c_dt_ids); | 1122 | MODULE_DEVICE_TABLE(of, ax88796c_dt_ids); |
| 1123 | #endif | ||
| 1122 | 1124 | ||
| 1123 | static const struct spi_device_id asix_id[] = { | 1125 | static const struct spi_device_id asix_id[] = { |
| 1124 | { "ax88796c", 0 }, | 1126 | { "ax88796c", 0 }, |
| @@ -443,7 +443,7 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change, · 442 unmodified lines | |||
| 443 | case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: { | 443 | case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: { |
| 444 | if (BNXT_PF(bp) && bp->pf.active_vfs) { | 444 | if (BNXT_PF(bp) && bp->pf.active_vfs) { |
| 445 | NL_SET_ERR_MSG_MOD(extack, | 445 | NL_SET_ERR_MSG_MOD(extack, |
| 446 | "reload is unsupported when VFs are allocated\n"); | 446 | "reload is unsupported when VFs are allocated"); |
| 447 | return -EOPNOTSUPP; | 447 | return -EOPNOTSUPP; |
| 448 | } | 448 | } |
| 449 | rtnl_lock(); | 449 | rtnl_lock(); |
| @@ -5503,7 +5503,6 @@ static bool tg3_setup_fiber_hw_autoneg(struct tg3 *tp, u32 mac_status) · 5502 unmodified lines | |||
| 5503 | int workaround, port_a; | 5503 | int workaround, port_a; |
| 5504 | 5504 | ||
| 5505 | serdes_cfg = 0; | 5505 | serdes_cfg = 0; |
| 5506 | expected_sg_dig_ctrl = 0; | ||
| 5507 | workaround = 0; | 5506 | workaround = 0; |
| 5508 | port_a = 1; | 5507 | port_a = 1; |
| 5509 | current_link_up = false; | 5508 | current_link_up = false; |
| @@ -2015,12 +2015,15 @@ static int cxgb4_get_module_info(struct net_device *dev, · 2014 unmodified lines | |||
| 2015 | if (ret) | 2015 | if (ret) |
| 2016 | return ret; | 2016 | return ret; |
| 2017 | 2017 | ||
| 2018 | if (!sff8472_comp || (sff_diag_type & 4)) { | 2018 | if (!sff8472_comp || (sff_diag_type & SFP_DIAG_ADDRMODE)) { |
| 2019 | modinfo->type = ETH_MODULE_SFF_8079; | 2019 | modinfo->type = ETH_MODULE_SFF_8079; |
| 2020 | modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; | 2020 | modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; |
| 2021 | } else { | 2021 | } else { |
| 2022 | modinfo->type = ETH_MODULE_SFF_8472; | 2022 | modinfo->type = ETH_MODULE_SFF_8472; |
| 2023 | modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; | 2023 | if (sff_diag_type & SFP_DIAG_IMPLEMENTED) |
| 2024 | modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; | ||
| 2025 | else | ||
| 2026 | modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN / 2; | ||
| 2024 | } | 2027 | } |
| 2025 | break; | 2028 | break; |
| 2026 | 2029 | ||
| @@ -293,6 +293,8 @@ enum { · 292 unmodified lines | |||
| 293 | #define I2C_PAGE_SIZE 0x100 | 293 | #define I2C_PAGE_SIZE 0x100 |
| 294 | #define SFP_DIAG_TYPE_ADDR 0x5c | 294 | #define SFP_DIAG_TYPE_ADDR 0x5c |
| 295 | #define SFP_DIAG_TYPE_LEN 0x1 | 295 | #define SFP_DIAG_TYPE_LEN 0x1 |
| 296 | #define SFP_DIAG_ADDRMODE BIT(2) | ||
| 297 | #define SFP_DIAG_IMPLEMENTED BIT(6) | ||
| 296 | #define SFF_8472_COMP_ADDR 0x5e | 298 | #define SFF_8472_COMP_ADDR 0x5e |
| 297 | #define SFF_8472_COMP_LEN 0x1 | 299 | #define SFF_8472_COMP_LEN 0x1 |
| 298 | #define SFF_REV_ADDR 0x1 | 300 | #define SFF_REV_ADDR 0x1 |
| @@ -1137,7 +1137,7 @@ static void gve_tx_timeout(struct net_device *dev, unsigned int txqueue) · 1136 unmodified lines | |||
| 1137 | goto reset; | 1137 | goto reset; |
| 1138 | 1138 | ||
| 1139 | ntfy_idx = gve_tx_idx_to_ntfy(priv, txqueue); | 1139 | ntfy_idx = gve_tx_idx_to_ntfy(priv, txqueue); |
| 1140 | if (ntfy_idx > priv->num_ntfy_blks) | 1140 | if (ntfy_idx >= priv->num_ntfy_blks) |
| 1141 | goto reset; | 1141 | goto reset; |
| 1142 | 1142 | ||
| 1143 | block = &priv->ntfy_blocks[ntfy_idx]; | 1143 | block = &priv->ntfy_blocks[ntfy_idx]; |
| @@ -500,7 +500,8 @@ static struct sk_buff *gve_rx_skb(struct gve_priv *priv, struct gve_rx_ring *rx, · 499 unmodified lines | |||
| 500 | rx->rx_copied_pkt++; | 500 | rx->rx_copied_pkt++; |
| 501 | rx->rx_frag_copy_cnt++; | 501 | rx->rx_frag_copy_cnt++; |
| 502 | rx->rx_copybreak_pkt++; | 502 | rx->rx_copybreak_pkt++; |
| 503 | } u64_stats_update_end(&rx->statss); | 503 | u64_stats_update_end(&rx->statss); |
| 504 | } | ||
| 504 | } else { | 505 | } else { |
| 505 | if (rx->data.raw_addressing) { | 506 | if (rx->data.raw_addressing) { |
| 506 | int recycle = gve_rx_can_recycle_buffer(page_info); | 507 | int recycle = gve_rx_can_recycle_buffer(page_info); |
| @@ -4210,6 +4210,13 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, · 4209 unmodified lines | |||
| 4210 | } | 4210 | } |
| 4211 | 4211 | ||
| 4212 | out: | 4212 | out: |
| 4213 | /* sync head pointer before exiting, since hardware will calculate | ||
| 4214 | * FBD number with head pointer | ||
| 4215 | */ | ||
| 4216 | if (unused_count > 0) | ||
| 4217 | failure = failure || | ||
| 4218 | hns3_nic_alloc_rx_buffers(ring, unused_count); | ||
| 4219 | |||
| 4213 | return failure ? budget : recv_pkts; | 4220 | return failure ? budget : recv_pkts; |
| 4214 | } | 4221 | } |
| 4215 | 4222 | ||
| @@ -238,9 +238,11 @@ static void hns3_lb_clear_tx_ring(struct hns3_nic_priv *priv, u32 start_ringid, · 237 unmodified lines | |||
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | /** | 240 | /** |
| 241 | * hns3_lp_run_test - run loopback test | 241 | * hns3_lp_run_test - run loopback test |
| 242 | * @ndev: net device | 242 | * @ndev: net device |
| 243 | * @mode: loopback type | 243 | * @mode: loopback type |
| 244 | * | ||
| 245 | * Return: %0 for success or a NIC loopback test error code on failure | ||
| 244 | */ | 246 | */ |
| 245 | static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode) | 247 | static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode) |
| 246 | { | 248 | { |
| @@ -398,7 +400,7 @@ static void hns3_do_selftest(struct net_device *ndev, int (*st_param)[2], · 151 unmodified lines | |||
| 398 | } | 400 | } |
| 399 | 401 | ||
| 400 | /** | 402 | /** |
| 401 | * hns3_nic_self_test - self test | 403 | * hns3_self_test - self test |
| 402 | * @ndev: net device | 404 | * @ndev: net device |
| 403 | * @eth_test: test cmd | 405 | * @eth_test: test cmd |
| 404 | * @data: test result | 406 | * @data: test result |
| @@ -483,6 +483,7 @@ static int hclge_firmware_compat_config(struct hclge_dev *hdev, bool en) · 482 unmodified lines | |||
| 483 | if (hnae3_dev_phy_imp_supported(hdev)) | 483 | if (hnae3_dev_phy_imp_supported(hdev)) |
| 484 | hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1); | 484 | hnae3_set_bit(compat, HCLGE_PHY_IMP_EN_B, 1); |
| 485 | hnae3_set_bit(compat, HCLGE_MAC_STATS_EXT_EN_B, 1); | 485 | hnae3_set_bit(compat, HCLGE_MAC_STATS_EXT_EN_B, 1); |
| 486 | hnae3_set_bit(compat, HCLGE_SYNC_RX_RING_HEAD_EN_B, 1); | ||
| 486 | 487 | ||
| 487 | req->compat = cpu_to_le32(compat); | 488 | req->compat = cpu_to_le32(compat); |
| 488 | } | 489 | } |
| @@ -1151,6 +1151,7 @@ struct hclge_query_ppu_pf_other_int_dfx_cmd { · 1150 unmodified lines | |||
| 1151 | #define HCLGE_NCSI_ERROR_REPORT_EN_B 1 | 1151 | #define HCLGE_NCSI_ERROR_REPORT_EN_B 1 |
| 1152 | #define HCLGE_PHY_IMP_EN_B 2 | 1152 | #define HCLGE_PHY_IMP_EN_B 2 |
| 1153 | #define HCLGE_MAC_STATS_EXT_EN_B 3 | 1153 | #define HCLGE_MAC_STATS_EXT_EN_B 3 |
| 1154 | #define HCLGE_SYNC_RX_RING_HEAD_EN_B 4 | ||
| 1154 | struct hclge_firmware_compat_cmd { | 1155 | struct hclge_firmware_compat_cmd { |
| 1155 | __le32 compat; | 1156 | __le32 compat; |
| 1156 | u8 rsv[20]; | 1157 | u8 rsv[20]; |
| @@ -129,7 +129,7 @@ static int hclge_ets_sch_mode_validate(struct hclge_dev *hdev, · 128 unmodified lines | |||
| 129 | u32 total_ets_bw = 0; | 129 | u32 total_ets_bw = 0; |
| 130 | u8 i; | 130 | u8 i; |
| 131 | 131 | ||
| 132 | for (i = 0; i < hdev->tc_max; i++) { | 132 | for (i = 0; i < HNAE3_MAX_TC; i++) { |
| 133 | switch (ets->tc_tsa[i]) { | 133 | switch (ets->tc_tsa[i]) { |
| 134 | case IEEE_8021QAZ_TSA_STRICT: | 134 | case IEEE_8021QAZ_TSA_STRICT: |
| 135 | if (hdev->tm_info.tc_info[i].tc_sch_mode != | 135 | if (hdev->tm_info.tc_info[i].tc_sch_mode != |
| @@ -286,28 +286,24 @@ err_out: · 150 unmodified lines | |||
| 286 | 286 | ||
| 287 | static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc) | 287 | static int hclge_ieee_getpfc(struct hnae3_handle *h, struct ieee_pfc *pfc) |
| 288 | { | 288 | { |
| 289 | u64 requests[HNAE3_MAX_TC], indications[HNAE3_MAX_TC]; | ||
| 290 | struct hclge_vport *vport = hclge_get_vport(h); | 289 | struct hclge_vport *vport = hclge_get_vport(h); |
| 291 | struct hclge_dev *hdev = vport->back; | 290 | struct hclge_dev *hdev = vport->back; |
| 292 | int ret; | 291 | int ret; |
| 293 | u8 i; | ||
| 294 | 292 | ||
| 295 | memset(pfc, 0, sizeof(*pfc)); | 293 | memset(pfc, 0, sizeof(*pfc)); |
| 296 | pfc->pfc_cap = hdev->pfc_max; | 294 | pfc->pfc_cap = hdev->pfc_max; |
| 297 | pfc->pfc_en = hdev->tm_info.pfc_en; | 295 | pfc->pfc_en = hdev->tm_info.pfc_en; |
| 298 | 296 | ||
| 299 | ret = hclge_pfc_tx_stats_get(hdev, requests); | 297 | ret = hclge_mac_update_stats(hdev); |
| 300 | if (ret) | 298 | if (ret) { |
| 299 | dev_err(&hdev->pdev->dev, | ||
| 300 | "failed to update MAC stats, ret = %d.\n", ret); | ||
| 301 | return ret; | 301 | return ret; |
| 302 | } | ||
| 302 | 303 | ||
| 303 | ret = hclge_pfc_rx_stats_get(hdev, indications); | 304 | hclge_pfc_tx_stats_get(hdev, pfc->requests); |
| 304 | if (ret) | 305 | hclge_pfc_rx_stats_get(hdev, pfc->indications); |
| 305 | return ret; | ||
| 306 | 306 | ||
| 307 | for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { | ||
| 308 | pfc->requests[i] = requests[i]; | ||
| 309 | pfc->indications[i] = indications[i]; | ||
| 310 | } | ||
| 311 | return 0; | 307 | return 0; |
| 312 | } | 308 | } |
| 313 | 309 | ||
| @@ -26,8 +26,6 @@ · 25 unmodified lines | |||
| 26 | #include "hclge_devlink.h" | 26 | #include "hclge_devlink.h" |
| 27 | 27 | ||
| 28 | #define HCLGE_NAME "hclge" | 28 | #define HCLGE_NAME "hclge" |
| 29 | #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset))) | ||
| 30 | #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f)) | ||
| 31 | 29 | ||
| 32 | #define HCLGE_BUF_SIZE_UNIT 256U | 30 | #define HCLGE_BUF_SIZE_UNIT 256U |
| 33 | #define HCLGE_BUF_MUL_BY 2 | 31 | #define HCLGE_BUF_MUL_BY 2 |
| @@ -568,6 +566,16 @@ static int hclge_mac_query_reg_num(struct hclge_dev *hdev, u32 *reg_num) · 534 unmodified lines | |||
| 568 | struct hclge_desc desc; | 566 | struct hclge_desc desc; |
| 569 | int ret; | 567 | int ret; |
| 570 | 568 | ||
| 569 | /* Driver needs total register number of both valid registers and | ||
| 570 | * reserved registers, but the old firmware only returns number | ||
| 571 | * of valid registers in device V2. To be compatible with these | ||
| 572 | * devices, driver uses a fixed value. | ||
| 573 | */ | ||
| 574 | if (hdev->ae_dev->dev_version == HNAE3_DEVICE_VERSION_V2) { | ||
| 575 | *reg_num = HCLGE_MAC_STATS_MAX_NUM_V1; | ||
| 576 | return 0; | ||
| 577 | } | ||
| 578 | |||
| 571 | hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_MAC_REG_NUM, true); | 579 | hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_MAC_REG_NUM, true); |
| 572 | ret = hclge_cmd_send(&hdev->hw, &desc, 1); | 580 | ret = hclge_cmd_send(&hdev->hw, &desc, 1); |
| 573 | if (ret) { | 581 | if (ret) { |
| @@ -587,7 +595,7 @@ static int hclge_mac_query_reg_num(struct hclge_dev *hdev, u32 *reg_num) · 13 unmodified lines | |||
| 587 | return 0; | 595 | return 0; |
| 588 | } | 596 | } |
| 589 | 597 | ||
| 590 | static int hclge_mac_update_stats(struct hclge_dev *hdev) | 598 | int hclge_mac_update_stats(struct hclge_dev *hdev) |
| 591 | { | 599 | { |
| 592 | /* The firmware supports the new statistics acquisition method */ | 600 | /* The firmware supports the new statistics acquisition method */ |
| 593 | if (hdev->ae_dev->dev_specs.mac_stats_num) | 601 | if (hdev->ae_dev->dev_specs.mac_stats_num) |
| @@ -2581,7 +2589,7 @@ static int hclge_init_roce_base_info(struct hclge_vport *vport) · 1987 unmodified lines | |||
| 2581 | if (hdev->num_msi < hdev->num_nic_msi + hdev->num_roce_msi) | 2589 | if (hdev->num_msi < hdev->num_nic_msi + hdev->num_roce_msi) |
| 2582 | return -EINVAL; | 2590 | return -EINVAL; |
| 2583 | 2591 | ||
| 2584 | roce->rinfo.base_vector = hdev->roce_base_vector; | 2592 | roce->rinfo.base_vector = hdev->num_nic_msi; |
| 2585 | 2593 | ||
| 2586 | roce->rinfo.netdev = nic->kinfo.netdev; | 2594 | roce->rinfo.netdev = nic->kinfo.netdev; |
| 2587 | roce->rinfo.roce_io_base = hdev->hw.io_base; | 2595 | roce->rinfo.roce_io_base = hdev->hw.io_base; |
| @@ -2617,10 +2625,6 @@ static int hclge_init_msi(struct hclge_dev *hdev) · 29 unmodified lines | |||
| 2617 | hdev->num_msi = vectors; | 2625 | hdev->num_msi = vectors; |
| 2618 | hdev->num_msi_left = vectors; | 2626 | hdev->num_msi_left = vectors; |
| 2619 | 2627 | ||
| 2620 | hdev->base_msi_vector = pdev->irq; | ||
| 2621 | hdev->roce_base_vector = hdev->base_msi_vector + | ||
| 2622 | hdev->num_nic_msi; | ||
| 2623 | |||
| 2624 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, | 2628 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, |
| 2625 | sizeof(u16), GFP_KERNEL); | 2629 | sizeof(u16), GFP_KERNEL); |
| 2626 | if (!hdev->vector_status) { | 2630 | if (!hdev->vector_status) { |
| @@ -8949,8 +8953,11 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport, · 6322 unmodified lines | |||
| 8949 | 8953 | ||
| 8950 | err_no_space: | 8954 | err_no_space: |
| 8951 | /* if already overflow, not to print each time */ | 8955 | /* if already overflow, not to print each time */ |
| 8952 | if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE)) | 8956 | if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE)) { |
| 8957 | vport->overflow_promisc_flags |= HNAE3_OVERFLOW_MPE; | ||
| 8953 | dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n"); | 8958 | dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n"); |
| 8959 | } | ||
| 8960 | |||
| 8954 | return -ENOSPC; | 8961 | return -ENOSPC; |
| 8955 | } | 8962 | } |
| 8956 | 8963 | ||
| @@ -9006,12 +9013,17 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport, · 49 unmodified lines | |||
| 9006 | 9013 | ||
| 9007 | static void hclge_sync_vport_mac_list(struct hclge_vport *vport, | 9014 | static void hclge_sync_vport_mac_list(struct hclge_vport *vport, |
| 9008 | struct list_head *list, | 9015 | struct list_head *list, |
| 9009 | int (*sync)(struct hclge_vport *, | 9016 | enum HCLGE_MAC_ADDR_TYPE mac_type) |
| 9010 | const unsigned char *)) | ||
| 9011 | { | 9017 | { |
| 9018 | int (*sync)(struct hclge_vport *vport, const unsigned char *addr); | ||
| 9012 | struct hclge_mac_node *mac_node, *tmp; | 9019 | struct hclge_mac_node *mac_node, *tmp; |
| 9013 | int ret; | 9020 | int ret; |
| 9014 | 9021 | ||
| 9022 | if (mac_type == HCLGE_MAC_ADDR_UC) | ||
| 9023 | sync = hclge_add_uc_addr_common; | ||
| 9024 | else | ||
| 9025 | sync = hclge_add_mc_addr_common; | ||
| 9026 | |||
| 9015 | list_for_each_entry_safe(mac_node, tmp, list, node) { | 9027 | list_for_each_entry_safe(mac_node, tmp, list, node) { |
| 9016 | ret = sync(vport, mac_node->mac_addr); | 9028 | ret = sync(vport, mac_node->mac_addr); |
| 9017 | if (!ret) { | 9029 | if (!ret) { |
| @@ -9023,8 +9035,13 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport, · 5 unmodified lines | |||
| 9023 | /* If one unicast mac address is existing in hardware, | 9035 | /* If one unicast mac address is existing in hardware, |
| 9024 | * we need to try whether other unicast mac addresses | 9036 | * we need to try whether other unicast mac addresses |
| 9025 | * are new addresses that can be added. | 9037 | * are new addresses that can be added. |
| 9038 | * Multicast mac address can be reusable, even though | ||
| 9039 | * there is no space to add new multicast mac address, | ||
| 9040 | * we should check whether other mac addresses are | ||
| 9041 | * existing in hardware for reuse. | ||
| 9026 | */ | 9042 | */ |
| 9027 | if (ret != -EEXIST) | 9043 | if ((mac_type == HCLGE_MAC_ADDR_UC && ret != -EEXIST) || |
| 9044 | (mac_type == HCLGE_MAC_ADDR_MC && ret != -ENOSPC)) | ||
| 9028 | break; | 9045 | break; |
| 9029 | } | 9046 | } |
| 9030 | } | 9047 | } |
| @@ -9032,12 +9049,17 @@ static void hclge_sync_vport_mac_list(struct hclge_vport *vport, · 1 unmodified line | |||
| 9032 | 9049 | ||
| 9033 | static void hclge_unsync_vport_mac_list(struct hclge_vport *vport, | 9050 | static void hclge_unsync_vport_mac_list(struct hclge_vport *vport, |
| 9034 | struct list_head *list, | 9051 | struct list_head *list, |
| 9035 | int (*unsync)(struct hclge_vport *, | 9052 | enum HCLGE_MAC_ADDR_TYPE mac_type) |
| 9036 | const unsigned char *)) | ||
| 9037 | { | 9053 | { |
| 9054 | int (*unsync)(struct hclge_vport *vport, const unsigned char *addr); | ||
| 9038 | struct hclge_mac_node *mac_node, *tmp; | 9055 | struct hclge_mac_node *mac_node, *tmp; |
| 9039 | int ret; | 9056 | int ret; |
| 9040 | 9057 | ||
| 9058 | if (mac_type == HCLGE_MAC_ADDR_UC) | ||
| 9059 | unsync = hclge_rm_uc_addr_common; | ||
| 9060 | else | ||
| 9061 | unsync = hclge_rm_mc_addr_common; | ||
| 9062 | |||
| 9041 | list_for_each_entry_safe(mac_node, tmp, list, node) { | 9063 | list_for_each_entry_safe(mac_node, tmp, list, node) { |
| 9042 | ret = unsync(vport, mac_node->mac_addr); | 9064 | ret = unsync(vport, mac_node->mac_addr); |
| 9043 | if (!ret || ret == -ENOENT) { | 9065 | if (!ret || ret == -ENOENT) { |
| @@ -9168,17 +9190,8 @@ stop_traverse: · 124 unmodified lines | |||
| 9168 | spin_unlock_bh(&vport->mac_list_lock); | 9190 | spin_unlock_bh(&vport->mac_list_lock); |
| 9169 | 9191 | ||
| 9170 | /* delete first, in order to get max mac table space for adding */ | 9192 | /* delete first, in order to get max mac table space for adding */ |
| 9171 | if (mac_type == HCLGE_MAC_ADDR_UC) { | 9193 | hclge_unsync_vport_mac_list(vport, &tmp_del_list, mac_type); |
| 9172 | hclge_unsync_vport_mac_list(vport, &tmp_del_list, | 9194 | hclge_sync_vport_mac_list(vport, &tmp_add_list, mac_type); |
| 9173 | hclge_rm_uc_addr_common); | ||
| 9174 | hclge_sync_vport_mac_list(vport, &tmp_add_list, | ||
| 9175 | hclge_add_uc_addr_common); | ||
| 9176 | } else { | ||
| 9177 | hclge_unsync_vport_mac_list(vport, &tmp_del_list, | ||
| 9178 | hclge_rm_mc_addr_common); | ||
| 9179 | hclge_sync_vport_mac_list(vport, &tmp_add_list, | ||
| 9180 | hclge_add_mc_addr_common); | ||
| 9181 | } | ||
| 9182 | 9195 | ||
| 9183 | /* if some mac addresses were added/deleted fail, move back to the | 9196 | /* if some mac addresses were added/deleted fail, move back to the |
| 9184 | * mac_list, and retry at next time. | 9197 | * mac_list, and retry at next time. |
| @@ -9337,12 +9350,7 @@ static void hclge_uninit_vport_mac_list(struct hclge_vport *vport, · 152 unmodified lines | |||
| 9337 | 9350 | ||
| 9338 | spin_unlock_bh(&vport->mac_list_lock); | 9351 | spin_unlock_bh(&vport->mac_list_lock); |
| 9339 | 9352 | ||
| 9340 | if (mac_type == HCLGE_MAC_ADDR_UC) | 9353 | hclge_unsync_vport_mac_list(vport, &tmp_del_list, mac_type); |
| 9341 | hclge_unsync_vport_mac_list(vport, &tmp_del_list, | ||
| 9342 | hclge_rm_uc_addr_common); | ||
| 9343 | else | ||
| 9344 | hclge_unsync_vport_mac_list(vport, &tmp_del_list, | ||
| 9345 | hclge_rm_mc_addr_common); | ||
| 9346 | 9354 | ||
| 9347 | if (!list_empty(&tmp_del_list)) | 9355 | if (!list_empty(&tmp_del_list)) |
| 9348 | dev_warn(&hdev->pdev->dev, | 9356 | dev_warn(&hdev->pdev->dev, |
| @@ -9410,36 +9418,6 @@ static int hclge_get_mac_ethertype_cmd_status(struct hclge_dev *hdev, · 61 unmodified lines | |||
| 9410 | return return_status; | 9418 | return return_status; |
| 9411 | } | 9419 | } |
| 9412 | 9420 | ||
| 9413 | static bool hclge_check_vf_mac_exist(struct hclge_vport *vport, int vf_idx, | ||
| 9414 | u8 *mac_addr) | ||
| 9415 | { | ||
| 9416 | struct hclge_mac_vlan_tbl_entry_cmd req; | ||
| 9417 | struct hclge_dev *hdev = vport->back; | ||
| 9418 | struct hclge_desc desc; | ||
| 9419 | u16 egress_port = 0; | ||
| 9420 | int i; | ||
| 9421 | |||
| 9422 | if (is_zero_ether_addr(mac_addr)) | ||
| 9423 | return false; | ||
| 9424 | |||
| 9425 | memset(&req, 0, sizeof(req)); | ||
| 9426 | hnae3_set_field(egress_port, HCLGE_MAC_EPORT_VFID_M, | ||
| 9427 | HCLGE_MAC_EPORT_VFID_S, vport->vport_id); | ||
| 9428 | req.egress_port = cpu_to_le16(egress_port); | ||
| 9429 | hclge_prepare_mac_addr(&req, mac_addr, false); | ||
| 9430 | |||
| 9431 | if (hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false) != -ENOENT) | ||
| 9432 | return true; | ||
| 9433 | |||
| 9434 | vf_idx += HCLGE_VF_VPORT_START_NUM; | ||
| 9435 | for (i = HCLGE_VF_VPORT_START_NUM; i < hdev->num_alloc_vport; i++) | ||
| 9436 | if (i != vf_idx && | ||
| 9437 | ether_addr_equal(mac_addr, hdev->vport[i].vf_info.mac)) | ||
| 9438 | return true; | ||
| 9439 | |||
| 9440 | return false; | ||
| 9441 | } | ||
| 9442 | |||
| 9443 | static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, | 9421 | static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, |
| 9444 | u8 *mac_addr) | 9422 | u8 *mac_addr) |
| 9445 | { | 9423 | { |
| @@ -9457,12 +9435,6 @@ static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, · 11 unmodified lines | |||
| 9457 | return 0; | 9435 | return 0; |
| 9458 | } | 9436 | } |
| 9459 | 9437 | ||
| 9460 | if (hclge_check_vf_mac_exist(vport, vf, mac_addr)) { | ||
| 9461 | dev_err(&hdev->pdev->dev, "Specified MAC(=%pM) exists!\n", | ||
| 9462 | mac_addr); | ||
| 9463 | return -EEXIST; | ||
| 9464 | } | ||
| 9465 | |||
| 9466 | ether_addr_copy(vport->vf_info.mac, mac_addr); | 9438 | ether_addr_copy(vport->vf_info.mac, mac_addr); |
| 9467 | 9439 | ||
| 9468 | if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) { | 9440 | if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) { |
| @@ -404,7 +404,7 @@ struct hclge_tm_info { · 403 unmodified lines | |||
| 404 | }; | 404 | }; |
| 405 | 405 | ||
| 406 | /* max number of mac statistics on each version */ | 406 | /* max number of mac statistics on each version */ |
| 407 | #define HCLGE_MAC_STATS_MAX_NUM_V1 84 | 407 | #define HCLGE_MAC_STATS_MAX_NUM_V1 87 |
| 408 | #define HCLGE_MAC_STATS_MAX_NUM_V2 105 | 408 | #define HCLGE_MAC_STATS_MAX_NUM_V2 105 |
| 409 | 409 | ||
| 410 | struct hclge_comm_stats_str { | 410 | struct hclge_comm_stats_str { |
| @@ -852,6 +852,9 @@ struct hclge_vf_vlan_cfg { · 441 unmodified lines | |||
| 852 | (y) = (_k_ ^ ~_v_) & (_k_); \ | 852 | (y) = (_k_ ^ ~_v_) & (_k_); \ |
| 853 | } while (0) | 853 | } while (0) |
| 854 | 854 | ||
| 855 | #define HCLGE_MAC_STATS_FIELD_OFF(f) (offsetof(struct hclge_mac_stats, f)) | ||
| 856 | #define HCLGE_STATS_READ(p, offset) (*(u64 *)((u8 *)(p) + (offset))) | ||
| 857 | |||
| 855 | #define HCLGE_MAC_TNL_LOG_SIZE 8 | 858 | #define HCLGE_MAC_TNL_LOG_SIZE 8 |
| 856 | #define HCLGE_VPORT_NUM 256 | 859 | #define HCLGE_VPORT_NUM 256 |
| 857 | struct hclge_dev { | 860 | struct hclge_dev { |
| @@ -904,12 +907,10 @@ struct hclge_dev { · 46 unmodified lines | |||
| 904 | u16 num_msi; | 907 | u16 num_msi; |
| 905 | u16 num_msi_left; | 908 | u16 num_msi_left; |
| 906 | u16 num_msi_used; | 909 | u16 num_msi_used; |
| 907 | u32 base_msi_vector; | ||
| 908 | u16 *vector_status; | 910 | u16 *vector_status; |
| 909 | int *vector_irq; | 911 | int *vector_irq; |
| 910 | u16 num_nic_msi; /* Num of nic vectors for this PF */ | 912 | u16 num_nic_msi; /* Num of nic vectors for this PF */ |
| 911 | u16 num_roce_msi; /* Num of roce vectors for this PF */ | 913 | u16 num_roce_msi; /* Num of roce vectors for this PF */ |
| 912 | int roce_base_vector; | ||
| 913 | 914 | ||
| 914 | unsigned long service_timer_period; | 915 | unsigned long service_timer_period; |
| 915 | unsigned long service_timer_previous; | 916 | unsigned long service_timer_previous; |
| @@ -1168,4 +1169,5 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport); · 252 unmodified lines | |||
| 1168 | int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len); | 1169 | int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len); |
| 1169 | int hclge_push_vf_link_status(struct hclge_vport *vport); | 1170 | int hclge_push_vf_link_status(struct hclge_vport *vport); |
| 1170 | int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en); | 1171 | int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request_en); |
| 1172 | int hclge_mac_update_stats(struct hclge_dev *hdev); | ||
| 1171 | #endif | 1173 | #endif |
| @@ -113,50 +113,50 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level, · 112 unmodified lines | |||
| 113 | return 0; | 113 | return 0; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | static int hclge_pfc_stats_get(struct hclge_dev *hdev, | 116 | static const u16 hclge_pfc_tx_stats_offset[] = { |
| 117 | enum hclge_opcode_type opcode, u64 *stats) | 117 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri0_pkt_num), |
| 118 | { | 118 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri1_pkt_num), |
| 119 | struct hclge_desc desc[HCLGE_TM_PFC_PKT_GET_CMD_NUM]; | 119 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri2_pkt_num), |
| 120 | int ret, i, j; | 120 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri3_pkt_num), |
| 121 | 121 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri4_pkt_num), | |
| 122 | if (!(opcode == HCLGE_OPC_QUERY_PFC_RX_PKT_CNT || | 122 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri5_pkt_num), |
| 123 | opcode == HCLGE_OPC_QUERY_PFC_TX_PKT_CNT)) | 123 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri6_pkt_num), |
| 124 | return -EINVAL; | 124 | HCLGE_MAC_STATS_FIELD_OFF(mac_tx_pfc_pri7_pkt_num) |
| 125 | 125 | }; | |
| 126 | for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM - 1; i++) { | ||
| 127 | hclge_cmd_setup_basic_desc(&desc[i], opcode, true); | ||
| 128 | desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); | ||
| 129 | } | ||
| 130 | |||
| 131 | hclge_cmd_setup_basic_desc(&desc[i], opcode, true); | ||
| 132 | 126 | ||
| 133 | ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_TM_PFC_PKT_GET_CMD_NUM); | 127 | static const u16 hclge_pfc_rx_stats_offset[] = { |
| 134 | if (ret) | 128 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri0_pkt_num), |
| 135 | return ret; | 129 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri1_pkt_num), |
| 130 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri2_pkt_num), | ||
| 131 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri3_pkt_num), | ||
| 132 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri4_pkt_num), | ||
| 133 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri5_pkt_num), | ||
| 134 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri6_pkt_num), | ||
| 135 | HCLGE_MAC_STATS_FIELD_OFF(mac_rx_pfc_pri7_pkt_num) | ||
| 136 | }; | ||
| 136 | 137 | ||
| 137 | for (i = 0; i < HCLGE_TM_PFC_PKT_GET_CMD_NUM; i++) { | 138 | static void hclge_pfc_stats_get(struct hclge_dev *hdev, bool tx, u64 *stats) |
| 138 | struct hclge_pfc_stats_cmd *pfc_stats = | 139 | { |
| 139 | (struct hclge_pfc_stats_cmd *)desc[i].data; | 140 | const u16 *offset; |
| 141 | int i; | ||
| 140 | 142 | ||
| 141 | for (j = 0; j < HCLGE_TM_PFC_NUM_GET_PER_CMD; j++) { | 143 | if (tx) |
| 142 | u32 index = i * HCLGE_TM_PFC_PKT_GET_CMD_NUM + j; | 144 | offset = hclge_pfc_tx_stats_offset; |
| 145 | else | ||
| 146 | offset = hclge_pfc_rx_stats_offset; | ||
| 143 | 147 | ||
| 144 | if (index < HCLGE_MAX_TC_NUM) | 148 | for (i = 0; i < HCLGE_MAX_TC_NUM; i++) |
| 145 | stats[index] = | 149 | stats[i] = HCLGE_STATS_READ(&hdev->mac_stats, offset[i]); |
| 146 | le64_to_cpu(pfc_stats->pkt_num[j]); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | return 0; | ||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats) | 152 | void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats) |
| 153 | { | 153 | { |
| 154 | return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_RX_PKT_CNT, stats); | 154 | hclge_pfc_stats_get(hdev, false, stats); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats) | 157 | void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats) |
| 158 | { | 158 | { |
| 159 | return hclge_pfc_stats_get(hdev, HCLGE_OPC_QUERY_PFC_TX_PKT_CNT, stats); | 159 | hclge_pfc_stats_get(hdev, true, stats); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx) | 162 | int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx) |
| @@ -1123,7 +1123,6 @@ static int hclge_tm_pri_tc_base_dwrr_cfg(struct hclge_dev *hdev) · 960 unmodified lines | |||
| 1123 | 1123 | ||
| 1124 | static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev) | 1124 | static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev) |
| 1125 | { | 1125 | { |
| 1126 | #define DEFAULT_TC_WEIGHT 1 | ||
| 1127 | #define DEFAULT_TC_OFFSET 14 | 1126 | #define DEFAULT_TC_OFFSET 14 |
| 1128 | 1127 | ||
| 1129 | struct hclge_ets_tc_weight_cmd *ets_weight; | 1128 | struct hclge_ets_tc_weight_cmd *ets_weight; |
| @@ -1136,13 +1135,7 @@ static int hclge_tm_ets_tc_dwrr_cfg(struct hclge_dev *hdev) · 6 unmodified lines | |||
| 1136 | for (i = 0; i < HNAE3_MAX_TC; i++) { | 1135 | for (i = 0; i < HNAE3_MAX_TC; i++) { |
| 1137 | struct hclge_pg_info *pg_info; | 1136 | struct hclge_pg_info *pg_info; |
| 1138 | 1137 | ||
| 1139 | ets_weight->tc_weight[i] = DEFAULT_TC_WEIGHT; | 1138 | pg_info = &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; |
| 1140 | |||
| 1141 | if (!(hdev->hw_tc_map & BIT(i))) | ||
| 1142 | continue; | ||
| 1143 | |||
| 1144 | pg_info = | ||
| 1145 | &hdev->tm_info.pg_info[hdev->tm_info.tc_info[i].pgid]; | ||
| 1146 | ets_weight->tc_weight[i] = pg_info->tc_dwrr[i]; | 1139 | ets_weight->tc_weight[i] = pg_info->tc_dwrr[i]; |
| 1147 | } | 1140 | } |
| 1148 | 1141 | ||
| @@ -228,8 +228,8 @@ int hclge_tm_dwrr_cfg(struct hclge_dev *hdev); · 227 unmodified lines | |||
| 228 | int hclge_tm_init_hw(struct hclge_dev *hdev, bool init); | 228 | int hclge_tm_init_hw(struct hclge_dev *hdev, bool init); |
| 229 | int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx); | 229 | int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx); |
| 230 | int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); | 230 | int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); |
| 231 | int hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); | 231 | void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats); |
| 232 | int hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); | 232 | void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats); |
| 233 | int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate); | 233 | int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate); |
| 234 | int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num); | 234 | int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num); |
| 235 | int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num); | 235 | int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num); |
| @@ -434,8 +434,28 @@ err_csq: · 433 unmodified lines | |||
| 434 | return ret; | 434 | return ret; |
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | static int hclgevf_firmware_compat_config(struct hclgevf_dev *hdev, bool en) | ||
| 438 | { | ||
| 439 | struct hclgevf_firmware_compat_cmd *req; | ||
| 440 | struct hclgevf_desc desc; | ||
| 441 | u32 compat = 0; | ||
| 442 | |||
| 443 | hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_IMP_COMPAT_CFG, false); | ||
| 444 | |||
| 445 | if (en) { | ||
| 446 | req = (struct hclgevf_firmware_compat_cmd *)desc.data; | ||
| 447 | |||
| 448 | hnae3_set_bit(compat, HCLGEVF_SYNC_RX_RING_HEAD_EN_B, 1); | ||
| 449 | |||
| 450 | req->compat = cpu_to_le32(compat); | ||
| 451 | } | ||
| 452 | |||
| 453 | return hclgevf_cmd_send(&hdev->hw, &desc, 1); | ||
| 454 | } | ||
| 455 | |||
| 437 | int hclgevf_cmd_init(struct hclgevf_dev *hdev) | 456 | int hclgevf_cmd_init(struct hclgevf_dev *hdev) |
| 438 | { | 457 | { |
| 458 | struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); | ||
| 439 | int ret; | 459 | int ret; |
| 440 | 460 | ||
| 441 | spin_lock_bh(&hdev->hw.cmq.csq.lock); | 461 | spin_lock_bh(&hdev->hw.cmq.csq.lock); |
| @@ -484,6 +504,17 @@ int hclgevf_cmd_init(struct hclgevf_dev *hdev) · 42 unmodified lines | |||
| 484 | hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK, | 504 | hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK, |
| 485 | HNAE3_FW_VERSION_BYTE0_SHIFT)); | 505 | HNAE3_FW_VERSION_BYTE0_SHIFT)); |
| 486 | 506 | ||
| 507 | if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) { | ||
| 508 | /* ask the firmware to enable some features, driver can work | ||
| 509 | * without it. | ||
| 510 | */ | ||
| 511 | ret = hclgevf_firmware_compat_config(hdev, true); | ||
| 512 | if (ret) | ||
| 513 | dev_warn(&hdev->pdev->dev, | ||
| 514 | "Firmware compatible features not enabled(%d).\n", | ||
| 515 | ret); | ||
| 516 | } | ||
| 517 | |||
| 487 | return 0; | 518 | return 0; |
| 488 | 519 | ||
| 489 | err_cmd_init: | 520 | err_cmd_init: |
| @@ -508,6 +539,7 @@ static void hclgevf_cmd_uninit_regs(struct hclgevf_hw *hw) · 18 unmodified lines | |||
| 508 | 539 | ||
| 509 | void hclgevf_cmd_uninit(struct hclgevf_dev *hdev) | 540 | void hclgevf_cmd_uninit(struct hclgevf_dev *hdev) |
| 510 | { | 541 | { |
| 542 | hclgevf_firmware_compat_config(hdev, false); | ||
| 511 | set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state); | 543 | set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state); |
| 512 | /* wait to ensure that the firmware completes the possible left | 544 | /* wait to ensure that the firmware completes the possible left |
| 513 | * over commands. | 545 | * over commands. |
| @@ -15,6 +15,12 @@ · 14 unmodified lines | |||
| 15 | struct hclgevf_hw; | 15 | struct hclgevf_hw; |
| 16 | struct hclgevf_dev; | 16 | struct hclgevf_dev; |
| 17 | 17 | ||
| 18 | #define HCLGEVF_SYNC_RX_RING_HEAD_EN_B 4 | ||
| 19 | struct hclgevf_firmware_compat_cmd { | ||
| 20 | __le32 compat; | ||
| 21 | u8 rsv[20]; | ||
| 22 | }; | ||
| 23 | |||
| 18 | struct hclgevf_desc { | 24 | struct hclgevf_desc { |
| 19 | __le16 opcode; | 25 | __le16 opcode; |
| 20 | __le16 flag; | 26 | __le16 flag; |
| @@ -107,6 +113,9 @@ enum hclgevf_opcode_type { · 86 unmodified lines | |||
| 107 | HCLGEVF_OPC_RSS_TC_MODE = 0x0D08, | 113 | HCLGEVF_OPC_RSS_TC_MODE = 0x0D08, |
| 108 | /* Mailbox cmd */ | 114 | /* Mailbox cmd */ |
| 109 | HCLGEVF_OPC_MBX_VF_TO_PF = 0x2001, | 115 | HCLGEVF_OPC_MBX_VF_TO_PF = 0x2001, |
| 116 | |||
| 117 | /* IMP stats command */ | ||
| 118 | HCLGEVF_OPC_IMP_COMPAT_CFG = 0x701A, | ||
| 110 | }; | 119 | }; |
| 111 | 120 | ||
| 112 | #define HCLGEVF_TQP_REG_OFFSET 0x80000 | 121 | #define HCLGEVF_TQP_REG_OFFSET 0x80000 |
| @@ -2557,7 +2557,7 @@ static int hclgevf_init_roce_base_info(struct hclgevf_dev *hdev) · 2556 unmodified lines | |||
| 2557 | hdev->num_msi_left == 0) | 2557 | hdev->num_msi_left == 0) |
| 2558 | return -EINVAL; | 2558 | return -EINVAL; |
| 2559 | 2559 | ||
| 2560 | roce->rinfo.base_vector = hdev->roce_base_vector; | 2560 | roce->rinfo.base_vector = hdev->roce_base_msix_offset; |
| 2561 | 2561 | ||
| 2562 | roce->rinfo.netdev = nic->kinfo.netdev; | 2562 | roce->rinfo.netdev = nic->kinfo.netdev; |
| 2563 | roce->rinfo.roce_io_base = hdev->hw.io_base; | 2563 | roce->rinfo.roce_io_base = hdev->hw.io_base; |
| @@ -2823,9 +2823,6 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev) · 259 unmodified lines | |||
| 2823 | hdev->num_msi = vectors; | 2823 | hdev->num_msi = vectors; |
| 2824 | hdev->num_msi_left = vectors; | 2824 | hdev->num_msi_left = vectors; |
| 2825 | 2825 | ||
| 2826 | hdev->base_msi_vector = pdev->irq; | ||
| 2827 | hdev->roce_base_vector = pdev->irq + hdev->roce_base_msix_offset; | ||
| 2828 | |||
| 2829 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, | 2826 | hdev->vector_status = devm_kcalloc(&pdev->dev, hdev->num_msi, |
| 2830 | sizeof(u16), GFP_KERNEL); | 2827 | sizeof(u16), GFP_KERNEL); |
| 2831 | if (!hdev->vector_status) { | 2828 | if (!hdev->vector_status) { |
| @@ -3013,7 +3010,10 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, · 181 unmodified lines | |||
| 3013 | 3010 | ||
| 3014 | /* un-init roce, if it exists */ | 3011 | /* un-init roce, if it exists */ |
| 3015 | if (hdev->roce_client) { | 3012 | if (hdev->roce_client) { |
| 3013 | while (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) | ||
| 3014 | msleep(HCLGEVF_WAIT_RESET_DONE); | ||
| 3016 | clear_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state); | 3015 | clear_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state); |
| 3016 | |||
| 3017 | hdev->roce_client->ops->uninit_instance(&hdev->roce, 0); | 3017 | hdev->roce_client->ops->uninit_instance(&hdev->roce, 0); |
| 3018 | hdev->roce_client = NULL; | 3018 | hdev->roce_client = NULL; |
| 3019 | hdev->roce.client = NULL; | 3019 | hdev->roce.client = NULL; |
| @@ -3022,6 +3022,8 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, · 2 unmodified lines | |||
| 3022 | /* un-init nic/unic, if this was not called by roce client */ | 3022 | /* un-init nic/unic, if this was not called by roce client */ |
| 3023 | if (client->ops->uninit_instance && hdev->nic_client && | 3023 | if (client->ops->uninit_instance && hdev->nic_client && |
| 3024 | client->type != HNAE3_CLIENT_ROCE) { | 3024 | client->type != HNAE3_CLIENT_ROCE) { |
| 3025 | while (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) | ||
| 3026 | msleep(HCLGEVF_WAIT_RESET_DONE); | ||
| 3025 | clear_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state); | 3027 | clear_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state); |
| 3026 | 3028 | ||
| 3027 | client->ops->uninit_instance(&hdev->nic, 0); | 3029 | client->ops->uninit_instance(&hdev->nic, 0); |
| @@ -109,6 +109,8 @@ · 108 unmodified lines | |||
| 109 | #define HCLGEVF_VF_RST_ING 0x07008 | 109 | #define HCLGEVF_VF_RST_ING 0x07008 |
| 110 | #define HCLGEVF_VF_RST_ING_BIT BIT(16) | 110 | #define HCLGEVF_VF_RST_ING_BIT BIT(16) |
| 111 | 111 | ||
| 112 | #define HCLGEVF_WAIT_RESET_DONE 100 | ||
| 113 | |||
| 112 | #define HCLGEVF_RSS_IND_TBL_SIZE 512 | 114 | #define HCLGEVF_RSS_IND_TBL_SIZE 512 |
| 113 | #define HCLGEVF_RSS_SET_BITMAP_MSK 0xffff | 115 | #define HCLGEVF_RSS_SET_BITMAP_MSK 0xffff |
| 114 | #define HCLGEVF_RSS_KEY_SIZE 40 | 116 | #define HCLGEVF_RSS_KEY_SIZE 40 |
| @@ -308,8 +310,6 @@ struct hclgevf_dev { · 193 unmodified lines | |||
| 308 | u16 num_nic_msix; /* Num of nic vectors for this VF */ | 310 | u16 num_nic_msix; /* Num of nic vectors for this VF */ |
| 309 | u16 num_roce_msix; /* Num of roce vectors for this VF */ | 311 | u16 num_roce_msix; /* Num of roce vectors for this VF */ |
| 310 | u16 roce_base_msix_offset; | 312 | u16 roce_base_msix_offset; |
| 311 | int roce_base_vector; | ||
| 312 | u32 base_msi_vector; | ||
| 313 | u16 *vector_status; | 313 | u16 *vector_status; |
| 314 | int *vector_irq; | 314 | int *vector_irq; |
| 315 | 315 | ||
| @@ -165,13 +165,10 @@ · 164 unmodified lines | |||
| 165 | #define ice_for_each_chnl_tc(i) \ | 165 | #define ice_for_each_chnl_tc(i) \ |
| 166 | for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++) | 166 | for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++) |
| 167 | 167 | ||
| 168 | #define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX | \ | 168 | #define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_UCAST_RX) |
| 169 | ICE_PROMISC_UCAST_RX | ICE_PROMISC_MCAST_RX) | ||
| 170 | 169 | ||
| 171 | #define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \ | 170 | #define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \ |
| 172 | ICE_PROMISC_MCAST_TX | \ | ||
| 173 | ICE_PROMISC_UCAST_RX | \ | 171 | ICE_PROMISC_UCAST_RX | \ |
| 174 | ICE_PROMISC_MCAST_RX | \ | ||
| 175 | ICE_PROMISC_VLAN_TX | \ | 172 | ICE_PROMISC_VLAN_TX | \ |
| 176 | ICE_PROMISC_VLAN_RX) | 173 | ICE_PROMISC_VLAN_RX) |
| 177 | 174 | ||
| @@ -962,7 +962,7 @@ ice_vsi_stop_tx_ring(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, · 961 unmodified lines | |||
| 962 | } else if (status == ICE_ERR_DOES_NOT_EXIST) { | 962 | } else if (status == ICE_ERR_DOES_NOT_EXIST) { |
| 963 | dev_dbg(ice_pf_to_dev(vsi->back), "LAN Tx queues do not exist, nothing to disable\n"); | 963 | dev_dbg(ice_pf_to_dev(vsi->back), "LAN Tx queues do not exist, nothing to disable\n"); |
| 964 | } else if (status) { | 964 | } else if (status) { |
| 965 | dev_err(ice_pf_to_dev(vsi->back), "Failed to disable LAN Tx queues, error: %s\n", | 965 | dev_dbg(ice_pf_to_dev(vsi->back), "Failed to disable LAN Tx queues, error: %s\n", |
| 966 | ice_stat_str(status)); | 966 | ice_stat_str(status)); |
| 967 | return -ENODEV; | 967 | return -ENODEV; |
| 968 | } | 968 | } |
| @@ -638,8 +638,7 @@ void ice_free_vfs(struct ice_pf *pf) · 637 unmodified lines | |||
| 638 | 638 | ||
| 639 | /* Avoid wait time by stopping all VFs at the same time */ | 639 | /* Avoid wait time by stopping all VFs at the same time */ |
| 640 | ice_for_each_vf(pf, i) | 640 | ice_for_each_vf(pf, i) |
| 641 | if (test_bit(ICE_VF_STATE_QS_ENA, pf->vf[i].vf_states)) | 641 | ice_dis_vf_qs(&pf->vf[i]); |
| 642 | ice_dis_vf_qs(&pf->vf[i]); | ||
| 643 | 642 | ||
| 644 | tmp = pf->num_alloc_vfs; | 643 | tmp = pf->num_alloc_vfs; |
| 645 | pf->num_qps_per_vf = 0; | 644 | pf->num_qps_per_vf = 0; |
| @@ -651,6 +650,8 @@ void ice_free_vfs(struct ice_pf *pf) · 5 unmodified lines | |||
| 651 | set_bit(ICE_VF_STATE_DIS, pf->vf[i].vf_states); | 650 | set_bit(ICE_VF_STATE_DIS, pf->vf[i].vf_states); |
| 652 | ice_free_vf_res(&pf->vf[i]); | 651 | ice_free_vf_res(&pf->vf[i]); |
| 653 | } | 652 | } |
| 653 | |||
| 654 | mutex_destroy(&pf->vf[i].cfg_lock); | ||
| 654 | } | 655 | } |
| 655 | 656 | ||
| 656 | if (ice_sriov_free_msix_res(pf)) | 657 | if (ice_sriov_free_msix_res(pf)) |
| @@ -1695,8 +1696,7 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) · 1038 unmodified lines | |||
| 1695 | 1696 | ||
| 1696 | vsi = ice_get_vf_vsi(vf); | 1697 | vsi = ice_get_vf_vsi(vf); |
| 1697 | 1698 | ||
| 1698 | if (test_bit(ICE_VF_STATE_QS_ENA, vf->vf_states)) | 1699 | ice_dis_vf_qs(vf); |
| 1699 | ice_dis_vf_qs(vf); | ||
| 1700 | 1700 | ||
| 1701 | /* Call Disable LAN Tx queue AQ whether or not queues are | 1701 | /* Call Disable LAN Tx queue AQ whether or not queues are |
| 1702 | * enabled. This is needed for successful completion of VFR. | 1702 | * enabled. This is needed for successful completion of VFR. |
| @@ -1948,6 +1948,8 @@ static void ice_set_dflt_settings_vfs(struct ice_pf *pf) · 245 unmodified lines | |||
| 1948 | ice_vf_fdir_init(vf); | 1948 | ice_vf_fdir_init(vf); |
| 1949 | 1949 | ||
| 1950 | ice_vc_set_dflt_vf_ops(&vf->vc_ops); | 1950 | ice_vc_set_dflt_vf_ops(&vf->vc_ops); |
| 1951 | |||
| 1952 | mutex_init(&vf->cfg_lock); | ||
| 1951 | } | 1953 | } |
| 1952 | } | 1954 | } |
| 1953 | 1955 | ||
| @@ -3013,6 +3015,7 @@ bool ice_is_any_vf_in_promisc(struct ice_pf *pf) · 1059 unmodified lines | |||
| 3013 | static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) | 3015 | static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) |
| 3014 | { | 3016 | { |
| 3015 | enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS; | 3017 | enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS; |
| 3018 | enum ice_status mcast_status = 0, ucast_status = 0; | ||
| 3016 | bool rm_promisc, alluni = false, allmulti = false; | 3019 | bool rm_promisc, alluni = false, allmulti = false; |
| 3017 | struct virtchnl_promisc_info *info = | 3020 | struct virtchnl_promisc_info *info = |
| 3018 | (struct virtchnl_promisc_info *)msg; | 3021 | (struct virtchnl_promisc_info *)msg; |
| @@ -3054,24 +3057,6 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) · 35 unmodified lines | |||
| 3054 | rm_promisc = !allmulti && !alluni; | 3057 | rm_promisc = !allmulti && !alluni; |
| 3055 | 3058 | ||
| 3056 | if (vsi->num_vlan || vf->port_vlan_info) { | 3059 | if (vsi->num_vlan || vf->port_vlan_info) { |
| 3057 | struct ice_vsi *pf_vsi = ice_get_main_vsi(pf); | ||
| 3058 | struct net_device *pf_netdev; | ||
| 3059 | |||
| 3060 | if (!pf_vsi) { | ||
| 3061 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 3062 | goto error_param; | ||
| 3063 | } | ||
| 3064 | |||
| 3065 | pf_netdev = pf_vsi->netdev; | ||
| 3066 | |||
| 3067 | ret = ice_set_vf_spoofchk(pf_netdev, vf->vf_id, rm_promisc); | ||
| 3068 | if (ret) { | ||
| 3069 | dev_err(dev, "Failed to update spoofchk to %s for VF %d VSI %d when setting promiscuous mode\n", | ||
| 3070 | rm_promisc ? "ON" : "OFF", vf->vf_id, | ||
| 3071 | vsi->vsi_num); | ||
| 3072 | v_ret = VIRTCHNL_STATUS_ERR_PARAM; | ||
| 3073 | } | ||
| 3074 | |||
| 3075 | if (rm_promisc) | 3060 | if (rm_promisc) |
| 3076 | ret = ice_cfg_vlan_pruning(vsi, true); | 3061 | ret = ice_cfg_vlan_pruning(vsi, true); |
| 3077 | else | 3062 | else |
| @@ -3105,52 +3090,51 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg) · 27 unmodified lines | |||
| 3105 | goto error_param; | 3090 | goto error_param; |
| 3106 | } | 3091 | } |
| 3107 | } else { | 3092 | } else { |
| 3108 | enum ice_status status; | 3093 | u8 mcast_m, ucast_m; |
| 3109 | u8 promisc_m; | 3094 | |
| 3110 | 3095 | if (vf->port_vlan_info || vsi->num_vlan > 1) { | |
| 3111 | if (alluni) { | 3096 | mcast_m = ICE_MCAST_VLAN_PROMISC_BITS; |
| 3112 | if (vf->port_vlan_info || vsi->num_vlan) | 3097 | ucast_m = ICE_UCAST_VLAN_PROMISC_BITS; |
| 3113 | promisc_m = ICE_UCAST_VLAN_PROMISC_BITS; | ||
| 3114 | else | ||
| 3115 | promisc_m = ICE_UCAST_PROMISC_BITS; | ||
| 3116 | } else if (allmulti) { | ||
| 3117 | if (vf->port_vlan_info || vsi->num_vlan) | ||
| 3118 | promisc_m = ICE_MCAST_VLAN_PROMISC_BITS; | ||
| 3119 | else | ||
| 3120 | promisc_m = ICE_MCAST_PROMISC_BITS; | ||
| 3121 | } else { | 3098 | } else { |
| 3122 | if (vf->port_vlan_info || vsi->num_vlan) | 3099 | mcast_m = ICE_MCAST_PROMISC_BITS; |
| 3123 | promisc_m = ICE_UCAST_VLAN_PROMISC_BITS; | 3100 | ucast_m = ICE_UCAST_PROMISC_BITS; |
| 3124 | else | ||
| 3125 | promisc_m = ICE_UCAST_PROMISC_BITS; | ||
| 3126 | } | 3101 | } |
| 3127 | 3102 | ||
| 3128 | /* Configure multicast/unicast with or without VLAN promiscuous | 3103 | ucast_status = ice_vf_set_vsi_promisc(vf, vsi, ucast_m, |
| 3129 | * mode | 3104 | !alluni); |
| 3130 | */ | 3105 | if (ucast_status) { |
| 3131 | status = ice_vf_set_vsi_promisc(vf, vsi, promisc_m, rm_promisc); | 3106 | dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed\n", |
| 3132 | if (status) { | 3107 | alluni ? "en" : "dis", vf->vf_id); |
| 3133 | dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed, error: %s\n", | 3108 | v_ret = ice_err_to_virt_err(ucast_status); |
| 3134 | rm_promisc ? "dis" : "en", vf->vf_id, | 3109 | } |
| 3135 | ice_stat_str(status)); | 3110 | |
| 3136 | v_ret = ice_err_to_virt_err(status); | 3111 | mcast_status = ice_vf_set_vsi_promisc(vf, vsi, mcast_m, |
| 3137 | goto error_param; | 3112 | !allmulti); |
| 3138 | } else { | 3113 | if (mcast_status) { |
| 3139 | dev_dbg(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d succeeded\n", | 3114 | dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed\n", |
| 3140 | rm_promisc ? "dis" : "en", vf->vf_id); | 3115 | allmulti ? "en" : "dis", vf->vf_id); |
| 3116 | v_ret = ice_err_to_virt_err(mcast_status); | ||
| 3141 | } | 3117 | } |
| 3142 | } | 3118 | } |
| 3143 | 3119 | ||
| 3144 | if (allmulti && | 3120 | if (!mcast_status) { |
| 3145 | !test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) | 3121 | if (allmulti && |
| 3146 | dev_info(dev, "VF %u successfully set multicast promiscuous mode\n", vf->vf_id); | 3122 | !test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) |
| 3147 | else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) | 3123 | dev_info(dev, "VF %u successfully set multicast promiscuous mode\n", |
| 3148 | dev_info(dev, "VF %u successfully unset multicast promiscuous mode\n", vf->vf_id); | 3124 | vf->vf_id); |
| 3125 | else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) | ||
| 3126 | dev_info(dev, "VF %u successfully unset multicast promiscuous mode\n", | ||
| 3127 | vf->vf_id); | ||
| 3128 | } | ||
| 3149 | 3129 | ||
| 3150 | if (alluni && !test_and_set_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states)) | 3130 | if (!ucast_status) { |
| 3151 | dev_info(dev, "VF %u successfully set unicast promiscuous mode\n", vf->vf_id); | 3131 | if (alluni && !test_and_set_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states)) |
| 3152 | else if (!alluni && test_and_clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states)) | 3132 | dev_info(dev, "VF %u successfully set unicast promiscuous mode\n", |
| 3153 | dev_info(dev, "VF %u successfully unset unicast promiscuous mode\n", vf->vf_id); | 3133 | vf->vf_id); |
| 3134 | else if (!alluni && test_and_clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states)) | ||
| 3135 | dev_info(dev, "VF %u successfully unset unicast promiscuous mode\n", | ||
| 3136 | vf->vf_id); | ||
| 3137 | } | ||
| 3154 | 3138 | ||
| 3155 | error_param: | 3139 | error_param: |
| 3156 | return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, | 3140 | return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, |
| @@ -3824,6 +3808,7 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, · 667 unmodified lines | |||
| 3824 | struct device *dev = ice_pf_to_dev(vf->pf); | 3808 | struct device *dev = ice_pf_to_dev(vf->pf); |
| 3825 | u8 *mac_addr = vc_ether_addr->addr; | 3809 | u8 *mac_addr = vc_ether_addr->addr; |
| 3826 | enum ice_status status; | 3810 | enum ice_status status; |
| 3811 | int ret = 0; | ||
| 3827 | 3812 | ||
| 3828 | /* device MAC already added */ | 3813 | /* device MAC already added */ |
| 3829 | if (ether_addr_equal(mac_addr, vf->dev_lan_addr.addr)) | 3814 | if (ether_addr_equal(mac_addr, vf->dev_lan_addr.addr)) |
| @@ -3836,20 +3821,23 @@ ice_vc_add_mac_addr(struct ice_vf *vf, struct ice_vsi *vsi, · 6 unmodified lines | |||
| 3836 | 3821 | ||
| 3837 | status = ice_fltr_add_mac(vsi, mac_addr, ICE_FWD_TO_VSI); | 3822 | status = ice_fltr_add_mac(vsi, mac_addr, ICE_FWD_TO_VSI); |
| 3838 | if (status == ICE_ERR_ALREADY_EXISTS) { | 3823 | if (status == ICE_ERR_ALREADY_EXISTS) { |
| 3839 | dev_err(dev, "MAC %pM already exists for VF %d\n", mac_addr, | 3824 | dev_dbg(dev, "MAC %pM already exists for VF %d\n", mac_addr, |
| 3840 | vf->vf_id); | 3825 | vf->vf_id); |
| 3841 | return -EEXIST; | 3826 | /* don't return since we might need to update |
| 3827 | * the primary MAC in ice_vfhw_mac_add() below | ||
| 3828 | */ | ||
| 3829 | ret = -EEXIST; | ||
| 3842 | } else if (status) { | 3830 | } else if (status) { |
| 3843 | dev_err(dev, "Failed to add MAC %pM for VF %d\n, error %s\n", | 3831 | dev_err(dev, "Failed to add MAC %pM for VF %d\n, error %s\n", |
| 3844 | mac_addr, vf->vf_id, ice_stat_str(status)); | 3832 | mac_addr, vf->vf_id, ice_stat_str(status)); |
| 3845 | return -EIO; | 3833 | return -EIO; |
| 3834 | } else { | ||
| 3835 | vf->num_mac++; | ||
| 3846 | } | 3836 | } |
| 3847 | 3837 | ||
| 3848 | ice_vfhw_mac_add(vf, vc_ether_addr); | 3838 | ice_vfhw_mac_add(vf, vc_ether_addr); |
| 3849 | 3839 | ||
| 3850 | vf->num_mac++; | 3840 | return ret; |
| 3851 | |||
| 3852 | return 0; | ||
| 3853 | } | 3841 | } |
| 3854 | 3842 | ||
| 3855 | /** | 3843 | /** |
| @@ -4151,6 +4139,8 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 295 unmodified lines | |||
| 4151 | return 0; | 4139 | return 0; |
| 4152 | } | 4140 | } |
| 4153 | 4141 | ||
| 4142 | mutex_lock(&vf->cfg_lock); | ||
| 4143 | |||
| 4154 | vf->port_vlan_info = vlanprio; | 4144 | vf->port_vlan_info = vlanprio; |
| 4155 | 4145 | ||
| 4156 | if (vf->port_vlan_info) | 4146 | if (vf->port_vlan_info) |
| @@ -4160,6 +4150,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, · 3 unmodified lines | |||
| 4160 | dev_info(dev, "Clearing port VLAN on VF %d\n", vf_id); | 4150 | dev_info(dev, "Clearing port VLAN on VF %d\n", vf_id); |
| 4161 | 4151 | ||
| 4162 | ice_vc_reset_vf(vf); | 4152 | ice_vc_reset_vf(vf); |
| 4153 | mutex_unlock(&vf->cfg_lock); | ||
| 4163 | 4154 | ||
| 4164 | return 0; | 4155 | return 0; |
| 4165 | } | 4156 | } |
| @@ -4699,6 +4690,15 @@ error_handler: · 533 unmodified lines | |||
| 4699 | return; | 4690 | return; |
| 4700 | } | 4691 | } |
| 4701 | 4692 | ||
| 4693 | /* VF is being configured in another context that triggers a VFR, so no | ||
| 4694 | * need to process this message | ||
| 4695 | */ | ||
| 4696 | if (!mutex_trylock(&vf->cfg_lock)) { | ||
| 4697 | dev_info(dev, "VF %u is being configured in another context that will trigger a VFR, so there is no need to handle this message\n", | ||
| 4698 | vf->vf_id); | ||
| 4699 | return; | ||
| 4700 | } | ||
| 4701 | |||
| 4702 | switch (v_opcode) { | 4702 | switch (v_opcode) { |
| 4703 | case VIRTCHNL_OP_VERSION: | 4703 | case VIRTCHNL_OP_VERSION: |
| 4704 | err = ops->get_ver_msg(vf, msg); | 4704 | err = ops->get_ver_msg(vf, msg); |
| @@ -4787,6 +4787,8 @@ error_handler: · 82 unmodified lines | |||
| 4787 | dev_info(dev, "PF failed to honor VF %d, opcode %d, error %d\n", | 4787 | dev_info(dev, "PF failed to honor VF %d, opcode %d, error %d\n", |
| 4788 | vf_id, v_opcode, err); | 4788 | vf_id, v_opcode, err); |
| 4789 | } | 4789 | } |
| 4790 | |||
| 4791 | mutex_unlock(&vf->cfg_lock); | ||
| 4790 | } | 4792 | } |
| 4791 | 4793 | ||
| 4792 | /** | 4794 | /** |
| @@ -4902,6 +4904,8 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) · 109 unmodified lines | |||
| 4902 | return -EINVAL; | 4904 | return -EINVAL; |
| 4903 | } | 4905 | } |
| 4904 | 4906 | ||
| 4907 | mutex_lock(&vf->cfg_lock); | ||
| 4908 | |||
| 4905 | /* VF is notified of its new MAC via the PF's response to the | 4909 | /* VF is notified of its new MAC via the PF's response to the |
| 4906 | * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset | 4910 | * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset |
| 4907 | */ | 4911 | */ |
| @@ -4920,6 +4924,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) · 12 unmodified lines | |||
| 4920 | } | 4924 | } |
| 4921 | 4925 | ||
| 4922 | ice_vc_reset_vf(vf); | 4926 | ice_vc_reset_vf(vf); |
| 4927 | mutex_unlock(&vf->cfg_lock); | ||
| 4923 | return 0; | 4928 | return 0; |
| 4924 | } | 4929 | } |
| 4925 | 4930 | ||
| @@ -4954,11 +4959,15 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) · 28 unmodified lines | |||
| 4954 | if (trusted == vf->trusted) | 4959 | if (trusted == vf->trusted) |
| 4955 | return 0; | 4960 | return 0; |
| 4956 | 4961 | ||
| 4962 | mutex_lock(&vf->cfg_lock); | ||
| 4963 | |||
| 4957 | vf->trusted = trusted; | 4964 | vf->trusted = trusted; |
| 4958 | ice_vc_reset_vf(vf); | 4965 | ice_vc_reset_vf(vf); |
| 4959 | dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", | 4966 | dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", |
| 4960 | vf_id, trusted ? "" : "un"); | 4967 | vf_id, trusted ? "" : "un"); |
| 4961 | 4968 | ||
| 4969 | mutex_unlock(&vf->cfg_lock); | ||
| 4970 | |||
| 4962 | return 0; | 4971 | return 0; |
| 4963 | } | 4972 | } |
| 4964 | 4973 | ||
| @@ -100,6 +100,11 @@ struct ice_vc_vf_ops { · 99 unmodified lines | |||
| 100 | struct ice_vf { | 100 | struct ice_vf { |
| 101 | struct ice_pf *pf; | 101 | struct ice_pf *pf; |
| 102 | 102 | ||
| 103 | /* Used during virtchnl message handling and NDO ops against the VF | ||
| 104 | * that will trigger a VFR | ||
| 105 | */ | ||
| 106 | struct mutex cfg_lock; | ||
| 107 | |||
| 103 | u16 vf_id; /* VF ID in the PF space */ | 108 | u16 vf_id; /* VF ID in the PF space */ |
| 104 | u16 lan_vsi_idx; /* index into PF struct */ | 109 | u16 lan_vsi_idx; /* index into PF struct */ |
| 105 | u16 ctrl_vsi_idx; | 110 | u16 ctrl_vsi_idx; |
| @@ -262,7 +262,7 @@ ltq_etop_hw_init(struct net_device *dev) · 261 unmodified lines | |||
| 262 | /* enable crc generation */ | 262 | /* enable crc generation */ |
| 263 | ltq_etop_w32(PPE32_CGEN, LQ_PPE32_ENET_MAC_CFG); | 263 | ltq_etop_w32(PPE32_CGEN, LQ_PPE32_ENET_MAC_CFG); |
| 264 | 264 | ||
| 265 | ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, rx_burst_len); | 265 | ltq_dma_init_port(DMA_PORT_ETOP, priv->tx_burst_len, priv->rx_burst_len); |
| 266 | 266 | ||
| 267 | for (i = 0; i < MAX_DMA_CHAN; i++) { | 267 | for (i = 0; i < MAX_DMA_CHAN; i++) { |
| 268 | int irq = LTQ_DMA_CH0_INT + i; | 268 | int irq = LTQ_DMA_CH0_INT + i; |
| @@ -242,10 +242,8 @@ static int liteeth_probe(struct platform_device *pdev) · 241 unmodified lines | |||
| 242 | priv->dev = &pdev->dev; | 242 | priv->dev = &pdev->dev; |
| 243 | 243 | ||
| 244 | irq = platform_get_irq(pdev, 0); | 244 | irq = platform_get_irq(pdev, 0); |
| 245 | if (irq < 0) { | 245 | if (irq < 0) |
| 246 | dev_err(&pdev->dev, "Failed to get IRQ %d\n", irq); | ||
| 247 | return irq; | 246 | return irq; |
| 248 | } | ||
| 249 | netdev->irq = irq; | 247 | netdev->irq = irq; |
| 250 | 248 | ||
| 251 | priv->base = devm_platform_ioremap_resource_byname(pdev, "mac"); | 249 | priv->base = devm_platform_ioremap_resource_byname(pdev, "mac"); |
| @@ -289,7 +287,6 @@ static int liteeth_remove(struct platform_device *pdev) · 37 unmodified lines | |||
| 289 | struct net_device *netdev = platform_get_drvdata(pdev); | 287 | struct net_device *netdev = platform_get_drvdata(pdev); |
| 290 | 288 | ||
| 291 | unregister_netdev(netdev); | 289 | unregister_netdev(netdev); |
| 292 | free_netdev(netdev); | ||
| 293 | 290 | ||
| 294 | return 0; | 291 | return 0; |
| 295 | } | 292 | } |
| @@ -1605,7 +1605,7 @@ static void mvpp22_gop_fca_set_periodic_timer(struct mvpp2_port *port) · 1604 unmodified lines | |||
| 1605 | mvpp22_gop_fca_enable_periodic(port, true); | 1605 | mvpp22_gop_fca_enable_periodic(port, true); |
| 1606 | } | 1606 | } |
| 1607 | 1607 | ||
| 1608 | static int mvpp22_gop_init(struct mvpp2_port *port) | 1608 | static int mvpp22_gop_init(struct mvpp2_port *port, phy_interface_t interface) |
| 1609 | { | 1609 | { |
| 1610 | struct mvpp2 *priv = port->priv; | 1610 | struct mvpp2 *priv = port->priv; |
| 1611 | u32 val; | 1611 | u32 val; |
| @@ -1613,7 +1613,7 @@ static int mvpp22_gop_init(struct mvpp2_port *port) · 1 unmodified line | |||
| 1613 | if (!priv->sysctrl_base) | 1613 | if (!priv->sysctrl_base) |
| 1614 | return 0; | 1614 | return 0; |
| 1615 | 1615 | ||
| 1616 | switch (port->phy_interface) { | 1616 | switch (interface) { |
| 1617 | case PHY_INTERFACE_MODE_RGMII: | 1617 | case PHY_INTERFACE_MODE_RGMII: |
| 1618 | case PHY_INTERFACE_MODE_RGMII_ID: | 1618 | case PHY_INTERFACE_MODE_RGMII_ID: |
| 1619 | case PHY_INTERFACE_MODE_RGMII_RXID: | 1619 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| @@ -1743,15 +1743,15 @@ static void mvpp22_gop_setup_irq(struct mvpp2_port *port) · 123 unmodified lines | |||
| 1743 | * lanes by the physical layer. This is why configurations like | 1743 | * lanes by the physical layer. This is why configurations like |
| 1744 | * "PPv2 (2500BaseX) - COMPHY (2500SGMII)" are valid. | 1744 | * "PPv2 (2500BaseX) - COMPHY (2500SGMII)" are valid. |
| 1745 | */ | 1745 | */ |
| 1746 | static int mvpp22_comphy_init(struct mvpp2_port *port) | 1746 | static int mvpp22_comphy_init(struct mvpp2_port *port, |
| 1747 | phy_interface_t interface) | ||
| 1747 | { | 1748 | { |
| 1748 | int ret; | 1749 | int ret; |
| 1749 | 1750 | ||
| 1750 | if (!port->comphy) | 1751 | if (!port->comphy) |
| 1751 | return 0; | 1752 | return 0; |
| 1752 | 1753 | ||
| 1753 | ret = phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET, | 1754 | ret = phy_set_mode_ext(port->comphy, PHY_MODE_ETHERNET, interface); |
| 1754 | port->phy_interface); | ||
| 1755 | if (ret) | 1755 | if (ret) |
| 1756 | return ret; | 1756 | return ret; |
| 1757 | 1757 | ||
| @@ -2172,7 +2172,8 @@ static void mvpp22_pcs_reset_assert(struct mvpp2_port *port) · 414 unmodified lines | |||
| 2172 | writel(val & ~MVPP22_XPCS_CFG0_RESET_DIS, xpcs + MVPP22_XPCS_CFG0); | 2172 | writel(val & ~MVPP22_XPCS_CFG0_RESET_DIS, xpcs + MVPP22_XPCS_CFG0); |
| 2173 | } | 2173 | } |
| 2174 | 2174 | ||
| 2175 | static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port) | 2175 | static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port, |
| 2176 | phy_interface_t interface) | ||
| 2176 | { | 2177 | { |
| 2177 | struct mvpp2 *priv = port->priv; | 2178 | struct mvpp2 *priv = port->priv; |
| 2178 | void __iomem *mpcs, *xpcs; | 2179 | void __iomem *mpcs, *xpcs; |
| @@ -2184,7 +2185,7 @@ static void mvpp22_pcs_reset_deassert(struct mvpp2_port *port) · 5 unmodified lines | |||
| 2184 | mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id); | 2185 | mpcs = priv->iface_base + MVPP22_MPCS_BASE(port->gop_id); |
| 2185 | xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id); | 2186 | xpcs = priv->iface_base + MVPP22_XPCS_BASE(port->gop_id); |
| 2186 | 2187 | ||
| 2187 | switch (port->phy_interface) { | 2188 | switch (interface) { |
| 2188 | case PHY_INTERFACE_MODE_10GBASER: | 2189 | case PHY_INTERFACE_MODE_10GBASER: |
| 2189 | val = readl(mpcs + MVPP22_MPCS_CLK_RESET); | 2190 | val = readl(mpcs + MVPP22_MPCS_CLK_RESET); |
| 2190 | val |= MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX | | 2191 | val |= MAC_CLK_RESET_MAC | MAC_CLK_RESET_SD_RX | |
| @@ -4529,7 +4530,8 @@ static int mvpp2_poll(struct napi_struct *napi, int budget) · 2338 unmodified lines | |||
| 4529 | return rx_done; | 4530 | return rx_done; |
| 4530 | } | 4531 | } |
| 4531 | 4532 | ||
| 4532 | static void mvpp22_mode_reconfigure(struct mvpp2_port *port) | 4533 | static void mvpp22_mode_reconfigure(struct mvpp2_port *port, |
| 4534 | phy_interface_t interface) | ||
| 4533 | { | 4535 | { |
| 4534 | u32 ctrl3; | 4536 | u32 ctrl3; |
| 4535 | 4537 | ||
| @@ -4540,18 +4542,18 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port) · 4 unmodified lines | |||
| 4540 | mvpp22_pcs_reset_assert(port); | 4542 | mvpp22_pcs_reset_assert(port); |
| 4541 | 4543 | ||
| 4542 | /* comphy reconfiguration */ | 4544 | /* comphy reconfiguration */ |
| 4543 | mvpp22_comphy_init(port); | 4545 | mvpp22_comphy_init(port, interface); |
| 4544 | 4546 | ||
| 4545 | /* gop reconfiguration */ | 4547 | /* gop reconfiguration */ |
| 4546 | mvpp22_gop_init(port); | 4548 | mvpp22_gop_init(port, interface); |
| 4547 | 4549 | ||
| 4548 | mvpp22_pcs_reset_deassert(port); | 4550 | mvpp22_pcs_reset_deassert(port, interface); |
| 4549 | 4551 | ||
| 4550 | if (mvpp2_port_supports_xlg(port)) { | 4552 | if (mvpp2_port_supports_xlg(port)) { |
| 4551 | ctrl3 = readl(port->base + MVPP22_XLG_CTRL3_REG); | 4553 | ctrl3 = readl(port->base + MVPP22_XLG_CTRL3_REG); |
| 4552 | ctrl3 &= ~MVPP22_XLG_CTRL3_MACMODESELECT_MASK; | 4554 | ctrl3 &= ~MVPP22_XLG_CTRL3_MACMODESELECT_MASK; |
| 4553 | 4555 | ||
| 4554 | if (mvpp2_is_xlg(port->phy_interface)) | 4556 | if (mvpp2_is_xlg(interface)) |
| 4555 | ctrl3 |= MVPP22_XLG_CTRL3_MACMODESELECT_10G; | 4557 | ctrl3 |= MVPP22_XLG_CTRL3_MACMODESELECT_10G; |
| 4556 | else | 4558 | else |
| 4557 | ctrl3 |= MVPP22_XLG_CTRL3_MACMODESELECT_GMAC; | 4559 | ctrl3 |= MVPP22_XLG_CTRL3_MACMODESELECT_GMAC; |
| @@ -4559,7 +4561,7 @@ static void mvpp22_mode_reconfigure(struct mvpp2_port *port) · 1 unmodified line | |||
| 4559 | writel(ctrl3, port->base + MVPP22_XLG_CTRL3_REG); | 4561 | writel(ctrl3, port->base + MVPP22_XLG_CTRL3_REG); |
| 4560 | } | 4562 | } |
| 4561 | 4563 | ||
| 4562 | if (mvpp2_port_supports_xlg(port) && mvpp2_is_xlg(port->phy_interface)) | 4564 | if (mvpp2_port_supports_xlg(port) && mvpp2_is_xlg(interface)) |
| 4563 | mvpp2_xlg_max_rx_size_set(port); | 4565 | mvpp2_xlg_max_rx_size_set(port); |
| 4564 | else | 4566 | else |
| 4565 | mvpp2_gmac_max_rx_size_set(port); | 4567 | mvpp2_gmac_max_rx_size_set(port); |
| @@ -4579,7 +4581,7 @@ static void mvpp2_start_dev(struct mvpp2_port *port) · 13 unmodified lines | |||
| 4579 | mvpp2_interrupts_enable(port); | 4581 | mvpp2_interrupts_enable(port); |
| 4580 | 4582 | ||
| 4581 | if (port->priv->hw_version >= MVPP22) | 4583 | if (port->priv->hw_version >= MVPP22) |
| 4582 | mvpp22_mode_reconfigure(port); | 4584 | mvpp22_mode_reconfigure(port, port->phy_interface); |
| 4583 | 4585 | ||
| 4584 | if (port->phylink) { | 4586 | if (port->phylink) { |
| 4585 | phylink_start(port->phylink); | 4587 | phylink_start(port->phylink); |
| @@ -6444,6 +6446,9 @@ static int mvpp2__mac_prepare(struct phylink_config *config, unsigned int mode, · 1858 unmodified lines | |||
| 6444 | mvpp22_gop_mask_irq(port); | 6446 | mvpp22_gop_mask_irq(port); |
| 6445 | 6447 | ||
| 6446 | phy_power_off(port->comphy); | 6448 | phy_power_off(port->comphy); |
| 6449 | |||
| 6450 | /* Reconfigure the serdes lanes */ | ||
| 6451 | mvpp22_mode_reconfigure(port, interface); | ||
| 6447 | } | 6452 | } |
| 6448 | } | 6453 | } |
| 6449 | 6454 | ||
| @@ -6498,9 +6503,6 @@ static int mvpp2_mac_finish(struct phylink_config *config, unsigned int mode, · 48 unmodified lines | |||
| 6498 | port->phy_interface != interface) { | 6503 | port->phy_interface != interface) { |
| 6499 | port->phy_interface = interface; | 6504 | port->phy_interface = interface; |
| 6500 | 6505 | ||
| 6501 | /* Reconfigure the serdes lanes */ | ||
| 6502 | mvpp22_mode_reconfigure(port); | ||
| 6503 | |||
| 6504 | /* Unmask interrupts */ | 6506 | /* Unmask interrupts */ |
| 6505 | mvpp22_gop_unmask_irq(port); | 6507 | mvpp22_gop_unmask_irq(port); |
| 6506 | } | 6508 | } |
| @@ -6961,7 +6963,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 454 unmodified lines | |||
| 6961 | * driver does this, we can remove this code. | 6963 | * driver does this, we can remove this code. |
| 6962 | */ | 6964 | */ |
| 6963 | if (port->comphy) { | 6965 | if (port->comphy) { |
| 6964 | err = mvpp22_comphy_init(port); | 6966 | err = mvpp22_comphy_init(port, port->phy_interface); |
| 6965 | if (err == 0) | 6967 | if (err == 0) |
| 6966 | phy_power_off(port->comphy); | 6968 | phy_power_off(port->comphy); |
| 6967 | } | 6969 | } |
| @@ -31,6 +31,7 @@ config NDC_DIS_DYNAMIC_CACHING · 30 unmodified lines | |||
| 31 | config OCTEONTX2_PF | 31 | config OCTEONTX2_PF |
| 32 | tristate "Marvell OcteonTX2 NIC Physical Function driver" | 32 | tristate "Marvell OcteonTX2 NIC Physical Function driver" |
| 33 | select OCTEONTX2_MBOX | 33 | select OCTEONTX2_MBOX |
| 34 | select NET_DEVLINK | ||
| 34 | depends on (64BIT && COMPILE_TEST) || ARM64 | 35 | depends on (64BIT && COMPILE_TEST) || ARM64 |
| 35 | depends on PCI | 36 | depends on PCI |
| 36 | depends on PTP_1588_CLOCK_OPTIONAL | 37 | depends on PTP_1588_CLOCK_OPTIONAL |
| @@ -2450,9 +2450,7 @@ alloc: · 2449 unmodified lines | |||
| 2450 | bmap = mcam->bmap_reverse; | 2450 | bmap = mcam->bmap_reverse; |
| 2451 | start = mcam->bmap_entries - start; | 2451 | start = mcam->bmap_entries - start; |
| 2452 | end = mcam->bmap_entries - end; | 2452 | end = mcam->bmap_entries - end; |
| 2453 | index = start; | 2453 | swap(start, end); |
| 2454 | start = end; | ||
| 2455 | end = index; | ||
| 2456 | } else { | 2454 | } else { |
| 2457 | bmap = mcam->bmap; | 2455 | bmap = mcam->bmap; |
| 2458 | } | 2456 | } |
| @@ -501,7 +501,7 @@ static const struct net_device_ops otx2vf_netdev_ops = { · 500 unmodified lines | |||
| 501 | .ndo_set_features = otx2vf_set_features, | 501 | .ndo_set_features = otx2vf_set_features, |
| 502 | .ndo_get_stats64 = otx2_get_stats64, | 502 | .ndo_get_stats64 = otx2_get_stats64, |
| 503 | .ndo_tx_timeout = otx2_tx_timeout, | 503 | .ndo_tx_timeout = otx2_tx_timeout, |
| 504 | .ndo_do_ioctl = otx2_ioctl, | 504 | .ndo_eth_ioctl = otx2_ioctl, |
| 505 | }; | 505 | }; |
| 506 | 506 | ||
| 507 | static int otx2_wq_init(struct otx2_nic *vf) | 507 | static int otx2_wq_init(struct otx2_nic *vf) |
| @@ -499,7 +499,8 @@ static void prestera_port_mdix_get(struct ethtool_link_ksettings *ecmd, · 498 unmodified lines | |||
| 499 | { | 499 | { |
| 500 | struct prestera_port_phy_state *state = &port->state_phy; | 500 | struct prestera_port_phy_state *state = &port->state_phy; |
| 501 | 501 | ||
| 502 | if (prestera_hw_port_phy_mode_get(port, &state->mdix, NULL, NULL, NULL)) { | 502 | if (prestera_hw_port_phy_mode_get(port, |
| 503 | &state->mdix, NULL, NULL, NULL)) { | ||
| 503 | netdev_warn(port->dev, "MDIX params get failed"); | 504 | netdev_warn(port->dev, "MDIX params get failed"); |
| 504 | state->mdix = ETH_TP_MDI_INVALID; | 505 | state->mdix = ETH_TP_MDI_INVALID; |
| 505 | } | 506 | } |
| @@ -180,108 +180,113 @@ struct prestera_msg_common_resp { · 179 unmodified lines | |||
| 180 | struct prestera_msg_ret ret; | 180 | struct prestera_msg_ret ret; |
| 181 | }; | 181 | }; |
| 182 | 182 | ||
| 183 | union prestera_msg_switch_param { | ||
| 184 | u8 mac[ETH_ALEN]; | ||
| 185 | __le32 ageing_timeout_ms; | ||
| 186 | } __packed; | ||
| 187 | |||
| 188 | struct prestera_msg_switch_attr_req { | 183 | struct prestera_msg_switch_attr_req { |
| 189 | struct prestera_msg_cmd cmd; | 184 | struct prestera_msg_cmd cmd; |
| 190 | __le32 attr; | 185 | __le32 attr; |
| 191 | union prestera_msg_switch_param param; | 186 | union { |
| 187 | __le32 ageing_timeout_ms; | ||
| 188 | struct { | ||
| 189 | u8 mac[ETH_ALEN]; | ||
| 190 | u8 __pad[2]; | ||
| 191 | }; | ||
| 192 | } param; | ||
| 192 | }; | 193 | }; |
| 193 | 194 | ||
| 194 | struct prestera_msg_switch_init_resp { | 195 | struct prestera_msg_switch_init_resp { |
| 195 | struct prestera_msg_ret ret; | 196 | struct prestera_msg_ret ret; |
| 196 | __le32 port_count; | 197 | __le32 port_count; |
| 197 | __le32 mtu_max; | 198 | __le32 mtu_max; |
| 198 | u8 switch_id; | ||
| 199 | u8 lag_max; | ||
| 200 | u8 lag_member_max; | ||
| 201 | __le32 size_tbl_router_nexthop; | 199 | __le32 size_tbl_router_nexthop; |
| 202 | } __packed __aligned(4); | 200 | u8 switch_id; |
| 201 | u8 lag_max; | ||
| 202 | u8 lag_member_max; | ||
| 203 | }; | ||
| 203 | 204 | ||
| 204 | struct prestera_msg_event_port_param { | 205 | struct prestera_msg_event_port_param { |
| 205 | union { | 206 | union { |
| 206 | struct { | 207 | struct { |
| 207 | u8 oper; | ||
| 208 | __le32 mode; | 208 | __le32 mode; |
| 209 | __le32 speed; | 209 | __le32 speed; |
| 210 | u8 oper; | ||
| 210 | u8 duplex; | 211 | u8 duplex; |
| 211 | u8 fc; | 212 | u8 fc; |
| 212 | u8 fec; | 213 | u8 fec; |
| 213 | } __packed mac; | 214 | } mac; |
| 214 | struct { | 215 | struct { |
| 215 | u8 mdix; | ||
| 216 | __le64 lmode_bmap; | 216 | __le64 lmode_bmap; |
| 217 | u8 mdix; | ||
| 217 | u8 fc; | 218 | u8 fc; |
| 218 | } __packed phy; | 219 | u8 __pad[2]; |
| 219 | } __packed; | 220 | } __packed phy; /* make sure always 12 bytes size */ |
| 220 | } __packed __aligned(4); | 221 | }; |
| 222 | }; | ||
| 221 | 223 | ||
| 222 | struct prestera_msg_port_cap_param { | 224 | struct prestera_msg_port_cap_param { |
| 223 | __le64 link_mode; | 225 | __le64 link_mode; |
| 224 | u8 type; | 226 | u8 type; |
| 225 | u8 fec; | 227 | u8 fec; |
| 226 | u8 fc; | 228 | u8 fc; |
| 227 | u8 transceiver; | 229 | u8 transceiver; |
| 228 | }; | 230 | }; |
| 229 | 231 | ||
| 230 | struct prestera_msg_port_flood_param { | 232 | struct prestera_msg_port_flood_param { |
| 231 | u8 type; | 233 | u8 type; |
| 232 | u8 enable; | 234 | u8 enable; |
| 235 | u8 __pad[2]; | ||
| 233 | }; | 236 | }; |
| 234 | 237 | ||
| 235 | union prestera_msg_port_param { | 238 | union prestera_msg_port_param { |
| 239 | __le32 mtu; | ||
| 240 | __le32 speed; | ||
| 241 | __le32 link_mode; | ||
| 236 | u8 admin_state; | 242 | u8 admin_state; |
| 237 | u8 oper_state; | 243 | u8 oper_state; |
| 238 | __le32 mtu; | ||
| 239 | u8 mac[ETH_ALEN]; | 244 | u8 mac[ETH_ALEN]; |
| 240 | u8 accept_frm_type; | 245 | u8 accept_frm_type; |
| 241 | __le32 speed; | ||
| 242 | u8 learning; | 246 | u8 learning; |
| 243 | u8 flood; | 247 | u8 flood; |
| 244 | __le32 link_mode; | ||
| 245 | u8 type; | 248 | u8 type; |
| 246 | u8 duplex; | 249 | u8 duplex; |
| 247 | u8 fec; | 250 | u8 fec; |
| 248 | u8 fc; | 251 | u8 fc; |
| 249 | |||
| 250 | union { | 252 | union { |
| 251 | struct { | 253 | struct { |
| 252 | u8 admin:1; | 254 | u8 admin; |
| 253 | u8 fc; | 255 | u8 fc; |
| 254 | u8 ap_enable; | 256 | u8 ap_enable; |
| 257 | u8 __reserved[5]; | ||
| 255 | union { | 258 | union { |
| 256 | struct { | 259 | struct { |
| 257 | __le32 mode; | 260 | __le32 mode; |
| 258 | u8 inband:1; | ||
| 259 | __le32 speed; | 261 | __le32 speed; |
| 260 | u8 duplex; | 262 | u8 inband; |
| 261 | u8 fec; | 263 | u8 duplex; |
| 262 | u8 fec_supp; | 264 | u8 fec; |
| 263 | } __packed reg_mode; | 265 | u8 fec_supp; |
| 266 | } reg_mode; | ||
| 264 | struct { | 267 | struct { |
| 265 | __le32 mode; | 268 | __le32 mode; |
| 266 | __le32 speed; | 269 | __le32 speed; |
| 267 | u8 fec; | 270 | u8 fec; |
| 268 | u8 fec_supp; | 271 | u8 fec_supp; |
| 269 | } __packed ap_modes[PRESTERA_AP_PORT_MAX]; | 272 | u8 __pad[2]; |
| 270 | } __packed; | 273 | } ap_modes[PRESTERA_AP_PORT_MAX]; |
| 271 | } __packed mac; | 274 | }; |
| 275 | } mac; | ||
| 272 | struct { | 276 | struct { |
| 273 | u8 admin:1; | ||
| 274 | u8 adv_enable; | ||
| 275 | __le64 modes; | 277 | __le64 modes; |
| 276 | __le32 mode; | 278 | __le32 mode; |
| 279 | u8 admin; | ||
| 280 | u8 adv_enable; | ||
| 277 | u8 mdix; | 281 | u8 mdix; |
| 278 | } __packed phy; | 282 | u8 __pad; |
| 279 | } __packed link; | 283 | } phy; |
| 284 | } link; | ||
| 280 | 285 | ||
| 281 | struct prestera_msg_port_cap_param cap; | 286 | struct prestera_msg_port_cap_param cap; |
| 282 | struct prestera_msg_port_flood_param flood_ext; | 287 | struct prestera_msg_port_flood_param flood_ext; |
| 283 | struct prestera_msg_event_port_param link_evt; | 288 | struct prestera_msg_event_port_param link_evt; |
| 284 | } __packed; | 289 | }; |
| 285 | 290 | ||
| 286 | struct prestera_msg_port_attr_req { | 291 | struct prestera_msg_port_attr_req { |
| 287 | struct prestera_msg_cmd cmd; | 292 | struct prestera_msg_cmd cmd; |
| @@ -289,14 +294,12 @@ struct prestera_msg_port_attr_req { · 1 unmodified line | |||
| 289 | __le32 port; | 294 | __le32 port; |
| 290 | __le32 dev; | 295 | __le32 dev; |
| 291 | union prestera_msg_port_param param; | 296 | union prestera_msg_port_param param; |
| 292 | } __packed __aligned(4); | 297 | }; |
| 293 | |||
| 294 | 298 | ||
| 295 | struct prestera_msg_port_attr_resp { | 299 | struct prestera_msg_port_attr_resp { |
| 296 | struct prestera_msg_ret ret; | 300 | struct prestera_msg_ret ret; |
| 297 | union prestera_msg_port_param param; | 301 | union prestera_msg_port_param param; |
| 298 | } __packed __aligned(4); | 302 | }; |
| 299 | |||
| 300 | 303 | ||
| 301 | struct prestera_msg_port_stats_resp { | 304 | struct prestera_msg_port_stats_resp { |
| 302 | struct prestera_msg_ret ret; | 305 | struct prestera_msg_ret ret; |
| @@ -313,6 +316,7 @@ struct prestera_msg_port_info_resp { · 10 unmodified lines | |||
| 313 | __le32 hw_id; | 316 | __le32 hw_id; |
| 314 | __le32 dev_id; | 317 | __le32 dev_id; |
| 315 | __le16 fp_id; | 318 | __le16 fp_id; |
| 319 | u8 pad[2]; | ||
| 316 | }; | 320 | }; |
| 317 | 321 | ||
| 318 | struct prestera_msg_vlan_req { | 322 | struct prestera_msg_vlan_req { |
| @@ -320,13 +324,13 @@ struct prestera_msg_vlan_req { · 1 unmodified line | |||
| 320 | __le32 port; | 324 | __le32 port; |
| 321 | __le32 dev; | 325 | __le32 dev; |
| 322 | __le16 vid; | 326 | __le16 vid; |
| 323 | u8 is_member; | 327 | u8 is_member; |
| 324 | u8 is_tagged; | 328 | u8 is_tagged; |
| 325 | }; | 329 | }; |
| 326 | 330 | ||
| 327 | struct prestera_msg_fdb_req { | 331 | struct prestera_msg_fdb_req { |
| 328 | struct prestera_msg_cmd cmd; | 332 | struct prestera_msg_cmd cmd; |
| 329 | u8 dest_type; | 333 | __le32 flush_mode; |
| 330 | union { | 334 | union { |
| 331 | struct { | 335 | struct { |
| 332 | __le32 port; | 336 | __le32 port; |
| @@ -334,22 +338,25 @@ struct prestera_msg_fdb_req { · 1 unmodified line | |||
| 334 | }; | 338 | }; |
| 335 | __le16 lag_id; | 339 | __le16 lag_id; |
| 336 | } dest; | 340 | } dest; |
| 337 | u8 mac[ETH_ALEN]; | ||
| 338 | __le16 vid; | 341 | __le16 vid; |
| 339 | u8 dynamic; | 342 | u8 dest_type; |
| 340 | __le32 flush_mode; | 343 | u8 dynamic; |
| 341 | } __packed __aligned(4); | 344 | u8 mac[ETH_ALEN]; |
| 345 | u8 __pad[2]; | ||
| 346 | }; | ||
| 342 | 347 | ||
| 343 | struct prestera_msg_bridge_req { | 348 | struct prestera_msg_bridge_req { |
| 344 | struct prestera_msg_cmd cmd; | 349 | struct prestera_msg_cmd cmd; |
| 345 | __le32 port; | 350 | __le32 port; |
| 346 | __le32 dev; | 351 | __le32 dev; |
| 347 | __le16 bridge; | 352 | __le16 bridge; |
| 353 | u8 pad[2]; | ||
| 348 | }; | 354 | }; |
| 349 | 355 | ||
| 350 | struct prestera_msg_bridge_resp { | 356 | struct prestera_msg_bridge_resp { |
| 351 | struct prestera_msg_ret ret; | 357 | struct prestera_msg_ret ret; |
| 352 | __le16 bridge; | 358 | __le16 bridge; |
| 359 | u8 pad[2]; | ||
| 353 | }; | 360 | }; |
| 354 | 361 | ||
| 355 | struct prestera_msg_acl_action { | 362 | struct prestera_msg_acl_action { |
| @@ -359,11 +366,12 @@ struct prestera_msg_acl_action { · 3 unmodified lines | |||
| 359 | 366 | ||
| 360 | struct prestera_msg_acl_match { | 367 | struct prestera_msg_acl_match { |
| 361 | __le32 type; | 368 | __le32 type; |
| 369 | __le32 __reserved; | ||
| 362 | union { | 370 | union { |
| 363 | struct { | 371 | struct { |
| 364 | u8 key; | 372 | u8 key; |
| 365 | u8 mask; | 373 | u8 mask; |
| 366 | } __packed u8; | 374 | } u8; |
| 367 | struct { | 375 | struct { |
| 368 | __le16 key; | 376 | __le16 key; |
| 369 | __le16 mask; | 377 | __le16 mask; |
| @@ -379,7 +387,7 @@ struct prestera_msg_acl_match { · 9 unmodified lines | |||
| 379 | struct { | 387 | struct { |
| 380 | u8 key[ETH_ALEN]; | 388 | u8 key[ETH_ALEN]; |
| 381 | u8 mask[ETH_ALEN]; | 389 | u8 mask[ETH_ALEN]; |
| 382 | } __packed mac; | 390 | } mac; |
| 383 | } keymask; | 391 | } keymask; |
| 384 | }; | 392 | }; |
| 385 | 393 | ||
| @@ -408,16 +416,19 @@ struct prestera_msg_acl_ruleset_bind_req { · 22 unmodified lines | |||
| 408 | __le32 port; | 416 | __le32 port; |
| 409 | __le32 dev; | 417 | __le32 dev; |
| 410 | __le16 ruleset_id; | 418 | __le16 ruleset_id; |
| 419 | u8 pad[2]; | ||
| 411 | }; | 420 | }; |
| 412 | 421 | ||
| 413 | struct prestera_msg_acl_ruleset_req { | 422 | struct prestera_msg_acl_ruleset_req { |
| 414 | struct prestera_msg_cmd cmd; | 423 | struct prestera_msg_cmd cmd; |
| 415 | __le16 id; | 424 | __le16 id; |
| 425 | u8 pad[2]; | ||
| 416 | }; | 426 | }; |
| 417 | 427 | ||
| 418 | struct prestera_msg_acl_ruleset_resp { | 428 | struct prestera_msg_acl_ruleset_resp { |
| 419 | struct prestera_msg_ret ret; | 429 | struct prestera_msg_ret ret; |
| 420 | __le16 id; | 430 | __le16 id; |
| 431 | u8 pad[2]; | ||
| 421 | }; | 432 | }; |
| 422 | 433 | ||
| 423 | struct prestera_msg_span_req { | 434 | struct prestera_msg_span_req { |
| @@ -425,11 +436,13 @@ struct prestera_msg_span_req { · 1 unmodified line | |||
| 425 | __le32 port; | 436 | __le32 port; |
| 426 | __le32 dev; | 437 | __le32 dev; |
| 427 | u8 id; | 438 | u8 id; |
| 439 | u8 pad[3]; | ||
| 428 | }; | 440 | }; |
| 429 | 441 | ||
| 430 | struct prestera_msg_span_resp { | 442 | struct prestera_msg_span_resp { |
| 431 | struct prestera_msg_ret ret; | 443 | struct prestera_msg_ret ret; |
| 432 | u8 id; | 444 | u8 id; |
| 445 | u8 pad[3]; | ||
| 433 | }; | 446 | }; |
| 434 | 447 | ||
| 435 | struct prestera_msg_stp_req { | 448 | struct prestera_msg_stp_req { |
| @@ -437,12 +450,14 @@ struct prestera_msg_stp_req { · 1 unmodified line | |||
| 437 | __le32 port; | 450 | __le32 port; |
| 438 | __le32 dev; | 451 | __le32 dev; |
| 439 | __le16 vid; | 452 | __le16 vid; |
| 440 | u8 state; | 453 | u8 state; |
| 454 | u8 __pad; | ||
| 441 | }; | 455 | }; |
| 442 | 456 | ||
| 443 | struct prestera_msg_rxtx_req { | 457 | struct prestera_msg_rxtx_req { |
| 444 | struct prestera_msg_cmd cmd; | 458 | struct prestera_msg_cmd cmd; |
| 445 | u8 use_sdma; | 459 | u8 use_sdma; |
| 460 | u8 pad[3]; | ||
| 446 | }; | 461 | }; |
| 447 | 462 | ||
| 448 | struct prestera_msg_rxtx_resp { | 463 | struct prestera_msg_rxtx_resp { |
| @@ -455,12 +470,14 @@ struct prestera_msg_lag_req { · 6 unmodified lines | |||
| 455 | __le32 port; | 470 | __le32 port; |
| 456 | __le32 dev; | 471 | __le32 dev; |
| 457 | __le16 lag_id; | 472 | __le16 lag_id; |
| 473 | u8 pad[2]; | ||
| 458 | }; | 474 | }; |
| 459 | 475 | ||
| 460 | struct prestera_msg_cpu_code_counter_req { | 476 | struct prestera_msg_cpu_code_counter_req { |
| 461 | struct prestera_msg_cmd cmd; | 477 | struct prestera_msg_cmd cmd; |
| 462 | u8 counter_type; | 478 | u8 counter_type; |
| 463 | u8 code; | 479 | u8 code; |
| 480 | u8 pad[2]; | ||
| 464 | }; | 481 | }; |
| 465 | 482 | ||
| 466 | struct mvsw_msg_cpu_code_counter_ret { | 483 | struct mvsw_msg_cpu_code_counter_ret { |
| @@ -485,21 +502,21 @@ union prestera_msg_event_fdb_param { · 18 unmodified lines | |||
| 485 | 502 | ||
| 486 | struct prestera_msg_event_fdb { | 503 | struct prestera_msg_event_fdb { |
| 487 | struct prestera_msg_event id; | 504 | struct prestera_msg_event id; |
| 488 | u8 dest_type; | 505 | __le32 vid; |
| 489 | union { | 506 | union { |
| 490 | __le32 port_id; | 507 | __le32 port_id; |
| 491 | __le16 lag_id; | 508 | __le16 lag_id; |
| 492 | } dest; | 509 | } dest; |
| 493 | __le32 vid; | ||
| 494 | union prestera_msg_event_fdb_param param; | 510 | union prestera_msg_event_fdb_param param; |
| 495 | } __packed __aligned(4); | 511 | u8 dest_type; |
| 512 | }; | ||
| 496 | 513 | ||
| 497 | static inline void prestera_hw_build_tests(void) | 514 | static void prestera_hw_build_tests(void) |
| 498 | { | 515 | { |
| 499 | /* check requests */ | 516 | /* check requests */ |
| 500 | BUILD_BUG_ON(sizeof(struct prestera_msg_common_req) != 4); | 517 | BUILD_BUG_ON(sizeof(struct prestera_msg_common_req) != 4); |
| 501 | BUILD_BUG_ON(sizeof(struct prestera_msg_switch_attr_req) != 16); | 518 | BUILD_BUG_ON(sizeof(struct prestera_msg_switch_attr_req) != 16); |
| 502 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_req) != 120); | 519 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_req) != 144); |
| 503 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_info_req) != 8); | 520 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_info_req) != 8); |
| 504 | BUILD_BUG_ON(sizeof(struct prestera_msg_vlan_req) != 16); | 521 | BUILD_BUG_ON(sizeof(struct prestera_msg_vlan_req) != 16); |
| 505 | BUILD_BUG_ON(sizeof(struct prestera_msg_fdb_req) != 28); | 522 | BUILD_BUG_ON(sizeof(struct prestera_msg_fdb_req) != 28); |
| @@ -516,7 +533,7 @@ static inline void prestera_hw_build_tests(void) · 10 unmodified lines | |||
| 516 | /* check responses */ | 533 | /* check responses */ |
| 517 | BUILD_BUG_ON(sizeof(struct prestera_msg_common_resp) != 8); | 534 | BUILD_BUG_ON(sizeof(struct prestera_msg_common_resp) != 8); |
| 518 | BUILD_BUG_ON(sizeof(struct prestera_msg_switch_init_resp) != 24); | 535 | BUILD_BUG_ON(sizeof(struct prestera_msg_switch_init_resp) != 24); |
| 519 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_resp) != 112); | 536 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_attr_resp) != 136); |
| 520 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_stats_resp) != 248); | 537 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_stats_resp) != 248); |
| 521 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_info_resp) != 20); | 538 | BUILD_BUG_ON(sizeof(struct prestera_msg_port_info_resp) != 20); |
| 522 | BUILD_BUG_ON(sizeof(struct prestera_msg_bridge_resp) != 12); | 539 | BUILD_BUG_ON(sizeof(struct prestera_msg_bridge_resp) != 12); |
| @@ -549,9 +566,9 @@ static int __prestera_cmd_ret(struct prestera_switch *sw, · 26 unmodified lines | |||
| 549 | if (err) | 566 | if (err) |
| 550 | return err; | 567 | return err; |
| 551 | 568 | ||
| 552 | if (__le32_to_cpu(ret->cmd.type) != PRESTERA_CMD_TYPE_ACK) | 569 | if (ret->cmd.type != __cpu_to_le32(PRESTERA_CMD_TYPE_ACK)) |
| 553 | return -EBADE; | 570 | return -EBADE; |
| 554 | if (__le32_to_cpu(ret->status) != PRESTERA_CMD_ACK_OK) | 571 | if (ret->status != __cpu_to_le32(PRESTERA_CMD_ACK_OK)) |
| 555 | return -EINVAL; | 572 | return -EINVAL; |
| 556 | 573 | ||
| 557 | return 0; | 574 | return 0; |
| @@ -1344,7 +1361,8 @@ int prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed) · 786 unmodified lines | |||
| 1344 | int prestera_hw_port_autoneg_restart(struct prestera_port *port) | 1361 | int prestera_hw_port_autoneg_restart(struct prestera_port *port) |
| 1345 | { | 1362 | { |
| 1346 | struct prestera_msg_port_attr_req req = { | 1363 | struct prestera_msg_port_attr_req req = { |
| 1347 | .attr = __cpu_to_le32(PRESTERA_CMD_PORT_ATTR_PHY_AUTONEG_RESTART), | 1364 | .attr = |
| 1365 | __cpu_to_le32(PRESTERA_CMD_PORT_ATTR_PHY_AUTONEG_RESTART), | ||
| 1348 | .port = __cpu_to_le32(port->hw_id), | 1366 | .port = __cpu_to_le32(port->hw_id), |
| 1349 | .dev = __cpu_to_le32(port->dev_id), | 1367 | .dev = __cpu_to_le32(port->dev_id), |
| 1350 | }; | 1368 | }; |
| @@ -405,7 +405,8 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id) · 404 unmodified lines | |||
| 405 | 405 | ||
| 406 | err = prestera_port_cfg_mac_write(port, &cfg_mac); | 406 | err = prestera_port_cfg_mac_write(port, &cfg_mac); |
| 407 | if (err) { | 407 | if (err) { |
| 408 | dev_err(prestera_dev(sw), "Failed to set port(%u) mac mode\n", id); | 408 | dev_err(prestera_dev(sw), |
| 409 | "Failed to set port(%u) mac mode\n", id); | ||
| 409 | goto err_port_init; | 410 | goto err_port_init; |
| 410 | } | 411 | } |
| 411 | 412 | ||
| @@ -418,7 +419,8 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id) · 6 unmodified lines | |||
| 418 | false, 0, 0, | 419 | false, 0, 0, |
| 419 | port->cfg_phy.mdix); | 420 | port->cfg_phy.mdix); |
| 420 | if (err) { | 421 | if (err) { |
| 421 | dev_err(prestera_dev(sw), "Failed to set port(%u) phy mode\n", id); | 422 | dev_err(prestera_dev(sw), |
| 423 | "Failed to set port(%u) phy mode\n", id); | ||
| 422 | goto err_port_init; | 424 | goto err_port_init; |
| 423 | } | 425 | } |
| 424 | } | 426 | } |
| @@ -411,7 +411,8 @@ static int prestera_fw_cmd_send(struct prestera_fw *fw, int qid, · 410 unmodified lines | |||
| 411 | goto cmd_exit; | 411 | goto cmd_exit; |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | memcpy_fromio(out_msg, prestera_fw_cmdq_buf(fw, qid) + in_size, ret_size); | 414 | memcpy_fromio(out_msg, |
| 415 | prestera_fw_cmdq_buf(fw, qid) + in_size, ret_size); | ||
| 415 | 416 | ||
| 416 | cmd_exit: | 417 | cmd_exit: |
| 417 | prestera_fw_write(fw, PRESTERA_CMDQ_REQ_CTL_REG(qid), | 418 | prestera_fw_write(fw, PRESTERA_CMDQ_REQ_CTL_REG(qid), |
| @@ -289,7 +289,7 @@ mlx5_lag_create_definer(struct mlx5_lag *ldev, enum netdev_lag_hash hash, · 288 unmodified lines | |||
| 289 | 289 | ||
| 290 | lag_definer = kzalloc(sizeof(*lag_definer), GFP_KERNEL); | 290 | lag_definer = kzalloc(sizeof(*lag_definer), GFP_KERNEL); |
| 291 | if (!lag_definer) | 291 | if (!lag_definer) |
| 292 | return ERR_PTR(ENOMEM); | 292 | return ERR_PTR(-ENOMEM); |
| 293 | 293 | ||
| 294 | match_definer_mask = kvzalloc(MLX5_FLD_SZ_BYTES(match_definer, | 294 | match_definer_mask = kvzalloc(MLX5_FLD_SZ_BYTES(match_definer, |
| 295 | match_mask), | 295 | match_mask), |
| @@ -1424,7 +1424,7 @@ static void mana_gd_shutdown(struct pci_dev *pdev) · 1423 unmodified lines | |||
| 1424 | { | 1424 | { |
| 1425 | struct gdma_context *gc = pci_get_drvdata(pdev); | 1425 | struct gdma_context *gc = pci_get_drvdata(pdev); |
| 1426 | 1426 | ||
| 1427 | dev_info(&pdev->dev, "Shutdown was calledd\n"); | 1427 | dev_info(&pdev->dev, "Shutdown was called\n"); |
| 1428 | 1428 | ||
| 1429 | mana_remove(&gc->mana, true); | 1429 | mana_remove(&gc->mana, true); |
| 1430 | 1430 | ||
| @@ -817,9 +817,7 @@ ef4_realloc_channels(struct ef4_nic *efx, u32 rxq_entries, u32 txq_entries) · 816 unmodified lines | |||
| 817 | efx->rxq_entries = rxq_entries; | 817 | efx->rxq_entries = rxq_entries; |
| 818 | efx->txq_entries = txq_entries; | 818 | efx->txq_entries = txq_entries; |
| 819 | for (i = 0; i < efx->n_channels; i++) { | 819 | for (i = 0; i < efx->n_channels; i++) { |
| 820 | channel = efx->channel[i]; | 820 | swap(efx->channel[i], other_channel[i]); |
| 821 | efx->channel[i] = other_channel[i]; | ||
| 822 | other_channel[i] = channel; | ||
| 823 | } | 821 | } |
| 824 | 822 | ||
| 825 | /* Restart buffer table allocation */ | 823 | /* Restart buffer table allocation */ |
| @@ -863,9 +861,7 @@ rollback: · 37 unmodified lines | |||
| 863 | efx->rxq_entries = old_rxq_entries; | 861 | efx->rxq_entries = old_rxq_entries; |
| 864 | efx->txq_entries = old_txq_entries; | 862 | efx->txq_entries = old_txq_entries; |
| 865 | for (i = 0; i < efx->n_channels; i++) { | 863 | for (i = 0; i < efx->n_channels; i++) { |
| 866 | channel = efx->channel[i]; | 864 | swap(efx->channel[i], other_channel[i]); |
| 867 | efx->channel[i] = other_channel[i]; | ||
| 868 | other_channel[i] = channel; | ||
| 869 | } | 865 | } |
| 870 | goto out; | 866 | goto out; |
| 871 | } | 867 | } |
| @@ -786,8 +786,6 @@ static int tc_setup_taprio(struct stmmac_priv *priv, · 785 unmodified lines | |||
| 786 | goto disable; | 786 | goto disable; |
| 787 | if (qopt->num_entries >= dep) | 787 | if (qopt->num_entries >= dep) |
| 788 | return -EINVAL; | 788 | return -EINVAL; |
| 789 | if (!qopt->base_time) | ||
| 790 | return -ERANGE; | ||
| 791 | if (!qopt->cycle_time) | 789 | if (!qopt->cycle_time) |
| 792 | return -ERANGE; | 790 | return -ERANGE; |
| 793 | 791 | ||
| @@ -1299,10 +1299,8 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params) · 1298 unmodified lines | |||
| 1299 | if (!ale) | 1299 | if (!ale) |
| 1300 | return ERR_PTR(-ENOMEM); | 1300 | return ERR_PTR(-ENOMEM); |
| 1301 | 1301 | ||
| 1302 | ale->p0_untag_vid_mask = | 1302 | ale->p0_untag_vid_mask = devm_bitmap_zalloc(params->dev, VLAN_N_VID, |
| 1303 | devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID), | 1303 | GFP_KERNEL); |
| 1304 | sizeof(unsigned long), | ||
| 1305 | GFP_KERNEL); | ||
| 1306 | if (!ale->p0_untag_vid_mask) | 1304 | if (!ale->p0_untag_vid_mask) |
| 1307 | return ERR_PTR(-ENOMEM); | 1305 | return ERR_PTR(-ENOMEM); |
| 1308 | 1306 | ||
| @@ -420,8 +420,20 @@ static int emac_set_coalesce(struct net_device *ndev, · 419 unmodified lines | |||
| 420 | u32 int_ctrl, num_interrupts = 0; | 420 | u32 int_ctrl, num_interrupts = 0; |
| 421 | u32 prescale = 0, addnl_dvdr = 1, coal_intvl = 0; | 421 | u32 prescale = 0, addnl_dvdr = 1, coal_intvl = 0; |
| 422 | 422 | ||
| 423 | if (!coal->rx_coalesce_usecs) | 423 | if (!coal->rx_coalesce_usecs) { |
| 424 | return -EINVAL; | 424 | priv->coal_intvl = 0; |
| 425 | |||
| 426 | switch (priv->version) { | ||
| 427 | case EMAC_VERSION_2: | ||
| 428 | emac_ctrl_write(EMAC_DM646X_CMINTCTRL, 0); | ||
| 429 | break; | ||
| 430 | default: | ||
| 431 | emac_ctrl_write(EMAC_CTRL_EWINTTCNT, 0); | ||
| 432 | break; | ||
| 433 | } | ||
| 434 | |||
| 435 | return 0; | ||
| 436 | } | ||
| 425 | 437 | ||
| 426 | coal_intvl = coal->rx_coalesce_usecs; | 438 | coal_intvl = coal->rx_coalesce_usecs; |
| 427 | 439 | ||
| @@ -672,11 +672,13 @@ static void sixpack_close(struct tty_struct *tty) · 671 unmodified lines | |||
| 672 | del_timer_sync(&sp->tx_t); | 672 | del_timer_sync(&sp->tx_t); |
| 673 | del_timer_sync(&sp->resync_t); | 673 | del_timer_sync(&sp->resync_t); |
| 674 | 674 | ||
| 675 | /* Free all 6pack frame buffers. */ | 675 | unregister_netdev(sp->dev); |
| 676 | |||
| 677 | /* Free all 6pack frame buffers after unreg. */ | ||
| 676 | kfree(sp->rbuff); | 678 | kfree(sp->rbuff); |
| 677 | kfree(sp->xbuff); | 679 | kfree(sp->xbuff); |
| 678 | 680 | ||
| 679 | unregister_netdev(sp->dev); | 681 | free_netdev(sp->dev); |
| 680 | } | 682 | } |
| 681 | 683 | ||
| 682 | /* Perform I/O control on an active 6pack channel. */ | 684 | /* Perform I/O control on an active 6pack channel. */ |
| @@ -792,13 +792,14 @@ static void mkiss_close(struct tty_struct *tty) · 791 unmodified lines | |||
| 792 | */ | 792 | */ |
| 793 | netif_stop_queue(ax->dev); | 793 | netif_stop_queue(ax->dev); |
| 794 | 794 | ||
| 795 | /* Free all AX25 frame buffers. */ | ||
| 796 | kfree(ax->rbuff); | ||
| 797 | kfree(ax->xbuff); | ||
| 798 | |||
| 799 | ax->tty = NULL; | 795 | ax->tty = NULL; |
| 800 | 796 | ||
| 801 | unregister_netdev(ax->dev); | 797 | unregister_netdev(ax->dev); |
| 798 | |||
| 799 | /* Free all AX25 frame buffers after unreg. */ | ||
| 800 | kfree(ax->rbuff); | ||
| 801 | kfree(ax->xbuff); | ||
| 802 | |||
| 802 | free_netdev(ax->dev); | 803 | free_netdev(ax->dev); |
| 803 | } | 804 | } |
| 804 | 805 | ||
| @@ -28,6 +28,11 @@ · 27 unmodified lines | |||
| 28 | #define LAN87XX_MASK_LINK_UP (0x0004) | 28 | #define LAN87XX_MASK_LINK_UP (0x0004) |
| 29 | #define LAN87XX_MASK_LINK_DOWN (0x0002) | 29 | #define LAN87XX_MASK_LINK_DOWN (0x0002) |
| 30 | 30 | ||
| 31 | /* MISC Control 1 Register */ | ||
| 32 | #define LAN87XX_CTRL_1 (0x11) | ||
| 33 | #define LAN87XX_MASK_RGMII_TXC_DLY_EN (0x4000) | ||
| 34 | #define LAN87XX_MASK_RGMII_RXC_DLY_EN (0x2000) | ||
| 35 | |||
| 31 | /* phyaccess nested types */ | 36 | /* phyaccess nested types */ |
| 32 | #define PHYACC_ATTR_MODE_READ 0 | 37 | #define PHYACC_ATTR_MODE_READ 0 |
| 33 | #define PHYACC_ATTR_MODE_WRITE 1 | 38 | #define PHYACC_ATTR_MODE_WRITE 1 |
| @@ -112,6 +117,43 @@ static int access_ereg_modify_changed(struct phy_device *phydev, · 78 unmodified lines | |||
| 112 | return rc; | 117 | return rc; |
| 113 | } | 118 | } |
| 114 | 119 | ||
| 120 | static int lan87xx_config_rgmii_delay(struct phy_device *phydev) | ||
| 121 | { | ||
| 122 | int rc; | ||
| 123 | |||
| 124 | if (!phy_interface_is_rgmii(phydev)) | ||
| 125 | return 0; | ||
| 126 | |||
| 127 | rc = access_ereg(phydev, PHYACC_ATTR_MODE_READ, | ||
| 128 | PHYACC_ATTR_BANK_MISC, LAN87XX_CTRL_1, 0); | ||
| 129 | if (rc < 0) | ||
| 130 | return rc; | ||
| 131 | |||
| 132 | switch (phydev->interface) { | ||
| 133 | case PHY_INTERFACE_MODE_RGMII: | ||
| 134 | rc &= ~LAN87XX_MASK_RGMII_TXC_DLY_EN; | ||
| 135 | rc &= ~LAN87XX_MASK_RGMII_RXC_DLY_EN; | ||
| 136 | break; | ||
| 137 | case PHY_INTERFACE_MODE_RGMII_ID: | ||
| 138 | rc |= LAN87XX_MASK_RGMII_TXC_DLY_EN; | ||
| 139 | rc |= LAN87XX_MASK_RGMII_RXC_DLY_EN; | ||
| 140 | break; | ||
| 141 | case PHY_INTERFACE_MODE_RGMII_RXID: | ||
| 142 | rc &= ~LAN87XX_MASK_RGMII_TXC_DLY_EN; | ||
| 143 | rc |= LAN87XX_MASK_RGMII_RXC_DLY_EN; | ||
| 144 | break; | ||
| 145 | case PHY_INTERFACE_MODE_RGMII_TXID: | ||
| 146 | rc |= LAN87XX_MASK_RGMII_TXC_DLY_EN; | ||
| 147 | rc &= ~LAN87XX_MASK_RGMII_RXC_DLY_EN; | ||
| 148 | break; | ||
| 149 | default: | ||
| 150 | return 0; | ||
| 151 | } | ||
| 152 | |||
| 153 | return access_ereg(phydev, PHYACC_ATTR_MODE_WRITE, | ||
| 154 | PHYACC_ATTR_BANK_MISC, LAN87XX_CTRL_1, rc); | ||
| 155 | } | ||
| 156 | |||
| 115 | static int lan87xx_phy_init(struct phy_device *phydev) | 157 | static int lan87xx_phy_init(struct phy_device *phydev) |
| 116 | { | 158 | { |
| 117 | static const struct access_ereg_val init[] = { | 159 | static const struct access_ereg_val init[] = { |
| @@ -185,7 +227,7 @@ static int lan87xx_phy_init(struct phy_device *phydev) · 67 unmodified lines | |||
| 185 | return rc; | 227 | return rc; |
| 186 | } | 228 | } |
| 187 | 229 | ||
| 188 | return 0; | 230 | return lan87xx_config_rgmii_delay(phydev); |
| 189 | } | 231 | } |
| 190 | 232 | ||
| 191 | static int lan87xx_phy_config_intr(struct phy_device *phydev) | 233 | static int lan87xx_phy_config_intr(struct phy_device *phydev) |
| @@ -815,7 +815,12 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, · 814 unmodified lines | |||
| 815 | phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; | 815 | phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; |
| 816 | 816 | ||
| 817 | /* Restart the PHY */ | 817 | /* Restart the PHY */ |
| 818 | _phy_start_aneg(phydev); | 818 | if (phy_is_started(phydev)) { |
| 819 | phydev->state = PHY_UP; | ||
| 820 | phy_trigger_machine(phydev); | ||
| 821 | } else { | ||
| 822 | _phy_start_aneg(phydev); | ||
| 823 | } | ||
| 819 | 824 | ||
| 820 | mutex_unlock(&phydev->lock); | 825 | mutex_unlock(&phydev->lock); |
| 821 | return 0; | 826 | return 0; |
| @@ -409,7 +409,7 @@ static int genmii_read_link(struct mii_phy *phy) · 408 unmodified lines | |||
| 409 | * though magic-aneg shouldn't prevent this case from occurring | 409 | * though magic-aneg shouldn't prevent this case from occurring |
| 410 | */ | 410 | */ |
| 411 | 411 | ||
| 412 | return 0; | 412 | return 0; |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | static int generic_suspend(struct mii_phy* phy) | 415 | static int generic_suspend(struct mii_phy* phy) |
| @@ -394,12 +394,10 @@ void ipc_imem_sys_devlink_close(struct iosm_devlink *ipc_devlink) · 393 unmodified lines | |||
| 394 | int boot_check_timeout = BOOT_CHECK_DEFAULT_TIMEOUT; | 394 | int boot_check_timeout = BOOT_CHECK_DEFAULT_TIMEOUT; |
| 395 | enum ipc_mem_exec_stage exec_stage; | 395 | enum ipc_mem_exec_stage exec_stage; |
| 396 | struct ipc_mem_channel *channel; | 396 | struct ipc_mem_channel *channel; |
| 397 | enum ipc_phase curr_phase; | ||
| 398 | int status = 0; | 397 | int status = 0; |
| 399 | u32 tail = 0; | 398 | u32 tail = 0; |
| 400 | 399 | ||
| 401 | channel = ipc_imem->ipc_devlink->devlink_sio.channel; | 400 | channel = ipc_imem->ipc_devlink->devlink_sio.channel; |
| 402 | curr_phase = ipc_imem->phase; | ||
| 403 | /* Increase the total wait time to boot_check_timeout */ | 401 | /* Increase the total wait time to boot_check_timeout */ |
| 404 | do { | 402 | do { |
| 405 | exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio); | 403 | exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio); |
| @@ -2216,7 +2216,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb) · 2215 unmodified lines | |||
| 2216 | frag = pn533_alloc_skb(dev, frag_size); | 2216 | frag = pn533_alloc_skb(dev, frag_size); |
| 2217 | if (!frag) { | 2217 | if (!frag) { |
| 2218 | skb_queue_purge(&dev->fragment_skb); | 2218 | skb_queue_purge(&dev->fragment_skb); |
| 2219 | break; | 2219 | return -ENOMEM; |
| 2220 | } | 2220 | } |
| 2221 | 2221 | ||
| 2222 | if (!dev->tgt_mode) { | 2222 | if (!dev->tgt_mode) { |
| @@ -2285,7 +2285,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev, · 62 unmodified lines | |||
| 2285 | /* jumbo frame ? */ | 2285 | /* jumbo frame ? */ |
| 2286 | if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { | 2286 | if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { |
| 2287 | rc = pn533_fill_fragment_skbs(dev, skb); | 2287 | rc = pn533_fill_fragment_skbs(dev, skb); |
| 2288 | if (rc <= 0) | 2288 | if (rc < 0) |
| 2289 | goto error; | 2289 | goto error; |
| 2290 | 2290 | ||
| 2291 | skb = skb_dequeue(&dev->fragment_skb); | 2291 | skb = skb_dequeue(&dev->fragment_skb); |
| @@ -2353,7 +2353,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) · 61 unmodified lines | |||
| 2353 | /* let's split in multiple chunks if size's too big */ | 2353 | /* let's split in multiple chunks if size's too big */ |
| 2354 | if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { | 2354 | if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { |
| 2355 | rc = pn533_fill_fragment_skbs(dev, skb); | 2355 | rc = pn533_fill_fragment_skbs(dev, skb); |
| 2356 | if (rc <= 0) | 2356 | if (rc < 0) |
| 2357 | goto error; | 2357 | goto error; |
| 2358 | 2358 | ||
| 2359 | /* get the first skb */ | 2359 | /* get the first skb */ |
| @@ -624,7 +624,7 @@ static void port100_recv_response(struct urb *urb) · 623 unmodified lines | |||
| 624 | break; /* success */ | 624 | break; /* success */ |
| 625 | case -ECONNRESET: | 625 | case -ECONNRESET: |
| 626 | case -ENOENT: | 626 | case -ENOENT: |
| 627 | nfc_err(&dev->interface->dev, | 627 | nfc_dbg(&dev->interface->dev, |
| 628 | "The urb has been canceled (status %d)\n", urb->status); | 628 | "The urb has been canceled (status %d)\n", urb->status); |
| 629 | goto sched_wq; | 629 | goto sched_wq; |
| 630 | case -ESHUTDOWN: | 630 | case -ESHUTDOWN: |
| @@ -678,7 +678,7 @@ static void port100_recv_ack(struct urb *urb) · 47 unmodified lines | |||
| 678 | break; /* success */ | 678 | break; /* success */ |
| 679 | case -ECONNRESET: | 679 | case -ECONNRESET: |
| 680 | case -ENOENT: | 680 | case -ENOENT: |
| 681 | nfc_err(&dev->interface->dev, | 681 | nfc_dbg(&dev->interface->dev, |
| 682 | "The urb has been stopped (status %d)\n", urb->status); | 682 | "The urb has been stopped (status %d)\n", urb->status); |
| 683 | goto sched_wq; | 683 | goto sched_wq; |
| 684 | case -ESHUTDOWN: | 684 | case -ESHUTDOWN: |
| @@ -942,7 +942,7 @@ static void port100_send_complete(struct urb *urb) · 257 unmodified lines | |||
| 942 | break; /* success */ | 942 | break; /* success */ |
| 943 | case -ECONNRESET: | 943 | case -ECONNRESET: |
| 944 | case -ENOENT: | 944 | case -ENOENT: |
| 945 | nfc_err(&dev->interface->dev, | 945 | nfc_dbg(&dev->interface->dev, |
| 946 | "The urb has been stopped (status %d)\n", urb->status); | 946 | "The urb has been stopped (status %d)\n", urb->status); |
| 947 | break; | 947 | break; |
| 948 | case -ESHUTDOWN: | 948 | case -ESHUTDOWN: |
| @@ -448,6 +448,30 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) · 447 unmodified lines | |||
| 448 | } | 448 | } |
| 449 | EXPORT_SYMBOL(simple_rmdir); | 449 | EXPORT_SYMBOL(simple_rmdir); |
| 450 | 450 | ||
| 451 | int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry, | ||
| 452 | struct inode *new_dir, struct dentry *new_dentry) | ||
| 453 | { | ||
| 454 | bool old_is_dir = d_is_dir(old_dentry); | ||
| 455 | bool new_is_dir = d_is_dir(new_dentry); | ||
| 456 | |||
| 457 | if (old_dir != new_dir && old_is_dir != new_is_dir) { | ||
| 458 | if (old_is_dir) { | ||
| 459 | drop_nlink(old_dir); | ||
| 460 | inc_nlink(new_dir); | ||
| 461 | } else { | ||
| 462 | drop_nlink(new_dir); | ||
| 463 | inc_nlink(old_dir); | ||
| 464 | } | ||
| 465 | } | ||
| 466 | old_dir->i_ctime = old_dir->i_mtime = | ||
| 467 | new_dir->i_ctime = new_dir->i_mtime = | ||
| 468 | d_inode(old_dentry)->i_ctime = | ||
| 469 | d_inode(new_dentry)->i_ctime = current_time(old_dir); | ||
| 470 | |||
| 471 | return 0; | ||
| 472 | } | ||
| 473 | EXPORT_SYMBOL_GPL(simple_rename_exchange); | ||
| 474 | |||
| 451 | int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir, | 475 | int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir, |
| 452 | struct dentry *old_dentry, struct inode *new_dir, | 476 | struct dentry *old_dentry, struct inode *new_dir, |
| 453 | struct dentry *new_dentry, unsigned int flags) | 477 | struct dentry *new_dentry, unsigned int flags) |
| @@ -455,9 +479,12 @@ int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir, · 1 unmodified line | |||
| 455 | struct inode *inode = d_inode(old_dentry); | 479 | struct inode *inode = d_inode(old_dentry); |
| 456 | int they_are_dirs = d_is_dir(old_dentry); | 480 | int they_are_dirs = d_is_dir(old_dentry); |
| 457 | 481 | ||
| 458 | if (flags & ~RENAME_NOREPLACE) | 482 | if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) |
| 459 | return -EINVAL; | 483 | return -EINVAL; |
| 460 | 484 | ||
| 485 | if (flags & RENAME_EXCHANGE) | ||
| 486 | return simple_rename_exchange(old_dir, old_dentry, new_dir, new_dentry); | ||
| 487 | |||
| 461 | if (!simple_empty(new_dentry)) | 488 | if (!simple_empty(new_dentry)) |
| 462 | return -ENOTEMPTY; | 489 | return -ENOTEMPTY; |
| 463 | 490 | ||
| @@ -484,6 +484,12 @@ bpf_ctx_record_field_size(struct bpf_insn_access_aux *aux, u32 size) · 483 unmodified lines | |||
| 484 | aux->ctx_field_size = size; | 484 | aux->ctx_field_size = size; |
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | static inline bool bpf_pseudo_func(const struct bpf_insn *insn) | ||
| 488 | { | ||
| 489 | return insn->code == (BPF_LD | BPF_IMM | BPF_DW) && | ||
| 490 | insn->src_reg == BPF_PSEUDO_FUNC; | ||
| 491 | } | ||
| 492 | |||
| 487 | struct bpf_prog_ops { | 493 | struct bpf_prog_ops { |
| 488 | int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr, | 494 | int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr, |
| 489 | union bpf_attr __user *uattr); | 495 | union bpf_attr __user *uattr); |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | |||
| 12 | struct ocelot_skb_cb { | 12 | struct ocelot_skb_cb { |
| 13 | struct sk_buff *clone; | 13 | struct sk_buff *clone; |
| 14 | unsigned int ptp_class; /* valid only for clones */ | 14 | unsigned int ptp_class; /* valid only for clones */ |
| 15 | u32 tstamp_lo; | ||
| 15 | u8 ptp_cmd; | 16 | u8 ptp_cmd; |
| 16 | u8 ts_id; | 17 | u8 ts_id; |
| 17 | }; | 18 | }; |
| @@ -10,6 +10,9 @@ · 9 unmodified lines | |||
| 10 | #define __ETHTOOL_LINK_MODE_MASK_NWORDS \ | 10 | #define __ETHTOOL_LINK_MODE_MASK_NWORDS \ |
| 11 | DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32) | 11 | DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32) |
| 12 | 12 | ||
| 13 | #define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT - \ | ||
| 14 | ETHTOOL_A_PAUSE_STAT_TX_FRAMES) | ||
| 15 | |||
| 13 | enum ethtool_multicast_groups { | 16 | enum ethtool_multicast_groups { |
| 14 | ETHNL_MCGRP_MONITOR, | 17 | ETHNL_MCGRP_MONITOR, |
| 15 | }; | 18 | }; |
| @@ -3385,6 +3385,8 @@ extern int simple_open(struct inode *inode, struct file *file); · 3384 unmodified lines | |||
| 3385 | extern int simple_link(struct dentry *, struct inode *, struct dentry *); | 3385 | extern int simple_link(struct dentry *, struct inode *, struct dentry *); |
| 3386 | extern int simple_unlink(struct inode *, struct dentry *); | 3386 | extern int simple_unlink(struct inode *, struct dentry *); |
| 3387 | extern int simple_rmdir(struct inode *, struct dentry *); | 3387 | extern int simple_rmdir(struct inode *, struct dentry *); |
| 3388 | extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry, | ||
| 3389 | struct inode *new_dir, struct dentry *new_dentry); | ||
| 3388 | extern int simple_rename(struct user_namespace *, struct inode *, | 3390 | extern int simple_rename(struct user_namespace *, struct inode *, |
| 3389 | struct dentry *, struct inode *, struct dentry *, | 3391 | struct dentry *, struct inode *, struct dentry *, |
| 3390 | unsigned int); | 3392 | unsigned int); |
| @@ -329,12 +329,14 @@ LSM_HOOK(int, 0, tun_dev_create, void) · 328 unmodified lines | |||
| 329 | LSM_HOOK(int, 0, tun_dev_attach_queue, void *security) | 329 | LSM_HOOK(int, 0, tun_dev_attach_queue, void *security) |
| 330 | LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security) | 330 | LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security) |
| 331 | LSM_HOOK(int, 0, tun_dev_open, void *security) | 331 | LSM_HOOK(int, 0, tun_dev_open, void *security) |
| 332 | LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_endpoint *ep, | 332 | LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_association *asoc, |
| 333 | struct sk_buff *skb) | 333 | struct sk_buff *skb) |
| 334 | LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname, | 334 | LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname, |
| 335 | struct sockaddr *address, int addrlen) | 335 | struct sockaddr *address, int addrlen) |
| 336 | LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_endpoint *ep, | 336 | LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_association *asoc, |
| 337 | struct sock *sk, struct sock *newsk) | 337 | struct sock *sk, struct sock *newsk) |
| 338 | LSM_HOOK(void, LSM_RET_VOID, sctp_assoc_established, struct sctp_association *asoc, | ||
| 339 | struct sk_buff *skb) | ||
| 338 | #endif /* CONFIG_SECURITY_NETWORK */ | 340 | #endif /* CONFIG_SECURITY_NETWORK */ |
| 339 | 341 | ||
| 340 | #ifdef CONFIG_SECURITY_INFINIBAND | 342 | #ifdef CONFIG_SECURITY_INFINIBAND |
| @@ -1027,9 +1027,9 @@ · 1026 unmodified lines | |||
| 1027 | * Security hooks for SCTP | 1027 | * Security hooks for SCTP |
| 1028 | * | 1028 | * |
| 1029 | * @sctp_assoc_request: | 1029 | * @sctp_assoc_request: |
| 1030 | * Passes the @ep and @chunk->skb of the association INIT packet to | 1030 | * Passes the @asoc and @chunk->skb of the association INIT packet to |
| 1031 | * the security module. | 1031 | * the security module. |
| 1032 | * @ep pointer to sctp endpoint structure. | 1032 | * @asoc pointer to sctp association structure. |
| 1033 | * @skb pointer to skbuff of association packet. | 1033 | * @skb pointer to skbuff of association packet. |
| 1034 | * Return 0 on success, error on failure. | 1034 | * Return 0 on success, error on failure. |
| 1035 | * @sctp_bind_connect: | 1035 | * @sctp_bind_connect: |
| @@ -1047,9 +1047,14 @@ · 11 unmodified lines | |||
| 1047 | * Called whenever a new socket is created by accept(2) (i.e. a TCP | 1047 | * Called whenever a new socket is created by accept(2) (i.e. a TCP |
| 1048 | * style socket) or when a socket is 'peeled off' e.g userspace | 1048 | * style socket) or when a socket is 'peeled off' e.g userspace |
| 1049 | * calls sctp_peeloff(3). | 1049 | * calls sctp_peeloff(3). |
| 1050 | * @ep pointer to current sctp endpoint structure. | 1050 | * @asoc pointer to current sctp association structure. |
| 1051 | * @sk pointer to current sock structure. | 1051 | * @sk pointer to current sock structure. |
| 1052 | * @sk pointer to new sock structure. | 1052 | * @newsk pointer to new sock structure. |
| 1053 | * @sctp_assoc_established: | ||
| 1054 | * Passes the @asoc and @chunk->skb of the association COOKIE_ACK packet | ||
| 1055 | * to the security module. | ||
| 1056 | * @asoc pointer to sctp association structure. | ||
| 1057 | * @skb pointer to skbuff of association packet. | ||
| 1053 | * | 1058 | * |
| 1054 | * Security hooks for Infiniband | 1059 | * Security hooks for Infiniband |
| 1055 | * | 1060 | * |
| @@ -179,7 +179,7 @@ struct xfrm_policy; · 178 unmodified lines | |||
| 179 | struct xfrm_state; | 179 | struct xfrm_state; |
| 180 | struct xfrm_user_sec_ctx; | 180 | struct xfrm_user_sec_ctx; |
| 181 | struct seq_file; | 181 | struct seq_file; |
| 182 | struct sctp_endpoint; | 182 | struct sctp_association; |
| 183 | 183 | ||
| 184 | #ifdef CONFIG_MMU | 184 | #ifdef CONFIG_MMU |
| 185 | extern unsigned long mmap_min_addr; | 185 | extern unsigned long mmap_min_addr; |
| @@ -1425,11 +1425,13 @@ int security_tun_dev_create(void); · 1239 unmodified lines | |||
| 1425 | int security_tun_dev_attach_queue(void *security); | 1425 | int security_tun_dev_attach_queue(void *security); |
| 1426 | int security_tun_dev_attach(struct sock *sk, void *security); | 1426 | int security_tun_dev_attach(struct sock *sk, void *security); |
| 1427 | int security_tun_dev_open(void *security); | 1427 | int security_tun_dev_open(void *security); |
| 1428 | int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb); | 1428 | int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb); |
| 1429 | int security_sctp_bind_connect(struct sock *sk, int optname, | 1429 | int security_sctp_bind_connect(struct sock *sk, int optname, |
| 1430 | struct sockaddr *address, int addrlen); | 1430 | struct sockaddr *address, int addrlen); |
| 1431 | void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk, | 1431 | void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, |
| 1432 | struct sock *newsk); | 1432 | struct sock *newsk); |
| 1433 | void security_sctp_assoc_established(struct sctp_association *asoc, | ||
| 1434 | struct sk_buff *skb); | ||
| 1433 | 1435 | ||
| 1434 | #else /* CONFIG_SECURITY_NETWORK */ | 1436 | #else /* CONFIG_SECURITY_NETWORK */ |
| 1435 | static inline int security_unix_stream_connect(struct sock *sock, | 1437 | static inline int security_unix_stream_connect(struct sock *sock, |
| @@ -1631,7 +1633,7 @@ static inline int security_tun_dev_open(void *security) · 195 unmodified lines | |||
| 1631 | return 0; | 1633 | return 0; |
| 1632 | } | 1634 | } |
| 1633 | 1635 | ||
| 1634 | static inline int security_sctp_assoc_request(struct sctp_endpoint *ep, | 1636 | static inline int security_sctp_assoc_request(struct sctp_association *asoc, |
| 1635 | struct sk_buff *skb) | 1637 | struct sk_buff *skb) |
| 1636 | { | 1638 | { |
| 1637 | return 0; | 1639 | return 0; |
| @@ -1644,11 +1646,16 @@ static inline int security_sctp_bind_connect(struct sock *sk, int optname, · 6 unmodified lines | |||
| 1644 | return 0; | 1646 | return 0; |
| 1645 | } | 1647 | } |
| 1646 | 1648 | ||
| 1647 | static inline void security_sctp_sk_clone(struct sctp_endpoint *ep, | 1649 | static inline void security_sctp_sk_clone(struct sctp_association *asoc, |
| 1648 | struct sock *sk, | 1650 | struct sock *sk, |
| 1649 | struct sock *newsk) | 1651 | struct sock *newsk) |
| 1650 | { | 1652 | { |
| 1651 | } | 1653 | } |
| 1654 | |||
| 1655 | static inline void security_sctp_assoc_established(struct sctp_association *asoc, | ||
| 1656 | struct sk_buff *skb) | ||
| 1657 | { | ||
| 1658 | } | ||
| 1652 | #endif /* CONFIG_SECURITY_NETWORK */ | 1659 | #endif /* CONFIG_SECURITY_NETWORK */ |
| 1653 | 1660 | ||
| 1654 | #ifdef CONFIG_SECURITY_INFINIBAND | 1661 | #ifdef CONFIG_SECURITY_INFINIBAND |
| @@ -454,9 +454,15 @@ enum { · 453 unmodified lines | |||
| 454 | * all frags to avoid possible bad checksum | 454 | * all frags to avoid possible bad checksum |
| 455 | */ | 455 | */ |
| 456 | SKBFL_SHARED_FRAG = BIT(1), | 456 | SKBFL_SHARED_FRAG = BIT(1), |
| 457 | |||
| 458 | /* segment contains only zerocopy data and should not be | ||
| 459 | * charged to the kernel memory. | ||
| 460 | */ | ||
| 461 | SKBFL_PURE_ZEROCOPY = BIT(2), | ||
| 457 | }; | 462 | }; |
| 458 | 463 | ||
| 459 | #define SKBFL_ZEROCOPY_FRAG (SKBFL_ZEROCOPY_ENABLE | SKBFL_SHARED_FRAG) | 464 | #define SKBFL_ZEROCOPY_FRAG (SKBFL_ZEROCOPY_ENABLE | SKBFL_SHARED_FRAG) |
| 465 | #define SKBFL_ALL_ZEROCOPY (SKBFL_ZEROCOPY_FRAG | SKBFL_PURE_ZEROCOPY) | ||
| 460 | 466 | ||
| 461 | /* | 467 | /* |
| 462 | * The callback notifies userspace to release buffers when skb DMA is done in | 468 | * The callback notifies userspace to release buffers when skb DMA is done in |
| @@ -1464,6 +1470,17 @@ static inline struct ubuf_info *skb_zcopy(struct sk_buff *skb) · 1001 unmodified lines | |||
| 1464 | return is_zcopy ? skb_uarg(skb) : NULL; | 1470 | return is_zcopy ? skb_uarg(skb) : NULL; |
| 1465 | } | 1471 | } |
| 1466 | 1472 | ||
| 1473 | static inline bool skb_zcopy_pure(const struct sk_buff *skb) | ||
| 1474 | { | ||
| 1475 | return skb_shinfo(skb)->flags & SKBFL_PURE_ZEROCOPY; | ||
| 1476 | } | ||
| 1477 | |||
| 1478 | static inline bool skb_pure_zcopy_same(const struct sk_buff *skb1, | ||
| 1479 | const struct sk_buff *skb2) | ||
| 1480 | { | ||
| 1481 | return skb_zcopy_pure(skb1) == skb_zcopy_pure(skb2); | ||
| 1482 | } | ||
| 1483 | |||
| 1467 | static inline void net_zcopy_get(struct ubuf_info *uarg) | 1484 | static inline void net_zcopy_get(struct ubuf_info *uarg) |
| 1468 | { | 1485 | { |
| 1469 | refcount_inc(&uarg->refcnt); | 1486 | refcount_inc(&uarg->refcnt); |
| @@ -1528,7 +1545,7 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy_success) · 58 unmodified lines | |||
| 1528 | if (!skb_zcopy_is_nouarg(skb)) | 1545 | if (!skb_zcopy_is_nouarg(skb)) |
| 1529 | uarg->callback(skb, uarg, zerocopy_success); | 1546 | uarg->callback(skb, uarg, zerocopy_success); |
| 1530 | 1547 | ||
| 1531 | skb_shinfo(skb)->flags &= ~SKBFL_ZEROCOPY_FRAG; | 1548 | skb_shinfo(skb)->flags &= ~SKBFL_ALL_ZEROCOPY; |
| 1532 | } | 1549 | } |
| 1533 | } | 1550 | } |
| 1534 | 1551 | ||
| @@ -1675,6 +1692,22 @@ static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) · 140 unmodified lines | |||
| 1675 | return 0; | 1692 | return 0; |
| 1676 | } | 1693 | } |
| 1677 | 1694 | ||
| 1695 | /* This variant of skb_unclone() makes sure skb->truesize is not changed */ | ||
| 1696 | static inline int skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri) | ||
| 1697 | { | ||
| 1698 | might_sleep_if(gfpflags_allow_blocking(pri)); | ||
| 1699 | |||
| 1700 | if (skb_cloned(skb)) { | ||
| 1701 | unsigned int save = skb->truesize; | ||
| 1702 | int res; | ||
| 1703 | |||
| 1704 | res = pskb_expand_head(skb, 0, 0, pri); | ||
| 1705 | skb->truesize = save; | ||
| 1706 | return res; | ||
| 1707 | } | ||
| 1708 | return 0; | ||
| 1709 | } | ||
| 1710 | |||
| 1678 | /** | 1711 | /** |
| 1679 | * skb_header_cloned - is the header a clone | 1712 | * skb_header_cloned - is the header a clone |
| 1680 | * @skb: buffer to check | 1713 | * @skb: buffer to check |
| @@ -507,6 +507,18 @@ static inline bool sk_psock_strp_enabled(struct sk_psock *psock) · 506 unmodified lines | |||
| 507 | return !!psock->saved_data_ready; | 507 | return !!psock->saved_data_ready; |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | static inline bool sk_is_tcp(const struct sock *sk) | ||
| 511 | { | ||
| 512 | return sk->sk_type == SOCK_STREAM && | ||
| 513 | sk->sk_protocol == IPPROTO_TCP; | ||
| 514 | } | ||
| 515 | |||
| 516 | static inline bool sk_is_udp(const struct sock *sk) | ||
| 517 | { | ||
| 518 | return sk->sk_type == SOCK_DGRAM && | ||
| 519 | sk->sk_protocol == IPPROTO_UDP; | ||
| 520 | } | ||
| 521 | |||
| 510 | #if IS_ENABLED(CONFIG_NET_SOCK_MSG) | 522 | #if IS_ENABLED(CONFIG_NET_SOCK_MSG) |
| 511 | 523 | ||
| 512 | #define BPF_F_STRPARSER (1UL << 1) | 524 | #define BPF_F_STRPARSER (1UL << 1) |
| @@ -72,7 +72,9 @@ struct llc_sap { · 71 unmodified lines | |||
| 72 | static inline | 72 | static inline |
| 73 | struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex) | 73 | struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex) |
| 74 | { | 74 | { |
| 75 | return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES]; | 75 | u32 bucket = hash_32(ifindex, LLC_SK_DEV_HASH_BITS); |
| 76 | |||
| 77 | return &sap->sk_dev_hash[bucket]; | ||
| 76 | } | 78 | } |
| 77 | 79 | ||
| 78 | static inline | 80 | static inline |
| @@ -1355,16 +1355,6 @@ struct sctp_endpoint { · 1354 unmodified lines | |||
| 1355 | reconf_enable:1; | 1355 | reconf_enable:1; |
| 1356 | 1356 | ||
| 1357 | __u8 strreset_enable; | 1357 | __u8 strreset_enable; |
| 1358 | |||
| 1359 | /* Security identifiers from incoming (INIT). These are set by | ||
| 1360 | * security_sctp_assoc_request(). These will only be used by | ||
| 1361 | * SCTP TCP type sockets and peeled off connections as they | ||
| 1362 | * cause a new socket to be generated. security_sctp_sk_clone() | ||
| 1363 | * will then plug these into the new socket. | ||
| 1364 | */ | ||
| 1365 | |||
| 1366 | u32 secid; | ||
| 1367 | u32 peer_secid; | ||
| 1368 | }; | 1358 | }; |
| 1369 | 1359 | ||
| 1370 | /* Recover the outter endpoint structure. */ | 1360 | /* Recover the outter endpoint structure. */ |
| @@ -2104,6 +2094,16 @@ struct sctp_association { · 733 unmodified lines | |||
| 2104 | __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1]; | 2094 | __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1]; |
| 2105 | __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1]; | 2095 | __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1]; |
| 2106 | 2096 | ||
| 2097 | /* Security identifiers from incoming (INIT). These are set by | ||
| 2098 | * security_sctp_assoc_request(). These will only be used by | ||
| 2099 | * SCTP TCP type sockets and peeled off connections as they | ||
| 2100 | * cause a new socket to be generated. security_sctp_sk_clone() | ||
| 2101 | * will then plug these into the new socket. | ||
| 2102 | */ | ||
| 2103 | |||
| 2104 | u32 secid; | ||
| 2105 | u32 peer_secid; | ||
| 2106 | |||
| 2107 | struct rcu_head rcu; | 2107 | struct rcu_head rcu; |
| 2108 | }; | 2108 | }; |
| 2109 | 2109 | ||
| @@ -54,10 +54,28 @@ struct strp_msg { · 53 unmodified lines | |||
| 54 | int offset; | 54 | int offset; |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | struct _strp_msg { | ||
| 58 | /* Internal cb structure. struct strp_msg must be first for passing | ||
| 59 | * to upper layer. | ||
| 60 | */ | ||
| 61 | struct strp_msg strp; | ||
| 62 | int accum_len; | ||
| 63 | }; | ||
| 64 | |||
| 65 | struct sk_skb_cb { | ||
| 66 | #define SK_SKB_CB_PRIV_LEN 20 | ||
| 67 | unsigned char data[SK_SKB_CB_PRIV_LEN]; | ||
| 68 | struct _strp_msg strp; | ||
| 69 | /* temp_reg is a temporary register used for bpf_convert_data_end_access | ||
| 70 | * when dst_reg == src_reg. | ||
| 71 | */ | ||
| 72 | u64 temp_reg; | ||
| 73 | }; | ||
| 74 | |||
| 57 | static inline struct strp_msg *strp_msg(struct sk_buff *skb) | 75 | static inline struct strp_msg *strp_msg(struct sk_buff *skb) |
| 58 | { | 76 | { |
| 59 | return (struct strp_msg *)((void *)skb->cb + | 77 | return (struct strp_msg *)((void *)skb->cb + |
| 60 | offsetof(struct qdisc_skb_cb, data)); | 78 | offsetof(struct sk_skb_cb, strp)); |
| 61 | } | 79 | } |
| 62 | 80 | ||
| 63 | /* Structure for an attached lower socket */ | 81 | /* Structure for an attached lower socket */ |
| @@ -293,7 +293,10 @@ static inline bool tcp_out_of_memory(struct sock *sk) · 292 unmodified lines | |||
| 293 | static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb) | 293 | static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb) |
| 294 | { | 294 | { |
| 295 | sk_wmem_queued_add(sk, -skb->truesize); | 295 | sk_wmem_queued_add(sk, -skb->truesize); |
| 296 | sk_mem_uncharge(sk, skb->truesize); | 296 | if (!skb_zcopy_pure(skb)) |
| 297 | sk_mem_uncharge(sk, skb->truesize); | ||
| 298 | else | ||
| 299 | sk_mem_uncharge(sk, SKB_TRUESIZE(skb_end_offset(skb))); | ||
| 297 | __kfree_skb(skb); | 300 | __kfree_skb(skb); |
| 298 | } | 301 | } |
| 299 | 302 | ||
| @@ -974,7 +977,8 @@ static inline bool tcp_skb_can_collapse(const struct sk_buff *to, · 674 unmodified lines | |||
| 974 | const struct sk_buff *from) | 977 | const struct sk_buff *from) |
| 975 | { | 978 | { |
| 976 | return likely(tcp_skb_can_collapse_to(to) && | 979 | return likely(tcp_skb_can_collapse_to(to) && |
| 977 | mptcp_skb_can_collapse(to, from)); | 980 | mptcp_skb_can_collapse(to, from) && |
| 981 | skb_pure_zcopy_same(to, from)); | ||
| 978 | } | 982 | } |
| 979 | 983 | ||
| 980 | /* Events passed to congestion control interface */ | 984 | /* Events passed to congestion control interface */ |
| @@ -411,7 +411,9 @@ enum { · 410 unmodified lines | |||
| 411 | ETHTOOL_A_PAUSE_STAT_TX_FRAMES, | 411 | ETHTOOL_A_PAUSE_STAT_TX_FRAMES, |
| 412 | ETHTOOL_A_PAUSE_STAT_RX_FRAMES, | 412 | ETHTOOL_A_PAUSE_STAT_RX_FRAMES, |
| 413 | 413 | ||
| 414 | /* add new constants above here */ | 414 | /* add new constants above here |
| 415 | * adjust ETHTOOL_PAUSE_STAT_CNT if adding non-stats! | ||
| 416 | */ | ||
| 415 | __ETHTOOL_A_PAUSE_STAT_CNT, | 417 | __ETHTOOL_A_PAUSE_STAT_CNT, |
| 416 | ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1) | 418 | ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1) |
| 417 | }; | 419 | }; |
| @@ -390,6 +390,13 @@ static int bpf_adj_branches(struct bpf_prog *prog, u32 pos, s32 end_old, · 389 unmodified lines | |||
| 390 | i = end_new; | 390 | i = end_new; |
| 391 | insn = prog->insnsi + end_old; | 391 | insn = prog->insnsi + end_old; |
| 392 | } | 392 | } |
| 393 | if (bpf_pseudo_func(insn)) { | ||
| 394 | ret = bpf_adj_delta_to_imm(insn, pos, end_old, | ||
| 395 | end_new, i, probe_pass); | ||
| 396 | if (ret) | ||
| 397 | return ret; | ||
| 398 | continue; | ||
| 399 | } | ||
| 393 | code = insn->code; | 400 | code = insn->code; |
| 394 | if ((BPF_CLASS(code) != BPF_JMP && | 401 | if ((BPF_CLASS(code) != BPF_JMP && |
| 395 | BPF_CLASS(code) != BPF_JMP32) || | 402 | BPF_CLASS(code) != BPF_JMP32) || |
| @@ -240,12 +240,6 @@ static bool bpf_pseudo_kfunc_call(const struct bpf_insn *insn) · 239 unmodified lines | |||
| 240 | insn->src_reg == BPF_PSEUDO_KFUNC_CALL; | 240 | insn->src_reg == BPF_PSEUDO_KFUNC_CALL; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | static bool bpf_pseudo_func(const struct bpf_insn *insn) | ||
| 244 | { | ||
| 245 | return insn->code == (BPF_LD | BPF_IMM | BPF_DW) && | ||
| 246 | insn->src_reg == BPF_PSEUDO_FUNC; | ||
| 247 | } | ||
| 248 | |||
| 249 | struct bpf_call_arg_meta { | 243 | struct bpf_call_arg_meta { |
| 250 | struct bpf_map *map_ptr; | 244 | struct bpf_map *map_ptr; |
| 251 | bool raw_mode; | 245 | bool raw_mode; |
| @@ -1960,16 +1954,10 @@ static int add_subprog_and_kfunc(struct bpf_verifier_env *env) · 1708 unmodified lines | |||
| 1960 | return -EPERM; | 1954 | return -EPERM; |
| 1961 | } | 1955 | } |
| 1962 | 1956 | ||
| 1963 | if (bpf_pseudo_func(insn)) { | 1957 | if (bpf_pseudo_func(insn) || bpf_pseudo_call(insn)) |
| 1964 | ret = add_subprog(env, i + insn->imm + 1); | ||
| 1965 | if (ret >= 0) | ||
| 1966 | /* remember subprog */ | ||
| 1967 | insn[1].imm = ret; | ||
| 1968 | } else if (bpf_pseudo_call(insn)) { | ||
| 1969 | ret = add_subprog(env, i + insn->imm + 1); | 1958 | ret = add_subprog(env, i + insn->imm + 1); |
| 1970 | } else { | 1959 | else |
| 1971 | ret = add_kfunc_call(env, insn->imm, insn->off); | 1960 | ret = add_kfunc_call(env, insn->imm, insn->off); |
| 1972 | } | ||
| 1973 | 1961 | ||
| 1974 | if (ret < 0) | 1962 | if (ret < 0) |
| 1975 | return ret; | 1963 | return ret; |
| @@ -3088,9 +3076,12 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, · 1112 unmodified lines | |||
| 3088 | reg = ®_state->stack[spi].spilled_ptr; | 3076 | reg = ®_state->stack[spi].spilled_ptr; |
| 3089 | 3077 | ||
| 3090 | if (is_spilled_reg(®_state->stack[spi])) { | 3078 | if (is_spilled_reg(®_state->stack[spi])) { |
| 3091 | if (size != BPF_REG_SIZE) { | 3079 | u8 spill_size = 1; |
| 3092 | u8 scalar_size = 0; | 3080 | |
| 3081 | for (i = BPF_REG_SIZE - 1; i > 0 && stype[i - 1] == STACK_SPILL; i--) | ||
| 3082 | spill_size++; | ||
| 3093 | 3083 | ||
| 3084 | if (size != BPF_REG_SIZE || spill_size != BPF_REG_SIZE) { | ||
| 3094 | if (reg->type != SCALAR_VALUE) { | 3085 | if (reg->type != SCALAR_VALUE) { |
| 3095 | verbose_linfo(env, env->insn_idx, "; "); | 3086 | verbose_linfo(env, env->insn_idx, "; "); |
| 3096 | verbose(env, "invalid size of register fill\n"); | 3087 | verbose(env, "invalid size of register fill\n"); |
| @@ -3101,10 +3092,7 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, · 4 unmodified lines | |||
| 3101 | if (dst_regno < 0) | 3092 | if (dst_regno < 0) |
| 3102 | return 0; | 3093 | return 0; |
| 3103 | 3094 | ||
| 3104 | for (i = BPF_REG_SIZE; i > 0 && stype[i - 1] == STACK_SPILL; i--) | 3095 | if (!(off % BPF_REG_SIZE) && size == spill_size) { |
| 3105 | scalar_size++; | ||
| 3106 | |||
| 3107 | if (!(off % BPF_REG_SIZE) && size == scalar_size) { | ||
| 3108 | /* The earlier check_reg_arg() has decided the | 3096 | /* The earlier check_reg_arg() has decided the |
| 3109 | * subreg_def for this insn. Save it first. | 3097 | * subreg_def for this insn. Save it first. |
| 3110 | */ | 3098 | */ |
| @@ -3128,12 +3116,6 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env, · 17 unmodified lines | |||
| 3128 | state->regs[dst_regno].live |= REG_LIVE_WRITTEN; | 3116 | state->regs[dst_regno].live |= REG_LIVE_WRITTEN; |
| 3129 | return 0; | 3117 | return 0; |
| 3130 | } | 3118 | } |
| 3131 | for (i = 1; i < BPF_REG_SIZE; i++) { | ||
| 3132 | if (stype[(slot - i) % BPF_REG_SIZE] != STACK_SPILL) { | ||
| 3133 | verbose(env, "corrupted spill memory\n"); | ||
| 3134 | return -EACCES; | ||
| 3135 | } | ||
| 3136 | } | ||
| 3137 | 3119 | ||
| 3138 | if (dst_regno >= 0) { | 3120 | if (dst_regno >= 0) { |
| 3139 | /* restore register state from stack */ | 3121 | /* restore register state from stack */ |
| @@ -9393,7 +9375,8 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn) · 6253 unmodified lines | |||
| 9393 | 9375 | ||
| 9394 | if (insn->src_reg == BPF_PSEUDO_FUNC) { | 9376 | if (insn->src_reg == BPF_PSEUDO_FUNC) { |
| 9395 | struct bpf_prog_aux *aux = env->prog->aux; | 9377 | struct bpf_prog_aux *aux = env->prog->aux; |
| 9396 | u32 subprogno = insn[1].imm; | 9378 | u32 subprogno = find_subprog(env, |
| 9379 | env->insn_idx + insn->imm + 1); | ||
| 9397 | 9380 | ||
| 9398 | if (!aux->func_info) { | 9381 | if (!aux->func_info) { |
| 9399 | verbose(env, "missing btf func_info\n"); | 9382 | verbose(env, "missing btf func_info\n"); |
| @@ -12563,14 +12546,9 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 3163 unmodified lines | |||
| 12563 | return 0; | 12546 | return 0; |
| 12564 | 12547 | ||
| 12565 | for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) { | 12548 | for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) { |
| 12566 | if (bpf_pseudo_func(insn)) { | 12549 | if (!bpf_pseudo_func(insn) && !bpf_pseudo_call(insn)) |
| 12567 | env->insn_aux_data[i].call_imm = insn->imm; | ||
| 12568 | /* subprog is encoded in insn[1].imm */ | ||
| 12569 | continue; | 12550 | continue; |
| 12570 | } | ||
| 12571 | 12551 | ||
| 12572 | if (!bpf_pseudo_call(insn)) | ||
| 12573 | continue; | ||
| 12574 | /* Upon error here we cannot fall back to interpreter but | 12552 | /* Upon error here we cannot fall back to interpreter but |
| 12575 | * need a hard reject of the program. Thus -EFAULT is | 12553 | * need a hard reject of the program. Thus -EFAULT is |
| 12576 | * propagated in any case. | 12554 | * propagated in any case. |
| @@ -12591,6 +12569,12 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 14 unmodified lines | |||
| 12591 | env->insn_aux_data[i].call_imm = insn->imm; | 12569 | env->insn_aux_data[i].call_imm = insn->imm; |
| 12592 | /* point imm to __bpf_call_base+1 from JITs point of view */ | 12570 | /* point imm to __bpf_call_base+1 from JITs point of view */ |
| 12593 | insn->imm = 1; | 12571 | insn->imm = 1; |
| 12572 | if (bpf_pseudo_func(insn)) | ||
| 12573 | /* jit (e.g. x86_64) may emit fewer instructions | ||
| 12574 | * if it learns a u32 imm is the same as a u64 imm. | ||
| 12575 | * Force a non zero here. | ||
| 12576 | */ | ||
| 12577 | insn[1].imm = 1; | ||
| 12594 | } | 12578 | } |
| 12595 | 12579 | ||
| 12596 | err = bpf_prog_alloc_jited_linfo(prog); | 12580 | err = bpf_prog_alloc_jited_linfo(prog); |
| @@ -12675,7 +12659,7 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 78 unmodified lines | |||
| 12675 | insn = func[i]->insnsi; | 12659 | insn = func[i]->insnsi; |
| 12676 | for (j = 0; j < func[i]->len; j++, insn++) { | 12660 | for (j = 0; j < func[i]->len; j++, insn++) { |
| 12677 | if (bpf_pseudo_func(insn)) { | 12661 | if (bpf_pseudo_func(insn)) { |
| 12678 | subprog = insn[1].imm; | 12662 | subprog = insn->off; |
| 12679 | insn[0].imm = (u32)(long)func[subprog]->bpf_func; | 12663 | insn[0].imm = (u32)(long)func[subprog]->bpf_func; |
| 12680 | insn[1].imm = ((u64)(long)func[subprog]->bpf_func) >> 32; | 12664 | insn[1].imm = ((u64)(long)func[subprog]->bpf_func) >> 32; |
| 12681 | continue; | 12665 | continue; |
| @@ -12726,7 +12710,8 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 44 unmodified lines | |||
| 12726 | for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) { | 12710 | for (i = 0, insn = prog->insnsi; i < prog->len; i++, insn++) { |
| 12727 | if (bpf_pseudo_func(insn)) { | 12711 | if (bpf_pseudo_func(insn)) { |
| 12728 | insn[0].imm = env->insn_aux_data[i].call_imm; | 12712 | insn[0].imm = env->insn_aux_data[i].call_imm; |
| 12729 | insn[1].imm = find_subprog(env, i + insn[0].imm + 1); | 12713 | insn[1].imm = insn->off; |
| 12714 | insn->off = 0; | ||
| 12730 | continue; | 12715 | continue; |
| 12731 | } | 12716 | } |
| 12732 | if (!bpf_pseudo_call(insn)) | 12717 | if (!bpf_pseudo_call(insn)) |
| @@ -2960,28 +2960,6 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry) · 2959 unmodified lines | |||
| 2960 | return shmem_unlink(dir, dentry); | 2960 | return shmem_unlink(dir, dentry); |
| 2961 | } | 2961 | } |
| 2962 | 2962 | ||
| 2963 | static int shmem_exchange(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) | ||
| 2964 | { | ||
| 2965 | bool old_is_dir = d_is_dir(old_dentry); | ||
| 2966 | bool new_is_dir = d_is_dir(new_dentry); | ||
| 2967 | |||
| 2968 | if (old_dir != new_dir && old_is_dir != new_is_dir) { | ||
| 2969 | if (old_is_dir) { | ||
| 2970 | drop_nlink(old_dir); | ||
| 2971 | inc_nlink(new_dir); | ||
| 2972 | } else { | ||
| 2973 | drop_nlink(new_dir); | ||
| 2974 | inc_nlink(old_dir); | ||
| 2975 | } | ||
| 2976 | } | ||
| 2977 | old_dir->i_ctime = old_dir->i_mtime = | ||
| 2978 | new_dir->i_ctime = new_dir->i_mtime = | ||
| 2979 | d_inode(old_dentry)->i_ctime = | ||
| 2980 | d_inode(new_dentry)->i_ctime = current_time(old_dir); | ||
| 2981 | |||
| 2982 | return 0; | ||
| 2983 | } | ||
| 2984 | |||
| 2985 | static int shmem_whiteout(struct user_namespace *mnt_userns, | 2963 | static int shmem_whiteout(struct user_namespace *mnt_userns, |
| 2986 | struct inode *old_dir, struct dentry *old_dentry) | 2964 | struct inode *old_dir, struct dentry *old_dentry) |
| 2987 | { | 2965 | { |
| @@ -3027,7 +3005,7 @@ static int shmem_rename2(struct user_namespace *mnt_userns, · 39 unmodified lines | |||
| 3027 | return -EINVAL; | 3005 | return -EINVAL; |
| 3028 | 3006 | ||
| 3029 | if (flags & RENAME_EXCHANGE) | 3007 | if (flags & RENAME_EXCHANGE) |
| 3030 | return shmem_exchange(old_dir, old_dentry, new_dir, new_dentry); | 3008 | return simple_rename_exchange(old_dir, old_dentry, new_dir, new_dentry); |
| 3031 | 3009 | ||
| 3032 | if (!simple_empty(new_dentry)) | 3010 | if (!simple_empty(new_dentry)) |
| 3033 | return -ENOTEMPTY; | 3011 | return -ENOTEMPTY; |
| @@ -123,9 +123,6 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) · 122 unmodified lines | |||
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | vlan_vid_del(real_dev, vlan->vlan_proto, vlan_id); | 125 | vlan_vid_del(real_dev, vlan->vlan_proto, vlan_id); |
| 126 | |||
| 127 | /* Get rid of the vlan's reference to real_dev */ | ||
| 128 | dev_put(real_dev); | ||
| 129 | } | 126 | } |
| 130 | 127 | ||
| 131 | int vlan_check_real_dev(struct net_device *real_dev, | 128 | int vlan_check_real_dev(struct net_device *real_dev, |
| @@ -843,6 +843,9 @@ static void vlan_dev_free(struct net_device *dev) · 842 unmodified lines | |||
| 843 | 843 | ||
| 844 | free_percpu(vlan->vlan_pcpu_stats); | 844 | free_percpu(vlan->vlan_pcpu_stats); |
| 845 | vlan->vlan_pcpu_stats = NULL; | 845 | vlan->vlan_pcpu_stats = NULL; |
| 846 | |||
| 847 | /* Get rid of the vlan's reference to real_dev */ | ||
| 848 | dev_put(vlan->real_dev); | ||
| 846 | } | 849 | } |
| 847 | 850 | ||
| 848 | void vlan_setup(struct net_device *dev) | 851 | void vlan_setup(struct net_device *dev) |
| @@ -75,6 +75,13 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data) · 74 unmodified lines | |||
| 75 | skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX; | 75 | skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX; |
| 76 | /* set default message type */ | 76 | /* set default message type */ |
| 77 | skcb->addr.type = J1939_TP; | 77 | skcb->addr.type = J1939_TP; |
| 78 | |||
| 79 | if (!j1939_address_is_valid(skcb->addr.sa)) { | ||
| 80 | netdev_err_once(priv->ndev, "%s: sa is broadcast address, ignoring!\n", | ||
| 81 | __func__); | ||
| 82 | goto done; | ||
| 83 | } | ||
| 84 | |||
| 78 | if (j1939_pgn_is_pdu1(skcb->addr.pgn)) { | 85 | if (j1939_pgn_is_pdu1(skcb->addr.pgn)) { |
| 79 | /* Type 1: with destination address */ | 86 | /* Type 1: with destination address */ |
| 80 | skcb->addr.da = skcb->addr.pgn; | 87 | skcb->addr.da = skcb->addr.pgn; |
| @@ -2023,6 +2023,11 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb) · 2022 unmodified lines | |||
| 2023 | extd = J1939_ETP; | 2023 | extd = J1939_ETP; |
| 2024 | fallthrough; | 2024 | fallthrough; |
| 2025 | case J1939_TP_CMD_BAM: | 2025 | case J1939_TP_CMD_BAM: |
| 2026 | if (cmd == J1939_TP_CMD_BAM && !j1939_cb_is_broadcast(skcb)) { | ||
| 2027 | netdev_err_once(priv->ndev, "%s: BAM to unicast (%02x), ignoring!\n", | ||
| 2028 | __func__, skcb->addr.sa); | ||
| 2029 | return; | ||
| 2030 | } | ||
| 2026 | fallthrough; | 2031 | fallthrough; |
| 2027 | case J1939_TP_CMD_RTS: | 2032 | case J1939_TP_CMD_RTS: |
| 2028 | if (skcb->addr.type != extd) | 2033 | if (skcb->addr.type != extd) |
| @@ -2085,6 +2090,12 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb) · 56 unmodified lines | |||
| 2085 | break; | 2090 | break; |
| 2086 | 2091 | ||
| 2087 | case J1939_ETP_CMD_ABORT: /* && J1939_TP_CMD_ABORT */ | 2092 | case J1939_ETP_CMD_ABORT: /* && J1939_TP_CMD_ABORT */ |
| 2093 | if (j1939_cb_is_broadcast(skcb)) { | ||
| 2094 | netdev_err_once(priv->ndev, "%s: abort to broadcast (%02x), ignoring!\n", | ||
| 2095 | __func__, skcb->addr.sa); | ||
| 2096 | return; | ||
| 2097 | } | ||
| 2098 | |||
| 2088 | if (j1939_tp_im_transmitter(skcb)) | 2099 | if (j1939_tp_im_transmitter(skcb)) |
| 2089 | j1939_xtp_rx_abort(priv, skb, true); | 2100 | j1939_xtp_rx_abort(priv, skb, true); |
| 2090 | 2101 | ||
| @@ -646,7 +646,8 @@ int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb, · 645 unmodified lines | |||
| 646 | skb->truesize += truesize; | 646 | skb->truesize += truesize; |
| 647 | if (sk && sk->sk_type == SOCK_STREAM) { | 647 | if (sk && sk->sk_type == SOCK_STREAM) { |
| 648 | sk_wmem_queued_add(sk, truesize); | 648 | sk_wmem_queued_add(sk, truesize); |
| 649 | sk_mem_charge(sk, truesize); | 649 | if (!skb_zcopy_pure(skb)) |
| 650 | sk_mem_charge(sk, truesize); | ||
| 650 | } else { | 651 | } else { |
| 651 | refcount_add(truesize, &skb->sk->sk_wmem_alloc); | 652 | refcount_add(truesize, &skb->sk->sk_wmem_alloc); |
| 652 | } | 653 | } |
| @@ -6928,7 +6928,7 @@ void napi_disable(struct napi_struct *n) · 6927 unmodified lines | |||
| 6928 | might_sleep(); | 6928 | might_sleep(); |
| 6929 | set_bit(NAPI_STATE_DISABLE, &n->state); | 6929 | set_bit(NAPI_STATE_DISABLE, &n->state); |
| 6930 | 6930 | ||
| 6931 | do { | 6931 | for ( ; ; ) { |
| 6932 | val = READ_ONCE(n->state); | 6932 | val = READ_ONCE(n->state); |
| 6933 | if (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) { | 6933 | if (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) { |
| 6934 | usleep_range(20, 200); | 6934 | usleep_range(20, 200); |
| @@ -6937,7 +6937,10 @@ void napi_disable(struct napi_struct *n) · 2 unmodified lines | |||
| 6937 | 6937 | ||
| 6938 | new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC; | 6938 | new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC; |
| 6939 | new &= ~(NAPIF_STATE_THREADED | NAPIF_STATE_PREFER_BUSY_POLL); | 6939 | new &= ~(NAPIF_STATE_THREADED | NAPIF_STATE_PREFER_BUSY_POLL); |
| 6940 | } while (cmpxchg(&n->state, val, new) != val); | 6940 | |
| 6941 | if (cmpxchg(&n->state, val, new) == val) | ||
| 6942 | break; | ||
| 6943 | } | ||
| 6941 | 6944 | ||
| 6942 | hrtimer_cancel(&n->timer); | 6945 | hrtimer_cancel(&n->timer); |
| 6943 | 6946 | ||
| @@ -66,7 +66,7 @@ struct devlink { · 65 unmodified lines | |||
| 66 | u8 reload_failed:1; | 66 | u8 reload_failed:1; |
| 67 | refcount_t refcount; | 67 | refcount_t refcount; |
| 68 | struct completion comp; | 68 | struct completion comp; |
| 69 | char priv[0] __aligned(NETDEV_ALIGN); | 69 | char priv[] __aligned(NETDEV_ALIGN); |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | void *devlink_priv(struct devlink *devlink) | 72 | void *devlink_priv(struct devlink *devlink) |
| @@ -9756,22 +9756,46 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type, · 9755 unmodified lines | |||
| 9756 | static struct bpf_insn *bpf_convert_data_end_access(const struct bpf_insn *si, | 9756 | static struct bpf_insn *bpf_convert_data_end_access(const struct bpf_insn *si, |
| 9757 | struct bpf_insn *insn) | 9757 | struct bpf_insn *insn) |
| 9758 | { | 9758 | { |
| 9759 | /* si->dst_reg = skb->data */ | 9759 | int reg; |
| 9760 | int temp_reg_off = offsetof(struct sk_buff, cb) + | ||
| 9761 | offsetof(struct sk_skb_cb, temp_reg); | ||
| 9762 | |||
| 9763 | if (si->src_reg == si->dst_reg) { | ||
| 9764 | /* We need an extra register, choose and save a register. */ | ||
| 9765 | reg = BPF_REG_9; | ||
| 9766 | if (si->src_reg == reg || si->dst_reg == reg) | ||
| 9767 | reg--; | ||
| 9768 | if (si->src_reg == reg || si->dst_reg == reg) | ||
| 9769 | reg--; | ||
| 9770 | *insn++ = BPF_STX_MEM(BPF_DW, si->src_reg, reg, temp_reg_off); | ||
| 9771 | } else { | ||
| 9772 | reg = si->dst_reg; | ||
| 9773 | } | ||
| 9774 | |||
| 9775 | /* reg = skb->data */ | ||
| 9760 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data), | 9776 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data), |
| 9761 | si->dst_reg, si->src_reg, | 9777 | reg, si->src_reg, |
| 9762 | offsetof(struct sk_buff, data)); | 9778 | offsetof(struct sk_buff, data)); |
| 9763 | /* AX = skb->len */ | 9779 | /* AX = skb->len */ |
| 9764 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, len), | 9780 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, len), |
| 9765 | BPF_REG_AX, si->src_reg, | 9781 | BPF_REG_AX, si->src_reg, |
| 9766 | offsetof(struct sk_buff, len)); | 9782 | offsetof(struct sk_buff, len)); |
| 9767 | /* si->dst_reg = skb->data + skb->len */ | 9783 | /* reg = skb->data + skb->len */ |
| 9768 | *insn++ = BPF_ALU64_REG(BPF_ADD, si->dst_reg, BPF_REG_AX); | 9784 | *insn++ = BPF_ALU64_REG(BPF_ADD, reg, BPF_REG_AX); |
| 9769 | /* AX = skb->data_len */ | 9785 | /* AX = skb->data_len */ |
| 9770 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data_len), | 9786 | *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_buff, data_len), |
| 9771 | BPF_REG_AX, si->src_reg, | 9787 | BPF_REG_AX, si->src_reg, |
| 9772 | offsetof(struct sk_buff, data_len)); | 9788 | offsetof(struct sk_buff, data_len)); |
| 9773 | /* si->dst_reg = skb->data + skb->len - skb->data_len */ | 9789 | |
| 9774 | *insn++ = BPF_ALU64_REG(BPF_SUB, si->dst_reg, BPF_REG_AX); | 9790 | /* reg = skb->data + skb->len - skb->data_len */ |
| 9791 | *insn++ = BPF_ALU64_REG(BPF_SUB, reg, BPF_REG_AX); | ||
| 9792 | |||
| 9793 | if (si->src_reg == si->dst_reg) { | ||
| 9794 | /* Restore the saved register */ | ||
| 9795 | *insn++ = BPF_MOV64_REG(BPF_REG_AX, si->src_reg); | ||
| 9796 | *insn++ = BPF_MOV64_REG(si->dst_reg, reg); | ||
| 9797 | *insn++ = BPF_LDX_MEM(BPF_DW, reg, BPF_REG_AX, temp_reg_off); | ||
| 9798 | } | ||
| 9775 | 9799 | ||
| 9776 | return insn; | 9800 | return insn; |
| 9777 | } | 9801 | } |
| @@ -9782,11 +9806,33 @@ static u32 sk_skb_convert_ctx_access(enum bpf_access_type type, · 4 unmodified lines | |||
| 9782 | struct bpf_prog *prog, u32 *target_size) | 9806 | struct bpf_prog *prog, u32 *target_size) |
| 9783 | { | 9807 | { |
| 9784 | struct bpf_insn *insn = insn_buf; | 9808 | struct bpf_insn *insn = insn_buf; |
| 9809 | int off; | ||
| 9785 | 9810 | ||
| 9786 | switch (si->off) { | 9811 | switch (si->off) { |
| 9787 | case offsetof(struct __sk_buff, data_end): | 9812 | case offsetof(struct __sk_buff, data_end): |
| 9788 | insn = bpf_convert_data_end_access(si, insn); | 9813 | insn = bpf_convert_data_end_access(si, insn); |
| 9789 | break; | 9814 | break; |
| 9815 | case offsetof(struct __sk_buff, cb[0]) ... | ||
| 9816 | offsetofend(struct __sk_buff, cb[4]) - 1: | ||
| 9817 | BUILD_BUG_ON(sizeof_field(struct sk_skb_cb, data) < 20); | ||
| 9818 | BUILD_BUG_ON((offsetof(struct sk_buff, cb) + | ||
| 9819 | offsetof(struct sk_skb_cb, data)) % | ||
| 9820 | sizeof(__u64)); | ||
| 9821 | |||
| 9822 | prog->cb_access = 1; | ||
| 9823 | off = si->off; | ||
| 9824 | off -= offsetof(struct __sk_buff, cb[0]); | ||
| 9825 | off += offsetof(struct sk_buff, cb); | ||
| 9826 | off += offsetof(struct sk_skb_cb, data); | ||
| 9827 | if (type == BPF_WRITE) | ||
| 9828 | *insn++ = BPF_STX_MEM(BPF_SIZE(si->code), si->dst_reg, | ||
| 9829 | si->src_reg, off); | ||
| 9830 | else | ||
| 9831 | *insn++ = BPF_LDX_MEM(BPF_SIZE(si->code), si->dst_reg, | ||
| 9832 | si->src_reg, off); | ||
| 9833 | break; | ||
| 9834 | |||
| 9835 | |||
| 9790 | default: | 9836 | default: |
| 9791 | return bpf_convert_ctx_access(type, si, insn_buf, prog, | 9837 | return bpf_convert_ctx_access(type, si, insn_buf, prog, |
| 9792 | target_size); | 9838 | target_size); |
| @@ -10423,8 +10469,10 @@ BPF_CALL_3(bpf_sk_lookup_assign, struct bpf_sk_lookup_kern *, ctx, · 630 unmodified lines | |||
| 10423 | return -EINVAL; | 10469 | return -EINVAL; |
| 10424 | if (unlikely(sk && sk_is_refcounted(sk))) | 10470 | if (unlikely(sk && sk_is_refcounted(sk))) |
| 10425 | return -ESOCKTNOSUPPORT; /* reject non-RCU freed sockets */ | 10471 | return -ESOCKTNOSUPPORT; /* reject non-RCU freed sockets */ |
| 10426 | if (unlikely(sk && sk->sk_state == TCP_ESTABLISHED)) | 10472 | if (unlikely(sk && sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN)) |
| 10427 | return -ESOCKTNOSUPPORT; /* reject connected sockets */ | 10473 | return -ESOCKTNOSUPPORT; /* only accept TCP socket in LISTEN */ |
| 10474 | if (unlikely(sk && sk_is_udp(sk) && sk->sk_state != TCP_CLOSE)) | ||
| 10475 | return -ESOCKTNOSUPPORT; /* only accept UDP socket in CLOSE */ | ||
| 10428 | 10476 | ||
| 10429 | /* Check if socket is suitable for packet L3/L4 protocol */ | 10477 | /* Check if socket is suitable for packet L3/L4 protocol */ |
| 10430 | if (sk && sk->sk_protocol != ctx->protocol) | 10478 | if (sk && sk->sk_protocol != ctx->protocol) |
| @@ -3433,8 +3433,9 @@ static inline void skb_split_no_header(struct sk_buff *skb, · 3432 unmodified lines | |||
| 3433 | void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len) | 3433 | void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len) |
| 3434 | { | 3434 | { |
| 3435 | int pos = skb_headlen(skb); | 3435 | int pos = skb_headlen(skb); |
| 3436 | const int zc_flags = SKBFL_SHARED_FRAG | SKBFL_PURE_ZEROCOPY; | ||
| 3436 | 3437 | ||
| 3437 | skb_shinfo(skb1)->flags |= skb_shinfo(skb)->flags & SKBFL_SHARED_FRAG; | 3438 | skb_shinfo(skb1)->flags |= skb_shinfo(skb)->flags & zc_flags; |
| 3438 | skb_zerocopy_clone(skb1, skb, 0); | 3439 | skb_zerocopy_clone(skb1, skb, 0); |
| 3439 | if (len < pos) /* Split line is inside header. */ | 3440 | if (len < pos) /* Split line is inside header. */ |
| 3440 | skb_split_inside_header(skb, skb1, len, pos); | 3441 | skb_split_inside_header(skb, skb1, len, pos); |
| @@ -3449,19 +3450,7 @@ EXPORT_SYMBOL(skb_split); · 8 unmodified lines | |||
| 3449 | */ | 3450 | */ |
| 3450 | static int skb_prepare_for_shift(struct sk_buff *skb) | 3451 | static int skb_prepare_for_shift(struct sk_buff *skb) |
| 3451 | { | 3452 | { |
| 3452 | int ret = 0; | 3453 | return skb_unclone_keeptruesize(skb, GFP_ATOMIC); |
| 3453 | |||
| 3454 | if (skb_cloned(skb)) { | ||
| 3455 | /* Save and restore truesize: pskb_expand_head() may reallocate | ||
| 3456 | * memory where ksize(kmalloc(S)) != ksize(kmalloc(S)), but we | ||
| 3457 | * cannot change truesize at this point. | ||
| 3458 | */ | ||
| 3459 | unsigned int save_truesize = skb->truesize; | ||
| 3460 | |||
| 3461 | ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); | ||
| 3462 | skb->truesize = save_truesize; | ||
| 3463 | } | ||
| 3464 | return ret; | ||
| 3465 | } | 3454 | } |
| 3466 | 3455 | ||
| 3467 | /** | 3456 | /** |
| @@ -976,7 +976,7 @@ static int sock_reserve_memory(struct sock *sk, int bytes) · 975 unmodified lines | |||
| 976 | bool charged; | 976 | bool charged; |
| 977 | int pages; | 977 | int pages; |
| 978 | 978 | ||
| 979 | if (!mem_cgroup_sockets_enabled || !sk->sk_memcg) | 979 | if (!mem_cgroup_sockets_enabled || !sk->sk_memcg || !sk_has_account(sk)) |
| 980 | return -EOPNOTSUPP; | 980 | return -EOPNOTSUPP; |
| 981 | 981 | ||
| 982 | if (!bytes) | 982 | if (!bytes) |
| @@ -511,12 +511,6 @@ static bool sock_map_op_okay(const struct bpf_sock_ops_kern *ops) · 510 unmodified lines | |||
| 511 | ops->op == BPF_SOCK_OPS_TCP_LISTEN_CB; | 511 | ops->op == BPF_SOCK_OPS_TCP_LISTEN_CB; |
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | static bool sk_is_tcp(const struct sock *sk) | ||
| 515 | { | ||
| 516 | return sk->sk_type == SOCK_STREAM && | ||
| 517 | sk->sk_protocol == IPPROTO_TCP; | ||
| 518 | } | ||
| 519 | |||
| 520 | static bool sock_map_redirect_allowed(const struct sock *sk) | 514 | static bool sock_map_redirect_allowed(const struct sock *sk) |
| 521 | { | 515 | { |
| 522 | if (sk_is_tcp(sk)) | 516 | if (sk_is_tcp(sk)) |
| @@ -101,6 +101,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, · 100 unmodified lines | |||
| 101 | struct dsa_port *dp; | 101 | struct dsa_port *dp; |
| 102 | u8 *extraction; | 102 | u8 *extraction; |
| 103 | u16 vlan_tpid; | 103 | u16 vlan_tpid; |
| 104 | u64 rew_val; | ||
| 104 | 105 | ||
| 105 | /* Revert skb->data by the amount consumed by the DSA master, | 106 | /* Revert skb->data by the amount consumed by the DSA master, |
| 106 | * so it points to the beginning of the frame. | 107 | * so it points to the beginning of the frame. |
| @@ -130,6 +131,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, · 23 unmodified lines | |||
| 130 | ocelot_xfh_get_qos_class(extraction, &qos_class); | 131 | ocelot_xfh_get_qos_class(extraction, &qos_class); |
| 131 | ocelot_xfh_get_tag_type(extraction, &tag_type); | 132 | ocelot_xfh_get_tag_type(extraction, &tag_type); |
| 132 | ocelot_xfh_get_vlan_tci(extraction, &vlan_tci); | 133 | ocelot_xfh_get_vlan_tci(extraction, &vlan_tci); |
| 134 | ocelot_xfh_get_rew_val(extraction, &rew_val); | ||
| 133 | 135 | ||
| 134 | skb->dev = dsa_master_find_slave(netdev, 0, src_port); | 136 | skb->dev = dsa_master_find_slave(netdev, 0, src_port); |
| 135 | if (!skb->dev) | 137 | if (!skb->dev) |
| @@ -143,6 +145,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, · 7 unmodified lines | |||
| 143 | 145 | ||
| 144 | dsa_default_offload_fwd_mark(skb); | 146 | dsa_default_offload_fwd_mark(skb); |
| 145 | skb->priority = qos_class; | 147 | skb->priority = qos_class; |
| 148 | OCELOT_SKB_CB(skb)->tstamp_lo = rew_val; | ||
| 146 | 149 | ||
| 147 | /* Ocelot switches copy frames unmodified to the CPU. However, it is | 150 | /* Ocelot switches copy frames unmodified to the CPU. However, it is |
| 148 | * possible for the user to request a VLAN modification through | 151 | * possible for the user to request a VLAN modification through |
| @@ -56,8 +56,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base, · 55 unmodified lines | |||
| 56 | 56 | ||
| 57 | if (req_base->flags & ETHTOOL_FLAG_STATS) | 57 | if (req_base->flags & ETHTOOL_FLAG_STATS) |
| 58 | n += nla_total_size(0) + /* _PAUSE_STATS */ | 58 | n += nla_total_size(0) + /* _PAUSE_STATS */ |
| 59 | nla_total_size_64bit(sizeof(u64)) * | 59 | nla_total_size_64bit(sizeof(u64)) * ETHTOOL_PAUSE_STAT_CNT; |
| 60 | (ETHTOOL_A_PAUSE_STAT_MAX - 2); | ||
| 61 | return n; | 60 | return n; |
| 62 | } | 61 | } |
| 63 | 62 | ||
| @@ -862,6 +862,7 @@ struct sk_buff *tcp_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp, · 861 unmodified lines | |||
| 862 | if (likely(skb)) { | 862 | if (likely(skb)) { |
| 863 | bool mem_scheduled; | 863 | bool mem_scheduled; |
| 864 | 864 | ||
| 865 | skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); | ||
| 865 | if (force_schedule) { | 866 | if (force_schedule) { |
| 866 | mem_scheduled = true; | 867 | mem_scheduled = true; |
| 867 | sk_forced_mem_schedule(sk, skb->truesize); | 868 | sk_forced_mem_schedule(sk, skb->truesize); |
| @@ -1318,6 +1319,15 @@ new_segment: · 450 unmodified lines | |||
| 1318 | 1319 | ||
| 1319 | copy = min_t(int, copy, pfrag->size - pfrag->offset); | 1320 | copy = min_t(int, copy, pfrag->size - pfrag->offset); |
| 1320 | 1321 | ||
| 1322 | /* skb changing from pure zc to mixed, must charge zc */ | ||
| 1323 | if (unlikely(skb_zcopy_pure(skb))) { | ||
| 1324 | if (!sk_wmem_schedule(sk, skb->data_len)) | ||
| 1325 | goto wait_for_space; | ||
| 1326 | |||
| 1327 | sk_mem_charge(sk, skb->data_len); | ||
| 1328 | skb_shinfo(skb)->flags &= ~SKBFL_PURE_ZEROCOPY; | ||
| 1329 | } | ||
| 1330 | |||
| 1321 | if (!sk_wmem_schedule(sk, copy)) | 1331 | if (!sk_wmem_schedule(sk, copy)) |
| 1322 | goto wait_for_space; | 1332 | goto wait_for_space; |
| 1323 | 1333 | ||
| @@ -1338,8 +1348,16 @@ new_segment: · 14 unmodified lines | |||
| 1338 | } | 1348 | } |
| 1339 | pfrag->offset += copy; | 1349 | pfrag->offset += copy; |
| 1340 | } else { | 1350 | } else { |
| 1341 | if (!sk_wmem_schedule(sk, copy)) | 1351 | /* First append to a fragless skb builds initial |
| 1342 | goto wait_for_space; | 1352 | * pure zerocopy skb |
| 1353 | */ | ||
| 1354 | if (!skb->len) | ||
| 1355 | skb_shinfo(skb)->flags |= SKBFL_PURE_ZEROCOPY; | ||
| 1356 | |||
| 1357 | if (!skb_zcopy_pure(skb)) { | ||
| 1358 | if (!sk_wmem_schedule(sk, copy)) | ||
| 1359 | goto wait_for_space; | ||
| 1360 | } | ||
| 1343 | 1361 | ||
| 1344 | err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg); | 1362 | err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg); |
| 1345 | if (err == -EMSGSIZE || err == -EEXIST) { | 1363 | if (err == -EMSGSIZE || err == -EEXIST) { |
| @@ -172,6 +172,41 @@ static int tcp_msg_wait_data(struct sock *sk, struct sk_psock *psock, · 171 unmodified lines | |||
| 172 | return ret; | 172 | return ret; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | static int tcp_bpf_recvmsg_parser(struct sock *sk, | ||
| 176 | struct msghdr *msg, | ||
| 177 | size_t len, | ||
| 178 | int nonblock, | ||
| 179 | int flags, | ||
| 180 | int *addr_len) | ||
| 181 | { | ||
| 182 | struct sk_psock *psock; | ||
| 183 | int copied; | ||
| 184 | |||
| 185 | if (unlikely(flags & MSG_ERRQUEUE)) | ||
| 186 | return inet_recv_error(sk, msg, len, addr_len); | ||
| 187 | |||
| 188 | psock = sk_psock_get(sk); | ||
| 189 | if (unlikely(!psock)) | ||
| 190 | return tcp_recvmsg(sk, msg, len, nonblock, flags, addr_len); | ||
| 191 | |||
| 192 | lock_sock(sk); | ||
| 193 | msg_bytes_ready: | ||
| 194 | copied = sk_msg_recvmsg(sk, psock, msg, len, flags); | ||
| 195 | if (!copied) { | ||
| 196 | long timeo; | ||
| 197 | int data; | ||
| 198 | |||
| 199 | timeo = sock_rcvtimeo(sk, nonblock); | ||
| 200 | data = tcp_msg_wait_data(sk, psock, timeo); | ||
| 201 | if (data && !sk_psock_queue_empty(psock)) | ||
| 202 | goto msg_bytes_ready; | ||
| 203 | copied = -EAGAIN; | ||
| 204 | } | ||
| 205 | release_sock(sk); | ||
| 206 | sk_psock_put(sk, psock); | ||
| 207 | return copied; | ||
| 208 | } | ||
| 209 | |||
| 175 | static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, | 210 | static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, |
| 176 | int nonblock, int flags, int *addr_len) | 211 | int nonblock, int flags, int *addr_len) |
| 177 | { | 212 | { |
| @@ -464,6 +499,8 @@ enum { · 286 unmodified lines | |||
| 464 | enum { | 499 | enum { |
| 465 | TCP_BPF_BASE, | 500 | TCP_BPF_BASE, |
| 466 | TCP_BPF_TX, | 501 | TCP_BPF_TX, |
| 502 | TCP_BPF_RX, | ||
| 503 | TCP_BPF_TXRX, | ||
| 467 | TCP_BPF_NUM_CFGS, | 504 | TCP_BPF_NUM_CFGS, |
| 468 | }; | 505 | }; |
| 469 | 506 | ||
| @@ -475,7 +512,6 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], · 5 unmodified lines | |||
| 475 | struct proto *base) | 512 | struct proto *base) |
| 476 | { | 513 | { |
| 477 | prot[TCP_BPF_BASE] = *base; | 514 | prot[TCP_BPF_BASE] = *base; |
| 478 | prot[TCP_BPF_BASE].unhash = sock_map_unhash; | ||
| 479 | prot[TCP_BPF_BASE].close = sock_map_close; | 515 | prot[TCP_BPF_BASE].close = sock_map_close; |
| 480 | prot[TCP_BPF_BASE].recvmsg = tcp_bpf_recvmsg; | 516 | prot[TCP_BPF_BASE].recvmsg = tcp_bpf_recvmsg; |
| 481 | prot[TCP_BPF_BASE].sock_is_readable = sk_msg_is_readable; | 517 | prot[TCP_BPF_BASE].sock_is_readable = sk_msg_is_readable; |
| @@ -483,6 +519,12 @@ static void tcp_bpf_rebuild_protos(struct proto prot[TCP_BPF_NUM_CFGS], · 1 unmodified line | |||
| 483 | prot[TCP_BPF_TX] = prot[TCP_BPF_BASE]; | 519 | prot[TCP_BPF_TX] = prot[TCP_BPF_BASE]; |
| 484 | prot[TCP_BPF_TX].sendmsg = tcp_bpf_sendmsg; | 520 | prot[TCP_BPF_TX].sendmsg = tcp_bpf_sendmsg; |
| 485 | prot[TCP_BPF_TX].sendpage = tcp_bpf_sendpage; | 521 | prot[TCP_BPF_TX].sendpage = tcp_bpf_sendpage; |
| 522 | |||
| 523 | prot[TCP_BPF_RX] = prot[TCP_BPF_BASE]; | ||
| 524 | prot[TCP_BPF_RX].recvmsg = tcp_bpf_recvmsg_parser; | ||
| 525 | |||
| 526 | prot[TCP_BPF_TXRX] = prot[TCP_BPF_TX]; | ||
| 527 | prot[TCP_BPF_TXRX].recvmsg = tcp_bpf_recvmsg_parser; | ||
| 486 | } | 528 | } |
| 487 | 529 | ||
| 488 | static void tcp_bpf_check_v6_needs_rebuild(struct proto *ops) | 530 | static void tcp_bpf_check_v6_needs_rebuild(struct proto *ops) |
| @@ -520,6 +562,10 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) · 31 unmodified lines | |||
| 520 | int family = sk->sk_family == AF_INET6 ? TCP_BPF_IPV6 : TCP_BPF_IPV4; | 562 | int family = sk->sk_family == AF_INET6 ? TCP_BPF_IPV6 : TCP_BPF_IPV4; |
| 521 | int config = psock->progs.msg_parser ? TCP_BPF_TX : TCP_BPF_BASE; | 563 | int config = psock->progs.msg_parser ? TCP_BPF_TX : TCP_BPF_BASE; |
| 522 | 564 | ||
| 565 | if (psock->progs.stream_verdict || psock->progs.skb_verdict) { | ||
| 566 | config = (config == TCP_BPF_TX) ? TCP_BPF_TXRX : TCP_BPF_RX; | ||
| 567 | } | ||
| 568 | |||
| 523 | if (restore) { | 569 | if (restore) { |
| 524 | if (inet_csk_has_ulp(sk)) { | 570 | if (inet_csk_has_ulp(sk)) { |
| 525 | /* TLS does not have an unhash proto in SW cases, | 571 | /* TLS does not have an unhash proto in SW cases, |
| @@ -408,13 +408,13 @@ static inline bool tcp_urg_mode(const struct tcp_sock *tp) · 407 unmodified lines | |||
| 408 | return tp->snd_una != tp->snd_up; | 408 | return tp->snd_una != tp->snd_up; |
| 409 | } | 409 | } |
| 410 | 410 | ||
| 411 | #define OPTION_SACK_ADVERTISE (1 << 0) | 411 | #define OPTION_SACK_ADVERTISE BIT(0) |
| 412 | #define OPTION_TS (1 << 1) | 412 | #define OPTION_TS BIT(1) |
| 413 | #define OPTION_MD5 (1 << 2) | 413 | #define OPTION_MD5 BIT(2) |
| 414 | #define OPTION_WSCALE (1 << 3) | 414 | #define OPTION_WSCALE BIT(3) |
| 415 | #define OPTION_FAST_OPEN_COOKIE (1 << 8) | 415 | #define OPTION_FAST_OPEN_COOKIE BIT(8) |
| 416 | #define OPTION_SMC (1 << 9) | 416 | #define OPTION_SMC BIT(9) |
| 417 | #define OPTION_MPTCP (1 << 10) | 417 | #define OPTION_MPTCP BIT(10) |
| 418 | 418 | ||
| 419 | static void smc_options_write(__be32 *ptr, u16 *options) | 419 | static void smc_options_write(__be32 *ptr, u16 *options) |
| 420 | { | 420 | { |
| @@ -1559,7 +1559,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, · 1138 unmodified lines | |||
| 1559 | return -ENOMEM; | 1559 | return -ENOMEM; |
| 1560 | } | 1560 | } |
| 1561 | 1561 | ||
| 1562 | if (skb_unclone(skb, gfp)) | 1562 | if (skb_unclone_keeptruesize(skb, gfp)) |
| 1563 | return -ENOMEM; | 1563 | return -ENOMEM; |
| 1564 | 1564 | ||
| 1565 | /* Get a new skb... force flag on. */ | 1565 | /* Get a new skb... force flag on. */ |
| @@ -1667,7 +1667,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) · 101 unmodified lines | |||
| 1667 | { | 1667 | { |
| 1668 | u32 delta_truesize; | 1668 | u32 delta_truesize; |
| 1669 | 1669 | ||
| 1670 | if (skb_unclone(skb, GFP_ATOMIC)) | 1670 | if (skb_unclone_keeptruesize(skb, GFP_ATOMIC)) |
| 1671 | return -ENOMEM; | 1671 | return -ENOMEM; |
| 1672 | 1672 | ||
| 1673 | delta_truesize = __pskb_trim_head(skb, len); | 1673 | delta_truesize = __pskb_trim_head(skb, len); |
| @@ -1677,7 +1677,8 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) · 3 unmodified lines | |||
| 1677 | if (delta_truesize) { | 1677 | if (delta_truesize) { |
| 1678 | skb->truesize -= delta_truesize; | 1678 | skb->truesize -= delta_truesize; |
| 1679 | sk_wmem_queued_add(sk, -delta_truesize); | 1679 | sk_wmem_queued_add(sk, -delta_truesize); |
| 1680 | sk_mem_uncharge(sk, delta_truesize); | 1680 | if (!skb_zcopy_pure(skb)) |
| 1681 | sk_mem_uncharge(sk, delta_truesize); | ||
| 1681 | } | 1682 | } |
| 1682 | 1683 | ||
| 1683 | /* Any change of skb->len requires recalculation of tso factor. */ | 1684 | /* Any change of skb->len requires recalculation of tso factor. */ |
| @@ -2295,7 +2296,9 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len) · 611 unmodified lines | |||
| 2295 | if (len <= skb->len) | 2296 | if (len <= skb->len) |
| 2296 | break; | 2297 | break; |
| 2297 | 2298 | ||
| 2298 | if (unlikely(TCP_SKB_CB(skb)->eor) || tcp_has_tx_tstamp(skb)) | 2299 | if (unlikely(TCP_SKB_CB(skb)->eor) || |
| 2300 | tcp_has_tx_tstamp(skb) || | ||
| 2301 | !skb_pure_zcopy_same(skb, next)) | ||
| 2299 | return false; | 2302 | return false; |
| 2300 | 2303 | ||
| 2301 | len -= skb->len; | 2304 | len -= skb->len; |
| @@ -3166,7 +3169,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) · 864 unmodified lines | |||
| 3166 | cur_mss, GFP_ATOMIC)) | 3169 | cur_mss, GFP_ATOMIC)) |
| 3167 | return -ENOMEM; /* We'll try again later. */ | 3170 | return -ENOMEM; /* We'll try again later. */ |
| 3168 | } else { | 3171 | } else { |
| 3169 | if (skb_unclone(skb, GFP_ATOMIC)) | 3172 | if (skb_unclone_keeptruesize(skb, GFP_ATOMIC)) |
| 3170 | return -ENOMEM; | 3173 | return -ENOMEM; |
| 3171 | 3174 | ||
| 3172 | diff = tcp_skb_pcount(skb); | 3175 | diff = tcp_skb_pcount(skb); |
| @@ -378,7 +378,7 @@ static int __net_init seg6_net_init(struct net *net) · 377 unmodified lines | |||
| 378 | kfree(rcu_dereference_raw(sdata->tun_src)); | 378 | kfree(rcu_dereference_raw(sdata->tun_src)); |
| 379 | kfree(sdata); | 379 | kfree(sdata); |
| 380 | return -ENOMEM; | 380 | return -ENOMEM; |
| 381 | }; | 381 | } |
| 382 | #endif | 382 | #endif |
| 383 | 383 | ||
| 384 | return 0; | 384 | return 0; |
| @@ -1263,7 +1263,6 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * · 1262 unmodified lines | |||
| 1263 | 1263 | ||
| 1264 | inet_sk(newsk)->pinet6 = tcp_inet6_sk(newsk); | 1264 | inet_sk(newsk)->pinet6 = tcp_inet6_sk(newsk); |
| 1265 | 1265 | ||
| 1266 | newinet = inet_sk(newsk); | ||
| 1267 | newnp = tcp_inet6_sk(newsk); | 1266 | newnp = tcp_inet6_sk(newsk); |
| 1268 | newtp = tcp_sk(newsk); | 1267 | newtp = tcp_sk(newsk); |
| 1269 | 1268 | ||
| @@ -700,9 +700,9 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb) · 699 unmodified lines | |||
| 700 | 700 | ||
| 701 | ret = encap_rcv(sk, skb); | 701 | ret = encap_rcv(sk, skb); |
| 702 | if (ret <= 0) { | 702 | if (ret <= 0) { |
| 703 | __UDP_INC_STATS(sock_net(sk), | 703 | __UDP6_INC_STATS(sock_net(sk), |
| 704 | UDP_MIB_INDATAGRAMS, | 704 | UDP_MIB_INDATAGRAMS, |
| 705 | is_udplite); | 705 | is_udplite); |
| 706 | return -ret; | 706 | return -ret; |
| 707 | } | 707 | } |
| 708 | } | 708 | } |
| @@ -33,6 +33,19 @@ static int mctp_release(struct socket *sock) · 32 unmodified lines | |||
| 33 | return 0; | 33 | return 0; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /* Generic sockaddr checks, padding checks only so far */ | ||
| 37 | static bool mctp_sockaddr_is_ok(const struct sockaddr_mctp *addr) | ||
| 38 | { | ||
| 39 | return !addr->__smctp_pad0 && !addr->__smctp_pad1; | ||
| 40 | } | ||
| 41 | |||
| 42 | static bool mctp_sockaddr_ext_is_ok(const struct sockaddr_mctp_ext *addr) | ||
| 43 | { | ||
| 44 | return !addr->__smctp_pad0[0] && | ||
| 45 | !addr->__smctp_pad0[1] && | ||
| 46 | !addr->__smctp_pad0[2]; | ||
| 47 | } | ||
| 48 | |||
| 36 | static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen) | 49 | static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen) |
| 37 | { | 50 | { |
| 38 | struct sock *sk = sock->sk; | 51 | struct sock *sk = sock->sk; |
| @@ -52,6 +65,9 @@ static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen) · 13 unmodified lines | |||
| 52 | /* it's a valid sockaddr for MCTP, cast and do protocol checks */ | 65 | /* it's a valid sockaddr for MCTP, cast and do protocol checks */ |
| 53 | smctp = (struct sockaddr_mctp *)addr; | 66 | smctp = (struct sockaddr_mctp *)addr; |
| 54 | 67 | ||
| 68 | if (!mctp_sockaddr_is_ok(smctp)) | ||
| 69 | return -EINVAL; | ||
| 70 | |||
| 55 | lock_sock(sk); | 71 | lock_sock(sk); |
| 56 | 72 | ||
| 57 | /* TODO: allow rebind */ | 73 | /* TODO: allow rebind */ |
| @@ -87,6 +103,8 @@ static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) · 29 unmodified lines | |||
| 87 | return -EINVAL; | 103 | return -EINVAL; |
| 88 | if (addr->smctp_family != AF_MCTP) | 104 | if (addr->smctp_family != AF_MCTP) |
| 89 | return -EINVAL; | 105 | return -EINVAL; |
| 106 | if (!mctp_sockaddr_is_ok(addr)) | ||
| 107 | return -EINVAL; | ||
| 90 | if (addr->smctp_tag & ~(MCTP_TAG_MASK | MCTP_TAG_OWNER)) | 108 | if (addr->smctp_tag & ~(MCTP_TAG_MASK | MCTP_TAG_OWNER)) |
| 91 | return -EINVAL; | 109 | return -EINVAL; |
| 92 | 110 | ||
| @@ -124,7 +142,8 @@ static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) · 31 unmodified lines | |||
| 124 | DECLARE_SOCKADDR(struct sockaddr_mctp_ext *, | 142 | DECLARE_SOCKADDR(struct sockaddr_mctp_ext *, |
| 125 | extaddr, msg->msg_name); | 143 | extaddr, msg->msg_name); |
| 126 | 144 | ||
| 127 | if (extaddr->smctp_halen > sizeof(cb->haddr)) { | 145 | if (!mctp_sockaddr_ext_is_ok(extaddr) || |
| 146 | extaddr->smctp_halen > sizeof(cb->haddr)) { | ||
| 128 | rc = -EINVAL; | 147 | rc = -EINVAL; |
| 129 | goto err_free; | 148 | goto err_free; |
| 130 | } | 149 | } |
| @@ -198,11 +217,13 @@ static int mctp_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, · 67 unmodified lines | |||
| 198 | 217 | ||
| 199 | addr = msg->msg_name; | 218 | addr = msg->msg_name; |
| 200 | addr->smctp_family = AF_MCTP; | 219 | addr->smctp_family = AF_MCTP; |
| 220 | addr->__smctp_pad0 = 0; | ||
| 201 | addr->smctp_network = cb->net; | 221 | addr->smctp_network = cb->net; |
| 202 | addr->smctp_addr.s_addr = hdr->src; | 222 | addr->smctp_addr.s_addr = hdr->src; |
| 203 | addr->smctp_type = type; | 223 | addr->smctp_type = type; |
| 204 | addr->smctp_tag = hdr->flags_seq_tag & | 224 | addr->smctp_tag = hdr->flags_seq_tag & |
| 205 | (MCTP_HDR_TAG_MASK | MCTP_HDR_FLAG_TO); | 225 | (MCTP_HDR_TAG_MASK | MCTP_HDR_FLAG_TO); |
| 226 | addr->__smctp_pad1 = 0; | ||
| 206 | msg->msg_namelen = sizeof(*addr); | 227 | msg->msg_namelen = sizeof(*addr); |
| 207 | 228 | ||
| 208 | if (msk->addr_ext) { | 229 | if (msk->addr_ext) { |
| @@ -211,6 +232,7 @@ static int mctp_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, · 2 unmodified lines | |||
| 211 | msg->msg_namelen = sizeof(*ae); | 232 | msg->msg_namelen = sizeof(*ae); |
| 212 | ae->smctp_ifindex = cb->ifindex; | 233 | ae->smctp_ifindex = cb->ifindex; |
| 213 | ae->smctp_halen = cb->halen; | 234 | ae->smctp_halen = cb->halen; |
| 235 | memset(ae->__smctp_pad0, 0x0, sizeof(ae->__smctp_pad0)); | ||
| 214 | memset(ae->smctp_haddr, 0x0, sizeof(ae->smctp_haddr)); | 236 | memset(ae->smctp_haddr, 0x0, sizeof(ae->smctp_haddr)); |
| 215 | memcpy(ae->smctp_haddr, cb->haddr, cb->halen); | 237 | memcpy(ae->smctp_haddr, cb->haddr, cb->halen); |
| 216 | } | 238 | } |
| @@ -47,6 +47,8 @@ · 46 unmodified lines | |||
| 47 | 47 | ||
| 48 | #include <net/ip_vs.h> | 48 | #include <net/ip_vs.h> |
| 49 | 49 | ||
| 50 | MODULE_ALIAS_GENL_FAMILY(IPVS_GENL_NAME); | ||
| 51 | |||
| 50 | /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */ | 52 | /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */ |
| 51 | static DEFINE_MUTEX(__ip_vs_mutex); | 53 | static DEFINE_MUTEX(__ip_vs_mutex); |
| 52 | 54 | ||
| @@ -560,7 +560,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, · 559 unmodified lines | |||
| 560 | goto nla_put_failure; | 560 | goto nla_put_failure; |
| 561 | 561 | ||
| 562 | if (indev && entskb->dev && | 562 | if (indev && entskb->dev && |
| 563 | entskb->mac_header != entskb->network_header) { | 563 | skb_mac_header_was_set(entskb)) { |
| 564 | struct nfqnl_msg_packet_hw phw; | 564 | struct nfqnl_msg_packet_hw phw; |
| 565 | int len; | 565 | int len; |
| 566 | 566 | ||
| @@ -1664,31 +1664,37 @@ static const struct genl_ops nfc_genl_ops[] = { · 1663 unmodified lines | |||
| 1664 | .cmd = NFC_CMD_DEV_UP, | 1664 | .cmd = NFC_CMD_DEV_UP, |
| 1665 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1665 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1666 | .doit = nfc_genl_dev_up, | 1666 | .doit = nfc_genl_dev_up, |
| 1667 | .flags = GENL_ADMIN_PERM, | ||
| 1667 | }, | 1668 | }, |
| 1668 | { | 1669 | { |
| 1669 | .cmd = NFC_CMD_DEV_DOWN, | 1670 | .cmd = NFC_CMD_DEV_DOWN, |
| 1670 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1671 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1671 | .doit = nfc_genl_dev_down, | 1672 | .doit = nfc_genl_dev_down, |
| 1673 | .flags = GENL_ADMIN_PERM, | ||
| 1672 | }, | 1674 | }, |
| 1673 | { | 1675 | { |
| 1674 | .cmd = NFC_CMD_START_POLL, | 1676 | .cmd = NFC_CMD_START_POLL, |
| 1675 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1677 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1676 | .doit = nfc_genl_start_poll, | 1678 | .doit = nfc_genl_start_poll, |
| 1679 | .flags = GENL_ADMIN_PERM, | ||
| 1677 | }, | 1680 | }, |
| 1678 | { | 1681 | { |
| 1679 | .cmd = NFC_CMD_STOP_POLL, | 1682 | .cmd = NFC_CMD_STOP_POLL, |
| 1680 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1683 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1681 | .doit = nfc_genl_stop_poll, | 1684 | .doit = nfc_genl_stop_poll, |
| 1685 | .flags = GENL_ADMIN_PERM, | ||
| 1682 | }, | 1686 | }, |
| 1683 | { | 1687 | { |
| 1684 | .cmd = NFC_CMD_DEP_LINK_UP, | 1688 | .cmd = NFC_CMD_DEP_LINK_UP, |
| 1685 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1689 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1686 | .doit = nfc_genl_dep_link_up, | 1690 | .doit = nfc_genl_dep_link_up, |
| 1691 | .flags = GENL_ADMIN_PERM, | ||
| 1687 | }, | 1692 | }, |
| 1688 | { | 1693 | { |
| 1689 | .cmd = NFC_CMD_DEP_LINK_DOWN, | 1694 | .cmd = NFC_CMD_DEP_LINK_DOWN, |
| 1690 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1695 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1691 | .doit = nfc_genl_dep_link_down, | 1696 | .doit = nfc_genl_dep_link_down, |
| 1697 | .flags = GENL_ADMIN_PERM, | ||
| 1692 | }, | 1698 | }, |
| 1693 | { | 1699 | { |
| 1694 | .cmd = NFC_CMD_GET_TARGET, | 1700 | .cmd = NFC_CMD_GET_TARGET, |
| @@ -1706,26 +1712,31 @@ static const struct genl_ops nfc_genl_ops[] = { · 11 unmodified lines | |||
| 1706 | .cmd = NFC_CMD_LLC_SET_PARAMS, | 1712 | .cmd = NFC_CMD_LLC_SET_PARAMS, |
| 1707 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1713 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1708 | .doit = nfc_genl_llc_set_params, | 1714 | .doit = nfc_genl_llc_set_params, |
| 1715 | .flags = GENL_ADMIN_PERM, | ||
| 1709 | }, | 1716 | }, |
| 1710 | { | 1717 | { |
| 1711 | .cmd = NFC_CMD_LLC_SDREQ, | 1718 | .cmd = NFC_CMD_LLC_SDREQ, |
| 1712 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1719 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1713 | .doit = nfc_genl_llc_sdreq, | 1720 | .doit = nfc_genl_llc_sdreq, |
| 1721 | .flags = GENL_ADMIN_PERM, | ||
| 1714 | }, | 1722 | }, |
| 1715 | { | 1723 | { |
| 1716 | .cmd = NFC_CMD_FW_DOWNLOAD, | 1724 | .cmd = NFC_CMD_FW_DOWNLOAD, |
| 1717 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1725 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1718 | .doit = nfc_genl_fw_download, | 1726 | .doit = nfc_genl_fw_download, |
| 1727 | .flags = GENL_ADMIN_PERM, | ||
| 1719 | }, | 1728 | }, |
| 1720 | { | 1729 | { |
| 1721 | .cmd = NFC_CMD_ENABLE_SE, | 1730 | .cmd = NFC_CMD_ENABLE_SE, |
| 1722 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1731 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1723 | .doit = nfc_genl_enable_se, | 1732 | .doit = nfc_genl_enable_se, |
| 1733 | .flags = GENL_ADMIN_PERM, | ||
| 1724 | }, | 1734 | }, |
| 1725 | { | 1735 | { |
| 1726 | .cmd = NFC_CMD_DISABLE_SE, | 1736 | .cmd = NFC_CMD_DISABLE_SE, |
| 1727 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1737 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1728 | .doit = nfc_genl_disable_se, | 1738 | .doit = nfc_genl_disable_se, |
| 1739 | .flags = GENL_ADMIN_PERM, | ||
| 1729 | }, | 1740 | }, |
| 1730 | { | 1741 | { |
| 1731 | .cmd = NFC_CMD_GET_SE, | 1742 | .cmd = NFC_CMD_GET_SE, |
| @@ -1737,21 +1748,25 @@ static const struct genl_ops nfc_genl_ops[] = { · 5 unmodified lines | |||
| 1737 | .cmd = NFC_CMD_SE_IO, | 1748 | .cmd = NFC_CMD_SE_IO, |
| 1738 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1749 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1739 | .doit = nfc_genl_se_io, | 1750 | .doit = nfc_genl_se_io, |
| 1751 | .flags = GENL_ADMIN_PERM, | ||
| 1740 | }, | 1752 | }, |
| 1741 | { | 1753 | { |
| 1742 | .cmd = NFC_CMD_ACTIVATE_TARGET, | 1754 | .cmd = NFC_CMD_ACTIVATE_TARGET, |
| 1743 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1755 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1744 | .doit = nfc_genl_activate_target, | 1756 | .doit = nfc_genl_activate_target, |
| 1757 | .flags = GENL_ADMIN_PERM, | ||
| 1745 | }, | 1758 | }, |
| 1746 | { | 1759 | { |
| 1747 | .cmd = NFC_CMD_VENDOR, | 1760 | .cmd = NFC_CMD_VENDOR, |
| 1748 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1761 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1749 | .doit = nfc_genl_vendor_cmd, | 1762 | .doit = nfc_genl_vendor_cmd, |
| 1763 | .flags = GENL_ADMIN_PERM, | ||
| 1750 | }, | 1764 | }, |
| 1751 | { | 1765 | { |
| 1752 | .cmd = NFC_CMD_DEACTIVATE_TARGET, | 1766 | .cmd = NFC_CMD_DEACTIVATE_TARGET, |
| 1753 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, | 1767 | .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
| 1754 | .doit = nfc_genl_deactivate_target, | 1768 | .doit = nfc_genl_deactivate_target, |
| 1769 | .flags = GENL_ADMIN_PERM, | ||
| 1755 | }, | 1770 | }, |
| 1756 | }; | 1771 | }; |
| 1757 | 1772 | ||
| @@ -95,18 +95,22 @@ static ktime_t sched_base_time(const struct sched_gate_list *sched) · 94 unmodified lines | |||
| 95 | return ns_to_ktime(sched->base_time); | 95 | return ns_to_ktime(sched->base_time); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | static ktime_t taprio_get_time(struct taprio_sched *q) | 98 | static ktime_t taprio_mono_to_any(const struct taprio_sched *q, ktime_t mono) |
| 99 | { | 99 | { |
| 100 | ktime_t mono = ktime_get(); | 100 | /* This pairs with WRITE_ONCE() in taprio_parse_clockid() */ |
| 101 | enum tk_offsets tk_offset = READ_ONCE(q->tk_offset); | ||
| 101 | 102 | ||
| 102 | switch (q->tk_offset) { | 103 | switch (tk_offset) { |
| 103 | case TK_OFFS_MAX: | 104 | case TK_OFFS_MAX: |
| 104 | return mono; | 105 | return mono; |
| 105 | default: | 106 | default: |
| 106 | return ktime_mono_to_any(mono, q->tk_offset); | 107 | return ktime_mono_to_any(mono, tk_offset); |
| 107 | } | 108 | } |
| 109 | } | ||
| 108 | 110 | ||
| 109 | return KTIME_MAX; | 111 | static ktime_t taprio_get_time(const struct taprio_sched *q) |
| 112 | { | ||
| 113 | return taprio_mono_to_any(q, ktime_get()); | ||
| 110 | } | 114 | } |
| 111 | 115 | ||
| 112 | static void taprio_free_sched_cb(struct rcu_head *head) | 116 | static void taprio_free_sched_cb(struct rcu_head *head) |
| @@ -319,7 +323,7 @@ static ktime_t get_tcp_tstamp(struct taprio_sched *q, struct sk_buff *skb) · 206 unmodified lines | |||
| 319 | return 0; | 323 | return 0; |
| 320 | } | 324 | } |
| 321 | 325 | ||
| 322 | return ktime_mono_to_any(skb->skb_mstamp_ns, q->tk_offset); | 326 | return taprio_mono_to_any(q, skb->skb_mstamp_ns); |
| 323 | } | 327 | } |
| 324 | 328 | ||
| 325 | /* There are a few scenarios where we will have to modify the txtime from | 329 | /* There are a few scenarios where we will have to modify the txtime from |
| @@ -1352,6 +1356,7 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, · 1026 unmodified lines | |||
| 1352 | } | 1356 | } |
| 1353 | } else if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]) { | 1357 | } else if (tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]) { |
| 1354 | int clockid = nla_get_s32(tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]); | 1358 | int clockid = nla_get_s32(tb[TCA_TAPRIO_ATTR_SCHED_CLOCKID]); |
| 1359 | enum tk_offsets tk_offset; | ||
| 1355 | 1360 | ||
| 1356 | /* We only support static clockids and we don't allow | 1361 | /* We only support static clockids and we don't allow |
| 1357 | * for it to be modified after the first init. | 1362 | * for it to be modified after the first init. |
| @@ -1366,22 +1371,24 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, · 8 unmodified lines | |||
| 1366 | 1371 | ||
| 1367 | switch (clockid) { | 1372 | switch (clockid) { |
| 1368 | case CLOCK_REALTIME: | 1373 | case CLOCK_REALTIME: |
| 1369 | q->tk_offset = TK_OFFS_REAL; | 1374 | tk_offset = TK_OFFS_REAL; |
| 1370 | break; | 1375 | break; |
| 1371 | case CLOCK_MONOTONIC: | 1376 | case CLOCK_MONOTONIC: |
| 1372 | q->tk_offset = TK_OFFS_MAX; | 1377 | tk_offset = TK_OFFS_MAX; |
| 1373 | break; | 1378 | break; |
| 1374 | case CLOCK_BOOTTIME: | 1379 | case CLOCK_BOOTTIME: |
| 1375 | q->tk_offset = TK_OFFS_BOOT; | 1380 | tk_offset = TK_OFFS_BOOT; |
| 1376 | break; | 1381 | break; |
| 1377 | case CLOCK_TAI: | 1382 | case CLOCK_TAI: |
| 1378 | q->tk_offset = TK_OFFS_TAI; | 1383 | tk_offset = TK_OFFS_TAI; |
| 1379 | break; | 1384 | break; |
| 1380 | default: | 1385 | default: |
| 1381 | NL_SET_ERR_MSG(extack, "Invalid 'clockid'"); | 1386 | NL_SET_ERR_MSG(extack, "Invalid 'clockid'"); |
| 1382 | err = -EINVAL; | 1387 | err = -EINVAL; |
| 1383 | goto out; | 1388 | goto out; |
| 1384 | } | 1389 | } |
| 1390 | /* This pairs with READ_ONCE() in taprio_mono_to_any */ | ||
| 1391 | WRITE_ONCE(q->tk_offset, tk_offset); | ||
| 1385 | 1392 | ||
| 1386 | q->clockid = clockid; | 1393 | q->clockid = clockid; |
| 1387 | } else { | 1394 | } else { |
| @@ -326,11 +326,6 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net, · 325 unmodified lines | |||
| 326 | struct sctp_packet *packet; | 326 | struct sctp_packet *packet; |
| 327 | int len; | 327 | int len; |
| 328 | 328 | ||
| 329 | /* Update socket peer label if first association. */ | ||
| 330 | if (security_sctp_assoc_request((struct sctp_endpoint *)ep, | ||
| 331 | chunk->skb)) | ||
| 332 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
| 333 | |||
| 334 | /* 6.10 Bundling | 329 | /* 6.10 Bundling |
| 335 | * An endpoint MUST NOT bundle INIT, INIT ACK or | 330 | * An endpoint MUST NOT bundle INIT, INIT ACK or |
| 336 | * SHUTDOWN COMPLETE with any other chunks. | 331 | * SHUTDOWN COMPLETE with any other chunks. |
| @@ -415,6 +410,12 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net, · 78 unmodified lines | |||
| 415 | if (!new_asoc) | 410 | if (!new_asoc) |
| 416 | goto nomem; | 411 | goto nomem; |
| 417 | 412 | ||
| 413 | /* Update socket peer label if first association. */ | ||
| 414 | if (security_sctp_assoc_request(new_asoc, chunk->skb)) { | ||
| 415 | sctp_association_free(new_asoc); | ||
| 416 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
| 417 | } | ||
| 418 | |||
| 418 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, | 419 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, |
| 419 | sctp_scope(sctp_source(chunk)), | 420 | sctp_scope(sctp_source(chunk)), |
| 420 | GFP_ATOMIC) < 0) | 421 | GFP_ATOMIC) < 0) |
| @@ -780,6 +781,10 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, · 359 unmodified lines | |||
| 780 | } | 781 | } |
| 781 | } | 782 | } |
| 782 | 783 | ||
| 784 | if (security_sctp_assoc_request(new_asoc, chunk->skb)) { | ||
| 785 | sctp_association_free(new_asoc); | ||
| 786 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
| 787 | } | ||
| 783 | 788 | ||
| 784 | /* Delay state machine commands until later. | 789 | /* Delay state machine commands until later. |
| 785 | * | 790 | * |
| @@ -941,7 +946,7 @@ enum sctp_disposition sctp_sf_do_5_1E_ca(struct net *net, · 155 unmodified lines | |||
| 941 | sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL()); | 946 | sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL()); |
| 942 | 947 | ||
| 943 | /* Set peer label for connection. */ | 948 | /* Set peer label for connection. */ |
| 944 | security_inet_conn_established(ep->base.sk, chunk->skb); | 949 | security_sctp_assoc_established((struct sctp_association *)asoc, chunk->skb); |
| 945 | 950 | ||
| 946 | /* RFC 2960 5.1 Normal Establishment of an Association | 951 | /* RFC 2960 5.1 Normal Establishment of an Association |
| 947 | * | 952 | * |
| @@ -1517,11 +1522,6 @@ static enum sctp_disposition sctp_sf_do_unexpected_init( · 569 unmodified lines | |||
| 1517 | struct sctp_packet *packet; | 1522 | struct sctp_packet *packet; |
| 1518 | int len; | 1523 | int len; |
| 1519 | 1524 | ||
| 1520 | /* Update socket peer label if first association. */ | ||
| 1521 | if (security_sctp_assoc_request((struct sctp_endpoint *)ep, | ||
| 1522 | chunk->skb)) | ||
| 1523 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
| 1524 | |||
| 1525 | /* 6.10 Bundling | 1525 | /* 6.10 Bundling |
| 1526 | * An endpoint MUST NOT bundle INIT, INIT ACK or | 1526 | * An endpoint MUST NOT bundle INIT, INIT ACK or |
| 1527 | * SHUTDOWN COMPLETE with any other chunks. | 1527 | * SHUTDOWN COMPLETE with any other chunks. |
| @@ -1594,6 +1594,12 @@ static enum sctp_disposition sctp_sf_do_unexpected_init( · 66 unmodified lines | |||
| 1594 | if (!new_asoc) | 1594 | if (!new_asoc) |
| 1595 | goto nomem; | 1595 | goto nomem; |
| 1596 | 1596 | ||
| 1597 | /* Update socket peer label if first association. */ | ||
| 1598 | if (security_sctp_assoc_request(new_asoc, chunk->skb)) { | ||
| 1599 | sctp_association_free(new_asoc); | ||
| 1600 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | ||
| 1601 | } | ||
| 1602 | |||
| 1597 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, | 1603 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, |
| 1598 | sctp_scope(sctp_source(chunk)), GFP_ATOMIC) < 0) | 1604 | sctp_scope(sctp_source(chunk)), GFP_ATOMIC) < 0) |
| 1599 | goto nomem; | 1605 | goto nomem; |
| @@ -2255,8 +2261,7 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook( · 655 unmodified lines | |||
| 2255 | } | 2261 | } |
| 2256 | 2262 | ||
| 2257 | /* Update socket peer label if first association. */ | 2263 | /* Update socket peer label if first association. */ |
| 2258 | if (security_sctp_assoc_request((struct sctp_endpoint *)ep, | 2264 | if (security_sctp_assoc_request(new_asoc, chunk->skb)) { |
| 2259 | chunk->skb)) { | ||
| 2260 | sctp_association_free(new_asoc); | 2265 | sctp_association_free(new_asoc); |
| 2261 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); | 2266 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
| 2262 | } | 2267 | } |
| @@ -4893,9 +4898,6 @@ static enum sctp_disposition sctp_sf_violation_chunk( · 2630 unmodified lines | |||
| 4893 | { | 4898 | { |
| 4894 | static const char err_str[] = "The following chunk violates protocol:"; | 4899 | static const char err_str[] = "The following chunk violates protocol:"; |
| 4895 | 4900 | ||
| 4896 | if (!asoc) | ||
| 4897 | return sctp_sf_violation(net, ep, asoc, type, arg, commands); | ||
| 4898 | |||
| 4899 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, | 4901 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
| 4900 | sizeof(err_str)); | 4902 | sizeof(err_str)); |
| 4901 | } | 4903 | } |
| @@ -9412,7 +9412,6 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, · 9411 unmodified lines | |||
| 9412 | struct inet_sock *inet = inet_sk(sk); | 9412 | struct inet_sock *inet = inet_sk(sk); |
| 9413 | struct inet_sock *newinet; | 9413 | struct inet_sock *newinet; |
| 9414 | struct sctp_sock *sp = sctp_sk(sk); | 9414 | struct sctp_sock *sp = sctp_sk(sk); |
| 9415 | struct sctp_endpoint *ep = sp->ep; | ||
| 9416 | 9415 | ||
| 9417 | newsk->sk_type = sk->sk_type; | 9416 | newsk->sk_type = sk->sk_type; |
| 9418 | newsk->sk_bound_dev_if = sk->sk_bound_dev_if; | 9417 | newsk->sk_bound_dev_if = sk->sk_bound_dev_if; |
| @@ -9457,9 +9456,9 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, · 38 unmodified lines | |||
| 9457 | net_enable_timestamp(); | 9456 | net_enable_timestamp(); |
| 9458 | 9457 | ||
| 9459 | /* Set newsk security attributes from original sk and connection | 9458 | /* Set newsk security attributes from original sk and connection |
| 9460 | * security attribute from ep. | 9459 | * security attribute from asoc. |
| 9461 | */ | 9460 | */ |
| 9462 | security_sctp_sk_clone(ep, sk, newsk); | 9461 | security_sctp_sk_clone(asoc, sk, newsk); |
| 9463 | } | 9462 | } |
| 9464 | 9463 | ||
| 9465 | static inline void sctp_copy_descendant(struct sock *sk_to, | 9464 | static inline void sctp_copy_descendant(struct sock *sk_to, |
| @@ -149,14 +149,18 @@ static int __smc_release(struct smc_sock *smc) · 148 unmodified lines | |||
| 149 | sock_set_flag(sk, SOCK_DEAD); | 149 | sock_set_flag(sk, SOCK_DEAD); |
| 150 | sk->sk_shutdown |= SHUTDOWN_MASK; | 150 | sk->sk_shutdown |= SHUTDOWN_MASK; |
| 151 | } else { | 151 | } else { |
| 152 | if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT) | 152 | if (sk->sk_state != SMC_CLOSED) { |
| 153 | sock_put(sk); /* passive closing */ | 153 | if (sk->sk_state != SMC_LISTEN && |
| 154 | if (sk->sk_state == SMC_LISTEN) { | 154 | sk->sk_state != SMC_INIT) |
| 155 | /* wake up clcsock accept */ | 155 | sock_put(sk); /* passive closing */ |
| 156 | rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR); | 156 | if (sk->sk_state == SMC_LISTEN) { |
| 157 | /* wake up clcsock accept */ | ||
| 158 | rc = kernel_sock_shutdown(smc->clcsock, | ||
| 159 | SHUT_RDWR); | ||
| 160 | } | ||
| 161 | sk->sk_state = SMC_CLOSED; | ||
| 162 | sk->sk_state_change(sk); | ||
| 157 | } | 163 | } |
| 158 | sk->sk_state = SMC_CLOSED; | ||
| 159 | sk->sk_state_change(sk); | ||
| 160 | smc_restore_fallback_changes(smc); | 164 | smc_restore_fallback_changes(smc); |
| 161 | } | 165 | } |
| 162 | 166 | ||
| @@ -99,7 +99,7 @@ TRACE_EVENT(smcr_link_down, · 98 unmodified lines | |||
| 99 | __entry->location = location; | 99 | __entry->location = location; |
| 100 | ), | 100 | ), |
| 101 | 101 | ||
| 102 | TP_printk("lnk=%p lgr=%p state=%d dev=%s location=%p", | 102 | TP_printk("lnk=%p lgr=%p state=%d dev=%s location=%pS", |
| 103 | __entry->lnk, __entry->lgr, | 103 | __entry->lnk, __entry->lgr, |
| 104 | __entry->state, __get_str(name), | 104 | __entry->state, __get_str(name), |
| 105 | __entry->location) | 105 | __entry->location) |
| @@ -27,18 +27,10 @@ · 26 unmodified lines | |||
| 27 | 27 | ||
| 28 | static struct workqueue_struct *strp_wq; | 28 | static struct workqueue_struct *strp_wq; |
| 29 | 29 | ||
| 30 | struct _strp_msg { | ||
| 31 | /* Internal cb structure. struct strp_msg must be first for passing | ||
| 32 | * to upper layer. | ||
| 33 | */ | ||
| 34 | struct strp_msg strp; | ||
| 35 | int accum_len; | ||
| 36 | }; | ||
| 37 | |||
| 38 | static inline struct _strp_msg *_strp_msg(struct sk_buff *skb) | 30 | static inline struct _strp_msg *_strp_msg(struct sk_buff *skb) |
| 39 | { | 31 | { |
| 40 | return (struct _strp_msg *)((void *)skb->cb + | 32 | return (struct _strp_msg *)((void *)skb->cb + |
| 41 | offsetof(struct qdisc_skb_cb, data)); | 33 | offsetof(struct sk_skb_cb, strp)); |
| 42 | } | 34 | } |
| 43 | 35 | ||
| 44 | /* Lower lock held */ | 36 | /* Lower lock held */ |
| @@ -1322,6 +1322,8 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr, · 1321 unmodified lines | |||
| 1322 | * non-blocking call. | 1322 | * non-blocking call. |
| 1323 | */ | 1323 | */ |
| 1324 | err = -EALREADY; | 1324 | err = -EALREADY; |
| 1325 | if (flags & O_NONBLOCK) | ||
| 1326 | goto out; | ||
| 1325 | break; | 1327 | break; |
| 1326 | default: | 1328 | default: |
| 1327 | if ((sk->sk_state == TCP_LISTEN) || | 1329 | if ((sk->sk_state == TCP_LISTEN) || |
| @@ -2367,9 +2367,9 @@ int security_tun_dev_open(void *security) · 2366 unmodified lines | |||
| 2367 | } | 2367 | } |
| 2368 | EXPORT_SYMBOL(security_tun_dev_open); | 2368 | EXPORT_SYMBOL(security_tun_dev_open); |
| 2369 | 2369 | ||
| 2370 | int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb) | 2370 | int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb) |
| 2371 | { | 2371 | { |
| 2372 | return call_int_hook(sctp_assoc_request, 0, ep, skb); | 2372 | return call_int_hook(sctp_assoc_request, 0, asoc, skb); |
| 2373 | } | 2373 | } |
| 2374 | EXPORT_SYMBOL(security_sctp_assoc_request); | 2374 | EXPORT_SYMBOL(security_sctp_assoc_request); |
| 2375 | 2375 | ||
| @@ -2381,13 +2381,20 @@ int security_sctp_bind_connect(struct sock *sk, int optname, · 5 unmodified lines | |||
| 2381 | } | 2381 | } |
| 2382 | EXPORT_SYMBOL(security_sctp_bind_connect); | 2382 | EXPORT_SYMBOL(security_sctp_bind_connect); |
| 2383 | 2383 | ||
| 2384 | void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk, | 2384 | void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, |
| 2385 | struct sock *newsk) | 2385 | struct sock *newsk) |
| 2386 | { | 2386 | { |
| 2387 | call_void_hook(sctp_sk_clone, ep, sk, newsk); | 2387 | call_void_hook(sctp_sk_clone, asoc, sk, newsk); |
| 2388 | } | 2388 | } |
| 2389 | EXPORT_SYMBOL(security_sctp_sk_clone); | 2389 | EXPORT_SYMBOL(security_sctp_sk_clone); |
| 2390 | 2390 | ||
| 2391 | void security_sctp_assoc_established(struct sctp_association *asoc, | ||
| 2392 | struct sk_buff *skb) | ||
| 2393 | { | ||
| 2394 | call_void_hook(sctp_assoc_established, asoc, skb); | ||
| 2395 | } | ||
| 2396 | EXPORT_SYMBOL(security_sctp_assoc_established); | ||
| 2397 | |||
| 2391 | #endif /* CONFIG_SECURITY_NETWORK */ | 2398 | #endif /* CONFIG_SECURITY_NETWORK */ |
| 2392 | 2399 | ||
| 2393 | #ifdef CONFIG_SECURITY_INFINIBAND | 2400 | #ifdef CONFIG_SECURITY_INFINIBAND |
| @@ -5339,10 +5339,10 @@ static void selinux_sock_graft(struct sock *sk, struct socket *parent) · 5338 unmodified lines | |||
| 5339 | * connect(2), sctp_connectx(3) or sctp_sendmsg(3) (with no association | 5339 | * connect(2), sctp_connectx(3) or sctp_sendmsg(3) (with no association |
| 5340 | * already present). | 5340 | * already present). |
| 5341 | */ | 5341 | */ |
| 5342 | static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, | 5342 | static int selinux_sctp_assoc_request(struct sctp_association *asoc, |
| 5343 | struct sk_buff *skb) | 5343 | struct sk_buff *skb) |
| 5344 | { | 5344 | { |
| 5345 | struct sk_security_struct *sksec = ep->base.sk->sk_security; | 5345 | struct sk_security_struct *sksec = asoc->base.sk->sk_security; |
| 5346 | struct common_audit_data ad; | 5346 | struct common_audit_data ad; |
| 5347 | struct lsm_network_audit net = {0,}; | 5347 | struct lsm_network_audit net = {0,}; |
| 5348 | u8 peerlbl_active; | 5348 | u8 peerlbl_active; |
| @@ -5359,7 +5359,7 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 10 unmodified lines | |||
| 5359 | /* This will return peer_sid = SECSID_NULL if there are | 5359 | /* This will return peer_sid = SECSID_NULL if there are |
| 5360 | * no peer labels, see security_net_peersid_resolve(). | 5360 | * no peer labels, see security_net_peersid_resolve(). |
| 5361 | */ | 5361 | */ |
| 5362 | err = selinux_skb_peerlbl_sid(skb, ep->base.sk->sk_family, | 5362 | err = selinux_skb_peerlbl_sid(skb, asoc->base.sk->sk_family, |
| 5363 | &peer_sid); | 5363 | &peer_sid); |
| 5364 | if (err) | 5364 | if (err) |
| 5365 | return err; | 5365 | return err; |
| @@ -5383,7 +5383,7 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 17 unmodified lines | |||
| 5383 | */ | 5383 | */ |
| 5384 | ad.type = LSM_AUDIT_DATA_NET; | 5384 | ad.type = LSM_AUDIT_DATA_NET; |
| 5385 | ad.u.net = &net; | 5385 | ad.u.net = &net; |
| 5386 | ad.u.net->sk = ep->base.sk; | 5386 | ad.u.net->sk = asoc->base.sk; |
| 5387 | err = avc_has_perm(&selinux_state, | 5387 | err = avc_has_perm(&selinux_state, |
| 5388 | sksec->peer_sid, peer_sid, sksec->sclass, | 5388 | sksec->peer_sid, peer_sid, sksec->sclass, |
| 5389 | SCTP_SOCKET__ASSOCIATION, &ad); | 5389 | SCTP_SOCKET__ASSOCIATION, &ad); |
| @@ -5392,7 +5392,7 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 2 unmodified lines | |||
| 5392 | } | 5392 | } |
| 5393 | 5393 | ||
| 5394 | /* Compute the MLS component for the connection and store | 5394 | /* Compute the MLS component for the connection and store |
| 5395 | * the information in ep. This will be used by SCTP TCP type | 5395 | * the information in asoc. This will be used by SCTP TCP type |
| 5396 | * sockets and peeled off connections as they cause a new | 5396 | * sockets and peeled off connections as they cause a new |
| 5397 | * socket to be generated. selinux_sctp_sk_clone() will then | 5397 | * socket to be generated. selinux_sctp_sk_clone() will then |
| 5398 | * plug this into the new socket. | 5398 | * plug this into the new socket. |
| @@ -5401,11 +5401,11 @@ static int selinux_sctp_assoc_request(struct sctp_endpoint *ep, · 2 unmodified lines | |||
| 5401 | if (err) | 5401 | if (err) |
| 5402 | return err; | 5402 | return err; |
| 5403 | 5403 | ||
| 5404 | ep->secid = conn_sid; | 5404 | asoc->secid = conn_sid; |
| 5405 | ep->peer_secid = peer_sid; | 5405 | asoc->peer_secid = peer_sid; |
| 5406 | 5406 | ||
| 5407 | /* Set any NetLabel labels including CIPSO/CALIPSO options. */ | 5407 | /* Set any NetLabel labels including CIPSO/CALIPSO options. */ |
| 5408 | return selinux_netlbl_sctp_assoc_request(ep, skb); | 5408 | return selinux_netlbl_sctp_assoc_request(asoc, skb); |
| 5409 | } | 5409 | } |
| 5410 | 5410 | ||
| 5411 | /* Check if sctp IPv4/IPv6 addresses are valid for binding or connecting | 5411 | /* Check if sctp IPv4/IPv6 addresses are valid for binding or connecting |
| @@ -5490,7 +5490,7 @@ static int selinux_sctp_bind_connect(struct sock *sk, int optname, · 78 unmodified lines | |||
| 5490 | } | 5490 | } |
| 5491 | 5491 | ||
| 5492 | /* Called whenever a new socket is created by accept(2) or sctp_peeloff(3). */ | 5492 | /* Called whenever a new socket is created by accept(2) or sctp_peeloff(3). */ |
| 5493 | static void selinux_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk, | 5493 | static void selinux_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, |
| 5494 | struct sock *newsk) | 5494 | struct sock *newsk) |
| 5495 | { | 5495 | { |
| 5496 | struct sk_security_struct *sksec = sk->sk_security; | 5496 | struct sk_security_struct *sksec = sk->sk_security; |
| @@ -5502,8 +5502,9 @@ static void selinux_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk, · 5 unmodified lines | |||
| 5502 | if (!selinux_policycap_extsockclass()) | 5502 | if (!selinux_policycap_extsockclass()) |
| 5503 | return selinux_sk_clone_security(sk, newsk); | 5503 | return selinux_sk_clone_security(sk, newsk); |
| 5504 | 5504 | ||
| 5505 | newsksec->sid = ep->secid; | 5505 | if (asoc->secid != SECSID_WILD) |
| 5506 | newsksec->peer_sid = ep->peer_secid; | 5506 | newsksec->sid = asoc->secid; |
| 5507 | newsksec->peer_sid = asoc->peer_secid; | ||
| 5507 | newsksec->sclass = sksec->sclass; | 5508 | newsksec->sclass = sksec->sclass; |
| 5508 | selinux_netlbl_sctp_sk_clone(sk, newsk); | 5509 | selinux_netlbl_sctp_sk_clone(sk, newsk); |
| 5509 | } | 5510 | } |
| @@ -5558,6 +5559,16 @@ static void selinux_inet_conn_established(struct sock *sk, struct sk_buff *skb) · 48 unmodified lines | |||
| 5558 | selinux_skb_peerlbl_sid(skb, family, &sksec->peer_sid); | 5559 | selinux_skb_peerlbl_sid(skb, family, &sksec->peer_sid); |
| 5559 | } | 5560 | } |
| 5560 | 5561 | ||
| 5562 | static void selinux_sctp_assoc_established(struct sctp_association *asoc, | ||
| 5563 | struct sk_buff *skb) | ||
| 5564 | { | ||
| 5565 | struct sk_security_struct *sksec = asoc->base.sk->sk_security; | ||
| 5566 | |||
| 5567 | selinux_inet_conn_established(asoc->base.sk, skb); | ||
| 5568 | asoc->peer_secid = sksec->peer_sid; | ||
| 5569 | asoc->secid = SECSID_WILD; | ||
| 5570 | } | ||
| 5571 | |||
| 5561 | static int selinux_secmark_relabel_packet(u32 sid) | 5572 | static int selinux_secmark_relabel_packet(u32 sid) |
| 5562 | { | 5573 | { |
| 5563 | const struct task_security_struct *__tsec; | 5574 | const struct task_security_struct *__tsec; |
| @@ -7228,6 +7239,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = { · 1664 unmodified lines | |||
| 7228 | LSM_HOOK_INIT(sctp_assoc_request, selinux_sctp_assoc_request), | 7239 | LSM_HOOK_INIT(sctp_assoc_request, selinux_sctp_assoc_request), |
| 7229 | LSM_HOOK_INIT(sctp_sk_clone, selinux_sctp_sk_clone), | 7240 | LSM_HOOK_INIT(sctp_sk_clone, selinux_sctp_sk_clone), |
| 7230 | LSM_HOOK_INIT(sctp_bind_connect, selinux_sctp_bind_connect), | 7241 | LSM_HOOK_INIT(sctp_bind_connect, selinux_sctp_bind_connect), |
| 7242 | LSM_HOOK_INIT(sctp_assoc_established, selinux_sctp_assoc_established), | ||
| 7231 | LSM_HOOK_INIT(inet_conn_request, selinux_inet_conn_request), | 7243 | LSM_HOOK_INIT(inet_conn_request, selinux_inet_conn_request), |
| 7232 | LSM_HOOK_INIT(inet_csk_clone, selinux_inet_csk_clone), | 7244 | LSM_HOOK_INIT(inet_csk_clone, selinux_inet_csk_clone), |
| 7233 | LSM_HOOK_INIT(inet_conn_established, selinux_inet_conn_established), | 7245 | LSM_HOOK_INIT(inet_conn_established, selinux_inet_conn_established), |
| @@ -39,7 +39,7 @@ int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, · 38 unmodified lines | |||
| 39 | int selinux_netlbl_skbuff_setsid(struct sk_buff *skb, | 39 | int selinux_netlbl_skbuff_setsid(struct sk_buff *skb, |
| 40 | u16 family, | 40 | u16 family, |
| 41 | u32 sid); | 41 | u32 sid); |
| 42 | int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep, | 42 | int selinux_netlbl_sctp_assoc_request(struct sctp_association *asoc, |
| 43 | struct sk_buff *skb); | 43 | struct sk_buff *skb); |
| 44 | int selinux_netlbl_inet_conn_request(struct request_sock *req, u16 family); | 44 | int selinux_netlbl_inet_conn_request(struct request_sock *req, u16 family); |
| 45 | void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family); | 45 | void selinux_netlbl_inet_csk_clone(struct sock *sk, u16 family); |
| @@ -98,7 +98,7 @@ static inline int selinux_netlbl_skbuff_setsid(struct sk_buff *skb, · 52 unmodified lines | |||
| 98 | return 0; | 98 | return 0; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | static inline int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep, | 101 | static inline int selinux_netlbl_sctp_assoc_request(struct sctp_association *asoc, |
| 102 | struct sk_buff *skb) | 102 | struct sk_buff *skb) |
| 103 | { | 103 | { |
| 104 | return 0; | 104 | return 0; |
| @@ -261,30 +261,30 @@ skbuff_setsid_return: · 260 unmodified lines | |||
| 261 | 261 | ||
| 262 | /** | 262 | /** |
| 263 | * selinux_netlbl_sctp_assoc_request - Label an incoming sctp association. | 263 | * selinux_netlbl_sctp_assoc_request - Label an incoming sctp association. |
| 264 | * @ep: incoming association endpoint. | 264 | * @asoc: incoming association. |
| 265 | * @skb: the packet. | 265 | * @skb: the packet. |
| 266 | * | 266 | * |
| 267 | * Description: | 267 | * Description: |
| 268 | * A new incoming connection is represented by @ep, ...... | 268 | * A new incoming connection is represented by @asoc, ...... |
| 269 | * Returns zero on success, negative values on failure. | 269 | * Returns zero on success, negative values on failure. |
| 270 | * | 270 | * |
| 271 | */ | 271 | */ |
| 272 | int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep, | 272 | int selinux_netlbl_sctp_assoc_request(struct sctp_association *asoc, |
| 273 | struct sk_buff *skb) | 273 | struct sk_buff *skb) |
| 274 | { | 274 | { |
| 275 | int rc; | 275 | int rc; |
| 276 | struct netlbl_lsm_secattr secattr; | 276 | struct netlbl_lsm_secattr secattr; |
| 277 | struct sk_security_struct *sksec = ep->base.sk->sk_security; | 277 | struct sk_security_struct *sksec = asoc->base.sk->sk_security; |
| 278 | struct sockaddr_in addr4; | 278 | struct sockaddr_in addr4; |
| 279 | struct sockaddr_in6 addr6; | 279 | struct sockaddr_in6 addr6; |
| 280 | 280 | ||
| 281 | if (ep->base.sk->sk_family != PF_INET && | 281 | if (asoc->base.sk->sk_family != PF_INET && |
| 282 | ep->base.sk->sk_family != PF_INET6) | 282 | asoc->base.sk->sk_family != PF_INET6) |
| 283 | return 0; | 283 | return 0; |
| 284 | 284 | ||
| 285 | netlbl_secattr_init(&secattr); | 285 | netlbl_secattr_init(&secattr); |
| 286 | rc = security_netlbl_sid_to_secattr(&selinux_state, | 286 | rc = security_netlbl_sid_to_secattr(&selinux_state, |
| 287 | ep->secid, &secattr); | 287 | asoc->secid, &secattr); |
| 288 | if (rc != 0) | 288 | if (rc != 0) |
| 289 | goto assoc_request_return; | 289 | goto assoc_request_return; |
| 290 | 290 | ||
| @@ -294,11 +294,11 @@ int selinux_netlbl_sctp_assoc_request(struct sctp_endpoint *ep, · 3 unmodified lines | |||
| 294 | if (ip_hdr(skb)->version == 4) { | 294 | if (ip_hdr(skb)->version == 4) { |
| 295 | addr4.sin_family = AF_INET; | 295 | addr4.sin_family = AF_INET; |
| 296 | addr4.sin_addr.s_addr = ip_hdr(skb)->saddr; | 296 | addr4.sin_addr.s_addr = ip_hdr(skb)->saddr; |
| 297 | rc = netlbl_conn_setattr(ep->base.sk, (void *)&addr4, &secattr); | 297 | rc = netlbl_conn_setattr(asoc->base.sk, (void *)&addr4, &secattr); |
| 298 | } else if (IS_ENABLED(CONFIG_IPV6) && ip_hdr(skb)->version == 6) { | 298 | } else if (IS_ENABLED(CONFIG_IPV6) && ip_hdr(skb)->version == 6) { |
| 299 | addr6.sin6_family = AF_INET6; | 299 | addr6.sin6_family = AF_INET6; |
| 300 | addr6.sin6_addr = ipv6_hdr(skb)->saddr; | 300 | addr6.sin6_addr = ipv6_hdr(skb)->saddr; |
| 301 | rc = netlbl_conn_setattr(ep->base.sk, (void *)&addr6, &secattr); | 301 | rc = netlbl_conn_setattr(asoc->base.sk, (void *)&addr6, &secattr); |
| 302 | } else { | 302 | } else { |
| 303 | rc = -EAFNOSUPPORT; | 303 | rc = -EAFNOSUPPORT; |
| 304 | } | 304 | } |
| @@ -22,24 +22,29 @@ else · 21 unmodified lines | |||
| 22 | _OUTPUT := $(CURDIR) | 22 | _OUTPUT := $(CURDIR) |
| 23 | endif | 23 | endif |
| 24 | BOOTSTRAP_OUTPUT := $(_OUTPUT)/bootstrap/ | 24 | BOOTSTRAP_OUTPUT := $(_OUTPUT)/bootstrap/ |
| 25 | |||
| 25 | LIBBPF_OUTPUT := $(_OUTPUT)/libbpf/ | 26 | LIBBPF_OUTPUT := $(_OUTPUT)/libbpf/ |
| 26 | LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) | 27 | LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) |
| 27 | LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include | 28 | LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include |
| 28 | LIBBPF_HDRS_DIR := $(LIBBPF_INCLUDE)/bpf | 29 | LIBBPF_HDRS_DIR := $(LIBBPF_INCLUDE)/bpf |
| 30 | LIBBPF := $(LIBBPF_OUTPUT)libbpf.a | ||
| 29 | 31 | ||
| 30 | LIBBPF = $(LIBBPF_OUTPUT)libbpf.a | 32 | LIBBPF_BOOTSTRAP_OUTPUT := $(BOOTSTRAP_OUTPUT)libbpf/ |
| 31 | LIBBPF_BOOTSTRAP_OUTPUT = $(BOOTSTRAP_OUTPUT)libbpf/ | 33 | LIBBPF_BOOTSTRAP_DESTDIR := $(LIBBPF_BOOTSTRAP_OUTPUT) |
| 32 | LIBBPF_BOOTSTRAP = $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a | 34 | LIBBPF_BOOTSTRAP_INCLUDE := $(LIBBPF_BOOTSTRAP_DESTDIR)/include |
| 35 | LIBBPF_BOOTSTRAP_HDRS_DIR := $(LIBBPF_BOOTSTRAP_INCLUDE)/bpf | ||
| 36 | LIBBPF_BOOTSTRAP := $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a | ||
| 33 | 37 | ||
| 34 | # We need to copy hashmap.h and nlattr.h which is not otherwise exported by | 38 | # We need to copy hashmap.h and nlattr.h which is not otherwise exported by |
| 35 | # libbpf, but still required by bpftool. | 39 | # libbpf, but still required by bpftool. |
| 36 | LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h) | 40 | LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h) |
| 41 | LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h) | ||
| 37 | 42 | ||
| 38 | ifeq ($(BPFTOOL_VERSION),) | 43 | ifeq ($(BPFTOOL_VERSION),) |
| 39 | BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) | 44 | BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) |
| 40 | endif | 45 | endif |
| 41 | 46 | ||
| 42 | $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR): | 47 | $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR): |
| 43 | $(QUIET_MKDIR)mkdir -p $@ | 48 | $(QUIET_MKDIR)mkdir -p $@ |
| 44 | 49 | ||
| 45 | $(LIBBPF): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_OUTPUT) | 50 | $(LIBBPF): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_OUTPUT) |
| @@ -52,7 +57,12 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_ · 6 unmodified lines | |||
| 52 | 57 | ||
| 53 | $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT) | 58 | $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT) |
| 54 | $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ | 59 | $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ |
| 55 | ARCH= CC=$(HOSTCC) LD=$(HOSTLD) $@ | 60 | DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR) prefix= \ |
| 61 | ARCH= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers | ||
| 62 | |||
| 63 | $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR) | ||
| 64 | $(call QUIET_INSTALL, $@) | ||
| 65 | $(Q)install -m 644 -t $(LIBBPF_BOOTSTRAP_HDRS_DIR) $< | ||
| 56 | 66 | ||
| 57 | $(LIBBPF)-clean: FORCE | $(LIBBPF_OUTPUT) | 67 | $(LIBBPF)-clean: FORCE | $(LIBBPF_OUTPUT) |
| 58 | $(call QUIET_CLEAN, libbpf) | 68 | $(call QUIET_CLEAN, libbpf) |
| @@ -172,11 +182,11 @@ else · 113 unmodified lines | |||
| 172 | $(Q)cp "$(VMLINUX_H)" $@ | 182 | $(Q)cp "$(VMLINUX_H)" $@ |
| 173 | endif | 183 | endif |
| 174 | 184 | ||
| 175 | $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF) | 185 | $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP) |
| 176 | $(QUIET_CLANG)$(CLANG) \ | 186 | $(QUIET_CLANG)$(CLANG) \ |
| 177 | -I$(if $(OUTPUT),$(OUTPUT),.) \ | 187 | -I$(if $(OUTPUT),$(OUTPUT),.) \ |
| 178 | -I$(srctree)/tools/include/uapi/ \ | 188 | -I$(srctree)/tools/include/uapi/ \ |
| 179 | -I$(LIBBPF_INCLUDE) \ | 189 | -I$(LIBBPF_BOOTSTRAP_INCLUDE) \ |
| 180 | -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@ | 190 | -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@ |
| 181 | 191 | ||
| 182 | $(OUTPUT)%.skel.h: $(OUTPUT)%.bpf.o $(BPFTOOL_BOOTSTRAP) | 192 | $(OUTPUT)%.skel.h: $(OUTPUT)%.bpf.o $(BPFTOOL_BOOTSTRAP) |
| @@ -209,8 +219,10 @@ $(BPFTOOL_BOOTSTRAP): $(BOOTSTRAP_OBJS) $(LIBBPF_BOOTSTRAP) · 26 unmodified lines | |||
| 209 | $(OUTPUT)bpftool: $(OBJS) $(LIBBPF) | 219 | $(OUTPUT)bpftool: $(OBJS) $(LIBBPF) |
| 210 | $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) | 220 | $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) |
| 211 | 221 | ||
| 212 | $(BOOTSTRAP_OUTPUT)%.o: %.c $(LIBBPF_INTERNAL_HDRS) | $(BOOTSTRAP_OUTPUT) | 222 | $(BOOTSTRAP_OUTPUT)%.o: %.c $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS) | $(BOOTSTRAP_OUTPUT) |
| 213 | $(QUIET_CC)$(HOSTCC) $(CFLAGS) -c -MMD -o $@ $< | 223 | $(QUIET_CC)$(HOSTCC) \ |
| 224 | $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),$(CFLAGS)) \ | ||
| 225 | -c -MMD -o $@ $< | ||
| 214 | 226 | ||
| 215 | $(OUTPUT)%.o: %.c | 227 | $(OUTPUT)%.o: %.c |
| 216 | $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $< | 228 | $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD -o $@ $< |
| @@ -257,6 +269,6 @@ doc-uninstall: · 40 unmodified lines | |||
| 257 | FORCE: | 269 | FORCE: |
| 258 | 270 | ||
| 259 | .SECONDARY: | 271 | .SECONDARY: |
| 260 | .PHONY: all FORCE clean install-bin install uninstall | 272 | .PHONY: all FORCE bootstrap clean install-bin install uninstall |
| 261 | .PHONY: doc doc-clean doc-install doc-uninstall | 273 | .PHONY: doc doc-clean doc-install doc-uninstall |
| 262 | .DEFAULT_GOAL := all | 274 | .DEFAULT_GOAL := all |
| @@ -515,6 +515,7 @@ int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value) · 514 unmodified lines | |||
| 515 | int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, __u64 flags) | 515 | int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, __u64 flags) |
| 516 | { | 516 | { |
| 517 | union bpf_attr attr; | 517 | union bpf_attr attr; |
| 518 | int ret; | ||
| 518 | 519 | ||
| 519 | memset(&attr, 0, sizeof(attr)); | 520 | memset(&attr, 0, sizeof(attr)); |
| 520 | attr.map_fd = fd; | 521 | attr.map_fd = fd; |
| @@ -522,7 +523,8 @@ int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, _ · 1 unmodified line | |||
| 522 | attr.value = ptr_to_u64(value); | 523 | attr.value = ptr_to_u64(value); |
| 523 | attr.flags = flags; | 524 | attr.flags = flags; |
| 524 | 525 | ||
| 525 | return sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, sizeof(attr)); | 526 | ret = sys_bpf(BPF_MAP_LOOKUP_AND_DELETE_ELEM, &attr, sizeof(attr)); |
| 527 | return libbpf_err_errno(ret); | ||
| 526 | } | 528 | } |
| 527 | 529 | ||
| 528 | int bpf_map_delete_elem(int fd, const void *key) | 530 | int bpf_map_delete_elem(int fd, const void *key) |
| @@ -8,7 +8,7 @@ · 7 unmodified lines | |||
| 8 | 8 | ||
| 9 | #define CG_NAME "/netcnt" | 9 | #define CG_NAME "/netcnt" |
| 10 | 10 | ||
| 11 | void test_netcnt(void) | 11 | void serial_test_netcnt(void) |
| 12 | { | 12 | { |
| 13 | union percpu_net_cnt *percpu_netcnt = NULL; | 13 | union percpu_net_cnt *percpu_netcnt = NULL; |
| 14 | struct bpf_cgroup_storage_key key; | 14 | struct bpf_cgroup_storage_key key; |
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* Copyright (c) 2020 Facebook */ | 2 | /* Copyright (c) 2020 Facebook */ |
| 3 | #define _GNU_SOURCE | 3 | #define _GNU_SOURCE |
| 4 | #include <stdio.h> | ||
| 4 | #include <sched.h> | 5 | #include <sched.h> |
| 5 | #include <sys/mount.h> | 6 | #include <sys/mount.h> |
| 6 | #include <sys/stat.h> | 7 | #include <sys/stat.h> |
| @@ -29,44 +30,106 @@ static int read_iter(char *file) · 22 unmodified lines | |||
| 29 | 30 | ||
| 30 | static int fn(void) | 31 | static int fn(void) |
| 31 | { | 32 | { |
| 32 | int err, duration = 0; | 33 | struct stat a, b, c; |
| 34 | int err, map; | ||
| 33 | 35 | ||
| 34 | err = unshare(CLONE_NEWNS); | 36 | err = unshare(CLONE_NEWNS); |
| 35 | if (CHECK(err, "unshare", "failed: %d\n", errno)) | 37 | if (!ASSERT_OK(err, "unshare")) |
| 36 | goto out; | 38 | goto out; |
| 37 | 39 | ||
| 38 | err = mount("", "/", "", MS_REC | MS_PRIVATE, NULL); | 40 | err = mount("", "/", "", MS_REC | MS_PRIVATE, NULL); |
| 39 | if (CHECK(err, "mount /", "failed: %d\n", errno)) | 41 | if (!ASSERT_OK(err, "mount /")) |
| 40 | goto out; | 42 | goto out; |
| 41 | 43 | ||
| 42 | err = umount(TDIR); | 44 | err = umount(TDIR); |
| 43 | if (CHECK(err, "umount " TDIR, "failed: %d\n", errno)) | 45 | if (!ASSERT_OK(err, "umount " TDIR)) |
| 44 | goto out; | 46 | goto out; |
| 45 | 47 | ||
| 46 | err = mount("none", TDIR, "tmpfs", 0, NULL); | 48 | err = mount("none", TDIR, "tmpfs", 0, NULL); |
| 47 | if (CHECK(err, "mount", "mount root failed: %d\n", errno)) | 49 | if (!ASSERT_OK(err, "mount tmpfs")) |
| 48 | goto out; | 50 | goto out; |
| 49 | 51 | ||
| 50 | err = mkdir(TDIR "/fs1", 0777); | 52 | err = mkdir(TDIR "/fs1", 0777); |
| 51 | if (CHECK(err, "mkdir "TDIR"/fs1", "failed: %d\n", errno)) | 53 | if (!ASSERT_OK(err, "mkdir " TDIR "/fs1")) |
| 52 | goto out; | 54 | goto out; |
| 53 | err = mkdir(TDIR "/fs2", 0777); | 55 | err = mkdir(TDIR "/fs2", 0777); |
| 54 | if (CHECK(err, "mkdir "TDIR"/fs2", "failed: %d\n", errno)) | 56 | if (!ASSERT_OK(err, "mkdir " TDIR "/fs2")) |
| 55 | goto out; | 57 | goto out; |
| 56 | 58 | ||
| 57 | err = mount("bpf", TDIR "/fs1", "bpf", 0, NULL); | 59 | err = mount("bpf", TDIR "/fs1", "bpf", 0, NULL); |
| 58 | if (CHECK(err, "mount bpffs "TDIR"/fs1", "failed: %d\n", errno)) | 60 | if (!ASSERT_OK(err, "mount bpffs " TDIR "/fs1")) |
| 59 | goto out; | 61 | goto out; |
| 60 | err = mount("bpf", TDIR "/fs2", "bpf", 0, NULL); | 62 | err = mount("bpf", TDIR "/fs2", "bpf", 0, NULL); |
| 61 | if (CHECK(err, "mount bpffs " TDIR "/fs2", "failed: %d\n", errno)) | 63 | if (!ASSERT_OK(err, "mount bpffs " TDIR "/fs2")) |
| 62 | goto out; | 64 | goto out; |
| 63 | 65 | ||
| 64 | err = read_iter(TDIR "/fs1/maps.debug"); | 66 | err = read_iter(TDIR "/fs1/maps.debug"); |
| 65 | if (CHECK(err, "reading " TDIR "/fs1/maps.debug", "failed\n")) | 67 | if (!ASSERT_OK(err, "reading " TDIR "/fs1/maps.debug")) |
| 66 | goto out; | 68 | goto out; |
| 67 | err = read_iter(TDIR "/fs2/progs.debug"); | 69 | err = read_iter(TDIR "/fs2/progs.debug"); |
| 68 | if (CHECK(err, "reading " TDIR "/fs2/progs.debug", "failed\n")) | 70 | if (!ASSERT_OK(err, "reading " TDIR "/fs2/progs.debug")) |
| 69 | goto out; | 71 | goto out; |
| 72 | |||
| 73 | err = mkdir(TDIR "/fs1/a", 0777); | ||
| 74 | if (!ASSERT_OK(err, "creating " TDIR "/fs1/a")) | ||
| 75 | goto out; | ||
| 76 | err = mkdir(TDIR "/fs1/a/1", 0777); | ||
| 77 | if (!ASSERT_OK(err, "creating " TDIR "/fs1/a/1")) | ||
| 78 | goto out; | ||
| 79 | err = mkdir(TDIR "/fs1/b", 0777); | ||
| 80 | if (!ASSERT_OK(err, "creating " TDIR "/fs1/b")) | ||
| 81 | goto out; | ||
| 82 | |||
| 83 | map = bpf_create_map(BPF_MAP_TYPE_ARRAY, 4, 4, 1, 0); | ||
| 84 | if (!ASSERT_GT(map, 0, "create_map(ARRAY)")) | ||
| 85 | goto out; | ||
| 86 | err = bpf_obj_pin(map, TDIR "/fs1/c"); | ||
| 87 | if (!ASSERT_OK(err, "pin map")) | ||
| 88 | goto out; | ||
| 89 | close(map); | ||
| 90 | |||
| 91 | /* Check that RENAME_EXCHANGE works for directories. */ | ||
| 92 | err = stat(TDIR "/fs1/a", &a); | ||
| 93 | if (!ASSERT_OK(err, "stat(" TDIR "/fs1/a)")) | ||
| 94 | goto out; | ||
| 95 | err = renameat2(0, TDIR "/fs1/a", 0, TDIR "/fs1/b", RENAME_EXCHANGE); | ||
| 96 | if (!ASSERT_OK(err, "renameat2(/fs1/a, /fs1/b, RENAME_EXCHANGE)")) | ||
| 97 | goto out; | ||
| 98 | err = stat(TDIR "/fs1/b", &b); | ||
| 99 | if (!ASSERT_OK(err, "stat(" TDIR "/fs1/b)")) | ||
| 100 | goto out; | ||
| 101 | if (!ASSERT_EQ(a.st_ino, b.st_ino, "b should have a's inode")) | ||
| 102 | goto out; | ||
| 103 | err = access(TDIR "/fs1/b/1", F_OK); | ||
| 104 | if (!ASSERT_OK(err, "access(" TDIR "/fs1/b/1)")) | ||
| 105 | goto out; | ||
| 106 | |||
| 107 | /* Check that RENAME_EXCHANGE works for mixed file types. */ | ||
| 108 | err = stat(TDIR "/fs1/c", &c); | ||
| 109 | if (!ASSERT_OK(err, "stat(" TDIR "/fs1/map)")) | ||
| 110 | goto out; | ||
| 111 | err = renameat2(0, TDIR "/fs1/c", 0, TDIR "/fs1/b", RENAME_EXCHANGE); | ||
| 112 | if (!ASSERT_OK(err, "renameat2(/fs1/c, /fs1/b, RENAME_EXCHANGE)")) | ||
| 113 | goto out; | ||
| 114 | err = stat(TDIR "/fs1/b", &b); | ||
| 115 | if (!ASSERT_OK(err, "stat(" TDIR "/fs1/b)")) | ||
| 116 | goto out; | ||
| 117 | if (!ASSERT_EQ(c.st_ino, b.st_ino, "b should have c's inode")) | ||
| 118 | goto out; | ||
| 119 | err = access(TDIR "/fs1/c/1", F_OK); | ||
| 120 | if (!ASSERT_OK(err, "access(" TDIR "/fs1/c/1)")) | ||
| 121 | goto out; | ||
| 122 | |||
| 123 | /* Check that RENAME_NOREPLACE works. */ | ||
| 124 | err = renameat2(0, TDIR "/fs1/b", 0, TDIR "/fs1/a", RENAME_NOREPLACE); | ||
| 125 | if (!ASSERT_ERR(err, "renameat2(RENAME_NOREPLACE)")) { | ||
| 126 | err = -EINVAL; | ||
| 127 | goto out; | ||
| 128 | } | ||
| 129 | err = access(TDIR "/fs1/b", F_OK); | ||
| 130 | if (!ASSERT_OK(err, "access(" TDIR "/fs1/b)")) | ||
| 131 | goto out; | ||
| 132 | |||
| 70 | out: | 133 | out: |
| 71 | umount(TDIR "/fs1"); | 134 | umount(TDIR "/fs1"); |
| 72 | umount(TDIR "/fs2"); | 135 | umount(TDIR "/fs2"); |
| @@ -23,6 +23,16 @@ struct callback_ctx { · 22 unmodified lines | |||
| 23 | int output; | 23 | int output; |
| 24 | }; | 24 | }; |
| 25 | 25 | ||
| 26 | const volatile int bypass_unused = 1; | ||
| 27 | |||
| 28 | static __u64 | ||
| 29 | unused_subprog(struct bpf_map *map, __u32 *key, __u64 *val, | ||
| 30 | struct callback_ctx *data) | ||
| 31 | { | ||
| 32 | data->output = 0; | ||
| 33 | return 1; | ||
| 34 | } | ||
| 35 | |||
| 26 | static __u64 | 36 | static __u64 |
| 27 | check_array_elem(struct bpf_map *map, __u32 *key, __u64 *val, | 37 | check_array_elem(struct bpf_map *map, __u32 *key, __u64 *val, |
| 28 | struct callback_ctx *data) | 38 | struct callback_ctx *data) |
| @@ -54,6 +64,8 @@ int test_pkt_access(struct __sk_buff *skb) · 25 unmodified lines | |||
| 54 | 64 | ||
| 55 | data.output = 0; | 65 | data.output = 0; |
| 56 | bpf_for_each_map_elem(&arraymap, check_array_elem, &data, 0); | 66 | bpf_for_each_map_elem(&arraymap, check_array_elem, &data, 0); |
| 67 | if (!bypass_unused) | ||
| 68 | bpf_for_each_map_elem(&arraymap, unused_subprog, &data, 0); | ||
| 57 | arraymap_output = data.output; | 69 | arraymap_output = data.output; |
| 58 | 70 | ||
| 59 | bpf_for_each_map_elem(&percpu_map, check_percpu_elem, (void *)0, 0); | 71 | bpf_for_each_map_elem(&percpu_map, check_percpu_elem, (void *)0, 0); |
| @@ -2,11 +2,11 @@ · 1 unmodified line | |||
| 2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # | 3 | # |
| 4 | # Test topology: | 4 | # Test topology: |
| 5 | # - - - - - - - - - - - - - - - - - - - - - - - - - | 5 | # - - - - - - - - - - - - - - - - - - - |
| 6 | # | veth1 veth2 veth3 | ... init net | 6 | # | veth1 veth2 veth3 | ns0 |
| 7 | # - -| - - - - - - | - - - - - - | - - | 7 | # - -| - - - - - - | - - - - - - | - - |
| 8 | # --------- --------- --------- | 8 | # --------- --------- --------- |
| 9 | # | veth0 | | veth0 | | veth0 | ... | 9 | # | veth0 | | veth0 | | veth0 | |
| 10 | # --------- --------- --------- | 10 | # --------- --------- --------- |
| 11 | # ns1 ns2 ns3 | 11 | # ns1 ns2 ns3 |
| 12 | # | 12 | # |
| @@ -31,6 +31,7 @@ IFACES="" · 18 unmodified lines | |||
| 31 | DRV_MODE="xdpgeneric xdpdrv xdpegress" | 31 | DRV_MODE="xdpgeneric xdpdrv xdpegress" |
| 32 | PASS=0 | 32 | PASS=0 |
| 33 | FAIL=0 | 33 | FAIL=0 |
| 34 | LOG_DIR=$(mktemp -d) | ||
| 34 | 35 | ||
| 35 | test_pass() | 36 | test_pass() |
| 36 | { | 37 | { |
| @@ -50,6 +51,7 @@ clean_up() · 13 unmodified lines | |||
| 50 | ip link del veth$i 2> /dev/null | 51 | ip link del veth$i 2> /dev/null |
| 51 | ip netns del ns$i 2> /dev/null | 52 | ip netns del ns$i 2> /dev/null |
| 52 | done | 53 | done |
| 54 | ip netns del ns0 2> /dev/null | ||
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | # Kselftest framework requirement - SKIP code is 4. | 57 | # Kselftest framework requirement - SKIP code is 4. |
| @@ -77,10 +79,12 @@ setup_ns() · 21 unmodified lines | |||
| 77 | mode="xdpdrv" | 79 | mode="xdpdrv" |
| 78 | fi | 80 | fi |
| 79 | 81 | ||
| 82 | ip netns add ns0 | ||
| 80 | for i in $(seq $NUM); do | 83 | for i in $(seq $NUM); do |
| 81 | ip netns add ns$i | 84 | ip netns add ns$i |
| 82 | ip link add veth$i type veth peer name veth0 netns ns$i | 85 | ip -n ns$i link add veth0 index 2 type veth \ |
| 83 | ip link set veth$i up | 86 | peer name veth$i netns ns0 index $((1 + $i)) |
| 87 | ip -n ns0 link set veth$i up | ||
| 84 | ip -n ns$i link set veth0 up | 88 | ip -n ns$i link set veth0 up |
| 85 | 89 | ||
| 86 | ip -n ns$i addr add 192.0.2.$i/24 dev veth0 | 90 | ip -n ns$i addr add 192.0.2.$i/24 dev veth0 |
| @@ -91,7 +95,7 @@ setup_ns() · 4 unmodified lines | |||
| 91 | xdp_dummy.o sec xdp &> /dev/null || \ | 95 | xdp_dummy.o sec xdp &> /dev/null || \ |
| 92 | { test_fail "Unable to load dummy xdp" && exit 1; } | 96 | { test_fail "Unable to load dummy xdp" && exit 1; } |
| 93 | IFACES="$IFACES veth$i" | 97 | IFACES="$IFACES veth$i" |
| 94 | veth_mac[$i]=$(ip link show veth$i | awk '/link\/ether/ {print $2}') | 98 | veth_mac[$i]=$(ip -n ns0 link show veth$i | awk '/link\/ether/ {print $2}') |
| 95 | done | 99 | done |
| 96 | } | 100 | } |
| 97 | 101 | ||
| @@ -100,17 +104,17 @@ do_egress_tests() · 2 unmodified lines | |||
| 100 | local mode=$1 | 104 | local mode=$1 |
| 101 | 105 | ||
| 102 | # mac test | 106 | # mac test |
| 103 | ip netns exec ns2 tcpdump -e -i veth0 -nn -l -e &> mac_ns1-2_${mode}.log & | 107 | ip netns exec ns2 tcpdump -e -i veth0 -nn -l -e &> ${LOG_DIR}/mac_ns1-2_${mode}.log & |
| 104 | ip netns exec ns3 tcpdump -e -i veth0 -nn -l -e &> mac_ns1-3_${mode}.log & | 108 | ip netns exec ns3 tcpdump -e -i veth0 -nn -l -e &> ${LOG_DIR}/mac_ns1-3_${mode}.log & |
| 105 | sleep 0.5 | 109 | sleep 0.5 |
| 106 | ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null | 110 | ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null |
| 107 | sleep 0.5 | 111 | sleep 0.5 |
| 108 | pkill -9 tcpdump | 112 | pkill tcpdump |
| 109 | 113 | ||
| 110 | # mac check | 114 | # mac check |
| 111 | grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" mac_ns1-2_${mode}.log && \ | 115 | grep -q "${veth_mac[2]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-2_${mode}.log && \ |
| 112 | test_pass "$mode mac ns1-2" || test_fail "$mode mac ns1-2" | 116 | test_pass "$mode mac ns1-2" || test_fail "$mode mac ns1-2" |
| 113 | grep -q "${veth_mac[3]} > ff:ff:ff:ff:ff:ff" mac_ns1-3_${mode}.log && \ | 117 | grep -q "${veth_mac[3]} > ff:ff:ff:ff:ff:ff" ${LOG_DIR}/mac_ns1-3_${mode}.log && \ |
| 114 | test_pass "$mode mac ns1-3" || test_fail "$mode mac ns1-3" | 118 | test_pass "$mode mac ns1-3" || test_fail "$mode mac ns1-3" |
| 115 | } | 119 | } |
| 116 | 120 | ||
| @@ -121,46 +125,46 @@ do_ping_tests() · 4 unmodified lines | |||
| 121 | # ping6 test: echo request should be redirect back to itself, not others | 125 | # ping6 test: echo request should be redirect back to itself, not others |
| 122 | ip netns exec ns1 ip neigh add 2001:db8::2 dev veth0 lladdr 00:00:00:00:00:02 | 126 | ip netns exec ns1 ip neigh add 2001:db8::2 dev veth0 lladdr 00:00:00:00:00:02 |
| 123 | 127 | ||
| 124 | ip netns exec ns1 tcpdump -i veth0 -nn -l -e &> ns1-1_${mode}.log & | 128 | ip netns exec ns1 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-1_${mode}.log & |
| 125 | ip netns exec ns2 tcpdump -i veth0 -nn -l -e &> ns1-2_${mode}.log & | 129 | ip netns exec ns2 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-2_${mode}.log & |
| 126 | ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ns1-3_${mode}.log & | 130 | ip netns exec ns3 tcpdump -i veth0 -nn -l -e &> ${LOG_DIR}/ns1-3_${mode}.log & |
| 127 | sleep 0.5 | 131 | sleep 0.5 |
| 128 | # ARP test | 132 | # ARP test |
| 129 | ip netns exec ns1 ping 192.0.2.254 -i 0.1 -c 4 &> /dev/null | 133 | ip netns exec ns1 arping -q -c 2 -I veth0 192.0.2.254 |
| 130 | # IPv4 test | 134 | # IPv4 test |
| 131 | ip netns exec ns1 ping 192.0.2.253 -i 0.1 -c 4 &> /dev/null | 135 | ip netns exec ns1 ping 192.0.2.253 -i 0.1 -c 4 &> /dev/null |
| 132 | # IPv6 test | 136 | # IPv6 test |
| 133 | ip netns exec ns1 ping6 2001:db8::2 -i 0.1 -c 2 &> /dev/null | 137 | ip netns exec ns1 ping6 2001:db8::2 -i 0.1 -c 2 &> /dev/null |
| 134 | sleep 0.5 | 138 | sleep 0.5 |
| 135 | pkill -9 tcpdump | 139 | pkill tcpdump |
| 136 | 140 | ||
| 137 | # All netns should receive the redirect arp requests | 141 | # All netns should receive the redirect arp requests |
| 138 | [ $(grep -c "who-has 192.0.2.254" ns1-1_${mode}.log) -gt 4 ] && \ | 142 | [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \ |
| 139 | test_pass "$mode arp(F_BROADCAST) ns1-1" || \ | 143 | test_pass "$mode arp(F_BROADCAST) ns1-1" || \ |
| 140 | test_fail "$mode arp(F_BROADCAST) ns1-1" | 144 | test_fail "$mode arp(F_BROADCAST) ns1-1" |
| 141 | [ $(grep -c "who-has 192.0.2.254" ns1-2_${mode}.log) -le 4 ] && \ | 145 | [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-2_${mode}.log) -eq 2 ] && \ |
| 142 | test_pass "$mode arp(F_BROADCAST) ns1-2" || \ | 146 | test_pass "$mode arp(F_BROADCAST) ns1-2" || \ |
| 143 | test_fail "$mode arp(F_BROADCAST) ns1-2" | 147 | test_fail "$mode arp(F_BROADCAST) ns1-2" |
| 144 | [ $(grep -c "who-has 192.0.2.254" ns1-3_${mode}.log) -le 4 ] && \ | 148 | [ $(grep -cF "who-has 192.0.2.254" ${LOG_DIR}/ns1-3_${mode}.log) -eq 2 ] && \ |
| 145 | test_pass "$mode arp(F_BROADCAST) ns1-3" || \ | 149 | test_pass "$mode arp(F_BROADCAST) ns1-3" || \ |
| 146 | test_fail "$mode arp(F_BROADCAST) ns1-3" | 150 | test_fail "$mode arp(F_BROADCAST) ns1-3" |
| 147 | 151 | ||
| 148 | # ns1 should not receive the redirect echo request, others should | 152 | # ns1 should not receive the redirect echo request, others should |
| 149 | [ $(grep -c "ICMP echo request" ns1-1_${mode}.log) -eq 4 ] && \ | 153 | [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \ |
| 150 | test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" || \ | 154 | test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" || \ |
| 151 | test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" | 155 | test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1" |
| 152 | [ $(grep -c "ICMP echo request" ns1-2_${mode}.log) -eq 4 ] && \ | 156 | [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-2_${mode}.log) -eq 4 ] && \ |
| 153 | test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" || \ | 157 | test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" || \ |
| 154 | test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" | 158 | test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2" |
| 155 | [ $(grep -c "ICMP echo request" ns1-3_${mode}.log) -eq 4 ] && \ | 159 | [ $(grep -c "ICMP echo request" ${LOG_DIR}/ns1-3_${mode}.log) -eq 4 ] && \ |
| 156 | test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" || \ | 160 | test_pass "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" || \ |
| 157 | test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" | 161 | test_fail "$mode IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3" |
| 158 | 162 | ||
| 159 | # ns1 should receive the echo request, ns2 should not | 163 | # ns1 should receive the echo request, ns2 should not |
| 160 | [ $(grep -c "ICMP6, echo request" ns1-1_${mode}.log) -eq 4 ] && \ | 164 | [ $(grep -c "ICMP6, echo request" ${LOG_DIR}/ns1-1_${mode}.log) -eq 4 ] && \ |
| 161 | test_pass "$mode IPv6 (no flags) ns1-1" || \ | 165 | test_pass "$mode IPv6 (no flags) ns1-1" || \ |
| 162 | test_fail "$mode IPv6 (no flags) ns1-1" | 166 | test_fail "$mode IPv6 (no flags) ns1-1" |
| 163 | [ $(grep -c "ICMP6, echo request" ns1-2_${mode}.log) -eq 0 ] && \ | 167 | [ $(grep -c "ICMP6, echo request" ${LOG_DIR}/ns1-2_${mode}.log) -eq 0 ] && \ |
| 164 | test_pass "$mode IPv6 (no flags) ns1-2" || \ | 168 | test_pass "$mode IPv6 (no flags) ns1-2" || \ |
| 165 | test_fail "$mode IPv6 (no flags) ns1-2" | 169 | test_fail "$mode IPv6 (no flags) ns1-2" |
| 166 | } | 170 | } |
| @@ -176,9 +180,13 @@ do_tests() · 9 unmodified lines | |||
| 176 | xdpgeneric) drv_p="-S";; | 180 | xdpgeneric) drv_p="-S";; |
| 177 | esac | 181 | esac |
| 178 | 182 | ||
| 179 | ./xdp_redirect_multi $drv_p $IFACES &> xdp_redirect_${mode}.log & | 183 | ip netns exec ns0 ./xdp_redirect_multi $drv_p $IFACES &> ${LOG_DIR}/xdp_redirect_${mode}.log & |
| 180 | xdp_pid=$! | 184 | xdp_pid=$! |
| 181 | sleep 1 | 185 | sleep 1 |
| 186 | if ! ps -p $xdp_pid > /dev/null; then | ||
| 187 | test_fail "$mode xdp_redirect_multi start failed" | ||
| 188 | return 1 | ||
| 189 | fi | ||
| 182 | 190 | ||
| 183 | if [ "$mode" = "xdpegress" ]; then | 191 | if [ "$mode" = "xdpegress" ]; then |
| 184 | do_egress_tests $mode | 192 | do_egress_tests $mode |
| @@ -189,16 +197,16 @@ do_tests() · 4 unmodified lines | |||
| 189 | kill $xdp_pid | 197 | kill $xdp_pid |
| 190 | } | 198 | } |
| 191 | 199 | ||
| 192 | trap clean_up 0 2 3 6 9 | 200 | trap clean_up EXIT |
| 193 | 201 | ||
| 194 | check_env | 202 | check_env |
| 195 | rm -f xdp_redirect_*.log ns*.log mac_ns*.log | ||
| 196 | 203 | ||
| 197 | for mode in ${DRV_MODE}; do | 204 | for mode in ${DRV_MODE}; do |
| 198 | setup_ns $mode | 205 | setup_ns $mode |
| 199 | do_tests $mode | 206 | do_tests $mode |
| 200 | clean_up | 207 | clean_up |
| 201 | done | 208 | done |
| 209 | rm -rf ${LOG_DIR} | ||
| 202 | 210 | ||
| 203 | echo "Summary: PASS $PASS, FAIL $FAIL" | 211 | echo "Summary: PASS $PASS, FAIL $FAIL" |
| 204 | [ $FAIL -eq 0 ] && exit 0 || exit 1 | 212 | [ $FAIL -eq 0 ] && exit 0 || exit 1 |
| @@ -265,3 +265,20 @@ · 264 unmodified lines | |||
| 265 | .result = ACCEPT, | 265 | .result = ACCEPT, |
| 266 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | 266 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, |
| 267 | }, | 267 | }, |
| 268 | { | ||
| 269 | "Spill a u32 scalar at fp-4 and then at fp-8", | ||
| 270 | .insns = { | ||
| 271 | /* r4 = 4321 */ | ||
| 272 | BPF_MOV32_IMM(BPF_REG_4, 4321), | ||
| 273 | /* *(u32 *)(r10 -4) = r4 */ | ||
| 274 | BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_4, -4), | ||
| 275 | /* *(u32 *)(r10 -8) = r4 */ | ||
| 276 | BPF_STX_MEM(BPF_W, BPF_REG_10, BPF_REG_4, -8), | ||
| 277 | /* r4 = *(u64 *)(r10 -8) */ | ||
| 278 | BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_10, -8), | ||
| 279 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 280 | BPF_EXIT_INSN(), | ||
| 281 | }, | ||
| 282 | .result = ACCEPT, | ||
| 283 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 284 | }, | ||
| @@ -129,7 +129,7 @@ int main(int argc, char **argv) · 128 unmodified lines | |||
| 129 | goto err_out; | 129 | goto err_out; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | printf("Get interfaces"); | 132 | printf("Get interfaces:"); |
| 133 | for (i = 0; i < MAX_IFACE_NUM && argv[optind + i]; i++) { | 133 | for (i = 0; i < MAX_IFACE_NUM && argv[optind + i]; i++) { |
| 134 | ifaces[i] = if_nametoindex(argv[optind + i]); | 134 | ifaces[i] = if_nametoindex(argv[optind + i]); |
| 135 | if (!ifaces[i]) | 135 | if (!ifaces[i]) |
| @@ -139,7 +139,7 @@ int main(int argc, char **argv) · 3 unmodified lines | |||
| 139 | goto err_out; | 139 | goto err_out; |
| 140 | } | 140 | } |
| 141 | if (ifaces[i] > MAX_INDEX_NUM) { | 141 | if (ifaces[i] > MAX_INDEX_NUM) { |
| 142 | printf("Interface index to large\n"); | 142 | printf(" interface index too large\n"); |
| 143 | goto err_out; | 143 | goto err_out; |
| 144 | } | 144 | } |
| 145 | printf(" %d", ifaces[i]); | 145 | printf(" %d", ifaces[i]); |
| @@ -12,7 +12,7 @@ TEST_PROGS += udpgro_bench.sh udpgro.sh test_vxlan_under_vrf.sh reuseport_addr_a · 11 unmodified lines | |||
| 12 | TEST_PROGS += test_vxlan_fdb_changelink.sh so_txtime.sh ipv6_flowlabel.sh | 12 | TEST_PROGS += test_vxlan_fdb_changelink.sh so_txtime.sh ipv6_flowlabel.sh |
| 13 | TEST_PROGS += tcp_fastopen_backup_key.sh fcnal-test.sh l2tp.sh traceroute.sh | 13 | TEST_PROGS += tcp_fastopen_backup_key.sh fcnal-test.sh l2tp.sh traceroute.sh |
| 14 | TEST_PROGS += fin_ack_lat.sh fib_nexthop_multiprefix.sh fib_nexthops.sh | 14 | TEST_PROGS += fin_ack_lat.sh fib_nexthop_multiprefix.sh fib_nexthops.sh |
| 15 | TEST_PROGS += altnames.sh icmp_redirect.sh ip6_gre_headroom.sh | 15 | TEST_PROGS += altnames.sh icmp.sh icmp_redirect.sh ip6_gre_headroom.sh |
| 16 | TEST_PROGS += route_localnet.sh | 16 | TEST_PROGS += route_localnet.sh |
| 17 | TEST_PROGS += reuseaddr_ports_exhausted.sh | 17 | TEST_PROGS += reuseaddr_ports_exhausted.sh |
| 18 | TEST_PROGS += txtimestamp.sh | 18 | TEST_PROGS += txtimestamp.sh |
| @@ -30,7 +30,12 @@ TEST_PROGS += ioam6.sh · 11 unmodified lines | |||
| 30 | TEST_PROGS += gro.sh | 30 | TEST_PROGS += gro.sh |
| 31 | TEST_PROGS += gre_gso.sh | 31 | TEST_PROGS += gre_gso.sh |
| 32 | TEST_PROGS += cmsg_so_mark.sh | 32 | TEST_PROGS += cmsg_so_mark.sh |
| 33 | TEST_PROGS_EXTENDED := in_netns.sh | 33 | TEST_PROGS += srv6_end_dt46_l3vpn_test.sh |
| 34 | TEST_PROGS += srv6_end_dt4_l3vpn_test.sh | ||
| 35 | TEST_PROGS += srv6_end_dt6_l3vpn_test.sh | ||
| 36 | TEST_PROGS += vrf_strict_mode_test.sh | ||
| 37 | TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh | ||
| 38 | TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh | ||
| 34 | TEST_GEN_FILES = socket nettest | 39 | TEST_GEN_FILES = socket nettest |
| 35 | TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any | 40 | TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any |
| 36 | TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite | 41 | TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite |
| @@ -80,7 +80,7 @@ test_gretap() · 79 unmodified lines | |||
| 80 | 80 | ||
| 81 | test_ip6gretap() | 81 | test_ip6gretap() |
| 82 | { | 82 | { |
| 83 | test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \ | 83 | test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ipv6' \ |
| 84 | "mirror to ip6gretap" | 84 | "mirror to ip6gretap" |
| 85 | } | 85 | } |
| 86 | 86 | ||
| @@ -74,7 +74,7 @@ test_span_gre_ttl() · 73 unmodified lines | |||
| 74 | 74 | ||
| 75 | mirror_install $swp1 ingress $tundev "matchall $tcflags" | 75 | mirror_install $swp1 ingress $tundev "matchall $tcflags" |
| 76 | tc filter add dev $h3 ingress pref 77 prot $prot \ | 76 | tc filter add dev $h3 ingress pref 77 prot $prot \ |
| 77 | flower ip_ttl 50 action pass | 77 | flower skip_hw ip_ttl 50 action pass |
| 78 | 78 | ||
| 79 | mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 0 | 79 | mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 0 |
| 80 | 80 | ||
| @@ -141,7 +141,7 @@ test_gretap() · 140 unmodified lines | |||
| 141 | 141 | ||
| 142 | test_ip6gretap() | 142 | test_ip6gretap() |
| 143 | { | 143 | { |
| 144 | test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \ | 144 | test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ipv6' \ |
| 145 | "mirror to ip6gretap" | 145 | "mirror to ip6gretap" |
| 146 | } | 146 | } |
| 147 | 147 | ||
| @@ -218,6 +218,7 @@ test_ip6gretap_forbidden_egress() · 70 unmodified lines | |||
| 218 | test_span_gre_untagged_egress() | 218 | test_span_gre_untagged_egress() |
| 219 | { | 219 | { |
| 220 | local tundev=$1; shift | 220 | local tundev=$1; shift |
| 221 | local ul_proto=$1; shift | ||
| 221 | local what=$1; shift | 222 | local what=$1; shift |
| 222 | 223 | ||
| 223 | RET=0 | 224 | RET=0 |
| @@ -225,7 +226,7 @@ test_span_gre_untagged_egress() · 1 unmodified line | |||
| 225 | mirror_install $swp1 ingress $tundev "matchall $tcflags" | 226 | mirror_install $swp1 ingress $tundev "matchall $tcflags" |
| 226 | 227 | ||
| 227 | quick_test_span_gre_dir $tundev ingress | 228 | quick_test_span_gre_dir $tundev ingress |
| 228 | quick_test_span_vlan_dir $h3 555 ingress | 229 | quick_test_span_vlan_dir $h3 555 ingress "$ul_proto" |
| 229 | 230 | ||
| 230 | h3_addr_add_del del $h3.555 | 231 | h3_addr_add_del del $h3.555 |
| 231 | bridge vlan add dev $swp3 vid 555 pvid untagged | 232 | bridge vlan add dev $swp3 vid 555 pvid untagged |
| @@ -233,7 +234,7 @@ test_span_gre_untagged_egress() · 1 unmodified line | |||
| 233 | sleep 5 | 234 | sleep 5 |
| 234 | 235 | ||
| 235 | quick_test_span_gre_dir $tundev ingress | 236 | quick_test_span_gre_dir $tundev ingress |
| 236 | fail_test_span_vlan_dir $h3 555 ingress | 237 | fail_test_span_vlan_dir $h3 555 ingress "$ul_proto" |
| 237 | 238 | ||
| 238 | h3_addr_add_del del $h3 | 239 | h3_addr_add_del del $h3 |
| 239 | bridge vlan add dev $swp3 vid 555 | 240 | bridge vlan add dev $swp3 vid 555 |
| @@ -241,7 +242,7 @@ test_span_gre_untagged_egress() · 1 unmodified line | |||
| 241 | sleep 5 | 242 | sleep 5 |
| 242 | 243 | ||
| 243 | quick_test_span_gre_dir $tundev ingress | 244 | quick_test_span_gre_dir $tundev ingress |
| 244 | quick_test_span_vlan_dir $h3 555 ingress | 245 | quick_test_span_vlan_dir $h3 555 ingress "$ul_proto" |
| 245 | 246 | ||
| 246 | mirror_uninstall $swp1 ingress | 247 | mirror_uninstall $swp1 ingress |
| 247 | 248 | ||
| @@ -250,12 +251,12 @@ test_span_gre_untagged_egress() · 2 unmodified lines | |||
| 250 | 251 | ||
| 251 | test_gretap_untagged_egress() | 252 | test_gretap_untagged_egress() |
| 252 | { | 253 | { |
| 253 | test_span_gre_untagged_egress gt4 "mirror to gretap" | 254 | test_span_gre_untagged_egress gt4 ip "mirror to gretap" |
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | test_ip6gretap_untagged_egress() | 257 | test_ip6gretap_untagged_egress() |
| 257 | { | 258 | { |
| 258 | test_span_gre_untagged_egress gt6 "mirror to ip6gretap" | 259 | test_span_gre_untagged_egress gt6 ipv6 "mirror to ip6gretap" |
| 259 | } | 260 | } |
| 260 | 261 | ||
| 261 | test_span_gre_fdb_roaming() | 262 | test_span_gre_fdb_roaming() |
| @@ -115,13 +115,14 @@ do_test_span_vlan_dir_ips() · 114 unmodified lines | |||
| 115 | local dev=$1; shift | 115 | local dev=$1; shift |
| 116 | local vid=$1; shift | 116 | local vid=$1; shift |
| 117 | local direction=$1; shift | 117 | local direction=$1; shift |
| 118 | local ul_proto=$1; shift | ||
| 118 | local ip1=$1; shift | 119 | local ip1=$1; shift |
| 119 | local ip2=$1; shift | 120 | local ip2=$1; shift |
| 120 | 121 | ||
| 121 | # Install the capture as skip_hw to avoid double-counting of packets. | 122 | # Install the capture as skip_hw to avoid double-counting of packets. |
| 122 | # The traffic is meant for local box anyway, so will be trapped to | 123 | # The traffic is meant for local box anyway, so will be trapped to |
| 123 | # kernel. | 124 | # kernel. |
| 124 | vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype ip" | 125 | vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype $ul_proto" |
| 125 | mirror_test v$h1 $ip1 $ip2 $dev 100 $expect | 126 | mirror_test v$h1 $ip1 $ip2 $dev 100 $expect |
| 126 | mirror_test v$h2 $ip2 $ip1 $dev 100 $expect | 127 | mirror_test v$h2 $ip2 $ip1 $dev 100 $expect |
| 127 | vlan_capture_uninstall $dev | 128 | vlan_capture_uninstall $dev |
| @@ -85,9 +85,9 @@ test_tagged_vlan_dir() · 84 unmodified lines | |||
| 85 | RET=0 | 85 | RET=0 |
| 86 | 86 | ||
| 87 | mirror_install $swp1 $direction $swp3.555 "matchall $tcflags" | 87 | mirror_install $swp1 $direction $swp3.555 "matchall $tcflags" |
| 88 | do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" \ | 88 | do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" ip \ |
| 89 | 192.0.2.17 192.0.2.18 | 89 | 192.0.2.17 192.0.2.18 |
| 90 | do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" \ | 90 | do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" ip \ |
| 91 | 192.0.2.17 192.0.2.18 | 91 | 192.0.2.17 192.0.2.18 |
| 92 | mirror_uninstall $swp1 $direction | 92 | mirror_uninstall $swp1 $direction |
| 93 | 93 | ||
| @@ -116,17 +116,18 @@ gre_gst_test_checks() · 115 unmodified lines | |||
| 116 | { | 116 | { |
| 117 | local name=$1 | 117 | local name=$1 |
| 118 | local addr=$2 | 118 | local addr=$2 |
| 119 | local proto=$3 | ||
| 119 | 120 | ||
| 120 | $NS_EXEC nc -kl $port >/dev/null & | 121 | $NS_EXEC nc $proto -kl $port >/dev/null & |
| 121 | PID=$! | 122 | PID=$! |
| 122 | while ! $NS_EXEC ss -ltn | grep -q $port; do ((i++)); sleep 0.01; done | 123 | while ! $NS_EXEC ss -ltn | grep -q $port; do ((i++)); sleep 0.01; done |
| 123 | 124 | ||
| 124 | cat $TMPFILE | timeout 1 nc $addr $port | 125 | cat $TMPFILE | timeout 1 nc $proto -N $addr $port |
| 125 | log_test $? 0 "$name - copy file w/ TSO" | 126 | log_test $? 0 "$name - copy file w/ TSO" |
| 126 | 127 | ||
| 127 | ethtool -K veth0 tso off | 128 | ethtool -K veth0 tso off |
| 128 | 129 | ||
| 129 | cat $TMPFILE | timeout 1 nc $addr $port | 130 | cat $TMPFILE | timeout 1 nc $proto -N $addr $port |
| 130 | log_test $? 0 "$name - copy file w/ GSO" | 131 | log_test $? 0 "$name - copy file w/ GSO" |
| 131 | 132 | ||
| 132 | ethtool -K veth0 tso on | 133 | ethtool -K veth0 tso on |
| @@ -155,7 +156,7 @@ gre6_gso_test() · 22 unmodified lines | |||
| 155 | sleep 2 | 156 | sleep 2 |
| 156 | 157 | ||
| 157 | gre_gst_test_checks GREv6/v4 172.16.2.2 | 158 | gre_gst_test_checks GREv6/v4 172.16.2.2 |
| 158 | gre_gst_test_checks GREv6/v6 2001:db8:1::2 | 159 | gre_gst_test_checks GREv6/v6 2001:db8:1::2 -6 |
| 159 | 160 | ||
| 160 | cleanup | 161 | cleanup |
| 161 | } | 162 | } |
| @@ -211,12 +211,16 @@ static void test(int *rcv_fd, int len, int family, int proto) · 210 unmodified lines | |||
| 211 | 211 | ||
| 212 | /* Forward iterate */ | 212 | /* Forward iterate */ |
| 213 | for (node = 0; node < len; ++node) { | 213 | for (node = 0; node < len; ++node) { |
| 214 | if (!numa_bitmask_isbitset(numa_nodes_ptr, node)) | ||
| 215 | continue; | ||
| 214 | send_from_node(node, family, proto); | 216 | send_from_node(node, family, proto); |
| 215 | receive_on_node(rcv_fd, len, epfd, node, proto); | 217 | receive_on_node(rcv_fd, len, epfd, node, proto); |
| 216 | } | 218 | } |
| 217 | 219 | ||
| 218 | /* Reverse iterate */ | 220 | /* Reverse iterate */ |
| 219 | for (node = len - 1; node >= 0; --node) { | 221 | for (node = len - 1; node >= 0; --node) { |
| 222 | if (!numa_bitmask_isbitset(numa_nodes_ptr, node)) | ||
| 223 | continue; | ||
| 220 | send_from_node(node, family, proto); | 224 | send_from_node(node, family, proto); |
| 221 | receive_on_node(rcv_fd, len, epfd, node, proto); | 225 | receive_on_node(rcv_fd, len, epfd, node, proto); |
| 222 | } | 226 | } |
| @@ -101,6 +101,8 @@ setup-vm() { · 100 unmodified lines | |||
| 101 | ip -netns hv-$id link set veth-tap master br0 | 101 | ip -netns hv-$id link set veth-tap master br0 |
| 102 | ip -netns hv-$id link set veth-tap up | 102 | ip -netns hv-$id link set veth-tap up |
| 103 | 103 | ||
| 104 | ip link set veth-hv address 02:1d:8d:dd:0c:6$id | ||
| 105 | |||
| 104 | ip link set veth-hv netns vm-$id | 106 | ip link set veth-hv netns vm-$id |
| 105 | ip -netns vm-$id addr add 10.0.0.$id/24 dev veth-hv | 107 | ip -netns vm-$id addr add 10.0.0.$id/24 dev veth-hv |
| 106 | ip -netns vm-$id link set veth-hv up | 108 | ip -netns vm-$id link set veth-hv up |
| @@ -654,7 +654,6 @@ TEST_F(tls, recvmsg_single_max) · 653 unmodified lines | |||
| 654 | TEST_F(tls, recvmsg_multiple) | 654 | TEST_F(tls, recvmsg_multiple) |
| 655 | { | 655 | { |
| 656 | unsigned int msg_iovlen = 1024; | 656 | unsigned int msg_iovlen = 1024; |
| 657 | unsigned int len_compared = 0; | ||
| 658 | struct iovec vec[1024]; | 657 | struct iovec vec[1024]; |
| 659 | char *iov_base[1024]; | 658 | char *iov_base[1024]; |
| 660 | unsigned int iov_len = 16; | 659 | unsigned int iov_len = 16; |
| @@ -675,8 +674,6 @@ TEST_F(tls, recvmsg_multiple) · 14 unmodified lines | |||
| 675 | hdr.msg_iovlen = msg_iovlen; | 674 | hdr.msg_iovlen = msg_iovlen; |
| 676 | hdr.msg_iov = vec; | 675 | hdr.msg_iov = vec; |
| 677 | EXPECT_NE(recvmsg(self->cfd, &hdr, 0), -1); | 676 | EXPECT_NE(recvmsg(self->cfd, &hdr, 0), -1); |
| 678 | for (i = 0; i < msg_iovlen; i++) | ||
| 679 | len_compared += iov_len; | ||
| 680 | 677 | ||
| 681 | for (i = 0; i < msg_iovlen; i++) | 678 | for (i = 0; i < msg_iovlen; i++) |
| 682 | free(iov_base[i]); | 679 | free(iov_base[i]); |
| @@ -293,19 +293,17 @@ static void usage(const char *filepath) · 292 unmodified lines | |||
| 293 | 293 | ||
| 294 | static void parse_opts(int argc, char **argv) | 294 | static void parse_opts(int argc, char **argv) |
| 295 | { | 295 | { |
| 296 | const char *bind_addr = NULL; | ||
| 296 | int c; | 297 | int c; |
| 297 | 298 | ||
| 298 | /* bind to any by default */ | ||
| 299 | setup_sockaddr(PF_INET6, "::", &cfg_bind_addr); | ||
| 300 | while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) { | 299 | while ((c = getopt(argc, argv, "4b:C:Gl:n:p:rR:S:tv")) != -1) { |
| 301 | switch (c) { | 300 | switch (c) { |
| 302 | case '4': | 301 | case '4': |
| 303 | cfg_family = PF_INET; | 302 | cfg_family = PF_INET; |
| 304 | cfg_alen = sizeof(struct sockaddr_in); | 303 | cfg_alen = sizeof(struct sockaddr_in); |
| 305 | setup_sockaddr(PF_INET, "0.0.0.0", &cfg_bind_addr); | ||
| 306 | break; | 304 | break; |
| 307 | case 'b': | 305 | case 'b': |
| 308 | setup_sockaddr(cfg_family, optarg, &cfg_bind_addr); | 306 | bind_addr = optarg; |
| 309 | break; | 307 | break; |
| 310 | case 'C': | 308 | case 'C': |
| 311 | cfg_connect_timeout_ms = strtoul(optarg, NULL, 0); | 309 | cfg_connect_timeout_ms = strtoul(optarg, NULL, 0); |
| @@ -341,6 +339,11 @@ static void parse_opts(int argc, char **argv) · 29 unmodified lines | |||
| 341 | } | 339 | } |
| 342 | } | 340 | } |
| 343 | 341 | ||
| 342 | if (!bind_addr) | ||
| 343 | bind_addr = cfg_family == PF_INET6 ? "::" : "0.0.0.0"; | ||
| 344 | |||
| 345 | setup_sockaddr(cfg_family, bind_addr, &cfg_bind_addr); | ||
| 346 | |||
| 344 | if (optind != argc) | 347 | if (optind != argc) |
| 345 | usage(argv[0]); | 348 | usage(argv[0]); |
| 346 | 349 | ||