lkml.org 
[lkml]   [2019]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.3 128/135] selftests: bpf: test_sockmap: handle file creation failures gracefully
    Date
    From: Jakub Kicinski <jakub.kicinski@netronome.com>

    [ Upstream commit 4b67c515036313f3c3ecba3cb2babb9cbddb3f85 ]

    test_sockmap creates a temporary file to use for sendpage.
    this may fail for various reasons. Handle the error rather
    than segfault.

    Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
    Reviewed-by: Simon Horman <simon.horman@netronome.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    tools/testing/selftests/bpf/test_sockmap.c | 9 +++++++++
    1 file changed, 9 insertions(+)

    --- a/tools/testing/selftests/bpf/test_sockmap.c
    +++ b/tools/testing/selftests/bpf/test_sockmap.c
    @@ -332,6 +332,10 @@ static int msg_loop_sendpage(int fd, int
    int i, fp;

    file = fopen(".sendpage_tst.tmp", "w+");
    + if (!file) {
    + perror("create file for sendpage");
    + return 1;
    + }
    for (i = 0; i < iov_length * cnt; i++, k++)
    fwrite(&k, sizeof(char), 1, file);
    fflush(file);
    @@ -339,6 +343,11 @@ static int msg_loop_sendpage(int fd, int
    fclose(file);

    fp = open(".sendpage_tst.tmp", O_RDONLY);
    + if (fp < 0) {
    + perror("reopen file for sendpage");
    + return 1;
    + }
    +
    clock_gettime(CLOCK_MONOTONIC, &s->start);
    for (i = 0; i < cnt; i++) {
    int sent = sendfile(fd, fp, NULL, iov_length);

    \
     
     \ /
      Last update: 2019-12-03 23:45    [W:4.829 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site