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

quic: fix build failure on older Linux versions #9

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

maxmouchet
Copy link

@maxmouchet maxmouchet commented Nov 8, 2023

The netinet/udp.h header is included twice in QUIC probe modules: once directly, and once through lib/includes.h.

This causes a build issue on older Linux versions (3.10):

/root/zmapv6/src/probe_modules/module_quic_initial.c: In function _quic_initial_make_packet_:                                                                    
/root/zmapv6/src/probe_modules/module_quic_initial.c:145:12: error: _struct udphdr_ has no member named _uh_sport_                                               
  udp_header->uh_sport =                                                                                                                                         
            ^                                                                                                                                                    
/root/zmapv6/src/probe_modules/module_quic_initial.c:176:12: error: _struct udphdr_ has no member named _uh_ulen_                                                
  udp_header->uh_ulen = ntohs(sizeof(struct udphdr) + payload_len);                                                                                              
            ^                                                                                                                                                    
In file included from /usr/include/bits/byteswap.h:35:0,                                                                                                         
                 from /usr/include/endian.h:60,                                                                                                                  
                 from /usr/include/sys/types.h:216,                                                                                                              
                 from /usr/include/netinet/udp.h:51,                                                                                                             
                 from /root/zmapv6/src/probe_modules/module_quic_initial.c:13:                                                                                   
/root/zmapv6/src/probe_modules/module_quic_initial.c: In function _quic_initial_print_packet_:                                                                   
/root/zmapv6/src/probe_modules/module_quic_initial.c:193:13: error: _struct udphdr_ has no member named _uh_sport_                                               
   ntohs(udph->uh_sport), ntohs(udph->uh_dport),                            

I think this is because in older kernels the udphdr struct was defined through an ifdef:

/* UDP header as specified by RFC 768, August 1980. */
#ifdef __FAVOR_BSD

struct udphdr
{
  u_int16_t uh_sport;                /* source port */
  u_int16_t uh_dport;                /* destination port */
  u_int16_t uh_ulen;                /* udp length */
  u_int16_t uh_sum;                /* udp checksum */
};

#else

struct udphdr
{
  u_int16_t source;
  u_int16_t dest;
  u_int16_t len;
  u_int16_t check;
};
#endif

Whereas it's a union in newer kernels.

Including the header through lib/includes.h fixes the issue because it defines __FAVOR_BSD if not already defined.

Copy link

@ogasser ogasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good to me 👍

The main issue is that in these files we were including netinet/udp.h before includes.h. output_modules/module_json.c also includes netinet/udp.h, but does not run into this issue due to includes.h being included first.

So from my side this looks good to be merged. What do you think @zirngibl @sattler ?

@zirngibl
Copy link

Sorry for the late reply but looks good to me as well

@zirngibl zirngibl merged commit b2e8392 into tumi8:master Nov 23, 2023
@maxmouchet maxmouchet deleted the fix-udphdr branch November 23, 2023 13:23
mkoch-tud pushed a commit to mkoch-tud/zmap that referenced this pull request Oct 10, 2024
…ap#780)

* fist pass at a debian workflow

* Refactored debian workflow into a common bsd/linux yml. Edited Dockerfile

* attempt #2

* attempt tumi8#3

* attempt tumi8#4

* attempt tumi8#5

* attempt tumi8#6

* attempt tumi8#7

* attempt tumi8#8

* attempt tumi8#9

* attempt tumi8#10, at least we're getting into the debian dockerfile

* Looks like its working, causing a compile error in get_gateway_linux to see if check fails

* Confirmed, debian workflow is working!

* Removed debugging ls in .yml

* testing arch build

* Added fedora test

* testing Gentoo test

* phillip/773: refactored all the github compile actions to be in a single .yml file

* phillip/773: added arch and gentoo Install instructions

* phillip/773: removed extra space in arch.Dockerfile

* phillip/773: apparently the free-bsd vm is picky about having the run being on the same line
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

Successfully merging this pull request may close these issues.

3 participants