History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

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 ...

Linus Torvalds committed 6 years ago

Commit c3bfc5d2 parents e5b3fc1 c5d728124 files · +254 −134Browse files

Unified · Split

24 files
  1. drivers/net/ethernet/cadence/macb_main.c +1 −0
  2. drivers/net/ethernet/emulex/benet/Kconfig +1 −1
  3. drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +38 −36
  4. drivers/net/ethernet/realtek/r8169_main.c +2 −1
  5. drivers/net/ethernet/ti/cpsw_ale.c +9 −3
  6. drivers/net/phy/realtek.c +9 −0
  7. include/linux/skmsg.h +14 −14
  8. include/net/tls.h +1 −2
  9. net/core/filter.c +4 −4
  10. net/core/skmsg.c +1 −1
  11. net/ipv4/tcp_bpf.c +1 −1
  12. net/openvswitch/datapath.c +9 −2
  13. net/sched/sch_mq.c +2 −1
  14. net/sched/sch_mqprio.c +2 −2
  15. net/sched/sch_multiq.c +1 −1
  16. net/sched/sch_prio.c +1 −1
  17. net/tipc/socket.c +15 −9
  18. net/tls/tls_main.c +2 −11
  19. net/tls/tls_sw.c +19 −13
  20. tools/testing/selftests/bpf/test_sockmap.c +28 −19
  21. tools/testing/selftests/bpf/xdping.c +1 −1
  22. tools/testing/selftests/net/forwarding/tc_common.sh +31 −8
  23. tools/testing/selftests/net/pmtu.sh +2 −3
  24. tools/testing/selftests/net/tls.c +60 −0
drivers/net/ethernet/cadence/macb_main.c+1−0
@@ -4422,6 +4422,7 @@ static int macb_remove(struct platform_device *pdev) · 4421 unmodified lines
44224422 mdiobus_free(bp->mii_bus);
44234423
44244424 unregister_netdev(dev);
4425+ tasklet_kill(&bp->hresp_err_tasklet);
44254426 pm_runtime_disable(&pdev->dev);
44264427 pm_runtime_dont_use_autosuspend(&pdev->dev);
44274428 if (!pm_runtime_suspended(&pdev->dev)) {
drivers/net/ethernet/emulex/benet/Kconfig+1−1
@@ -49,4 +49,4 @@ config BE2NET_SKYHAWK · 48 unmodified lines
4949
5050 comment "WARNING: be2net is useless without any enabled chip"
5151 depends on BE2NET_BE2=n && BE2NET_BE3=n && BE2NET_LANCER=n && \
52− BE2NET_SKYHAWK=n && BE2NET
52+ BE2NET_SKYHAWK=n && BE2NET
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c+38−36
@@ -130,42 +130,6 @@ static const char *mlx5e_netdev_kind(struct net_device *dev) · 129 unmodified lines
130130 return "unknown";
131131 }
132132
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−
169133 static int mlx5e_gen_ip_tunnel_header(char buf[], __u8 *ip_proto,
170134 struct mlx5e_encap_entry *e)
171135 {
@@ -319,6 +283,43 @@ release_neigh: · 147 unmodified lines
319283 return err;
320284 }
321285
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+
322323 int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
323324 struct net_device *mirred_dev,
324325 struct mlx5e_encap_entry *e)
@@ -436,6 +437,7 @@ release_neigh: · 111 unmodified lines
436437 neigh_release(n);
437438 return err;
438439 }
440+#endif
439441
440442 bool mlx5e_tc_tun_device_to_offload(struct mlx5e_priv *priv,
441443 struct net_device *netdev)
drivers/net/ethernet/realtek/r8169_main.c+2−1
@@ -1542,6 +1542,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) · 1541 unmodified lines
15421542 rtl_lock_config_regs(tp);
15431543
15441544 device_set_wakeup_enable(tp_to_dev(tp), wolopts);
1545+ tp->dev->wol_enabled = wolopts ? 1 : 0;
15451546 }
15461547
15471548 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
38723873 case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28:
38733874 r8168dp_hw_jumbo_enable(tp);
38743875 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:
38763877 r8168e_hw_jumbo_enable(tp);
38773878 break;
38783879 default:
drivers/net/ethernet/ti/cpsw_ale.c+9−3
@@ -384,7 +384,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask, · 383 unmodified lines
384384 int flags, u16 vid)
385385 {
386386 u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
387− int mcast_members;
387+ int mcast_members = 0;
388388 int idx;
389389
390390 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
397397 mcast_members = cpsw_ale_get_port_mask(ale_entry,
398398 ale->port_mask_bits);
399399 mcast_members &= ~port_mask;
400+ }
401+
402+ if (mcast_members)
400403 cpsw_ale_set_port_mask(ale_entry, mcast_members,
401404 ale->port_mask_bits);
402− } else {
405+ else
403406 cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE);
404− }
405407
406408 cpsw_ale_write(ale, idx, ale_entry);
407409 return 0;
@@ -478,6 +480,10 @@ static void cpsw_ale_del_vlan_modify(struct cpsw_ale *ale, u32 *ale_entry, · 70 unmodified lines
478480 members = cpsw_ale_get_vlan_member_list(ale_entry,
479481 ale->vlan_field_bits);
480482 members &= ~port_mask;
483+ if (!members) {
484+ cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE);
485+ return;
486+ }
481487
482488 untag = cpsw_ale_get_vlan_untag_force(ale_entry,
483489 ale->vlan_field_bits);
drivers/net/phy/realtek.c+9−0
@@ -439,6 +439,15 @@ static struct phy_driver realtek_drvs[] = { · 438 unmodified lines
439439 .resume = genphy_resume,
440440 .read_page = rtl821x_read_page,
441441 .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,
442451 }, {
443452 PHY_ID_MATCH_EXACT(0x001cc910),
444453 .name = "RTL8211 Gigabit Ethernet",
include/linux/skmsg.h+14−14
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <net/strparser.h>
1515
1616 #define MAX_MSG_FRAGS MAX_SKB_FRAGS
17+#define NR_MSG_FRAG_IDS (MAX_MSG_FRAGS + 1)
1718
1819 enum __sk_action {
1920 __SK_DROP = 0,
@@ -29,13 +30,15 @@ struct sk_msg_sg { · 9 unmodified lines
2930 u32 size;
3031 u32 copybreak;
3132 unsigned long copy;
32− /* The extra element is used for chaining the front and sections when
33− * the list becomes partitioned (e.g. end < start). The crypto APIs
34− * require the chaining.
33+ /* The extra two elements:
34+ * 1) used for chaining the front and sections when the list becomes
35+ * partitioned (e.g. end < start). The crypto APIs require the
36+ * chaining;
37+ * 2) to chain tailer SG entries after the message.
3538 */
36− struct scatterlist data[MAX_MSG_FRAGS + 1];
39+ struct scatterlist data[MAX_MSG_FRAGS + 2];
3740 };
38−static_assert(BITS_PER_LONG >= MAX_MSG_FRAGS);
41+static_assert(BITS_PER_LONG >= NR_MSG_FRAG_IDS);
3942
4043 /* UAPI in filter.c depends on struct sk_msg_sg being first element. */
4144 struct sk_msg {
@@ -142,13 +145,13 @@ static inline void sk_msg_apply_bytes(struct sk_psock *psock, u32 bytes) · 100 unmodified lines
142145
143146 static inline u32 sk_msg_iter_dist(u32 start, u32 end)
144147 {
145− return end >= start ? end - start : end + (MAX_MSG_FRAGS - start);
148+ return end >= start ? end - start : end + (NR_MSG_FRAG_IDS - start);
146149 }
147150
148151 #define sk_msg_iter_var_prev(var) \
149152 do { \
150153 if (var == 0) \
151− var = MAX_MSG_FRAGS - 1; \
154+ var = NR_MSG_FRAG_IDS - 1; \
152155 else \
153156 var--; \
154157 } while (0)
@@ -156,7 +159,7 @@ static inline u32 sk_msg_iter_dist(u32 start, u32 end) · 1 unmodified line
156159 #define sk_msg_iter_var_next(var) \
157160 do { \
158161 var++; \
159− if (var == MAX_MSG_FRAGS) \
162+ if (var == NR_MSG_FRAG_IDS) \
160163 var = 0; \
161164 } while (0)
162165
@@ -173,9 +176,9 @@ static inline void sk_msg_clear_meta(struct sk_msg *msg) · 10 unmodified lines
173176
174177 static inline void sk_msg_init(struct sk_msg *msg)
175178 {
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);
177180 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);
179182 }
180183
181184 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
196199
197200 static inline bool sk_msg_full(const struct sk_msg *msg)
198201 {
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;
200203 }
201204
202205 static inline u32 sk_msg_elem_used(const struct sk_msg *msg)
203206 {
204− if (sk_msg_full(msg))
205− return MAX_MSG_FRAGS;
206−
207207 return sk_msg_iter_dist(msg->sg.start, msg->sg.end);
208208 }
209209
include/net/tls.h+1−2
@@ -100,7 +100,6 @@ struct tls_rec { · 99 unmodified lines
100100 struct list_head list;
101101 int tx_ready;
102102 int tx_flags;
103− int inplace_crypto;
104103
105104 struct sk_msg msg_plaintext;
106105 struct sk_msg msg_encrypted;
@@ -377,7 +376,7 @@ int tls_push_sg(struct sock *sk, struct tls_context *ctx, · 270 unmodified lines
377376 int flags);
378377 int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
379378 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);
381380
382381 static inline struct tls_msg *tls_msg(struct sk_buff *skb)
383382 {
net/core/filter.c+4−4
@@ -2299,7 +2299,7 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start, · 2298 unmodified lines
22992299 WARN_ON_ONCE(last_sge == first_sge);
23002300 shift = last_sge > first_sge ?
23012301 last_sge - first_sge - 1 :
2302− MAX_SKB_FRAGS - first_sge + last_sge - 1;
2302+ NR_MSG_FRAG_IDS - first_sge + last_sge - 1;
23032303 if (!shift)
23042304 goto out;
23052305
@@ -2308,8 +2308,8 @@ BPF_CALL_4(bpf_msg_pull_data, struct sk_msg *, msg, u32, start, · 2 unmodified lines
23082308 do {
23092309 u32 move_from;
23102310
2311− if (i + shift >= MAX_MSG_FRAGS)
2312− move_from = i + shift - MAX_MSG_FRAGS;
2311+ if (i + shift >= NR_MSG_FRAG_IDS)
2312+ move_from = i + shift - NR_MSG_FRAG_IDS;
23132313 else
23142314 move_from = i + shift;
23152315 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
23232323 } while (1);
23242324
23252325 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 :
23272327 msg->sg.end - shift;
23282328 out:
23292329 msg->data = sg_virt(&msg->sg.data[first_sge]) + start - offset;
net/core/skmsg.c+1−1
@@ -421,7 +421,7 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb) · 420 unmodified lines
421421 copied = skb->len;
422422 msg->sg.start = 0;
423423 msg->sg.size = copied;
424− msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge;
424+ msg->sg.end = num_sge;
425425 msg->skb = skb;
426426
427427 sk_psock_queue_msg(psock, msg);
net/ipv4/tcp_bpf.c+1−1
@@ -301,7 +301,7 @@ EXPORT_SYMBOL_GPL(tcp_bpf_sendmsg_redir); · 300 unmodified lines
301301 static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,
302302 struct sk_msg *msg, int *copied, int flags)
303303 {
304− bool cork = false, enospc = msg->sg.start == msg->sg.end;
304+ bool cork = false, enospc = sk_msg_full(msg);
305305 struct sock *sk_redir;
306306 u32 tosend, delta = 0;
307307 int ret;
net/openvswitch/datapath.c+9−2
@@ -905,7 +905,10 @@ static struct sk_buff *ovs_flow_cmd_build_info(const struct sw_flow *flow, · 904 unmodified lines
905905 retval = ovs_flow_cmd_fill_info(flow, dp_ifindex, skb,
906906 info->snd_portid, info->snd_seq, 0,
907907 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+ }
909912 return skb;
910913 }
911914
@@ -1369,7 +1372,10 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) · 457 unmodified lines
13691372 OVS_FLOW_CMD_DEL,
13701373 ufid_flags);
13711374 rcu_read_unlock();
1372− BUG_ON(err < 0);
1375+ if (WARN_ON_ONCE(err < 0)) {
1376+ kfree_skb(reply);
1377+ goto out_free;
1378+ }
13731379
13741380 ovs_notify(&dp_flow_genl_family, reply, info);
13751381 } else {
@@ -1377,6 +1383,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) · 1 unmodified line
13771383 }
13781384 }
13791385
1386+out_free:
13801387 ovs_flow_free(flow, true);
13811388 return 0;
13821389 unlock:
net/sched/sch_mq.c+2−1
@@ -245,7 +245,8 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 244 unmodified lines
245245 struct netdev_queue *dev_queue = mq_queue_get(sch, cl);
246246
247247 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 ||
249250 qdisc_qstats_copy(d, sch) < 0)
250251 return -1;
251252 return 0;
net/sched/sch_mqprio.c+2−2
@@ -557,8 +557,8 @@ static int mqprio_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 556 unmodified lines
557557 struct netdev_queue *dev_queue = mqprio_queue_get(sch, cl);
558558
559559 sch = dev_queue->qdisc_sleeping;
560− if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch),
561− d, NULL, &sch->bstats) < 0 ||
560+ if (gnet_stats_copy_basic(qdisc_root_sleeping_running(sch), d,
561+ sch->cpu_bstats, &sch->bstats) < 0 ||
562562 qdisc_qstats_copy(d, sch) < 0)
563563 return -1;
564564 }
net/sched/sch_multiq.c+1−1
@@ -339,7 +339,7 @@ static int multiq_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 338 unmodified lines
339339
340340 cl_q = q->queues[cl - 1];
341341 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 ||
343343 qdisc_qstats_copy(d, cl_q) < 0)
344344 return -1;
345345
net/sched/sch_prio.c+1−1
@@ -356,7 +356,7 @@ static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl, · 355 unmodified lines
356356
357357 cl_q = q->queues[cl - 1];
358358 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 ||
360360 qdisc_qstats_copy(d, cl_q) < 0)
361361 return -1;
362362
net/tipc/socket.c+15−9
@@ -532,7 +532,7 @@ static void __tipc_shutdown(struct socket *sock, int error) · 531 unmodified lines
532532 struct sock *sk = sock->sk;
533533 struct tipc_sock *tsk = tipc_sk(sk);
534534 struct net *net = sock_net(sk);
535− long timeout = CONN_TIMEOUT_DEFAULT;
535+ long timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT);
536536 u32 dnode = tsk_peer_node(tsk);
537537 struct sk_buff *skb;
538538
@@ -540,12 +540,10 @@ static void __tipc_shutdown(struct socket *sock, int error) · 1 unmodified line
540540 tipc_wait_for_cond(sock, &timeout, (!tsk->cong_link_cnt &&
541541 !tsk_conn_cong(tsk)));
542542
543− /* Push out unsent messages or remove if pending SYN */
544− skb = skb_peek(&sk->sk_write_queue);
545− if (skb && !msg_is_syn(buf_msg(skb)))
546− tipc_sk_push_backlog(tsk);
547− else
548− __skb_queue_purge(&sk->sk_write_queue);
543+ /* Push out delayed messages if in Nagle mode */
544+ tipc_sk_push_backlog(tsk);
545+ /* Remove pending SYN */
546+ __skb_queue_purge(&sk->sk_write_queue);
549547
550548 /* Reject all unreceived messages, except on an active connection
551549 * (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
12481246 struct sk_buff_head *txq = &tsk->sk.sk_write_queue;
12491247 struct net *net = sock_net(&tsk->sk);
12501248 u32 dnode = tsk_peer_node(tsk);
1249+ struct sk_buff *skb = skb_peek(txq);
12511250 int rc;
12521251
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)))
12541257 return;
12551258
12561259 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
14471450 rc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts);
14481451 if (unlikely(rc != dlen))
14491452 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);
14511455 return -ENOMEM;
1456+ }
14521457
14531458 trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, " ");
14541459 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
27572762 if (sock_owned_by_user(sk)) {
27582763 sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 20);
27592764 bh_unlock_sock(sk);
2765+ sock_put(sk);
27602766 return;
27612767 }
27622768
net/tls/tls_main.c+2−11
@@ -209,24 +209,15 @@ int tls_push_partial_record(struct sock *sk, struct tls_context *ctx, · 208 unmodified lines
209209 return tls_push_sg(sk, ctx, sg, offset, flags);
210210 }
211211
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)
213213 {
214214 struct scatterlist *sg;
215215
216− sg = ctx->partially_sent_record;
217− if (!sg)
218− return false;
219−
220− while (1) {
216+ for (sg = ctx->partially_sent_record; sg; sg = sg_next(sg)) {
221217 put_page(sg_page(sg));
222218 sk_mem_uncharge(sk, sg->length);
223−
224− if (sg_is_last(sg))
225− break;
226− sg++;
227219 }
228220 ctx->partially_sent_record = NULL;
229− return true;
230221 }
231222
232223 static void tls_write_space(struct sock *sk)
net/tls/tls_sw.c+19−13
@@ -710,8 +710,7 @@ static int tls_push_record(struct sock *sk, int flags, · 709 unmodified lines
710710 }
711711
712712 i = msg_pl->sg.start;
713− sg_chain(rec->sg_aead_in, 2, rec->inplace_crypto ?
714− &msg_en->sg.data[i] : &msg_pl->sg.data[i]);
713+ sg_chain(rec->sg_aead_in, 2, &msg_pl->sg.data[i]);
715714
716715 i = msg_en->sg.end;
717716 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
771770
772771 policy = !(flags & MSG_SENDPAGE_NOPOLICY);
773772 psock = sk_psock_get(sk);
774− if (!psock || !policy)
775− return tls_push_record(sk, flags, record_type);
773+ if (!psock || !policy) {
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+ }
776781 more_data:
777782 enospc = sk_msg_full(msg);
778783 if (psock->eval == __SK_NONE) {
@@ -970,8 +975,6 @@ alloc_encrypted: · 191 unmodified lines
970975 if (ret)
971976 goto fallback_to_reg_send;
972977
973− rec->inplace_crypto = 0;
974−
975978 num_zc++;
976979 copied += try_to_copy;
977980
@@ -984,7 +987,7 @@ alloc_encrypted: · 6 unmodified lines
984987 num_async++;
985988 else if (ret == -ENOMEM)
986989 goto wait_for_memory;
987− else if (ret == -ENOSPC)
990+ else if (ctx->open_rec && ret == -ENOSPC)
988991 goto rollback_iter;
989992 else if (ret != -EAGAIN)
990993 goto send_end;
@@ -1053,11 +1056,12 @@ wait_for_memory: · 62 unmodified lines
10531056 ret = sk_stream_wait_memory(sk, &timeo);
10541057 if (ret) {
10551058 trim_sgl:
1056− tls_trim_both_msgs(sk, orig_size);
1059+ if (ctx->open_rec)
1060+ tls_trim_both_msgs(sk, orig_size);
10571061 goto send_end;
10581062 }
10591063
1060− if (msg_en->sg.size < required_size)
1064+ if (ctx->open_rec && msg_en->sg.size < required_size)
10611065 goto alloc_encrypted;
10621066 }
10631067
@@ -1169,7 +1173,6 @@ alloc_payload: · 105 unmodified lines
11691173
11701174 tls_ctx->pending_open_record_frags = true;
11711175 if (full_record || eor || sk_msg_full(msg_pl)) {
1172− rec->inplace_crypto = 0;
11731176 ret = bpf_exec_tx_verdict(msg_pl, sk, full_record,
11741177 record_type, &copied, flags);
11751178 if (ret) {
@@ -1190,11 +1193,13 @@ wait_for_sndbuf: · 14 unmodified lines
11901193 wait_for_memory:
11911194 ret = sk_stream_wait_memory(sk, &timeo);
11921195 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);
11941198 goto sendpage_end;
11951199 }
11961200
1197− goto alloc_payload;
1201+ if (ctx->open_rec)
1202+ goto alloc_payload;
11981203 }
11991204
12001205 if (num_async) {
@@ -2084,7 +2089,8 @@ void tls_sw_release_resources_tx(struct sock *sk) · 883 unmodified lines
20842089 /* Free up un-sent records in tx_list. First, free
20852090 * the partially sent record if any at head of tx_list.
20862091 */
2087− if (tls_free_partial_record(sk, tls_ctx)) {
2092+ if (tls_ctx->partially_sent_record) {
2093+ tls_free_partial_record(sk, tls_ctx);
20882094 rec = list_first_entry(&ctx->tx_list,
20892095 struct tls_rec, list);
20902096 list_del(&rec->list);
tools/testing/selftests/bpf/test_sockmap.c+28−19
@@ -240,14 +240,14 @@ static int sockmap_init_sockets(int verbose) · 239 unmodified lines
240240 addr.sin_port = htons(S1_PORT);
241241 err = bind(s1, (struct sockaddr *)&addr, sizeof(addr));
242242 if (err < 0) {
243− perror("bind s1 failed()\n");
243+ perror("bind s1 failed()");
244244 return errno;
245245 }
246246
247247 addr.sin_port = htons(S2_PORT);
248248 err = bind(s2, (struct sockaddr *)&addr, sizeof(addr));
249249 if (err < 0) {
250− perror("bind s2 failed()\n");
250+ perror("bind s2 failed()");
251251 return errno;
252252 }
253253
@@ -255,14 +255,14 @@ static int sockmap_init_sockets(int verbose) · 1 unmodified line
255255 addr.sin_port = htons(S1_PORT);
256256 err = listen(s1, 32);
257257 if (err < 0) {
258− perror("listen s1 failed()\n");
258+ perror("listen s1 failed()");
259259 return errno;
260260 }
261261
262262 addr.sin_port = htons(S2_PORT);
263263 err = listen(s2, 32);
264264 if (err < 0) {
265− perror("listen s1 failed()\n");
265+ perror("listen s1 failed()");
266266 return errno;
267267 }
268268
@@ -270,14 +270,14 @@ static int sockmap_init_sockets(int verbose) · 1 unmodified line
270270 addr.sin_port = htons(S1_PORT);
271271 err = connect(c1, (struct sockaddr *)&addr, sizeof(addr));
272272 if (err < 0 && errno != EINPROGRESS) {
273− perror("connect c1 failed()\n");
273+ perror("connect c1 failed()");
274274 return errno;
275275 }
276276
277277 addr.sin_port = htons(S2_PORT);
278278 err = connect(c2, (struct sockaddr *)&addr, sizeof(addr));
279279 if (err < 0 && errno != EINPROGRESS) {
280− perror("connect c2 failed()\n");
280+ perror("connect c2 failed()");
281281 return errno;
282282 } else if (err < 0) {
283283 err = 0;
@@ -286,13 +286,13 @@ static int sockmap_init_sockets(int verbose) · 2 unmodified lines
286286 /* Accept Connecrtions */
287287 p1 = accept(s1, NULL, NULL);
288288 if (p1 < 0) {
289− perror("accept s1 failed()\n");
289+ perror("accept s1 failed()");
290290 return errno;
291291 }
292292
293293 p2 = accept(s2, NULL, NULL);
294294 if (p2 < 0) {
295− perror("accept s1 failed()\n");
295+ perror("accept s1 failed()");
296296 return errno;
297297 }
298298
@@ -332,6 +332,10 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, · 33 unmodified lines
332332 int i, fp;
333333
334334 file = fopen(".sendpage_tst.tmp", "w+");
335+ if (!file) {
336+ perror("create file for sendpage");
337+ return 1;
338+ }
335339 for (i = 0; i < iov_length * cnt; i++, k++)
336340 fwrite(&k, sizeof(char), 1, file);
337341 fflush(file);
@@ -339,12 +343,17 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, · 1 unmodified line
339343 fclose(file);
340344
341345 fp = open(".sendpage_tst.tmp", O_RDONLY);
346+ if (fp < 0) {
347+ perror("reopen file for sendpage");
348+ return 1;
349+ }
350+
342351 clock_gettime(CLOCK_MONOTONIC, &s->start);
343352 for (i = 0; i < cnt; i++) {
344353 int sent = sendfile(fd, fp, NULL, iov_length);
345354
346355 if (!drop && sent < 0) {
347− perror("send loop error:");
356+ perror("send loop error");
348357 close(fp);
349358 return sent;
350359 } 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
463472 int sent = sendmsg(fd, &msg, flags);
464473
465474 if (!drop && sent < 0) {
466− perror("send loop error:");
475+ perror("send loop error");
467476 goto out_errno;
468477 } else if (drop && sent >= 0) {
469478 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
499508 total_bytes -= txmsg_pop_total;
500509 err = clock_gettime(CLOCK_MONOTONIC, &s->start);
501510 if (err < 0)
502− perror("recv start time: ");
511+ perror("recv start time");
503512 while (s->bytes_recvd < total_bytes) {
504513 if (txmsg_cork) {
505514 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
543552 if (recv < 0) {
544553 if (errno != EWOULDBLOCK) {
545554 clock_gettime(CLOCK_MONOTONIC, &s->end);
546− perror("recv failed()\n");
555+ perror("recv failed()");
547556 goto out_errno;
548557 }
549558 }
@@ -557,7 +566,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 7 unmodified lines
557566
558567 errno = msg_verify_data(&msg, recv, chunk_sz);
559568 if (errno) {
560− perror("data verify msg failed\n");
569+ perror("data verify msg failed");
561570 goto out_errno;
562571 }
563572 if (recvp) {
@@ -565,7 +574,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, · 1 unmodified line
565574 recvp,
566575 chunk_sz);
567576 if (errno) {
568− perror("data verify msg_peek failed\n");
577+ perror("data verify msg_peek failed");
569578 goto out_errno;
570579 }
571580 }
@@ -654,7 +663,7 @@ static int sendmsg_test(struct sockmap_options *opt) · 82 unmodified lines
654663 err = 0;
655664 exit(err ? 1 : 0);
656665 } else if (rxpid == -1) {
657− perror("msg_loop_rx: ");
666+ perror("msg_loop_rx");
658667 return errno;
659668 }
660669
@@ -681,7 +690,7 @@ static int sendmsg_test(struct sockmap_options *opt) · 20 unmodified lines
681690 s.bytes_recvd, recvd_Bps, recvd_Bps/giga);
682691 exit(err ? 1 : 0);
683692 } else if (txpid == -1) {
684− perror("msg_loop_tx: ");
693+ perror("msg_loop_tx");
685694 return errno;
686695 }
687696
@@ -715,7 +724,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt) · 27 unmodified lines
715724 /* Ping/Pong data from client to server */
716725 sc = send(c1, buf, sizeof(buf), 0);
717726 if (sc < 0) {
718− perror("send failed()\n");
727+ perror("send failed()");
719728 return sc;
720729 }
721730
@@ -748,7 +757,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt) · 26 unmodified lines
748757 rc = recv(i, buf, sizeof(buf), 0);
749758 if (rc < 0) {
750759 if (errno != EWOULDBLOCK) {
751− perror("recv failed()\n");
760+ perror("recv failed()");
752761 return rc;
753762 }
754763 }
@@ -760,7 +769,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt) · 5 unmodified lines
760769
761770 sc = send(i, buf, rc, 0);
762771 if (sc < 0) {
763− perror("send failed()\n");
772+ perror("send failed()");
764773 return sc;
765774 }
766775 }
tools/testing/selftests/bpf/xdping.c+1−1
@@ -45,7 +45,7 @@ static int get_stats(int fd, __u16 count, __u32 raddr) · 44 unmodified lines
4545 printf("\nXDP RTT data:\n");
4646
4747 if (bpf_map_lookup_elem(fd, &raddr, &pinginfo)) {
48− perror("bpf_map_lookup elem: ");
48+ perror("bpf_map_lookup elem");
4949 return 1;
5050 }
5151
tools/testing/selftests/net/forwarding/tc_common.sh+31−8
@@ -3,16 +3,42 @@ · 2 unmodified lines
33
44 CHECK_TC="yes"
55
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+
635 tc_check_packets()
736 {
837 local id=$1
938 local handle=$2
1039 local count=$3
1140
12− cmd_jq "tc -j -s filter show $id" \
13− ".[] | select(.options.handle == $handle) | \
14− select(.options.actions[0].stats.packets == $count)" \
15− &> /dev/null
41+ __tc_check_packets "$id" "$handle" "$count" "=="
1642 }
1743
1844 tc_check_packets_hitting()
@@ -20,8 +46,5 @@ tc_check_packets_hitting() · 1 unmodified line
2046 local id=$1
2147 local handle=$2
2248
23− cmd_jq "tc -j -s filter show $id" \
24− ".[] | select(.options.handle == $handle) | \
25− select(.options.actions[0].stats.packets > 0)" \
26− &> /dev/null
49+ __tc_check_packets "$id" "$handle" 0 ">"
2750 }
tools/testing/selftests/net/pmtu.sh+2−3
@@ -1249,8 +1249,7 @@ test_list_flush_ipv4_exception() { · 1248 unmodified lines
12491249 done
12501250 run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst2}"
12511251
1252− # Each exception is printed as two lines
1253− if [ "$(${ns_a} ip route list cache | wc -l)" -ne 202 ]; then
1252+ if [ "$(${ns_a} ip -oneline route list cache | wc -l)" -ne 101 ]; then
12541253 err " can't list cached exceptions"
12551254 fail=1
12561255 fi
@@ -1300,7 +1299,7 @@ test_list_flush_ipv6_exception() { · 43 unmodified lines
13001299 run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst_prefix1}${i}"
13011300 done
13021301 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
13041303 err " can't list cached exceptions"
13051304 fail=1
13061305 fi
tools/testing/selftests/net/tls.c+60−0
@@ -268,6 +268,38 @@ TEST_F(tls, sendmsg_single) · 267 unmodified lines
268268 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
269269 }
270270
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+
271303 TEST_F(tls, sendmsg_large)
272304 {
273305 void *mem = malloc(16384);
@@ -694,6 +726,34 @@ TEST_F(tls, recv_lowat) · 420 unmodified lines
694726 EXPECT_EQ(memcmp(send_mem, recv_mem + 10, 5), 0);
695727 }
696728
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+
697757 TEST_F(tls, bidir)
698758 {
699759 char const *test_str = "test_read";

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t