Skip to content

Commit 77e4245

Browse files
committed
net: ethernet: Remove length update
The length update for ip and ipv6 is done in the respecive protocol functions. Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
1 parent 8ce480b commit 77e4245

File tree

1 file changed

+0
-46
lines changed

1 file changed

+0
-46
lines changed

subsys/net/l2/ethernet/ethernet.c

-46
Original file line numberDiff line numberDiff line change
@@ -118,48 +118,6 @@ void net_eth_ipv6_mcast_to_mac_addr(const struct in6_addr *ipv6_addr,
118118
#define print_vlan_ll_addrs(...)
119119
#endif /* CONFIG_NET_VLAN */
120120

121-
static inline void ethernet_update_length(struct net_if *iface,
122-
struct net_pkt *pkt)
123-
{
124-
uint16_t len;
125-
#ifdef CONFIG_NET_VLAN
126-
const uint16_t min_len =
127-
NET_ETH_MINIMAL_FRAME_SIZE - (net_pkt_vlan_tag(pkt) != NET_VLAN_TAG_UNSPEC
128-
? sizeof(struct net_eth_vlan_hdr)
129-
: sizeof(struct net_eth_hdr));
130-
#else
131-
const uint16_t min_len = NET_ETH_MINIMAL_FRAME_SIZE - sizeof(struct net_eth_hdr);
132-
#endif
133-
134-
/* Let's check IP payload's length. If it's smaller than 46 bytes,
135-
* i.e. smaller than minimal Ethernet frame size minus ethernet
136-
* header size,then Ethernet has padded so it fits in the minimal
137-
* frame size of 60 bytes. In that case, we need to get rid of it.
138-
*/
139-
140-
if (net_pkt_family(pkt) == AF_INET) {
141-
len = ntohs(NET_IPV4_HDR(pkt)->len);
142-
} else if (net_pkt_family(pkt) == AF_INET6) {
143-
len = ntohs(NET_IPV6_HDR(pkt)->len) + NET_IPV6H_LEN;
144-
} else {
145-
return;
146-
}
147-
148-
if (len < min_len) {
149-
struct net_buf *frag;
150-
151-
for (frag = pkt->frags; frag; frag = frag->frags) {
152-
if (frag->len < len) {
153-
len -= frag->len;
154-
} else {
155-
frag->len = len;
156-
len = 0U;
157-
}
158-
}
159-
}
160-
}
161-
162-
163121
static void ethernet_update_rx_stats(struct net_if *iface, size_t length,
164122
bool dst_broadcast, bool dst_eth_multicast)
165123
{
@@ -357,10 +315,6 @@ static enum net_verdict ethernet_recv(struct net_if *iface,
357315

358316
body_len = net_pkt_get_len(pkt);
359317

360-
if (type != NET_ETH_PTYPE_EAPOL) {
361-
ethernet_update_length(iface, pkt);
362-
}
363-
364318
ethernet_update_rx_stats(iface, body_len + hdr_len, dst_broadcast, dst_eth_multicast);
365319
return verdict;
366320
drop:

0 commit comments

Comments
 (0)