aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-12-04 14:14:46 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-12-04 14:14:46 -0500
commit236fa078c622610a5e9df6225e997bd027cbf3c3 (patch)
treeffd8e0251028f00245d0dcf0f3b30d1ca746ebf4
parent8ee5ad1d4c0ba93f96d0db31e98102e61ff7d12b (diff)
parentc2eb6d07a63cb01f0ef978b28927335198c544ce (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Various TCP control block fixes, including one that crashes with SELinux, from David Ahern and Eric Dumazet. 2) Fix ACK generation in rxrpc, from David Howells. 3) ipvlan doesn't set the mark properly in the ipv4 route lookup key, from Gao Feng. 4) SIT configuration doesn't take on the frag_off ipv4 field configuration properly, fix from Hangbin Liu. 5) TSO can fail after device down/up on stmmac, fix from Lars Persson. 6) Various bpftool fixes (mostly in JSON handling) from Quentin Monnet. 7) Various SKB leak fixes in vhost/tun/tap (mostly observed as performance problems). From Wei Xu. 8) mvpps's TX descriptors were not zero initialized, from Yan Markman. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (57 commits) tcp: use IPCB instead of TCP_SKB_CB in inet_exact_dif_match() tcp: add tcp_v4_fill_cb()/tcp_v4_restore_cb() rxrpc: Fix the MAINTAINERS record rxrpc: Use correct netns source in rxrpc_release_sock() liquidio: fix incorrect indentation of assignment statement stmmac: reset last TSO segment size after device open ipvlan: Add the skb->mark as flow4's member to lookup route s390/qeth: build max size GSO skbs on L2 devices s390/qeth: fix GSO throughput regression s390/qeth: fix thinko in IPv4 multicast address tracking tap: free skb if flags error tun: free skb in early errors vhost: fix skb leak in handle_rx() bnxt_en: Fix a variable scoping in bnxt_hwrm_do_send_msg() bnxt_en: fix dst/src fid for vxlan encap/decap actions bnxt_en: wildcard smac while creating tunnel decap filter bnxt_en: Need to unconditionally shut down RoCE in bnxt_shutdown phylink: ensure we take the link down when phylink_stop() is called sfp: warn about modules requiring address change sequence sfp: improve RX_LOS handling ...
-rw-r--r--MAINTAINERS18
-rw-r--r--drivers/net/can/flexcan.c9
-rw-r--r--drivers/net/can/peak_canfd/peak_pciefd_main.c5
-rw-r--r--drivers/net/can/sja1000/peak_pci.c5
-rw-r--r--drivers/net/can/ti_hecc.c3
-rw-r--r--drivers/net/can/usb/kvaser_usb.c11
-rw-r--r--drivers/net/can/usb/mcba_usb.c3
-rw-r--r--drivers/net/dsa/bcm_sf2_cfp.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c5
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c55
-rw-r--r--drivers/net/ethernet/cavium/liquidio/lio_main.c2
-rw-r--r--drivers/net/ethernet/marvell/mvpp2.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c1
-rw-r--r--drivers/net/ipvlan/ipvlan_core.c1
-rw-r--r--drivers/net/phy/micrel.c6
-rw-r--r--drivers/net/phy/phylink.c1
-rw-r--r--drivers/net/phy/sfp.c41
-rw-r--r--drivers/net/tap.c14
-rw-r--r--drivers/net/tun.c24
-rw-r--r--drivers/s390/net/qeth_core.h3
-rw-r--r--drivers/s390/net/qeth_core_main.c31
-rw-r--r--drivers/s390/net/qeth_l2_main.c4
-rw-r--r--drivers/s390/net/qeth_l3_main.c7
-rw-r--r--drivers/vhost/net.c20
-rw-r--r--include/linux/skbuff.h3
-rw-r--r--include/net/sctp/structs.h3
-rw-r--r--include/net/tc_act/tc_sample.h1
-rw-r--r--include/net/tcp.h3
-rw-r--r--include/trace/events/xdp.h1
-rw-r--r--kernel/bpf/core.c3
-rw-r--r--kernel/bpf/offload.c15
-rw-r--r--kernel/trace/bpf_trace.c8
-rw-r--r--net/dccp/minisocks.c6
-rw-r--r--net/ipv4/tcp_ipv4.c59
-rw-r--r--net/ipv4/tcp_minisocks.c6
-rw-r--r--net/ipv6/sit.c1
-rw-r--r--net/ipv6/tcp_ipv6.c11
-rw-r--r--net/rxrpc/af_rxrpc.c5
-rw-r--r--net/rxrpc/call_event.c4
-rw-r--r--net/rxrpc/conn_event.c50
-rw-r--r--net/rxrpc/conn_object.c2
-rw-r--r--net/rxrpc/input.c4
-rw-r--r--net/rxrpc/sendmsg.c2
-rw-r--r--net/sched/act_sample.c14
-rw-r--r--net/sctp/chunk.c11
-rw-r--r--net/sctp/outqueue.c19
-rw-r--r--net/tipc/udp_media.c4
-rw-r--r--samples/bpf/bpf_load.c14
-rw-r--r--tools/bpf/bpftool/Documentation/Makefile2
-rw-r--r--tools/bpf/bpftool/Makefile7
-rw-r--r--tools/bpf/bpftool/main.c36
-rw-r--r--tools/bpf/bpftool/main.h5
-rw-r--r--tools/testing/selftests/bpf/test_verifier_log.c7
54 files changed, 397 insertions, 187 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 603d49e877a9..745337ed01f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -554,13 +554,13 @@ S: Orphan
554F: Documentation/filesystems/affs.txt 554F: Documentation/filesystems/affs.txt
555F: fs/affs/ 555F: fs/affs/
556 556
557AFS FILESYSTEM & AF_RXRPC SOCKET DOMAIN 557AFS FILESYSTEM
558M: David Howells <dhowells@redhat.com> 558M: David Howells <dhowells@redhat.com>
559L: linux-afs@lists.infradead.org 559L: linux-afs@lists.infradead.org
560S: Supported 560S: Supported
561F: fs/afs/ 561F: fs/afs/
562F: include/net/af_rxrpc.h 562F: include/trace/events/afs.h
563F: net/rxrpc/af_rxrpc.c 563F: Documentation/filesystems/afs.txt
564W: https://www.infradead.org/~dhowells/kafs/ 564W: https://www.infradead.org/~dhowells/kafs/
565 565
566AGPGART DRIVER 566AGPGART DRIVER
@@ -11776,6 +11776,18 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/jes/linux.git rtl8xxxu-deve
11776S: Maintained 11776S: Maintained
11777F: drivers/net/wireless/realtek/rtl8xxxu/ 11777F: drivers/net/wireless/realtek/rtl8xxxu/
11778 11778
11779RXRPC SOCKETS (AF_RXRPC)
11780M: David Howells <dhowells@redhat.com>
11781L: linux-afs@lists.infradead.org
11782S: Supported
11783F: net/rxrpc/
11784F: include/keys/rxrpc-type.h
11785F: include/net/af_rxrpc.h
11786F: include/trace/events/rxrpc.h
11787F: include/uapi/linux/rxrpc.h
11788F: Documentation/networking/rxrpc.txt
11789W: https://www.infradead.org/~dhowells/kafs/
11790
11779S3 SAVAGE FRAMEBUFFER DRIVER 11791S3 SAVAGE FRAMEBUFFER DRIVER
11780M: Antonino Daplas <adaplas@gmail.com> 11792M: Antonino Daplas <adaplas@gmail.com>
11781L: linux-fbdev@vger.kernel.org 11793L: linux-fbdev@vger.kernel.org
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index a13a4896a8bd..0626dcfd1f3d 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -184,12 +184,12 @@
184 * Below is some version info we got: 184 * Below is some version info we got:
185 * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR re- 185 * SOC Version IP-Version Glitch- [TR]WRN_INT IRQ Err Memory err RTR re-
186 * Filter? connected? Passive detection ception in MB 186 * Filter? connected? Passive detection ception in MB
187 * MX25 FlexCAN2 03.00.00.00 no no ? no no 187 * MX25 FlexCAN2 03.00.00.00 no no no no no
188 * MX28 FlexCAN2 03.00.04.00 yes yes no no no 188 * MX28 FlexCAN2 03.00.04.00 yes yes no no no
189 * MX35 FlexCAN2 03.00.00.00 no no ? no no 189 * MX35 FlexCAN2 03.00.00.00 no no no no no
190 * MX53 FlexCAN2 03.00.00.00 yes no no no no 190 * MX53 FlexCAN2 03.00.00.00 yes no no no no
191 * MX6s FlexCAN3 10.00.12.00 yes yes no no yes 191 * MX6s FlexCAN3 10.00.12.00 yes yes no no yes
192 * VF610 FlexCAN3 ? no yes ? yes yes? 192 * VF610 FlexCAN3 ? no yes no yes yes?
193 * 193 *
194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected. 194 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
195 */ 195 */
@@ -297,7 +297,8 @@ static const struct flexcan_devtype_data fsl_imx6q_devtype_data = {
297 297
298static const struct flexcan_devtype_data fsl_vf610_devtype_data = { 298static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
299 .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS | 299 .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
300 FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP, 300 FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
301 FLEXCAN_QUIRK_BROKEN_PERR_STATE,
301}; 302};
302 303
303static const struct can_bittiming_const flexcan_bittiming_const = { 304static const struct can_bittiming_const flexcan_bittiming_const = {
diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
index b4efd711f824..788c3464a3b0 100644
--- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
+++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
@@ -825,7 +825,10 @@ err_release_regions:
825err_disable_pci: 825err_disable_pci:
826 pci_disable_device(pdev); 826 pci_disable_device(pdev);
827 827
828 return err; 828 /* pci_xxx_config_word() return positive PCIBIOS_xxx error codes while
829 * the probe() function must return a negative errno in case of failure
830 * (err is unchanged if negative) */
831 return pcibios_err_to_errno(err);
829} 832}
830 833
831/* free the board structure object, as well as its resources: */ 834/* free the board structure object, as well as its resources: */
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index 131026fbc2d7..5adc95c922ee 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -717,7 +717,10 @@ failure_release_regions:
717failure_disable_pci: 717failure_disable_pci:
718 pci_disable_device(pdev); 718 pci_disable_device(pdev);
719 719
720 return err; 720 /* pci_xxx_config_word() return positive PCIBIOS_xxx error codes while
721 * the probe() function must return a negative errno in case of failure
722 * (err is unchanged if negative) */
723 return pcibios_err_to_errno(err);
721} 724}
722 725
723static void peak_pci_remove(struct pci_dev *pdev) 726static void peak_pci_remove(struct pci_dev *pdev)
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 4d4941469cfc..db6ea936dc3f 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -637,6 +637,9 @@ static int ti_hecc_rx_poll(struct napi_struct *napi, int quota)
637 mbx_mask = hecc_read(priv, HECC_CANMIM); 637 mbx_mask = hecc_read(priv, HECC_CANMIM);
638 mbx_mask |= HECC_TX_MBOX_MASK; 638 mbx_mask |= HECC_TX_MBOX_MASK;
639 hecc_write(priv, HECC_CANMIM, mbx_mask); 639 hecc_write(priv, HECC_CANMIM, mbx_mask);
640 } else {
641 /* repoll is done only if whole budget is used */
642 num_pkts = quota;
640 } 643 }
641 644
642 return num_pkts; 645 return num_pkts;
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 9b18d96ef526..f95945915d20 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -609,8 +609,8 @@ static int kvaser_usb_wait_msg(const struct kvaser_usb *dev, u8 id,
609 } 609 }
610 610
611 if (pos + tmp->len > actual_len) { 611 if (pos + tmp->len > actual_len) {
612 dev_err(dev->udev->dev.parent, 612 dev_err_ratelimited(dev->udev->dev.parent,
613 "Format error\n"); 613 "Format error\n");
614 break; 614 break;
615 } 615 }
616 616
@@ -813,6 +813,7 @@ static int kvaser_usb_simple_msg_async(struct kvaser_usb_net_priv *priv,
813 if (err) { 813 if (err) {
814 netdev_err(netdev, "Error transmitting URB\n"); 814 netdev_err(netdev, "Error transmitting URB\n");
815 usb_unanchor_urb(urb); 815 usb_unanchor_urb(urb);
816 kfree(buf);
816 usb_free_urb(urb); 817 usb_free_urb(urb);
817 return err; 818 return err;
818 } 819 }
@@ -1333,7 +1334,7 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
1333 goto resubmit_urb; 1334 goto resubmit_urb;
1334 } 1335 }
1335 1336
1336 while (pos <= urb->actual_length - MSG_HEADER_LEN) { 1337 while (pos <= (int)(urb->actual_length - MSG_HEADER_LEN)) {
1337 msg = urb->transfer_buffer + pos; 1338 msg = urb->transfer_buffer + pos;
1338 1339
1339 /* The Kvaser firmware can only read and write messages that 1340 /* The Kvaser firmware can only read and write messages that
@@ -1352,7 +1353,8 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
1352 } 1353 }
1353 1354
1354 if (pos + msg->len > urb->actual_length) { 1355 if (pos + msg->len > urb->actual_length) {
1355 dev_err(dev->udev->dev.parent, "Format error\n"); 1356 dev_err_ratelimited(dev->udev->dev.parent,
1357 "Format error\n");
1356 break; 1358 break;
1357 } 1359 }
1358 1360
@@ -1768,6 +1770,7 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
1768 spin_unlock_irqrestore(&priv->tx_contexts_lock, flags); 1770 spin_unlock_irqrestore(&priv->tx_contexts_lock, flags);
1769 1771
1770 usb_unanchor_urb(urb); 1772 usb_unanchor_urb(urb);
1773 kfree(buf);
1771 1774
1772 stats->tx_dropped++; 1775 stats->tx_dropped++;
1773 1776
diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c
index 7f0272558bef..ef417dcddbf7 100644
--- a/drivers/net/can/usb/mcba_usb.c
+++ b/drivers/net/can/usb/mcba_usb.c
@@ -592,6 +592,7 @@ static void mcba_usb_read_bulk_callback(struct urb *urb)
592 break; 592 break;
593 593
594 case -ENOENT: 594 case -ENOENT:
595 case -EPIPE:
595 case -ESHUTDOWN: 596 case -ESHUTDOWN:
596 return; 597 return;
597 598
@@ -862,7 +863,7 @@ static int mcba_usb_probe(struct usb_interface *intf,
862 goto cleanup_unregister_candev; 863 goto cleanup_unregister_candev;
863 } 864 }
864 865
865 dev_info(&intf->dev, "Microchip CAN BUS analizer connected\n"); 866 dev_info(&intf->dev, "Microchip CAN BUS Analyzer connected\n");
866 867
867 return 0; 868 return 0;
868 869
diff --git a/drivers/net/dsa/bcm_sf2_cfp.c b/drivers/net/dsa/bcm_sf2_cfp.c
index b721a2009b50..23b45da784cb 100644
--- a/drivers/net/dsa/bcm_sf2_cfp.c
+++ b/drivers/net/dsa/bcm_sf2_cfp.c
@@ -625,7 +625,7 @@ static int bcm_sf2_cfp_ipv6_rule_set(struct bcm_sf2_priv *priv, int port,
625 bcm_sf2_cfp_slice_ipv6(priv, v6_spec->ip6src, v6_spec->psrc, 625 bcm_sf2_cfp_slice_ipv6(priv, v6_spec->ip6src, v6_spec->psrc,
626 slice_num, false); 626 slice_num, false);
627 bcm_sf2_cfp_slice_ipv6(priv, v6_m_spec->ip6src, v6_m_spec->psrc, 627 bcm_sf2_cfp_slice_ipv6(priv, v6_m_spec->ip6src, v6_m_spec->psrc,
628 slice_num, true); 628 SLICE_NUM_MASK, true);
629 629
630 /* Insert into TCAM now because we need to insert a second rule */ 630 /* Insert into TCAM now because we need to insert a second rule */
631 bcm_sf2_cfp_rule_addr_set(priv, rule_index[0]); 631 bcm_sf2_cfp_rule_addr_set(priv, rule_index[0]);
@@ -699,7 +699,7 @@ static int bcm_sf2_cfp_ipv6_rule_set(struct bcm_sf2_priv *priv, int port,
699 /* Insert into Action and policer RAMs now, set chain ID to 699 /* Insert into Action and policer RAMs now, set chain ID to
700 * the one we are chained to 700 * the one we are chained to
701 */ 701 */
702 ret = bcm_sf2_cfp_act_pol_set(priv, rule_index[0], port_num, 702 ret = bcm_sf2_cfp_act_pol_set(priv, rule_index[1], port_num,
703 queue_num, true); 703 queue_num, true);
704 if (ret) 704 if (ret)
705 goto out_err; 705 goto out_err;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index c5c38d4b7d1c..28f5e94274ee 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3368,6 +3368,7 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
3368 u16 cp_ring_id, len = 0; 3368 u16 cp_ring_id, len = 0;
3369 struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr; 3369 struct hwrm_err_output *resp = bp->hwrm_cmd_resp_addr;
3370 u16 max_req_len = BNXT_HWRM_MAX_REQ_LEN; 3370 u16 max_req_len = BNXT_HWRM_MAX_REQ_LEN;
3371 struct hwrm_short_input short_input = {0};
3371 3372
3372 req->seq_id = cpu_to_le16(bp->hwrm_cmd_seq++); 3373 req->seq_id = cpu_to_le16(bp->hwrm_cmd_seq++);
3373 memset(resp, 0, PAGE_SIZE); 3374 memset(resp, 0, PAGE_SIZE);
@@ -3376,7 +3377,6 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
3376 3377
3377 if (bp->flags & BNXT_FLAG_SHORT_CMD) { 3378 if (bp->flags & BNXT_FLAG_SHORT_CMD) {
3378 void *short_cmd_req = bp->hwrm_short_cmd_req_addr; 3379 void *short_cmd_req = bp->hwrm_short_cmd_req_addr;
3379 struct hwrm_short_input short_input = {0};
3380 3380
3381 memcpy(short_cmd_req, req, msg_len); 3381 memcpy(short_cmd_req, req, msg_len);
3382 memset(short_cmd_req + msg_len, 0, BNXT_HWRM_MAX_REQ_LEN - 3382 memset(short_cmd_req + msg_len, 0, BNXT_HWRM_MAX_REQ_LEN -
@@ -8263,8 +8263,9 @@ static void bnxt_shutdown(struct pci_dev *pdev)
8263 if (netif_running(dev)) 8263 if (netif_running(dev))
8264 dev_close(dev); 8264 dev_close(dev);
8265 8265
8266 bnxt_ulp_shutdown(bp);
8267
8266 if (system_state == SYSTEM_POWER_OFF) { 8268 if (system_state == SYSTEM_POWER_OFF) {
8267 bnxt_ulp_shutdown(bp);
8268 bnxt_clear_int_mode(bp); 8269 bnxt_clear_int_mode(bp);
8269 pci_wake_from_d3(pdev, bp->wol); 8270 pci_wake_from_d3(pdev, bp->wol);
8270 pci_set_power_state(pdev, PCI_D3hot); 8271 pci_set_power_state(pdev, PCI_D3hot);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index d5031f436f83..3d201d7324bd 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -56,7 +56,6 @@ static int bnxt_tc_parse_redir(struct bnxt *bp,
56{ 56{
57 int ifindex = tcf_mirred_ifindex(tc_act); 57 int ifindex = tcf_mirred_ifindex(tc_act);
58 struct net_device *dev; 58 struct net_device *dev;
59 u16 dst_fid;
60 59
61 dev = __dev_get_by_index(dev_net(bp->dev), ifindex); 60 dev = __dev_get_by_index(dev_net(bp->dev), ifindex);
62 if (!dev) { 61 if (!dev) {
@@ -64,15 +63,7 @@ static int bnxt_tc_parse_redir(struct bnxt *bp,
64 return -EINVAL; 63 return -EINVAL;
65 } 64 }
66 65
67 /* find the FID from dev */
68 dst_fid = bnxt_flow_get_dst_fid(bp, dev);
69 if (dst_fid == BNXT_FID_INVALID) {
70 netdev_info(bp->dev, "can't get fid for ifindex=%d", ifindex);
71 return -EINVAL;
72 }
73
74 actions->flags |= BNXT_TC_ACTION_FLAG_FWD; 66 actions->flags |= BNXT_TC_ACTION_FLAG_FWD;
75 actions->dst_fid = dst_fid;
76 actions->dst_dev = dev; 67 actions->dst_dev = dev;
77 return 0; 68 return 0;
78} 69}
@@ -160,13 +151,17 @@ static int bnxt_tc_parse_actions(struct bnxt *bp,
160 if (rc) 151 if (rc)
161 return rc; 152 return rc;
162 153
163 /* Tunnel encap/decap action must be accompanied by a redirect action */ 154 if (actions->flags & BNXT_TC_ACTION_FLAG_FWD) {
164 if ((actions->flags & BNXT_TC_ACTION_FLAG_TUNNEL_ENCAP || 155 if (actions->flags & BNXT_TC_ACTION_FLAG_TUNNEL_ENCAP) {
165 actions->flags & BNXT_TC_ACTION_FLAG_TUNNEL_DECAP) && 156 /* dst_fid is PF's fid */
166 !(actions->flags & BNXT_TC_ACTION_FLAG_FWD)) { 157 actions->dst_fid = bp->pf.fw_fid;
167 netdev_info(bp->dev, 158 } else {
168 "error: no redir action along with encap/decap"); 159 /* find the FID from dst_dev */
169 return -EINVAL; 160 actions->dst_fid =
161 bnxt_flow_get_dst_fid(bp, actions->dst_dev);
162 if (actions->dst_fid == BNXT_FID_INVALID)
163 return -EINVAL;
164 }
170 } 165 }
171 166
172 return rc; 167 return rc;
@@ -532,10 +527,8 @@ static int hwrm_cfa_decap_filter_alloc(struct bnxt *bp,
532 } 527 }
533 528
534 if (flow->flags & BNXT_TC_FLOW_FLAGS_TUNL_ETH_ADDRS) { 529 if (flow->flags & BNXT_TC_FLOW_FLAGS_TUNL_ETH_ADDRS) {
535 enables |= CFA_DECAP_FILTER_ALLOC_REQ_ENABLES_DST_MACADDR | 530 enables |= CFA_DECAP_FILTER_ALLOC_REQ_ENABLES_DST_MACADDR;
536 CFA_DECAP_FILTER_ALLOC_REQ_ENABLES_SRC_MACADDR;
537 ether_addr_copy(req.dst_macaddr, l2_info->dmac); 531 ether_addr_copy(req.dst_macaddr, l2_info->dmac);
538 ether_addr_copy(req.src_macaddr, l2_info->smac);
539 } 532 }
540 if (l2_info->num_vlans) { 533 if (l2_info->num_vlans) {
541 enables |= CFA_DECAP_FILTER_ALLOC_REQ_ENABLES_T_IVLAN_VID; 534 enables |= CFA_DECAP_FILTER_ALLOC_REQ_ENABLES_T_IVLAN_VID;
@@ -901,10 +894,10 @@ static void bnxt_tc_put_decap_handle(struct bnxt *bp,
901 894
902static int bnxt_tc_resolve_tunnel_hdrs(struct bnxt *bp, 895static int bnxt_tc_resolve_tunnel_hdrs(struct bnxt *bp,
903 struct ip_tunnel_key *tun_key, 896 struct ip_tunnel_key *tun_key,
904 struct bnxt_tc_l2_key *l2_info, 897 struct bnxt_tc_l2_key *l2_info)
905 struct net_device *real_dst_dev)
906{ 898{
907#ifdef CONFIG_INET 899#ifdef CONFIG_INET
900 struct net_device *real_dst_dev = bp->dev;
908 struct flowi4 flow = { {0} }; 901 struct flowi4 flow = { {0} };
909 struct net_device *dst_dev; 902 struct net_device *dst_dev;
910 struct neighbour *nbr; 903 struct neighbour *nbr;
@@ -1008,14 +1001,13 @@ static int bnxt_tc_get_decap_handle(struct bnxt *bp, struct bnxt_tc_flow *flow,
1008 */ 1001 */
1009 tun_key.u.ipv4.dst = flow->tun_key.u.ipv4.src; 1002 tun_key.u.ipv4.dst = flow->tun_key.u.ipv4.src;
1010 tun_key.tp_dst = flow->tun_key.tp_dst; 1003 tun_key.tp_dst = flow->tun_key.tp_dst;
1011 rc = bnxt_tc_resolve_tunnel_hdrs(bp, &tun_key, &l2_info, bp->dev); 1004 rc = bnxt_tc_resolve_tunnel_hdrs(bp, &tun_key, &l2_info);
1012 if (rc) 1005 if (rc)
1013 goto put_decap; 1006 goto put_decap;
1014 1007
1015 decap_key->ttl = tun_key.ttl;
1016 decap_l2_info = &decap_node->l2_info; 1008 decap_l2_info = &decap_node->l2_info;
1009 /* decap smac is wildcarded */
1017 ether_addr_copy(decap_l2_info->dmac, l2_info.smac); 1010 ether_addr_copy(decap_l2_info->dmac, l2_info.smac);
1018 ether_addr_copy(decap_l2_info->smac, l2_info.dmac);
1019 if (l2_info.num_vlans) { 1011 if (l2_info.num_vlans) {
1020 decap_l2_info->num_vlans = l2_info.num_vlans; 1012 decap_l2_info->num_vlans = l2_info.num_vlans;
1021 decap_l2_info->inner_vlan_tpid = l2_info.inner_vlan_tpid; 1013 decap_l2_info->inner_vlan_tpid = l2_info.inner_vlan_tpid;
@@ -1095,8 +1087,7 @@ static int bnxt_tc_get_encap_handle(struct bnxt *bp, struct bnxt_tc_flow *flow,
1095 if (encap_node->tunnel_handle != INVALID_TUNNEL_HANDLE) 1087 if (encap_node->tunnel_handle != INVALID_TUNNEL_HANDLE)
1096 goto done; 1088 goto done;
1097 1089
1098 rc = bnxt_tc_resolve_tunnel_hdrs(bp, encap_key, &encap_node->l2_info, 1090 rc = bnxt_tc_resolve_tunnel_hdrs(bp, encap_key, &encap_node->l2_info);
1099 flow->actions.dst_dev);
1100 if (rc) 1091 if (rc)
1101 goto put_encap; 1092 goto put_encap;
1102 1093
@@ -1169,6 +1160,15 @@ static int __bnxt_tc_del_flow(struct bnxt *bp,
1169 return 0; 1160 return 0;
1170} 1161}
1171 1162
1163static void bnxt_tc_set_src_fid(struct bnxt *bp, struct bnxt_tc_flow *flow,
1164 u16 src_fid)
1165{
1166 if (flow->actions.flags & BNXT_TC_ACTION_FLAG_TUNNEL_DECAP)
1167 flow->src_fid = bp->pf.fw_fid;
1168 else
1169 flow->src_fid = src_fid;
1170}
1171
1172/* Add a new flow or replace an existing flow. 1172/* Add a new flow or replace an existing flow.
1173 * Notes on locking: 1173 * Notes on locking:
1174 * There are essentially two critical sections here. 1174 * There are essentially two critical sections here.
@@ -1204,7 +1204,8 @@ static int bnxt_tc_add_flow(struct bnxt *bp, u16 src_fid,
1204 rc = bnxt_tc_parse_flow(bp, tc_flow_cmd, flow); 1204 rc = bnxt_tc_parse_flow(bp, tc_flow_cmd, flow);
1205 if (rc) 1205 if (rc)
1206 goto free_node; 1206 goto free_node;
1207 flow->src_fid = src_fid; 1207
1208 bnxt_tc_set_src_fid(bp, flow, src_fid);
1208 1209
1209 if (!bnxt_tc_can_offload(bp, flow)) { 1210 if (!bnxt_tc_can_offload(bp, flow)) {
1210 rc = -ENOSPC; 1211 rc = -ENOSPC;
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 6aa0eee88ea5..a5eecd895a82 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -1113,7 +1113,7 @@ static int liquidio_watchdog(void *param)
1113 dev_err(&oct->pci_dev->dev, 1113 dev_err(&oct->pci_dev->dev,
1114 "ERROR: Octeon core %d crashed or got stuck! See oct-fwdump for details.\n", 1114 "ERROR: Octeon core %d crashed or got stuck! See oct-fwdump for details.\n",
1115 core); 1115 core);
1116 err_msg_was_printed[core] = true; 1116 err_msg_was_printed[core] = true;
1117 } 1117 }
1118 } 1118 }
1119 1119
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index d83a78be98a2..fed2b2f909fc 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -5598,7 +5598,7 @@ static int mvpp2_aggr_txq_init(struct platform_device *pdev,
5598 u32 txq_dma; 5598 u32 txq_dma;
5599 5599
5600 /* Allocate memory for TX descriptors */ 5600 /* Allocate memory for TX descriptors */
5601 aggr_txq->descs = dma_alloc_coherent(&pdev->dev, 5601 aggr_txq->descs = dma_zalloc_coherent(&pdev->dev,
5602 MVPP2_AGGR_TXQ_SIZE * MVPP2_DESC_ALIGNED_SIZE, 5602 MVPP2_AGGR_TXQ_SIZE * MVPP2_DESC_ALIGNED_SIZE,
5603 &aggr_txq->descs_dma, GFP_KERNEL); 5603 &aggr_txq->descs_dma, GFP_KERNEL);
5604 if (!aggr_txq->descs) 5604 if (!aggr_txq->descs)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index e5ff734d4f9b..9eb7f65d8000 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -808,8 +808,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
808 val, reg); 808 val, reg);
809 809
810 if (gmac->variant->soc_has_internal_phy) { 810 if (gmac->variant->soc_has_internal_phy) {
811 if (of_property_read_bool(priv->plat->phy_node, 811 if (of_property_read_bool(node, "allwinner,leds-active-low"))
812 "allwinner,leds-active-low"))
813 reg |= H3_EPHY_LED_POL; 812 reg |= H3_EPHY_LED_POL;
814 else 813 else
815 reg &= ~H3_EPHY_LED_POL; 814 reg &= ~H3_EPHY_LED_POL;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f63c2ddced3c..d7250539d0bd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2588,6 +2588,7 @@ static int stmmac_open(struct net_device *dev)
2588 2588
2589 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); 2589 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
2590 priv->rx_copybreak = STMMAC_RX_COPYBREAK; 2590 priv->rx_copybreak = STMMAC_RX_COPYBREAK;
2591 priv->mss = 0;
2591 2592
2592 ret = alloc_dma_desc_resources(priv); 2593 ret = alloc_dma_desc_resources(priv);
2593 if (ret < 0) { 2594 if (ret < 0) {
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 11c1e7950fe5..77cc4fbaeace 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -393,6 +393,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb)
393 .flowi4_oif = dev->ifindex, 393 .flowi4_oif = dev->ifindex,
394 .flowi4_tos = RT_TOS(ip4h->tos), 394 .flowi4_tos = RT_TOS(ip4h->tos),
395 .flowi4_flags = FLOWI_FLAG_ANYSRC, 395 .flowi4_flags = FLOWI_FLAG_ANYSRC,
396 .flowi4_mark = skb->mark,
396 .daddr = ip4h->daddr, 397 .daddr = ip4h->daddr,
397 .saddr = ip4h->saddr, 398 .saddr = ip4h->saddr,
398 }; 399 };
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index fdb43dd9b5cd..ab4614113403 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -496,16 +496,18 @@ static int ksz9031_of_load_skew_values(struct phy_device *phydev,
496 return ksz9031_extended_write(phydev, OP_DATA, 2, reg, newval); 496 return ksz9031_extended_write(phydev, OP_DATA, 2, reg, newval);
497} 497}
498 498
499/* Center KSZ9031RNX FLP timing at 16ms. */
499static int ksz9031_center_flp_timing(struct phy_device *phydev) 500static int ksz9031_center_flp_timing(struct phy_device *phydev)
500{ 501{
501 int result; 502 int result;
502 503
503 /* Center KSZ9031RNX FLP timing at 16ms. */
504 result = ksz9031_extended_write(phydev, OP_DATA, 0, 504 result = ksz9031_extended_write(phydev, OP_DATA, 0,
505 MII_KSZ9031RN_FLP_BURST_TX_HI, 0x0006); 505 MII_KSZ9031RN_FLP_BURST_TX_HI, 0x0006);
506 if (result)
507 return result;
508
506 result = ksz9031_extended_write(phydev, OP_DATA, 0, 509 result = ksz9031_extended_write(phydev, OP_DATA, 0,
507 MII_KSZ9031RN_FLP_BURST_TX_LO, 0x1A80); 510 MII_KSZ9031RN_FLP_BURST_TX_LO, 0x1A80);
508
509 if (result) 511 if (result)
510 return result; 512 return result;
511 513
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e3bbc70372d3..5dc9668dde34 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -773,6 +773,7 @@ void phylink_stop(struct phylink *pl)
773 sfp_upstream_stop(pl->sfp_bus); 773 sfp_upstream_stop(pl->sfp_bus);
774 774
775 set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); 775 set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
776 queue_work(system_power_efficient_wq, &pl->resolve);
776 flush_work(&pl->resolve); 777 flush_work(&pl->resolve);
777} 778}
778EXPORT_SYMBOL_GPL(phylink_stop); 779EXPORT_SYMBOL_GPL(phylink_stop);
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index e381811e5f11..9dfc1c4c954f 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -351,12 +351,13 @@ static void sfp_sm_link_check_los(struct sfp *sfp)
351{ 351{
352 unsigned int los = sfp->state & SFP_F_LOS; 352 unsigned int los = sfp->state & SFP_F_LOS;
353 353
354 /* FIXME: what if neither SFP_OPTIONS_LOS_INVERTED nor 354 /* If neither SFP_OPTIONS_LOS_INVERTED nor SFP_OPTIONS_LOS_NORMAL
355 * SFP_OPTIONS_LOS_NORMAL are set? For now, we assume 355 * are set, we assume that no LOS signal is available.
356 * the same as SFP_OPTIONS_LOS_NORMAL set.
357 */ 356 */
358 if (sfp->id.ext.options & SFP_OPTIONS_LOS_INVERTED) 357 if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED))
359 los ^= SFP_F_LOS; 358 los ^= SFP_F_LOS;
359 else if (!(sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_NORMAL)))
360 los = 0;
360 361
361 if (los) 362 if (los)
362 sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0); 363 sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0);
@@ -364,6 +365,22 @@ static void sfp_sm_link_check_los(struct sfp *sfp)
364 sfp_sm_link_up(sfp); 365 sfp_sm_link_up(sfp);
365} 366}
366 367
368static bool sfp_los_event_active(struct sfp *sfp, unsigned int event)
369{
370 return (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) &&
371 event == SFP_E_LOS_LOW) ||
372 (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_NORMAL) &&
373 event == SFP_E_LOS_HIGH);
374}
375
376static bool sfp_los_event_inactive(struct sfp *sfp, unsigned int event)
377{
378 return (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) &&
379 event == SFP_E_LOS_HIGH) ||
380 (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_NORMAL) &&
381 event == SFP_E_LOS_LOW);
382}
383
367static void sfp_sm_fault(struct sfp *sfp, bool warn) 384static void sfp_sm_fault(struct sfp *sfp, bool warn)
368{ 385{
369 if (sfp->sm_retries && !--sfp->sm_retries) { 386 if (sfp->sm_retries && !--sfp->sm_retries) {
@@ -470,6 +487,11 @@ static int sfp_sm_mod_probe(struct sfp *sfp)
470 return -EINVAL; 487 return -EINVAL;
471 } 488 }
472 489
490 /* If the module requires address swap mode, warn about it */
491 if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)
492 dev_warn(sfp->dev,
493 "module address swap to access page 0xA2 is not supported.\n");
494
473 return sfp_module_insert(sfp->sfp_bus, &sfp->id); 495 return sfp_module_insert(sfp->sfp_bus, &sfp->id);
474} 496}
475 497
@@ -581,9 +603,7 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
581 case SFP_S_WAIT_LOS: 603 case SFP_S_WAIT_LOS:
582 if (event == SFP_E_TX_FAULT) 604 if (event == SFP_E_TX_FAULT)
583 sfp_sm_fault(sfp, true); 605 sfp_sm_fault(sfp, true);
584 else if (event == 606 else if (sfp_los_event_inactive(sfp, event))
585 (sfp->id.ext.options & SFP_OPTIONS_LOS_INVERTED ?
586 SFP_E_LOS_HIGH : SFP_E_LOS_LOW))
587 sfp_sm_link_up(sfp); 607 sfp_sm_link_up(sfp);
588 break; 608 break;
589 609
@@ -591,9 +611,7 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
591 if (event == SFP_E_TX_FAULT) { 611 if (event == SFP_E_TX_FAULT) {
592 sfp_sm_link_down(sfp); 612 sfp_sm_link_down(sfp);
593 sfp_sm_fault(sfp, true); 613 sfp_sm_fault(sfp, true);
594 } else if (event == 614 } else if (sfp_los_event_active(sfp, event)) {
595 (sfp->id.ext.options & SFP_OPTIONS_LOS_INVERTED ?
596 SFP_E_LOS_LOW : SFP_E_LOS_HIGH)) {
597 sfp_sm_link_down(sfp); 615 sfp_sm_link_down(sfp);
598 sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0); 616 sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0);
599 } 617 }
@@ -639,7 +657,8 @@ static int sfp_module_info(struct sfp *sfp, struct ethtool_modinfo *modinfo)
639{ 657{
640 /* locking... and check module is present */ 658 /* locking... and check module is present */
641 659
642 if (sfp->id.ext.sff8472_compliance) { 660 if (sfp->id.ext.sff8472_compliance &&
661 !(sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)) {
643 modinfo->type = ETH_MODULE_SFF_8472; 662 modinfo->type = ETH_MODULE_SFF_8472;
644 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; 663 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
645 } else { 664 } else {
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index e9489b88407c..0a886fda0129 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -829,8 +829,11 @@ static ssize_t tap_do_read(struct tap_queue *q,
829 DEFINE_WAIT(wait); 829 DEFINE_WAIT(wait);
830 ssize_t ret = 0; 830 ssize_t ret = 0;
831 831
832 if (!iov_iter_count(to)) 832 if (!iov_iter_count(to)) {
833 if (skb)
834 kfree_skb(skb);
833 return 0; 835 return 0;
836 }
834 837
835 if (skb) 838 if (skb)
836 goto put; 839 goto put;
@@ -1154,11 +1157,14 @@ static int tap_recvmsg(struct socket *sock, struct msghdr *m,
1154 size_t total_len, int flags) 1157 size_t total_len, int flags)
1155{ 1158{
1156 struct tap_queue *q = container_of(sock, struct tap_queue, sock); 1159 struct tap_queue *q = container_of(sock, struct tap_queue, sock);
1160 struct sk_buff *skb = m->msg_control;
1157 int ret; 1161 int ret;
1158 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) 1162 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
1163 if (skb)
1164 kfree_skb(skb);
1159 return -EINVAL; 1165 return -EINVAL;
1160 ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT, 1166 }
1161 m->msg_control); 1167 ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT, skb);
1162 if (ret > total_len) { 1168 if (ret > total_len) {
1163 m->msg_flags |= MSG_TRUNC; 1169 m->msg_flags |= MSG_TRUNC;
1164 ret = flags & MSG_TRUNC ? ret : total_len; 1170 ret = flags & MSG_TRUNC ? ret : total_len;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 95749006d687..4f4a842a1c9c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1952,8 +1952,11 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
1952 1952
1953 tun_debug(KERN_INFO, tun, "tun_do_read\n"); 1953 tun_debug(KERN_INFO, tun, "tun_do_read\n");
1954 1954
1955 if (!iov_iter_count(to)) 1955 if (!iov_iter_count(to)) {
1956 if (skb)
1957 kfree_skb(skb);
1956 return 0; 1958 return 0;
1959 }
1957 1960
1958 if (!skb) { 1961 if (!skb) {
1959 /* Read frames from ring */ 1962 /* Read frames from ring */
@@ -2069,22 +2072,24 @@ static int tun_recvmsg(struct socket *sock, struct msghdr *m, size_t total_len,
2069{ 2072{
2070 struct tun_file *tfile = container_of(sock, struct tun_file, socket); 2073 struct tun_file *tfile = container_of(sock, struct tun_file, socket);
2071 struct tun_struct *tun = tun_get(tfile); 2074 struct tun_struct *tun = tun_get(tfile);
2075 struct sk_buff *skb = m->msg_control;
2072 int ret; 2076 int ret;
2073 2077
2074 if (!tun) 2078 if (!tun) {
2075 return -EBADFD; 2079 ret = -EBADFD;
2080 goto out_free_skb;
2081 }
2076 2082
2077 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC|MSG_ERRQUEUE)) { 2083 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC|MSG_ERRQUEUE)) {
2078 ret = -EINVAL; 2084 ret = -EINVAL;
2079 goto out; 2085 goto out_put_tun;
2080 } 2086 }
2081 if (flags & MSG_ERRQUEUE) { 2087 if (flags & MSG_ERRQUEUE) {
2082 ret = sock_recv_errqueue(sock->sk, m, total_len, 2088 ret = sock_recv_errqueue(sock->sk, m, total_len,
2083 SOL_PACKET, TUN_TX_TIMESTAMP); 2089 SOL_PACKET, TUN_TX_TIMESTAMP);
2084 goto out; 2090 goto out;
2085 } 2091 }
2086 ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT, 2092 ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT, skb);
2087 m->msg_control);
2088 if (ret > (ssize_t)total_len) { 2093 if (ret > (ssize_t)total_len) {
2089 m->msg_flags |= MSG_TRUNC; 2094 m->msg_flags |= MSG_TRUNC;
2090 ret = flags & MSG_TRUNC ? ret : total_len; 2095 ret = flags & MSG_TRUNC ? ret : total_len;
@@ -2092,6 +2097,13 @@ static int tun_recvmsg(struct socket *sock, struct msghdr *m, size_t total_len,
2092out: 2097out:
2093 tun_put(tun); 2098 tun_put(tun);
2094 return ret; 2099 return ret;
2100
2101out_put_tun:
2102 tun_put(tun);
2103out_free_skb:
2104 if (skb)
2105 kfree_skb(skb);
2106 return ret;
2095} 2107}
2096 2108
2097static int tun_peek_len(struct socket *sock) 2109static int tun_peek_len(struct socket *sock)
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index 9cd569ef43ec..15015a24f8ad 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -987,6 +987,9 @@ struct qeth_cmd_buffer *qeth_get_setassparms_cmd(struct qeth_card *,
987int qeth_set_features(struct net_device *, netdev_features_t); 987int qeth_set_features(struct net_device *, netdev_features_t);
988void qeth_recover_features(struct net_device *dev); 988void qeth_recover_features(struct net_device *dev);
989netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t); 989netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t);
990netdev_features_t qeth_features_check(struct sk_buff *skb,
991 struct net_device *dev,
992 netdev_features_t features);
990int qeth_vm_request_mac(struct qeth_card *card); 993int qeth_vm_request_mac(struct qeth_card *card);
991int qeth_push_hdr(struct sk_buff *skb, struct qeth_hdr **hdr, unsigned int len); 994int qeth_push_hdr(struct sk_buff *skb, struct qeth_hdr **hdr, unsigned int len);
992 995
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 98a7f84540ab..430e3214f7e2 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -20,6 +20,11 @@
20#include <linux/mii.h> 20#include <linux/mii.h>
21#include <linux/kthread.h> 21#include <linux/kthread.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/if_vlan.h>
24#include <linux/netdevice.h>
25#include <linux/netdev_features.h>
26#include <linux/skbuff.h>
27
23#include <net/iucv/af_iucv.h> 28#include <net/iucv/af_iucv.h>
24#include <net/dsfield.h> 29#include <net/dsfield.h>
25 30
@@ -6439,6 +6444,32 @@ netdev_features_t qeth_fix_features(struct net_device *dev,
6439} 6444}
6440EXPORT_SYMBOL_GPL(qeth_fix_features); 6445EXPORT_SYMBOL_GPL(qeth_fix_features);
6441 6446
6447netdev_features_t qeth_features_check(struct sk_buff *skb,
6448 struct net_device *dev,
6449 netdev_features_t features)
6450{
6451 /* GSO segmentation builds skbs with
6452 * a (small) linear part for the headers, and
6453 * page frags for the data.
6454 * Compared to a linear skb, the header-only part consumes an
6455 * additional buffer element. This reduces buffer utilization, and
6456 * hurts throughput. So compress small segments into one element.
6457 */
6458 if (netif_needs_gso(skb, features)) {
6459 /* match skb_segment(): */
6460 unsigned int doffset = skb->data - skb_mac_header(skb);
6461 unsigned int hsize = skb_shinfo(skb)->gso_size;
6462 unsigned int hroom = skb_headroom(skb);
6463
6464 /* linearize only if resulting skb allocations are order-0: */
6465 if (SKB_DATA_ALIGN(hroom + doffset + hsize) <= SKB_MAX_HEAD(0))
6466 features &= ~NETIF_F_SG;
6467 }
6468
6469 return vlan_features_check(skb, features);
6470}
6471EXPORT_SYMBOL_GPL(qeth_features_check);
6472
6442static int __init qeth_core_init(void) 6473static int __init qeth_core_init(void)
6443{ 6474{
6444 int rc; 6475 int rc;
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 93d7e345d180..5863ea170ff2 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -961,6 +961,7 @@ static const struct net_device_ops qeth_l2_netdev_ops = {
961 .ndo_stop = qeth_l2_stop, 961 .ndo_stop = qeth_l2_stop,
962 .ndo_get_stats = qeth_get_stats, 962 .ndo_get_stats = qeth_get_stats,
963 .ndo_start_xmit = qeth_l2_hard_start_xmit, 963 .ndo_start_xmit = qeth_l2_hard_start_xmit,
964 .ndo_features_check = qeth_features_check,
964 .ndo_validate_addr = eth_validate_addr, 965 .ndo_validate_addr = eth_validate_addr,
965 .ndo_set_rx_mode = qeth_l2_set_rx_mode, 966 .ndo_set_rx_mode = qeth_l2_set_rx_mode,
966 .ndo_do_ioctl = qeth_do_ioctl, 967 .ndo_do_ioctl = qeth_do_ioctl,
@@ -1011,6 +1012,7 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
1011 if (card->info.type == QETH_CARD_TYPE_OSD && !card->info.guestlan) { 1012 if (card->info.type == QETH_CARD_TYPE_OSD && !card->info.guestlan) {
1012 card->dev->hw_features = NETIF_F_SG; 1013 card->dev->hw_features = NETIF_F_SG;
1013 card->dev->vlan_features = NETIF_F_SG; 1014 card->dev->vlan_features = NETIF_F_SG;
1015 card->dev->features |= NETIF_F_SG;
1014 /* OSA 3S and earlier has no RX/TX support */ 1016 /* OSA 3S and earlier has no RX/TX support */
1015 if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) { 1017 if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) {
1016 card->dev->hw_features |= NETIF_F_IP_CSUM; 1018 card->dev->hw_features |= NETIF_F_IP_CSUM;
@@ -1029,8 +1031,6 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
1029 1031
1030 card->info.broadcast_capable = 1; 1032 card->info.broadcast_capable = 1;
1031 qeth_l2_request_initial_mac(card); 1033 qeth_l2_request_initial_mac(card);
1032 card->dev->gso_max_size = (QETH_MAX_BUFFER_ELEMENTS(card) - 1) *
1033 PAGE_SIZE;
1034 SET_NETDEV_DEV(card->dev, &card->gdev->dev); 1034 SET_NETDEV_DEV(card->dev, &card->gdev->dev);
1035 netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); 1035 netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT);
1036 netif_carrier_off(card->dev); 1036 netif_carrier_off(card->dev);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 0f8c12738b06..6a73894b0cb5 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1377,6 +1377,7 @@ qeth_l3_add_mc_to_hash(struct qeth_card *card, struct in_device *in4_dev)
1377 1377
1378 tmp->u.a4.addr = be32_to_cpu(im4->multiaddr); 1378 tmp->u.a4.addr = be32_to_cpu(im4->multiaddr);
1379 memcpy(tmp->mac, buf, sizeof(tmp->mac)); 1379 memcpy(tmp->mac, buf, sizeof(tmp->mac));
1380 tmp->is_multicast = 1;
1380 1381
1381 ipm = qeth_l3_ip_from_hash(card, tmp); 1382 ipm = qeth_l3_ip_from_hash(card, tmp);
1382 if (ipm) { 1383 if (ipm) {
@@ -2918,6 +2919,7 @@ static const struct net_device_ops qeth_l3_osa_netdev_ops = {
2918 .ndo_stop = qeth_l3_stop, 2919 .ndo_stop = qeth_l3_stop,
2919 .ndo_get_stats = qeth_get_stats, 2920 .ndo_get_stats = qeth_get_stats,
2920 .ndo_start_xmit = qeth_l3_hard_start_xmit, 2921 .ndo_start_xmit = qeth_l3_hard_start_xmit,
2922 .ndo_features_check = qeth_features_check,
2921 .ndo_validate_addr = eth_validate_addr, 2923 .ndo_validate_addr = eth_validate_addr,
2922 .ndo_set_rx_mode = qeth_l3_set_multicast_list, 2924 .ndo_set_rx_mode = qeth_l3_set_multicast_list,
2923 .ndo_do_ioctl = qeth_do_ioctl, 2925 .ndo_do_ioctl = qeth_do_ioctl,
@@ -2958,6 +2960,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2958 card->dev->vlan_features = NETIF_F_SG | 2960 card->dev->vlan_features = NETIF_F_SG |
2959 NETIF_F_RXCSUM | NETIF_F_IP_CSUM | 2961 NETIF_F_RXCSUM | NETIF_F_IP_CSUM |
2960 NETIF_F_TSO; 2962 NETIF_F_TSO;
2963 card->dev->features |= NETIF_F_SG;
2961 } 2964 }
2962 } 2965 }
2963 } else if (card->info.type == QETH_CARD_TYPE_IQD) { 2966 } else if (card->info.type == QETH_CARD_TYPE_IQD) {
@@ -2985,8 +2988,8 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2985 NETIF_F_HW_VLAN_CTAG_RX | 2988 NETIF_F_HW_VLAN_CTAG_RX |
2986 NETIF_F_HW_VLAN_CTAG_FILTER; 2989 NETIF_F_HW_VLAN_CTAG_FILTER;
2987 netif_keep_dst(card->dev); 2990 netif_keep_dst(card->dev);
2988 card->dev->gso_max_size = (QETH_MAX_BUFFER_ELEMENTS(card) - 1) * 2991 netif_set_gso_max_size(card->dev, (QETH_MAX_BUFFER_ELEMENTS(card) - 1) *
2989 PAGE_SIZE; 2992 PAGE_SIZE);
2990 2993
2991 SET_NETDEV_DEV(card->dev, &card->gdev->dev); 2994 SET_NETDEV_DEV(card->dev, &card->gdev->dev);
2992 netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); 2995 netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT);
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 8d626d7c2e7e..c7bdeb655646 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -778,16 +778,6 @@ static void handle_rx(struct vhost_net *net)
778 /* On error, stop handling until the next kick. */ 778 /* On error, stop handling until the next kick. */
779 if (unlikely(headcount < 0)) 779 if (unlikely(headcount < 0))
780 goto out; 780 goto out;
781 if (nvq->rx_array)
782 msg.msg_control = vhost_net_buf_consume(&nvq->rxq);
783 /* On overrun, truncate and discard */
784 if (unlikely(headcount > UIO_MAXIOV)) {
785 iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1);
786 err = sock->ops->recvmsg(sock, &msg,
787 1, MSG_DONTWAIT | MSG_TRUNC);
788 pr_debug("Discarded rx packet: len %zd\n", sock_len);
789 continue;
790 }
791 /* OK, now we need to know about added descriptors. */ 781 /* OK, now we need to know about added descriptors. */
792 if (!headcount) { 782 if (!headcount) {
793 if (unlikely(vhost_enable_notify(&net->dev, vq))) { 783 if (unlikely(vhost_enable_notify(&net->dev, vq))) {
@@ -800,6 +790,16 @@ static void handle_rx(struct vhost_net *net)
800 * they refilled. */ 790 * they refilled. */
801 goto out; 791 goto out;
802 } 792 }
793 if (nvq->rx_array)
794 msg.msg_control = vhost_net_buf_consume(&nvq->rxq);
795 /* On overrun, truncate and discard */
796 if (unlikely(headcount > UIO_MAXIOV)) {
797 iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1);
798 err = sock->ops->recvmsg(sock, &msg,
799 1, MSG_DONTWAIT | MSG_TRUNC);
800 pr_debug("Discarded rx packet: len %zd\n", sock_len);
801 continue;
802 }
803 /* We don't need to be notified again. */ 803 /* We don't need to be notified again. */
804 iov_iter_init(&msg.msg_iter, READ, vq->iov, in, vhost_len); 804 iov_iter_init(&msg.msg_iter, READ, vq->iov, in, vhost_len);
805 fixup = msg.msg_iter; 805 fixup = msg.msg_iter;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index bc486ef23f20..a38c80e9f91e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1406,8 +1406,7 @@ static inline struct sk_buff *skb_get(struct sk_buff *skb)
1406} 1406}
1407 1407
1408/* 1408/*
1409 * If users == 1, we are the only owner and are can avoid redundant 1409 * If users == 1, we are the only owner and can avoid redundant atomic changes.
1410 * atomic change.
1411 */ 1410 */
1412 1411
1413/** 1412/**
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 16f949eef52f..2f8f93da5dc2 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -503,7 +503,8 @@ struct sctp_datamsg {
503 /* Did the messenge fail to send? */ 503 /* Did the messenge fail to send? */
504 int send_error; 504 int send_error;
505 u8 send_failed:1, 505 u8 send_failed:1,
506 can_delay; /* should this message be Nagle delayed */ 506 can_delay:1, /* should this message be Nagle delayed */
507 abandoned:1; /* should this message be abandoned */
507}; 508};
508 509
509struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *, 510struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *,
diff --git a/include/net/tc_act/tc_sample.h b/include/net/tc_act/tc_sample.h
index 524cee4f4c81..01dbfea32672 100644
--- a/include/net/tc_act/tc_sample.h
+++ b/include/net/tc_act/tc_sample.h
@@ -14,7 +14,6 @@ struct tcf_sample {
14 struct psample_group __rcu *psample_group; 14 struct psample_group __rcu *psample_group;
15 u32 psample_group_num; 15 u32 psample_group_num;
16 struct list_head tcfm_list; 16 struct list_head tcfm_list;
17 struct rcu_head rcu;
18}; 17};
19#define to_sample(a) ((struct tcf_sample *)a) 18#define to_sample(a) ((struct tcf_sample *)a)
20 19
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 4e09398009c1..6998707e81f3 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -844,12 +844,11 @@ static inline int tcp_v6_sdif(const struct sk_buff *skb)
844} 844}
845#endif 845#endif
846 846
847/* TCP_SKB_CB reference means this can not be used from early demux */
848static inline bool inet_exact_dif_match(struct net *net, struct sk_buff *skb) 847static inline bool inet_exact_dif_match(struct net *net, struct sk_buff *skb)
849{ 848{
850#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) 849#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
851 if (!net->ipv4.sysctl_tcp_l3mdev_accept && 850 if (!net->ipv4.sysctl_tcp_l3mdev_accept &&
852 skb && ipv4_l3mdev_skb(TCP_SKB_CB(skb)->header.h4.flags)) 851 skb && ipv4_l3mdev_skb(IPCB(skb)->flags))
853 return true; 852 return true;
854#endif 853#endif
855 return false; 854 return false;
diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h
index 4cd0f05d0113..8989a92c571a 100644
--- a/include/trace/events/xdp.h
+++ b/include/trace/events/xdp.h
@@ -8,6 +8,7 @@
8#include <linux/netdevice.h> 8#include <linux/netdevice.h>
9#include <linux/filter.h> 9#include <linux/filter.h>
10#include <linux/tracepoint.h> 10#include <linux/tracepoint.h>
11#include <linux/bpf.h>
11 12
12#define __XDP_ACT_MAP(FN) \ 13#define __XDP_ACT_MAP(FN) \
13 FN(ABORTED) \ 14 FN(ABORTED) \
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index b9f8686a84cf..86b50aa26ee8 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1447,7 +1447,8 @@ int bpf_prog_array_length(struct bpf_prog_array __rcu *progs)
1447 rcu_read_lock(); 1447 rcu_read_lock();
1448 prog = rcu_dereference(progs)->progs; 1448 prog = rcu_dereference(progs)->progs;
1449 for (; *prog; prog++) 1449 for (; *prog; prog++)
1450 cnt++; 1450 if (*prog != &dummy_bpf_prog.prog)
1451 cnt++;
1451 rcu_read_unlock(); 1452 rcu_read_unlock();
1452 return cnt; 1453 return cnt;
1453} 1454}
diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c
index 68ec884440b7..8455b89d1bbf 100644
--- a/kernel/bpf/offload.c
+++ b/kernel/bpf/offload.c
@@ -1,3 +1,18 @@
1/*
2 * Copyright (C) 2017 Netronome Systems, Inc.
3 *
4 * This software is licensed under the GNU General License Version 2,
5 * June 1991 as shown in the file COPYING in the top-level directory of this
6 * source tree.
7 *
8 * THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS"
9 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
10 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
12 * OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
13 * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
14 */
15
1#include <linux/bpf.h> 16#include <linux/bpf.h>
2#include <linux/bpf_verifier.h> 17#include <linux/bpf_verifier.h>
3#include <linux/bug.h> 18#include <linux/bug.h>
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 27d1f4ffa3de..0ce99c379c30 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -759,6 +759,8 @@ const struct bpf_prog_ops perf_event_prog_ops = {
759 759
760static DEFINE_MUTEX(bpf_event_mutex); 760static DEFINE_MUTEX(bpf_event_mutex);
761 761
762#define BPF_TRACE_MAX_PROGS 64
763
762int perf_event_attach_bpf_prog(struct perf_event *event, 764int perf_event_attach_bpf_prog(struct perf_event *event,
763 struct bpf_prog *prog) 765 struct bpf_prog *prog)
764{ 766{
@@ -772,6 +774,12 @@ int perf_event_attach_bpf_prog(struct perf_event *event,
772 goto unlock; 774 goto unlock;
773 775
774 old_array = event->tp_event->prog_array; 776 old_array = event->tp_event->prog_array;
777 if (old_array &&
778 bpf_prog_array_length(old_array) >= BPF_TRACE_MAX_PROGS) {
779 ret = -E2BIG;
780 goto unlock;
781 }
782
775 ret = bpf_prog_array_copy(old_array, NULL, prog, &new_array); 783 ret = bpf_prog_array_copy(old_array, NULL, prog, &new_array);
776 if (ret < 0) 784 if (ret < 0)
777 goto unlock; 785 goto unlock;
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index abd07a443219..178bb9833311 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -57,10 +57,16 @@ void dccp_time_wait(struct sock *sk, int state, int timeo)
57 if (state == DCCP_TIME_WAIT) 57 if (state == DCCP_TIME_WAIT)
58 timeo = DCCP_TIMEWAIT_LEN; 58 timeo = DCCP_TIMEWAIT_LEN;
59 59
60 /* tw_timer is pinned, so we need to make sure BH are disabled
61 * in following section, otherwise timer handler could run before
62 * we complete the initialization.
63 */
64 local_bh_disable();
60 inet_twsk_schedule(tw, timeo); 65 inet_twsk_schedule(tw, timeo);
61 /* Linkage updates. */ 66 /* Linkage updates. */
62 __inet_twsk_hashdance(tw, sk, &dccp_hashinfo); 67 __inet_twsk_hashdance(tw, sk, &dccp_hashinfo);
63 inet_twsk_put(tw); 68 inet_twsk_put(tw);
69 local_bh_enable();
64 } else { 70 } else {
65 /* Sorry, if we're out of memory, just CLOSE this 71 /* Sorry, if we're out of memory, just CLOSE this
66 * socket up. We've got bigger problems than 72 * socket up. We've got bigger problems than
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index c6bc0c4d19c6..77ea45da0fe9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1591,6 +1591,34 @@ int tcp_filter(struct sock *sk, struct sk_buff *skb)
1591} 1591}
1592EXPORT_SYMBOL(tcp_filter); 1592EXPORT_SYMBOL(tcp_filter);
1593 1593
1594static void tcp_v4_restore_cb(struct sk_buff *skb)
1595{
1596 memmove(IPCB(skb), &TCP_SKB_CB(skb)->header.h4,
1597 sizeof(struct inet_skb_parm));
1598}
1599
1600static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph,
1601 const struct tcphdr *th)
1602{
1603 /* This is tricky : We move IPCB at its correct location into TCP_SKB_CB()
1604 * barrier() makes sure compiler wont play fool^Waliasing games.
1605 */
1606 memmove(&TCP_SKB_CB(skb)->header.h4, IPCB(skb),
1607 sizeof(struct inet_skb_parm));
1608 barrier();
1609
1610 TCP_SKB_CB(skb)->seq = ntohl(th->seq);
1611 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
1612 skb->len - th->doff * 4);
1613 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1614 TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th);
1615 TCP_SKB_CB(skb)->tcp_tw_isn = 0;
1616 TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph);
1617 TCP_SKB_CB(skb)->sacked = 0;
1618 TCP_SKB_CB(skb)->has_rxtstamp =
1619 skb->tstamp || skb_hwtstamps(skb)->hwtstamp;
1620}
1621
1594/* 1622/*
1595 * From tcp_input.c 1623 * From tcp_input.c
1596 */ 1624 */
@@ -1631,24 +1659,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
1631 1659
1632 th = (const struct tcphdr *)skb->data; 1660 th = (const struct tcphdr *)skb->data;
1633 iph = ip_hdr(skb); 1661 iph = ip_hdr(skb);
1634 /* This is tricky : We move IPCB at its correct location into TCP_SKB_CB()
1635 * barrier() makes sure compiler wont play fool^Waliasing games.
1636 */
1637 memmove(&TCP_SKB_CB(skb)->header.h4, IPCB(skb),
1638 sizeof(struct inet_skb_parm));
1639 barrier();
1640
1641 TCP_SKB_CB(skb)->seq = ntohl(th->seq);
1642 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
1643 skb->len - th->doff * 4);
1644 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1645 TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th);
1646 TCP_SKB_CB(skb)->tcp_tw_isn = 0;
1647 TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph);
1648 TCP_SKB_CB(skb)->sacked = 0;
1649 TCP_SKB_CB(skb)->has_rxtstamp =
1650 skb->tstamp || skb_hwtstamps(skb)->hwtstamp;
1651
1652lookup: 1662lookup:
1653 sk = __inet_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th), th->source, 1663 sk = __inet_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th), th->source,
1654 th->dest, sdif, &refcounted); 1664 th->dest, sdif, &refcounted);
@@ -1679,14 +1689,19 @@ process:
1679 sock_hold(sk); 1689 sock_hold(sk);
1680 refcounted = true; 1690 refcounted = true;
1681 nsk = NULL; 1691 nsk = NULL;
1682 if (!tcp_filter(sk, skb)) 1692 if (!tcp_filter(sk, skb)) {
1693 th = (const struct tcphdr *)skb->data;
1694 iph = ip_hdr(skb);
1695 tcp_v4_fill_cb(skb, iph, th);
1683 nsk = tcp_check_req(sk, skb, req, false); 1696 nsk = tcp_check_req(sk, skb, req, false);
1697 }
1684 if (!nsk) { 1698 if (!nsk) {
1685 reqsk_put(req); 1699 reqsk_put(req);
1686 goto discard_and_relse; 1700 goto discard_and_relse;
1687 } 1701 }
1688 if (nsk == sk) { 1702 if (nsk == sk) {
1689 reqsk_put(req); 1703 reqsk_put(req);
1704 tcp_v4_restore_cb(skb);
1690 } else if (tcp_child_process(sk, nsk, skb)) { 1705 } else if (tcp_child_process(sk, nsk, skb)) {
1691 tcp_v4_send_reset(nsk, skb); 1706 tcp_v4_send_reset(nsk, skb);
1692 goto discard_and_relse; 1707 goto discard_and_relse;
@@ -1712,6 +1727,7 @@ process:
1712 goto discard_and_relse; 1727 goto discard_and_relse;
1713 th = (const struct tcphdr *)skb->data; 1728 th = (const struct tcphdr *)skb->data;
1714 iph = ip_hdr(skb); 1729 iph = ip_hdr(skb);
1730 tcp_v4_fill_cb(skb, iph, th);
1715 1731
1716 skb->dev = NULL; 1732 skb->dev = NULL;
1717 1733
@@ -1742,6 +1758,8 @@ no_tcp_socket:
1742 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) 1758 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
1743 goto discard_it; 1759 goto discard_it;
1744 1760
1761 tcp_v4_fill_cb(skb, iph, th);
1762
1745 if (tcp_checksum_complete(skb)) { 1763 if (tcp_checksum_complete(skb)) {
1746csum_error: 1764csum_error:
1747 __TCP_INC_STATS(net, TCP_MIB_CSUMERRORS); 1765 __TCP_INC_STATS(net, TCP_MIB_CSUMERRORS);
@@ -1768,6 +1786,8 @@ do_time_wait:
1768 goto discard_it; 1786 goto discard_it;
1769 } 1787 }
1770 1788
1789 tcp_v4_fill_cb(skb, iph, th);
1790
1771 if (tcp_checksum_complete(skb)) { 1791 if (tcp_checksum_complete(skb)) {
1772 inet_twsk_put(inet_twsk(sk)); 1792 inet_twsk_put(inet_twsk(sk));
1773 goto csum_error; 1793 goto csum_error;
@@ -1784,6 +1804,7 @@ do_time_wait:
1784 if (sk2) { 1804 if (sk2) {
1785 inet_twsk_deschedule_put(inet_twsk(sk)); 1805 inet_twsk_deschedule_put(inet_twsk(sk));
1786 sk = sk2; 1806 sk = sk2;
1807 tcp_v4_restore_cb(skb);
1787 refcounted = false; 1808 refcounted = false;
1788 goto process; 1809 goto process;
1789 } 1810 }
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index e36eff0403f4..b079b619b60c 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -310,10 +310,16 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
310 if (state == TCP_TIME_WAIT) 310 if (state == TCP_TIME_WAIT)
311 timeo = TCP_TIMEWAIT_LEN; 311 timeo = TCP_TIMEWAIT_LEN;
312 312
313 /* tw_timer is pinned, so we need to make sure BH are disabled
314 * in following section, otherwise timer handler could run before
315 * we complete the initialization.
316 */
317 local_bh_disable();
313 inet_twsk_schedule(tw, timeo); 318 inet_twsk_schedule(tw, timeo);
314 /* Linkage updates. */ 319 /* Linkage updates. */
315 __inet_twsk_hashdance(tw, sk, &tcp_hashinfo); 320 __inet_twsk_hashdance(tw, sk, &tcp_hashinfo);
316 inet_twsk_put(tw); 321 inet_twsk_put(tw);
322 local_bh_enable();
317 } else { 323 } else {
318 /* Sorry, if we're out of memory, just CLOSE this 324 /* Sorry, if we're out of memory, just CLOSE this
319 * socket up. We've got bigger problems than 325 * socket up. We've got bigger problems than
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index d60ddcb0bfe2..d7dc23c1b2ca 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1098,6 +1098,7 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p,
1098 ipip6_tunnel_link(sitn, t); 1098 ipip6_tunnel_link(sitn, t);
1099 t->parms.iph.ttl = p->iph.ttl; 1099 t->parms.iph.ttl = p->iph.ttl;
1100 t->parms.iph.tos = p->iph.tos; 1100 t->parms.iph.tos = p->iph.tos;
1101 t->parms.iph.frag_off = p->iph.frag_off;
1101 if (t->parms.link != p->link || t->fwmark != fwmark) { 1102 if (t->parms.link != p->link || t->fwmark != fwmark) {
1102 t->parms.link = p->link; 1103 t->parms.link = p->link;
1103 t->fwmark = fwmark; 1104 t->fwmark = fwmark;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 6bb98c93edfe..1f04ec0e4a7a 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1454,7 +1454,6 @@ process:
1454 struct sock *nsk; 1454 struct sock *nsk;
1455 1455
1456 sk = req->rsk_listener; 1456 sk = req->rsk_listener;
1457 tcp_v6_fill_cb(skb, hdr, th);
1458 if (tcp_v6_inbound_md5_hash(sk, skb)) { 1457 if (tcp_v6_inbound_md5_hash(sk, skb)) {
1459 sk_drops_add(sk, skb); 1458 sk_drops_add(sk, skb);
1460 reqsk_put(req); 1459 reqsk_put(req);
@@ -1467,8 +1466,12 @@ process:
1467 sock_hold(sk); 1466 sock_hold(sk);
1468 refcounted = true; 1467 refcounted = true;
1469 nsk = NULL; 1468 nsk = NULL;
1470 if (!tcp_filter(sk, skb)) 1469 if (!tcp_filter(sk, skb)) {
1470 th = (const struct tcphdr *)skb->data;
1471 hdr = ipv6_hdr(skb);
1472 tcp_v6_fill_cb(skb, hdr, th);
1471 nsk = tcp_check_req(sk, skb, req, false); 1473 nsk = tcp_check_req(sk, skb, req, false);
1474 }
1472 if (!nsk) { 1475 if (!nsk) {
1473 reqsk_put(req); 1476 reqsk_put(req);
1474 goto discard_and_relse; 1477 goto discard_and_relse;
@@ -1492,8 +1495,6 @@ process:
1492 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 1495 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1493 goto discard_and_relse; 1496 goto discard_and_relse;
1494 1497
1495 tcp_v6_fill_cb(skb, hdr, th);
1496
1497 if (tcp_v6_inbound_md5_hash(sk, skb)) 1498 if (tcp_v6_inbound_md5_hash(sk, skb))
1498 goto discard_and_relse; 1499 goto discard_and_relse;
1499 1500
@@ -1501,6 +1502,7 @@ process:
1501 goto discard_and_relse; 1502 goto discard_and_relse;
1502 th = (const struct tcphdr *)skb->data; 1503 th = (const struct tcphdr *)skb->data;
1503 hdr = ipv6_hdr(skb); 1504 hdr = ipv6_hdr(skb);
1505 tcp_v6_fill_cb(skb, hdr, th);
1504 1506
1505 skb->dev = NULL; 1507 skb->dev = NULL;
1506 1508
@@ -1590,7 +1592,6 @@ do_time_wait:
1590 tcp_v6_timewait_ack(sk, skb); 1592 tcp_v6_timewait_ack(sk, skb);
1591 break; 1593 break;
1592 case TCP_TW_RST: 1594 case TCP_TW_RST:
1593 tcp_v6_restore_cb(skb);
1594 tcp_v6_send_reset(sk, skb); 1595 tcp_v6_send_reset(sk, skb);
1595 inet_twsk_deschedule_put(inet_twsk(sk)); 1596 inet_twsk_deschedule_put(inet_twsk(sk));
1596 goto discard_it; 1597 goto discard_it;
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 8f7cf4c042be..dcd818fa837e 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -860,6 +860,7 @@ static void rxrpc_sock_destructor(struct sock *sk)
860static int rxrpc_release_sock(struct sock *sk) 860static int rxrpc_release_sock(struct sock *sk)
861{ 861{
862 struct rxrpc_sock *rx = rxrpc_sk(sk); 862 struct rxrpc_sock *rx = rxrpc_sk(sk);
863 struct rxrpc_net *rxnet = rxrpc_net(sock_net(&rx->sk));
863 864
864 _enter("%p{%d,%d}", sk, sk->sk_state, refcount_read(&sk->sk_refcnt)); 865 _enter("%p{%d,%d}", sk, sk->sk_state, refcount_read(&sk->sk_refcnt));
865 866
@@ -895,8 +896,8 @@ static int rxrpc_release_sock(struct sock *sk)
895 rxrpc_release_calls_on_socket(rx); 896 rxrpc_release_calls_on_socket(rx);
896 flush_workqueue(rxrpc_workqueue); 897 flush_workqueue(rxrpc_workqueue);
897 rxrpc_purge_queue(&sk->sk_receive_queue); 898 rxrpc_purge_queue(&sk->sk_receive_queue);
898 rxrpc_queue_work(&rx->local->rxnet->service_conn_reaper); 899 rxrpc_queue_work(&rxnet->service_conn_reaper);
899 rxrpc_queue_work(&rx->local->rxnet->client_conn_reaper); 900 rxrpc_queue_work(&rxnet->client_conn_reaper);
900 901
901 rxrpc_put_local(rx->local); 902 rxrpc_put_local(rx->local);
902 rx->local = NULL; 903 rx->local = NULL;
diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index bda952ffe6a6..ad2ab1103189 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -123,7 +123,7 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
123 else 123 else
124 ack_at = expiry; 124 ack_at = expiry;
125 125
126 ack_at = jiffies + expiry; 126 ack_at += now;
127 if (time_before(ack_at, call->ack_at)) { 127 if (time_before(ack_at, call->ack_at)) {
128 WRITE_ONCE(call->ack_at, ack_at); 128 WRITE_ONCE(call->ack_at, ack_at);
129 rxrpc_reduce_call_timer(call, ack_at, now, 129 rxrpc_reduce_call_timer(call, ack_at, now,
@@ -426,7 +426,7 @@ recheck_state:
426 next = call->expect_rx_by; 426 next = call->expect_rx_by;
427 427
428#define set(T) { t = READ_ONCE(T); if (time_before(t, next)) next = t; } 428#define set(T) { t = READ_ONCE(T); if (time_before(t, next)) next = t; }
429 429
430 set(call->expect_req_by); 430 set(call->expect_req_by);
431 set(call->expect_term_by); 431 set(call->expect_term_by);
432 set(call->ack_at); 432 set(call->ack_at);
diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index 9e9a8db1bc9c..4ca11be6be3c 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -30,22 +30,18 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
30 struct rxrpc_skb_priv *sp = skb ? rxrpc_skb(skb) : NULL; 30 struct rxrpc_skb_priv *sp = skb ? rxrpc_skb(skb) : NULL;
31 struct rxrpc_channel *chan; 31 struct rxrpc_channel *chan;
32 struct msghdr msg; 32 struct msghdr msg;
33 struct kvec iov; 33 struct kvec iov[3];
34 struct { 34 struct {
35 struct rxrpc_wire_header whdr; 35 struct rxrpc_wire_header whdr;
36 union { 36 union {
37 struct { 37 __be32 abort_code;
38 __be32 code; 38 struct rxrpc_ackpacket ack;
39 } abort;
40 struct {
41 struct rxrpc_ackpacket ack;
42 u8 padding[3];
43 struct rxrpc_ackinfo info;
44 };
45 }; 39 };
46 } __attribute__((packed)) pkt; 40 } __attribute__((packed)) pkt;
41 struct rxrpc_ackinfo ack_info;
47 size_t len; 42 size_t len;
48 u32 serial, mtu, call_id; 43 int ioc;
44 u32 serial, mtu, call_id, padding;
49 45
50 _enter("%d", conn->debug_id); 46 _enter("%d", conn->debug_id);
51 47
@@ -66,6 +62,13 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
66 msg.msg_controllen = 0; 62 msg.msg_controllen = 0;
67 msg.msg_flags = 0; 63 msg.msg_flags = 0;
68 64
65 iov[0].iov_base = &pkt;
66 iov[0].iov_len = sizeof(pkt.whdr);
67 iov[1].iov_base = &padding;
68 iov[1].iov_len = 3;
69 iov[2].iov_base = &ack_info;
70 iov[2].iov_len = sizeof(ack_info);
71
69 pkt.whdr.epoch = htonl(conn->proto.epoch); 72 pkt.whdr.epoch = htonl(conn->proto.epoch);
70 pkt.whdr.cid = htonl(conn->proto.cid); 73 pkt.whdr.cid = htonl(conn->proto.cid);
71 pkt.whdr.callNumber = htonl(call_id); 74 pkt.whdr.callNumber = htonl(call_id);
@@ -80,8 +83,10 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
80 len = sizeof(pkt.whdr); 83 len = sizeof(pkt.whdr);
81 switch (chan->last_type) { 84 switch (chan->last_type) {
82 case RXRPC_PACKET_TYPE_ABORT: 85 case RXRPC_PACKET_TYPE_ABORT:
83 pkt.abort.code = htonl(chan->last_abort); 86 pkt.abort_code = htonl(chan->last_abort);
84 len += sizeof(pkt.abort); 87 iov[0].iov_len += sizeof(pkt.abort_code);
88 len += sizeof(pkt.abort_code);
89 ioc = 1;
85 break; 90 break;
86 91
87 case RXRPC_PACKET_TYPE_ACK: 92 case RXRPC_PACKET_TYPE_ACK:
@@ -94,13 +99,19 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
94 pkt.ack.serial = htonl(skb ? sp->hdr.serial : 0); 99 pkt.ack.serial = htonl(skb ? sp->hdr.serial : 0);
95 pkt.ack.reason = skb ? RXRPC_ACK_DUPLICATE : RXRPC_ACK_IDLE; 100 pkt.ack.reason = skb ? RXRPC_ACK_DUPLICATE : RXRPC_ACK_IDLE;
96 pkt.ack.nAcks = 0; 101 pkt.ack.nAcks = 0;
97 pkt.info.rxMTU = htonl(rxrpc_rx_mtu); 102 ack_info.rxMTU = htonl(rxrpc_rx_mtu);
98 pkt.info.maxMTU = htonl(mtu); 103 ack_info.maxMTU = htonl(mtu);
99 pkt.info.rwind = htonl(rxrpc_rx_window_size); 104 ack_info.rwind = htonl(rxrpc_rx_window_size);
100 pkt.info.jumbo_max = htonl(rxrpc_rx_jumbo_max); 105 ack_info.jumbo_max = htonl(rxrpc_rx_jumbo_max);
101 pkt.whdr.flags |= RXRPC_SLOW_START_OK; 106 pkt.whdr.flags |= RXRPC_SLOW_START_OK;
102 len += sizeof(pkt.ack) + sizeof(pkt.info); 107 padding = 0;
108 iov[0].iov_len += sizeof(pkt.ack);
109 len += sizeof(pkt.ack) + 3 + sizeof(ack_info);
110 ioc = 3;
103 break; 111 break;
112
113 default:
114 return;
104 } 115 }
105 116
106 /* Resync with __rxrpc_disconnect_call() and check that the last call 117 /* Resync with __rxrpc_disconnect_call() and check that the last call
@@ -110,9 +121,6 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
110 if (READ_ONCE(chan->last_call) != call_id) 121 if (READ_ONCE(chan->last_call) != call_id)
111 return; 122 return;
112 123
113 iov.iov_base = &pkt;
114 iov.iov_len = len;
115
116 serial = atomic_inc_return(&conn->serial); 124 serial = atomic_inc_return(&conn->serial);
117 pkt.whdr.serial = htonl(serial); 125 pkt.whdr.serial = htonl(serial);
118 126
@@ -127,7 +135,7 @@ static void rxrpc_conn_retransmit_call(struct rxrpc_connection *conn,
127 break; 135 break;
128 } 136 }
129 137
130 kernel_sendmsg(conn->params.local->socket, &msg, &iov, 1, len); 138 kernel_sendmsg(conn->params.local->socket, &msg, iov, ioc, len);
131 _leave(""); 139 _leave("");
132 return; 140 return;
133} 141}
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 1aad04a32d5e..c628351eb900 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -424,7 +424,7 @@ void rxrpc_service_connection_reaper(struct work_struct *work)
424 if (earliest != now + MAX_JIFFY_OFFSET) { 424 if (earliest != now + MAX_JIFFY_OFFSET) {
425 _debug("reschedule reaper %ld", (long)earliest - (long)now); 425 _debug("reschedule reaper %ld", (long)earliest - (long)now);
426 ASSERT(time_after(earliest, now)); 426 ASSERT(time_after(earliest, now));
427 rxrpc_set_service_reap_timer(rxnet, earliest); 427 rxrpc_set_service_reap_timer(rxnet, earliest);
428 } 428 }
429 429
430 while (!list_empty(&graveyard)) { 430 while (!list_empty(&graveyard)) {
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 23a5e61d8f79..6fc61400337f 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -976,7 +976,7 @@ static void rxrpc_input_call_packet(struct rxrpc_call *call,
976 rxrpc_reduce_call_timer(call, expect_rx_by, now, 976 rxrpc_reduce_call_timer(call, expect_rx_by, now,
977 rxrpc_timer_set_for_normal); 977 rxrpc_timer_set_for_normal);
978 } 978 }
979 979
980 switch (sp->hdr.type) { 980 switch (sp->hdr.type) {
981 case RXRPC_PACKET_TYPE_DATA: 981 case RXRPC_PACKET_TYPE_DATA:
982 rxrpc_input_data(call, skb, skew); 982 rxrpc_input_data(call, skb, skew);
@@ -1213,7 +1213,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
1213 goto reupgrade; 1213 goto reupgrade;
1214 conn->service_id = sp->hdr.serviceId; 1214 conn->service_id = sp->hdr.serviceId;
1215 } 1215 }
1216 1216
1217 if (sp->hdr.callNumber == 0) { 1217 if (sp->hdr.callNumber == 0) {
1218 /* Connection-level packet */ 1218 /* Connection-level packet */
1219 _debug("CONN %p {%d}", conn, conn->debug_id); 1219 _debug("CONN %p {%d}", conn, conn->debug_id);
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index a1c53ac066a1..09f2a3e05221 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -233,7 +233,7 @@ static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
233 if (resend_at < 1) 233 if (resend_at < 1)
234 resend_at = 1; 234 resend_at = 1;
235 235
236 resend_at = now + rxrpc_resend_timeout; 236 resend_at += now;
237 WRITE_ONCE(call->resend_at, resend_at); 237 WRITE_ONCE(call->resend_at, resend_at);
238 rxrpc_reduce_call_timer(call, resend_at, now, 238 rxrpc_reduce_call_timer(call, resend_at, now,
239 rxrpc_timer_set_for_send); 239 rxrpc_timer_set_for_send);
diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c
index 8b5abcd2f32f..9438969290a6 100644
--- a/net/sched/act_sample.c
+++ b/net/sched/act_sample.c
@@ -96,23 +96,16 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
96 return ret; 96 return ret;
97} 97}
98 98
99static void tcf_sample_cleanup_rcu(struct rcu_head *rcu) 99static void tcf_sample_cleanup(struct tc_action *a, int bind)
100{ 100{
101 struct tcf_sample *s = container_of(rcu, struct tcf_sample, rcu); 101 struct tcf_sample *s = to_sample(a);
102 struct psample_group *psample_group; 102 struct psample_group *psample_group;
103 103
104 psample_group = rcu_dereference_protected(s->psample_group, 1); 104 psample_group = rtnl_dereference(s->psample_group);
105 RCU_INIT_POINTER(s->psample_group, NULL); 105 RCU_INIT_POINTER(s->psample_group, NULL);
106 psample_group_put(psample_group); 106 psample_group_put(psample_group);
107} 107}
108 108
109static void tcf_sample_cleanup(struct tc_action *a, int bind)
110{
111 struct tcf_sample *s = to_sample(a);
112
113 call_rcu(&s->rcu, tcf_sample_cleanup_rcu);
114}
115
116static bool tcf_sample_dev_ok_push(struct net_device *dev) 109static bool tcf_sample_dev_ok_push(struct net_device *dev)
117{ 110{
118 switch (dev->type) { 111 switch (dev->type) {
@@ -264,7 +257,6 @@ static int __init sample_init_module(void)
264 257
265static void __exit sample_cleanup_module(void) 258static void __exit sample_cleanup_module(void)
266{ 259{
267 rcu_barrier();
268 tcf_unregister_action(&act_sample_ops, &sample_net_ops); 260 tcf_unregister_action(&act_sample_ops, &sample_net_ops);
269} 261}
270 262
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 7b261afc47b9..7f8baa48e7c2 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -53,6 +53,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg)
53 msg->send_failed = 0; 53 msg->send_failed = 0;
54 msg->send_error = 0; 54 msg->send_error = 0;
55 msg->can_delay = 1; 55 msg->can_delay = 1;
56 msg->abandoned = 0;
56 msg->expires_at = 0; 57 msg->expires_at = 0;
57 INIT_LIST_HEAD(&msg->chunks); 58 INIT_LIST_HEAD(&msg->chunks);
58} 59}
@@ -304,6 +305,13 @@ int sctp_chunk_abandoned(struct sctp_chunk *chunk)
304 if (!chunk->asoc->peer.prsctp_capable) 305 if (!chunk->asoc->peer.prsctp_capable)
305 return 0; 306 return 0;
306 307
308 if (chunk->msg->abandoned)
309 return 1;
310
311 if (!chunk->has_tsn &&
312 !(chunk->chunk_hdr->flags & SCTP_DATA_FIRST_FRAG))
313 return 0;
314
307 if (SCTP_PR_TTL_ENABLED(chunk->sinfo.sinfo_flags) && 315 if (SCTP_PR_TTL_ENABLED(chunk->sinfo.sinfo_flags) &&
308 time_after(jiffies, chunk->msg->expires_at)) { 316 time_after(jiffies, chunk->msg->expires_at)) {
309 struct sctp_stream_out *streamout = 317 struct sctp_stream_out *streamout =
@@ -316,6 +324,7 @@ int sctp_chunk_abandoned(struct sctp_chunk *chunk)
316 chunk->asoc->abandoned_unsent[SCTP_PR_INDEX(TTL)]++; 324 chunk->asoc->abandoned_unsent[SCTP_PR_INDEX(TTL)]++;
317 streamout->ext->abandoned_unsent[SCTP_PR_INDEX(TTL)]++; 325 streamout->ext->abandoned_unsent[SCTP_PR_INDEX(TTL)]++;
318 } 326 }
327 chunk->msg->abandoned = 1;
319 return 1; 328 return 1;
320 } else if (SCTP_PR_RTX_ENABLED(chunk->sinfo.sinfo_flags) && 329 } else if (SCTP_PR_RTX_ENABLED(chunk->sinfo.sinfo_flags) &&
321 chunk->sent_count > chunk->sinfo.sinfo_timetolive) { 330 chunk->sent_count > chunk->sinfo.sinfo_timetolive) {
@@ -324,10 +333,12 @@ int sctp_chunk_abandoned(struct sctp_chunk *chunk)
324 333
325 chunk->asoc->abandoned_sent[SCTP_PR_INDEX(RTX)]++; 334 chunk->asoc->abandoned_sent[SCTP_PR_INDEX(RTX)]++;
326 streamout->ext->abandoned_sent[SCTP_PR_INDEX(RTX)]++; 335 streamout->ext->abandoned_sent[SCTP_PR_INDEX(RTX)]++;
336 chunk->msg->abandoned = 1;
327 return 1; 337 return 1;
328 } else if (!SCTP_PR_POLICY(chunk->sinfo.sinfo_flags) && 338 } else if (!SCTP_PR_POLICY(chunk->sinfo.sinfo_flags) &&
329 chunk->msg->expires_at && 339 chunk->msg->expires_at &&
330 time_after(jiffies, chunk->msg->expires_at)) { 340 time_after(jiffies, chunk->msg->expires_at)) {
341 chunk->msg->abandoned = 1;
331 return 1; 342 return 1;
332 } 343 }
333 /* PRIO policy is processed by sendmsg, not here */ 344 /* PRIO policy is processed by sendmsg, not here */
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 4db012aa25f7..7d67feeeffc1 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -364,10 +364,12 @@ static int sctp_prsctp_prune_sent(struct sctp_association *asoc,
364 list_for_each_entry_safe(chk, temp, queue, transmitted_list) { 364 list_for_each_entry_safe(chk, temp, queue, transmitted_list) {
365 struct sctp_stream_out *streamout; 365 struct sctp_stream_out *streamout;
366 366
367 if (!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) || 367 if (!chk->msg->abandoned &&
368 chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive) 368 (!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) ||
369 chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive))
369 continue; 370 continue;
370 371
372 chk->msg->abandoned = 1;
371 list_del_init(&chk->transmitted_list); 373 list_del_init(&chk->transmitted_list);
372 sctp_insert_list(&asoc->outqueue.abandoned, 374 sctp_insert_list(&asoc->outqueue.abandoned,
373 &chk->transmitted_list); 375 &chk->transmitted_list);
@@ -377,7 +379,8 @@ static int sctp_prsctp_prune_sent(struct sctp_association *asoc,
377 asoc->abandoned_sent[SCTP_PR_INDEX(PRIO)]++; 379 asoc->abandoned_sent[SCTP_PR_INDEX(PRIO)]++;
378 streamout->ext->abandoned_sent[SCTP_PR_INDEX(PRIO)]++; 380 streamout->ext->abandoned_sent[SCTP_PR_INDEX(PRIO)]++;
379 381
380 if (!chk->tsn_gap_acked) { 382 if (queue != &asoc->outqueue.retransmit &&
383 !chk->tsn_gap_acked) {
381 if (chk->transport) 384 if (chk->transport)
382 chk->transport->flight_size -= 385 chk->transport->flight_size -=
383 sctp_data_size(chk); 386 sctp_data_size(chk);
@@ -403,10 +406,13 @@ static int sctp_prsctp_prune_unsent(struct sctp_association *asoc,
403 q->sched->unsched_all(&asoc->stream); 406 q->sched->unsched_all(&asoc->stream);
404 407
405 list_for_each_entry_safe(chk, temp, &q->out_chunk_list, list) { 408 list_for_each_entry_safe(chk, temp, &q->out_chunk_list, list) {
406 if (!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) || 409 if (!chk->msg->abandoned &&
407 chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive) 410 (!(chk->chunk_hdr->flags & SCTP_DATA_FIRST_FRAG) ||
411 !SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) ||
412 chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive))
408 continue; 413 continue;
409 414
415 chk->msg->abandoned = 1;
410 sctp_sched_dequeue_common(q, chk); 416 sctp_sched_dequeue_common(q, chk);
411 asoc->sent_cnt_removable--; 417 asoc->sent_cnt_removable--;
412 asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++; 418 asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
@@ -1434,7 +1440,8 @@ static void sctp_check_transmitted(struct sctp_outq *q,
1434 /* If this chunk has not been acked, stop 1440 /* If this chunk has not been acked, stop
1435 * considering it as 'outstanding'. 1441 * considering it as 'outstanding'.
1436 */ 1442 */
1437 if (!tchunk->tsn_gap_acked) { 1443 if (transmitted_queue != &q->retransmit &&
1444 !tchunk->tsn_gap_acked) {
1438 if (tchunk->transport) 1445 if (tchunk->transport)
1439 tchunk->transport->flight_size -= 1446 tchunk->transport->flight_size -=
1440 sctp_data_size(tchunk); 1447 sctp_data_size(tchunk);
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index ecca64fc6a6f..3deabcab4882 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -371,10 +371,6 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb)
371 goto rcu_out; 371 goto rcu_out;
372 } 372 }
373 373
374 tipc_rcv(sock_net(sk), skb, b);
375 rcu_read_unlock();
376 return 0;
377
378rcu_out: 374rcu_out:
379 rcu_read_unlock(); 375 rcu_read_unlock();
380out: 376out:
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index 522ca9252d6c..242631aa4ea2 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -193,8 +193,18 @@ static int load_and_attach(const char *event, struct bpf_insn *prog, int size)
193 return -1; 193 return -1;
194 } 194 }
195 event_fd[prog_cnt - 1] = efd; 195 event_fd[prog_cnt - 1] = efd;
196 ioctl(efd, PERF_EVENT_IOC_ENABLE, 0); 196 err = ioctl(efd, PERF_EVENT_IOC_ENABLE, 0);
197 ioctl(efd, PERF_EVENT_IOC_SET_BPF, fd); 197 if (err < 0) {
198 printf("ioctl PERF_EVENT_IOC_ENABLE failed err %s\n",
199 strerror(errno));
200 return -1;
201 }
202 err = ioctl(efd, PERF_EVENT_IOC_SET_BPF, fd);
203 if (err < 0) {
204 printf("ioctl PERF_EVENT_IOC_SET_BPF failed err %s\n",
205 strerror(errno));
206 return -1;
207 }
198 208
199 return 0; 209 return 0;
200} 210}
diff --git a/tools/bpf/bpftool/Documentation/Makefile b/tools/bpf/bpftool/Documentation/Makefile
index bde77d7c4390..37292bb5ce60 100644
--- a/tools/bpf/bpftool/Documentation/Makefile
+++ b/tools/bpf/bpftool/Documentation/Makefile
@@ -6,7 +6,7 @@ RM ?= rm -f
6 6
7# Make the path relative to DESTDIR, not prefix 7# Make the path relative to DESTDIR, not prefix
8ifndef DESTDIR 8ifndef DESTDIR
9prefix?=$(HOME) 9prefix ?= /usr/local
10endif 10endif
11mandir ?= $(prefix)/share/man 11mandir ?= $(prefix)/share/man
12man8dir = $(mandir)/man8 12man8dir = $(mandir)/man8
diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 813826c50936..ec3052c0b004 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -45,8 +45,8 @@ $(LIBBPF)-clean:
45 $(call QUIET_CLEAN, libbpf) 45 $(call QUIET_CLEAN, libbpf)
46 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null 46 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
47 47
48prefix = /usr 48prefix = /usr/local
49bash_compdir ?= $(prefix)/share/bash-completion/completions 49bash_compdir ?= /usr/share/bash-completion/completions
50 50
51CC = gcc 51CC = gcc
52 52
@@ -76,6 +76,7 @@ clean: $(LIBBPF)-clean
76 $(Q)rm -rf $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d 76 $(Q)rm -rf $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
77 77
78install: 78install:
79 install -m 0755 -d $(prefix)/sbin
79 install $(OUTPUT)bpftool $(prefix)/sbin/bpftool 80 install $(OUTPUT)bpftool $(prefix)/sbin/bpftool
80 install -m 0755 -d $(bash_compdir) 81 install -m 0755 -d $(bash_compdir)
81 install -m 0644 bash-completion/bpftool $(bash_compdir) 82 install -m 0644 bash-completion/bpftool $(bash_compdir)
@@ -88,5 +89,5 @@ doc-install:
88 89
89FORCE: 90FORCE:
90 91
91.PHONY: all clean FORCE 92.PHONY: all clean FORCE install doc doc-install
92.DEFAULT_GOAL := all 93.DEFAULT_GOAL := all
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index d6e4762170a4..d294bc8168be 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -58,11 +58,19 @@ bool show_pinned;
58struct pinned_obj_table prog_table; 58struct pinned_obj_table prog_table;
59struct pinned_obj_table map_table; 59struct pinned_obj_table map_table;
60 60
61static void __noreturn clean_and_exit(int i)
62{
63 if (json_output)
64 jsonw_destroy(&json_wtr);
65
66 exit(i);
67}
68
61void usage(void) 69void usage(void)
62{ 70{
63 last_do_help(last_argc - 1, last_argv + 1); 71 last_do_help(last_argc - 1, last_argv + 1);
64 72
65 exit(-1); 73 clean_and_exit(-1);
66} 74}
67 75
68static int do_help(int argc, char **argv) 76static int do_help(int argc, char **argv)
@@ -280,6 +288,7 @@ int main(int argc, char **argv)
280 hash_init(prog_table.table); 288 hash_init(prog_table.table);
281 hash_init(map_table.table); 289 hash_init(map_table.table);
282 290
291 opterr = 0;
283 while ((opt = getopt_long(argc, argv, "Vhpjf", 292 while ((opt = getopt_long(argc, argv, "Vhpjf",
284 options, NULL)) >= 0) { 293 options, NULL)) >= 0) {
285 switch (opt) { 294 switch (opt) {
@@ -291,13 +300,25 @@ int main(int argc, char **argv)
291 pretty_output = true; 300 pretty_output = true;
292 /* fall through */ 301 /* fall through */
293 case 'j': 302 case 'j':
294 json_output = true; 303 if (!json_output) {
304 json_wtr = jsonw_new(stdout);
305 if (!json_wtr) {
306 p_err("failed to create JSON writer");
307 return -1;
308 }
309 json_output = true;
310 }
311 jsonw_pretty(json_wtr, pretty_output);
295 break; 312 break;
296 case 'f': 313 case 'f':
297 show_pinned = true; 314 show_pinned = true;
298 break; 315 break;
299 default: 316 default:
300 usage(); 317 p_err("unrecognized option '%s'", argv[optind - 1]);
318 if (json_output)
319 clean_and_exit(-1);
320 else
321 usage();
301 } 322 }
302 } 323 }
303 324
@@ -306,15 +327,6 @@ int main(int argc, char **argv)
306 if (argc < 0) 327 if (argc < 0)
307 usage(); 328 usage();
308 329
309 if (json_output) {
310 json_wtr = jsonw_new(stdout);
311 if (!json_wtr) {
312 p_err("failed to create JSON writer");
313 return -1;
314 }
315 jsonw_pretty(json_wtr, pretty_output);
316 }
317
318 bfd_init(); 330 bfd_init();
319 331
320 ret = cmd_select(cmds, argc, argv, do_help); 332 ret = cmd_select(cmds, argc, argv, do_help);
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index 9c191e222d6f..bff330b49791 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -41,6 +41,7 @@
41#include <stdbool.h> 41#include <stdbool.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <linux/bpf.h> 43#include <linux/bpf.h>
44#include <linux/compiler.h>
44#include <linux/kernel.h> 45#include <linux/kernel.h>
45#include <linux/hashtable.h> 46#include <linux/hashtable.h>
46 47
@@ -50,7 +51,7 @@
50 51
51#define NEXT_ARG() ({ argc--; argv++; if (argc < 0) usage(); }) 52#define NEXT_ARG() ({ argc--; argv++; if (argc < 0) usage(); })
52#define NEXT_ARGP() ({ (*argc)--; (*argv)++; if (*argc < 0) usage(); }) 53#define NEXT_ARGP() ({ (*argc)--; (*argv)++; if (*argc < 0) usage(); })
53#define BAD_ARG() ({ p_err("what is '%s'?\n", *argv); -1; }) 54#define BAD_ARG() ({ p_err("what is '%s'?", *argv); -1; })
54 55
55#define ERR_MAX_LEN 1024 56#define ERR_MAX_LEN 1024
56 57
@@ -80,7 +81,7 @@ void p_info(const char *fmt, ...);
80 81
81bool is_prefix(const char *pfx, const char *str); 82bool is_prefix(const char *pfx, const char *str);
82void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep); 83void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep);
83void usage(void) __attribute__((noreturn)); 84void usage(void) __noreturn;
84 85
85struct pinned_obj_table { 86struct pinned_obj_table {
86 DECLARE_HASHTABLE(table, 16); 87 DECLARE_HASHTABLE(table, 16);
diff --git a/tools/testing/selftests/bpf/test_verifier_log.c b/tools/testing/selftests/bpf/test_verifier_log.c
index 3cc0b561489e..e9626cf5607a 100644
--- a/tools/testing/selftests/bpf/test_verifier_log.c
+++ b/tools/testing/selftests/bpf/test_verifier_log.c
@@ -3,6 +3,8 @@
3#include <stdio.h> 3#include <stdio.h>
4#include <string.h> 4#include <string.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <sys/time.h>
7#include <sys/resource.h>
6 8
7#include <linux/bpf.h> 9#include <linux/bpf.h>
8#include <linux/filter.h> 10#include <linux/filter.h>
@@ -131,11 +133,16 @@ static void test_log_bad(char *log, size_t log_len, int log_level)
131 133
132int main(int argc, char **argv) 134int main(int argc, char **argv)
133{ 135{
136 struct rlimit limit = { RLIM_INFINITY, RLIM_INFINITY };
134 char full_log[LOG_SIZE]; 137 char full_log[LOG_SIZE];
135 char log[LOG_SIZE]; 138 char log[LOG_SIZE];
136 size_t want_len; 139 size_t want_len;
137 int i; 140 int i;
138 141
142 /* allow unlimited locked memory to have more consistent error code */
143 if (setrlimit(RLIMIT_MEMLOCK, &limit) < 0)
144 perror("Unable to lift memlock rlimit");
145
139 memset(log, 1, LOG_SIZE); 146 memset(log, 1, LOG_SIZE);
140 147
141 /* Test incorrect attr */ 148 /* Test incorrect attr */