Closed mj1595 closed 4 years ago
Hello,
I think that as a workaround, you can include these three folders in this order:
-I/usr/src/linux-headers-4.19.55.mptcp/include/generated/uapi
-I/usr/src/linux-headers-4.19.55.mptcp/include/uapi
-I/usr/src/linux-headers-4.19.55.mptcp/include
But that's a workaround and apparently not recommended. I would suggest you to follow instructions from https://kernelnewbies.org/KernelHeaders#User_space_programs
The correct way to package the header files for a distribution is to run 'make headers_install' from the kernel source directory to install the headers into /usr/include and then rebuild the C library package, with a dependency on the specific version of the just installed kernel headers.
If you are distributing a user space program that depends on a specific version of some kernel headers, e.g. because your program runs only on patched or very recent kernels, you cannot rely on the headers in /usr/include. You also cannot use the header files from /usr/src/linux/include or /lib/modules/*/build/include/ because they have not been prepared for inclusion in user space. The kernel should warn you about this if you try it and point you to this Wiki page. The correct way to address this problem is to isolate the specific interfaces that you need, e.g. a single header file that is patched in a new kernel providing the ioctl numbers for a character device used by your program. In your own program, add a copy of that source file, with a notice that it should be kept in sync with new kernel versions. If your program is not licensed under GPLv2, make sure you have permission from the author of that file to distribute it under the license of your own program. Since your program now depends on kernel interfaces that may not be present in a regular kernel, it's a good idea to add run-time checks that make sure the kernel understands the interface and give a helpful error message if there is no fallback to an older interface.
Please re-open this issue if it doesn't help.
Hello, I met the same problem that compiler_types.h:No such file or directory, and I have tried to include these three folders in this order,
-I/usr/src/linux-headers-4.19.55.mptcp/include/generated/uapi
-I/usr/src/linux-headers-4.19.55.mptcp/include/uapi
-I/usr/src/linux-headers-4.19.55.mptcp/include
then a lot of redeclaration errors occur. How should I include to address this problem?
@cxht do you have other "include"? Which version of the MPTCP kernel are you using? What's the compiler command you used?
@matttbe Thanks for your attention, I have addressed this problem after checking include headers, but another problem appears. When I call getsockopt() function, it always return -1. Is the location of getsockopt wrong or other?
My entire code is here:
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <linux/tcp.h>
#include <stdio.h>
#define MPTCP_INFO_FLAG_SAVE_MASTER 0x01
int main()
{
struct mptcp_info minfo;
struct mptcp_meta_info meta_info;
struct tcp_info initial;
struct tcp_info others[3];
struct mptcp_sub_info others_info[3];
int val = MPTCP_INFO_FLAG_SAVE_MASTER;
minfo.tcp_info_len = sizeof(struct tcp_info);
minfo.sub_len = sizeof(others);
minfo.meta_len = sizeof(struct mptcp_meta_info);
minfo.meta_info = &meta_info;
minfo.initial = &initial;
minfo.subflows = &others;
minfo.sub_info_len = sizeof(struct mptcp_sub_info);
minfo.total_sub_info_len = sizeof(others_info);
minfo.subflow_info = &others_info;
int sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sockfd == -1)
printf("\nsocket error");
struct sockaddr_in serv_addr;
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr("10.2.0.1");
serv_addr.sin_port = htons(8080);
char pathmanager[] = "fullmesh";
int a =setsockopt(sockfd, 6, MPTCP_PATH_MANAGER, pathmanager, sizeof(pathmanager));
printf("\nfullmesh a=%d",a);
char scheduler[] = "roundrobin";
a = setsockopt(sockfd, 6, MPTCP_SCHEDULER, scheduler, sizeof(scheduler));
printf("\nsch a=%d",a);
connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));
a= setsockopt(sockfd, 6, MPTCP_INFO, &val, sizeof(val));
printf("\n save master=%d",a);
int m = getsockopt(sockfd, 6, MPTCP_INFO, &minfo, sizeof(minfo));
if(m==-1)
{
printf("\ncannot getsockopt(MPTCP_INFO)");
//printf("\nerrno = %s\n",strerror(errno));
}
printf("bytes:%d\nuna:%d\nrtt:%d\n",minfo.initial->tcpi_bytes_sent,minfo.initial->tcpi_unacked,minfo.initial->tcpi_rtt);
char sendbuf[1024];
char recvbuf[1024];
FILE *f ;
f=fopen("random","r");
while(fgets(sendbuf, sizeof(sendbuf), f) > 0)
{
send(sockfd, sendbuf, strlen(sendbuf),0);
if(strcmp(sendbuf,"exit\n")==0)
break;
recv(sockfd, recvbuf, sizeof(recvbuf),0);
//fputs(recvbuf, stdout);
memset(sendbuf, 0, sizeof(sendbuf));
memset(recvbuf, 0, sizeof(recvbuf));
}
close(sockfd);
close(f);
return 0;
}
Thanks for your attention, I have addressed this problem after checking include headers
Good! We can keep this ticket closed.
but another problem appears. When I call getsockopt() function, it always return -1. Is the location of getsockopt wrong or other?
The issue seems different, may you create a new ticket with an answer for all these questions:
errno
value? (number + message)
I am trying to add mptcp linux kernel header files path into my code but I am getting the error given below. I had a look into the issues that were mentioned here already. I did use gcc -I /usr/src/linux-headers-4.19.55.mptcp/include/uapi. Kindly let me know what to be done?