From 65f474bbae9a33b08707084efb95701e187f79e3 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Thu, 23 Feb 2023 19:50:49 +0900 Subject: net/eth: Introduce EthL4HdrProto igb, a new network device emulation, will need SCTP checksum offloading. Currently eth_get_protocols() has a bool parameter for each protocol currently it supports, but there will be a bit too many parameters if we add yet another protocol. Introduce an enum type, EthL4HdrProto to represent all L4 protocols eth_get_protocols() support with one parameter. Signed-off-by: Akihiko Odaki Signed-off-by: Jason Wang --- net/eth.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'net/eth.c') diff --git a/net/eth.c b/net/eth.c index c1c14cf6b9..70bcd8e355 100644 --- a/net/eth.c +++ b/net/eth.c @@ -138,7 +138,6 @@ _eth_tcp_has_data(bool is_ip4, void eth_get_protocols(const struct iovec *iov, int iovcnt, bool *hasip4, bool *hasip6, - bool *hasudp, bool *hastcp, size_t *l3hdr_off, size_t *l4hdr_off, size_t *l5hdr_off, @@ -153,7 +152,8 @@ void eth_get_protocols(const struct iovec *iov, int iovcnt, size_t copied; uint8_t ip_p; - *hasip4 = *hasip6 = *hasudp = *hastcp = false; + *hasip4 = *hasip6 = false; + l4hdr_info->proto = ETH_L4_HDR_PROTO_INVALID; proto = eth_get_l3_proto(iov, iovcnt, l2hdr_len); @@ -197,11 +197,11 @@ void eth_get_protocols(const struct iovec *iov, int iovcnt, switch (ip_p) { case IP_PROTO_TCP: - *hastcp = _eth_copy_chunk(input_size, - iov, iovcnt, - *l4hdr_off, sizeof(l4hdr_info->hdr.tcp), - &l4hdr_info->hdr.tcp); - if (*hastcp) { + if (_eth_copy_chunk(input_size, + iov, iovcnt, + *l4hdr_off, sizeof(l4hdr_info->hdr.tcp), + &l4hdr_info->hdr.tcp)) { + l4hdr_info->proto = ETH_L4_HDR_PROTO_TCP; *l5hdr_off = *l4hdr_off + TCP_HEADER_DATA_OFFSET(&l4hdr_info->hdr.tcp); @@ -215,11 +215,13 @@ void eth_get_protocols(const struct iovec *iov, int iovcnt, break; case IP_PROTO_UDP: - *hasudp = _eth_copy_chunk(input_size, - iov, iovcnt, - *l4hdr_off, sizeof(l4hdr_info->hdr.udp), - &l4hdr_info->hdr.udp); - *l5hdr_off = *l4hdr_off + sizeof(l4hdr_info->hdr.udp); + if (_eth_copy_chunk(input_size, + iov, iovcnt, + *l4hdr_off, sizeof(l4hdr_info->hdr.udp), + &l4hdr_info->hdr.udp)) { + l4hdr_info->proto = ETH_L4_HDR_PROTO_UDP; + *l5hdr_off = *l4hdr_off + sizeof(l4hdr_info->hdr.udp); + } break; } } -- cgit v1.2.3