aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-06-24 05:58:51 -0400
committerDavid S. Miller <davem@davemloft.net>2015-06-24 05:58:51 -0400
commit3a07bd6fead4f00f67b1bf5f551e686661c4f52c (patch)
treef8b8f257d928a9ae1aeb3fdbe748f03f1012f02e
parent204621551b2a0060a013b92f7add4d5c452fa7cb (diff)
parentf1590670ce069eefeb93916391a67643e6ad1630 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: drivers/net/ethernet/mellanox/mlx4/main.c net/packet/af_packet.c Both conflicts were cases of simple overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/isdn/hisax/Kconfig4
-rw-r--r--drivers/net/can/dev.c5
-rw-r--r--drivers/net/can/slcan.c1
-rw-r--r--drivers/net/can/vcan.c3
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c26
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c8
-rw-r--r--drivers/net/ethernet/rocker/rocker.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/descs.h2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/enh_desc.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/norm_desc.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c44
-rw-r--r--drivers/net/xen-netback/xenbus.c4
-rw-r--r--include/net/netns/sctp.h1
-rw-r--r--include/net/sctp/structs.h4
-rw-r--r--net/bridge/br_ioctl.c2
-rw-r--r--net/bridge/br_multicast.c4
-rw-r--r--net/bridge/br_stp_if.c4
-rw-r--r--net/can/af_can.c6
-rw-r--r--net/core/neighbour.c13
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/ip_sockglue.c11
-rw-r--r--net/ipv4/tcp.c7
-rw-r--r--net/ipv4/tcp_fastopen.c2
-rw-r--r--net/ipv6/datagram.c12
-rw-r--r--net/mac80211/key.c13
-rw-r--r--net/packet/af_packet.c20
-rw-r--r--net/rose/af_rose.c3
-rw-r--r--net/sctp/socket.c43
29 files changed, 186 insertions, 72 deletions
diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 97465ac5a2d5..eb83d94ab4fe 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -237,7 +237,7 @@ config HISAX_MIC
237 237
238config HISAX_NETJET 238config HISAX_NETJET
239 bool "NETjet card" 239 bool "NETjet card"
240 depends on PCI && (BROKEN || !(PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV || (XTENSA && !CPU_LITTLE_ENDIAN))) 240 depends on PCI && (BROKEN || !(PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV || (XTENSA && !CPU_LITTLE_ENDIAN) || MICROBLAZE))
241 depends on VIRT_TO_BUS 241 depends on VIRT_TO_BUS
242 help 242 help
243 This enables HiSax support for the NetJet from Traverse 243 This enables HiSax support for the NetJet from Traverse
@@ -249,7 +249,7 @@ config HISAX_NETJET
249 249
250config HISAX_NETJET_U 250config HISAX_NETJET_U
251 bool "NETspider U card" 251 bool "NETspider U card"
252 depends on PCI && (BROKEN || !(PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV || (XTENSA && !CPU_LITTLE_ENDIAN))) 252 depends on PCI && (BROKEN || !(PPC || PARISC || M68K || (MIPS && !CPU_LITTLE_ENDIAN) || FRV || (XTENSA && !CPU_LITTLE_ENDIAN) || MICROBLAZE))
253 depends on VIRT_TO_BUS 253 depends on VIRT_TO_BUS
254 help 254 help
255 This enables HiSax support for the Netspider U interface ISDN card 255 This enables HiSax support for the Netspider U interface ISDN card
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index b0f69248cb71..e9b1810d319f 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -440,6 +440,9 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
440 struct can_frame *cf = (struct can_frame *)skb->data; 440 struct can_frame *cf = (struct can_frame *)skb->data;
441 u8 dlc = cf->can_dlc; 441 u8 dlc = cf->can_dlc;
442 442
443 if (!(skb->tstamp.tv64))
444 __net_timestamp(skb);
445
443 netif_rx(priv->echo_skb[idx]); 446 netif_rx(priv->echo_skb[idx]);
444 priv->echo_skb[idx] = NULL; 447 priv->echo_skb[idx] = NULL;
445 448
@@ -575,6 +578,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
575 if (unlikely(!skb)) 578 if (unlikely(!skb))
576 return NULL; 579 return NULL;
577 580
581 __net_timestamp(skb);
578 skb->protocol = htons(ETH_P_CAN); 582 skb->protocol = htons(ETH_P_CAN);
579 skb->pkt_type = PACKET_BROADCAST; 583 skb->pkt_type = PACKET_BROADCAST;
580 skb->ip_summed = CHECKSUM_UNNECESSARY; 584 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -603,6 +607,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
603 if (unlikely(!skb)) 607 if (unlikely(!skb))
604 return NULL; 608 return NULL;
605 609
610 __net_timestamp(skb);
606 skb->protocol = htons(ETH_P_CANFD); 611 skb->protocol = htons(ETH_P_CANFD);
607 skb->pkt_type = PACKET_BROADCAST; 612 skb->pkt_type = PACKET_BROADCAST;
608 skb->ip_summed = CHECKSUM_UNNECESSARY; 613 skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index c837eb91d43e..f64f5290d6f8 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -207,6 +207,7 @@ static void slc_bump(struct slcan *sl)
207 if (!skb) 207 if (!skb)
208 return; 208 return;
209 209
210 __net_timestamp(skb);
210 skb->dev = sl->dev; 211 skb->dev = sl->dev;
211 skb->protocol = htons(ETH_P_CAN); 212 skb->protocol = htons(ETH_P_CAN);
212 skb->pkt_type = PACKET_BROADCAST; 213 skb->pkt_type = PACKET_BROADCAST;
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index 674f367087c5..0ce868de855d 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -78,6 +78,9 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev)
78 skb->dev = dev; 78 skb->dev = dev;
79 skb->ip_summed = CHECKSUM_UNNECESSARY; 79 skb->ip_summed = CHECKSUM_UNNECESSARY;
80 80
81 if (!(skb->tstamp.tv64))
82 __net_timestamp(skb);
83
81 netif_rx_ni(skb); 84 netif_rx_ni(skb);
82} 85}
83 86
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index c5f299d74549..56316db6c5a6 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -487,6 +487,9 @@ static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
487{ 487{
488 struct sk_buff *new_skb; 488 struct sk_buff *new_skb;
489 489
490 if (skb_linearize(skb))
491 return NULL;
492
490 /* Alloc new skb */ 493 /* Alloc new skb */
491 new_skb = netdev_alloc_skb(dev, skb->len + 4); 494 new_skb = netdev_alloc_skb(dev, skb->len + 4);
492 if (!new_skb) 495 if (!new_skb)
@@ -512,12 +515,27 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
512 cbd_t __iomem *bdp; 515 cbd_t __iomem *bdp;
513 int curidx; 516 int curidx;
514 u16 sc; 517 u16 sc;
515 int nr_frags = skb_shinfo(skb)->nr_frags; 518 int nr_frags;
516 skb_frag_t *frag; 519 skb_frag_t *frag;
517 int len; 520 int len;
518
519#ifdef CONFIG_FS_ENET_MPC5121_FEC 521#ifdef CONFIG_FS_ENET_MPC5121_FEC
520 if (((unsigned long)skb->data) & 0x3) { 522 int is_aligned = 1;
523 int i;
524
525 if (!IS_ALIGNED((unsigned long)skb->data, 4)) {
526 is_aligned = 0;
527 } else {
528 nr_frags = skb_shinfo(skb)->nr_frags;
529 frag = skb_shinfo(skb)->frags;
530 for (i = 0; i < nr_frags; i++, frag++) {
531 if (!IS_ALIGNED(frag->page_offset, 4)) {
532 is_aligned = 0;
533 break;
534 }
535 }
536 }
537
538 if (!is_aligned) {
521 skb = tx_skb_align_workaround(dev, skb); 539 skb = tx_skb_align_workaround(dev, skb);
522 if (!skb) { 540 if (!skb) {
523 /* 541 /*
@@ -529,6 +547,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
529 } 547 }
530 } 548 }
531#endif 549#endif
550
532 spin_lock(&fep->tx_lock); 551 spin_lock(&fep->tx_lock);
533 552
534 /* 553 /*
@@ -536,6 +555,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
536 */ 555 */
537 bdp = fep->cur_tx; 556 bdp = fep->cur_tx;
538 557
558 nr_frags = skb_shinfo(skb)->nr_frags;
539 if (fep->tx_free <= nr_frags || (CBDR_SC(bdp) & BD_ENET_TX_READY)) { 559 if (fep->tx_free <= nr_frags || (CBDR_SC(bdp) & BD_ENET_TX_READY)) {
540 netif_stop_queue(dev); 560 netif_stop_queue(dev);
541 spin_unlock(&fep->tx_lock); 561 spin_unlock(&fep->tx_lock);
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index ecce8261ce3b..5bdf78231a4e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1013,6 +1013,12 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
1013 val = mvreg_read(pp, MVNETA_GMAC_CLOCK_DIVIDER); 1013 val = mvreg_read(pp, MVNETA_GMAC_CLOCK_DIVIDER);
1014 val |= MVNETA_GMAC_1MS_CLOCK_ENABLE; 1014 val |= MVNETA_GMAC_1MS_CLOCK_ENABLE;
1015 mvreg_write(pp, MVNETA_GMAC_CLOCK_DIVIDER, val); 1015 mvreg_write(pp, MVNETA_GMAC_CLOCK_DIVIDER, val);
1016 } else {
1017 val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
1018 val &= ~(MVNETA_GMAC_INBAND_AN_ENABLE |
1019 MVNETA_GMAC_AN_SPEED_EN |
1020 MVNETA_GMAC_AN_DUPLEX_EN);
1021 mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
1016 } 1022 }
1017 1023
1018 mvneta_set_ucast_table(pp, -1); 1024 mvneta_set_ucast_table(pp, -1);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 4e69cf52a579..33e68b11a158 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -479,6 +479,14 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
479 } 479 }
480 } 480 }
481 481
482 if (mlx4_is_master(dev) && (dev->caps.num_ports == 2) &&
483 (port_type_array[0] == MLX4_PORT_TYPE_IB) &&
484 (port_type_array[1] == MLX4_PORT_TYPE_ETH)) {
485 mlx4_warn(dev,
486 "Granular QoS per VF not supported with IB/Eth configuration\n");
487 dev->caps.flags2 &= ~MLX4_DEV_CAP_FLAG2_QOS_VPP;
488 }
489
482 dev->caps.max_counters = dev_cap->max_counters; 490 dev->caps.max_counters = dev_cap->max_counters;
483 491
484 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps; 492 dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FW] = dev_cap->reserved_qps;
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 83e913b60d9c..2d8578cade03 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -5297,7 +5297,7 @@ static int __init rocker_module_init(void)
5297 return 0; 5297 return 0;
5298 5298
5299err_pci_register_driver: 5299err_pci_register_driver:
5300 unregister_netdevice_notifier(&rocker_netevent_nb); 5300 unregister_netevent_notifier(&rocker_netevent_nb);
5301 unregister_netdevice_notifier(&rocker_netdevice_nb); 5301 unregister_netdevice_notifier(&rocker_netdevice_nb);
5302 return err; 5302 return err;
5303} 5303}
diff --git a/drivers/net/ethernet/stmicro/stmmac/descs.h b/drivers/net/ethernet/stmicro/stmmac/descs.h
index ad3996038018..799c2929c536 100644
--- a/drivers/net/ethernet/stmicro/stmmac/descs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/descs.h
@@ -158,6 +158,8 @@ struct dma_desc {
158 u32 buffer2_size:13; 158 u32 buffer2_size:13;
159 u32 reserved4:3; 159 u32 reserved4:3;
160 } etx; /* -- enhanced -- */ 160 } etx; /* -- enhanced -- */
161
162 u64 all_flags;
161 } des01; 163 } des01;
162 unsigned int des2; 164 unsigned int des2;
163 unsigned int des3; 165 unsigned int des3;
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
index 1e2bcf5f89e1..7d944449f5ef 100644
--- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
@@ -240,6 +240,7 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
240static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, 240static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
241 int mode, int end) 241 int mode, int end)
242{ 242{
243 p->des01.all_flags = 0;
243 p->des01.erx.own = 1; 244 p->des01.erx.own = 1;
244 p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1; 245 p->des01.erx.buffer1_size = BUF_SIZE_8KiB - 1;
245 246
@@ -254,7 +255,7 @@ static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
254 255
255static void enh_desc_init_tx_desc(struct dma_desc *p, int mode, int end) 256static void enh_desc_init_tx_desc(struct dma_desc *p, int mode, int end)
256{ 257{
257 p->des01.etx.own = 0; 258 p->des01.all_flags = 0;
258 if (mode == STMMAC_CHAIN_MODE) 259 if (mode == STMMAC_CHAIN_MODE)
259 ehn_desc_tx_set_on_chain(p, end); 260 ehn_desc_tx_set_on_chain(p, end);
260 else 261 else
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
index 35ad4f427ae2..48c3456445b2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
@@ -123,6 +123,7 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x,
123static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode, 123static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode,
124 int end) 124 int end)
125{ 125{
126 p->des01.all_flags = 0;
126 p->des01.rx.own = 1; 127 p->des01.rx.own = 1;
127 p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1; 128 p->des01.rx.buffer1_size = BUF_SIZE_2KiB - 1;
128 129
@@ -137,7 +138,7 @@ static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode,
137 138
138static void ndesc_init_tx_desc(struct dma_desc *p, int mode, int end) 139static void ndesc_init_tx_desc(struct dma_desc *p, int mode, int end)
139{ 140{
140 p->des01.tx.own = 0; 141 p->des01.all_flags = 0;
141 if (mode == STMMAC_CHAIN_MODE) 142 if (mode == STMMAC_CHAIN_MODE)
142 ndesc_tx_set_on_chain(p, end); 143 ndesc_tx_set_on_chain(p, end);
143 else 144 else
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a5156739e1e1..50f7a7a26821 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1195,41 +1195,41 @@ static int alloc_dma_desc_resources(struct stmmac_priv *priv)
1195 goto err_tx_skbuff; 1195 goto err_tx_skbuff;
1196 1196
1197 if (priv->extend_desc) { 1197 if (priv->extend_desc) {
1198 priv->dma_erx = dma_alloc_coherent(priv->device, rxsize * 1198 priv->dma_erx = dma_zalloc_coherent(priv->device, rxsize *
1199 sizeof(struct 1199 sizeof(struct
1200 dma_extended_desc), 1200 dma_extended_desc),
1201 &priv->dma_rx_phy, 1201 &priv->dma_rx_phy,
1202 GFP_KERNEL); 1202 GFP_KERNEL);
1203 if (!priv->dma_erx) 1203 if (!priv->dma_erx)
1204 goto err_dma; 1204 goto err_dma;
1205 1205
1206 priv->dma_etx = dma_alloc_coherent(priv->device, txsize * 1206 priv->dma_etx = dma_zalloc_coherent(priv->device, txsize *
1207 sizeof(struct 1207 sizeof(struct
1208 dma_extended_desc), 1208 dma_extended_desc),
1209 &priv->dma_tx_phy, 1209 &priv->dma_tx_phy,
1210 GFP_KERNEL); 1210 GFP_KERNEL);
1211 if (!priv->dma_etx) { 1211 if (!priv->dma_etx) {
1212 dma_free_coherent(priv->device, priv->dma_rx_size * 1212 dma_free_coherent(priv->device, priv->dma_rx_size *
1213 sizeof(struct dma_extended_desc), 1213 sizeof(struct dma_extended_desc),
1214 priv->dma_erx, priv->dma_rx_phy); 1214 priv->dma_erx, priv->dma_rx_phy);
1215 goto err_dma; 1215 goto err_dma;
1216 } 1216 }
1217 } else { 1217 } else {
1218 priv->dma_rx = dma_alloc_coherent(priv->device, rxsize * 1218 priv->dma_rx = dma_zalloc_coherent(priv->device, rxsize *
1219 sizeof(struct dma_desc), 1219 sizeof(struct dma_desc),
1220 &priv->dma_rx_phy, 1220 &priv->dma_rx_phy,
1221 GFP_KERNEL); 1221 GFP_KERNEL);
1222 if (!priv->dma_rx) 1222 if (!priv->dma_rx)
1223 goto err_dma; 1223 goto err_dma;
1224 1224
1225 priv->dma_tx = dma_alloc_coherent(priv->device, txsize * 1225 priv->dma_tx = dma_zalloc_coherent(priv->device, txsize *
1226 sizeof(struct dma_desc), 1226 sizeof(struct dma_desc),
1227 &priv->dma_tx_phy, 1227 &priv->dma_tx_phy,
1228 GFP_KERNEL); 1228 GFP_KERNEL);
1229 if (!priv->dma_tx) { 1229 if (!priv->dma_tx) {
1230 dma_free_coherent(priv->device, priv->dma_rx_size * 1230 dma_free_coherent(priv->device, priv->dma_rx_size *
1231 sizeof(struct dma_desc), 1231 sizeof(struct dma_desc),
1232 priv->dma_rx, priv->dma_rx_phy); 1232 priv->dma_rx, priv->dma_rx_phy);
1233 goto err_dma; 1233 goto err_dma;
1234 } 1234 }
1235 } 1235 }
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 968787abf78d..ec383b0f5443 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -681,6 +681,9 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
681 char *node; 681 char *node;
682 unsigned maxlen = strlen(dev->nodename) + sizeof("/rate"); 682 unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
683 683
684 if (vif->credit_watch.node)
685 return -EADDRINUSE;
686
684 node = kmalloc(maxlen, GFP_KERNEL); 687 node = kmalloc(maxlen, GFP_KERNEL);
685 if (!node) 688 if (!node)
686 return -ENOMEM; 689 return -ENOMEM;
@@ -770,6 +773,7 @@ static void connect(struct backend_info *be)
770 } 773 }
771 774
772 xen_net_read_rate(dev, &credit_bytes, &credit_usec); 775 xen_net_read_rate(dev, &credit_bytes, &credit_usec);
776 xen_unregister_watchers(be->vif);
773 xen_register_watchers(dev, be->vif); 777 xen_register_watchers(dev, be->vif);
774 read_xenbus_vif_flags(be); 778 read_xenbus_vif_flags(be);
775 779
diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index 3573a81815ad..8ba379f9e467 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -31,6 +31,7 @@ struct netns_sctp {
31 struct list_head addr_waitq; 31 struct list_head addr_waitq;
32 struct timer_list addr_wq_timer; 32 struct timer_list addr_wq_timer;
33 struct list_head auto_asconf_splist; 33 struct list_head auto_asconf_splist;
34 /* Lock that protects both addr_waitq and auto_asconf_splist */
34 spinlock_t addr_wq_lock; 35 spinlock_t addr_wq_lock;
35 36
36 /* Lock that protects the local_addr_list writers */ 37 /* Lock that protects the local_addr_list writers */
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 2bb2fcf5b11f..495c87e367b3 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -223,6 +223,10 @@ struct sctp_sock {
223 atomic_t pd_mode; 223 atomic_t pd_mode;
224 /* Receive to here while partial delivery is in effect. */ 224 /* Receive to here while partial delivery is in effect. */
225 struct sk_buff_head pd_lobby; 225 struct sk_buff_head pd_lobby;
226
227 /* These must be the last fields, as they will skipped on copies,
228 * like on accept and peeloff operations
229 */
226 struct list_head auto_asconf_list; 230 struct list_head auto_asconf_list;
227 int do_auto_asconf; 231 int do_auto_asconf;
228}; 232};
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index a9a4a1b7863d..8d423bc649b9 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -247,9 +247,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
247 if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN)) 247 if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
248 return -EPERM; 248 return -EPERM;
249 249
250 spin_lock_bh(&br->lock);
251 br_stp_set_bridge_priority(br, args[1]); 250 br_stp_set_bridge_priority(br, args[1]);
252 spin_unlock_bh(&br->lock);
253 return 0; 251 return 0;
254 252
255 case BRCTL_SET_PORT_PRIORITY: 253 case BRCTL_SET_PORT_PRIORITY:
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 2e246a1a9b43..742a6c27d7a2 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -37,6 +37,8 @@
37 37
38static void br_multicast_start_querier(struct net_bridge *br, 38static void br_multicast_start_querier(struct net_bridge *br,
39 struct bridge_mcast_own_query *query); 39 struct bridge_mcast_own_query *query);
40static void br_multicast_add_router(struct net_bridge *br,
41 struct net_bridge_port *port);
40unsigned int br_mdb_rehash_seq; 42unsigned int br_mdb_rehash_seq;
41 43
42static inline int br_ip_equal(const struct br_ip *a, const struct br_ip *b) 44static inline int br_ip_equal(const struct br_ip *a, const struct br_ip *b)
@@ -936,6 +938,8 @@ void br_multicast_enable_port(struct net_bridge_port *port)
936#if IS_ENABLED(CONFIG_IPV6) 938#if IS_ENABLED(CONFIG_IPV6)
937 br_multicast_enable(&port->ip6_own_query); 939 br_multicast_enable(&port->ip6_own_query);
938#endif 940#endif
941 if (port->multicast_router == 2 && hlist_unhashed(&port->rlist))
942 br_multicast_add_router(br, port);
939 943
940out: 944out:
941 spin_unlock(&br->multicast_lock); 945 spin_unlock(&br->multicast_lock);
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 41146872c1b4..7832d07f48f6 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -243,12 +243,13 @@ bool br_stp_recalculate_bridge_id(struct net_bridge *br)
243 return true; 243 return true;
244} 244}
245 245
246/* called under bridge lock */ 246/* Acquires and releases bridge lock */
247void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio) 247void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio)
248{ 248{
249 struct net_bridge_port *p; 249 struct net_bridge_port *p;
250 int wasroot; 250 int wasroot;
251 251
252 spin_lock_bh(&br->lock);
252 wasroot = br_is_root_bridge(br); 253 wasroot = br_is_root_bridge(br);
253 254
254 list_for_each_entry(p, &br->port_list, list) { 255 list_for_each_entry(p, &br->port_list, list) {
@@ -266,6 +267,7 @@ void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio)
266 br_port_state_selection(br); 267 br_port_state_selection(br);
267 if (br_is_root_bridge(br) && !wasroot) 268 if (br_is_root_bridge(br) && !wasroot)
268 br_become_root_bridge(br); 269 br_become_root_bridge(br);
270 spin_unlock_bh(&br->lock);
269} 271}
270 272
271/* called under bridge lock */ 273/* called under bridge lock */
diff --git a/net/can/af_can.c b/net/can/af_can.c
index d4d404bdfc9a..7933e62a7318 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -310,8 +310,12 @@ int can_send(struct sk_buff *skb, int loop)
310 return err; 310 return err;
311 } 311 }
312 312
313 if (newskb) 313 if (newskb) {
314 if (!(newskb->tstamp.tv64))
315 __net_timestamp(newskb);
316
314 netif_rx_ni(newskb); 317 netif_rx_ni(newskb);
318 }
315 319
316 /* update statistics */ 320 /* update statistics */
317 can_stats.tx_frames++; 321 can_stats.tx_frames++;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 3a74df750af4..84195dacb8b6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -958,6 +958,8 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
958 rc = 0; 958 rc = 0;
959 if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE)) 959 if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE))
960 goto out_unlock_bh; 960 goto out_unlock_bh;
961 if (neigh->dead)
962 goto out_dead;
961 963
962 if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) { 964 if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) {
963 if (NEIGH_VAR(neigh->parms, MCAST_PROBES) + 965 if (NEIGH_VAR(neigh->parms, MCAST_PROBES) +
@@ -1014,6 +1016,13 @@ out_unlock_bh:
1014 write_unlock(&neigh->lock); 1016 write_unlock(&neigh->lock);
1015 local_bh_enable(); 1017 local_bh_enable();
1016 return rc; 1018 return rc;
1019
1020out_dead:
1021 if (neigh->nud_state & NUD_STALE)
1022 goto out_unlock_bh;
1023 write_unlock_bh(&neigh->lock);
1024 kfree_skb(skb);
1025 return 1;
1017} 1026}
1018EXPORT_SYMBOL(__neigh_event_send); 1027EXPORT_SYMBOL(__neigh_event_send);
1019 1028
@@ -1077,6 +1086,8 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1077 if (!(flags & NEIGH_UPDATE_F_ADMIN) && 1086 if (!(flags & NEIGH_UPDATE_F_ADMIN) &&
1078 (old & (NUD_NOARP | NUD_PERMANENT))) 1087 (old & (NUD_NOARP | NUD_PERMANENT)))
1079 goto out; 1088 goto out;
1089 if (neigh->dead)
1090 goto out;
1080 1091
1081 if (!(new & NUD_VALID)) { 1092 if (!(new & NUD_VALID)) {
1082 neigh_del_timer(neigh); 1093 neigh_del_timer(neigh);
@@ -1228,6 +1239,8 @@ EXPORT_SYMBOL(neigh_update);
1228 */ 1239 */
1229void __neigh_set_probe_once(struct neighbour *neigh) 1240void __neigh_set_probe_once(struct neighbour *neigh)
1230{ 1241{
1242 if (neigh->dead)
1243 return;
1231 neigh->updated = jiffies; 1244 neigh->updated = jiffies;
1232 if (!(neigh->nud_state & NUD_FAILED)) 1245 if (!(neigh->nud_state & NUD_FAILED))
1233 return; 1246 return;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index cc858ef44451..9532ee87151f 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -228,6 +228,8 @@ int inet_listen(struct socket *sock, int backlog)
228 err = 0; 228 err = 0;
229 if (err) 229 if (err)
230 goto out; 230 goto out;
231
232 tcp_fastopen_init_key_once(true);
231 } 233 }
232 err = inet_csk_listen_start(sk, backlog); 234 err = inet_csk_listen_start(sk, backlog);
233 if (err) 235 if (err)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 04ae2992a5cd..c3c359ad66e3 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -432,6 +432,15 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf
432 kfree_skb(skb); 432 kfree_skb(skb);
433} 433}
434 434
435/* For some errors we have valid addr_offset even with zero payload and
436 * zero port. Also, addr_offset should be supported if port is set.
437 */
438static inline bool ipv4_datagram_support_addr(struct sock_exterr_skb *serr)
439{
440 return serr->ee.ee_origin == SO_EE_ORIGIN_ICMP ||
441 serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL || serr->port;
442}
443
435/* IPv4 supports cmsg on all imcp errors and some timestamps 444/* IPv4 supports cmsg on all imcp errors and some timestamps
436 * 445 *
437 * Timestamp code paths do not initialize the fields expected by cmsg: 446 * Timestamp code paths do not initialize the fields expected by cmsg:
@@ -498,7 +507,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
498 507
499 serr = SKB_EXT_ERR(skb); 508 serr = SKB_EXT_ERR(skb);
500 509
501 if (sin && serr->port) { 510 if (sin && ipv4_datagram_support_addr(serr)) {
502 sin->sin_family = AF_INET; 511 sin->sin_family = AF_INET;
503 sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + 512 sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) +
504 serr->addr_offset); 513 serr->addr_offset);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 697b86dd45b3..7f4056785acc 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2573,10 +2573,13 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2573 2573
2574 case TCP_FASTOPEN: 2574 case TCP_FASTOPEN:
2575 if (val >= 0 && ((1 << sk->sk_state) & (TCPF_CLOSE | 2575 if (val >= 0 && ((1 << sk->sk_state) & (TCPF_CLOSE |
2576 TCPF_LISTEN))) 2576 TCPF_LISTEN))) {
2577 tcp_fastopen_init_key_once(true);
2578
2577 err = fastopen_init_queue(sk, val); 2579 err = fastopen_init_queue(sk, val);
2578 else 2580 } else {
2579 err = -EINVAL; 2581 err = -EINVAL;
2582 }
2580 break; 2583 break;
2581 case TCP_TIMESTAMP: 2584 case TCP_TIMESTAMP:
2582 if (!tp->repair) 2585 if (!tp->repair)
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 46b087a27503..f9c0fb84e435 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -78,8 +78,6 @@ static bool __tcp_fastopen_cookie_gen(const void *path,
78 struct tcp_fastopen_context *ctx; 78 struct tcp_fastopen_context *ctx;
79 bool ok = false; 79 bool ok = false;
80 80
81 tcp_fastopen_init_key_once(true);
82
83 rcu_read_lock(); 81 rcu_read_lock();
84 ctx = rcu_dereference(tcp_fastopen_ctx); 82 ctx = rcu_dereference(tcp_fastopen_ctx);
85 if (ctx) { 83 if (ctx) {
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 762a58c772b8..62d908e64eeb 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -325,6 +325,16 @@ void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu)
325 kfree_skb(skb); 325 kfree_skb(skb);
326} 326}
327 327
328/* For some errors we have valid addr_offset even with zero payload and
329 * zero port. Also, addr_offset should be supported if port is set.
330 */
331static inline bool ipv6_datagram_support_addr(struct sock_exterr_skb *serr)
332{
333 return serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6 ||
334 serr->ee.ee_origin == SO_EE_ORIGIN_ICMP ||
335 serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL || serr->port;
336}
337
328/* IPv6 supports cmsg on all origins aside from SO_EE_ORIGIN_LOCAL. 338/* IPv6 supports cmsg on all origins aside from SO_EE_ORIGIN_LOCAL.
329 * 339 *
330 * At one point, excluding local errors was a quick test to identify icmp/icmp6 340 * At one point, excluding local errors was a quick test to identify icmp/icmp6
@@ -389,7 +399,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
389 399
390 serr = SKB_EXT_ERR(skb); 400 serr = SKB_EXT_ERR(skb);
391 401
392 if (sin && serr->port) { 402 if (sin && ipv6_datagram_support_addr(serr)) {
393 const unsigned char *nh = skb_network_header(skb); 403 const unsigned char *nh = skb_network_header(skb);
394 sin->sin6_family = AF_INET6; 404 sin->sin6_family = AF_INET6;
395 sin->sin6_flowinfo = 0; 405 sin->sin6_flowinfo = 0;
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 8abc31ebcf61..b22df3a79a41 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -66,12 +66,15 @@ update_vlan_tailroom_need_count(struct ieee80211_sub_if_data *sdata, int delta)
66 if (sdata->vif.type != NL80211_IFTYPE_AP) 66 if (sdata->vif.type != NL80211_IFTYPE_AP)
67 return; 67 return;
68 68
69 mutex_lock(&sdata->local->mtx); 69 /* crypto_tx_tailroom_needed_cnt is protected by this */
70 assert_key_lock(sdata->local);
71
72 rcu_read_lock();
70 73
71 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) 74 list_for_each_entry_rcu(vlan, &sdata->u.ap.vlans, u.vlan.list)
72 vlan->crypto_tx_tailroom_needed_cnt += delta; 75 vlan->crypto_tx_tailroom_needed_cnt += delta;
73 76
74 mutex_unlock(&sdata->local->mtx); 77 rcu_read_unlock();
75} 78}
76 79
77static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata) 80static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
@@ -95,6 +98,8 @@ static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
95 * http://mid.gmane.org/1308590980.4322.19.camel@jlt3.sipsolutions.net 98 * http://mid.gmane.org/1308590980.4322.19.camel@jlt3.sipsolutions.net
96 */ 99 */
97 100
101 assert_key_lock(sdata->local);
102
98 update_vlan_tailroom_need_count(sdata, 1); 103 update_vlan_tailroom_need_count(sdata, 1);
99 104
100 if (!sdata->crypto_tx_tailroom_needed_cnt++) { 105 if (!sdata->crypto_tx_tailroom_needed_cnt++) {
@@ -109,6 +114,8 @@ static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
109static void decrease_tailroom_need_count(struct ieee80211_sub_if_data *sdata, 114static void decrease_tailroom_need_count(struct ieee80211_sub_if_data *sdata,
110 int delta) 115 int delta)
111{ 116{
117 assert_key_lock(sdata->local);
118
112 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt < delta); 119 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt < delta);
113 120
114 update_vlan_tailroom_need_count(sdata, -delta); 121 update_vlan_tailroom_need_count(sdata, -delta);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f5c87031b121..c9e8741226c6 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1322,16 +1322,6 @@ static void packet_sock_destruct(struct sock *sk)
1322 sk_refcnt_debug_dec(sk); 1322 sk_refcnt_debug_dec(sk);
1323} 1323}
1324 1324
1325static int fanout_rr_next(struct packet_fanout *f, unsigned int num)
1326{
1327 int x = atomic_read(&f->rr_cur) + 1;
1328
1329 if (x >= num)
1330 x = 0;
1331
1332 return x;
1333}
1334
1335static bool fanout_flow_is_huge(struct packet_sock *po, struct sk_buff *skb) 1325static bool fanout_flow_is_huge(struct packet_sock *po, struct sk_buff *skb)
1336{ 1326{
1337 u32 rxhash; 1327 u32 rxhash;
@@ -1357,13 +1347,9 @@ static unsigned int fanout_demux_lb(struct packet_fanout *f,
1357 struct sk_buff *skb, 1347 struct sk_buff *skb,
1358 unsigned int num) 1348 unsigned int num)
1359{ 1349{
1360 int cur, old; 1350 unsigned int val = atomic_inc_return(&f->rr_cur);
1361 1351
1362 cur = atomic_read(&f->rr_cur); 1352 return val % num;
1363 while ((old = atomic_cmpxchg(&f->rr_cur, cur,
1364 fanout_rr_next(f, num))) != cur)
1365 cur = old;
1366 return cur;
1367} 1353}
1368 1354
1369static unsigned int fanout_demux_cpu(struct packet_fanout *f, 1355static unsigned int fanout_demux_cpu(struct packet_fanout *f,
@@ -1435,7 +1421,7 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev,
1435 struct packet_type *pt, struct net_device *orig_dev) 1421 struct packet_type *pt, struct net_device *orig_dev)
1436{ 1422{
1437 struct packet_fanout *f = pt->af_packet_priv; 1423 struct packet_fanout *f = pt->af_packet_priv;
1438 unsigned int num = f->num_members; 1424 unsigned int num = READ_ONCE(f->num_members);
1439 struct packet_sock *po; 1425 struct packet_sock *po;
1440 unsigned int idx; 1426 unsigned int idx;
1441 1427
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 36dbc2da3661..129d357d2722 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -192,7 +192,8 @@ static void rose_kill_by_device(struct net_device *dev)
192 192
193 if (rose->device == dev) { 193 if (rose->device == dev) {
194 rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0); 194 rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
195 rose->neighbour->use--; 195 if (rose->neighbour)
196 rose->neighbour->use--;
196 rose->device = NULL; 197 rose->device = NULL;
197 } 198 }
198 } 199 }
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f09de7fac2e6..5f6c4e61325b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1528,8 +1528,10 @@ static void sctp_close(struct sock *sk, long timeout)
1528 1528
1529 /* Supposedly, no process has access to the socket, but 1529 /* Supposedly, no process has access to the socket, but
1530 * the net layers still may. 1530 * the net layers still may.
1531 * Also, sctp_destroy_sock() needs to be called with addr_wq_lock
1532 * held and that should be grabbed before socket lock.
1531 */ 1533 */
1532 local_bh_disable(); 1534 spin_lock_bh(&net->sctp.addr_wq_lock);
1533 bh_lock_sock(sk); 1535 bh_lock_sock(sk);
1534 1536
1535 /* Hold the sock, since sk_common_release() will put sock_put() 1537 /* Hold the sock, since sk_common_release() will put sock_put()
@@ -1539,7 +1541,7 @@ static void sctp_close(struct sock *sk, long timeout)
1539 sk_common_release(sk); 1541 sk_common_release(sk);
1540 1542
1541 bh_unlock_sock(sk); 1543 bh_unlock_sock(sk);
1542 local_bh_enable(); 1544 spin_unlock_bh(&net->sctp.addr_wq_lock);
1543 1545
1544 sock_put(sk); 1546 sock_put(sk);
1545 1547
@@ -3580,6 +3582,7 @@ static int sctp_setsockopt_auto_asconf(struct sock *sk, char __user *optval,
3580 if ((val && sp->do_auto_asconf) || (!val && !sp->do_auto_asconf)) 3582 if ((val && sp->do_auto_asconf) || (!val && !sp->do_auto_asconf))
3581 return 0; 3583 return 0;
3582 3584
3585 spin_lock_bh(&sock_net(sk)->sctp.addr_wq_lock);
3583 if (val == 0 && sp->do_auto_asconf) { 3586 if (val == 0 && sp->do_auto_asconf) {
3584 list_del(&sp->auto_asconf_list); 3587 list_del(&sp->auto_asconf_list);
3585 sp->do_auto_asconf = 0; 3588 sp->do_auto_asconf = 0;
@@ -3588,6 +3591,7 @@ static int sctp_setsockopt_auto_asconf(struct sock *sk, char __user *optval,
3588 &sock_net(sk)->sctp.auto_asconf_splist); 3591 &sock_net(sk)->sctp.auto_asconf_splist);
3589 sp->do_auto_asconf = 1; 3592 sp->do_auto_asconf = 1;
3590 } 3593 }
3594 spin_unlock_bh(&sock_net(sk)->sctp.addr_wq_lock);
3591 return 0; 3595 return 0;
3592} 3596}
3593 3597
@@ -4121,18 +4125,28 @@ static int sctp_init_sock(struct sock *sk)
4121 local_bh_disable(); 4125 local_bh_disable();
4122 percpu_counter_inc(&sctp_sockets_allocated); 4126 percpu_counter_inc(&sctp_sockets_allocated);
4123 sock_prot_inuse_add(net, sk->sk_prot, 1); 4127 sock_prot_inuse_add(net, sk->sk_prot, 1);
4128
4129 /* Nothing can fail after this block, otherwise
4130 * sctp_destroy_sock() will be called without addr_wq_lock held
4131 */
4124 if (net->sctp.default_auto_asconf) { 4132 if (net->sctp.default_auto_asconf) {
4133 spin_lock(&sock_net(sk)->sctp.addr_wq_lock);
4125 list_add_tail(&sp->auto_asconf_list, 4134 list_add_tail(&sp->auto_asconf_list,
4126 &net->sctp.auto_asconf_splist); 4135 &net->sctp.auto_asconf_splist);
4127 sp->do_auto_asconf = 1; 4136 sp->do_auto_asconf = 1;
4128 } else 4137 spin_unlock(&sock_net(sk)->sctp.addr_wq_lock);
4138 } else {
4129 sp->do_auto_asconf = 0; 4139 sp->do_auto_asconf = 0;
4140 }
4141
4130 local_bh_enable(); 4142 local_bh_enable();
4131 4143
4132 return 0; 4144 return 0;
4133} 4145}
4134 4146
4135/* Cleanup any SCTP per socket resources. */ 4147/* Cleanup any SCTP per socket resources. Must be called with
4148 * sock_net(sk)->sctp.addr_wq_lock held if sp->do_auto_asconf is true
4149 */
4136static void sctp_destroy_sock(struct sock *sk) 4150static void sctp_destroy_sock(struct sock *sk)
4137{ 4151{
4138 struct sctp_sock *sp; 4152 struct sctp_sock *sp;
@@ -7195,6 +7209,19 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
7195 newinet->mc_list = NULL; 7209 newinet->mc_list = NULL;
7196} 7210}
7197 7211
7212static inline void sctp_copy_descendant(struct sock *sk_to,
7213 const struct sock *sk_from)
7214{
7215 int ancestor_size = sizeof(struct inet_sock) +
7216 sizeof(struct sctp_sock) -
7217 offsetof(struct sctp_sock, auto_asconf_list);
7218
7219 if (sk_from->sk_family == PF_INET6)
7220 ancestor_size += sizeof(struct ipv6_pinfo);
7221
7222 __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
7223}
7224
7198/* Populate the fields of the newsk from the oldsk and migrate the assoc 7225/* Populate the fields of the newsk from the oldsk and migrate the assoc
7199 * and its messages to the newsk. 7226 * and its messages to the newsk.
7200 */ 7227 */
@@ -7209,7 +7236,6 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
7209 struct sk_buff *skb, *tmp; 7236 struct sk_buff *skb, *tmp;
7210 struct sctp_ulpevent *event; 7237 struct sctp_ulpevent *event;
7211 struct sctp_bind_hashbucket *head; 7238 struct sctp_bind_hashbucket *head;
7212 struct list_head tmplist;
7213 7239
7214 /* Migrate socket buffer sizes and all the socket level options to the 7240 /* Migrate socket buffer sizes and all the socket level options to the
7215 * new socket. 7241 * new socket.
@@ -7217,12 +7243,7 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
7217 newsk->sk_sndbuf = oldsk->sk_sndbuf; 7243 newsk->sk_sndbuf = oldsk->sk_sndbuf;
7218 newsk->sk_rcvbuf = oldsk->sk_rcvbuf; 7244 newsk->sk_rcvbuf = oldsk->sk_rcvbuf;
7219 /* Brute force copy old sctp opt. */ 7245 /* Brute force copy old sctp opt. */
7220 if (oldsp->do_auto_asconf) { 7246 sctp_copy_descendant(newsk, oldsk);
7221 memcpy(&tmplist, &newsp->auto_asconf_list, sizeof(tmplist));
7222 inet_sk_copy_descendant(newsk, oldsk);
7223 memcpy(&newsp->auto_asconf_list, &tmplist, sizeof(tmplist));
7224 } else
7225 inet_sk_copy_descendant(newsk, oldsk);
7226 7247
7227 /* Restore the ep value that was overwritten with the above structure 7248 /* Restore the ep value that was overwritten with the above structure
7228 * copy. 7249 * copy.