Skip to content

Commit ec0c967

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: "Last bit of straggler fixes... 1) Fix btf library licensing to LGPL, from Martin KaFai lau. 2) Fix error handling in bpf sockmap code, from Daniel Borkmann. 3) XDP cpumap teardown handling wrt. execution contexts, from Jesper Dangaard Brouer. 4) Fix loss of runtime PM on failed vlan add/del, from Ivan Khoronzhuk. 5) xen-netfront caches skb_shinfo(skb) across a __pskb_pull_tail() call, which potentially changes the skb's data buffer, and thus skb_shinfo(). Fix from Juergen Gross" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: xen/netfront: don't cache skb_shinfo() net: ethernet: ti: cpsw: fix runtime_pm while add/kill vlan net: ethernet: ti: cpsw: clear all entries when delete vid xdp: fix bug in devmap teardown code path samples/bpf: xdp_redirect_cpu adjustment to reproduce teardown race easier xdp: fix bug in cpumap teardown code path bpf, sockmap: fix cork timeout for select due to epipe bpf, sockmap: fix leak in bpf_tcp_sendmsg wait for mem path bpf, sockmap: fix bpf_tcp_sendmsg sock error handling bpf: btf: Change tools/lib/bpf/btf to LGPL
2 parents 4f7a7be + d472b3a commit ec0c967

File tree

11 files changed

+46
-39
lines changed

11 files changed

+46
-39
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,14 +2086,16 @@ static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
20862086
int i;
20872087

20882088
for (i = 0; i < cpsw->data.slaves; i++) {
2089-
if (vid == cpsw->slaves[i].port_vlan)
2090-
return -EINVAL;
2089+
if (vid == cpsw->slaves[i].port_vlan) {
2090+
ret = -EINVAL;
2091+
goto err;
2092+
}
20912093
}
20922094
}
20932095

20942096
dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
20952097
ret = cpsw_add_vlan_ale_entry(priv, vid);
2096-
2098+
err:
20972099
pm_runtime_put(cpsw->dev);
20982100
return ret;
20992101
}
@@ -2119,22 +2121,17 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
21192121

21202122
for (i = 0; i < cpsw->data.slaves; i++) {
21212123
if (vid == cpsw->slaves[i].port_vlan)
2122-
return -EINVAL;
2124+
goto err;
21232125
}
21242126
}
21252127

21262128
dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
21272129
ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0);
2128-
if (ret != 0)
2129-
return ret;
2130-
2131-
ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
2132-
HOST_PORT_NUM, ALE_VLAN, vid);
2133-
if (ret != 0)
2134-
return ret;
2135-
2136-
ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
2137-
0, ALE_VLAN, vid);
2130+
ret |= cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
2131+
HOST_PORT_NUM, ALE_VLAN, vid);
2132+
ret |= cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
2133+
0, ALE_VLAN, vid);
2134+
err:
21382135
pm_runtime_put(cpsw->dev);
21392136
return ret;
21402137
}

drivers/net/ethernet/ti/cpsw_ale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
394394

395395
idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0);
396396
if (idx < 0)
397-
return -EINVAL;
397+
return -ENOENT;
398398

399399
cpsw_ale_read(ale, idx, ale_entry);
400400

drivers/net/xen-netfront.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,6 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
894894
struct sk_buff *skb,
895895
struct sk_buff_head *list)
896896
{
897-
struct skb_shared_info *shinfo = skb_shinfo(skb);
898897
RING_IDX cons = queue->rx.rsp_cons;
899898
struct sk_buff *nskb;
900899

@@ -903,15 +902,16 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
903902
RING_GET_RESPONSE(&queue->rx, ++cons);
904903
skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0];
905904

906-
if (shinfo->nr_frags == MAX_SKB_FRAGS) {
905+
if (skb_shinfo(skb)->nr_frags == MAX_SKB_FRAGS) {
907906
unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
908907

909908
BUG_ON(pull_to <= skb_headlen(skb));
910909
__pskb_pull_tail(skb, pull_to - skb_headlen(skb));
911910
}
912-
BUG_ON(shinfo->nr_frags >= MAX_SKB_FRAGS);
911+
BUG_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS);
913912

914-
skb_add_rx_frag(skb, shinfo->nr_frags, skb_frag_page(nfrag),
913+
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
914+
skb_frag_page(nfrag),
915915
rx->offset, rx->status, PAGE_SIZE);
916916

917917
skb_shinfo(nskb)->nr_frags = 0;

kernel/bpf/cpumap.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct bpf_cpu_map {
6969
};
7070

7171
static int bq_flush_to_queue(struct bpf_cpu_map_entry *rcpu,
72-
struct xdp_bulk_queue *bq);
72+
struct xdp_bulk_queue *bq, bool in_napi_ctx);
7373

7474
static u64 cpu_map_bitmap_size(const union bpf_attr *attr)
7575
{
@@ -375,7 +375,7 @@ static void __cpu_map_entry_free(struct rcu_head *rcu)
375375
struct xdp_bulk_queue *bq = per_cpu_ptr(rcpu->bulkq, cpu);
376376

377377
/* No concurrent bq_enqueue can run at this point */
378-
bq_flush_to_queue(rcpu, bq);
378+
bq_flush_to_queue(rcpu, bq, false);
379379
}
380380
free_percpu(rcpu->bulkq);
381381
/* Cannot kthread_stop() here, last put free rcpu resources */
@@ -558,7 +558,7 @@ const struct bpf_map_ops cpu_map_ops = {
558558
};
559559

560560
static int bq_flush_to_queue(struct bpf_cpu_map_entry *rcpu,
561-
struct xdp_bulk_queue *bq)
561+
struct xdp_bulk_queue *bq, bool in_napi_ctx)
562562
{
563563
unsigned int processed = 0, drops = 0;
564564
const int to_cpu = rcpu->cpu;
@@ -578,7 +578,10 @@ static int bq_flush_to_queue(struct bpf_cpu_map_entry *rcpu,
578578
err = __ptr_ring_produce(q, xdpf);
579579
if (err) {
580580
drops++;
581-
xdp_return_frame_rx_napi(xdpf);
581+
if (likely(in_napi_ctx))
582+
xdp_return_frame_rx_napi(xdpf);
583+
else
584+
xdp_return_frame(xdpf);
582585
}
583586
processed++;
584587
}
@@ -598,7 +601,7 @@ static int bq_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_frame *xdpf)
598601
struct xdp_bulk_queue *bq = this_cpu_ptr(rcpu->bulkq);
599602

600603
if (unlikely(bq->count == CPU_MAP_BULK_SIZE))
601-
bq_flush_to_queue(rcpu, bq);
604+
bq_flush_to_queue(rcpu, bq, true);
602605

603606
/* Notice, xdp_buff/page MUST be queued here, long enough for
604607
* driver to code invoking us to finished, due to driver
@@ -661,7 +664,7 @@ void __cpu_map_flush(struct bpf_map *map)
661664

662665
/* Flush all frames in bulkq to real queue */
663666
bq = this_cpu_ptr(rcpu->bulkq);
664-
bq_flush_to_queue(rcpu, bq);
667+
bq_flush_to_queue(rcpu, bq, true);
665668

666669
/* If already running, costs spin_lock_irqsave + smb_mb */
667670
wake_up_process(rcpu->kthread);

kernel/bpf/devmap.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ void __dev_map_insert_ctx(struct bpf_map *map, u32 bit)
217217
}
218218

219219
static int bq_xmit_all(struct bpf_dtab_netdev *obj,
220-
struct xdp_bulk_queue *bq, u32 flags)
220+
struct xdp_bulk_queue *bq, u32 flags,
221+
bool in_napi_ctx)
221222
{
222223
struct net_device *dev = obj->dev;
223224
int sent = 0, drops = 0, err = 0;
@@ -254,7 +255,10 @@ static int bq_xmit_all(struct bpf_dtab_netdev *obj,
254255
struct xdp_frame *xdpf = bq->q[i];
255256

256257
/* RX path under NAPI protection, can return frames faster */
257-
xdp_return_frame_rx_napi(xdpf);
258+
if (likely(in_napi_ctx))
259+
xdp_return_frame_rx_napi(xdpf);
260+
else
261+
xdp_return_frame(xdpf);
258262
drops++;
259263
}
260264
goto out;
@@ -286,7 +290,7 @@ void __dev_map_flush(struct bpf_map *map)
286290
__clear_bit(bit, bitmap);
287291

288292
bq = this_cpu_ptr(dev->bulkq);
289-
bq_xmit_all(dev, bq, XDP_XMIT_FLUSH);
293+
bq_xmit_all(dev, bq, XDP_XMIT_FLUSH, true);
290294
}
291295
}
292296

@@ -316,7 +320,7 @@ static int bq_enqueue(struct bpf_dtab_netdev *obj, struct xdp_frame *xdpf,
316320
struct xdp_bulk_queue *bq = this_cpu_ptr(obj->bulkq);
317321

318322
if (unlikely(bq->count == DEV_MAP_BULK_SIZE))
319-
bq_xmit_all(obj, bq, 0);
323+
bq_xmit_all(obj, bq, 0, true);
320324

321325
/* Ingress dev_rx will be the same for all xdp_frame's in
322326
* bulk_queue, because bq stored per-CPU and must be flushed
@@ -385,7 +389,7 @@ static void dev_map_flush_old(struct bpf_dtab_netdev *dev)
385389
__clear_bit(dev->bit, bitmap);
386390

387391
bq = per_cpu_ptr(dev->bulkq, cpu);
388-
bq_xmit_all(dev, bq, XDP_XMIT_FLUSH);
392+
bq_xmit_all(dev, bq, XDP_XMIT_FLUSH, false);
389393
}
390394
}
391395
}

kernel/bpf/sockmap.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,12 +1048,12 @@ static int bpf_tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
10481048
timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
10491049

10501050
while (msg_data_left(msg)) {
1051-
struct sk_msg_buff *m;
1051+
struct sk_msg_buff *m = NULL;
10521052
bool enospc = false;
10531053
int copy;
10541054

10551055
if (sk->sk_err) {
1056-
err = sk->sk_err;
1056+
err = -sk->sk_err;
10571057
goto out_err;
10581058
}
10591059

@@ -1116,8 +1116,11 @@ static int bpf_tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
11161116
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
11171117
wait_for_memory:
11181118
err = sk_stream_wait_memory(sk, &timeo);
1119-
if (err)
1119+
if (err) {
1120+
if (m && m != psock->cork)
1121+
free_start_sg(sk, m);
11201122
goto out_err;
1123+
}
11211124
}
11221125
out_err:
11231126
if (err < 0)

samples/bpf/xdp_redirect_cpu_kern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <uapi/linux/bpf.h>
1515
#include "bpf_helpers.h"
1616

17-
#define MAX_CPUS 12 /* WARNING - sync with _user.c */
17+
#define MAX_CPUS 64 /* WARNING - sync with _user.c */
1818

1919
/* Special map type that can XDP_REDIRECT frames to another CPU */
2020
struct bpf_map_def SEC("maps") cpu_map = {

samples/bpf/xdp_redirect_cpu_user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static const char *__doc__ =
1919
#include <arpa/inet.h>
2020
#include <linux/if_link.h>
2121

22-
#define MAX_CPUS 12 /* WARNING - sync with _kern.c */
22+
#define MAX_CPUS 64 /* WARNING - sync with _kern.c */
2323

2424
/* How many xdp_progs are defined in _kern.c */
2525
#define MAX_PROG 5
@@ -527,7 +527,7 @@ static void stress_cpumap(void)
527527
* procedure.
528528
*/
529529
create_cpu_entry(1, 1024, 0, false);
530-
create_cpu_entry(1, 128, 0, false);
530+
create_cpu_entry(1, 8, 0, false);
531531
create_cpu_entry(1, 16000, 0, false);
532532
}
533533

tools/lib/bpf/btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: GPL-2.0 */
1+
// SPDX-License-Identifier: LGPL-2.1
22
/* Copyright (c) 2018 Facebook */
33

44
#include <stdlib.h>

tools/lib/bpf/btf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: GPL-2.0 */
1+
/* SPDX-License-Identifier: LGPL-2.1 */
22
/* Copyright (c) 2018 Facebook */
33

44
#ifndef __BPF_BTF_H

tools/testing/selftests/bpf/test_sockmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
354354
while (s->bytes_recvd < total_bytes) {
355355
if (txmsg_cork) {
356356
timeout.tv_sec = 0;
357-
timeout.tv_usec = 1000;
357+
timeout.tv_usec = 300000;
358358
} else {
359359
timeout.tv_sec = 1;
360360
timeout.tv_usec = 0;

0 commit comments

Comments
 (0)