bpf: test_maps, only support ESTABLISHED socks
Ensure that sockets added to a sock{map|hash} that is not in the
ESTABLISHED state is rejected.
Fixes: 1aa12bdf1b
("bpf: sockmap, add sock close() hook to remove socks")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
b05545e15e
commit
5028027844
@ -580,7 +580,11 @@ static void test_sockmap(int tasks, void *data)
|
|||||||
/* Test update without programs */
|
/* Test update without programs */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 0; i < 6; i++) {
|
||||||
err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY);
|
err = bpf_map_update_elem(fd, &i, &sfd[i], BPF_ANY);
|
||||||
if (err) {
|
if (i < 2 && !err) {
|
||||||
|
printf("Allowed update sockmap '%i:%i' not in ESTABLISHED\n",
|
||||||
|
i, sfd[i]);
|
||||||
|
goto out_sockmap;
|
||||||
|
} else if (i >= 2 && err) {
|
||||||
printf("Failed noprog update sockmap '%i:%i'\n",
|
printf("Failed noprog update sockmap '%i:%i'\n",
|
||||||
i, sfd[i]);
|
i, sfd[i]);
|
||||||
goto out_sockmap;
|
goto out_sockmap;
|
||||||
@ -741,7 +745,7 @@ static void test_sockmap(int tasks, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test map update elem afterwards fd lives in fd and map_fd */
|
/* Test map update elem afterwards fd lives in fd and map_fd */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 2; i < 6; i++) {
|
||||||
err = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY);
|
err = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("Failed map_fd_rx update sockmap %i '%i:%i'\n",
|
printf("Failed map_fd_rx update sockmap %i '%i:%i'\n",
|
||||||
@ -845,7 +849,7 @@ static void test_sockmap(int tasks, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Delete the elems without programs */
|
/* Delete the elems without programs */
|
||||||
for (i = 0; i < 6; i++) {
|
for (i = 2; i < 6; i++) {
|
||||||
err = bpf_map_delete_elem(fd, &i);
|
err = bpf_map_delete_elem(fd, &i);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("Failed delete sockmap %i '%i:%i'\n",
|
printf("Failed delete sockmap %i '%i:%i'\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user