Skip to content

Commit 8f18e4d

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Various ipvlan fixes from Eric Dumazet and Mahesh Bandewar. The most important is to not assume the packet is RX just because the destination address matches that of the device. Such an assumption causes problems when an interface is put into loopback mode. 2) If we retry when creating a new tc entry (because we dropped the RTNL mutex in order to load a module, for example) we end up with -EAGAIN and then loop trying to replay the request. But we didn't reset some state when looping back to the top like this, and if another thread meanwhile inserted the same tc entry we were trying to, we re-link it creating an enless loop in the tc chain. Fix from Daniel Borkmann. 3) There are two different WRITE bits in the MDIO address register for the stmmac chip, depending upon the chip variant. Due to a bug we could set them both, fix from Hock Leong Kweh. 4) Fix mlx4 bug in XDP_TX handling, from Tariq Toukan. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: net: stmmac: fix incorrect bit set in gmac4 mdio addr register r8169: add support for RTL8168 series add-on card. net: xdp: remove unused bfp_warn_invalid_xdp_buffer() openvswitch: upcall: Fix vlan handling. ipv4: Namespaceify tcp_tw_reuse knob net: korina: Fix NAPI versus resources freeing net, sched: fix soft lockup in tc_classify net/mlx4_en: Fix user prio field in XDP forward tipc: don't send FIN message from connectionless socket ipvlan: fix multicast processing ipvlan: fix various issues in ipvlan_process_multicast()
2 parents 0dad3a3 + 5799fc9 commit 8f18e4d

File tree

17 files changed

+112
-86
lines changed

17 files changed

+112
-86
lines changed

drivers/net/ethernet/korina.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,10 @@ static void korina_restart_task(struct work_struct *work)
900900
DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR,
901901
&lp->rx_dma_regs->dmasm);
902902

903-
korina_free_ring(dev);
904-
905903
napi_disable(&lp->napi);
906904

905+
korina_free_ring(dev);
906+
907907
if (korina_init(dev) < 0) {
908908
printk(KERN_ERR "%s: cannot restart device\n", dev->name);
909909
return;
@@ -1064,12 +1064,12 @@ static int korina_close(struct net_device *dev)
10641064
tmp = tmp | DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR;
10651065
writel(tmp, &lp->rx_dma_regs->dmasm);
10661066

1067-
korina_free_ring(dev);
1068-
10691067
napi_disable(&lp->napi);
10701068

10711069
cancel_work_sync(&lp->restart_task);
10721070

1071+
korina_free_ring(dev);
1072+
10731073
free_irq(lp->rx_irq, dev);
10741074
free_irq(lp->tx_irq, dev);
10751075
free_irq(lp->ovr_irq, dev);

drivers/net/ethernet/mellanox/mlx4/en_netdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,8 @@ int mlx4_en_start_port(struct net_device *dev)
16381638

16391639
/* Configure tx cq's and rings */
16401640
for (t = 0 ; t < MLX4_EN_NUM_TX_TYPES; t++) {
1641-
u8 num_tx_rings_p_up = t == TX ? priv->num_tx_rings_p_up : 1;
1641+
u8 num_tx_rings_p_up = t == TX ?
1642+
priv->num_tx_rings_p_up : priv->tx_ring_num[t];
16421643

16431644
for (i = 0; i < priv->tx_ring_num[t]; i++) {
16441645
/* Configure cq */

drivers/net/ethernet/realtek/r8169.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ enum cfg_version {
326326
static const struct pci_device_id rtl8169_pci_tbl[] = {
327327
{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 },
328328
{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 },
329+
{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8161), 0, 0, RTL_CFG_1 },
329330
{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
330331
{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 },
331332
{ PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
116116
unsigned int mii_address = priv->hw->mii.addr;
117117
unsigned int mii_data = priv->hw->mii.data;
118118

119-
u32 value = MII_WRITE | MII_BUSY;
119+
u32 value = MII_BUSY;
120120

121121
value |= (phyaddr << priv->hw->mii.addr_shift)
122122
& priv->hw->mii.addr_mask;
@@ -126,6 +126,8 @@ static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg,
126126
& priv->hw->mii.clk_csr_mask;
127127
if (priv->plat->has_gmac4)
128128
value |= MII_GMAC4_WRITE;
129+
else
130+
value |= MII_WRITE;
129131

130132
/* Wait until any existing MII operation is complete */
131133
if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))

drivers/net/ipvlan/ipvlan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ struct ipvl_port {
9999
int count;
100100
};
101101

102+
struct ipvl_skb_cb {
103+
bool tx_pkt;
104+
};
105+
#define IPVL_SKB_CB(_skb) ((struct ipvl_skb_cb *)&((_skb)->cb[0]))
106+
102107
static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d)
103108
{
104109
return rcu_dereference(d->rx_handler_data);

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void ipvlan_process_multicast(struct work_struct *work)
198198
unsigned int mac_hash;
199199
int ret;
200200
u8 pkt_type;
201-
bool hlocal, dlocal;
201+
bool tx_pkt;
202202

203203
__skb_queue_head_init(&list);
204204

@@ -207,50 +207,57 @@ void ipvlan_process_multicast(struct work_struct *work)
207207
spin_unlock_bh(&port->backlog.lock);
208208

209209
while ((skb = __skb_dequeue(&list)) != NULL) {
210+
struct net_device *dev = skb->dev;
211+
bool consumed = false;
212+
210213
ethh = eth_hdr(skb);
211-
hlocal = ether_addr_equal(ethh->h_source, port->dev->dev_addr);
214+
tx_pkt = IPVL_SKB_CB(skb)->tx_pkt;
212215
mac_hash = ipvlan_mac_hash(ethh->h_dest);
213216

214217
if (ether_addr_equal(ethh->h_dest, port->dev->broadcast))
215218
pkt_type = PACKET_BROADCAST;
216219
else
217220
pkt_type = PACKET_MULTICAST;
218221

219-
dlocal = false;
220222
rcu_read_lock();
221223
list_for_each_entry_rcu(ipvlan, &port->ipvlans, pnode) {
222-
if (hlocal && (ipvlan->dev == skb->dev)) {
223-
dlocal = true;
224+
if (tx_pkt && (ipvlan->dev == skb->dev))
224225
continue;
225-
}
226226
if (!test_bit(mac_hash, ipvlan->mac_filters))
227227
continue;
228-
228+
if (!(ipvlan->dev->flags & IFF_UP))
229+
continue;
229230
ret = NET_RX_DROP;
230231
len = skb->len + ETH_HLEN;
231232
nskb = skb_clone(skb, GFP_ATOMIC);
232-
if (!nskb)
233-
goto acct;
234-
235-
nskb->pkt_type = pkt_type;
236-
nskb->dev = ipvlan->dev;
237-
if (hlocal)
238-
ret = dev_forward_skb(ipvlan->dev, nskb);
239-
else
240-
ret = netif_rx(nskb);
241-
acct:
233+
local_bh_disable();
234+
if (nskb) {
235+
consumed = true;
236+
nskb->pkt_type = pkt_type;
237+
nskb->dev = ipvlan->dev;
238+
if (tx_pkt)
239+
ret = dev_forward_skb(ipvlan->dev, nskb);
240+
else
241+
ret = netif_rx(nskb);
242+
}
242243
ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
244+
local_bh_enable();
243245
}
244246
rcu_read_unlock();
245247

246-
if (dlocal) {
248+
if (tx_pkt) {
247249
/* If the packet originated here, send it out. */
248250
skb->dev = port->dev;
249251
skb->pkt_type = pkt_type;
250252
dev_queue_xmit(skb);
251253
} else {
252-
kfree_skb(skb);
254+
if (consumed)
255+
consume_skb(skb);
256+
else
257+
kfree_skb(skb);
253258
}
259+
if (dev)
260+
dev_put(dev);
254261
}
255262
}
256263

@@ -470,15 +477,24 @@ static int ipvlan_process_outbound(struct sk_buff *skb)
470477
}
471478

472479
static void ipvlan_multicast_enqueue(struct ipvl_port *port,
473-
struct sk_buff *skb)
480+
struct sk_buff *skb, bool tx_pkt)
474481
{
475482
if (skb->protocol == htons(ETH_P_PAUSE)) {
476483
kfree_skb(skb);
477484
return;
478485
}
479486

487+
/* Record that the deferred packet is from TX or RX path. By
488+
* looking at mac-addresses on packet will lead to erronus decisions.
489+
* (This would be true for a loopback-mode on master device or a
490+
* hair-pin mode of the switch.)
491+
*/
492+
IPVL_SKB_CB(skb)->tx_pkt = tx_pkt;
493+
480494
spin_lock(&port->backlog.lock);
481495
if (skb_queue_len(&port->backlog) < IPVLAN_QBACKLOG_LIMIT) {
496+
if (skb->dev)
497+
dev_hold(skb->dev);
482498
__skb_queue_tail(&port->backlog, skb);
483499
spin_unlock(&port->backlog.lock);
484500
schedule_work(&port->wq);
@@ -537,7 +553,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)
537553

538554
} else if (is_multicast_ether_addr(eth->h_dest)) {
539555
ipvlan_skb_crossing_ns(skb, NULL);
540-
ipvlan_multicast_enqueue(ipvlan->port, skb);
556+
ipvlan_multicast_enqueue(ipvlan->port, skb, true);
541557
return NET_XMIT_SUCCESS;
542558
}
543559

@@ -634,7 +650,7 @@ static rx_handler_result_t ipvlan_handle_mode_l2(struct sk_buff **pskb,
634650
*/
635651
if (nskb) {
636652
ipvlan_skb_crossing_ns(nskb, NULL);
637-
ipvlan_multicast_enqueue(port, nskb);
653+
ipvlan_multicast_enqueue(port, nskb, false);
638654
}
639655
}
640656
} else {

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static int ipvlan_port_create(struct net_device *dev)
135135
static void ipvlan_port_destroy(struct net_device *dev)
136136
{
137137
struct ipvl_port *port = ipvlan_port_get_rtnl(dev);
138+
struct sk_buff *skb;
138139

139140
dev->priv_flags &= ~IFF_IPVLAN_MASTER;
140141
if (port->mode == IPVLAN_MODE_L3S) {
@@ -144,7 +145,11 @@ static void ipvlan_port_destroy(struct net_device *dev)
144145
}
145146
netdev_rx_handler_unregister(dev);
146147
cancel_work_sync(&port->wq);
147-
__skb_queue_purge(&port->backlog);
148+
while ((skb = __skb_dequeue(&port->backlog)) != NULL) {
149+
if (skb->dev)
150+
dev_put(skb->dev);
151+
kfree_skb(skb);
152+
}
148153
kfree(port);
149154
}
150155

include/linux/filter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ bool bpf_helper_changes_pkt_data(void *func);
610610
struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
611611
const struct bpf_insn *patch, u32 len);
612612
void bpf_warn_invalid_xdp_action(u32 act);
613-
void bpf_warn_invalid_xdp_buffer(void);
614613

615614
#ifdef CONFIG_BPF_JIT
616615
extern int bpf_jit_enable;

include/net/netns/ipv4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct netns_ipv4 {
110110
int sysctl_tcp_orphan_retries;
111111
int sysctl_tcp_fin_timeout;
112112
unsigned int sysctl_tcp_notsent_lowat;
113+
int sysctl_tcp_tw_reuse;
113114

114115
int sysctl_igmp_max_memberships;
115116
int sysctl_igmp_max_msf;

include/net/tcp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ extern int sysctl_tcp_wmem[3];
252252
extern int sysctl_tcp_rmem[3];
253253
extern int sysctl_tcp_app_win;
254254
extern int sysctl_tcp_adv_win_scale;
255-
extern int sysctl_tcp_tw_reuse;
256255
extern int sysctl_tcp_frto;
257256
extern int sysctl_tcp_low_latency;
258257
extern int sysctl_tcp_nometrics_save;

net/core/filter.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,12 +2972,6 @@ void bpf_warn_invalid_xdp_action(u32 act)
29722972
}
29732973
EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_action);
29742974

2975-
void bpf_warn_invalid_xdp_buffer(void)
2976-
{
2977-
WARN_ONCE(1, "Illegal XDP buffer encountered, expect throughput degradation\n");
2978-
}
2979-
EXPORT_SYMBOL_GPL(bpf_warn_invalid_xdp_buffer);
2980-
29812975
static u32 sk_filter_convert_ctx_access(enum bpf_access_type type, int dst_reg,
29822976
int src_reg, int ctx_off,
29832977
struct bpf_insn *insn_buf,

net/ipv4/sysctl_net_ipv4.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,6 @@ static struct ctl_table ipv4_table[] = {
432432
.extra1 = &tcp_adv_win_scale_min,
433433
.extra2 = &tcp_adv_win_scale_max,
434434
},
435-
{
436-
.procname = "tcp_tw_reuse",
437-
.data = &sysctl_tcp_tw_reuse,
438-
.maxlen = sizeof(int),
439-
.mode = 0644,
440-
.proc_handler = proc_dointvec
441-
},
442435
{
443436
.procname = "tcp_frto",
444437
.data = &sysctl_tcp_frto,
@@ -960,6 +953,13 @@ static struct ctl_table ipv4_net_table[] = {
960953
.mode = 0644,
961954
.proc_handler = proc_dointvec,
962955
},
956+
{
957+
.procname = "tcp_tw_reuse",
958+
.data = &init_net.ipv4.sysctl_tcp_tw_reuse,
959+
.maxlen = sizeof(int),
960+
.mode = 0644,
961+
.proc_handler = proc_dointvec
962+
},
963963
#ifdef CONFIG_IP_ROUTE_MULTIPATH
964964
{
965965
.procname = "fib_multipath_use_neigh",

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
#include <crypto/hash.h>
8585
#include <linux/scatterlist.h>
8686

87-
int sysctl_tcp_tw_reuse __read_mostly;
8887
int sysctl_tcp_low_latency __read_mostly;
8988

9089
#ifdef CONFIG_TCP_MD5SIG
@@ -120,7 +119,7 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
120119
and use initial timestamp retrieved from peer table.
121120
*/
122121
if (tcptw->tw_ts_recent_stamp &&
123-
(!twp || (sysctl_tcp_tw_reuse &&
122+
(!twp || (sock_net(sk)->ipv4.sysctl_tcp_tw_reuse &&
124123
get_seconds() - tcptw->tw_ts_recent_stamp > 1))) {
125124
tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2;
126125
if (tp->write_seq == 0)
@@ -2456,6 +2455,7 @@ static int __net_init tcp_sk_init(struct net *net)
24562455
net->ipv4.sysctl_tcp_orphan_retries = 0;
24572456
net->ipv4.sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
24582457
net->ipv4.sysctl_tcp_notsent_lowat = UINT_MAX;
2458+
net->ipv4.sysctl_tcp_tw_reuse = 0;
24592459

24602460
return 0;
24612461
fail:

net/openvswitch/datapath.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
606606
rcu_assign_pointer(flow->sf_acts, acts);
607607
packet->priority = flow->key.phy.priority;
608608
packet->mark = flow->key.phy.skb_mark;
609-
packet->protocol = flow->key.eth.type;
610609

611610
rcu_read_lock();
612611
dp = get_dp_rcu(net, ovs_header->dp_ifindex);

0 commit comments

Comments
 (0)