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

Can't compile v 2.3.2 on Apline Linux 3.20 #2503

Open
MarcelloPercoco opened this issue Nov 9, 2024 · 6 comments
Open

Can't compile v 2.3.2 on Apline Linux 3.20 #2503

MarcelloPercoco opened this issue Nov 9, 2024 · 6 comments

Comments

@MarcelloPercoco
Copy link

MarcelloPercoco commented Nov 9, 2024

Hello,

i have some errors trying to compile keepalived 2.3.2 with alpine 3.20.
Any idea how to fix this?

/bin/bash ./configure --disable-dynamic-linking

Errors:

37.60 In file included from /usr/include/net/ethernet.h:10,
37.60 from vrrp.c:44:
37.60 /usr/include/netinet/if_ether.h:115:8: error: redefinition of 'struct ethhdr'
37.60 115 | struct ethhdr {
37.60 | ^~~~~~
37.60 In file included from vrrp.c:43:
37.60 /usr/include/linux/if_ether.h:173:8: note: originally defined here
37.60 173 | struct ethhdr {
37.60 | ^~~~~~

Packages installed:

bash
autoconf
curl
libgcc
libip4tc
libip6tc
gcc
ipset
ipset-dev
iptables
iptables-dev
libnfnetlink
libnfnetlink-dev
libnl3
libnl3-dev
make
musl-dev
openssl
openssl-dev

Thanks and best regards

@rmartin16
Copy link
Contributor

This issue should be resolved now via f129c58 (via #2499).

However, even once I build from master branch now, I get a seg fault at runtime.

❯ docker run --rm -it keepalived
Keepalived[1]: Starting Keepalived v2.3.2 (11/08,2024), git commit v2.3.2-13-g48dbf3d0
Keepalived[1]: Running on Linux 6.9.3-76060903-generic #202405300957~1726766035~22.04~4092a0e SMP PREEMPT_DYNAMIC Thu S (built for Linux 6.6.0)
Keepalived[1]: Command line: '/usr/sbin/keepalived' '--dont-fork' '--log-console' '-f'
Keepalived[1]:               '/etc/keepalived/keepalived.conf'
Keepalived[1]: Configuration file /etc/keepalived/keepalived.conf
Keepalived[1]: NOTICE: setting config option max_auto_priority should result in better keepalived performance
Keepalived[1]: Starting VRRP child process, pid=7
Keepalived[1]: pid 7 exited due to segmentation fault (SIGSEGV).

I'm still trying to diagnose this...

@rmartin16
Copy link
Contributor

Looks like some directories are assumed to already exist when they do not on Alpine.

Notably, these two:

/usr/share/iproute2/rt_addrprotos.d
/etc/iproute2/rt_addrprotos.d

Once these directories exist, keepalived no longer seg faults.

backtraces
/ # gdb /usr/sbin/keepalived /coredump/core-keepalived.10.ee22c551c350.1731169922 
GNU gdb (GDB) 14.2

Reading symbols from /usr/sbin/keepalived...
[New LWP 10]
Core was generated by `keepalived --dont-fork --log-console'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007768585b606b in closedir (dir=dir@entry=0x0) at src/dirent/closedir.c:8

warning: 8	src/dirent/closedir.c: No such file or directory
(gdb) bt full
#0  0x00007768585b606b in closedir (dir=dir@entry=0x0) at src/dirent/closedir.c:8
        ret = <optimized out>
#1  0x000057a0c3f1fe74 in initialise_list (l=l@entry=0x57a0c3f51a10 <rt_addrprotos>, file_name=file_name@entry=0x57a0c3f277c0 "rt_addrprotos", 
    default_list=default_list@entry=0x57a0c3f4ff40 <rtaddrproto_default>, max=max@entry=255) at rttables.c:416
        path = 0x77685805f050 "/usr/share/iproute2/rt_addrprotos.d"
        etc_path = 0x776858060590 ""
        statbuf = {st_dev = 0, st_ino = 0, st_nlink = 0, st_mode = 3287440415, st_uid = 22432, st_gid = 0, __pad0 = 0, st_rdev = 96347993382616, st_size = 65, st_blksize = 131290042909961, 
          st_blocks = 0, st_atim = {tv_sec = 206158430232, tv_nsec = 140734826375680}, st_mtim = {tv_sec = 140734826375488, tv_nsec = 140734826375696}, st_ctim = {tv_sec = 140734826375504, tv_nsec = 0}, 
          __unused = {-1, 0, 0}}
        ent = <optimized out>
        dir = 0x0
#2  0x000057a0c3f20100 in initialise_list (max=255, default_list=0x57a0c3f4ff40 <rtaddrproto_default>, file_name=0x57a0c3f277c0 "rt_addrprotos", l=0x57a0c3f51a10 <rt_addrprotos>) at rttables.c:458
        etc_path = <optimized out>
        statbuf = <optimized out>
        ent = <optimized out>
        dir = <optimized out>
        path = <optimized out>
        path = <optimized out>
        etc_path = <optimized out>
        statbuf = <optimized out>
        ent = <optimized out>
        dir = <optimized out>
#3  find_entry (name=name@entry=0x57a0c3f25c1f "keepalived", id=id@entry=0x7fff61556a14, l=l@entry=0x57a0c3f51a10 <rt_addrprotos>, file_name=file_name@entry=0x57a0c3f277c0 "rt_addrprotos", 
    default_list=default_list@entry=0x57a0c3f4ff40 <rtaddrproto_default>, max=max@entry=255) at rttables.c:453
        endptr = 0x57a0c3f25c1f "keepalived"
        l_id = <optimized out>
        rte = <optimized out>
#4  0x000057a0c3f205dd in find_rttables_addrproto (name=name@entry=0x57a0c3f25c1f "keepalived", id=id@entry=0x57a0c3f520d2 <address_protocol> "") at rttables.c:698
        val = 0
#5  0x000057a0c3efd69f in set_addrproto () at vrrp_ipaddress.c:854
No locals.
#6  0x000057a0c3ee038c in start_vrrp_child () at vrrp_daemon.c:1130
        pid = <optimized out>
        syslog_ident = <optimized out>
#7  0x000057a0c3eb71f3 in start_keepalived (thread=<optimized out>) at main.c:548
        have_child = false
#8  0x000057a0c3f16c2e in thread_call (thread=0x776858088a70) at scheduler.c:2078
--Type <RET> for more, q to quit, c to continue without paging--c
No locals.
#9  process_threads (m=0x776858088e70) at scheduler.c:2145
        thread = 0x776858088a70
        thread_list = <optimized out>
        thread_type = 7
        exit_code = <optimized out>
#10 0x000057a0c3f174e1 in launch_thread_scheduler (m=<optimized out>) at scheduler.c:2267
No locals.
#11 0x000057a0c3eb9232 in keepalived_main (argc=<optimized out>, argv=<optimized out>) at main.c:2869
        report_stopped = true
        uname_buf = {sysname = "Linux", '\000' <repeats 59 times>, nodename = "ee22c551c350", '\000' <repeats 52 times>, release = "6.9.3-76060903-generic", '\000' <repeats 42 times>, 
          version = "#202405300957~1726766035~22.04~4092a0e SMP PREEMPT_DYNAMIC Thu S", machine = "x86_64", '\000' <repeats 58 times>, domainname = "(none)", '\000' <repeats 58 times>}
        end = 0x7fff61556bed ""
        exit_code = 0
        magic = <optimized out>
        script_flags = <optimized out>
        usage = {ru_utime = {tv_sec = 0, tv_usec = 1731169174}, ru_stime = {tv_sec = 606637922, tv_usec = 0}, ru_maxrss = 0, ru_ixrss = 0, ru_idrss = 0, ru_isrss = 0, ru_minflt = 0, ru_majflt = 0, 
          ru_nswap = 0, ru_inblock = 0, ru_oublock = 0, ru_msgsnd = 0, ru_msgrcv = 0, ru_nsignals = 0, ru_nvcsw = 0, ru_nivcsw = 0, __reserved = {0 <repeats 16 times>}}
        child_usage = {ru_utime = {tv_sec = 96347993806029, tv_usec = 1}, ru_stime = {tv_sec = 0, tv_usec = 102}, ru_maxrss = 96347993806143, ru_ixrss = 0, ru_idrss = 0, ru_isrss = 80, 
          ru_minflt = 96347993824500, ru_majflt = 0, ru_nswap = 0, ru_inblock = 67, ru_oublock = 96347993806038, ru_msgsnd = 0, ru_msgrcv = 0, ru_nsignals = 66, ru_nvcsw = 96347993826898, ru_nivcsw = 0, 
          __reserved = {0, 3, 96347993806045, 0, 0, 108, 96347993806057, 0, 0, 68, 96347993806068, 1, 0, 83, 96347993806081, 2}}
        name = <optimized out>
        end = <optimized out>
#12 0x00007768585b670a in libc_start_main_stage2 (main=0x57a0c3eb6080 <main>, argc=3, argv=0x7fff61557428) at src/env/__libc_start_main.c:95
        envp = 0x7fff61557448
#13 0x000057a0c3eb609b in _start ()
No symbol table info available.
/ # gdb /usr/sbin/keepalived /coredump/core-keepalived.108.ee22c551c350.1731170082 
GNU gdb (GDB) 14.2

Reading symbols from /usr/sbin/keepalived...
[New LWP 108]
Core was generated by `keepalived --dont-fork --log-console'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000731be928006b in closedir (dir=dir@entry=0x0) at src/dirent/closedir.c:8

warning: 8	src/dirent/closedir.c: No such file or directory
(gdb) bt full
#0  0x0000731be928006b in closedir (dir=dir@entry=0x0) at src/dirent/closedir.c:8
        ret = <optimized out>
#1  0x00005bbee67b1ef3 in initialise_list (l=l@entry=0x5bbee67e3a10 <rt_addrprotos>, file_name=file_name@entry=0x5bbee67b97c0 "rt_addrprotos", 
    default_list=default_list@entry=0x5bbee67e1f40 <rtaddrproto_default>, max=max@entry=255) at rttables.c:429
        path = 0x731be8d29050 "/etc/iproute2/rt_addrprotos.d"
        etc_path = 0x731be8d2a590 ""
        statbuf = {st_dev = 0, st_ino = 0, st_nlink = 0, st_mode = 3866852383, st_uid = 23486, st_gid = 0, __pad0 = 0, st_rdev = 100875468324568, st_size = 65, st_blksize = 126563713246473, 
          st_blocks = 0, st_atim = {tv_sec = 206158430232, tv_nsec = 140729481743296}, st_mtim = {tv_sec = 140729481743104, tv_nsec = 140729481743312}, st_ctim = {tv_sec = 140729481743120, tv_nsec = 0}, 
          __unused = {-1, 0, 0}}
        ent = <optimized out>
        dir = 0x0
#2  0x00005bbee67b2100 in initialise_list (max=255, default_list=0x5bbee67e1f40 <rtaddrproto_default>, file_name=0x5bbee67b97c0 "rt_addrprotos", l=0x5bbee67e3a10 <rt_addrprotos>) at rttables.c:458
        etc_path = <optimized out>
        statbuf = <optimized out>
        ent = <optimized out>
        dir = <optimized out>
        path = <optimized out>
        path = <optimized out>
        etc_path = <optimized out>
        statbuf = <optimized out>
        ent = <optimized out>
        dir = <optimized out>
#3  find_entry (name=name@entry=0x5bbee67b7c1f "keepalived", id=id@entry=0x7ffe22c4cbd4, l=l@entry=0x5bbee67e3a10 <rt_addrprotos>, file_name=file_name@entry=0x5bbee67b97c0 "rt_addrprotos", 
    default_list=default_list@entry=0x5bbee67e1f40 <rtaddrproto_default>, max=max@entry=255) at rttables.c:453
        endptr = 0x5bbee67b7c1f "keepalived"
        l_id = <optimized out>
        rte = <optimized out>
#4  0x00005bbee67b25dd in find_rttables_addrproto (name=name@entry=0x5bbee67b7c1f "keepalived", id=id@entry=0x5bbee67e40d2 <address_protocol> "") at rttables.c:698
        val = 0
#5  0x00005bbee678f69f in set_addrproto () at vrrp_ipaddress.c:854
No locals.
#6  0x00005bbee677238c in start_vrrp_child () at vrrp_daemon.c:1130
        pid = <optimized out>
        syslog_ident = <optimized out>
#7  0x00005bbee67491f3 in start_keepalived (thread=<optimized out>) at main.c:548
        have_child = false
#8  0x00005bbee67a8c2e in thread_call (thread=0x731be8d52a70) at scheduler.c:2078
--Type <RET> for more, q to quit, c to continue without paging--c
No locals.
#9  process_threads (m=0x731be8d52e70) at scheduler.c:2145
        thread = 0x731be8d52a70
        thread_list = <optimized out>
        thread_type = 7
        exit_code = <optimized out>
#10 0x00005bbee67a94e1 in launch_thread_scheduler (m=<optimized out>) at scheduler.c:2267
No locals.
#11 0x00005bbee674b232 in keepalived_main (argc=<optimized out>, argv=<optimized out>) at main.c:2869
        report_stopped = true
        uname_buf = {sysname = "Linux", '\000' <repeats 59 times>, nodename = "ee22c551c350", '\000' <repeats 52 times>, release = "6.9.3-76060903-generic", '\000' <repeats 42 times>, 
          version = "#202405300957~1726766035~22.04~4092a0e SMP PREEMPT_DYNAMIC Thu S", machine = "x86_64", '\000' <repeats 58 times>, domainname = "(none)", '\000' <repeats 58 times>}
        end = 0x7ffe22c4cdad ""
        exit_code = 0
        magic = <optimized out>
        script_flags = <optimized out>
        usage = {ru_utime = {tv_sec = 0, tv_usec = 1731169174}, ru_stime = {tv_sec = 606637922, tv_usec = 0}, ru_maxrss = 0, ru_ixrss = 0, ru_idrss = 0, ru_isrss = 0, ru_minflt = 0, ru_majflt = 0, 
          ru_nswap = 0, ru_inblock = 0, ru_oublock = 0, ru_msgsnd = 0, ru_msgrcv = 0, ru_nsignals = 0, ru_nvcsw = 0, ru_nivcsw = 0, __reserved = {0 <repeats 16 times>}}
        child_usage = {ru_utime = {tv_sec = 100875468747981, tv_usec = 1}, ru_stime = {tv_sec = 0, tv_usec = 102}, ru_maxrss = 100875468748095, ru_ixrss = 0, ru_idrss = 0, ru_isrss = 80, 
          ru_minflt = 100875468766452, ru_majflt = 0, ru_nswap = 0, ru_inblock = 67, ru_oublock = 100875468747990, ru_msgsnd = 0, ru_msgrcv = 0, ru_nsignals = 66, ru_nvcsw = 100875468768850, 
          ru_nivcsw = 0, __reserved = {0, 3, 100875468747997, 0, 0, 108, 100875468748009, 0, 0, 68, 100875468748020, 1, 0, 83, 100875468748033, 2}}
        name = <optimized out>
        end = <optimized out>
#12 0x0000731be928070a in libc_start_main_stage2 (main=0x5bbee6748080 <main>, argc=3, argv=0x7ffe22c4d5e8) at src/env/__libc_start_main.c:95
        envp = 0x7ffe22c4d608
#13 0x00005bbee674809b in _start ()
No symbol table info available.

@rmartin16
Copy link
Contributor

@MarcelloPercoco,

FWIW, this is what I'm updating so I can build the 2.3.2 release:

  • Update vrrp.c to not include linux/if_ether.h
    • sed -i 's/#include <linux\/if_ether.h>//' keepalived/vrrp/vrrp.c
  • Run ./configure with bash instead of sh
  • Install linux-headers alongside the other necessary packages
  • Ensure /usr/share/iproute2/rt_addrprotos.d and /etc/iproute2/rt_addrprotos.d directories exist

@MarcelloPercoco
Copy link
Author

@rmartin16

Thanks, i will give it a try :)

@pqarmitage
Copy link
Collaborator

Commit f129c58 has already been mentioned - with musl headers you cannot include both <net/ethernet.h> and <linux/if_ether.h> since they both define struct ethhdr. With glibc <net/ethernet.h> includes <linux/if_ether.h> to obtain the definition of struct ethhdr, and there are the proper include guards to stop a duplicate definition.

Commit ada5254 resolves the configure issues and makes it work with busybox sh.

Commit 042dc49 fixes the segfault. I really don't know what I was thinking when I wrote that bit of code!

I will make some further changes to better handle no /etc/iproute2 or /usr/share/iproute2 directories, but the latest commit appears to work for now.

@MarcelloPercoco
Copy link
Author

@rmartin16

Hi.

I've tried with your suggestion and can confirm that compile and works on alpine linux.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants