Pull networking fixes from David Miller: 1) Fix several scatter gather list issues in kTLS code, from Jakub Kicinski. 2) macb driver device remove has to kill the hresp_err_tasklet. From Chuhong Yuan. 3) Several memory leak and reference count bug fixes in tipc, from Tung Nguyen. 4) Fix mlx5 build error w/o ipv6, from Yue Haibing. 5) Fix jumbo frame and other regressions in r8169, from Heiner Kallweit. 6) Undo some BUG_ON()'s and replace them with WARN_ON_ONCE and proper error propagation/handling. From Paolo Abeni. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (24 commits) openvswitch: remove another BUG_ON() openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info() net: phy: realtek: fix using paged operations with RTL8105e / RTL8208 r8169: fix resume on cable plug-in r8169: fix jumbo configuration for RTL8168evl net: emulex: benet: indent a Kconfig depends continuation line selftests: forwarding: fix race between packet receive and tc check net: sched: fix `tc -s class show` no bstats on class with nolock subqueues net: ethernet: ti: ale: ensure vlan/mdb deleted when no members net/mlx5e: Fix build error without IPV6 selftests: pmtu: use -oneline for ip route list cache tipc: fix duplicate SYN messages under link congestion tipc: fix wrong timeout input for tipc_wait_for_cond() tipc: fix wrong socket reference counter after tipc_sk_timeout() returns tipc: fix potential memory leak in __tipc_sendmsg() net: macb: add missed tasklet_kill selftests: bpf: correct perror strings selftests: bpf: test_sockmap: handle file creation failures gracefully net/tls: use sg_next() to walk sg entries net/tls: remove the dead inplace_crypto code ...
Unified · Split
| @@ -4422,6 +4422,7 @@ static int macb_remove(struct platform_device *pdev) · 4421 unmodified lines | |||
| 4422 | mdiobus_free(bp->mii_bus); | 4422 | mdiobus_free(bp->mii_bus); |
| 4423 | 4423 | ||
| 4424 | unregister_netdev(dev); | 4424 | unregister_netdev(dev); |
| 4425 | tasklet_kill(&bp->hresp_err_tasklet); | ||
| 4425 | pm_runtime_disable(&pdev->dev); | 4426 | pm_runtime_disable(&pdev->dev); |
| 4426 | pm_runtime_dont_use_autosuspend(&pdev->dev); | 4427 | pm_runtime_dont_use_autosuspend(&pdev->dev); |
| 4427 | if (!pm_runtime_suspended(&pdev->dev)) { | 4428 | if (!pm_runtime_suspended(&pdev->dev)) { |
| @@ -49,4 +49,4 @@ config BE2NET_SKYHAWK · 48 unmodified lines | |||
| 49 | 49 | ||
| 50 | comment "WARNING: be2net is useless without any enabled chip" | 50 | comment "WARNING: be2net is useless without any enabled chip" |
| 51 | depends on BE2NET_BE2=n && BE2NET_BE3=n && BE2NET_LANCER=n && \ | 51 | depends on BE2NET_BE2=n && BE2NET_BE3=n && BE2NET_LANCER=n && \ |
| 52 | BE2NET_SKYHAWK=n && BE2NET | 52 | BE2NET_SKYHAWK=n && BE2NET |
| @@ -130,42 +130,6 @@ static const char *mlx5e_netdev_kind(struct net_device *dev) · 129 unmodified lines | |||
| 130 | return "unknown"; | 130 | return "unknown"; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv, | ||
| 134 | struct net_device *mirred_dev, | ||
| 135 | struct net_device **out_dev, | ||
| 136 | struct net_device **route_dev, | ||
| 137 | struct flowi6 *fl6, | ||
| 138 | struct neighbour **out_n, | ||
| 139 | u8 *out_ttl) | ||
| 140 | { | ||
| 141 | struct dst_entry *dst; | ||
| 142 | struct neighbour *n; | ||
| 143 | |||
| 144 | int ret; | ||
| 145 | |||
| 146 | ret = ipv6_stub->ipv6_dst_lookup(dev_net(mirred_dev), NULL, &dst, | ||
| 147 | fl6); | ||
| 148 | if (ret < 0) | ||
| 149 | return ret; | ||
| 150 | |||
| 151 | if (!(*out_ttl)) | ||
| 152 | *out_ttl = ip6_dst_hoplimit(dst); | ||
| 153 | |||
| 154 | ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev); | ||
| 155 | if (ret < 0) { | ||
| 156 | dst_release(dst); | ||
| 157 | return ret; | ||
| 158 | } | ||
| 159 | |||
| 160 | n = dst_neigh_lookup(dst, &fl6->daddr); | ||
| 161 | dst_release(dst); | ||
| 162 | if (!n) | ||
| 163 | return -ENOMEM; | ||
| 164 | |||
| 165 | *out_n = n; | ||
| 166 | return 0; | ||
| 167 | } | ||
| 168 | |||
| 169 | static int mlx5e_gen_ip_tunnel_header(char buf[], __u8 *ip_proto, | 133 | static int mlx5e_gen_ip_tunnel_header(char buf[], __u8 *ip_proto, |
| 170 | struct mlx5e_encap_entry *e) | 134 | struct mlx5e_encap_entry *e) |
| 171 | { | 135 | { |
| @@ -319,6 +283,43 @@ release_neigh: · 147 unmodified lines | |||
| 319 | return err; | 283 | return err; |
| 320 | } | 284 | } |
| 321 | 285 | ||
| 286 | #if IS_ENABLED(CONFIG_INET) && IS_ENABLED(CONFIG_IPV6) | ||
| 287 | static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv, | ||
| 288 | struct net_device *mirred_dev, | ||
| 289 | struct net_device **out_dev, | ||
| 290 | struct net_device **route_dev, | ||
| 291 | struct flowi6 *fl6, | ||
| 292 | struct neighbour **out_n, | ||
| 293 | u8 *out_ttl) | ||
| 294 | { | ||
| 295 | struct dst_entry *dst; | ||
| 296 | struct neighbour *n; | ||
| 297 | |||
| 298 | int ret; | ||
| 299 | |||
| 300 | ret = ipv6_stub->ipv6_dst_lookup(dev_net(mirred_dev), NULL, &dst, | ||
| 301 | fl6); | ||
| 302 | if (ret < 0) | ||
| 303 | return ret; | ||
| 304 | |||
| 305 | if (!(*out_ttl)) | ||
| 306 | *out_ttl = ip6_dst_hoplimit(dst); | ||
| 307 | |||
| 308 | ret = get_route_and_out_devs(priv, dst->dev, route_dev, out_dev); | ||
| 309 | if (ret < 0) { | ||
| 310 | dst_release(dst); | ||
| 311 | return ret; | ||
| 312 | } | ||
| 313 | |||
| 314 | n = dst_neigh_lookup(dst, &fl6->daddr); | ||
| 315 | dst_release(dst); | ||
| 316 | if (!n) | ||
| 317 | return -ENOMEM; | ||
| 318 | |||
| 319 | *out_n = n; | ||
| 320 | return 0; | ||
| 321 | } | ||
| 322 | |||
| 322 | int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, | 323 | int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, |
| 323 | struct net_device *mirred_dev, | 324 | struct net_device *mirred_dev, |
| 324 | struct mlx5e_encap_entry *e) | 325 | struct mlx5e_encap_entry *e) |
| @@ -436,6 +437,7 @@ release_neigh: · 111 unmodified lines | |||
| 436 | neigh_release(n); | 437 | neigh_release(n); |
| 437 | return err; | 438 | return err; |
| 438 | } | 439 | } |
| 440 | #endif | ||
| 439 | 441 | ||
| 440 | bool mlx5e_tc_tun_device_to_offload(struct mlx5e_priv *priv, | 442 | bool mlx5e_tc_tun_device_to_offload(struct mlx5e_priv *priv, |
| 441 | struct net_device *netdev) | 443 | struct net_device *netdev) |
| @@ -1542,6 +1542,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) · 1541 unmodified lines | |||
| 1542 | rtl_lock_config_regs(tp); | 1542 | rtl_lock_config_regs(tp); |
| 1543 | 1543 | ||
| 1544 | device_set_wakeup_enable(tp_to_dev(tp), wolopts); | 1544 | device_set_wakeup_enable(tp_to_dev(tp), wolopts); |
| 1545 | tp->dev->wol_enabled = wolopts ? 1 : 0; | ||
| 1545 | } | 1546 | } |
| 1546 | 1547 | ||
| 1547 | static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 1548 | static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
| @@ -3872,7 +3873,7 @@ static void rtl_hw_jumbo_enable(struct rtl8169_private *tp) · 2324 unmodified lines | |||
| 3872 | case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28: | 3873 | case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28: |
| 3873 | r8168dp_hw_jumbo_enable(tp); | 3874 | r8168dp_hw_jumbo_enable(tp); |
| 3874 | break; | 3875 | break; |
| 3875 | case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_34: | 3876 | case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33: |
| 3876 | r8168e_hw_jumbo_enable(tp); | 3877 | r8168e_hw_jumbo_enable(tp); |
| 3877 | break; | 3878 | break; |
| 3878 | default: | 3879 | default: |
| @@ -384,7 +384,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask, · 383 unmodified lines | |||
| 384 | int flags, u16 vid) | 384 | int flags, u16 vid) |
| 385 | { | 385 | { |
| 386 | u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; | 386 | u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0}; |
| 387 | int mcast_members; | 387 | int mcast_members = 0; |
| 388 | int idx; | 388 | int idx; |
| 389 | 389 | ||
| 390 | idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); | 390 | idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); |
| @@ -397,11 +397,13 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask, · 6 unmodified lines | |||
| 397 | mcast_members = cpsw_ale_get_port_mask(ale_entry, | 397 | mcast_members = cpsw_ale_get_port_mask(ale_entry, |
| 398 | ale->port_mask_bits); | 398 | ale->port_mask_bits); |
| 399 | mcast_members &= ~port_mask; | 399 | mcast_members &= ~port_mask; |
| 400 | } | ||
| 401 | |||
| 402 | if (mcast_members) | ||
| 400 | cpsw_ale_set_port_mask(ale_entry, mcast_members, | 403 | cpsw_ale_set_port_mask(ale_entry, mcast_members, |
| 401 | ale->port_mask_bits); | 404 | ale->port_mask_bits); |
| 402 | } else { | 405 | else |
| 403 | cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); | 406 | cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); |
| 404 | } | ||
| 405 | 407 | ||
| 406 | cpsw_ale_write(ale, idx, ale_entry); | 408 | cpsw_ale_write(ale, idx, ale_entry); |
| 407 | return 0; | 409 | return 0; |
| @@ -478,6 +480,10 @@ static void cpsw_ale_del_vlan_modify(struct cpsw_ale *ale, u32 *ale_entry, · 70 unmodified lines | |||
| 478 | members = cpsw_ale_get_vlan_member_list(ale_entry, | 480 | members = cpsw_ale_get_vlan_member_list(ale_entry, |
| 479 | ale->vlan_field_bits); | 481 | ale->vlan_field_bits); |
| 480 | members &= ~port_mask; | 482 | members &= ~port_mask; |
| 483 | if (!members) { | ||
| 484 | cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE); | ||
| 485 | return; | ||
| 486 | } | ||
| 481 | 487 | ||
| 482 | untag = cpsw_ale_get_vlan_untag_force(ale_entry, | 488 | untag = cpsw_ale_get_vlan_untag_force(ale_entry, |
| 483 | ale->vlan_field_bits); | 489 | ale->vlan_field_bits); |
| @@ -439,6 +439,15 @@ static struct phy_driver realtek_drvs[] = { · 438 unmodified lines | |||
| 439 | .resume = genphy_resume, | 439 | .resume = genphy_resume, |
| 440 | .read_page = rtl821x_read_page, | 440 | .read_page = rtl821x_read_page, |
| 441 | .write_page = rtl821x_write_page, | 441 | .write_page = rtl821x_write_page, |
| 442 | }, { | ||
| 443 | PHY_ID_MATCH_MODEL(0x001cc880), | ||
| 444 | .name = "RTL8208 Fast Ethernet", | ||
| 445 | .read_mmd = genphy_read_mmd_unsupported, | ||
| 446 | .write_mmd = genphy_write_mmd_unsupported, | ||
| 447 | .suspend = genphy_suspend, | ||
| 448 | .resume = genphy_resume, | ||
| 449 | .read_page = rtl821x_read_page, | ||
| 450 | .write_page = rtl821x_write_page, | ||
| 442 | }, { | 451 | }, { |
| 443 | PHY_ID_MATCH_EXACT(0x001cc910), | 452 | PHY_ID_MATCH_EXACT(0x001cc910), |
| 444 | .name = "RTL8211 Gigabit Ethernet", | 453 | .name = "RTL8211 Gigabit Ethernet", |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | |||
| 14 | #include <net/strparser.h> | 14 | #include <net/strparser.h> |
| 15 | 15 | ||
| 16 | #define MAX_MSG_FRAGS MAX_SKB_FRAGS | 16 | #define MAX_MSG_FRAGS MAX_SKB_FRAGS |
| 17 | #define NR_MSG_FRAG_IDS (MAX_MSG_FRAGS + 1) | ||
| 17 | 18 | ||
| 18 | enum __sk_action { | 19 | enum __sk_action { |
| 19 | __SK_DROP = 0, | 20 | __SK_DROP = 0, |
| @@ -29,13 +30,15 @@ struct sk_msg_sg { · 9 unmodified lines | |||
| 29 | u32 size; | 30 | u32 size; |
| 30 | u32 copybreak; | 31 | u32 copybreak; |
| 31 | unsigned long copy; | 32 | unsigned long copy; |
| 32 | /* The extra element is used for chaining the front and sections when | 33 | /* The extra two elements: |
| 33 | * the list becomes partitioned (e.g. end < start). The crypto APIs | 34 | * 1) used for chaining the front and sections when the list becomes |
| 34 | * require the chaining. | 35 | * partitioned (e.g. end < start). The crypto APIs require the |
| 36 | * chaining; | ||
| 37 | * 2) to chain tailer SG entries after the message. | ||
| 35 | */ | 38 | */ |
| 36 | struct scatterlist data[MAX_MSG_FRAGS + 1]; | 39 | struct scatterlist data[MAX_MSG_FRAGS + 2]; |
| 37 | }; | 40 | }; |
| 38 | static_assert(BITS_PER_LONG >= MAX_MSG_FRAGS); | 41 | static_assert(BITS_PER_LONG >= NR_MSG_FRAG_IDS); |
| 39 | 42 | ||
| 40 | /* UAPI in filter.c depends on struct sk_msg_sg being first element. */ | 43 | /* UAPI in filter.c depends on struct sk_msg_sg being first element. */ |
| 41 | struct sk_msg { | 44 | struct sk_msg { |
| @@ -142,13 +145,13 @@ static inline void sk_msg_apply_bytes(struct sk_psock *psock, u32 bytes) · 100 unmodified lines | |||
| 142 | 145 | ||
| 143 | static inline u32 sk_msg_iter_dist(u32 start, u32 end) | 146 | static inline u32 sk_msg_iter_dist(u32 start, u32 end) |
| 144 | { | 147 | { |
| 145 | return end >= start ? end - start : end + (MAX_MSG_FRAGS - start); | 148 | return end >= start ? end - start : end + (NR_MSG_FRAG_IDS - start); |
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | #define sk_msg_iter_var_prev(var) \ | 151 | #define sk_msg_iter_var_prev(var) \ |
| 149 | do { \ | 152 | do { \ |
| 150 | if (var == 0) \ | 153 | if (var == 0) \ |
| 151 | var = MAX_MSG_FRAGS - 1; \ | 154 | var = NR_MSG_FRAG_IDS - 1; \ |
| 152 | else \ | 155 | else \ |
| 153 | var--; \ | 156 | var--; \ |
| 154 | } while (0) | 157 | } while (0) |
| @@ -156,7 +159,7 @@ static inline u32 sk_msg_iter_dist(u32 start, u32 end) · 1 unmodified line | |||
| 156 | #define sk_msg_iter_var_next(var) \ | 159 | #define sk_msg_iter_var_next(var) \ |
| 157 | do { \ | 160 | do { \ |
| 158 | var++; \ | 161 | var++; \ |
| 159 | if (var == MAX_MSG_FRAGS) \ | 162 | if (var == NR_MSG_FRAG_IDS) \ |
| 160 | var = 0; \ | 163 | var = 0; \ |
| 161 | } while (0) | 164 | } while (0) |
| 162 | 165 | ||
| @@ -173,9 +176,9 @@ static inline void sk_msg_clear_meta(struct sk_msg *msg) · 10 unmodified lines | |||
| 173 | 176 | ||
| 174 | static inline void sk_msg_init(struct sk_msg *msg) | 177 | static inline void sk_msg_init(struct sk_msg *msg) |
| 175 | { | 178 | { |
| 176 | BUILD_BUG_ON(ARRAY_SIZE(msg->sg.data) - 1 != MAX_MSG_FRAGS); | 179 | BUILD_BUG_ON(ARRAY_SIZE(msg->sg.data) - 1 != NR_MSG_FRAG_IDS); |
| 177 | memset(msg, 0, sizeof(*msg)); | 180 | memset(msg, 0, sizeof(*msg)); |
| 178 | sg_init_marker(msg->sg.data, MAX_MSG_FRAGS); | 181 | sg_init_marker(msg->sg.data, NR_MSG_FRAG_IDS); |
| 179 | } | 182 | } |
| 180 | 183 | ||
| 181 | static inline void sk_msg_xfer(struct sk_msg *dst, struct sk_msg *src, | 184 | static inline void sk_msg_xfer(struct sk_msg *dst, struct sk_msg *src, |
| @@ -196,14 +199,11 @@ static inline void sk_msg_xfer_full(struct sk_msg *dst, struct sk_msg *src) · 14 unmodified lines | |||
| 196 | 199 | ||
| 197 | static inline bool sk_msg_full(const struct sk_msg *msg) | 200 | static inline bool sk_msg_full(const struct sk_msg *msg) |
| 198 | { | 201 | { |
| 199 | return (msg->sg.end == msg->sg.start) && msg->sg.size; | 202 | return sk_msg_iter_dist(msg->sg.start, msg->sg.end) == MAX_MSG_FRAGS; |
| 200 | } | 203 | } |
| 201 | 204 | ||
| 202 | static inline u32 sk_msg_elem_used(const struct sk_msg *msg) | 205 | static inline u32 sk_msg_elem_used(const struct sk_msg *msg) |
| 203 | { | 206 | { |
| 204 | if (sk_msg_full(msg)) | ||
| 205 | return MAX_MSG_FRAGS; | ||
| 206 | |||
| 207 | return sk_msg_iter_dist(msg->sg.start, msg->sg.end); | 207 | return sk_msg_iter_dist(msg->sg.start, msg->sg.end); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| @@ -100,7 +100,6 @@ struct tls_rec { · 99 unmodified lines | |||
| 100 | struct list_head list; | 100 | struct list_head list; |
| 101 | int tx_ready; | 101 | int tx_ready; |
| 102 | int tx_flags; | 102 | int tx_flags; |
| 103 | int inplace_crypto; | ||
| 104 | 103 | ||
| 105 | struct sk_msg msg_plaintext; | 104 | struct sk_msg msg_plaintext; |
| 106 | struct sk_msg msg_encrypted; | 105 | struct sk_msg msg_encrypted; |
| @@ -377,7 +376,7 @@ int tls_push_sg(struct sock *sk, struct tls_context *ctx, · 270 unmodified lines | |||
| 377 | int flags); | 376 | int flags); |
| 378 | int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, | 377 | int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, |
| 379 | int flags); | 378 | int flags); |
| 380 | bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx); | 379 | void tls_free_partial_record(struct sock *sk, struct tls_context *ctx); |
| 381 | 380 | ||
| 382 | static inline struct tls_msg *tls_msg(struct sk_buff *skb) | 381 | static inline struct tls_msg *tls_msg(struct sk_buff *skb) |
| 383 | { | 382 | { |
| @@ -2299,7 +2299,7 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start, · 2298 unmodified lines | |||
| 2299 | WARN_ON_ONCE(last_sge == first_sge); | 2299 | WARN_ON_ONCE(last_sge == first_sge); |
| 2300 | shift = last_sge > first_sge ? | 2300 | shift = last_sge > first_sge ? |
| 2301 | last_sge - first_sge - 1 : | 2301 | last_sge - first_sge - 1 : |
| 2302 | MAX_SKB_FRAGS - first_sge + last_sge - 1; | 2302 | NR_MSG_FRAG_IDS - first_sge + last_sge - 1; |
| 2303 | if (!shift) | 2303 | if (!shift) |
| 2304 | goto out; | 2304 | goto out; |
| 2305 | 2305 | ||
| @@ -2308,8 +2308,8 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start, · 2 unmodified lines | |||
| 2308 | do { | 2308 | do { |
| 2309 | u32 move_from; | 2309 | u32 move_from; |
| 2310 | 2310 | ||
| 2311 | if (i + shift >= MAX_MSG_FRAGS) | 2311 | if (i + shift >= NR_MSG_FRAG_IDS) |
| 2312 | move_from = i + shift - MAX_MSG_FRAGS; | 2312 | move_from = i + shift - NR_MSG_FRAG_IDS; |
| 2313 | else | 2313 | else |
| 2314 | move_from = i + shift; | 2314 | move_from = i + shift; |
| 2315 | if (move_from == msg->sg.end) | 2315 | if (move_from == msg->sg.end) |
| @@ -2323,7 +2323,7 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start, · 7 unmodified lines | |||
| 2323 | } while (1); | 2323 | } while (1); |
| 2324 | 2324 | ||
| 2325 | msg->sg.end = msg->sg.end - shift > msg->sg.end ? | 2325 | msg->sg.end = msg->sg.end - shift > msg->sg.end ? |
| 2326 | msg->sg.end - shift + MAX_MSG_FRAGS : | 2326 | msg->sg.end - shift + NR_MSG_FRAG_IDS : |
| 2327 | msg->sg.end - shift; | 2327 | msg->sg.end - shift; |
| 2328 | out: | 2328 | out: |
| 2329 | msg->data = sg_virt(&msg->sg.data[first_sge]) + start - offset; | 2329 | msg->data = sg_virt(&msg->sg.data[first_sge]) + start - offset; |
| @@ -421,7 +421,7 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb) · 420 unmodified lines | |||
| 421 | copied = skb->len; | 421 | copied = skb->len; |
| 422 | msg->sg.start = 0; | 422 | msg->sg.start = 0; |
| 423 | msg->sg.size = copied; | 423 | msg->sg.size = copied; |
| 424 | msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge; | 424 | msg->sg.end = num_sge; |
| 425 | msg->skb = skb; | 425 | msg->skb = skb; |
| 426 | 426 | ||
| 427 | sk_psock_queue_msg(psock, msg); | 427 | sk_psock_queue_msg(psock, msg); |
| @@ -301,7 +301,7 @@ EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir); · 300 unmodified lines | |||
| 301 | static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, | 301 | static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, |
| 302 | struct sk_msg *msg, int *copied, int flags) | 302 | struct sk_msg *msg, int *copied, int flags) |
| 303 | { | 303 | { |
| 304 | bool cork = false, enospc = msg->sg.start == msg->sg.end; | 304 | bool cork = false, enospc = sk_msg_full(msg); |
| 305 | struct sock *sk_redir; | 305 | struct sock *sk_redir; |
| 306 | u32 tosend, delta = 0; | 306 | u32 tosend, delta = 0; |
| 307 | int ret; | 307 | int ret; |
| @@ -905,7 +905,10 @@ static struct sk_buff *ovs_flow_cmd_build_info(const struct sw_flow *flow, · 904 unmodified lines | |||
| 905 | retval = ovs_flow_cmd_fill_info(flow, dp_ifindex, skb, | 905 | retval = ovs_flow_cmd_fill_info(flow, dp_ifindex, skb, |
| 906 | info->snd_portid, info->snd_seq, 0, | 906 | info->snd_portid, info->snd_seq, 0, |
| 907 | cmd, ufid_flags); | 907 | cmd, ufid_flags); |
| 908 | BUG_ON(retval < 0); | 908 | if (WARN_ON_ONCE(retval < 0)) { |
| 909 | kfree_skb(skb); | ||
| 910 | skb = ERR_PTR(retval); | ||
| 911 | } | ||
| 909 | return skb; | 912 | return skb; |
| 910 | } | 913 | } |
| 911 | 914 | ||
| @@ -1369,7 +1372,10 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) · 457 unmodified lines | |||
| 1369 | OVS_FLOW_CMD_DEL, | 1372 | OVS_FLOW_CMD_DEL, |
| 1370 | ufid_flags); | 1373 | ufid_flags); |
| 1371 | rcu_read_unlock(); | 1374 | rcu_read_unlock(); |
| 1372 | BUG_ON(err < 0); | 1375 | if (WARN_ON_ONCE(err < 0)) { |
| 1376 | kfree_skb(reply); | ||
| 1377 | goto out_free; | ||
| 1378 | } | ||
| 1373 | 1379 | ||
| 1374 | ovs_notify(&dp_flow_genl_family, reply, info); | 1380 | ovs_notify(&dp_flow_genl_family, reply, info); |
| 1375 | } else { | 1381 | } else { |
| @@ -1377,6 +1383,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) · 1 unmodified line | |||
| 1377 | } | 1383 | } |
| 1378 | } | 1384 | } |
| 1379 | 1385 | ||
| 1386 | out_free: | ||
| 1380 | ovs_flow_free(flow, true); | 1387 | ovs_flow_free(flow, true); |
| 1381 | return 0; | 1388 | return 0; |
| 1382 | unlock: | 1389 | unlock: |
| @@ -245,7 +245,8 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 244 unmodified lines | |||
| 245 | struct netdev_queue *dev_queue = mq_queue_get(sch, cl); | 245 | struct netdev_queue *dev_queue = mq_queue_get(sch, cl); |
| 246 | 246 | ||
| 247 | sch = dev_queue->qdisc_sleeping; | 247 | sch = dev_queue->qdisc_sleeping; |
| 248 | if (gnet_stats_copy_basic(&sch->running, d, NULL, &sch->bstats) < 0 || | 248 | if (gnet_stats_copy_basic(&sch->running, d, sch->cpu_bstats, |
| 249 | &sch->bstats) < 0 || | ||
| 249 | qdisc_qstats_copy(d, sch) < 0) | 250 | qdisc_qstats_copy(d, sch) < 0) |
| 250 | return -1; | 251 | return -1; |
| 251 | return 0; | 252 | return 0; |
| @@ -557,8 +557,8 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 556 unmodified lines | |||
| 557 | struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl); | 557 | struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl); |
| 558 | 558 | ||
| 559 | sch = dev_queue->qdisc_sleeping; | 559 | sch = dev_queue->qdisc_sleeping; |
| 560 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), | 560 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), d, |
| 561 | d, NULL, &sch->bstats) < 0 || | 561 | sch->cpu_bstats, &sch->bstats) < 0 || |
| 562 | qdisc_qstats_copy(d, sch) < 0) | 562 | qdisc_qstats_copy(d, sch) < 0) |
| 563 | return -1; | 563 | return -1; |
| 564 | } | 564 | } |
| @@ -339,7 +339,7 @@ static int multiq_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 338 unmodified lines | |||
| 339 | 339 | ||
| 340 | cl_q = q->queues[cl - 1]; | 340 | cl_q = q->queues[cl - 1]; |
| 341 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), | 341 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), |
| 342 | d, NULL, &cl_q->bstats) < 0 || | 342 | d, cl_q->cpu_bstats, &cl_q->bstats) < 0 || |
| 343 | qdisc_qstats_copy(d, cl_q) < 0) | 343 | qdisc_qstats_copy(d, cl_q) < 0) |
| 344 | return -1; | 344 | return -1; |
| 345 | 345 | ||
| @@ -356,7 +356,7 @@ static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 355 unmodified lines | |||
| 356 | 356 | ||
| 357 | cl_q = q->queues[cl - 1]; | 357 | cl_q = q->queues[cl - 1]; |
| 358 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), | 358 | if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), |
| 359 | d, NULL, &cl_q->bstats) < 0 || | 359 | d, cl_q->cpu_bstats, &cl_q->bstats) < 0 || |
| 360 | qdisc_qstats_copy(d, cl_q) < 0) | 360 | qdisc_qstats_copy(d, cl_q) < 0) |
| 361 | return -1; | 361 | return -1; |
| 362 | 362 | ||
| @@ -532,7 +532,7 @@ static void __tipc_shutdown(struct socket *sock, int error) · 531 unmodified lines | |||
| 532 | struct sock *sk = sock->sk; | 532 | struct sock *sk = sock->sk; |
| 533 | struct tipc_sock *tsk = tipc_sk(sk); | 533 | struct tipc_sock *tsk = tipc_sk(sk); |
| 534 | struct net *net = sock_net(sk); | 534 | struct net *net = sock_net(sk); |
| 535 | long timeout = CONN_TIMEOUT_DEFAULT; | 535 | long timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); |
| 536 | u32 dnode = tsk_peer_node(tsk); | 536 | u32 dnode = tsk_peer_node(tsk); |
| 537 | struct sk_buff *skb; | 537 | struct sk_buff *skb; |
| 538 | 538 | ||
| @@ -540,12 +540,10 @@ static void __tipc_shutdown(struct socket *sock, int error) · 1 unmodified line | |||
| 540 | tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt && | 540 | tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt && |
| 541 | !tsk_conn_cong(tsk))); | 541 | !tsk_conn_cong(tsk))); |
| 542 | 542 | ||
| 543 | /* Push out unsent messages or remove if pending SYN */ | 543 | /* Push out delayed messages if in Nagle mode */ |
| 544 | skb = skb_peek(&sk->sk_write_queue); | 544 | tipc_sk_push_backlog(tsk); |
| 545 | if (skb && !msg_is_syn(buf_msg(skb))) | 545 | /* Remove pending SYN */ |
| 546 | tipc_sk_push_backlog(tsk); | 546 | __skb_queue_purge(&sk->sk_write_queue); |
| 547 | else | ||
| 548 | __skb_queue_purge(&sk->sk_write_queue); | ||
| 549 | 547 | ||
| 550 | /* Reject all unreceived messages, except on an active connection | 548 | /* Reject all unreceived messages, except on an active connection |
| 551 | * (which disconnects locally & sends a 'FIN+' to peer). | 549 | * (which disconnects locally & sends a 'FIN+' to peer). |
| @@ -1248,9 +1246,14 @@ static void tipc_sk_push_backlog(struct tipc_sock *tsk) · 696 unmodified lines | |||
| 1248 | struct sk_buff_head *txq = &tsk->sk.sk_write_queue; | 1246 | struct sk_buff_head *txq = &tsk->sk.sk_write_queue; |
| 1249 | struct net *net = sock_net(&tsk->sk); | 1247 | struct net *net = sock_net(&tsk->sk); |
| 1250 | u32 dnode = tsk_peer_node(tsk); | 1248 | u32 dnode = tsk_peer_node(tsk); |
| 1249 | struct sk_buff *skb = skb_peek(txq); | ||
| 1251 | int rc; | 1250 | int rc; |
| 1252 | 1251 | ||
| 1253 | if (skb_queue_empty(txq) || tsk->cong_link_cnt) | 1252 | if (!skb || tsk->cong_link_cnt) |
| 1253 | return; | ||
| 1254 | |||
| 1255 | /* Do not send SYN again after congestion */ | ||
| 1256 | if (msg_is_syn(buf_msg(skb))) | ||
| 1254 | return; | 1257 | return; |
| 1255 | 1258 | ||
| 1256 | tsk->snt_unacked += tsk->snd_backlog; | 1259 | tsk->snt_unacked += tsk->snd_backlog; |
| @@ -1447,8 +1450,10 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) · 190 unmodified lines | |||
| 1447 | rc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts); | 1450 | rc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts); |
| 1448 | if (unlikely(rc != dlen)) | 1451 | if (unlikely(rc != dlen)) |
| 1449 | return rc; | 1452 | return rc; |
| 1450 | if (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue))) | 1453 | if (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue))) { |
| 1454 | __skb_queue_purge(&pkts); | ||
| 1451 | return -ENOMEM; | 1455 | return -ENOMEM; |
| 1456 | } | ||
| 1452 | 1457 | ||
| 1453 | trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, " "); | 1458 | trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, " "); |
| 1454 | rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); | 1459 | rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid); |
| @@ -2757,6 +2762,7 @@ static void tipc_sk_timeout(struct timer_list *t) · 1302 unmodified lines | |||
| 2757 | if (sock_owned_by_user(sk)) { | 2762 | if (sock_owned_by_user(sk)) { |
| 2758 | sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20); | 2763 | sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20); |
| 2759 | bh_unlock_sock(sk); | 2764 | bh_unlock_sock(sk); |
| 2765 | sock_put(sk); | ||
| 2760 | return; | 2766 | return; |
| 2761 | } | 2767 | } |
| 2762 | 2768 | ||
| @@ -209,24 +209,15 @@ int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, · 208 unmodified lines | |||
| 209 | return tls_push_sg(sk, ctx, sg, offset, flags); | 209 | return tls_push_sg(sk, ctx, sg, offset, flags); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | bool tls_free_partial_record(struct sock *sk, struct tls_context *ctx) | 212 | void tls_free_partial_record(struct sock *sk, struct tls_context *ctx) |
| 213 | { | 213 | { |
| 214 | struct scatterlist *sg; | 214 | struct scatterlist *sg; |
| 215 | 215 | ||
| 216 | sg = ctx->partially_sent_record; | 216 | for (sg = ctx->partially_sent_record; sg; sg = sg_next(sg)) { |
| 217 | if (!sg) | ||
| 218 | return false; | ||
| 219 | |||
| 220 | while (1) { | ||
| 221 | put_page(sg_page(sg)); | 217 | put_page(sg_page(sg)); |
| 222 | sk_mem_uncharge(sk, sg->length); | 218 | sk_mem_uncharge(sk, sg->length); |
| 223 | |||
| 224 | if (sg_is_last(sg)) | ||
| 225 | break; | ||
| 226 | sg++; | ||
| 227 | } | 219 | } |
| 228 | ctx->partially_sent_record = NULL; | 220 | ctx->partially_sent_record = NULL; |
| 229 | return true; | ||
| 230 | } | 221 | } |
| 231 | 222 | ||
| 232 | static void tls_write_space(struct sock *sk) | 223 | static void tls_write_space(struct sock *sk) |
| @@ -710,8 +710,7 @@ static int tls_push_record(struct sock *sk, int flags, · 709 unmodified lines | |||
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | i = msg_pl->sg.start; | 712 | i = msg_pl->sg.start; |
| 713 | sg_chain(rec->sg_aead_in, 2, rec->inplace_crypto ? | 713 | sg_chain(rec->sg_aead_in, 2, &msg_pl->sg.data[i]); |
| 714 | &msg_en->sg.data[i] : &msg_pl->sg.data[i]); | ||
| 715 | 714 | ||
| 716 | i = msg_en->sg.end; | 715 | i = msg_en->sg.end; |
| 717 | sk_msg_iter_var_prev(i); | 716 | sk_msg_iter_var_prev(i); |
| @@ -771,8 +770,14 @@ static int bpf_exec_tx_verdict(struct sk_msg *msg, struct sock *sk, · 53 unmodified lines | |||
| 771 | 770 | ||
| 772 | policy = !(flags & MSG_SENDPAGE_NOPOLICY); | 771 | policy = !(flags & MSG_SENDPAGE_NOPOLICY); |
| 773 | psock = sk_psock_get(sk); | 772 | psock = sk_psock_get(sk); |
| 774 | if (!psock || !policy) | 773 | if (!psock || !policy) { |
| 775 | return tls_push_record(sk, flags, record_type); | 774 | err = tls_push_record(sk, flags, record_type); |
| 775 | if (err) { | ||
| 776 | *copied -= sk_msg_free(sk, msg); | ||
| 777 | tls_free_open_rec(sk); | ||
| 778 | } | ||
| 779 | return err; | ||
| 780 | } | ||
| 776 | more_data: | 781 | more_data: |
| 777 | enospc = sk_msg_full(msg); | 782 | enospc = sk_msg_full(msg); |
| 778 | if (psock->eval == __SK_NONE) { | 783 | if (psock->eval == __SK_NONE) { |
| @@ -970,8 +975,6 @@ alloc_encrypted: · 191 unmodified lines | |||
| 970 | if (ret) | 975 | if (ret) |
| 971 | goto fallback_to_reg_send; | 976 | goto fallback_to_reg_send; |
| 972 | 977 | ||
| 973 | rec->inplace_crypto = 0; | ||
| 974 | |||
| 975 | num_zc++; | 978 | num_zc++; |
| 976 | copied += try_to_copy; | 979 | copied += try_to_copy; |
| 977 | 980 | ||
| @@ -984,7 +987,7 @@ alloc_encrypted: · 6 unmodified lines | |||
| 984 | num_async++; | 987 | num_async++; |
| 985 | else if (ret == -ENOMEM) | 988 | else if (ret == -ENOMEM) |
| 986 | goto wait_for_memory; | 989 | goto wait_for_memory; |
| 987 | else if (ret == -ENOSPC) | 990 | else if (ctx->open_rec && ret == -ENOSPC) |
| 988 | goto rollback_iter; | 991 | goto rollback_iter; |
| 989 | else if (ret != -EAGAIN) | 992 | else if (ret != -EAGAIN) |
| 990 | goto send_end; | 993 | goto send_end; |
| @@ -1053,11 +1056,12 @@ wait_for_memory: · 62 unmodified lines | |||
| 1053 | ret = sk_stream_wait_memory(sk, &timeo); | 1056 | ret = sk_stream_wait_memory(sk, &timeo); |
| 1054 | if (ret) { | 1057 | if (ret) { |
| 1055 | trim_sgl: | 1058 | trim_sgl: |
| 1056 | tls_trim_both_msgs(sk, orig_size); | 1059 | if (ctx->open_rec) |
| 1060 | tls_trim_both_msgs(sk, orig_size); | ||
| 1057 | goto send_end; | 1061 | goto send_end; |
| 1058 | } | 1062 | } |
| 1059 | 1063 | ||
| 1060 | if (msg_en->sg.size < required_size) | 1064 | if (ctx->open_rec && msg_en->sg.size < required_size) |
| 1061 | goto alloc_encrypted; | 1065 | goto alloc_encrypted; |
| 1062 | } | 1066 | } |
| 1063 | 1067 | ||
| @@ -1169,7 +1173,6 @@ alloc_payload: · 105 unmodified lines | |||
| 1169 | 1173 | ||
| 1170 | tls_ctx->pending_open_record_frags = true; | 1174 | tls_ctx->pending_open_record_frags = true; |
| 1171 | if (full_record || eor || sk_msg_full(msg_pl)) { | 1175 | if (full_record || eor || sk_msg_full(msg_pl)) { |
| 1172 | rec->inplace_crypto = 0; | ||
| 1173 | ret = bpf_exec_tx_verdict(msg_pl, sk, full_record, | 1176 | ret = bpf_exec_tx_verdict(msg_pl, sk, full_record, |
| 1174 | record_type, &copied, flags); | 1177 | record_type, &copied, flags); |
| 1175 | if (ret) { | 1178 | if (ret) { |
| @@ -1190,11 +1193,13 @@ wait_for_sndbuf: · 14 unmodified lines | |||
| 1190 | wait_for_memory: | 1193 | wait_for_memory: |
| 1191 | ret = sk_stream_wait_memory(sk, &timeo); | 1194 | ret = sk_stream_wait_memory(sk, &timeo); |
| 1192 | if (ret) { | 1195 | if (ret) { |
| 1193 | tls_trim_both_msgs(sk, msg_pl->sg.size); | 1196 | if (ctx->open_rec) |
| 1197 | tls_trim_both_msgs(sk, msg_pl->sg.size); | ||
| 1194 | goto sendpage_end; | 1198 | goto sendpage_end; |
| 1195 | } | 1199 | } |
| 1196 | 1200 | ||
| 1197 | goto alloc_payload; | 1201 | if (ctx->open_rec) |
| 1202 | goto alloc_payload; | ||
| 1198 | } | 1203 | } |
| 1199 | 1204 | ||
| 1200 | if (num_async) { | 1205 | if (num_async) { |
| @@ -2084,7 +2089,8 @@ void tls_sw_release_resources_tx(struct sock *sk) · 883 unmodified lines | |||
| 2084 | /* Free up un-sent records in tx_list. First, free | 2089 | /* Free up un-sent records in tx_list. First, free |
| 2085 | * the partially sent record if any at head of tx_list. | 2090 | * the partially sent record if any at head of tx_list. |
| 2086 | */ | 2091 | */ |
| 2087 | if (tls_free_partial_record(sk, tls_ctx)) { | 2092 | if (tls_ctx->partially_sent_record) { |
| 2093 | tls_free_partial_record(sk, tls_ctx); | ||
| 2088 | rec = list_first_entry(&ctx->tx_list, | 2094 | rec = list_first_entry(&ctx->tx_list, |
| 2089 | struct tls_rec, list); | 2095 | struct tls_rec, list); |
| 2090 | list_del(&rec->list); | 2096 | list_del(&rec->list); |
| @@ -240,14 +240,14 @@ static int sockmap_init_sockets(int verbose) · 239 unmodified lines | |||
| 240 | addr.sin_port = htons(S1_PORT); | 240 | addr.sin_port = htons(S1_PORT); |
| 241 | err = bind(s1, (struct sockaddr *)&addr, sizeof(addr)); | 241 | err = bind(s1, (struct sockaddr *)&addr, sizeof(addr)); |
| 242 | if (err < 0) { | 242 | if (err < 0) { |
| 243 | perror("bind s1 failed()\n"); | 243 | perror("bind s1 failed()"); |
| 244 | return errno; | 244 | return errno; |
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | addr.sin_port = htons(S2_PORT); | 247 | addr.sin_port = htons(S2_PORT); |
| 248 | err = bind(s2, (struct sockaddr *)&addr, sizeof(addr)); | 248 | err = bind(s2, (struct sockaddr *)&addr, sizeof(addr)); |
| 249 | if (err < 0) { | 249 | if (err < 0) { |
| 250 | perror("bind s2 failed()\n"); | 250 | perror("bind s2 failed()"); |
| 251 | return errno; | 251 | return errno; |
| 252 | } | 252 | } |
| 253 | 253 | ||
| @@ -255,14 +255,14 @@ static int sockmap_init_sockets(int verbose) · 1 unmodified line | |||
| 255 | addr.sin_port = htons(S1_PORT); | 255 | addr.sin_port = htons(S1_PORT); |
| 256 | err = listen(s1, 32); | 256 | err = listen(s1, 32); |
| 257 | if (err < 0) { | 257 | if (err < 0) { |
| 258 | perror("listen s1 failed()\n"); | 258 | perror("listen s1 failed()"); |
| 259 | return errno; | 259 | return errno; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | addr.sin_port = htons(S2_PORT); | 262 | addr.sin_port = htons(S2_PORT); |
| 263 | err = listen(s2, 32); | 263 | err = listen(s2, 32); |
| 264 | if (err < 0) { | 264 | if (err < 0) { |
| 265 | perror("listen s1 failed()\n"); | 265 | perror("listen s1 failed()"); |
| 266 | return errno; | 266 | return errno; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| @@ -270,14 +270,14 @@ static int sockmap_init_sockets(int verbose) · 1 unmodified line | |||
| 270 | addr.sin_port = htons(S1_PORT); | 270 | addr.sin_port = htons(S1_PORT); |
| 271 | err = connect(c1, (struct sockaddr *)&addr, sizeof(addr)); | 271 | err = connect(c1, (struct sockaddr *)&addr, sizeof(addr)); |
| 272 | if (err < 0 && errno != EINPROGRESS) { | 272 | if (err < 0 && errno != EINPROGRESS) { |
| 273 | perror("connect c1 failed()\n"); | 273 | perror("connect c1 failed()"); |
| 274 | return errno; | 274 | return errno; |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | addr.sin_port = htons(S2_PORT); | 277 | addr.sin_port = htons(S2_PORT); |
| 278 | err = connect(c2, (struct sockaddr *)&addr, sizeof(addr)); | 278 | err = connect(c2, (struct sockaddr *)&addr, sizeof(addr)); |
| 279 | if (err < 0 && errno != EINPROGRESS) { | 279 | if (err < 0 && errno != EINPROGRESS) { |
| 280 | perror("connect c2 failed()\n"); | 280 | perror("connect c2 failed()"); |
| 281 | return errno; | 281 | return errno; |
| 282 | } else if (err < 0) { | 282 | } else if (err < 0) { |
| 283 | err = 0; | 283 | err = 0; |
| @@ -286,13 +286,13 @@ static int sockmap_init_sockets(int verbose) · 2 unmodified lines | |||
| 286 | /* Accept Connecrtions */ | 286 | /* Accept Connecrtions */ |
| 287 | p1 = accept(s1, NULL, NULL); | 287 | p1 = accept(s1, NULL, NULL); |
| 288 | if (p1 < 0) { | 288 | if (p1 < 0) { |
| 289 | perror("accept s1 failed()\n"); | 289 | perror("accept s1 failed()"); |
| 290 | return errno; | 290 | return errno; |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | p2 = accept(s2, NULL, NULL); | 293 | p2 = accept(s2, NULL, NULL); |
| 294 | if (p2 < 0) { | 294 | if (p2 < 0) { |
| 295 | perror("accept s1 failed()\n"); | 295 | perror("accept s1 failed()"); |
| 296 | return errno; | 296 | return errno; |
| 297 | } | 297 | } |
| 298 | 298 | ||
| @@ -332,6 +332,10 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, · 33 unmodified lines | |||
| 332 | int i, fp; | 332 | int i, fp; |
| 333 | 333 | ||
| 334 | file = fopen(".sendpage_tst.tmp", "w+"); | 334 | file = fopen(".sendpage_tst.tmp", "w+"); |
| 335 | if (!file) { | ||
| 336 | perror("create file for sendpage"); | ||
| 337 | return 1; | ||
| 338 | } | ||
| 335 | for (i = 0; i < iov_length * cnt; i++, k++) | 339 | for (i = 0; i < iov_length * cnt; i++, k++) |
| 336 | fwrite(&k, sizeof(char), 1, file); | 340 | fwrite(&k, sizeof(char), 1, file); |
| 337 | fflush(file); | 341 | fflush(file); |
| @@ -339,12 +343,17 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, · 1 unmodified line | |||
| 339 | fclose(file); | 343 | fclose(file); |
| 340 | 344 | ||
| 341 | fp = open(".sendpage_tst.tmp", O_RDONLY); | 345 | fp = open(".sendpage_tst.tmp", O_RDONLY); |
| 346 | if (fp < 0) { | ||
| 347 | perror("reopen file for sendpage"); | ||
| 348 | return 1; | ||
| 349 | } | ||
| 350 | |||
| 342 | clock_gettime(CLOCK_MONOTONIC, &s->start); | 351 | clock_gettime(CLOCK_MONOTONIC, &s->start); |
| 343 | for (i = 0; i < cnt; i++) { | 352 | for (i = 0; i < cnt; i++) { |
| 344 | int sent = sendfile(fd, fp, NULL, iov_length); | 353 | int sent = sendfile(fd, fp, NULL, iov_length); |
| 345 | 354 | ||
| 346 | if (!drop && sent < 0) { | 355 | if (!drop && sent < 0) { |
| 347 | perror("send loop error:"); | 356 | perror("send loop error"); |
| 348 | close(fp); | 357 | close(fp); |
| 349 | return sent; | 358 | return sent; |
| 350 | } else if (drop && sent >= 0) { | 359 | } else if (drop && sent >= 0) { |
| @@ -463,7 +472,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 112 unmodified lines | |||
| 463 | int sent = sendmsg(fd, &msg, flags); | 472 | int sent = sendmsg(fd, &msg, flags); |
| 464 | 473 | ||
| 465 | if (!drop && sent < 0) { | 474 | if (!drop && sent < 0) { |
| 466 | perror("send loop error:"); | 475 | perror("send loop error"); |
| 467 | goto out_errno; | 476 | goto out_errno; |
| 468 | } else if (drop && sent >= 0) { | 477 | } else if (drop && sent >= 0) { |
| 469 | printf("send loop error expected: %i\n", sent); | 478 | printf("send loop error expected: %i\n", sent); |
| @@ -499,7 +508,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 29 unmodified lines | |||
| 499 | total_bytes -= txmsg_pop_total; | 508 | total_bytes -= txmsg_pop_total; |
| 500 | err = clock_gettime(CLOCK_MONOTONIC, &s->start); | 509 | err = clock_gettime(CLOCK_MONOTONIC, &s->start); |
| 501 | if (err < 0) | 510 | if (err < 0) |
| 502 | perror("recv start time: "); | 511 | perror("recv start time"); |
| 503 | while (s->bytes_recvd < total_bytes) { | 512 | while (s->bytes_recvd < total_bytes) { |
| 504 | if (txmsg_cork) { | 513 | if (txmsg_cork) { |
| 505 | timeout.tv_sec = 0; | 514 | timeout.tv_sec = 0; |
| @@ -543,7 +552,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 37 unmodified lines | |||
| 543 | if (recv < 0) { | 552 | if (recv < 0) { |
| 544 | if (errno != EWOULDBLOCK) { | 553 | if (errno != EWOULDBLOCK) { |
| 545 | clock_gettime(CLOCK_MONOTONIC, &s->end); | 554 | clock_gettime(CLOCK_MONOTONIC, &s->end); |
| 546 | perror("recv failed()\n"); | 555 | perror("recv failed()"); |
| 547 | goto out_errno; | 556 | goto out_errno; |
| 548 | } | 557 | } |
| 549 | } | 558 | } |
| @@ -557,7 +566,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 7 unmodified lines | |||
| 557 | 566 | ||
| 558 | errno = msg_verify_data(&msg, recv, chunk_sz); | 567 | errno = msg_verify_data(&msg, recv, chunk_sz); |
| 559 | if (errno) { | 568 | if (errno) { |
| 560 | perror("data verify msg failed\n"); | 569 | perror("data verify msg failed"); |
| 561 | goto out_errno; | 570 | goto out_errno; |
| 562 | } | 571 | } |
| 563 | if (recvp) { | 572 | if (recvp) { |
| @@ -565,7 +574,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 1 unmodified line | |||
| 565 | recvp, | 574 | recvp, |
| 566 | chunk_sz); | 575 | chunk_sz); |
| 567 | if (errno) { | 576 | if (errno) { |
| 568 | perror("data verify msg_peek failed\n"); | 577 | perror("data verify msg_peek failed"); |
| 569 | goto out_errno; | 578 | goto out_errno; |
| 570 | } | 579 | } |
| 571 | } | 580 | } |
| @@ -654,7 +663,7 @@ static int sendmsg_test(struct sockmap_options *opt) · 82 unmodified lines | |||
| 654 | err = 0; | 663 | err = 0; |
| 655 | exit(err ? 1 : 0); | 664 | exit(err ? 1 : 0); |
| 656 | } else if (rxpid == -1) { | 665 | } else if (rxpid == -1) { |
| 657 | perror("msg_loop_rx: "); | 666 | perror("msg_loop_rx"); |
| 658 | return errno; | 667 | return errno; |
| 659 | } | 668 | } |
| 660 | 669 | ||
| @@ -681,7 +690,7 @@ static int sendmsg_test(struct sockmap_options *opt) · 20 unmodified lines | |||
| 681 | s.bytes_recvd, recvd_Bps, recvd_Bps/giga); | 690 | s.bytes_recvd, recvd_Bps, recvd_Bps/giga); |
| 682 | exit(err ? 1 : 0); | 691 | exit(err ? 1 : 0); |
| 683 | } else if (txpid == -1) { | 692 | } else if (txpid == -1) { |
| 684 | perror("msg_loop_tx: "); | 693 | perror("msg_loop_tx"); |
| 685 | return errno; | 694 | return errno; |
| 686 | } | 695 | } |
| 687 | 696 | ||
| @@ -715,7 +724,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt) · 27 unmodified lines | |||
| 715 | /* Ping/Pong data from client to server */ | 724 | /* Ping/Pong data from client to server */ |
| 716 | sc = send(c1, buf, sizeof(buf), 0); | 725 | sc = send(c1, buf, sizeof(buf), 0); |
| 717 | if (sc < 0) { | 726 | if (sc < 0) { |
| 718 | perror("send failed()\n"); | 727 | perror("send failed()"); |
| 719 | return sc; | 728 | return sc; |
| 720 | } | 729 | } |
| 721 | 730 | ||
| @@ -748,7 +757,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt) · 26 unmodified lines | |||
| 748 | rc = recv(i, buf, sizeof(buf), 0); | 757 | rc = recv(i, buf, sizeof(buf), 0); |
| 749 | if (rc < 0) { | 758 | if (rc < 0) { |
| 750 | if (errno != EWOULDBLOCK) { | 759 | if (errno != EWOULDBLOCK) { |
| 751 | perror("recv failed()\n"); | 760 | perror("recv failed()"); |
| 752 | return rc; | 761 | return rc; |
| 753 | } | 762 | } |
| 754 | } | 763 | } |
| @@ -760,7 +769,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt) · 5 unmodified lines | |||
| 760 | 769 | ||
| 761 | sc = send(i, buf, rc, 0); | 770 | sc = send(i, buf, rc, 0); |
| 762 | if (sc < 0) { | 771 | if (sc < 0) { |
| 763 | perror("send failed()\n"); | 772 | perror("send failed()"); |
| 764 | return sc; | 773 | return sc; |
| 765 | } | 774 | } |
| 766 | } | 775 | } |
| @@ -45,7 +45,7 @@ static int get_stats(int fd, __u16 count, __u32 raddr) · 44 unmodified lines | |||
| 45 | printf("\nXDP RTT data:\n"); | 45 | printf("\nXDP RTT data:\n"); |
| 46 | 46 | ||
| 47 | if (bpf_map_lookup_elem(fd, &raddr, &pinginfo)) { | 47 | if (bpf_map_lookup_elem(fd, &raddr, &pinginfo)) { |
| 48 | perror("bpf_map_lookup elem: "); | 48 | perror("bpf_map_lookup elem"); |
| 49 | return 1; | 49 | return 1; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| @@ -3,16 +3,42 @@ · 2 unmodified lines | |||
| 3 | 3 | ||
| 4 | CHECK_TC="yes" | 4 | CHECK_TC="yes" |
| 5 | 5 | ||
| 6 | # Can be overridden by the configuration file. See lib.sh | ||
| 7 | TC_HIT_TIMEOUT=${TC_HIT_TIMEOUT:=1000} # ms | ||
| 8 | |||
| 9 | __tc_check_packets() | ||
| 10 | { | ||
| 11 | local id=$1 | ||
| 12 | local handle=$2 | ||
| 13 | local count=$3 | ||
| 14 | local operator=$4 | ||
| 15 | |||
| 16 | start_time="$(date -u +%s%3N)" | ||
| 17 | while true | ||
| 18 | do | ||
| 19 | cmd_jq "tc -j -s filter show $id" \ | ||
| 20 | ".[] | select(.options.handle == $handle) | \ | ||
| 21 | select(.options.actions[0].stats.packets $operator $count)" \ | ||
| 22 | &> /dev/null | ||
| 23 | ret=$? | ||
| 24 | if [[ $ret -eq 0 ]]; then | ||
| 25 | return $ret | ||
| 26 | fi | ||
| 27 | current_time="$(date -u +%s%3N)" | ||
| 28 | diff=$(expr $current_time - $start_time) | ||
| 29 | if [ "$diff" -gt "$TC_HIT_TIMEOUT" ]; then | ||
| 30 | return 1 | ||
| 31 | fi | ||
| 32 | done | ||
| 33 | } | ||
| 34 | |||
| 6 | tc_check_packets() | 35 | tc_check_packets() |
| 7 | { | 36 | { |
| 8 | local id=$1 | 37 | local id=$1 |
| 9 | local handle=$2 | 38 | local handle=$2 |
| 10 | local count=$3 | 39 | local count=$3 |
| 11 | 40 | ||
| 12 | cmd_jq "tc -j -s filter show $id" \ | 41 | __tc_check_packets "$id" "$handle" "$count" "==" |
| 13 | ".[] | select(.options.handle == $handle) | \ | ||
| 14 | select(.options.actions[0].stats.packets == $count)" \ | ||
| 15 | &> /dev/null | ||
| 16 | } | 42 | } |
| 17 | 43 | ||
| 18 | tc_check_packets_hitting() | 44 | tc_check_packets_hitting() |
| @@ -20,8 +46,5 @@ tc_check_packets_hitting() · 1 unmodified line | |||
| 20 | local id=$1 | 46 | local id=$1 |
| 21 | local handle=$2 | 47 | local handle=$2 |
| 22 | 48 | ||
| 23 | cmd_jq "tc -j -s filter show $id" \ | 49 | __tc_check_packets "$id" "$handle" 0 ">" |
| 24 | ".[] | select(.options.handle == $handle) | \ | ||
| 25 | select(.options.actions[0].stats.packets > 0)" \ | ||
| 26 | &> /dev/null | ||
| 27 | } | 50 | } |
| @@ -1249,8 +1249,7 @@ test_list_flush_ipv4_exception() { · 1248 unmodified lines | |||
| 1249 | done | 1249 | done |
| 1250 | run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst2}" | 1250 | run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst2}" |
| 1251 | 1251 | ||
| 1252 | # Each exception is printed as two lines | 1252 | if [ "$(${ns_a} ip -oneline route list cache | wc -l)" -ne 101 ]; then |
| 1253 | if [ "$(${ns_a} ip route list cache | wc -l)" -ne 202 ]; then | ||
| 1254 | err " can't list cached exceptions" | 1253 | err " can't list cached exceptions" |
| 1255 | fail=1 | 1254 | fail=1 |
| 1256 | fi | 1255 | fi |
| @@ -1300,7 +1299,7 @@ test_list_flush_ipv6_exception() { · 43 unmodified lines | |||
| 1300 | run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst_prefix1}${i}" | 1299 | run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst_prefix1}${i}" |
| 1301 | done | 1300 | done |
| 1302 | run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst2}" | 1301 | run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst2}" |
| 1303 | if [ "$(${ns_a} ip -6 route list cache | wc -l)" -ne 101 ]; then | 1302 | if [ "$(${ns_a} ip -oneline -6 route list cache | wc -l)" -ne 101 ]; then |
| 1304 | err " can't list cached exceptions" | 1303 | err " can't list cached exceptions" |
| 1305 | fail=1 | 1304 | fail=1 |
| 1306 | fi | 1305 | fi |
| @@ -268,6 +268,38 @@ TEST_F(tls, sendmsg_single) · 267 unmodified lines | |||
| 268 | EXPECT_EQ(memcmp(buf, test_str, send_len), 0); | 268 | EXPECT_EQ(memcmp(buf, test_str, send_len), 0); |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | #define MAX_FRAGS 64 | ||
| 272 | #define SEND_LEN 13 | ||
| 273 | TEST_F(tls, sendmsg_fragmented) | ||
| 274 | { | ||
| 275 | char const *test_str = "test_sendmsg"; | ||
| 276 | char buf[SEND_LEN * MAX_FRAGS]; | ||
| 277 | struct iovec vec[MAX_FRAGS]; | ||
| 278 | struct msghdr msg; | ||
| 279 | int i, frags; | ||
| 280 | |||
| 281 | for (frags = 1; frags <= MAX_FRAGS; frags++) { | ||
| 282 | for (i = 0; i < frags; i++) { | ||
| 283 | vec[i].iov_base = (char *)test_str; | ||
| 284 | vec[i].iov_len = SEND_LEN; | ||
| 285 | } | ||
| 286 | |||
| 287 | memset(&msg, 0, sizeof(struct msghdr)); | ||
| 288 | msg.msg_iov = vec; | ||
| 289 | msg.msg_iovlen = frags; | ||
| 290 | |||
| 291 | EXPECT_EQ(sendmsg(self->fd, &msg, 0), SEND_LEN * frags); | ||
| 292 | EXPECT_EQ(recv(self->cfd, buf, SEND_LEN * frags, MSG_WAITALL), | ||
| 293 | SEND_LEN * frags); | ||
| 294 | |||
| 295 | for (i = 0; i < frags; i++) | ||
| 296 | EXPECT_EQ(memcmp(buf + SEND_LEN * i, | ||
| 297 | test_str, SEND_LEN), 0); | ||
| 298 | } | ||
| 299 | } | ||
| 300 | #undef MAX_FRAGS | ||
| 301 | #undef SEND_LEN | ||
| 302 | |||
| 271 | TEST_F(tls, sendmsg_large) | 303 | TEST_F(tls, sendmsg_large) |
| 272 | { | 304 | { |
| 273 | void *mem = malloc(16384); | 305 | void *mem = malloc(16384); |
| @@ -694,6 +726,34 @@ TEST_F(tls, recv_lowat) · 420 unmodified lines | |||
| 694 | EXPECT_EQ(memcmp(send_mem, recv_mem + 10, 5), 0); | 726 | EXPECT_EQ(memcmp(send_mem, recv_mem + 10, 5), 0); |
| 695 | } | 727 | } |
| 696 | 728 | ||
| 729 | TEST_F(tls, recv_rcvbuf) | ||
| 730 | { | ||
| 731 | char send_mem[4096]; | ||
| 732 | char recv_mem[4096]; | ||
| 733 | int rcv_buf = 1024; | ||
| 734 | |||
| 735 | memset(send_mem, 0x1c, sizeof(send_mem)); | ||
| 736 | |||
| 737 | EXPECT_EQ(setsockopt(self->cfd, SOL_SOCKET, SO_RCVBUF, | ||
| 738 | &rcv_buf, sizeof(rcv_buf)), 0); | ||
| 739 | |||
| 740 | EXPECT_EQ(send(self->fd, send_mem, 512, 0), 512); | ||
| 741 | memset(recv_mem, 0, sizeof(recv_mem)); | ||
| 742 | EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0), 512); | ||
| 743 | EXPECT_EQ(memcmp(send_mem, recv_mem, 512), 0); | ||
| 744 | |||
| 745 | if (self->notls) | ||
| 746 | return; | ||
| 747 | |||
| 748 | EXPECT_EQ(send(self->fd, send_mem, 4096, 0), 4096); | ||
| 749 | memset(recv_mem, 0, sizeof(recv_mem)); | ||
| 750 | EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0), -1); | ||
| 751 | EXPECT_EQ(errno, EMSGSIZE); | ||
| 752 | |||
| 753 | EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0), -1); | ||
| 754 | EXPECT_EQ(errno, EMSGSIZE); | ||
| 755 | } | ||
| 756 | |||
| 697 | TEST_F(tls, bidir) | 757 | TEST_F(tls, bidir) |
| 698 | { | 758 | { |
| 699 | char const *test_str = "test_read"; | 759 | char const *test_str = "test_read"; |