aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-04-30 03:50:54 -0400
committerDavid S. Miller <davem@davemloft.net>2013-04-30 03:55:20 -0400
commit58717686cf7c7f5a70b3a8907ade8a3ce74306b1 (patch)
tree57f5d78524bfd5e65aa9f3943da9c1a3e6ff65b7
parentcff63a52924c6a78fa525c67d81480c85736ff3c (diff)
parent79f632c71bea0d0864d84d6a4ce78da5a9430f5b (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c drivers/net/ethernet/emulex/benet/be.h include/net/tcp.h net/mac802154/mac802154.h Most conflicts were minor overlapping stuff. The be2net driver brought in some fixes that added __vlan_put_tag calls, which in net-next take an additional argument. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/isdn/mISDN/socket.c1
-rw-r--r--drivers/isdn/sc/init.c4
-rw-r--r--drivers/net/bonding/bond_main.c6
-rw-r--r--drivers/net/caif/caif_spi.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c11
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h19
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c32
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h7
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c70
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h13
-rw-r--r--drivers/net/ethernet/emulex/benet/be_ethtool.c3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c121
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ptp.c3
-rw-r--r--drivers/net/ethernet/realtek/r8169.c9
-rw-r--r--drivers/net/ethernet/sfc/mcdi.c2
-rw-r--r--drivers/net/tun.c15
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/batman-adv/routing.c11
-rw-r--r--net/core/datagram.c22
-rw-r--r--net/ipv4/tcp_ipv4.c1
-rw-r--r--net/mac802154/mac802154.h2
-rw-r--r--net/netfilter/ipvs/ip_vs_pe_sip.c6
-rw-r--r--net/netrom/af_netrom.c2
-rw-r--r--net/nfc/llcp_sock.c5
-rw-r--r--net/unix/af_unix.c25
-rw-r--r--net/vmw_vsock/af_vsock.c4
26 files changed, 293 insertions, 104 deletions
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 8b07f83d48ad..e47dcb9d1e91 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -578,6 +578,7 @@ data_sock_getname(struct socket *sock, struct sockaddr *addr,
578 lock_sock(sk); 578 lock_sock(sk);
579 579
580 *addr_len = sizeof(*maddr); 580 *addr_len = sizeof(*maddr);
581 maddr->family = AF_ISDN;
581 maddr->dev = _pms(sk)->dev->id; 582 maddr->dev = _pms(sk)->dev->id;
582 maddr->channel = _pms(sk)->ch.nr; 583 maddr->channel = _pms(sk)->ch.nr;
583 maddr->sapi = _pms(sk)->ch.addr & 0xff; 584 maddr->sapi = _pms(sk)->ch.addr & 0xff;
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
index 6b580b2c717f..ca997bd4e818 100644
--- a/drivers/isdn/sc/init.c
+++ b/drivers/isdn/sc/init.c
@@ -33,8 +33,8 @@ static unsigned long ram[] = {0, 0, 0, 0};
33static bool do_reset = 0; 33static bool do_reset = 0;
34 34
35module_param_array(io, int, NULL, 0); 35module_param_array(io, int, NULL, 0);
36module_param_array(irq, int, NULL, 0); 36module_param_array(irq, byte, NULL, 0);
37module_param_array(ram, int, NULL, 0); 37module_param_array(ram, long, NULL, 0);
38module_param(do_reset, bool, 0); 38module_param(do_reset, bool, 0);
39 39
40static int identify_board(unsigned long, unsigned int); 40static int identify_board(unsigned long, unsigned int);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 532153db1f9c..d0aade04e49a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1917,14 +1917,16 @@ err_detach:
1917 bond_detach_slave(bond, new_slave); 1917 bond_detach_slave(bond, new_slave);
1918 if (bond->primary_slave == new_slave) 1918 if (bond->primary_slave == new_slave)
1919 bond->primary_slave = NULL; 1919 bond->primary_slave = NULL;
1920 write_unlock_bh(&bond->lock);
1921 if (bond->curr_active_slave == new_slave) { 1920 if (bond->curr_active_slave == new_slave) {
1921 bond_change_active_slave(bond, NULL);
1922 write_unlock_bh(&bond->lock);
1922 read_lock(&bond->lock); 1923 read_lock(&bond->lock);
1923 write_lock_bh(&bond->curr_slave_lock); 1924 write_lock_bh(&bond->curr_slave_lock);
1924 bond_change_active_slave(bond, NULL);
1925 bond_select_active_slave(bond); 1925 bond_select_active_slave(bond);
1926 write_unlock_bh(&bond->curr_slave_lock); 1926 write_unlock_bh(&bond->curr_slave_lock);
1927 read_unlock(&bond->lock); 1927 read_unlock(&bond->lock);
1928 } else {
1929 write_unlock_bh(&bond->lock);
1928 } 1930 }
1929 slave_disable_netpoll(new_slave); 1931 slave_disable_netpoll(new_slave);
1930 1932
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index 2fb279a63c50..155db68e13ba 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -863,6 +863,7 @@ static int __init cfspi_init_module(void)
863 driver_remove_file(&cfspi_spi_driver.driver, 863 driver_remove_file(&cfspi_spi_driver.driver,
864 &driver_attr_up_head_align); 864 &driver_attr_up_head_align);
865 err_create_up_head_align: 865 err_create_up_head_align:
866 platform_driver_unregister(&cfspi_spi_driver);
866 err_dev_register: 867 err_dev_register:
867 return result; 868 return result;
868} 869}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 466b512cda4f..b8fbe266ab68 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1044,6 +1044,7 @@ static irqreturn_t bnx2x_msix_fp_int(int irq, void *fp_cookie)
1044 DP(NETIF_MSG_INTR, 1044 DP(NETIF_MSG_INTR,
1045 "got an MSI-X interrupt on IDX:SB [fp %d fw_sd %d igusb %d]\n", 1045 "got an MSI-X interrupt on IDX:SB [fp %d fw_sd %d igusb %d]\n",
1046 fp->index, fp->fw_sb_id, fp->igu_sb_id); 1046 fp->index, fp->fw_sb_id, fp->igu_sb_id);
1047
1047 bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, 0, IGU_INT_DISABLE, 0); 1048 bnx2x_ack_sb(bp, fp->igu_sb_id, USTORM_ID, 0, IGU_INT_DISABLE, 0);
1048 1049
1049#ifdef BNX2X_STOP_ON_ERROR 1050#ifdef BNX2X_STOP_ON_ERROR
@@ -1725,7 +1726,7 @@ static int bnx2x_req_irq(struct bnx2x *bp)
1725 return request_irq(irq, bnx2x_interrupt, flags, bp->dev->name, bp->dev); 1726 return request_irq(irq, bnx2x_interrupt, flags, bp->dev->name, bp->dev);
1726} 1727}
1727 1728
1728static int bnx2x_setup_irqs(struct bnx2x *bp) 1729int bnx2x_setup_irqs(struct bnx2x *bp)
1729{ 1730{
1730 int rc = 0; 1731 int rc = 0;
1731 if (bp->flags & USING_MSIX_FLAG && 1732 if (bp->flags & USING_MSIX_FLAG &&
@@ -2581,6 +2582,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
2581 } 2582 }
2582 } 2583 }
2583 2584
2585 bnx2x_pre_irq_nic_init(bp);
2586
2584 /* Connect to IRQs */ 2587 /* Connect to IRQs */
2585 rc = bnx2x_setup_irqs(bp); 2588 rc = bnx2x_setup_irqs(bp);
2586 if (rc) { 2589 if (rc) {
@@ -2590,11 +2593,11 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
2590 LOAD_ERROR_EXIT(bp, load_error2); 2593 LOAD_ERROR_EXIT(bp, load_error2);
2591 } 2594 }
2592 2595
2593 /* Setup NIC internals and enable interrupts */
2594 bnx2x_nic_init(bp, load_code);
2595
2596 /* Init per-function objects */ 2596 /* Init per-function objects */
2597 if (IS_PF(bp)) { 2597 if (IS_PF(bp)) {
2598 /* Setup NIC internals and enable interrupts */
2599 bnx2x_post_irq_nic_init(bp, load_code);
2600
2598 bnx2x_init_bp_objs(bp); 2601 bnx2x_init_bp_objs(bp);
2599 bnx2x_iov_nic_init(bp); 2602 bnx2x_iov_nic_init(bp);
2600 2603
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 54e1b149acb3..151675d66b0d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -295,16 +295,29 @@ void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw);
295void bnx2x_nic_init_cnic(struct bnx2x *bp); 295void bnx2x_nic_init_cnic(struct bnx2x *bp);
296 296
297/** 297/**
298 * bnx2x_nic_init - init driver internals. 298 * bnx2x_preirq_nic_init - init driver internals.
299 * 299 *
300 * @bp: driver handle 300 * @bp: driver handle
301 * 301 *
302 * Initializes: 302 * Initializes:
303 * - rings 303 * - fastpath object
304 * - fastpath rings
305 * etc.
306 */
307void bnx2x_pre_irq_nic_init(struct bnx2x *bp);
308
309/**
310 * bnx2x_postirq_nic_init - init driver internals.
311 *
312 * @bp: driver handle
313 * @load_code: COMMON, PORT or FUNCTION
314 *
315 * Initializes:
304 * - status blocks 316 * - status blocks
317 * - slowpath rings
305 * - etc. 318 * - etc.
306 */ 319 */
307void bnx2x_nic_init(struct bnx2x *bp, u32 load_code); 320void bnx2x_post_irq_nic_init(struct bnx2x *bp, u32 load_code);
308/** 321/**
309 * bnx2x_alloc_mem_cnic - allocate driver's memory for cnic. 322 * bnx2x_alloc_mem_cnic - allocate driver's memory for cnic.
310 * 323 *
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 91a0434ce1bd..a024eec94be1 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -6030,10 +6030,11 @@ void bnx2x_nic_init_cnic(struct bnx2x *bp)
6030 mmiowb(); 6030 mmiowb();
6031} 6031}
6032 6032
6033void bnx2x_nic_init(struct bnx2x *bp, u32 load_code) 6033void bnx2x_pre_irq_nic_init(struct bnx2x *bp)
6034{ 6034{
6035 int i; 6035 int i;
6036 6036
6037 /* Setup NIC internals and enable interrupts */
6037 for_each_eth_queue(bp, i) 6038 for_each_eth_queue(bp, i)
6038 bnx2x_init_eth_fp(bp, i); 6039 bnx2x_init_eth_fp(bp, i);
6039 6040
@@ -6041,19 +6042,27 @@ void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)
6041 rmb(); 6042 rmb();
6042 bnx2x_init_rx_rings(bp); 6043 bnx2x_init_rx_rings(bp);
6043 bnx2x_init_tx_rings(bp); 6044 bnx2x_init_tx_rings(bp);
6045
6044 if (IS_VF(bp)) { 6046 if (IS_VF(bp)) {
6045 bnx2x_memset_stats(bp); 6047 bnx2x_memset_stats(bp);
6046 return; 6048 return;
6047 } 6049 }
6048 6050
6049 /* Initialize MOD_ABS interrupts */ 6051 if (IS_PF(bp)) {
6050 bnx2x_init_mod_abs_int(bp, &bp->link_vars, bp->common.chip_id, 6052 /* Initialize MOD_ABS interrupts */
6051 bp->common.shmem_base, bp->common.shmem2_base, 6053 bnx2x_init_mod_abs_int(bp, &bp->link_vars, bp->common.chip_id,
6052 BP_PORT(bp)); 6054 bp->common.shmem_base,
6055 bp->common.shmem2_base, BP_PORT(bp));
6056
6057 /* initialize the default status block and sp ring */
6058 bnx2x_init_def_sb(bp);
6059 bnx2x_update_dsb_idx(bp);
6060 bnx2x_init_sp_ring(bp);
6061 }
6062}
6053 6063
6054 bnx2x_init_def_sb(bp); 6064void bnx2x_post_irq_nic_init(struct bnx2x *bp, u32 load_code)
6055 bnx2x_update_dsb_idx(bp); 6065{
6056 bnx2x_init_sp_ring(bp);
6057 bnx2x_init_eq_ring(bp); 6066 bnx2x_init_eq_ring(bp);
6058 bnx2x_init_internal(bp, load_code); 6067 bnx2x_init_internal(bp, load_code);
6059 bnx2x_pf_init(bp); 6068 bnx2x_pf_init(bp);
@@ -6071,12 +6080,7 @@ void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)
6071 AEU_INPUTS_ATTN_BITS_SPIO5); 6080 AEU_INPUTS_ATTN_BITS_SPIO5);
6072} 6081}
6073 6082
6074/* end of nic init */ 6083/* gzip service functions */
6075
6076/*
6077 * gzip service functions
6078 */
6079
6080static int bnx2x_gunzip_init(struct bnx2x *bp) 6084static int bnx2x_gunzip_init(struct bnx2x *bp)
6081{ 6085{
6082 bp->gunzip_buf = dma_alloc_coherent(&bp->pdev->dev, FW_BUF_SIZE, 6086 bp->gunzip_buf = dma_alloc_coherent(&bp->pdev->dev, FW_BUF_SIZE,
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 9045903dcda3..234ce6f07544 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -329,6 +329,7 @@ enum vf_state {
329#define BE_FLAGS_WORKER_SCHEDULED (1 << 3) 329#define BE_FLAGS_WORKER_SCHEDULED (1 << 3)
330#define BE_UC_PMAC_COUNT 30 330#define BE_UC_PMAC_COUNT 30
331#define BE_VF_UC_PMAC_COUNT 2 331#define BE_VF_UC_PMAC_COUNT 2
332#define BE_FLAGS_QNQ_ASYNC_EVT_RCVD (1 << 11)
332 333
333struct phy_info { 334struct phy_info {
334 u8 transceiver; 335 u8 transceiver;
@@ -436,6 +437,7 @@ struct be_adapter {
436 bool wol; 437 bool wol;
437 u32 uc_macs; /* Count of secondary UC MAC programmed */ 438 u32 uc_macs; /* Count of secondary UC MAC programmed */
438 u16 asic_rev; 439 u16 asic_rev;
440 u16 qnq_vid;
439 u32 msg_enable; 441 u32 msg_enable;
440 int be_get_temp_freq; 442 int be_get_temp_freq;
441 u16 max_mcast_mac; 443 u16 max_mcast_mac;
@@ -651,6 +653,11 @@ static inline bool be_is_wol_excluded(struct be_adapter *adapter)
651 } 653 }
652} 654}
653 655
656static inline int qnq_async_evt_rcvd(struct be_adapter *adapter)
657{
658 return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD;
659}
660
654extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, 661extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
655 u16 num_popped); 662 u16 num_popped);
656extern void be_link_status_update(struct be_adapter *adapter, u8 link_status); 663extern void be_link_status_update(struct be_adapter *adapter, u8 link_status);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 9080c2775e9f..25d3290b8cac 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -263,6 +263,27 @@ static void be_async_grp5_evt_process(struct be_adapter *adapter,
263 } 263 }
264} 264}
265 265
266static void be_async_dbg_evt_process(struct be_adapter *adapter,
267 u32 trailer, struct be_mcc_compl *cmp)
268{
269 u8 event_type = 0;
270 struct be_async_event_qnq *evt = (struct be_async_event_qnq *) cmp;
271
272 event_type = (trailer >> ASYNC_TRAILER_EVENT_TYPE_SHIFT) &
273 ASYNC_TRAILER_EVENT_TYPE_MASK;
274
275 switch (event_type) {
276 case ASYNC_DEBUG_EVENT_TYPE_QNQ:
277 if (evt->valid)
278 adapter->qnq_vid = le16_to_cpu(evt->vlan_tag);
279 adapter->flags |= BE_FLAGS_QNQ_ASYNC_EVT_RCVD;
280 break;
281 default:
282 dev_warn(&adapter->pdev->dev, "Unknown debug event\n");
283 break;
284 }
285}
286
266static inline bool is_link_state_evt(u32 trailer) 287static inline bool is_link_state_evt(u32 trailer)
267{ 288{
268 return ((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) & 289 return ((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
@@ -277,6 +298,13 @@ static inline bool is_grp5_evt(u32 trailer)
277 ASYNC_EVENT_CODE_GRP_5); 298 ASYNC_EVENT_CODE_GRP_5);
278} 299}
279 300
301static inline bool is_dbg_evt(u32 trailer)
302{
303 return (((trailer >> ASYNC_TRAILER_EVENT_CODE_SHIFT) &
304 ASYNC_TRAILER_EVENT_CODE_MASK) ==
305 ASYNC_EVENT_CODE_QNQ);
306}
307
280static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter) 308static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter)
281{ 309{
282 struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq; 310 struct be_queue_info *mcc_cq = &adapter->mcc_obj.cq;
@@ -325,6 +353,9 @@ int be_process_mcc(struct be_adapter *adapter)
325 else if (is_grp5_evt(compl->flags)) 353 else if (is_grp5_evt(compl->flags))
326 be_async_grp5_evt_process(adapter, 354 be_async_grp5_evt_process(adapter,
327 compl->flags, compl); 355 compl->flags, compl);
356 else if (is_dbg_evt(compl->flags))
357 be_async_dbg_evt_process(adapter,
358 compl->flags, compl);
328 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { 359 } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) {
329 status = be_mcc_compl_process(adapter, compl); 360 status = be_mcc_compl_process(adapter, compl);
330 atomic_dec(&mcc_obj->q.used); 361 atomic_dec(&mcc_obj->q.used);
@@ -1020,6 +1051,7 @@ int be_cmd_mccq_ext_create(struct be_adapter *adapter,
1020 1051
1021 /* Subscribe to Link State and Group 5 Events(bits 1 and 5 set) */ 1052 /* Subscribe to Link State and Group 5 Events(bits 1 and 5 set) */
1022 req->async_event_bitmap[0] = cpu_to_le32(0x00000022); 1053 req->async_event_bitmap[0] = cpu_to_le32(0x00000022);
1054 req->async_event_bitmap[0] |= cpu_to_le32(1 << ASYNC_EVENT_CODE_QNQ);
1023 be_dws_cpu_to_le(ctxt, sizeof(req->context)); 1055 be_dws_cpu_to_le(ctxt, sizeof(req->context));
1024 1056
1025 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); 1057 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
@@ -2457,6 +2489,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
2457 struct mgmt_controller_attrib *attribs; 2489 struct mgmt_controller_attrib *attribs;
2458 struct be_dma_mem attribs_cmd; 2490 struct be_dma_mem attribs_cmd;
2459 2491
2492 if (mutex_lock_interruptible(&adapter->mbox_lock))
2493 return -1;
2494
2460 memset(&attribs_cmd, 0, sizeof(struct be_dma_mem)); 2495 memset(&attribs_cmd, 0, sizeof(struct be_dma_mem));
2461 attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs); 2496 attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs);
2462 attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size, 2497 attribs_cmd.va = pci_alloc_consistent(adapter->pdev, attribs_cmd.size,
@@ -2464,12 +2499,10 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
2464 if (!attribs_cmd.va) { 2499 if (!attribs_cmd.va) {
2465 dev_err(&adapter->pdev->dev, 2500 dev_err(&adapter->pdev->dev,
2466 "Memory allocation failure\n"); 2501 "Memory allocation failure\n");
2467 return -ENOMEM; 2502 status = -ENOMEM;
2503 goto err;
2468 } 2504 }
2469 2505
2470 if (mutex_lock_interruptible(&adapter->mbox_lock))
2471 return -1;
2472
2473 wrb = wrb_from_mbox(adapter); 2506 wrb = wrb_from_mbox(adapter);
2474 if (!wrb) { 2507 if (!wrb) {
2475 status = -EBUSY; 2508 status = -EBUSY;
@@ -2489,8 +2522,9 @@ int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
2489 2522
2490err: 2523err:
2491 mutex_unlock(&adapter->mbox_lock); 2524 mutex_unlock(&adapter->mbox_lock);
2492 pci_free_consistent(adapter->pdev, attribs_cmd.size, attribs_cmd.va, 2525 if (attribs_cmd.va)
2493 attribs_cmd.dma); 2526 pci_free_consistent(adapter->pdev, attribs_cmd.size,
2527 attribs_cmd.va, attribs_cmd.dma);
2494 return status; 2528 return status;
2495} 2529}
2496 2530
@@ -2788,6 +2822,9 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
2788 CMD_SUBSYSTEM_ETH)) 2822 CMD_SUBSYSTEM_ETH))
2789 return -EPERM; 2823 return -EPERM;
2790 2824
2825 if (mutex_lock_interruptible(&adapter->mbox_lock))
2826 return -1;
2827
2791 memset(&cmd, 0, sizeof(struct be_dma_mem)); 2828 memset(&cmd, 0, sizeof(struct be_dma_mem));
2792 cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1); 2829 cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1);
2793 cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, 2830 cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size,
@@ -2795,12 +2832,10 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
2795 if (!cmd.va) { 2832 if (!cmd.va) {
2796 dev_err(&adapter->pdev->dev, 2833 dev_err(&adapter->pdev->dev,
2797 "Memory allocation failure\n"); 2834 "Memory allocation failure\n");
2798 return -ENOMEM; 2835 status = -ENOMEM;
2836 goto err;
2799 } 2837 }
2800 2838
2801 if (mutex_lock_interruptible(&adapter->mbox_lock))
2802 return -1;
2803
2804 wrb = wrb_from_mbox(adapter); 2839 wrb = wrb_from_mbox(adapter);
2805 if (!wrb) { 2840 if (!wrb) {
2806 status = -EBUSY; 2841 status = -EBUSY;
@@ -2831,7 +2866,8 @@ int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
2831 } 2866 }
2832err: 2867err:
2833 mutex_unlock(&adapter->mbox_lock); 2868 mutex_unlock(&adapter->mbox_lock);
2834 pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma); 2869 if (cmd.va)
2870 pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
2835 return status; 2871 return status;
2836 2872
2837} 2873}
@@ -2964,16 +3000,18 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
2964 int status; 3000 int status;
2965 struct be_dma_mem cmd; 3001 struct be_dma_mem cmd;
2966 3002
3003 if (mutex_lock_interruptible(&adapter->mbox_lock))
3004 return -1;
3005
2967 memset(&cmd, 0, sizeof(struct be_dma_mem)); 3006 memset(&cmd, 0, sizeof(struct be_dma_mem));
2968 cmd.size = sizeof(struct be_cmd_resp_get_func_config); 3007 cmd.size = sizeof(struct be_cmd_resp_get_func_config);
2969 cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, 3008 cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size,
2970 &cmd.dma); 3009 &cmd.dma);
2971 if (!cmd.va) { 3010 if (!cmd.va) {
2972 dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); 3011 dev_err(&adapter->pdev->dev, "Memory alloc failure\n");
2973 return -ENOMEM; 3012 status = -ENOMEM;
3013 goto err;
2974 } 3014 }
2975 if (mutex_lock_interruptible(&adapter->mbox_lock))
2976 return -1;
2977 3015
2978 wrb = wrb_from_mbox(adapter); 3016 wrb = wrb_from_mbox(adapter);
2979 if (!wrb) { 3017 if (!wrb) {
@@ -3016,8 +3054,8 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
3016 } 3054 }
3017err: 3055err:
3018 mutex_unlock(&adapter->mbox_lock); 3056 mutex_unlock(&adapter->mbox_lock);
3019 pci_free_consistent(adapter->pdev, cmd.size, 3057 if (cmd.va)
3020 cmd.va, cmd.dma); 3058 pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
3021 return status; 3059 return status;
3022} 3060}
3023 3061
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 1b01e9b32794..a855668e0cc5 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -84,6 +84,9 @@ struct be_mcc_compl {
84#define ASYNC_EVENT_QOS_SPEED 0x1 84#define ASYNC_EVENT_QOS_SPEED 0x1
85#define ASYNC_EVENT_COS_PRIORITY 0x2 85#define ASYNC_EVENT_COS_PRIORITY 0x2
86#define ASYNC_EVENT_PVID_STATE 0x3 86#define ASYNC_EVENT_PVID_STATE 0x3
87#define ASYNC_EVENT_CODE_QNQ 0x6
88#define ASYNC_DEBUG_EVENT_TYPE_QNQ 1
89
87struct be_async_event_trailer { 90struct be_async_event_trailer {
88 u32 code; 91 u32 code;
89}; 92};
@@ -144,6 +147,16 @@ struct be_async_event_grp5_pvid_state {
144 struct be_async_event_trailer trailer; 147 struct be_async_event_trailer trailer;
145} __packed; 148} __packed;
146 149
150/* async event indicating outer VLAN tag in QnQ */
151struct be_async_event_qnq {
152 u8 valid; /* Indicates if outer VLAN is valid */
153 u8 rsvd0;
154 u16 vlan_tag;
155 u32 event_tag;
156 u8 rsvd1[4];
157 struct be_async_event_trailer trailer;
158} __packed;
159
147struct be_mcc_mailbox { 160struct be_mcc_mailbox {
148 struct be_mcc_wrb wrb; 161 struct be_mcc_wrb wrb;
149 struct be_mcc_compl compl; 162 struct be_mcc_compl compl;
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index ec3050b3133e..5733cde88e2c 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -680,7 +680,8 @@ be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
680 680
681 if (be_is_wol_supported(adapter)) { 681 if (be_is_wol_supported(adapter)) {
682 wol->supported |= WAKE_MAGIC; 682 wol->supported |= WAKE_MAGIC;
683 wol->wolopts |= WAKE_MAGIC; 683 if (adapter->wol)
684 wol->wolopts |= WAKE_MAGIC;
684 } else 685 } else
685 wol->wolopts = 0; 686 wol->wolopts = 0;
686 memset(&wol->sopass, 0, sizeof(wol->sopass)); 687 memset(&wol->sopass, 0, sizeof(wol->sopass));
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 1c734915933f..4babc8a4a543 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -639,13 +639,8 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter *adapter,
639 return vlan_tag; 639 return vlan_tag;
640} 640}
641 641
642static int be_vlan_tag_chk(struct be_adapter *adapter, struct sk_buff *skb)
643{
644 return vlan_tx_tag_present(skb) || adapter->pvid;
645}
646
647static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr, 642static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr,
648 struct sk_buff *skb, u32 wrb_cnt, u32 len) 643 struct sk_buff *skb, u32 wrb_cnt, u32 len, bool skip_hw_vlan)
649{ 644{
650 u16 vlan_tag; 645 u16 vlan_tag;
651 646
@@ -672,8 +667,9 @@ static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr,
672 AMAP_SET_BITS(struct amap_eth_hdr_wrb, vlan_tag, hdr, vlan_tag); 667 AMAP_SET_BITS(struct amap_eth_hdr_wrb, vlan_tag, hdr, vlan_tag);
673 } 668 }
674 669
670 /* To skip HW VLAN tagging: evt = 1, compl = 0 */
671 AMAP_SET_BITS(struct amap_eth_hdr_wrb, complete, hdr, !skip_hw_vlan);
675 AMAP_SET_BITS(struct amap_eth_hdr_wrb, event, hdr, 1); 672 AMAP_SET_BITS(struct amap_eth_hdr_wrb, event, hdr, 1);
676 AMAP_SET_BITS(struct amap_eth_hdr_wrb, complete, hdr, 1);
677 AMAP_SET_BITS(struct amap_eth_hdr_wrb, num_wrb, hdr, wrb_cnt); 673 AMAP_SET_BITS(struct amap_eth_hdr_wrb, num_wrb, hdr, wrb_cnt);
678 AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len); 674 AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len);
679} 675}
@@ -696,7 +692,8 @@ static void unmap_tx_frag(struct device *dev, struct be_eth_wrb *wrb,
696} 692}
697 693
698static int make_tx_wrbs(struct be_adapter *adapter, struct be_queue_info *txq, 694static int make_tx_wrbs(struct be_adapter *adapter, struct be_queue_info *txq,
699 struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb) 695 struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb,
696 bool skip_hw_vlan)
700{ 697{
701 dma_addr_t busaddr; 698 dma_addr_t busaddr;
702 int i, copied = 0; 699 int i, copied = 0;
@@ -745,7 +742,7 @@ static int make_tx_wrbs(struct be_adapter *adapter, struct be_queue_info *txq,
745 queue_head_inc(txq); 742 queue_head_inc(txq);
746 } 743 }
747 744
748 wrb_fill_hdr(adapter, hdr, first_skb, wrb_cnt, copied); 745 wrb_fill_hdr(adapter, hdr, first_skb, wrb_cnt, copied, skip_hw_vlan);
749 be_dws_cpu_to_le(hdr, sizeof(*hdr)); 746 be_dws_cpu_to_le(hdr, sizeof(*hdr));
750 747
751 return copied; 748 return copied;
@@ -762,7 +759,8 @@ dma_err:
762} 759}
763 760
764static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter, 761static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
765 struct sk_buff *skb) 762 struct sk_buff *skb,
763 bool *skip_hw_vlan)
766{ 764{
767 u16 vlan_tag = 0; 765 u16 vlan_tag = 0;
768 766
@@ -777,9 +775,67 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
777 skb->vlan_tci = 0; 775 skb->vlan_tci = 0;
778 } 776 }
779 777
778 if (qnq_async_evt_rcvd(adapter) && adapter->pvid) {
779 if (!vlan_tag)
780 vlan_tag = adapter->pvid;
781 if (skip_hw_vlan)
782 *skip_hw_vlan = true;
783 }
784
785 if (vlan_tag) {
786 skb = __vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
787 if (unlikely(!skb))
788 return skb;
789
790 skb->vlan_tci = 0;
791 }
792
793 /* Insert the outer VLAN, if any */
794 if (adapter->qnq_vid) {
795 vlan_tag = adapter->qnq_vid;
796 skb = __vlan_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
797 if (unlikely(!skb))
798 return skb;
799 if (skip_hw_vlan)
800 *skip_hw_vlan = true;
801 }
802
780 return skb; 803 return skb;
781} 804}
782 805
806static bool be_ipv6_exthdr_check(struct sk_buff *skb)
807{
808 struct ethhdr *eh = (struct ethhdr *)skb->data;
809 u16 offset = ETH_HLEN;
810
811 if (eh->h_proto == htons(ETH_P_IPV6)) {
812 struct ipv6hdr *ip6h = (struct ipv6hdr *)(skb->data + offset);
813
814 offset += sizeof(struct ipv6hdr);
815 if (ip6h->nexthdr != NEXTHDR_TCP &&
816 ip6h->nexthdr != NEXTHDR_UDP) {
817 struct ipv6_opt_hdr *ehdr =
818 (struct ipv6_opt_hdr *) (skb->data + offset);
819
820 /* offending pkt: 2nd byte following IPv6 hdr is 0xff */
821 if (ehdr->hdrlen == 0xff)
822 return true;
823 }
824 }
825 return false;
826}
827
828static int be_vlan_tag_tx_chk(struct be_adapter *adapter, struct sk_buff *skb)
829{
830 return vlan_tx_tag_present(skb) || adapter->pvid || adapter->qnq_vid;
831}
832
833static int be_ipv6_tx_stall_chk(struct be_adapter *adapter, struct sk_buff *skb)
834{
835 return BE3_chip(adapter) &&
836 be_ipv6_exthdr_check(skb);
837}
838
783static netdev_tx_t be_xmit(struct sk_buff *skb, 839static netdev_tx_t be_xmit(struct sk_buff *skb,
784 struct net_device *netdev) 840 struct net_device *netdev)
785{ 841{
@@ -790,33 +846,64 @@ static netdev_tx_t be_xmit(struct sk_buff *skb,
790 u32 wrb_cnt = 0, copied = 0; 846 u32 wrb_cnt = 0, copied = 0;
791 u32 start = txq->head, eth_hdr_len; 847 u32 start = txq->head, eth_hdr_len;
792 bool dummy_wrb, stopped = false; 848 bool dummy_wrb, stopped = false;
849 bool skip_hw_vlan = false;
850 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
793 851
794 eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ? 852 eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ?
795 VLAN_ETH_HLEN : ETH_HLEN; 853 VLAN_ETH_HLEN : ETH_HLEN;
796 854
797 /* HW has a bug which considers padding bytes as legal 855 /* For padded packets, BE HW modifies tot_len field in IP header
798 * and modifies the IPv4 hdr's 'tot_len' field 856 * incorrecly when VLAN tag is inserted by HW.
799 */ 857 */
800 if (skb->len <= 60 && be_vlan_tag_chk(adapter, skb) && 858 if (skb->len <= 60 && vlan_tx_tag_present(skb) && is_ipv4_pkt(skb)) {
801 is_ipv4_pkt(skb)) {
802 ip = (struct iphdr *)ip_hdr(skb); 859 ip = (struct iphdr *)ip_hdr(skb);
803 pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len)); 860 pskb_trim(skb, eth_hdr_len + ntohs(ip->tot_len));
804 } 861 }
805 862
863 /* If vlan tag is already inlined in the packet, skip HW VLAN
864 * tagging in UMC mode
865 */
866 if ((adapter->function_mode & UMC_ENABLED) &&
867 veh->h_vlan_proto == htons(ETH_P_8021Q))
868 skip_hw_vlan = true;
869
806 /* HW has a bug wherein it will calculate CSUM for VLAN 870 /* HW has a bug wherein it will calculate CSUM for VLAN
807 * pkts even though it is disabled. 871 * pkts even though it is disabled.
808 * Manually insert VLAN in pkt. 872 * Manually insert VLAN in pkt.
809 */ 873 */
810 if (skb->ip_summed != CHECKSUM_PARTIAL && 874 if (skb->ip_summed != CHECKSUM_PARTIAL &&
811 be_vlan_tag_chk(adapter, skb)) { 875 vlan_tx_tag_present(skb)) {
812 skb = be_insert_vlan_in_pkt(adapter, skb); 876 skb = be_insert_vlan_in_pkt(adapter, skb, &skip_hw_vlan);
877 if (unlikely(!skb))
878 goto tx_drop;
879 }
880
881 /* HW may lockup when VLAN HW tagging is requested on
882 * certain ipv6 packets. Drop such pkts if the HW workaround to
883 * skip HW tagging is not enabled by FW.
884 */
885 if (unlikely(be_ipv6_tx_stall_chk(adapter, skb) &&
886 (adapter->pvid || adapter->qnq_vid) &&
887 !qnq_async_evt_rcvd(adapter)))
888 goto tx_drop;
889
890 /* Manual VLAN tag insertion to prevent:
891 * ASIC lockup when the ASIC inserts VLAN tag into
892 * certain ipv6 packets. Insert VLAN tags in driver,
893 * and set event, completion, vlan bits accordingly
894 * in the Tx WRB.
895 */
896 if (be_ipv6_tx_stall_chk(adapter, skb) &&
897 be_vlan_tag_tx_chk(adapter, skb)) {
898 skb = be_insert_vlan_in_pkt(adapter, skb, &skip_hw_vlan);
813 if (unlikely(!skb)) 899 if (unlikely(!skb))
814 goto tx_drop; 900 goto tx_drop;
815 } 901 }
816 902
817 wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb); 903 wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb);
818 904
819 copied = make_tx_wrbs(adapter, txq, skb, wrb_cnt, dummy_wrb); 905 copied = make_tx_wrbs(adapter, txq, skb, wrb_cnt, dummy_wrb,
906 skip_hw_vlan);
820 if (copied) { 907 if (copied) {
821 int gso_segs = skb_shinfo(skb)->gso_segs; 908 int gso_segs = skb_shinfo(skb)->gso_segs;
822 909
diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index fe8e9e5cfb2b..576e4b858fce 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -130,7 +130,6 @@ struct gianfar_ptp_registers {
130 130
131#define DRIVER "gianfar_ptp" 131#define DRIVER "gianfar_ptp"
132#define DEFAULT_CKSEL 1 132#define DEFAULT_CKSEL 1
133#define N_ALARM 1 /* first alarm is used internally to reset fipers */
134#define N_EXT_TS 2 133#define N_EXT_TS 2
135#define REG_SIZE sizeof(struct gianfar_ptp_registers) 134#define REG_SIZE sizeof(struct gianfar_ptp_registers)
136 135
@@ -413,7 +412,7 @@ static struct ptp_clock_info ptp_gianfar_caps = {
413 .owner = THIS_MODULE, 412 .owner = THIS_MODULE,
414 .name = "gianfar clock", 413 .name = "gianfar clock",
415 .max_adj = 512000, 414 .max_adj = 512000,
416 .n_alarm = N_ALARM, 415 .n_alarm = 0,
417 .n_ext_ts = N_EXT_TS, 416 .n_ext_ts = N_EXT_TS,
418 .n_per_out = 0, 417 .n_per_out = 0,
419 .pps = 1, 418 .pps = 1,
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index c6dac38fd9cc..79c520b64fdd 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -5896,6 +5896,14 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
5896 goto err_stop_0; 5896 goto err_stop_0;
5897 } 5897 }
5898 5898
5899 /* 8168evl does not automatically pad to minimum length. */
5900 if (unlikely(tp->mac_version == RTL_GIGA_MAC_VER_34 &&
5901 skb->len < ETH_ZLEN)) {
5902 if (skb_padto(skb, ETH_ZLEN))
5903 goto err_update_stats;
5904 skb_put(skb, ETH_ZLEN - skb->len);
5905 }
5906
5899 if (unlikely(le32_to_cpu(txd->opts1) & DescOwn)) 5907 if (unlikely(le32_to_cpu(txd->opts1) & DescOwn))
5900 goto err_stop_0; 5908 goto err_stop_0;
5901 5909
@@ -5967,6 +5975,7 @@ err_dma_1:
5967 rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd); 5975 rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd);
5968err_dma_0: 5976err_dma_0:
5969 dev_kfree_skb(skb); 5977 dev_kfree_skb(skb);
5978err_update_stats:
5970 dev->stats.tx_dropped++; 5979 dev->stats.tx_dropped++;
5971 return NETDEV_TX_OK; 5980 return NETDEV_TX_OK;
5972 5981
diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index 0095ce95150b..97dd8f18c001 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -667,7 +667,7 @@ fail:
667int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 667int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
668 u16 *fw_subtype_list, u32 *capabilities) 668 u16 *fw_subtype_list, u32 *capabilities)
669{ 669{
670 uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMIN]; 670 uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMAX];
671 size_t outlen, offset, i; 671 size_t outlen, offset, i;
672 int port_num = efx_port_num(efx); 672 int port_num = efx_port_num(efx);
673 int rc; 673 int rc;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 66109a2ad886..f042b0373e5d 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1471,14 +1471,17 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
1471 if (!tun) 1471 if (!tun)
1472 return -EBADFD; 1472 return -EBADFD;
1473 1473
1474 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) 1474 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
1475 return -EINVAL; 1475 ret = -EINVAL;
1476 goto out;
1477 }
1476 ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len, 1478 ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len,
1477 flags & MSG_DONTWAIT); 1479 flags & MSG_DONTWAIT);
1478 if (ret > total_len) { 1480 if (ret > total_len) {
1479 m->msg_flags |= MSG_TRUNC; 1481 m->msg_flags |= MSG_TRUNC;
1480 ret = flags & MSG_TRUNC ? ret : total_len; 1482 ret = flags & MSG_TRUNC ? ret : total_len;
1481 } 1483 }
1484out:
1482 tun_put(tun); 1485 tun_put(tun);
1483 return ret; 1486 return ret;
1484} 1487}
@@ -1593,8 +1596,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1593 return err; 1596 return err;
1594 1597
1595 if (tun->flags & TUN_TAP_MQ && 1598 if (tun->flags & TUN_TAP_MQ &&
1596 (tun->numqueues + tun->numdisabled > 1)) 1599 (tun->numqueues + tun->numdisabled > 1)) {
1597 return -EBUSY; 1600 /* One or more queue has already been attached, no need
1601 * to initialize the device again.
1602 */
1603 return 0;
1604 }
1598 } 1605 }
1599 else { 1606 else {
1600 char *name; 1607 char *name;
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 4a141e3cf076..ef12839a7cfe 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1253,7 +1253,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
1253 goto out; 1253 goto out;
1254 1254
1255 *uaddr_len = sizeof(struct sockaddr_at); 1255 *uaddr_len = sizeof(struct sockaddr_at);
1256 memset(&sat.sat_zero, 0, sizeof(sat.sat_zero)); 1256 memset(&sat, 0, sizeof(sat));
1257 1257
1258 if (peer) { 1258 if (peer) {
1259 err = -ENOTCONN; 1259 err = -ENOTCONN;
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 2f1f88923df8..b27a4d792d15 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -939,7 +939,7 @@ out:
939} 939}
940 940
941static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, 941static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
942 struct sk_buff *skb) { 942 struct sk_buff *skb, int hdr_len) {
943 uint8_t curr_ttvn, old_ttvn; 943 uint8_t curr_ttvn, old_ttvn;
944 struct batadv_orig_node *orig_node; 944 struct batadv_orig_node *orig_node;
945 struct ethhdr *ethhdr; 945 struct ethhdr *ethhdr;
@@ -948,7 +948,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
948 int is_old_ttvn; 948 int is_old_ttvn;
949 949
950 /* check if there is enough data before accessing it */ 950 /* check if there is enough data before accessing it */
951 if (pskb_may_pull(skb, sizeof(*unicast_packet) + ETH_HLEN) < 0) 951 if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0)
952 return 0; 952 return 0;
953 953
954 /* create a copy of the skb (in case of for re-routing) to modify it. */ 954 /* create a copy of the skb (in case of for re-routing) to modify it. */
@@ -956,7 +956,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
956 return 0; 956 return 0;
957 957
958 unicast_packet = (struct batadv_unicast_packet *)skb->data; 958 unicast_packet = (struct batadv_unicast_packet *)skb->data;
959 ethhdr = (struct ethhdr *)(skb->data + sizeof(*unicast_packet)); 959 ethhdr = (struct ethhdr *)(skb->data + hdr_len);
960 960
961 /* check if the destination client was served by this node and it is now 961 /* check if the destination client was served by this node and it is now
962 * roaming. In this case, it means that the node has got a ROAM_ADV 962 * roaming. In this case, it means that the node has got a ROAM_ADV
@@ -1072,8 +1072,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
1072 1072
1073 if (check < 0) 1073 if (check < 0)
1074 return NET_RX_DROP; 1074 return NET_RX_DROP;
1075 1075 if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
1076 if (!batadv_check_unicast_ttvn(bat_priv, skb))
1077 return NET_RX_DROP; 1076 return NET_RX_DROP;
1078 1077
1079 /* packet for me */ 1078 /* packet for me */
@@ -1117,7 +1116,7 @@ int batadv_recv_ucast_frag_packet(struct sk_buff *skb,
1117 if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0) 1116 if (batadv_check_unicast_packet(bat_priv, skb, hdr_size) < 0)
1118 return NET_RX_DROP; 1117 return NET_RX_DROP;
1119 1118
1120 if (!batadv_check_unicast_ttvn(bat_priv, skb)) 1119 if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
1121 return NET_RX_DROP; 1120 return NET_RX_DROP;
1122 1121
1123 unicast_packet = (struct batadv_unicast_frag_packet *)skb->data; 1122 unicast_packet = (struct batadv_unicast_frag_packet *)skb->data;
diff --git a/net/core/datagram.c b/net/core/datagram.c
index ebba65d7e0da..b71423db7785 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -78,9 +78,10 @@ static int receiver_wake_function(wait_queue_t *wait, unsigned int mode, int syn
78 return autoremove_wake_function(wait, mode, sync, key); 78 return autoremove_wake_function(wait, mode, sync, key);
79} 79}
80/* 80/*
81 * Wait for a packet.. 81 * Wait for the last received packet to be different from skb
82 */ 82 */
83static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) 83static int wait_for_more_packets(struct sock *sk, int *err, long *timeo_p,
84 const struct sk_buff *skb)
84{ 85{
85 int error; 86 int error;
86 DEFINE_WAIT_FUNC(wait, receiver_wake_function); 87 DEFINE_WAIT_FUNC(wait, receiver_wake_function);
@@ -92,7 +93,7 @@ static int wait_for_packet(struct sock *sk, int *err, long *timeo_p)
92 if (error) 93 if (error)
93 goto out_err; 94 goto out_err;
94 95
95 if (!skb_queue_empty(&sk->sk_receive_queue)) 96 if (sk->sk_receive_queue.prev != skb)
96 goto out; 97 goto out;
97 98
98 /* Socket shut down? */ 99 /* Socket shut down? */
@@ -131,9 +132,9 @@ out_noerr:
131 * __skb_recv_datagram - Receive a datagram skbuff 132 * __skb_recv_datagram - Receive a datagram skbuff
132 * @sk: socket 133 * @sk: socket
133 * @flags: MSG_ flags 134 * @flags: MSG_ flags
135 * @peeked: returns non-zero if this packet has been seen before
134 * @off: an offset in bytes to peek skb from. Returns an offset 136 * @off: an offset in bytes to peek skb from. Returns an offset
135 * within an skb where data actually starts 137 * within an skb where data actually starts
136 * @peeked: returns non-zero if this packet has been seen before
137 * @err: error code returned 138 * @err: error code returned
138 * 139 *
139 * Get a datagram skbuff, understands the peeking, nonblocking wakeups 140 * Get a datagram skbuff, understands the peeking, nonblocking wakeups
@@ -161,7 +162,7 @@ out_noerr:
161struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags, 162struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
162 int *peeked, int *off, int *err) 163 int *peeked, int *off, int *err)
163{ 164{
164 struct sk_buff *skb; 165 struct sk_buff *skb, *last;
165 long timeo; 166 long timeo;
166 /* 167 /*
167 * Caller is allowed not to check sk->sk_err before skb_recv_datagram() 168 * Caller is allowed not to check sk->sk_err before skb_recv_datagram()
@@ -182,13 +183,17 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
182 */ 183 */
183 unsigned long cpu_flags; 184 unsigned long cpu_flags;
184 struct sk_buff_head *queue = &sk->sk_receive_queue; 185 struct sk_buff_head *queue = &sk->sk_receive_queue;
186 int _off = *off;
185 187
188 last = (struct sk_buff *)queue;
186 spin_lock_irqsave(&queue->lock, cpu_flags); 189 spin_lock_irqsave(&queue->lock, cpu_flags);
187 skb_queue_walk(queue, skb) { 190 skb_queue_walk(queue, skb) {
191 last = skb;
188 *peeked = skb->peeked; 192 *peeked = skb->peeked;
189 if (flags & MSG_PEEK) { 193 if (flags & MSG_PEEK) {
190 if (*off >= skb->len && skb->len) { 194 if (_off >= skb->len && (skb->len || _off ||
191 *off -= skb->len; 195 skb->peeked)) {
196 _off -= skb->len;
192 continue; 197 continue;
193 } 198 }
194 skb->peeked = 1; 199 skb->peeked = 1;
@@ -197,6 +202,7 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
197 __skb_unlink(skb, queue); 202 __skb_unlink(skb, queue);
198 203
199 spin_unlock_irqrestore(&queue->lock, cpu_flags); 204 spin_unlock_irqrestore(&queue->lock, cpu_flags);
205 *off = _off;
200 return skb; 206 return skb;
201 } 207 }
202 spin_unlock_irqrestore(&queue->lock, cpu_flags); 208 spin_unlock_irqrestore(&queue->lock, cpu_flags);
@@ -206,7 +212,7 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags,
206 if (!timeo) 212 if (!timeo)
207 goto no_packet; 213 goto no_packet;
208 214
209 } while (!wait_for_packet(sk, err, &timeo)); 215 } while (!wait_for_more_packets(sk, err, &timeo, last));
210 216
211 return NULL; 217 return NULL;
212 218
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 8ea975164596..d979657b8a12 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1927,6 +1927,7 @@ bool tcp_prequeue(struct sock *sk, struct sk_buff *skb)
1927 skb_queue_len(&tp->ucopy.prequeue) == 0) 1927 skb_queue_len(&tp->ucopy.prequeue) == 0)
1928 return false; 1928 return false;
1929 1929
1930 skb_dst_force(skb);
1930 __skb_queue_tail(&tp->ucopy.prequeue, skb); 1931 __skb_queue_tail(&tp->ucopy.prequeue, skb);
1931 tp->ucopy.memory += skb->truesize; 1932 tp->ucopy.memory += skb->truesize;
1932 if (tp->ucopy.memory > sk->sk_rcvbuf) { 1933 if (tp->ucopy.memory > sk->sk_rcvbuf) {
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 5c9e021994ba..d48422e27110 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -88,7 +88,7 @@ struct mac802154_sub_if_data {
88 88
89#define mac802154_to_priv(_hw) container_of(_hw, struct mac802154_priv, hw) 89#define mac802154_to_priv(_hw) container_of(_hw, struct mac802154_priv, hw)
90 90
91#define MAC802154_CHAN_NONE (~(u8)0) /* No channel is assigned */ 91#define MAC802154_CHAN_NONE 0xff /* No channel is assigned */
92 92
93extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced; 93extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
94extern struct ieee802154_mlme_ops mac802154_mlme_wpan; 94extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c b/net/netfilter/ipvs/ip_vs_pe_sip.c
index 9a8f4213e8a6..9ef22bdce9f1 100644
--- a/net/netfilter/ipvs/ip_vs_pe_sip.c
+++ b/net/netfilter/ipvs/ip_vs_pe_sip.c
@@ -38,14 +38,10 @@ static int get_callid(const char *dptr, unsigned int dataoff,
38 if (ret > 0) 38 if (ret > 0)
39 break; 39 break;
40 if (!ret) 40 if (!ret)
41 return 0; 41 return -EINVAL;
42 dataoff += *matchoff; 42 dataoff += *matchoff;
43 } 43 }
44 44
45 /* Empty callid is useless */
46 if (!*matchlen)
47 return -EINVAL;
48
49 /* Too large is useless */ 45 /* Too large is useless */
50 if (*matchlen > IP_VS_PEDATA_MAXLEN) 46 if (*matchlen > IP_VS_PEDATA_MAXLEN)
51 return -EINVAL; 47 return -EINVAL;
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 103bd704b5fc..ec0c80fde69f 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -834,6 +834,8 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
834 struct sock *sk = sock->sk; 834 struct sock *sk = sock->sk;
835 struct nr_sock *nr = nr_sk(sk); 835 struct nr_sock *nr = nr_sk(sk);
836 836
837 memset(&sax->fsa_ax25, 0, sizeof(struct sockaddr_ax25));
838
837 lock_sock(sk); 839 lock_sock(sk);
838 if (peer != 0) { 840 if (peer != 0) {
839 if (sk->sk_state != TCP_ESTABLISHED) { 841 if (sk->sk_state != TCP_ESTABLISHED) {
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 38f08c31cdd8..380253eccb74 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -508,12 +508,13 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *uaddr,
508 pr_debug("%p %d %d %d\n", sk, llcp_sock->target_idx, 508 pr_debug("%p %d %d %d\n", sk, llcp_sock->target_idx,
509 llcp_sock->dsap, llcp_sock->ssap); 509 llcp_sock->dsap, llcp_sock->ssap);
510 510
511 uaddr->sa_family = AF_NFC; 511 memset(llcp_addr, 0, sizeof(*llcp_addr));
512
513 *len = sizeof(struct sockaddr_nfc_llcp); 512 *len = sizeof(struct sockaddr_nfc_llcp);
514 513
514 llcp_addr->sa_family = AF_NFC;
515 llcp_addr->dev_idx = llcp_sock->dev->idx; 515 llcp_addr->dev_idx = llcp_sock->dev->idx;
516 llcp_addr->target_idx = llcp_sock->target_idx; 516 llcp_addr->target_idx = llcp_sock->target_idx;
517 llcp_addr->nfc_protocol = llcp_sock->nfc_protocol;
517 llcp_addr->dsap = llcp_sock->dsap; 518 llcp_addr->dsap = llcp_sock->dsap;
518 llcp_addr->ssap = llcp_sock->ssap; 519 llcp_addr->ssap = llcp_sock->ssap;
519 llcp_addr->service_name_len = llcp_sock->service_name_len; 520 llcp_addr->service_name_len = llcp_sock->service_name_len;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 9efe01113c5c..826e09938bff 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1858,10 +1858,10 @@ out:
1858} 1858}
1859 1859
1860/* 1860/*
1861 * Sleep until data has arrive. But check for races.. 1861 * Sleep until more data has arrived. But check for races..
1862 */ 1862 */
1863 1863static long unix_stream_data_wait(struct sock *sk, long timeo,
1864static long unix_stream_data_wait(struct sock *sk, long timeo) 1864 struct sk_buff *last)
1865{ 1865{
1866 DEFINE_WAIT(wait); 1866 DEFINE_WAIT(wait);
1867 1867
@@ -1870,7 +1870,7 @@ static long unix_stream_data_wait(struct sock *sk, long timeo)
1870 for (;;) { 1870 for (;;) {
1871 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 1871 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
1872 1872
1873 if (!skb_queue_empty(&sk->sk_receive_queue) || 1873 if (skb_peek_tail(&sk->sk_receive_queue) != last ||
1874 sk->sk_err || 1874 sk->sk_err ||
1875 (sk->sk_shutdown & RCV_SHUTDOWN) || 1875 (sk->sk_shutdown & RCV_SHUTDOWN) ||
1876 signal_pending(current) || 1876 signal_pending(current) ||
@@ -1889,8 +1889,6 @@ static long unix_stream_data_wait(struct sock *sk, long timeo)
1889 return timeo; 1889 return timeo;
1890} 1890}
1891 1891
1892
1893
1894static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, 1892static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1895 struct msghdr *msg, size_t size, 1893 struct msghdr *msg, size_t size,
1896 int flags) 1894 int flags)
@@ -1935,14 +1933,12 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1935 goto out; 1933 goto out;
1936 } 1934 }
1937 1935
1938 skip = sk_peek_offset(sk, flags);
1939
1940 do { 1936 do {
1941 int chunk; 1937 int chunk;
1942 struct sk_buff *skb; 1938 struct sk_buff *skb, *last;
1943 1939
1944 unix_state_lock(sk); 1940 unix_state_lock(sk);
1945 skb = skb_peek(&sk->sk_receive_queue); 1941 last = skb = skb_peek(&sk->sk_receive_queue);
1946again: 1942again:
1947 if (skb == NULL) { 1943 if (skb == NULL) {
1948 unix_sk(sk)->recursion_level = 0; 1944 unix_sk(sk)->recursion_level = 0;
@@ -1965,7 +1961,7 @@ again:
1965 break; 1961 break;
1966 mutex_unlock(&u->readlock); 1962 mutex_unlock(&u->readlock);
1967 1963
1968 timeo = unix_stream_data_wait(sk, timeo); 1964 timeo = unix_stream_data_wait(sk, timeo, last);
1969 1965
1970 if (signal_pending(current) 1966 if (signal_pending(current)
1971 || mutex_lock_interruptible(&u->readlock)) { 1967 || mutex_lock_interruptible(&u->readlock)) {
@@ -1979,10 +1975,13 @@ again:
1979 break; 1975 break;
1980 } 1976 }
1981 1977
1982 if (skip >= skb->len) { 1978 skip = sk_peek_offset(sk, flags);
1979 while (skip >= skb->len) {
1983 skip -= skb->len; 1980 skip -= skb->len;
1981 last = skb;
1984 skb = skb_peek_next(skb, &sk->sk_receive_queue); 1982 skb = skb_peek_next(skb, &sk->sk_receive_queue);
1985 goto again; 1983 if (!skb)
1984 goto again;
1986 } 1985 }
1987 1986
1988 unix_state_unlock(sk); 1987 unix_state_unlock(sk);
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 7f93e2a42d7a..3f77f42a3b58 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -165,7 +165,7 @@ static struct list_head vsock_bind_table[VSOCK_HASH_SIZE + 1];
165static struct list_head vsock_connected_table[VSOCK_HASH_SIZE]; 165static struct list_head vsock_connected_table[VSOCK_HASH_SIZE];
166static DEFINE_SPINLOCK(vsock_table_lock); 166static DEFINE_SPINLOCK(vsock_table_lock);
167 167
168static __init void vsock_init_tables(void) 168static void vsock_init_tables(void)
169{ 169{
170 int i; 170 int i;
171 171
@@ -1932,7 +1932,6 @@ static const struct file_operations vsock_device_ops = {
1932 1932
1933static struct miscdevice vsock_device = { 1933static struct miscdevice vsock_device = {
1934 .name = "vsock", 1934 .name = "vsock",
1935 .minor = MISC_DYNAMIC_MINOR,
1936 .fops = &vsock_device_ops, 1935 .fops = &vsock_device_ops,
1937}; 1936};
1938 1937
@@ -1942,6 +1941,7 @@ static int __vsock_core_init(void)
1942 1941
1943 vsock_init_tables(); 1942 vsock_init_tables();
1944 1943
1944 vsock_device.minor = MISC_DYNAMIC_MINOR;
1945 err = misc_register(&vsock_device); 1945 err = misc_register(&vsock_device);
1946 if (err) { 1946 if (err) {
1947 pr_err("Failed to register misc device\n"); 1947 pr_err("Failed to register misc device\n");