From 7007975949f5177fbf2514633cc44ba0ac4712c5 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 27 Sep 2016 15:04:41 +0800 Subject: all: fix build on CentOS 6 by checking presence of several macros Protect usage of macros not present in pre-3.x kernels. Signed-off-by: Yousong Zhou Signed-off-by: Tobias Klauser --- dev.c | 2 ++ proto_nlmsg.c | 4 ++++ ring.h | 6 +++++- ring_rx.c | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dev.c b/dev.c index 5a43643..2960976 100644 --- a/dev.c +++ b/dev.c @@ -385,8 +385,10 @@ const char *device_type2str(uint16_t type) return "phonet"; case ARPHRD_PHONET_PIPE: return "phonet_pipe"; +#if defined(ARPHRD_CAIF) case ARPHRD_CAIF: return "caif"; +#endif case ARPHRD_IP6GRE: return "ip6gre"; case ARPHRD_NETLINK: diff --git a/proto_nlmsg.c b/proto_nlmsg.c index 6b43335..f8993e7 100644 --- a/proto_nlmsg.c +++ b/proto_nlmsg.c @@ -159,7 +159,9 @@ static const char *nlmsg_family2str(uint16_t family) case NETLINK_SCSITRANSPORT: return "SCSI transports"; case NETLINK_ECRYPTFS: return "ecryptfs"; case NETLINK_RDMA: return "RDMA"; +#if defined(NETLINK_CRYPTO) case NETLINK_CRYPTO: return "Crypto layer"; +#endif default: return "Unknown"; } } @@ -630,9 +632,11 @@ static void rtnl_print_route(struct nlmsghdr *hdr) rta_fmt(attr, "Pref Src %s", addr2str(rtm->rtm_family, RTA_DATA(attr), addr_str, sizeof(addr_str))); break; +#if defined(RTA_MARK) case RTA_MARK: rta_fmt(attr, "Mark 0x%x", RTA_UINT(attr)); break; +#endif case RTA_FLOW: rta_fmt(attr, "Flow 0x%x", RTA_UINT(attr)); break; diff --git a/ring.h b/ring.h index 1886781..d411fc4 100644 --- a/ring.h +++ b/ring.h @@ -70,7 +70,11 @@ static inline uint16_t tpacket_uhdr_vlan_proto(union tpacket_uhdr *hdr __maybe_u static inline bool tpacket_has_vlan_info(union tpacket_uhdr *hdr) { - uint32_t valid = TP_STATUS_VLAN_VALID; + uint32_t valid = 0; + +#ifdef TP_STATUS_VLAN_VALID + valid |= TP_STATUS_VLAN_VALID; +#endif #ifdef TP_STATUS_VLAN_TPID_VALID valid |= TP_STATUS_VLAN_TPID_VALID; diff --git a/ring_rx.c b/ring_rx.c index 8bfb658..99f8da0 100644 --- a/ring_rx.c +++ b/ring_rx.c @@ -202,12 +202,16 @@ static void join_fanout_group(int sock, uint32_t fanout_group, uint32_t fanout_t if (fanout_group == 0) return; +#if defined(PACKET_FANOUT) fanout_opt = (fanout_group & 0xffff) | (fanout_type << 16); ret = setsockopt(sock, SOL_PACKET, PACKET_FANOUT, &fanout_opt, sizeof(fanout_opt)); if (ret < 0) panic("Cannot set fanout ring mode!\n"); +#else + panic("fanout ring mode is not available!\n"); +#endif } void ring_rx_setup(struct ring *ring, int sock, size_t size, int ifindex, -- cgit v1.2.3-54-g00ecf