Pull networking fixes from David Miller: "Another week, another set of bug fixes: 1) Fix pskb_pull length in __xfrm_transport_prep(), from Xin Long. 2) Fix double xfrm_state put in esp{4,6}_gro_receive(), also from Xin Long. 3) Re-arm discovery timer properly in mac80211 mesh code, from Linus Lüssing. 4) Prevent buffer overflows in nf_conntrack_pptp debug code, from Pablo Neira Ayuso. 5) Fix race in ktls code between tls_sw_recvmsg() and tls_decrypt_done(), from Vinay Kumar Yadav. 6) Fix crashes on TCP fallback in MPTCP code, from Paolo Abeni. 7) More validation is necessary of untrusted GSO packets coming from virtualization devices, from Willem de Bruijn. 8) Fix endianness of bnxt_en firmware message length accesses, from Edwin Peer. 9) Fix infinite loop in sch_fq_pie, from Davide Caratti. 10) Fix lockdep splat in DSA by setting lockless TX in netdev features for slave ports, from Vladimir Oltean. 11) Fix suspend/resume crashes in mlx5, from Mark Bloch. 12) Fix use after free in bpf fmod_ret, from Alexei Starovoitov. 13) ARP retransmit timer guard uses wrong offset, from Hongbin Liu. 14) Fix leak in inetdev_init(), from Yang Yingliang. 15) Don't try to use inet hash and unhash in l2tp code, results in crashes. From Eric Dumazet" * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (77 commits) l2tp: add sk_family checks to l2tp_validate_socket l2tp: do not use inet_hash()/inet_unhash() net: qrtr: Allocate workqueue before kernel_bind mptcp: remove msk from the token container at destruction time. mptcp: fix race between MP_JOIN and close mptcp: fix unblocking connect() net/sched: act_ct: add nat mangle action only for NAT-conntrack devinet: fix memleak in inetdev_init() virtio_vsock: Fix race condition in virtio_transport_recv_pkt drivers/net/ibmvnic: Update VNIC protocol version reporting NFC: st21nfca: add missed kfree_skb() in an error path neigh: fix ARP retransmit timer guard bpf, selftests: Add a verifier test for assigning 32bit reg states to 64bit ones bpf, selftests: Verifier bounds tests need to be updated bpf: Fix a verifier issue when assigning 32bit reg states to 64bit ones bpf: Fix use-after-free in fmod_ret check net/mlx5e: replace EINVAL in mlx5e_flower_parse_meta() net/mlx5e: Fix MLX5_TC_CT dependencies net/mlx5e: Properly set default values when disabling adaptive moderation net/mlx5e: Fix arch depending casting issue in FEC ...
Unified · Split
| @@ -126,6 +126,7 @@ config PPC · 125 unmodified lines | |||
| 126 | select ARCH_HAS_MMIOWB if PPC64 | 126 | select ARCH_HAS_MMIOWB if PPC64 |
| 127 | select ARCH_HAS_PHYS_TO_DMA | 127 | select ARCH_HAS_PHYS_TO_DMA |
| 128 | select ARCH_HAS_PMEM_API | 128 | select ARCH_HAS_PMEM_API |
| 129 | select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE | ||
| 129 | select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 | 130 | select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 |
| 130 | select ARCH_HAS_PTE_SPECIAL | 131 | select ARCH_HAS_PTE_SPECIAL |
| 131 | select ARCH_HAS_MEMBARRIER_CALLBACKS | 132 | select ARCH_HAS_MEMBARRIER_CALLBACKS |
| @@ -682,7 +682,7 @@ int chtls_push_frames(struct chtls_sock *csk, int comp) · 681 unmodified lines | |||
| 682 | make_tx_data_wr(sk, skb, immdlen, len, | 682 | make_tx_data_wr(sk, skb, immdlen, len, |
| 683 | credits_needed, completion); | 683 | credits_needed, completion); |
| 684 | tp->snd_nxt += len; | 684 | tp->snd_nxt += len; |
| 685 | tp->lsndtime = tcp_time_stamp(tp); | 685 | tp->lsndtime = tcp_jiffies32; |
| 686 | if (completion) | 686 | if (completion) |
| 687 | ULP_SKB_CB(skb)->flags &= ~ULPCB_FLAG_NEED_HDR; | 687 | ULP_SKB_CB(skb)->flags &= ~ULPCB_FLAG_NEED_HDR; |
| 688 | } else { | 688 | } else { |
| @@ -149,8 +149,10 @@ int bond_sysfs_slave_add(struct slave *slave) · 148 unmodified lines | |||
| 149 | 149 | ||
| 150 | err = kobject_init_and_add(&slave->kobj, &slave_ktype, | 150 | err = kobject_init_and_add(&slave->kobj, &slave_ktype, |
| 151 | &(slave->dev->dev.kobj), "bonding_slave"); | 151 | &(slave->dev->dev.kobj), "bonding_slave"); |
| 152 | if (err) | 152 | if (err) { |
| 153 | kobject_put(&slave->kobj); | ||
| 153 | return err; | 154 | return err; |
| 155 | } | ||
| 154 | 156 | ||
| 155 | for (a = slave_attrs; *a; ++a) { | 157 | for (a = slave_attrs; *a; ++a) { |
| 156 | err = sysfs_create_file(&slave->kobj, &((*a)->attr)); | 158 | err = sysfs_create_file(&slave->kobj, &((*a)->attr)); |
| @@ -102,13 +102,17 @@ static void felix_vlan_add(struct dsa_switch *ds, int port, · 101 unmodified lines | |||
| 102 | const struct switchdev_obj_port_vlan *vlan) | 102 | const struct switchdev_obj_port_vlan *vlan) |
| 103 | { | 103 | { |
| 104 | struct ocelot *ocelot = ds->priv; | 104 | struct ocelot *ocelot = ds->priv; |
| 105 | u16 flags = vlan->flags; | ||
| 105 | u16 vid; | 106 | u16 vid; |
| 106 | int err; | 107 | int err; |
| 107 | 108 | ||
| 109 | if (dsa_is_cpu_port(ds, port)) | ||
| 110 | flags &= ~BRIDGE_VLAN_INFO_UNTAGGED; | ||
| 111 | |||
| 108 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { | 112 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { |
| 109 | err = ocelot_vlan_add(ocelot, port, vid, | 113 | err = ocelot_vlan_add(ocelot, port, vid, |
| 110 | vlan->flags & BRIDGE_VLAN_INFO_PVID, | 114 | flags & BRIDGE_VLAN_INFO_PVID, |
| 111 | vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED); | 115 | flags & BRIDGE_VLAN_INFO_UNTAGGED); |
| 112 | if (err) { | 116 | if (err) { |
| 113 | dev_err(ds->dev, "Failed to add VLAN %d to port %d: %d\n", | 117 | dev_err(ds->dev, "Failed to add VLAN %d to port %d: %d\n", |
| 114 | vid, port, err); | 118 | vid, port, err); |
| @@ -4176,14 +4176,12 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, · 4175 unmodified lines | |||
| 4176 | int i, intr_process, rc, tmo_count; | 4176 | int i, intr_process, rc, tmo_count; |
| 4177 | struct input *req = msg; | 4177 | struct input *req = msg; |
| 4178 | u32 *data = msg; | 4178 | u32 *data = msg; |
| 4179 | __le32 *resp_len; | ||
| 4180 | u8 *valid; | 4179 | u8 *valid; |
| 4181 | u16 cp_ring_id, len = 0; | 4180 | u16 cp_ring_id, len = 0; |
| 4182 | struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr; | 4181 | struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr; |
| 4183 | u16 max_req_len = BNXT_HWRM_MAX_REQ_LEN; | 4182 | u16 max_req_len = BNXT_HWRM_MAX_REQ_LEN; |
| 4184 | struct hwrm_short_input short_input = {0}; | 4183 | struct hwrm_short_input short_input = {0}; |
| 4185 | u32 doorbell_offset = BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER; | 4184 | u32 doorbell_offset = BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER; |
| 4186 | u8 *resp_addr = (u8 *)bp->hwrm_cmd_resp_addr; | ||
| 4187 | u32 bar_offset = BNXT_GRCPF_REG_CHIMP_COMM; | 4185 | u32 bar_offset = BNXT_GRCPF_REG_CHIMP_COMM; |
| 4188 | u16 dst = BNXT_HWRM_CHNL_CHIMP; | 4186 | u16 dst = BNXT_HWRM_CHNL_CHIMP; |
| 4189 | 4187 | ||
| @@ -4201,7 +4199,6 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, · 11 unmodified lines | |||
| 4201 | bar_offset = BNXT_GRCPF_REG_KONG_COMM; | 4199 | bar_offset = BNXT_GRCPF_REG_KONG_COMM; |
| 4202 | doorbell_offset = BNXT_GRCPF_REG_KONG_COMM_TRIGGER; | 4200 | doorbell_offset = BNXT_GRCPF_REG_KONG_COMM_TRIGGER; |
| 4203 | resp = bp->hwrm_cmd_kong_resp_addr; | 4201 | resp = bp->hwrm_cmd_kong_resp_addr; |
| 4204 | resp_addr = (u8 *)bp->hwrm_cmd_kong_resp_addr; | ||
| 4205 | } | 4202 | } |
| 4206 | 4203 | ||
| 4207 | memset(resp, 0, PAGE_SIZE); | 4204 | memset(resp, 0, PAGE_SIZE); |
| @@ -4270,7 +4267,6 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, · 62 unmodified lines | |||
| 4270 | tmo_count = HWRM_SHORT_TIMEOUT_COUNTER; | 4267 | tmo_count = HWRM_SHORT_TIMEOUT_COUNTER; |
| 4271 | timeout = timeout - HWRM_SHORT_MIN_TIMEOUT * HWRM_SHORT_TIMEOUT_COUNTER; | 4268 | timeout = timeout - HWRM_SHORT_MIN_TIMEOUT * HWRM_SHORT_TIMEOUT_COUNTER; |
| 4272 | tmo_count += DIV_ROUND_UP(timeout, HWRM_MIN_TIMEOUT); | 4269 | tmo_count += DIV_ROUND_UP(timeout, HWRM_MIN_TIMEOUT); |
| 4273 | resp_len = (__le32 *)(resp_addr + HWRM_RESP_LEN_OFFSET); | ||
| 4274 | 4270 | ||
| 4275 | if (intr_process) { | 4271 | if (intr_process) { |
| 4276 | u16 seq_id = bp->hwrm_intr_seq_id; | 4272 | u16 seq_id = bp->hwrm_intr_seq_id; |
| @@ -4298,9 +4294,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, · 21 unmodified lines | |||
| 4298 | le16_to_cpu(req->req_type)); | 4294 | le16_to_cpu(req->req_type)); |
| 4299 | return -EBUSY; | 4295 | return -EBUSY; |
| 4300 | } | 4296 | } |
| 4301 | len = (le32_to_cpu(*resp_len) & HWRM_RESP_LEN_MASK) >> | 4297 | len = le16_to_cpu(resp->resp_len); |
| 4302 | HWRM_RESP_LEN_SFT; | 4298 | valid = ((u8 *)resp) + len - 1; |
| 4303 | valid = resp_addr + len - 1; | ||
| 4304 | } else { | 4299 | } else { |
| 4305 | int j; | 4300 | int j; |
| 4306 | 4301 | ||
| @@ -4311,8 +4306,7 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, · 4 unmodified lines | |||
| 4311 | */ | 4306 | */ |
| 4312 | if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) | 4307 | if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) |
| 4313 | return -EBUSY; | 4308 | return -EBUSY; |
| 4314 | len = (le32_to_cpu(*resp_len) & HWRM_RESP_LEN_MASK) >> | 4309 | len = le16_to_cpu(resp->resp_len); |
| 4315 | HWRM_RESP_LEN_SFT; | ||
| 4316 | if (len) | 4310 | if (len) |
| 4317 | break; | 4311 | break; |
| 4318 | /* on first few passes, just barely sleep */ | 4312 | /* on first few passes, just barely sleep */ |
| @@ -4334,7 +4328,7 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len, · 15 unmodified lines | |||
| 4334 | } | 4328 | } |
| 4335 | 4329 | ||
| 4336 | /* Last byte of resp contains valid bit */ | 4330 | /* Last byte of resp contains valid bit */ |
| 4337 | valid = resp_addr + len - 1; | 4331 | valid = ((u8 *)resp) + len - 1; |
| 4338 | for (j = 0; j < HWRM_VALID_BIT_DELAY_USEC; j++) { | 4332 | for (j = 0; j < HWRM_VALID_BIT_DELAY_USEC; j++) { |
| 4339 | /* make sure we read from updated DMA memory */ | 4333 | /* make sure we read from updated DMA memory */ |
| 4340 | dma_rmb(); | 4334 | dma_rmb(); |
| @@ -9310,7 +9304,7 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init, · 4969 unmodified lines | |||
| 9310 | bnxt_free_skbs(bp); | 9304 | bnxt_free_skbs(bp); |
| 9311 | 9305 | ||
| 9312 | /* Save ring stats before shutdown */ | 9306 | /* Save ring stats before shutdown */ |
| 9313 | if (bp->bnapi) | 9307 | if (bp->bnapi && irq_re_init) |
| 9314 | bnxt_get_ring_stats(bp, &bp->net_stats_prev); | 9308 | bnxt_get_ring_stats(bp, &bp->net_stats_prev); |
| 9315 | if (irq_re_init) { | 9309 | if (irq_re_init) { |
| 9316 | bnxt_free_irq(bp); | 9310 | bnxt_free_irq(bp); |
| @@ -656,11 +656,6 @@ struct nqe_cn { · 655 unmodified lines | |||
| 656 | #define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout) | 656 | #define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout) |
| 657 | #define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4) | 657 | #define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4) |
| 658 | #define HWRM_COREDUMP_TIMEOUT ((HWRM_CMD_TIMEOUT) * 12) | 658 | #define HWRM_COREDUMP_TIMEOUT ((HWRM_CMD_TIMEOUT) * 12) |
| 659 | #define HWRM_RESP_ERR_CODE_MASK 0xffff | ||
| 660 | #define HWRM_RESP_LEN_OFFSET 4 | ||
| 661 | #define HWRM_RESP_LEN_MASK 0xffff0000 | ||
| 662 | #define HWRM_RESP_LEN_SFT 16 | ||
| 663 | #define HWRM_RESP_VALID_MASK 0xff000000 | ||
| 664 | #define BNXT_HWRM_REQ_MAX_SIZE 128 | 659 | #define BNXT_HWRM_REQ_MAX_SIZE 128 |
| 665 | #define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \ | 660 | #define BNXT_HWRM_REQS_PER_PAGE (BNXT_PAGE_SIZE / \ |
| 666 | BNXT_HWRM_REQ_MAX_SIZE) | 661 | BNXT_HWRM_REQ_MAX_SIZE) |
| @@ -2012,11 +2012,12 @@ int bnxt_flash_package_from_file(struct net_device *dev, const char *filename, · 2011 unmodified lines | |||
| 2012 | 2012 | ||
| 2013 | bnxt_hwrm_fw_set_time(bp); | 2013 | bnxt_hwrm_fw_set_time(bp); |
| 2014 | 2014 | ||
| 2015 | if (bnxt_find_nvram_item(dev, BNX_DIR_TYPE_UPDATE, | 2015 | rc = bnxt_find_nvram_item(dev, BNX_DIR_TYPE_UPDATE, |
| 2016 | BNX_DIR_ORDINAL_FIRST, BNX_DIR_EXT_NONE, | 2016 | BNX_DIR_ORDINAL_FIRST, BNX_DIR_EXT_NONE, |
| 2017 | &index, &item_len, NULL) != 0) { | 2017 | &index, &item_len, NULL); |
| 2018 | if (rc) { | ||
| 2018 | netdev_err(dev, "PKG update area not created in nvram\n"); | 2019 | netdev_err(dev, "PKG update area not created in nvram\n"); |
| 2019 | return -ENOBUFS; | 2020 | return rc; |
| 2020 | } | 2021 | } |
| 2021 | 2022 | ||
| 2022 | rc = request_firmware(&fw, filename, &dev->dev); | 2023 | rc = request_firmware(&fw, filename, &dev->dev); |
| @@ -2914,7 +2914,7 @@ static int dpaa_eth_probe(struct platform_device *pdev) · 2913 unmodified lines | |||
| 2914 | } | 2914 | } |
| 2915 | 2915 | ||
| 2916 | /* Do this here, so we can be verbose early */ | 2916 | /* Do this here, so we can be verbose early */ |
| 2917 | SET_NETDEV_DEV(net_dev, dev); | 2917 | SET_NETDEV_DEV(net_dev, dev->parent); |
| 2918 | dev_set_drvdata(dev, net_dev); | 2918 | dev_set_drvdata(dev, net_dev); |
| 2919 | 2919 | ||
| 2920 | priv = netdev_priv(net_dev); | 2920 | priv = netdev_priv(net_dev); |
| @@ -4678,12 +4678,10 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq, · 4677 unmodified lines | |||
| 4678 | dev_err(dev, "Error %ld in VERSION_EXCHG_RSP\n", rc); | 4678 | dev_err(dev, "Error %ld in VERSION_EXCHG_RSP\n", rc); |
| 4679 | break; | 4679 | break; |
| 4680 | } | 4680 | } |
| 4681 | dev_info(dev, "Partner protocol version is %d\n", | 4681 | ibmvnic_version = |
| 4682 | crq->version_exchange_rsp.version); | ||
| 4683 | if (be16_to_cpu(crq->version_exchange_rsp.version) < | ||
| 4684 | ibmvnic_version) | ||
| 4685 | ibmvnic_version = | ||
| 4686 | be16_to_cpu(crq->version_exchange_rsp.version); | 4682 | be16_to_cpu(crq->version_exchange_rsp.version); |
| 4683 | dev_info(dev, "Partner protocol version is %d\n", | ||
| 4684 | ibmvnic_version); | ||
| 4687 | send_cap_queries(adapter); | 4685 | send_cap_queries(adapter); |
| 4688 | break; | 4686 | break; |
| 4689 | case QUERY_CAPABILITY_RSP: | 4687 | case QUERY_CAPABILITY_RSP: |
| @@ -80,7 +80,7 @@ config MLX5_ESWITCH · 79 unmodified lines | |||
| 80 | 80 | ||
| 81 | config MLX5_TC_CT | 81 | config MLX5_TC_CT |
| 82 | bool "MLX5 TC connection tracking offload support" | 82 | bool "MLX5 TC connection tracking offload support" |
| 83 | depends on MLX5_CORE_EN && NET_SWITCHDEV && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT | 83 | depends on MLX5_ESWITCH && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT |
| 84 | default y | 84 | default y |
| 85 | help | 85 | help |
| 86 | Say Y here if you want to support offloading connection tracking rules | 86 | Say Y here if you want to support offloading connection tracking rules |
| @@ -1068,10 +1068,12 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv); · 1067 unmodified lines | |||
| 1068 | 1068 | ||
| 1069 | void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len, | 1069 | void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len, |
| 1070 | int num_channels); | 1070 | int num_channels); |
| 1071 | void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, | 1071 | |
| 1072 | u8 cq_period_mode); | 1072 | void mlx5e_reset_tx_moderation(struct mlx5e_params *params, u8 cq_period_mode); |
| 1073 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, | 1073 | void mlx5e_reset_rx_moderation(struct mlx5e_params *params, u8 cq_period_mode); |
| 1074 | u8 cq_period_mode); | 1074 | void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode); |
| 1075 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode); | ||
| 1076 | |||
| 1075 | void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params); | 1077 | void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params); |
| 1076 | void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, | 1078 | void mlx5e_init_rq_type_params(struct mlx5_core_dev *mdev, |
| 1077 | struct mlx5e_params *params); | 1079 | struct mlx5e_params *params); |
| @@ -369,17 +369,19 @@ enum mlx5e_fec_supported_link_mode { · 368 unmodified lines | |||
| 369 | *_policy = MLX5_GET(pplm_reg, _buf, fec_override_admin_##link); \ | 369 | *_policy = MLX5_GET(pplm_reg, _buf, fec_override_admin_##link); \ |
| 370 | } while (0) | 370 | } while (0) |
| 371 | 371 | ||
| 372 | #define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link) \ | 372 | #define MLX5E_FEC_OVERRIDE_ADMIN_50G_POLICY(buf, policy, write, link) \ |
| 373 | do { \ | 373 | do { \ |
| 374 | u16 *__policy = &(policy); \ | 374 | unsigned long policy_long; \ |
| 375 | bool _write = (write); \ | 375 | u16 *__policy = &(policy); \ |
| 376 | \ | 376 | bool _write = (write); \ |
| 377 | if (_write && *__policy) \ | 377 | \ |
| 378 | *__policy = find_first_bit((u_long *)__policy, \ | 378 | policy_long = *__policy; \ |
| 379 | sizeof(u16) * BITS_PER_BYTE);\ | 379 | if (_write && *__policy) \ |
| 380 | MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link); \ | 380 | *__policy = find_first_bit(&policy_long, \ |
| 381 | if (!_write && *__policy) \ | 381 | sizeof(policy_long) * BITS_PER_BYTE);\ |
| 382 | *__policy = 1 << *__policy; \ | 382 | MLX5E_FEC_OVERRIDE_ADMIN_POLICY(buf, *__policy, _write, link); \ |
| 383 | if (!_write && *__policy) \ | ||
| 384 | *__policy = 1 << *__policy; \ | ||
| 383 | } while (0) | 385 | } while (0) |
| 384 | 386 | ||
| 385 | /* get/set FEC admin field for a given speed */ | 387 | /* get/set FEC admin field for a given speed */ |
| @@ -527,8 +527,8 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, · 526 unmodified lines | |||
| 527 | struct dim_cq_moder *rx_moder, *tx_moder; | 527 | struct dim_cq_moder *rx_moder, *tx_moder; |
| 528 | struct mlx5_core_dev *mdev = priv->mdev; | 528 | struct mlx5_core_dev *mdev = priv->mdev; |
| 529 | struct mlx5e_channels new_channels = {}; | 529 | struct mlx5e_channels new_channels = {}; |
| 530 | bool reset_rx, reset_tx; | ||
| 530 | int err = 0; | 531 | int err = 0; |
| 531 | bool reset; | ||
| 532 | 532 | ||
| 533 | if (!MLX5_CAP_GEN(mdev, cq_moderation)) | 533 | if (!MLX5_CAP_GEN(mdev, cq_moderation)) |
| 534 | return -EOPNOTSUPP; | 534 | return -EOPNOTSUPP; |
| @@ -566,15 +566,28 @@ int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, · 31 unmodified lines | |||
| 566 | } | 566 | } |
| 567 | /* we are opened */ | 567 | /* we are opened */ |
| 568 | 568 | ||
| 569 | reset = (!!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled) || | 569 | reset_rx = !!coal->use_adaptive_rx_coalesce != priv->channels.params.rx_dim_enabled; |
| 570 | (!!coal->use_adaptive_tx_coalesce != priv->channels.params.tx_dim_enabled); | 570 | reset_tx = !!coal->use_adaptive_tx_coalesce != priv->channels.params.tx_dim_enabled; |
| 571 | 571 | ||
| 572 | if (!reset) { | 572 | if (!reset_rx && !reset_tx) { |
| 573 | mlx5e_set_priv_channels_coalesce(priv, coal); | 573 | mlx5e_set_priv_channels_coalesce(priv, coal); |
| 574 | priv->channels.params = new_channels.params; | 574 | priv->channels.params = new_channels.params; |
| 575 | goto out; | 575 | goto out; |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | if (reset_rx) { | ||
| 579 | u8 mode = MLX5E_GET_PFLAG(&new_channels.params, | ||
| 580 | MLX5E_PFLAG_RX_CQE_BASED_MODER); | ||
| 581 | |||
| 582 | mlx5e_reset_rx_moderation(&new_channels.params, mode); | ||
| 583 | } | ||
| 584 | if (reset_tx) { | ||
| 585 | u8 mode = MLX5E_GET_PFLAG(&new_channels.params, | ||
| 586 | MLX5E_PFLAG_TX_CQE_BASED_MODER); | ||
| 587 | |||
| 588 | mlx5e_reset_tx_moderation(&new_channels.params, mode); | ||
| 589 | } | ||
| 590 | |||
| 578 | err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); | 591 | err = mlx5e_safe_switch_channels(priv, &new_channels, NULL, NULL); |
| 579 | 592 | ||
| 580 | out: | 593 | out: |
| @@ -665,11 +678,12 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = { · 84 unmodified lines | |||
| 665 | static int get_fec_supported_advertised(struct mlx5_core_dev *dev, | 678 | static int get_fec_supported_advertised(struct mlx5_core_dev *dev, |
| 666 | struct ethtool_link_ksettings *link_ksettings) | 679 | struct ethtool_link_ksettings *link_ksettings) |
| 667 | { | 680 | { |
| 668 | u_long active_fec = 0; | 681 | unsigned long active_fec_long; |
| 682 | u32 active_fec; | ||
| 669 | u32 bitn; | 683 | u32 bitn; |
| 670 | int err; | 684 | int err; |
| 671 | 685 | ||
| 672 | err = mlx5e_get_fec_mode(dev, (u32 *)&active_fec, NULL); | 686 | err = mlx5e_get_fec_mode(dev, &active_fec, NULL); |
| 673 | if (err) | 687 | if (err) |
| 674 | return (err == -EOPNOTSUPP) ? 0 : err; | 688 | return (err == -EOPNOTSUPP) ? 0 : err; |
| 675 | 689 | ||
| @@ -682,10 +696,11 @@ static int get_fec_supported_advertised(struct mlx5_core_dev *dev, · 6 unmodified lines | |||
| 682 | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1, | 696 | MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1, |
| 683 | ETHTOOL_LINK_MODE_FEC_LLRS_BIT); | 697 | ETHTOOL_LINK_MODE_FEC_LLRS_BIT); |
| 684 | 698 | ||
| 699 | active_fec_long = active_fec; | ||
| 685 | /* active fec is a bit set, find out which bit is set and | 700 | /* active fec is a bit set, find out which bit is set and |
| 686 | * advertise the corresponding ethtool bit | 701 | * advertise the corresponding ethtool bit |
| 687 | */ | 702 | */ |
| 688 | bitn = find_first_bit(&active_fec, sizeof(u32) * BITS_PER_BYTE); | 703 | bitn = find_first_bit(&active_fec_long, sizeof(active_fec_long) * BITS_PER_BYTE); |
| 689 | if (bitn < ARRAY_SIZE(pplm_fec_2_ethtool_linkmodes)) | 704 | if (bitn < ARRAY_SIZE(pplm_fec_2_ethtool_linkmodes)) |
| 690 | __set_bit(pplm_fec_2_ethtool_linkmodes[bitn], | 705 | __set_bit(pplm_fec_2_ethtool_linkmodes[bitn], |
| 691 | link_ksettings->link_modes.advertising); | 706 | link_ksettings->link_modes.advertising); |
| @@ -1517,8 +1532,8 @@ static int mlx5e_get_fecparam(struct net_device *netdev, · 825 unmodified lines | |||
| 1517 | { | 1532 | { |
| 1518 | struct mlx5e_priv *priv = netdev_priv(netdev); | 1533 | struct mlx5e_priv *priv = netdev_priv(netdev); |
| 1519 | struct mlx5_core_dev *mdev = priv->mdev; | 1534 | struct mlx5_core_dev *mdev = priv->mdev; |
| 1520 | u16 fec_configured = 0; | 1535 | u16 fec_configured; |
| 1521 | u32 fec_active = 0; | 1536 | u32 fec_active; |
| 1522 | int err; | 1537 | int err; |
| 1523 | 1538 | ||
| 1524 | err = mlx5e_get_fec_mode(mdev, &fec_active, &fec_configured); | 1539 | err = mlx5e_get_fec_mode(mdev, &fec_active, &fec_configured); |
| @@ -1526,14 +1541,14 @@ static int mlx5e_get_fecparam(struct net_device *netdev, · 1 unmodified line | |||
| 1526 | if (err) | 1541 | if (err) |
| 1527 | return err; | 1542 | return err; |
| 1528 | 1543 | ||
| 1529 | fecparam->active_fec = pplm2ethtool_fec((u_long)fec_active, | 1544 | fecparam->active_fec = pplm2ethtool_fec((unsigned long)fec_active, |
| 1530 | sizeof(u32) * BITS_PER_BYTE); | 1545 | sizeof(unsigned long) * BITS_PER_BYTE); |
| 1531 | 1546 | ||
| 1532 | if (!fecparam->active_fec) | 1547 | if (!fecparam->active_fec) |
| 1533 | return -EOPNOTSUPP; | 1548 | return -EOPNOTSUPP; |
| 1534 | 1549 | ||
| 1535 | fecparam->fec = pplm2ethtool_fec((u_long)fec_configured, | 1550 | fecparam->fec = pplm2ethtool_fec((unsigned long)fec_configured, |
| 1536 | sizeof(u16) * BITS_PER_BYTE); | 1551 | sizeof(unsigned long) * BITS_PER_BYTE); |
| 1537 | 1552 | ||
| 1538 | return 0; | 1553 | return 0; |
| 1539 | } | 1554 | } |
| @@ -4716,7 +4716,7 @@ static u8 mlx5_to_net_dim_cq_period_mode(u8 cq_period_mode) · 4715 unmodified lines | |||
| 4716 | DIM_CQ_PERIOD_MODE_START_FROM_EQE; | 4716 | DIM_CQ_PERIOD_MODE_START_FROM_EQE; |
| 4717 | } | 4717 | } |
| 4718 | 4718 | ||
| 4719 | void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) | 4719 | void mlx5e_reset_tx_moderation(struct mlx5e_params *params, u8 cq_period_mode) |
| 4720 | { | 4720 | { |
| 4721 | if (params->tx_dim_enabled) { | 4721 | if (params->tx_dim_enabled) { |
| 4722 | u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode); | 4722 | u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode); |
| @@ -4725,13 +4725,9 @@ void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) · 2 unmodified lines | |||
| 4725 | } else { | 4725 | } else { |
| 4726 | params->tx_cq_moderation = mlx5e_get_def_tx_moderation(cq_period_mode); | 4726 | params->tx_cq_moderation = mlx5e_get_def_tx_moderation(cq_period_mode); |
| 4727 | } | 4727 | } |
| 4728 | |||
| 4729 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_TX_CQE_BASED_MODER, | ||
| 4730 | params->tx_cq_moderation.cq_period_mode == | ||
| 4731 | MLX5_CQ_PERIOD_MODE_START_FROM_CQE); | ||
| 4732 | } | 4728 | } |
| 4733 | 4729 | ||
| 4734 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) | 4730 | void mlx5e_reset_rx_moderation(struct mlx5e_params *params, u8 cq_period_mode) |
| 4735 | { | 4731 | { |
| 4736 | if (params->rx_dim_enabled) { | 4732 | if (params->rx_dim_enabled) { |
| 4737 | u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode); | 4733 | u8 dim_period_mode = mlx5_to_net_dim_cq_period_mode(cq_period_mode); |
| @@ -4740,7 +4736,19 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) · 2 unmodified lines | |||
| 4740 | } else { | 4736 | } else { |
| 4741 | params->rx_cq_moderation = mlx5e_get_def_rx_moderation(cq_period_mode); | 4737 | params->rx_cq_moderation = mlx5e_get_def_rx_moderation(cq_period_mode); |
| 4742 | } | 4738 | } |
| 4739 | } | ||
| 4740 | |||
| 4741 | void mlx5e_set_tx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) | ||
| 4742 | { | ||
| 4743 | mlx5e_reset_tx_moderation(params, cq_period_mode); | ||
| 4744 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_TX_CQE_BASED_MODER, | ||
| 4745 | params->tx_cq_moderation.cq_period_mode == | ||
| 4746 | MLX5_CQ_PERIOD_MODE_START_FROM_CQE); | ||
| 4747 | } | ||
| 4743 | 4748 | ||
| 4749 | void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode) | ||
| 4750 | { | ||
| 4751 | mlx5e_reset_rx_moderation(params, cq_period_mode); | ||
| 4744 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_BASED_MODER, | 4752 | MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_BASED_MODER, |
| 4745 | params->rx_cq_moderation.cq_period_mode == | 4753 | params->rx_cq_moderation.cq_period_mode == |
| 4746 | MLX5_CQ_PERIOD_MODE_START_FROM_CQE); | 4754 | MLX5_CQ_PERIOD_MODE_START_FROM_CQE); |
| @@ -2068,7 +2068,7 @@ static int mlx5e_flower_parse_meta(struct net_device *filter_dev, · 2067 unmodified lines | |||
| 2068 | flow_rule_match_meta(rule, &match); | 2068 | flow_rule_match_meta(rule, &match); |
| 2069 | if (match.mask->ingress_ifindex != 0xFFFFFFFF) { | 2069 | if (match.mask->ingress_ifindex != 0xFFFFFFFF) { |
| 2070 | NL_SET_ERR_MSG_MOD(extack, "Unsupported ingress ifindex mask"); | 2070 | NL_SET_ERR_MSG_MOD(extack, "Unsupported ingress ifindex mask"); |
| 2071 | return -EINVAL; | 2071 | return -EOPNOTSUPP; |
| 2072 | } | 2072 | } |
| 2073 | 2073 | ||
| 2074 | ingress_dev = __dev_get_by_index(dev_net(filter_dev), | 2074 | ingress_dev = __dev_get_by_index(dev_net(filter_dev), |
| @@ -2076,13 +2076,13 @@ static int mlx5e_flower_parse_meta(struct net_device *filter_dev, · 1 unmodified line | |||
| 2076 | if (!ingress_dev) { | 2076 | if (!ingress_dev) { |
| 2077 | NL_SET_ERR_MSG_MOD(extack, | 2077 | NL_SET_ERR_MSG_MOD(extack, |
| 2078 | "Can't find the ingress port to match on"); | 2078 | "Can't find the ingress port to match on"); |
| 2079 | return -EINVAL; | 2079 | return -ENOENT; |
| 2080 | } | 2080 | } |
| 2081 | 2081 | ||
| 2082 | if (ingress_dev != filter_dev) { | 2082 | if (ingress_dev != filter_dev) { |
| 2083 | NL_SET_ERR_MSG_MOD(extack, | 2083 | NL_SET_ERR_MSG_MOD(extack, |
| 2084 | "Can't match on the ingress filter port"); | 2084 | "Can't match on the ingress filter port"); |
| 2085 | return -EINVAL; | 2085 | return -EOPNOTSUPP; |
| 2086 | } | 2086 | } |
| 2087 | 2087 | ||
| 2088 | return 0; | 2088 | return 0; |
| @@ -3849,10 +3849,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, · 1760 unmodified lines | |||
| 3849 | if (!mlx5e_is_valid_eswitch_fwd_dev(priv, out_dev)) { | 3849 | if (!mlx5e_is_valid_eswitch_fwd_dev(priv, out_dev)) { |
| 3850 | NL_SET_ERR_MSG_MOD(extack, | 3850 | NL_SET_ERR_MSG_MOD(extack, |
| 3851 | "devices are not on same switch HW, can't offload forwarding"); | 3851 | "devices are not on same switch HW, can't offload forwarding"); |
| 3852 | netdev_warn(priv->netdev, | ||
| 3853 | "devices %s %s not on same switch HW, can't offload forwarding\n", | ||
| 3854 | priv->netdev->name, | ||
| 3855 | out_dev->name); | ||
| 3856 | return -EOPNOTSUPP; | 3852 | return -EOPNOTSUPP; |
| 3857 | } | 3853 | } |
| 3858 | 3854 | ||
| @@ -4614,7 +4610,7 @@ void mlx5e_tc_stats_matchall(struct mlx5e_priv *priv, · 755 unmodified lines | |||
| 4614 | dpkts = cur_stats.rx_packets - rpriv->prev_vf_vport_stats.rx_packets; | 4610 | dpkts = cur_stats.rx_packets - rpriv->prev_vf_vport_stats.rx_packets; |
| 4615 | dbytes = cur_stats.rx_bytes - rpriv->prev_vf_vport_stats.rx_bytes; | 4611 | dbytes = cur_stats.rx_bytes - rpriv->prev_vf_vport_stats.rx_bytes; |
| 4616 | rpriv->prev_vf_vport_stats = cur_stats; | 4612 | rpriv->prev_vf_vport_stats = cur_stats; |
| 4617 | flow_stats_update(&ma->stats, dpkts, dbytes, jiffies, | 4613 | flow_stats_update(&ma->stats, dbytes, dpkts, jiffies, |
| 4618 | FLOW_ACTION_HW_STATS_DELAYED); | 4614 | FLOW_ACTION_HW_STATS_DELAYED); |
| 4619 | } | 4615 | } |
| 4620 | 4616 | ||
| @@ -1549,6 +1549,22 @@ static void shutdown(struct pci_dev *pdev) · 1548 unmodified lines | |||
| 1549 | mlx5_pci_disable_device(dev); | 1549 | mlx5_pci_disable_device(dev); |
| 1550 | } | 1550 | } |
| 1551 | 1551 | ||
| 1552 | static int mlx5_suspend(struct pci_dev *pdev, pm_message_t state) | ||
| 1553 | { | ||
| 1554 | struct mlx5_core_dev *dev = pci_get_drvdata(pdev); | ||
| 1555 | |||
| 1556 | mlx5_unload_one(dev, false); | ||
| 1557 | |||
| 1558 | return 0; | ||
| 1559 | } | ||
| 1560 | |||
| 1561 | static int mlx5_resume(struct pci_dev *pdev) | ||
| 1562 | { | ||
| 1563 | struct mlx5_core_dev *dev = pci_get_drvdata(pdev); | ||
| 1564 | |||
| 1565 | return mlx5_load_one(dev, false); | ||
| 1566 | } | ||
| 1567 | |||
| 1552 | static const struct pci_device_id mlx5_core_pci_table[] = { | 1568 | static const struct pci_device_id mlx5_core_pci_table[] = { |
| 1553 | { PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_CONNECTIB) }, | 1569 | { PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_CONNECTIB) }, |
| 1554 | { PCI_VDEVICE(MELLANOX, 0x1012), MLX5_PCI_DEV_IS_VF}, /* Connect-IB VF */ | 1570 | { PCI_VDEVICE(MELLANOX, 0x1012), MLX5_PCI_DEV_IS_VF}, /* Connect-IB VF */ |
| @@ -1592,6 +1608,8 @@ static struct pci_driver mlx5_core_driver = { · 37 unmodified lines | |||
| 1592 | .id_table = mlx5_core_pci_table, | 1608 | .id_table = mlx5_core_pci_table, |
| 1593 | .probe = init_one, | 1609 | .probe = init_one, |
| 1594 | .remove = remove_one, | 1610 | .remove = remove_one, |
| 1611 | .suspend = mlx5_suspend, | ||
| 1612 | .resume = mlx5_resume, | ||
| 1595 | .shutdown = shutdown, | 1613 | .shutdown = shutdown, |
| 1596 | .err_handler = &mlx5_err_handler, | 1614 | .err_handler = &mlx5_err_handler, |
| 1597 | .sriov_configure = mlx5_core_sriov_configure, | 1615 | .sriov_configure = mlx5_core_sriov_configure, |
| @@ -1440,7 +1440,8 @@ __nfp_flower_update_merge_stats(struct nfp_app *app, · 1439 unmodified lines | |||
| 1440 | ctx_id = be32_to_cpu(sub_flow->meta.host_ctx_id); | 1440 | ctx_id = be32_to_cpu(sub_flow->meta.host_ctx_id); |
| 1441 | priv->stats[ctx_id].pkts += pkts; | 1441 | priv->stats[ctx_id].pkts += pkts; |
| 1442 | priv->stats[ctx_id].bytes += bytes; | 1442 | priv->stats[ctx_id].bytes += bytes; |
| 1443 | max_t(u64, priv->stats[ctx_id].used, used); | 1443 | priv->stats[ctx_id].used = max_t(u64, used, |
| 1444 | priv->stats[ctx_id].used); | ||
| 1444 | } | 1445 | } |
| 1445 | } | 1446 | } |
| 1446 | 1447 | ||
| @@ -3651,7 +3651,7 @@ int qlcnic_83xx_interrupt_test(struct net_device *netdev) · 3650 unmodified lines | |||
| 3651 | ahw->diag_cnt = 0; | 3651 | ahw->diag_cnt = 0; |
| 3652 | ret = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_INTRPT_TEST); | 3652 | ret = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_INTRPT_TEST); |
| 3653 | if (ret) | 3653 | if (ret) |
| 3654 | goto fail_diag_irq; | 3654 | goto fail_mbx_args; |
| 3655 | 3655 | ||
| 3656 | if (adapter->flags & QLCNIC_MSIX_ENABLED) | 3656 | if (adapter->flags & QLCNIC_MSIX_ENABLED) |
| 3657 | intrpt_id = ahw->intr_tbl[0].id; | 3657 | intrpt_id = ahw->intr_tbl[0].id; |
| @@ -3681,6 +3681,8 @@ int qlcnic_83xx_interrupt_test(struct net_device *netdev) · 23 unmodified lines | |||
| 3681 | 3681 | ||
| 3682 | done: | 3682 | done: |
| 3683 | qlcnic_free_mbx_args(&cmd); | 3683 | qlcnic_free_mbx_args(&cmd); |
| 3684 | |||
| 3685 | fail_mbx_args: | ||
| 3684 | qlcnic_83xx_diag_free_res(netdev, drv_sds_rings); | 3686 | qlcnic_83xx_diag_free_res(netdev, drv_sds_rings); |
| 3685 | 3687 | ||
| 3686 | fail_diag_irq: | 3688 | fail_diag_irq: |
| @@ -630,7 +630,8 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) · 629 unmodified lines | |||
| 630 | config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; | 630 | config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; |
| 631 | ptp_v2 = PTP_TCR_TSVER2ENA; | 631 | ptp_v2 = PTP_TCR_TSVER2ENA; |
| 632 | snap_type_sel = PTP_TCR_SNAPTYPSEL_1; | 632 | snap_type_sel = PTP_TCR_SNAPTYPSEL_1; |
| 633 | ts_event_en = PTP_TCR_TSEVNTENA; | 633 | if (priv->synopsys_id != DWMAC_CORE_5_10) |
| 634 | ts_event_en = PTP_TCR_TSEVNTENA; | ||
| 634 | ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; | 635 | ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; |
| 635 | ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; | 636 | ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; |
| 636 | ptp_over_ethernet = PTP_TCR_TSIPENA; | 637 | ptp_over_ethernet = PTP_TCR_TSIPENA; |
| @@ -1324,6 +1324,7 @@ static const struct usb_device_id products[] = { · 1323 unmodified lines | |||
| 1324 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ | 1324 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ |
| 1325 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ | 1325 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ |
| 1326 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ | 1326 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
| 1327 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1031, 3)}, /* Telit LE910C1-EUX */ | ||
| 1327 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ | 1328 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)}, /* Telit LE922A */ |
| 1328 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1050, 2)}, /* Telit FN980 */ | 1329 | {QMI_QUIRK_SET_DTR(0x1bc7, 0x1050, 2)}, /* Telit FN980 */ |
| 1329 | {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ | 1330 | {QMI_FIXED_INTF(0x1bc7, 0x1100, 3)}, /* Telit ME910 */ |
| @@ -173,8 +173,10 @@ static int st21nfca_tm_send_atr_res(struct nfc_hci_dev *hdev, · 172 unmodified lines | |||
| 173 | memcpy(atr_res->gbi, atr_req->gbi, gb_len); | 173 | memcpy(atr_res->gbi, atr_req->gbi, gb_len); |
| 174 | r = nfc_set_remote_general_bytes(hdev->ndev, atr_res->gbi, | 174 | r = nfc_set_remote_general_bytes(hdev->ndev, atr_res->gbi, |
| 175 | gb_len); | 175 | gb_len); |
| 176 | if (r < 0) | 176 | if (r < 0) { |
| 177 | kfree_skb(skb); | ||
| 177 | return r; | 178 | return r; |
| 179 | } | ||
| 178 | } | 180 | } |
| 179 | 181 | ||
| 180 | info->dep_info.curr_nfc_dep_pni = 0; | 182 | info->dep_info.curr_nfc_dep_pni = 0; |
| @@ -2047,7 +2047,7 @@ ieee80211_he_ppe_size(u8 ppe_thres_hdr, const u8 *phy_cap_info) · 2046 unmodified lines | |||
| 2047 | } | 2047 | } |
| 2048 | 2048 | ||
| 2049 | /* HE Operation defines */ | 2049 | /* HE Operation defines */ |
| 2050 | #define IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK 0x00000003 | 2050 | #define IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK 0x00000007 |
| 2051 | #define IEEE80211_HE_OPERATION_TWT_REQUIRED 0x00000008 | 2051 | #define IEEE80211_HE_OPERATION_TWT_REQUIRED 0x00000008 |
| 2052 | #define IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK 0x00003ff0 | 2052 | #define IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK 0x00003ff0 |
| 2053 | #define IEEE80211_HE_OPERATION_RTS_THRESHOLD_OFFSET 4 | 2053 | #define IEEE80211_HE_OPERATION_RTS_THRESHOLD_OFFSET 4 |
| @@ -10,7 +10,7 @@ · 9 unmodified lines | |||
| 10 | #include <net/netfilter/nf_conntrack_expect.h> | 10 | #include <net/netfilter/nf_conntrack_expect.h> |
| 11 | #include <uapi/linux/netfilter/nf_conntrack_tuple_common.h> | 11 | #include <uapi/linux/netfilter/nf_conntrack_tuple_common.h> |
| 12 | 12 | ||
| 13 | extern const char *const pptp_msg_name[]; | 13 | const char *pptp_msg_name(u_int16_t msg); |
| 14 | 14 | ||
| 15 | /* state of the control session */ | 15 | /* state of the control session */ |
| 16 | enum pptp_ctrlsess_state { | 16 | enum pptp_ctrlsess_state { |
| @@ -31,6 +31,7 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, · 30 unmodified lines | |||
| 31 | { | 31 | { |
| 32 | unsigned int gso_type = 0; | 32 | unsigned int gso_type = 0; |
| 33 | unsigned int thlen = 0; | 33 | unsigned int thlen = 0; |
| 34 | unsigned int p_off = 0; | ||
| 34 | unsigned int ip_proto; | 35 | unsigned int ip_proto; |
| 35 | 36 | ||
| 36 | if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { | 37 | if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { |
| @@ -68,7 +69,8 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, · 31 unmodified lines | |||
| 68 | if (!skb_partial_csum_set(skb, start, off)) | 69 | if (!skb_partial_csum_set(skb, start, off)) |
| 69 | return -EINVAL; | 70 | return -EINVAL; |
| 70 | 71 | ||
| 71 | if (skb_transport_offset(skb) + thlen > skb_headlen(skb)) | 72 | p_off = skb_transport_offset(skb) + thlen; |
| 73 | if (p_off > skb_headlen(skb)) | ||
| 72 | return -EINVAL; | 74 | return -EINVAL; |
| 73 | } else { | 75 | } else { |
| 74 | /* gso packets without NEEDS_CSUM do not set transport_offset. | 76 | /* gso packets without NEEDS_CSUM do not set transport_offset. |
| @@ -92,23 +94,32 @@ retry: · 17 unmodified lines | |||
| 92 | return -EINVAL; | 94 | return -EINVAL; |
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | if (keys.control.thoff + thlen > skb_headlen(skb) || | 97 | p_off = keys.control.thoff + thlen; |
| 98 | if (p_off > skb_headlen(skb) || | ||
| 96 | keys.basic.ip_proto != ip_proto) | 99 | keys.basic.ip_proto != ip_proto) |
| 97 | return -EINVAL; | 100 | return -EINVAL; |
| 98 | 101 | ||
| 99 | skb_set_transport_header(skb, keys.control.thoff); | 102 | skb_set_transport_header(skb, keys.control.thoff); |
| 103 | } else if (gso_type) { | ||
| 104 | p_off = thlen; | ||
| 105 | if (p_off > skb_headlen(skb)) | ||
| 106 | return -EINVAL; | ||
| 100 | } | 107 | } |
| 101 | } | 108 | } |
| 102 | 109 | ||
| 103 | if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { | 110 | if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) { |
| 104 | u16 gso_size = __virtio16_to_cpu(little_endian, hdr->gso_size); | 111 | u16 gso_size = __virtio16_to_cpu(little_endian, hdr->gso_size); |
| 112 | struct skb_shared_info *shinfo = skb_shinfo(skb); | ||
| 105 | 113 | ||
| 106 | skb_shinfo(skb)->gso_size = gso_size; | 114 | /* Too small packets are not really GSO ones. */ |
| 107 | skb_shinfo(skb)->gso_type = gso_type; | 115 | if (skb->len - p_off > gso_size) { |
| 116 | shinfo->gso_size = gso_size; | ||
| 117 | shinfo->gso_type = gso_type; | ||
| 108 | 118 | ||
| 109 | /* Header must be checked, and gso_segs computed. */ | 119 | /* Header must be checked, and gso_segs computed. */ |
| 110 | skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; | 120 | shinfo->gso_type |= SKB_GSO_DODGY; |
| 111 | skb_shinfo(skb)->gso_segs = 0; | 121 | shinfo->gso_segs = 0; |
| 122 | } | ||
| 112 | } | 123 | } |
| 113 | 124 | ||
| 114 | return 0; | 125 | return 0; |
| @@ -25,6 +25,7 @@ struct espintcp_ctx { · 24 unmodified lines | |||
| 25 | struct espintcp_msg partial; | 25 | struct espintcp_msg partial; |
| 26 | void (*saved_data_ready)(struct sock *sk); | 26 | void (*saved_data_ready)(struct sock *sk); |
| 27 | void (*saved_write_space)(struct sock *sk); | 27 | void (*saved_write_space)(struct sock *sk); |
| 28 | void (*saved_destruct)(struct sock *sk); | ||
| 28 | struct work_struct work; | 29 | struct work_struct work; |
| 29 | bool tx_running; | 30 | bool tx_running; |
| 30 | }; | 31 | }; |
| @@ -447,6 +447,16 @@ static inline int fib_num_tclassid_users(struct net *net) · 446 unmodified lines | |||
| 447 | #endif | 447 | #endif |
| 448 | int fib_unmerge(struct net *net); | 448 | int fib_unmerge(struct net *net); |
| 449 | 449 | ||
| 450 | static inline bool nhc_l3mdev_matches_dev(const struct fib_nh_common *nhc, | ||
| 451 | const struct net_device *dev) | ||
| 452 | { | ||
| 453 | if (nhc->nhc_dev == dev || | ||
| 454 | l3mdev_master_ifindex_rcu(nhc->nhc_dev) == dev->ifindex) | ||
| 455 | return true; | ||
| 456 | |||
| 457 | return false; | ||
| 458 | } | ||
| 459 | |||
| 450 | /* Exported by fib_semantics.c */ | 460 | /* Exported by fib_semantics.c */ |
| 451 | int ip_fib_check_default(__be32 gw, struct net_device *dev); | 461 | int ip_fib_check_default(__be32 gw, struct net_device *dev); |
| 452 | int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force); | 462 | int fib_sync_down_dev(struct net_device *dev, unsigned long event, bool force); |
| @@ -479,6 +489,8 @@ void fib_nh_common_release(struct fib_nh_common *nhc); · 26 unmodified lines | |||
| 479 | void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri); | 489 | void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri); |
| 480 | void fib_trie_init(void); | 490 | void fib_trie_init(void); |
| 481 | struct fib_table *fib_trie_table(u32 id, struct fib_table *alias); | 491 | struct fib_table *fib_trie_table(u32 id, struct fib_table *alias); |
| 492 | bool fib_lookup_good_nhc(const struct fib_nh_common *nhc, int fib_flags, | ||
| 493 | const struct flowi4 *flp); | ||
| 482 | 494 | ||
| 483 | static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) | 495 | static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) |
| 484 | { | 496 | { |
| @@ -70,6 +70,7 @@ struct nh_grp_entry { · 69 unmodified lines | |||
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | struct nh_group { | 72 | struct nh_group { |
| 73 | struct nh_group *spare; /* spare group for removals */ | ||
| 73 | u16 num_nh; | 74 | u16 num_nh; |
| 74 | bool mpath; | 75 | bool mpath; |
| 75 | bool has_v4; | 76 | bool has_v4; |
| @@ -136,21 +137,20 @@ static inline unsigned int nexthop_num_path(const struct nexthop *nh) · 60 unmodified lines | |||
| 136 | { | 137 | { |
| 137 | unsigned int rc = 1; | 138 | unsigned int rc = 1; |
| 138 | 139 | ||
| 139 | if (nexthop_is_multipath(nh)) { | 140 | if (nh->is_group) { |
| 140 | struct nh_group *nh_grp; | 141 | struct nh_group *nh_grp; |
| 141 | 142 | ||
| 142 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); | 143 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 143 | rc = nh_grp->num_nh; | 144 | if (nh_grp->mpath) |
| 145 | rc = nh_grp->num_nh; | ||
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | return rc; | 148 | return rc; |
| 147 | } | 149 | } |
| 148 | 150 | ||
| 149 | static inline | 151 | static inline |
| 150 | struct nexthop *nexthop_mpath_select(const struct nexthop *nh, int nhsel) | 152 | struct nexthop *nexthop_mpath_select(const struct nh_group *nhg, int nhsel) |
| 151 | { | 153 | { |
| 152 | const struct nh_group *nhg = rcu_dereference_rtnl(nh->nh_grp); | ||
| 153 | |||
| 154 | /* for_nexthops macros in fib_semantics.c grabs a pointer to | 154 | /* for_nexthops macros in fib_semantics.c grabs a pointer to |
| 155 | * the nexthop before checking nhsel | 155 | * the nexthop before checking nhsel |
| 156 | */ | 156 | */ |
| @@ -185,12 +185,14 @@ static inline bool nexthop_is_blackhole(const struct nexthop *nh) · 28 unmodified lines | |||
| 185 | { | 185 | { |
| 186 | const struct nh_info *nhi; | 186 | const struct nh_info *nhi; |
| 187 | 187 | ||
| 188 | if (nexthop_is_multipath(nh)) { | 188 | if (nh->is_group) { |
| 189 | if (nexthop_num_path(nh) > 1) | 189 | struct nh_group *nh_grp; |
| 190 | return false; | 190 | |
| 191 | nh = nexthop_mpath_select(nh, 0); | 191 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 192 | if (!nh) | 192 | if (nh_grp->num_nh > 1) |
| 193 | return false; | 193 | return false; |
| 194 | |||
| 195 | nh = nh_grp->nh_entries[0].nh; | ||
| 194 | } | 196 | } |
| 195 | 197 | ||
| 196 | nhi = rcu_dereference_rtnl(nh->nh_info); | 198 | nhi = rcu_dereference_rtnl(nh->nh_info); |
| @@ -216,16 +218,79 @@ struct fib_nh_common *nexthop_fib_nhc(struct nexthop *nh, int nhsel) · 19 unmodified lines | |||
| 216 | BUILD_BUG_ON(offsetof(struct fib_nh, nh_common) != 0); | 218 | BUILD_BUG_ON(offsetof(struct fib_nh, nh_common) != 0); |
| 217 | BUILD_BUG_ON(offsetof(struct fib6_nh, nh_common) != 0); | 219 | BUILD_BUG_ON(offsetof(struct fib6_nh, nh_common) != 0); |
| 218 | 220 | ||
| 219 | if (nexthop_is_multipath(nh)) { | 221 | if (nh->is_group) { |
| 220 | nh = nexthop_mpath_select(nh, nhsel); | 222 | struct nh_group *nh_grp; |
| 221 | if (!nh) | 223 | |
| 222 | return NULL; | 224 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 225 | if (nh_grp->mpath) { | ||
| 226 | nh = nexthop_mpath_select(nh_grp, nhsel); | ||
| 227 | if (!nh) | ||
| 228 | return NULL; | ||
| 229 | } | ||
| 223 | } | 230 | } |
| 224 | 231 | ||
| 225 | nhi = rcu_dereference_rtnl(nh->nh_info); | 232 | nhi = rcu_dereference_rtnl(nh->nh_info); |
| 226 | return &nhi->fib_nhc; | 233 | return &nhi->fib_nhc; |
| 227 | } | 234 | } |
| 228 | 235 | ||
| 236 | /* called from fib_table_lookup with rcu_lock */ | ||
| 237 | static inline | ||
| 238 | struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh, | ||
| 239 | int fib_flags, | ||
| 240 | const struct flowi4 *flp, | ||
| 241 | int *nhsel) | ||
| 242 | { | ||
| 243 | struct nh_info *nhi; | ||
| 244 | |||
| 245 | if (nh->is_group) { | ||
| 246 | struct nh_group *nhg = rcu_dereference(nh->nh_grp); | ||
| 247 | int i; | ||
| 248 | |||
| 249 | for (i = 0; i < nhg->num_nh; i++) { | ||
| 250 | struct nexthop *nhe = nhg->nh_entries[i].nh; | ||
| 251 | |||
| 252 | nhi = rcu_dereference(nhe->nh_info); | ||
| 253 | if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) { | ||
| 254 | *nhsel = i; | ||
| 255 | return &nhi->fib_nhc; | ||
| 256 | } | ||
| 257 | } | ||
| 258 | } else { | ||
| 259 | nhi = rcu_dereference(nh->nh_info); | ||
| 260 | if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) { | ||
| 261 | *nhsel = 0; | ||
| 262 | return &nhi->fib_nhc; | ||
| 263 | } | ||
| 264 | } | ||
| 265 | |||
| 266 | return NULL; | ||
| 267 | } | ||
| 268 | |||
| 269 | static inline bool nexthop_uses_dev(const struct nexthop *nh, | ||
| 270 | const struct net_device *dev) | ||
| 271 | { | ||
| 272 | struct nh_info *nhi; | ||
| 273 | |||
| 274 | if (nh->is_group) { | ||
| 275 | struct nh_group *nhg = rcu_dereference(nh->nh_grp); | ||
| 276 | int i; | ||
| 277 | |||
| 278 | for (i = 0; i < nhg->num_nh; i++) { | ||
| 279 | struct nexthop *nhe = nhg->nh_entries[i].nh; | ||
| 280 | |||
| 281 | nhi = rcu_dereference(nhe->nh_info); | ||
| 282 | if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev)) | ||
| 283 | return true; | ||
| 284 | } | ||
| 285 | } else { | ||
| 286 | nhi = rcu_dereference(nh->nh_info); | ||
| 287 | if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev)) | ||
| 288 | return true; | ||
| 289 | } | ||
| 290 | |||
| 291 | return false; | ||
| 292 | } | ||
| 293 | |||
| 229 | static inline unsigned int fib_info_num_path(const struct fib_info *fi) | 294 | static inline unsigned int fib_info_num_path(const struct fib_info *fi) |
| 230 | { | 295 | { |
| 231 | if (unlikely(fi->nh)) | 296 | if (unlikely(fi->nh)) |
| @@ -263,8 +328,11 @@ static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh) · 31 unmodified lines | |||
| 263 | { | 328 | { |
| 264 | struct nh_info *nhi; | 329 | struct nh_info *nhi; |
| 265 | 330 | ||
| 266 | if (nexthop_is_multipath(nh)) { | 331 | if (nh->is_group) { |
| 267 | nh = nexthop_mpath_select(nh, 0); | 332 | struct nh_group *nh_grp; |
| 333 | |||
| 334 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); | ||
| 335 | nh = nexthop_mpath_select(nh_grp, 0); | ||
| 268 | if (!nh) | 336 | if (!nh) |
| 269 | return NULL; | 337 | return NULL; |
| 270 | } | 338 | } |
| @@ -135,6 +135,8 @@ struct tls_sw_context_tx { · 134 unmodified lines | |||
| 135 | struct tls_rec *open_rec; | 135 | struct tls_rec *open_rec; |
| 136 | struct list_head tx_list; | 136 | struct list_head tx_list; |
| 137 | atomic_t encrypt_pending; | 137 | atomic_t encrypt_pending; |
| 138 | /* protect crypto_wait with encrypt_pending */ | ||
| 139 | spinlock_t encrypt_compl_lock; | ||
| 138 | int async_notify; | 140 | int async_notify; |
| 139 | u8 async_capable:1; | 141 | u8 async_capable:1; |
| 140 | 142 | ||
| @@ -155,6 +157,8 @@ struct tls_sw_context_rx { · 14 unmodified lines | |||
| 155 | u8 async_capable:1; | 157 | u8 async_capable:1; |
| 156 | u8 decrypted:1; | 158 | u8 decrypted:1; |
| 157 | atomic_t decrypt_pending; | 159 | atomic_t decrypt_pending; |
| 160 | /* protect crypto_wait with decrypt_pending*/ | ||
| 161 | spinlock_t decrypt_compl_lock; | ||
| 158 | bool async_notify; | 162 | bool async_notify; |
| 159 | }; | 163 | }; |
| 160 | 164 | ||
| @@ -304,7 +304,7 @@ enum xfrm_attr_type_t { · 303 unmodified lines | |||
| 304 | XFRMA_PROTO, /* __u8 */ | 304 | XFRMA_PROTO, /* __u8 */ |
| 305 | XFRMA_ADDRESS_FILTER, /* struct xfrm_address_filter */ | 305 | XFRMA_ADDRESS_FILTER, /* struct xfrm_address_filter */ |
| 306 | XFRMA_PAD, | 306 | XFRMA_PAD, |
| 307 | XFRMA_OFFLOAD_DEV, /* struct xfrm_state_offload */ | 307 | XFRMA_OFFLOAD_DEV, /* struct xfrm_user_offload */ |
| 308 | XFRMA_SET_MARK, /* __u32 */ | 308 | XFRMA_SET_MARK, /* __u32 */ |
| 309 | XFRMA_SET_MARK_MASK, /* __u32 */ | 309 | XFRMA_SET_MARK_MASK, /* __u32 */ |
| 310 | XFRMA_IF_ID, /* __u32 */ | 310 | XFRMA_IF_ID, /* __u32 */ |
| @@ -1168,14 +1168,14 @@ static void __reg_assign_32_into_64(struct bpf_reg_state *reg) · 1167 unmodified lines | |||
| 1168 | * but must be positive otherwise set to worse case bounds | 1168 | * but must be positive otherwise set to worse case bounds |
| 1169 | * and refine later from tnum. | 1169 | * and refine later from tnum. |
| 1170 | */ | 1170 | */ |
| 1171 | if (reg->s32_min_value > 0) | 1171 | if (reg->s32_min_value >= 0 && reg->s32_max_value >= 0) |
| 1172 | reg->smin_value = reg->s32_min_value; | ||
| 1173 | else | ||
| 1174 | reg->smin_value = 0; | ||
| 1175 | if (reg->s32_max_value > 0) | ||
| 1176 | reg->smax_value = reg->s32_max_value; | 1172 | reg->smax_value = reg->s32_max_value; |
| 1177 | else | 1173 | else |
| 1178 | reg->smax_value = U32_MAX; | 1174 | reg->smax_value = U32_MAX; |
| 1175 | if (reg->s32_min_value >= 0) | ||
| 1176 | reg->smin_value = reg->s32_min_value; | ||
| 1177 | else | ||
| 1178 | reg->smin_value = 0; | ||
| 1179 | } | 1179 | } |
| 1180 | 1180 | ||
| 1181 | static void __reg_combine_32_into_64(struct bpf_reg_state *reg) | 1181 | static void __reg_combine_32_into_64(struct bpf_reg_state *reg) |
| @@ -10428,22 +10428,13 @@ static int check_struct_ops_btf_id(struct bpf_verifier_env *env) · 9246 unmodified lines | |||
| 10428 | } | 10428 | } |
| 10429 | #define SECURITY_PREFIX "security_" | 10429 | #define SECURITY_PREFIX "security_" |
| 10430 | 10430 | ||
| 10431 | static int check_attach_modify_return(struct bpf_verifier_env *env) | 10431 | static int check_attach_modify_return(struct bpf_prog *prog, unsigned long addr) |
| 10432 | { | 10432 | { |
| 10433 | struct bpf_prog *prog = env->prog; | ||
| 10434 | unsigned long addr = (unsigned long) prog->aux->trampoline->func.addr; | ||
| 10435 | |||
| 10436 | /* This is expected to be cleaned up in the future with the KRSI effort | ||
| 10437 | * introducing the LSM_HOOK macro for cleaning up lsm_hooks.h. | ||
| 10438 | */ | ||
| 10439 | if (within_error_injection_list(addr) || | 10433 | if (within_error_injection_list(addr) || |
| 10440 | !strncmp(SECURITY_PREFIX, prog->aux->attach_func_name, | 10434 | !strncmp(SECURITY_PREFIX, prog->aux->attach_func_name, |
| 10441 | sizeof(SECURITY_PREFIX) - 1)) | 10435 | sizeof(SECURITY_PREFIX) - 1)) |
| 10442 | return 0; | 10436 | return 0; |
| 10443 | 10437 | ||
| 10444 | verbose(env, "fmod_ret attach_btf_id %u (%s) is not modifiable\n", | ||
| 10445 | prog->aux->attach_btf_id, prog->aux->attach_func_name); | ||
| 10446 | |||
| 10447 | return -EINVAL; | 10438 | return -EINVAL; |
| 10448 | } | 10439 | } |
| 10449 | 10440 | ||
| @@ -10654,11 +10645,18 @@ static int check_attach_btf_id(struct bpf_verifier_env *env) · 204 unmodified lines | |||
| 10654 | goto out; | 10645 | goto out; |
| 10655 | } | 10646 | } |
| 10656 | } | 10647 | } |
| 10648 | |||
| 10649 | if (prog->expected_attach_type == BPF_MODIFY_RETURN) { | ||
| 10650 | ret = check_attach_modify_return(prog, addr); | ||
| 10651 | if (ret) | ||
| 10652 | verbose(env, "%s() is not modifiable\n", | ||
| 10653 | prog->aux->attach_func_name); | ||
| 10654 | } | ||
| 10655 | |||
| 10656 | if (ret) | ||
| 10657 | goto out; | ||
| 10657 | tr->func.addr = (void *)addr; | 10658 | tr->func.addr = (void *)addr; |
| 10658 | prog->aux->trampoline = tr; | 10659 | prog->aux->trampoline = tr; |
| 10659 | |||
| 10660 | if (prog->expected_attach_type == BPF_MODIFY_RETURN) | ||
| 10661 | ret = check_attach_modify_return(env); | ||
| 10662 | out: | 10660 | out: |
| 10663 | mutex_unlock(&tr->mutex); | 10661 | mutex_unlock(&tr->mutex); |
| 10664 | if (ret) | 10662 | if (ret) |
| @@ -2413,7 +2413,8 @@ void br_multicast_uninit_stats(struct net_bridge *br) · 2412 unmodified lines | |||
| 2413 | free_percpu(br->mcast_stats); | 2413 | free_percpu(br->mcast_stats); |
| 2414 | } | 2414 | } |
| 2415 | 2415 | ||
| 2416 | static void mcast_stats_add_dir(u64 *dst, u64 *src) | 2416 | /* noinline for https://bugs.llvm.org/show_bug.cgi?id=45802#c9 */ |
| 2417 | static noinline_for_stack void mcast_stats_add_dir(u64 *dst, u64 *src) | ||
| 2417 | { | 2418 | { |
| 2418 | dst[BR_MCAST_DIR_RX] += src[BR_MCAST_DIR_RX]; | 2419 | dst[BR_MCAST_DIR_RX] += src[BR_MCAST_DIR_RX]; |
| 2419 | dst[BR_MCAST_DIR_TX] += src[BR_MCAST_DIR_TX]; | 2420 | dst[BR_MCAST_DIR_TX] += src[BR_MCAST_DIR_TX]; |
| @@ -31,6 +31,12 @@ static void nft_reject_br_push_etherhdr(struct sk_buff *oldskb, · 30 unmodified lines | |||
| 31 | ether_addr_copy(eth->h_dest, eth_hdr(oldskb)->h_source); | 31 | ether_addr_copy(eth->h_dest, eth_hdr(oldskb)->h_source); |
| 32 | eth->h_proto = eth_hdr(oldskb)->h_proto; | 32 | eth->h_proto = eth_hdr(oldskb)->h_proto; |
| 33 | skb_pull(nskb, ETH_HLEN); | 33 | skb_pull(nskb, ETH_HLEN); |
| 34 | |||
| 35 | if (skb_vlan_tag_present(oldskb)) { | ||
| 36 | u16 vid = skb_vlan_tag_get(oldskb); | ||
| 37 | |||
| 38 | __vlan_hwaccel_put_tag(nskb, oldskb->vlan_proto, vid); | ||
| 39 | } | ||
| 34 | } | 40 | } |
| 35 | 41 | ||
| 36 | static int nft_bridge_iphdr_validate(struct sk_buff *skb) | 42 | static int nft_bridge_iphdr_validate(struct sk_buff *skb) |
| @@ -1082,8 +1082,8 @@ static void neigh_timer_handler(struct timer_list *t) · 1081 unmodified lines | |||
| 1082 | } | 1082 | } |
| 1083 | 1083 | ||
| 1084 | if (neigh->nud_state & NUD_IN_TIMER) { | 1084 | if (neigh->nud_state & NUD_IN_TIMER) { |
| 1085 | if (time_before(next, jiffies + HZ/2)) | 1085 | if (time_before(next, jiffies + HZ/100)) |
| 1086 | next = jiffies + HZ/2; | 1086 | next = jiffies + HZ/100; |
| 1087 | if (!mod_timer(&neigh->timer, next)) | 1087 | if (!mod_timer(&neigh->timer, next)) |
| 1088 | neigh_hold(neigh); | 1088 | neigh_hold(neigh); |
| 1089 | } | 1089 | } |
| @@ -1736,6 +1736,7 @@ int dsa_slave_create(struct dsa_port *port) · 1735 unmodified lines | |||
| 1736 | if (ds->ops->port_vlan_add && ds->ops->port_vlan_del) | 1736 | if (ds->ops->port_vlan_add && ds->ops->port_vlan_del) |
| 1737 | slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | 1737 | slave_dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; |
| 1738 | slave_dev->hw_features |= NETIF_F_HW_TC; | 1738 | slave_dev->hw_features |= NETIF_F_HW_TC; |
| 1739 | slave_dev->features |= NETIF_F_LLTX; | ||
| 1739 | slave_dev->ethtool_ops = &dsa_slave_ethtool_ops; | 1740 | slave_dev->ethtool_ops = &dsa_slave_ethtool_ops; |
| 1740 | if (!IS_ERR_OR_NULL(port->mac)) | 1741 | if (!IS_ERR_OR_NULL(port->mac)) |
| 1741 | ether_addr_copy(slave_dev->dev_addr, port->mac); | 1742 | ether_addr_copy(slave_dev->dev_addr, port->mac); |
| @@ -276,6 +276,7 @@ static struct in_device *inetdev_init(struct net_device *dev) · 275 unmodified lines | |||
| 276 | err = devinet_sysctl_register(in_dev); | 276 | err = devinet_sysctl_register(in_dev); |
| 277 | if (err) { | 277 | if (err) { |
| 278 | in_dev->dead = 1; | 278 | in_dev->dead = 1; |
| 279 | neigh_parms_release(&arp_tbl, in_dev->arp_parms); | ||
| 279 | in_dev_put(in_dev); | 280 | in_dev_put(in_dev); |
| 280 | in_dev = NULL; | 281 | in_dev = NULL; |
| 281 | goto out; | 282 | goto out; |
| @@ -63,10 +63,8 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head, · 62 unmodified lines | |||
| 63 | sp->olen++; | 63 | sp->olen++; |
| 64 | 64 | ||
| 65 | xo = xfrm_offload(skb); | 65 | xo = xfrm_offload(skb); |
| 66 | if (!xo) { | 66 | if (!xo) |
| 67 | xfrm_state_put(x); | ||
| 68 | goto out_reset; | 67 | goto out_reset; |
| 69 | } | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | xo->flags |= XFRM_GRO; | 70 | xo->flags |= XFRM_GRO; |
| @@ -139,19 +137,27 @@ static struct sk_buff *xfrm4_beet_gso_segment(struct xfrm_state *x, · 66 unmodified lines | |||
| 139 | struct xfrm_offload *xo = xfrm_offload(skb); | 137 | struct xfrm_offload *xo = xfrm_offload(skb); |
| 140 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 138 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
| 141 | const struct net_offload *ops; | 139 | const struct net_offload *ops; |
| 142 | int proto = xo->proto; | 140 | u8 proto = xo->proto; |
| 143 | 141 | ||
| 144 | skb->transport_header += x->props.header_len; | 142 | skb->transport_header += x->props.header_len; |
| 145 | 143 | ||
| 146 | if (proto == IPPROTO_BEETPH) { | 144 | if (x->sel.family != AF_INET6) { |
| 147 | struct ip_beet_phdr *ph = (struct ip_beet_phdr *)skb->data; | 145 | if (proto == IPPROTO_BEETPH) { |
| 146 | struct ip_beet_phdr *ph = | ||
| 147 | (struct ip_beet_phdr *)skb->data; | ||
| 148 | |||
| 149 | skb->transport_header += ph->hdrlen * 8; | ||
| 150 | proto = ph->nexthdr; | ||
| 151 | } else { | ||
| 152 | skb->transport_header -= IPV4_BEET_PHMAXLEN; | ||
| 153 | } | ||
| 154 | } else { | ||
| 155 | __be16 frag; | ||
| 148 | 156 | ||
| 149 | skb->transport_header += ph->hdrlen * 8; | 157 | skb->transport_header += |
| 150 | proto = ph->nexthdr; | 158 | ipv6_skip_exthdr(skb, 0, &proto, &frag); |
| 151 | } else if (x->sel.family != AF_INET6) { | 159 | if (proto == IPPROTO_TCP) |
| 152 | skb->transport_header -= IPV4_BEET_PHMAXLEN; | 160 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4; |
| 153 | } else if (proto == IPPROTO_TCP) { | ||
| 154 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4; | ||
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | __skb_pull(skb, skb_transport_offset(skb)); | 163 | __skb_pull(skb, skb_transport_offset(skb)); |
| @@ -309,17 +309,18 @@ bool fib_info_nh_uses_dev(struct fib_info *fi, const struct net_device *dev) · 308 unmodified lines | |||
| 309 | { | 309 | { |
| 310 | bool dev_match = false; | 310 | bool dev_match = false; |
| 311 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 311 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
| 312 | int ret; | 312 | if (unlikely(fi->nh)) { |
| 313 | dev_match = nexthop_uses_dev(fi->nh, dev); | ||
| 314 | } else { | ||
| 315 | int ret; | ||
| 313 | 316 | ||
| 314 | for (ret = 0; ret < fib_info_num_path(fi); ret++) { | 317 | for (ret = 0; ret < fib_info_num_path(fi); ret++) { |
| 315 | const struct fib_nh_common *nhc = fib_info_nhc(fi, ret); | 318 | const struct fib_nh_common *nhc = fib_info_nhc(fi, ret); |
| 316 | 319 | ||
| 317 | if (nhc->nhc_dev == dev) { | 320 | if (nhc_l3mdev_matches_dev(nhc, dev)) { |
| 318 | dev_match = true; | 321 | dev_match = true; |
| 319 | break; | 322 | break; |
| 320 | } else if (l3mdev_master_ifindex_rcu(nhc->nhc_dev) == dev->ifindex) { | 323 | } |
| 321 | dev_match = true; | ||
| 322 | break; | ||
| 323 | } | 324 | } |
| 324 | } | 325 | } |
| 325 | #else | 326 | #else |
| @@ -1371,6 +1371,26 @@ static inline t_key prefix_mismatch(t_key key, struct key_vector *n) · 1370 unmodified lines | |||
| 1371 | return (key ^ prefix) & (prefix | -prefix); | 1371 | return (key ^ prefix) & (prefix | -prefix); |
| 1372 | } | 1372 | } |
| 1373 | 1373 | ||
| 1374 | bool fib_lookup_good_nhc(const struct fib_nh_common *nhc, int fib_flags, | ||
| 1375 | const struct flowi4 *flp) | ||
| 1376 | { | ||
| 1377 | if (nhc->nhc_flags & RTNH_F_DEAD) | ||
| 1378 | return false; | ||
| 1379 | |||
| 1380 | if (ip_ignore_linkdown(nhc->nhc_dev) && | ||
| 1381 | nhc->nhc_flags & RTNH_F_LINKDOWN && | ||
| 1382 | !(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE)) | ||
| 1383 | return false; | ||
| 1384 | |||
| 1385 | if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) { | ||
| 1386 | if (flp->flowi4_oif && | ||
| 1387 | flp->flowi4_oif != nhc->nhc_oif) | ||
| 1388 | return false; | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | return true; | ||
| 1392 | } | ||
| 1393 | |||
| 1374 | /* should be called with rcu_read_lock */ | 1394 | /* should be called with rcu_read_lock */ |
| 1375 | int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, | 1395 | int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, |
| 1376 | struct fib_result *res, int fib_flags) | 1396 | struct fib_result *res, int fib_flags) |
| @@ -1503,6 +1523,7 @@ found: · 126 unmodified lines | |||
| 1503 | /* Step 3: Process the leaf, if that fails fall back to backtracing */ | 1523 | /* Step 3: Process the leaf, if that fails fall back to backtracing */ |
| 1504 | hlist_for_each_entry_rcu(fa, &n->leaf, fa_list) { | 1524 | hlist_for_each_entry_rcu(fa, &n->leaf, fa_list) { |
| 1505 | struct fib_info *fi = fa->fa_info; | 1525 | struct fib_info *fi = fa->fa_info; |
| 1526 | struct fib_nh_common *nhc; | ||
| 1506 | int nhsel, err; | 1527 | int nhsel, err; |
| 1507 | 1528 | ||
| 1508 | if ((BITS_PER_LONG > KEYLENGTH) || (fa->fa_slen < KEYLENGTH)) { | 1529 | if ((BITS_PER_LONG > KEYLENGTH) || (fa->fa_slen < KEYLENGTH)) { |
| @@ -1528,26 +1549,25 @@ out_reject: · 19 unmodified lines | |||
| 1528 | if (fi->fib_flags & RTNH_F_DEAD) | 1549 | if (fi->fib_flags & RTNH_F_DEAD) |
| 1529 | continue; | 1550 | continue; |
| 1530 | 1551 | ||
| 1531 | if (unlikely(fi->nh && nexthop_is_blackhole(fi->nh))) { | 1552 | if (unlikely(fi->nh)) { |
| 1532 | err = fib_props[RTN_BLACKHOLE].error; | 1553 | if (nexthop_is_blackhole(fi->nh)) { |
| 1533 | goto out_reject; | 1554 | err = fib_props[RTN_BLACKHOLE].error; |
| 1555 | goto out_reject; | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | nhc = nexthop_get_nhc_lookup(fi->nh, fib_flags, flp, | ||
| 1559 | &nhsel); | ||
| 1560 | if (nhc) | ||
| 1561 | goto set_result; | ||
| 1562 | goto miss; | ||
| 1534 | } | 1563 | } |
| 1535 | 1564 | ||
| 1536 | for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) { | 1565 | for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) { |
| 1537 | struct fib_nh_common *nhc = fib_info_nhc(fi, nhsel); | 1566 | nhc = fib_info_nhc(fi, nhsel); |
| 1538 | 1567 | ||
| 1539 | if (nhc->nhc_flags & RTNH_F_DEAD) | 1568 | if (!fib_lookup_good_nhc(nhc, fib_flags, flp)) |
| 1540 | continue; | 1569 | continue; |
| 1541 | if (ip_ignore_linkdown(nhc->nhc_dev) && | 1570 | set_result: |
| 1542 | nhc->nhc_flags & RTNH_F_LINKDOWN && | ||
| 1543 | !(fib_flags & FIB_LOOKUP_IGNORE_LINKSTATE)) | ||
| 1544 | continue; | ||
| 1545 | if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) { | ||
| 1546 | if (flp->flowi4_oif && | ||
| 1547 | flp->flowi4_oif != nhc->nhc_oif) | ||
| 1548 | continue; | ||
| 1549 | } | ||
| 1550 | |||
| 1551 | if (!(fib_flags & FIB_LOOKUP_NOREF)) | 1571 | if (!(fib_flags & FIB_LOOKUP_NOREF)) |
| 1552 | refcount_inc(&fi->fib_clntref); | 1572 | refcount_inc(&fi->fib_clntref); |
| 1553 | 1573 | ||
| @@ -1568,6 +1588,7 @@ out_reject: · 14 unmodified lines | |||
| 1568 | return err; | 1588 | return err; |
| 1569 | } | 1589 | } |
| 1570 | } | 1590 | } |
| 1591 | miss: | ||
| 1571 | #ifdef CONFIG_IP_FIB_TRIE_STATS | 1592 | #ifdef CONFIG_IP_FIB_TRIE_STATS |
| 1572 | this_cpu_inc(stats->semantic_match_miss); | 1593 | this_cpu_inc(stats->semantic_match_miss); |
| 1573 | #endif | 1594 | #endif |
| @@ -93,7 +93,28 @@ static int vti_rcv_proto(struct sk_buff *skb) · 92 unmodified lines | |||
| 93 | 93 | ||
| 94 | static int vti_rcv_tunnel(struct sk_buff *skb) | 94 | static int vti_rcv_tunnel(struct sk_buff *skb) |
| 95 | { | 95 | { |
| 96 | return vti_rcv(skb, ip_hdr(skb)->saddr, true); | 96 | struct ip_tunnel_net *itn = net_generic(dev_net(skb->dev), vti_net_id); |
| 97 | const struct iphdr *iph = ip_hdr(skb); | ||
| 98 | struct ip_tunnel *tunnel; | ||
| 99 | |||
| 100 | tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, TUNNEL_NO_KEY, | ||
| 101 | iph->saddr, iph->daddr, 0); | ||
| 102 | if (tunnel) { | ||
| 103 | struct tnl_ptk_info tpi = { | ||
| 104 | .proto = htons(ETH_P_IP), | ||
| 105 | }; | ||
| 106 | |||
| 107 | if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) | ||
| 108 | goto drop; | ||
| 109 | if (iptunnel_pull_header(skb, 0, tpi.proto, false)) | ||
| 110 | goto drop; | ||
| 111 | return ip_tunnel_rcv(tunnel, skb, &tpi, NULL, false); | ||
| 112 | } | ||
| 113 | |||
| 114 | return -EINVAL; | ||
| 115 | drop: | ||
| 116 | kfree_skb(skb); | ||
| 117 | return 0; | ||
| 97 | } | 118 | } |
| 98 | 119 | ||
| 99 | static int vti_rcv_cb(struct sk_buff *skb, int err) | 120 | static int vti_rcv_cb(struct sk_buff *skb, int err) |
| @@ -166,8 +166,7 @@ pptp_outbound_pkt(struct sk_buff *skb, · 165 unmodified lines | |||
| 166 | break; | 166 | break; |
| 167 | default: | 167 | default: |
| 168 | pr_debug("unknown outbound packet 0x%04x:%s\n", msg, | 168 | pr_debug("unknown outbound packet 0x%04x:%s\n", msg, |
| 169 | msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] : | 169 | pptp_msg_name(msg)); |
| 170 | pptp_msg_name[0]); | ||
| 171 | fallthrough; | 170 | fallthrough; |
| 172 | case PPTP_SET_LINK_INFO: | 171 | case PPTP_SET_LINK_INFO: |
| 173 | /* only need to NAT in case PAC is behind NAT box */ | 172 | /* only need to NAT in case PAC is behind NAT box */ |
| @@ -268,9 +267,7 @@ pptp_inbound_pkt(struct sk_buff *skb, · 94 unmodified lines | |||
| 268 | pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID); | 267 | pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID); |
| 269 | break; | 268 | break; |
| 270 | default: | 269 | default: |
| 271 | pr_debug("unknown inbound packet %s\n", | 270 | pr_debug("unknown inbound packet %s\n", pptp_msg_name(msg)); |
| 272 | msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] : | ||
| 273 | pptp_msg_name[0]); | ||
| 274 | fallthrough; | 271 | fallthrough; |
| 275 | case PPTP_START_SESSION_REQUEST: | 272 | case PPTP_START_SESSION_REQUEST: |
| 276 | case PPTP_START_SESSION_REPLY: | 273 | case PPTP_START_SESSION_REPLY: |
| @@ -63,9 +63,16 @@ static void nexthop_free_mpath(struct nexthop *nh) · 62 unmodified lines | |||
| 63 | int i; | 63 | int i; |
| 64 | 64 | ||
| 65 | nhg = rcu_dereference_raw(nh->nh_grp); | 65 | nhg = rcu_dereference_raw(nh->nh_grp); |
| 66 | for (i = 0; i < nhg->num_nh; ++i) | 66 | for (i = 0; i < nhg->num_nh; ++i) { |
| 67 | WARN_ON(nhg->nh_entries[i].nh); | 67 | struct nh_grp_entry *nhge = &nhg->nh_entries[i]; |
| 68 | |||
| 69 | WARN_ON(!list_empty(&nhge->nh_list)); | ||
| 70 | nexthop_put(nhge->nh); | ||
| 71 | } | ||
| 72 | |||
| 73 | WARN_ON(nhg->spare == nhg); | ||
| 68 | 74 | ||
| 75 | kfree(nhg->spare); | ||
| 69 | kfree(nhg); | 76 | kfree(nhg); |
| 70 | } | 77 | } |
| 71 | 78 | ||
| @@ -694,41 +701,56 @@ static void nh_group_rebalance(struct nh_group *nhg) · 622 unmodified lines | |||
| 694 | } | 701 | } |
| 695 | } | 702 | } |
| 696 | 703 | ||
| 697 | static void remove_nh_grp_entry(struct nh_grp_entry *nhge, | 704 | static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge, |
| 698 | struct nh_group *nhg, | ||
| 699 | struct nl_info *nlinfo) | 705 | struct nl_info *nlinfo) |
| 700 | { | 706 | { |
| 707 | struct nh_grp_entry *nhges, *new_nhges; | ||
| 708 | struct nexthop *nhp = nhge->nh_parent; | ||
| 701 | struct nexthop *nh = nhge->nh; | 709 | struct nexthop *nh = nhge->nh; |
| 702 | struct nh_grp_entry *nhges; | 710 | struct nh_group *nhg, *newg; |
| 703 | bool found = false; | 711 | int i, j; |
| 704 | int i; | ||
| 705 | 712 | ||
| 706 | WARN_ON(!nh); | 713 | WARN_ON(!nh); |
| 707 | 714 | ||
| 708 | nhges = nhg->nh_entries; | 715 | nhg = rtnl_dereference(nhp->nh_grp); |
| 709 | for (i = 0; i < nhg->num_nh; ++i) { | 716 | newg = nhg->spare; |
| 710 | if (found) { | ||
| 711 | nhges[i-1].nh = nhges[i].nh; | ||
| 712 | nhges[i-1].weight = nhges[i].weight; | ||
| 713 | list_del(&nhges[i].nh_list); | ||
| 714 | list_add(&nhges[i-1].nh_list, &nhges[i-1].nh->grp_list); | ||
| 715 | } else if (nhg->nh_entries[i].nh == nh) { | ||
| 716 | found = true; | ||
| 717 | } | ||
| 718 | } | ||
| 719 | 717 | ||
| 720 | if (WARN_ON(!found)) | 718 | /* last entry, keep it visible and remove the parent */ |
| 719 | if (nhg->num_nh == 1) { | ||
| 720 | remove_nexthop(net, nhp, nlinfo); | ||
| 721 | return; | 721 | return; |
| 722 | } | ||
| 723 | |||
| 724 | newg->has_v4 = nhg->has_v4; | ||
| 725 | newg->mpath = nhg->mpath; | ||
| 726 | newg->num_nh = nhg->num_nh; | ||
| 722 | 727 | ||
| 723 | nhg->num_nh--; | 728 | /* copy old entries to new except the one getting removed */ |
| 724 | nhg->nh_entries[nhg->num_nh].nh = NULL; | 729 | nhges = nhg->nh_entries; |
| 730 | new_nhges = newg->nh_entries; | ||
| 731 | for (i = 0, j = 0; i < nhg->num_nh; ++i) { | ||
| 732 | /* current nexthop getting removed */ | ||
| 733 | if (nhg->nh_entries[i].nh == nh) { | ||
| 734 | newg->num_nh--; | ||
| 735 | continue; | ||
| 736 | } | ||
| 725 | 737 | ||
| 726 | nh_group_rebalance(nhg); | 738 | list_del(&nhges[i].nh_list); |
| 739 | new_nhges[j].nh_parent = nhges[i].nh_parent; | ||
| 740 | new_nhges[j].nh = nhges[i].nh; | ||
| 741 | new_nhges[j].weight = nhges[i].weight; | ||
| 742 | list_add(&new_nhges[j].nh_list, &new_nhges[j].nh->grp_list); | ||
| 743 | j++; | ||
| 744 | } | ||
| 727 | 745 | ||
| 728 | nexthop_put(nh); | 746 | nh_group_rebalance(newg); |
| 747 | rcu_assign_pointer(nhp->nh_grp, newg); | ||
| 748 | |||
| 749 | list_del(&nhge->nh_list); | ||
| 750 | nexthop_put(nhge->nh); | ||
| 729 | 751 | ||
| 730 | if (nlinfo) | 752 | if (nlinfo) |
| 731 | nexthop_notify(RTM_NEWNEXTHOP, nhge->nh_parent, nlinfo); | 753 | nexthop_notify(RTM_NEWNEXTHOP, nhp, nlinfo); |
| 732 | } | 754 | } |
| 733 | 755 | ||
| 734 | static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh, | 756 | static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh, |
| @@ -736,17 +758,11 @@ static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh, · 1 unmodified line | |||
| 736 | { | 758 | { |
| 737 | struct nh_grp_entry *nhge, *tmp; | 759 | struct nh_grp_entry *nhge, *tmp; |
| 738 | 760 | ||
| 739 | list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) { | 761 | list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) |
| 740 | struct nh_group *nhg; | 762 | remove_nh_grp_entry(net, nhge, nlinfo); |
| 741 | |||
| 742 | list_del(&nhge->nh_list); | ||
| 743 | nhg = rtnl_dereference(nhge->nh_parent->nh_grp); | ||
| 744 | remove_nh_grp_entry(nhge, nhg, nlinfo); | ||
| 745 | 763 | ||
| 746 | /* if this group has no more entries then remove it */ | 764 | /* make sure all see the newly published array before releasing rtnl */ |
| 747 | if (!nhg->num_nh) | 765 | synchronize_rcu(); |
| 748 | remove_nexthop(net, nhge->nh_parent, nlinfo); | ||
| 749 | } | ||
| 750 | } | 766 | } |
| 751 | 767 | ||
| 752 | static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo) | 768 | static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo) |
| @@ -760,10 +776,7 @@ static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo) · 7 unmodified lines | |||
| 760 | if (WARN_ON(!nhge->nh)) | 776 | if (WARN_ON(!nhge->nh)) |
| 761 | continue; | 777 | continue; |
| 762 | 778 | ||
| 763 | list_del(&nhge->nh_list); | 779 | list_del_init(&nhge->nh_list); |
| 764 | nexthop_put(nhge->nh); | ||
| 765 | nhge->nh = NULL; | ||
| 766 | nhg->num_nh--; | ||
| 767 | } | 780 | } |
| 768 | } | 781 | } |
| 769 | 782 | ||
| @@ -1086,6 +1099,7 @@ static struct nexthop *nexthop_create_group(struct net *net, · 316 unmodified lines | |||
| 1086 | { | 1099 | { |
| 1087 | struct nlattr *grps_attr = cfg->nh_grp; | 1100 | struct nlattr *grps_attr = cfg->nh_grp; |
| 1088 | struct nexthop_grp *entry = nla_data(grps_attr); | 1101 | struct nexthop_grp *entry = nla_data(grps_attr); |
| 1102 | u16 num_nh = nla_len(grps_attr) / sizeof(*entry); | ||
| 1089 | struct nh_group *nhg; | 1103 | struct nh_group *nhg; |
| 1090 | struct nexthop *nh; | 1104 | struct nexthop *nh; |
| 1091 | int i; | 1105 | int i; |
| @@ -1096,12 +1110,21 @@ static struct nexthop *nexthop_create_group(struct net *net, · 4 unmodified lines | |||
| 1096 | 1110 | ||
| 1097 | nh->is_group = 1; | 1111 | nh->is_group = 1; |
| 1098 | 1112 | ||
| 1099 | nhg = nexthop_grp_alloc(nla_len(grps_attr) / sizeof(*entry)); | 1113 | nhg = nexthop_grp_alloc(num_nh); |
| 1100 | if (!nhg) { | 1114 | if (!nhg) { |
| 1101 | kfree(nh); | 1115 | kfree(nh); |
| 1102 | return ERR_PTR(-ENOMEM); | 1116 | return ERR_PTR(-ENOMEM); |
| 1103 | } | 1117 | } |
| 1104 | 1118 | ||
| 1119 | /* spare group used for removals */ | ||
| 1120 | nhg->spare = nexthop_grp_alloc(num_nh); | ||
| 1121 | if (!nhg) { | ||
| 1122 | kfree(nhg); | ||
| 1123 | kfree(nh); | ||
| 1124 | return NULL; | ||
| 1125 | } | ||
| 1126 | nhg->spare->spare = nhg; | ||
| 1127 | |||
| 1105 | for (i = 0; i < nhg->num_nh; ++i) { | 1128 | for (i = 0; i < nhg->num_nh; ++i) { |
| 1106 | struct nexthop *nhe; | 1129 | struct nexthop *nhe; |
| 1107 | struct nh_info *nhi; | 1130 | struct nh_info *nhi; |
| @@ -1133,6 +1156,7 @@ out_no_nh: · 25 unmodified lines | |||
| 1133 | for (; i >= 0; --i) | 1156 | for (; i >= 0; --i) |
| 1134 | nexthop_put(nhg->nh_entries[i].nh); | 1157 | nexthop_put(nhg->nh_entries[i].nh); |
| 1135 | 1158 | ||
| 1159 | kfree(nhg->spare); | ||
| 1136 | kfree(nhg); | 1160 | kfree(nhg); |
| 1137 | kfree(nh); | 1161 | kfree(nh); |
| 1138 | 1162 | ||
| @@ -85,10 +85,8 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head, · 84 unmodified lines | |||
| 85 | sp->olen++; | 85 | sp->olen++; |
| 86 | 86 | ||
| 87 | xo = xfrm_offload(skb); | 87 | xo = xfrm_offload(skb); |
| 88 | if (!xo) { | 88 | if (!xo) |
| 89 | xfrm_state_put(x); | ||
| 90 | goto out_reset; | 89 | goto out_reset; |
| 91 | } | ||
| 92 | } | 90 | } |
| 93 | 91 | ||
| 94 | xo->flags |= XFRM_GRO; | 92 | xo->flags |= XFRM_GRO; |
| @@ -123,9 +121,16 @@ static void esp6_gso_encap(struct xfrm_state *x, struct sk_buff *skb) · 28 unmodified lines | |||
| 123 | struct ip_esp_hdr *esph; | 121 | struct ip_esp_hdr *esph; |
| 124 | struct ipv6hdr *iph = ipv6_hdr(skb); | 122 | struct ipv6hdr *iph = ipv6_hdr(skb); |
| 125 | struct xfrm_offload *xo = xfrm_offload(skb); | 123 | struct xfrm_offload *xo = xfrm_offload(skb); |
| 126 | int proto = iph->nexthdr; | 124 | u8 proto = iph->nexthdr; |
| 127 | 125 | ||
| 128 | skb_push(skb, -skb_network_offset(skb)); | 126 | skb_push(skb, -skb_network_offset(skb)); |
| 127 | |||
| 128 | if (x->outer_mode.encap == XFRM_MODE_TRANSPORT) { | ||
| 129 | __be16 frag; | ||
| 130 | |||
| 131 | ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &proto, &frag); | ||
| 132 | } | ||
| 133 | |||
| 129 | esph = ip_esp_hdr(skb); | 134 | esph = ip_esp_hdr(skb); |
| 130 | *skb_mac_header(skb) = IPPROTO_ESP; | 135 | *skb_mac_header(skb) = IPPROTO_ESP; |
| 131 | 136 | ||
| @@ -166,23 +171,31 @@ static struct sk_buff *xfrm6_beet_gso_segment(struct xfrm_state *x, · 34 unmodified lines | |||
| 166 | struct xfrm_offload *xo = xfrm_offload(skb); | 171 | struct xfrm_offload *xo = xfrm_offload(skb); |
| 167 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 172 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
| 168 | const struct net_offload *ops; | 173 | const struct net_offload *ops; |
| 169 | int proto = xo->proto; | 174 | u8 proto = xo->proto; |
| 170 | 175 | ||
| 171 | skb->transport_header += x->props.header_len; | 176 | skb->transport_header += x->props.header_len; |
| 172 | 177 | ||
| 173 | if (proto == IPPROTO_BEETPH) { | ||
| 174 | struct ip_beet_phdr *ph = (struct ip_beet_phdr *)skb->data; | ||
| 175 | |||
| 176 | skb->transport_header += ph->hdrlen * 8; | ||
| 177 | proto = ph->nexthdr; | ||
| 178 | } | ||
| 179 | |||
| 180 | if (x->sel.family != AF_INET6) { | 178 | if (x->sel.family != AF_INET6) { |
| 181 | skb->transport_header -= | 179 | skb->transport_header -= |
| 182 | (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); | 180 | (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); |
| 183 | 181 | ||
| 182 | if (proto == IPPROTO_BEETPH) { | ||
| 183 | struct ip_beet_phdr *ph = | ||
| 184 | (struct ip_beet_phdr *)skb->data; | ||
| 185 | |||
| 186 | skb->transport_header += ph->hdrlen * 8; | ||
| 187 | proto = ph->nexthdr; | ||
| 188 | } else { | ||
| 189 | skb->transport_header -= IPV4_BEET_PHMAXLEN; | ||
| 190 | } | ||
| 191 | |||
| 184 | if (proto == IPPROTO_TCP) | 192 | if (proto == IPPROTO_TCP) |
| 185 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; | 193 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; |
| 194 | } else { | ||
| 195 | __be16 frag; | ||
| 196 | |||
| 197 | skb->transport_header += | ||
| 198 | ipv6_skip_exthdr(skb, 0, &proto, &frag); | ||
| 186 | } | 199 | } |
| 187 | 200 | ||
| 188 | __skb_pull(skb, skb_transport_offset(skb)); | 201 | __skb_pull(skb, skb_transport_offset(skb)); |
| @@ -1458,6 +1458,9 @@ static int l2tp_validate_socket(const struct sock *sk, const struct net *net, · 1457 unmodified lines | |||
| 1458 | if (sk->sk_type != SOCK_DGRAM) | 1458 | if (sk->sk_type != SOCK_DGRAM) |
| 1459 | return -EPROTONOSUPPORT; | 1459 | return -EPROTONOSUPPORT; |
| 1460 | 1460 | ||
| 1461 | if (sk->sk_family != PF_INET && sk->sk_family != PF_INET6) | ||
| 1462 | return -EPROTONOSUPPORT; | ||
| 1463 | |||
| 1461 | if ((encap == L2TP_ENCAPTYPE_UDP && sk->sk_protocol != IPPROTO_UDP) || | 1464 | if ((encap == L2TP_ENCAPTYPE_UDP && sk->sk_protocol != IPPROTO_UDP) || |
| 1462 | (encap == L2TP_ENCAPTYPE_IP && sk->sk_protocol != IPPROTO_L2TP)) | 1465 | (encap == L2TP_ENCAPTYPE_IP && sk->sk_protocol != IPPROTO_L2TP)) |
| 1463 | return -EPROTONOSUPPORT; | 1466 | return -EPROTONOSUPPORT; |
| @@ -20,7 +20,6 @@ · 19 unmodified lines | |||
| 20 | #include <net/icmp.h> | 20 | #include <net/icmp.h> |
| 21 | #include <net/udp.h> | 21 | #include <net/udp.h> |
| 22 | #include <net/inet_common.h> | 22 | #include <net/inet_common.h> |
| 23 | #include <net/inet_hashtables.h> | ||
| 24 | #include <net/tcp_states.h> | 23 | #include <net/tcp_states.h> |
| 25 | #include <net/protocol.h> | 24 | #include <net/protocol.h> |
| 26 | #include <net/xfrm.h> | 25 | #include <net/xfrm.h> |
| @@ -209,15 +208,31 @@ discard: · 182 unmodified lines | |||
| 209 | return 0; | 208 | return 0; |
| 210 | } | 209 | } |
| 211 | 210 | ||
| 212 | static int l2tp_ip_open(struct sock *sk) | 211 | static int l2tp_ip_hash(struct sock *sk) |
| 213 | { | 212 | { |
| 214 | /* Prevent autobind. We don't have ports. */ | 213 | if (sk_unhashed(sk)) { |
| 215 | inet_sk(sk)->inet_num = IPPROTO_L2TP; | 214 | write_lock_bh(&l2tp_ip_lock); |
| 215 | sk_add_node(sk, &l2tp_ip_table); | ||
| 216 | write_unlock_bh(&l2tp_ip_lock); | ||
| 217 | } | ||
| 218 | return 0; | ||
| 219 | } | ||
| 216 | 220 | ||
| 221 | static void l2tp_ip_unhash(struct sock *sk) | ||
| 222 | { | ||
| 223 | if (sk_unhashed(sk)) | ||
| 224 | return; | ||
| 217 | write_lock_bh(&l2tp_ip_lock); | 225 | write_lock_bh(&l2tp_ip_lock); |
| 218 | sk_add_node(sk, &l2tp_ip_table); | 226 | sk_del_node_init(sk); |
| 219 | write_unlock_bh(&l2tp_ip_lock); | 227 | write_unlock_bh(&l2tp_ip_lock); |
| 228 | } | ||
| 229 | |||
| 230 | static int l2tp_ip_open(struct sock *sk) | ||
| 231 | { | ||
| 232 | /* Prevent autobind. We don't have ports. */ | ||
| 233 | inet_sk(sk)->inet_num = IPPROTO_L2TP; | ||
| 220 | 234 | ||
| 235 | l2tp_ip_hash(sk); | ||
| 221 | return 0; | 236 | return 0; |
| 222 | } | 237 | } |
| 223 | 238 | ||
| @@ -594,8 +609,8 @@ static struct proto l2tp_ip_prot = { · 370 unmodified lines | |||
| 594 | .sendmsg = l2tp_ip_sendmsg, | 609 | .sendmsg = l2tp_ip_sendmsg, |
| 595 | .recvmsg = l2tp_ip_recvmsg, | 610 | .recvmsg = l2tp_ip_recvmsg, |
| 596 | .backlog_rcv = l2tp_ip_backlog_recv, | 611 | .backlog_rcv = l2tp_ip_backlog_recv, |
| 597 | .hash = inet_hash, | 612 | .hash = l2tp_ip_hash, |
| 598 | .unhash = inet_unhash, | 613 | .unhash = l2tp_ip_unhash, |
| 599 | .obj_size = sizeof(struct l2tp_ip_sock), | 614 | .obj_size = sizeof(struct l2tp_ip_sock), |
| 600 | #ifdef CONFIG_COMPAT | 615 | #ifdef CONFIG_COMPAT |
| 601 | .compat_setsockopt = compat_ip_setsockopt, | 616 | .compat_setsockopt = compat_ip_setsockopt, |
| @@ -20,8 +20,6 @@ · 19 unmodified lines | |||
| 20 | #include <net/icmp.h> | 20 | #include <net/icmp.h> |
| 21 | #include <net/udp.h> | 21 | #include <net/udp.h> |
| 22 | #include <net/inet_common.h> | 22 | #include <net/inet_common.h> |
| 23 | #include <net/inet_hashtables.h> | ||
| 24 | #include <net/inet6_hashtables.h> | ||
| 25 | #include <net/tcp_states.h> | 23 | #include <net/tcp_states.h> |
| 26 | #include <net/protocol.h> | 24 | #include <net/protocol.h> |
| 27 | #include <net/xfrm.h> | 25 | #include <net/xfrm.h> |
| @@ -222,15 +220,31 @@ discard: · 194 unmodified lines | |||
| 222 | return 0; | 220 | return 0; |
| 223 | } | 221 | } |
| 224 | 222 | ||
| 225 | static int l2tp_ip6_open(struct sock *sk) | 223 | static int l2tp_ip6_hash(struct sock *sk) |
| 226 | { | 224 | { |
| 227 | /* Prevent autobind. We don't have ports. */ | 225 | if (sk_unhashed(sk)) { |
| 228 | inet_sk(sk)->inet_num = IPPROTO_L2TP; | 226 | write_lock_bh(&l2tp_ip6_lock); |
| 227 | sk_add_node(sk, &l2tp_ip6_table); | ||
| 228 | write_unlock_bh(&l2tp_ip6_lock); | ||
| 229 | } | ||
| 230 | return 0; | ||
| 231 | } | ||
| 229 | 232 | ||
| 233 | static void l2tp_ip6_unhash(struct sock *sk) | ||
| 234 | { | ||
| 235 | if (sk_unhashed(sk)) | ||
| 236 | return; | ||
| 230 | write_lock_bh(&l2tp_ip6_lock); | 237 | write_lock_bh(&l2tp_ip6_lock); |
| 231 | sk_add_node(sk, &l2tp_ip6_table); | 238 | sk_del_node_init(sk); |
| 232 | write_unlock_bh(&l2tp_ip6_lock); | 239 | write_unlock_bh(&l2tp_ip6_lock); |
| 240 | } | ||
| 241 | |||
| 242 | static int l2tp_ip6_open(struct sock *sk) | ||
| 243 | { | ||
| 244 | /* Prevent autobind. We don't have ports. */ | ||
| 245 | inet_sk(sk)->inet_num = IPPROTO_L2TP; | ||
| 233 | 246 | ||
| 247 | l2tp_ip6_hash(sk); | ||
| 234 | return 0; | 248 | return 0; |
| 235 | } | 249 | } |
| 236 | 250 | ||
| @@ -728,8 +742,8 @@ static struct proto l2tp_ip6_prot = { · 491 unmodified lines | |||
| 728 | .sendmsg = l2tp_ip6_sendmsg, | 742 | .sendmsg = l2tp_ip6_sendmsg, |
| 729 | .recvmsg = l2tp_ip6_recvmsg, | 743 | .recvmsg = l2tp_ip6_recvmsg, |
| 730 | .backlog_rcv = l2tp_ip6_backlog_recv, | 744 | .backlog_rcv = l2tp_ip6_backlog_recv, |
| 731 | .hash = inet6_hash, | 745 | .hash = l2tp_ip6_hash, |
| 732 | .unhash = inet_unhash, | 746 | .unhash = l2tp_ip6_unhash, |
| 733 | .obj_size = sizeof(struct l2tp_ip6_sock), | 747 | .obj_size = sizeof(struct l2tp_ip6_sock), |
| 734 | #ifdef CONFIG_COMPAT | 748 | #ifdef CONFIG_COMPAT |
| 735 | .compat_setsockopt = compat_ipv6_setsockopt, | 749 | .compat_setsockopt = compat_ipv6_setsockopt, |
| @@ -1103,7 +1103,14 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) · 1102 unmodified lines | |||
| 1103 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, ifmsh->sn, | 1103 | mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->vif.addr, ifmsh->sn, |
| 1104 | target_flags, mpath->dst, mpath->sn, da, 0, | 1104 | target_flags, mpath->dst, mpath->sn, da, 0, |
| 1105 | ttl, lifetime, 0, ifmsh->preq_id++, sdata); | 1105 | ttl, lifetime, 0, ifmsh->preq_id++, sdata); |
| 1106 | |||
| 1107 | spin_lock_bh(&mpath->state_lock); | ||
| 1108 | if (mpath->flags & MESH_PATH_DELETED) { | ||
| 1109 | spin_unlock_bh(&mpath->state_lock); | ||
| 1110 | goto enddiscovery; | ||
| 1111 | } | ||
| 1106 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); | 1112 | mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); |
| 1113 | spin_unlock_bh(&mpath->state_lock); | ||
| 1107 | 1114 | ||
| 1108 | enddiscovery: | 1115 | enddiscovery: |
| 1109 | rcu_read_unlock(); | 1116 | rcu_read_unlock(); |
| @@ -954,7 +954,8 @@ fallback: · 953 unmodified lines | |||
| 954 | 954 | ||
| 955 | pr_debug("block timeout %ld", timeo); | 955 | pr_debug("block timeout %ld", timeo); |
| 956 | mptcp_wait_data(sk, &timeo); | 956 | mptcp_wait_data(sk, &timeo); |
| 957 | if (unlikely(__mptcp_tcp_fallback(msk))) | 957 | ssock = __mptcp_tcp_fallback(msk); |
| 958 | if (unlikely(ssock)) | ||
| 958 | goto fallback; | 959 | goto fallback; |
| 959 | } | 960 | } |
| 960 | 961 | ||
| @@ -1262,11 +1263,14 @@ static void mptcp_close(struct sock *sk, long timeout) · 301 unmodified lines | |||
| 1262 | 1263 | ||
| 1263 | lock_sock(sk); | 1264 | lock_sock(sk); |
| 1264 | 1265 | ||
| 1265 | mptcp_token_destroy(msk->token); | ||
| 1266 | inet_sk_state_store(sk, TCP_CLOSE); | 1266 | inet_sk_state_store(sk, TCP_CLOSE); |
| 1267 | 1267 | ||
| 1268 | __mptcp_flush_join_list(msk); | 1268 | /* be sure to always acquire the join list lock, to sync vs |
| 1269 | 1269 | * mptcp_finish_join(). | |
| 1270 | */ | ||
| 1271 | spin_lock_bh(&msk->join_list_lock); | ||
| 1272 | list_splice_tail_init(&msk->join_list, &msk->conn_list); | ||
| 1273 | spin_unlock_bh(&msk->join_list_lock); | ||
| 1270 | list_splice_init(&msk->conn_list, &conn_list); | 1274 | list_splice_init(&msk->conn_list, &conn_list); |
| 1271 | 1275 | ||
| 1272 | data_fin_tx_seq = msk->write_seq; | 1276 | data_fin_tx_seq = msk->write_seq; |
| @@ -1456,6 +1460,7 @@ static void mptcp_destroy(struct sock *sk) · 183 unmodified lines | |||
| 1456 | { | 1460 | { |
| 1457 | struct mptcp_sock *msk = mptcp_sk(sk); | 1461 | struct mptcp_sock *msk = mptcp_sk(sk); |
| 1458 | 1462 | ||
| 1463 | mptcp_token_destroy(msk->token); | ||
| 1459 | if (msk->cached_ext) | 1464 | if (msk->cached_ext) |
| 1460 | __skb_ext_put(msk->cached_ext); | 1465 | __skb_ext_put(msk->cached_ext); |
| 1461 | 1466 | ||
| @@ -1622,22 +1627,30 @@ bool mptcp_finish_join(struct sock *sk) · 160 unmodified lines | |||
| 1622 | if (!msk->pm.server_side) | 1627 | if (!msk->pm.server_side) |
| 1623 | return true; | 1628 | return true; |
| 1624 | 1629 | ||
| 1625 | /* passive connection, attach to msk socket */ | 1630 | if (!mptcp_pm_allow_new_subflow(msk)) |
| 1631 | return false; | ||
| 1632 | |||
| 1633 | /* active connections are already on conn_list, and we can't acquire | ||
| 1634 | * msk lock here. | ||
| 1635 | * use the join list lock as synchronization point and double-check | ||
| 1636 | * msk status to avoid racing with mptcp_close() | ||
| 1637 | */ | ||
| 1638 | spin_lock_bh(&msk->join_list_lock); | ||
| 1639 | ret = inet_sk_state_load(parent) == TCP_ESTABLISHED; | ||
| 1640 | if (ret && !WARN_ON_ONCE(!list_empty(&subflow->node))) | ||
| 1641 | list_add_tail(&subflow->node, &msk->join_list); | ||
| 1642 | spin_unlock_bh(&msk->join_list_lock); | ||
| 1643 | if (!ret) | ||
| 1644 | return false; | ||
| 1645 | |||
| 1646 | /* attach to msk socket only after we are sure he will deal with us | ||
| 1647 | * at close time | ||
| 1648 | */ | ||
| 1626 | parent_sock = READ_ONCE(parent->sk_socket); | 1649 | parent_sock = READ_ONCE(parent->sk_socket); |
| 1627 | if (parent_sock && !sk->sk_socket) | 1650 | if (parent_sock && !sk->sk_socket) |
| 1628 | mptcp_sock_graft(sk, parent_sock); | 1651 | mptcp_sock_graft(sk, parent_sock); |
| 1629 | 1652 | subflow->map_seq = msk->ack_seq; | |
| 1630 | ret = mptcp_pm_allow_new_subflow(msk); | 1653 | return true; |
| 1631 | if (ret) { | ||
| 1632 | subflow->map_seq = msk->ack_seq; | ||
| 1633 | |||
| 1634 | /* active connections are already on conn_list */ | ||
| 1635 | spin_lock_bh(&msk->join_list_lock); | ||
| 1636 | if (!WARN_ON_ONCE(!list_empty(&subflow->node))) | ||
| 1637 | list_add_tail(&subflow->node, &msk->join_list); | ||
| 1638 | spin_unlock_bh(&msk->join_list_lock); | ||
| 1639 | } | ||
| 1640 | return ret; | ||
| 1641 | } | 1654 | } |
| 1642 | 1655 | ||
| 1643 | bool mptcp_sk_is_subflow(const struct sock *sk) | 1656 | bool mptcp_sk_is_subflow(const struct sock *sk) |
| @@ -1711,6 +1724,14 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, · 67 unmodified lines | |||
| 1711 | int err; | 1724 | int err; |
| 1712 | 1725 | ||
| 1713 | lock_sock(sock->sk); | 1726 | lock_sock(sock->sk); |
| 1727 | if (sock->state != SS_UNCONNECTED && msk->subflow) { | ||
| 1728 | /* pending connection or invalid state, let existing subflow | ||
| 1729 | * cope with that | ||
| 1730 | */ | ||
| 1731 | ssock = msk->subflow; | ||
| 1732 | goto do_connect; | ||
| 1733 | } | ||
| 1734 | |||
| 1714 | ssock = __mptcp_socket_create(msk, TCP_SYN_SENT); | 1735 | ssock = __mptcp_socket_create(msk, TCP_SYN_SENT); |
| 1715 | if (IS_ERR(ssock)) { | 1736 | if (IS_ERR(ssock)) { |
| 1716 | err = PTR_ERR(ssock); | 1737 | err = PTR_ERR(ssock); |
| @@ -1725,9 +1746,17 @@ static int mptcp_stream_connect(struct socket *sock, struct sockaddr *uaddr, · 8 unmodified lines | |||
| 1725 | mptcp_subflow_ctx(ssock->sk)->request_mptcp = 0; | 1746 | mptcp_subflow_ctx(ssock->sk)->request_mptcp = 0; |
| 1726 | #endif | 1747 | #endif |
| 1727 | 1748 | ||
| 1749 | do_connect: | ||
| 1728 | err = ssock->ops->connect(ssock, uaddr, addr_len, flags); | 1750 | err = ssock->ops->connect(ssock, uaddr, addr_len, flags); |
| 1729 | inet_sk_state_store(sock->sk, inet_sk_state_load(ssock->sk)); | 1751 | sock->state = ssock->state; |
| 1730 | mptcp_copy_inaddrs(sock->sk, ssock->sk); | 1752 | |
| 1753 | /* on successful connect, the msk state will be moved to established by | ||
| 1754 | * subflow_finish_connect() | ||
| 1755 | */ | ||
| 1756 | if (!err || err == EINPROGRESS) | ||
| 1757 | mptcp_copy_inaddrs(sock->sk, ssock->sk); | ||
| 1758 | else | ||
| 1759 | inet_sk_state_store(sock->sk, inet_sk_state_load(ssock->sk)); | ||
| 1731 | 1760 | ||
| 1732 | unlock: | 1761 | unlock: |
| 1733 | release_sock(sock->sk); | 1762 | release_sock(sock->sk); |
| @@ -59,7 +59,7 @@ list_set_ktest(struct ip_set *set, const struct sk_buff *skb, · 58 unmodified lines | |||
| 59 | /* Don't lookup sub-counters at all */ | 59 | /* Don't lookup sub-counters at all */ |
| 60 | opt->cmdflags &= ~IPSET_FLAG_MATCH_COUNTERS; | 60 | opt->cmdflags &= ~IPSET_FLAG_MATCH_COUNTERS; |
| 61 | if (opt->cmdflags & IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE) | 61 | if (opt->cmdflags & IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE) |
| 62 | opt->cmdflags &= ~IPSET_FLAG_SKIP_COUNTER_UPDATE; | 62 | opt->cmdflags |= IPSET_FLAG_SKIP_COUNTER_UPDATE; |
| 63 | list_for_each_entry_rcu(e, &map->members, list) { | 63 | list_for_each_entry_rcu(e, &map->members, list) { |
| 64 | ret = ip_set_test(e->id, skb, par, opt); | 64 | ret = ip_set_test(e->id, skb, par, opt); |
| 65 | if (ret <= 0) | 65 | if (ret <= 0) |
| @@ -2016,22 +2016,18 @@ static void nf_conntrack_attach(struct sk_buff *nskb, const struct sk_buff *skb) · 2015 unmodified lines | |||
| 2016 | nf_conntrack_get(skb_nfct(nskb)); | 2016 | nf_conntrack_get(skb_nfct(nskb)); |
| 2017 | } | 2017 | } |
| 2018 | 2018 | ||
| 2019 | static int nf_conntrack_update(struct net *net, struct sk_buff *skb) | 2019 | static int __nf_conntrack_update(struct net *net, struct sk_buff *skb, |
| 2020 | struct nf_conn *ct, | ||
| 2021 | enum ip_conntrack_info ctinfo) | ||
| 2020 | { | 2022 | { |
| 2021 | struct nf_conntrack_tuple_hash *h; | 2023 | struct nf_conntrack_tuple_hash *h; |
| 2022 | struct nf_conntrack_tuple tuple; | 2024 | struct nf_conntrack_tuple tuple; |
| 2023 | enum ip_conntrack_info ctinfo; | ||
| 2024 | struct nf_nat_hook *nat_hook; | 2025 | struct nf_nat_hook *nat_hook; |
| 2025 | unsigned int status; | 2026 | unsigned int status; |
| 2026 | struct nf_conn *ct; | ||
| 2027 | int dataoff; | 2027 | int dataoff; |
| 2028 | u16 l3num; | 2028 | u16 l3num; |
| 2029 | u8 l4num; | 2029 | u8 l4num; |
| 2030 | 2030 | ||
| 2031 | ct = nf_ct_get(skb, &ctinfo); | ||
| 2032 | if (!ct || nf_ct_is_confirmed(ct)) | ||
| 2033 | return 0; | ||
| 2034 | |||
| 2035 | l3num = nf_ct_l3num(ct); | 2031 | l3num = nf_ct_l3num(ct); |
| 2036 | 2032 | ||
| 2037 | dataoff = get_l4proto(skb, skb_network_offset(skb), l3num, &l4num); | 2033 | dataoff = get_l4proto(skb, skb_network_offset(skb), l3num, &l4num); |
| @@ -2088,6 +2084,76 @@ static int nf_conntrack_update(struct net *net, struct sk_buff *skb) · 50 unmodified lines | |||
| 2088 | return 0; | 2084 | return 0; |
| 2089 | } | 2085 | } |
| 2090 | 2086 | ||
| 2087 | /* This packet is coming from userspace via nf_queue, complete the packet | ||
| 2088 | * processing after the helper invocation in nf_confirm(). | ||
| 2089 | */ | ||
| 2090 | static int nf_confirm_cthelper(struct sk_buff *skb, struct nf_conn *ct, | ||
| 2091 | enum ip_conntrack_info ctinfo) | ||
| 2092 | { | ||
| 2093 | const struct nf_conntrack_helper *helper; | ||
| 2094 | const struct nf_conn_help *help; | ||
| 2095 | int protoff; | ||
| 2096 | |||
| 2097 | help = nfct_help(ct); | ||
| 2098 | if (!help) | ||
| 2099 | return 0; | ||
| 2100 | |||
| 2101 | helper = rcu_dereference(help->helper); | ||
| 2102 | if (!(helper->flags & NF_CT_HELPER_F_USERSPACE)) | ||
| 2103 | return 0; | ||
| 2104 | |||
| 2105 | switch (nf_ct_l3num(ct)) { | ||
| 2106 | case NFPROTO_IPV4: | ||
| 2107 | protoff = skb_network_offset(skb) + ip_hdrlen(skb); | ||
| 2108 | break; | ||
| 2109 | #if IS_ENABLED(CONFIG_IPV6) | ||
| 2110 | case NFPROTO_IPV6: { | ||
| 2111 | __be16 frag_off; | ||
| 2112 | u8 pnum; | ||
| 2113 | |||
| 2114 | pnum = ipv6_hdr(skb)->nexthdr; | ||
| 2115 | protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, | ||
| 2116 | &frag_off); | ||
| 2117 | if (protoff < 0 || (frag_off & htons(~0x7)) != 0) | ||
| 2118 | return 0; | ||
| 2119 | break; | ||
| 2120 | } | ||
| 2121 | #endif | ||
| 2122 | default: | ||
| 2123 | return 0; | ||
| 2124 | } | ||
| 2125 | |||
| 2126 | if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) && | ||
| 2127 | !nf_is_loopback_packet(skb)) { | ||
| 2128 | if (!nf_ct_seq_adjust(skb, ct, ctinfo, protoff)) { | ||
| 2129 | NF_CT_STAT_INC_ATOMIC(nf_ct_net(ct), drop); | ||
| 2130 | return -1; | ||
| 2131 | } | ||
| 2132 | } | ||
| 2133 | |||
| 2134 | /* We've seen it coming out the other side: confirm it */ | ||
| 2135 | return nf_conntrack_confirm(skb) == NF_DROP ? - 1 : 0; | ||
| 2136 | } | ||
| 2137 | |||
| 2138 | static int nf_conntrack_update(struct net *net, struct sk_buff *skb) | ||
| 2139 | { | ||
| 2140 | enum ip_conntrack_info ctinfo; | ||
| 2141 | struct nf_conn *ct; | ||
| 2142 | int err; | ||
| 2143 | |||
| 2144 | ct = nf_ct_get(skb, &ctinfo); | ||
| 2145 | if (!ct) | ||
| 2146 | return 0; | ||
| 2147 | |||
| 2148 | if (!nf_ct_is_confirmed(ct)) { | ||
| 2149 | err = __nf_conntrack_update(net, skb, ct, ctinfo); | ||
| 2150 | if (err < 0) | ||
| 2151 | return err; | ||
| 2152 | } | ||
| 2153 | |||
| 2154 | return nf_confirm_cthelper(skb, ct, ctinfo); | ||
| 2155 | } | ||
| 2156 | |||
| 2091 | static bool nf_conntrack_get_tuple_skb(struct nf_conntrack_tuple *dst_tuple, | 2157 | static bool nf_conntrack_get_tuple_skb(struct nf_conntrack_tuple *dst_tuple, |
| 2092 | const struct sk_buff *skb) | 2158 | const struct sk_buff *skb) |
| 2093 | { | 2159 | { |
| @@ -72,24 +72,32 @@ EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn); · 71 unmodified lines | |||
| 72 | 72 | ||
| 73 | #if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) | 73 | #if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) |
| 74 | /* PptpControlMessageType names */ | 74 | /* PptpControlMessageType names */ |
| 75 | const char *const pptp_msg_name[] = { | 75 | static const char *const pptp_msg_name_array[PPTP_MSG_MAX + 1] = { |
| 76 | "UNKNOWN_MESSAGE", | 76 | [0] = "UNKNOWN_MESSAGE", |
| 77 | "START_SESSION_REQUEST", | 77 | [PPTP_START_SESSION_REQUEST] = "START_SESSION_REQUEST", |
| 78 | "START_SESSION_REPLY", | 78 | [PPTP_START_SESSION_REPLY] = "START_SESSION_REPLY", |
| 79 | "STOP_SESSION_REQUEST", | 79 | [PPTP_STOP_SESSION_REQUEST] = "STOP_SESSION_REQUEST", |
| 80 | "STOP_SESSION_REPLY", | 80 | [PPTP_STOP_SESSION_REPLY] = "STOP_SESSION_REPLY", |
| 81 | "ECHO_REQUEST", | 81 | [PPTP_ECHO_REQUEST] = "ECHO_REQUEST", |
| 82 | "ECHO_REPLY", | 82 | [PPTP_ECHO_REPLY] = "ECHO_REPLY", |
| 83 | "OUT_CALL_REQUEST", | 83 | [PPTP_OUT_CALL_REQUEST] = "OUT_CALL_REQUEST", |
| 84 | "OUT_CALL_REPLY", | 84 | [PPTP_OUT_CALL_REPLY] = "OUT_CALL_REPLY", |
| 85 | "IN_CALL_REQUEST", | 85 | [PPTP_IN_CALL_REQUEST] = "IN_CALL_REQUEST", |
| 86 | "IN_CALL_REPLY", | 86 | [PPTP_IN_CALL_REPLY] = "IN_CALL_REPLY", |
| 87 | "IN_CALL_CONNECT", | 87 | [PPTP_IN_CALL_CONNECT] = "IN_CALL_CONNECT", |
| 88 | "CALL_CLEAR_REQUEST", | 88 | [PPTP_CALL_CLEAR_REQUEST] = "CALL_CLEAR_REQUEST", |
| 89 | "CALL_DISCONNECT_NOTIFY", | 89 | [PPTP_CALL_DISCONNECT_NOTIFY] = "CALL_DISCONNECT_NOTIFY", |
| 90 | "WAN_ERROR_NOTIFY", | 90 | [PPTP_WAN_ERROR_NOTIFY] = "WAN_ERROR_NOTIFY", |
| 91 | "SET_LINK_INFO" | 91 | [PPTP_SET_LINK_INFO] = "SET_LINK_INFO" |
| 92 | }; | 92 | }; |
| 93 | |||
| 94 | const char *pptp_msg_name(u_int16_t msg) | ||
| 95 | { | ||
| 96 | if (msg > PPTP_MSG_MAX) | ||
| 97 | return pptp_msg_name_array[0]; | ||
| 98 | |||
| 99 | return pptp_msg_name_array[msg]; | ||
| 100 | } | ||
| 93 | EXPORT_SYMBOL(pptp_msg_name); | 101 | EXPORT_SYMBOL(pptp_msg_name); |
| 94 | #endif | 102 | #endif |
| 95 | 103 | ||
| @@ -276,7 +284,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff, · 180 unmodified lines | |||
| 276 | typeof(nf_nat_pptp_hook_inbound) nf_nat_pptp_inbound; | 284 | typeof(nf_nat_pptp_hook_inbound) nf_nat_pptp_inbound; |
| 277 | 285 | ||
| 278 | msg = ntohs(ctlh->messageType); | 286 | msg = ntohs(ctlh->messageType); |
| 279 | pr_debug("inbound control message %s\n", pptp_msg_name[msg]); | 287 | pr_debug("inbound control message %s\n", pptp_msg_name(msg)); |
| 280 | 288 | ||
| 281 | switch (msg) { | 289 | switch (msg) { |
| 282 | case PPTP_START_SESSION_REPLY: | 290 | case PPTP_START_SESSION_REPLY: |
| @@ -311,7 +319,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff, · 28 unmodified lines | |||
| 311 | pcid = pptpReq->ocack.peersCallID; | 319 | pcid = pptpReq->ocack.peersCallID; |
| 312 | if (info->pns_call_id != pcid) | 320 | if (info->pns_call_id != pcid) |
| 313 | goto invalid; | 321 | goto invalid; |
| 314 | pr_debug("%s, CID=%X, PCID=%X\n", pptp_msg_name[msg], | 322 | pr_debug("%s, CID=%X, PCID=%X\n", pptp_msg_name(msg), |
| 315 | ntohs(cid), ntohs(pcid)); | 323 | ntohs(cid), ntohs(pcid)); |
| 316 | 324 | ||
| 317 | if (pptpReq->ocack.resultCode == PPTP_OUTCALL_CONNECT) { | 325 | if (pptpReq->ocack.resultCode == PPTP_OUTCALL_CONNECT) { |
| @@ -328,7 +336,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff, · 10 unmodified lines | |||
| 328 | goto invalid; | 336 | goto invalid; |
| 329 | 337 | ||
| 330 | cid = pptpReq->icreq.callID; | 338 | cid = pptpReq->icreq.callID; |
| 331 | pr_debug("%s, CID=%X\n", pptp_msg_name[msg], ntohs(cid)); | 339 | pr_debug("%s, CID=%X\n", pptp_msg_name(msg), ntohs(cid)); |
| 332 | info->cstate = PPTP_CALL_IN_REQ; | 340 | info->cstate = PPTP_CALL_IN_REQ; |
| 333 | info->pac_call_id = cid; | 341 | info->pac_call_id = cid; |
| 334 | break; | 342 | break; |
| @@ -347,7 +355,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff, · 12 unmodified lines | |||
| 347 | if (info->pns_call_id != pcid) | 355 | if (info->pns_call_id != pcid) |
| 348 | goto invalid; | 356 | goto invalid; |
| 349 | 357 | ||
| 350 | pr_debug("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(pcid)); | 358 | pr_debug("%s, PCID=%X\n", pptp_msg_name(msg), ntohs(pcid)); |
| 351 | info->cstate = PPTP_CALL_IN_CONF; | 359 | info->cstate = PPTP_CALL_IN_CONF; |
| 352 | 360 | ||
| 353 | /* we expect a GRE connection from PAC to PNS */ | 361 | /* we expect a GRE connection from PAC to PNS */ |
| @@ -357,7 +365,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff, · 3 unmodified lines | |||
| 357 | case PPTP_CALL_DISCONNECT_NOTIFY: | 365 | case PPTP_CALL_DISCONNECT_NOTIFY: |
| 358 | /* server confirms disconnect */ | 366 | /* server confirms disconnect */ |
| 359 | cid = pptpReq->disc.callID; | 367 | cid = pptpReq->disc.callID; |
| 360 | pr_debug("%s, CID=%X\n", pptp_msg_name[msg], ntohs(cid)); | 368 | pr_debug("%s, CID=%X\n", pptp_msg_name(msg), ntohs(cid)); |
| 361 | info->cstate = PPTP_CALL_NONE; | 369 | info->cstate = PPTP_CALL_NONE; |
| 362 | 370 | ||
| 363 | /* untrack this call id, unexpect GRE packets */ | 371 | /* untrack this call id, unexpect GRE packets */ |
| @@ -384,7 +392,7 @@ pptp_inbound_pkt(struct sk_buff *skb, unsigned int protoff, · 20 unmodified lines | |||
| 384 | invalid: | 392 | invalid: |
| 385 | pr_debug("invalid %s: type=%d cid=%u pcid=%u " | 393 | pr_debug("invalid %s: type=%d cid=%u pcid=%u " |
| 386 | "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n", | 394 | "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n", |
| 387 | msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] : pptp_msg_name[0], | 395 | pptp_msg_name(msg), |
| 388 | msg, ntohs(cid), ntohs(pcid), info->cstate, info->sstate, | 396 | msg, ntohs(cid), ntohs(pcid), info->cstate, info->sstate, |
| 389 | ntohs(info->pns_call_id), ntohs(info->pac_call_id)); | 397 | ntohs(info->pns_call_id), ntohs(info->pac_call_id)); |
| 390 | return NF_ACCEPT; | 398 | return NF_ACCEPT; |
| @@ -404,7 +412,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff, · 13 unmodified lines | |||
| 404 | typeof(nf_nat_pptp_hook_outbound) nf_nat_pptp_outbound; | 412 | typeof(nf_nat_pptp_hook_outbound) nf_nat_pptp_outbound; |
| 405 | 413 | ||
| 406 | msg = ntohs(ctlh->messageType); | 414 | msg = ntohs(ctlh->messageType); |
| 407 | pr_debug("outbound control message %s\n", pptp_msg_name[msg]); | 415 | pr_debug("outbound control message %s\n", pptp_msg_name(msg)); |
| 408 | 416 | ||
| 409 | switch (msg) { | 417 | switch (msg) { |
| 410 | case PPTP_START_SESSION_REQUEST: | 418 | case PPTP_START_SESSION_REQUEST: |
| @@ -426,7 +434,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff, · 15 unmodified lines | |||
| 426 | info->cstate = PPTP_CALL_OUT_REQ; | 434 | info->cstate = PPTP_CALL_OUT_REQ; |
| 427 | /* track PNS call id */ | 435 | /* track PNS call id */ |
| 428 | cid = pptpReq->ocreq.callID; | 436 | cid = pptpReq->ocreq.callID; |
| 429 | pr_debug("%s, CID=%X\n", pptp_msg_name[msg], ntohs(cid)); | 437 | pr_debug("%s, CID=%X\n", pptp_msg_name(msg), ntohs(cid)); |
| 430 | info->pns_call_id = cid; | 438 | info->pns_call_id = cid; |
| 431 | break; | 439 | break; |
| 432 | 440 | ||
| @@ -440,7 +448,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff, · 7 unmodified lines | |||
| 440 | pcid = pptpReq->icack.peersCallID; | 448 | pcid = pptpReq->icack.peersCallID; |
| 441 | if (info->pac_call_id != pcid) | 449 | if (info->pac_call_id != pcid) |
| 442 | goto invalid; | 450 | goto invalid; |
| 443 | pr_debug("%s, CID=%X PCID=%X\n", pptp_msg_name[msg], | 451 | pr_debug("%s, CID=%X PCID=%X\n", pptp_msg_name(msg), |
| 444 | ntohs(cid), ntohs(pcid)); | 452 | ntohs(cid), ntohs(pcid)); |
| 445 | 453 | ||
| 446 | if (pptpReq->icack.resultCode == PPTP_INCALL_ACCEPT) { | 454 | if (pptpReq->icack.resultCode == PPTP_INCALL_ACCEPT) { |
| @@ -480,7 +488,7 @@ pptp_outbound_pkt(struct sk_buff *skb, unsigned int protoff, · 33 unmodified lines | |||
| 480 | invalid: | 488 | invalid: |
| 481 | pr_debug("invalid %s: type=%d cid=%u pcid=%u " | 489 | pr_debug("invalid %s: type=%d cid=%u pcid=%u " |
| 482 | "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n", | 490 | "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n", |
| 483 | msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] : pptp_msg_name[0], | 491 | pptp_msg_name(msg), |
| 484 | msg, ntohs(cid), ntohs(pcid), info->cstate, info->sstate, | 492 | msg, ntohs(cid), ntohs(pcid), info->cstate, info->sstate, |
| 485 | ntohs(info->pns_call_id), ntohs(info->pac_call_id)); | 493 | ntohs(info->pns_call_id), ntohs(info->pac_call_id)); |
| 486 | return NF_ACCEPT; | 494 | return NF_ACCEPT; |
| @@ -103,7 +103,7 @@ nfnl_cthelper_from_nlattr(struct nlattr *attr, struct nf_conn *ct) · 102 unmodified lines | |||
| 103 | if (help->helper->data_len == 0) | 103 | if (help->helper->data_len == 0) |
| 104 | return -EINVAL; | 104 | return -EINVAL; |
| 105 | 105 | ||
| 106 | nla_memcpy(help->data, nla_data(attr), sizeof(help->data)); | 106 | nla_memcpy(help->data, attr, sizeof(help->data)); |
| 107 | return 0; | 107 | return 0; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| @@ -240,6 +240,7 @@ nfnl_cthelper_create(const struct nlattr * const tb[], · 130 unmodified lines | |||
| 240 | ret = -ENOMEM; | 240 | ret = -ENOMEM; |
| 241 | goto err2; | 241 | goto err2; |
| 242 | } | 242 | } |
| 243 | helper->data_len = size; | ||
| 243 | 244 | ||
| 244 | helper->flags |= NF_CT_HELPER_F_USERSPACE; | 245 | helper->flags |= NF_CT_HELPER_F_USERSPACE; |
| 245 | memcpy(&helper->tuple, tuple, sizeof(struct nf_conntrack_tuple)); | 246 | memcpy(&helper->tuple, tuple, sizeof(struct nf_conntrack_tuple)); |
| @@ -712,6 +712,10 @@ void qrtr_ns_init(void) · 711 unmodified lines | |||
| 712 | goto err_sock; | 712 | goto err_sock; |
| 713 | } | 713 | } |
| 714 | 714 | ||
| 715 | qrtr_ns.workqueue = alloc_workqueue("qrtr_ns_handler", WQ_UNBOUND, 1); | ||
| 716 | if (!qrtr_ns.workqueue) | ||
| 717 | goto err_sock; | ||
| 718 | |||
| 715 | qrtr_ns.sock->sk->sk_data_ready = qrtr_ns_data_ready; | 719 | qrtr_ns.sock->sk->sk_data_ready = qrtr_ns_data_ready; |
| 716 | 720 | ||
| 717 | sq.sq_port = QRTR_PORT_CTRL; | 721 | sq.sq_port = QRTR_PORT_CTRL; |
| @@ -720,17 +724,13 @@ void qrtr_ns_init(void) · 2 unmodified lines | |||
| 720 | ret = kernel_bind(qrtr_ns.sock, (struct sockaddr *)&sq, sizeof(sq)); | 724 | ret = kernel_bind(qrtr_ns.sock, (struct sockaddr *)&sq, sizeof(sq)); |
| 721 | if (ret < 0) { | 725 | if (ret < 0) { |
| 722 | pr_err("failed to bind to socket\n"); | 726 | pr_err("failed to bind to socket\n"); |
| 723 | goto err_sock; | 727 | goto err_wq; |
| 724 | } | 728 | } |
| 725 | 729 | ||
| 726 | qrtr_ns.bcast_sq.sq_family = AF_QIPCRTR; | 730 | qrtr_ns.bcast_sq.sq_family = AF_QIPCRTR; |
| 727 | qrtr_ns.bcast_sq.sq_node = QRTR_NODE_BCAST; | 731 | qrtr_ns.bcast_sq.sq_node = QRTR_NODE_BCAST; |
| 728 | qrtr_ns.bcast_sq.sq_port = QRTR_PORT_CTRL; | 732 | qrtr_ns.bcast_sq.sq_port = QRTR_PORT_CTRL; |
| 729 | 733 | ||
| 730 | qrtr_ns.workqueue = alloc_workqueue("qrtr_ns_handler", WQ_UNBOUND, 1); | ||
| 731 | if (!qrtr_ns.workqueue) | ||
| 732 | goto err_sock; | ||
| 733 | |||
| 734 | ret = say_hello(&qrtr_ns.bcast_sq); | 734 | ret = say_hello(&qrtr_ns.bcast_sq); |
| 735 | if (ret < 0) | 735 | if (ret < 0) |
| 736 | goto err_wq; | 736 | goto err_wq; |
| @@ -199,6 +199,9 @@ static int tcf_ct_flow_table_add_action_nat(struct net *net, · 198 unmodified lines | |||
| 199 | const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple; | 199 | const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple; |
| 200 | struct nf_conntrack_tuple target; | 200 | struct nf_conntrack_tuple target; |
| 201 | 201 | ||
| 202 | if (!(ct->status & IPS_NAT_MASK)) | ||
| 203 | return 0; | ||
| 204 | |||
| 202 | nf_ct_invert_tuple(&target, &ct->tuplehash[!dir].tuple); | 205 | nf_ct_invert_tuple(&target, &ct->tuplehash[!dir].tuple); |
| 203 | 206 | ||
| 204 | switch (tuple->src.l3num) { | 207 | switch (tuple->src.l3num) { |
| @@ -297,9 +297,9 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt, · 296 unmodified lines | |||
| 297 | goto flow_error; | 297 | goto flow_error; |
| 298 | } | 298 | } |
| 299 | q->flows_cnt = nla_get_u32(tb[TCA_FQ_PIE_FLOWS]); | 299 | q->flows_cnt = nla_get_u32(tb[TCA_FQ_PIE_FLOWS]); |
| 300 | if (!q->flows_cnt || q->flows_cnt > 65536) { | 300 | if (!q->flows_cnt || q->flows_cnt >= 65536) { |
| 301 | NL_SET_ERR_MSG_MOD(extack, | 301 | NL_SET_ERR_MSG_MOD(extack, |
| 302 | "Number of flows must be < 65536"); | 302 | "Number of flows must range in [1..65535]"); |
| 303 | goto flow_error; | 303 | goto flow_error; |
| 304 | } | 304 | } |
| 305 | } | 305 | } |
| @@ -31,7 +31,7 @@ menuconfig IP_SCTP · 30 unmodified lines | |||
| 31 | homing at either or both ends of an association." | 31 | homing at either or both ends of an association." |
| 32 | 32 | ||
| 33 | To compile this protocol support as a module, choose M here: the | 33 | To compile this protocol support as a module, choose M here: the |
| 34 | module will be called sctp. Debug messages are handeled by the | 34 | module will be called sctp. Debug messages are handled by the |
| 35 | kernel's dynamic debugging framework. | 35 | kernel's dynamic debugging framework. |
| 36 | 36 | ||
| 37 | If in doubt, say N. | 37 | If in doubt, say N. |
| @@ -343,6 +343,9 @@ void sctp_ulpevent_nofity_peer_addr_change(struct sctp_transport *transport, · 342 unmodified lines | |||
| 343 | struct sockaddr_storage addr; | 343 | struct sockaddr_storage addr; |
| 344 | struct sctp_ulpevent *event; | 344 | struct sctp_ulpevent *event; |
| 345 | 345 | ||
| 346 | if (asoc->state < SCTP_STATE_ESTABLISHED) | ||
| 347 | return; | ||
| 348 | |||
| 346 | memset(&addr, 0, sizeof(struct sockaddr_storage)); | 349 | memset(&addr, 0, sizeof(struct sockaddr_storage)); |
| 347 | memcpy(&addr, &transport->ipaddr, transport->af_specific->sockaddr_len); | 350 | memcpy(&addr, &transport->ipaddr, transport->af_specific->sockaddr_len); |
| 348 | 351 | ||
| @@ -206,10 +206,12 @@ static void tls_decrypt_done(struct crypto_async_request *req, int err) · 205 unmodified lines | |||
| 206 | 206 | ||
| 207 | kfree(aead_req); | 207 | kfree(aead_req); |
| 208 | 208 | ||
| 209 | spin_lock_bh(&ctx->decrypt_compl_lock); | ||
| 209 | pending = atomic_dec_return(&ctx->decrypt_pending); | 210 | pending = atomic_dec_return(&ctx->decrypt_pending); |
| 210 | 211 | ||
| 211 | if (!pending && READ_ONCE(ctx->async_notify)) | 212 | if (!pending && ctx->async_notify) |
| 212 | complete(&ctx->async_wait.completion); | 213 | complete(&ctx->async_wait.completion); |
| 214 | spin_unlock_bh(&ctx->decrypt_compl_lock); | ||
| 213 | } | 215 | } |
| 214 | 216 | ||
| 215 | static int tls_do_decryption(struct sock *sk, | 217 | static int tls_do_decryption(struct sock *sk, |
| @@ -467,10 +469,12 @@ static void tls_encrypt_done(struct crypto_async_request *req, int err) · 251 unmodified lines | |||
| 467 | ready = true; | 469 | ready = true; |
| 468 | } | 470 | } |
| 469 | 471 | ||
| 472 | spin_lock_bh(&ctx->encrypt_compl_lock); | ||
| 470 | pending = atomic_dec_return(&ctx->encrypt_pending); | 473 | pending = atomic_dec_return(&ctx->encrypt_pending); |
| 471 | 474 | ||
| 472 | if (!pending && READ_ONCE(ctx->async_notify)) | 475 | if (!pending && ctx->async_notify) |
| 473 | complete(&ctx->async_wait.completion); | 476 | complete(&ctx->async_wait.completion); |
| 477 | spin_unlock_bh(&ctx->encrypt_compl_lock); | ||
| 474 | 478 | ||
| 475 | if (!ready) | 479 | if (!ready) |
| 476 | return; | 480 | return; |
| @@ -929,6 +933,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) · 452 unmodified lines | |||
| 929 | int num_zc = 0; | 933 | int num_zc = 0; |
| 930 | int orig_size; | 934 | int orig_size; |
| 931 | int ret = 0; | 935 | int ret = 0; |
| 936 | int pending; | ||
| 932 | 937 | ||
| 933 | if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL)) | 938 | if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL)) |
| 934 | return -EOPNOTSUPP; | 939 | return -EOPNOTSUPP; |
| @@ -1095,13 +1100,19 @@ trim_sgl: · 160 unmodified lines | |||
| 1095 | goto send_end; | 1100 | goto send_end; |
| 1096 | } else if (num_zc) { | 1101 | } else if (num_zc) { |
| 1097 | /* Wait for pending encryptions to get completed */ | 1102 | /* Wait for pending encryptions to get completed */ |
| 1098 | smp_store_mb(ctx->async_notify, true); | 1103 | spin_lock_bh(&ctx->encrypt_compl_lock); |
| 1104 | ctx->async_notify = true; | ||
| 1099 | 1105 | ||
| 1100 | if (atomic_read(&ctx->encrypt_pending)) | 1106 | pending = atomic_read(&ctx->encrypt_pending); |
| 1107 | spin_unlock_bh(&ctx->encrypt_compl_lock); | ||
| 1108 | if (pending) | ||
| 1101 | crypto_wait_req(-EINPROGRESS, &ctx->async_wait); | 1109 | crypto_wait_req(-EINPROGRESS, &ctx->async_wait); |
| 1102 | else | 1110 | else |
| 1103 | reinit_completion(&ctx->async_wait.completion); | 1111 | reinit_completion(&ctx->async_wait.completion); |
| 1104 | 1112 | ||
| 1113 | /* There can be no concurrent accesses, since we have no | ||
| 1114 | * pending encrypt operations | ||
| 1115 | */ | ||
| 1105 | WRITE_ONCE(ctx->async_notify, false); | 1116 | WRITE_ONCE(ctx->async_notify, false); |
| 1106 | 1117 | ||
| 1107 | if (ctx->async_wait.err) { | 1118 | if (ctx->async_wait.err) { |
| @@ -1732,6 +1743,7 @@ int tls_sw_recvmsg(struct sock *sk, · 624 unmodified lines | |||
| 1732 | bool is_kvec = iov_iter_is_kvec(&msg->msg_iter); | 1743 | bool is_kvec = iov_iter_is_kvec(&msg->msg_iter); |
| 1733 | bool is_peek = flags & MSG_PEEK; | 1744 | bool is_peek = flags & MSG_PEEK; |
| 1734 | int num_async = 0; | 1745 | int num_async = 0; |
| 1746 | int pending; | ||
| 1735 | 1747 | ||
| 1736 | flags |= nonblock; | 1748 | flags |= nonblock; |
| 1737 | 1749 | ||
| @@ -1894,8 +1906,11 @@ pick_next_record: · 156 unmodified lines | |||
| 1894 | recv_end: | 1906 | recv_end: |
| 1895 | if (num_async) { | 1907 | if (num_async) { |
| 1896 | /* Wait for all previously submitted records to be decrypted */ | 1908 | /* Wait for all previously submitted records to be decrypted */ |
| 1897 | smp_store_mb(ctx->async_notify, true); | 1909 | spin_lock_bh(&ctx->decrypt_compl_lock); |
| 1898 | if (atomic_read(&ctx->decrypt_pending)) { | 1910 | ctx->async_notify = true; |
| 1911 | pending = atomic_read(&ctx->decrypt_pending); | ||
| 1912 | spin_unlock_bh(&ctx->decrypt_compl_lock); | ||
| 1913 | if (pending) { | ||
| 1899 | err = crypto_wait_req(-EINPROGRESS, &ctx->async_wait); | 1914 | err = crypto_wait_req(-EINPROGRESS, &ctx->async_wait); |
| 1900 | if (err) { | 1915 | if (err) { |
| 1901 | /* one of async decrypt failed */ | 1916 | /* one of async decrypt failed */ |
| @@ -1907,6 +1922,10 @@ recv_end: · 5 unmodified lines | |||
| 1907 | } else { | 1922 | } else { |
| 1908 | reinit_completion(&ctx->async_wait.completion); | 1923 | reinit_completion(&ctx->async_wait.completion); |
| 1909 | } | 1924 | } |
| 1925 | |||
| 1926 | /* There can be no concurrent accesses, since we have no | ||
| 1927 | * pending decrypt operations | ||
| 1928 | */ | ||
| 1910 | WRITE_ONCE(ctx->async_notify, false); | 1929 | WRITE_ONCE(ctx->async_notify, false); |
| 1911 | 1930 | ||
| 1912 | /* Drain records from the rx_list & copy if required */ | 1931 | /* Drain records from the rx_list & copy if required */ |
| @@ -2293,6 +2312,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) · 380 unmodified lines | |||
| 2293 | 2312 | ||
| 2294 | if (tx) { | 2313 | if (tx) { |
| 2295 | crypto_init_wait(&sw_ctx_tx->async_wait); | 2314 | crypto_init_wait(&sw_ctx_tx->async_wait); |
| 2315 | spin_lock_init(&sw_ctx_tx->encrypt_compl_lock); | ||
| 2296 | crypto_info = &ctx->crypto_send.info; | 2316 | crypto_info = &ctx->crypto_send.info; |
| 2297 | cctx = &ctx->tx; | 2317 | cctx = &ctx->tx; |
| 2298 | aead = &sw_ctx_tx->aead_send; | 2318 | aead = &sw_ctx_tx->aead_send; |
| @@ -2301,6 +2321,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx) · 2 unmodified lines | |||
| 2301 | sw_ctx_tx->tx_work.sk = sk; | 2321 | sw_ctx_tx->tx_work.sk = sk; |
| 2302 | } else { | 2322 | } else { |
| 2303 | crypto_init_wait(&sw_ctx_rx->async_wait); | 2323 | crypto_init_wait(&sw_ctx_rx->async_wait); |
| 2324 | spin_lock_init(&sw_ctx_rx->decrypt_compl_lock); | ||
| 2304 | crypto_info = &ctx->crypto_recv.info; | 2325 | crypto_info = &ctx->crypto_recv.info; |
| 2305 | cctx = &ctx->rx; | 2326 | cctx = &ctx->rx; |
| 2306 | skb_queue_head_init(&sw_ctx_rx->rx_list); | 2327 | skb_queue_head_init(&sw_ctx_rx->rx_list); |
| @@ -1408,7 +1408,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, · 1407 unmodified lines | |||
| 1408 | /* Wait for children sockets to appear; these are the new sockets | 1408 | /* Wait for children sockets to appear; these are the new sockets |
| 1409 | * created upon connection establishment. | 1409 | * created upon connection establishment. |
| 1410 | */ | 1410 | */ |
| 1411 | timeout = sock_sndtimeo(listener, flags & O_NONBLOCK); | 1411 | timeout = sock_rcvtimeo(listener, flags & O_NONBLOCK); |
| 1412 | prepare_to_wait(sk_sleep(listener), &wait, TASK_INTERRUPTIBLE); | 1412 | prepare_to_wait(sk_sleep(listener), &wait, TASK_INTERRUPTIBLE); |
| 1413 | 1413 | ||
| 1414 | while ((connected = vsock_dequeue_accept(listener)) == NULL && | 1414 | while ((connected = vsock_dequeue_accept(listener)) == NULL && |
| @@ -1132,6 +1132,14 @@ void virtio_transport_recv_pkt(struct virtio_transport *t, · 1131 unmodified lines | |||
| 1132 | 1132 | ||
| 1133 | lock_sock(sk); | 1133 | lock_sock(sk); |
| 1134 | 1134 | ||
| 1135 | /* Check if sk has been released before lock_sock */ | ||
| 1136 | if (sk->sk_shutdown == SHUTDOWN_MASK) { | ||
| 1137 | (void)virtio_transport_reset_no_sock(t, pkt); | ||
| 1138 | release_sock(sk); | ||
| 1139 | sock_put(sk); | ||
| 1140 | goto free_pkt; | ||
| 1141 | } | ||
| 1142 | |||
| 1135 | /* Update CID in case it has changed after a transport reset event */ | 1143 | /* Update CID in case it has changed after a transport reset event */ |
| 1136 | vsk->local_addr.svm_cid = dst.svm_cid; | 1144 | vsk->local_addr.svm_cid = dst.svm_cid; |
| 1137 | 1145 | ||
| @@ -142,7 +142,7 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev, · 141 unmodified lines | |||
| 142 | if (result) | 142 | if (result) |
| 143 | return result; | 143 | return result; |
| 144 | 144 | ||
| 145 | if (rdev->wiphy.debugfsdir) | 145 | if (!IS_ERR_OR_NULL(rdev->wiphy.debugfsdir)) |
| 146 | debugfs_rename(rdev->wiphy.debugfsdir->d_parent, | 146 | debugfs_rename(rdev->wiphy.debugfsdir->d_parent, |
| 147 | rdev->wiphy.debugfsdir, | 147 | rdev->wiphy.debugfsdir, |
| 148 | rdev->wiphy.debugfsdir->d_parent, newname); | 148 | rdev->wiphy.debugfsdir->d_parent, newname); |
| @@ -341,8 +341,8 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) · 340 unmodified lines | |||
| 341 | { | 341 | { |
| 342 | bool unaligned_chunks = mr->flags & XDP_UMEM_UNALIGNED_CHUNK_FLAG; | 342 | bool unaligned_chunks = mr->flags & XDP_UMEM_UNALIGNED_CHUNK_FLAG; |
| 343 | u32 chunk_size = mr->chunk_size, headroom = mr->headroom; | 343 | u32 chunk_size = mr->chunk_size, headroom = mr->headroom; |
| 344 | u64 npgs, addr = mr->addr, size = mr->len; | ||
| 344 | unsigned int chunks, chunks_per_page; | 345 | unsigned int chunks, chunks_per_page; |
| 345 | u64 addr = mr->addr, size = mr->len; | ||
| 346 | int err; | 346 | int err; |
| 347 | 347 | ||
| 348 | if (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) { | 348 | if (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) { |
| @@ -372,6 +372,10 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) · 23 unmodified lines | |||
| 372 | if ((addr + size) < addr) | 372 | if ((addr + size) < addr) |
| 373 | return -EINVAL; | 373 | return -EINVAL; |
| 374 | 374 | ||
| 375 | npgs = div_u64(size, PAGE_SIZE); | ||
| 376 | if (npgs > U32_MAX) | ||
| 377 | return -EINVAL; | ||
| 378 | |||
| 375 | chunks = (unsigned int)div_u64(size, chunk_size); | 379 | chunks = (unsigned int)div_u64(size, chunk_size); |
| 376 | if (chunks == 0) | 380 | if (chunks == 0) |
| 377 | return -EINVAL; | 381 | return -EINVAL; |
| @@ -391,7 +395,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) · 13 unmodified lines | |||
| 391 | umem->size = size; | 395 | umem->size = size; |
| 392 | umem->headroom = headroom; | 396 | umem->headroom = headroom; |
| 393 | umem->chunk_size_nohr = chunk_size - headroom; | 397 | umem->chunk_size_nohr = chunk_size - headroom; |
| 394 | umem->npgs = size / PAGE_SIZE; | 398 | umem->npgs = (u32)npgs; |
| 395 | umem->pgs = NULL; | 399 | umem->pgs = NULL; |
| 396 | umem->user = NULL; | 400 | umem->user = NULL; |
| 397 | umem->flags = mr->flags; | 401 | umem->flags = mr->flags; |
| @@ -379,6 +379,7 @@ static void espintcp_destruct(struct sock *sk) · 378 unmodified lines | |||
| 379 | { | 379 | { |
| 380 | struct espintcp_ctx *ctx = espintcp_getctx(sk); | 380 | struct espintcp_ctx *ctx = espintcp_getctx(sk); |
| 381 | 381 | ||
| 382 | ctx->saved_destruct(sk); | ||
| 382 | kfree(ctx); | 383 | kfree(ctx); |
| 383 | } | 384 | } |
| 384 | 385 | ||
| @@ -419,6 +420,7 @@ static int espintcp_init_sk(struct sock *sk) · 34 unmodified lines | |||
| 419 | sk->sk_socket->ops = &espintcp_ops; | 420 | sk->sk_socket->ops = &espintcp_ops; |
| 420 | ctx->saved_data_ready = sk->sk_data_ready; | 421 | ctx->saved_data_ready = sk->sk_data_ready; |
| 421 | ctx->saved_write_space = sk->sk_write_space; | 422 | ctx->saved_write_space = sk->sk_write_space; |
| 423 | ctx->saved_destruct = sk->sk_destruct; | ||
| 422 | sk->sk_data_ready = espintcp_data_ready; | 424 | sk->sk_data_ready = espintcp_data_ready; |
| 423 | sk->sk_write_space = espintcp_write_space; | 425 | sk->sk_write_space = espintcp_write_space; |
| 424 | sk->sk_destruct = espintcp_destruct; | 426 | sk->sk_destruct = espintcp_destruct; |
| @@ -25,12 +25,10 @@ static void __xfrm_transport_prep(struct xfrm_state *x, struct sk_buff *skb, · 24 unmodified lines | |||
| 25 | struct xfrm_offload *xo = xfrm_offload(skb); | 25 | struct xfrm_offload *xo = xfrm_offload(skb); |
| 26 | 26 | ||
| 27 | skb_reset_mac_len(skb); | 27 | skb_reset_mac_len(skb); |
| 28 | pskb_pull(skb, skb->mac_len + hsize + x->props.header_len); | 28 | if (xo->flags & XFRM_GSO_SEGMENT) |
| 29 | |||
| 30 | if (xo->flags & XFRM_GSO_SEGMENT) { | ||
| 31 | skb_reset_transport_header(skb); | ||
| 32 | skb->transport_header -= x->props.header_len; | 29 | skb->transport_header -= x->props.header_len; |
| 33 | } | 30 | |
| 31 | pskb_pull(skb, skb_transport_offset(skb) + x->props.header_len); | ||
| 34 | } | 32 | } |
| 35 | 33 | ||
| 36 | static void __xfrm_mode_tunnel_prep(struct xfrm_state *x, struct sk_buff *skb, | 34 | static void __xfrm_mode_tunnel_prep(struct xfrm_state *x, struct sk_buff *skb, |
| @@ -644,7 +644,7 @@ resume: · 643 unmodified lines | |||
| 644 | dev_put(skb->dev); | 644 | dev_put(skb->dev); |
| 645 | 645 | ||
| 646 | spin_lock(&x->lock); | 646 | spin_lock(&x->lock); |
| 647 | if (nexthdr <= 0) { | 647 | if (nexthdr < 0) { |
| 648 | if (nexthdr == -EBADMSG) { | 648 | if (nexthdr == -EBADMSG) { |
| 649 | xfrm_audit_state_icvfail(x, skb, | 649 | xfrm_audit_state_icvfail(x, skb, |
| 650 | x->type->proto); | 650 | x->type->proto); |
| @@ -750,7 +750,28 @@ static struct rtnl_link_ops xfrmi_link_ops __read_mostly = { · 749 unmodified lines | |||
| 750 | .get_link_net = xfrmi_get_link_net, | 750 | .get_link_net = xfrmi_get_link_net, |
| 751 | }; | 751 | }; |
| 752 | 752 | ||
| 753 | static void __net_exit xfrmi_exit_batch_net(struct list_head *net_exit_list) | ||
| 754 | { | ||
| 755 | struct net *net; | ||
| 756 | LIST_HEAD(list); | ||
| 757 | |||
| 758 | rtnl_lock(); | ||
| 759 | list_for_each_entry(net, net_exit_list, exit_list) { | ||
| 760 | struct xfrmi_net *xfrmn = net_generic(net, xfrmi_net_id); | ||
| 761 | struct xfrm_if __rcu **xip; | ||
| 762 | struct xfrm_if *xi; | ||
| 763 | |||
| 764 | for (xip = &xfrmn->xfrmi[0]; | ||
| 765 | (xi = rtnl_dereference(*xip)) != NULL; | ||
| 766 | xip = &xi->next) | ||
| 767 | unregister_netdevice_queue(xi->dev, &list); | ||
| 768 | } | ||
| 769 | unregister_netdevice_many(&list); | ||
| 770 | rtnl_unlock(); | ||
| 771 | } | ||
| 772 | |||
| 753 | static struct pernet_operations xfrmi_net_ops = { | 773 | static struct pernet_operations xfrmi_net_ops = { |
| 774 | .exit_batch = xfrmi_exit_batch_net, | ||
| 754 | .id = &xfrmi_net_id, | 775 | .id = &xfrmi_net_id, |
| 755 | .size = sizeof(struct xfrmi_net), | 776 | .size = sizeof(struct xfrmi_net), |
| 756 | }; | 777 | }; |
| @@ -583,18 +583,20 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb) · 582 unmodified lines | |||
| 583 | xfrm_state_hold(x); | 583 | xfrm_state_hold(x); |
| 584 | 584 | ||
| 585 | if (skb_is_gso(skb)) { | 585 | if (skb_is_gso(skb)) { |
| 586 | skb_shinfo(skb)->gso_type |= SKB_GSO_ESP; | 586 | if (skb->inner_protocol) |
| 587 | return xfrm_output_gso(net, sk, skb); | ||
| 587 | 588 | ||
| 588 | return xfrm_output2(net, sk, skb); | 589 | skb_shinfo(skb)->gso_type |= SKB_GSO_ESP; |
| 590 | goto out; | ||
| 589 | } | 591 | } |
| 590 | 592 | ||
| 591 | if (x->xso.dev && x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM) | 593 | if (x->xso.dev && x->xso.dev->features & NETIF_F_HW_ESP_TX_CSUM) |
| 592 | goto out; | 594 | goto out; |
| 595 | } else { | ||
| 596 | if (skb_is_gso(skb)) | ||
| 597 | return xfrm_output_gso(net, sk, skb); | ||
| 593 | } | 598 | } |
| 594 | 599 | ||
| 595 | if (skb_is_gso(skb)) | ||
| 596 | return xfrm_output_gso(net, sk, skb); | ||
| 597 | |||
| 598 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | 600 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
| 599 | err = skb_checksum_help(skb); | 601 | err = skb_checksum_help(skb); |
| 600 | if (err) { | 602 | if (err) { |
| @@ -640,7 +642,8 @@ void xfrm_local_error(struct sk_buff *skb, int mtu) · 39 unmodified lines | |||
| 640 | 642 | ||
| 641 | if (skb->protocol == htons(ETH_P_IP)) | 643 | if (skb->protocol == htons(ETH_P_IP)) |
| 642 | proto = AF_INET; | 644 | proto = AF_INET; |
| 643 | else if (skb->protocol == htons(ETH_P_IPV6)) | 645 | else if (skb->protocol == htons(ETH_P_IPV6) && |
| 646 | skb->sk->sk_family == AF_INET6) | ||
| 644 | proto = AF_INET6; | 647 | proto = AF_INET6; |
| 645 | else | 648 | else |
| 646 | return; | 649 | return; |
| @@ -1436,12 +1436,7 @@ static void xfrm_policy_requeue(struct xfrm_policy *old, · 1435 unmodified lines | |||
| 1436 | static bool xfrm_policy_mark_match(struct xfrm_policy *policy, | 1436 | static bool xfrm_policy_mark_match(struct xfrm_policy *policy, |
| 1437 | struct xfrm_policy *pol) | 1437 | struct xfrm_policy *pol) |
| 1438 | { | 1438 | { |
| 1439 | u32 mark = policy->mark.v & policy->mark.m; | 1439 | if (policy->mark.v == pol->mark.v && |
| 1440 | |||
| 1441 | if (policy->mark.v == pol->mark.v && policy->mark.m == pol->mark.m) | ||
| 1442 | return true; | ||
| 1443 | |||
| 1444 | if ((mark & pol->mark.m) == pol->mark.v && | ||
| 1445 | policy->priority == pol->priority) | 1440 | policy->priority == pol->priority) |
| 1446 | return true; | 1441 | return true; |
| 1447 | 1442 | ||
| @@ -238,7 +238,7 @@ · 237 unmodified lines | |||
| 238 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | 238 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), |
| 239 | BPF_LD_MAP_FD(BPF_REG_1, 0), | 239 | BPF_LD_MAP_FD(BPF_REG_1, 0), |
| 240 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), | 240 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), |
| 241 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | 241 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), |
| 242 | /* r1 = [0x00, 0xff] */ | 242 | /* r1 = [0x00, 0xff] */ |
| 243 | BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), | 243 | BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), |
| 244 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 0xffffff80 >> 1), | 244 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 0xffffff80 >> 1), |
| @@ -253,10 +253,6 @@ · 8 unmodified lines | |||
| 253 | * [0xffff'ffff'0000'0080, 0xffff'ffff'ffff'ffff] | 253 | * [0xffff'ffff'0000'0080, 0xffff'ffff'ffff'ffff] |
| 254 | */ | 254 | */ |
| 255 | BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 0xffffff80 >> 1), | 255 | BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 0xffffff80 >> 1), |
| 256 | /* r1 = 0 or | ||
| 257 | * [0x00ff'ffff'ff00'0000, 0x00ff'ffff'ffff'ffff] | ||
| 258 | */ | ||
| 259 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_1, 8), | ||
| 260 | /* error on OOB pointer computation */ | 256 | /* error on OOB pointer computation */ |
| 261 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | 257 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), |
| 262 | /* exit */ | 258 | /* exit */ |
| @@ -265,8 +261,10 @@ · 2 unmodified lines | |||
| 265 | }, | 261 | }, |
| 266 | .fixup_map_hash_8b = { 3 }, | 262 | .fixup_map_hash_8b = { 3 }, |
| 267 | /* not actually fully unbounded, but the bound is very high */ | 263 | /* not actually fully unbounded, but the bound is very high */ |
| 268 | .errstr = "value 72057594021150720 makes map_value pointer be out of bounds", | 264 | .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root", |
| 269 | .result = REJECT | 265 | .result_unpriv = REJECT, |
| 266 | .errstr = "value -4294967168 makes map_value pointer be out of bounds", | ||
| 267 | .result = REJECT, | ||
| 270 | }, | 268 | }, |
| 271 | { | 269 | { |
| 272 | "bounds check after truncation of boundary-crossing range (2)", | 270 | "bounds check after truncation of boundary-crossing range (2)", |
| @@ -276,7 +274,7 @@ · 3 unmodified lines | |||
| 276 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | 274 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), |
| 277 | BPF_LD_MAP_FD(BPF_REG_1, 0), | 275 | BPF_LD_MAP_FD(BPF_REG_1, 0), |
| 278 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), | 276 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), |
| 279 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | 277 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), |
| 280 | /* r1 = [0x00, 0xff] */ | 278 | /* r1 = [0x00, 0xff] */ |
| 281 | BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), | 279 | BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), |
| 282 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 0xffffff80 >> 1), | 280 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 0xffffff80 >> 1), |
| @@ -293,10 +291,6 @@ · 10 unmodified lines | |||
| 293 | * [0xffff'ffff'0000'0080, 0xffff'ffff'ffff'ffff] | 291 | * [0xffff'ffff'0000'0080, 0xffff'ffff'ffff'ffff] |
| 294 | */ | 292 | */ |
| 295 | BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 0xffffff80 >> 1), | 293 | BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 0xffffff80 >> 1), |
| 296 | /* r1 = 0 or | ||
| 297 | * [0x00ff'ffff'ff00'0000, 0x00ff'ffff'ffff'ffff] | ||
| 298 | */ | ||
| 299 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_1, 8), | ||
| 300 | /* error on OOB pointer computation */ | 294 | /* error on OOB pointer computation */ |
| 301 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | 295 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), |
| 302 | /* exit */ | 296 | /* exit */ |
| @@ -305,8 +299,10 @@ · 2 unmodified lines | |||
| 305 | }, | 299 | }, |
| 306 | .fixup_map_hash_8b = { 3 }, | 300 | .fixup_map_hash_8b = { 3 }, |
| 307 | /* not actually fully unbounded, but the bound is very high */ | 301 | /* not actually fully unbounded, but the bound is very high */ |
| 308 | .errstr = "value 72057594021150720 makes map_value pointer be out of bounds", | 302 | .errstr_unpriv = "R1 has unknown scalar with mixed signed bounds, pointer arithmetic with it prohibited for !root", |
| 309 | .result = REJECT | 303 | .result_unpriv = REJECT, |
| 304 | .errstr = "value -4294967168 makes map_value pointer be out of bounds", | ||
| 305 | .result = REJECT, | ||
| 310 | }, | 306 | }, |
| 311 | { | 307 | { |
| 312 | "bounds check after wrapping 32-bit addition", | 308 | "bounds check after wrapping 32-bit addition", |
| @@ -539,3 +535,25 @@ · 226 unmodified lines | |||
| 539 | }, | 535 | }, |
| 540 | .result = ACCEPT | 536 | .result = ACCEPT |
| 541 | }, | 537 | }, |
| 538 | { | ||
| 539 | "assigning 32bit bounds to 64bit for wA = 0, wB = wA", | ||
| 540 | .insns = { | ||
| 541 | BPF_LDX_MEM(BPF_W, BPF_REG_8, BPF_REG_1, | ||
| 542 | offsetof(struct __sk_buff, data_end)), | ||
| 543 | BPF_LDX_MEM(BPF_W, BPF_REG_7, BPF_REG_1, | ||
| 544 | offsetof(struct __sk_buff, data)), | ||
| 545 | BPF_MOV32_IMM(BPF_REG_9, 0), | ||
| 546 | BPF_MOV32_REG(BPF_REG_2, BPF_REG_9), | ||
| 547 | BPF_MOV64_REG(BPF_REG_6, BPF_REG_7), | ||
| 548 | BPF_ALU64_REG(BPF_ADD, BPF_REG_6, BPF_REG_2), | ||
| 549 | BPF_MOV64_REG(BPF_REG_3, BPF_REG_6), | ||
| 550 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 8), | ||
| 551 | BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_8, 1), | ||
| 552 | BPF_LDX_MEM(BPF_W, BPF_REG_5, BPF_REG_6, 0), | ||
| 553 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 554 | BPF_EXIT_INSN(), | ||
| 555 | }, | ||
| 556 | .prog_type = BPF_PROG_TYPE_SCHED_CLS, | ||
| 557 | .result = ACCEPT, | ||
| 558 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
| 559 | }, | ||
| @@ -0,0 +1,21 @@ | |||
| 1 | [ | ||
| 2 | { | ||
| 3 | "id": "83be", | ||
| 4 | "name": "Create FQ-PIE with invalid number of flows", | ||
| 5 | "category": [ | ||
| 6 | "qdisc", | ||
| 7 | "fq_pie" | ||
| 8 | ], | ||
| 9 | "setup": [ | ||
| 10 | "$IP link add dev $DUMMY type dummy || /bin/true" | ||
| 11 | ], | ||
| 12 | "cmdUnderTest": "$TC qdisc add dev $DUMMY root fq_pie flows 65536", | ||
| 13 | "expExitCode": "2", | ||
| 14 | "verifyCmd": "$TC qdisc show dev $DUMMY", | ||
| 15 | "matchPattern": "qdisc", | ||
| 16 | "matchCount": "0", | ||
| 17 | "teardown": [ | ||
| 18 | "$IP link del dev $DUMMY" | ||
| 19 | ] | ||
| 20 | } | ||
| 21 | ] | ||