wangyu- / udp2raw

A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
MIT License
7.16k stars 1.16k forks source link

Build fails with linux 6.5 headers #492

Open chvp opened 11 months ago

chvp commented 11 months ago

Since this commit, sockaddr_ll includes a flex array, leading to the following build errors:

In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/log.h:5,
                 from /build/source/log.cpp:1:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct packet_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/misc.h:13,
                 from /build/source/log.cpp:2:
/build/source/network.h:233:11: note: next member 'i32_t packet_info_t::data_len' declared here
  233 |     i32_t data_len;
      |           ^~~~~~~~
/build/source/network.h:204:8: note: in the definition of 'struct packet_info_t'
  204 | struct packet_info_t  // todo change this to union
      |        ^~~~~~~~~~~~~
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
/build/source/network.h:233:11: note: next member 'i32_t packet_info_t::data_len' declared here
  233 |     i32_t data_len;
      |           ^~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:76: CMakeFiles/udp2raw.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:146: CMakeFiles/udp2raw.dir/log.cpp.o] Error 1
In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/common.cpp:8:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct packet_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/misc.h:13,
                 from /build/source/common.cpp:10:
/build/source/network.h:233:11: note: next member 'i32_t packet_info_t::data_len' declared here
  233 |     i32_t data_len;
      |           ^~~~~~~~
/build/source/network.h:204:8: note: in the definition of 'struct packet_info_t'
  204 | struct packet_info_t  // todo change this to union
      |        ^~~~~~~~~~~~~
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
/build/source/network.h:233:11: note: next member 'i32_t packet_info_t::data_len' declared here
  233 |     i32_t data_len;
      |           ^~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:174: CMakeFiles/udp2raw.dir/common.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/udp2raw.dir/all] Error 2
wangyu- commented 11 months ago

I tried to make a fix in d1a9bcc4fb5a7c4f65e96de0f0561af507f627b2

/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);

since it's complaining not at the end, I moved it to the end.

Please check if the commit fix the issue (i don't have a linux 6.5 kernel machine to test yet)

chvp commented 11 months ago

Unfortunately that still fails. These are the errors:

In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/network.cpp:7:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/network.cpp:8:
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/log.h:5,
                 from /build/source/log.cpp:1:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/misc.h:13,
                 from /build/source/log.cpp:2:
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/main.cpp:1:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/main.cpp:2:
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:146: CMakeFiles/udp2raw.dir/log.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct conn_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
In file included from /build/source/main.cpp:3:
/build/source/connection.h:218:8: note: in the definition of 'struct conn_info_t'
  218 | struct conn_info_t  // stores info for a raw connection.for client ,there is only one connection,for server there can be thousand of connection since server can
      |        ^~~~~~~~~~~
In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/common.cpp:8:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/misc.h:13,
                 from /build/source/common.cpp:10:
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:76: CMakeFiles/udp2raw.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:160: CMakeFiles/udp2raw.dir/network.cpp.o] Error 1
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:174: CMakeFiles/udp2raw.dir/common.cpp.o] Error 1
In file included from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/posix_types.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/types.h:9,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/stat.h:5,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/statx.h:31,
                 from /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/sys/stat.h:465,
                 from /build/source/common.h:20,
                 from /build/source/connection.h:14,
                 from /build/source/connection.cpp:8:
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct raw_info_'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
In file included from /build/source/connection.h:16:
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
/build/source/network.h:238:8: note: in the definition of 'struct raw_info_t'
  238 | struct raw_info_t {
      |        ^~~~~~~~~~
/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct conn_info_t'
   24 |                 __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
      |                 ^~~~~~~~~~~~~~~~~~~~
/build/source/network.h:240:19: note: next member 'packet_info_t raw_info_t::recv_info' declared here
  240 |     packet_info_t recv_info;
      |                   ^~~~~~~~~
/build/source/connection.h:218:8: note: in the definition of 'struct conn_info_t'
  218 | struct conn_info_t  // stores info for a raw connection.for client ,there is only one connection,for server there can be thousand of connection since server can
      |        ^~~~~~~~~~~
make[2]: *** [CMakeFiles/udp2raw.dir/build.make:188: CMakeFiles/udp2raw.dir/connection.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/udp2raw.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Wyk72 commented 4 months ago

Same problem here:

/usr/include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::::::sll_addr_flex' not at end of 'struct raw_info_t' 24 | __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex); | ^~~~~~~~

Alpine Linux Kernel 6.6

wangyu- commented 4 months ago

sorry I was a bit busy.

let me try to fix in this month.

it should be a simple fix, but I don't have the environment at hand.

wangyu- commented 3 months ago

Hi, I cannot reproduce this compile error.

root@vultr:~/udp2raw# uname -r
6.8.0-31-generic
root@vultr:~/udp2raw# sudo apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
linux-headers-6.8.0-31-generic is already the newest version (6.8.0-31.31).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@vultr:~/udp2raw# make
echo "const char *gitversion = \"248acee50bee94603a3f55694fcc88f73ffd8b70\";" > git_version.h
rm -f udp2raw
g++   -o udp2raw          -I. main.cpp lib/md5.cpp lib/pbkdf2-sha1.cpp lib/pbkdf2-sha256.cpp encrypt.cpp log.cpp network.cpp common.cpp  connection.cpp misc.cpp fd_manager.cpp client.cpp server.cpp -lpthread lib/aes_faster_c/aes.cpp lib/aes_faster_c/wrapper.cpp my_ev.cpp -isystem libev -std=c++11   -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers  -lrt -ggdb -static -O2
root@vultr:~/udp2raw#

Here is the head definition in 6.8.0:

root@vultr:~/udp2raw# cat /usr/src/linux-headers-6.8.0-31/include/uapi/linux/if_packet.h |head -n30
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef __LINUX_IF_PACKET_H
#define __LINUX_IF_PACKET_H

#include <asm/byteorder.h>
#include <linux/types.h>

struct sockaddr_pkt {
    unsigned short spkt_family;
    unsigned char spkt_device[14];
    __be16 spkt_protocol;
};

struct sockaddr_ll {
    unsigned short  sll_family;
    __be16      sll_protocol;
    int     sll_ifindex;
    unsigned short  sll_hatype;
    unsigned char   sll_pkttype;
    unsigned char   sll_halen;
    unsigned char   sll_addr[8];
};

Does this mean the kernel community has reverted the change? (and as a result we don't need a fix on our side any more?)