aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-09-09 00:11:01 -0400
committerDavid S. Miller <davem@davemloft.net>2017-09-09 00:11:01 -0400
commita7bc57749f231dcd5fdbc7b653bc260064caf0b9 (patch)
tree0925d65fb3e7e0eec9f6d08f22086a861d294dac /tools
parent109980b894e9dae66c37c3d804a415aa68b19c7e (diff)
parent374fb014fc5b15e420faa00af036868a635eadd3 (diff)
Merge branch 'xdp-bpf-fixes'
John Fastabend says: ==================== net: Fixes for XDP/BPF The following fixes, UAPI updates, and small improvement, i. XDP needs to be called inside RCU with preempt disabled. ii. Not strictly a bug fix but we have an attach command in the sockmap UAPI already to avoid having a single kernel released with only the attach and not the detach I'm pushing this into net branch. Its early in the RC cycle so I think this is OK (not ideal but better than supporting a UAPI with a missing detach forever). iii. Final patch replace cpu_relax with cond_resched in devmap. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/test_maps.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index 4acc772a28c0..fe3a443a1102 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -558,7 +558,7 @@ static void test_sockmap(int tasks, void *data)
558 } 558 }
559 } 559 }
560 560
561 /* Test attaching bad fds */ 561 /* Test attaching/detaching bad fds */
562 err = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_PARSER, 0); 562 err = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_PARSER, 0);
563 if (!err) { 563 if (!err) {
564 printf("Failed invalid parser prog attach\n"); 564 printf("Failed invalid parser prog attach\n");
@@ -571,6 +571,30 @@ static void test_sockmap(int tasks, void *data)
571 goto out_sockmap; 571 goto out_sockmap;
572 } 572 }
573 573
574 err = bpf_prog_attach(-1, fd, __MAX_BPF_ATTACH_TYPE, 0);
575 if (!err) {
576 printf("Failed unknown prog attach\n");
577 goto out_sockmap;
578 }
579
580 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER);
581 if (err) {
582 printf("Failed empty parser prog detach\n");
583 goto out_sockmap;
584 }
585
586 err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT);
587 if (err) {
588 printf("Failed empty verdict prog detach\n");
589 goto out_sockmap;
590 }
591
592 err = bpf_prog_detach(fd, __MAX_BPF_ATTACH_TYPE);
593 if (!err) {
594 printf("Detach invalid prog successful\n");
595 goto out_sockmap;
596 }
597
574 /* Load SK_SKB program and Attach */ 598 /* Load SK_SKB program and Attach */
575 err = bpf_prog_load(SOCKMAP_PARSE_PROG, 599 err = bpf_prog_load(SOCKMAP_PARSE_PROG,
576 BPF_PROG_TYPE_SK_SKB, &obj, &parse_prog); 600 BPF_PROG_TYPE_SK_SKB, &obj, &parse_prog);
@@ -643,6 +667,13 @@ static void test_sockmap(int tasks, void *data)
643 goto out_sockmap; 667 goto out_sockmap;
644 } 668 }
645 669
670 err = bpf_prog_attach(verdict_prog, map_fd_rx,
671 __MAX_BPF_ATTACH_TYPE, 0);
672 if (!err) {
673 printf("Attached unknown bpf prog\n");
674 goto out_sockmap;
675 }
676
646 /* Test map update elem afterwards fd lives in fd and map_fd */ 677 /* Test map update elem afterwards fd lives in fd and map_fd */
647 for (i = 0; i < 6; i++) { 678 for (i = 0; i < 6; i++) {
648 err = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY); 679 err = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY);
@@ -809,6 +840,24 @@ static void test_sockmap(int tasks, void *data)
809 assert(status == 0); 840 assert(status == 0);
810 } 841 }
811 842
843 err = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE);
844 if (!err) {
845 printf("Detached an invalid prog type.\n");
846 goto out_sockmap;
847 }
848
849 err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER);
850 if (err) {
851 printf("Failed parser prog detach\n");
852 goto out_sockmap;
853 }
854
855 err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT);
856 if (err) {
857 printf("Failed parser prog detach\n");
858 goto out_sockmap;
859 }
860
812 /* Test map close sockets */ 861 /* Test map close sockets */
813 for (i = 0; i < 6; i++) 862 for (i = 0; i < 6; i++)
814 close(sfd[i]); 863 close(sfd[i]);