vppinfra: fix compiling error due to incompatible udphdr field names 21/31421/2
authorJieqiang Wang <jieqiang.wang@arm.com>
Wed, 10 Feb 2021 15:16:51 +0000 (15:16 +0000)
committerBeno�t Ganne <bganne@cisco.com>
Thu, 4 Mar 2021 09:22:57 +0000 (09:22 +0000)
commit3f79e27409301217f493e41f104a848903ca4103
tree5bac33d93488b264d19b681ebc1e6810178a1909
parent57084e54082a29d19d2e4b71581c2a4980f8ce15
vppinfra: fix compiling error due to incompatible udphdr field names

Compiling VPP on CentOS 7 will fail shown as below. The root cause is
that uh_sport/uh_dport field names for struct udphdr are chosen only if
macro __FAVOR_BSD in /usr/include/netinet/udp.h is defined for glibc
version less than 2.19. Fix this issue by using source and dest field
names in struct udphdr for compatibility reasons.

FAILED: vppinfra/CMakeFiles/vppinfra.dir/unix-formats.c.o
ccache /opt/rh/devtoolset-9/root/bin/cc -Dvppinfra_EXPORTS -I/vpp/src -I. -Iinclude -Wno-address-of-packed-member -g -fPIC -Werror -Wall -march=corei7 -mtune=corei7-avx  -O2 -fstack-protector -D_FORTIFY_SOURCE=2 -fno-common  -flto -fno-fat-lto-objects -fPIC   -fvisibility=hidden -ffunction-sections -fdata-sections -MD -MT vppinfra/CMakeFiles/vppinfra.dir/unix-formats.c.o -MF vppinfra/CMakeFiles/vppinfra.dir/unix-formats.c.o.d -o vppinfra/CMakeFiles/vppinfra.dir/unix-formats.c.o   -c /vpp/src/vppinfra/unix-formats.c
/vpp/src/vppinfra/unix-formats.c: In function 'format_udp4_packet':
/vpp/src/vppinfra/unix-formats.c:319:19: error: 'struct udphdr' has no member named 'uh_sport'
  319 |   u16 source = udp->uh_sport;
      |                   ^~
/vpp/src/vppinfra/unix-formats.c:320:17: error: 'struct udphdr' has no member named 'uh_dport'
  320 |   u16 dest = udp->uh_dport;

Type: fix

Change-Id: Ifc99c7286ea3fac463096152267033ac0518c230
Signed-off-by: Jieqiang Wang <jieqiang.wang@arm.com>
Reviewed-by: Lijian Zhang <lijian.zhang@arm.com>
Reviewed-by: Tianyu Li <tianyu.li@arm.com>
src/vppinfra/unix-formats.c