Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some function tests returned error #24

Closed
jijianwen opened this issue May 2, 2018 · 3 comments
Closed

Some function tests returned error #24

jijianwen opened this issue May 2, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@jijianwen
Copy link
Contributor

Commit eaf7032 fixed the compilation error. My system is rhel-7.5 which has /usr/include/linux/sctp.h,but when compiling lksctp-tools, it uses src/include/linux/sctp.h as default. After compilation, I got some error when executing test programs under func_tests directory. The reason should be that some structures are different between 2 header files. For example:
setsockopt(SCTP_EVENTS) in test_1_to_1_events returned Invalid arguments.

I think kernel checked the size of relevant struct and returned error for there are more fields in src/include/linux/sctp.h than /usr/include/linux/sctp.h

@marceloleitner marceloleitner self-assigned this May 2, 2018
@marceloleitner marceloleitner added this to the 1.0.18 milestone May 2, 2018
@marceloleitner
Copy link
Contributor

Your reasoning is correct. This exhibits a backward compatibility issue that was already there: newer lksctp-tools, with updated structs, also wouldn't work with kernels not having those fields in struct sctp_event_subscribe.

@marceloleitner marceloleitner removed this from the 1.0.18 milestone May 2, 2018
@marceloleitner
Copy link
Contributor

We should fix this at kernel level, with something like:

--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2320,7 +2320,7 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
        struct sctp_ulpevent *event;

        if (optlen > sizeof(struct sctp_event_subscribe))
-               return -EINVAL;
+               optlen = sizeof(struct sctp_event_subscribe);
        if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
                return -EFAULT;

@@ -2342,7 +2342,7 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
                }
        }

-       return 0;
+       return optlen;
 }

 /* 7.1.8 Automatic Close of associations (SCTP_AUTOCLOSE)

Still need to check for other possible occurrences of similar issues.

@marceloleitner
Copy link
Contributor

Scratch my previous comment. The issue is that the local copy is always being used, even where it should be using the system UAPI one. I fixed issue #22 and issue #23 wrongly. Instead, the library needs to probe what the kernel supports while building and only use that.
I'll use this issue to fix all this.

@marceloleitner marceloleitner added this to the 1.0.18 milestone May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants