1
0
mirror of https://passt.top/passt synced 2024-07-06 17:56:15 +00:00

conf: Given IPv4 address and no netmask, assign RFC 790-style classes

Provide a sane default, instead of /0, if an address is given, and it
doesn't correspond to any host address we could find via netlink.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2022-02-18 19:58:13 +01:00
parent eb18f862cb
commit 01ae772dcc

2
conf.c
View File

@ -468,6 +468,7 @@ static void conf_ip(struct ctx *c)
nl_addr(0, c->ifi, AF_INET, &c->addr4, &mask_len, NULL); nl_addr(0, c->ifi, AF_INET, &c->addr4, &mask_len, NULL);
c->mask4 = htonl(0xffffffff << (32 - mask_len)); c->mask4 = htonl(0xffffffff << (32 - mask_len));
}
if (!c->mask4) { if (!c->mask4) {
if (IN_CLASSA(ntohl(c->addr4))) if (IN_CLASSA(ntohl(c->addr4)))
@ -479,7 +480,6 @@ static void conf_ip(struct ctx *c)
else else
c->mask4 = 0xffffffff; c->mask4 = 0xffffffff;
} }
}
memcpy(&c->addr4_seen, &c->addr4, sizeof(c->addr4_seen)); memcpy(&c->addr4_seen, &c->addr4, sizeof(c->addr4_seen));