Skip to content

Commit 212dab0

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Handle frames in error situations properly in AF_XDP, from Jakub Kicinski. 2) tcp_mmap test case only tests ipv6 due to a thinko, fix from Maninder Singh. 3) Session refcnt fix in l2tp_ppp, from Guillaume Nault. 4) Fix regression in netlink bind handling of multicast gruops, from Dmitry Safonov. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: netlink: Don't shift on 64 for ngroups net/smc: no cursor update send in state SMC_INIT l2tp: fix missing refcount drop in pppol2tp_tunnel_ioctl() mlxsw: core_acl_flex_actions: Remove redundant mirror resource destruction mlxsw: core_acl_flex_actions: Remove redundant counter destruction mlxsw: core_acl_flex_actions: Remove redundant resource destruction mlxsw: core_acl_flex_actions: Return error for conflicting actions selftests/bpf: update test_lwt_seg6local.sh according to iproute2 drivers: net: lmc: fix case value for target abort error selftest/net: fix protocol family to work for IPv4. net: xsk: don't return frames via the allocator on error tools/bpftool: fix a percpu_array map dump problem
2 parents 60f5a21 + 91874ec commit 212dab0

File tree

9 files changed

+57
-42
lines changed

9 files changed

+57
-42
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,16 @@ static void mlxsw_afa_resource_add(struct mlxsw_afa_block *block,
327327
list_add(&resource->list, &block->resource_list);
328328
}
329329

330+
static void mlxsw_afa_resource_del(struct mlxsw_afa_resource *resource)
331+
{
332+
list_del(&resource->list);
333+
}
334+
330335
static void mlxsw_afa_resources_destroy(struct mlxsw_afa_block *block)
331336
{
332337
struct mlxsw_afa_resource *resource, *tmp;
333338

334339
list_for_each_entry_safe(resource, tmp, &block->resource_list, list) {
335-
list_del(&resource->list);
336340
resource->destructor(block, resource);
337341
}
338342
}
@@ -530,6 +534,7 @@ static void
530534
mlxsw_afa_fwd_entry_ref_destroy(struct mlxsw_afa_block *block,
531535
struct mlxsw_afa_fwd_entry_ref *fwd_entry_ref)
532536
{
537+
mlxsw_afa_resource_del(&fwd_entry_ref->resource);
533538
mlxsw_afa_fwd_entry_put(block->afa, fwd_entry_ref->fwd_entry);
534539
kfree(fwd_entry_ref);
535540
}
@@ -579,6 +584,7 @@ static void
579584
mlxsw_afa_counter_destroy(struct mlxsw_afa_block *block,
580585
struct mlxsw_afa_counter *counter)
581586
{
587+
mlxsw_afa_resource_del(&counter->resource);
582588
block->afa->ops->counter_index_put(block->afa->ops_priv,
583589
counter->counter_index);
584590
kfree(counter);
@@ -626,8 +632,8 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block,
626632
char *oneact;
627633
char *actions;
628634

629-
if (WARN_ON(block->finished))
630-
return NULL;
635+
if (block->finished)
636+
return ERR_PTR(-EINVAL);
631637
if (block->cur_act_index + action_size >
632638
block->afa->max_acts_per_set) {
633639
struct mlxsw_afa_set *set;
@@ -637,7 +643,7 @@ static char *mlxsw_afa_block_append_action(struct mlxsw_afa_block *block,
637643
*/
638644
set = mlxsw_afa_set_create(false);
639645
if (!set)
640-
return NULL;
646+
return ERR_PTR(-ENOBUFS);
641647
set->prev = block->cur_set;
642648
block->cur_act_index = 0;
643649
block->cur_set->next = set;
@@ -724,8 +730,8 @@ int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
724730
MLXSW_AFA_VLAN_CODE,
725731
MLXSW_AFA_VLAN_SIZE);
726732

727-
if (!act)
728-
return -ENOBUFS;
733+
if (IS_ERR(act))
734+
return PTR_ERR(act);
729735
mlxsw_afa_vlan_pack(act, MLXSW_AFA_VLAN_VLAN_TAG_CMD_NOP,
730736
MLXSW_AFA_VLAN_CMD_SET_OUTER, vid,
731737
MLXSW_AFA_VLAN_CMD_SET_OUTER, pcp,
@@ -806,8 +812,8 @@ int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block)
806812
MLXSW_AFA_TRAPDISC_CODE,
807813
MLXSW_AFA_TRAPDISC_SIZE);
808814

809-
if (!act)
810-
return -ENOBUFS;
815+
if (IS_ERR(act))
816+
return PTR_ERR(act);
811817
mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
812818
MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 0);
813819
return 0;
@@ -820,8 +826,8 @@ int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id)
820826
MLXSW_AFA_TRAPDISC_CODE,
821827
MLXSW_AFA_TRAPDISC_SIZE);
822828

823-
if (!act)
824-
return -ENOBUFS;
829+
if (IS_ERR(act))
830+
return PTR_ERR(act);
825831
mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
826832
MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD,
827833
trap_id);
@@ -836,8 +842,8 @@ int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
836842
MLXSW_AFA_TRAPDISC_CODE,
837843
MLXSW_AFA_TRAPDISC_SIZE);
838844

839-
if (!act)
840-
return -ENOBUFS;
845+
if (IS_ERR(act))
846+
return PTR_ERR(act);
841847
mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
842848
MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD,
843849
trap_id);
@@ -856,6 +862,7 @@ static void
856862
mlxsw_afa_mirror_destroy(struct mlxsw_afa_block *block,
857863
struct mlxsw_afa_mirror *mirror)
858864
{
865+
mlxsw_afa_resource_del(&mirror->resource);
859866
block->afa->ops->mirror_del(block->afa->ops_priv,
860867
mirror->local_in_port,
861868
mirror->span_id,
@@ -908,8 +915,8 @@ mlxsw_afa_block_append_allocated_mirror(struct mlxsw_afa_block *block,
908915
char *act = mlxsw_afa_block_append_action(block,
909916
MLXSW_AFA_TRAPDISC_CODE,
910917
MLXSW_AFA_TRAPDISC_SIZE);
911-
if (!act)
912-
return -ENOBUFS;
918+
if (IS_ERR(act))
919+
return PTR_ERR(act);
913920
mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
914921
MLXSW_AFA_TRAPDISC_FORWARD_ACTION_FORWARD, 0);
915922
mlxsw_afa_trapdisc_mirror_pack(act, true, mirror_agent);
@@ -996,8 +1003,8 @@ int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
9961003

9971004
act = mlxsw_afa_block_append_action(block, MLXSW_AFA_FORWARD_CODE,
9981005
MLXSW_AFA_FORWARD_SIZE);
999-
if (!act) {
1000-
err = -ENOBUFS;
1006+
if (IS_ERR(act)) {
1007+
err = PTR_ERR(act);
10011008
goto err_append_action;
10021009
}
10031010
mlxsw_afa_forward_pack(act, MLXSW_AFA_FORWARD_TYPE_PBS,
@@ -1052,8 +1059,8 @@ int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
10521059
{
10531060
char *act = mlxsw_afa_block_append_action(block, MLXSW_AFA_POLCNT_CODE,
10541061
MLXSW_AFA_POLCNT_SIZE);
1055-
if (!act)
1056-
return -ENOBUFS;
1062+
if (IS_ERR(act))
1063+
return PTR_ERR(act);
10571064
mlxsw_afa_polcnt_pack(act, MLXSW_AFA_POLCNT_COUNTER_SET_TYPE_PACKETS_BYTES,
10581065
counter_index);
10591066
return 0;
@@ -1123,8 +1130,8 @@ int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid)
11231130
char *act = mlxsw_afa_block_append_action(block,
11241131
MLXSW_AFA_VIRFWD_CODE,
11251132
MLXSW_AFA_VIRFWD_SIZE);
1126-
if (!act)
1127-
return -ENOBUFS;
1133+
if (IS_ERR(act))
1134+
return PTR_ERR(act);
11281135
mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid);
11291136
return 0;
11301137
}
@@ -1193,8 +1200,8 @@ int mlxsw_afa_block_append_mcrouter(struct mlxsw_afa_block *block,
11931200
char *act = mlxsw_afa_block_append_action(block,
11941201
MLXSW_AFA_MCROUTER_CODE,
11951202
MLXSW_AFA_MCROUTER_SIZE);
1196-
if (!act)
1197-
return -ENOBUFS;
1203+
if (IS_ERR(act))
1204+
return PTR_ERR(act);
11981205
mlxsw_afa_mcrouter_pack(act, MLXSW_AFA_MCROUTER_RPF_ACTION_TRAP,
11991206
expected_irif, min_mtu, rmid_valid, kvdl_index);
12001207
return 0;

drivers/net/wan/lmc/lmc_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
13621362
case 0x001:
13631363
printk(KERN_WARNING "%s: Master Abort (naughty)\n", dev->name);
13641364
break;
1365-
case 0x010:
1365+
case 0x002:
13661366
printk(KERN_WARNING "%s: Target Abort (not so naughty)\n", dev->name);
13671367
break;
13681368
default:

net/l2tp/l2tp_ppp.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,13 +1201,18 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
12011201
l2tp_session_get(sock_net(sk), tunnel,
12021202
stats.session_id);
12031203

1204-
if (session && session->pwtype == L2TP_PWTYPE_PPP) {
1205-
err = pppol2tp_session_ioctl(session, cmd,
1206-
arg);
1204+
if (!session) {
1205+
err = -EBADR;
1206+
break;
1207+
}
1208+
if (session->pwtype != L2TP_PWTYPE_PPP) {
12071209
l2tp_session_dec_refcount(session);
1208-
} else {
12091210
err = -EBADR;
1211+
break;
12101212
}
1213+
1214+
err = pppol2tp_session_ioctl(session, cmd, arg);
1215+
l2tp_session_dec_refcount(session);
12111216
break;
12121217
}
12131218
#ifdef CONFIG_XFRM

net/netlink/af_netlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,8 +1013,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
10131013

10141014
if (nlk->ngroups == 0)
10151015
groups = 0;
1016-
else
1017-
groups &= (1ULL << nlk->ngroups) - 1;
1016+
else if (nlk->ngroups < 8*sizeof(groups))
1017+
groups &= (1UL << nlk->ngroups) - 1;
10181018

10191019
bound = nlk->bound;
10201020
if (bound) {

net/smc/smc_cdc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
233233
/* force immediate tx of current consumer cursor, but
234234
* under send_lock to guarantee arrival in seqno-order
235235
*/
236-
smc_tx_sndbuf_nonempty(conn);
236+
if (smc->sk.sk_state != SMC_INIT)
237+
smc_tx_sndbuf_nonempty(conn);
237238
}
238239
}
239240

net/xdp/xsk.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
8484
{
8585
int err = xskq_produce_batch_desc(xs->rx, (u64)xdp->handle, len);
8686

87-
if (err) {
88-
xdp_return_buff(xdp);
87+
if (err)
8988
xs->rx_dropped++;
90-
}
9189

9290
return err;
9391
}

tools/bpf/bpftool/map.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <assert.h>
3737
#include <errno.h>
3838
#include <fcntl.h>
39+
#include <linux/kernel.h>
3940
#include <stdbool.h>
4041
#include <stdio.h>
4142
#include <stdlib.h>
@@ -90,7 +91,8 @@ static bool map_is_map_of_progs(__u32 type)
9091
static void *alloc_value(struct bpf_map_info *info)
9192
{
9293
if (map_is_per_cpu(info->type))
93-
return malloc(info->value_size * get_possible_cpus());
94+
return malloc(round_up(info->value_size, 8) *
95+
get_possible_cpus());
9496
else
9597
return malloc(info->value_size);
9698
}
@@ -161,9 +163,10 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
161163
jsonw_name(json_wtr, "value");
162164
print_hex_data_json(value, info->value_size);
163165
} else {
164-
unsigned int i, n;
166+
unsigned int i, n, step;
165167

166168
n = get_possible_cpus();
169+
step = round_up(info->value_size, 8);
167170

168171
jsonw_name(json_wtr, "key");
169172
print_hex_data_json(key, info->key_size);
@@ -176,7 +179,7 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key,
176179
jsonw_int_field(json_wtr, "cpu", i);
177180

178181
jsonw_name(json_wtr, "value");
179-
print_hex_data_json(value + i * info->value_size,
182+
print_hex_data_json(value + i * step,
180183
info->value_size);
181184

182185
jsonw_end_object(json_wtr);
@@ -207,17 +210,18 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key,
207210

208211
printf("\n");
209212
} else {
210-
unsigned int i, n;
213+
unsigned int i, n, step;
211214

212215
n = get_possible_cpus();
216+
step = round_up(info->value_size, 8);
213217

214218
printf("key:\n");
215219
fprint_hex(stdout, key, info->key_size, " ");
216220
printf("\n");
217221
for (i = 0; i < n; i++) {
218222
printf("value (CPU %02d):%c",
219223
i, info->value_size > 16 ? '\n' : ' ');
220-
fprint_hex(stdout, value + i * info->value_size,
224+
fprint_hex(stdout, value + i * step,
221225
info->value_size, " ");
222226
printf("\n");
223227
}

tools/testing/selftests/bpf/test_lwt_seg6local.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ ip netns exec ns2 ip -6 route add fb00::6 encap bpf in obj test_lwt_seg6local.o
115115
ip netns exec ns2 ip -6 route add fd00::1 dev veth3 via fb00::43 scope link
116116

117117
ip netns exec ns3 ip -6 route add fc42::1 dev veth5 via fb00::65
118-
ip netns exec ns3 ip -6 route add fd00::1 encap seg6local action End.BPF obj test_lwt_seg6local.o sec add_egr_x dev veth4
118+
ip netns exec ns3 ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec add_egr_x dev veth4
119119

120-
ip netns exec ns4 ip -6 route add fd00::2 encap seg6local action End.BPF obj test_lwt_seg6local.o sec pop_egr dev veth6
120+
ip netns exec ns4 ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec pop_egr dev veth6
121121
ip netns exec ns4 ip -6 addr add fc42::1 dev lo
122122
ip netns exec ns4 ip -6 route add fd00::3 dev veth7 via fb00::87
123123

124124
ip netns exec ns5 ip -6 route add fd00::4 table 117 dev veth9 via fb00::109
125-
ip netns exec ns5 ip -6 route add fd00::3 encap seg6local action End.BPF obj test_lwt_seg6local.o sec inspect_t dev veth8
125+
ip netns exec ns5 ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec inspect_t dev veth8
126126

127127
ip netns exec ns6 ip -6 addr add fb00::6/16 dev lo
128128
ip netns exec ns6 ip -6 addr add fd00::4/16 dev lo

tools/testing/selftests/net/tcp_mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ int main(int argc, char *argv[])
402402
exit(1);
403403
}
404404

405-
fd = socket(AF_INET6, SOCK_STREAM, 0);
405+
fd = socket(cfg_family, SOCK_STREAM, 0);
406406
if (fd == -1) {
407407
perror("socket");
408408
exit(1);

0 commit comments

Comments
 (0)