Another IP forwarding design simplification: Remove an unnecessary field from state structure.

This commit is contained in:
Gregory Nutt 2017-07-06 16:51:08 -06:00
parent b5d7187df6
commit db69e4b09c
4 changed files with 12 additions and 28 deletions

View File

@ -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);

View File

@ -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 */
};
/****************************************************************************

View File

@ -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

View File

@ -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