diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 25fd323be74..3e9aaf89aa2 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -80,7 +80,6 @@ void devif_forward(FAR struct forward_s *fwd) /* Copy the IOB chain that contains the L3L3 headers and any data payload */ - DEBUGASSERT(fwd->f_iob->io_pktlen >= fwd->f_hdrsize); DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev)); ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob, fwd->f_iob->io_pktlen, 0); diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index 3180f16ac71..40c7c757da8 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -163,7 +163,6 @@ struct forward_s FAR struct iob_s *f_iob; /* IOB chain containing the packet */ FAR struct devif_callback_s *f_cb; /* Reference to callback instance */ union fwd_conn_u f_conn; /* Protocol-specific connection struct */ - uint8_t f_hdrsize; /* The size of the L2+L3 headers */ }; /**************************************************************************** diff --git a/net/devif/ipv4_forward.c b/net/devif/ipv4_forward.c index 20077493136..075f47bc7a8 100644 --- a/net/devif/ipv4_forward.c +++ b/net/devif/ipv4_forward.c @@ -80,7 +80,7 @@ * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC +#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN) static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) { /* Size is determined by the following protocol header, */ @@ -267,7 +267,9 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) { FAR struct forward_s *fwd = NULL; +#ifdef CONFIG_DEBUG_NET_WARN int hdrsize; +#endif int ret; /* Verify that the full packet will fit within the forwarding devices MTU. @@ -297,16 +299,8 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, fwd->f_dev = fwddev; /* Forwarding device */ - /* Get the size of the IPv4 + L3 header. Use this to determine start of - * the data payload. - * - * Remember that the size of the L1 header has already been subtracted - * from dev->d_len. - * - * REVISIT: Consider an alternative design that does not require data - * copying. This would require a pool of d_buf's that are managed by - * the network rather than the network device. - */ +#ifdef CONFIG_DEBUG_NET_WARN + /* Get the size of the IPv4 + L3 header. */ hdrsize = ipv4_hdrsize(ipv4); if (hdrsize < IPv4_HDRLEN) @@ -324,8 +318,7 @@ static int ipv4_dev_forward(FAR struct net_driver_s *dev, ret = -E2BIG; goto errout_with_fwd; } - - fwd->f_hdrsize = hdrsize; +#endif /* Try to allocate the head of an IOB chain. If this fails, the * packet will be dropped; we are not operating in a context diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 1ece8ccee76..240ed6de6a3 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -86,7 +86,7 @@ * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC +#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN) static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) { /* Size is determined by the following protocol header, */ @@ -368,7 +368,9 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) { FAR struct forward_s *fwd = NULL; +#ifdef CONFIG_DEBUG_NET_WARN int hdrsize; +#endif int ret; /* Perform any necessary packet conversions. */ @@ -408,16 +410,8 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, fwd->f_dev = fwddev; /* Forwarding device */ - /* Get the size of the IPv6 + L3 header. Use this to determine start - * of the data payload. - * - * Remember that the size of the L1 header has already been subtracted - * from dev->d_len. - * - * REVISIT: Consider an alternative design that does not require data - * copying. This would require a pool of d_buf's that are managed by - * the network rather than the network device. - */ +#ifdef CONFIG_DEBUG_NET_WARN + /* Get the size of the IPv6 + L3 header. */ hdrsize = ipv6_hdrsize(ipv6); if (hdrsize < IPv6_HDRLEN) @@ -435,8 +429,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, ret = -E2BIG; goto errout_with_fwd; } - - fwd->f_hdrsize = hdrsize; +#endif /* Try to allocate the head of an IOB chain. If this fails, the * packet will be dropped; we are not operating in a context where