aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-09-07 11:19:57 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-09-09 15:40:04 +0200
commitec2b58ea4dc45079470efedaa632da25031d5adc (patch)
tree8590159cb26a4db0fc943d657093f6e8bbbe6345
parent8e9333616ac3dd37dfb2261f08dd0b16018d0686 (diff)
downloadpasst-ec2b58ea4dc45079470efedaa632da25031d5adc.tar
passt-ec2b58ea4dc45079470efedaa632da25031d5adc.tar.gz
passt-ec2b58ea4dc45079470efedaa632da25031d5adc.tar.bz2
passt-ec2b58ea4dc45079470efedaa632da25031d5adc.tar.lz
passt-ec2b58ea4dc45079470efedaa632da25031d5adc.tar.xz
passt-ec2b58ea4dc45079470efedaa632da25031d5adc.tar.zst
passt-ec2b58ea4dc45079470efedaa632da25031d5adc.zip
conf, dhcp, ndp: Fix message about default MTU, make NDP consistent
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--conf.c15
-rw-r--r--dhcp.c3
-rw-r--r--ndp.c2
3 files changed, 16 insertions, 4 deletions
diff --git a/conf.c b/conf.c
index fd8f3cf..2622a38 100644
--- a/conf.c
+++ b/conf.c
@@ -617,7 +617,9 @@ static void usage(const char *name)
info(" /tmp/passt_ISO8601-TIMESTAMP_INSTANCE-NUMBER.pcap");
info( " -m, --mtu MTU Assign MTU via DHCP/NDP");
- info( " default: no MTU assigned via DHCP/NDP options");
+ info( " a zero value disables assignment");
+ info( " default: 65520: maximum 802.3 MTU minus 802.3 header");
+ info( " length, rounded to 32 bits (IPv4 words)");
info( " -a, --address ADDR Assign IPv4 or IPv6 address ADDR");
info( " can be specified zero to two times (for IPv4 and IPv6)");
info( " default: use addresses from interface with default route");
@@ -954,6 +956,12 @@ void conf(struct ctx *c, int argc, char **argv)
errno = 0;
c->mtu = strtol(optarg, NULL, 0);
+
+ if (!c->mtu) {
+ c->mtu = -1;
+ break;
+ }
+
if (c->mtu < ETH_MIN_MTU || c->mtu > (int)ETH_MAX_MTU ||
errno) {
err("Invalid MTU: %s", optarg);
@@ -1132,6 +1140,11 @@ void conf(struct ctx *c, int argc, char **argv)
}
}
+ if (!c->mtu) {
+ c->mtu = (ETH_MAX_MTU - ETH_HLEN) /
+ sizeof(uint32_t) * sizeof(uint32_t);
+ }
+
get_routes(c);
get_addrs(c);
diff --git a/dhcp.c b/dhcp.c
index 4969eec..24194ee 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -49,7 +49,6 @@ struct opt {
static struct opt opts[255] = {
[1] = { 0, 4, { 0 }, 0, { 0 }, }, /* Mask */
[3] = { 0, 4, { 0 }, 0, { 0 }, }, /* Router */
- [26] = { 0, 2, { 0xff, 0xf0 }, 0, { 0 }, }, /* MTU */
[51] = { 0, 4, { 0xff, 0xff, 0xff, 0xff }, 0, { 0 }, }, /* Lease time */
[53] = { 0, 1, { 0 }, 0, { 0 }, }, /* Type */
#define DHCPDISCOVER 1
@@ -319,7 +318,7 @@ int dhcp(struct ctx *c, struct ethhdr *eh, size_t len)
*(unsigned long *)&opts[121].s[10] = c->gw4;
}
- if (c->mtu) {
+ if (c->mtu != -1) {
opts[26].slen = 2;
opts[26].s[0] = c->mtu / 256;
opts[26].s[1] = c->mtu % 256;
diff --git a/ndp.c b/ndp.c
index 74445ad..a1d76c1 100644
--- a/ndp.c
+++ b/ndp.c
@@ -116,7 +116,7 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
memcpy(p, &c->addr6, 8); /* prefix */
p += 16;
- if (c->mtu) {
+ if (c->mtu != -1) {
*p++ = 5; /* type */
*p++ = 1; /* length */
p += 2; /* reserved */