diff options
Diffstat (limited to 'lib/test_bpf.c')
| -rw-r--r-- | lib/test_bpf.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c index c579e0f58818..89e0345733bd 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c | |||
| @@ -66,7 +66,7 @@ struct bpf_test { | |||
| 66 | const char *descr; | 66 | const char *descr; |
| 67 | union { | 67 | union { |
| 68 | struct sock_filter insns[MAX_INSNS]; | 68 | struct sock_filter insns[MAX_INSNS]; |
| 69 | struct sock_filter_int insns_int[MAX_INSNS]; | 69 | struct bpf_insn insns_int[MAX_INSNS]; |
| 70 | } u; | 70 | } u; |
| 71 | __u8 aux; | 71 | __u8 aux; |
| 72 | __u8 data[MAX_DATA]; | 72 | __u8 data[MAX_DATA]; |
| @@ -1761,9 +1761,9 @@ static int probe_filter_length(struct sock_filter *fp) | |||
| 1761 | return len + 1; | 1761 | return len + 1; |
| 1762 | } | 1762 | } |
| 1763 | 1763 | ||
| 1764 | static struct sk_filter *generate_filter(int which, int *err) | 1764 | static struct bpf_prog *generate_filter(int which, int *err) |
| 1765 | { | 1765 | { |
| 1766 | struct sk_filter *fp; | 1766 | struct bpf_prog *fp; |
| 1767 | struct sock_fprog_kern fprog; | 1767 | struct sock_fprog_kern fprog; |
| 1768 | unsigned int flen = probe_filter_length(tests[which].u.insns); | 1768 | unsigned int flen = probe_filter_length(tests[which].u.insns); |
| 1769 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; | 1769 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; |
| @@ -1773,7 +1773,7 @@ static struct sk_filter *generate_filter(int which, int *err) | |||
| 1773 | fprog.filter = tests[which].u.insns; | 1773 | fprog.filter = tests[which].u.insns; |
| 1774 | fprog.len = flen; | 1774 | fprog.len = flen; |
| 1775 | 1775 | ||
| 1776 | *err = sk_unattached_filter_create(&fp, &fprog); | 1776 | *err = bpf_prog_create(&fp, &fprog); |
| 1777 | if (tests[which].aux & FLAG_EXPECTED_FAIL) { | 1777 | if (tests[which].aux & FLAG_EXPECTED_FAIL) { |
| 1778 | if (*err == -EINVAL) { | 1778 | if (*err == -EINVAL) { |
| 1779 | pr_cont("PASS\n"); | 1779 | pr_cont("PASS\n"); |
| @@ -1798,7 +1798,7 @@ static struct sk_filter *generate_filter(int which, int *err) | |||
| 1798 | break; | 1798 | break; |
| 1799 | 1799 | ||
| 1800 | case INTERNAL: | 1800 | case INTERNAL: |
| 1801 | fp = kzalloc(sk_filter_size(flen), GFP_KERNEL); | 1801 | fp = kzalloc(bpf_prog_size(flen), GFP_KERNEL); |
| 1802 | if (fp == NULL) { | 1802 | if (fp == NULL) { |
| 1803 | pr_cont("UNEXPECTED_FAIL no memory left\n"); | 1803 | pr_cont("UNEXPECTED_FAIL no memory left\n"); |
| 1804 | *err = -ENOMEM; | 1804 | *err = -ENOMEM; |
| @@ -1807,9 +1807,9 @@ static struct sk_filter *generate_filter(int which, int *err) | |||
| 1807 | 1807 | ||
| 1808 | fp->len = flen; | 1808 | fp->len = flen; |
| 1809 | memcpy(fp->insnsi, tests[which].u.insns_int, | 1809 | memcpy(fp->insnsi, tests[which].u.insns_int, |
| 1810 | fp->len * sizeof(struct sock_filter_int)); | 1810 | fp->len * sizeof(struct bpf_insn)); |
| 1811 | 1811 | ||
| 1812 | sk_filter_select_runtime(fp); | 1812 | bpf_prog_select_runtime(fp); |
| 1813 | break; | 1813 | break; |
| 1814 | } | 1814 | } |
| 1815 | 1815 | ||
| @@ -1817,21 +1817,21 @@ static struct sk_filter *generate_filter(int which, int *err) | |||
| 1817 | return fp; | 1817 | return fp; |
| 1818 | } | 1818 | } |
| 1819 | 1819 | ||
| 1820 | static void release_filter(struct sk_filter *fp, int which) | 1820 | static void release_filter(struct bpf_prog *fp, int which) |
| 1821 | { | 1821 | { |
| 1822 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; | 1822 | __u8 test_type = tests[which].aux & TEST_TYPE_MASK; |
| 1823 | 1823 | ||
| 1824 | switch (test_type) { | 1824 | switch (test_type) { |
| 1825 | case CLASSIC: | 1825 | case CLASSIC: |
| 1826 | sk_unattached_filter_destroy(fp); | 1826 | bpf_prog_destroy(fp); |
| 1827 | break; | 1827 | break; |
| 1828 | case INTERNAL: | 1828 | case INTERNAL: |
| 1829 | sk_filter_free(fp); | 1829 | bpf_prog_free(fp); |
| 1830 | break; | 1830 | break; |
| 1831 | } | 1831 | } |
| 1832 | } | 1832 | } |
| 1833 | 1833 | ||
| 1834 | static int __run_one(const struct sk_filter *fp, const void *data, | 1834 | static int __run_one(const struct bpf_prog *fp, const void *data, |
| 1835 | int runs, u64 *duration) | 1835 | int runs, u64 *duration) |
| 1836 | { | 1836 | { |
| 1837 | u64 start, finish; | 1837 | u64 start, finish; |
| @@ -1840,7 +1840,7 @@ static int __run_one(const struct sk_filter *fp, const void *data, | |||
| 1840 | start = ktime_to_us(ktime_get()); | 1840 | start = ktime_to_us(ktime_get()); |
| 1841 | 1841 | ||
| 1842 | for (i = 0; i < runs; i++) | 1842 | for (i = 0; i < runs; i++) |
| 1843 | ret = SK_RUN_FILTER(fp, data); | 1843 | ret = BPF_PROG_RUN(fp, data); |
| 1844 | 1844 | ||
| 1845 | finish = ktime_to_us(ktime_get()); | 1845 | finish = ktime_to_us(ktime_get()); |
| 1846 | 1846 | ||
| @@ -1850,7 +1850,7 @@ static int __run_one(const struct sk_filter *fp, const void *data, | |||
| 1850 | return ret; | 1850 | return ret; |
| 1851 | } | 1851 | } |
| 1852 | 1852 | ||
| 1853 | static int run_one(const struct sk_filter *fp, struct bpf_test *test) | 1853 | static int run_one(const struct bpf_prog *fp, struct bpf_test *test) |
| 1854 | { | 1854 | { |
| 1855 | int err_cnt = 0, i, runs = MAX_TESTRUNS; | 1855 | int err_cnt = 0, i, runs = MAX_TESTRUNS; |
| 1856 | 1856 | ||
| @@ -1884,7 +1884,7 @@ static __init int test_bpf(void) | |||
| 1884 | int i, err_cnt = 0, pass_cnt = 0; | 1884 | int i, err_cnt = 0, pass_cnt = 0; |
| 1885 | 1885 | ||
| 1886 | for (i = 0; i < ARRAY_SIZE(tests); i++) { | 1886 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
| 1887 | struct sk_filter *fp; | 1887 | struct bpf_prog *fp; |
| 1888 | int err; | 1888 | int err; |
| 1889 | 1889 | ||
| 1890 | pr_info("#%d %s ", i, tests[i].descr); | 1890 | pr_info("#%d %s ", i, tests[i].descr); |
