Use ip/ipv6 structures in al_eth only if they are supported

The ip/ipv6 header files are included only if the appropriate definition
exists, but the driver was missing similar checks when using the
ip and ip6_hdr structures.

If the kernel was not built with the INET or INET6 option, the driver
was preventing kernel from being built.

To fix that, the missing ifdef checks were added to the driver.

PR: Bug 230886
Submitted by: Michal Krawczyk <mk@semihalf.com>
Reported by: O. Hartmann
Approved by: re (gjb)
Obtained from: Semihalf
MFC after: 1 week
Sponsored by: Amazon, Inc.
This commit is contained in:
Marcin Wojtas 2018-08-28 17:09:41 +00:00
parent 670c1e4b1c
commit 0b5cab4e0f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=338351

View File

@ -1202,8 +1202,12 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
uint32_t mss = m->m_pkthdr.tso_segsz;
struct ether_vlan_header *eh;
uint16_t etype;
#ifdef INET
struct ip *ip;
#endif
#ifdef INET6
struct ip6_hdr *ip6;
#endif
struct tcphdr *th = NULL;
int ehdrlen, ip_hlen = 0;
uint8_t ipproto = 0;
@ -1243,6 +1247,7 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
}
switch (etype) {
#ifdef INET
case ETHERTYPE_IP:
ip = (struct ip *)(m->m_data + ehdrlen);
ip_hlen = ip->ip_hl << 2;
@ -1256,6 +1261,8 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
else
hal_pkt->l4_proto_idx = AL_ETH_PROTO_ID_UDP;
break;
#endif /* INET */
#ifdef INET6
case ETHERTYPE_IPV6:
ip6 = (struct ip6_hdr *)(m->m_data + ehdrlen);
hal_pkt->l3_proto_idx = AL_ETH_PROTO_ID_IPv6;
@ -1267,6 +1274,7 @@ al_eth_tx_csum(struct al_eth_ring *tx_ring, struct al_eth_tx_buffer *tx_info,
else
hal_pkt->l4_proto_idx = AL_ETH_PROTO_ID_UDP;
break;
#endif /* INET6 */
default:
break;
}