Skip to content

Commit f0af5ee

Browse files
committed
Addressed reviewer's comments
1 parent c74109e commit f0af5ee

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define ETHERNET
99
#define LINK_MTU 1536
1010
#ifndef LINK_MTU_MIN
11-
#define LINK_MTU_MIN 64
11+
#define LINK_MTU_MIN 64U
1212
#endif
1313
#if LINK_MTU < LINK_MTU_MIN
1414
#error "LINK_MTU must be greater than or equal to LINK_MTU_MIN"

docs/API.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ int wolfIP_mtu_get(struct wolfIP *s, unsigned int if_idx, uint32_t *mtu);
211211
Access the link-layer descriptor(s) that should be wired to hardware drivers. `_ex` returns `NULL` if `if_idx` exceeds `WOLFIP_MAX_INTERFACES`.
212212
`wolfIP_mtu_set()` updates the effective per-interface MTU, treating `0` as the default `LINK_MTU` and clamping to `[LINK_MTU_MIN, LINK_MTU]`. `wolfIP_mtu_get()` returns the effective MTU currently used by the stack.
213213
For `non_ethernet` devices this value remains the internal frame budget; the maximum IP bytes handed to the driver are reduced by `ETH_HEADER_LEN` when Ethernet support is compiled in.
214+
- Returns: `wolfIP_getdev()`/`wolfIP_getdev_ex()` return a pointer to the link-layer descriptor or `NULL` on invalid interface index; `wolfIP_mtu_set()` returns `0` on success or a negative error code on failure; `wolfIP_mtu_get()` returns `0` on success or a negative error code on failure and stores the effective MTU in `*mtu`.
214215
215216
## DHCP Client Functions
216217

src/wolfip.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ static inline int tx_has_writable_space(const struct tsocket *t)
12281228
return 0;
12291229
}
12301230

1231+
/* Effective link-layer frame budget after applying default/min/max clamping. */
12311232
static inline uint32_t wolfIP_ll_frame_mtu(const struct wolfIP_ll_dev *ll)
12321233
{
12331234
uint32_t mtu;
@@ -1242,18 +1243,22 @@ static inline uint32_t wolfIP_ll_frame_mtu(const struct wolfIP_ll_dev *ll)
12421243
return mtu;
12431244
}
12441245

1246+
/* Per-interface wrapper around the clamped link-layer frame MTU helper. */
12451247
static inline uint32_t wolfIP_frame_mtu(struct wolfIP *s, unsigned int if_idx)
12461248
{
12471249
return wolfIP_ll_frame_mtu(wolfIP_ll_at(s, if_idx));
12481250
}
12491251

1252+
/* IP payload MTU derived from the frame budget after removing link overhead. */
12501253
static inline uint32_t wolfIP_ip_mtu(struct wolfIP *s, unsigned int if_idx)
12511254
{
12521255
uint32_t mtu = wolfIP_frame_mtu(s, if_idx);
12531256

12541257
if (mtu <= ETH_HEADER_LEN)
12551258
return 0;
12561259
mtu -= ETH_HEADER_LEN;
1260+
/* Frame MTU may exceed the IPv4 payload maximum (e.g. 1536-byte link
1261+
* frames), but IP payload MTU remains capped at the standard 1500 bytes. */
12571262
if (mtu > IP_MTU_MAX)
12581263
mtu = IP_MTU_MAX;
12591264
return mtu;
@@ -5290,8 +5295,6 @@ static void arp_queue_packet(struct wolfIP *s, unsigned int if_idx, ip4 dest,
52905295

52915296
if (!s || len == 0)
52925297
return;
5293-
if (len > LINK_MTU)
5294-
return;
52955298
if (len > wolfIP_frame_mtu(s, if_idx))
52965299
return;
52975300

0 commit comments

Comments
 (0)