mirror of
https://passt.top/passt
synced 2025-05-23 09:45:34 +02:00
conf: Be more precise about minimum MTUs
Currently we reject the -m option if given a value less than ETH_MIN_MTU (68). That define is derived from the kernel, but its name is misleading: it doesn't really have anything to do with Ethernet per se, but is rather the minimum payload any L2 link must be able to handle in order to carry IPv4. For IPv6, it's not sufficient: that requires an MTU of at least 1280. Newer kernels have better named constants IPV4_MIN_MTU and IPv6_MIN_MTU. Copy and use those constants instead, along with some more specific error messages. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
672d786de1
commit
1924e25f07
3 changed files with 22 additions and 9 deletions
18
conf.c
18
conf.c
|
@ -1663,9 +1663,9 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||
if (errno || *e)
|
||||
die("Invalid MTU: %s", optarg);
|
||||
|
||||
if (mtu && (mtu < ETH_MIN_MTU || mtu > ETH_MAX_MTU)) {
|
||||
die("MTU %lu out of range (%u..%u)", mtu,
|
||||
ETH_MIN_MTU, ETH_MAX_MTU);
|
||||
if (mtu > ETH_MAX_MTU) {
|
||||
die("MTU %lu too large (max %u)",
|
||||
mtu, ETH_MAX_MTU);
|
||||
}
|
||||
|
||||
c->mtu = mtu;
|
||||
|
@ -1842,9 +1842,21 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||
c->ifi4 = conf_ip4(ifi4, &c->ip4);
|
||||
if (!v4_only)
|
||||
c->ifi6 = conf_ip6(ifi6, &c->ip6);
|
||||
|
||||
if (c->ifi4 && c->mtu < IPV4_MIN_MTU) {
|
||||
warn("MTU %"PRIu16" is too small for IPv4 (minimum %u)",
|
||||
c->mtu, IPV4_MIN_MTU);
|
||||
}
|
||||
if (c->ifi6 && c->mtu < IPV6_MIN_MTU) {
|
||||
warn("MTU %"PRIu16" is too small for IPv6 (minimum %u)",
|
||||
c->mtu, IPV6_MIN_MTU);
|
||||
}
|
||||
|
||||
if ((*c->ip4.ifname_out && !c->ifi4) ||
|
||||
(*c->ip6.ifname_out && !c->ifi6))
|
||||
die("External interface not usable");
|
||||
|
||||
|
||||
if (!c->ifi4 && !c->ifi6) {
|
||||
info("No external interface as template, switch to local mode");
|
||||
|
||||
|
|
7
ip.h
7
ip.h
|
@ -129,4 +129,11 @@ static const struct in6_addr in6addr_ll_all_nodes = {
|
|||
/* IPv4 Limited Broadcast (RFC 919, Section 7), 255.255.255.255 */
|
||||
static const struct in_addr in4addr_broadcast = { 0xffffffff };
|
||||
|
||||
#ifndef IPV4_MIN_MTU
|
||||
#define IPV4_MIN_MTU 68
|
||||
#endif
|
||||
#ifndef IPV6_MIN_MTU
|
||||
#define IPV6_MIN_MTU 1280
|
||||
#endif
|
||||
|
||||
#endif /* IP_H */
|
||||
|
|
6
util.h
6
util.h
|
@ -34,15 +34,9 @@
|
|||
#ifndef ETH_MAX_MTU
|
||||
#define ETH_MAX_MTU USHRT_MAX
|
||||
#endif
|
||||
#ifndef ETH_MIN_MTU
|
||||
#define ETH_MIN_MTU 68
|
||||
#endif
|
||||
#ifndef IP_MAX_MTU
|
||||
#define IP_MAX_MTU USHRT_MAX
|
||||
#endif
|
||||
#ifndef IPV6_MIN_MTU
|
||||
#define IPV6_MIN_MTU 1280
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue