mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
* uip: parenthesise UIP_LLH_LEN The macro expands to a bare sum, so wherever it is subtracted the second term gets added instead. UIP_TCP_MSS - and with it UIP_RECEIVE_WINDOW - therefore comes out 24 bytes above the buffer's real capacity. UIP_APPDATA_SIZE and UIP_REASS_BUFSIZE are wrong the same way, though neither is reachable today. The additions, uip_buf[UIP_LLH_LEN] and friends, were right by luck. * uip: keep the advertised MSS below the buffer edge Deriving the MSS straight from the buffer size makes the switch advertise exactly the segment that fills uip_buf to its last byte, and a peer that takes it literally corrupts every large upload: the firmware image arrives fully acknowledged, with no retransmissions on the wire, yet the CRC over the streamed body never matches and the flash write is abandoned. Isolated by changing nothing but the segment size, same buffer and same file: 1490-byte segments fail four times out of four, 1460-byte segments succeed, 745-byte segments succeed. Linux halves its segments against a window this small, so only macOS on a jumbo link ever produces a full-size segment - which is why the failure hides so well. Where exactly the full segment breaks the stream is not pinned down yet; until it is, the advertised MSS stays a step below the edge. * uip: size the buffer to the largest frame the CPU port accepts UIP_TCP_MSS derives from UIP_CONF_BUFFER_SIZE, and the buffer was large enough for frames the hardware will never deliver, so the switch advertised a segment size no peer could usefully reach. A client on a jumbo-MTU link took it at its word and the oversized replies went nowhere. Size the buffer to the ingress limit instead. ICMP bypasses MSS and so probes the hardware directly: on a SWTGW218AS a 1502-byte payload is answered and 1503 never arrives, which puts the largest frame the NIC hands us at 1556 bytes of uip_buf. UIP_TCP_MSS then derives to 1490, the same edge measured over TCP. Frames above the limit are dropped by the NIC rather than written to the buffer - an 8 kB ping leaves the switch untouched - so nothing overruns it. Frees 644 bytes of XDATA. * uip: trim these comments, one of which had stopped being true The note above UIP_CONF_BUFFER_SIZE claimed the MSS derives from it as 1490. It does not: the commit that follows pins the MSS at 1460 on purpose, a step below that ceiling, because a segment filling the buffer to its last byte corrupts large uploads. Left as it was, the file argued with itself. Both blocks are shorter now. What justifies the numbers stays, which is the ICMP measurement behind 1556 and the four-out-of-four failure behind 1460. What went is the storytelling around them, which belongs in this thread rather than in a config header. * uip: derive the MSS from the buffer again, minus explicit headroom The review asked why the buffer size and the MSS are both set by hand when one used to follow from the other. They answer different questions, but the gap between them is a number in its own right, so it gets a name now: UIP_CONF_BUFFER_EXTRA, and UIP_TCP_MSS goes back to being derived. The headroom is where the measurement lives. A segment that fills uip_buf to its last byte corrupts large uploads: with nothing but the segment size changing, 1490 fails four times out of four and 1460 succeeds. With the buffer sized to the frame the NIC accepts, an extra of 30 lands on 1460. Deriving it the other way round does not work. Sizing the buffer from a 1460 byte MSS gives 1526, which is 30 bytes under the frame the NIC actually delivers. A 1502 byte ICMP payload occupies 1556 bytes of uip_buf and is answered today, and it would stop fitting. The generated image is byte for byte the same as the one with 1460 written out, so the expression lands on the value that was measured. --------- Co-authored-by: d00f <tokyusho@chatik.pl>
181 lines
4.7 KiB
C
181 lines
4.7 KiB
C
/**
|
|
* \addtogroup uipopt
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* \name Project-specific configuration options
|
|
* @{
|
|
*
|
|
* uIP has a number of configuration options that can be overridden
|
|
* for each project. These are kept in a project-specific uip-conf.h
|
|
* file and all configuration names have the prefix UIP_CONF.
|
|
*/
|
|
|
|
/*
|
|
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
* This file is part of the uIP TCP/IP stack
|
|
*
|
|
* $Id: uip-conf.h,v 1.6 2006/06/12 08:00:31 adam Exp $
|
|
*/
|
|
|
|
/**
|
|
* \file
|
|
* An example uIP configuration file
|
|
* \author
|
|
* Adam Dunkels <adam@sics.se>
|
|
*/
|
|
|
|
#ifndef __UIP_CONF_H__
|
|
#define __UIP_CONF_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
#define UIP_CONF_EXTERNAL_BUFFER
|
|
#define UIP_ARCH_CHKSUM 1
|
|
#define UIP_ARCH_IPCHKSUM 1
|
|
|
|
/**
|
|
* 8 bit datatype
|
|
*
|
|
* This typedef defines the 8-bit type used throughout uIP.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
typedef uint8_t u8_t;
|
|
|
|
/**
|
|
* 16 bit datatype
|
|
*
|
|
* This typedef defines the 16-bit type used throughout uIP.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
typedef uint16_t u16_t;
|
|
|
|
/**
|
|
* Statistics datatype
|
|
*
|
|
* This typedef defines the dataype used for keeping statistics in
|
|
* uIP.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
typedef unsigned short uip_stats_t;
|
|
|
|
/**
|
|
* Maximum number of TCP connections. TODO: Increase this, but also make the socket state/buffer per-connection.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_MAX_CONNECTIONS 1
|
|
|
|
/**
|
|
* Maximum number of listening TCP ports. TODO: increase this!
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_MAX_LISTENPORTS 1
|
|
|
|
/**
|
|
* uIP buffer size.
|
|
*
|
|
* Sized to the largest frame the CPU port accepts on ingress: anything above
|
|
* that the NIC drops in hardware, so a larger buffer only costs XDATA. Measured
|
|
* with ICMP, which bypasses MSS and so probes the hardware directly: a 1502-byte
|
|
* payload is answered and 1503 is not, which puts the frame at 1556 bytes of
|
|
* uip_buf. The limit is the NIC's rather than a port's, so how the frame was
|
|
* tagged on the wire does not change it.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_BUFFER_SIZE 1556
|
|
|
|
/**
|
|
* Bytes of the buffer kept out of the advertised MSS.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_BUFFER_EXTRA 30
|
|
|
|
/**
|
|
* CPU byte order.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
|
|
|
|
/**
|
|
* Logging on or off
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_LOGGING 1
|
|
|
|
/**
|
|
* UDP support on or off
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_UDP 1
|
|
|
|
/**
|
|
* UDP checksums on or off
|
|
* The RTL8372/3 are able to calculate and verify all L2 and L3 checksums
|
|
* in hardware. The TX checksums are configured in the CPU-tag of outgoing
|
|
* packets, while the RTL837X_NIC_RX_CTRL register configures the verification
|
|
* of the checksum of inbound packets and subsequent possible drop.
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_UDP_CHECKSUMS 0
|
|
|
|
/**
|
|
* uIP statistics on or off
|
|
*
|
|
* \hideinitializer
|
|
*/
|
|
#define UIP_CONF_STATISTICS 1
|
|
|
|
/* Here we include the header file for the application(s) we use in
|
|
our project. */
|
|
/*#include "smtp.h"*/
|
|
#include "httpd.h"
|
|
#include "udp_apps.h"
|
|
/*#include "telnetd.h"*/
|
|
/*#include "webserver.h" */
|
|
/*#include "dhcpc.h"*/
|
|
/*#include "resolv.h"*/
|
|
/*#include "webclient.h"*/
|
|
|
|
#endif /* __UIP_CONF_H__ */
|
|
|
|
/** @} */
|
|
/** @} */
|