aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-02-18 19:58:13 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-02-21 13:41:13 +0100
commit01ae772dcc4ba7930179521bb22712bb4256bb03 (patch)
tree435b9e63ca2cd90e3e8f4e7c1ca85e1cfab0927d
parenteb18f862cb4fb35d7e55039c76af38cd46d931aa (diff)
downloadpasst-01ae772dcc4ba7930179521bb22712bb4256bb03.tar
passt-01ae772dcc4ba7930179521bb22712bb4256bb03.tar.gz
passt-01ae772dcc4ba7930179521bb22712bb4256bb03.tar.bz2
passt-01ae772dcc4ba7930179521bb22712bb4256bb03.tar.lz
passt-01ae772dcc4ba7930179521bb22712bb4256bb03.tar.xz
passt-01ae772dcc4ba7930179521bb22712bb4256bb03.tar.zst
passt-01ae772dcc4ba7930179521bb22712bb4256bb03.zip
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>
-rw-r--r--conf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/conf.c b/conf.c
index 41895de..279fdfe 100644
--- a/conf.c
+++ b/conf.c
@@ -468,17 +468,17 @@ static void conf_ip(struct ctx *c)
nl_addr(0, c->ifi, AF_INET, &c->addr4, &mask_len, NULL);
c->mask4 = htonl(0xffffffff << (32 - mask_len));
+ }
- if (!c->mask4) {
- if (IN_CLASSA(ntohl(c->addr4)))
- c->mask4 = htonl(IN_CLASSA_NET);
- else if (IN_CLASSB(ntohl(c->addr4)))
- c->mask4 = htonl(IN_CLASSB_NET);
- else if (IN_CLASSC(ntohl(c->addr4)))
- c->mask4 = htonl(IN_CLASSC_NET);
- else
- c->mask4 = 0xffffffff;
- }
+ if (!c->mask4) {
+ if (IN_CLASSA(ntohl(c->addr4)))
+ c->mask4 = htonl(IN_CLASSA_NET);
+ else if (IN_CLASSB(ntohl(c->addr4)))
+ c->mask4 = htonl(IN_CLASSB_NET);
+ else if (IN_CLASSC(ntohl(c->addr4)))
+ c->mask4 = htonl(IN_CLASSC_NET);
+ else
+ c->mask4 = 0xffffffff;
}
memcpy(&c->addr4_seen, &c->addr4, sizeof(c->addr4_seen));